@pairbo/ui-kit 0.3.9 → 0.3.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui-kit.js CHANGED
@@ -6,21 +6,21 @@
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:gh,defineProperty:fh,getOwnPropertyDescriptor:mh,getOwnPropertyNames:bh,getOwnPropertySymbols:vh,getPrototypeOf:_h}=Object,pi=globalThis,na=pi.trustedTypes,yh=na?na.emptyScript:"",Co=pi.reactiveElementPolyfillSupport,Es=(o,t)=>o,Lr={toAttribute(o,t){switch(t){case Boolean:o=o?yh:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},vn=(o,t)=>!gh(o,t),aa={attribute:!0,type:String,converter:Lr,reflect:!1,hasChanged:vn};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),pi.litPropertyMetadata??(pi.litPropertyMetadata=new WeakMap);let Yi=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=aa){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&fh(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=mh(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return s==null?void 0:s.call(this)},set(n){const a=s==null?void 0:s.call(this);r.call(this,n),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??aa}static _$Ei(){if(this.hasOwnProperty(Es("elementProperties")))return;const t=_h(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Es("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Es("properties"))){const e=this.properties,i=[...bh(e),...vh(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,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 s of i)e.unshift(oa(s))}else t!==void 0&&e.push(oa(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||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 ph(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EC(t,e){var r;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const n=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:Lr).toAttribute(e,i.type);this._$Em=t,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(t,e){var r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const n=i.getPropertyOptions(s),a=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)==null?void 0:r.fromAttribute)!==void 0?n.converter:Lr;this._$Em=s,this[s]=a.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,i){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??vn)(this[t],e))return;this.P(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&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 t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,n]of this._$Ep)this[r]=n;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,n]of s)n.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],n)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),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(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};Yi.elementStyles=[],Yi.shadowRootOptions={mode:"open"},Yi[Es("elementProperties")]=new Map,Yi[Es("finalized")]=new Map,Co==null||Co({ReactiveElement:Yi}),(pi.reactiveElementVersions??(pi.reactiveElementVersions=[])).push("2.0.4");/**
9
+ */const{is:gh,defineProperty:fh,getOwnPropertyDescriptor:mh,getOwnPropertyNames:bh,getOwnPropertySymbols:vh,getPrototypeOf:_h}=Object,fi=globalThis,na=fi.trustedTypes,yh=na?na.emptyScript:"",Co=fi.reactiveElementPolyfillSupport,ks=(o,t)=>o,Lr={toAttribute(o,t){switch(t){case Boolean:o=o?yh:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},vn=(o,t)=>!gh(o,t),aa={attribute:!0,type:String,converter:Lr,reflect:!1,hasChanged:vn};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),fi.litPropertyMetadata??(fi.litPropertyMetadata=new WeakMap);let Yi=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=aa){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&fh(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=mh(this.prototype,t)??{get(){return this[e]},set(n){this[e]=n}};return{get(){return s==null?void 0:s.call(this)},set(n){const a=s==null?void 0:s.call(this);r.call(this,n),this.requestUpdate(t,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??aa}static _$Ei(){if(this.hasOwnProperty(ks("elementProperties")))return;const t=_h(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ks("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ks("properties"))){const e=this.properties,i=[...bh(e),...vh(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,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 s of i)e.unshift(oa(s))}else t!==void 0&&e.push(oa(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?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(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||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 ph(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EC(t,e){var r;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const n=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:Lr).toAttribute(e,i.type);this._$Em=t,n==null?this.removeAttribute(s):this.setAttribute(s,n),this._$Em=null}}_$AK(t,e){var r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const n=i.getPropertyOptions(s),a=typeof n.converter=="function"?{fromAttribute:n.converter}:((r=n.converter)==null?void 0:r.fromAttribute)!==void 0?n.converter:Lr;this._$Em=s,this[s]=a.fromAttribute(e,n.type),this._$Em=null}}requestUpdate(t,e,i){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??vn)(this[t],e))return;this.P(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&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 t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,n]of this._$Ep)this[r]=n;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,n]of s)n.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],n)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),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(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}};Yi.elementStyles=[],Yi.shadowRootOptions={mode:"open"},Yi[ks("elementProperties")]=new Map,Yi[ks("finalized")]=new Map,Co==null||Co({ReactiveElement:Yi}),(fi.reactiveElementVersions??(fi.reactiveElementVersions=[])).push("2.0.4");/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
- */const ks=globalThis,Fr=ks.trustedTypes,la=Fr?Fr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Sl="$lit$",ci=`lit$${Math.random().toFixed(9).slice(2)}$`,Tl="?"+ci,xh=`<${Tl}>`,Fi=document,Ls=()=>Fi.createComment(""),Fs=o=>o===null||typeof o!="object"&&typeof o!="function",_n=Array.isArray,wh=o=>_n(o)||typeof(o==null?void 0:o[Symbol.iterator])=="function",So=`[
14
- \f\r]`,gs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ca=/-->/g,ha=/>/g,Ti=RegExp(`>|${So}(?:([^\\s"'>=/]+)(${So}*=${So}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),da=/'/g,ua=/"/g,El=/^(?:script|style|textarea|title)$/i,Ch=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),L=Ch(1),ve=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),pa=new WeakMap,Di=Fi.createTreeWalker(Fi,129);function kl(o,t){if(!_n(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return la!==void 0?la.createHTML(t):t}const Sh=(o,t)=>{const e=o.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",n=gs;for(let a=0;a<e;a++){const l=o[a];let c,h,d=-1,u=0;for(;u<l.length&&(n.lastIndex=u,h=n.exec(l),h!==null);)u=n.lastIndex,n===gs?h[1]==="!--"?n=ca:h[1]!==void 0?n=ha:h[2]!==void 0?(El.test(h[2])&&(s=RegExp("</"+h[2],"g")),n=Ti):h[3]!==void 0&&(n=Ti):n===Ti?h[0]===">"?(n=s??gs,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,c=h[1],n=h[3]===void 0?Ti:h[3]==='"'?ua:da):n===ua||n===da?n=Ti:n===ca||n===ha?n=gs:(n=Ti,s=void 0);const g=n===Ti&&o[a+1].startsWith("/>")?" ":"";r+=n===gs?l+xh:d>=0?(i.push(c),l.slice(0,d)+Sl+l.slice(d)+ci+g):l+ci+(d===-2?a:g)}return[kl(o,r+(o[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Wo=class Ol{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,n=0;const a=t.length-1,l=this.parts,[c,h]=Sh(t,e);if(this.el=Ol.createElement(c,i),Di.currentNode=this.el.content,e===2||e===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=Di.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Sl)){const u=h[n++],g=s.getAttribute(d).split(ci),p=/([.?@])?(.*)/.exec(u);l.push({type:1,index:r,name:p[2],strings:g,ctor:p[1]==="."?Eh:p[1]==="?"?kh:p[1]==="@"?Oh:Qr}),s.removeAttribute(d)}else d.startsWith(ci)&&(l.push({type:6,index:r}),s.removeAttribute(d));if(El.test(s.tagName)){const d=s.textContent.split(ci),u=d.length-1;if(u>0){s.textContent=Fr?Fr.emptyScript:"";for(let g=0;g<u;g++)s.append(d[g],Ls()),Di.nextNode(),l.push({type:2,index:++r});s.append(d[u],Ls())}}}else if(s.nodeType===8)if(s.data===Tl)l.push({type:2,index:r});else{let d=-1;for(;(d=s.data.indexOf(ci,d+1))!==-1;)l.push({type:7,index:r}),d+=ci.length-1}r++}}static createElement(t,e){const i=Fi.createElement("template");return i.innerHTML=t,i}};function is(o,t,e=o,i){var n,a;if(t===ve)return t;let s=i!==void 0?(n=e._$Co)==null?void 0:n[i]:e._$Cl;const r=Fs(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(o),s._$AT(o,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=is(o,s._$AS(o,t.values),s,i)),t}let Th=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=((t==null?void 0:t.creationScope)??Fi).importNode(e,!0);Di.currentNode=s;let r=Di.nextNode(),n=0,a=0,l=i[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new Jr(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Ph(r,this,t)),this._$AV.push(c),l=i[++a]}n!==(l==null?void 0:l.index)&&(r=Di.nextNode(),n++)}return Di.currentNode=Fi,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},Jr=class Pl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=q,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=is(this,t,e),Fs(t)?t===q||t==null||t===""?(this._$AH!==q&&this._$AR(),this._$AH=q):t!==this._$AH&&t!==ve&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):wh(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!==q&&Fs(this._$AH)?this._$AA.nextSibling.data=t:this.T(Fi.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Wo.createElement(kl(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const n=new Th(s,this),a=n.u(this.options);n.p(e),this.T(a),this._$AH=n}}_$AC(t){let e=pa.get(t.strings);return e===void 0&&pa.set(t.strings,e=new Wo(t)),e}k(t){_n(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Pl(this.O(Ls()),this.O(Ls()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Qr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=q,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=q}_$AI(t,e=this,i,s){const r=this.strings;let n=!1;if(r===void 0)t=is(this,t,e,0),n=!Fs(t)||t!==this._$AH&&t!==ve,n&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=is(this,a[i+l],e,l),c===ve&&(c=this._$AH[l]),n||(n=!Fs(c)||c!==this._$AH[l]),c===q?t=q:t!==q&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}n&&!s&&this.j(t)}j(t){t===q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Eh=class extends Qr{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===q?void 0:t}},kh=class extends Qr{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==q)}},Oh=class extends Qr{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=is(this,t,e,0)??q)===ve)return;const i=this._$AH,s=t===q&&i!==q||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==q&&(i===q||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Ph=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){is(this,t)}};const Dh={I:Jr},To=ks.litHtmlPolyfillSupport;To==null||To(Wo,Jr),(ks.litHtmlVersions??(ks.litHtmlVersions=[])).push("3.2.1");const Dl=(o,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new Jr(t.insertBefore(Ls(),r),r,void 0,e??{})}return s._$AI(o),s};/**
13
+ */const Os=globalThis,Fr=Os.trustedTypes,la=Fr?Fr.createPolicy("lit-html",{createHTML:o=>o}):void 0,Sl="$lit$",di=`lit$${Math.random().toFixed(9).slice(2)}$`,Tl="?"+di,xh=`<${Tl}>`,Fi=document,Fs=()=>Fi.createComment(""),js=o=>o===null||typeof o!="object"&&typeof o!="function",_n=Array.isArray,wh=o=>_n(o)||typeof(o==null?void 0:o[Symbol.iterator])=="function",So=`[
14
+ \f\r]`,fs=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ca=/-->/g,ha=/>/g,Ei=RegExp(`>|${So}(?:([^\\s"'>=/]+)(${So}*=${So}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),da=/'/g,ua=/"/g,El=/^(?:script|style|textarea|title)$/i,Ch=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),L=Ch(1),_e=Symbol.for("lit-noChange"),q=Symbol.for("lit-nothing"),pa=new WeakMap,Ai=Fi.createTreeWalker(Fi,129);function kl(o,t){if(!_n(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return la!==void 0?la.createHTML(t):t}const Sh=(o,t)=>{const e=o.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",n=fs;for(let a=0;a<e;a++){const l=o[a];let c,h,d=-1,u=0;for(;u<l.length&&(n.lastIndex=u,h=n.exec(l),h!==null);)u=n.lastIndex,n===fs?h[1]==="!--"?n=ca:h[1]!==void 0?n=ha:h[2]!==void 0?(El.test(h[2])&&(s=RegExp("</"+h[2],"g")),n=Ei):h[3]!==void 0&&(n=Ei):n===Ei?h[0]===">"?(n=s??fs,d=-1):h[1]===void 0?d=-2:(d=n.lastIndex-h[2].length,c=h[1],n=h[3]===void 0?Ei:h[3]==='"'?ua:da):n===ua||n===da?n=Ei:n===ca||n===ha?n=fs:(n=Ei,s=void 0);const g=n===Ei&&o[a+1].startsWith("/>")?" ":"";r+=n===fs?l+xh:d>=0?(i.push(c),l.slice(0,d)+Sl+l.slice(d)+di+g):l+di+(d===-2?a:g)}return[kl(o,r+(o[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};let Wo=class Ol{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,n=0;const a=t.length-1,l=this.parts,[c,h]=Sh(t,e);if(this.el=Ol.createElement(c,i),Ai.currentNode=this.el.content,e===2||e===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(s=Ai.nextNode())!==null&&l.length<a;){if(s.nodeType===1){if(s.hasAttributes())for(const d of s.getAttributeNames())if(d.endsWith(Sl)){const u=h[n++],g=s.getAttribute(d).split(di),p=/([.?@])?(.*)/.exec(u);l.push({type:1,index:r,name:p[2],strings:g,ctor:p[1]==="."?Eh:p[1]==="?"?kh:p[1]==="@"?Oh:Qr}),s.removeAttribute(d)}else d.startsWith(di)&&(l.push({type:6,index:r}),s.removeAttribute(d));if(El.test(s.tagName)){const d=s.textContent.split(di),u=d.length-1;if(u>0){s.textContent=Fr?Fr.emptyScript:"";for(let g=0;g<u;g++)s.append(d[g],Fs()),Ai.nextNode(),l.push({type:2,index:++r});s.append(d[u],Fs())}}}else if(s.nodeType===8)if(s.data===Tl)l.push({type:2,index:r});else{let d=-1;for(;(d=s.data.indexOf(di,d+1))!==-1;)l.push({type:7,index:r}),d+=di.length-1}r++}}static createElement(t,e){const i=Fi.createElement("template");return i.innerHTML=t,i}};function ss(o,t,e=o,i){var n,a;if(t===_e)return t;let s=i!==void 0?(n=e._$Co)==null?void 0:n[i]:e._$Cl;const r=js(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((a=s==null?void 0:s._$AO)==null||a.call(s,!1),r===void 0?s=void 0:(s=new r(o),s._$AT(o,e,i)),i!==void 0?(e._$Co??(e._$Co=[]))[i]=s:e._$Cl=s),s!==void 0&&(t=ss(o,s._$AS(o,t.values),s,i)),t}let Th=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=((t==null?void 0:t.creationScope)??Fi).importNode(e,!0);Ai.currentNode=s;let r=Ai.nextNode(),n=0,a=0,l=i[0];for(;l!==void 0;){if(n===l.index){let c;l.type===2?c=new Jr(r,r.nextSibling,this,t):l.type===1?c=new l.ctor(r,l.name,l.strings,this,t):l.type===6&&(c=new Ph(r,this,t)),this._$AV.push(c),l=i[++a]}n!==(l==null?void 0:l.index)&&(r=Ai.nextNode(),n++)}return Ai.currentNode=Fi,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}},Jr=class Pl{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,i,s){this.type=2,this._$AH=q,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=ss(this,t,e),js(t)?t===q||t==null||t===""?(this._$AH!==q&&this._$AR(),this._$AH=q):t!==this._$AH&&t!==_e&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):wh(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!==q&&js(this._$AH)?this._$AA.nextSibling.data=t:this.T(Fi.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=Wo.createElement(kl(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const n=new Th(s,this),a=n.u(this.options);n.p(e),this.T(a),this._$AH=n}}_$AC(t){let e=pa.get(t.strings);return e===void 0&&pa.set(t.strings,e=new Wo(t)),e}k(t){_n(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new Pl(this.O(Fs()),this.O(Fs()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}},Qr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=q,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=q}_$AI(t,e=this,i,s){const r=this.strings;let n=!1;if(r===void 0)t=ss(this,t,e,0),n=!js(t)||t!==this._$AH&&t!==_e,n&&(this._$AH=t);else{const a=t;let l,c;for(t=r[0],l=0;l<r.length-1;l++)c=ss(this,a[i+l],e,l),c===_e&&(c=this._$AH[l]),n||(n=!js(c)||c!==this._$AH[l]),c===q?t=q:t!==q&&(t+=(c??"")+r[l+1]),this._$AH[l]=c}n&&!s&&this.j(t)}j(t){t===q?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Eh=class extends Qr{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===q?void 0:t}},kh=class extends Qr{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==q)}},Oh=class extends Qr{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=ss(this,t,e,0)??q)===_e)return;const i=this._$AH,s=t===q&&i!==q||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==q&&(i===q||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}},Ph=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){ss(this,t)}};const Dh={I:Jr},To=Os.litHtmlPolyfillSupport;To==null||To(Wo,Jr),(Os.litHtmlVersions??(Os.litHtmlVersions=[])).push("3.2.1");const Dl=(o,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new Jr(t.insertBefore(Fs(),r),r,void 0,e??{})}return s._$AI(o),s};/**
16
16
  * @license
17
17
  * Copyright 2017 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
19
- */let Li=class extends Yi{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Dl(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return ve}};var wl;Li._$litElement$=!0,Li.finalized=!0,(wl=globalThis.litElementHydrateSupport)==null||wl.call(globalThis,{LitElement:Li});const Eo=globalThis.litElementPolyfillSupport;Eo==null||Eo({LitElement:Li});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
19
+ */let Qi=class extends Yi{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=Dl(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return _e}};var wl;Qi._$litElement$=!0,Qi.finalized=!0,(wl=globalThis.litElementHydrateSupport)==null||wl.call(globalThis,{LitElement:Qi});const Eo=globalThis.litElementPolyfillSupport;Eo==null||Eo({LitElement:Qi});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.1");/**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const ht=o=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(o,t)}):customElements.define(o,t)};/**
23
+ */const dt=o=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(o,t)}):customElements.define(o,t)};/**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
@@ -36,7 +36,7 @@
36
36
  * @license
37
37
  * Copyright 2017 Google LLC
38
38
  * SPDX-License-Identifier: BSD-3-Clause
39
- */function V(o,t){return(e,i,s)=>{const r=n=>{var a;return((a=n.renderRoot)==null?void 0:a.querySelector(o))??null};return Al(e,i,{get(){return r(this)}})}}/**
39
+ */function H(o,t){return(e,i,s)=>{const r=n=>{var a;return((a=n.renderRoot)==null?void 0:a.querySelector(o))??null};return Al(e,i,{get(){return r(this)}})}}/**
40
40
  * @license
41
41
  * Copyright 2017 Google LLC
42
42
  * SPDX-License-Identifier: BSD-3-Clause
@@ -52,7 +52,7 @@
52
52
  background-color: #fff;
53
53
  color: black;
54
54
  }
55
- `;var Fh=Object.getOwnPropertyDescriptor,jh=(o,t,e,i)=>{for(var s=i>1?void 0:i?Fh(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=n(s)||s);return s};let jr=class extends Li{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 o=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");o&&o.classList.toggle("message-selector-hidden")}_onGiftChange(o){const t=o.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(o){o.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(o){o.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return L`
55
+ `;var Fh=Object.getOwnPropertyDescriptor,jh=(o,t,e,i)=>{for(var s=i>1?void 0:i?Fh(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=n(s)||s);return s};let jr=class extends Qi{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 o=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");o&&o.classList.toggle("message-selector-hidden")}_onGiftChange(o){const t=o.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(o){o.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(o){o.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return L`
56
56
  <div class="message-selector">
57
57
  <!-- Gift Checkbox: Always visible -->
58
58
  <div>
@@ -124,7 +124,7 @@
124
124
  code {
125
125
  font-family: monospace;
126
126
  }
127
- `];jr.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};jr=jh([ht("pairbo-message-selector")],jr);const pt=Q`
127
+ `];jr.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};jr=jh([dt("pairbo-message-selector")],jr);const pt=Q`
128
128
  :host {
129
129
  box-sizing: border-box;
130
130
  text-shadow: none;
@@ -159,15 +159,15 @@
159
159
  .form-control__label > slot {
160
160
  font-size: 16.5px;
161
161
  }
162
- `;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Go=function(o,t){return Go=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Go(o,t)};function Ml(o,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Go(o,t);function e(){this.constructor=o}o.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var te=function(){return te=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},te.apply(this,arguments)};function Bh(o,t,e){for(var i=0,s=t.length,r;i<s;i++)(r||!(i in t))&&(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return o.concat(r||Array.prototype.slice.call(t))}var ft={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Qt={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},zt={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},Rh=["fuseOptions","classNames"],di={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},zh=function(o){return{type:ft.ADD_CHOICE,choice:o}},ga=function(o){return{type:ft.REMOVE_CHOICE,choice:o}},Hh=function(o){return{type:ft.FILTER_CHOICES,results:o}},Nh=function(o){return{type:ft.ACTIVATE_CHOICES,active:o}},Vh=function(o){return{type:ft.ADD_GROUP,group:o}},Uh=function(o){return{type:ft.ADD_ITEM,item:o}},fa=function(o){return{type:ft.REMOVE_ITEM,item:o}},tr=function(o,t){return{type:ft.HIGHLIGHT_ITEM,item:o,highlighted:t}},Wh=function(o,t){return Math.floor(Math.random()*(t-o)+o)},ma=function(o){return Array.from({length:o},function(){return Wh(0,36).toString(36)}).join("")},Gh=function(o,t){var e=o.id||o.name&&"".concat(o.name,"-").concat(ma(2))||ma(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Yh=function(o,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=o[i];s;){if(s.matches(t))return s;s=s[i]}return null},Xh=function(o,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=o.offsetTop+o.offsetHeight:i=o.offsetTop>=t.scrollTop,i},to=function(o){if(typeof o!="string"){if(o==null)return"";if(typeof o=="object"){if("raw"in o)return to(o.raw);if("trusted"in o)return o.trusted}return o}return o.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},qh=function(){var o=document.createElement("div");return function(t){o.innerHTML=t.trim();for(var e=o.children[0];o.firstChild;)o.removeChild(o.firstChild);return e}}(),Os=function(o,t){return typeof o=="function"?o(to(t),t):o},ba=function(o){return typeof o=="function"?o():o},Ai=function(o){if(typeof o=="string")return o;if(typeof o=="object"){if("trusted"in o)return o.trusted;if("raw"in o)return o.raw}return""},Kh=function(o){if(typeof o=="string")return o;if(typeof o=="object"){if("escaped"in o)return o.escaped;if("trusted"in o)return o.trusted}return""},xn=function(o,t){return o?Kh(t):to(t)},Ue=function(o,t,e){o.innerHTML=xn(t,e)},Zh=function(o,t){var e=o.value,i=o.label,s=i===void 0?e:i,r=t.value,n=t.label,a=n===void 0?r:n;return Ai(s).localeCompare(Ai(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},Jh=function(o,t){return o.rank-t.rank},Qh=function(o,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return o.dispatchEvent(i)},td=function(o,t){var e=Object.keys(o).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},eo=function(o){return Array.isArray(o)?o:[o]},fs=function(o){return o&&Array.isArray(o)?o.map(function(t){return".".concat(t)}).join(""):".".concat(o)},z=function(o,t){var e;(e=o.classList).add.apply(e,eo(t))},Me=function(o,t){var e;(e=o.classList).remove.apply(e,eo(t))},ed=function(o){if(typeof o<"u")try{return JSON.parse(o)}catch{return o}return{}},id=function(o,t,e){var i=o.itemEl;i&&(Me(i,e),z(i,t))},sd=function(){function o(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return o.prototype.show=function(){return z(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},o.prototype.hide=function(){return Me(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},o}(),va=function(){function o(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 o.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},o.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},o.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},o.prototype.open=function(t,e){z(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(z(this.element,this.classNames.flippedState),this.isFlipped=!0)},o.prototype.close=function(){Me(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Me(this.element,this.classNames.flippedState),this.isFlipped=!1)},o.prototype.addFocusState=function(){z(this.element,this.classNames.focusState)},o.prototype.removeFocusState=function(){Me(this.element,this.classNames.focusState)},o.prototype.enable=function(){Me(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},o.prototype.disable=function(){z(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===di.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},o.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)},o.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},o.prototype.addLoadingState=function(){z(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},o.prototype.removeLoadingState=function(){Me(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},o}(),rd=function(){function o(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(o.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),o.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})},o.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)},o.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},o.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},o.prototype.focus=function(){this.isFocussed||this.element.focus()},o.prototype.blur=function(){this.isFocussed&&this.element.blur()},o.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},o.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")},o.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},o.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},o.prototype._onInput=function(){this.type!==di.SelectOne&&this.setWidth()},o.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},o.prototype._onFocus=function(){this.isFocussed=!0},o.prototype._onBlur=function(){this.isFocussed=!1},o}(),od=4,_a=function(){function o(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return o.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},o.prototype.scrollToTop=function(){this.element.scrollTop=0},o.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,n=t.offsetHeight,a=t.offsetTop+n,l=e>0?this.element.scrollTop+a-r:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},o.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},o.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},o.prototype._animateScroll=function(t,e){var i=this,s=od,r=this.element.scrollTop,n=!1;e>0?(this._scrollDown(r,s,t),r<t&&(n=!0)):(this._scrollUp(r,s,t),r>t&&(n=!0)),n&&requestAnimationFrame(function(){i._animateScroll(t,e)})},o}(),Il=function(){function o(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(o.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),o.prototype.conceal=function(){var t=this.element;z(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")},o.prototype.reveal=function(){var t=this.element;Me(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")},o.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},o.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},o.prototype.triggerEvent=function(t,e){Qh(this.element,t,e||{})},o}(),nd=function(o){Ml(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}return t}(Il),Cs=function(o,t){return t===void 0&&(t=!0),typeof o>"u"?t:!!o},Ll=function(o){if(typeof o=="string"&&(o=o.split(" ").filter(function(t){return t.length})),Array.isArray(o)&&o.length)return o},Ae=function(o,t,e){if(e===void 0&&(e=!0),typeof o=="string"){var i=to(o),s=e||i===o?o:{escaped:i,raw:o},r=Ae({value:o,label:s,selected:!0},!1);return r}var n=o;if("choices"in n){if(!t)throw new TypeError("optGroup is not allowed");var a=n,l=a.choices.map(function(u){return Ae(u,!1)}),c={id:0,label:Ai(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=n,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Cs(h.active),selected:Cs(h.selected,!1),disabled:Cs(h.disabled,!1),placeholder:Cs(h.placeholder,!1),highlighted:!1,labelClass:Ll(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},ad=function(o){return o.tagName==="INPUT"},Fl=function(o){return o.tagName==="SELECT"},ld=function(o){return o.tagName==="OPTION"},cd=function(o){return o.tagName==="OPTGROUP"},hd=function(o){Ml(t,o);function t(e){var i=e.element,s=e.classNames,r=e.template,n=e.extractPlaceholder,a=o.call(this,{element:i,classNames:s})||this;return a.template=r,a.extractPlaceholder=n,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(r){var n=r;if(!n.element){var a=i.template(n);s.appendChild(a),n.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){ld(s)?i.push(e._optionToChoice(s)):cd(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.innerText,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Ll(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:ed(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),r=Array.from(s).map(function(n){return i._optionToChoice(n)});return{id:0,label:e.label||"",element:e,active:!!r.length,disabled:e.disabled,choices:r}},t}(Il),dd={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"]},ya={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(o){return!!o&&o!==""},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:Zh,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(o){return'Press Enter to add <b>"'.concat(o,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(o){return"Remove item: ".concat(o)},maxItemText:function(o){return"Only ".concat(o," values can be added")},valueComparer:function(o,t){return o===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:dd,appendGroupInSearch:!1},xa=function(o){var t=o.itemEl;t&&(t.remove(),o.itemEl=void 0)};function ud(o,t,e){var i=o,s=!0;switch(t.type){case ft.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case ft.REMOVE_ITEM:{t.item.selected=!1;var r=t.item.element;if(r){r.selected=!1,r.removeAttribute("selected");var n=r.parentElement;n&&Fl(n)&&n.type===di.SelectOne&&(n.value="")}xa(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case ft.REMOVE_CHOICE:{xa(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case ft.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&id(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function pd(o,t){var e=o,i=!0;switch(t.type){case ft.ADD_GROUP:{e.push(t.group);break}case ft.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function gd(o,t,e){var i=o,s=!0;switch(t.type){case ft.ADD_CHOICE:{i.push(t.choice);break}case ft.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(n){return n.id!==t.choice.id})),i=i.filter(function(n){return n.id!==t.choice.id});break}case ft.ADD_ITEM:case ft.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case ft.FILTER_CHOICES:{var r=[];t.results.forEach(function(n){r[n.item.id]=n}),i.forEach(function(n){var a=r[n.id];a!==void 0?(n.score=a.score,n.rank=a.rank,n.active=!0):(n.score=0,n.rank=0,n.active=!1),e&&e.appendGroupInSearch&&(n.choiceEl=void 0)});break}case ft.ACTIVATE_CHOICES:{i.forEach(function(n){n.active=t.active,e&&e.appendGroupInSearch&&(n.choiceEl=void 0)});break}case ft.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var wa={groups:pd,items:ud,choices:gd},fd=function(){function o(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(o.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),o.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},o.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)})},o.prototype.subscribe=function(t){return this._listeners.push(t),this},o.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(wa).forEach(function(n){var a=wa[n](i[n],t,e._context);a.update&&(s=!0,r[n]=!0,i[n]=a.state)}),s&&(this._txn?this._changeSet=r:this._listeners.forEach(function(n){return n(r)}))},o.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(i){return i(e)}))}}},Object.defineProperty(o.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return!t.disabled&&t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(o.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(r){return r.active&&!r.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),o.prototype.inTxn=function(){return this._txn>0},o.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},o.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},o}(),Ht={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function md(o,t,e){return(t=vd(t))in o?Object.defineProperty(o,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[t]=e,o}function Ca(o,t){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable})),e.push.apply(e,i)}return e}function qi(o){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ca(Object(e),!0).forEach(function(i){md(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):Ca(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function bd(o,t){if(typeof o!="object"||!o)return o;var e=o[Symbol.toPrimitive];if(e!==void 0){var i=e.call(o,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(o)}function vd(o){var t=bd(o,"string");return typeof t=="symbol"?t:t+""}function Qe(o){return Array.isArray?Array.isArray(o):Bl(o)==="[object Array]"}function _d(o){if(typeof o=="string")return o;let t=o+"";return t=="0"&&1/o==-1/0?"-0":t}function yd(o){return o==null?"":_d(o)}function Le(o){return typeof o=="string"}function jl(o){return typeof o=="number"}function xd(o){return o===!0||o===!1||wd(o)&&Bl(o)=="[object Boolean]"}function $l(o){return typeof o=="object"}function wd(o){return $l(o)&&o!==null}function de(o){return o!=null}function ko(o){return!o.trim().length}function Bl(o){return o==null?o===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(o)}const Cd="Incorrect 'index' type",Sd=o=>`Invalid value for key ${o}`,Td=o=>`Pattern length exceeds max of ${o}.`,Ed=o=>`Missing ${o} property in key`,kd=o=>`Property 'weight' in key '${o}' must be a positive integer`,Sa=Object.prototype.hasOwnProperty;class Od{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Rl(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Rl(o){let t=null,e=null,i=null,s=1,r=null;if(Le(o)||Qe(o))i=o,t=Ta(o),e=Yo(o);else{if(!Sa.call(o,"name"))throw new Error(Ed("name"));const n=o.name;if(i=n,Sa.call(o,"weight")&&(s=o.weight,s<=0))throw new Error(kd(n));t=Ta(n),e=Yo(n),r=o.getFn}return{path:t,id:e,weight:s,src:i,getFn:r}}function Ta(o){return Qe(o)?o:o.split(".")}function Yo(o){return Qe(o)?o.join("."):o}function Pd(o,t){let e=[],i=!1;const s=(r,n,a)=>{if(de(r))if(!n[a])e.push(r);else{let l=n[a];const c=r[l];if(!de(c))return;if(a===n.length-1&&(Le(c)||jl(c)||xd(c)))e.push(yd(c));else if(Qe(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],n,a+1)}else n.length&&s(c,n,a+1)}};return s(o,Le(t)?t.split("."):t,0),i?e:e[0]}const Dd={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ad={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(o,t)=>o.score===t.score?o.idx<t.idx?-1:1:o.score<t.score?-1:1},Md={location:0,threshold:.6,distance:100},Id={useExtendedSearch:!1,getFn:Pd,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var j=qi(qi(qi(qi({},Ad),Dd),Md),Id);const Ld=/[^ ]+/g;function Fd(o=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const r=s.match(Ld).length;if(e.has(r))return e.get(r);const n=1/Math.pow(r,.5*o),a=parseFloat(Math.round(n*i)/i);return e.set(r,a),a},clear(){e.clear()}}}class wn{constructor({getFn:t=j.getFn,fieldNormWeight:e=j.fieldNormWeight}={}){this.norm=Fd(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((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Le(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();Le(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(!de(t)||ko(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((s,r)=>{let n=s.getFn?s.getFn(t):this.getFn(t,s.path);if(de(n)){if(Qe(n)){let a=[];const l=[{nestedArrIndex:-1,value:n}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(de(h))if(Le(h)&&!ko(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else Qe(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[r]=a}else if(Le(n)&&!ko(n)){let a={v:n,n:this.norm.get(n)};i.$[r]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function zl(o,t,{getFn:e=j.getFn,fieldNormWeight:i=j.fieldNormWeight}={}){const s=new wn({getFn:e,fieldNormWeight:i});return s.setKeys(o.map(Rl)),s.setSources(t),s.create(),s}function jd(o,{getFn:t=j.getFn,fieldNormWeight:e=j.fieldNormWeight}={}){const{keys:i,records:s}=o,r=new wn({getFn:t,fieldNormWeight:e});return r.setKeys(i),r.setIndexRecords(s),r}function er(o,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=j.distance,ignoreLocation:r=j.ignoreLocation}={}){const n=t/o.length;if(r)return n;const a=Math.abs(i-e);return s?n+a/s:a?1:n}function $d(o=[],t=j.minMatchCharLength){let e=[],i=-1,s=-1,r=0;for(let n=o.length;r<n;r+=1){let a=o[r];a&&i===-1?i=r:!a&&i!==-1&&(s=r-1,s-i+1>=t&&e.push([i,s]),i=-1)}return o[r-1]&&r-i>=t&&e.push([i,r-1]),e}const Ei=32;function Bd(o,t,e,{location:i=j.location,distance:s=j.distance,threshold:r=j.threshold,findAllMatches:n=j.findAllMatches,minMatchCharLength:a=j.minMatchCharLength,includeMatches:l=j.includeMatches,ignoreLocation:c=j.ignoreLocation}={}){if(t.length>Ei)throw new Error(Td(Ei));const h=t.length,d=o.length,u=Math.max(0,Math.min(i,d));let g=r,p=u;const f=a>1||l,b=f?Array(d):[];let m;for(;(m=o.indexOf(t,p))>-1;){let E=er(t,{currentLocation:m,expectedLocation:u,distance:s,ignoreLocation:c});if(g=Math.min(E,g),p=m+h,f){let S=0;for(;S<h;)b[m+S]=1,S+=1}}p=-1;let y=[],w=1,T=h+d;const k=1<<h-1;for(let E=0;E<h;E+=1){let S=0,D=T;for(;S<D;)er(t,{errors:E,currentLocation:u+D,expectedLocation:u,distance:s,ignoreLocation:c})<=g?S=D:T=D,D=Math.floor((T-S)/2+S);T=D;let I=Math.max(1,u-D+1),M=n?d:Math.min(u+D,d)+h,B=Array(M+2);B[M+1]=(1<<E)-1;for(let F=M;F>=I;F-=1){let Y=F-1,tt=e[o.charAt(Y)];if(f&&(b[Y]=+!!tt),B[F]=(B[F+1]<<1|1)&tt,E&&(B[F]|=(y[F+1]|y[F])<<1|1|y[F+1]),B[F]&k&&(w=er(t,{errors:E,currentLocation:Y,expectedLocation:u,distance:s,ignoreLocation:c}),w<=g)){if(g=w,p=Y,p<=u)break;I=Math.max(1,2*u-p)}}if(er(t,{errors:E+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>g)break;y=B}const O={isMatch:p>=0,score:Math.max(.001,w)};if(f){const E=$d(b,a);E.length?l&&(O.indices=E):O.isMatch=!1}return O}function Rd(o){let t={};for(let e=0,i=o.length;e<i;e+=1){const s=o.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class Hl{constructor(t,{location:e=j.location,threshold:i=j.threshold,distance:s=j.distance,includeMatches:r=j.includeMatches,findAllMatches:n=j.findAllMatches,minMatchCharLength:a=j.minMatchCharLength,isCaseSensitive:l=j.isCaseSensitive,ignoreLocation:c=j.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:n,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,g)=>{this.chunks.push({pattern:u,alphabet:Rd(u),startIndex:g})},d=this.pattern.length;if(d>Ei){let u=0;const g=d%Ei,p=d-g;for(;u<p;)h(this.pattern.substr(u,Ei),u),u+=Ei;if(g){const f=d-Ei;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let p={isMatch:!0,score:0};return i&&(p.indices=[[0,t.length-1]]),p}const{location:s,distance:r,threshold:n,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:p,alphabet:f,startIndex:b})=>{const{isMatch:m,score:y,indices:w}=Bd(t,p,f,{location:s+b,distance:r,threshold:n,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});m&&(u=!0),d+=y,m&&w&&(h=[...h,...w])});let g={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(g.indices=h),g}}class yi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ea(t,this.multiRegex)}static isSingleMatch(t){return Ea(t,this.singleRegex)}search(){}}function Ea(o,t){const e=o.match(t);return e?e[1]:null}class zd extends yi{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]}}}class Hd extends yi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class Nd extends yi{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 Vd extends yi{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 Ud extends yi{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 Wd extends yi{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 Nl extends yi{constructor(t,{location:e=j.location,threshold:i=j.threshold,distance:s=j.distance,includeMatches:r=j.includeMatches,findAllMatches:n=j.findAllMatches,minMatchCharLength:a=j.minMatchCharLength,isCaseSensitive:l=j.isCaseSensitive,ignoreLocation:c=j.ignoreLocation}={}){super(t),this._bitapSearch=new Hl(t,{location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:n,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Vl extends yi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],r=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+r,s.push([i,e-1]);const n=!!s.length;return{isMatch:n,score:n?0:1,indices:s}}}const Xo=[zd,Vl,Nd,Vd,Wd,Ud,Hd,Nl],ka=Xo.length,Gd=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Yd="|";function Xd(o,t={}){return o.split(Yd).map(e=>{let i=e.trim().split(Gd).filter(r=>r&&!!r.trim()),s=[];for(let r=0,n=i.length;r<n;r+=1){const a=i[r];let l=!1,c=-1;for(;!l&&++c<ka;){const h=Xo[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<ka;){const h=Xo[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const qd=new Set([Nl.type,Vl.type]);class Kd{constructor(t,{isCaseSensitive:e=j.isCaseSensitive,includeMatches:i=j.includeMatches,minMatchCharLength:s=j.minMatchCharLength,ignoreLocation:r=j.ignoreLocation,findAllMatches:n=j.findAllMatches,location:a=j.location,threshold:l=j.threshold,distance:c=j.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:n,ignoreLocation:r,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=Xd(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,n=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];n.length=0,r=0;for(let d=0,u=h.length;d<u;d+=1){const g=h[d],{isMatch:p,indices:f,score:b}=g.search(t);if(p){if(r+=1,a+=b,i){const m=g.constructor.type;qd.has(m)?n=[...n,...f]:n.push(f)}}else{a=0,r=0,n.length=0;break}}if(r){let d={isMatch:!0,score:a/r};return i&&(d.indices=n),d}}return{isMatch:!1,score:1}}}const qo=[];function Zd(...o){qo.push(...o)}function Ko(o,t){for(let e=0,i=qo.length;e<i;e+=1){let s=qo[e];if(s.condition(o,t))return new s(o,t)}return new Hl(o,t)}const $r={AND:"$and",OR:"$or"},Zo={PATH:"$path",PATTERN:"$val"},Jo=o=>!!(o[$r.AND]||o[$r.OR]),Jd=o=>!!o[Zo.PATH],Qd=o=>!Qe(o)&&$l(o)&&!Jo(o),Oa=o=>({[$r.AND]:Object.keys(o).map(t=>({[t]:o[t]}))});function Ul(o,t,{auto:e=!0}={}){const i=s=>{let r=Object.keys(s);const n=Jd(s);if(!n&&r.length>1&&!Jo(s))return i(Oa(s));if(Qd(s)){const l=n?s[Zo.PATH]:r[0],c=n?s[Zo.PATTERN]:s[l];if(!Le(c))throw new Error(Sd(l));const h={keyId:Yo(l),pattern:c};return e&&(h.searcher=Ko(c,t)),h}let a={children:[],operator:r[0]};return r.forEach(l=>{const c=s[l];Qe(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return Jo(o)||(o=Oa(o)),i(o)}function tu(o,{ignoreFieldNorm:t=j.ignoreFieldNorm}){o.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:r,score:n})=>{const a=s?s.weight:null;i*=Math.pow(n===0&&a?Number.EPSILON:n,(a||1)*(t?1:r))}),e.score=i})}function eu(o,t){const e=o.matches;t.matches=[],de(e)&&e.forEach(i=>{if(!de(i.indices)||!i.indices.length)return;const{indices:s,value:r}=i;let n={indices:s,value:r};i.key&&(n.key=i.key.src),i.idx>-1&&(n.refIndex=i.idx),t.matches.push(n)})}function iu(o,t){t.score=o.score}function su(o,t,{includeMatches:e=j.includeMatches,includeScore:i=j.includeScore}={}){const s=[];return e&&s.push(eu),i&&s.push(iu),o.map(r=>{const{idx:n}=r,a={item:t[n],refIndex:n};return s.length&&s.forEach(l=>{l(r,a)}),a})}class os{constructor(t,e={},i){this.options=qi(qi({},j),e),this.options.useExtendedSearch,this._keyStore=new Od(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof wn))throw new Error(Cd);this._myIndex=e||zl(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){de(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:n,ignoreFieldNorm:a}=this.options;let l=Le(t)?Le(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return tu(l,{ignoreFieldNorm:a}),r&&l.sort(n),jl(e)&&e>-1&&(l=l.slice(0,e)),su(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=Ko(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:r,i:n,n:a})=>{if(!de(r))return;const{isMatch:l,score:c,indices:h}=e.searchIn(r);l&&s.push({item:r,idx:n,matches:[{score:c,value:r,norm:a,indices:h}]})}),s}_searchLogical(t){const e=Ul(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,g=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return g&&g.length?[{idx:c,item:l,matches:g}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const g=a.children[d],p=i(g,l,c);if(p.length)h.push(...p);else if(a.operator===$r.AND)return[]}return h},s=this._myIndex.records,r={},n=[];return s.forEach(({$:a,i:l})=>{if(de(a)){let c=i(e,a,l);c.length&&(r[l]||(r[l]={idx:l,item:a,matches:[]},n.push(r[l])),c.forEach(({matches:h})=>{r[l].matches.push(...h)}))}}),n}_searchObjectList(t){const e=Ko(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach(({$:n,i:a})=>{if(!de(n))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:n[h],searcher:e}))}),l.length&&r.push({idx:a,item:n,matches:l})}),r}_findMatches({key:t,value:e,searcher:i}){if(!de(e))return[];let s=[];if(Qe(e))e.forEach(({v:r,i:n,n:a})=>{if(!de(r))return;const{isMatch:l,score:c,indices:h}=i.searchIn(r);l&&s.push({score:c,key:t,value:r,idx:n,norm:a,indices:h})});else{const{v:r,n}=e,{isMatch:a,score:l,indices:c}=i.searchIn(r);a&&s.push({score:l,key:t,value:r,norm:n,indices:c})}return s}}os.version="7.0.0";os.createIndex=zl;os.parseIndex=jd;os.config=j;os.parseQuery=Ul;Zd(Kd);var ru=function(){function o(t){this._haystack=[],this._fuseOptions=te(te({},t.fuseOptions),{keys:Bh([],t.searchFields),includeMatches:!0})}return o.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},o.prototype.reset=function(){this._haystack=[],this._fuse=void 0},o.prototype.isEmptyIndex=function(){return!this._haystack.length},o.prototype.search=function(t){this._fuse||(this._fuse=new os(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},o}();function ou(o){return new ru(o)}var nu=function(o){for(var t in o)if(Object.prototype.hasOwnProperty.call(o,t))return!1;return!0},Oo=function(o,t,e){var i=o.dataset,s=t.customProperties,r=t.labelClass,n=t.labelDescription;r&&(i.labelClass=eo(r).join(" ")),n&&(i.labelDescription=n),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!nu(s)&&(i.customProperties=JSON.stringify(s)))},Pa=function(o,t,e){var i=t&&o.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},au={containerOuter:function(o,t,e,i,s,r,n){var a=o.classNames.containerOuter,l=document.createElement("div");return z(l,a),l.dataset.type=r,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):n||Pa(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(o){var t=o.classNames.containerInner,e=document.createElement("div");return z(e,t),e},itemList:function(o,t){var e=o.searchEnabled,i=o.classNames,s=i.list,r=i.listSingle,n=i.listItems,a=document.createElement("div");return z(a,s),z(a,t?r:n),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(o,t){var e=o.allowHTML,i=o.classNames.placeholder,s=document.createElement("div");return z(s,i),Ue(s,e,t),s},item:function(o,t,e){var i=o.allowHTML,s=o.removeItemButtonAlignLeft,r=o.removeItemIconText,n=o.removeItemLabelText,a=o.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,g=Ai(t.value),p=document.createElement("div");if(z(p,l),t.labelClass){var f=document.createElement("span");Ue(f,i,t.label),z(f,t.labelClass),p.appendChild(f)}else Ue(p,i,t.label);if(p.dataset.item="",p.dataset.id=t.id,p.dataset.value=g,Oo(p,t,!0),(t.disabled||this.containerOuter.isDisabled)&&p.setAttribute("aria-disabled","true"),this._isSelectElement&&(p.setAttribute("aria-selected","true"),p.setAttribute("role","option")),t.placeholder&&(z(p,u),p.dataset.placeholder=""),z(p,t.highlighted?h:d),e){t.disabled&&Me(p,d),p.dataset.deletable="";var b=document.createElement("button");b.type="button",z(b,c),Ue(b,!0,Os(r,t.value));var m=Os(n,t.value);m&&b.setAttribute("aria-label",m),b.dataset.button="",s?p.insertAdjacentElement("afterbegin",b):p.appendChild(b)}return p},choiceList:function(o,t){var e=o.classNames.list,i=document.createElement("div");return z(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(o,t){var e=o.allowHTML,i=o.classNames,s=i.group,r=i.groupHeading,n=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Ai(l),d=document.createElement("div");z(d,s),c&&z(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 z(u,r),Ue(u,e,l||""),d.appendChild(u),d},choice:function(o,t,e,i){var s=o.allowHTML,r=o.classNames,n=r.item,a=r.itemChoice,l=r.itemSelectable,c=r.selectedState,h=r.itemDisabled,d=r.description,u=r.placeholder,g=t.label,p=Ai(t.value),f=document.createElement("div");f.id=t.elementId,z(f,n),z(f,a),i&&typeof g=="string"&&(g=xn(s,g),g+=" (".concat(i,")"),g={trusted:g});var b=f;if(t.labelClass){var m=document.createElement("span");Ue(m,s,g),z(m,t.labelClass),b=m,f.appendChild(m)}else Ue(f,s,g);if(t.labelDescription){var y="".concat(t.elementId,"-description");b.setAttribute("aria-describedby",y);var w=document.createElement("span");Ue(w,s,t.labelDescription),w.id=y,z(w,d),f.appendChild(w)}return t.selected&&z(f,c),t.placeholder&&z(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=p,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),Oo(f,t,!1),t.disabled?(z(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(z(f,l),f.dataset.choiceSelectable=""),f},input:function(o,t){var e=o.classNames,i=e.input,s=e.inputCloned,r=o.labelId,n=document.createElement("input");return n.type="search",z(n,i),z(n,s),n.autocomplete="off",n.autocapitalize="off",n.spellcheck=!1,n.setAttribute("role","textbox"),n.setAttribute("aria-autocomplete","list"),t?n.setAttribute("aria-label",t):r||Pa(this._docRoot,this.passedElement.element.id,n),n},dropdown:function(o){var t=o.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return z(s,e),z(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(o,t,e){var i=o.classNames,s=i.item,r=i.itemChoice,n=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Ht.generic);var h=document.createElement("div");switch(Ue(h,!0,t),z(h,s),z(h,r),z(h,c),e){case Ht.addChoice:z(h,n);break;case Ht.noResults:z(h,a);break;case Ht.noChoices:z(h,l);break}return e===Ht.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(o){var t=Ai(o.label),e=new Option(t,o.value,!1,o.selected);return Oo(e,o,!0),e.disabled=o.disabled,o.selected&&e.setAttribute("selected",""),e}},lu="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,cu={},Po=function(o){if(o)return o.dataset.id?parseInt(o.dataset.id,10):void 0},ms="[data-choice-selectable]",Wl=function(){function o(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=o.defaults;this.config=te(te(te({},s.allOptions),s.options),e),Rh.forEach(function(m){i.config[m]=te(te(te({},s.allOptions[m]),s.options[m]),e[m])});var r=this.config;r.silent||this._validateConfig();var n=r.shadowRoot||document.documentElement;this._docRoot=n;var a=typeof t=="string"?n.querySelector(t):t;if(!a||typeof a!="object"||!(ad(a)||Fl(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===di.Text;(c||r.maxItemCount!==1)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=di.SelectMultiple);var h=l===di.SelectOne,d=l===di.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&r.addItems||u&&r.addChoices,typeof r.renderSelectedChoices!="boolean"&&(r.renderSelectedChoices=r.renderSelectedChoices==="always"||h),r.closeDropdownOnSelect==="auto"?r.closeDropdownOnSelect=c||h||r.singleModeForMultiSelect:r.closeDropdownOnSelect=Cs(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var g=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);r.addItemFilter=g.test.bind(g)}if(this._isTextElement)this.passedElement=new nd({element:a,classNames:r.classNames});else{var p=a;this.passedElement=new hd({element:p,classNames:r.classNames,template:function(m){return i._templates.option(m)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new fd(r),this._currentValue="",r.searchEnabled=!c&&r.searchEnabled||d,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Gh(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,b=window.getComputedStyle(document.documentElement).direction;f!==b&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.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){r.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(m){return m.value})}return Object.defineProperty(o,"defaults",{get:function(){return Object.preventExtensions({get options(){return cu},get allOptions(){return ya},get templates(){return au}})},enumerable:!1,configurable:!0}),o.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=ou(this.config),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 t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},o.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=o.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},o.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},o.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},o.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(tr(i,!0)),e&&this.passedElement.triggerEvent(Qt.highlightItem,this._getChoiceForOutput(i)),this)},o.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(tr(i,!1)),e&&this.passedElement.triggerEvent(Qt.unhighlightItem,this._getChoiceForOutput(i)),this)},o.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(tr(e,!0)),t.passedElement.triggerEvent(Qt.highlightItem,t._getChoiceForOutput(e)))})}),this},o.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(tr(e,!1)),t.passedElement.triggerEvent(Qt.highlightItem,t._getChoiceForOutput(e)))})}),this},o.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},o.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},o.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},o.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(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(Qt.showDropdown)}),this)},o.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(Qt.hideDropdown)}),this):this},o.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},o.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Ae(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},o.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},o.prototype.setChoices=function(t,e,i,s,r){var n=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),r===void 0&&(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(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(s&&this.clearChoices(),typeof t=="function"){var a=t(this);if(typeof Promise=="function"&&a instanceof Promise)return new Promise(function(l){return requestAnimationFrame(l)}).then(function(){return n._handleLoadingState(!0)}).then(function(){return a}).then(function(l){return n.setChoices(l,e,i,s)}).catch(function(l){n.config.silent||console.error(l)}).then(function(){return n._handleLoadingState(!1)}).then(function(){return n});if(!Array.isArray(a))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof a));return this.setChoices(a,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&&(n._isSearching=!1);var l=e==="value",c=i==="label";t.forEach(function(h){if("choices"in h){var d=h;c||(d=te(te({},d),{label:d[i]})),n._addGroup(Ae(d,!0))}else{var u=h;(!c||!l)&&(u=te(te({},u),{value:u[e],label:u[i]})),n._addChoice(Ae(u,!1))}}),n.unhighlightAll()}),this._searcher.reset(),this},o.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var r=s.passedElement.optionsAsChoices(),n={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&!l.disabled&&(n[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(fa(l)):n[l.value]&&(l.selected=!0)};r.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),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)},o.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(ga(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Qt.removeItem,this._getChoiceForOutput(e)),this):this},o.prototype.clearChoices=function(){var t=this;return this._store.withTxn(function(){t._store.choices.forEach(function(e){e.selected||t._store.dispatch(ga(e))})}),this._searcher.reset(),this},o.prototype.clearStore=function(t){return t===void 0&&(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},o.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},o.prototype._validateConfig=function(){var t=this.config,e=td(t,ya);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},o.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},o.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,r=this._store,n=r.activeGroups,a=r.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(p){return!p.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(p){return p.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,g=function(p,f,b){s?p.sort(Jh):i.shouldSort&&p.sort(i.sorter);var m=p.length;m=!f&&l&&m>l?l:m,m--,p.every(function(y,w){var T=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,b);return y.choiceEl=T,h.appendChild(T),!y.disabled&&(s||!y.selected)&&(u=!0),w<m})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&g(a.filter(function(p){return p.placeholder&&!p.group}),!1,void 0),n.length&&!s?(i.shouldSort&&n.sort(i.sorter),g(a.filter(function(p){return!p.placeholder&&!p.group}),!1,void 0),n.forEach(function(p){var f=d(p.choices);if(f.length){if(p.label){var b=p.groupEl||t._templates.choiceGroup(t.config,p);p.groupEl=b,b.remove(),h.appendChild(b)}g(f,!0,i.appendGroupInSearch&&s?p.label:void 0)}})):g(d(a),!1,void 0)),u||(this._notice||(this._notice={text:ba(s?i.noResultsText:i.noChoicesText),type:s?Ht.noResults:Ht.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},o.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),n=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=n(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,r.appendChild(u))};e.forEach(a);var l=!!r.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var c=i.children.length;if(l||c>1){var h=i.querySelector(fs(s.classNames.placeholder));h&&h.remove()}else c||(l=!0,a(Ae({selected:!0,value:"",label:s.placeholderValue||"",placeholder:!0},!1)))}l&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=n(d);u&&(u.remove(),r.append(u))}),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},o.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===Ht.addChoice&&(e===Ht.noResults||e===Ht.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},o.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(fs(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},o.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)}},o.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}},o.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Qt.change,{value:t})},o.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&Po(t.parentElement),r=s&&i.find(function(n){return n.id===s});r&&this._store.withTxn(function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var n=e._store.choices.reverse().find(function(a){return!a.disabled&&a.placeholder});n&&(e._addItem(n),e.unhighlightAll(),n.value&&e._triggerChange(n.value))}})}},o.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var r=Po(t);r&&(s.forEach(function(n){n.id===r&&!n.highlighted?i.highlightItem(n):!e&&n.highlighted&&i.unhighlightItem(n)}),this.input.focus())}},o.prototype._handleChoiceAction=function(t){var e=this,i=Po(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},o.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(r){return r.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))}},o.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(n){return Ae(n,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(n){return Ae(n,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(n){n.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(n){return Ae(n,!0)});var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},o.prototype._handleLoadingState=function(t){t===void 0&&(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||"")},o.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Qt.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},o.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(typeof i=="function"?i(e):i,Ht.addChoice),!1):!0},o.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=Os(e.customAddItemText,t)),i){var r=this._store.choices.find(function(n){return e.valueComparer(n.value,t)});if(this._isSelectElement){if(r)return this._displayNotice("",Ht.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&r&&(i=!1,s=Os(e.uniqueItemText,t))}return i&&(s=Os(e.addItemText,t)),s&&this._displayNotice(s,Ht.addChoice),i},o.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,n=r&&r.type;return n!==Ht.addChoice&&(s.length?this._clearNotice():this._displayNotice(ba(this.config.noResultsText),Ht.noResults)),this._store.dispatch(Hh(s)),s.length},o.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Nh(!0)),this.passedElement.triggerEvent(Qt.search,{value:"",resultCount:0}))},o.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()},o.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()},o.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==zt.ESC_KEY&&e!==zt.TAB_KEY&&e!==zt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case zt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case zt.ENTER_KEY:return this._onEnterKey(t,i);case zt.ESC_KEY:return this._onEscapeKey(t,i);case zt.UP_KEY:case zt.PAGE_UP_KEY:case zt.DOWN_KEY:case zt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case zt.DELETE_KEY:case zt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},o.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},o.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},o.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},o.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);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var n=this.dropdown.element.querySelector(fs(this.config.classNames.highlightedState));if(!(n&&this._handleChoiceAction(n))){if(!r||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(Ae(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},o.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},o.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===zt.DOWN_KEY||i===zt.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===zt.PAGE_DOWN_KEY||i===zt.PAGE_UP_KEY,n=void 0;if(r)s>0?n=this.dropdown.element.querySelector("".concat(ms,":last-of-type")):n=this.dropdown.element.querySelector(ms);else{var a=this.dropdown.element.querySelector(fs(this.config.classNames.highlightedState));a?n=Yh(a,ms,s):n=this.dropdown.element.querySelector(ms)}n&&(Xh(n,this.choiceList.element,s)||this.choiceList.scrollToChildElement(n,s),this._highlightChoice(n)),t.preventDefault()}},o.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},o.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},o.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},o.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(lu&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?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()}}},o.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},o.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},o.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var r=e===this.input.element;this._isTextElement?r&&i.addFocusState():this._isSelectMultipleElement?r&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),r&&this.showDropdown(!0))}},o.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!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())},o.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)})},o.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(ms));if(e.length){var i=t,s=this.config.classNames.highlightedState,r=Array.from(this.dropdown.element.querySelectorAll(fs(s)));r.forEach(function(n){Me(n,s),n.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),z(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Qt.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},o.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(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(Uh(t)),e&&(this.passedElement.triggerEvent(Qt.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Qt.choice,this._getChoiceForOutput(t)))},o.prototype._removeItem=function(t){if(t.id){this._store.dispatch(fa(t));var e=this._notice;e&&e.type===Ht.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Qt.removeItem,this._getChoiceForOutput(t))}},o.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(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(a){return s.valueComparer(a.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,n=s.appendValue;r&&(t.value=r+t.value),n&&(t.value+=n.toString()),(r||n)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(zh(t)),t.selected&&this._addItem(t,e,i)}},o.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(Vh(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)}))},o.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,qh,xn,eo));var s={};Object.keys(this._templates).forEach(function(r){r in i?s[r]=i[r].bind(t):s[r]=t._templates[r].bind(t)}),this._templates=s},o.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,r=i.position,n=i.classNames,a=this._elementType;this.containerOuter=new va({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:n,type:a,position:r}),this.containerInner=new va({element:t.containerInner(i),classNames:n,type:a,position:r}),this.input=new rd({element:t.input(i,this._placeholderValue),classNames:n,type:a,preventPaste:!i.paste}),this.choiceList=new _a({element:t.choiceList(i,s)}),this.itemList=new _a({element:t.itemList(i,s)}),this.dropdown=new sd({element:t.dropdown(i),classNames:n,type:a})},o.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},o.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()},o.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var r=t.findIndex(function(n){return n.selected})===-1;r&&t.some(function(n){return n.disabled||"choices"in n?!1:(n.selected=!0,!0)})}t.forEach(function(n){"choices"in n?s._isSelectElement&&s._addGroup(n,i):s._addChoice(n,i)})},o.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(r){return i.config.valueComparer(r.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},o.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},o.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},o.version="11.0.3",o}();const Gl='.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 zi{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const s=i.target;(this.slotNames.includes("[default]")&&!s.name||s.name&&this.slotNames.includes(s.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&&((e=t.textContent)==null?void 0:e.trim())!=="")return!0;if(t.nodeType===t.ELEMENT_NODE){const i=t;if(i.tagName.toLowerCase()==="pbo-visually-hidden")return!1;if(!i.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(t){return this.host.querySelector(`:scope > [slot="${t}"]`)!==null}test(t){return t==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}/**
162
+ `;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Go=function(o,t){return Go=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(e[s]=i[s])},Go(o,t)};function Ml(o,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Go(o,t);function e(){this.constructor=o}o.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var te=function(){return te=Object.assign||function(t){for(var e,i=1,s=arguments.length;i<s;i++){e=arguments[i];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t},te.apply(this,arguments)};function Bh(o,t,e){for(var i=0,s=t.length,r;i<s;i++)(r||!(i in t))&&(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return o.concat(r||Array.prototype.slice.call(t))}var mt={ADD_CHOICE:"ADD_CHOICE",REMOVE_CHOICE:"REMOVE_CHOICE",FILTER_CHOICES:"FILTER_CHOICES",ACTIVATE_CHOICES:"ACTIVATE_CHOICES",CLEAR_CHOICES:"CLEAR_CHOICES",ADD_GROUP:"ADD_GROUP",ADD_ITEM:"ADD_ITEM",REMOVE_ITEM:"REMOVE_ITEM",HIGHLIGHT_ITEM:"HIGHLIGHT_ITEM"},Qt={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},zt={TAB_KEY:9,SHIFT_KEY:16,BACK_KEY:46,DELETE_KEY:8,ENTER_KEY:13,A_KEY:65,ESC_KEY:27,UP_KEY:38,DOWN_KEY:40,PAGE_UP_KEY:33,PAGE_DOWN_KEY:34},Rh=["fuseOptions","classNames"],pi={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},zh=function(o){return{type:mt.ADD_CHOICE,choice:o}},ga=function(o){return{type:mt.REMOVE_CHOICE,choice:o}},Hh=function(o){return{type:mt.FILTER_CHOICES,results:o}},Nh=function(o){return{type:mt.ACTIVATE_CHOICES,active:o}},Vh=function(o){return{type:mt.ADD_GROUP,group:o}},Uh=function(o){return{type:mt.ADD_ITEM,item:o}},fa=function(o){return{type:mt.REMOVE_ITEM,item:o}},tr=function(o,t){return{type:mt.HIGHLIGHT_ITEM,item:o,highlighted:t}},Wh=function(o,t){return Math.floor(Math.random()*(t-o)+o)},ma=function(o){return Array.from({length:o},function(){return Wh(0,36).toString(36)}).join("")},Gh=function(o,t){var e=o.id||o.name&&"".concat(o.name,"-").concat(ma(2))||ma(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},Yh=function(o,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),s=o[i];s;){if(s.matches(t))return s;s=s[i]}return null},Xh=function(o,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=o.offsetTop+o.offsetHeight:i=o.offsetTop>=t.scrollTop,i},to=function(o){if(typeof o!="string"){if(o==null)return"";if(typeof o=="object"){if("raw"in o)return to(o.raw);if("trusted"in o)return o.trusted}return o}return o.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/'/g,"&#039;").replace(/"/g,"&quot;")},qh=function(){var o=document.createElement("div");return function(t){o.innerHTML=t.trim();for(var e=o.children[0];o.firstChild;)o.removeChild(o.firstChild);return e}}(),Ps=function(o,t){return typeof o=="function"?o(to(t),t):o},ba=function(o){return typeof o=="function"?o():o},Mi=function(o){if(typeof o=="string")return o;if(typeof o=="object"){if("trusted"in o)return o.trusted;if("raw"in o)return o.raw}return""},Kh=function(o){if(typeof o=="string")return o;if(typeof o=="object"){if("escaped"in o)return o.escaped;if("trusted"in o)return o.trusted}return""},xn=function(o,t){return o?Kh(t):to(t)},Ge=function(o,t,e){o.innerHTML=xn(t,e)},Zh=function(o,t){var e=o.value,i=o.label,s=i===void 0?e:i,r=t.value,n=t.label,a=n===void 0?r:n;return Mi(s).localeCompare(Mi(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},Jh=function(o,t){return o.rank-t.rank},Qh=function(o,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return o.dispatchEvent(i)},td=function(o,t){var e=Object.keys(o).sort(),i=Object.keys(t).sort();return e.filter(function(s){return i.indexOf(s)<0})},eo=function(o){return Array.isArray(o)?o:[o]},ms=function(o){return o&&Array.isArray(o)?o.map(function(t){return".".concat(t)}).join(""):".".concat(o)},z=function(o,t){var e;(e=o.classList).add.apply(e,eo(t))},Ie=function(o,t){var e;(e=o.classList).remove.apply(e,eo(t))},ed=function(o){if(typeof o<"u")try{return JSON.parse(o)}catch{return o}return{}},id=function(o,t,e){var i=o.itemEl;i&&(Ie(i,e),z(i,t))},sd=function(){function o(t){var e=t.element,i=t.type,s=t.classNames;this.element=e,this.classNames=s,this.type=i,this.isActive=!1}return o.prototype.show=function(){return z(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},o.prototype.hide=function(){return Ie(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},o}(),va=function(){function o(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 o.prototype.shouldFlip=function(t,e){var i=!1;return this.position==="auto"?i=this.element.getBoundingClientRect().top-e>=0&&!window.matchMedia("(min-height: ".concat(t+1,"px)")).matches:this.position==="top"&&(i=!0),i},o.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},o.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},o.prototype.open=function(t,e){z(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(z(this.element,this.classNames.flippedState),this.isFlipped=!0)},o.prototype.close=function(){Ie(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Ie(this.element,this.classNames.flippedState),this.isFlipped=!1)},o.prototype.addFocusState=function(){z(this.element,this.classNames.focusState)},o.prototype.removeFocusState=function(){Ie(this.element,this.classNames.focusState)},o.prototype.enable=function(){Ie(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===pi.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},o.prototype.disable=function(){z(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===pi.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},o.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)},o.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},o.prototype.addLoadingState=function(){z(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},o.prototype.removeLoadingState=function(){Ie(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},o}(),rd=function(){function o(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(o.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),o.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})},o.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)},o.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},o.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},o.prototype.focus=function(){this.isFocussed||this.element.focus()},o.prototype.blur=function(){this.isFocussed&&this.element.blur()},o.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},o.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")},o.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},o.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},o.prototype._onInput=function(){this.type!==pi.SelectOne&&this.setWidth()},o.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},o.prototype._onFocus=function(){this.isFocussed=!0},o.prototype._onBlur=function(){this.isFocussed=!1},o}(),od=4,_a=function(){function o(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return o.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},o.prototype.scrollToTop=function(){this.element.scrollTop=0},o.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var s=this.element.offsetHeight,r=this.element.scrollTop+s,n=t.offsetHeight,a=t.offsetTop+n,l=e>0?this.element.scrollTop+a-r:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},o.prototype._scrollDown=function(t,e,i){var s=(i-t)/e,r=s>1?s:1;this.element.scrollTop=t+r},o.prototype._scrollUp=function(t,e,i){var s=(t-i)/e,r=s>1?s:1;this.element.scrollTop=t-r},o.prototype._animateScroll=function(t,e){var i=this,s=od,r=this.element.scrollTop,n=!1;e>0?(this._scrollDown(r,s,t),r<t&&(n=!0)):(this._scrollUp(r,s,t),r>t&&(n=!0)),n&&requestAnimationFrame(function(){i._animateScroll(t,e)})},o}(),Il=function(){function o(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(o.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),o.prototype.conceal=function(){var t=this.element;z(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")},o.prototype.reveal=function(){var t=this.element;Ie(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")},o.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},o.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},o.prototype.triggerEvent=function(t,e){Qh(this.element,t,e||{})},o}(),nd=function(o){Ml(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}return t}(Il),Ss=function(o,t){return t===void 0&&(t=!0),typeof o>"u"?t:!!o},Ll=function(o){if(typeof o=="string"&&(o=o.split(" ").filter(function(t){return t.length})),Array.isArray(o)&&o.length)return o},Me=function(o,t,e){if(e===void 0&&(e=!0),typeof o=="string"){var i=to(o),s=e||i===o?o:{escaped:i,raw:o},r=Me({value:o,label:s,selected:!0},!1);return r}var n=o;if("choices"in n){if(!t)throw new TypeError("optGroup is not allowed");var a=n,l=a.choices.map(function(u){return Me(u,!1)}),c={id:0,label:Mi(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=n,d={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Ss(h.active),selected:Ss(h.selected,!1),disabled:Ss(h.disabled,!1),placeholder:Ss(h.placeholder,!1),highlighted:!1,labelClass:Ll(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return d},ad=function(o){return o.tagName==="INPUT"},Fl=function(o){return o.tagName==="SELECT"},ld=function(o){return o.tagName==="OPTION"},cd=function(o){return o.tagName==="OPTGROUP"},hd=function(o){Ml(t,o);function t(e){var i=e.element,s=e.classNames,r=e.template,n=e.extractPlaceholder,a=o.call(this,{element:i,classNames:s})||this;return a.template=r,a.extractPlaceholder=n,a}return Object.defineProperty(t.prototype,"placeholderOption",{get:function(){return this.element.querySelector('option[value=""]')||this.element.querySelector("option[placeholder]")},enumerable:!1,configurable:!0}),t.prototype.addOptions=function(e){var i=this,s=document.createDocumentFragment();e.forEach(function(r){var n=r;if(!n.element){var a=i.template(n);s.appendChild(a),n.element=a}}),this.element.appendChild(s)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(s){ld(s)?i.push(e._optionToChoice(s)):cd(s)&&i.push(e._optgroupToChoice(s))}),i},t.prototype._optionToChoice=function(e){return!e.hasAttribute("value")&&e.hasAttribute("placeholder")&&(e.setAttribute("value",""),e.value=""),{id:0,group:null,score:0,rank:0,value:e.value,label:e.innerText,element:e,active:!0,selected:this.extractPlaceholder?e.selected:e.hasAttribute("selected"),disabled:e.disabled,highlighted:!1,placeholder:this.extractPlaceholder&&(!e.value||e.hasAttribute("placeholder")),labelClass:typeof e.dataset.labelClass<"u"?Ll(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:ed(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,s=e.querySelectorAll("option"),r=Array.from(s).map(function(n){return i._optionToChoice(n)});return{id:0,label:e.label||"",element:e,active:!!r.length,disabled:e.disabled,choices:r}},t}(Il),dd={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"]},ya={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(o){return!!o&&o!==""},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:Zh,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(o){return'Press Enter to add <b>"'.concat(o,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(o){return"Remove item: ".concat(o)},maxItemText:function(o){return"Only ".concat(o," values can be added")},valueComparer:function(o,t){return o===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:dd,appendGroupInSearch:!1},xa=function(o){var t=o.itemEl;t&&(t.remove(),o.itemEl=void 0)};function ud(o,t,e){var i=o,s=!0;switch(t.type){case mt.ADD_ITEM:{t.item.selected=!0;var r=t.item.element;r&&(r.selected=!0,r.setAttribute("selected","")),i.push(t.item);break}case mt.REMOVE_ITEM:{t.item.selected=!1;var r=t.item.element;if(r){r.selected=!1,r.removeAttribute("selected");var n=r.parentElement;n&&Fl(n)&&n.type===pi.SelectOne&&(n.value="")}xa(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case mt.REMOVE_CHOICE:{xa(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case mt.HIGHLIGHT_ITEM:{var a=t.highlighted,l=i.find(function(c){return c.id===t.item.id});l&&l.highlighted!==a&&(l.highlighted=a,e&&id(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{s=!1;break}}return{state:i,update:s}}function pd(o,t){var e=o,i=!0;switch(t.type){case mt.ADD_GROUP:{e.push(t.group);break}case mt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function gd(o,t,e){var i=o,s=!0;switch(t.type){case mt.ADD_CHOICE:{i.push(t.choice);break}case mt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(n){return n.id!==t.choice.id})),i=i.filter(function(n){return n.id!==t.choice.id});break}case mt.ADD_ITEM:case mt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case mt.FILTER_CHOICES:{var r=[];t.results.forEach(function(n){r[n.item.id]=n}),i.forEach(function(n){var a=r[n.id];a!==void 0?(n.score=a.score,n.rank=a.rank,n.active=!0):(n.score=0,n.rank=0,n.active=!1),e&&e.appendGroupInSearch&&(n.choiceEl=void 0)});break}case mt.ACTIVATE_CHOICES:{i.forEach(function(n){n.active=t.active,e&&e.appendGroupInSearch&&(n.choiceEl=void 0)});break}case mt.CLEAR_CHOICES:{i=[];break}default:{s=!1;break}}return{state:i,update:s}}var wa={groups:pd,items:ud,choices:gd},fd=function(){function o(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(o.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),o.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},o.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)})},o.prototype.subscribe=function(t){return this._listeners.push(t),this},o.prototype.dispatch=function(t){var e=this,i=this._state,s=!1,r=this._changeSet||this.changeSet(!1);Object.keys(wa).forEach(function(n){var a=wa[n](i[n],t,e._context);a.update&&(s=!0,r[n]=!0,i[n]=a.state)}),s&&(this._txn?this._changeSet=r:this._listeners.forEach(function(n){return n(r)}))},o.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(i){return i(e)}))}}},Object.defineProperty(o.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return!t.disabled&&t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(o.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(r){return r.active&&!r.disabled});return i&&s},[])},enumerable:!1,configurable:!0}),o.prototype.inTxn=function(){return this._txn>0},o.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},o.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},o}(),Ht={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function md(o,t,e){return(t=vd(t))in o?Object.defineProperty(o,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[t]=e,o}function Ca(o,t){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable})),e.push.apply(e,i)}return e}function qi(o){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ca(Object(e),!0).forEach(function(i){md(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):Ca(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function bd(o,t){if(typeof o!="object"||!o)return o;var e=o[Symbol.toPrimitive];if(e!==void 0){var i=e.call(o,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(o)}function vd(o){var t=bd(o,"string");return typeof t=="symbol"?t:t+""}function ei(o){return Array.isArray?Array.isArray(o):Bl(o)==="[object Array]"}function _d(o){if(typeof o=="string")return o;let t=o+"";return t=="0"&&1/o==-1/0?"-0":t}function yd(o){return o==null?"":_d(o)}function Fe(o){return typeof o=="string"}function jl(o){return typeof o=="number"}function xd(o){return o===!0||o===!1||wd(o)&&Bl(o)=="[object Boolean]"}function $l(o){return typeof o=="object"}function wd(o){return $l(o)&&o!==null}function de(o){return o!=null}function ko(o){return!o.trim().length}function Bl(o){return o==null?o===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(o)}const Cd="Incorrect 'index' type",Sd=o=>`Invalid value for key ${o}`,Td=o=>`Pattern length exceeds max of ${o}.`,Ed=o=>`Missing ${o} property in key`,kd=o=>`Property 'weight' in key '${o}' must be a positive integer`,Sa=Object.prototype.hasOwnProperty;class Od{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let s=Rl(i);this._keys.push(s),this._keyMap[s.id]=s,e+=s.weight}),this._keys.forEach(i=>{i.weight/=e})}get(t){return this._keyMap[t]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}}function Rl(o){let t=null,e=null,i=null,s=1,r=null;if(Fe(o)||ei(o))i=o,t=Ta(o),e=Yo(o);else{if(!Sa.call(o,"name"))throw new Error(Ed("name"));const n=o.name;if(i=n,Sa.call(o,"weight")&&(s=o.weight,s<=0))throw new Error(kd(n));t=Ta(n),e=Yo(n),r=o.getFn}return{path:t,id:e,weight:s,src:i,getFn:r}}function Ta(o){return ei(o)?o:o.split(".")}function Yo(o){return ei(o)?o.join("."):o}function Pd(o,t){let e=[],i=!1;const s=(r,n,a)=>{if(de(r))if(!n[a])e.push(r);else{let l=n[a];const c=r[l];if(!de(c))return;if(a===n.length-1&&(Fe(c)||jl(c)||xd(c)))e.push(yd(c));else if(ei(c)){i=!0;for(let h=0,d=c.length;h<d;h+=1)s(c[h],n,a+1)}else n.length&&s(c,n,a+1)}};return s(o,Fe(t)?t.split("."):t,0),i?e:e[0]}const Dd={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},Ad={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(o,t)=>o.score===t.score?o.idx<t.idx?-1:1:o.score<t.score?-1:1},Md={location:0,threshold:.6,distance:100},Id={useExtendedSearch:!1,getFn:Pd,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var j=qi(qi(qi(qi({},Ad),Dd),Md),Id);const Ld=/[^ ]+/g;function Fd(o=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(s){const r=s.match(Ld).length;if(e.has(r))return e.get(r);const n=1/Math.pow(r,.5*o),a=parseFloat(Math.round(n*i)/i);return e.set(r,a),a},clear(){e.clear()}}}class wn{constructor({getFn:t=j.getFn,fieldNormWeight:e=j.fieldNormWeight}={}){this.norm=Fd(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((e,i)=>{this._keysMap[e.id]=i})}create(){this.isCreated||!this.docs.length||(this.isCreated=!0,Fe(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();Fe(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(!de(t)||ko(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((s,r)=>{let n=s.getFn?s.getFn(t):this.getFn(t,s.path);if(de(n)){if(ei(n)){let a=[];const l=[{nestedArrIndex:-1,value:n}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(de(h))if(Fe(h)&&!ko(h)){let d={v:h,i:c,n:this.norm.get(h)};a.push(d)}else ei(h)&&h.forEach((d,u)=>{l.push({nestedArrIndex:u,value:d})})}i.$[r]=a}else if(Fe(n)&&!ko(n)){let a={v:n,n:this.norm.get(n)};i.$[r]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function zl(o,t,{getFn:e=j.getFn,fieldNormWeight:i=j.fieldNormWeight}={}){const s=new wn({getFn:e,fieldNormWeight:i});return s.setKeys(o.map(Rl)),s.setSources(t),s.create(),s}function jd(o,{getFn:t=j.getFn,fieldNormWeight:e=j.fieldNormWeight}={}){const{keys:i,records:s}=o,r=new wn({getFn:t,fieldNormWeight:e});return r.setKeys(i),r.setIndexRecords(s),r}function er(o,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:s=j.distance,ignoreLocation:r=j.ignoreLocation}={}){const n=t/o.length;if(r)return n;const a=Math.abs(i-e);return s?n+a/s:a?1:n}function $d(o=[],t=j.minMatchCharLength){let e=[],i=-1,s=-1,r=0;for(let n=o.length;r<n;r+=1){let a=o[r];a&&i===-1?i=r:!a&&i!==-1&&(s=r-1,s-i+1>=t&&e.push([i,s]),i=-1)}return o[r-1]&&r-i>=t&&e.push([i,r-1]),e}const ki=32;function Bd(o,t,e,{location:i=j.location,distance:s=j.distance,threshold:r=j.threshold,findAllMatches:n=j.findAllMatches,minMatchCharLength:a=j.minMatchCharLength,includeMatches:l=j.includeMatches,ignoreLocation:c=j.ignoreLocation}={}){if(t.length>ki)throw new Error(Td(ki));const h=t.length,d=o.length,u=Math.max(0,Math.min(i,d));let g=r,p=u;const f=a>1||l,b=f?Array(d):[];let m;for(;(m=o.indexOf(t,p))>-1;){let E=er(t,{currentLocation:m,expectedLocation:u,distance:s,ignoreLocation:c});if(g=Math.min(E,g),p=m+h,f){let S=0;for(;S<h;)b[m+S]=1,S+=1}}p=-1;let y=[],w=1,T=h+d;const k=1<<h-1;for(let E=0;E<h;E+=1){let S=0,D=T;for(;S<D;)er(t,{errors:E,currentLocation:u+D,expectedLocation:u,distance:s,ignoreLocation:c})<=g?S=D:T=D,D=Math.floor((T-S)/2+S);T=D;let I=Math.max(1,u-D+1),M=n?d:Math.min(u+D,d)+h,B=Array(M+2);B[M+1]=(1<<E)-1;for(let F=M;F>=I;F-=1){let Y=F-1,tt=e[o.charAt(Y)];if(f&&(b[Y]=+!!tt),B[F]=(B[F+1]<<1|1)&tt,E&&(B[F]|=(y[F+1]|y[F])<<1|1|y[F+1]),B[F]&k&&(w=er(t,{errors:E,currentLocation:Y,expectedLocation:u,distance:s,ignoreLocation:c}),w<=g)){if(g=w,p=Y,p<=u)break;I=Math.max(1,2*u-p)}}if(er(t,{errors:E+1,currentLocation:u,expectedLocation:u,distance:s,ignoreLocation:c})>g)break;y=B}const O={isMatch:p>=0,score:Math.max(.001,w)};if(f){const E=$d(b,a);E.length?l&&(O.indices=E):O.isMatch=!1}return O}function Rd(o){let t={};for(let e=0,i=o.length;e<i;e+=1){const s=o.charAt(e);t[s]=(t[s]||0)|1<<i-e-1}return t}class Hl{constructor(t,{location:e=j.location,threshold:i=j.threshold,distance:s=j.distance,includeMatches:r=j.includeMatches,findAllMatches:n=j.findAllMatches,minMatchCharLength:a=j.minMatchCharLength,isCaseSensitive:l=j.isCaseSensitive,ignoreLocation:c=j.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:n,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(u,g)=>{this.chunks.push({pattern:u,alphabet:Rd(u),startIndex:g})},d=this.pattern.length;if(d>ki){let u=0;const g=d%ki,p=d-g;for(;u<p;)h(this.pattern.substr(u,ki),u),u+=ki;if(g){const f=d-ki;h(this.pattern.substr(f),f)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let p={isMatch:!0,score:0};return i&&(p.indices=[[0,t.length-1]]),p}const{location:s,distance:r,threshold:n,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],d=0,u=!1;this.chunks.forEach(({pattern:p,alphabet:f,startIndex:b})=>{const{isMatch:m,score:y,indices:w}=Bd(t,p,f,{location:s+b,distance:r,threshold:n,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});m&&(u=!0),d+=y,m&&w&&(h=[...h,...w])});let g={isMatch:u,score:u?d/this.chunks.length:1};return u&&i&&(g.indices=h),g}}class xi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ea(t,this.multiRegex)}static isSingleMatch(t){return Ea(t,this.singleRegex)}search(){}}function Ea(o,t){const e=o.match(t);return e?e[1]:null}class zd extends xi{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]}}}class Hd extends xi{constructor(t){super(t)}static get type(){return"inverse-exact"}static get multiRegex(){return/^!"(.*)"$/}static get singleRegex(){return/^!(.*)$/}search(t){const i=t.indexOf(this.pattern)===-1;return{isMatch:i,score:i?0:1,indices:[0,t.length-1]}}}class Nd extends xi{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 Vd extends xi{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 Ud extends xi{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 Wd extends xi{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 Nl extends xi{constructor(t,{location:e=j.location,threshold:i=j.threshold,distance:s=j.distance,includeMatches:r=j.includeMatches,findAllMatches:n=j.findAllMatches,minMatchCharLength:a=j.minMatchCharLength,isCaseSensitive:l=j.isCaseSensitive,ignoreLocation:c=j.ignoreLocation}={}){super(t),this._bitapSearch=new Hl(t,{location:e,threshold:i,distance:s,includeMatches:r,findAllMatches:n,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c})}static get type(){return"fuzzy"}static get multiRegex(){return/^"(.*)"$/}static get singleRegex(){return/^(.*)$/}search(t){return this._bitapSearch.searchIn(t)}}class Vl extends xi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const s=[],r=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+r,s.push([i,e-1]);const n=!!s.length;return{isMatch:n,score:n?0:1,indices:s}}}const Xo=[zd,Vl,Nd,Vd,Wd,Ud,Hd,Nl],ka=Xo.length,Gd=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,Yd="|";function Xd(o,t={}){return o.split(Yd).map(e=>{let i=e.trim().split(Gd).filter(r=>r&&!!r.trim()),s=[];for(let r=0,n=i.length;r<n;r+=1){const a=i[r];let l=!1,c=-1;for(;!l&&++c<ka;){const h=Xo[c];let d=h.isMultiMatch(a);d&&(s.push(new h(d,t)),l=!0)}if(!l)for(c=-1;++c<ka;){const h=Xo[c];let d=h.isSingleMatch(a);if(d){s.push(new h(d,t));break}}}return s})}const qd=new Set([Nl.type,Vl.type]);class Kd{constructor(t,{isCaseSensitive:e=j.isCaseSensitive,includeMatches:i=j.includeMatches,minMatchCharLength:s=j.minMatchCharLength,ignoreLocation:r=j.ignoreLocation,findAllMatches:n=j.findAllMatches,location:a=j.location,threshold:l=j.threshold,distance:c=j.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:s,findAllMatches:n,ignoreLocation:r,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=Xd(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,n=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];n.length=0,r=0;for(let d=0,u=h.length;d<u;d+=1){const g=h[d],{isMatch:p,indices:f,score:b}=g.search(t);if(p){if(r+=1,a+=b,i){const m=g.constructor.type;qd.has(m)?n=[...n,...f]:n.push(f)}}else{a=0,r=0,n.length=0;break}}if(r){let d={isMatch:!0,score:a/r};return i&&(d.indices=n),d}}return{isMatch:!1,score:1}}}const qo=[];function Zd(...o){qo.push(...o)}function Ko(o,t){for(let e=0,i=qo.length;e<i;e+=1){let s=qo[e];if(s.condition(o,t))return new s(o,t)}return new Hl(o,t)}const $r={AND:"$and",OR:"$or"},Zo={PATH:"$path",PATTERN:"$val"},Jo=o=>!!(o[$r.AND]||o[$r.OR]),Jd=o=>!!o[Zo.PATH],Qd=o=>!ei(o)&&$l(o)&&!Jo(o),Oa=o=>({[$r.AND]:Object.keys(o).map(t=>({[t]:o[t]}))});function Ul(o,t,{auto:e=!0}={}){const i=s=>{let r=Object.keys(s);const n=Jd(s);if(!n&&r.length>1&&!Jo(s))return i(Oa(s));if(Qd(s)){const l=n?s[Zo.PATH]:r[0],c=n?s[Zo.PATTERN]:s[l];if(!Fe(c))throw new Error(Sd(l));const h={keyId:Yo(l),pattern:c};return e&&(h.searcher=Ko(c,t)),h}let a={children:[],operator:r[0]};return r.forEach(l=>{const c=s[l];ei(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return Jo(o)||(o=Oa(o)),i(o)}function tu(o,{ignoreFieldNorm:t=j.ignoreFieldNorm}){o.forEach(e=>{let i=1;e.matches.forEach(({key:s,norm:r,score:n})=>{const a=s?s.weight:null;i*=Math.pow(n===0&&a?Number.EPSILON:n,(a||1)*(t?1:r))}),e.score=i})}function eu(o,t){const e=o.matches;t.matches=[],de(e)&&e.forEach(i=>{if(!de(i.indices)||!i.indices.length)return;const{indices:s,value:r}=i;let n={indices:s,value:r};i.key&&(n.key=i.key.src),i.idx>-1&&(n.refIndex=i.idx),t.matches.push(n)})}function iu(o,t){t.score=o.score}function su(o,t,{includeMatches:e=j.includeMatches,includeScore:i=j.includeScore}={}){const s=[];return e&&s.push(eu),i&&s.push(iu),o.map(r=>{const{idx:n}=r,a={item:t[n],refIndex:n};return s.length&&s.forEach(l=>{l(r,a)}),a})}class ns{constructor(t,e={},i){this.options=qi(qi({},j),e),this.options.useExtendedSearch,this._keyStore=new Od(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof wn))throw new Error(Cd);this._myIndex=e||zl(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight})}add(t){de(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:n,ignoreFieldNorm:a}=this.options;let l=Fe(t)?Fe(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return tu(l,{ignoreFieldNorm:a}),r&&l.sort(n),jl(e)&&e>-1&&(l=l.slice(0,e)),su(l,this._docs,{includeMatches:i,includeScore:s})}_searchStringList(t){const e=Ko(t,this.options),{records:i}=this._myIndex,s=[];return i.forEach(({v:r,i:n,n:a})=>{if(!de(r))return;const{isMatch:l,score:c,indices:h}=e.searchIn(r);l&&s.push({item:r,idx:n,matches:[{score:c,value:r,norm:a,indices:h}]})}),s}_searchLogical(t){const e=Ul(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:d,searcher:u}=a,g=this._findMatches({key:this._keyStore.get(d),value:this._myIndex.getValueForItemAtKeyId(l,d),searcher:u});return g&&g.length?[{idx:c,item:l,matches:g}]:[]}const h=[];for(let d=0,u=a.children.length;d<u;d+=1){const g=a.children[d],p=i(g,l,c);if(p.length)h.push(...p);else if(a.operator===$r.AND)return[]}return h},s=this._myIndex.records,r={},n=[];return s.forEach(({$:a,i:l})=>{if(de(a)){let c=i(e,a,l);c.length&&(r[l]||(r[l]={idx:l,item:a,matches:[]},n.push(r[l])),c.forEach(({matches:h})=>{r[l].matches.push(...h)}))}}),n}_searchObjectList(t){const e=Ko(t,this.options),{keys:i,records:s}=this._myIndex,r=[];return s.forEach(({$:n,i:a})=>{if(!de(n))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:n[h],searcher:e}))}),l.length&&r.push({idx:a,item:n,matches:l})}),r}_findMatches({key:t,value:e,searcher:i}){if(!de(e))return[];let s=[];if(ei(e))e.forEach(({v:r,i:n,n:a})=>{if(!de(r))return;const{isMatch:l,score:c,indices:h}=i.searchIn(r);l&&s.push({score:c,key:t,value:r,idx:n,norm:a,indices:h})});else{const{v:r,n}=e,{isMatch:a,score:l,indices:c}=i.searchIn(r);a&&s.push({score:l,key:t,value:r,norm:n,indices:c})}return s}}ns.version="7.0.0";ns.createIndex=zl;ns.parseIndex=jd;ns.config=j;ns.parseQuery=Ul;Zd(Kd);var ru=function(){function o(t){this._haystack=[],this._fuseOptions=te(te({},t.fuseOptions),{keys:Bh([],t.searchFields),includeMatches:!0})}return o.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},o.prototype.reset=function(){this._haystack=[],this._fuse=void 0},o.prototype.isEmptyIndex=function(){return!this._haystack.length},o.prototype.search=function(t){this._fuse||(this._fuse=new ns(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,s){return{item:i.item,score:i.score||0,rank:s+1}})},o}();function ou(o){return new ru(o)}var nu=function(o){for(var t in o)if(Object.prototype.hasOwnProperty.call(o,t))return!1;return!0},Oo=function(o,t,e){var i=o.dataset,s=t.customProperties,r=t.labelClass,n=t.labelDescription;r&&(i.labelClass=eo(r).join(" ")),n&&(i.labelDescription=n),e&&s&&(typeof s=="string"?i.customProperties=s:typeof s=="object"&&!nu(s)&&(i.customProperties=JSON.stringify(s)))},Pa=function(o,t,e){var i=t&&o.querySelector("label[for='".concat(t,"']")),s=i&&i.innerText;s&&e.setAttribute("aria-label",s)},au={containerOuter:function(o,t,e,i,s,r,n){var a=o.classNames.containerOuter,l=document.createElement("div");return z(l,a),l.dataset.type=r,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",s?"combobox":"listbox"),s?l.setAttribute("aria-autocomplete","list"):n||Pa(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(o){var t=o.classNames.containerInner,e=document.createElement("div");return z(e,t),e},itemList:function(o,t){var e=o.searchEnabled,i=o.classNames,s=i.list,r=i.listSingle,n=i.listItems,a=document.createElement("div");return z(a,s),z(a,t?r:n),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(o,t){var e=o.allowHTML,i=o.classNames.placeholder,s=document.createElement("div");return z(s,i),Ge(s,e,t),s},item:function(o,t,e){var i=o.allowHTML,s=o.removeItemButtonAlignLeft,r=o.removeItemIconText,n=o.removeItemLabelText,a=o.classNames,l=a.item,c=a.button,h=a.highlightedState,d=a.itemSelectable,u=a.placeholder,g=Mi(t.value),p=document.createElement("div");if(z(p,l),t.labelClass){var f=document.createElement("span");Ge(f,i,t.label),z(f,t.labelClass),p.appendChild(f)}else Ge(p,i,t.label);if(p.dataset.item="",p.dataset.id=t.id,p.dataset.value=g,Oo(p,t,!0),(t.disabled||this.containerOuter.isDisabled)&&p.setAttribute("aria-disabled","true"),this._isSelectElement&&(p.setAttribute("aria-selected","true"),p.setAttribute("role","option")),t.placeholder&&(z(p,u),p.dataset.placeholder=""),z(p,t.highlighted?h:d),e){t.disabled&&Ie(p,d),p.dataset.deletable="";var b=document.createElement("button");b.type="button",z(b,c),Ge(b,!0,Ps(r,t.value));var m=Ps(n,t.value);m&&b.setAttribute("aria-label",m),b.dataset.button="",s?p.insertAdjacentElement("afterbegin",b):p.appendChild(b)}return p},choiceList:function(o,t){var e=o.classNames.list,i=document.createElement("div");return z(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(o,t){var e=o.allowHTML,i=o.classNames,s=i.group,r=i.groupHeading,n=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Mi(l),d=document.createElement("div");z(d,s),c&&z(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 z(u,r),Ge(u,e,l||""),d.appendChild(u),d},choice:function(o,t,e,i){var s=o.allowHTML,r=o.classNames,n=r.item,a=r.itemChoice,l=r.itemSelectable,c=r.selectedState,h=r.itemDisabled,d=r.description,u=r.placeholder,g=t.label,p=Mi(t.value),f=document.createElement("div");f.id=t.elementId,z(f,n),z(f,a),i&&typeof g=="string"&&(g=xn(s,g),g+=" (".concat(i,")"),g={trusted:g});var b=f;if(t.labelClass){var m=document.createElement("span");Ge(m,s,g),z(m,t.labelClass),b=m,f.appendChild(m)}else Ge(f,s,g);if(t.labelDescription){var y="".concat(t.elementId,"-description");b.setAttribute("aria-describedby",y);var w=document.createElement("span");Ge(w,s,t.labelDescription),w.id=y,z(w,d),f.appendChild(w)}return t.selected&&z(f,c),t.placeholder&&z(f,u),f.setAttribute("role",t.group?"treeitem":"option"),f.dataset.choice="",f.dataset.id=t.id,f.dataset.value=p,e&&(f.dataset.selectText=e),t.group&&(f.dataset.groupId="".concat(t.group.id)),Oo(f,t,!1),t.disabled?(z(f,h),f.dataset.choiceDisabled="",f.setAttribute("aria-disabled","true")):(z(f,l),f.dataset.choiceSelectable=""),f},input:function(o,t){var e=o.classNames,i=e.input,s=e.inputCloned,r=o.labelId,n=document.createElement("input");return n.type="search",z(n,i),z(n,s),n.autocomplete="off",n.autocapitalize="off",n.spellcheck=!1,n.setAttribute("role","textbox"),n.setAttribute("aria-autocomplete","list"),t?n.setAttribute("aria-label",t):r||Pa(this._docRoot,this.passedElement.element.id,n),n},dropdown:function(o){var t=o.classNames,e=t.list,i=t.listDropdown,s=document.createElement("div");return z(s,e),z(s,i),s.setAttribute("aria-expanded","false"),s},notice:function(o,t,e){var i=o.classNames,s=i.item,r=i.itemChoice,n=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Ht.generic);var h=document.createElement("div");switch(Ge(h,!0,t),z(h,s),z(h,r),z(h,c),e){case Ht.addChoice:z(h,n);break;case Ht.noResults:z(h,a);break;case Ht.noChoices:z(h,l);break}return e===Ht.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(o){var t=Mi(o.label),e=new Option(t,o.value,!1,o.selected);return Oo(e,o,!0),e.disabled=o.disabled,o.selected&&e.setAttribute("selected",""),e}},lu="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,cu={},Po=function(o){if(o)return o.dataset.id?parseInt(o.dataset.id,10):void 0},bs="[data-choice-selectable]",Wl=function(){function o(t,e){t===void 0&&(t="[data-choice]"),e===void 0&&(e={});var i=this;this.initialisedOK=void 0,this._hasNonChoicePlaceholder=!1,this._lastAddedChoiceId=0,this._lastAddedGroupId=0;var s=o.defaults;this.config=te(te(te({},s.allOptions),s.options),e),Rh.forEach(function(m){i.config[m]=te(te(te({},s.allOptions[m]),s.options[m]),e[m])});var r=this.config;r.silent||this._validateConfig();var n=r.shadowRoot||document.documentElement;this._docRoot=n;var a=typeof t=="string"?n.querySelector(t):t;if(!a||typeof a!="object"||!(ad(a)||Fl(a)))throw TypeError(!a&&typeof t=="string"?"Selector ".concat(t," failed to find an element"):"Expected one of the following types text|select-one|select-multiple");var l=a.type,c=l===pi.Text;(c||r.maxItemCount!==1)&&(r.singleModeForMultiSelect=!1),r.singleModeForMultiSelect&&(l=pi.SelectMultiple);var h=l===pi.SelectOne,d=l===pi.SelectMultiple,u=h||d;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=d,this._isSelectElement=h||d,this._canAddUserChoices=c&&r.addItems||u&&r.addChoices,typeof r.renderSelectedChoices!="boolean"&&(r.renderSelectedChoices=r.renderSelectedChoices==="always"||h),r.closeDropdownOnSelect==="auto"?r.closeDropdownOnSelect=c||h||r.singleModeForMultiSelect:r.closeDropdownOnSelect=Ss(r.closeDropdownOnSelect),r.placeholder&&(r.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,r.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var g=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);r.addItemFilter=g.test.bind(g)}if(this._isTextElement)this.passedElement=new nd({element:a,classNames:r.classNames});else{var p=a;this.passedElement=new hd({element:p,classNames:r.classNames,template:function(m){return i._templates.option(m)},extractPlaceholder:r.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new fd(r),this._currentValue="",r.searchEnabled=!c&&r.searchEnabled||d,this._canSearch=r.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=Gh(a,"choices-"),this._direction=a.dir,!this._direction){var f=window.getComputedStyle(a).direction,b=window.getComputedStyle(document.documentElement).direction;f!==b&&(this._direction=f)}if(this._idNames={itemChoice:"item-choice"},this._templates=s.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){r.silent||console.warn("Trying to initialise Choices on element already initialised",{element:t}),this.initialised=!0,this.initialisedOK=!1;return}this.init(),this._initialItems=this._store.items.map(function(m){return m.value})}return Object.defineProperty(o,"defaults",{get:function(){return Object.preventExtensions({get options(){return cu},get allOptions(){return ya},get templates(){return au}})},enumerable:!1,configurable:!0}),o.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=ou(this.config),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 t=this.config.callbackOnInit;typeof t=="function"&&t.call(this)}},o.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=o.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},o.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},o.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},o.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(tr(i,!0)),e&&this.passedElement.triggerEvent(Qt.highlightItem,this._getChoiceForOutput(i)),this)},o.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(s){return s.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(tr(i,!1)),e&&this.passedElement.triggerEvent(Qt.unhighlightItem,this._getChoiceForOutput(i)),this)},o.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(tr(e,!0)),t.passedElement.triggerEvent(Qt.highlightItem,t._getChoiceForOutput(e)))})}),this},o.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(tr(e,!1)),t.passedElement.triggerEvent(Qt.highlightItem,t._getChoiceForOutput(e)))})}),this},o.prototype.removeActiveItemsByValue=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){return i.value===t}).forEach(function(i){return e._removeItem(i)})}),this},o.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var s=i.id;return s!==t}).forEach(function(i){return e._removeItem(i)})}),this},o.prototype.removeHighlightedItems=function(t){var e=this;return t===void 0&&(t=!1),this._store.withTxn(function(){e._store.highlightedActiveItems.forEach(function(i){e._removeItem(i),t&&e._triggerChange(i.value)})}),this},o.prototype.showDropdown=function(t){var e=this;return this.dropdown.isActive?this:(t===void 0&&(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(Qt.showDropdown)}),this)},o.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(Qt.hideDropdown)}),this):this},o.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(s){return t?s.value:e._getChoiceForOutput(s)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},o.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Me(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},o.prototype.setChoiceByValue=function(t){var e=this;return this.initialisedOK?this._isTextElement?this:(this._store.withTxn(function(){var i=Array.isArray(t)?t:[t];i.forEach(function(s){return e._findAndSelectChoiceByValue(s)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},o.prototype.setChoices=function(t,e,i,s,r){var n=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),s===void 0&&(s=!1),r===void 0&&(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(typeof e!="string"||!e)throw new TypeError("value parameter must be a name of 'value' field in passed objects");if(s&&this.clearChoices(),typeof t=="function"){var a=t(this);if(typeof Promise=="function"&&a instanceof Promise)return new Promise(function(l){return requestAnimationFrame(l)}).then(function(){return n._handleLoadingState(!0)}).then(function(){return a}).then(function(l){return n.setChoices(l,e,i,s)}).catch(function(l){n.config.silent||console.error(l)}).then(function(){return n._handleLoadingState(!1)}).then(function(){return n});if(!Array.isArray(a))throw new TypeError(".setChoices first argument function must return either array of choices or Promise, got: ".concat(typeof a));return this.setChoices(a,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&&(n._isSearching=!1);var l=e==="value",c=i==="label";t.forEach(function(h){if("choices"in h){var d=h;c||(d=te(te({},d),{label:d[i]})),n._addGroup(Me(d,!0))}else{var u=h;(!c||!l)&&(u=te(te({},u),{value:u[e],label:u[i]})),n._addChoice(Me(u,!1))}}),n.unhighlightAll()}),this._searcher.reset(),this},o.prototype.refresh=function(t,e,i){var s=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var r=s.passedElement.optionsAsChoices(),n={};i||s._store.items.forEach(function(l){l.id&&l.active&&l.selected&&!l.disabled&&(n[l.value]=!0)}),s.clearStore(!1);var a=function(l){i?s._store.dispatch(fa(l)):n[l.value]&&(l.selected=!0)};r.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),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)},o.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(ga(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(Qt.removeItem,this._getChoiceForOutput(e)),this):this},o.prototype.clearChoices=function(){var t=this;return this._store.withTxn(function(){t._store.choices.forEach(function(e){e.selected||t._store.dispatch(ga(e))})}),this._searcher.reset(),this},o.prototype.clearStore=function(t){return t===void 0&&(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},o.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},o.prototype._validateConfig=function(){var t=this.config,e=td(t,ya);e.length&&console.warn("Unknown config option(s) passed",e.join(", ")),t.allowHTML&&t.allowHtmlUserInput&&(t.addItems&&console.warn("Warning: allowHTML/allowHtmlUserInput/addItems all being true is strongly not recommended and may lead to XSS attacks"),t.addChoices&&console.warn("Warning: allowHTML/allowHtmlUserInput/addChoices all being true is strongly not recommended and may lead to XSS attacks"))},o.prototype._render=function(t){t===void 0&&(t={choices:!0,groups:!0,items:!0}),!this._store.inTxn()&&(this._isSelectElement&&(t.choices||t.groups)&&this._renderChoices(),t.items&&this._renderItems())},o.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,s=e._isSearching,r=this._store,n=r.activeGroups,a=r.activeChoices,l=0;if(s&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(p){return!p.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),d=function(p){return p.filter(function(f){return!f.placeholder&&(s?!!f.rank:i.renderSelectedChoices||!f.selected)})},u=!1,g=function(p,f,b){s?p.sort(Jh):i.shouldSort&&p.sort(i.sorter);var m=p.length;m=!f&&l&&m>l?l:m,m--,p.every(function(y,w){var T=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,b);return y.choiceEl=T,h.appendChild(T),!y.disabled&&(s||!y.selected)&&(u=!0),w<m})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!s&&this._isSelectOneElement&&g(a.filter(function(p){return p.placeholder&&!p.group}),!1,void 0),n.length&&!s?(i.shouldSort&&n.sort(i.sorter),g(a.filter(function(p){return!p.placeholder&&!p.group}),!1,void 0),n.forEach(function(p){var f=d(p.choices);if(f.length){if(p.label){var b=p.groupEl||t._templates.choiceGroup(t.config,p);p.groupEl=b,b.remove(),h.appendChild(b)}g(f,!0,i.appendGroupInSearch&&s?p.label:void 0)}})):g(d(a),!1,void 0)),u||(this._notice||(this._notice={text:ba(s?i.noResultsText:i.noChoicesText),type:s?Ht.noResults:Ht.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),u&&this._highlightChoice()}},o.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,s=this.config,r=document.createDocumentFragment(),n=function(d){return i.querySelector('[data-item][data-id="'.concat(d.id,'"]'))},a=function(d){var u=d.itemEl;u&&u.parentElement||(u=n(d)||t._templates.item(s,d,s.removeItemButton),d.itemEl=u,r.appendChild(u))};e.forEach(a);var l=!!r.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var c=i.children.length;if(l||c>1){var h=i.querySelector(ms(s.classNames.placeholder));h&&h.remove()}else c||(l=!0,a(Me({selected:!0,value:"",label:s.placeholderValue||"",placeholder:!0},!1)))}l&&(i.append(r),s.shouldSortItems&&!this._isSelectOneElement&&(e.sort(s.sorter),e.forEach(function(d){var u=n(d);u&&(u.remove(),r.append(u))}),i.append(r))),this._isTextElement&&(this.passedElement.value=e.map(function(d){var u=d.value;return u}).join(s.delimiter))},o.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var s=this._notice;if(s&&(s.type===e&&s.text===t||s.type===Ht.addChoice&&(e===Ht.noResults||e===Ht.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},o.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(ms(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},o.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)}},o.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}},o.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(Qt.change,{value:t})},o.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var s=t&&Po(t.parentElement),r=s&&i.find(function(n){return n.id===s});r&&this._store.withTxn(function(){if(e._removeItem(r),e._triggerChange(r.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var n=e._store.choices.reverse().find(function(a){return!a.disabled&&a.placeholder});n&&(e._addItem(n),e.unhighlightAll(),n.value&&e._triggerChange(n.value))}})}},o.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.items;if(!(!s.length||!this.config.removeItems||this._isSelectOneElement)){var r=Po(t);r&&(s.forEach(function(n){n.id===r&&!n.highlighted?i.highlightItem(n):!e&&n.highlighted&&i.unhighlightItem(n)}),this.input.focus())}},o.prototype._handleChoiceAction=function(t){var e=this,i=Po(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},o.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],s=t.some(function(r){return r.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))}},o.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(n){return Me(n,!1)}),this.passedElement.value){var s=this.passedElement.value.split(i.delimiter).map(function(n){return Me(n,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(s)}this._presetChoices.forEach(function(n){n.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(n){return Me(n,!0)});var r=this.passedElement.optionsAsChoices();r&&(t=this._presetChoices).push.apply(t,r)}},o.prototype._handleLoadingState=function(t){t===void 0&&(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||"")},o.prototype._handleSearch=function(t){if(this.input.isFocussed)if(t!==null&&typeof t<"u"&&t.length>=this.config.searchFloor){var e=this.config.searchChoices?this._searchChoices(t):0;e!==null&&this.passedElement.triggerEvent(Qt.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},o.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(typeof i=="function"?i(e):i,Ht.addChoice),!1):!0},o.prototype._canCreateItem=function(t){var e=this.config,i=!0,s="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,s=Ps(e.customAddItemText,t)),i){var r=this._store.choices.find(function(n){return e.valueComparer(n.value,t)});if(this._isSelectElement){if(r)return this._displayNotice("",Ht.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&r&&(i=!1,s=Ps(e.uniqueItemText,t))}return i&&(s=Ps(e.addItemText,t)),s&&this._displayNotice(s,Ht.addChoice),i},o.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,n=r&&r.type;return n!==Ht.addChoice&&(s.length?this._clearNotice():this._displayNotice(ba(this.config.noResultsText),Ht.noResults)),this._store.dispatch(Hh(s)),s.length},o.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(Nh(!0)),this.passedElement.triggerEvent(Qt.search,{value:"",resultCount:0}))},o.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()},o.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()},o.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,s=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==zt.ESC_KEY&&e!==zt.TAB_KEY&&e!==zt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&s&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case zt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case zt.ENTER_KEY:return this._onEnterKey(t,i);case zt.ESC_KEY:return this._onEscapeKey(t,i);case zt.UP_KEY:case zt.PAGE_UP_KEY:case zt.DOWN_KEY:case zt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case zt.DELETE_KEY:case zt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},o.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},o.prototype._onInput=function(){var t=this.input.value;if(!t){this._isTextElement?this.hideDropdown(!0):this._stopSearch();return}this._canAddItems()&&(this._canSearch&&this._handleSearch(t),this._canAddUserChoices&&(this._canCreateItem(t),this._isSelectElement&&(this._highlightPosition=0,this._highlightChoice())))},o.prototype._onSelectKey=function(t,e){if((t.ctrlKey||t.metaKey)&&e){this._canSearch=!1;var i=this.config.removeItems&&!this.input.value&&this.input.element===document.activeElement;i&&this.highlightAll()}},o.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);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var n=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));if(!(n&&this._handleChoiceAction(n))){if(!r||!s){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(s,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(s))return;i._addChoice(Me(s,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(s),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},o.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},o.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var s=i===zt.DOWN_KEY||i===zt.PAGE_DOWN_KEY?1:-1,r=t.metaKey||i===zt.PAGE_DOWN_KEY||i===zt.PAGE_UP_KEY,n=void 0;if(r)s>0?n=this.dropdown.element.querySelector("".concat(bs,":last-of-type")):n=this.dropdown.element.querySelector(bs);else{var a=this.dropdown.element.querySelector(ms(this.config.classNames.highlightedState));a?n=Yh(a,bs,s):n=this.dropdown.element.querySelector(bs)}n&&(Xh(n,this.choiceList.element,s)||this.choiceList.scrollToChildElement(n,s),this._highlightChoice(n)),t.preventDefault()}},o.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},o.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},o.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var s=e===this.containerOuter.element||e===this.containerInner.element;s&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},o.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(lu&&this.choiceList.element.contains(e)){var i=this.choiceList.element.firstElementChild;this._isScrollingOnIe=this._direction==="ltr"?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()}}},o.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},o.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,s=i.element.contains(e);s?!this.dropdown.isActive&&!i.isDisabled?this._isTextElement?document.activeElement!==this.input.element&&this.input.focus():(this.showDropdown(),i.element.focus()):this._isSelectOneElement&&e!==this.input.element&&!this.dropdown.element.contains(e)&&this.hideDropdown():(i.removeFocusState(),this.hideDropdown(!0),this.unhighlightAll())},o.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);if(s){var r=e===this.input.element;this._isTextElement?r&&i.addFocusState():this._isSelectMultipleElement?r&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),r&&this.showDropdown(!0))}},o.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,s=e&&i.element.contains(e);s&&!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())},o.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)})},o.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(bs));if(e.length){var i=t,s=this.config.classNames.highlightedState,r=Array.from(this.dropdown.element.querySelectorAll(ms(s)));r.forEach(function(n){Ie(n,s),n.setAttribute("aria-selected","false")}),i?this._highlightPosition=e.indexOf(i):(e.length>this._highlightPosition?i=e[this._highlightPosition]:i=e[e.length-1],i||(i=e[0])),z(i,s),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(Qt.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},o.prototype._addItem=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(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(Uh(t)),e&&(this.passedElement.triggerEvent(Qt.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(Qt.choice,this._getChoiceForOutput(t)))},o.prototype._removeItem=function(t){if(t.id){this._store.dispatch(fa(t));var e=this._notice;e&&e.type===Ht.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(Qt.removeItem,this._getChoiceForOutput(t))}},o.prototype._addChoice=function(t,e,i){if(e===void 0&&(e=!0),i===void 0&&(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(a){return s.valueComparer(a.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,n=s.appendValue;r&&(t.value=r+t.value),n&&(t.value+=n.toString()),(r||n)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(zh(t)),t.selected&&this._addItem(t,e,i)}},o.prototype._addGroup=function(t,e){var i=this;if(e===void 0&&(e=!0),t.id)throw new TypeError("Can not re-add a group which has already been added");this._store.dispatch(Vh(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)}))},o.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,qh,xn,eo));var s={};Object.keys(this._templates).forEach(function(r){r in i?s[r]=i[r].bind(t):s[r]=t._templates[r].bind(t)}),this._templates=s},o.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,s=e._isSelectOneElement,r=i.position,n=i.classNames,a=this._elementType;this.containerOuter=new va({element:t.containerOuter(i,this._direction,this._isSelectElement,s,i.searchEnabled,a,i.labelId),classNames:n,type:a,position:r}),this.containerInner=new va({element:t.containerInner(i),classNames:n,type:a,position:r}),this.input=new rd({element:t.input(i,this._placeholderValue),classNames:n,type:a,preventPaste:!i.paste}),this.choiceList=new _a({element:t.choiceList(i,s)}),this.itemList=new _a({element:t.itemList(i,s)}),this.dropdown=new sd({element:t.dropdown(i),classNames:n,type:a})},o.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},o.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()},o.prototype._addPredefinedChoices=function(t,e,i){var s=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var r=t.findIndex(function(n){return n.selected})===-1;r&&t.some(function(n){return n.disabled||"choices"in n?!1:(n.selected=!0,!0)})}t.forEach(function(n){"choices"in n?s._isSelectElement&&s._addGroup(n,i):s._addChoice(n,i)})},o.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var s=this._store.choices.find(function(r){return i.config.valueComparer(r.value,t)});return s&&!s.disabled&&!s.selected?(this._addItem(s,!0,e),!0):!1},o.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},o.prototype._warnChoicesInitFailed=function(t){if(!this.config.silent)if(this.initialised){if(!this.initialisedOK)throw new TypeError("".concat(t," called for an element which has multiple instances of Choices initialised on it"))}else throw new TypeError("".concat(t," called on a non-initialised instance of Choices"))},o.version="11.0.3",o}();const Gl='.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 zi{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const s=i.target;(this.slotNames.includes("[default]")&&!s.name||s.name&&this.slotNames.includes(s.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&&((e=t.textContent)==null?void 0:e.trim())!=="")return!0;if(t.nodeType===t.ELEMENT_NODE){const i=t;if(i.tagName.toLowerCase()==="pbo-visually-hidden")return!1;if(!i.hasAttribute("slot"))return!0}return!1})}hasNamedSlot(t){return this.host.querySelector(`:scope > [slot="${t}"]`)!==null}test(t){return t==="[default]"?this.hasDefaultSlot():this.hasNamedSlot(t)}hostConnected(){this.host.shadowRoot.addEventListener("slotchange",this.handleSlotChange)}hostDisconnected(){this.host.shadowRoot.removeEventListener("slotchange",this.handleSlotChange)}}/**
163
163
  * @license
164
164
  * Copyright 2017 Google LLC
165
165
  * SPDX-License-Identifier: BSD-3-Clause
166
- */const li={ATTRIBUTE:1,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},io=o=>(...t)=>({_$litDirective$:o,values:t});let so=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)}};/**
166
+ */const hi={ATTRIBUTE:1,PROPERTY:3,BOOLEAN_ATTRIBUTE:4},io=o=>(...t)=>({_$litDirective$:o,values:t});let so=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)}};/**
167
167
  * @license
168
168
  * Copyright 2018 Google LLC
169
169
  * SPDX-License-Identifier: BSD-3-Clause
170
- */const pe=io(class extends so{constructor(o){var t;if(super(o),o.type!==li.ATTRIBUTE||o.name!=="class"||((t=o.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(o){return" "+Object.keys(o).filter(t=>o[t]).join(" ")+" "}update(o,[t]){var i,s;if(this.st===void 0){this.st=new Set,o.strings!==void 0&&(this.nt=new Set(o.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.nt)!=null&&i.has(r))&&this.st.add(r);return this.render(t)}const e=o.element.classList;for(const r of this.st)r in t||(e.remove(r),this.st.delete(r));for(const r in t){const n=!!t[r];n===this.st.has(r)||(s=this.nt)!=null&&s.has(r)||(n?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return ve}}),Us=Q`
170
+ */const pe=io(class extends so{constructor(o){var t;if(super(o),o.type!==hi.ATTRIBUTE||o.name!=="class"||((t=o.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(o){return" "+Object.keys(o).filter(t=>o[t]).join(" ")+" "}update(o,[t]){var i,s;if(this.st===void 0){this.st=new Set,o.strings!==void 0&&(this.nt=new Set(o.strings.join(" ").split(/\s/).filter(r=>r!=="")));for(const r in t)t[r]&&!((i=this.nt)!=null&&i.has(r))&&this.st.add(r);return this.render(t)}const e=o.element.classList;for(const r of this.st)r in t||(e.remove(r),this.st.delete(r));for(const r in t){const n=!!t[r];n===this.st.has(r)||(s=this.nt)!=null&&s.has(r)||(n?(e.add(r),this.st.add(r)):(e.remove(r),this.st.delete(r)))}return _e}}),Ws=Q`
171
171
  .form-control .form-control__label {
172
172
  display: none;
173
173
  }
@@ -223,7 +223,7 @@
223
223
  .form-control--has-help-text.form-control--radio-group .form-control__help-text {
224
224
  margin-top: var(--pbo-spacing-2x);
225
225
  }
226
- `;function N(o,t){const e={waitUntilFirstUpdate:!1,...t};return function(i,s){const r=Array.isArray(o)?o:[o],{update:n}=i;i.update=function(a){r.forEach(l=>{const c=l;if(a.has(c)){const h=a.get(c),d=this[c];h!==d&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[s](h,d)}}),n.call(this,a)}}}var hu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,Hi=(o,t,e,i)=>{for(var s=i>1?void 0:i?du(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&hu(t,e,s),s};let je=class extends Li{constructor(){super(...arguments),this.hasSlotController=new zi(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="",this._handleDocumentClick=o=>{var e;const t=o.composedPath();this&&!t.includes(this)&&((e=this._choices)==null||e.hideDropdown())}}get value(){var o;return(o=this._choices)==null?void 0:o.getValue().value}handleDisabledChanged(){var o;this._choices&&this.disabled?this._choices.disable():(o=this._choices)==null||o.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var o;(o=this._choices)==null||o.destroy(),this._choices=new Wl(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:e===0})),placeholder:!1,shouldSortItems:!1,itemSelectText:"",callbackOnCreateTemplates:function(t,e,i){return{item:({classNames:s},r)=>{var a;const n=[i(s.item).join(" "),i(r.highlighted?s.highlightedState:s.itemSelectable).join(" ")].join(" ");return t(`
226
+ `;function V(o,t){const e={waitUntilFirstUpdate:!1,...t};return function(i,s){const r=Array.isArray(o)?o:[o],{update:n}=i;i.update=function(a){r.forEach(l=>{const c=l;if(a.has(c)){const h=a.get(c),d=this[c];h!==d&&(!e.waitUntilFirstUpdate||this.hasUpdated)&&this[s](h,d)}}),n.call(this,a)}}}class gt extends Qi{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}var hu=Object.defineProperty,du=Object.getOwnPropertyDescriptor,Hi=(o,t,e,i)=>{for(var s=i>1?void 0:i?du(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&hu(t,e,s),s};let $e=class extends gt{constructor(){super(...arguments),this.hasSlotController=new zi(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="",this._handleDocumentClick=o=>{var e;const t=o.composedPath();this&&!t.includes(this)&&((e=this._choices)==null||e.hideDropdown())}}get value(){var o;return(o=this._choices)==null?void 0:o.getValue().value}handleDisabledChanged(){var o;this._choices&&this.disabled?this._choices.disable():(o=this._choices)==null||o.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var o;(o=this._choices)==null||o.destroy(),this._choices=new Wl(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:e===0})),placeholder:!1,shouldSortItems:!1,itemSelectText:"",callbackOnCreateTemplates:function(t,e,i){return{item:({classNames:s},r)=>{var a;const n=[i(s.item).join(" "),i(r.highlighted?s.highlightedState:s.itemSelectable).join(" ")].join(" ");return t(`
227
227
  <div
228
228
  class="${n}"
229
229
  data-item
@@ -246,7 +246,7 @@
246
246
  >
247
247
  ${r.label}
248
248
  </div>
249
- `)}}}}),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 o=this.hasSlotController.test("label"),t=this.label?!0:!!o;return L` <div
249
+ `)}}}}),this.choiceEl.addEventListener("change",t=>{const e=t.target;this.emit("pbo-change",{detail:{value:e.value}})})}render(){const o=this.hasSlotController.test("label"),t=this.label?!0:!!o;return L` <div
250
250
  class=${pe({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":t})}
251
251
  >
252
252
  <label
@@ -258,7 +258,7 @@
258
258
  <slot name="label">${this.label}</slot>
259
259
  </label>
260
260
  </div>
261
- <select part="base" class="js-choice"></select>`}};je.styles=[pt,$h,Us,Zr(Gl)];Hi([C({type:Array})],je.prototype,"fonts",2);Hi([C({type:Boolean,reflect:!0})],je.prototype,"disabled",2);Hi([C()],je.prototype,"size",2);Hi([C()],je.prototype,"label",2);Hi([V(".js-choice")],je.prototype,"choiceEl",2);Hi([N("disabled",{waitUntilFirstUpdate:!0})],je.prototype,"handleDisabledChanged",1);je=Hi([ht("pbo-font-selector")],je);const Yl=Q`
261
+ <select part="base" class="js-choice"></select>`}};$e.styles=[pt,$h,Ws,Zr(Gl)];Hi([C({type:Array})],$e.prototype,"fonts",2);Hi([C({type:Boolean,reflect:!0})],$e.prototype,"disabled",2);Hi([C()],$e.prototype,"size",2);Hi([C()],$e.prototype,"label",2);Hi([H(".js-choice")],$e.prototype,"choiceEl",2);Hi([V("disabled",{waitUntilFirstUpdate:!0})],$e.prototype,"handleDisabledChanged",1);$e=Hi([dt("pbo-font-selector")],$e);const Yl=Q`
262
262
  :host {
263
263
  display: inline-block;
264
264
  position: relative;
@@ -921,11 +921,11 @@
921
921
  * Copyright 2020 Google LLC
922
922
  * SPDX-License-Identifier: BSD-3-Clause
923
923
  */const Xl=Symbol.for(""),uu=o=>{if((o==null?void 0:o.r)===Xl)return o==null?void 0:o._$litStatic$},Da=(o,...t)=>({_$litStatic$:t.reduce((e,i,s)=>e+(r=>{if(r._$litStatic$!==void 0)return r._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${r}. Use 'unsafeStatic' to pass non-literal values, but
924
- take care to ensure page security.`)})(i)+o[s+1],o[0]),r:Xl}),Aa=new Map,pu=o=>(t,...e)=>{const i=e.length;let s,r;const n=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(r=e[c],(s=uu(r))!==void 0);)l+=s+t[++c],h=!0;c!==i&&a.push(r),n.push(l),c++}if(c===i&&n.push(t[i]),h){const d=n.join("$$lit$$");(t=Aa.get(d))===void 0&&(n.raw=n,Aa.set(d,t=n)),e=a}return o(t,...e)},Ma=pu(L);class yt extends Li{emit(t,e){const i=new CustomEvent(t,{bubbles:!0,cancelable:!0,composed:!0,detail:{},...e});return this.dispatchEvent(i),i}}const bs=new WeakMap,vs=new WeakMap,_s=new WeakMap,Do=new WeakSet,ir=new WeakMap;class Cn{constructor(t,e){this.handleFormData=i=>{const s=this.options.disabled(this.host),r=this.options.name(this.host),n=this.options.value(this.host),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!s&&!a&&typeof r=="string"&&r.length>0&&typeof n<"u"&&(Array.isArray(n)?n.forEach(l=>{i.formData.append(r,l.toString())}):i.formData.append(r,n.toString()))},this.handleFormSubmit=i=>{var n;const s=this.options.disabled(this.host),r=this.options.reportValidity;this.form&&!this.form.noValidate&&((n=bs.get(this.form))==null||n.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!s&&!r(this.host)&&(i==null||i.preventDefault(),i==null||i.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),ir.set(this.host,[])},this.handleInteraction=i=>{const s=ir.get(this.host);s.includes(i.type)||s.push(i.type),s.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const i=this.form.querySelectorAll("*");for(const s of i)if(typeof s.checkValidity=="function"&&!s.checkValidity())return!1}return!0},this.doAction=(i,s)=>{if(this.form){const r=document.createElement("button");r.type=i,r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.clipPath="inset(50%)",r.style.overflow="hidden",r.style.whiteSpace="nowrap",s&&(r.name=s.name,r.value=s.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(n=>{s.hasAttribute(n)&&r.setAttribute(n,s.getAttribute(n))})),this.form.append(r),r.click(),r.remove()}},(this.host=t).addController(this),this.options={form:i=>{const s=i.form;if(s){const n=i.getRootNode().querySelector(`#${s}`);if(n)return n}return i.closest("form")},name:i=>i.name,value:i=>i.value,defaultValue:i=>i.defaultValue,disabled:i=>i.disabled??!1,reportValidity:i=>typeof i.reportValidity=="function"?i.reportValidity():!0,checkValidity:i=>typeof i.checkValidity=="function"?i.checkValidity():!0,setValue:(i,s)=>i.value=s,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),ir.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),ir.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,bs.has(this.form)?bs.get(this.form).add(this.host):bs.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),vs.has(this.form)||(vs.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),_s.has(this.form)||(_s.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=bs.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),vs.has(this.form)&&(this.form.reportValidity=vs.get(this.form),vs.delete(this.form)),_s.has(this.form)&&(this.form.checkValidity=_s.get(this.form),_s.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(typeof e.reportValidity=="function"&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){e?Do.add(t):Do.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=!!Do.has(e),s=!!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)||t==null||t.preventDefault()}}const ro=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),gu=Object.freeze({...ro,valid:!1,valueMissing:!1}),fu=Object.freeze({...ro,valid:!1,customError:!0});/**
924
+ take care to ensure page security.`)})(i)+o[s+1],o[0]),r:Xl}),Aa=new Map,pu=o=>(t,...e)=>{const i=e.length;let s,r;const n=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(r=e[c],(s=uu(r))!==void 0);)l+=s+t[++c],h=!0;c!==i&&a.push(r),n.push(l),c++}if(c===i&&n.push(t[i]),h){const d=n.join("$$lit$$");(t=Aa.get(d))===void 0&&(n.raw=n,Aa.set(d,t=n)),e=a}return o(t,...e)},Ma=pu(L),vs=new WeakMap,_s=new WeakMap,ys=new WeakMap,Do=new WeakSet,ir=new WeakMap;class Cn{constructor(t,e){this.handleFormData=i=>{const s=this.options.disabled(this.host),r=this.options.name(this.host),n=this.options.value(this.host),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!s&&!a&&typeof r=="string"&&r.length>0&&typeof n<"u"&&(Array.isArray(n)?n.forEach(l=>{i.formData.append(r,l.toString())}):i.formData.append(r,n.toString()))},this.handleFormSubmit=i=>{var n;const s=this.options.disabled(this.host),r=this.options.reportValidity;this.form&&!this.form.noValidate&&((n=vs.get(this.form))==null||n.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!s&&!r(this.host)&&(i==null||i.preventDefault(),i==null||i.stopImmediatePropagation())},this.handleFormReset=()=>{this.options.setValue(this.host,this.options.defaultValue(this.host)),this.setUserInteracted(this.host,!1),ir.set(this.host,[])},this.handleInteraction=i=>{const s=ir.get(this.host);s.includes(i.type)||s.push(i.type),s.length===this.options.assumeInteractionOn.length&&this.setUserInteracted(this.host,!0)},this.checkFormValidity=()=>{if(this.form&&!this.form.noValidate){const i=this.form.querySelectorAll("*");for(const s of i)if(typeof s.checkValidity=="function"&&!s.checkValidity())return!1}return!0},this.doAction=(i,s)=>{if(this.form){const r=document.createElement("button");r.type=i,r.style.position="absolute",r.style.width="0",r.style.height="0",r.style.clipPath="inset(50%)",r.style.overflow="hidden",r.style.whiteSpace="nowrap",s&&(r.name=s.name,r.value=s.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(n=>{s.hasAttribute(n)&&r.setAttribute(n,s.getAttribute(n))})),this.form.append(r),r.click(),r.remove()}},(this.host=t).addController(this),this.options={form:i=>{const s=i.form;if(s){const n=i.getRootNode().querySelector(`#${s}`);if(n)return n}return i.closest("form")},name:i=>i.name,value:i=>i.value,defaultValue:i=>i.defaultValue,disabled:i=>i.disabled??!1,reportValidity:i=>typeof i.reportValidity=="function"?i.reportValidity():!0,checkValidity:i=>typeof i.checkValidity=="function"?i.checkValidity():!0,setValue:(i,s)=>i.value=s,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),ir.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),ir.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,vs.has(this.form)?vs.get(this.form).add(this.host):vs.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),_s.has(this.form)||(_s.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),ys.has(this.form)||(ys.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=vs.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),_s.has(this.form)&&(this.form.reportValidity=_s.get(this.form),_s.delete(this.form)),ys.has(this.form)&&(this.form.checkValidity=ys.get(this.form),ys.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(typeof e.reportValidity=="function"&&!e.reportValidity())return!1}return!0}setUserInteracted(t,e){e?Do.add(t):Do.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=!!Do.has(e),s=!!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)||t==null||t.preventDefault()}}const ro=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),gu=Object.freeze({...ro,valid:!1,valueMissing:!1}),fu=Object.freeze({...ro,valid:!1,customError:!0});/**
925
925
  * @license
926
926
  * Copyright 2018 Google LLC
927
927
  * SPDX-License-Identifier: BSD-3-Clause
928
- */const hi=o=>o??q,mu=Q`
928
+ */const ui=o=>o??q,mu=Q`
929
929
  :host {
930
930
  --track-width: 2px;
931
931
  --track-color: rgb(128 128 128 / 25%);
@@ -982,19 +982,19 @@
982
982
  stroke-dasharray: 0.05em, 3em;
983
983
  }
984
984
  }
985
- `;var bu=Object.getOwnPropertyDescriptor,vu=(o,t,e,i)=>{for(var s=i>1?void 0:i?bu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=n(s)||s);return s};let ss=class extends yt{render(){return L`
985
+ `;var bu=Object.getOwnPropertyDescriptor,vu=(o,t,e,i)=>{for(var s=i>1?void 0:i?bu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=n(s)||s);return s};let rs=class extends gt{render(){return L`
986
986
  <svg part="base" class="spinner" role="progressbar" aria-label="loading">
987
987
  <circle class="spinner__track"></circle>
988
988
  <circle class="spinner__indicator"></circle>
989
989
  </svg>
990
- `}};ss.styles=[pt,mu];ss=vu([ht("pbo-spinner")],ss);var _u=Object.defineProperty,yu=Object.getOwnPropertyDescriptor,Bt=(o,t,e,i)=>{for(var s=i>1?void 0:i?yu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&_u(t,e,s),s};let et=class extends yt{constructor(){super(...arguments),this.formControlController=new Cn(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new zi(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.error=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:ro}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(){this.type==="submit"&&this.formControlController.submit(this),this.type==="reset"&&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():!0}getForm(){return this.formControlController.getForm()}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}render(){const t=this.isLink(),e=t?Da`a`:Da`button`;return Ma`
990
+ `}};rs.styles=[pt,mu];rs=vu([dt("pbo-spinner")],rs);var _u=Object.defineProperty,yu=Object.getOwnPropertyDescriptor,Bt=(o,t,e,i)=>{for(var s=i>1?void 0:i?yu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&_u(t,e,s),s};let et=class extends gt{constructor(){super(...arguments),this.formControlController=new Cn(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new zi(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.error=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:ro}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(){this.type==="submit"&&this.formControlController.submit(this),this.type==="reset"&&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():!0}getForm(){return this.formControlController.getForm()}reset(t){this.doAction("reset",t)}submit(t){this.doAction("submit",t)}render(){const t=this.isLink(),e=t?Da`a`:Da`button`;return Ma`
991
991
  <${e}
992
992
  part="base"
993
993
  class= ${pe({button:!0,"button--default":this.variant==="default","button--primary":this.variant==="primary","button--success":this.variant==="success","button--neutral":this.variant==="neutral","button--warning":this.variant==="warning","button--danger":this.variant==="danger","button--text":this.variant==="text","button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","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})}
994
- ?disabled=${hi(t?void 0:this.disabled)}
994
+ ?disabled=${ui(t?void 0:this.disabled)}
995
995
  tabindex=${this.disabled?"-1":"0"}
996
996
  href="${this.href}"
997
- name=${hi(t?void 0:this.name)}
997
+ name=${ui(t?void 0:this.name)}
998
998
  @blur=${this.handleBlur}
999
999
  @focus=${this.handleFocus}
1000
1000
  @invalid=${this.isButton()?this.handleInvalid:null}
@@ -1004,7 +1004,7 @@
1004
1004
  <slot part="label" class="button__label"></slot>
1005
1005
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
1006
1006
  ${this.loading?Ma`<pbo-spinner part="spinner"></pbo-spinner>`:""}
1007
- </${e}>`}};et.styles=[pt,Yl];et.dependencies={"pbo-spinner":ss};Bt([V(".button")],et.prototype,"button",2);Bt([V(".button--loading pbo-spinner")],et.prototype,"spinner",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"disabled",2);Bt([C()],et.prototype,"href",2);Bt([C()],et.prototype,"name",2);Bt([C()],et.prototype,"value",2);Bt([C({reflect:!0})],et.prototype,"variant",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"outline",2);Bt([C({reflect:!0})],et.prototype,"size",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"circle",2);Bt([C({reflect:!0})],et.prototype,"type",2);Bt([C({type:Boolean,reflect:!0,attribute:"color-block"})],et.prototype,"colorBlock",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"loading",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"error",2);Bt([$()],et.prototype,"isIconButton",2);Bt([$()],et.prototype,"hasFocus",2);et=Bt([ht("pbo-button")],et);const hb=et,xu=Q`
1007
+ </${e}>`}};et.styles=[pt,Yl];et.dependencies={"pbo-spinner":rs};Bt([H(".button")],et.prototype,"button",2);Bt([H(".button--loading pbo-spinner")],et.prototype,"spinner",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"disabled",2);Bt([C()],et.prototype,"href",2);Bt([C()],et.prototype,"name",2);Bt([C()],et.prototype,"value",2);Bt([C({reflect:!0})],et.prototype,"variant",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"outline",2);Bt([C({reflect:!0})],et.prototype,"size",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"circle",2);Bt([C({reflect:!0})],et.prototype,"type",2);Bt([C({type:Boolean,reflect:!0,attribute:"color-block"})],et.prototype,"colorBlock",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"loading",2);Bt([C({type:Boolean,reflect:!0})],et.prototype,"error",2);Bt([$()],et.prototype,"isIconButton",2);Bt([$()],et.prototype,"hasFocus",2);et=Bt([dt("pbo-button")],et);const hb=et,xu=Q`
1008
1008
  :host {
1009
1009
  display: inline-block;
1010
1010
  }
@@ -1013,7 +1013,7 @@
1013
1013
  /* display: flex; */
1014
1014
  /* flex-wrap: nowrap; */
1015
1015
  }
1016
- `;var wu=Object.defineProperty,Cu=Object.getOwnPropertyDescriptor,oo=(o,t,e,i)=>{for(var s=i>1?void 0:i?Cu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&wu(t,e,s),s};let fi=class extends yt{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=ys(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=ys(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=ys(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=ys(t.target);e==null||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=ys(e);s&&(s.toggleAttribute("data-pbo-button-group__button",!0),s.toggleAttribute("data-pbo-button-group__button--first",i===0),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",s.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return L`
1016
+ `;var wu=Object.defineProperty,Cu=Object.getOwnPropertyDescriptor,oo=(o,t,e,i)=>{for(var s=i>1?void 0:i?Cu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&wu(t,e,s),s};let bi=class extends gt{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=xs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=xs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=xs(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=xs(t.target);e==null||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=xs(e);s&&(s.toggleAttribute("data-pbo-button-group__button",!0),s.toggleAttribute("data-pbo-button-group__button--first",i===0),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",s.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return L`
1017
1017
  <div
1018
1018
  part="base"
1019
1019
  class=${pe({"button-group":!0})}
@@ -1026,7 +1026,7 @@
1026
1026
  >
1027
1027
  <slot @slotchange=${this.handleSlotChange}></slot>
1028
1028
  </div>
1029
- `}};fi.styles=[pt,xu];oo([V("slot")],fi.prototype,"defaultSlot",2);oo([$()],fi.prototype,"disableRole",2);oo([C()],fi.prototype,"label",2);fi=oo([ht("pbo-button-group")],fi);function ys(o){const t="pbo-button, pbo-radio-button";return o.closest(t)??o.querySelector(t)}const ub=fi,Su=Q`
1029
+ `}};bi.styles=[pt,xu];oo([H("slot")],bi.prototype,"defaultSlot",2);oo([$()],bi.prototype,"disableRole",2);oo([C()],bi.prototype,"label",2);bi=oo([dt("pbo-button-group")],bi);function xs(o){const t="pbo-button, pbo-radio-button";return o.closest(t)??o.querySelector(t)}const ub=bi,Su=Q`
1030
1030
  ${Yl}
1031
1031
 
1032
1032
  .button__prefix,
@@ -1047,7 +1047,7 @@
1047
1047
  * @license
1048
1048
  * Copyright 2018 Google LLC
1049
1049
  * SPDX-License-Identifier: BSD-3-Clause
1050
- */const ql="important",Tu=" !"+ql,ue=io(class extends so{constructor(o){var t;if(super(o),o.type!==li.ATTRIBUTE||o.name!=="style"||((t=o.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce((t,e)=>{const i=o[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(o,[t]){const{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ft.add(i);const r=typeof s=="string"&&s.endsWith(Tu);i.includes("-")||r?e.setProperty(i,r?s.slice(0,-11):s,r?ql:""):e[i]=s}}return ve}});var Eu=Object.defineProperty,ku=Object.getOwnPropertyDescriptor,He=(o,t,e,i)=>{for(var s=i>1?void 0:i?ku(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Eu(t,e,s),s};let ge=class extends yt{constructor(){super(...arguments),this.hasSlotController=new zi(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){t.preventDefault(),t.stopPropagation();return}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 L`
1050
+ */const ql="important",Tu=" !"+ql,ue=io(class extends so{constructor(o){var t;if(super(o),o.type!==hi.ATTRIBUTE||o.name!=="style"||((t=o.strings)==null?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce((t,e)=>{const i=o[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(o,[t]){const{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(const i of this.ft)t[i]==null&&(this.ft.delete(i),i.includes("-")?e.removeProperty(i):e[i]=null);for(const i in t){const s=t[i];if(s!=null){this.ft.add(i);const r=typeof s=="string"&&s.endsWith(Tu);i.includes("-")||r?e.setProperty(i,r?s.slice(0,-11):s,r?ql:""):e[i]=s}}return _e}});var Eu=Object.defineProperty,ku=Object.getOwnPropertyDescriptor,Ne=(o,t,e,i)=>{for(var s=i>1?void 0:i?ku(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Eu(t,e,s),s};let ge=class extends gt{constructor(){super(...arguments),this.hasSlotController=new zi(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){t.preventDefault(),t.stopPropagation();return}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 L`
1051
1051
  <div part="base" role="presentation">
1052
1052
  <button
1053
1053
  part="${`button${this.checked?"button--checked":""}`}"
@@ -1055,7 +1055,7 @@
1055
1055
  aria-checked="${this.checked}"
1056
1056
  class=${pe({button:!0,"button--default":!0,"button--color-block":!!this.isColorString(this.value),"button--small":this.size==="small","button--medium":this.size==="medium","button--large":this.size==="large","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})}
1057
1057
  type="button"
1058
- value=${hi(this.value)}
1058
+ value=${ui(this.value)}
1059
1059
  @blur=${this.handleBlur}
1060
1060
  @click=${this.handleClick}
1061
1061
  @focus=${this.handleFocus}
@@ -1066,7 +1066,7 @@
1066
1066
  <slot name="suffix" part="suffix" class="button__suffix"></slot>
1067
1067
  </button>
1068
1068
  </div>
1069
- `}};ge.styles=[pt,Su];He([V(".button")],ge.prototype,"input",2);He([V(".hidden-input")],ge.prototype,"hiddenInput",2);He([C({type:Boolean,reflect:!0})],ge.prototype,"checked",2);He([C()],ge.prototype,"value",2);He([C({type:Boolean,reflect:!0})],ge.prototype,"disabled",2);He([C({reflect:!0})],ge.prototype,"size",2);He([C({type:Boolean,reflect:!0})],ge.prototype,"circle",2);He([C({type:Boolean,reflect:!0,attribute:"icon-only"})],ge.prototype,"iconOnly",2);He([$()],ge.prototype,"hasFocus",2);ge=He([ht("pbo-radio-button")],ge);const gb=ge,Ou=Q`
1069
+ `}};ge.styles=[pt,Su];Ne([H(".button")],ge.prototype,"input",2);Ne([H(".hidden-input")],ge.prototype,"hiddenInput",2);Ne([C({type:Boolean,reflect:!0})],ge.prototype,"checked",2);Ne([C()],ge.prototype,"value",2);Ne([C({type:Boolean,reflect:!0})],ge.prototype,"disabled",2);Ne([C({reflect:!0})],ge.prototype,"size",2);Ne([C({type:Boolean,reflect:!0})],ge.prototype,"circle",2);Ne([C({type:Boolean,reflect:!0,attribute:"icon-only"})],ge.prototype,"iconOnly",2);Ne([$()],ge.prototype,"hasFocus",2);ge=Ne([dt("pbo-radio-button")],ge);const gb=ge,Ou=Q`
1070
1070
  :host {
1071
1071
  display: block;
1072
1072
  }
@@ -1102,7 +1102,7 @@
1102
1102
  .form-control__label > slot {
1103
1103
  font-size: 16.5px;
1104
1104
  }
1105
- `;var Pu=Object.defineProperty,Du=Object.getOwnPropertyDescriptor,Vt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Du(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Pu(t,e,s),s};let at=class extends yt{constructor(){super(...arguments),this.formControlController=new Cn(this),this.hasSlotController=new zi(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!==""?fu:t?gu:ro}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):!0}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(e=>e.checked=e.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(r=>r.checked=r===e),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(t){}syncRadios(){if(customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")){this.syncRadioElements();return}if(customElements.get("pbo-radio")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio").then(()=>{this.syncRadios()});if(customElements.get("pbo-radio-button")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio-button").then(()=>{this.syncRadios()})}async syncRadioElements(){var e;const t=this.getAllRadios();if(await Promise.all(t.map(async i=>{await i.updateComplete,i.checked=i.value===this.value})),this.hasButtonGroup=t.some(i=>i.tagName.toLowerCase()==="pbo-radio-button"),t.length>0&&!t.some(i=>i.checked))if(this.hasButtonGroup){const i=(e=t[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else t[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?!0:!!e,s=this.label?!0:!!t;return L`
1105
+ `;var Pu=Object.defineProperty,Du=Object.getOwnPropertyDescriptor,Vt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Du(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Pu(t,e,s),s};let lt=class extends gt{constructor(){super(...arguments),this.formControlController=new Cn(this),this.hasSlotController=new zi(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!==""?fu:t?gu:ro}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):!0}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(e=>e.checked=e.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(r=>r.checked=r===e),this.value!==s&&(this.emit("pbo-change"),this.emit("pbo-input")))}handleLabelClick(){this.focus()}handleKeyDown(t){}syncRadios(){if(customElements.get("pbo-radio")&&customElements.get("pbo-radio-button")){this.syncRadioElements();return}if(customElements.get("pbo-radio")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio").then(()=>{this.syncRadios()});if(customElements.get("pbo-radio-button")){this.syncRadioElements();return}else customElements.whenDefined("pbo-radio-button").then(()=>{this.syncRadios()})}async syncRadioElements(){var e;const t=this.getAllRadios();if(await Promise.all(t.map(async i=>{await i.updateComplete,i.checked=i.value===this.value})),this.hasButtonGroup=t.some(i=>i.tagName.toLowerCase()==="pbo-radio-button"),t.length>0&&!t.some(i=>i.checked))if(this.hasButtonGroup){const i=(e=t[0].shadowRoot)==null?void 0:e.querySelector("button");i&&i.setAttribute("tabindex","0")}else t[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?!0:!!e,s=this.label?!0:!!t;return L`
1106
1106
  <fieldset
1107
1107
  role="radiogroup"
1108
1108
  part="form-control"
@@ -1149,7 +1149,7 @@
1149
1149
  <slot name="help-text">${this.helpText}</slot>
1150
1150
  </div>
1151
1151
  </fieldset>
1152
- `}};at.styles=[pt,Ou,Us];at.dependencies={"pbo-button-group":fi};Vt([V("slot:not([name])")],at.prototype,"defaultSlot",2);Vt([V(".radio-group__validation-input")],at.prototype,"validationInput",2);Vt([$()],at.prototype,"hasButtonGroup",2);Vt([$()],at.prototype,"errorMessage",2);Vt([$()],at.prototype,"defaultValue",2);Vt([C({type:Boolean,reflect:!0})],at.prototype,"required",2);Vt([C()],at.prototype,"name",2);Vt([C({reflect:!0})],at.prototype,"value",2);Vt([C({attribute:"help-text"})],at.prototype,"helpText",2);Vt([C()],at.prototype,"label",2);Vt([C({type:Boolean,reflect:!0,attribute:"icon-group"})],at.prototype,"iconGroup",2);Vt([C()],at.prototype,"size",2);Vt([C({type:Boolean,reflect:!0})],at.prototype,"disabled",2);Vt([C({reflect:!0})],at.prototype,"form",2);Vt([N("value")],at.prototype,"handleValueChange",1);at=Vt([ht("pbo-radio-group")],at);const mb=at,Au=Q`
1152
+ `}};lt.styles=[pt,Ou,Ws];lt.dependencies={"pbo-button-group":bi};Vt([H("slot:not([name])")],lt.prototype,"defaultSlot",2);Vt([H(".radio-group__validation-input")],lt.prototype,"validationInput",2);Vt([$()],lt.prototype,"hasButtonGroup",2);Vt([$()],lt.prototype,"errorMessage",2);Vt([$()],lt.prototype,"defaultValue",2);Vt([C({type:Boolean,reflect:!0})],lt.prototype,"required",2);Vt([C()],lt.prototype,"name",2);Vt([C({reflect:!0})],lt.prototype,"value",2);Vt([C({attribute:"help-text"})],lt.prototype,"helpText",2);Vt([C()],lt.prototype,"label",2);Vt([C({type:Boolean,reflect:!0,attribute:"icon-group"})],lt.prototype,"iconGroup",2);Vt([C()],lt.prototype,"size",2);Vt([C({type:Boolean,reflect:!0})],lt.prototype,"disabled",2);Vt([C({reflect:!0})],lt.prototype,"form",2);Vt([V("value")],lt.prototype,"handleValueChange",1);lt=Vt([dt("pbo-radio-group")],lt);const mb=lt,Au=Q`
1153
1153
  :host {
1154
1154
  display: block;
1155
1155
  position: relative;
@@ -1345,7 +1345,7 @@
1345
1345
  * @license
1346
1346
  * Copyright 2020 Google LLC
1347
1347
  * SPDX-License-Identifier: BSD-3-Clause
1348
- */const $u=io(class extends so{constructor(o){if(super(o),o.type!==li.PROPERTY&&o.type!==li.ATTRIBUTE&&o.type!==li.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Lu(o))throw Error("`live` bindings can only contain a single expression")}render(o){return o}update(o,[t]){if(t===ve||t===q)return t;const e=o.element,i=o.name;if(o.type===li.PROPERTY){if(t===e[i])return ve}else if(o.type===li.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return ve}else if(o.type===li.ATTRIBUTE&&e.getAttribute(i)===t+"")return ve;return Qo(o),t}});var Bu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Lt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ru(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Bu(t,e,s),s};let lt=class extends yt{constructor(){super(...arguments),this.formControlController=new Cn(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new zi(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){if(t){typeof t.top=="number"&&(this.input.scrollTop=t.top),typeof t.left=="number"&&(this.input.scrollLeft=t.left);return}return{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,n=i??this.input.selectionEnd;this.input.setRangeText(t,r,n,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?!0:!!t;return L` <div
1348
+ */const $u=io(class extends so{constructor(o){if(super(o),o.type!==hi.PROPERTY&&o.type!==hi.ATTRIBUTE&&o.type!==hi.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!Lu(o))throw Error("`live` bindings can only contain a single expression")}render(o){return o}update(o,[t]){if(t===_e||t===q)return t;const e=o.element,i=o.name;if(o.type===hi.PROPERTY){if(t===e[i])return _e}else if(o.type===hi.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return _e}else if(o.type===hi.ATTRIBUTE&&e.getAttribute(i)===t+"")return _e;return Qo(o),t}});var Bu=Object.defineProperty,Ru=Object.getOwnPropertyDescriptor,Lt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ru(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Bu(t,e,s),s};let ct=class extends gt{constructor(){super(...arguments),this.formControlController=new Cn(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new zi(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){if(t){typeof t.top=="number"&&(this.input.scrollTop=t.top),typeof t.left=="number"&&(this.input.scrollLeft=t.left);return}return{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,n=i??this.input.selectionEnd;this.input.setRangeText(t,r,n,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?!0:!!t;return L` <div
1349
1349
  part="form-control"
1350
1350
  class=${pe({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--has-help-text":e,invalid:!0})}
1351
1351
  >
@@ -1359,15 +1359,15 @@
1359
1359
  id="input"
1360
1360
  class="textarea__control"
1361
1361
  title=${this.title}
1362
- name=${hi(this.name)}
1362
+ name=${ui(this.name)}
1363
1363
  .value=${$u(this.value)}
1364
1364
  ?disabled=${this.disabled}
1365
1365
  ?readonly=${this.readonly}
1366
1366
  ?required=${this.required}
1367
- placeholder=${hi(this.placeholder)}
1368
- rows=${hi(this.rows)}
1369
- minlength=${hi(this.minlength)}
1370
- maxlength=${hi(this.maxlength)}
1367
+ placeholder=${ui(this.placeholder)}
1368
+ rows=${ui(this.rows)}
1369
+ minlength=${ui(this.minlength)}
1370
+ maxlength=${ui(this.maxlength)}
1371
1371
  aria-describedby="help-text"
1372
1372
  @change=${this.handleChange}
1373
1373
  @input=${this.handleInput}
@@ -1387,7 +1387,7 @@
1387
1387
  >
1388
1388
  <slot name="help-text">${this.helpText}</slot>
1389
1389
  </div>
1390
- </div>`}};lt.styles=[pt,Au,Us];Lt([V(".textarea__control")],lt.prototype,"input",2);Lt([V(".textarea__size-adjuster")],lt.prototype,"sizeAdjuster",2);Lt([$()],lt.prototype,"hasFocus",2);Lt([C()],lt.prototype,"name",2);Lt([C()],lt.prototype,"value",2);Lt([C({reflect:!0})],lt.prototype,"size",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"filled",2);Lt([C()],lt.prototype,"placeholder",2);Lt([C({type:Number})],lt.prototype,"rows",2);Lt([C()],lt.prototype,"resize",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"disabled",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"readonly",2);Lt([C({reflect:!0})],lt.prototype,"form",2);Lt([C({type:Boolean,reflect:!0})],lt.prototype,"required",2);Lt([C({type:Number})],lt.prototype,"minlength",2);Lt([C({type:Number})],lt.prototype,"maxlength",2);Lt([C({attribute:"help-text"})],lt.prototype,"helpText",2);lt=Lt([ht("pbo-textarea")],lt);const vb=lt,zu=Q`
1390
+ </div>`}};ct.styles=[pt,Au,Ws];Lt([H(".textarea__control")],ct.prototype,"input",2);Lt([H(".textarea__size-adjuster")],ct.prototype,"sizeAdjuster",2);Lt([$()],ct.prototype,"hasFocus",2);Lt([C()],ct.prototype,"name",2);Lt([C()],ct.prototype,"value",2);Lt([C({reflect:!0})],ct.prototype,"size",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"filled",2);Lt([C()],ct.prototype,"placeholder",2);Lt([C({type:Number})],ct.prototype,"rows",2);Lt([C()],ct.prototype,"resize",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"disabled",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"readonly",2);Lt([C({reflect:!0})],ct.prototype,"form",2);Lt([C({type:Boolean,reflect:!0})],ct.prototype,"required",2);Lt([C({type:Number})],ct.prototype,"minlength",2);Lt([C({type:Number})],ct.prototype,"maxlength",2);Lt([C({attribute:"help-text"})],ct.prototype,"helpText",2);ct=Lt([dt("pbo-textarea")],ct);const vb=ct,zu=Q`
1391
1391
  :host {
1392
1392
  display: block;
1393
1393
  }
@@ -1474,7 +1474,7 @@
1474
1474
  .skip::part(label) {
1475
1475
  font-size: 14px;
1476
1476
  }
1477
- `,ui=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),xs=o=>o!=null,Kl=o=>Object.entries(o).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function Nu(o,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>o.apply(this,i),t)}}var Vu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,Et=(o,t,e,i)=>{for(var s=i>1?void 0:i?Uu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Vu(t,e,s),s};let K=class extends yt{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=K.CTA_STATES.primary,this.wrappedSubmitTypeForm=async t=>{console.warn("submitTypingForm function not implemented",t)},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}updateWrappedSubmitTypeForm(){this.wrappedSubmitTypeForm=async t=>{this.loading=!0,this.disabled=!0;try{this.submitTypeForm(t),await new Promise(e=>setTimeout(e,1e3))}catch(e){console.error("Error submitting type form:",e)}finally{this.loading=!1,this.disabled=!1}}}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 e,i,s,r,n,a,l,c;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,sku:(s=this.card)==null?void 0:s.sku,variantId:(r=this.card)==null?void 0:r.variantId,font:((n=this.fontSelector)==null?void 0:n.value)||"",text:((a=this.greetingText)==null?void 0:a.value)||"",color:((l=this.textColor)==null?void 0:l.value)||"",alignment:((c=this.textAlignment)==null?void 0:c.value)||""};return Kl(t)}handleFormChange(t){var e;this.ctaButtonState=K.CTA_STATES.primary,this.charsNum=((e=this.greetingText)==null?void 0:e.value.length)||0,this.emit("pbo-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.wrappedSubmitTypeForm(this.formData);return}if(this.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=K.CTA_STATES.danger,this.greetingText.focus();return}this.wrappedSubmitTypeForm(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.charsNum;return L`
1477
+ `,gi=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),ws=o=>o!=null,Kl=o=>Object.entries(o).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});function Nu(o,t){let e;return function(...i){clearTimeout(e),e=setTimeout(()=>o.apply(this,i),t)}}var Vu=Object.defineProperty,Uu=Object.getOwnPropertyDescriptor,At=(o,t,e,i)=>{for(var s=i>1?void 0:i?Uu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Vu(t,e,s),s};let K=class extends gt{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.onClose=()=>{},this.windowHeight=window.innerHeight,this.charsNum=0,this.ctaButtonState=K.CTA_STATES.primary,this.wrappedSubmitTypeForm=async t=>{console.warn("submitTypingForm function not implemented",t)},this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}updateWrappedSubmitTypeForm(){this.wrappedSubmitTypeForm=async t=>{this.loading=!0,this.disabled=!0;try{this.submitTypeForm(t),this.onClose(),this.emit("pbo-type-form-submitted")}catch(e){console.error("Error submitting type form:",e)}finally{this.loading=!1,this.disabled=!1}}}firstUpdated(){console.log("Is type-form disabled: ",this.disabled,this.loading),this.textArea.addEventListener("invalid",()=>{alert("Please add a message to continue")})}get formData(){var e,i,s,r,n,a,l,c;const t={pboCardId:((e=this.card)==null?void 0:e.pboId)||"Unknown",productId:(i=this.card)==null?void 0:i.productId,sku:(s=this.card)==null?void 0:s.sku,variantId:(r=this.card)==null?void 0:r.variantId,font:((n=this.fontSelector)==null?void 0:n.value)||"",text:((a=this.greetingText)==null?void 0:a.value)||"",color:((l=this.textColor)==null?void 0:l.value)||"",alignment:((c=this.textAlignment)==null?void 0:c.value)||""};return Kl(t)}handleFormChange(t){var e;this.ctaButtonState=K.CTA_STATES.primary,this.charsNum=((e=this.greetingText)==null?void 0:e.value.length)||0,this.emit("pbo-type-form-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.wrappedSubmitTypeForm(this.formData);return}if(this.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=K.CTA_STATES.danger,this.greetingText.focus();return}this.wrappedSubmitTypeForm(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.charsNum;return L`
1478
1478
  <form class="typing-form" @submit=${this.submitFormHandler}>
1479
1479
  <pbo-textarea
1480
1480
  exportparts="textarea:editor-textarea"
@@ -1485,6 +1485,8 @@
1485
1485
  rows="${window.innerHeight>=800?12:8}"
1486
1486
  placeholder="Type your message here"
1487
1487
  resize="none"
1488
+ ?disabled="${this.disabled}"
1489
+ ?loading="${this.loading}"
1488
1490
  >
1489
1491
  </pbo-textarea>
1490
1492
 
@@ -1495,7 +1497,7 @@
1495
1497
  .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"}]}"
1496
1498
  @pbo-change=${this.handleFormChange}
1497
1499
  size="large"
1498
- disabled="${this.disabled}"
1500
+ ?disabled="${this.disabled}"
1499
1501
  ></pbo-font-selector>
1500
1502
 
1501
1503
  <div class="color-alignment-container">
@@ -1507,8 +1509,8 @@
1507
1509
  size="large"
1508
1510
  exportparts="form-control-label:color-selector-label,form-control-label:type-form-label"
1509
1511
  >
1510
- <pbo-radio-button disabled="${this.disabled}" value="rgb(0,0,0)" size="small" circle></pbo-radio-button>
1511
- <pbo-radio-button disabled="${this.disabled}" value="rgb(255,255,255)" size="small" circle></pbo-radio-button>
1512
+ <pbo-radio-button ?disabled="${this.disabled}" value="rgb(0,0,0)" size="small" circle></pbo-radio-button>
1513
+ <pbo-radio-button ?disabled="${this.disabled}" value="rgb(255,255,255)" size="small" circle></pbo-radio-button>
1512
1514
  </pbo-radio-group>
1513
1515
 
1514
1516
  <pbo-radio-group
@@ -1568,6 +1570,8 @@
1568
1570
  type="submit"
1569
1571
  class="submit"
1570
1572
  variant="${this.ctaButtonState.type}"
1573
+ ?loading="${this.loading}"
1574
+ ?disabled="${this.disabled}"
1571
1575
  >
1572
1576
  ${this.ctaButtonState.message}
1573
1577
  </pbo-button>
@@ -1579,13 +1583,15 @@
1579
1583
  variant="text"
1580
1584
  size="small"
1581
1585
  class="skip"
1586
+ ?loading="${this.loading}"
1587
+ ?disabled="${this.disabled}"
1582
1588
  >
1583
1589
  Skip
1584
1590
  </pbo-button>
1585
1591
  `:""}
1586
1592
  </div>
1587
1593
  </form>
1588
- `}};K.styles=[pt,Us,Hu];K.dependencies={"pbo-font-selector":je,"pbo-textarea":lt,"pbo-color-radio-group":at,"pbo-radio-group":at,"pbo-radio-button":at,"pbo-button":et};K.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:"Save and Continue"}};Et([C({type:String,reflect:!0})],K.prototype,"cardInnerImageUrl",2);Et([C()],K.prototype,"card",2);Et([C()],K.prototype,"submitTypeForm",2);Et([C({type:Boolean,reflect:!0})],K.prototype,"loading",2);Et([C({type:Boolean,reflect:!0})],K.prototype,"disabled",2);Et([V(".greeting-text")],K.prototype,"greetingText",2);Et([V(".font-selector")],K.prototype,"fontSelector",2);Et([V(".text-color")],K.prototype,"textColor",2);Et([V(".text-alignment")],K.prototype,"textAlignment",2);Et([V(".typing-form")],K.prototype,"typingForm",2);Et([V("pbo-textarea")],K.prototype,"textArea",2);Et([yn(".cta-buttons pbo-button")],K.prototype,"ctaButtons",2);Et([$()],K.prototype,"windowHeight",2);Et([$()],K.prototype,"charsNum",2);Et([$()],K.prototype,"ctaButtonState",2);Et([$()],K.prototype,"wrappedSubmitTypeForm",2);Et([N("submitTypeForm")],K.prototype,"updateWrappedSubmitTypeForm",1);Et([N("loading",{waitUntilFirstUpdate:!0})],K.prototype,"isLoadingChanged",1);Et([N("disabled",{waitUntilFirstUpdate:!0})],K.prototype,"disabledChanged",1);K=Et([ht("pbo-type-form")],K);/**
1594
+ `}};K.styles=[pt,Ws,Hu];K.dependencies={"pbo-font-selector":$e,"pbo-textarea":ct,"pbo-color-radio-group":lt,"pbo-radio-group":lt,"pbo-radio-button":lt,"pbo-button":et};K.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:"Save and Continue"}};At([C({type:String,reflect:!0})],K.prototype,"cardInnerImageUrl",2);At([C()],K.prototype,"card",2);At([C()],K.prototype,"submitTypeForm",2);At([C({type:Boolean,reflect:!0})],K.prototype,"loading",2);At([C({type:Boolean,reflect:!0})],K.prototype,"disabled",2);At([C({type:Function})],K.prototype,"onClose",2);At([H(".greeting-text")],K.prototype,"greetingText",2);At([H(".font-selector")],K.prototype,"fontSelector",2);At([H(".text-color")],K.prototype,"textColor",2);At([H(".text-alignment")],K.prototype,"textAlignment",2);At([H(".typing-form")],K.prototype,"typingForm",2);At([H("pbo-textarea")],K.prototype,"textArea",2);At([yn(".cta-buttons pbo-button")],K.prototype,"ctaButtons",2);At([$()],K.prototype,"windowHeight",2);At([$()],K.prototype,"charsNum",2);At([$()],K.prototype,"ctaButtonState",2);At([$()],K.prototype,"wrappedSubmitTypeForm",2);At([V("submitTypeForm")],K.prototype,"updateWrappedSubmitTypeForm",1);K=At([dt("pbo-type-form")],K);/**
1589
1595
  * @license
1590
1596
  * Copyright 2017 Google LLC
1591
1597
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1754,7 +1760,7 @@
1754
1760
  background-color: #f3f3f3;
1755
1761
  }
1756
1762
  }
1757
- `;var Yu=Object.defineProperty,Xu=Object.getOwnPropertyDescriptor,Ne=(o,t,e,i)=>{for(var s=i>1?void 0:i?Xu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Yu(t,e,s),s};let oe=class extends yt{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.skeleton=!1,this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.skeleton||(this.imgEl.onload=()=>this.handleOnLoad())}render(){return this.skeleton?L`<div class="skeleton"></div>`:L`
1763
+ `;var Yu=Object.defineProperty,Xu=Object.getOwnPropertyDescriptor,Ve=(o,t,e,i)=>{for(var s=i>1?void 0:i?Xu(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Yu(t,e,s),s};let oe=class extends gt{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.skeleton=!1,this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.skeleton||(this.imgEl.onload=()=>this.handleOnLoad())}render(){return this.skeleton?L`<div class="skeleton"></div>`:L`
1758
1764
  ${this.loaded?"":L` <div class="skeleton"></div>`}
1759
1765
  <img
1760
1766
  src=${this.src}
@@ -1762,7 +1768,7 @@
1762
1768
  class=${pe({loaded:this.loaded,hidden:!this.loaded})}
1763
1769
  @error=${()=>this.handleError()}
1764
1770
  />
1765
- `}};oe.styles=[pt,Gu];Ne([C()],oe.prototype,"skeletonHeight",2);Ne([C()],oe.prototype,"skeletonWidth",2);Ne([C()],oe.prototype,"src",2);Ne([C()],oe.prototype,"alt",2);Ne([C()],oe.prototype,"placeholder",2);Ne([C({type:Boolean})],oe.prototype,"skeleton",2);Ne([$()],oe.prototype,"loaded",2);Ne([V("img")],oe.prototype,"imgEl",2);Ne([N("src")],oe.prototype,"handleSrcChange",1);oe=Ne([ht("pbo-image")],oe);var qu=Object.defineProperty,Ku=Object.getOwnPropertyDescriptor,Ut=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ku(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&qu(t,e,s),s};let vt=class extends yt{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(!ui()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",e=>{var n,a;const{detail:i}=e,s=(n=this.shadowRoot)==null?void 0:n.querySelector("#handwritten-main-canvas"),r=(a=this.shadowRoot)==null?void 0:a.querySelector("#handwritten-zoomed-preview-canvas");s&&r&&(s.imageWidth=i.width,s.imageHeight=i.height,s.imageTop=i.top,s.imageLeft=i.left,r.imageWidth=i.width,r.imageHeight=i.height,r.imageTop=i.top,r.imageLeft=i.left)}),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active");const t=(e,i)=>{e.addEventListener("click",()=>{this.focusOn(i)})};for(let e=0;e<this.thumbnailElements.length;e++)t(this.thumbnailElements[e],e)}handleCardChange(t,e){var i,s,r,n;e&&(this.mainImageTemplates=[L`<pbo-image src="${e.medias.cover.url||"https://picsum.photos/id/1/300/400"}" alt="" />`,L`<pbo-type-canvas
1771
+ `}};oe.styles=[pt,Gu];Ve([C()],oe.prototype,"skeletonHeight",2);Ve([C()],oe.prototype,"skeletonWidth",2);Ve([C()],oe.prototype,"src",2);Ve([C()],oe.prototype,"alt",2);Ve([C()],oe.prototype,"placeholder",2);Ve([C({type:Boolean})],oe.prototype,"skeleton",2);Ve([$()],oe.prototype,"loaded",2);Ve([H("img")],oe.prototype,"imgEl",2);Ve([V("src")],oe.prototype,"handleSrcChange",1);oe=Ve([dt("pbo-image")],oe);var qu=Object.defineProperty,Ku=Object.getOwnPropertyDescriptor,Ut=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ku(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&qu(t,e,s),s};let _t=class extends gt{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.emit("pbo_close_live_preview",{detail:{editor:this.type}})},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0),this.emit("pbo_open_live_preview",{detail:{editor:this.type}})},this.handleOpenZoomedClick=t=>{if(!gi()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",e=>{var n,a;const{detail:i}=e,s=(n=this.shadowRoot)==null?void 0:n.querySelector("#handwritten-main-canvas"),r=(a=this.shadowRoot)==null?void 0:a.querySelector("#handwritten-zoomed-preview-canvas");s&&r&&(s.imageWidth=i.width,s.imageHeight=i.height,s.imageTop=i.top,s.imageLeft=i.left,r.imageWidth=i.width,r.imageHeight=i.height,r.imageTop=i.top,r.imageLeft=i.left)}),this.updateComplete,this.thumbnailElements[this.focusIndex].classList.add("active"),this.mainSlideElements[this.focusIndex].classList.add("active");const t=(e,i)=>{e.addEventListener("click",()=>{this.focusOn(i)})};for(let e=0;e<this.thumbnailElements.length;e++)t(this.thumbnailElements[e],e)}handleCardChange(t,e){var i,s,r,n;e&&(this.mainImageTemplates=[L`<pbo-image src="${e.medias.cover.url||"https://picsum.photos/id/1/300/400"}" alt="" />`,L`<pbo-type-canvas
1766
1772
  background-url=${e.medias.insert.url}
1767
1773
  message=${(i=this.livePreviewProps)==null?void 0:i.text}
1768
1774
  alignment=${((s=this.livePreviewProps)==null?void 0:s.alignment)||"left"}
@@ -1799,7 +1805,7 @@
1799
1805
  <div class="main-slide-container">
1800
1806
  <div class="main-slide" @click="${this.handleOpenZoomedClick}">
1801
1807
  <pbo-image src="${((s=this.card)==null?void 0:s.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt=""></pbo-image>
1802
- ${ui()?L`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
1808
+ ${gi()?L`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
1803
1809
  <svg
1804
1810
  stroke="currentColor"
1805
1811
  fill="none"
@@ -1833,7 +1839,7 @@
1833
1839
  handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
1834
1840
  @click="${this.handleOpenZoomedClick}"
1835
1841
  ></pbo-handwritten-canvas>`)}
1836
- ${ui()?L`<div class="zoomed-preview-open-button">
1842
+ ${gi()?L`<div class="zoomed-preview-open-button">
1837
1843
  <svg
1838
1844
  stroke="currentColor"
1839
1845
  fill="none"
@@ -1858,7 +1864,7 @@
1858
1864
  src="${((d=this.card)==null?void 0:d.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}"
1859
1865
  alt=""
1860
1866
  ></pbo-image>
1861
- ${ui()?L`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
1867
+ ${gi()?L`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
1862
1868
  <svg
1863
1869
  stroke="currentColor"
1864
1870
  fill="none"
@@ -1921,7 +1927,7 @@
1921
1927
  />
1922
1928
  </pbo-zoomed-preview>
1923
1929
  </pbo-drawer>
1924
- `}};vt.styles=[pt,Wu];vt.dependencies={"pbo-image":oe};Ut([C({type:Object})],vt.prototype,"card",2);Ut([C({type:Number,reflect:!0})],vt.prototype,"focusIndex",2);Ut([C({type:Object})],vt.prototype,"livePreviewProps",2);Ut([C()],vt.prototype,"handwrittenPreviewProps",2);Ut([C()],vt.prototype,"type",2);Ut([V("#thumbnails")],vt.prototype,"thumbnailCarousel",2);Ut([V("#main-carousel")],vt.prototype,"mainCarousel",2);Ut([V(".editor__zoomed")],vt.prototype,"zoomedPreview",2);Ut([V(".main-slide.active")],vt.prototype,"activeMainSlide",2);Ut([V("pbo-type-canvas")],vt.prototype,"typeCanvas",2);Ut([yn(".thumbnail")],vt.prototype,"thumbnailElements",2);Ut([yn(".main-slide")],vt.prototype,"mainSlideElements",2);Ut([$()],vt.prototype,"mainImageTemplates",2);Ut([N("card")],vt.prototype,"handleCardChange",1);Ut([N("focusIndex")],vt.prototype,"handleFocusIndexChange",1);vt=Ut([ht("pbo-editor-card-slider")],vt);var Zu=Object.defineProperty,Ju=Object.getOwnPropertyDescriptor,ae=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ju(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Zu(t,e,s),s};let Dt=class extends yt{constructor(){super(...arguments),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.handleHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1),ui()&&t.detail.processedFileUrl!==""&&t.detail.isLoading===!1&&(this.slider.openZoomedPreview(),this.slider.scrollIntoView({behavior:"smooth",block:"start"}))},this.handleHandwrittenImageDimensionsChanged=t=>{this.handwrittenForm.setDimensions(t.detail)},this.handleZoomedPreviewOpen=()=>{this.zoomedPreview.open=!0},this.handleEditorChange=t=>{this.editorType=t.detail.value}}async handleCardChange(){await this.updateComplete,this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}handleEditorTypeChange(){this.updateComplete.then(()=>{this.slider.focusOn(1),this.editorType==="handwritten"&&ui()&&this.handwrittenForm.scrollIntoView(!0)})}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",this.handleHandwrittenImageDimensionsChanged),this.typeForm.addEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-change",this.handleHandwrittenFormChange),document.addEventListener("pbo-zoomed-preview-open",this.handleZoomedPreviewOpen)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-change",this.handleHandwrittenFormChange)}render(){return L`
1930
+ `}};_t.styles=[pt,Wu];_t.dependencies={"pbo-image":oe};Ut([C({type:Object})],_t.prototype,"card",2);Ut([C({type:Number,reflect:!0})],_t.prototype,"focusIndex",2);Ut([C({type:Object})],_t.prototype,"livePreviewProps",2);Ut([C()],_t.prototype,"handwrittenPreviewProps",2);Ut([C()],_t.prototype,"type",2);Ut([H("#thumbnails")],_t.prototype,"thumbnailCarousel",2);Ut([H("#main-carousel")],_t.prototype,"mainCarousel",2);Ut([H(".editor__zoomed")],_t.prototype,"zoomedPreview",2);Ut([H(".main-slide.active")],_t.prototype,"activeMainSlide",2);Ut([H("pbo-type-canvas")],_t.prototype,"typeCanvas",2);Ut([yn(".thumbnail")],_t.prototype,"thumbnailElements",2);Ut([yn(".main-slide")],_t.prototype,"mainSlideElements",2);Ut([$()],_t.prototype,"mainImageTemplates",2);Ut([V("card")],_t.prototype,"handleCardChange",1);Ut([V("focusIndex")],_t.prototype,"handleFocusIndexChange",1);_t=Ut([dt("pbo-editor-card-slider")],_t);var Zu=Object.defineProperty,Ju=Object.getOwnPropertyDescriptor,ae=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ju(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Zu(t,e,s),s};let Pt=class extends gt{constructor(){super(...arguments),this.card=null,this.onClose=()=>{},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.handleHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1),gi()&&t.detail.processedFileUrl!==""&&t.detail.isLoading===!1&&(this.slider.openZoomedPreview(),this.slider.scrollIntoView({behavior:"smooth",block:"start"}))},this.handleHandwrittenImageDimensionsChanged=t=>{this.handwrittenForm.setDimensions(t.detail)},this.handleEditorChange=t=>{this.emit("pbo-switch-editor",{detail:{fromEditor:this.editorType,toEditor:t.detail.editor},bubbles:!0,composed:!0}),this.editorType=t.detail.editor}}async handleCardChange(){await this.updateComplete,this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}handleEditorTypeChange(){this.updateComplete.then(()=>{this.slider.focusOn(1),this.editorType==="handwritten"&&gi()&&this.handwrittenForm.scrollIntoView(!0)})}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",this.handleHandwrittenImageDimensionsChanged),this.typeForm.addEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-change",this.handleHandwrittenFormChange)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-change",this.handleHandwrittenFormChange)}render(){return L`
1925
1931
  <div class="editor">
1926
1932
  <div class="editor__card" part="editor-card-slider-container">
1927
1933
  <pbo-editor-card-slider
@@ -1934,7 +1940,11 @@
1934
1940
  </div>
1935
1941
 
1936
1942
  <div class="editor__form" part="editor-form-container">
1937
- <pbo-editor-selector @pbo-change=${this.handleEditorChange} part="editor-selector"></pbo-editor-selector>
1943
+ <pbo-editor-selector
1944
+ @pbo-editor-selector-change=${this.handleEditorChange}
1945
+ part="editor-selector"
1946
+ ></pbo-editor-selector>
1947
+
1938
1948
  <pbo-type-form
1939
1949
  part="type-form"
1940
1950
  exportparts="
@@ -1949,6 +1959,7 @@
1949
1959
  cta-link-button-base
1950
1960
  "
1951
1961
  .submitTypeForm=${this.submitTypeForm}
1962
+ .onClose=${this.onClose}
1952
1963
  style=${ue({display:this.editorType==="type"?"block":"none"})}
1953
1964
  ></pbo-type-form>
1954
1965
  <pbo-handwritten-form
@@ -1961,11 +1972,12 @@
1961
1972
  "
1962
1973
  style=${ue({display:this.editorType==="handwritten"?"block":"none"})}
1963
1974
  .submitHandwrittenForm=${this.submitHandwrittenForm}
1975
+ .onClose=${this.onClose}
1964
1976
  .getProcessedImg=${this.getProcessedImg}
1965
1977
  ></pbo-handwritten-form>
1966
1978
  </div>
1967
1979
  </div>
1968
- `}};Dt.styles=[pt,zu];Dt.dependencies={"editor-card-slider":vt,"pbo-type-form":K};ae([C({type:Object})],Dt.prototype,"card",2);ae([C()],Dt.prototype,"submitTypeForm",2);ae([C()],Dt.prototype,"submitHandwrittenForm",2);ae([C()],Dt.prototype,"getProcessedImg",2);ae([V("pbo-type-form")],Dt.prototype,"typeForm",2);ae([V("pbo-handwritten-form")],Dt.prototype,"handwrittenForm",2);ae([V("pbo-editor-card-slider")],Dt.prototype,"slider",2);ae([V(".editor__zoomed")],Dt.prototype,"zoomedPreview",2);ae([$()],Dt.prototype,"formData",2);ae([$()],Dt.prototype,"handwrittenFormState",2);ae([$()],Dt.prototype,"editorType",2);ae([N("card")],Dt.prototype,"handleCardChange",1);ae([N("editorType")],Dt.prototype,"handleEditorTypeChange",1);Dt=ae([ht("pbo-editor")],Dt);const Cb=Dt,Sb=K,Tb=vt,Qu=Q`
1980
+ `}};Pt.styles=[pt,zu];Pt.dependencies={"editor-card-slider":_t,"pbo-type-form":K};ae([C({type:Object})],Pt.prototype,"card",2);ae([C()],Pt.prototype,"submitTypeForm",2);ae([C()],Pt.prototype,"submitHandwrittenForm",2);ae([C()],Pt.prototype,"getProcessedImg",2);ae([C({type:Function})],Pt.prototype,"onClose",2);ae([H("pbo-type-form")],Pt.prototype,"typeForm",2);ae([H("pbo-handwritten-form")],Pt.prototype,"handwrittenForm",2);ae([H("pbo-editor-card-slider")],Pt.prototype,"slider",2);ae([$()],Pt.prototype,"formData",2);ae([$()],Pt.prototype,"handwrittenFormState",2);ae([$()],Pt.prototype,"editorType",2);ae([V("card")],Pt.prototype,"handleCardChange",1);ae([V("editorType")],Pt.prototype,"handleEditorTypeChange",1);Pt=ae([dt("pbo-editor")],Pt);const Cb=Pt,Sb=K,Tb=_t,Qu=Q`
1969
1981
  :host {
1970
1982
  display: block;
1971
1983
  --title-font-size: 18.75px;
@@ -2167,29 +2179,23 @@
2167
2179
  * @license
2168
2180
  * Copyright 2021 Google LLC
2169
2181
  * SPDX-License-Identifier: BSD-3-Clause
2170
- */function*Zl(o,t){if(o!==void 0){let e=0;for(const i of o)yield t(i,e++)}}function Sn(o){return typeof o=="number"}function tn(o){return typeof o=="string"}function no(o){return typeof o=="boolean"}function Ba(o){return Object.prototype.toString.call(o)==="[object Object]"}function ot(o){return Math.abs(o)}function Tn(o){return Math.sign(o)}function Ps(o,t){return ot(o-t)}function ep(o,t){if(o===0||t===0||ot(o)<=ot(t))return 0;const e=Ps(ot(o),ot(t));return ot(e/o)}function ip(o){return Math.round(o*100)/100}function js(o){return $s(o).map(Number)}function Te(o){return o[Ws(o)]}function Ws(o){return Math.max(0,o.length-1)}function En(o,t){return t===Ws(o)}function Ra(o,t=0){return Array.from(Array(o),(e,i)=>t+i)}function $s(o){return Object.keys(o)}function Jl(o,t){return[o,t].reduce((e,i)=>($s(i).forEach(s=>{const r=e[s],n=i[s],a=Ba(r)&&Ba(n);e[s]=a?Jl(r,n):n}),e),{})}function en(o,t){return typeof t.MouseEvent<"u"&&o instanceof t.MouseEvent}function sp(o,t){const e={start:i,center:s,end:r};function i(){return 0}function s(l){return r(l)/2}function r(l){return t-l}function n(l,c){return tn(o)?e[o](l):o(t,l,c)}return{measure:n}}function Bs(){let o=[];function t(s,r,n,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(r,n,a),l=()=>s.removeEventListener(r,n,a);else{const c=s;c.addListener(n),l=()=>c.removeListener(n)}return o.push(l),i}function e(){o=o.filter(s=>s())}const i={add:t,clear:e};return i}function rp(o,t,e,i){const s=Bs(),r=1e3/60;let n=null,a=0,l=0;function c(){s.add(o,"visibilitychange",()=>{o.hidden&&p()})}function h(){g(),s.clear()}function d(b){if(!l)return;n||(n=b,e(),e());const m=b-n;for(n=b,a+=m;a>=r;)e(),a-=r;const y=a/r;i(y),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function g(){t.cancelAnimationFrame(l),n=null,a=0,l=0}function p(){n=null,a=0}return{init:c,destroy:h,start:u,stop:g,update:e,render:i}}function op(o,t){const e=t==="rtl",i=o==="y",s=i?"y":"x",r=i?"x":"y",n=!i&&e?-1:1,a=h(),l=d();function c(p){const{height:f,width:b}=p;return i?f:b}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(p){return p*n}return{scroll:s,cross:r,startEdge:a,endEdge:l,measureSize:c,direction:u}}function ji(o=0,t=0){const e=ot(o-t);function i(c){return c<o}function s(c){return c>t}function r(c){return i(c)||s(c)}function n(c){return r(c)?i(c)?o:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:o,constrain:n,reachedAny:r,reachedMax:s,reachedMin:i,removeOffset:a}}function Ql(o,t,e){const{constrain:i}=ji(0,o),s=o+1;let r=n(t);function n(u){return e?ot((s+u)%s):i(u)}function a(){return r}function l(u){return r=n(u),d}function c(u){return h().set(a()+u)}function h(){return Ql(o,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function np(o,t,e,i,s,r,n,a,l,c,h,d,u,g,p,f,b,m,y){const{cross:w,direction:T}=o,k=["INPUT","SELECT","TEXTAREA"],O={passive:!1},E=Bs(),S=Bs(),D=ji(50,225).constrain(g.measure(20)),I={mouse:300,touch:400},M={mouse:500,touch:600},B=p?43:25;let R=!1,F=0,Y=0,tt=!1,xt=!1,W=!1,wt=!1;function Gt(A){if(!y)return;function J(Xt){(no(y)||y(A,Xt))&&le(Xt)}const Ct=t;E.add(Ct,"dragstart",Xt=>Xt.preventDefault(),O).add(Ct,"touchmove",()=>{},O).add(Ct,"touchend",()=>{}).add(Ct,"touchstart",J).add(Ct,"mousedown",J).add(Ct,"touchcancel",Ft).add(Ct,"contextmenu",Ft).add(Ct,"click",ce,!0)}function Yt(){E.clear(),S.clear()}function Oe(){const A=wt?e:t;S.add(A,"touchmove",Ot,O).add(A,"touchend",Ft).add(A,"mousemove",Ot,O).add(A,"mouseup",Ft)}function fe(A){const J=A.nodeName||"";return k.includes(J)}function It(){return(p?M:I)[wt?"mouse":"touch"]}function Pe(A,J){const Ct=d.add(Tn(A)*-1),Xt=h.byDistance(A,!p).distance;return p||ot(A)<D?Xt:b&&J?Xt*.5:h.byIndex(Ct.get(),0).distance}function le(A){const J=en(A,i);wt=J,W=p&&J&&!A.buttons&&R,R=Ps(s.get(),n.get())>=2,!(J&&A.button!==0)&&(fe(A.target)||(tt=!0,r.pointerDown(A),c.useFriction(0).useDuration(0),s.set(n),Oe(),F=r.readPoint(A),Y=r.readPoint(A,w),u.emit("pointerDown")))}function Ot(A){if(!en(A,i)&&A.touches.length>=2)return Ft(A);const Ct=r.readPoint(A),Xt=r.readPoint(A,w),De=Ps(Ct,F),Ve=Ps(Xt,Y);if(!xt&&!wt&&(!A.cancelable||(xt=De>Ve,!xt)))return Ft(A);const Ci=r.pointerMove(A);De>f&&(W=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(T(Ci)),A.preventDefault()}function Ft(A){const Ct=h.byDistance(0,!1).index!==d.get(),Xt=r.pointerUp(A)*It(),De=Pe(T(Xt),Ct),Ve=ep(Xt,De),Ci=B-10*Ve,oi=m+Ve/50;xt=!1,tt=!1,S.clear(),c.useDuration(Ci).useFriction(oi),l.distance(De,!p),wt=!1,u.emit("pointerUp")}function ce(A){W&&(A.stopPropagation(),A.preventDefault(),W=!1)}function gt(){return tt}return{init:Gt,destroy:Yt,pointerDown:gt}}function ap(o,t){let i,s;function r(d){return d.timeStamp}function n(d,u){const p=`client${(u||o.scroll)==="x"?"X":"Y"}`;return(en(d,t)?d:d.touches[0])[p]}function a(d){return i=d,s=d,n(d)}function l(d){const u=n(d)-n(s),g=r(d)-r(i)>170;return s=d,g&&(i=d),u}function c(d){if(!i||!s)return 0;const u=n(s)-n(i),g=r(d)-r(i),p=r(d)-r(s)>170,f=u/g;return g&&!p&&ot(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:n}}function lp(){function o(e){const{offsetTop:i,offsetLeft:s,offsetWidth:r,offsetHeight:n}=e;return{top:i,right:s+r,bottom:i+n,left:s,width:r,height:n}}return{measure:o}}function cp(o){function t(i){return o*(i/100)}return{measure:t}}function hp(o,t,e,i,s,r,n){const a=[o].concat(i);let l,c,h=[],d=!1;function u(b){return s.measureSize(n.measure(b))}function g(b){if(!r)return;c=u(o),h=i.map(u);function m(y){for(const w of y){if(d)return;const T=w.target===o,k=i.indexOf(w.target),O=T?c:h[k],E=u(T?o:i[k]);if(ot(E-O)>=.5){b.reInit(),t.emit("resize");break}}}l=new ResizeObserver(y=>{(no(r)||r(b,y))&&m(y)}),e.requestAnimationFrame(()=>{a.forEach(y=>l.observe(y))})}function p(){d=!0,l&&l.disconnect()}return{init:g,destroy:p}}function dp(o,t,e,i,s,r){let n=0,a=0,l=s,c=r,h=o.get(),d=0;function u(){const O=i.get()-o.get(),E=!l;let S=0;return E?(n=0,e.set(i),o.set(i),S=O):(e.set(o),n+=O/l,n*=c,h+=n,o.add(n),S=h-d),a=Tn(S),d=h,k}function g(){const O=i.get()-t.get();return ot(O)<.001}function p(){return l}function f(){return a}function b(){return n}function m(){return w(s)}function y(){return T(r)}function w(O){return l=O,k}function T(O){return c=O,k}const k={direction:f,duration:p,velocity:b,seek:u,settled:g,useBaseFriction:y,useBaseDuration:m,useFriction:T,useDuration:w};return k}function up(o,t,e,i,s){const r=s.measure(10),n=s.measure(50),a=ji(.1,.99);let l=!1;function c(){return!(l||!o.reachedAny(e.get())||!o.reachedAny(t.get()))}function h(g){if(!c())return;const p=o.reachedMin(t.get())?"min":"max",f=ot(o[p]-t.get()),b=e.get()-t.get(),m=a.constrain(f/n);e.subtract(b*m),!g&&ot(b)<r&&(e.set(o.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(g){l=!g}return{shouldConstrain:c,constrain:h,toggleActive:d}}function pp(o,t,e,i,s){const r=ji(-t+o,0),n=d(),a=h(),l=u();function c(p,f){return Ps(p,f)<=1}function h(){const p=n[0],f=Te(n),b=n.lastIndexOf(p),m=n.indexOf(f)+1;return ji(b,m)}function d(){return e.map((p,f)=>{const{min:b,max:m}=r,y=r.constrain(p),w=!f,T=En(e,f);return w?m:T||c(b,y)?b:c(m,y)?m:y}).map(p=>parseFloat(p.toFixed(3)))}function u(){if(t<=o+s)return[r.max];if(i==="keepSnaps")return n;const{min:p,max:f}=a;return n.slice(p,f)}return{snapsContained:l,scrollContainLimit:a}}function gp(o,t,e){const i=t[0],s=e?i-o:Te(t);return{limit:ji(s,i)}}function fp(o,t,e,i){const r=t.min+.1,n=t.max+.1,{reachedMin:a,reachedMax:l}=ji(r,n);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const g=o*(u*-1);i.forEach(p=>p.add(g))}return{loop:h}}function mp(o){const{max:t,length:e}=o;function i(r){const n=r-t;return e?n/-e:0}return{get:i}}function bp(o,t,e,i,s){const{startEdge:r,endEdge:n}=o,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=g();function d(){return a(i).map(f=>Te(f)[n]-f[0][r]).map(ot)}function u(){return i.map(f=>e[r]-f[r]).map(f=>-ot(f))}function g(){return a(c).map(f=>f[0]).map((f,b)=>f+l[b])}return{snaps:c,snapsAligned:h}}function vp(o,t,e,i,s,r){const{groupSlides:n}=s,{min:a,max:l}=i,c=h();function h(){const u=n(r),g=!o||t==="keepSnaps";return e.length===1?[r]:g?u:u.slice(a,l).map((p,f,b)=>{const m=!f,y=En(b,f);if(m){const w=Te(b[0])+1;return Ra(w)}if(y){const w=Ws(r)-Te(b)[0]+1;return Ra(w,Te(b)[0])}return p})}return{slideRegistry:c}}function _p(o,t,e,i,s){const{reachedAny:r,removeOffset:n,constrain:a}=i;function l(p){return p.concat().sort((f,b)=>ot(f)-ot(b))[0]}function c(p){const f=o?n(p):a(p),b=t.map((y,w)=>({diff:h(y-f,0),index:w})).sort((y,w)=>ot(y.diff)-ot(w.diff)),{index:m}=b[0];return{index:m,distance:f}}function h(p,f){const b=[p,p+e,p-e];if(!o)return p;if(!f)return l(b);const m=b.filter(y=>Tn(y)===f);return m.length?l(m):Te(b)-e}function d(p,f){const b=t[p]-s.get(),m=h(b,f);return{index:p,distance:m}}function u(p,f){const b=s.get()+p,{index:m,distance:y}=c(b),w=!o&&r(b);if(!f||w)return{index:m,distance:p};const T=t[m]-y,k=p+h(T,0);return{index:m,distance:k}}return{byDistance:u,byIndex:d,shortcut:h}}function yp(o,t,e,i,s,r,n){function a(d){const u=d.distance,g=d.index!==t.get();r.add(u),u&&(i.duration()?o.start():(o.update(),o.render(1),o.update())),g&&(e.set(t.get()),t.set(d.index),n.emit("select"))}function l(d,u){const g=s.byDistance(d,u);a(g)}function c(d,u){const g=t.clone().set(d),p=s.byIndex(g.get(),u);a(p)}return{distance:l,index:c}}function xp(o,t,e,i,s,r,n,a){const l={passive:!0,capture:!0};let c=0;function h(g){if(!a)return;function p(f){if(new Date().getTime()-c>10)return;n.emit("slideFocusStart"),o.scrollLeft=0;const y=e.findIndex(w=>w.includes(f));Sn(y)&&(s.useDuration(0),i.index(y,0),n.emit("slideFocus"))}r.add(document,"keydown",d,!1),t.forEach((f,b)=>{r.add(f,"focus",m=>{(no(a)||a(g,m))&&p(b)},l)})}function d(g){g.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Ss(o){let t=o;function e(){return t}function i(l){t=n(l)}function s(l){t+=n(l)}function r(l){t-=n(l)}function n(l){return Sn(l)?l:l.get()}return{get:e,set:i,add:s,subtract:r}}function tc(o,t){const e=o.scroll==="x"?n:a,i=t.style;let s=null,r=!1;function n(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(r)return;const g=ip(o.direction(u));g!==s&&(i.transform=e(g),s=g)}function c(u){r=!u}function h(){r||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function wp(o,t,e,i,s,r,n,a,l){const h=js(s),d=js(s).reverse(),u=m().concat(y());function g(E,S){return E.reduce((D,I)=>D-s[I],S)}function p(E,S){return E.reduce((D,I)=>g(D,S)>0?D.concat([I]):D,[])}function f(E){return r.map((S,D)=>({start:S-i[D]+.5+E,end:S+t-.5+E}))}function b(E,S,D){const I=f(S);return E.map(M=>{const B=D?0:-e,R=D?e:0,F=D?"end":"start",Y=I[M][F];return{index:M,loopPoint:Y,slideLocation:Ss(-1),translate:tc(o,l[M]),target:()=>a.get()>Y?B:R}})}function m(){const E=n[0],S=p(d,E);return b(S,e,!1)}function y(){const E=t-n[0]-1,S=p(h,E);return b(S,-e,!0)}function w(){return u.every(({index:E})=>{const S=h.filter(D=>D!==E);return g(S,t)<=.1})}function T(){u.forEach(E=>{const{target:S,translate:D,slideLocation:I}=E,M=S();M!==I.get()&&(D.to(M),I.set(M))})}function k(){u.forEach(E=>E.translate.clear())}return{canLoop:w,clear:k,loop:T,loopPoints:u}}function Cp(o,t,e){let i,s=!1;function r(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(no(e)||e(l,h))&&c(h)}),i.observe(o,{childList:!0})}function n(){i&&i.disconnect(),s=!0}return{init:r,destroy:n}}function Sp(o,t,e,i){const s={};let r=null,n=null,a,l=!1;function c(){a=new IntersectionObserver(p=>{l||(p.forEach(f=>{const b=t.indexOf(f.target);s[b]=f}),r=null,n=null,e.emit("slidesInView"))},{root:o.parentElement,threshold:i}),t.forEach(p=>a.observe(p))}function h(){a&&a.disconnect(),l=!0}function d(p){return $s(s).reduce((f,b)=>{const m=parseInt(b),{isIntersecting:y}=s[m];return(p&&y||!p&&!y)&&f.push(m),f},[])}function u(p=!0){if(p&&r)return r;if(!p&&n)return n;const f=d(p);return p&&(r=f),p||(n=f),f}return{init:c,destroy:h,get:u}}function Tp(o,t,e,i,s,r){const{measureSize:n,startEdge:a,endEdge:l}=o,c=e[0]&&s,h=p(),d=f(),u=e.map(n),g=b();function p(){if(!c)return 0;const y=e[0];return ot(t[a]-y[a])}function f(){if(!c)return 0;const y=r.getComputedStyle(Te(i));return parseFloat(y.getPropertyValue(`margin-${l}`))}function b(){return e.map((y,w,T)=>{const k=!w,O=En(T,w);return k?u[w]+h:O?u[w]+d:T[w+1][a]-y[a]}).map(ot)}return{slideSizes:u,slideSizesWithGaps:g,startGap:h,endGap:d}}function Ep(o,t,e,i,s,r,n,a,l){const{startEdge:c,endEdge:h,direction:d}=o,u=Sn(e);function g(m,y){return js(m).filter(w=>w%y===0).map(w=>m.slice(w,w+y))}function p(m){return m.length?js(m).reduce((y,w,T)=>{const k=Te(y)||0,O=k===0,E=w===Ws(m),S=s[c]-r[k][c],D=s[c]-r[w][h],I=!i&&O?d(n):0,M=!i&&E?d(a):0,B=ot(D-M-(S+I));return T&&B>t+l&&y.push(w),E&&y.push(m.length),y},[]).map((y,w,T)=>{const k=Math.max(T[w-1]||0);return m.slice(k,y)}):[]}function f(m){return u?g(m,e):p(m)}return{groupSlides:f}}function kp(o,t,e,i,s,r,n){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:g,dragThreshold:p,inViewThreshold:f,slidesToScroll:b,skipSnaps:m,containScroll:y,watchResize:w,watchSlides:T,watchDrag:k,watchFocus:O}=r,E=2,S=lp(),D=S.measure(t),I=e.map(S.measure),M=op(l,c),B=M.measureSize(D),R=cp(B),F=sp(a,B),Y=!d&&!!y,tt=d||!!y,{slideSizes:xt,slideSizesWithGaps:W,startGap:wt,endGap:Gt}=Tp(M,D,I,e,tt,s),Yt=Ep(M,B,b,d,D,I,wt,Gt,E),{snaps:Oe,snapsAligned:fe}=bp(M,F,D,I,Yt),It=-Te(Oe)+Te(W),{snapsContained:Pe,scrollContainLimit:le}=pp(B,It,fe,y,E),Ot=Y?Pe:fe,{limit:Ft}=gp(It,Ot,d),ce=Ql(Ws(Ot),h,d),gt=ce.clone(),st=js(e),A=({dragHandler:Ui,scrollBody:xo,scrollBounds:wo,options:{loop:Qs}})=>{Qs||wo.constrain(Ui.pointerDown()),xo.seek()},J=({scrollBody:Ui,translate:xo,location:wo,offsetLocation:Qs,previousLocation:oh,scrollLooper:nh,slideLooper:ah,dragHandler:lh,animation:ch,eventHandler:Jn,scrollBounds:hh,options:{loop:Qn}},ta)=>{const ea=Ui.settled(),dh=!hh.shouldConstrain(),ia=Qn?ea:ea&&dh,sa=ia&&!lh.pointerDown();sa&&ch.stop();const uh=wo.get()*ta+oh.get()*(1-ta);Qs.set(uh),Qn&&(nh.loop(Ui.direction()),ah.loop()),xo.to(Qs.get()),sa&&Jn.emit("settle"),ia||Jn.emit("scroll")},Ct=rp(i,s,()=>A(yo),Ui=>J(yo,Ui)),Xt=.68,De=Ot[ce.get()],Ve=Ss(De),Ci=Ss(De),oi=Ss(De),Si=Ss(De),ps=dp(Ve,oi,Ci,Si,u,Xt),vo=_p(d,Ot,It,Ft,Si),_o=yp(Ct,ce,gt,ps,vo,Si,n),qn=mp(Ft),Kn=Bs(),sh=Sp(t,e,n,f),{slideRegistry:Zn}=vp(Y,y,Ot,le,Yt,st),rh=xp(o,e,Zn,_o,ps,Kn,n,O),yo={ownerDocument:i,ownerWindow:s,eventHandler:n,containerRect:D,slideRects:I,animation:Ct,axis:M,dragHandler:np(M,o,i,s,Si,ap(M,s),Ve,Ct,_o,ps,vo,ce,n,R,g,p,m,Xt,k),eventStore:Kn,percentOfView:R,index:ce,indexPrevious:gt,limit:Ft,location:Ve,offsetLocation:oi,previousLocation:Ci,options:r,resizeHandler:hp(t,n,s,e,M,w,S),scrollBody:ps,scrollBounds:up(Ft,oi,Si,ps,R),scrollLooper:fp(It,Ft,oi,[Ve,oi,Ci,Si]),scrollProgress:qn,scrollSnapList:Ot.map(qn.get),scrollSnaps:Ot,scrollTarget:vo,scrollTo:_o,slideLooper:wp(M,B,It,xt,W,Oe,Ot,oi,e),slideFocus:rh,slidesHandler:Cp(t,n,T),slidesInView:sh,slideIndexes:st,slideRegistry:Zn,slidesToScroll:Yt,target:Si,translate:tc(M,t)};return yo}function Op(){let o={},t;function e(c){t=c}function i(c){return o[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function r(c,h){return o[c]=i(c).concat([h]),l}function n(c,h){return o[c]=i(c).filter(d=>d!==h),l}function a(){o={}}const l={init:e,emit:s,off:n,on:r,clear:a};return l}const Pp={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Dp(o){function t(r,n){return Jl(r,n||{})}function e(r){const n=r.breakpoints||{},a=$s(n).filter(l=>o.matchMedia(l).matches).map(l=>n[l]).reduce((l,c)=>t(l,c),{});return t(r,a)}function i(r){return r.map(n=>$s(n.breakpoints||{})).reduce((n,a)=>n.concat(a),[]).map(o.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function Ap(o){let t=[];function e(r,n){return t=n.filter(({options:a})=>o.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(r,o)),n.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(r=>r.destroy())}return{init:e,destroy:i}}function kn(o,t,e){const i=o.ownerDocument,s=i.defaultView,r=Dp(s),n=Ap(r),a=Bs(),l=Op(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=r,{on:u,off:g,emit:p}=l,f=M;let b=!1,m,y=c(Pp,kn.globalOptions),w=c(y),T=[],k,O,E;function S(){const{container:st,slides:A}=w;O=(tn(st)?o.querySelector(st):st)||o.children[0];const Ct=tn(A)?O.querySelectorAll(A):A;E=[].slice.call(Ct||O.children)}function D(st){const A=kp(o,O,E,i,s,st,l);if(st.loop&&!A.slideLooper.canLoop()){const J=Object.assign({},st,{loop:!1});return D(J)}return A}function I(st,A){b||(y=c(y,st),w=h(y),T=A||T,S(),m=D(w),d([y,...T.map(({options:J})=>J)]).forEach(J=>a.add(J,"change",M)),w.active&&(m.translate.to(m.location.get()),m.animation.init(),m.slidesInView.init(),m.slideFocus.init(gt),m.eventHandler.init(gt),m.resizeHandler.init(gt),m.slidesHandler.init(gt),m.options.loop&&m.slideLooper.loop(),O.offsetParent&&E.length&&m.dragHandler.init(gt),k=n.init(gt,T)))}function M(st,A){const J=Yt();B(),I(c({startIndex:J},st),A),l.emit("reInit")}function B(){m.dragHandler.destroy(),m.eventStore.clear(),m.translate.clear(),m.slideLooper.clear(),m.resizeHandler.destroy(),m.slidesHandler.destroy(),m.slidesInView.destroy(),m.animation.destroy(),n.destroy(),a.clear()}function R(){b||(b=!0,a.clear(),B(),l.emit("destroy"),l.clear())}function F(st,A,J){!w.active||b||(m.scrollBody.useBaseFriction().useDuration(A===!0?0:w.duration),m.scrollTo.index(st,J||0))}function Y(st){const A=m.index.add(1).get();F(A,st,-1)}function tt(st){const A=m.index.add(-1).get();F(A,st,1)}function xt(){return m.index.add(1).get()!==Yt()}function W(){return m.index.add(-1).get()!==Yt()}function wt(){return m.scrollSnapList}function Gt(){return m.scrollProgress.get(m.offsetLocation.get())}function Yt(){return m.index.get()}function Oe(){return m.indexPrevious.get()}function fe(){return m.slidesInView.get()}function It(){return m.slidesInView.get(!1)}function Pe(){return k}function le(){return m}function Ot(){return o}function Ft(){return O}function ce(){return E}const gt={canScrollNext:xt,canScrollPrev:W,containerNode:Ft,internalEngine:le,destroy:R,off:g,on:u,emit:p,plugins:Pe,previousScrollSnap:Oe,reInit:f,rootNode:Ot,scrollNext:Y,scrollPrev:tt,scrollProgress:Gt,scrollSnapList:wt,scrollTo:F,selectedScrollSnap:Yt,slideNodes:ce,slidesInView:fe,slidesNotInView:It};return I(t,e),setTimeout(()=>l.emit("init"),0),gt}kn.globalOptions=void 0;var Mp=Object.defineProperty,Ip=Object.getOwnPropertyDescriptor,Gs=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ip(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Mp(t,e,s),s};let mi=class extends yt{constructor(){super(...arguments),this.cards=[],this.skeleton=!1,this.firstUpdated=()=>{const t={align:"start",axis:"x",loop:!1},e=this.shadowRoot.querySelector(".embla"),i=e.querySelector(".embla__viewport"),s=e.querySelector(".embla__button--prev"),r=e.querySelector(".embla__button--next"),n=kn(i,t),a=this.addPrevNextBtnsClickHandlers(n,s,r);n.on("destroy",a),n.on("reInit",()=>{var l,c;!n.canScrollPrev()&&!n.canScrollNext()?(console.debug("No previous or next slides available, hiding arrows."),((l=this.shadowRoot)==null?void 0:l.querySelectorAll(".embla__button_container")).forEach(d=>{d.style.visibility="hidden"})):(console.debug("Previous or next slides available, showing arrows."),((c=this.shadowRoot)==null?void 0:c.querySelectorAll(".embla__button_container")).forEach(d=>{d.style.visibility="visible"}))})},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),(t=this.imageSplide)==null||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId}})},this.addTogglePrevNextBtnsActive=(t,e,i)=>{const s=()=>{t.canScrollPrev()?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),t.canScrollNext()?i.removeAttribute("disabled"):i.setAttribute("disabled","disabled")};return t.on("select",s).on("init",s).on("reInit",s),()=>{e.removeAttribute("disabled"),i.removeAttribute("disabled")}}}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"}addPrevNextBtnsClickHandlers(t,e,i){const s=()=>{t.scrollPrev()},r=()=>{t.scrollNext()};e.addEventListener("click",s,!1),i.addEventListener("click",r,!1);const n=this.addTogglePrevNextBtnsActive(t,e,i);return()=>{n(),e.removeEventListener("click",s,!1),i.removeEventListener("click",r,!1)}}render(){return this.skeleton?L`
2182
+ */function*Zl(o,t){if(o!==void 0){let e=0;for(const i of o)yield t(i,e++)}}function Sn(o){return typeof o=="number"}function tn(o){return typeof o=="string"}function no(o){return typeof o=="boolean"}function Ba(o){return Object.prototype.toString.call(o)==="[object Object]"}function nt(o){return Math.abs(o)}function Tn(o){return Math.sign(o)}function Ds(o,t){return nt(o-t)}function ep(o,t){if(o===0||t===0||nt(o)<=nt(t))return 0;const e=Ds(nt(o),nt(t));return nt(e/o)}function ip(o){return Math.round(o*100)/100}function $s(o){return Bs(o).map(Number)}function Ee(o){return o[Gs(o)]}function Gs(o){return Math.max(0,o.length-1)}function En(o,t){return t===Gs(o)}function Ra(o,t=0){return Array.from(Array(o),(e,i)=>t+i)}function Bs(o){return Object.keys(o)}function Jl(o,t){return[o,t].reduce((e,i)=>(Bs(i).forEach(s=>{const r=e[s],n=i[s],a=Ba(r)&&Ba(n);e[s]=a?Jl(r,n):n}),e),{})}function en(o,t){return typeof t.MouseEvent<"u"&&o instanceof t.MouseEvent}function sp(o,t){const e={start:i,center:s,end:r};function i(){return 0}function s(l){return r(l)/2}function r(l){return t-l}function n(l,c){return tn(o)?e[o](l):o(t,l,c)}return{measure:n}}function Rs(){let o=[];function t(s,r,n,a={passive:!0}){let l;if("addEventListener"in s)s.addEventListener(r,n,a),l=()=>s.removeEventListener(r,n,a);else{const c=s;c.addListener(n),l=()=>c.removeListener(n)}return o.push(l),i}function e(){o=o.filter(s=>s())}const i={add:t,clear:e};return i}function rp(o,t,e,i){const s=Rs(),r=1e3/60;let n=null,a=0,l=0;function c(){s.add(o,"visibilitychange",()=>{o.hidden&&p()})}function h(){g(),s.clear()}function d(b){if(!l)return;n||(n=b,e(),e());const m=b-n;for(n=b,a+=m;a>=r;)e(),a-=r;const y=a/r;i(y),l&&(l=t.requestAnimationFrame(d))}function u(){l||(l=t.requestAnimationFrame(d))}function g(){t.cancelAnimationFrame(l),n=null,a=0,l=0}function p(){n=null,a=0}return{init:c,destroy:h,start:u,stop:g,update:e,render:i}}function op(o,t){const e=t==="rtl",i=o==="y",s=i?"y":"x",r=i?"x":"y",n=!i&&e?-1:1,a=h(),l=d();function c(p){const{height:f,width:b}=p;return i?f:b}function h(){return i?"top":e?"right":"left"}function d(){return i?"bottom":e?"left":"right"}function u(p){return p*n}return{scroll:s,cross:r,startEdge:a,endEdge:l,measureSize:c,direction:u}}function ji(o=0,t=0){const e=nt(o-t);function i(c){return c<o}function s(c){return c>t}function r(c){return i(c)||s(c)}function n(c){return r(c)?i(c)?o:t:c}function a(c){return e?c-e*Math.ceil((c-t)/e):c}return{length:e,max:t,min:o,constrain:n,reachedAny:r,reachedMax:s,reachedMin:i,removeOffset:a}}function Ql(o,t,e){const{constrain:i}=ji(0,o),s=o+1;let r=n(t);function n(u){return e?nt((s+u)%s):i(u)}function a(){return r}function l(u){return r=n(u),d}function c(u){return h().set(a()+u)}function h(){return Ql(o,a(),e)}const d={get:a,set:l,add:c,clone:h};return d}function np(o,t,e,i,s,r,n,a,l,c,h,d,u,g,p,f,b,m,y){const{cross:w,direction:T}=o,k=["INPUT","SELECT","TEXTAREA"],O={passive:!1},E=Rs(),S=Rs(),D=ji(50,225).constrain(g.measure(20)),I={mouse:300,touch:400},M={mouse:500,touch:600},B=p?43:25;let R=!1,F=0,Y=0,tt=!1,xt=!1,W=!1,wt=!1;function Gt(A){if(!y)return;function J(Xt){(no(y)||y(A,Xt))&&le(Xt)}const Ct=t;E.add(Ct,"dragstart",Xt=>Xt.preventDefault(),O).add(Ct,"touchmove",()=>{},O).add(Ct,"touchend",()=>{}).add(Ct,"touchstart",J).add(Ct,"mousedown",J).add(Ct,"touchcancel",Ft).add(Ct,"contextmenu",Ft).add(Ct,"click",ce,!0)}function Yt(){E.clear(),S.clear()}function Pe(){const A=wt?e:t;S.add(A,"touchmove",kt,O).add(A,"touchend",Ft).add(A,"mousemove",kt,O).add(A,"mouseup",Ft)}function me(A){const J=A.nodeName||"";return k.includes(J)}function It(){return(p?M:I)[wt?"mouse":"touch"]}function De(A,J){const Ct=d.add(Tn(A)*-1),Xt=h.byDistance(A,!p).distance;return p||nt(A)<D?Xt:b&&J?Xt*.5:h.byIndex(Ct.get(),0).distance}function le(A){const J=en(A,i);wt=J,W=p&&J&&!A.buttons&&R,R=Ds(s.get(),n.get())>=2,!(J&&A.button!==0)&&(me(A.target)||(tt=!0,r.pointerDown(A),c.useFriction(0).useDuration(0),s.set(n),Pe(),F=r.readPoint(A),Y=r.readPoint(A,w),u.emit("pointerDown")))}function kt(A){if(!en(A,i)&&A.touches.length>=2)return Ft(A);const Ct=r.readPoint(A),Xt=r.readPoint(A,w),Ae=Ds(Ct,F),We=Ds(Xt,Y);if(!xt&&!wt&&(!A.cancelable||(xt=Ae>We,!xt)))return Ft(A);const Si=r.pointerMove(A);Ae>f&&(W=!0),c.useFriction(.3).useDuration(.75),a.start(),s.add(T(Si)),A.preventDefault()}function Ft(A){const Ct=h.byDistance(0,!1).index!==d.get(),Xt=r.pointerUp(A)*It(),Ae=De(T(Xt),Ct),We=ep(Xt,Ae),Si=B-10*We,ai=m+We/50;xt=!1,tt=!1,S.clear(),c.useDuration(Si).useFriction(ai),l.distance(Ae,!p),wt=!1,u.emit("pointerUp")}function ce(A){W&&(A.stopPropagation(),A.preventDefault(),W=!1)}function ft(){return tt}return{init:Gt,destroy:Yt,pointerDown:ft}}function ap(o,t){let i,s;function r(d){return d.timeStamp}function n(d,u){const p=`client${(u||o.scroll)==="x"?"X":"Y"}`;return(en(d,t)?d:d.touches[0])[p]}function a(d){return i=d,s=d,n(d)}function l(d){const u=n(d)-n(s),g=r(d)-r(i)>170;return s=d,g&&(i=d),u}function c(d){if(!i||!s)return 0;const u=n(s)-n(i),g=r(d)-r(i),p=r(d)-r(s)>170,f=u/g;return g&&!p&&nt(f)>.1?f:0}return{pointerDown:a,pointerMove:l,pointerUp:c,readPoint:n}}function lp(){function o(e){const{offsetTop:i,offsetLeft:s,offsetWidth:r,offsetHeight:n}=e;return{top:i,right:s+r,bottom:i+n,left:s,width:r,height:n}}return{measure:o}}function cp(o){function t(i){return o*(i/100)}return{measure:t}}function hp(o,t,e,i,s,r,n){const a=[o].concat(i);let l,c,h=[],d=!1;function u(b){return s.measureSize(n.measure(b))}function g(b){if(!r)return;c=u(o),h=i.map(u);function m(y){for(const w of y){if(d)return;const T=w.target===o,k=i.indexOf(w.target),O=T?c:h[k],E=u(T?o:i[k]);if(nt(E-O)>=.5){b.reInit(),t.emit("resize");break}}}l=new ResizeObserver(y=>{(no(r)||r(b,y))&&m(y)}),e.requestAnimationFrame(()=>{a.forEach(y=>l.observe(y))})}function p(){d=!0,l&&l.disconnect()}return{init:g,destroy:p}}function dp(o,t,e,i,s,r){let n=0,a=0,l=s,c=r,h=o.get(),d=0;function u(){const O=i.get()-o.get(),E=!l;let S=0;return E?(n=0,e.set(i),o.set(i),S=O):(e.set(o),n+=O/l,n*=c,h+=n,o.add(n),S=h-d),a=Tn(S),d=h,k}function g(){const O=i.get()-t.get();return nt(O)<.001}function p(){return l}function f(){return a}function b(){return n}function m(){return w(s)}function y(){return T(r)}function w(O){return l=O,k}function T(O){return c=O,k}const k={direction:f,duration:p,velocity:b,seek:u,settled:g,useBaseFriction:y,useBaseDuration:m,useFriction:T,useDuration:w};return k}function up(o,t,e,i,s){const r=s.measure(10),n=s.measure(50),a=ji(.1,.99);let l=!1;function c(){return!(l||!o.reachedAny(e.get())||!o.reachedAny(t.get()))}function h(g){if(!c())return;const p=o.reachedMin(t.get())?"min":"max",f=nt(o[p]-t.get()),b=e.get()-t.get(),m=a.constrain(f/n);e.subtract(b*m),!g&&nt(b)<r&&(e.set(o.constrain(e.get())),i.useDuration(25).useBaseFriction())}function d(g){l=!g}return{shouldConstrain:c,constrain:h,toggleActive:d}}function pp(o,t,e,i,s){const r=ji(-t+o,0),n=d(),a=h(),l=u();function c(p,f){return Ds(p,f)<=1}function h(){const p=n[0],f=Ee(n),b=n.lastIndexOf(p),m=n.indexOf(f)+1;return ji(b,m)}function d(){return e.map((p,f)=>{const{min:b,max:m}=r,y=r.constrain(p),w=!f,T=En(e,f);return w?m:T||c(b,y)?b:c(m,y)?m:y}).map(p=>parseFloat(p.toFixed(3)))}function u(){if(t<=o+s)return[r.max];if(i==="keepSnaps")return n;const{min:p,max:f}=a;return n.slice(p,f)}return{snapsContained:l,scrollContainLimit:a}}function gp(o,t,e){const i=t[0],s=e?i-o:Ee(t);return{limit:ji(s,i)}}function fp(o,t,e,i){const r=t.min+.1,n=t.max+.1,{reachedMin:a,reachedMax:l}=ji(r,n);function c(u){return u===1?l(e.get()):u===-1?a(e.get()):!1}function h(u){if(!c(u))return;const g=o*(u*-1);i.forEach(p=>p.add(g))}return{loop:h}}function mp(o){const{max:t,length:e}=o;function i(r){const n=r-t;return e?n/-e:0}return{get:i}}function bp(o,t,e,i,s){const{startEdge:r,endEdge:n}=o,{groupSlides:a}=s,l=d().map(t.measure),c=u(),h=g();function d(){return a(i).map(f=>Ee(f)[n]-f[0][r]).map(nt)}function u(){return i.map(f=>e[r]-f[r]).map(f=>-nt(f))}function g(){return a(c).map(f=>f[0]).map((f,b)=>f+l[b])}return{snaps:c,snapsAligned:h}}function vp(o,t,e,i,s,r){const{groupSlides:n}=s,{min:a,max:l}=i,c=h();function h(){const u=n(r),g=!o||t==="keepSnaps";return e.length===1?[r]:g?u:u.slice(a,l).map((p,f,b)=>{const m=!f,y=En(b,f);if(m){const w=Ee(b[0])+1;return Ra(w)}if(y){const w=Gs(r)-Ee(b)[0]+1;return Ra(w,Ee(b)[0])}return p})}return{slideRegistry:c}}function _p(o,t,e,i,s){const{reachedAny:r,removeOffset:n,constrain:a}=i;function l(p){return p.concat().sort((f,b)=>nt(f)-nt(b))[0]}function c(p){const f=o?n(p):a(p),b=t.map((y,w)=>({diff:h(y-f,0),index:w})).sort((y,w)=>nt(y.diff)-nt(w.diff)),{index:m}=b[0];return{index:m,distance:f}}function h(p,f){const b=[p,p+e,p-e];if(!o)return p;if(!f)return l(b);const m=b.filter(y=>Tn(y)===f);return m.length?l(m):Ee(b)-e}function d(p,f){const b=t[p]-s.get(),m=h(b,f);return{index:p,distance:m}}function u(p,f){const b=s.get()+p,{index:m,distance:y}=c(b),w=!o&&r(b);if(!f||w)return{index:m,distance:p};const T=t[m]-y,k=p+h(T,0);return{index:m,distance:k}}return{byDistance:u,byIndex:d,shortcut:h}}function yp(o,t,e,i,s,r,n){function a(d){const u=d.distance,g=d.index!==t.get();r.add(u),u&&(i.duration()?o.start():(o.update(),o.render(1),o.update())),g&&(e.set(t.get()),t.set(d.index),n.emit("select"))}function l(d,u){const g=s.byDistance(d,u);a(g)}function c(d,u){const g=t.clone().set(d),p=s.byIndex(g.get(),u);a(p)}return{distance:l,index:c}}function xp(o,t,e,i,s,r,n,a){const l={passive:!0,capture:!0};let c=0;function h(g){if(!a)return;function p(f){if(new Date().getTime()-c>10)return;n.emit("slideFocusStart"),o.scrollLeft=0;const y=e.findIndex(w=>w.includes(f));Sn(y)&&(s.useDuration(0),i.index(y,0),n.emit("slideFocus"))}r.add(document,"keydown",d,!1),t.forEach((f,b)=>{r.add(f,"focus",m=>{(no(a)||a(g,m))&&p(b)},l)})}function d(g){g.code==="Tab"&&(c=new Date().getTime())}return{init:h}}function Ts(o){let t=o;function e(){return t}function i(l){t=n(l)}function s(l){t+=n(l)}function r(l){t-=n(l)}function n(l){return Sn(l)?l:l.get()}return{get:e,set:i,add:s,subtract:r}}function tc(o,t){const e=o.scroll==="x"?n:a,i=t.style;let s=null,r=!1;function n(u){return`translate3d(${u}px,0px,0px)`}function a(u){return`translate3d(0px,${u}px,0px)`}function l(u){if(r)return;const g=ip(o.direction(u));g!==s&&(i.transform=e(g),s=g)}function c(u){r=!u}function h(){r||(i.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:c}}function wp(o,t,e,i,s,r,n,a,l){const h=$s(s),d=$s(s).reverse(),u=m().concat(y());function g(E,S){return E.reduce((D,I)=>D-s[I],S)}function p(E,S){return E.reduce((D,I)=>g(D,S)>0?D.concat([I]):D,[])}function f(E){return r.map((S,D)=>({start:S-i[D]+.5+E,end:S+t-.5+E}))}function b(E,S,D){const I=f(S);return E.map(M=>{const B=D?0:-e,R=D?e:0,F=D?"end":"start",Y=I[M][F];return{index:M,loopPoint:Y,slideLocation:Ts(-1),translate:tc(o,l[M]),target:()=>a.get()>Y?B:R}})}function m(){const E=n[0],S=p(d,E);return b(S,e,!1)}function y(){const E=t-n[0]-1,S=p(h,E);return b(S,-e,!0)}function w(){return u.every(({index:E})=>{const S=h.filter(D=>D!==E);return g(S,t)<=.1})}function T(){u.forEach(E=>{const{target:S,translate:D,slideLocation:I}=E,M=S();M!==I.get()&&(D.to(M),I.set(M))})}function k(){u.forEach(E=>E.translate.clear())}return{canLoop:w,clear:k,loop:T,loopPoints:u}}function Cp(o,t,e){let i,s=!1;function r(l){if(!e)return;function c(h){for(const d of h)if(d.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}i=new MutationObserver(h=>{s||(no(e)||e(l,h))&&c(h)}),i.observe(o,{childList:!0})}function n(){i&&i.disconnect(),s=!0}return{init:r,destroy:n}}function Sp(o,t,e,i){const s={};let r=null,n=null,a,l=!1;function c(){a=new IntersectionObserver(p=>{l||(p.forEach(f=>{const b=t.indexOf(f.target);s[b]=f}),r=null,n=null,e.emit("slidesInView"))},{root:o.parentElement,threshold:i}),t.forEach(p=>a.observe(p))}function h(){a&&a.disconnect(),l=!0}function d(p){return Bs(s).reduce((f,b)=>{const m=parseInt(b),{isIntersecting:y}=s[m];return(p&&y||!p&&!y)&&f.push(m),f},[])}function u(p=!0){if(p&&r)return r;if(!p&&n)return n;const f=d(p);return p&&(r=f),p||(n=f),f}return{init:c,destroy:h,get:u}}function Tp(o,t,e,i,s,r){const{measureSize:n,startEdge:a,endEdge:l}=o,c=e[0]&&s,h=p(),d=f(),u=e.map(n),g=b();function p(){if(!c)return 0;const y=e[0];return nt(t[a]-y[a])}function f(){if(!c)return 0;const y=r.getComputedStyle(Ee(i));return parseFloat(y.getPropertyValue(`margin-${l}`))}function b(){return e.map((y,w,T)=>{const k=!w,O=En(T,w);return k?u[w]+h:O?u[w]+d:T[w+1][a]-y[a]}).map(nt)}return{slideSizes:u,slideSizesWithGaps:g,startGap:h,endGap:d}}function Ep(o,t,e,i,s,r,n,a,l){const{startEdge:c,endEdge:h,direction:d}=o,u=Sn(e);function g(m,y){return $s(m).filter(w=>w%y===0).map(w=>m.slice(w,w+y))}function p(m){return m.length?$s(m).reduce((y,w,T)=>{const k=Ee(y)||0,O=k===0,E=w===Gs(m),S=s[c]-r[k][c],D=s[c]-r[w][h],I=!i&&O?d(n):0,M=!i&&E?d(a):0,B=nt(D-M-(S+I));return T&&B>t+l&&y.push(w),E&&y.push(m.length),y},[]).map((y,w,T)=>{const k=Math.max(T[w-1]||0);return m.slice(k,y)}):[]}function f(m){return u?g(m,e):p(m)}return{groupSlides:f}}function kp(o,t,e,i,s,r,n){const{align:a,axis:l,direction:c,startIndex:h,loop:d,duration:u,dragFree:g,dragThreshold:p,inViewThreshold:f,slidesToScroll:b,skipSnaps:m,containScroll:y,watchResize:w,watchSlides:T,watchDrag:k,watchFocus:O}=r,E=2,S=lp(),D=S.measure(t),I=e.map(S.measure),M=op(l,c),B=M.measureSize(D),R=cp(B),F=sp(a,B),Y=!d&&!!y,tt=d||!!y,{slideSizes:xt,slideSizesWithGaps:W,startGap:wt,endGap:Gt}=Tp(M,D,I,e,tt,s),Yt=Ep(M,B,b,d,D,I,wt,Gt,E),{snaps:Pe,snapsAligned:me}=bp(M,F,D,I,Yt),It=-Ee(Pe)+Ee(W),{snapsContained:De,scrollContainLimit:le}=pp(B,It,me,y,E),kt=Y?De:me,{limit:Ft}=gp(It,kt,d),ce=Ql(Gs(kt),h,d),ft=ce.clone(),rt=$s(e),A=({dragHandler:Ui,scrollBody:xo,scrollBounds:wo,options:{loop:Qs}})=>{Qs||wo.constrain(Ui.pointerDown()),xo.seek()},J=({scrollBody:Ui,translate:xo,location:wo,offsetLocation:Qs,previousLocation:oh,scrollLooper:nh,slideLooper:ah,dragHandler:lh,animation:ch,eventHandler:Jn,scrollBounds:hh,options:{loop:Qn}},ta)=>{const ea=Ui.settled(),dh=!hh.shouldConstrain(),ia=Qn?ea:ea&&dh,sa=ia&&!lh.pointerDown();sa&&ch.stop();const uh=wo.get()*ta+oh.get()*(1-ta);Qs.set(uh),Qn&&(nh.loop(Ui.direction()),ah.loop()),xo.to(Qs.get()),sa&&Jn.emit("settle"),ia||Jn.emit("scroll")},Ct=rp(i,s,()=>A(yo),Ui=>J(yo,Ui)),Xt=.68,Ae=kt[ce.get()],We=Ts(Ae),Si=Ts(Ae),ai=Ts(Ae),Ti=Ts(Ae),gs=dp(We,ai,Si,Ti,u,Xt),vo=_p(d,kt,It,Ft,Ti),_o=yp(Ct,ce,ft,gs,vo,Ti,n),qn=mp(Ft),Kn=Rs(),sh=Sp(t,e,n,f),{slideRegistry:Zn}=vp(Y,y,kt,le,Yt,rt),rh=xp(o,e,Zn,_o,gs,Kn,n,O),yo={ownerDocument:i,ownerWindow:s,eventHandler:n,containerRect:D,slideRects:I,animation:Ct,axis:M,dragHandler:np(M,o,i,s,Ti,ap(M,s),We,Ct,_o,gs,vo,ce,n,R,g,p,m,Xt,k),eventStore:Kn,percentOfView:R,index:ce,indexPrevious:ft,limit:Ft,location:We,offsetLocation:ai,previousLocation:Si,options:r,resizeHandler:hp(t,n,s,e,M,w,S),scrollBody:gs,scrollBounds:up(Ft,ai,Ti,gs,R),scrollLooper:fp(It,Ft,ai,[We,ai,Si,Ti]),scrollProgress:qn,scrollSnapList:kt.map(qn.get),scrollSnaps:kt,scrollTarget:vo,scrollTo:_o,slideLooper:wp(M,B,It,xt,W,Pe,kt,ai,e),slideFocus:rh,slidesHandler:Cp(t,n,T),slidesInView:sh,slideIndexes:rt,slideRegistry:Zn,slidesToScroll:Yt,target:Ti,translate:tc(M,t)};return yo}function Op(){let o={},t;function e(c){t=c}function i(c){return o[c]||[]}function s(c){return i(c).forEach(h=>h(t,c)),l}function r(c,h){return o[c]=i(c).concat([h]),l}function n(c,h){return o[c]=i(c).filter(d=>d!==h),l}function a(){o={}}const l={init:e,emit:s,off:n,on:r,clear:a};return l}const Pp={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function Dp(o){function t(r,n){return Jl(r,n||{})}function e(r){const n=r.breakpoints||{},a=Bs(n).filter(l=>o.matchMedia(l).matches).map(l=>n[l]).reduce((l,c)=>t(l,c),{});return t(r,a)}function i(r){return r.map(n=>Bs(n.breakpoints||{})).reduce((n,a)=>n.concat(a),[]).map(o.matchMedia)}return{mergeOptions:t,optionsAtMedia:e,optionsMediaQueries:i}}function Ap(o){let t=[];function e(r,n){return t=n.filter(({options:a})=>o.optionsAtMedia(a).active!==!1),t.forEach(a=>a.init(r,o)),n.reduce((a,l)=>Object.assign(a,{[l.name]:l}),{})}function i(){t=t.filter(r=>r.destroy())}return{init:e,destroy:i}}function kn(o,t,e){const i=o.ownerDocument,s=i.defaultView,r=Dp(s),n=Ap(r),a=Rs(),l=Op(),{mergeOptions:c,optionsAtMedia:h,optionsMediaQueries:d}=r,{on:u,off:g,emit:p}=l,f=M;let b=!1,m,y=c(Pp,kn.globalOptions),w=c(y),T=[],k,O,E;function S(){const{container:rt,slides:A}=w;O=(tn(rt)?o.querySelector(rt):rt)||o.children[0];const Ct=tn(A)?O.querySelectorAll(A):A;E=[].slice.call(Ct||O.children)}function D(rt){const A=kp(o,O,E,i,s,rt,l);if(rt.loop&&!A.slideLooper.canLoop()){const J=Object.assign({},rt,{loop:!1});return D(J)}return A}function I(rt,A){b||(y=c(y,rt),w=h(y),T=A||T,S(),m=D(w),d([y,...T.map(({options:J})=>J)]).forEach(J=>a.add(J,"change",M)),w.active&&(m.translate.to(m.location.get()),m.animation.init(),m.slidesInView.init(),m.slideFocus.init(ft),m.eventHandler.init(ft),m.resizeHandler.init(ft),m.slidesHandler.init(ft),m.options.loop&&m.slideLooper.loop(),O.offsetParent&&E.length&&m.dragHandler.init(ft),k=n.init(ft,T)))}function M(rt,A){const J=Yt();B(),I(c({startIndex:J},rt),A),l.emit("reInit")}function B(){m.dragHandler.destroy(),m.eventStore.clear(),m.translate.clear(),m.slideLooper.clear(),m.resizeHandler.destroy(),m.slidesHandler.destroy(),m.slidesInView.destroy(),m.animation.destroy(),n.destroy(),a.clear()}function R(){b||(b=!0,a.clear(),B(),l.emit("destroy"),l.clear())}function F(rt,A,J){!w.active||b||(m.scrollBody.useBaseFriction().useDuration(A===!0?0:w.duration),m.scrollTo.index(rt,J||0))}function Y(rt){const A=m.index.add(1).get();F(A,rt,-1)}function tt(rt){const A=m.index.add(-1).get();F(A,rt,1)}function xt(){return m.index.add(1).get()!==Yt()}function W(){return m.index.add(-1).get()!==Yt()}function wt(){return m.scrollSnapList}function Gt(){return m.scrollProgress.get(m.offsetLocation.get())}function Yt(){return m.index.get()}function Pe(){return m.indexPrevious.get()}function me(){return m.slidesInView.get()}function It(){return m.slidesInView.get(!1)}function De(){return k}function le(){return m}function kt(){return o}function Ft(){return O}function ce(){return E}const ft={canScrollNext:xt,canScrollPrev:W,containerNode:Ft,internalEngine:le,destroy:R,off:g,on:u,emit:p,plugins:De,previousScrollSnap:Pe,reInit:f,rootNode:kt,scrollNext:Y,scrollPrev:tt,scrollProgress:Gt,scrollSnapList:wt,scrollTo:F,selectedScrollSnap:Yt,slideNodes:ce,slidesInView:me,slidesNotInView:It};return I(t,e),setTimeout(()=>l.emit("init"),0),ft}kn.globalOptions=void 0;var Mp=Object.defineProperty,Ip=Object.getOwnPropertyDescriptor,Ue=(o,t,e,i)=>{for(var s=i>1?void 0:i?Ip(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Mp(t,e,s),s};let fe=class extends gt{constructor(){super(...arguments),this.cards=[],this.skeleton=!1,this.firstUpdated=()=>{const t={align:"start",axis:"x",loop:!1};console.log(this.emblaNode,this.emblaViewport,this.emblaPrevButton,this.emblaNextButton);const e=kn(this.emblaViewport,t);if(this.skeleton)return;const i=this.addPrevNextBtnsClickHandlers(e,this.emblaPrevButton,this.emblaNextButton);e.on("destroy",i),e.on("reInit",()=>{!e.canScrollPrev()&&!e.canScrollNext()?(console.debug("No previous or next slides available, hiding arrows."),this.emblaPrevButton.style.visibility="hidden",this.emblaNextButton.style.visibility="hidden"):(console.debug("Previous or next slides available, showing arrows."),this.emblaPrevButton.style.visibility="visible",this.emblaNextButton.style.visibility="visible")})},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),(t=this.imageSplide)==null||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId}})},this.addTogglePrevNextBtnsActive=(t,e,i)=>{const s=()=>{t.canScrollPrev()?e.removeAttribute("disabled"):e.setAttribute("disabled","disabled"),t.canScrollNext()?i.removeAttribute("disabled"):i.setAttribute("disabled","disabled")};return t.on("select",s).on("init",s).on("reInit",s),()=>{e.removeAttribute("disabled"),i.removeAttribute("disabled")}}}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"}addPrevNextBtnsClickHandlers(t,e,i){const s=()=>{t.scrollPrev()},r=()=>{t.scrollNext()};e.addEventListener("click",s,!1),i.addEventListener("click",r,!1);const n=this.addTogglePrevNextBtnsActive(t,e,i);return()=>{n(),e.removeEventListener("click",s,!1),i.removeEventListener("click",r,!1)}}render(){return this.skeleton?L`
2171
2183
  <div class="category-container skeleton">
2172
2184
  <div class="title"></div>
2173
- <div
2174
- id="category-carousel"
2175
- class="splide"
2176
- aria-label="The carousel with thumbnails. Selecting a thumbnail will change the Beautiful Gallery carousel."
2177
- >
2178
- <div class="splide__track">
2179
- <ul class="splide__list">
2180
- <li class="splide__slide">
2181
- <pbo-image skeleton></pbo-image>
2182
- </li>
2183
- <li class="splide__slide">
2184
- <pbo-image skeleton></pbo-image>
2185
- </li>
2186
- <li class="splide__slide">
2187
- <pbo-image skeleton></pbo-image>
2188
- </li>
2189
- <li class="splide__slide">
2190
- <pbo-image skeleton></pbo-image>
2191
- </li>
2192
- </ul>
2185
+ <div class="embla__viewport">
2186
+ <div class="embla__container">
2187
+ <div class="embla__slide">
2188
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2189
+ </div>
2190
+ <div class="embla__slide">
2191
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2192
+ </div>
2193
+ <div class="embla__slide">
2194
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2195
+ </div>
2196
+ <div class="embla__slide">
2197
+ <pbo-image skeleton class="embla__slide__img skeleton_img"></pbo-image>
2198
+ </div>
2193
2199
  </div>
2194
2200
  </div>
2195
2201
  </div>
@@ -2235,7 +2241,7 @@
2235
2241
  </div>
2236
2242
  </section>
2237
2243
  </div>
2238
- `}};mi.styles=[pt,Qu,Zr(tp)];Gs([C({type:Array})],mi.prototype,"cards",2);Gs([C({type:Boolean,reflect:!0})],mi.prototype,"skeleton",2);Gs([V("#category-carousel")],mi.prototype,"imageCarousel",2);Gs([$()],mi.prototype,"imageSplide",2);mi=Gs([ht("pbo-category")],mi);const kb=mi,Lp=Q`
2244
+ `}};fe.styles=[pt,Qu,Zr(tp)];Ue([C({type:Array})],fe.prototype,"cards",2);Ue([C({type:Boolean,reflect:!0})],fe.prototype,"skeleton",2);Ue([H("#category-carousel")],fe.prototype,"imageCarousel",2);Ue([H(".embla")],fe.prototype,"emblaNode",2);Ue([H(".embla__viewport")],fe.prototype,"emblaViewport",2);Ue([H(".embla__button--prev")],fe.prototype,"emblaPrevButton",2);Ue([H(".embla__button--next")],fe.prototype,"emblaNextButton",2);Ue([H(".embla__container")],fe.prototype,"emblaContainerEl",2);Ue([$()],fe.prototype,"imageSplide",2);fe=Ue([dt("pbo-category")],fe);const kb=fe,Lp=Q`
2239
2245
  :host {
2240
2246
  --size: 70%;
2241
2247
  --header-spacing: var(--pbo-spacing-large);
@@ -2321,7 +2327,7 @@
2321
2327
  width: 100%;
2322
2328
  height: var(--size);
2323
2329
  }
2324
- `;var Fp=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,Ni=(o,t,e,i)=>{for(var s=i>1?void 0:i?jp(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Fp(t,e,s),s};let $e=class extends yt{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1}requestClose(o){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 L`
2330
+ `;var Fp=Object.defineProperty,jp=Object.getOwnPropertyDescriptor,Ni=(o,t,e,i)=>{for(var s=i>1?void 0:i?jp(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Fp(t,e,s),s};let Be=class extends gt{constructor(){super(...arguments),this.open=!1,this.placement="bottom",this.radius=!0,this.contained=!1}requestClose(o){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 L`
2325
2331
  <div
2326
2332
  part="base"
2327
2333
  class=${pe({drawer:!0,"drawer--bottom":this.placement==="bottom","drawer--top":this.placement==="top","drawer--left":this.placement==="left","drawer--right":this.placement==="right","drawer--open":this.open,"drawer--contained":this.contained})}
@@ -2338,7 +2344,7 @@
2338
2344
  <slot part="body" class="drawer__body"></slot>
2339
2345
  </div>
2340
2346
  </div>
2341
- `}};$e.styles=[pt,Lp];Ni([V(".drawer")],$e.prototype,"drawer",2);Ni([C({type:Boolean,reflect:!0})],$e.prototype,"open",2);Ni([C({reflect:!0})],$e.prototype,"placement",2);Ni([C({type:Boolean,reflect:!0})],$e.prototype,"radius",2);Ni([C({type:Boolean,reflect:!0})],$e.prototype,"contained",2);Ni([N("open",{waitUntilFirstUpdate:!0})],$e.prototype,"handleOpenChange",1);$e=Ni([ht("pbo-drawer")],$e);const Ob=$e,$p=Q`
2347
+ `}};Be.styles=[pt,Lp];Ni([H(".drawer")],Be.prototype,"drawer",2);Ni([C({type:Boolean,reflect:!0})],Be.prototype,"open",2);Ni([C({reflect:!0})],Be.prototype,"placement",2);Ni([C({type:Boolean,reflect:!0})],Be.prototype,"radius",2);Ni([C({type:Boolean,reflect:!0})],Be.prototype,"contained",2);Ni([V("open",{waitUntilFirstUpdate:!0})],Be.prototype,"handleOpenChange",1);Be=Ni([dt("pbo-drawer")],Be);const Ob=Be,$p=Q`
2342
2348
  :host {
2343
2349
  display: block;
2344
2350
  width: 100%;
@@ -2477,14 +2483,14 @@
2477
2483
  :host {
2478
2484
  display: block;
2479
2485
  }
2480
- `;var Rp=Object.defineProperty,zp=Object.getOwnPropertyDescriptor,On=(o,t,e,i)=>{for(var s=i>1?void 0:i?zp(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Rp(t,e,s),s};let $i=class extends yt{constructor(){super(...arguments),this.categories=[],this.loading=!0}render(){return this.loading?L`
2486
+ `;var Rp=Object.defineProperty,zp=Object.getOwnPropertyDescriptor,On=(o,t,e,i)=>{for(var s=i>1?void 0:i?zp(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Rp(t,e,s),s};let $i=class extends gt{constructor(){super(...arguments),this.categories=[],this.loading=!0}render(){return this.loading?L`
2481
2487
  <pbo-category skeleton></pbo-category>
2482
2488
  <pbo-category skeleton></pbo-category>
2483
2489
  `:L`
2484
2490
  ${Zl(this.categories,t=>L`<pbo-category .cards=${t.cards} .name=${t.name}>
2485
2491
  <h3 slot="title">${t.name}</h3>
2486
2492
  </pbo-category>`)}
2487
- `}};$i.styles=[pt,Bp];On([C({type:Array})],$i.prototype,"categories",2);On([C({type:Boolean,reflect:!0})],$i.prototype,"loading",2);$i=On([ht("pbo-card-selection")],$i);var Hp=Object.defineProperty,Np=Object.getOwnPropertyDescriptor,Wt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Np(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Hp(t,e,s),s};let Tt=class extends yt{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.isLoadingCategories=!1,this.isError=!1,this.errorMessage="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",this.selectedCard=null,this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);this.selectedCard=i,this.goToEditor()}}get editorEl(){var t;return((t=this.shadowRoot)==null?void 0:t.querySelector("pbo-editor"))||null}handleGetProcessedImgUpdate(){this.editorEl&&(this.editorEl.getProcessedImg=this.getProcessedImg)}goToEditor(){this.currentPage="editor"}goToSelector(){this.currentPage="selection"}connectedCallback(){var t;super.connectedCallback(),(t=this.shadowRoot)==null||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.shadowRoot)==null||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){if(!this.cardSelectionEl){console.error("Card selection element not found");return}this.cardSelectionEl.categories=this.categories}handleCategoriesUpdate(){console.log(this.categories),this.cardSelectionEl&&this.categories!==void 0&&this.categories.length>0&&(this.cardSelectionEl.categories=this.categories,this.requestUpdate())}setIsLoadingCategories(t){this.isLoadingCategories=t,this.cardSelectionEl&&(this.cardSelectionEl.loading=t)}findCardInCategoryById(t){console.log("Categories from findCardInCategoryById",this.categories);for(const e of this.categories){const i=e.cards.find(s=>s.pboId===t);if(console.log("card from findCardInCategoryById",i),i)return i}return null}render(){return L`
2493
+ `}};$i.styles=[pt,Bp];On([C({type:Array})],$i.prototype,"categories",2);On([C({type:Boolean,reflect:!0})],$i.prototype,"loading",2);$i=On([dt("pbo-card-selection")],$i);var Hp=Object.defineProperty,Np=Object.getOwnPropertyDescriptor,Wt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Np(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Hp(t,e,s),s};let Tt=class extends gt{constructor(){super(...arguments),this.onClose=()=>{},this.currentPage="selection",this.categories=[],this.isLoadingCategories=!1,this.isError=!1,this.errorMessage="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...",this.selectedCard=null,this.selectedCardId=null,this.selectedCardDetails=null,this.handleCardSelected=t=>{const{cardId:e}=t.detail,i=this.findCardInCategoryById(e);this.selectedCard=i,this.goToEditor()}}get editorEl(){var t;return((t=this.shadowRoot)==null?void 0:t.querySelector("pbo-editor"))||null}handleGetProcessedImgUpdate(){this.editorEl&&(this.editorEl.getProcessedImg=this.getProcessedImg)}goToEditor(){this.currentPage="editor"}goToSelector(){this.currentPage="selection"}connectedCallback(){var t;super.connectedCallback(),(t=this.shadowRoot)==null||t.addEventListener("pbo-category-card-selected",this.handleCardSelected)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.shadowRoot)==null||t.removeEventListener("pbo-category-card-selected",this.handleCardSelected)}firstUpdated(){if(!this.cardSelectionEl){console.error("Card selection element not found");return}this.cardSelectionEl.categories=this.categories}handleCategoriesUpdate(){console.log(this.categories),this.cardSelectionEl&&this.categories!==void 0&&this.categories.length>0&&(this.cardSelectionEl.categories=this.categories,this.requestUpdate())}setIsLoadingCategories(t){this.isLoadingCategories=t,this.cardSelectionEl&&(this.cardSelectionEl.loading=t)}findCardInCategoryById(t){for(const e of this.categories){const i=e.cards.find(s=>s.pboId===t);if(console.log("card from findCardInCategoryById",i),i)return i}return null}render(){return L`
2488
2494
  <div part="base" class="page-manager">
2489
2495
  <div class="header" part="header">
2490
2496
  <div class="back-button" part="back-button">
@@ -2555,12 +2561,13 @@
2555
2561
  .submitTypeForm=${this.submitTypeForm}
2556
2562
  .submitHandwrittenForm=${this.submitHandwrittenForm}
2557
2563
  .getProcessedImg=${this.getProcessedImg}
2564
+ .onClose=${this.onClose}
2558
2565
  name="editor"
2559
2566
  ></pbo-editor>
2560
2567
  </div>
2561
2568
  </div>
2562
2569
  </div>
2563
- `}};Tt.styles=[pt,$p];Tt.dependencies={"pbo-button":et,"pbo-card-selection":$i,"pbo-editor":Dt};Wt([V("pbo-card-selection")],Tt.prototype,"cardSelectionEl",2);Wt([C({type:Function})],Tt.prototype,"onClose",2);Wt([C({type:String,reflect:!0})],Tt.prototype,"currentPage",2);Wt([C()],Tt.prototype,"categories",2);Wt([C()],Tt.prototype,"submitTypeForm",2);Wt([C()],Tt.prototype,"submitHandwrittenForm",2);Wt([C()],Tt.prototype,"getProcessedImg",2);Wt([C({type:Boolean})],Tt.prototype,"isLoadingCategories",2);Wt([C({type:Boolean})],Tt.prototype,"isError",2);Wt([C({type:String})],Tt.prototype,"errorMessage",2);Wt([$()],Tt.prototype,"selectedCard",2);Wt([$()],Tt.prototype,"selectedCardId",2);Wt([$()],Tt.prototype,"selectedCardDetails",2);Wt([N("getProcessedImg")],Tt.prototype,"handleGetProcessedImgUpdate",1);Wt([N("categories")],Tt.prototype,"handleCategoriesUpdate",1);Tt=Wt([ht("pbo-page-manager")],Tt);const Ab=Tt,Mb=$i,Vp=Q`
2570
+ `}};Tt.styles=[pt,$p];Tt.dependencies={"pbo-button":et,"pbo-card-selection":$i,"pbo-editor":Pt};Wt([H("pbo-card-selection")],Tt.prototype,"cardSelectionEl",2);Wt([C({type:Function})],Tt.prototype,"onClose",2);Wt([C({type:String,reflect:!0})],Tt.prototype,"currentPage",2);Wt([C()],Tt.prototype,"categories",2);Wt([C()],Tt.prototype,"submitTypeForm",2);Wt([C()],Tt.prototype,"submitHandwrittenForm",2);Wt([C()],Tt.prototype,"getProcessedImg",2);Wt([C({type:Boolean})],Tt.prototype,"isLoadingCategories",2);Wt([C({type:Boolean})],Tt.prototype,"isError",2);Wt([C({type:String})],Tt.prototype,"errorMessage",2);Wt([$()],Tt.prototype,"selectedCard",2);Wt([$()],Tt.prototype,"selectedCardId",2);Wt([$()],Tt.prototype,"selectedCardDetails",2);Wt([V("getProcessedImg")],Tt.prototype,"handleGetProcessedImgUpdate",1);Wt([V("categories")],Tt.prototype,"handleCategoriesUpdate",1);Tt=Wt([dt("pbo-page-manager")],Tt);const Ab=Tt,Mb=$i,Vp=Q`
2564
2571
  :host {
2565
2572
  display: block;
2566
2573
  width: 100%;
@@ -2612,35 +2619,35 @@
2612
2619
  .type-canvas-container.image-loading pbo-image {
2613
2620
  display: block;
2614
2621
  }
2615
- `;function v(o,t,e){return(t=function(i){var s=function(r,n){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var l=a.call(r,n);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(r)}(i,"string");return typeof s=="symbol"?s:s+""}(t))in o?Object.defineProperty(o,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[t]=e,o}function za(o,t){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable})),e.push.apply(e,i)}return e}function _(o){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?za(Object(e),!0).forEach(function(i){v(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):za(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function it(o,t){if(o==null)return{};var e,i,s=function(n,a){if(n==null)return{};var l={};for(var c in n)if({}.hasOwnProperty.call(n,c)){if(a.indexOf(c)>=0)continue;l[c]=n[c]}return l}(o,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(o);for(i=0;i<r.length;i++)e=r[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(o,e)&&(s[e]=o[e])}return s}function xi(o,t){return t||(t=o.slice(0)),Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(t)}}))}class Ha{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const U=new class extends Ha{constructor(o){super(),this.configure(o)}configure(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,o)}addFonts(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=_(_({},this.fontPaths),o)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(o=>{delete this.fontPaths[o]})}clearFonts(){this.fontPaths={}}restoreDefaults(o){const t=new Ha,e=(o==null?void 0:o.reduce((i,s)=>(i[s]=t[s],i),{}))||t;this.configure(e)}},bi=function(o){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[o]("fabric",...e)};class Fe extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class Up extends Fe{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Wp{}class Gp extends Wp{testPrecision(t,e){const i="precision ".concat(e,` float;
2616
- void 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(i=>this.testPrecision(e,i)),e.getExtension("WEBGL_lose_context").loseContext(),bi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Yp={};let Na;const Be=()=>Na||(Na={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Gp,dispose(){},copyPasteData:Yp}),ns=()=>Be().document,Pn=()=>Be().window,ec=()=>{var o;return Math.max((o=U.devicePixelRatio)!==null&&o!==void 0?o:Pn().devicePixelRatio,1)},Ds=new class{constructor(){v(this,"charWidthsCache",{}),v(this,"boundsOfCurveCache",{})}getFontCache(o){let{fontFamily:t,fontStyle:e,fontWeight:i}=o;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const s=this.charWidthsCache[t],r="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return s[r]||(s[r]={}),s[r]}clearFontCache(o){(o=(o||"").toLowerCase())?this.charWidthsCache[o]&&delete this.charWidthsCache[o]:this.charWidthsCache={}}limitDimsByArea(o){const{perfLimitSizeTotal:t}=U,e=Math.sqrt(t*o);return[Math.floor(e),Math.floor(t/e)]}},sn="6.5.4";function Pr(){}const Ys=Math.PI/2,Br=2*Math.PI,Dn=Math.PI/180,Jt=Object.freeze([1,0,0,1,0,0]),An=16,ni=.4477152502,H="center",G="left",ie="top",rn="bottom",mt="right",se="none",Mn=/\r?\n/,ic="moving",ao="scaling",sc="rotating",In="rotate",rc="skewing",Rs="resizing",Xp="modifyPoly",qp="modifyPath",Rr="changed",lo="scale",ne="scaleX",_e="scaleY",as="skewX",ls="skewY",Pt="fill",re="stroke",zr="modified",Wi="json",Mo="svg",P=new class{constructor(){this[Wi]=new Map,this[Mo]=new Map}has(o){return this[Wi].has(o)}getClass(o){const t=this[Wi].get(o);if(!t)throw new Fe("No class registered for ".concat(o));return t}setClass(o,t){t?this[Wi].set(t,o):(this[Wi].set(o.type,o),this[Wi].set(o.type.toLowerCase(),o))}getSVGClass(o){return this[Mo].get(o)}setSVGClass(o,t){this[Mo].set(t??o.type.toLowerCase(),o)}},Hr=new class extends Array{remove(o){const t=this.indexOf(o);t>-1&&this.splice(t,1)}cancelAll(){const o=this.splice(0);return o.forEach(t=>t.abort()),o}cancelByCanvas(o){if(!o)return[];const t=this.filter(e=>{var i;return e.target===o||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===o});return t.forEach(e=>e.abort()),t}cancelByTarget(o){if(!o)return[];const t=this.filter(e=>e.target===o);return t.forEach(e=>e.abort()),t}};class Kp{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(i=>{let[s,r]=i;this.on(s,r)}),()=>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(typeof t=="object"){const i=[];return Object.entries(t).forEach(s=>{let[r,n]=s;i.push(this.once(r,n))}),()=>i.forEach(s=>s())}if(e){const i=this.on(t,function(){for(var s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];e.call(this,...r),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(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach(i=>{let[s,r]=i;this._removeEventListener(s,r)}):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let r=0;r<s.length;r++)s[r].call(this,e||{})}}const Xi=(o,t)=>{const e=o.indexOf(t);return e!==-1&&o.splice(e,1),o},ti=o=>{if(o===0)return 1;switch(Math.abs(o)/Ys){case 1:case 3:return 0;case 2:return-1}return Math.cos(o)},ei=o=>{if(o===0)return 0;const t=o/Ys,e=Math.sign(o);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(o)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ln;const i=ei(t),s=ti(t),r=this.subtract(e);return new x(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Ln=new x(0,0),Dr=o=>!!o&&Array.isArray(o._objects);function oc(o){class t extends o{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];const n=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),n}insertAt(i){for(var s=arguments.length,r=new Array(s>1?s-1:0),n=1;n<s;n++)r[n-1]=arguments[n];return this._objects.splice(i,0,...r),r.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const i=this._objects,s=[];for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.forEach(l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(i){this.getObjects().forEach((s,r,n)=>i(s,r,n))}getObjects(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.length===0?[...this._objects]:this._objects.filter(n=>n.isType(...s))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some(r=>r instanceof t&&r.contains(i,!0))}complexity(){return this._objects.reduce((i,s)=>i+=s.complexity?s.complexity():0,0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Xi(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Xi(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==0){const n=this.findNewLowerIndex(i,r,s);return Xi(this._objects,i),this._objects.splice(n,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==this._objects.length-1){const n=this.findNewUpperIndex(i,r,s);return Xi(this._objects,i),this._objects.splice(n,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Xi(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,r){let n;if(r){n=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){n=a;break}}else n=s-1;return n}findNewUpperIndex(i,s,r){let n;if(r){n=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){n=a;break}}else n=s+1;return n}collectObjects(i){let{left:s,top:r,width:n,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(s,r),d=h.add(new x(n,a));for(let u=this._objects.length-1;u>=0;u--){const g=this._objects[u];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,d)||g.isContainedWithinRect(h,d)||l&&g.containsPoint(h)||l&&g.containsPoint(d))&&c.push(g)}return c}}return t}class nc extends Kp{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Ar(o){return Pn().requestAnimationFrame(o)}function Zp(o){return Pn().cancelAnimationFrame(o)}let Jp=0;const vi=()=>Jp++,ke=()=>{const o=ns().createElement("canvas");if(!o||o.getContext===void 0)throw new Fe("Failed to create `canvas` element");return o},Qp=()=>ns().createElement("img"),Re=o=>{const t=ke();return t.width=o.width,t.height=o.height,t},ac=(o,t,e)=>o.toDataURL("image/".concat(t),e),bt=o=>o*Dn,Bi=o=>o/Dn,tg=o=>o.every((t,e)=>t===Jt[e]),ee=(o,t,e)=>new x(o).transform(t,e),Se=o=>{const t=1/(o[0]*o[3]-o[1]*o[2]),e=[t*o[3],-t*o[1],-t*o[2],t*o[0],0,0],{x:i,y:s}=new x(o[4],o[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},$t=(o,t,e)=>[o[0]*t[0]+o[2]*t[1],o[1]*t[0]+o[3]*t[1],o[0]*t[2]+o[2]*t[3],o[1]*t[2]+o[3]*t[3],e?0:o[0]*t[4]+o[2]*t[5]+o[4],e?0:o[1]*t[4]+o[3]*t[5]+o[5]],Fn=(o,t)=>o.reduceRight((e,i)=>i&&e?$t(i,e,t):i||e,void 0)||Jt.concat(),lc=o=>{let[t,e]=o;return Math.atan2(e,t)},Nr=o=>{const t=lc(o),e=Math.pow(o[0],2)+Math.pow(o[1],2),i=Math.sqrt(e),s=(o[0]*o[3]-o[2]*o[1])/i,r=Math.atan2(o[0]*o[2]+o[1]*o[3],e);return{angle:Bi(t),scaleX:i,scaleY:s,skewX:Bi(r),skewY:0,translateX:o[4]||0,translateY:o[5]||0}},Xs=function(o){return[1,0,0,1,o,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function qs(){let{angle:o=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=bt(o),s=ti(i),r=ei(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const jn=function(o){return[o,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:o,0,0]},cc=o=>Math.tan(bt(o)),hc=o=>[1,0,cc(o),1,0,0],dc=o=>[1,cc(o),0,1,0,0],co=o=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:n=0}=o,a=jn(i?-t:t,s?-e:e);return r&&(a=$t(a,hc(r),!0)),n&&(a=$t(a,dc(n),!0)),a},eg=o=>{const{translateX:t=0,translateY:e=0,angle:i=0}=o;let s=Xs(t,e);i&&(s=$t(s,qs({angle:i})));const r=co(o);return tg(r)||(s=$t(s,r)),s},Mr=function(o){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(i,s){if(t&&t.aborted)return s(new Up("loadImage"));const r=Qp();let n;t&&(n=function(l){r.src="",s(l)},t.addEventListener("abort",n,{once:!0}));const a=function(){r.onload=r.onerror=null,n&&(t==null||t.removeEventListener("abort",n)),i(r)};o?(r.onload=a,r.onerror=function(){n&&(t==null||t.removeEventListener("abort",n)),s(new Fe("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=o):a()})},zs=function(o){let{signal:t,reviver:e=Pr}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((i,s)=>{const r=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(o.map(n=>P.getClass(n.type).fromObject(n,{signal:t}).then(a=>(e(n,a),r.push(a),a)))).then(i).catch(n=>{r.forEach(a=>{a.dispose&&a.dispose()}),s(n)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},ho=function(o){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const r=Object.values(o).map(a=>a&&a.type&&P.has(a.type)?zs([a],{signal:t}).then(l=>{let[c]=l;return s.push(c),c}):a),n=Object.keys(o);Promise.all(r).then(a=>a.reduce((l,c,h)=>(l[n[h]]=c,l),{})).then(e).catch(a=>{s.forEach(l=>{l.dispose&&l.dispose()}),i(a)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},cs=function(o){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in o&&(t[e]=o[e]),t),{})},$n=(o,t)=>Object.keys(o).reduce((e,i)=>(t(o[i],i,o)&&(e[i]=o[i]),e),{}),Va={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"},Io=(o,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?o+6*(t-o)*e:e<.5?t:e<2/3?o+(t-o)*(2/3-e)*6:o),Ua=(o,t,e,i)=>{o/=255,t/=255,e/=255;const s=Math.max(o,t,e),r=Math.min(o,t,e);let n,a;const l=(s+r)/2;if(s===r)n=a=0;else{const c=s-r;switch(a=l>.5?c/(2-s-r):c/(s+r),s){case o:n=(t-e)/c+(t<e?6:0);break;case t:n=(e-o)/c+2;break;case e:n=(o-t)/c+4}n/=6}return[Math.round(360*n),Math.round(100*a),Math.round(100*l),i]},Wa=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(o)/(o.endsWith("%")?100:1)},sr=o=>Math.min(Math.round(o),255).toString(16).toUpperCase().padStart(2,"0"),Ga=o=>{let[t,e,i,s=1]=o;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class X{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof X)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 Va&&(t=Va[t]),t==="transparent"?[255,255,255,0]:X.sourceFromHex(t)||X.sourceFromRgb(t)||X.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]=Ua(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=Ua(...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(sr(t)).concat(sr(e)).concat(sr(i)).concat(sr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Ga(this.getSource())),this}toBlackWhite(t){const[e,,,i]=Ga(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof X||(t=new X(t));const e=this.getSource(),i=t.getSource(),[s,r,n]=e.map((a,l)=>Math.round(.5*a+.5*i[l]));return this.setSource([s,r,n,e[3]]),this}static fromRgb(t){return X.fromRgba(t)}static fromRgba(t){return new X(X.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[i,s,r]=e.slice(1,4).map(n=>{const a=parseFloat(n);return n.endsWith("%")?Math.round(2.55*a):a});return[i,s,r,Wa(e[4])]}}static fromHsl(t){return X.fromHsla(t)}static fromHsla(t){return new X(X.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=(X.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let n,a,l;if(s===0)n=a=l=r;else{const c=r<=.5?r*(s+1):r+s-r*s,h=2*r-c;n=Io(h,c,i+1/3),a=Io(h,c,i),l=Io(h,c,i-1/3)}return[Math.round(255*n),Math.round(255*a),Math.round(255*l),Wa(e[4])]}static fromHex(t){return new X(X.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(l=>l+l):e.match(/.{2}/g);const[s,r,n,a=255]=i.map(l=>parseInt(l,16));return[s,r,n,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?Bi(i):e.includes("turn")?360*i:i}}const nt=(o,t)=>parseFloat(Number(o).toFixed(t)),Qi=function(o){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:An;const e=/\D{0,2}$/.exec(o),i=parseFloat(o),s=U.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},ig=o=>{const[t,e]=o.trim().split(" "),[i,s]=(r=t)&&r!==se?[r.slice(1,4),r.slice(5,8)]:r===se?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},Vr=o=>"matrix("+o.map(t=>nt(t,U.NUM_FRACTION_DIGITS)).join(" ")+")",Hs=function(o,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const r=new X(t),n=r.getAlpha();e=r.toRgb(),n!==1&&(i=n.toString())}else e="none";return s?"".concat(o,": ").concat(e,"; ").concat(i?"".concat(o,"-opacity: ").concat(i,"; "):""):"".concat(o,'="').concat(e,'" ').concat(i?"".concat(o,'-opacity="').concat(i,'" '):"")},be=o=>!!o&&o.toLive!==void 0,Ya=o=>!!o&&typeof o.toObject=="function",Xa=o=>!!o&&o.offsetX!==void 0&&"source"in o,ki=o=>!!o&&"multiSelectionStacking"in o;function uc(o){const t=o&&Ce(o);let e=0,i=0;if(!o||!t)return{left:e,top:i};let s=o;const r=t.documentElement,n=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=n.scrollLeft||r.scrollLeft||0,i=n.scrollTop||r.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const Ce=o=>o.ownerDocument||null,pc=o=>{var t;return((t=o.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},gc=function(o,t,e){let{width:i,height:s}=e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;o.width=i,o.height=s,r>1&&(o.setAttribute("width",(i*r).toString()),o.setAttribute("height",(s*r).toString()),t.scale(r,r))},on=(o,t)=>{let{width:e,height:i}=t;e&&(o.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(o.style.height=typeof i=="number"?"".concat(i,"px"):i)};function qa(o){return o.onselectstart!==void 0&&(o.onselectstart=()=>!1),o.style.userSelect=se,o}class fc{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&ns().getElementById(t)||ke();var i;if(e.hasAttribute("data-fabric"))throw new Fe("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;gc(i,s,t,e)}setCSSDimensions(t){on(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&Ce(t),s={left:0,top:0};if(!i)return s;const r=((e=pc(t))===null||e===void 0?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 n={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(n=t.getBoundingClientRect());const l=uc(t);return{left:n.left+l.left-(a.clientLeft||0)+s.left,top:n.top+l.top-(a.clientTop||0)+s.top}}(this.lower.el)}dispose(){Be().dispose(this.lower.el),delete this.lower}}const sg={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Jt]};class Ks extends oc(nc){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return Ks.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new fc(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&&(bi("warn",`Canvas is trying to add an object that belongs to a different canvas.
2617
- Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?ec():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&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=_({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}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=ee(t,Se(s));s[0]=e,s[3]=e;const n=ee(r,s);s[4]+=i.x-n.x,s[5]+=i.y-n.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Ar(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Se(this.viewportTransform),s=ee({x:0,y:0},i),r=ee({x:t,y:e},i),n=s.min(r),a=s.max(r);return this.vptCoords={tl:n,tr:new x(a.x,n.y),bl:new x(n.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Zp(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,n=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=be(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=a?i.toLive(t):i,n&&t.transform(...r),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=n,n&&t.transform(...r),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return ee(this.getCenterPoint(),Se(this.viewportTransform))}_centerObject(t,e){t.setXY(e,H,H),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 _(_(_({version:sn},cs(this,e)),{},{objects:this._objects.filter(r=>!r.excludeFromExport).map(r=>this._toObject(r,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,n=this.backgroundColor,a=this.overlayColor;return be(n)?n.excludeFromExport||(i.background=n.toObject(e)):n&&(i.background=n),be(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),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&&arguments[0]!==void 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,`)" >
2622
+ `;function v(o,t,e){return(t=function(i){var s=function(r,n){if(typeof r!="object"||!r)return r;var a=r[Symbol.toPrimitive];if(a!==void 0){var l=a.call(r,n);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(r)}(i,"string");return typeof s=="symbol"?s:s+""}(t))in o?Object.defineProperty(o,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):o[t]=e,o}function za(o,t){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(o);t&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(o,s).enumerable})),e.push.apply(e,i)}return e}function _(o){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?za(Object(e),!0).forEach(function(i){v(o,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(e)):za(Object(e)).forEach(function(i){Object.defineProperty(o,i,Object.getOwnPropertyDescriptor(e,i))})}return o}function it(o,t){if(o==null)return{};var e,i,s=function(n,a){if(n==null)return{};var l={};for(var c in n)if({}.hasOwnProperty.call(n,c)){if(a.indexOf(c)>=0)continue;l[c]=n[c]}return l}(o,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(o);for(i=0;i<r.length;i++)e=r[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(o,e)&&(s[e]=o[e])}return s}function wi(o,t){return t||(t=o.slice(0)),Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(t)}}))}class Ha{constructor(){v(this,"browserShadowBlurConstant",1),v(this,"DPI",96),v(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),v(this,"perfLimitSizeTotal",2097152),v(this,"maxCacheSideLimit",4096),v(this,"minCacheSideLimit",256),v(this,"disableStyleCopyPaste",!1),v(this,"enableGLFiltering",!0),v(this,"textureSize",4096),v(this,"forceGLPutImageData",!1),v(this,"cachesBoundsOfCurve",!1),v(this,"fontPaths",{}),v(this,"NUM_FRACTION_DIGITS",4)}}const U=new class extends Ha{constructor(o){super(),this.configure(o)}configure(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,o)}addFonts(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=_(_({},this.fontPaths),o)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(o=>{delete this.fontPaths[o]})}clearFonts(){this.fontPaths={}}restoreDefaults(o){const t=new Ha,e=(o==null?void 0:o.reduce((i,s)=>(i[s]=t[s],i),{}))||t;this.configure(e)}},vi=function(o){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return console[o]("fabric",...e)};class je extends Error{constructor(t,e){super("fabric: ".concat(t),e)}}class Up extends je{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}class Wp{}class Gp extends Wp{testPrecision(t,e){const i="precision ".concat(e,` float;
2623
+ void 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(i=>this.testPrecision(e,i)),e.getExtension("WEBGL_lose_context").loseContext(),vi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}}const Yp={};let Na;const Re=()=>Na||(Na={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new Gp,dispose(){},copyPasteData:Yp}),as=()=>Re().document,Pn=()=>Re().window,ec=()=>{var o;return Math.max((o=U.devicePixelRatio)!==null&&o!==void 0?o:Pn().devicePixelRatio,1)},As=new class{constructor(){v(this,"charWidthsCache",{}),v(this,"boundsOfCurveCache",{})}getFontCache(o){let{fontFamily:t,fontStyle:e,fontWeight:i}=o;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const s=this.charWidthsCache[t],r="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return s[r]||(s[r]={}),s[r]}clearFontCache(o){(o=(o||"").toLowerCase())?this.charWidthsCache[o]&&delete this.charWidthsCache[o]:this.charWidthsCache={}}limitDimsByArea(o){const{perfLimitSizeTotal:t}=U,e=Math.sqrt(t*o);return[Math.floor(e),Math.floor(t/e)]}},sn="6.5.4";function Pr(){}const Ys=Math.PI/2,Br=2*Math.PI,Dn=Math.PI/180,Jt=Object.freeze([1,0,0,1,0,0]),An=16,li=.4477152502,N="center",G="left",ie="top",rn="bottom",bt="right",se="none",Mn=/\r?\n/,ic="moving",ao="scaling",sc="rotating",In="rotate",rc="skewing",zs="resizing",Xp="modifyPoly",qp="modifyPath",Rr="changed",lo="scale",ne="scaleX",ye="scaleY",ls="skewX",cs="skewY",Ot="fill",re="stroke",zr="modified",Wi="json",Mo="svg",P=new class{constructor(){this[Wi]=new Map,this[Mo]=new Map}has(o){return this[Wi].has(o)}getClass(o){const t=this[Wi].get(o);if(!t)throw new je("No class registered for ".concat(o));return t}setClass(o,t){t?this[Wi].set(t,o):(this[Wi].set(o.type,o),this[Wi].set(o.type.toLowerCase(),o))}getSVGClass(o){return this[Mo].get(o)}setSVGClass(o,t){this[Mo].set(t??o.type.toLowerCase(),o)}},Hr=new class extends Array{remove(o){const t=this.indexOf(o);t>-1&&this.splice(t,1)}cancelAll(){const o=this.splice(0);return o.forEach(t=>t.abort()),o}cancelByCanvas(o){if(!o)return[];const t=this.filter(e=>{var i;return e.target===o||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===o});return t.forEach(e=>e.abort()),t}cancelByTarget(o){if(!o)return[];const t=this.filter(e=>e.target===o);return t.forEach(e=>e.abort()),t}};class Kp{constructor(){v(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(i=>{let[s,r]=i;this.on(s,r)}),()=>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(typeof t=="object"){const i=[];return Object.entries(t).forEach(s=>{let[r,n]=s;i.push(this.once(r,n))}),()=>i.forEach(s=>s())}if(e){const i=this.on(t,function(){for(var s=arguments.length,r=new Array(s),n=0;n<s;n++)r[n]=arguments[n];e.call(this,...r),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(t===void 0)for(const i in this.__eventListeners)this._removeEventListener(i);else typeof t=="object"?Object.entries(t).forEach(i=>{let[s,r]=i;this._removeEventListener(s,r)}):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const s=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(s)for(let r=0;r<s.length;r++)s[r].call(this,e||{})}}const Xi=(o,t)=>{const e=o.indexOf(t);return e!==-1&&o.splice(e,1),o},ii=o=>{if(o===0)return 1;switch(Math.abs(o)/Ys){case 1:case 3:return 0;case 2:return-1}return Math.cos(o)},si=o=>{if(o===0)return 0;const t=o/Ys,e=Math.sign(o);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(o)};class x{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new x(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new x(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new x(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new x(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new x(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new x(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new x(this.x/t.x,this.y/t.y)}scalarDivide(t){return new x(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new x(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new x(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new x(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".concat(this.x,",").concat(this.y)}setXY(t,e){return this.x=t,this.y=e,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setFromPoint(t){return this.x=t.x,this.y=t.y,this}swap(t){const e=this.x,i=this.y;this.x=t.x,this.y=t.y,t.x=e,t.y=i}clone(){return new x(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Ln;const i=si(t),s=ii(t),r=this.subtract(e);return new x(r.x*s-r.y*i,r.x*i+r.y*s).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new x(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const Ln=new x(0,0),Dr=o=>!!o&&Array.isArray(o._objects);function oc(o){class t extends o{constructor(){super(...arguments),v(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];const n=this._objects.push(...s);return s.forEach(a=>this._onObjectAdded(a)),n}insertAt(i){for(var s=arguments.length,r=new Array(s>1?s-1:0),n=1;n<s;n++)r[n-1]=arguments[n];return this._objects.splice(i,0,...r),r.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const i=this._objects,s=[];for(var r=arguments.length,n=new Array(r),a=0;a<r;a++)n[a]=arguments[a];return n.forEach(l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),s.push(l),this._onObjectRemoved(l))}),s}forEachObject(i){this.getObjects().forEach((s,r,n)=>i(s,r,n))}getObjects(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];return s.length===0?[...this._objects]:this._objects.filter(n=>n.isType(...s))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,s){return!!this._objects.includes(i)||!!s&&this._objects.some(r=>r instanceof t&&r.contains(i,!0))}complexity(){return this._objects.reduce((i,s)=>i+=s.complexity?s.complexity():0,0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(Xi(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(Xi(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==0){const n=this.findNewLowerIndex(i,r,s);return Xi(this._objects,i),this._objects.splice(n,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,s){if(!i)return!1;const r=this._objects.indexOf(i);if(r!==this._objects.length-1){const n=this.findNewUpperIndex(i,r,s);return Xi(this._objects,i),this._objects.splice(n,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,s){return i!==this._objects[s]&&(Xi(this._objects,i),this._objects.splice(s,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,s,r){let n;if(r){n=s;for(let a=s-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){n=a;break}}else n=s-1;return n}findNewUpperIndex(i,s,r){let n;if(r){n=s;for(let a=s+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){n=a;break}}else n=s+1;return n}collectObjects(i){let{left:s,top:r,width:n,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new x(s,r),d=h.add(new x(n,a));for(let u=this._objects.length-1;u>=0;u--){const g=this._objects[u];g.selectable&&g.visible&&(l&&g.intersectsWithRect(h,d)||g.isContainedWithinRect(h,d)||l&&g.containsPoint(h)||l&&g.containsPoint(d))&&c.push(g)}return c}}return t}class nc extends Kp{_setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};for(const e in t)this.set(e,t[e])}_setObject(t){for(const e in t)this._set(e,t[e])}set(t,e){return typeof t=="object"?this._setObject(t):this._set(t,e),this}_set(t,e){this[t]=e}toggle(t){const e=this.get(t);return typeof e=="boolean"&&this.set(t,!e),this}get(t){return this[t]}}function Ar(o){return Pn().requestAnimationFrame(o)}function Zp(o){return Pn().cancelAnimationFrame(o)}let Jp=0;const _i=()=>Jp++,Oe=()=>{const o=as().createElement("canvas");if(!o||o.getContext===void 0)throw new je("Failed to create `canvas` element");return o},Qp=()=>as().createElement("img"),ze=o=>{const t=Oe();return t.width=o.width,t.height=o.height,t},ac=(o,t,e)=>o.toDataURL("image/".concat(t),e),vt=o=>o*Dn,Bi=o=>o/Dn,tg=o=>o.every((t,e)=>t===Jt[e]),ee=(o,t,e)=>new x(o).transform(t,e),Te=o=>{const t=1/(o[0]*o[3]-o[1]*o[2]),e=[t*o[3],-t*o[1],-t*o[2],t*o[0],0,0],{x:i,y:s}=new x(o[4],o[5]).transform(e,!0);return e[4]=-i,e[5]=-s,e},$t=(o,t,e)=>[o[0]*t[0]+o[2]*t[1],o[1]*t[0]+o[3]*t[1],o[0]*t[2]+o[2]*t[3],o[1]*t[2]+o[3]*t[3],e?0:o[0]*t[4]+o[2]*t[5]+o[4],e?0:o[1]*t[4]+o[3]*t[5]+o[5]],Fn=(o,t)=>o.reduceRight((e,i)=>i&&e?$t(i,e,t):i||e,void 0)||Jt.concat(),lc=o=>{let[t,e]=o;return Math.atan2(e,t)},Nr=o=>{const t=lc(o),e=Math.pow(o[0],2)+Math.pow(o[1],2),i=Math.sqrt(e),s=(o[0]*o[3]-o[2]*o[1])/i,r=Math.atan2(o[0]*o[2]+o[1]*o[3],e);return{angle:Bi(t),scaleX:i,scaleY:s,skewX:Bi(r),skewY:0,translateX:o[4]||0,translateY:o[5]||0}},Xs=function(o){return[1,0,0,1,o,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function qs(){let{angle:o=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=vt(o),s=ii(i),r=si(i);return[s,r,-r,s,t?t-(s*t-r*e):0,e?e-(r*t+s*e):0]}const jn=function(o){return[o,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:o,0,0]},cc=o=>Math.tan(vt(o)),hc=o=>[1,0,cc(o),1,0,0],dc=o=>[1,cc(o),0,1,0,0],co=o=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:s=!1,skewX:r=0,skewY:n=0}=o,a=jn(i?-t:t,s?-e:e);return r&&(a=$t(a,hc(r),!0)),n&&(a=$t(a,dc(n),!0)),a},eg=o=>{const{translateX:t=0,translateY:e=0,angle:i=0}=o;let s=Xs(t,e);i&&(s=$t(s,qs({angle:i})));const r=co(o);return tg(r)||(s=$t(s,r)),s},Mr=function(o){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(i,s){if(t&&t.aborted)return s(new Up("loadImage"));const r=Qp();let n;t&&(n=function(l){r.src="",s(l)},t.addEventListener("abort",n,{once:!0}));const a=function(){r.onload=r.onerror=null,n&&(t==null||t.removeEventListener("abort",n)),i(r)};o?(r.onload=a,r.onerror=function(){n&&(t==null||t.removeEventListener("abort",n)),s(new je("Error loading ".concat(r.src)))},e&&(r.crossOrigin=e),r.src=o):a()})},Hs=function(o){let{signal:t,reviver:e=Pr}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((i,s)=>{const r=[];t&&t.addEventListener("abort",s,{once:!0}),Promise.all(o.map(n=>P.getClass(n.type).fromObject(n,{signal:t}).then(a=>(e(n,a),r.push(a),a)))).then(i).catch(n=>{r.forEach(a=>{a.dispose&&a.dispose()}),s(n)}).finally(()=>{t&&t.removeEventListener("abort",s)})})},ho=function(o){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,i)=>{const s=[];t&&t.addEventListener("abort",i,{once:!0});const r=Object.values(o).map(a=>a&&a.type&&P.has(a.type)?Hs([a],{signal:t}).then(l=>{let[c]=l;return s.push(c),c}):a),n=Object.keys(o);Promise.all(r).then(a=>a.reduce((l,c,h)=>(l[n[h]]=c,l),{})).then(e).catch(a=>{s.forEach(l=>{l.dispose&&l.dispose()}),i(a)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},hs=function(o){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in o&&(t[e]=o[e]),t),{})},$n=(o,t)=>Object.keys(o).reduce((e,i)=>(t(o[i],i,o)&&(e[i]=o[i]),e),{}),Va={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"},Io=(o,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?o+6*(t-o)*e:e<.5?t:e<2/3?o+(t-o)*(2/3-e)*6:o),Ua=(o,t,e,i)=>{o/=255,t/=255,e/=255;const s=Math.max(o,t,e),r=Math.min(o,t,e);let n,a;const l=(s+r)/2;if(s===r)n=a=0;else{const c=s-r;switch(a=l>.5?c/(2-s-r):c/(s+r),s){case o:n=(t-e)/c+(t<e?6:0);break;case t:n=(e-o)/c+2;break;case e:n=(o-t)/c+4}n/=6}return[Math.round(360*n),Math.round(100*a),Math.round(100*l),i]},Wa=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(o)/(o.endsWith("%")?100:1)},sr=o=>Math.min(Math.round(o),255).toString(16).toUpperCase().padStart(2,"0"),Ga=o=>{let[t,e,i,s=1]=o;const r=Math.round(.3*t+.59*e+.11*i);return[r,r,r,s]};class X{constructor(t){if(v(this,"isUnrecognised",!1),t)if(t instanceof X)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 Va&&(t=Va[t]),t==="transparent"?[255,255,255,0]:X.sourceFromHex(t)||X.sourceFromRgb(t)||X.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]=Ua(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,s]=Ua(...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(sr(t)).concat(sr(e)).concat(sr(i)).concat(sr(Math.round(255*s)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Ga(this.getSource())),this}toBlackWhite(t){const[e,,,i]=Ga(this.getSource()),s=e<(t||127)?0:255;return this.setSource([s,s,s,i]),this}overlayWith(t){t instanceof X||(t=new X(t));const e=this.getSource(),i=t.getSource(),[s,r,n]=e.map((a,l)=>Math.round(.5*a+.5*i[l]));return this.setSource([s,r,n,e[3]]),this}static fromRgb(t){return X.fromRgba(t)}static fromRgba(t){return new X(X.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[i,s,r]=e.slice(1,4).map(n=>{const a=parseFloat(n);return n.endsWith("%")?Math.round(2.55*a):a});return[i,s,r,Wa(e[4])]}}static fromHsl(t){return X.fromHsla(t)}static fromHsla(t){return new X(X.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=(X.parseAngletoDegrees(e[1])%360+360)%360/360,s=parseFloat(e[2])/100,r=parseFloat(e[3])/100;let n,a,l;if(s===0)n=a=l=r;else{const c=r<=.5?r*(s+1):r+s-r*s,h=2*r-c;n=Io(h,c,i+1/3),a=Io(h,c,i),l=Io(h,c,i-1/3)}return[Math.round(255*n),Math.round(255*a),Math.round(255*l),Wa(e[4])]}static fromHex(t){return new X(X.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(l=>l+l):e.match(/.{2}/g);const[s,r,n,a=255]=i.map(l=>parseInt(l,16));return[s,r,n,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?Bi(i):e.includes("turn")?360*i:i}}const at=(o,t)=>parseFloat(Number(o).toFixed(t)),ts=function(o){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:An;const e=/\D{0,2}$/.exec(o),i=parseFloat(o),s=U.DPI;switch(e==null?void 0:e[0]){case"mm":return i*s/25.4;case"cm":return i*s/2.54;case"in":return i*s;case"pt":return i*s/72;case"pc":return i*s/72*12;case"em":return i*t;default:return i}},ig=o=>{const[t,e]=o.trim().split(" "),[i,s]=(r=t)&&r!==se?[r.slice(1,4),r.slice(5,8)]:r===se?[r,r]:["Mid","Mid"];var r;return{meetOrSlice:e||"meet",alignX:i,alignY:s}},Vr=o=>"matrix("+o.map(t=>at(t,U.NUM_FRACTION_DIGITS)).join(" ")+")",Ns=function(o,t){let e,i,s=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const r=new X(t),n=r.getAlpha();e=r.toRgb(),n!==1&&(i=n.toString())}else e="none";return s?"".concat(o,": ").concat(e,"; ").concat(i?"".concat(o,"-opacity: ").concat(i,"; "):""):"".concat(o,'="').concat(e,'" ').concat(i?"".concat(o,'-opacity="').concat(i,'" '):"")},ve=o=>!!o&&o.toLive!==void 0,Ya=o=>!!o&&typeof o.toObject=="function",Xa=o=>!!o&&o.offsetX!==void 0&&"source"in o,Oi=o=>!!o&&"multiSelectionStacking"in o;function uc(o){const t=o&&Se(o);let e=0,i=0;if(!o||!t)return{left:e,top:i};let s=o;const r=t.documentElement,n=t.body||{scrollLeft:0,scrollTop:0};for(;s&&(s.parentNode||s.host)&&(s=s.parentNode||s.host,s===t?(e=n.scrollLeft||r.scrollLeft||0,i=n.scrollTop||r.scrollTop||0):(e+=s.scrollLeft||0,i+=s.scrollTop||0),s.nodeType!==1||s.style.position!=="fixed"););return{left:e,top:i}}const Se=o=>o.ownerDocument||null,pc=o=>{var t;return((t=o.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},gc=function(o,t,e){let{width:i,height:s}=e,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;o.width=i,o.height=s,r>1&&(o.setAttribute("width",(i*r).toString()),o.setAttribute("height",(s*r).toString()),t.scale(r,r))},on=(o,t)=>{let{width:e,height:i}=t;e&&(o.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(o.style.height=typeof i=="number"?"".concat(i,"px"):i)};function qa(o){return o.onselectstart!==void 0&&(o.onselectstart=()=>!1),o.style.userSelect=se,o}class fc{constructor(t){v(this,"_originalCanvasStyle",void 0),v(this,"lower",void 0);const e=this.createLowerCanvas(t);this.lower={el:e,ctx:e.getContext("2d")}}createLowerCanvas(t){const e=(i=t)&&i.getContext!==void 0?t:t&&as().getElementById(t)||Oe();var i;if(e.hasAttribute("data-fabric"))throw new je("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;gc(i,s,t,e)}setCSSDimensions(t){on(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&Se(t),s={left:0,top:0};if(!i)return s;const r=((e=pc(t))===null||e===void 0?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 n={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(n=t.getBoundingClientRect());const l=uc(t);return{left:n.left+l.left-(a.clientLeft||0)+s.left,top:n.top+l.top-(a.clientTop||0)+s.top}}(this.lower.el)}dispose(){Re().dispose(this.lower.el),delete this.lower}}const sg={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Jt]};class Ks extends oc(nc){get lowerCanvasEl(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.el}get contextContainer(){var t;return(t=this.elements.lower)===null||t===void 0?void 0:t.ctx}static getDefaults(){return Ks.ownDefaults}constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,this.constructor.getDefaults()),this.set(e),this.initElements(t),this._setDimensionsImpl({width:this.width||this.elements.lower.el.width||0,height:this.height||this.elements.lower.el.height||0}),this.skipControlsDrawing=!1,this.viewportTransform=[...this.viewportTransform],this.calcViewportBoundaries()}initElements(t){this.elements=new fc(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&&(vi("warn",`Canvas is trying to add an object that belongs to a different canvas.
2624
+ Resulting to default behavior: removing object from previous canvas and adding to new canvas`),t.canvas.remove(t)),t._set("canvas",this),t.setCoords(),this.fire("object:added",{target:t}),t.fire("added",{target:this})}_onObjectRemoved(t){t._set("canvas",void 0),this.fire("object:removed",{target:t}),t.fire("removed",{target:this})}_onStackOrderChanged(){this.renderOnAddRemove&&this.requestRenderAll()}getRetinaScaling(){return this.enableRetinaScaling?ec():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&&arguments[1]!==void 0?arguments[1]:{};if(!e){const s=_({width:this.width,height:this.height},t);this.elements.setDimensions(s,this.getRetinaScaling()),this.hasLostContext=!0,this.width=s.width,this.height=s.height}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=ee(t,Te(s));s[0]=e,s[3]=e;const n=ee(r,s);s[4]+=i.x-n.x,s[5]+=i.y-n.y,this.setViewportTransform(s)}setZoom(t){this.zoomToPoint(new x(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new x(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=Ar(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,i=Te(this.viewportTransform),s=ee({x:0,y:0},i),r=ee({x:t,y:e},i),n=s.min(r),a=s.max(r);return this.vptCoords={tl:n,tr:new x(a.x,n.y),bl:new x(n.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(Zp(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,n=this["".concat(e,"Vpt")];if(!i&&!s)return;const a=ve(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=a?i.toLive(t):i,n&&t.transform(...r),a){t.transform(1,0,0,1,i.offsetX||0,i.offsetY||0);const l=i.gradientTransform||i.patternTransform;l&&t.transform(...l)}t.fill(),t.restore()}if(s){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=n,n&&t.transform(...r),s.render(t),this.skipOffscreen=l,t.restore()}}_renderBackground(t){this._renderBackgroundOrOverlay(t,"background")}_renderOverlay(t){this._renderBackgroundOrOverlay(t,"overlay")}getCenter(){return{top:this.height/2,left:this.width/2}}getCenterPoint(){return new x(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new x(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new x(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new x(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return ee(this.getCenterPoint(),Te(this.viewportTransform))}_centerObject(t,e){t.setXY(e,N,N),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 _(_(_({version:sn},hs(this,e)),{},{objects:this._objects.filter(r=>!r.excludeFromExport).map(r=>this._toObject(r,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,n=this.backgroundColor,a=this.overlayColor;return ve(n)?n.excludeFromExport||(i.background=n.toObject(e)):n&&(i.background=n),ve(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),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&&arguments[0]!==void 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,`)" >
2618
2625
  `)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
2619
2626
  `),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" ?>
2620
2627
  `,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
2621
- `)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),r=U.NUM_FRACTION_DIGITS,n=e.viewBox;let a;if(n)a='viewBox="'.concat(n.x," ").concat(n.y," ").concat(n.width," ").concat(n.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(nt(-l[4]/l[0],r)," ").concat(nt(-l[5]/l[3],r)," ").concat(nt(this.width/l[0],r)," ").concat(nt(this.height/l[3],r),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',s,'" ',a,`xml:space="preserve">
2628
+ `)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),s=e.height||"".concat(this.height),r=U.NUM_FRACTION_DIGITS,n=e.viewBox;let a;if(n)a='viewBox="'.concat(n.x," ").concat(n.y," ").concat(n.width," ").concat(n.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(at(-l[4]/l[0],r)," ").concat(at(-l[5]/l[3],r)," ").concat(at(this.width/l[0],r)," ").concat(at(this.height/l[3],r),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',s,'" ',a,`xml:space="preserve">
2622
2629
  `,"<desc>Created with Fabric.js ",sn,`</desc>
2623
2630
  `,`<defs>
2624
2631
  `,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
2625
- `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(vi()),'<clipPath id="'.concat(e.clipPathId,`" >
2632
+ `)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(_i()),'<clipPath id="'.concat(e.clipPathId,`" >
2626
2633
  `).concat(e.toClipPathSVG(t.reviver),`</clipPath>
2627
- `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(be(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?Vr(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=U.fontPaths;this._objects.forEach(function r(n){t.push(n),Dr(n)&&n._objects.forEach(r)}),t.forEach(r=>{if(!(n=r)||typeof n._renderText!="function")return;var n;const{styles:a,fontFamily:l}=r;!e[l]&&i[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:d=""}=h;!e[d]&&i[d]&&(e[d]=!0)})}))});const s=Object.keys(e).map(r=>` @font-face {
2634
+ `)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(ve(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?Vr(s):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=U.fontPaths;this._objects.forEach(function r(n){t.push(n),Dr(n)&&n._objects.forEach(r)}),t.forEach(r=>{if(!(n=r)||typeof n._renderText!="function")return;var n;const{styles:a,fontFamily:l}=r;!e[l]&&i[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:d=""}=h;!e[d]&&i[d]&&(e[d]=!0)})}))});const s=Object.keys(e).map(r=>` @font-face {
2628
2635
  font-family: '`.concat(r,`';
2629
2636
  src: url('`).concat(i[r],`');
2630
2637
  }
2631
2638
  `)).join("");return s?` <style type="text/css"><![CDATA[
2632
2639
  `.concat(s,`]]></style>
2633
- `):""}_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(be(i)){const s=i.repeat||"",r=this.width,n=this.height,a=this["".concat(e,"Vpt")]?Vr(Se(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(r/2,",").concat(n/2,')" x="').concat(i.offsetX-r/2,'" y="').concat(i.offsetY-n/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!Xa(i)?r:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Xa(i)?n:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
2640
+ `):""}_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(ve(i)){const s=i.repeat||"",r=this.width,n=this.height,a=this["".concat(e,"Vpt")]?Vr(Te(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(r/2,",").concat(n/2,')" x="').concat(i.offsetX-r/2,'" y="').concat(i.offsetY-n/2,'" width="').concat(s!=="repeat-y"&&s!=="no-repeat"||!Xa(i)?r:i.source.width,'" height="').concat(s!=="repeat-x"&&s!=="no-repeat"||!Xa(i)?n:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
2634
2641
  `))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
2635
- `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new Fe("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[],backgroundImage:n,background:a,overlayImage:l,overlay:c,clipPath:h}=s,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([zs(r,{reviver:e,signal:i}),ho({backgroundImage:n,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(u=>{let[g,p]=u;return this.clear(),this.add(...g),this.set(s),this.set(p),this.renderOnAddRemove=d,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Re(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,n=s*(r?this.getRetinaScaling():1);return ac(this.toCanvasElement(n,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:r,filter:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,g=c*t,p=this.viewportTransform,f=[g,0,0,g,(p[4]-(s||0))*t,(p[5]-(r||0))*t],b=this.enableRetinaScaling,m=Re({width:a,height:l}),y=n?this._objects.filter(w=>n(w)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),y),this.viewportTransform=p,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=b,this.skipControlsDrawing=u,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Hr.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," }>")}}v(Ks,"ownDefaults",sg);const rg=["touchstart","touchmove","touchend"],og=o=>{const t=uc(o.target),e=function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i}(o);return new x(e.clientX+t.left,e.clientY+t.top)},nn=o=>rg.includes(o.type)||o.pointerType==="touch",an=o=>{o.preventDefault(),o.stopPropagation()},Ze=o=>{let t=0,e=0,i=0,s=0;for(let r=0,n=o.length;r<n;r++){const{x:a,y:l}=o[r];(a>i||!r)&&(i=a),(a<t||!r)&&(t=a),(l>s||!r)&&(s=l),(l<e||!r)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},ng=["translateX","translateY","scaleX","scaleY"],ag=(o,t)=>Ur(o,$t(t,o.calcOwnMatrix())),Ur=(o,t)=>{const e=Nr(t),{translateX:i,translateY:s,scaleX:r,scaleY:n}=e,a=it(e,ng),l=new x(i,s);o.flipX=!1,o.flipY=!1,Object.assign(o,a),o.set({scaleX:r,scaleY:n}),o.setPositionByOrigin(l,H,H)},lg=o=>{o.scaleX=1,o.scaleY=1,o.skewX=0,o.skewY=0,o.flipX=!1,o.flipY=!1,o.rotate(0)},mc=o=>({scaleX:o.scaleX,scaleY:o.scaleY,skewX:o.skewX,skewY:o.skewY,angle:o.angle,left:o.left,flipX:o.flipX,flipY:o.flipY,top:o.top}),Bn=(o,t,e)=>{const i=o/2,s=t/2,r=[new x(-i,-s),new x(i,-s),new x(-i,s),new x(i,s)].map(a=>a.transform(e)),n=Ze(r);return new x(n.width,n.height)},uo=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Jt;return $t(Se(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt),o)},ts=function(o){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return o.transform(uo(t,e))},cg=function(o){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return o.transform(uo(t,e),!0)},hg=(o,t,e)=>{const i=uo(t,e);return Ur(o,$t(i,o.calcOwnMatrix())),i},bc=(o,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(o),_(_({},t),{},{target:i})),i.fire(o,t)},dg={left:-.5,top:-.5,center:0,bottom:.5,right:.5},St=o=>typeof o=="string"?dg[o]:o-.5,Wr="not-allowed";function vc(o){return St(o.originX)===St(H)&&St(o.originY)===St(H)}function Ka(o){return .5-St(o)}const Ee=(o,t)=>o[t],_c=(o,t,e,i)=>({e:o,transform:t,pointer:new x(e,i)});function yc(o,t){const e=o.getTotalAngle()+Bi(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Rn(o,t,e,i,s){var r;let{target:n,corner:a}=o;const l=n.controls[a],c=((r=n.canvas)===null||r===void 0?void 0:r.getZoom())||1,h=n.padding/c,d=function(u,g,p,f){const b=u.getRelativeCenterPoint(),m=p!==void 0&&f!==void 0?u.translateToGivenOrigin(b,H,H,p,f):new x(u.left,u.top);return(u.angle?g.rotate(-bt(u.angle),b):g).subtract(m)}(n,new x(i,s),t,e);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 ug=(o,t,e,i)=>{const{target:s,offsetX:r,offsetY:n}=t,a=e-r,l=i-n,c=!Ee(s,"lockMovementX")&&s.left!==a,h=!Ee(s,"lockMovementY")&&s.top!==l;return c&&s.set(G,a),h&&s.set(ie,l),(c||h)&&bc(ic,_c(o,t,e,i)),c||h};class xc{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):se,r=this.strokeDashOffset?this.strokeDashOffset:"0",n=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=Hs(Pt,this.fill);return[Hs(re,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",n,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Vr(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?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&&arguments[1]!==void 0?arguments[1]:{};const n=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,g=this.shadow,p=[],f=t.indexOf("COMMON_PARTS");let b;l&&(l.clipPathId="CLIPPATH_".concat(vi()),b='<clipPath id="'.concat(l.clipPathId,`" >
2642
+ `)}loadFromJSON(t,e){let{signal:i}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return Promise.reject(new je("`json` is undefined"));const s=typeof t=="string"?JSON.parse(t):t,{objects:r=[],backgroundImage:n,background:a,overlayImage:l,overlay:c,clipPath:h}=s,d=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Hs(r,{reviver:e,signal:i}),ho({backgroundImage:n,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(u=>{let[g,p]=u;return this.clear(),this.add(...g),this.set(s),this.set(p),this.renderOnAddRemove=d,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=ze(this);return new this.constructor(t)}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const{format:e="png",quality:i=1,multiplier:s=1,enableRetinaScaling:r=!1}=t,n=s*(r?this.getRetinaScaling():1);return ac(this.toCanvasElement(n,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:s,top:r,filter:n}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=(e||this.width)*t,l=(i||this.height)*t,c=this.getZoom(),h=this.width,d=this.height,u=this.skipControlsDrawing,g=c*t,p=this.viewportTransform,f=[g,0,0,g,(p[4]-(s||0))*t,(p[5]-(r||0))*t],b=this.enableRetinaScaling,m=ze({width:a,height:l}),y=n?this._objects.filter(w=>n(w)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=f,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(m.getContext("2d"),y),this.viewportTransform=p,this.width=h,this.height=d,this.calcViewportBoundaries(),this.enableRetinaScaling=b,this.skipControlsDrawing=u,m}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),Hr.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," }>")}}v(Ks,"ownDefaults",sg);const rg=["touchstart","touchmove","touchend"],og=o=>{const t=uc(o.target),e=function(i){const s=i.changedTouches;return s&&s[0]?s[0]:i}(o);return new x(e.clientX+t.left,e.clientY+t.top)},nn=o=>rg.includes(o.type)||o.pointerType==="touch",an=o=>{o.preventDefault(),o.stopPropagation()},Qe=o=>{let t=0,e=0,i=0,s=0;for(let r=0,n=o.length;r<n;r++){const{x:a,y:l}=o[r];(a>i||!r)&&(i=a),(a<t||!r)&&(t=a),(l>s||!r)&&(s=l),(l<e||!r)&&(e=l)}return{left:t,top:e,width:i-t,height:s-e}},ng=["translateX","translateY","scaleX","scaleY"],ag=(o,t)=>Ur(o,$t(t,o.calcOwnMatrix())),Ur=(o,t)=>{const e=Nr(t),{translateX:i,translateY:s,scaleX:r,scaleY:n}=e,a=it(e,ng),l=new x(i,s);o.flipX=!1,o.flipY=!1,Object.assign(o,a),o.set({scaleX:r,scaleY:n}),o.setPositionByOrigin(l,N,N)},lg=o=>{o.scaleX=1,o.scaleY=1,o.skewX=0,o.skewY=0,o.flipX=!1,o.flipY=!1,o.rotate(0)},mc=o=>({scaleX:o.scaleX,scaleY:o.scaleY,skewX:o.skewX,skewY:o.skewY,angle:o.angle,left:o.left,flipX:o.flipX,flipY:o.flipY,top:o.top}),Bn=(o,t,e)=>{const i=o/2,s=t/2,r=[new x(-i,-s),new x(i,-s),new x(-i,s),new x(i,s)].map(a=>a.transform(e)),n=Qe(r);return new x(n.width,n.height)},uo=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Jt;return $t(Te(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt),o)},es=function(o){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return o.transform(uo(t,e))},cg=function(o){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Jt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Jt;return o.transform(uo(t,e),!0)},hg=(o,t,e)=>{const i=uo(t,e);return Ur(o,$t(i,o.calcOwnMatrix())),i},bc=(o,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(o),_(_({},t),{},{target:i})),i.fire(o,t)},dg={left:-.5,top:-.5,center:0,bottom:.5,right:.5},St=o=>typeof o=="string"?dg[o]:o-.5,Wr="not-allowed";function vc(o){return St(o.originX)===St(N)&&St(o.originY)===St(N)}function Ka(o){return .5-St(o)}const ke=(o,t)=>o[t],_c=(o,t,e,i)=>({e:o,transform:t,pointer:new x(e,i)});function yc(o,t){const e=o.getTotalAngle()+Bi(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function Rn(o,t,e,i,s){var r;let{target:n,corner:a}=o;const l=n.controls[a],c=((r=n.canvas)===null||r===void 0?void 0:r.getZoom())||1,h=n.padding/c,d=function(u,g,p,f){const b=u.getRelativeCenterPoint(),m=p!==void 0&&f!==void 0?u.translateToGivenOrigin(b,N,N,p,f):new x(u.left,u.top);return(u.angle?g.rotate(-vt(u.angle),b):g).subtract(m)}(n,new x(i,s),t,e);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 ug=(o,t,e,i)=>{const{target:s,offsetX:r,offsetY:n}=t,a=e-r,l=i-n,c=!ke(s,"lockMovementX")&&s.left!==a,h=!ke(s,"lockMovementY")&&s.top!==l;return c&&s.set(G,a),h&&s.set(ie,l),(c||h)&&bc(ic,_c(o,t,e,i)),c||h};class xc{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):se,r=this.strokeDashOffset?this.strokeDashOffset:"0",n=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",d=t?"":this.getSvgFilter(),u=Ns(Ot,this.fill);return[Ns(re,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",n,"; ","stroke-dashoffset: ",r,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",u,"fill-rule: ",e,"; ","opacity: ",c,";",d,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),s='transform="'.concat(Vr(i));return"".concat(s).concat(e,'" ')}_toSVG(t){return[""]}toSVG(t){return this._createBaseSVGMarkup(this._toSVG(t),{reviver:t})}toClipPathSVG(t){return" "+this._createBaseClipPathSVGMarkup(this._toSVG(t),{reviver:t})}_createBaseClipPathSVGMarkup(t){let{reviver:e,additionalTransform:i=""}=arguments.length>1&&arguments[1]!==void 0?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&&arguments[1]!==void 0?arguments[1]:{};const n=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=s?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,d=this.stroke,u=this.fill,g=this.shadow,p=[],f=t.indexOf("COMMON_PARTS");let b;l&&(l.clipPathId="CLIPPATH_".concat(_i()),b='<clipPath id="'.concat(l.clipPathId,`" >
2636
2643
  `).concat(l.toClipPathSVG(i),`</clipPath>
2637
2644
  `)),h&&p.push("<g ",a,this.getSvgCommons(),` >
2638
2645
  `),p.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
2639
- `);const m=[n,c,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,be(u)&&p.push(u.toSVG(this)),be(d)&&p.push(d.toSVG(this)),g&&p.push(g.toSVG(this)),l&&p.push(b),p.push(t.join("")),p.push(`</g>
2646
+ `);const m=[n,c,e?"":this.addPaintOrder()," ",r?'transform="'.concat(r,'" '):""].join("");return t[f]=m,ve(u)&&p.push(u.toSVG(this)),ve(d)&&p.push(d.toSVG(this)),g&&p.push(g.toSVG(this)),l&&p.push(b),p.push(t.join("")),p.push(`</g>
2640
2647
  `),h&&p.push(`</g>
2641
- `),i?i(p.join("")):p.join("")}addPaintOrder(){return this.paintFirst!==Pt?' paint-order="'.concat(this.paintFirst,'" '):""}}function po(o){return new RegExp("^("+o.join("|")+")\\b","i")}var Za;const Ri=String.raw(Za||(Za=xi(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),pg=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Ri+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Ri+"))?\\s+(.*)"),gg={cx:G,x:G,r:"radius",cy:ie,y:ie,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"},Lo="font-size",Fo="clip-path";po(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);po(["symbol","image","marker","pattern","view","svg"]);const Ja=po(["symbol","g","a","svg","clipPath","defs"]),fg=new x(1,0),wc=new x,Cc=(o,t)=>o.rotate(t),ln=(o,t)=>new x(t).subtract(o),cn=o=>o.distanceFrom(wc),hn=(o,t)=>Math.atan2(As(o,t),bg(o,t)),mg=o=>hn(fg,o),zn=o=>o.eq(wc)?o:o.scalarDivide(cn(o)),Sc=function(o){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return zn(new x(-o.y,o.x).scalarMultiply(t?1:-1))},As=(o,t)=>o.x*t.y-o.y*t.x,bg=(o,t)=>o.x*t.x+o.y*t.y,Qa=(o,t,e)=>{if(o.eq(t)||o.eq(e))return!0;const i=As(t,e),s=As(t,o),r=As(e,o);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},tl="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",el=new RegExp("(?:\\s|^)"+tl+tl+"("+Ri+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class Je{constructor(t){const e=typeof t=="string"?Je.parseShadow(t):t;Object.assign(this,Je.ownDefaults,e),this.id=vi()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(el.exec(e)||[]).map(n=>parseFloat(n)||0);return{color:(e.replace(el,"")||"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=Cc(new x(this.offsetX,this.offsetY),bt(-t.angle)),i=new X(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*nt((Math.abs(e.x)+this.blur)/t.width,U.NUM_FRACTION_DIGITS)+20,r=100*nt((Math.abs(e.y)+this.blur)/t.height,U.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,`%" >
2642
- <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(nt(this.blur?this.blur/2:0,U.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
2643
- <feOffset dx="`).concat(nt(e.x,U.NUM_FRACTION_DIGITS),'" dy="').concat(nt(e.y,U.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
2648
+ `),i?i(p.join("")):p.join("")}addPaintOrder(){return this.paintFirst!==Ot?' paint-order="'.concat(this.paintFirst,'" '):""}}function po(o){return new RegExp("^("+o.join("|")+")\\b","i")}var Za;const Ri=String.raw(Za||(Za=wi(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),pg=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Ri+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Ri+"))?\\s+(.*)"),gg={cx:G,x:G,r:"radius",cy:ie,y:ie,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"},Lo="font-size",Fo="clip-path";po(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);po(["symbol","image","marker","pattern","view","svg"]);const Ja=po(["symbol","g","a","svg","clipPath","defs"]),fg=new x(1,0),wc=new x,Cc=(o,t)=>o.rotate(t),ln=(o,t)=>new x(t).subtract(o),cn=o=>o.distanceFrom(wc),hn=(o,t)=>Math.atan2(Ms(o,t),bg(o,t)),mg=o=>hn(fg,o),zn=o=>o.eq(wc)?o:o.scalarDivide(cn(o)),Sc=function(o){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return zn(new x(-o.y,o.x).scalarMultiply(t?1:-1))},Ms=(o,t)=>o.x*t.y-o.y*t.x,bg=(o,t)=>o.x*t.x+o.y*t.y,Qa=(o,t,e)=>{if(o.eq(t)||o.eq(e))return!0;const i=Ms(t,e),s=Ms(t,o),r=Ms(e,o);return i>=0?s>=0&&r<=0:!(s<=0&&r>=0)},tl="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",el=new RegExp("(?:\\s|^)"+tl+tl+"("+Ri+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ti{constructor(t){const e=typeof t=="string"?ti.parseShadow(t):t;Object.assign(this,ti.ownDefaults,e),this.id=_i()}static parseShadow(t){const e=t.trim(),[,i=0,s=0,r=0]=(el.exec(e)||[]).map(n=>parseFloat(n)||0);return{color:(e.replace(el,"")||"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=Cc(new x(this.offsetX,this.offsetY),vt(-t.angle)),i=new X(this.color);let s=40,r=40;return t.width&&t.height&&(s=100*at((Math.abs(e.x)+this.blur)/t.width,U.NUM_FRACTION_DIGITS)+20,r=100*at((Math.abs(e.y)+this.blur)/t.height,U.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,`%" >
2649
+ <feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(at(this.blur?this.blur/2:0,U.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
2650
+ <feOffset dx="`).concat(at(e.x,U.NUM_FRACTION_DIGITS),'" dy="').concat(at(e.y,U.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
2644
2651
  <feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
2645
2652
  <feComposite in2="oBlur" operator="in" />
2646
2653
  <feMerge>
@@ -2648,44 +2655,44 @@ Resulting to default behavior: removing object from previous canvas and adding t
2648
2655
  <feMergeNode in="SourceGraphic"></feMergeNode>
2649
2656
  </feMerge>
2650
2657
  </filter>
2651
- `)}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=Je.ownDefaults;return this.includeDefaultValues?t:$n(t,(i,s)=>i!==e[s])}static async fromObject(t){return new this(t)}}v(Je,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(Je,"type","shadow"),P.setClass(Je,"shadow");const rs=(o,t,e)=>Math.max(o,Math.min(t,e)),vg=[ie,G,ne,_e,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",as,ls],si=[Pt,re,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],_g={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:G,originY:ie,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Pt,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},yg=(o,t,e,i)=>-e*Math.cos(o/i*Ys)+e+t,xg=()=>!1;class Hn{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:n=yg,onStart:a=Pr,onChange:l=Pr,onComplete:c=Pr,abort:h=xg,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=n,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,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 this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>Ar(t),this.delay):Ar(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,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Ar(this.tick)))}register(){Hr.push(this)}unregister(){Hr.remove(this)}abort(){this._state="aborted",this.unregister()}}const wg=["startValue","endValue"];class Cg extends Hn{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},it(t,wg)),{},{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 Sg=["startValue","endValue"];class Tg extends Hn{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},it(t,Sg)),{},{startValue:e,byValue:i.map((s,r)=>s-e[r])}))}calculate(t){const e=this.startValue.map((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Eg=["startValue","endValue","easing","onChange","onComplete","abort"],kg=(o,t,e,i)=>t+e*(1-Math.cos(o/i*Ys)),jo=o=>o&&((t,e,i)=>o(new X(t).toRgba(),e,i));class Og extends Hn{constructor(t){let{startValue:e,endValue:i,easing:s=kg,onChange:r,onComplete:n,abort:a}=t,l=it(t,Eg);const c=new X(e).getSource(),h=new X(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map((d,u)=>d-c[u]),easing:s,onChange:jo(r),onComplete:jo(n),abort:jo(a)}))}calculate(t){const[e,i,s,r]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),n=[...[e,i,s].map(Math.round),rs(0,r,1)];return{value:n,valueProgress:n.map((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0).find(a=>a!==0)||0}}}function Tc(o){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(o)?new Tg(o):new Cg(o);return t.start(),t}function Pg(o){const t=new Og(o);return t.start(),t}class rt{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(s=>!this.includes(s))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&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=ln(e,i),n=ln(e,t).divide(r);return s?Math.abs(n.x)===Math.abs(n.y):n.x===n.y&&n.x>=0&&n.x<=1}}static isPointInPolygon(t,e){const i=new x(t).setX(Math.min(t.x-1,...e.map(r=>r.x)));let s=0;for(let r=0;r<e.length;r++){const n=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,i);if(n.includes(t))return!0;s+=+(n.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let r=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],n=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,g=c*u-h*d,p=a*u-l*d,f=h*a-c*l;if(f!==0){const b=g/f,m=p/f;return(r||0<=b&&b<=1)&&(n||0<=m&&m<=1)?new rt("Intersection").append(new x(t.x+b*a,t.y+b*l)):new rt}if(g===0||p===0){const b=r||n||rt.isPointContained(t,i,s)||rt.isPointContained(e,i,s)||rt.isPointContained(i,t,e)||rt.isPointContained(s,t,e);return new rt(b?"Coincident":void 0)}return new rt("Parallel")}static intersectSegmentLine(t,e,i,s){return rt.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return rt.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const r=new rt,n=i.length;for(let a,l,c,h=0;h<n;h++){if(a=i[h],l=i[(h+1)%n],c=rt.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return rt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new rt,s=t.length,r=[];for(let n=0;n<s;n++){const a=t[n],l=t[(n+1)%s],c=rt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(r.push(c),i.append(a,l)):i.append(...c.points)}return r.length>0&&r.length===t.length?new rt("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),n=new x(r.x,s.y),a=new x(s.x,r.y);return rt.intersectPolygonPolygon(t,[s,n,r,a])}}class Dg extends nc{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?ee(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=ee(t,Se(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?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 n=this.group.calcTransformMatrix();return r.map(a=>ee(a,n))}return r}intersectsWithRect(t,e){return rt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=rt.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:i,top:s,width:r,height:n}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+n<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return rt.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)?!0: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 Ze(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ne,t),this._set(_e,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?Bi(lc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Jt.concat()}calcACoords(){const t=qs({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Xs(e,i),r=$t(s,t),n=this._getTransformedDimensions(),a=n.x/2,l=n.y/2;return{tl:ee({x:-a,y:-l},r),tr:ee({x:a,y:-l},r),bl:ee({x:-a,y:l},r),br:ee({x:a,y:l},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,St(this.originX),St(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every((r,n)=>r===i[n])?s.value:(this.group&&(e=$t(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=eg(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,r=0;this.strokeUniform&&(s=0,r=i);const n=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new x(n*e.scaleX,a*e.scaleY):Bn(n,a,co(e)),l.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let n=t.x,a=t.y;const l=St(s)-St(e),c=St(r)-St(i);if(l||c){const h=this._getTransformedDimensions();n+=l*h.x,a+=c*h.y}return new x(n,a)}translateToCenterPoint(t,e,i){if(e===H&&i===H)return t;const s=this.translateToGivenOrigin(t,e,i,H,H);return this.angle?s.rotate(bt(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,H,H,e,i);return this.angle?s.rotate(bt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ee(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,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(),G,ie)}}const Ag=["type"],Mg=["extraParam"];let We=class Ir extends Dg{static getDefaults(){return Ir.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){bi("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Ir.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=ke(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=U.maxCacheSideLimit,r=U.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=U.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const n=e/i,[a,l]=Ds.limitDimsByArea(n),c=rs(r,a,s),h=rs(r,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,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:n,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==r||this.zoomY!==n;if(!t||!e)return!1;if(c||h){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 d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,n),this.zoomX=r,this.zoomY=n,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Nr(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),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:t===0?1e-4:t}_set(t,e){t!==ne&&t!==_e||(e=this._constrainScale(e)),t===ne&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof Je||(e=new Je(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 this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r}=this,{width:n,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,width:n,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===re&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,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=Re(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(r=>{r.transform(s)}),e.parentClipPaths.push(t),t.absolutePositioned){const r=Se(this.calcTransformMatrix());s.transform(r[0],r[1],r[2],r[3],r[4],r[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&&arguments[0]!==void 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,be(i)?i.gradientUnits==="percentage"||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&&(be(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&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[r,,,n]=(i==null?void 0:i.viewportTransform)||Jt,a=r*s,l=n*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*U.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!be(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 e.gradientUnits==="percentage"?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===re?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),n=s.x/this.scaleX/r,a=s.y/this.scaleY/r,l=Re({width:Math.ceil(n),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(n,0),c.lineTo(n,a),c.lineTo(0,a),c.closePath(),c.translate(n/2,a/2),c.scale(s.zoomX/this.scaleX/r,s.zoomY/this.scaleY/r),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(P.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=mc(this),i=this.group,s=this.shadow,r=Math.abs,n=t.enableRetinaScaling?ec():1,a=(t.multiplier||1)*n,l=t.canvasProvider||(y=>new Ks(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&lg(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&hg(this,this.getViewportTransform()),this.setCoords();const c=ke(),h=this.getBoundingRect(),d=this.shadow,u=new x;if(d){const y=d.blur,w=d.nonScaling?new x(1,1):this.getObjectScaling();u.x=2*Math.round(r(d.offsetX)+y)*r(w.x),u.y=2*Math.round(r(d.offsetY)+y)*r(w.y)}const g=h.width+u.x,p=h.height+u.y;c.width=Math.ceil(g),c.height=Math.ceil(p);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new x(f.width/2,f.height/2),H,H);const b=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const m=f.toCanvasElement(a||1,t);return this.set("canvas",b),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),m}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ac(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:r,y:n}=this.getRelativeCenterPoint();this.originX=H,this.originY=H,this.left=r,this.top=n}if(this.set("angle",t),e){const{x:r,y:n}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=r,this.top=n,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Hr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Be().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((i,s)=>{let[r,n]=s;return i[r]=this._animate(r,n,e),i},{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:n,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??s.reduce((d,u)=>d[u],this),endValue:e,abort:n==null?void 0:n.bind(this),onChange:(d,u,g)=>{s.reduce((p,f,b)=>(b===s.length-1&&(p[f]=d),p[f]),this),l&&l(d,u,g)},onComplete:(d,u,g)=>{this.setCoords(),c&&c(d,u,g)}});return r?Pg(h):Tc(h)}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(e.length===0&&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 n=0;n<i.length;n++){if(this===i[n])return{fork:[],otherFork:[t,...i.slice(0,n)],common:[this,...e]};if(s===i[n])return{fork:[this,...e.slice(0,r)],otherFork:[t,...i.slice(0,n)],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(),n=i._objects.indexOf(s),a=i._objects.indexOf(r);return n>-1&&n>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Ir.customProperties,this.constructor.customProperties||[]);let e;const i=U.NUM_FRACTION_DIGITS,{clipPath:s,fill:r,stroke:n,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:g,height:p,strokeWidth:f,strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:T,scaleX:k,scaleY:O,angle:E,flipX:S,flipY:D,opacity:I,visible:M,backgroundColor:B,fillRule:R,paintFirst:F,globalCompositeOperation:Y,skewX:tt,skewY:xt}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const W=Gt=>nt(Gt,i),wt=_(_({},cs(this,t)),{},{type:this.constructor.type,version:sn,originX:d,originY:u,left:W(c),top:W(h),width:W(g),height:W(p),fill:Ya(r)?r.toObject():r,stroke:Ya(n)?n.toObject():n,strokeWidth:W(f),strokeDashArray:l&&l.concat(),strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:W(T),scaleX:W(k),scaleY:W(O),angle:W(E),flipX:S,flipY:D,opacity:W(I),shadow:a&&a.toObject(),visible:M,backgroundColor:B,fillRule:R,paintFirst:F,globalCompositeOperation:Y,skewX:W(tt),skewY:W(xt)},e?{clipPath:e}:null);return this.includeDefaultValues?wt:this._removeDefaultValues(wt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return $n(t,(s,r)=>{if(r===G||r===ie||r==="type")return!0;const n=i[r];return s!==n&&!(Array.isArray(s)&&Array.isArray(n)&&s.length===0&&n.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=it(t,Ag),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=it(i,Mg);return ho(e,r).then(n=>s?(delete n[s],new this(e[s],n)):new this(n))}static fromObject(t,e){return this._fromObject(t,e)}};v(We,"stateProperties",vg),v(We,"cacheProperties",si),v(We,"ownDefaults",_g),v(We,"type","FabricObject"),v(We,"colorProperties",[Pt,re,"backgroundColor"]),v(We,"customProperties",[]),P.setClass(We),P.setClass(We,"object");const hs=(o,t,e)=>(i,s,r,n)=>{const a=t(i,s,r,n);return a&&bc(o,_(_({},_c(i,s,r,n)),e)),a};function ds(o){return(t,e,i,s)=>{const{target:r,originX:n,originY:a}=e,l=r.getRelativeCenterPoint(),c=r.translateToOriginPoint(l,n,a),h=o(t,e,i,s);return r.setPositionByOrigin(c,e.originX,e.originY),h}}const il=hs(Rs,ds((o,t,e,i)=>{const s=Rn(t,t.originX,t.originY,e,i);if(St(t.originX)===St(H)||St(t.originX)===St(mt)&&s.x<0||St(t.originX)===St(G)&&s.x>0){const{target:r}=t,n=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=vc(t)?2:1,l=r.width,c=Math.abs(s.x*a/r.scaleX)-n;return r.set("width",Math.max(c,1)),l!==r.width}return!1}));function Ig(o,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,n=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Pt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;o.save(),o.fillStyle=i.cornerColor||s.cornerColor||"",o.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r>n?(h=r,o.scale(1,n/r),u=e*r/n):n>r?(h=n,o.scale(r/n,1),d=t*n/r):h=r,o.beginPath(),o.arc(d,u,h/2,0,Br,!1),o[l](),c&&o.stroke(),o.restore()}function Lg(o,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,n=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Pt,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=r/2,d=n/2;o.save(),o.fillStyle=i.cornerColor||s.cornerColor||"",o.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",o.translate(t,e);const u=s.getTotalAngle();o.rotate(bt(u)),o["".concat(l,"Rect")](-h,-d,r,n),c&&o.strokeRect(-h,-d,r,n),o.restore()}class xe{constructor(t){v(this,"visible",!0),v(this,"actionName",lo),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:n,tr:a,br:l,bl:c}=s;return((r=e.canvas)===null||r===void 0?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&rt.isPointInPolygon(i,[n,a,l,c])}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(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,n){const a=Fn([Xs(i,s),qs({angle:t}),jn((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,i,s,r){((s=s||{}).cornerStyle||r.cornerStyle)==="circle"?Ig.call(this,t,e,i,s,r):Lg.call(this,t,e,i,s,r)}}const Fg=(o,t,e)=>e.lockRotation?Wr:t.cursorStyle,jg=hs(sc,ds((o,t,e,i)=>{let{target:s,ex:r,ey:n,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(Ee(s,"lockRotation"))return!1;const d=Math.atan2(n-h.y,r-h.x),u=Math.atan2(i-h.y,e-h.x);let g=Bi(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,b=s.snapThreshold||f,m=Math.ceil(g/f)*f,y=Math.floor(g/f)*f;Math.abs(g-y)<b?g=y:Math.abs(g-m)<b&&(g=m)}g<0&&(g=360+g),g%=360;const p=s.angle!==g;return s.angle=g,p}));function Ec(o,t){const e=t.canvas,i=o[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function kc(o,t,e){const i=Ee(o,"lockScalingX"),s=Ee(o,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:r,height:n,strokeWidth:a}=o;return r===0&&a===0&&t!=="y"||n===0&&a===0&&t!=="x"}const $g=["e","se","s","sw","w","nw","n","ne","e"],Ts=(o,t,e)=>{const i=Ec(o,e);if(kc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Wr;const s=yc(e,t);return"".concat($g[s],"-resize")};function Nn(o,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,n=s.by,a=Ec(o,r);let l,c,h,d,u,g;if(kc(r,n,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Rn(t,t.originX,t.originY,e,i),u=n!=="y"?Math.sign(l.x||t.signX||1):1,g=n!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=g),Ee(r,"lockScalingFlip")&&(t.signX!==u||t.signY!==g))return!1;if(d=r._getTransformedDimensions(),a&&!n){const b=Math.abs(l.x)+Math.abs(l.y),{original:m}=t,y=b/(Math.abs(d.x*m.scaleX/r.scaleX)+Math.abs(d.y*m.scaleY/r.scaleY));c=m.scaleX*y,h=m.scaleY*y}else c=Math.abs(l.x*r.scaleX/d.x),h=Math.abs(l.y*r.scaleY/d.y);vc(t)&&(c*=2,h*=2),t.signX!==u&&n!=="y"&&(t.originX=Ka(t.originX),c*=-1,t.signX=u),t.signY!==g&&n!=="x"&&(t.originY=Ka(t.originY),h*=-1,t.signY=g)}const p=r.scaleX,f=r.scaleY;return n?(n==="x"&&r.set(ne,c),n==="y"&&r.set(_e,h)):(!Ee(r,"lockScalingX")&&r.set(ne,c),!Ee(r,"lockScalingY")&&r.set(_e,h)),p!==r.scaleX||f!==r.scaleY}const rr=hs(ao,ds((o,t,e,i)=>Nn(o,t,e,i))),Bg=hs(ao,ds((o,t,e,i)=>Nn(o,t,e,i,{by:"x"}))),Rg=hs(ao,ds((o,t,e,i)=>Nn(o,t,e,i,{by:"y"}))),zg=["target","ex","ey","skewingSide"],$o={x:{counterAxis:"y",scale:ne,skew:as,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:_e,skew:ls,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Hg=["ns","nesw","ew","nwse"],Ng=(o,t,e)=>{if(t.x!==0&&Ee(e,"lockSkewingY")||t.y!==0&&Ee(e,"lockSkewingX"))return Wr;const i=yc(e,t)%4;return"".concat(Hg[i],"-resize")};function Oc(o,t,e,i,s){const{target:r}=e,{counterAxis:n,origin:a,lockSkewing:l,skew:c,flip:h}=$o[o];if(Ee(r,l))return!1;const{origin:d,flip:u}=$o[n],g=St(e[d])*(r[u]?-1:1),p=-Math.sign(g)*(r[h]?-1:1),f=.5*-((r[c]===0&&Rn(e,H,H,i,s)[o]>0||r[c]>0?1:-1)*p)+.5;return hs(rc,ds((m,y,w,T)=>function(k,O,E){let{target:S,ex:D,ey:I,skewingSide:M}=O,B=it(O,zg);const{skew:R}=$o[k],F=E.subtract(new x(D,I)).divide(new x(S.scaleX,S.scaleY))[k],Y=S[R],tt=B[R],xt=Math.tan(bt(tt)),W=k==="y"?S._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:S._getTransformedDimensions({scaleX:1,scaleY:1}).y,wt=2*F*M/Math.max(W,1)+xt,Gt=Bi(Math.atan(wt));S.set(R,Gt);const Yt=Y!==S[R];if(Yt&&k==="y"){const{skewX:Oe,scaleX:fe}=S,It=S._getTransformedDimensions({skewY:Y}),Pe=S._getTransformedDimensions(),le=Oe!==0?It.x/Pe.x:1;le!==1&&S.set(ne,le*fe)}return Yt}(o,y,new x(w,T))))(t,_(_({},e),{},{[a]:f,skewingSide:p}),i,s)}const Vg=(o,t,e,i)=>Oc("x",o,t,e,i),Ug=(o,t,e,i)=>Oc("y",o,t,e,i);function go(o,t){return o[t.canvas.altActionKey]}const or=(o,t,e)=>{const i=go(o,e);return t.x===0?i?as:_e:t.y===0?i?ls:ne:""},Ki=(o,t,e)=>go(o,e)?Ng(0,t,e):Ts(o,t,e),sl=(o,t,e,i)=>go(o,t.target)?Ug(o,t,e,i):Bg(o,t,e,i),rl=(o,t,e,i)=>go(o,t.target)?Vg(o,t,e,i):Rg(o,t,e,i),Pc=()=>({ml:new xe({x:-.5,y:0,cursorStyleHandler:Ki,actionHandler:sl,getActionName:or}),mr:new xe({x:.5,y:0,cursorStyleHandler:Ki,actionHandler:sl,getActionName:or}),mb:new xe({x:0,y:.5,cursorStyleHandler:Ki,actionHandler:rl,getActionName:or}),mt:new xe({x:0,y:-.5,cursorStyleHandler:Ki,actionHandler:rl,getActionName:or}),tl:new xe({x:-.5,y:-.5,cursorStyleHandler:Ts,actionHandler:rr}),tr:new xe({x:.5,y:-.5,cursorStyleHandler:Ts,actionHandler:rr}),bl:new xe({x:-.5,y:.5,cursorStyleHandler:Ts,actionHandler:rr}),br:new xe({x:.5,y:.5,cursorStyleHandler:Ts,actionHandler:rr}),mtr:new xe({x:0,y:-.5,actionHandler:jg,cursorStyleHandler:Fg,offsetY:-40,withConnection:!0,actionName:In})}),Wg=()=>({mr:new xe({x:.5,y:0,actionHandler:il,cursorStyleHandler:Ki,actionName:Rs}),ml:new xe({x:-.5,y:0,actionHandler:il,cursorStyleHandler:Ki,actionName:Rs})}),Gg=()=>_(_({},Pc()),Wg());class Ns extends We{static getDefaults(){return _(_({},super.getDefaults()),Ns.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Ns.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Pc()}}_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(lo))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[r,n]=i[s],a=this.controls[r];if(a.shouldActivate(r,this,t,e?n.touchCorner:n.corner))return this.__corner=r,{key:r,control:a,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Xs(e.x,e.y),s=qs({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=$t(i,s),n=$t(t,r),a=$t(n,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Nr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl((d,u)=>{const g=d.positionHandler(c,a,this,d);h[u]=Object.assign(g,this._calcCornerCoords(d,g))}),h}_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(bt(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&&arguments[2]!==void 0?arguments[2]:{};const s=_({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&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,r=_({hasBorders:i,hasControls:s},e),n=this.getViewportTransform(),a=r.hasBorders,l=r.hasControls,c=$t(n,this.calcTransformMatrix()),h=Nr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(bt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const r=Bn(this.width,this.height,co(e)),n=this.isStrokeAccountedForInDimensions()?Ln:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=r.add(n).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&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:r,cornerColor:n}=this,a=_({cornerStrokeColor:s,cornerDashArray:r,cornerColor:n},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[i,s]=e;return this.setControlVisible(i,s)})}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 Dc(o,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(o.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))})}),o}v(Ns,"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 Nt extends Ns{}Dc(Nt,[xc]),P.setClass(Nt),P.setClass(Nt,"object");const Yg=(o,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:r}=o.getImageData(t-i,e-i,s,s);for(let n=3;n<r.length;n+=4)if(r[n]>0)return!1;return!0};class Ac{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const i=ln(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 this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(bt(this.options.skewY)),e.x+=e.y*Math.tan(bt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Xg=new x;class es extends Ac{static getOrthogonalRotationFactor(t,e){const i=e?hn(t,e):mg(t);return Math.abs(i)<Ys?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=hn(this.AB,this.AC),this.bisector=zn(Cc(this.AB.eq(Xg)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),r=Sc(s),n=es.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*n)}projectBevel(){const t=[];return(this.alpha%Br==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?cn(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return cn(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new x(es.getOrthogonalRotationFactor(this.bisector),es.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(r=>{Qa(r,t,e)&&i.push(this.A.add(r))}),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:n,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(bt(s)),Math.tan(bt(r))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/n**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new x(Math.sqrt(Math.max(h**2-d**2,0)),d),g=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/n+1/n*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),p=new x(g,Math.sqrt(Math.max(h**2-g**2,0)));return[p,p.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f)).forEach(f=>{Qa(f,t,e)&&i.push(this.applySkew(this.A).add(f))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Br==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),n=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=As(s,n)>0,l=a?s:r,c=a?r:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class ol extends Ac{constructor(t,e,i){super(i),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Sc(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 x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new es(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(zn(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const qg=function(o,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(o.length===0)return i;const s=o.reduce((r,n)=>(r[r.length-1].eq(n)||r.push(new x(n)),r),[new x(o[0])]);if(s.length===1)e=!0;else if(!e){const r=s[0],n=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,a=>!a.eq(r));s.splice(n+1)}return s.forEach((r,n,a)=>{let l,c;n===0?(c=a[1],l=e?r:a[a.length-1]):n===a.length-1?(l=a[n-1],c=e?r:a[0]):(l=a[n-1],c=a[n+1]),e&&a.length===1?i.push(...new ol(r,r,t).project()):!e||n!==0&&n!==a.length-1?i.push(...new es(r,l,c,t).project()):i.push(...new ol(r,n===0?c:l,t).project())}),i},Vn=o=>{const t={};return Object.keys(o).forEach(e=>{t[e]={},Object.keys(o[e]).forEach(i=>{t[e][i]=_({},o[e][i])})}),t},Kg=o=>o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Un=o=>{const t=[];for(let e,i=0;i<o.length;i++)(e=Zg(o,i))!==!1&&t.push(e);return t},Zg=(o,t)=>{const e=o.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return o.charAt(t);if(55296<=e&&e<=56319){if(o.length<=t+1)throw"High surrogate without following low surrogate";const s=o.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return o.charAt(t)+o.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=o.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Wn=function(o,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return o.fill!==t.fill||o.stroke!==t.stroke||o.strokeWidth!==t.strokeWidth||o.fontSize!==t.fontSize||o.fontFamily!==t.fontFamily||o.fontWeight!==t.fontWeight||o.fontStyle!==t.fontStyle||o.textBackgroundColor!==t.textBackgroundColor||o.deltaY!==t.deltaY||e&&(o.overline!==t.overline||o.underline!==t.underline||o.linethrough!==t.linethrough)},Jg=(o,t)=>{const e=t.split(`
2652
- `),i=[];let s=-1,r={};o=Vn(o);for(let n=0;n<e.length;n++){const a=Un(e[n]);if(o[n])for(let l=0;l<a.length;l++){s++;const c=o[n][l];c&&Object.keys(c).length>0&&(Wn(r,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),r=c||{}}else s+=a.length,r={}}return i},Qg=(o,t)=>{if(!Array.isArray(o))return Vn(o);const e=t.split(Mn),i={};let s=-1,r=0;for(let n=0;n<e.length;n++){const a=Un(e[n]);for(let l=0;l<a.length;l++)s++,o[r]&&o[r].start<=s&&s<o[r].end&&(i[n]=i[n]||{},i[n][l]=_({},o[r].style),s===o[r].end-1&&r++)}return i},wi=["display","transform",Pt,"fill-opacity","fill-rule","opacity",re,"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 nl(o,t){const e=o.nodeName,i=o.getAttribute("class"),s=o.getAttribute("id"),r="(?![a-zA-Z\\-]+)";let n;if(n=new RegExp("^"+e,"i"),t=t.replace(n,""),s&&t.length&&(n=new RegExp("#"+s+r,"i"),t=t.replace(n,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)n=new RegExp("\\."+a[l]+r,"i"),t=t.replace(n,"")}return t.length===0}function tf(o,t){let e=!0;const i=nl(o,t.pop());return i&&t.length&&(e=function(s,r){let n,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&r.length;)a&&(n=r.pop()),a=nl(s=s.parentElement,n);return r.length===0}(o,t)),i&&e&&t.length===0}const ef=o=>{var t;return(t=gg[o])!==null&&t!==void 0?t:o},sf=new RegExp("(".concat(Ri,")"),"gi"),rf=o=>o.replace(sf," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var al,ll,cl,hl,dl,ul,pl;const Zt="(".concat(Ri,")"),of=String.raw(al||(al=xi(["(skewX)(",")"],["(skewX)\\(","\\)"])),Zt),nf=String.raw(ll||(ll=xi(["(skewY)(",")"],["(skewY)\\(","\\)"])),Zt),af=String.raw(cl||(cl=xi(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Zt,Zt,Zt),lf=String.raw(hl||(hl=xi(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Zt,Zt),cf=String.raw(dl||(dl=xi(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Zt,Zt),hf=String.raw(ul||(ul=xi(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Zt,Zt,Zt,Zt,Zt,Zt),Gn="(?:".concat(hf,"|").concat(cf,"|").concat(af,"|").concat(lf,"|").concat(of,"|").concat(nf,")"),df="(?:".concat(Gn,"*)"),uf=String.raw(pl||(pl=xi(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),df),pf=new RegExp(uf),gf=new RegExp(Gn),ff=new RegExp(Gn,"g");function dn(o){const t=[];if(!(o=rf(o).replace(/\s*([()])\s*/gi,"$1"))||o&&!pf.test(o))return[...Jt];for(const e of o.matchAll(ff)){const i=gf.exec(e[0]);if(!i)continue;let s=Jt;const r=i.filter(p=>!!p),[,n,...a]=r,[l,c,h,d,u,g]=a.map(p=>parseFloat(p));switch(n){case"translate":s=Xs(l,c);break;case In:s=qs({angle:l},{x:c,y:h});break;case lo:s=jn(l,c);break;case as:s=hc(l);break;case ls:s=dc(l);break;case"matrix":s=[l,c,h,d,u,g]}t.push(s)}return Fn(t)}function mf(o,t,e,i){const s=Array.isArray(t);let r,n=t;if(o!==Pt&&o!==re||t!==se){if(o==="strokeUniform")return t==="non-scaling-stroke";if(o==="strokeDashArray")n=t===se?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(o==="transformMatrix")n=e&&e.transformMatrix?$t(e.transformMatrix,dn(t)):dn(t);else if(o==="visible")n=t!==se&&t!=="hidden",e&&e.visible===!1&&(n=!1);else if(o==="opacity")n=parseFloat(t),e&&e.opacity!==void 0&&(n*=e.opacity);else if(o==="textAnchor")n=t==="start"?G:t==="end"?mt:H;else if(o==="charSpacing")r=Qi(t,i)/i*1e3;else if(o==="paintFirst"){const a=t.indexOf(Pt),l=t.indexOf(re);n=Pt,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(n=re)}else{if(o==="href"||o==="xlink:href"||o==="font"||o==="id")return t;if(o==="imageSmoothing")return t==="optimizeQuality";r=s?t.map(Qi):Qi(t,i)}}else n="";return!s&&isNaN(r)?n:r}function bf(o,t){const e=o.match(pg);if(!e)return;const i=e[1],s=e[3],r=e[4],n=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),r&&(t.fontSize=Qi(r)),a&&(t.fontFamily=a),n&&(t.lineHeight=n==="normal"?1:n)}function vf(o,t){o.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()})}function _f(o){const t={},e=o.getAttribute("style");return e&&(typeof e=="string"?vf(e,t):function(i,s){Object.entries(i).forEach(r=>{let[n,a]=r;a!==void 0&&(s[n.toLowerCase()]=a)})}(e,t)),t}const yf={stroke:"strokeOpacity",fill:"fillOpacity"};function ri(o,t,e){if(!o)return{};let i,s={},r=An;o.parentNode&&Ja.test(o.parentNode.nodeName)&&(s=ri(o.parentElement,t,e),s.fontSize&&(i=r=Qi(s.fontSize)));const n=_(_(_({},t.reduce((c,h)=>{const d=o.getAttribute(h);return d&&(c[h]=d),c},{})),function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};for(const u in h)tf(c,u.split(" "))&&(d=_(_({},d),h[u]));return d}(o,e)),_f(o));n[Fo]&&o.setAttribute(Fo,n[Fo]),n[Lo]&&(i=Qi(n[Lo],r),n[Lo]="".concat(i));const a={};for(const c in n){const h=ef(c),d=mf(h,n[c],s,i);a[h]=d}a&&a.font&&bf(a.font,a);const l=_(_({},s),a);return Ja.test(o.nodeName)?l:function(c){const h=Nt.getDefaults();return Object.entries(yf).forEach(d=>{let[u,g]=d;if(c[g]===void 0||c[u]==="")return;if(c[u]===void 0){if(!h[u])return;c[u]=h[u]}if(c[u].indexOf("url(")===0)return;const p=new X(c[u]);c[u]=p.setAlpha(nt(p.getAlpha()*c[g],2)).toRgba()}),c}(l)}const xf=["left","top","width","height","visible"],Mc=["rx","ry"];class jt extends Nt{static getDefaults(){return _(_({},super.getDefaults()),jt.ownDefaults)}constructor(t){super(),Object.assign(this,jt.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,n=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=n!==0||a!==0;t.beginPath(),t.moveTo(s+n,r),t.lineTo(s+e-n,r),l&&t.bezierCurveTo(s+e-ni*n,r,s+e,r+ni*a,s+e,r+a),t.lineTo(s+e,r+i-a),l&&t.bezierCurveTo(s+e,r+i-ni*a,s+e-ni*n,r+i,s+e-n,r+i),t.lineTo(s+n,r+i),l&&t.bezierCurveTo(s+ni*n,r+i,s,r+i-ni*a,s,r+i-a),t.lineTo(s,r+a),l&&t.bezierCurveTo(s,r+ni*a,s+ni*n,r,s+n,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Mc,...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,`" />
2653
- `)]}static async fromElement(t,e,i){const s=ri(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:n=0,width:a=0,height:l=0,visible:c=!0}=s,h=it(s,xf);return new this(_(_(_({},e),h),{},{left:r,top:n,width:a,height:l,visible:!!(c&&a&&l)}))}}v(jt,"type","Rect"),v(jt,"cacheProperties",[...si,...Mc]),v(jt,"ownDefaults",{rx:0,ry:0}),v(jt,"ATTRIBUTE_NAMES",[...wi,"x","y","rx","ry","width","height"]),P.setClass(jt),P.setSVGClass(jt);const Xe="initialization",Gr="added",Yn="removed",Yr="imperative",Ic=(o,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:n}=t,a=n&&n!==o?uo(n.calcTransformMatrix(),o.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?cg(new x(i,i),void 0,o.calcTransformMatrix()):Ln,d=!e&&c?i:0,u=Bn(s+d,r+d,Fn([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class fo{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Xe||e===Yr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Xe&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Yr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:n,width:a,height:l}=Ze(t.map(d=>Ic(s,d)).reduce((d,u)=>d.concat(u),[])),c=new x(a,l),h=new x(r,n).add(c.scalarDivide(2));if(i===Xe){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(fo,"type","strategy");class un extends fo{shouldPerformLayout(t){return!0}}v(un,"type","fit-content"),P.setClass(un);const wf=["strategy"],Cf=["target","strategy","bubbles","prevStrategy"],Lc="layoutManager";class Vs{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new un;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const 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[zr,ic,Rs,sc,ao,rc,Rr,Xp,qp].map(s=>t.on(s,r=>this.performLayout(s===zr?{type:"object_modified",trigger:s,e:r,target:i}:{type:"object_modifying",trigger:s,e:r,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(i=>i()),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===Xe||i===Gr?this.subscribeTargets(t):i===Yn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Yr&&t.deep){const r=it(t,wf);e.forEachObject(n=>n.layoutManager&&n.layoutManager.performLayout(_(_({},r),{},{bubbles:!1,target:n})))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const n=s===Xe?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=r,h=n.subtract(a).add(l).transform(s===Xe?Jt:Se(e.calcOwnMatrix()),!0).add(c);return{result:r,prevCenter:n,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var n,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Xe?i.set({left:(n=t.x)!==null&&n!==void 0?n:r.x+s.x*St(i.originX),top:(a=t.y)!==null&&a!==void 0?a:r.y+s.y*St(i.originY)}):(i.setPositionByOrigin(r,H,H),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:n}=t,a=it(t,Cf),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;r&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(i=>i())),t.clear()}toObject(){return{type:Lc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}P.setClass(Vs,Lc);const Sf=["type","objects","layoutManager"];class Tf extends Vs{performLayout(){}}class gi extends oc(Nt){static getDefaults(){return _(_({},super.getDefaults()),gi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,gi.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(s=>{this.enterGroup(s,!1)}),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Vs,this.layoutManager.performLayout({type:Xe,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(bi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(bi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i)}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(Gr,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),n=super.insertAt(t,...r);return this._onAfterObjectsChange(Gr,r),n}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Yn,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),t==="canvas"&&i!==e&&(this._objects||[]).forEach(s=>{s._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const r=s.indexOf(i);r>-1&&(s.splice(r,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&&Ur(t,$t(Se(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||(Ur(t,$t(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=Nt.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 n=this._objects[r];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&n.group!==this?(t.save(),t.transform(...Se(this.calcTransformMatrix())),n.render(t),t.restore()):n.group===this&&n.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(_({target:this,type:Yr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const r=s.includeDefaultValues;s.includeDefaultValues=i;const n=s[t||"toObject"](e);return s.includeDefaultValues=r,n})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".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=jt.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",` >
2658
+ `)}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=ti.ownDefaults;return this.includeDefaultValues?t:$n(t,(i,s)=>i!==e[s])}static async fromObject(t){return new this(t)}}v(ti,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),v(ti,"type","shadow"),P.setClass(ti,"shadow");const os=(o,t,e)=>Math.max(o,Math.min(t,e)),vg=[ie,G,ne,ye,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",ls,cs],oi=[Ot,re,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],_g={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:G,originY:ie,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:Ot,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},yg=(o,t,e,i)=>-e*Math.cos(o/i*Ys)+e+t,xg=()=>!1;class Hn{constructor(t){let{startValue:e,byValue:i,duration:s=500,delay:r=0,easing:n=yg,onStart:a=Pr,onChange:l=Pr,onComplete:c=Pr,abort:h=xg,target:d}=t;v(this,"_state","pending"),v(this,"durationProgress",0),v(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=s,this.delay=r,this.easing=n,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=d,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 this._state==="aborted"||this._state==="completed"}start(){const t=e=>{this._state==="pending"&&(this.startTime=e||+new Date,this._state="running",this._onStart(),this.tick(this.startTime))};this.register(),this.delay>0?setTimeout(()=>Ar(t),this.delay):Ar(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,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),Ar(this.tick)))}register(){Hr.push(this)}unregister(){Hr.remove(this)}abort(){this._state="aborted",this.unregister()}}const wg=["startValue","endValue"];class Cg extends Hn{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},it(t,wg)),{},{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 Sg=["startValue","endValue"];class Tg extends Hn{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},it(t,Sg)),{},{startValue:e,byValue:i.map((s,r)=>s-e[r])}))}calculate(t){const e=this.startValue.map((i,s)=>this.easing(t,i,this.byValue[s],this.duration,s));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Eg=["startValue","endValue","easing","onChange","onComplete","abort"],kg=(o,t,e,i)=>t+e*(1-Math.cos(o/i*Ys)),jo=o=>o&&((t,e,i)=>o(new X(t).toRgba(),e,i));class Og extends Hn{constructor(t){let{startValue:e,endValue:i,easing:s=kg,onChange:r,onComplete:n,abort:a}=t,l=it(t,Eg);const c=new X(e).getSource(),h=new X(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map((d,u)=>d-c[u]),easing:s,onChange:jo(r),onComplete:jo(n),abort:jo(a)}))}calculate(t){const[e,i,s,r]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),n=[...[e,i,s].map(Math.round),os(0,r,1)];return{value:n,valueProgress:n.map((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0).find(a=>a!==0)||0}}}function Tc(o){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(o)?new Tg(o):new Cg(o);return t.start(),t}function Pg(o){const t=new Og(o);return t.start(),t}class ot{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(s=>!this.includes(s))),this}static isPointContained(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0&&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=ln(e,i),n=ln(e,t).divide(r);return s?Math.abs(n.x)===Math.abs(n.y):n.x===n.y&&n.x>=0&&n.x<=1}}static isPointInPolygon(t,e){const i=new x(t).setX(Math.min(t.x-1,...e.map(r=>r.x)));let s=0;for(let r=0;r<e.length;r++){const n=this.intersectSegmentSegment(e[r],e[(r+1)%e.length],t,i);if(n.includes(t))return!0;s+=+(n.status==="Intersection")}return s%2==1}static intersectLineLine(t,e,i,s){let r=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],n=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=s.x-i.x,h=s.y-i.y,d=t.x-i.x,u=t.y-i.y,g=c*u-h*d,p=a*u-l*d,f=h*a-c*l;if(f!==0){const b=g/f,m=p/f;return(r||0<=b&&b<=1)&&(n||0<=m&&m<=1)?new ot("Intersection").append(new x(t.x+b*a,t.y+b*l)):new ot}if(g===0||p===0){const b=r||n||ot.isPointContained(t,i,s)||ot.isPointContained(e,i,s)||ot.isPointContained(i,t,e)||ot.isPointContained(s,t,e);return new ot(b?"Coincident":void 0)}return new ot("Parallel")}static intersectSegmentLine(t,e,i,s){return ot.intersectLineLine(t,e,i,s,!1,!0)}static intersectSegmentSegment(t,e,i,s){return ot.intersectLineLine(t,e,i,s,!1,!1)}static intersectLinePolygon(t,e,i){let s=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const r=new ot,n=i.length;for(let a,l,c,h=0;h<n;h++){if(a=i[h],l=i[(h+1)%n],c=ot.intersectLineLine(t,e,a,l,s,!1),c.status==="Coincident")return c;r.append(...c.points)}return r.points.length>0&&(r.status="Intersection"),r}static intersectSegmentPolygon(t,e,i){return ot.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new ot,s=t.length,r=[];for(let n=0;n<s;n++){const a=t[n],l=t[(n+1)%s],c=ot.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(r.push(c),i.append(a,l)):i.append(...c.points)}return r.length>0&&r.length===t.length?new ot("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const s=e.min(i),r=e.max(i),n=new x(r.x,s.y),a=new x(s.x,r.y);return ot.intersectPolygonPolygon(t,[s,n,r,a])}}class Dg extends nc{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?ee(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=ee(t,Te(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new x(this.left,this.top)}setRelativeXY(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.originX,i=arguments.length>2&&arguments[2]!==void 0?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 n=this.group.calcTransformMatrix();return r.map(a=>ee(a,n))}return r}intersectsWithRect(t,e){return ot.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=ot.intersectPolygonPolygon(this.getCoords(),t.getCoords());return e.status==="Intersection"||e.status==="Coincident"||t.isContainedWithinObject(this)||this.isContainedWithinObject(t)}isContainedWithinObject(t){return this.getCoords().every(e=>t.containsPoint(e))}isContainedWithinRect(t,e){const{left:i,top:s,width:r,height:n}=this.getBoundingRect();return i>=t.x&&i+r<=e.x&&s>=t.y&&s+n<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return ot.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)?!0: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 Qe(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(ne,t),this._set(ye,t),this.setCoords()}scaleToWidth(t){const e=this.getBoundingRect().width/this.getScaledWidth();return this.scale(t/this.width/e)}scaleToHeight(t){const e=this.getBoundingRect().height/this.getScaledHeight();return this.scale(t/this.height/e)}getCanvasRetinaScaling(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.getRetinaScaling())||1}getTotalAngle(){return this.group?Bi(lc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Jt.concat()}calcACoords(){const t=qs({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),s=Xs(e,i),r=$t(s,t),n=this._getTransformedDimensions(),a=n.x/2,l=n.y/2;return{tl:ee({x:-a,y:-l},r),tr:ee({x:a,y:-l},r),bl:ee({x:-a,y:l},r),br:ee({x:a,y:l},r)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,St(this.originX),St(this.originY)),e}calcTransformMatrix(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=this.calcOwnMatrix();if(t||!this.group)return e;const i=this.transformMatrixKey(t),s=this.matrixCache;return s&&s.key.every((r,n)=>r===i[n])?s.value:(this.group&&(e=$t(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=eg(s);return this.ownMatrixCache={key:t,value:r},r}_getNonTransformedDimensions(){return new x(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let s=i,r=0;this.strokeUniform&&(s=0,r=i);const n=e.width+s,a=e.height+s;let l;return l=e.skewX===0&&e.skewY===0?new x(n*e.scaleX,a*e.scaleY):Bn(n,a,co(e)),l.scalarAdd(r)}translateToGivenOrigin(t,e,i,s,r){let n=t.x,a=t.y;const l=St(s)-St(e),c=St(r)-St(i);if(l||c){const h=this._getTransformedDimensions();n+=l*h.x,a+=c*h.y}return new x(n,a)}translateToCenterPoint(t,e,i){if(e===N&&i===N)return t;const s=this.translateToGivenOrigin(t,e,i,N,N);return this.angle?s.rotate(vt(this.angle),t):s}translateToOriginPoint(t,e,i){const s=this.translateToGivenOrigin(t,N,N,e,i);return this.angle?s.rotate(vt(this.angle),t):s}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?ee(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new x(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,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(),G,ie)}}const Ag=["type"],Mg=["extraParam"];let Ye=class Ir extends Dg{static getDefaults(){return Ir.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){vi("warn","Setting type has no effect",t)}constructor(t){super(),v(this,"_cacheContext",null),Object.assign(this,Ir.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Oe(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,s=U.maxCacheSideLimit,r=U.minCacheSideLimit;if(e<=s&&i<=s&&e*i<=U.perfLimitSizeTotal)return e<r&&(t.width=r),i<r&&(t.height=r),t;const n=e/i,[a,l]=As.limitDimsByArea(n),c=os(r,a,s),h=os(r,l,s);return e>c&&(t.zoomX/=e/c,t.width=c,t.capped=!0),i>h&&(t.zoomY/=i/h,t.height=h,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:n,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||s!==t.height,h=this.zoomX!==r||this.zoomY!==n;if(!t||!e)return!1;if(c||h){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 d=a/2,u=l/2;return this.cacheTranslationX=Math.round(t.width/2-d)+d,this.cacheTranslationY=Math.round(t.height/2-u)+u,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(r,n),this.zoomX=r,this.zoomY=n,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new x(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=Nr(this.calcTransformMatrix());return new x(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),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:t===0?1e-4:t}_set(t,e){t!==ne&&t!==ye||(e=this._constrainScale(e)),t===ne&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ti||(e=new ti(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 this.opacity===0||!this.width&&!this.height&&this.strokeWidth===0||!this.visible}render(t){this.isNotVisible()||this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(t.save(),this._setupCompositeOperation(t),this.drawSelectionBackground(t),this.transform(t),this._setOpacity(t),this._setShadow(t),this.shouldCache()?(this.renderCache(),this.drawCacheOnCanvas(t)):(this._removeCacheCanvas(),this.drawObject(t,!1,{}),this.dirty=!1),t.restore())}drawSelectionBackground(t){}renderCache(t){if(t=t||{},this._cacheCanvas&&this._cacheContext||this._createCacheCanvas(),this.isCacheDirty()&&this._cacheContext){const{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r}=this,{width:n,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:s,cacheTranslationY:r,width:n,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===re&&this.hasFill()&&this.hasStroke()&&this.shadow)||!!this.clipPath}shouldCache(){return this.ownCaching=this.objectCaching&&(!this.parent||!this.parent.isOnACache())||this.needsItsOwnCache(),this.ownCaching}willDrawShadow(){return!!this.shadow&&(this.shadow.offsetX!==0||this.shadow.offsetY!==0)}drawClipPathOnCache(t,e,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=ze(e),s=i.getContext("2d");if(s.translate(e.cacheTranslationX,e.cacheTranslationY),s.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(r=>{r.transform(s)}),e.parentClipPaths.push(t),t.absolutePositioned){const r=Te(this.calcTransformMatrix());s.transform(r[0],r[1],r[2],r[3],r[4],r[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&&arguments[0]!==void 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,ve(i)?i.gradientUnits==="percentage"||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&&(ve(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&&e.length!==0&&t.setLineDash(e)}_setShadow(t){if(!this.shadow)return;const e=this.shadow,i=this.canvas,s=this.getCanvasRetinaScaling(),[r,,,n]=(i==null?void 0:i.viewportTransform)||Jt,a=r*s,l=n*s,c=e.nonScaling?new x(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*U.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!ve(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 e.gradientUnits==="percentage"?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===re?(this._renderStroke(t),this._renderFill(t)):(this._renderFill(t),this._renderStroke(t))}_render(t){}_renderFill(t){this.fill&&(t.save(),this._setFillStyles(t,this),this.fillRule==="evenodd"?t.fill("evenodd"):t.fill(),t.restore())}_renderStroke(t){if(this.stroke&&this.strokeWidth!==0){if(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this.strokeUniform){const e=this.getObjectScaling();t.scale(1/e.x,1/e.y)}this._setLineDash(t,this.strokeDashArray),this._setStrokeStyles(t,this),t.stroke(),t.restore()}}_applyPatternForTransformedGradient(t,e){var i;const s=this._limitCacheSize(this._getCacheCanvasDimensions()),r=this.getCanvasRetinaScaling(),n=s.x/this.scaleX/r,a=s.y/this.scaleY/r,l=ze({width:Math.ceil(n),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(n,0),c.lineTo(n,a),c.lineTo(0,a),c.closePath(),c.translate(n/2,a/2),c.scale(s.zoomX/this.scaleX/r,s.zoomY/this.scaleY/r),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(r*this.scaleX/s.zoomX,r*this.scaleY/s.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new x(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(P.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=mc(this),i=this.group,s=this.shadow,r=Math.abs,n=t.enableRetinaScaling?ec():1,a=(t.multiplier||1)*n,l=t.canvasProvider||(y=>new Ks(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&lg(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&hg(this,this.getViewportTransform()),this.setCoords();const c=Oe(),h=this.getBoundingRect(),d=this.shadow,u=new x;if(d){const y=d.blur,w=d.nonScaling?new x(1,1):this.getObjectScaling();u.x=2*Math.round(r(d.offsetX)+y)*r(w.x),u.y=2*Math.round(r(d.offsetY)+y)*r(w.y)}const g=h.width+u.x,p=h.height+u.y;c.width=Math.ceil(g),c.height=Math.ceil(p);const f=l(c);t.format==="jpeg"&&(f.backgroundColor="#fff"),this.setPositionByOrigin(new x(f.width/2,f.height/2),N,N);const b=this.canvas;f._objects=[this],this.set("canvas",f),this.setCoords();const m=f.toCanvasElement(a||1,t);return this.set("canvas",b),this.shadow=s,i&&(this.group=i),this.set(e),this.setCoords(),f._objects=[],f.destroy(),m}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return ac(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:r,y:n}=this.getRelativeCenterPoint();this.originX=N,this.originY=N,this.left=r,this.top=n}if(this.set("angle",t),e){const{x:r,y:n}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,s);this.left=r,this.top=n,this.originX=i,this.originY=s}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){Hr.cancelByTarget(this),this.off(),this._set("canvas",void 0),this._cacheCanvas&&Re().dispose(this._cacheCanvas),this._cacheCanvas=void 0,this._cacheContext=null}animate(t,e){return Object.entries(t).reduce((i,s)=>{let[r,n]=s;return i[r]=this._animate(r,n,e),i},{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=t.split("."),r=this.constructor.colorProperties.includes(s[s.length-1]),{abort:n,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??s.reduce((d,u)=>d[u],this),endValue:e,abort:n==null?void 0:n.bind(this),onChange:(d,u,g)=>{s.reduce((p,f,b)=>(b===s.length-1&&(p[f]=d),p[f]),this),l&&l(d,u,g)},onComplete:(d,u,g)=>{this.setCoords(),c&&c(d,u,g)}});return r?Pg(h):Tc(h)}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(e.length===0&&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 n=0;n<i.length;n++){if(this===i[n])return{fork:[],otherFork:[t,...i.slice(0,n)],common:[this,...e]};if(s===i[n])return{fork:[this,...e.slice(0,r)],otherFork:[t,...i.slice(0,n)],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(),n=i._objects.indexOf(s),a=i._objects.indexOf(r);return n>-1&&n>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(Ir.customProperties,this.constructor.customProperties||[]);let e;const i=U.NUM_FRACTION_DIGITS,{clipPath:s,fill:r,stroke:n,shadow:a,strokeDashArray:l,left:c,top:h,originX:d,originY:u,width:g,height:p,strokeWidth:f,strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:T,scaleX:k,scaleY:O,angle:E,flipX:S,flipY:D,opacity:I,visible:M,backgroundColor:B,fillRule:R,paintFirst:F,globalCompositeOperation:Y,skewX:tt,skewY:xt}=this;s&&!s.excludeFromExport&&(e=s.toObject(t.concat("inverted","absolutePositioned")));const W=Gt=>at(Gt,i),wt=_(_({},hs(this,t)),{},{type:this.constructor.type,version:sn,originX:d,originY:u,left:W(c),top:W(h),width:W(g),height:W(p),fill:Ya(r)?r.toObject():r,stroke:Ya(n)?n.toObject():n,strokeWidth:W(f),strokeDashArray:l&&l.concat(),strokeLineCap:b,strokeDashOffset:m,strokeLineJoin:y,strokeUniform:w,strokeMiterLimit:W(T),scaleX:W(k),scaleY:W(O),angle:W(E),flipX:S,flipY:D,opacity:W(I),shadow:a&&a.toObject(),visible:M,backgroundColor:B,fillRule:R,paintFirst:F,globalCompositeOperation:Y,skewX:W(tt),skewY:W(xt)},e?{clipPath:e}:null);return this.includeDefaultValues?wt:this._removeDefaultValues(wt)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return $n(t,(s,r)=>{if(r===G||r===ie||r==="type")return!0;const n=i[r];return s!==n&&!(Array.isArray(s)&&Array.isArray(n)&&s.length===0&&n.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=it(t,Ag),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:s}=i,r=it(i,Mg);return ho(e,r).then(n=>s?(delete n[s],new this(e[s],n)):new this(n))}static fromObject(t,e){return this._fromObject(t,e)}};v(Ye,"stateProperties",vg),v(Ye,"cacheProperties",oi),v(Ye,"ownDefaults",_g),v(Ye,"type","FabricObject"),v(Ye,"colorProperties",[Ot,re,"backgroundColor"]),v(Ye,"customProperties",[]),P.setClass(Ye),P.setClass(Ye,"object");const ds=(o,t,e)=>(i,s,r,n)=>{const a=t(i,s,r,n);return a&&bc(o,_(_({},_c(i,s,r,n)),e)),a};function us(o){return(t,e,i,s)=>{const{target:r,originX:n,originY:a}=e,l=r.getRelativeCenterPoint(),c=r.translateToOriginPoint(l,n,a),h=o(t,e,i,s);return r.setPositionByOrigin(c,e.originX,e.originY),h}}const il=ds(zs,us((o,t,e,i)=>{const s=Rn(t,t.originX,t.originY,e,i);if(St(t.originX)===St(N)||St(t.originX)===St(bt)&&s.x<0||St(t.originX)===St(G)&&s.x>0){const{target:r}=t,n=r.strokeWidth/(r.strokeUniform?r.scaleX:1),a=vc(t)?2:1,l=r.width,c=Math.abs(s.x*a/r.scaleX)-n;return r.set("width",Math.max(c,1)),l!==r.width}return!1}));function Ig(o,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,n=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Ot,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor);let h,d=t,u=e;o.save(),o.fillStyle=i.cornerColor||s.cornerColor||"",o.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",r>n?(h=r,o.scale(1,n/r),u=e*r/n):n>r?(h=n,o.scale(r/n,1),d=t*n/r):h=r,o.beginPath(),o.arc(d,u,h/2,0,Br,!1),o[l](),c&&o.stroke(),o.restore()}function Lg(o,t,e,i,s){i=i||{};const r=this.sizeX||i.cornerSize||s.cornerSize,n=this.sizeY||i.cornerSize||s.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:s.transparentCorners,l=a?re:Ot,c=!a&&(i.cornerStrokeColor||s.cornerStrokeColor),h=r/2,d=n/2;o.save(),o.fillStyle=i.cornerColor||s.cornerColor||"",o.strokeStyle=i.cornerStrokeColor||s.cornerStrokeColor||"",o.translate(t,e);const u=s.getTotalAngle();o.rotate(vt(u)),o["".concat(l,"Rect")](-h,-d,r,n),c&&o.strokeRect(-h,-d,r,n),o.restore()}class we{constructor(t){v(this,"visible",!0),v(this,"actionName",lo),v(this,"angle",0),v(this,"x",0),v(this,"y",0),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"sizeX",0),v(this,"sizeY",0),v(this,"touchSizeX",0),v(this,"touchSizeY",0),v(this,"cursorStyle","crosshair"),v(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,s){var r;let{tl:n,tr:a,br:l,bl:c}=s;return((r=e.canvas)===null||r===void 0?void 0:r.getActiveObject())===e&&e.isControlVisible(t)&&ot.isPointInPolygon(i,[n,a,l,c])}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(i=(s=t._controlsVisibility)===null||s===void 0?void 0:s[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,s){return new x(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,s,r,n){const a=Fn([Xs(i,s),qs({angle:t}),jn((r?this.touchSizeX:this.sizeX)||e,(r?this.touchSizeY:this.sizeY)||e)]);return{tl:new x(-.5,-.5).transform(a),tr:new x(.5,-.5).transform(a),br:new x(.5,.5).transform(a),bl:new x(-.5,.5).transform(a)}}render(t,e,i,s,r){((s=s||{}).cornerStyle||r.cornerStyle)==="circle"?Ig.call(this,t,e,i,s,r):Lg.call(this,t,e,i,s,r)}}const Fg=(o,t,e)=>e.lockRotation?Wr:t.cursorStyle,jg=ds(sc,us((o,t,e,i)=>{let{target:s,ex:r,ey:n,theta:a,originX:l,originY:c}=t;const h=s.translateToOriginPoint(s.getRelativeCenterPoint(),l,c);if(ke(s,"lockRotation"))return!1;const d=Math.atan2(n-h.y,r-h.x),u=Math.atan2(i-h.y,e-h.x);let g=Bi(u-d+a);if(s.snapAngle&&s.snapAngle>0){const f=s.snapAngle,b=s.snapThreshold||f,m=Math.ceil(g/f)*f,y=Math.floor(g/f)*f;Math.abs(g-y)<b?g=y:Math.abs(g-m)<b&&(g=m)}g<0&&(g=360+g),g%=360;const p=s.angle!==g;return s.angle=g,p}));function Ec(o,t){const e=t.canvas,i=o[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function kc(o,t,e){const i=ke(o,"lockScalingX"),s=ke(o,"lockScalingY");if(i&&s||!t&&(i||s)&&e||i&&t==="x"||s&&t==="y")return!0;const{width:r,height:n,strokeWidth:a}=o;return r===0&&a===0&&t!=="y"||n===0&&a===0&&t!=="x"}const $g=["e","se","s","sw","w","nw","n","ne","e"],Es=(o,t,e)=>{const i=Ec(o,e);if(kc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return Wr;const s=yc(e,t);return"".concat($g[s],"-resize")};function Nn(o,t,e,i){let s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const r=t.target,n=s.by,a=Ec(o,r);let l,c,h,d,u,g;if(kc(r,n,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=Rn(t,t.originX,t.originY,e,i),u=n!=="y"?Math.sign(l.x||t.signX||1):1,g=n!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=u),t.signY||(t.signY=g),ke(r,"lockScalingFlip")&&(t.signX!==u||t.signY!==g))return!1;if(d=r._getTransformedDimensions(),a&&!n){const b=Math.abs(l.x)+Math.abs(l.y),{original:m}=t,y=b/(Math.abs(d.x*m.scaleX/r.scaleX)+Math.abs(d.y*m.scaleY/r.scaleY));c=m.scaleX*y,h=m.scaleY*y}else c=Math.abs(l.x*r.scaleX/d.x),h=Math.abs(l.y*r.scaleY/d.y);vc(t)&&(c*=2,h*=2),t.signX!==u&&n!=="y"&&(t.originX=Ka(t.originX),c*=-1,t.signX=u),t.signY!==g&&n!=="x"&&(t.originY=Ka(t.originY),h*=-1,t.signY=g)}const p=r.scaleX,f=r.scaleY;return n?(n==="x"&&r.set(ne,c),n==="y"&&r.set(ye,h)):(!ke(r,"lockScalingX")&&r.set(ne,c),!ke(r,"lockScalingY")&&r.set(ye,h)),p!==r.scaleX||f!==r.scaleY}const rr=ds(ao,us((o,t,e,i)=>Nn(o,t,e,i))),Bg=ds(ao,us((o,t,e,i)=>Nn(o,t,e,i,{by:"x"}))),Rg=ds(ao,us((o,t,e,i)=>Nn(o,t,e,i,{by:"y"}))),zg=["target","ex","ey","skewingSide"],$o={x:{counterAxis:"y",scale:ne,skew:ls,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:ye,skew:cs,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},Hg=["ns","nesw","ew","nwse"],Ng=(o,t,e)=>{if(t.x!==0&&ke(e,"lockSkewingY")||t.y!==0&&ke(e,"lockSkewingX"))return Wr;const i=yc(e,t)%4;return"".concat(Hg[i],"-resize")};function Oc(o,t,e,i,s){const{target:r}=e,{counterAxis:n,origin:a,lockSkewing:l,skew:c,flip:h}=$o[o];if(ke(r,l))return!1;const{origin:d,flip:u}=$o[n],g=St(e[d])*(r[u]?-1:1),p=-Math.sign(g)*(r[h]?-1:1),f=.5*-((r[c]===0&&Rn(e,N,N,i,s)[o]>0||r[c]>0?1:-1)*p)+.5;return ds(rc,us((m,y,w,T)=>function(k,O,E){let{target:S,ex:D,ey:I,skewingSide:M}=O,B=it(O,zg);const{skew:R}=$o[k],F=E.subtract(new x(D,I)).divide(new x(S.scaleX,S.scaleY))[k],Y=S[R],tt=B[R],xt=Math.tan(vt(tt)),W=k==="y"?S._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:S._getTransformedDimensions({scaleX:1,scaleY:1}).y,wt=2*F*M/Math.max(W,1)+xt,Gt=Bi(Math.atan(wt));S.set(R,Gt);const Yt=Y!==S[R];if(Yt&&k==="y"){const{skewX:Pe,scaleX:me}=S,It=S._getTransformedDimensions({skewY:Y}),De=S._getTransformedDimensions(),le=Pe!==0?It.x/De.x:1;le!==1&&S.set(ne,le*me)}return Yt}(o,y,new x(w,T))))(t,_(_({},e),{},{[a]:f,skewingSide:p}),i,s)}const Vg=(o,t,e,i)=>Oc("x",o,t,e,i),Ug=(o,t,e,i)=>Oc("y",o,t,e,i);function go(o,t){return o[t.canvas.altActionKey]}const or=(o,t,e)=>{const i=go(o,e);return t.x===0?i?ls:ye:t.y===0?i?cs:ne:""},Ki=(o,t,e)=>go(o,e)?Ng(0,t,e):Es(o,t,e),sl=(o,t,e,i)=>go(o,t.target)?Ug(o,t,e,i):Bg(o,t,e,i),rl=(o,t,e,i)=>go(o,t.target)?Vg(o,t,e,i):Rg(o,t,e,i),Pc=()=>({ml:new we({x:-.5,y:0,cursorStyleHandler:Ki,actionHandler:sl,getActionName:or}),mr:new we({x:.5,y:0,cursorStyleHandler:Ki,actionHandler:sl,getActionName:or}),mb:new we({x:0,y:.5,cursorStyleHandler:Ki,actionHandler:rl,getActionName:or}),mt:new we({x:0,y:-.5,cursorStyleHandler:Ki,actionHandler:rl,getActionName:or}),tl:new we({x:-.5,y:-.5,cursorStyleHandler:Es,actionHandler:rr}),tr:new we({x:.5,y:-.5,cursorStyleHandler:Es,actionHandler:rr}),bl:new we({x:-.5,y:.5,cursorStyleHandler:Es,actionHandler:rr}),br:new we({x:.5,y:.5,cursorStyleHandler:Es,actionHandler:rr}),mtr:new we({x:0,y:-.5,actionHandler:jg,cursorStyleHandler:Fg,offsetY:-40,withConnection:!0,actionName:In})}),Wg=()=>({mr:new we({x:.5,y:0,actionHandler:il,cursorStyleHandler:Ki,actionName:zs}),ml:new we({x:-.5,y:0,actionHandler:il,cursorStyleHandler:Ki,actionName:zs})}),Gg=()=>_(_({},Pc()),Wg());class Vs extends Ye{static getDefaults(){return _(_({},super.getDefaults()),Vs.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),Vs.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Pc()}}_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(lo))return!1}return super._updateCacheCanvas()}getActiveControl(){const t=this.__corner;return t?{key:t,control:this.controls[t],coord:this.oCoords[t]}:void 0}findControl(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!this.hasControls||!this.canvas)return;this.__corner=void 0;const i=Object.entries(this.oCoords);for(let s=i.length-1;s>=0;s--){const[r,n]=i[s],a=this.controls[r];if(a.shouldActivate(r,this,t,e?n.touchCorner:n.corner))return this.__corner=r,{key:r,control:a,coord:this.oCoords[r]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=Xs(e.x,e.y),s=qs({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),r=$t(i,s),n=$t(t,r),a=$t(n,[1/t[0],0,0,1/t[3],0,0]),l=this.group?Nr(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl((d,u)=>{const g=d.positionHandler(c,a,this,d);h[u]=Object.assign(g,this._calcCornerCoords(d,g))}),h}_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(vt(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&&arguments[2]!==void 0?arguments[2]:{};const s=_({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&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:s}=this,r=_({hasBorders:i,hasControls:s},e),n=this.getViewportTransform(),a=r.hasBorders,l=r.hasControls,c=$t(n,this.calcTransformMatrix()),h=Nr(c);t.save(),t.translate(h.translateX,h.translateY),t.lineWidth=this.borderScaleFactor,this.group===this.parent&&(t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1),this.flipX&&(h.angle-=180),t.rotate(vt(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let s;if(i&&i.forActiveSelection||this.group){const r=Bn(this.width,this.height,co(e)),n=this.isStrokeAccountedForInDimensions()?Ln:(this.strokeUniform?new x().scalarAdd(this.canvas?this.canvas.getZoom():1):new x(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);s=r.add(n).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&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:s,cornerDashArray:r,cornerColor:n}=this,a=_({cornerStrokeColor:s,cornerDashArray:r,cornerColor:n},e);t.setTransform(i,0,0,i,0,0),t.strokeStyle=t.fillStyle=a.cornerColor,this.transparentCorners||(t.strokeStyle=a.cornerStrokeColor),this._setLineDash(t,a.cornerDashArray),this.forEachControl((l,c)=>{if(l.getVisibility(this,c)){const h=this.oCoords[c];l.render(t,h.x,h.y,a,this)}}),t.restore()}isControlVisible(t){return this.controls[t]&&this.controls[t].getVisibility(this,t)}setControlVisible(t,e){this._controlsVisibility||(this._controlsVisibility={}),this._controlsVisibility[t]=e}setControlsVisibility(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.entries(t).forEach(e=>{let[i,s]=e;return this.setControlVisible(i,s)})}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 Dc(o,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(o.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))})}),o}v(Vs,"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 Nt extends Vs{}Dc(Nt,[xc]),P.setClass(Nt),P.setClass(Nt,"object");const Yg=(o,t,e,i)=>{const s=2*(i=Math.round(i))+1,{data:r}=o.getImageData(t-i,e-i,s,s);for(let n=3;n<r.length;n+=4)if(r[n]>0)return!1;return!0};class Ac{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new x(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new x(1/this.options.scaleX,1/this.options.scaleY):new x(1,1)}createSideVector(t,e){const i=ln(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 this.options.skewX!==0||this.options.skewY!==0}applySkew(t){const e=new x(t);return e.y+=e.x*Math.tan(vt(this.options.skewY)),e.x+=e.y*Math.tan(vt(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const Xg=new x;class is extends Ac{static getOrthogonalRotationFactor(t,e){const i=e?hn(t,e):mg(t);return Math.abs(i)<Ys?-1:1}constructor(t,e,i,s){super(s),v(this,"AB",void 0),v(this,"AC",void 0),v(this,"alpha",void 0),v(this,"bisector",void 0),this.A=new x(t),this.B=new x(e),this.C=new x(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=hn(this.AB,this.AC),this.bisector=zn(Cc(this.AB.eq(Xg)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e),r=Sc(s),n=is.getOrthogonalRotationFactor(r,this.bisector);return this.scaleUnitVector(r,i*n)}projectBevel(){const t=[];return(this.alpha%Br==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?cn(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return cn(s)/this.strokeProjectionMagnitude<=r&&t.push(this.applySkew(this.A.add(s))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],s=new x(is.getOrthogonalRotationFactor(this.bisector),is.getOrthogonalRotationFactor(new x(this.bisector.y,this.bisector.x)));return[new x(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s),new x(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(s)].forEach(r=>{Qa(r,t,e)&&i.push(this.A.add(r))}),i}projectRoundWithSkew(t,e){const i=[],{skewX:s,skewY:r,scaleX:n,scaleY:a,strokeUniform:l}=this.options,c=new x(Math.tan(vt(s)),Math.tan(vt(r))),h=this.strokeProjectionMagnitude,d=l?h/a/Math.sqrt(1/a**2+1/n**2*c.y**2):h/Math.sqrt(1+c.y**2),u=new x(Math.sqrt(Math.max(h**2-d**2,0)),d),g=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/n+1/n*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),p=new x(g,Math.sqrt(Math.max(h**2-g**2,0)));return[p,p.scalarMultiply(-1),u,u.scalarMultiply(-1)].map(f=>this.applySkew(l?f.multiply(this.strokeUniformScalar):f)).forEach(f=>{Qa(f,t,e)&&i.push(this.applySkew(this.A).add(f))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%Br==0,i=this.applySkew(this.A),s=t[e?0:2].subtract(i),r=t[e?1:0].subtract(i),n=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Ms(s,n)>0,l=a?s:r,c=a?r:s;return this.isSkewed()?t.push(...this.projectRoundWithSkew(l,c)):t.push(...this.projectRoundNoSkew(l,c)),t}projectPoints(){switch(this.options.strokeLineJoin){case"miter":return this.projectMiter();case"round":return this.projectRound();default:return this.projectBevel()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t,angle:this.alpha,bisector:this.bisector}))}}class ol extends Ac{constructor(t,e,i){super(i),this.A=new x(t),this.T=new x(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const s=this.createSideVector(t,e);return this.scaleUnitVector(Sc(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 x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new is(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new x(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(zn(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),s=this.A.add(i);t.push(s.add(e),s.subtract(e))}return t.map(e=>this.applySkew(e))}projectPoints(){switch(this.options.strokeLineCap){case"round":return this.projectRound();case"square":return this.projectSquare();default:return this.projectButt()}}project(){return this.projectPoints().map(t=>({originPoint:this.A,projectedPoint:t}))}}const qg=function(o,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(o.length===0)return i;const s=o.reduce((r,n)=>(r[r.length-1].eq(n)||r.push(new x(n)),r),[new x(o[0])]);if(s.length===1)e=!0;else if(!e){const r=s[0],n=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(s,a=>!a.eq(r));s.splice(n+1)}return s.forEach((r,n,a)=>{let l,c;n===0?(c=a[1],l=e?r:a[a.length-1]):n===a.length-1?(l=a[n-1],c=e?r:a[0]):(l=a[n-1],c=a[n+1]),e&&a.length===1?i.push(...new ol(r,r,t).project()):!e||n!==0&&n!==a.length-1?i.push(...new is(r,l,c,t).project()):i.push(...new ol(r,n===0?c:l,t).project())}),i},Vn=o=>{const t={};return Object.keys(o).forEach(e=>{t[e]={},Object.keys(o[e]).forEach(i=>{t[e][i]=_({},o[e][i])})}),t},Kg=o=>o.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),Un=o=>{const t=[];for(let e,i=0;i<o.length;i++)(e=Zg(o,i))!==!1&&t.push(e);return t},Zg=(o,t)=>{const e=o.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return o.charAt(t);if(55296<=e&&e<=56319){if(o.length<=t+1)throw"High surrogate without following low surrogate";const s=o.charCodeAt(t+1);if(56320>s||s>57343)throw"High surrogate without following low surrogate";return o.charAt(t)+o.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=o.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},Wn=function(o,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return o.fill!==t.fill||o.stroke!==t.stroke||o.strokeWidth!==t.strokeWidth||o.fontSize!==t.fontSize||o.fontFamily!==t.fontFamily||o.fontWeight!==t.fontWeight||o.fontStyle!==t.fontStyle||o.textBackgroundColor!==t.textBackgroundColor||o.deltaY!==t.deltaY||e&&(o.overline!==t.overline||o.underline!==t.underline||o.linethrough!==t.linethrough)},Jg=(o,t)=>{const e=t.split(`
2659
+ `),i=[];let s=-1,r={};o=Vn(o);for(let n=0;n<e.length;n++){const a=Un(e[n]);if(o[n])for(let l=0;l<a.length;l++){s++;const c=o[n][l];c&&Object.keys(c).length>0&&(Wn(r,c,!0)?i.push({start:s,end:s+1,style:c}):i[i.length-1].end++),r=c||{}}else s+=a.length,r={}}return i},Qg=(o,t)=>{if(!Array.isArray(o))return Vn(o);const e=t.split(Mn),i={};let s=-1,r=0;for(let n=0;n<e.length;n++){const a=Un(e[n]);for(let l=0;l<a.length;l++)s++,o[r]&&o[r].start<=s&&s<o[r].end&&(i[n]=i[n]||{},i[n][l]=_({},o[r].style),s===o[r].end-1&&r++)}return i},Ci=["display","transform",Ot,"fill-opacity","fill-rule","opacity",re,"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 nl(o,t){const e=o.nodeName,i=o.getAttribute("class"),s=o.getAttribute("id"),r="(?![a-zA-Z\\-]+)";let n;if(n=new RegExp("^"+e,"i"),t=t.replace(n,""),s&&t.length&&(n=new RegExp("#"+s+r,"i"),t=t.replace(n,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)n=new RegExp("\\."+a[l]+r,"i"),t=t.replace(n,"")}return t.length===0}function tf(o,t){let e=!0;const i=nl(o,t.pop());return i&&t.length&&(e=function(s,r){let n,a=!0;for(;s.parentElement&&s.parentElement.nodeType===1&&r.length;)a&&(n=r.pop()),a=nl(s=s.parentElement,n);return r.length===0}(o,t)),i&&e&&t.length===0}const ef=o=>{var t;return(t=gg[o])!==null&&t!==void 0?t:o},sf=new RegExp("(".concat(Ri,")"),"gi"),rf=o=>o.replace(sf," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var al,ll,cl,hl,dl,ul,pl;const Zt="(".concat(Ri,")"),of=String.raw(al||(al=wi(["(skewX)(",")"],["(skewX)\\(","\\)"])),Zt),nf=String.raw(ll||(ll=wi(["(skewY)(",")"],["(skewY)\\(","\\)"])),Zt),af=String.raw(cl||(cl=wi(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Zt,Zt,Zt),lf=String.raw(hl||(hl=wi(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Zt,Zt),cf=String.raw(dl||(dl=wi(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Zt,Zt),hf=String.raw(ul||(ul=wi(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Zt,Zt,Zt,Zt,Zt,Zt),Gn="(?:".concat(hf,"|").concat(cf,"|").concat(af,"|").concat(lf,"|").concat(of,"|").concat(nf,")"),df="(?:".concat(Gn,"*)"),uf=String.raw(pl||(pl=wi(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),df),pf=new RegExp(uf),gf=new RegExp(Gn),ff=new RegExp(Gn,"g");function dn(o){const t=[];if(!(o=rf(o).replace(/\s*([()])\s*/gi,"$1"))||o&&!pf.test(o))return[...Jt];for(const e of o.matchAll(ff)){const i=gf.exec(e[0]);if(!i)continue;let s=Jt;const r=i.filter(p=>!!p),[,n,...a]=r,[l,c,h,d,u,g]=a.map(p=>parseFloat(p));switch(n){case"translate":s=Xs(l,c);break;case In:s=qs({angle:l},{x:c,y:h});break;case lo:s=jn(l,c);break;case ls:s=hc(l);break;case cs:s=dc(l);break;case"matrix":s=[l,c,h,d,u,g]}t.push(s)}return Fn(t)}function mf(o,t,e,i){const s=Array.isArray(t);let r,n=t;if(o!==Ot&&o!==re||t!==se){if(o==="strokeUniform")return t==="non-scaling-stroke";if(o==="strokeDashArray")n=t===se?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(o==="transformMatrix")n=e&&e.transformMatrix?$t(e.transformMatrix,dn(t)):dn(t);else if(o==="visible")n=t!==se&&t!=="hidden",e&&e.visible===!1&&(n=!1);else if(o==="opacity")n=parseFloat(t),e&&e.opacity!==void 0&&(n*=e.opacity);else if(o==="textAnchor")n=t==="start"?G:t==="end"?bt:N;else if(o==="charSpacing")r=ts(t,i)/i*1e3;else if(o==="paintFirst"){const a=t.indexOf(Ot),l=t.indexOf(re);n=Ot,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(n=re)}else{if(o==="href"||o==="xlink:href"||o==="font"||o==="id")return t;if(o==="imageSmoothing")return t==="optimizeQuality";r=s?t.map(ts):ts(t,i)}}else n="";return!s&&isNaN(r)?n:r}function bf(o,t){const e=o.match(pg);if(!e)return;const i=e[1],s=e[3],r=e[4],n=e[5],a=e[6];i&&(t.fontStyle=i),s&&(t.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)),r&&(t.fontSize=ts(r)),a&&(t.fontFamily=a),n&&(t.lineHeight=n==="normal"?1:n)}function vf(o,t){o.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[i,s]=e.split(":");t[i.trim().toLowerCase()]=s.trim()})}function _f(o){const t={},e=o.getAttribute("style");return e&&(typeof e=="string"?vf(e,t):function(i,s){Object.entries(i).forEach(r=>{let[n,a]=r;a!==void 0&&(s[n.toLowerCase()]=a)})}(e,t)),t}const yf={stroke:"strokeOpacity",fill:"fillOpacity"};function ni(o,t,e){if(!o)return{};let i,s={},r=An;o.parentNode&&Ja.test(o.parentNode.nodeName)&&(s=ni(o.parentElement,t,e),s.fontSize&&(i=r=ts(s.fontSize)));const n=_(_(_({},t.reduce((c,h)=>{const d=o.getAttribute(h);return d&&(c[h]=d),c},{})),function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},d={};for(const u in h)tf(c,u.split(" "))&&(d=_(_({},d),h[u]));return d}(o,e)),_f(o));n[Fo]&&o.setAttribute(Fo,n[Fo]),n[Lo]&&(i=ts(n[Lo],r),n[Lo]="".concat(i));const a={};for(const c in n){const h=ef(c),d=mf(h,n[c],s,i);a[h]=d}a&&a.font&&bf(a.font,a);const l=_(_({},s),a);return Ja.test(o.nodeName)?l:function(c){const h=Nt.getDefaults();return Object.entries(yf).forEach(d=>{let[u,g]=d;if(c[g]===void 0||c[u]==="")return;if(c[u]===void 0){if(!h[u])return;c[u]=h[u]}if(c[u].indexOf("url(")===0)return;const p=new X(c[u]);c[u]=p.setAlpha(at(p.getAlpha()*c[g],2)).toRgba()}),c}(l)}const xf=["left","top","width","height","visible"],Mc=["rx","ry"];class jt extends Nt{static getDefaults(){return _(_({},super.getDefaults()),jt.ownDefaults)}constructor(t){super(),Object.assign(this,jt.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,n=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=n!==0||a!==0;t.beginPath(),t.moveTo(s+n,r),t.lineTo(s+e-n,r),l&&t.bezierCurveTo(s+e-li*n,r,s+e,r+li*a,s+e,r+a),t.lineTo(s+e,r+i-a),l&&t.bezierCurveTo(s+e,r+i-li*a,s+e-li*n,r+i,s+e-n,r+i),t.lineTo(s+n,r+i),l&&t.bezierCurveTo(s+li*n,r+i,s,r+i-li*a,s,r+i-a),t.lineTo(s,r+a),l&&t.bezierCurveTo(s,r+li*a,s+li*n,r,s+n,r),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Mc,...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,`" />
2660
+ `)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:n=0,width:a=0,height:l=0,visible:c=!0}=s,h=it(s,xf);return new this(_(_(_({},e),h),{},{left:r,top:n,width:a,height:l,visible:!!(c&&a&&l)}))}}v(jt,"type","Rect"),v(jt,"cacheProperties",[...oi,...Mc]),v(jt,"ownDefaults",{rx:0,ry:0}),v(jt,"ATTRIBUTE_NAMES",[...Ci,"x","y","rx","ry","width","height"]),P.setClass(jt),P.setSVGClass(jt);const Ke="initialization",Gr="added",Yn="removed",Yr="imperative",Ic=(o,t)=>{const{strokeUniform:e,strokeWidth:i,width:s,height:r,group:n}=t,a=n&&n!==o?uo(n.calcTransformMatrix(),o.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?cg(new x(i,i),void 0,o.calcTransformMatrix()):Ln,d=!e&&c?i:0,u=Bn(s+d,r+d,Fn([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(u),l.add(u)]};class fo{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:s}=t;return e===Ke||e===Yr||!!i&&s!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Ke&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:s}=e;if(i===Yr&&e.overrides)return e.overrides;if(t.length===0)return;const{left:r,top:n,width:a,height:l}=Qe(t.map(d=>Ic(s,d)).reduce((d,u)=>d.concat(u),[])),c=new x(a,l),h=new x(r,n).add(c.scalarDivide(2));if(i===Ke){const d=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new x(0,0),size:d}}return{center:h.transform(s.calcOwnMatrix()),size:c}}}v(fo,"type","strategy");class un extends fo{shouldPerformLayout(t){return!0}}v(un,"type","fit-content"),P.setClass(un);const wf=["strategy"],Cf=["target","strategy","bubbles","prevStrategy"],Lc="layoutManager";class Us{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new un;v(this,"strategy",void 0),this.strategy=t,this._subscriptions=new Map}performLayout(t){const e=_(_({bubbles:!0,strategy:this.strategy},t),{},{prevStrategy:this._prevLayoutStrategy,stopPropagation(){this.bubbles=!1}});this.onBeforeLayout(e);const 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[zr,ic,zs,sc,ao,rc,Rr,Xp,qp].map(s=>t.on(s,r=>this.performLayout(s===zr?{type:"object_modified",trigger:s,e:r,target:i}:{type:"object_modifying",trigger:s,e:r,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(i=>i()),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===Ke||i===Gr?this.subscribeTargets(t):i===Yn&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),s&&s.fire("object:layout:before",{target:e,context:t}),i===Yr&&t.deep){const r=it(t,wf);e.forEachObject(n=>n.layoutManager&&n.layoutManager.performLayout(_(_({},r),{},{bubbles:!1,target:n})))}}getLayoutResult(t){const{target:e,strategy:i,type:s}=t,r=i.calcLayoutResult(t,e.getObjects());if(!r)return;const n=s===Ke?new x:e.getRelativeCenterPoint(),{center:a,correction:l=new x,relativeCorrection:c=new x}=r,h=n.subtract(a).add(l).transform(s===Ke?Jt:Te(e.calcOwnMatrix()),!0).add(c);return{result:r,prevCenter:n,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:s},nextCenter:r}=e;var n,a;i.set({width:s.x,height:s.y}),this.layoutObjects(t,e),t.type===Ke?i.set({left:(n=t.x)!==null&&n!==void 0?n:r.x+s.x*St(i.originX),top:(a=t.y)!==null&&a!==void 0?a:r.y+s.y*St(i.originY)}):(i.setPositionByOrigin(r,N,N),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:n}=t,a=it(t,Cf),{canvas:l}=i;i.fire("layout:after",{context:t,result:e}),l&&l.fire("object:layout:after",{context:t,result:e,target:i});const c=i.parent;r&&c!=null&&c.layoutManager&&((a.path||(a.path=[])).push(i),c.layoutManager.performLayout(_(_({},a),{},{target:c}))),i.set("dirty",!0)}dispose(){const{_subscriptions:t}=this;t.forEach(e=>e.forEach(i=>i())),t.clear()}toObject(){return{type:Lc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}P.setClass(Us,Lc);const Sf=["type","objects","layoutManager"];class Tf extends Us{performLayout(){}}class mi extends oc(Nt){static getDefaults(){return _(_({},super.getDefaults()),mi.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"_activeObjects",[]),v(this,"__objectSelectionTracker",void 0),v(this,"__objectSelectionDisposer",void 0),Object.assign(this,mi.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(s=>{this.enterGroup(s,!1)}),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Us,this.layoutManager.performLayout({type:Ke,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(vi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(vi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,i,s)=>this.canEnterGroup(e)&&s.indexOf(e)===i)}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(Gr,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),n=super.insertAt(t,...r);return this._onAfterObjectsChange(Gr,r),n}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(Yn,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),t==="canvas"&&i!==e&&(this._objects||[]).forEach(s=>{s._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const s=this._activeObjects;if(t)s.push(i),this._set("dirty",!0);else if(s.length>0){const r=s.indexOf(i);r>-1&&(s.splice(r,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&&Ur(t,$t(Te(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||(Ur(t,$t(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=Nt.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 n=this._objects[r];(s=this.canvas)!==null&&s!==void 0&&s.preserveObjectStacking&&n.group!==this?(t.save(),t.transform(...Te(this.calcTransformMatrix())),n.render(t),t.restore()):n.group===this&&n.render(t)}this._drawClipPath(t,this.clipPath,i)}setCoords(){super.setCoords(),this._shouldSetNestedCoords()&&this.forEachObject(t=>t.setCoords())}triggerLayout(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.layoutManager.performLayout(_({target:this,type:Yr},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter(function(s){return!s.excludeFromExport}).map(function(s){const r=s.includeDefaultValues;s.includeDefaultValues=i;const n=s[t||"toObject"](e);return s.includeDefaultValues=r,n})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".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=jt.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",` >
2654
2661
  `],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toSVG(t));return e.push(`</g>
2655
- `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:r}=t,n=it(t,Sf);return Promise.all([zs(s,e),ho(n,e)]).then(a=>{let[l,c]=a;const h=new this(l,_(_(_({},n),c),{},{layoutManager:new Tf}));if(r){const d=P.getClass(r.type),u=P.getClass(r.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Vs;return h.layoutManager.subscribeTargets({type:Xe,target:h,targets:h.getObjects()}),h.setCoords(),h})}}v(gi,"type","Group"),v(gi,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),P.setClass(gi);const Ef=(o,t)=>Math.min(t.width/o.width,t.height/o.height),kf=(o,t)=>Math.max(t.width/o.width,t.height/o.height),pn="\\s*,?\\s*",ws="".concat(pn,"(").concat(Ri,")"),Of="".concat(ws).concat(ws).concat(ws).concat(pn,"([01])").concat(pn,"([01])").concat(ws).concat(ws),Pf={m:"l",M:"L"},Df=(o,t,e,i,s,r,n,a,l,c,h)=>{const d=ti(o),u=ei(o),g=ti(t),p=ei(t),f=e*s*g-i*r*p+n,b=i*s*g+e*r*p+a;return["C",c+l*(-e*s*u-i*r*d),h+l*(-i*s*u+e*r*d),f+l*(e*s*p+i*r*g),b+l*(i*s*p-e*r*g),f,b]},gl=(o,t,e,i)=>{const s=Math.atan2(t,o),r=Math.atan2(i,e);return r>=s?r-s:2*Math.PI-(s-r)};function fl(o,t,e,i,s,r,n,a){let l;if(U.cachesBoundsOfCurve&&(l=[...arguments].join(),Ds.boundsOfCurveCache[l]))return Ds.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let g=6*o-12*e+6*s,p=-3*o+9*e-9*s+3*n,f=3*e-3*o;for(let T=0;T<2;++T){if(T>0&&(g=6*t-12*i+6*r,p=-3*t+9*i-9*r+3*a,f=3*i-3*t),h(p)<1e-12){if(h(g)<1e-12)continue;const D=-f/g;0<D&&D<1&&d.push(D);continue}const k=g*g-4*f*p;if(k<0)continue;const O=c(k),E=(-g+O)/(2*p);0<E&&E<1&&d.push(E);const S=(-g-O)/(2*p);0<S&&S<1&&d.push(S)}let b=d.length;const m=b,y=Fc(o,t,e,i,s,r,n,a);for(;b--;){const{x:T,y:k}=y(d[b]);u[0][b]=T,u[1][b]=k}u[0][m]=o,u[1][m]=t,u[0][m+1]=n,u[1][m+1]=a;const w=[new x(Math.min(...u[0]),Math.min(...u[1])),new x(Math.max(...u[0]),Math.max(...u[1]))];return U.cachesBoundsOfCurve&&(Ds.boundsOfCurveCache[l]=w),w}const Af=(o,t,e)=>{let[i,s,r,n,a,l,c,h]=e;const d=((u,g,p,f,b,m,y)=>{if(p===0||f===0)return[];let w=0,T=0,k=0;const O=Math.PI,E=y*Dn,S=ei(E),D=ti(E),I=.5*(-D*u-S*g),M=.5*(-D*g+S*u),B=p**2,R=f**2,F=M**2,Y=I**2,tt=B*R-B*F-R*Y;let xt=Math.abs(p),W=Math.abs(f);if(tt<0){const gt=Math.sqrt(1-tt/(B*R));xt*=gt,W*=gt}else k=(b===m?-1:1)*Math.sqrt(tt/(B*F+R*Y));const wt=k*xt*M/W,Gt=-k*W*I/xt,Yt=D*wt-S*Gt+.5*u,Oe=S*wt+D*Gt+.5*g;let fe=gl(1,0,(I-wt)/xt,(M-Gt)/W),It=gl((I-wt)/xt,(M-Gt)/W,(-I-wt)/xt,(-M-Gt)/W);m===0&&It>0?It-=2*O:m===1&&It<0&&(It+=2*O);const Pe=Math.ceil(Math.abs(It/O*2)),le=[],Ot=It/Pe,Ft=8/3*Math.sin(Ot/4)*Math.sin(Ot/4)/Math.sin(Ot/2);let ce=fe+Ot;for(let gt=0;gt<Pe;gt++)le[gt]=Df(fe,ce,D,S,xt,W,Yt,Oe,Ft,w,T),w=le[gt][5],T=le[gt][6],fe=ce,ce+=Ot;return le})(c-o,h-t,s,r,a,l,n);for(let u=0,g=d.length;u<g;u++)d[u][1]+=o,d[u][2]+=t,d[u][3]+=o,d[u][4]+=t,d[u][5]+=o,d[u][6]+=t;return d},Mf=o=>{let t=0,e=0,i=0,s=0;const r=[];let n,a=0,l=0;for(const c of o){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":n==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":n==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Af(t,e,h).forEach(u=>r.push(u)),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(r.push(d),n=d[0]):n=""}return r},Xr=(o,t,e,i)=>Math.sqrt((e-o)**2+(i-t)**2),Fc=(o,t,e,i,s,r,n,a)=>l=>{const c=l**3,h=(g=>3*g**2*(1-g))(l),d=(g=>3*g*(1-g)**2)(l),u=(g=>(1-g)**3)(l);return new x(n*c+s*h+e*d+o*u,a*c+r*h+i*d+t*u)},jc=o=>o**2,$c=o=>2*o*(1-o),Bc=o=>(1-o)**2,If=(o,t,e,i,s,r,n,a)=>l=>{const c=jc(l),h=$c(l),d=Bc(l),u=3*(d*(e-o)+h*(s-e)+c*(n-s)),g=3*(d*(i-t)+h*(r-i)+c*(a-r));return Math.atan2(g,u)},Lf=(o,t,e,i,s,r)=>n=>{const a=jc(n),l=$c(n),c=Bc(n);return new x(s*a+e*l+o*c,r*a+i*l+t*c)},Ff=(o,t,e,i,s,r)=>n=>{const a=1-n,l=2*(a*(e-o)+n*(s-e)),c=2*(a*(i-t)+n*(r-i));return Math.atan2(c,l)},ml=(o,t,e)=>{let i=new x(t,e),s=0;for(let r=1;r<=100;r+=1){const n=o(r/100);s+=Xr(i.x,i.y,n.x,n.y),i=n}return s},jf=(o,t)=>{let e,i=0,s=0,r={x:o.x,y:o.y},n=_({},r),a=.01,l=0;const c=o.iterator,h=o.angleFinder;for(;s<t&&a>1e-4;)n=c(i),l=i,e=Xr(r.x,r.y,n.x,n.y),e+s>t?(i-=a,a/=2):(r=n,i+=a,s+=e);return _(_({},n),{},{angle:h(l)})},Rc=o=>{let t,e,i=0,s=0,r=0,n=0,a=0;const l=[];for(const c of o){const h={x:s,y:r,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=n=s=c[1],e.y=a=r=c[2];break;case"L":e=h,e.length=Xr(s,r,c[1],c[2]),s=c[1],r=c[2];break;case"C":t=Fc(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=If(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=ml(t,s,r),s=c[5],r=c[6];break;case"Q":t=Lf(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ff(s,r,c[1],c[2],c[3],c[4]),e.length=ml(t,s,r),s=c[3],r=c[4];break;case"Z":e=h,e.destX=n,e.destY=a,e.length=Xr(s,r,n,a),s=n,r=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:r}),l},$f=function(o,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Rc(o),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],r=t/s.length,n=o[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return _(_({},new x(s.x,s.y).lerp(new x(s.destX,s.destY),r)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return _(_({},new x(s.x,s.y).lerp(new x(n[1],n[2]),r)),{},{angle:Math.atan2(n[2]-s.y,n[1]-s.x)});case"C":case"Q":return jf(s,t)}},Bf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),bl=new RegExp(Of,"g"),Rf=new RegExp(Ri,"gi"),zf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Hf=o=>{var t;const e=[],i=(t=o.match(Bf))!==null&&t!==void 0?t:[];for(const s of i){const r=s[0];if(r==="z"||r==="Z"){e.push([r]);continue}const n=zf[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){bl.lastIndex=0;for(let l=null;l=bl.exec(s);)a.push(...l.slice(1))}else a=s.match(Rf)||[];for(let l=0;l<a.length;l+=n){const c=new Array(n),h=Pf[r];c[0]=l>0&&h?h:r;for(let d=0;d<n;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},Nf=(o,t)=>o.map(e=>e.map((i,s)=>s===0||t===void 0?i:nt(i,t)).join(" ")).join(" ");function gn(o,t){const e=o.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(i=>{let[s,r]=i;return e.setProperty(s,r)}))}class Vf extends fc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,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 n=this.createContainerElement();n.classList.add(i),s.parentNode&&s.parentNode.replaceChild(n,s),n.append(s,r),this.container=n}createUpperCanvas(){const{el:t}=this.lower,e=ke();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=ns().createElement("div");return t.setAttribute("data-fabric","wrapper"),gn(t,{position:"relative"}),qa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;gn(t,_(_({},i),{},{"touch-action":s?"manipulation":se})),qa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;gc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),on(this.upper.el,t),on(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(),Be().dispose(this.upper.el),delete this.upper,delete this.container}}class mo extends Ks{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_objectsToRender",void 0),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),mo.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Vf(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 n=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=n,r.restore();const a=Math.round(s*this.getRetinaScaling());return Yg(r,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(i=>!!i&&t[i]===!0):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&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===lo||e===ne||e===_e||e===Rs?s=this.centeredScaling||t.centeredScaling:e===In&&(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=mt:["mr","tr","br"].includes(e)&&(i.x=G),["tl","mt","tr"].includes(e)?i.y=rn:["bl","mb","br"].includes(e)&&(i.y=ie)),i}_setupCurrentTransform(t,e,i){var s;const r=e.group?ts(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:n="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):ug,c=((g,p,f,b)=>{if(!p||!g)return"drag";const m=b.controls[p];return m.getActionName(f,m,b)})(i,n,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:H,y:H}:this._getOriginFromCorner(e,n),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:n,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:d.x,originY:d.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:bt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},mc(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,n=new x(e,i).transform(this.viewportTransform),a=new x(e+s,i+r).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(n.x,a.x),h=Math.min(n.y,a.y),d=Math.max(n.x,a.x),u=Math.max(n.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Nt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}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,nn(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const r=this.targets;this.targets=[];const n=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&n&&n!==i?(this.targets=r,i):n}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[n,a,l,c]=i,h=Math.atan2(a.y-n.y,a.x-n.x),d=ti(h)*r,u=ei(h)*r,g=d+u,p=d-u;i=[new x(n.x-p,n.y-g),new x(a.x+g,a.y-p),new x(l.x+p,l.y+g),new x(c.x-g,c.y+p)]}return rt.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,ts(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Dr(s)&&s.subTargetCheck){const r=this._searchPossibleTargets(s._objects,e);r&&this.targets.push(r)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Dr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let r=s.length-1;r>0;r--){const n=s[r];if(!Dr(n)||!n.interactive)return n}return s[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&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let r=og(t),n=s.width||0,a=s.height||0;n&&a||(ie in s&&rn in s&&(a=Math.abs(s.top-s.bottom)),mt in s&&G in s&&(n=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=ts(r,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);const c=n===0||a===0?new x(1,1):new x(i.width/n,i.height/a);return r.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=ke(),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 ki(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),n=[],a=[];t.forEach(l=>{r.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))}),r.forEach(l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),n.push(l))}),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:n,deselected:a})):r.length>0?(s=!0,this.fire("selection:created",{e,selected:n})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),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})&&(this._activeObject=t,ki(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),ki(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(zr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;ki(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&&ki(e)&&this._activeObject===e){const i=cs(t,["angle","flipX","flipY",G,ne,_e,as,ls,ie]);return ag(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(mo,"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 Uf{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.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),Xi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Wf=["target","oldTarget","fireCanvas","e"],he={passive:!1},Gi=(o,t)=>{const e=o.getViewportPoint(t),i=o.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},ai=function(o){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return o.addEventListener(...e)},me=function(o){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return o.removeEventListener(...e)},Gf={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 qr extends mo{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Uf(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(ai,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(pc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,he),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,he)}removeListeners(){this.addOrRemove(me,"remove");const t=this._getEventPrefix(),e=Ce(this.upperCanvasEl);me(e,"".concat(t,"up"),this._onMouseUp),me(e,"touchend",this._onTouchEnd,he),me(e,"".concat(t,"move"),this._onMouseMove,he),me(e,"touchmove",this._onMouseMove,he),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},Gi(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",_(_({},i),{},{target:s})),s&&s.fire("mouseout",_({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},Gi(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 ai(this.upperCanvasEl,"drag",this._onDragProgress)}an(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const n=this.contextTop;n.save(),n.transform(...this.viewportTransform),e&&(n.save(),e.transform(n),e.renderDragSourceEffect(t),n.restore(),s=!0),i&&(n.save(),i.transform(n),i.renderDropTargetEffect(t),n.restore(),s=!0),n.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==se,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};me(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,n={e:t,target:i,subTargets:s,dragSource:r,canDrop:!1,dropTarget:void 0};let a;this.fire(e,n),this._fireEnterLeaveEvents(i,n),i&&(i.canDrop(t)&&(a=i),i.fire(e,n));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,n)}this._renderDragEffects(t,r,a),this._dropTarget=a}_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",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},Gi(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&&an(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 t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(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(),n=Ce(s);ai(n,"touchend",this._onTouchEnd,he),e&&ai(n,"touchmove",this._onMouseMove,he),me(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();me(e,"".concat(i,"move"),this._onMouseMove,he);const s=Ce(e);ai(s,"".concat(i,"up"),this._onMouseUp),ai(s,"".concat(i,"move"),this._onMouseMove,he)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=Ce(this.upperCanvasEl);me(i,"touchend",this._onTouchEnd,he),me(i,"touchmove",this._onMouseMove,he),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{ai(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 s=Ce(this.upperCanvasEl);me(s,"".concat(i,"up"),this._onMouseUp),me(s,"".concat(i,"move"),this._onMouseMove,he),ai(e,"".concat(i,"move"),this._onMouseMove,he)}}_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:n}=t;if(n)return(this.fireMiddleClick&&n===1||this.fireRightClick&&n===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=r===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(r)||!h&&r===this._activeObject)}if(r){const h=r.findControl(this.getViewportPoint(t),nn(t)),{key:d,control:u}=h||{};if(l=d,r.selectable&&r!==this._activeObject&&r.activeOn==="up")this.setActiveObject(r,t),c=!0;else if(u){const g=u.getMouseUpHandler(t,r,u);g&&(a=this.getScenePoint(t),g.call(u,t,i,a.x,a.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&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=_(_({e:t,target:i,subTargets:s},Gi(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{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 n=0;n<s.length;n++)s[n]!==i&&s[n].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&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down"),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||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 n=this.getScenePoint(t);this._groupSelector={x:n.x,y:n.y,deltaY:0,deltaX:0}}if(e){const n=e===this._activeObject;e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),nn(t));if(e===this._activeObject&&(a||!r)){this._setupCurrentTransform(t,e,n);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=ts(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 i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,r=this.targets,n=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<n;a++)this.fireSyntheticInOutEvents("mouse",{e:t,target:r[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,n=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<n;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:r[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:n}=e,a=it(e,Wf);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=Gf[t],u=s!==i;if(s&&u){const g=_(_({},a),{},{e:n,target:s,nextTarget:i},Gi(this,n));r&&this.fire(d,g),s.fire(c,g)}if(i&&u){const g=_(_({},a),{},{e:n,target:i,previousTarget:s},Gi(this,n));r&&this.fire(h,g),i.fire(l,g)}}__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?ts(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:n}=e,a=!!r&&r(t,e,i.x,i.y);a&&n.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=ki(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const n=r.control;this.setCursor(n.cursorStyleHandler(t,n,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(n=>{i=n.hoverCursor||i}),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=ki(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 r=i.getObjects();if(e===i){const n=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(r,n)||this.searchPossibleTargets(this._objects,n))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(r,t)}else{i.isEditing&&i.exitEditing();const r=new(P.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(i,e),this._hoveredTarget=r,this._setActiveObject(r,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,n=new x(e,i),a=n.add(new x(s,r)),l=n.min(a),c=n.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=n.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(u=>!u.onSelect({e:t})).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=P.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const zc={x1:0,y1:0,x2:0,y2:0},Yf=_(_({},zc),{},{r1:0,r2:0}),Zi=(o,t)=>isNaN(o)&&typeof t=="number"?t:o,Xf=/^(\d+\.\d+)%|(\d+)%$/;function Hc(o){return o&&Xf.test(o)}function Nc(o,t){const e=typeof o=="number"?o:typeof o=="string"?parseFloat(o)/(Hc(o)?100:1):NaN;return rs(0,Zi(e,t),1)}const qf=/\s*;\s*/,Kf=/\s*:\s*/;function Zf(o,t){let e,i;const s=o.getAttribute("style");if(s){const n=s.split(qf);n[n.length-1]===""&&n.pop();for(let a=n.length;a--;){const[l,c]=n[a].split(Kf).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new X(e||o.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:Nc(o.getAttribute("offset"),0),color:r.toRgb(),opacity:Zi(parseFloat(i||o.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function Jf(o,t){const e=[],i=o.getElementsByTagName("stop"),s=Nc(t,1);for(let r=i.length;r--;)e.push(Zf(i[r],s));return e}function Vc(o){return o.nodeName==="linearGradient"||o.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Uc(o){return o.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function ye(o,t){return o.getAttribute(t)}function Qf(o,t){return function(e,i){let s,{width:r,height:n,gradientUnits:a}=i;return Object.keys(e).reduce((l,c)=>{const h=e[c];return h==="Infinity"?s=1:h==="-Infinity"?s=0:(s=typeof h=="string"?parseFloat(h):h,typeof h=="string"&&Hc(h)&&(s*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(s*=r),c!=="y1"&&c!=="y2"||(s*=n)))),l[c]=s,l},{})}(Vc(o)==="linear"?function(e){return{x1:ye(e,"x1")||0,y1:ye(e,"y1")||0,x2:ye(e,"x2")||"100%",y2:ye(e,"y2")||0}}(o):function(e){return{x1:ye(e,"fx")||ye(e,"cx")||"50%",y1:ye(e,"fy")||ye(e,"cy")||"50%",r1:0,x2:ye(e,"cx")||"50%",y2:ye(e,"cy")||"50%",r2:ye(e,"r")||"50%"}}(o),_(_({},t),{},{gradientUnits:Uc(o)}))}class nr{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:n=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?Yf:zc),s),colorStops:r,offsetX:n,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(vi()):vi()})}addColorStop(t){for(const e in t){const i=new X(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},cs(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map(e=>_({},e)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Jt.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",n=this.colorStops.map(d=>_({},d)).sort((d,u)=>d.offset-u.offset);let a=-this.offsetX,l=-this.offsetY;var c;r==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Vr(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:g,y2:p}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',g,'" y2="',p,`">
2662
+ `),e}getSvgStyles(){const t=this.opacity!==void 0&&this.opacity!==1?"opacity: ".concat(this.opacity,";"):"",e=this.visible?"":" visibility: hidden;";return[t,this.getSvgFilter(),e].join("")}toClipPathSVG(t){const e=[],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let s=0;s<this._objects.length;s++)e.push(" ",this._objects[s].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:s=[],layoutManager:r}=t,n=it(t,Sf);return Promise.all([Hs(s,e),ho(n,e)]).then(a=>{let[l,c]=a;const h=new this(l,_(_(_({},n),c),{},{layoutManager:new Tf}));if(r){const d=P.getClass(r.type),u=P.getClass(r.strategy);h.layoutManager=new d(new u)}else h.layoutManager=new Us;return h.layoutManager.subscribeTargets({type:Ke,target:h,targets:h.getObjects()}),h.setCoords(),h})}}v(mi,"type","Group"),v(mi,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),P.setClass(mi);const Ef=(o,t)=>Math.min(t.width/o.width,t.height/o.height),kf=(o,t)=>Math.max(t.width/o.width,t.height/o.height),pn="\\s*,?\\s*",Cs="".concat(pn,"(").concat(Ri,")"),Of="".concat(Cs).concat(Cs).concat(Cs).concat(pn,"([01])").concat(pn,"([01])").concat(Cs).concat(Cs),Pf={m:"l",M:"L"},Df=(o,t,e,i,s,r,n,a,l,c,h)=>{const d=ii(o),u=si(o),g=ii(t),p=si(t),f=e*s*g-i*r*p+n,b=i*s*g+e*r*p+a;return["C",c+l*(-e*s*u-i*r*d),h+l*(-i*s*u+e*r*d),f+l*(e*s*p+i*r*g),b+l*(i*s*p-e*r*g),f,b]},gl=(o,t,e,i)=>{const s=Math.atan2(t,o),r=Math.atan2(i,e);return r>=s?r-s:2*Math.PI-(s-r)};function fl(o,t,e,i,s,r,n,a){let l;if(U.cachesBoundsOfCurve&&(l=[...arguments].join(),As.boundsOfCurveCache[l]))return As.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,d=[],u=[[0,0],[0,0]];let g=6*o-12*e+6*s,p=-3*o+9*e-9*s+3*n,f=3*e-3*o;for(let T=0;T<2;++T){if(T>0&&(g=6*t-12*i+6*r,p=-3*t+9*i-9*r+3*a,f=3*i-3*t),h(p)<1e-12){if(h(g)<1e-12)continue;const D=-f/g;0<D&&D<1&&d.push(D);continue}const k=g*g-4*f*p;if(k<0)continue;const O=c(k),E=(-g+O)/(2*p);0<E&&E<1&&d.push(E);const S=(-g-O)/(2*p);0<S&&S<1&&d.push(S)}let b=d.length;const m=b,y=Fc(o,t,e,i,s,r,n,a);for(;b--;){const{x:T,y:k}=y(d[b]);u[0][b]=T,u[1][b]=k}u[0][m]=o,u[1][m]=t,u[0][m+1]=n,u[1][m+1]=a;const w=[new x(Math.min(...u[0]),Math.min(...u[1])),new x(Math.max(...u[0]),Math.max(...u[1]))];return U.cachesBoundsOfCurve&&(As.boundsOfCurveCache[l]=w),w}const Af=(o,t,e)=>{let[i,s,r,n,a,l,c,h]=e;const d=((u,g,p,f,b,m,y)=>{if(p===0||f===0)return[];let w=0,T=0,k=0;const O=Math.PI,E=y*Dn,S=si(E),D=ii(E),I=.5*(-D*u-S*g),M=.5*(-D*g+S*u),B=p**2,R=f**2,F=M**2,Y=I**2,tt=B*R-B*F-R*Y;let xt=Math.abs(p),W=Math.abs(f);if(tt<0){const ft=Math.sqrt(1-tt/(B*R));xt*=ft,W*=ft}else k=(b===m?-1:1)*Math.sqrt(tt/(B*F+R*Y));const wt=k*xt*M/W,Gt=-k*W*I/xt,Yt=D*wt-S*Gt+.5*u,Pe=S*wt+D*Gt+.5*g;let me=gl(1,0,(I-wt)/xt,(M-Gt)/W),It=gl((I-wt)/xt,(M-Gt)/W,(-I-wt)/xt,(-M-Gt)/W);m===0&&It>0?It-=2*O:m===1&&It<0&&(It+=2*O);const De=Math.ceil(Math.abs(It/O*2)),le=[],kt=It/De,Ft=8/3*Math.sin(kt/4)*Math.sin(kt/4)/Math.sin(kt/2);let ce=me+kt;for(let ft=0;ft<De;ft++)le[ft]=Df(me,ce,D,S,xt,W,Yt,Pe,Ft,w,T),w=le[ft][5],T=le[ft][6],me=ce,ce+=kt;return le})(c-o,h-t,s,r,a,l,n);for(let u=0,g=d.length;u<g;u++)d[u][1]+=o,d[u][2]+=t,d[u][3]+=o,d[u][4]+=t,d[u][5]+=o,d[u][6]+=t;return d},Mf=o=>{let t=0,e=0,i=0,s=0;const r=[];let n,a=0,l=0;for(const c of o){const h=[...c];let d;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],d=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],d=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],d=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],s=h[2],d=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],d=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":n==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],d=["C",a,l,h[1],h[2],t,e],a=d[3],l=d[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],d=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":n==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],d=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":Af(t,e,h).forEach(u=>r.push(u)),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=s,d=["Z"]}d?(r.push(d),n=d[0]):n=""}return r},Xr=(o,t,e,i)=>Math.sqrt((e-o)**2+(i-t)**2),Fc=(o,t,e,i,s,r,n,a)=>l=>{const c=l**3,h=(g=>3*g**2*(1-g))(l),d=(g=>3*g*(1-g)**2)(l),u=(g=>(1-g)**3)(l);return new x(n*c+s*h+e*d+o*u,a*c+r*h+i*d+t*u)},jc=o=>o**2,$c=o=>2*o*(1-o),Bc=o=>(1-o)**2,If=(o,t,e,i,s,r,n,a)=>l=>{const c=jc(l),h=$c(l),d=Bc(l),u=3*(d*(e-o)+h*(s-e)+c*(n-s)),g=3*(d*(i-t)+h*(r-i)+c*(a-r));return Math.atan2(g,u)},Lf=(o,t,e,i,s,r)=>n=>{const a=jc(n),l=$c(n),c=Bc(n);return new x(s*a+e*l+o*c,r*a+i*l+t*c)},Ff=(o,t,e,i,s,r)=>n=>{const a=1-n,l=2*(a*(e-o)+n*(s-e)),c=2*(a*(i-t)+n*(r-i));return Math.atan2(c,l)},ml=(o,t,e)=>{let i=new x(t,e),s=0;for(let r=1;r<=100;r+=1){const n=o(r/100);s+=Xr(i.x,i.y,n.x,n.y),i=n}return s},jf=(o,t)=>{let e,i=0,s=0,r={x:o.x,y:o.y},n=_({},r),a=.01,l=0;const c=o.iterator,h=o.angleFinder;for(;s<t&&a>1e-4;)n=c(i),l=i,e=Xr(r.x,r.y,n.x,n.y),e+s>t?(i-=a,a/=2):(r=n,i+=a,s+=e);return _(_({},n),{},{angle:h(l)})},Rc=o=>{let t,e,i=0,s=0,r=0,n=0,a=0;const l=[];for(const c of o){const h={x:s,y:r,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=n=s=c[1],e.y=a=r=c[2];break;case"L":e=h,e.length=Xr(s,r,c[1],c[2]),s=c[1],r=c[2];break;case"C":t=Fc(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=If(s,r,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=ml(t,s,r),s=c[5],r=c[6];break;case"Q":t=Lf(s,r,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=Ff(s,r,c[1],c[2],c[3],c[4]),e.length=ml(t,s,r),s=c[3],r=c[4];break;case"Z":e=h,e.destX=n,e.destY=a,e.length=Xr(s,r,n,a),s=n,r=a}i+=e.length,l.push(e)}return l.push({length:i,x:s,y:r}),l},$f=function(o,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Rc(o),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const s=e[i],r=t/s.length,n=o[i];switch(s.command){case"M":return{x:s.x,y:s.y,angle:0};case"Z":return _(_({},new x(s.x,s.y).lerp(new x(s.destX,s.destY),r)),{},{angle:Math.atan2(s.destY-s.y,s.destX-s.x)});case"L":return _(_({},new x(s.x,s.y).lerp(new x(n[1],n[2]),r)),{},{angle:Math.atan2(n[2]-s.y,n[1]-s.x)});case"C":case"Q":return jf(s,t)}},Bf=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),bl=new RegExp(Of,"g"),Rf=new RegExp(Ri,"gi"),zf={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},Hf=o=>{var t;const e=[],i=(t=o.match(Bf))!==null&&t!==void 0?t:[];for(const s of i){const r=s[0];if(r==="z"||r==="Z"){e.push([r]);continue}const n=zf[r.toLowerCase()];let a=[];if(r==="a"||r==="A"){bl.lastIndex=0;for(let l=null;l=bl.exec(s);)a.push(...l.slice(1))}else a=s.match(Rf)||[];for(let l=0;l<a.length;l+=n){const c=new Array(n),h=Pf[r];c[0]=l>0&&h?h:r;for(let d=0;d<n;d++)c[d+1]=parseFloat(a[l+d]);e.push(c)}}return e},Nf=(o,t)=>o.map(e=>e.map((i,s)=>s===0||t===void 0?i:at(i,t)).join(" ")).join(" ");function gn(o,t){const e=o.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(i=>{let[s,r]=i;return e.setProperty(s,r)}))}class Vf extends fc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),v(this,"upper",void 0),v(this,"container",void 0);const{el:s}=this.lower,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 n=this.createContainerElement();n.classList.add(i),s.parentNode&&s.parentNode.replaceChild(n,s),n.append(s,r),this.container=n}createUpperCanvas(){const{el:t}=this.lower,e=Oe();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=as().createElement("div");return t.setAttribute("data-fabric","wrapper"),gn(t,{position:"relative"}),qa(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:s}=e;gn(t,_(_({},i),{},{"touch-action":s?"manipulation":se})),qa(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:s}=this.upper;gc(i,s,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),on(this.upper.el,t),on(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(),Re().dispose(this.upper.el),delete this.upper,delete this.container}}class mo extends Ks{constructor(){super(...arguments),v(this,"targets",[]),v(this,"_hoveredTargets",[]),v(this,"_objectsToRender",void 0),v(this,"_currentTransform",null),v(this,"_groupSelector",null),v(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),mo.ownDefaults)}get upperCanvasEl(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.el}get contextTop(){var t;return(t=this.elements.upper)===null||t===void 0?void 0:t.ctx}get wrapperEl(){return this.elements.container}initElements(t){this.elements=new Vf(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 n=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(r),t.selectionBackgroundColor=n,r.restore();const a=Math.round(s*this.getRetinaScaling());return Yg(r,a,a,a)}_isSelectionKeyPressed(t){const e=this.selectionKey;return!!e&&(Array.isArray(e)?!!e.find(i=>!!i&&t[i]===!0):t[e])}_shouldClearSelection(t,e){const i=this.getActiveObjects(),s=this._activeObject;return!!(!e||e&&s&&i.length>1&&i.indexOf(e)===-1&&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===lo||e===ne||e===ye||e===zs?s=this.centeredScaling||t.centeredScaling:e===In&&(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=bt:["mr","tr","br"].includes(e)&&(i.x=G),["tl","mt","tr"].includes(e)?i.y=rn:["bl","mb","br"].includes(e)&&(i.y=ie)),i}_setupCurrentTransform(t,e,i){var s;const r=e.group?es(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:n="",control:a}=e.getActiveControl()||{},l=i&&a?(s=a.getActionHandler(t,e,a))===null||s===void 0?void 0:s.bind(a):ug,c=((g,p,f,b)=>{if(!p||!g)return"drag";const m=b.controls[p];return m.getActionName(f,m,b)})(i,n,t,e),h=t[this.centeredKey],d=this._shouldCenterTransform(e,c,h)?{x:N,y:N}:this._getOriginFromCorner(e,n),u={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:n,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:r.x-e.left,offsetY:r.y-e.top,originX:d.x,originY:d.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,theta:vt(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},mc(e)),{},{originX:d.x,originY:d.y})};this._currentTransform=u,this.fire("before:transform",{e:t,transform:u})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:s,deltaY:r}=this._groupSelector,n=new x(e,i).transform(this.viewportTransform),a=new x(e+s,i+r).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(n.x,a.x),h=Math.min(n.y,a.y),d=Math.max(n.x,a.x),u=Math.max(n.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,d-c,u-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,d-=l,u-=l,Nt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,d-c,u-h))}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,nn(t))||s.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const r=this.targets;this.targets=[];const n=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&n&&n!==i?(this.targets=r,i):n}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[n,a,l,c]=i,h=Math.atan2(a.y-n.y,a.x-n.x),d=ii(h)*r,u=si(h)*r,g=d+u,p=d-u;i=[new x(n.x-p,n.y-g),new x(a.x+g,a.y-p),new x(l.x+p,l.y+g),new x(c.x-g,c.y+p)]}return ot.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,es(e,void 0,this.viewportTransform))&&(!this.perPixelTargetFind&&!t.perPixelTargetFind||t.isEditing||!this.isTargetTransparent(t,e.x,e.y)))}_searchPossibleTargets(t,e){let i=t.length;for(;i--;){const s=t[i];if(this._checkTarget(s,e)){if(Dr(s)&&s.subTargetCheck){const r=this._searchPossibleTargets(s._objects,e);r&&this.targets.push(r)}return s}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&Dr(i)&&i.interactive&&this.targets[0]){const s=this.targets;for(let r=s.length-1;r>0;r--){const n=s[r];if(!Dr(n)||!n.interactive)return n}return s[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&&arguments[1]!==void 0&&arguments[1];const i=this.upperCanvasEl,s=i.getBoundingClientRect();let r=og(t),n=s.width||0,a=s.height||0;n&&a||(ie in s&&rn in s&&(a=Math.abs(s.top-s.bottom)),bt in s&&G in s&&(n=Math.abs(s.right-s.left))),this.calcOffset(),r.x=r.x-this._offset.left,r.y=r.y-this._offset.top,e||(r=es(r,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(r.x/=l,r.y/=l);const c=n===0||a===0?new x(1,1):new x(i.width/n,i.height/a);return r.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Oe(),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 Oi(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,s=!1;const r=this.getActiveObjects(),n=[],a=[];t.forEach(l=>{r.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))}),r.forEach(l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),n.push(l))}),t.length>0&&r.length>0?(s=!0,i&&this.fire("selection:updated",{e,selected:n,deselected:a})):r.length>0?(s=!0,this.fire("selection:created",{e,selected:n})):t.length>0&&(s=!0,this.fire("selection:cleared",{e,deselected:a})),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})&&(this._activeObject=t,Oi(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),Oi(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(zr,s))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;Oi(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&&Oi(e)&&this._activeObject===e){const i=hs(t,["angle","flipX","flipY",G,ne,ye,ls,cs,ie]);return ag(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const s=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(s)}}v(mo,"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 Uf{constructor(t){v(this,"targets",[]),v(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:s}=t.getActiveObject()||{};s&&s.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),Xi(this.targets,t)}register(t){this.target=t}unregister(t){t===this.target&&(this.target=void 0)}onMouseMove(t){var e;!((e=this.target)===null||e===void 0)&&e.isEditing&&this.target.updateSelectionOnMouseMove(t)}clear(){this.targets=[],this.target=void 0}dispose(){this.clear(),this.__disposer(),delete this.__disposer}}const Wf=["target","oldTarget","fireCanvas","e"],he={passive:!1},Gi=(o,t)=>{const e=o.getViewportPoint(t),i=o.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},ci=function(o){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return o.addEventListener(...e)},be=function(o){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return o.removeEventListener(...e)},Gf={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 qr extends mo{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),v(this,"_isClick",void 0),v(this,"textEditingManager",new Uf(this)),["_onMouseDown","_onTouchStart","_onMouseMove","_onMouseUp","_onTouchEnd","_onResize","_onMouseWheel","_onMouseOut","_onMouseEnter","_onContextMenu","_onDoubleClick","_onDragStart","_onDragEnd","_onDragProgress","_onDragOver","_onDragEnter","_onDragLeave","_onDrop"].forEach(e=>{this[e]=this[e].bind(this)}),this.addOrRemove(ci,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,s=this._getEventPrefix();t(pc(i),"resize",this._onResize),t(i,s+"down",this._onMouseDown),t(i,"".concat(s,"move"),this._onMouseMove,he),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,he)}removeListeners(){this.addOrRemove(be,"remove");const t=this._getEventPrefix(),e=Se(this.upperCanvasEl);be(e,"".concat(t,"up"),this._onMouseUp),be(e,"touchend",this._onTouchEnd,he),be(e,"".concat(t,"move"),this._onMouseMove,he),be(e,"touchmove",this._onMouseMove,he),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},Gi(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach(s=>{this.fire("mouse:out",_(_({},i),{},{target:s})),s&&s.fire("mouseout",_({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},Gi(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 ci(this.upperCanvasEl,"drag",this._onDragProgress)}an(t)}_renderDragEffects(t,e,i){let s=!1;const r=this._dropTarget;r&&r!==e&&r!==i&&(r.clearContextTop(),s=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const n=this.contextTop;n.save(),n.transform(...this.viewportTransform),e&&(n.save(),e.transform(n),e.renderDragSourceEffect(t),n.restore(),s=!0),i&&(n.save(),i.transform(n),i.renderDropTargetEffect(t),n.restore(),s=!0),n.restore(),s&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==se,i=e?this._activeObject:void 0,s={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};be(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,n={e:t,target:i,subTargets:s,dragSource:r,canDrop:!1,dropTarget:void 0};let a;this.fire(e,n),this._fireEnterLeaveEvents(i,n),i&&(i.canDrop(t)&&(a=i),i.fire(e,n));for(let l=0;l<s.length;l++){const c=s[l];c.canDrop(t)&&(a=c),c.fire(e,n)}this._renderDragEffects(t,r,a),this._dropTarget=a}_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",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},Gi(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&&an(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 t.isPrimary===!0||t.isPrimary!==!1&&(t.type==="touchend"&&t.touches.length===0||!t.changedTouches||t.changedTouches[0].identifier===this.mainTouchId)}_onTouchStart(t){let e=!this.allowTouchScrolling;const i=this._activeObject;this.mainTouchId===void 0&&(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(),n=Se(s);ci(n,"touchend",this._onTouchEnd,he),e&&ci(n,"touchmove",this._onMouseMove,he),be(s,"".concat(r,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();be(e,"".concat(i,"move"),this._onMouseMove,he);const s=Se(e);ci(s,"".concat(i,"up"),this._onMouseUp),ci(s,"".concat(i,"move"),this._onMouseMove,he)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=Se(this.upperCanvasEl);be(i,"touchend",this._onTouchEnd,he),be(i,"touchmove",this._onMouseMove,he),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{ci(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 s=Se(this.upperCanvasEl);be(s,"".concat(i,"up"),this._onMouseUp),be(s,"".concat(i,"move"),this._onMouseMove,he),ci(e,"".concat(i,"move"),this._onMouseMove,he)}}_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:n}=t;if(n)return(this.fireMiddleClick&&n===1||this.fireRightClick&&n===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!s){const h=r===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(r)||!h&&r===this._activeObject)}if(r){const h=r.findControl(this.getViewportPoint(t),nn(t)),{key:d,control:u}=h||{};if(l=d,r.selectable&&r!==this._activeObject&&r.activeOn==="up")this.setActiveObject(r,t),c=!0;else if(u){const g=u.getMouseUpHandler(t,r,u);g&&(a=this.getScenePoint(t),g.call(u,t,i,a.x,a.y))}r.isMoving=!1}if(i&&(i.target!==r||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],d=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),d&&d.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,r),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,r&&(r.__corner=void 0),c?this.requestRenderAll():s||(e=this._activeObject)!==null&&e!==void 0&&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=_(_({e:t,target:i,subTargets:s},Gi(this,t)),{},{transform:this._currentTransform},e==="up:before"||e==="up"?{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 n=0;n<s.length;n++)s[n]!==i&&s[n].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&&i===1||this.fireRightClick&&i===2)&&this._handleEvent(t,"down"),void this._resetTransformEventData();if(this.isDrawingMode)return void this._onMouseDownInDrawingMode(t);if(!this._isMainEvent(t)||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 n=this.getScenePoint(t);this._groupSelector={x:n.x,y:n.y,deltaY:0,deltaX:0}}if(e){const n=e===this._activeObject;e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),nn(t));if(e===this._activeObject&&(a||!r)){this._setupCurrentTransform(t,e,n);const l=a?a.control:void 0,c=this.getScenePoint(t),h=l&&l.getMouseDownHandler(t,e,l);h&&h.call(l,t,this._currentTransform,c.x,c.y)}}s&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),s&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=es(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 i=this.findTarget(t);this._setCursorFromEvent(t,i),this._fireOverOutEvents(t,i)}this.textEditingManager.onMouseMove(t),this._handleEvent(t,"move"),this._resetTransformEventData()}_fireOverOutEvents(t,e){const i=this._hoveredTarget,s=this._hoveredTargets,r=this.targets,n=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<n;a++)this.fireSyntheticInOutEvents("mouse",{e:t,target:r[a],oldTarget:s[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,s=this._hoveredTargets,r=this.targets,n=Math.max(s.length,r.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<n;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:r[a],oldTarget:s[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:s,fireCanvas:r,e:n}=e,a=it(e,Wf);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:d}=Gf[t],u=s!==i;if(s&&u){const g=_(_({},a),{},{e:n,target:s,nextTarget:i},Gi(this,n));r&&this.fire(d,g),s.fire(c,g)}if(i&&u){const g=_(_({},a),{},{e:n,target:i,previousTarget:s},Gi(this,n));r&&this.fire(h,g),i.fire(l,g)}}__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?es(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:n}=e,a=!!r&&r(t,e,i.x,i.y);a&&n.setCoords(),s==="drag"&&a&&(e.target.isMoving=!0,this.setCursor(e.target.moveCursor||this.moveCursor)),e.actionPerformed=e.actionPerformed||a}_setCursorFromEvent(t,e){if(!e)return void this.setCursor(this.defaultCursor);let i=e.hoverCursor||this.hoverCursor;const s=Oi(this._activeObject)?this._activeObject:null,r=(!s||e.group!==s)&&e.findControl(this.getViewportPoint(t));if(r){const n=r.control;this.setCursor(n.cursorStyleHandler(t,n,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(n=>{i=n.hoverCursor||i}),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,s=Oi(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 r=i.getObjects();if(e===i){const n=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(r,n)||this.searchPossibleTargets(this._objects,n))||!e.selectable)return!1}e.group===i?(i.remove(e),this._hoveredTarget=e,this._hoveredTargets=[...this.targets],i.size()===1&&this._setActiveObject(i.item(0),t)):(i.multiSelectAdd(e),this._hoveredTarget=i,this._hoveredTargets=[...this.targets]),this._fireSelectionEvents(r,t)}else{i.isEditing&&i.exitEditing();const r=new(P.getClass("ActiveSelection"))([],{canvas:this});r.multiSelectAdd(i,e),this._hoveredTarget=r,this._setActiveObject(r,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,n=new x(e,i),a=n.add(new x(s,r)),l=n.min(a),c=n.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),d=n.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(u=>!u.onSelect({e:t})).reverse():h;if(d.length===1)this.setActiveObject(d[0],t);else if(d.length>1){const u=P.getClass("ActiveSelection");this.setActiveObject(new u(d,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const zc={x1:0,y1:0,x2:0,y2:0},Yf=_(_({},zc),{},{r1:0,r2:0}),Zi=(o,t)=>isNaN(o)&&typeof t=="number"?t:o,Xf=/^(\d+\.\d+)%|(\d+)%$/;function Hc(o){return o&&Xf.test(o)}function Nc(o,t){const e=typeof o=="number"?o:typeof o=="string"?parseFloat(o)/(Hc(o)?100:1):NaN;return os(0,Zi(e,t),1)}const qf=/\s*;\s*/,Kf=/\s*:\s*/;function Zf(o,t){let e,i;const s=o.getAttribute("style");if(s){const n=s.split(qf);n[n.length-1]===""&&n.pop();for(let a=n.length;a--;){const[l,c]=n[a].split(Kf).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const r=new X(e||o.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:Nc(o.getAttribute("offset"),0),color:r.toRgb(),opacity:Zi(parseFloat(i||o.getAttribute("stop-opacity")||""),1)*r.getAlpha()*t}}function Jf(o,t){const e=[],i=o.getElementsByTagName("stop"),s=Nc(t,1);for(let r=i.length;r--;)e.push(Zf(i[r],s));return e}function Vc(o){return o.nodeName==="linearGradient"||o.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Uc(o){return o.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function xe(o,t){return o.getAttribute(t)}function Qf(o,t){return function(e,i){let s,{width:r,height:n,gradientUnits:a}=i;return Object.keys(e).reduce((l,c)=>{const h=e[c];return h==="Infinity"?s=1:h==="-Infinity"?s=0:(s=typeof h=="string"?parseFloat(h):h,typeof h=="string"&&Hc(h)&&(s*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(s*=r),c!=="y1"&&c!=="y2"||(s*=n)))),l[c]=s,l},{})}(Vc(o)==="linear"?function(e){return{x1:xe(e,"x1")||0,y1:xe(e,"y1")||0,x2:xe(e,"x2")||"100%",y2:xe(e,"y2")||0}}(o):function(e){return{x1:xe(e,"fx")||xe(e,"cx")||"50%",y1:xe(e,"fy")||xe(e,"cy")||"50%",r1:0,x2:xe(e,"cx")||"50%",y2:xe(e,"cy")||"50%",r2:xe(e,"r")||"50%"}}(o),_(_({},t),{},{gradientUnits:Uc(o)}))}class nr{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:s={},colorStops:r=[],offsetX:n=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?Yf:zc),s),colorStops:r,offsetX:n,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(_i()):_i()})}addColorStop(t){for(const e in t){const i=new X(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},hs(this,t)),{},{type:this.type,coords:_({},this.coords),colorStops:this.colorStops.map(e=>_({},e)),offsetX:this.offsetX,offsetY:this.offsetY,gradientUnits:this.gradientUnits,gradientTransform:this.gradientTransform?[...this.gradientTransform]:void 0})}toSVG(t){let{additionalTransform:e}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=[],s=this.gradientTransform?this.gradientTransform.concat():Jt.concat(),r=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",n=this.colorStops.map(d=>_({},d)).sort((d,u)=>d.offset-u.offset);let a=-this.offsetX,l=-this.offsetY;var c;r==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),s[4]-=a,s[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(r,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(Vr(s),'"'),""].join(" ");if(this.type==="linear"){const{x1:d,y1:u,x2:g,y2:p}=this.coords;i.push("<linearGradient ",h,' x1="',d,'" y1="',u,'" x2="',g,'" y2="',p,`">
2656
2663
  `)}else if(this.type==="radial"){const{x1:d,y1:u,x2:g,y2:p,r1:f,r2:b}=this.coords,m=f>b;i.push("<radialGradient ",h,' cx="',m?d:g,'" cy="',m?u:p,'" r="',m?f:b,'" fx="',m?g:d,'" fy="',m?p:u,`">
2657
2664
  `),m&&(n.reverse(),n.forEach(w=>{w.offset=1-w.offset}));const y=Math.min(f,b);if(y>0){const w=y/Math.max(f,b);n.forEach(T=>{T.offset+=w*(1-T.offset)})}}return n.forEach(d=>{let{color:u,offset:g,opacity:p}=d;i.push("<stop ",'offset="',100*g+"%",'" style="stop-color:',u,p!==void 0?";stop-opacity: "+p:";",`"/>
2658
2665
  `)}),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
2659
- `),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:n,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,n,s,r,a);return this.colorStops.forEach(c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new X(h).setAlpha(d).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map(s=>_({},s)):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=Uc(t),r=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:Vc(t),coords:Qf(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Jf(t,i.opacity),gradientUnits:s,gradientTransform:dn(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}v(nr,"type","Gradient"),P.setClass(nr,"gradient"),P.setClass(nr,"linear"),P.setClass(nr,"radial");const tm=["type","source","patternTransform"];class Bo{get type(){return"pattern"}set type(t){bi("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=vi(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return _(_({},cs(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:nt(this.offsetX,U.NUM_FRACTION_DIGITS),offsetY:nt(this.offsetY,U.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:n}=this,a=Zi(this.offsetX/e,0),l=Zi(this.offsetY/i,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(a||0):Zi(s.width/e,0),h=r==="repeat-x"||r==="no-repeat"?1+Math.abs(l||0):Zi(s.height/i,0);return['<pattern id="SVGID_'.concat(n,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
2660
- `)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,n=it(t,tm);const a=await Mr(s,_(_({},e),{},{crossOrigin:n.crossOrigin}));return new this(_(_({},n),{},{patternTransform:r&&r.slice(0),source:a}))}}v(Bo,"type","Pattern"),P.setClass(Bo),P.setClass(Bo,"pattern");const em=["path","left","top"],im=["d"];class Oi extends Nt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,n=it(e,em);super(),Object.assign(this,Oi.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),typeof s=="number"&&this.set(G,s),typeof r=="number"&&this.set(ie,r)}_setPath(t,e){this.path=Mf(Array.isArray(t)?t:Hf(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,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&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{path:this.path.map(e=>e.slice())})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Nf(this.path,U.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
2661
- `)]}_getOffsetTransform(){const t=U.NUM_FRACTION_DIGITS;return" translate(".concat(nt(-this.pathOffset.x,t),", ").concat(nt(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,H,H)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const n of this.path)switch(n[0]){case"L":s=n[1],r=n[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=n[1],r=n[2],e=s,i=r;break;case"C":t.push(...fl(s,r,n[1],n[2],n[3],n[4],n[5],n[6])),s=n[5],r=n[6];break;case"Q":t.push(...fl(s,r,n[1],n[2],n[1],n[2],n[3],n[4])),s=n[3],r=n[4];break;case"Z":s=e,r=i}return Ze(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new x(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=ri(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,_(_(_({},it(s,im)),e),{},{left:void 0,top:void 0}))}}v(Oi,"type","Path"),v(Oi,"cacheProperties",[...si,"path","fillRule"]),v(Oi,"ATTRIBUTE_NAMES",[...wi,"d"]),P.setClass(Oi),P.setSVGClass(Oi);const sm=["left","top","radius"],Wc=["radius","startAngle","endAngle","counterClockwise"];class Ge extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Ge.ownDefaults)}constructor(t){super(),Object.assign(this,Ge.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,bt(this.startAngle),bt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ne)}getRadiusY(){return this.get("radius")*this.get(_e)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Wc,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
2662
- `];{const{radius:e}=this,i=bt(this.startAngle),s=bt(this.endAngle),r=ti(i)*e,n=ei(i)*e,a=ti(s)*e,l=ei(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(n," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
2663
- `]}}static async fromElement(t,e,i){const s=ri(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:n=0,radius:a=0}=s;return new this(_(_({},it(s,sm)),{},{radius:a,left:r-a,top:n-a}))}static fromObject(t){return super._fromObject(t)}}v(Ge,"type","Circle"),v(Ge,"cacheProperties",[...si,...Wc]),v(Ge,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(Ge,"ATTRIBUTE_NAMES",["cx","cy","r",...wi]),P.setClass(Ge),P.setSVGClass(Ge);const rm=["x1","y1","x2","y2"],om=["x1","y1","x2","y2"],fn=["x1","x2","y1","y2"];class Pi extends Nt{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Pi.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:n,top:a}=r;typeof n=="number"&&this.set(G,n),typeof a=="number"&&this.set(ie,a)}_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:n,width:a,height:l}=Ze([{x:t,y:e},{x:i,y:s}]),c=new x(r+a/2,n+l/2);this.setPositionByOrigin(c,H,H)}_set(t,e){return super._set(t,e),fn.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;be(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new x((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:r,height:n}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*r/2,x2:a*-r/2,y1:l*n/2,y2:l*-n/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,`" />
2664
- `)]}static async fromElement(t,e,i){const s=ri(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:n=0,x2:a=0,y2:l=0}=s;return new this([r,n,a,l],it(s,rm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,n=it(t,om);return this._fromObject(_(_({},n),{},{points:[e,i,s,r]}),{extraParam:"points"})}}v(Pi,"type","Line"),v(Pi,"cacheProperties",[...si,...fn]),v(Pi,"ATTRIBUTE_NAMES",wi.concat(fn)),P.setClass(Pi),P.setSVGClass(Pi);class Mi extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Mi.ownDefaults)}constructor(t){super(),Object.assign(this,Mi.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),'" />']}}v(Mi,"type","Triangle"),v(Mi,"ownDefaults",{width:100,height:100}),P.setClass(Mi),P.setSVGClass(Mi);const Gc=["rx","ry"];class Ye extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Ye.ownDefaults)}constructor(t){super(),Object.assign(this,Ye.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(ne)}getRy(){return this.get("ry")*this.get(_e)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Gc,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
2665
- `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Br,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=ri(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function nm(o){if(!o)return[];const t=o.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(Ye,"type","Ellipse"),v(Ye,"cacheProperties",[...si,...Gc]),v(Ye,"ownDefaults",{rx:0,ry:0}),v(Ye,"ATTRIBUTE_NAMES",[...wi,"cx","cy","rx","ry"]),P.setClass(Ye),P.setSVGClass(Ye);const am=["left","top"],Yc={exactBoundingBox:!1};class we extends Nt{static getDefaults(){return _(_({},super.getDefaults()),we.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,we.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(G,i),typeof s=="number"&&this.set(ie,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return qg(this.points,t,this.isOpen())}_calcDimensions(t){t=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(c=>c.projectedPoint):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new x,strokeOffset:new x,strokeDiff:new x};const i=Ze(e),s=co(_(_({},t),{},{scaleX:1,scaleY:1})),r=Ze(this.points.map(c=>ee(c,s,!0))),n=new x(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(bt(this.skewX)),l-=a*Math.tan(bt(this.skewY))),_(_({},i),{},{pathOffset:new x(a,l),strokeOffset:new x(r.left,r.top).subtract(new x(i.left,i.top)).multiply(n),strokeDiff:new x(i.width,i.height).subtract(new x(r.width,r.height)).multiply(n)})}_findCenterFromElement(){const t=Ze(this.points);return new x(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:n,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:r,pathOffset:n,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new x(e+s/2,i+r/2),H,H)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let n;if(Object.keys(t).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var e,i;const{width:a,height:l}=this._calcDimensions(t);n=new x((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,r;n=new x((s=t.width)!==null&&s!==void 0?s:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return n.multiply(new x(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===ne||t===_e)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{points:this.points.map(e=>{let{x:i,y:s}=e;return{x:i,y:s}})})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=U.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r<n;r++)t.push(nt(this.points[r].x-e,s),",",nt(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
2666
- `)]}_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 n=this.points[r];t.lineTo(n.x-i,n.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(nm(t.getAttribute("points")),_(_({},it(ri(t,this.ATTRIBUTE_NAMES,i),am)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(we,"ownDefaults",Yc),v(we,"type","Polyline"),v(we,"layoutProperties",[as,ls,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(we,"cacheProperties",[...si,"points"]),v(we,"ATTRIBUTE_NAMES",[...wi]),P.setClass(we),P.setSVGClass(we);class ar extends we{isOpen(){return!1}}v(ar,"ownDefaults",Yc),v(ar,"type","Polygon"),P.setClass(ar),P.setSVGClass(ar);const Xc=["fontSize","fontWeight","fontFamily","fontStyle"],qc=["underline","overline","linethrough"],Kc=[...Xc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Zc=[...Kc,...qc,"textBackgroundColor","direction"],lm=[...Xc,...qc,re,"strokeWidth",Pt,"deltaY","textBackgroundColor"],cm={_reNewline:Mn,_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:G,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:G,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},Ie="justify",Kr="justify-left",Ms="justify-right",Is="justify-center";class Jc extends Nt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const r in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const r in i[s])if(i[s][r][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,n=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};r++,h[t]!==void 0?(s?h[t]!==s&&(n=!1):s=h[t],h[t]===this[t]&&delete h[t]):n=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;n&&r===a&&(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],Object.keys(i[r]).length===0&&delete i[r];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const r=$n(_(_({},this._getStyleDeclaration(i,s)),e),n=>n!==void 0);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&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return _(_({},cs(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]}}v(Jc,"_styleProperties",lm);const hm=/ +/g,dm=/"/g;function Ro(o,t,e,i,s){return" ".concat(function(r,n){let{left:a,top:l,width:c,height:h}=n,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:U.NUM_FRACTION_DIGITS;const u=Hs(Pt,r,!1),[g,p,f,b]=[a,l,c,h].map(m=>nt(m,d));return"<rect ".concat(u,' x="').concat(g,'" y="').concat(p,'" width="').concat(f,'" height="').concat(b,'"></rect>')}(o,{left:t,top:e,width:i,height:s}),`
2667
- `)}const um=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let zo;class qt extends Jc{static getDefaults(){return _(_({},super.getDefaults()),qt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,qt.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=Rc(t.path))}_splitText(){const t=this._splitTextIntoLines(this.text);return this.textLines=t.lines,this._textLines=t.graphemeLines,this._unwrappedTextLines=t._unwrappedLines,this._text=t.graphemeText,t}initDimensions(){this._splitText(),this._clearCache(),this.dirty=!0,this.path?(this.width=this.path.width,this.height=this.path.height):(this.width=this.calcTextWidth()||this.cursorWidth||this.MIN_TEXT_WIDTH,this.height=this.calcTextHeight()),this.textAlign.includes(Ie)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,n,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Ie||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,r=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=r.length;h++)n=this.__charBounds[l][h],this._reSpaceAndTab.test(r[h])?(n.width+=t,n.kernedWidth+=t,n.left+=s,s+=t):n.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===re?(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 H:t.textBaseline="middle";break;case"ascender":t.textBaseline=ie;break;case"descender":t.textBaseline=rn}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,r,n){this._renderChars(t,e,i,s,r,n)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,n=this._textLines.length;r<n;r++){const a=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=a;continue}const l=this._textLines[r].length,c=this._getLineLeftOffset(r);let h,d,u=0,g=0,p=this.getValueOfPropertyAt(r,0,"textBackgroundColor");for(let f=0;f<l;f++){const b=this.__charBounds[r][f];d=this.getValueOfPropertyAt(r,f,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=d,d&&t.fillRect(-b.width/2,-a/this.lineHeight*(1-this._fontSizeFraction),b.width,a/this.lineHeight),t.restore()):d!==p?(h=i+c+g,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=p,p&&t.fillRect(h,s,u,a/this.lineHeight),g=b.left,u=b.width,p=d):u+=b.kernedWidth}d&&!this.path&&(h=i+c+g,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,a/this.lineHeight)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=Ds.getFontCache(e),n=this._getFontDeclaration(e),a=i+t,l=i&&n===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,g;if(i&&r[i]!==void 0&&(u=r[i]),r[t]!==void 0&&(g=h=r[t]),l&&r[a]!==void 0&&(d=r[a],g=d-u),h===void 0||u===void 0||d===void 0){const p=function(){return zo||(zo=Re({width:0,height:0}).getContext("2d")),zo}();this._setTextStyles(p,e,!0),h===void 0&&(g=h=p.measureText(t).width,r[t]=h),u===void 0&&l&&i&&(u=p.measureText(i).width,r[i]=u),l&&d===void 0&&(d=p.measureText(a).width,r[a]=d,g=d-u)}return{width:h*c,kernedWidth:g*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const r=this.pathSide===mt,n=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},n&&n.segmentsInfo){let h=0;const d=n.segmentsInfo[n.segmentsInfo.length-1].length;switch(this.textAlign){case G:h=r?d-s:0;break;case H:h=(d-s)/2;break;case mt:h=r?0:d-s}h+=this.pathStartOffset*(r?-1:1);for(let u=r?l-1:0;r?u>=0:u<l;r?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=$f(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===mt?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){const n=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,n,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:n.fontSize,kernedWidth:h,deltaY:n.deltaY};if(i>0&&!r){const g=this.__charBounds[e][i-1];u.left=g.left+g.width+l.kernedWidth-l.width}return u}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 this.direction==="ltr"?-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 n=0,a=this._textLines.length;n<a;n++){const l=this.getHeightOfLine(n),c=l/this.lineHeight,h=this._getLineLeftOffset(n);this._renderTextLine(e,t,this._textLines[n],s+h,r+i+c,n),i+=l}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Pt))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,r,n){const a=this.getHeightOfLine(n),l=this.textAlign.includes(Ie),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(n)&&!c,d=this.direction==="ltr",u=this.direction==="ltr"?1:-1,g=e.direction;let p,f,b,m,y,w="",T=0;if(e.save(),g!==this.direction&&(e.canvas.setAttribute("dir",d?"ltr":"rtl"),e.direction=d?"ltr":"rtl",e.textAlign=d?G:mt),r-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,n,0,i.join(""),s,r),void e.restore();for(let k=0,O=i.length-1;k<=O;k++)m=k===O||this.charSpacing||c,w+=i[k],b=this.__charBounds[n][k],T===0?(s+=u*(b.kernedWidth-b.width),T+=b.width):T+=b.kernedWidth,l&&!m&&this._reSpaceAndTab.test(i[k])&&(m=!0),m||(p=p||this.getCompleteStyleDeclaration(n,k),f=this.getCompleteStyleDeclaration(n,k+1),m=Wn(p,f,!1)),m&&(c?(e.save(),e.translate(b.renderLeft,b.renderTop),e.rotate(b.angle),this._renderChar(t,e,n,k,w,-T/2,0),e.restore()):(y=s,this._renderChar(t,e,n,k,w,y,r)),w="",p=f,s+=u*T,T=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=Re({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 be(i)?i.gradientUnits==="percentage"||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,n,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(r,n-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(r,n-u.offsetX,a-u.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"),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:r*i.size,deltaY:n+r*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,n=this.isEndOfWrapping(t);let a=0;return s===Ie||s===Is&&!n||s===Ms&&!n||s===Kr&&!n?0:(s===H&&(a=i/2),s===mt&&(a=i),s===Is&&(a=i/2),s===Ms&&(a=i),r==="rtl"&&(s===mt||s===Ie||s===Ms?a=0:s===G||s===Kr?a=-i:s!==H&&s!==Is||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),r=this.path,n=this._getWidthOfCharSpacing(),a=this.offsets[e];for(let l=0,c=this._textLines.length;l<c;l++){const h=this.getHeightOfLine(l);if(!this[e]&&!this.styleHas(e,l)){i+=h;continue}const d=this._textLines[l],u=h/this.lineHeight,g=this._getLineLeftOffset(l);let p,f,b=0,m=0,y=this.getValueOfPropertyAt(l,0,e),w=this.getValueOfPropertyAt(l,0,Pt);const T=i+u*(1-this._fontSizeFraction);let k=this.getHeightOfChar(l,0),O=this.getValueOfPropertyAt(l,0,"deltaY");for(let S=0,D=d.length;S<D;S++){const I=this.__charBounds[l][S];p=this.getValueOfPropertyAt(l,S,e),f=this.getValueOfPropertyAt(l,S,Pt);const M=this.getHeightOfChar(l,S),B=this.getValueOfPropertyAt(l,S,"deltaY");if(r&&p&&f)t.save(),t.fillStyle=w,t.translate(I.renderLeft,I.renderTop),t.rotate(I.angle),t.fillRect(-I.kernedWidth/2,a*M+B,I.kernedWidth,this.fontSize/15),t.restore();else if((p!==y||f!==w||M!==k||B!==O)&&m>0){let R=s+g+b;this.direction==="rtl"&&(R=this.width-R-m),y&&w&&(t.fillStyle=w,t.fillRect(R,T+a*k+O,m,this.fontSize/15)),b=I.left,m=I.width,y=p,w=f,k=M,O=B}else m+=I.kernedWidth}let E=s+g+b;this.direction==="rtl"&&(E=this.width-E-m),t.fillStyle=f,p&&f&&t.fillRect(E,T+a*k+O,m-n,this.fontSize/15),i+=h}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const n=t.includes("'")||t.includes('"')||t.includes(",")||qt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?this.CACHE_FONT_SIZE:s,"px"),n].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Un(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
2668
- `];let r=[];for(let n=0;n<e.length;n++)i[n]=this.graphemeSplit(e[n]),r=r.concat(i[n],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject([...Zc,...t])),{},{styles:Jg(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(typeof t=="object")for(const n in t)n==="path"&&this.setPathInfo(),s=s||i.includes(n),r=r||n==="path";else s=i.includes(t),r=t==="path";return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=ri(t,qt.ATTRIBUTE_NAMES,i),r=_(_({},e),s),{textAnchor:n=G,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=An,strokeWidth:g=1}=r,p=it(r,um),f=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),_({left:d+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:u},p)),b=f.getScaledHeight()/f.height,m=((f.height+f.strokeWidth)*f.lineHeight-f.height)*b,y=f.getScaledHeight()+m;let w=0;return n===H&&(w=f.getScaledWidth()/2),n===mt&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(y-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:g}),f}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Qg(t.styles||{},t.text)}),{extraParam:"text"})}}v(qt,"textLayoutProperties",Kc),v(qt,"cacheProperties",[...si,...Zc]),v(qt,"ownDefaults",cm),v(qt,"type","Text"),v(qt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(qt,"ATTRIBUTE_NAMES",wi.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Dc(qt,[class extends xc{_toSVG(){const o=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(o.textTop,o.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(o){return this._createBaseSVGMarkup(this._toSVG(),{reviver:o,noStyle:!0,withShadow:!0})}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(o){let{textBgRects:t,textSpans:e}=o;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'.concat(this.fontFamily.replace(dm,"'"),'" '):"",this.fontSize?'font-size="'.concat(this.fontSize,'" '):"",this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
2669
- `]}_getSVGTextAndBg(o,t){const e=[],i=[];let s,r=o;this.backgroundColor&&i.push(...Ro(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let n=0,a=this._textLines.length;n<a;n++)s=this._getLineLeftOffset(n),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",n))&&this._setSVGTextLineBg(i,n,t+s,r),this._setSVGTextLineText(e,n,t+s,r),r+=this.getHeightOfLine(n);return{textSpans:e,textBgRects:i}}_createTextCharSpan(o,t,e,i){const s=this.getSvgSpanStyles(t,o!==o.trim()||!!o.match(hm)),r=s?'style="'.concat(s,'"'):"",n=t.deltaY,a=n?' dy="'.concat(nt(n,U.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(nt(e,U.NUM_FRACTION_DIGITS),'" y="').concat(nt(i,U.NUM_FRACTION_DIGITS),'" ').concat(a).concat(r,">").concat(Kg(o),"</tspan>")}_setSVGTextLineText(o,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(Ie),n=this._textLines[t];let a,l,c,h,d,u="",g=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let p=0,f=n.length-1;p<=f;p++)d=p===f||this.charSpacing,u+=n[p],c=this.__charBounds[t][p],g===0?(e+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,r&&!d&&this._reSpaceAndTab.test(n[p])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,p),l=this.getCompleteStyleDeclaration(t,p+1),d=Wn(a,l,!0)),d&&(h=this._getStyleDeclaration(t,p),o.push(this._createTextCharSpan(u,h,e,i)),u="",a=l,this.direction==="rtl"?e-=g:e+=g,g=0)}_setSVGTextLineBg(o,t,e,i){const s=this._textLines[t],r=this.getHeightOfLine(t)/this.lineHeight;let n,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:g}=this.__charBounds[t][h];n=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),n!==c?(c&&o.push(...Ro(c,e+l,i,a,r)),l=d,a=u,c=n):a+=g}n&&o.push(...Ro(c,e+l,i,a,r))}_getSVGLineTopOffset(o){let t,e=0;for(t=0;t<o;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(o){return"".concat(super.getSvgStyles(o)," white-space: pre;")}getSvgSpanStyles(o,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:r,fontSize:n,fontStyle:a,fontWeight:l,deltaY:c}=o,h=this.getSvgTextDecoration(o);return[s?Hs(re,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",n?"font-size: ".concat(n,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",h&&"text-decoration: ".concat(h,"; "),r?Hs(Pt,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(o){return["overline","underline","line-through"].filter(t=>o[t.replace("-","")]).join(" ")}}]),P.setClass(qt),P.setSVGClass(qt);class pm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach(i=>i()),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 n=this.target,a=n.canvas,l=new x(n.flipX?-1:1,n.flipY?-1:1),c=n._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(n.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=n.getCanvasRetinaScaling(),g=n.getBoundingRect(),p=h.subtract(new x(g.left,g.top)),f=a.viewportTransform,b=p.add(d).transform(f,!0),m=n.backgroundColor,y=Vn(n.styles);n.backgroundColor="";const w={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};n.setSelectionStyles(w,0,s),n.setSelectionStyles(w,r,n.text.length),n.dirty=!0;const T=n.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});n.backgroundColor=m,n.styles=y,n.dirty=!0,gn(T,{position:"fixed",left:"".concat(-T.width,"px"),border:se,width:"".concat(T.width/u,"px"),height:"".concat(T.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{T.remove()},Ce(t.target||this.target.hiddenTextarea).body.appendChild(T),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(T,b.x,b.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),n=_({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}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}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{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=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(r&&!s){const n=this.target,a=n.canvas;let l=n.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=r[Math.max(0,r.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,g=this.__dragStartSelection.selectionEnd;l>u&&l<=g?l=u:l>g&&(l-=g-u),n.removeChars(u,g),delete this.__dragStartSelection}n._reNewline.test(h)&&(n._reNewline.test(n._text[l])||l===n._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=n,n.insertChars(r,c,l),a.setActiveObject(n),n.enterEditing(i),n.selectionStart=Math.min(l+d,n._text.length),n.selectionEnd=Math.min(n.selectionStart+r.length,n._text.length),n.hiddenTextarea.value=n.text,n._updateTextarea(),n.hiddenTextarea.focus(),n.fire(Rr,{index:l+d,action:"drop"}),a.fire("text:changed",{target:n}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,r=this.target.canvas,{selectionStart:n,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||se;l===se?(s.selectionStart=n,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(n,a),s.selectionStart=s.selectionEnd=n,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Rr,{index:n,action:"dragend"}),r.fire("text:changed",{target:s}),r.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const vl=/[ \n\.,;!\?\-]/;class gm extends qt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:r}=t;return Tc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:n=>{this._currentCursorOpacity=n,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}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])&&(e===-1||!Mn.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!vl.test(r);)s+=e,r=i[s];return e===-1&&vl.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;Ce(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 n=i.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(n).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,n=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-n,g=d-n,p=new x(e.left+a,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/d));return p.x<0&&(p.x=0),p.x>u&&(p.x=u),p.y<0&&(p.y=0),p.y>g&&(p.y=g),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:"".concat(p.x,"px"),top:"".concat(p.y,"px"),fontSize:"".concat(n,"px"),charHeight:n}}_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(zr),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:n}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[r])for(let a=n;a<this._unwrappedTextLines[r].length;a++){const l=this.styles[r][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-n]=l)}for(let a=i+1;a<=r;a++)delete this.styles[a];this.shiftLineStyles(r,i-r)}else if(this.styles[i]){const a=this.styles[i],l=n-s;for(let c=s;c<n;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=n&&(a[h-l]=a[c],delete a[c])}}}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={},n=this._unwrappedTextLines[t].length,a=n===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,r[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=r,h=!0),(h||n>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:_({},s[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],n=r?_({},r):{};i||(i=1);for(const l in n){const c=parseInt(l,10);c>=e&&(r[c+i]=n[c],n[c-i]||delete r[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},s[i]));return}if(!r)return;const a=r[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let n,a=0;for(let l=0;l<t.length;l++)t[l]===`
2670
- `?(a++,r[a]=0):r[a]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],a),n=1;n<a;n++)r[n]>0?this.insertCharStyleObject(s.lineIndex+n,0,r[n],i):i&&this.styles[s.lineIndex+n]&&i[0]&&(this.styles[s.lineIndex+n][0]=i[0]),i=i&&i.slice(r[n]+1);r[n]>0&&this.insertCharStyleObject(s.lineIndex+n,0,r[n],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?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=G:this._selectionDirection===mt&&(this._selectionDirection=G,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===mt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=mt:this._selectionDirection===G&&(this._selectionDirection=mt,this.selectionStart=e),this.selectionEnd=i)}}class fm extends gm{initHiddenTextarea(){const t=this.canvas&&Ce(this.canvas.getElement())||ns(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map(n=>{let[a,l]=n;return e.setAttribute(a,l)});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(n=>{let[a,l]=n;return e.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire(Rr),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,n=s.length,a=this.selectionStart,l=this.selectionEnd,c=a!==l;let h,d,u,g,p=n-r;const f=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),b=a>f.selectionStart;c?(d=this._text.slice(a,l),p+=l-a):n<r&&(d=b?this._text.slice(l+p,l):this._text.slice(a,a-p));const m=s.slice(f.selectionEnd-p,f.selectionEnd);if(d&&d.length&&(m.length&&(h=this.getSelectionStyles(a,a+1,!1),h=m.map(()=>h[0])),c?(u=a,g=l):b?(u=l-d.length,g=l):(u=l,g=l+d.length),this.removeStyleFromTo(u,g)),m.length){const{copyPasteData:y}=Be();e&&m.join("")===y.copiedText&&!U.disableStyleCopyPaste&&(h=y.copiedTextStyle),this.insertNewStyleBlock(m,a,h)}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}=Be();t.copiedText=this.getSelectedText(),U.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||t.keyCode===34)return this._text.length-i;const n=s.charIndex,a=this._getWidthBeforeCursor(r,n),l=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(n).length+l+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(r===0||t.metaKey||t.keyCode===33)return-i;const n=s.charIndex,a=this._getWidthBeforeCursor(r,n),l=this._getIndexOnLine(r-1,a),c=this._textLines[r].slice(0,n),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,n=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,n+=s,n>e){r=!0;const h=n-s,d=n,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return r||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===mt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=rs(0,this.selectionStart,s),this.selectionEnd=rs(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===G?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=G,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===mt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=G,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===G&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=mt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=mt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Ho=o=>!!o.button;class mm extends fm{constructor(){super(...arguments),v(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 pm(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),an(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}=t;this.canvas&&this.editable&&!Ho(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}=t;this.canvas&&this.editable&&!Ho(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const r=this.canvas._activeObject;if(r&&r!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Ho(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(Se(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),r=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let n=Math.abs(this._getLineLeftOffset(r));const a=this._textLines[r].length,l=this.__charBounds[r];for(let c=0;c<a;c++){const h=n+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-n)&&s++;break}n=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const lr="moveCursorUp",cr="moveCursorDown",hr="moveCursorLeft",dr="moveCursorRight",ur="exitEditing",bm=_({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:ur,27:ur,33:lr,34:cr,35:dr,36:hr,37:hr,38:lr,39:dr,40:cr},keysMapRtl:{9:ur,27:ur,33:lr,34:cr,35:hr,36:dr,37:dr,38:lr,39:hr,40:cr},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class qe extends mm{static getDefaults(){return _(_({},super.getDefaults()),qe.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},qe.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof qr&&this.canvas.textEditingManager.remove(this),e instanceof qr&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const 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&&arguments[0]!==void 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 c=0;c<r;c++)e+=this.getHeightOfLine(c);const n=this._getLineLeftOffset(r),a=this.__charBounds[r][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:n+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===mt||this.textAlign===Ie||this.textAlign===Ms?l.left*=-1:this.textAlign===G||this.textAlign===Kr?l.left=n-(i>0?i:0):this.textAlign!==H&&this.textAlign!==Is||(l.left=n-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,n=this.getValueOfPropertyAt(s,r,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,r,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-n*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:n}}_renderCursor(t,e,i){const{color:s,opacity:r,left:n,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,t.fillRect(n,a,l,c)}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,n=this.textAlign.includes(Ie),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(r),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let g=c;g<=h;g++){const p=this._getLineLeftOffset(g)||0;let f=this.getHeightOfLine(g),b=0,m=0,y=0;if(g===c&&(m=this.__charBounds[c][d].left),g>=c&&g<h)y=n&&!this.isEndOfWrapping(g)?this.width:this.getLineWidth(g)||5;else if(g===h)if(u===0)y=this.__charBounds[h][u].left;else{const E=this._getWidthOfCharSpacing();y=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-E}b=f,(this.lineHeight<1||g===h&&this.lineHeight>1)&&(f/=this.lineHeight);let w=i.left+p+m,T=f,k=0;const O=y-m;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",T=1,k=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===mt||this.textAlign===Ie||this.textAlign===Ms?w=this.width-w-O:this.textAlign===G||this.textAlign===Kr?w=i.left+p-y:this.textAlign!==H&&this.textAlign!==Is||(w=i.left+p-y)),t.fillRect(w,i.top+i.topOffset+k,O,T),i.topOffset+=b}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Pt)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(qe,"ownDefaults",bm),v(qe,"type","IText"),P.setClass(qe),P.setClass(qe,"i-text");class Ke extends qe{static getDefaults(){return _(_({},super.getDefaults()),Ke.ownDefaults)}constructor(t,e){super(t,_(_({},Ke.ownDefaults),e))}static createControls(){return{controls:Gg()}}initDimensions(){this.initialized&&(this.isEditing&&this.initDelayedCursor(),this._clearCache(),this.dynamicMinWidth=0,this._styleMap=this._generateStyleMap(this._splitText()),this.dynamicMinWidth>this.width&&this._set("width",this.dynamicMinWidth),this.textAlign.includes(Ie)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let n=0;n<t.graphemeLines.length;n++)t.graphemeText[s]===`
2671
- `&&n>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&n>0&&(i++,s++),r[n]={line:e,offset:i},s+=t.graphemeLines[n].length,i+=t.graphemeLines[n].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,r=!1;const n=this._styleMap[t],a=this._styleMap[t+1];n&&(t=n.line,i=n.offset),a&&(s=a.line,r=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!r||d<e))for(const u in l[c][h])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((r,n)=>{let a=0;const l=e?this.graphemeSplit(r):this.wordSplit(r);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,n,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}})}),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=0;for(let n=0,a=t.length;n<a;n++)r+=this._getGraphemeBox(t[n],e,n+s,i,!0).kernedWidth,i=t[n];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],g=0,p=0,f=!0;e-=n;const b=Math.max(e,s,this.dynamicMinWidth),m=r[t];let y;for(g=0,y=0;y<m.length;y++){const{word:w,width:T}=m[y];g+=w.length,d+=p+T-a,d>b&&!f?(c.push(u),u=[],d=T,f=!0):d+=a,f||l||u.push(h),u=u.concat(w),p=l?0:this._measureWord([h],t,g),g++,f=!1}return y&&c.push(u),s+n>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+n),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),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 s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(Ke,"type","Textbox"),v(Ke,"textLayoutProperties",[...qe.textLayoutProperties,"width"]),v(Ke,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),P.setClass(Ke);class _l extends fo{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:n,height:a}=Ze(Ic(i,s)),l=new x(n,a);if(s.absolutePositioned)return{center:ts(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:d=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(_l,"type","clip-path"),P.setClass(_l);class yl extends fo{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new x(i.width||s.x,i.height||s.y)}}v(yl,"type","fixed"),P.setClass(yl);class vm extends Vs{subscribeTargets(t){const e=t.target;t.targets.reduce((i,s)=>(s.parent&&i.add(s.parent),i),new Set).forEach(i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})})}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce((s,r)=>(r.parent&&s.add(r.parent),s),new Set).forEach(s=>{!i.some(r=>r.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})})}}class Ii extends gi{static getDefaults(){return _(_({},super.getDefaults()),Ii.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Ii.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:r??new vm})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(s=>{const r=this._objects.findIndex(a=>a.isInFrontOf(s)),n=r===-1?this.size():r;this.insertAt(n,s)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(bi("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(s=>{const{parent:r}=s;r&&i.add(r)}),t===Yn?i.forEach(s=>{s._onAfterObjectsChange(Gr,e)}):i.forEach(s=>{s._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=_(_({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()}}v(Ii,"type","ActiveSelection"),v(Ii,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),P.setClass(Ii),P.setClass(Ii,"activeSelection");class _m{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,r){const n=r.getContext("2d");if(!n)return;n.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:n.getImageData(0,0,i,s),originalEl:e,originalImageData:n.getImageData(0,0,i,s),canvasEl:r,ctx:n,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===i&&l.height===s||(r.width=l.width,r.height=l.height),n.putImageData(l,0,0),a}}class Qc{constructor(){let{tileSize:t=U.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=Re({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,n){const a=this.gl,l=r.getContext("2d");if(!a||!l)return;let c;n&&(c=this.getCachedTexture(n,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach(u=>{u&&u.applyTo(h)}),function(u){const g=u.targetCanvas,p=g.width,f=g.height,b=u.destinationWidth,m=u.destinationHeight;p===b&&f===m||(g.width=b,g.height=m)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,r){const{NEAREST:n,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:g,TEXTURE_WRAP_T:p}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,r||n),t.texParameteri(a,u,r||n),t.texParameteri(a,g,h),t.texParameteri(a,p,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}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 n=i.height-s.height;r.drawImage(i,0,n,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,n=s*r*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,n),l=new Uint8ClampedArray(this.imageBuffer,0,n);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,r);i.putImageData(c,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 No;function ym(){const{WebGLProbe:o}=Be();return o.queryWebGL(ke()),U.enableGLFiltering&&o.isSupported(U.textureSize)?new Qc({tileSize:U.textureSize}):new _m}function Vo(){return!No&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(No=ym()),No}const xm=["filters","resizeFilter","src","crossOrigin","type"],th=["cropX","cropY"];class Kt extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Kt.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Kt.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(vi()),this.setElement(typeof t=="string"?(this.canvas&&Ce(this.canvas.getElement())||ns()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(e),t.classList.add(Kt.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Vo(!1);e instanceof Qc&&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&&Be().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,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&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(i=>{i&&e.push(i.toObject())}),_(_({},super.toObject([...th,...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=[],n=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=vi();r.push('<clipPath id="imageCrop_'+c+`">
2666
+ `),i.join("")}toLive(t){const{x1:e,y1:i,x2:s,y2:r,r1:n,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,s,r):t.createRadialGradient(e,i,n,s,r,a);return this.colorStops.forEach(c=>{let{color:h,opacity:d,offset:u}=c;l.addColorStop(u,d!==void 0?new X(h).setAlpha(d).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map(s=>_({},s)):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const s=Uc(t),r=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:Vc(t),coords:Qf(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:Jf(t,i.opacity),gradientUnits:s,gradientTransform:dn(t.getAttribute("gradientTransform")||"")},s==="pixels"?{offsetX:e.width/2-r.x,offsetY:e.height/2-r.y}:{offsetX:0,offsetY:0}))}}v(nr,"type","Gradient"),P.setClass(nr,"gradient"),P.setClass(nr,"linear"),P.setClass(nr,"radial");const tm=["type","source","patternTransform"];class Bo{get type(){return"pattern"}set type(t){vi("warn","Setting type has no effect",t)}constructor(t){v(this,"repeat","repeat"),v(this,"offsetX",0),v(this,"offsetY",0),v(this,"crossOrigin",""),this.id=_i(),Object.assign(this,t)}isImageSource(){return!!this.source&&typeof this.source.src=="string"}isCanvasSource(){return!!this.source&&!!this.source.toDataURL}sourceToString(){return this.isImageSource()?this.source.src:this.isCanvasSource()?this.source.toDataURL():""}toLive(t){return this.source&&(!this.isImageSource()||this.source.complete&&this.source.naturalWidth!==0&&this.source.naturalHeight!==0)?t.createPattern(this.source,this.repeat):null}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const{repeat:e,crossOrigin:i}=this;return _(_({},hs(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:at(this.offsetX,U.NUM_FRACTION_DIGITS),offsetY:at(this.offsetY,U.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:s,repeat:r,id:n}=this,a=Zi(this.offsetX/e,0),l=Zi(this.offsetY/i,0),c=r==="repeat-y"||r==="no-repeat"?1+Math.abs(a||0):Zi(s.width/e,0),h=r==="repeat-x"||r==="no-repeat"?1+Math.abs(l||0):Zi(s.height/i,0);return['<pattern id="SVGID_'.concat(n,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(s.width,'" height="').concat(s.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
2667
+ `)}static async fromObject(t,e){let{type:i,source:s,patternTransform:r}=t,n=it(t,tm);const a=await Mr(s,_(_({},e),{},{crossOrigin:n.crossOrigin}));return new this(_(_({},n),{},{patternTransform:r&&r.slice(0),source:a}))}}v(Bo,"type","Pattern"),P.setClass(Bo),P.setClass(Bo,"pattern");const em=["path","left","top"],im=["d"];class Pi extends Nt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:s,top:r}=e,n=it(e,em);super(),Object.assign(this,Pi.ownDefaults),this.setOptions(n),this._setPath(t||[],!0),typeof s=="number"&&this.set(G,s),typeof r=="number"&&this.set(ie,r)}_setPath(t,e){this.path=Mf(Array.isArray(t)?t:Hf(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new x(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,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&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{path:this.path.map(e=>e.slice())})}toDatalessObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.toObject(t);return this.sourcePath&&(delete e.path,e.sourcePath=this.sourcePath),e}_toSVG(){const t=Nf(this.path,U.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
2668
+ `)]}_getOffsetTransform(){const t=U.NUM_FRACTION_DIGITS;return" translate(".concat(at(-this.pathOffset.x,t),", ").concat(at(-this.pathOffset.y,t),")")}toClipPathSVG(t){const e=this._getOffsetTransform();return" "+this._createBaseClipPathSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}toSVG(t){const e=this._getOffsetTransform();return this._createBaseSVGMarkup(this._toSVG(),{reviver:t,additionalTransform:e})}complexity(){return this.path.length}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{width:e,height:i,pathOffset:s}=this._calcDimensions();this.set({width:e,height:i,pathOffset:s}),t&&this.setPositionByOrigin(s,N,N)}_calcBoundsFromPath(){const t=[];let e=0,i=0,s=0,r=0;for(const n of this.path)switch(n[0]){case"L":s=n[1],r=n[2],t.push({x:e,y:i},{x:s,y:r});break;case"M":s=n[1],r=n[2],e=s,i=r;break;case"C":t.push(...fl(s,r,n[1],n[2],n[3],n[4],n[5],n[6])),s=n[5],r=n[6];break;case"Q":t.push(...fl(s,r,n[1],n[2],n[1],n[2],n[3],n[4])),s=n[3],r=n[4];break;case"Z":s=e,r=i}return Qe(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new x(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{d:r}=s;return new this(r,_(_(_({},it(s,im)),e),{},{left:void 0,top:void 0}))}}v(Pi,"type","Path"),v(Pi,"cacheProperties",[...oi,"path","fillRule"]),v(Pi,"ATTRIBUTE_NAMES",[...Ci,"d"]),P.setClass(Pi),P.setSVGClass(Pi);const sm=["left","top","radius"],Wc=["radius","startAngle","endAngle","counterClockwise"];class Xe extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Xe.ownDefaults)}constructor(t){super(),Object.assign(this,Xe.ownDefaults),this.setOptions(t)}_set(t,e){return super._set(t,e),t==="radius"&&this.setRadius(e),this}_render(t){t.beginPath(),t.arc(0,0,this.radius,vt(this.startAngle),vt(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(ne)}getRadiusY(){return this.get("radius")*this.get(ye)}setRadius(t){this.radius=t,this.set({width:2*t,height:2*t})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Wc,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
2669
+ `];{const{radius:e}=this,i=vt(this.startAngle),s=vt(this.endAngle),r=ii(i)*e,n=si(i)*e,a=ii(s)*e,l=si(s)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(r," ").concat(n," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
2670
+ `]}}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{left:r=0,top:n=0,radius:a=0}=s;return new this(_(_({},it(s,sm)),{},{radius:a,left:r-a,top:n-a}))}static fromObject(t){return super._fromObject(t)}}v(Xe,"type","Circle"),v(Xe,"cacheProperties",[...oi,...Wc]),v(Xe,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),v(Xe,"ATTRIBUTE_NAMES",["cx","cy","r",...Ci]),P.setClass(Xe),P.setSVGClass(Xe);const rm=["x1","y1","x2","y2"],om=["x1","y1","x2","y2"],fn=["x1","x2","y1","y2"];class Di extends Nt{constructor(){let[t,e,i,s]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Di.ownDefaults),this.setOptions(r),this.x1=t,this.x2=i,this.y1=e,this.y2=s,this._setWidthHeight();const{left:n,top:a}=r;typeof n=="number"&&this.set(G,n),typeof a=="number"&&this.set(ie,a)}_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:n,width:a,height:l}=Qe([{x:t,y:e},{x:i,y:s}]),c=new x(r+a/2,n+l/2);this.setPositionByOrigin(c,N,N)}_set(t,e){return super._set(t,e),fn.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;ve(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(s=this.stroke)!==null&&s!==void 0?s:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new x((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:s,width:r,height:n}=this,a=t<=e?-1:1,l=i<=s?-1:1;return{x1:a*r/2,x2:a*-r/2,y1:l*n/2,y2:l*-n/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,`" />
2671
+ `)]}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i),{x1:r=0,y1:n=0,x2:a=0,y2:l=0}=s;return new this([r,n,a,l],it(s,rm))}static fromObject(t){let{x1:e,y1:i,x2:s,y2:r}=t,n=it(t,om);return this._fromObject(_(_({},n),{},{points:[e,i,s,r]}),{extraParam:"points"})}}v(Di,"type","Line"),v(Di,"cacheProperties",[...oi,...fn]),v(Di,"ATTRIBUTE_NAMES",Ci.concat(fn)),P.setClass(Di),P.setSVGClass(Di);class Ii extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Ii.ownDefaults)}constructor(t){super(),Object.assign(this,Ii.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),'" />']}}v(Ii,"type","Triangle"),v(Ii,"ownDefaults",{width:100,height:100}),P.setClass(Ii),P.setSVGClass(Ii);const Gc=["rx","ry"];class qe extends Nt{static getDefaults(){return _(_({},super.getDefaults()),qe.ownDefaults)}constructor(t){super(),Object.assign(this,qe.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(ne)}getRy(){return this.get("ry")*this.get(ye)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Gc,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
2672
+ `)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,Br,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const s=ni(t,this.ATTRIBUTE_NAMES,i);return s.left=(s.left||0)-s.rx,s.top=(s.top||0)-s.ry,new this(s)}}function nm(o){if(!o)return[];const t=o.replace(/,/g," ").trim().split(/\s+/),e=[];for(let i=0;i<t.length;i+=2)e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])});return e}v(qe,"type","Ellipse"),v(qe,"cacheProperties",[...oi,...Gc]),v(qe,"ownDefaults",{rx:0,ry:0}),v(qe,"ATTRIBUTE_NAMES",[...Ci,"cx","cy","rx","ry"]),P.setClass(qe),P.setSVGClass(qe);const am=["left","top"],Yc={exactBoundingBox:!1};class Ce extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Ce.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),v(this,"strokeDiff",void 0),Object.assign(this,Ce.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:s}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(G,i),typeof s=="number"&&this.set(ie,s)}isOpen(){return!0}_projectStrokeOnPoints(t){return qg(this.points,t,this.isOpen())}_calcDimensions(t){t=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(c=>c.projectedPoint):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new x,strokeOffset:new x,strokeDiff:new x};const i=Qe(e),s=co(_(_({},t),{},{scaleX:1,scaleY:1})),r=Qe(this.points.map(c=>ee(c,s,!0))),n=new x(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(vt(this.skewX)),l-=a*Math.tan(vt(this.skewY))),_(_({},i),{},{pathOffset:new x(a,l),strokeOffset:new x(r.left,r.top).subtract(new x(i.left,i.top)).multiply(n),strokeDiff:new x(i.width,i.height).subtract(new x(r.width,r.height)).multiply(n)})}_findCenterFromElement(){const t=Qe(this.points);return new x(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:n,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:s,height:r,pathOffset:n,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new x(e+s/2,i+r/2),N,N)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new x(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let n;if(Object.keys(t).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var e,i;const{width:a,height:l}=this._calcDimensions(t);n=new x((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var s,r;n=new x((s=t.width)!==null&&s!==void 0?s:this.width,(r=t.height)!==null&&r!==void 0?r:this.height)}return n.multiply(new x(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===ne||t===ye)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),s}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),{},{points:this.points.map(e=>{let{x:i,y:s}=e;return{x:i,y:s}})})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,s=U.NUM_FRACTION_DIGITS;for(let r=0,n=this.points.length;r<n;r++)t.push(at(this.points[r].x-e,s),",",at(this.points[r].y-i,s)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
2673
+ `)]}_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 n=this.points[r];t.lineTo(n.x-i,n.y-s)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(nm(t.getAttribute("points")),_(_({},it(ni(t,this.ATTRIBUTE_NAMES,i),am)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}v(Ce,"ownDefaults",Yc),v(Ce,"type","Polyline"),v(Ce,"layoutProperties",[ls,cs,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),v(Ce,"cacheProperties",[...oi,"points"]),v(Ce,"ATTRIBUTE_NAMES",[...Ci]),P.setClass(Ce),P.setSVGClass(Ce);class ar extends Ce{isOpen(){return!1}}v(ar,"ownDefaults",Yc),v(ar,"type","Polygon"),P.setClass(ar),P.setSVGClass(ar);const Xc=["fontSize","fontWeight","fontFamily","fontStyle"],qc=["underline","overline","linethrough"],Kc=[...Xc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],Zc=[...Kc,...qc,"textBackgroundColor","direction"],lm=[...Xc,...qc,re,"strokeWidth",Ot,"deltaY","textBackgroundColor"],cm={_reNewline:Mn,_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:G,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:G,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},Le="justify",Kr="justify-left",Is="justify-right",Ls="justify-center";class Jc extends Nt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const s in e[i])for(const r in e[i][s])return!1;return!0}styleHas(t,e){if(!this.styles||e!==void 0&&!this.styles[e])return!1;const i=e===void 0?this.styles:{0:this.styles[e]};for(const s in i)for(const r in i[s])if(i[s][r][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,s,r=0,n=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};r++,h[t]!==void 0?(s?h[t]!==s&&(n=!1):s=h[t],h[t]===this[t]&&delete h[t]):n=!1,Object.keys(h).length!==0?i++:delete e[l][c]}i===0&&delete e[l]}for(let l=0;l<this._textLines.length;l++)a+=this._textLines[l].length;n&&r===a&&(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],Object.keys(i[r]).length===0&&delete i[r];Object.keys(i).length===0&&delete e[s]}}_extendStyles(t,e){const{lineIndex:i,charIndex:s}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const r=$n(_(_({},this._getStyleDeclaration(i,s)),e),n=>n!==void 0);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&&(i=s[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return _(_({},hs(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]}}v(Jc,"_styleProperties",lm);const hm=/ +/g,dm=/"/g;function Ro(o,t,e,i,s){return" ".concat(function(r,n){let{left:a,top:l,width:c,height:h}=n,d=arguments.length>2&&arguments[2]!==void 0?arguments[2]:U.NUM_FRACTION_DIGITS;const u=Ns(Ot,r,!1),[g,p,f,b]=[a,l,c,h].map(m=>at(m,d));return"<rect ".concat(u,' x="').concat(g,'" y="').concat(p,'" width="').concat(f,'" height="').concat(b,'"></rect>')}(o,{left:t,top:e,width:i,height:s}),`
2674
+ `)}const um=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let zo;class qt extends Jc{static getDefaults(){return _(_({},super.getDefaults()),qt.ownDefaults)}constructor(t,e){super(),v(this,"__charBounds",[]),Object.assign(this,qt.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=Rc(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(Le)&&this.enlargeSpaces()}enlargeSpaces(){let t,e,i,s,r,n,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Le||l!==c-1&&!this.isEndOfWrapping(l))&&(s=0,r=this._textLines[l],e=this.getLineWidth(l),e<this.width&&(a=this.textLines[l].match(this._reSpacesAndTabs)))){i=a.length,t=(this.width-e)/i;for(let h=0;h<=r.length;h++)n=this.__charBounds[l][h],this._reSpaceAndTab.test(r[h])?(n.width+=t,n.kernedWidth+=t,n.left+=s,s+=t):n.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===re?(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 N:t.textBaseline="middle";break;case"ascender":t.textBaseline=ie;break;case"descender":t.textBaseline=rn}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const s=this.getLineWidth(e);s>t&&(t=s)}return t}_renderTextLine(t,e,i,s,r,n){this._renderChars(t,e,i,s,r,n)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let s=this._getTopOffset();for(let r=0,n=this._textLines.length;r<n;r++){const a=this.getHeightOfLine(r);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",r)){s+=a;continue}const l=this._textLines[r].length,c=this._getLineLeftOffset(r);let h,d,u=0,g=0,p=this.getValueOfPropertyAt(r,0,"textBackgroundColor");for(let f=0;f<l;f++){const b=this.__charBounds[r][f];d=this.getValueOfPropertyAt(r,f,"textBackgroundColor"),this.path?(t.save(),t.translate(b.renderLeft,b.renderTop),t.rotate(b.angle),t.fillStyle=d,d&&t.fillRect(-b.width/2,-a/this.lineHeight*(1-this._fontSizeFraction),b.width,a/this.lineHeight),t.restore()):d!==p?(h=i+c+g,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=p,p&&t.fillRect(h,s,u,a/this.lineHeight),g=b.left,u=b.width,p=d):u+=b.kernedWidth}d&&!this.path&&(h=i+c+g,this.direction==="rtl"&&(h=this.width-h-u),t.fillStyle=d,t.fillRect(h,s,u,a/this.lineHeight)),s+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,s){const r=As.getFontCache(e),n=this._getFontDeclaration(e),a=i+t,l=i&&n===this._getFontDeclaration(s),c=e.fontSize/this.CACHE_FONT_SIZE;let h,d,u,g;if(i&&r[i]!==void 0&&(u=r[i]),r[t]!==void 0&&(g=h=r[t]),l&&r[a]!==void 0&&(d=r[a],g=d-u),h===void 0||u===void 0||d===void 0){const p=function(){return zo||(zo=ze({width:0,height:0}).getContext("2d")),zo}();this._setTextStyles(p,e,!0),h===void 0&&(g=h=p.measureText(t).width,r[t]=h),u===void 0&&l&&i&&(u=p.measureText(i).width,r[i]=u),l&&d===void 0&&(d=p.measureText(a).width,r[a]=d,g=d-u)}return{width:h*c,kernedWidth:g*c}}getHeightOfChar(t,e){return this.getValueOfPropertyAt(t,e,"fontSize")}measureLine(t){const e=this._measureLine(t);return this.charSpacing!==0&&(e.width-=this._getWidthOfCharSpacing()),e.width<0&&(e.width=0),e}_measureLine(t){let e,i,s=0;const r=this.pathSide===bt,n=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const d=a[h];i=this._getGraphemeBox(d,t,h,e),c[h]=i,s+=i.kernedWidth,e=d}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},n&&n.segmentsInfo){let h=0;const d=n.segmentsInfo[n.segmentsInfo.length-1].length;switch(this.textAlign){case G:h=r?d-s:0;break;case N:h=(d-s)/2;break;case bt:h=r?0:d-s}h+=this.pathStartOffset*(r?-1:1);for(let u=r?l-1:0;r?u>=0:u<l;r?u--:u++)i=c[u],h>d?h%=d:h<0&&(h+=d),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:s,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,s=this.path,r=$f(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===bt?Math.PI:0)}_getGraphemeBox(t,e,i,s,r){const n=this.getCompleteStyleDeclaration(e,i),a=s?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,n,s,a);let c,h=l.kernedWidth,d=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),d+=c,h+=c);const u={width:d,left:0,height:n.fontSize,kernedWidth:h,deltaY:n.deltaY};if(i>0&&!r){const g=this.__charBounds[e][i-1];u.left=g.left+g.width+l.kernedWidth-l.width}return u}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 this.direction==="ltr"?-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 n=0,a=this._textLines.length;n<a;n++){const l=this.getHeightOfLine(n),c=l/this.lineHeight,h=this._getLineLeftOffset(n);this._renderTextLine(e,t,this._textLines[n],s+h,r+i+c,n),i+=l}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(Ot))&&this._renderTextCommon(t,"fillText")}_renderTextStroke(t){(this.stroke&&this.strokeWidth!==0||!this.isEmptyStyles())&&(this.shadow&&!this.shadow.affectStroke&&this._removeShadow(t),t.save(),this._setLineDash(t,this.strokeDashArray),t.beginPath(),this._renderTextCommon(t,"strokeText"),t.closePath(),t.restore())}_renderChars(t,e,i,s,r,n){const a=this.getHeightOfLine(n),l=this.textAlign.includes(Le),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(n)&&!c,d=this.direction==="ltr",u=this.direction==="ltr"?1:-1,g=e.direction;let p,f,b,m,y,w="",T=0;if(e.save(),g!==this.direction&&(e.canvas.setAttribute("dir",d?"ltr":"rtl"),e.direction=d?"ltr":"rtl",e.textAlign=d?G:bt),r-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,n,0,i.join(""),s,r),void e.restore();for(let k=0,O=i.length-1;k<=O;k++)m=k===O||this.charSpacing||c,w+=i[k],b=this.__charBounds[n][k],T===0?(s+=u*(b.kernedWidth-b.width),T+=b.width):T+=b.kernedWidth,l&&!m&&this._reSpaceAndTab.test(i[k])&&(m=!0),m||(p=p||this.getCompleteStyleDeclaration(n,k),f=this.getCompleteStyleDeclaration(n,k+1),m=Wn(p,f,!1)),m&&(c?(e.save(),e.translate(b.renderLeft,b.renderTop),e.rotate(b.angle),this._renderChar(t,e,n,k,w,-T/2,0),e.restore()):(y=s,this._renderChar(t,e,n,k,w,y,r)),w="",p=f,s+=u*T,T=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,s=ze({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 ve(i)?i.gradientUnits==="percentage"||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,n,a){const l=this._getStyleDeclaration(i,s),c=this.getCompleteStyleDeclaration(i,s),h=t==="fillText"&&c.fill,d=t==="strokeText"&&c.stroke&&c.strokeWidth;if(d||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const u=this._setFillStyles(e,c);e.fillText(r,n-u.offsetX,a-u.offsetY)}if(d){const u=this._setStrokeStyles(e,c);e.strokeText(r,n-u.offsetX,a-u.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"),n=this.getValueOfPropertyAt(s.lineIndex,s.charIndex,"deltaY"),a={fontSize:r*i.size,deltaY:n+r*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,s=this.textAlign,r=this.direction,n=this.isEndOfWrapping(t);let a=0;return s===Le||s===Ls&&!n||s===Is&&!n||s===Kr&&!n?0:(s===N&&(a=i/2),s===bt&&(a=i),s===Ls&&(a=i/2),s===Is&&(a=i),r==="rtl"&&(s===bt||s===Le||s===Is?a=0:s===G||s===Kr?a=-i:s!==N&&s!==Ls||(a=-i/2)),a)}_clearCache(){this._forceClearCache=!1,this.__lineWidths=[],this.__lineHeights=[],this.__charBounds=[]}getLineWidth(t){if(this.__lineWidths[t]!==void 0)return this.__lineWidths[t];const{width:e}=this.measureLine(t);return this.__lineWidths[t]=e,e}_getWidthOfCharSpacing(){return this.charSpacing!==0?this.fontSize*this.charSpacing/1e3:0}getValueOfPropertyAt(t,e,i){var s;return(s=this._getStyleDeclaration(t,e)[i])!==null&&s!==void 0?s:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const s=this._getLeftOffset(),r=this.path,n=this._getWidthOfCharSpacing(),a=this.offsets[e];for(let l=0,c=this._textLines.length;l<c;l++){const h=this.getHeightOfLine(l);if(!this[e]&&!this.styleHas(e,l)){i+=h;continue}const d=this._textLines[l],u=h/this.lineHeight,g=this._getLineLeftOffset(l);let p,f,b=0,m=0,y=this.getValueOfPropertyAt(l,0,e),w=this.getValueOfPropertyAt(l,0,Ot);const T=i+u*(1-this._fontSizeFraction);let k=this.getHeightOfChar(l,0),O=this.getValueOfPropertyAt(l,0,"deltaY");for(let S=0,D=d.length;S<D;S++){const I=this.__charBounds[l][S];p=this.getValueOfPropertyAt(l,S,e),f=this.getValueOfPropertyAt(l,S,Ot);const M=this.getHeightOfChar(l,S),B=this.getValueOfPropertyAt(l,S,"deltaY");if(r&&p&&f)t.save(),t.fillStyle=w,t.translate(I.renderLeft,I.renderTop),t.rotate(I.angle),t.fillRect(-I.kernedWidth/2,a*M+B,I.kernedWidth,this.fontSize/15),t.restore();else if((p!==y||f!==w||M!==k||B!==O)&&m>0){let R=s+g+b;this.direction==="rtl"&&(R=this.width-R-m),y&&w&&(t.fillStyle=w,t.fillRect(R,T+a*k+O,m,this.fontSize/15)),b=I.left,m=I.width,y=p,w=f,k=M,O=B}else m+=I.kernedWidth}let E=s+g+b;this.direction==="rtl"&&(E=this.width-E-m),t.fillStyle=f,p&&f&&t.fillRect(E,T+a*k+O,m-n,this.fontSize/15),i+=h}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:s=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;const n=t.includes("'")||t.includes('"')||t.includes(",")||qt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(r?this.CACHE_FONT_SIZE:s,"px"),n].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return Un(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),s=[`
2675
+ `];let r=[];for(let n=0;n<e.length;n++)i[n]=this.graphemeSplit(e[n]),r=r.concat(i[n],s);return r.pop(),{_unwrappedLines:i,lines:e,graphemeText:r,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject([...Zc,...t])),{},{styles:Jg(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(typeof t=="object")for(const n in t)n==="path"&&this.setPathInfo(),s=s||i.includes(n),r=r||n==="path";else s=i.includes(t),r=t==="path";return r&&this.setPathInfo(),s&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const s=ni(t,qt.ATTRIBUTE_NAMES,i),r=_(_({},e),s),{textAnchor:n=G,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:d=0,fontSize:u=An,strokeWidth:g=1}=r,p=it(r,um),f=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),_({left:d+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:u},p)),b=f.getScaledHeight()/f.height,m=((f.height+f.strokeWidth)*f.lineHeight-f.height)*b,y=f.getScaledHeight()+m;let w=0;return n===N&&(w=f.getScaledWidth()/2),n===bt&&(w=f.getScaledWidth()),f.set({left:f.left-w,top:f.top-(y-f.fontSize*(.07+f._fontSizeFraction))/f.lineHeight,strokeWidth:g}),f}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Qg(t.styles||{},t.text)}),{extraParam:"text"})}}v(qt,"textLayoutProperties",Kc),v(qt,"cacheProperties",[...oi,...Zc]),v(qt,"ownDefaults",cm),v(qt,"type","Text"),v(qt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),v(qt,"ATTRIBUTE_NAMES",Ci.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Dc(qt,[class extends xc{_toSVG(){const o=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(o.textTop,o.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(o){return this._createBaseSVGMarkup(this._toSVG(),{reviver:o,noStyle:!0,withShadow:!0})}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(o){let{textBgRects:t,textSpans:e}=o;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'.concat(this.fontFamily.replace(dm,"'"),'" '):"",this.fontSize?'font-size="'.concat(this.fontSize,'" '):"",this.fontStyle?'font-style="'.concat(this.fontStyle,'" '):"",this.fontWeight?'font-weight="'.concat(this.fontWeight,'" '):"",i?'text-decoration="'.concat(i,'" '):"",this.direction==="rtl"?'direction="'.concat(this.direction,'" '):"",'style="',this.getSvgStyles(!0),'"',this.addPaintOrder()," >",e.join(""),`</text>
2676
+ `]}_getSVGTextAndBg(o,t){const e=[],i=[];let s,r=o;this.backgroundColor&&i.push(...Ro(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let n=0,a=this._textLines.length;n<a;n++)s=this._getLineLeftOffset(n),this.direction==="rtl"&&(s+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",n))&&this._setSVGTextLineBg(i,n,t+s,r),this._setSVGTextLineText(e,n,t+s,r),r+=this.getHeightOfLine(n);return{textSpans:e,textBgRects:i}}_createTextCharSpan(o,t,e,i){const s=this.getSvgSpanStyles(t,o!==o.trim()||!!o.match(hm)),r=s?'style="'.concat(s,'"'):"",n=t.deltaY,a=n?' dy="'.concat(at(n,U.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(at(e,U.NUM_FRACTION_DIGITS),'" y="').concat(at(i,U.NUM_FRACTION_DIGITS),'" ').concat(a).concat(r,">").concat(Kg(o),"</tspan>")}_setSVGTextLineText(o,t,e,i){const s=this.getHeightOfLine(t),r=this.textAlign.includes(Le),n=this._textLines[t];let a,l,c,h,d,u="",g=0;i+=s*(1-this._fontSizeFraction)/this.lineHeight;for(let p=0,f=n.length-1;p<=f;p++)d=p===f||this.charSpacing,u+=n[p],c=this.__charBounds[t][p],g===0?(e+=c.kernedWidth-c.width,g+=c.width):g+=c.kernedWidth,r&&!d&&this._reSpaceAndTab.test(n[p])&&(d=!0),d||(a=a||this.getCompleteStyleDeclaration(t,p),l=this.getCompleteStyleDeclaration(t,p+1),d=Wn(a,l,!0)),d&&(h=this._getStyleDeclaration(t,p),o.push(this._createTextCharSpan(u,h,e,i)),u="",a=l,this.direction==="rtl"?e-=g:e+=g,g=0)}_setSVGTextLineBg(o,t,e,i){const s=this._textLines[t],r=this.getHeightOfLine(t)/this.lineHeight;let n,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<s.length;h++){const{left:d,width:u,kernedWidth:g}=this.__charBounds[t][h];n=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),n!==c?(c&&o.push(...Ro(c,e+l,i,a,r)),l=d,a=u,c=n):a+=g}n&&o.push(...Ro(c,e+l,i,a,r))}_getSVGLineTopOffset(o){let t,e=0;for(t=0;t<o;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(o){return"".concat(super.getSvgStyles(o)," white-space: pre;")}getSvgSpanStyles(o,t){const{fontFamily:e,strokeWidth:i,stroke:s,fill:r,fontSize:n,fontStyle:a,fontWeight:l,deltaY:c}=o,h=this.getSvgTextDecoration(o);return[s?Ns(re,s):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",n?"font-size: ".concat(n,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",h&&"text-decoration: ".concat(h,"; "),r?Ns(Ot,r):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(o){return["overline","underline","line-through"].filter(t=>o[t.replace("-","")]).join(" ")}}]),P.setClass(qt),P.setSVGClass(qt);class pm{constructor(t){v(this,"target",void 0),v(this,"__mouseDownInPlace",!1),v(this,"__dragStartFired",!1),v(this,"__isDraggingOver",!1),v(this,"__dragStartSelection",void 0),v(this,"__dragImageDisposer",void 0),v(this,"_dispose",void 0),this.target=t;const e=[this.target.on("dragenter",this.dragEnterHandler.bind(this)),this.target.on("dragover",this.dragOverHandler.bind(this)),this.target.on("dragleave",this.dragLeaveHandler.bind(this)),this.target.on("dragend",this.dragEndHandler.bind(this)),this.target.on("drop",this.dropHandler.bind(this))];this._dispose=()=>{e.forEach(i=>i()),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 n=this.target,a=n.canvas,l=new x(n.flipX?-1:1,n.flipY?-1:1),c=n._getCursorBoundaries(s),h=new x(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(n.calcTransformMatrix()),d=a.getScenePoint(t).subtract(h),u=n.getCanvasRetinaScaling(),g=n.getBoundingRect(),p=h.subtract(new x(g.left,g.top)),f=a.viewportTransform,b=p.add(d).transform(f,!0),m=n.backgroundColor,y=Vn(n.styles);n.backgroundColor="";const w={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};n.setSelectionStyles(w,0,s),n.setSelectionStyles(w,r,n.text.length),n.dirty=!0;const T=n.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});n.backgroundColor=m,n.styles=y,n.dirty=!0,gn(T,{position:"fixed",left:"".concat(-T.width,"px"),border:se,width:"".concat(T.width/u,"px"),height:"".concat(T.height/u,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{T.remove()},Se(t.target||this.target.hiddenTextarea).body.appendChild(T),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(T,b.x,b.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const s=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},r=e._text.slice(s.selectionStart,s.selectionEnd).join(""),n=_({text:e.text,value:r},s);t.dataTransfer.setData("text/plain",r),t.dataTransfer.setData("application/fabric",JSON.stringify({value:r,styles:e.getSelectionStyles(s.selectionStart,s.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,n)}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}=t;const i=this.targetCanDrop(e);!this.__isDraggingOver&&i&&(this.__isDraggingOver=!0)}dragOverHandler(t){const{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=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(r&&!s){const n=this.target,a=n.canvas;let l=n.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=r[Math.max(0,r.length-1)],d=0;if(this.__dragStartSelection){const u=this.__dragStartSelection.selectionStart,g=this.__dragStartSelection.selectionEnd;l>u&&l<=g?l=u:l>g&&(l-=g-u),n.removeChars(u,g),delete this.__dragStartSelection}n._reNewline.test(h)&&(n._reNewline.test(n._text[l])||l===n._text.length)&&(r=r.trimEnd()),t.didDrop=!0,t.dropTarget=n,n.insertChars(r,c,l),a.setActiveObject(n),n.enterEditing(i),n.selectionStart=Math.min(l+d,n._text.length),n.selectionEnd=Math.min(n.selectionStart+r.length,n._text.length),n.hiddenTextarea.value=n.text,n._updateTextarea(),n.hiddenTextarea.focus(),n.fire(Rr,{index:l+d,action:"drop"}),a.fire("text:changed",{target:n}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const s=this.target,r=this.target.canvas,{selectionStart:n,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||se;l===se?(s.selectionStart=n,s.selectionEnd=a,s._updateTextarea(),s.hiddenTextarea.focus()):(s.clearContextTop(),l==="move"&&(s.removeChars(n,a),s.selectionStart=s.selectionEnd=n,s.hiddenTextarea&&(s.hiddenTextarea.value=s.text),s._updateTextarea(),s.fire(Rr,{index:n,action:"dragend"}),r.fire("text:changed",{target:s}),r.requestRenderAll()),s.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const vl=/[ \n\.,;!\?\-]/;class gm extends qt{constructor(){super(...arguments),v(this,"_currentCursorOpacity",1)}initBehavior(){this._tick=this._tick.bind(this),this._onTickComplete=this._onTickComplete.bind(this),this.updateSelectionOnMouseMove=this.updateSelectionOnMouseMove.bind(this)}onDeselect(t){return this.isEditing&&this.exitEditing(),this.selected=!1,super.onDeselect(t)}_animateCursor(t){let{toValue:e,duration:i,delay:s,onComplete:r}=t;return Tc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:s,onComplete:r,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:n=>{this._currentCursorOpacity=n,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}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])&&(e===-1||!Mn.test(i[t-1]))?t-1:t,r=i[s];for(;s>0&&s<i.length&&!vl.test(r);)s+=e,r=i[s];return e===-1&&vl.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;Se(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 n=i.slice(t,e);return{selectionStart:r,selectionEnd:r+this.graphemeSplit(n).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,n=this.getValueOfPropertyAt(s,r,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,d=c.height/l,u=h-n,g=d-n,p=new x(e.left+a,e.top+e.topOffset+n).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new x(c.clientWidth/h,c.clientHeight/d));return p.x<0&&(p.x=0),p.x>u&&(p.x=u),p.y<0&&(p.y=0),p.y>g&&(p.y=g),p.x+=this.canvas._offset.left,p.y+=this.canvas._offset.top,{left:"".concat(p.x,"px"),top:"".concat(p.y,"px"),fontSize:"".concat(n,"px"),charHeight:n}}_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(zr),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:n}=this.get2DCursorLocation(e,!0);if(i!==r){if(this.styles[i])for(let a=s;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[r])for(let a=n;a<this._unwrappedTextLines[r].length;a++){const l=this.styles[r][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][s+a-n]=l)}for(let a=i+1;a<=r;a++)delete this.styles[a];this.shiftLineStyles(r,i-r)}else if(this.styles[i]){const a=this.styles[i],l=n-s;for(let c=s;c<n;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=n&&(a[h-l]=a[c],delete a[c])}}}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={},n=this._unwrappedTextLines[t].length,a=n===e;let l=!1;i||(i=1),this.shiftLineStyles(t,i);const c=this.styles[t]?this.styles[t][e===0?e:e-1]:void 0;for(const d in this.styles[t]){const u=parseInt(d,10);u>=e&&(l=!0,r[u-e]=this.styles[t][d],a&&e===0||delete this.styles[t][d])}let h=!1;for(l&&!a&&(this.styles[t+i]=r,h=!0),(h||n>e)&&i--;i>0;)s&&s[i-1]?this.styles[t+i]={0:_({},s[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,s){this.styles||(this.styles={});const r=this.styles[t],n=r?_({},r):{};i||(i=1);for(const l in n){const c=parseInt(l,10);c>=e&&(r[c+i]=n[c],n[c-i]||delete r[c])}if(this._forceClearCache=!0,s){for(;i--;)Object.keys(s[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},s[i]));return}if(!r)return;const a=r[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const s=this.get2DCursorLocation(e,!0),r=[0];let n,a=0;for(let l=0;l<t.length;l++)t[l]===`
2677
+ `?(a++,r[a]=0):r[a]++;for(r[0]>0&&(this.insertCharStyleObject(s.lineIndex,s.charIndex,r[0],i),i=i&&i.slice(r[0]+1)),a&&this.insertNewlineStyleObject(s.lineIndex,s.charIndex+r[0],a),n=1;n<a;n++)r[n]>0?this.insertCharStyleObject(s.lineIndex+n,0,r[n],i):i&&this.styles[s.lineIndex+n]&&i[0]&&(this.styles[s.lineIndex+n][0]=i[0]),i=i&&i.slice(r[n]+1);r[n]>0&&this.insertCharStyleObject(s.lineIndex+n,0,r[n],i)}removeChars(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t+1;this.removeStyleFromTo(t,e),this._text.splice(t,e-t),this.text=this._text.join(""),this.set("dirty",!0),this.initDimensions(),this.setCoords(),this._removeExtraneousStyles()}insertChars(t,e,i){let s=arguments.length>3&&arguments[3]!==void 0?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=G:this._selectionDirection===bt&&(this._selectionDirection=G,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===bt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=bt:this._selectionDirection===G&&(this._selectionDirection=bt,this.selectionStart=e),this.selectionEnd=i)}}class fm extends gm{initHiddenTextarea(){const t=this.canvas&&Se(this.canvas.getElement())||as(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map(n=>{let[a,l]=n;return e.setAttribute(a,l)});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(n=>{let[a,l]=n;return e.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire(Rr),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,n=s.length,a=this.selectionStart,l=this.selectionEnd,c=a!==l;let h,d,u,g,p=n-r;const f=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),b=a>f.selectionStart;c?(d=this._text.slice(a,l),p+=l-a):n<r&&(d=b?this._text.slice(l+p,l):this._text.slice(a,a-p));const m=s.slice(f.selectionEnd-p,f.selectionEnd);if(d&&d.length&&(m.length&&(h=this.getSelectionStyles(a,a+1,!1),h=m.map(()=>h[0])),c?(u=a,g=l):b?(u=l-d.length,g=l):(u=l,g=l+d.length),this.removeStyleFromTo(u,g)),m.length){const{copyPasteData:y}=Re();e&&m.join("")===y.copiedText&&!U.disableStyleCopyPaste&&(h=y.copiedTextStyle),this.insertNewStyleBlock(m,a,h)}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}=Re();t.copiedText=this.getSelectedText(),U.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||t.keyCode===34)return this._text.length-i;const n=s.charIndex,a=this._getWidthBeforeCursor(r,n),l=this._getIndexOnLine(r+1,a);return this._textLines[r].slice(n).length+l+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(r===0||t.metaKey||t.keyCode===33)return-i;const n=s.charIndex,a=this._getWidthBeforeCursor(r,n),l=this._getIndexOnLine(r-1,a),c=this._textLines[r].slice(0,n),h=this.missingNewlineOffset(r-1);return-this._textLines[r-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let s,r,n=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(s=this.__charBounds[t][l].width,n+=s,n>e){r=!0;const h=n-s,d=n,u=Math.abs(h-e);a=Math.abs(d-e)<u?l:l-1;break}return r||(a=i.length-1),a}moveCursorDown(t){this.selectionStart>=this._text.length&&this.selectionEnd>=this._text.length||this._moveCursorUpOrDown("Down",t)}moveCursorUp(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorUpOrDown("Up",t)}_moveCursorUpOrDown(t,e){const i=this["get".concat(t,"CursorOffset")](e,this._selectionDirection===bt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const s=this.text.length;this.selectionStart=os(0,this.selectionStart,s),this.selectionEnd=os(0,this.selectionEnd,s),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===G?this.selectionStart+t:this.selectionEnd+t;return this.setSelectionStartEndWithShift(this.selectionStart,this.selectionEnd,e),t!==0}moveCursorWithoutShift(t){return t<0?(this.selectionStart+=t,this.selectionEnd=this.selectionStart):(this.selectionEnd+=t,this.selectionStart=this.selectionEnd),t!==0}moveCursorLeft(t){this.selectionStart===0&&this.selectionEnd===0||this._moveCursorLeftOrRight("Left",t)}_move(t,e,i){let s;if(t.altKey)s=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;s=this["findLineBoundary".concat(i)](this[e])}return s!==void 0&&this[e]!==s&&(this[e]=s,!0)}_moveLeft(t,e){return this._move(t,e,"Left")}_moveRight(t,e){return this._move(t,e,"Right")}moveCursorLeftWithoutShift(t){let e=!0;return this._selectionDirection=G,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===bt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=G,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===G&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=bt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=bt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const Ho=o=>!!o.button;class mm extends fm{constructor(){super(...arguments),v(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 pm(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),an(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}=t;this.canvas&&this.editable&&!Ho(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}=t;this.canvas&&this.editable&&!Ho(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e,transform:i}=t;const s=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const r=this.canvas._activeObject;if(r&&r!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||Ho(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(Te(this.calcTransformMatrix())).add(new x(-this._getLeftOffset(),-this._getTopOffset()));let i=0,s=0,r=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),r=c,c>0&&(s+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let n=Math.abs(this._getLineLeftOffset(r));const a=this._textLines[r].length,l=this.__charBounds[r];for(let c=0;c<a;c++){const h=n+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-n)&&s++;break}n=h,s++}return Math.min(this.flipX?a-s:s,this._text.length)}}const lr="moveCursorUp",cr="moveCursorDown",hr="moveCursorLeft",dr="moveCursorRight",ur="exitEditing",bm=_({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:ur,27:ur,33:lr,34:cr,35:dr,36:hr,37:hr,38:lr,39:dr,40:cr},keysMapRtl:{9:ur,27:ur,33:lr,34:cr,35:hr,36:dr,37:dr,38:lr,39:hr,40:cr},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Ze extends mm{static getDefaults(){return _(_({},super.getDefaults()),Ze.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},Ze.ownDefaults),e)),this.initBehavior()}_set(t,e){return this.isEditing&&this._savedProps&&t in this._savedProps?(this._savedProps[t]=e,this):(t==="canvas"&&(this.canvas instanceof qr&&this.canvas.textEditingManager.remove(this),e instanceof qr&&e.textEditingManager.add(this)),super._set(t,e))}setSelectionStart(t){t=Math.max(t,0),this._updateAndFire("selectionStart",t)}setSelectionEnd(t){t=Math.min(t,this.text.length),this._updateAndFire("selectionEnd",t)}_updateAndFire(t,e){this[t]!==e&&(this._fireSelectionChanged(),this[t]=e),this._updateTextarea()}_fireSelectionChanged(){this.fire("selection:changed"),this.canvas&&this.canvas.fire("text:selection:changed",{target:this})}initDimensions(){this.isEditing&&this.initDelayedCursor(),super.initDimensions()}getSelectionStyles(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart||0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionEnd,i=arguments.length>2?arguments[2]:void 0;return super.getSelectionStyles(t,e,i)}setSelectionStyles(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.selectionStart||0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.selectionEnd;return super.setSelectionStyles(t,e,i)}get2DCursorLocation(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1?arguments[1]:void 0;return super.get2DCursorLocation(t,e)}render(t){super.render(t),this.cursorOffsetCache={},this.renderCursorOrSelection()}toCanvasElement(t){const e=this.isEditing;this.isEditing=!1;const 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&&arguments[0]!==void 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 c=0;c<r;c++)e+=this.getHeightOfLine(c);const n=this._getLineLeftOffset(r),a=this.__charBounds[r][s];a&&(i=a.left),this.charSpacing!==0&&s===this._textLines[r].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:n+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===bt||this.textAlign===Le||this.textAlign===Is?l.left*=-1:this.textAlign===G||this.textAlign===Kr?l.left=n-(i>0?i:0):this.textAlign!==N&&this.textAlign!==Ls||(l.left=n-(i>0?i:0))),l}renderCursorAt(t){this._renderCursor(this.canvas.contextTop,this._getCursorBoundaries(t,!0),t)}renderCursor(t,e){this._renderCursor(t,e,this.selectionStart)}getCursorRenderingData(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.selectionStart,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this._getCursorBoundaries(t);const i=this.get2DCursorLocation(t),s=i.lineIndex,r=i.charIndex>0?i.charIndex-1:0,n=this.getValueOfPropertyAt(s,r,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(s,r,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(s)/this.lineHeight-n*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(s,r,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:n}}_renderCursor(t,e,i){const{color:s,opacity:r,left:n,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=s,t.globalAlpha=r,t.fillRect(n,a,l,c)}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,n=this.textAlign.includes(Le),a=this.get2DCursorLocation(s),l=this.get2DCursorLocation(r),c=a.lineIndex,h=l.lineIndex,d=a.charIndex<0?0:a.charIndex,u=l.charIndex<0?0:l.charIndex;for(let g=c;g<=h;g++){const p=this._getLineLeftOffset(g)||0;let f=this.getHeightOfLine(g),b=0,m=0,y=0;if(g===c&&(m=this.__charBounds[c][d].left),g>=c&&g<h)y=n&&!this.isEndOfWrapping(g)?this.width:this.getLineWidth(g)||5;else if(g===h)if(u===0)y=this.__charBounds[h][u].left;else{const E=this._getWidthOfCharSpacing();y=this.__charBounds[h][u-1].left+this.__charBounds[h][u-1].width-E}b=f,(this.lineHeight<1||g===h&&this.lineHeight>1)&&(f/=this.lineHeight);let w=i.left+p+m,T=f,k=0;const O=y-m;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",T=1,k=f):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===bt||this.textAlign===Le||this.textAlign===Is?w=this.width-w-O:this.textAlign===G||this.textAlign===Kr?w=i.left+p-y:this.textAlign!==N&&this.textAlign!==Ls||(w=i.left+p-y)),t.fillRect(w,i.top+i.topOffset+k,O,T),i.topOffset+=b}}getCurrentCharFontSize(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,"fontSize")}getCurrentCharColor(){const t=this._getCurrentCharIndex();return this.getValueOfPropertyAt(t.l,t.c,Ot)}_getCurrentCharIndex(){const t=this.get2DCursorLocation(this.selectionStart,!0),e=t.charIndex>0?t.charIndex-1:0;return{l:t.lineIndex,c:e}}dispose(){this.exitEditingImpl(),this.draggableTextDelegate.dispose(),super.dispose()}}v(Ze,"ownDefaults",bm),v(Ze,"type","IText"),P.setClass(Ze),P.setClass(Ze,"i-text");class Je extends Ze{static getDefaults(){return _(_({},super.getDefaults()),Je.ownDefaults)}constructor(t,e){super(t,_(_({},Je.ownDefaults),e))}static createControls(){return{controls:Gg()}}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(Le)&&this.enlargeSpaces(),this.height=this.calcTextHeight())}_generateStyleMap(t){let e=0,i=0,s=0;const r={};for(let n=0;n<t.graphemeLines.length;n++)t.graphemeText[s]===`
2678
+ `&&n>0?(i=0,s++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[s])&&n>0&&(i++,s++),r[n]={line:e,offset:i},s+=t.graphemeLines[n].length,i+=t.graphemeLines[n].length;return r}styleHas(t,e){if(this._styleMap&&!this.isWrapping){const i=this._styleMap[e];i&&(e=i.line)}return super.styleHas(t,e)}isEmptyStyles(t){if(!this.styles)return!0;let e,i=0,s=t+1,r=!1;const n=this._styleMap[t],a=this._styleMap[t+1];n&&(t=n.line,i=n.offset),a&&(s=a.line,r=s===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const d=parseInt(h,10);if(d>=i&&(!r||d<e))for(const u in l[c][h])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((r,n)=>{let a=0;const l=e?this.graphemeSplit(r):this.wordSplit(r);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),d=this._measureWord(h,n,a);return s=Math.max(d,s),a+=h.length+i.length,{word:h,width:d}})}),largestWordWidth:s}}_measureWord(t,e){let i,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=0;for(let n=0,a=t.length;n<a;n++)r+=this._getGraphemeBox(t[n],e,n+s,i,!0).kernedWidth,i=t[n];return r}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:s,wordsData:r}=i,n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let d=0,u=[],g=0,p=0,f=!0;e-=n;const b=Math.max(e,s,this.dynamicMinWidth),m=r[t];let y;for(g=0,y=0;y<m.length;y++){const{word:w,width:T}=m[y];g+=w.length,d+=p+T-a,d>b&&!f?(c.push(u),u=[],d=T,f=!0):d+=a,f||l||u.push(h),u=u.concat(w),p=l?0:this._measureWord([h],t,g),g++,f=!1}return y&&c.push(u),s+n>this.dynamicMinWidth&&(this.dynamicMinWidth=s-a+n),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),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 s=this._styleMap[e].line;t.set("".concat(s),!0)}}for(const e in this.styles)t.has(e)||delete this.styles[e]}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject(["minWidth","splitByGrapheme",...t])}}v(Je,"type","Textbox"),v(Je,"textLayoutProperties",[...Ze.textLayoutProperties,"width"]),v(Je,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),P.setClass(Je);class _l extends fo{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:n,height:a}=Qe(Ic(i,s)),l=new x(n,a);if(s.absolutePositioned)return{center:es(s.getRelativeCenterPoint(),void 0,r?r.calcTransformMatrix():void 0),size:l};{const c=s.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new x,correction:d=new x}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:d.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}v(_l,"type","clip-path"),P.setClass(_l);class yl extends fo{getInitialSize(t,e){let{target:i}=t,{size:s}=e;return new x(i.width||s.x,i.height||s.y)}}v(yl,"type","fixed"),P.setClass(yl);class vm extends Us{subscribeTargets(t){const e=t.target;t.targets.reduce((i,s)=>(s.parent&&i.add(s.parent),i),new Set).forEach(i=>{i.layoutManager.subscribeTargets({target:i,targets:[e]})})}unsubscribeTargets(t){const e=t.target,i=e.getObjects();t.targets.reduce((s,r)=>(r.parent&&s.add(r.parent),s),new Set).forEach(s=>{!i.some(r=>r.parent===s)&&s.layoutManager.unsubscribeTargets({target:s,targets:[e]})})}}class Li extends mi{static getDefaults(){return _(_({},super.getDefaults()),Li.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Li.ownDefaults),this.setOptions(e);const{left:i,top:s,layoutManager:r}=e;this.groupInit(t,{left:i,top:s,layoutManager:r??new vm})}_shouldSetNestedCoords(){return!0}__objectSelectionMonitor(){}multiSelectAdd(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];this.multiSelectionStacking==="selection-order"?this.add(...e):e.forEach(s=>{const r=this._objects.findIndex(a=>a.isInFrontOf(s)),n=r===-1?this.size():r;this.insertAt(n,s)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(vi("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(s=>{const{parent:r}=s;r&&i.add(r)}),t===Yn?i.forEach(s=>{s._onAfterObjectsChange(Gr,e)}):i.forEach(s=>{s._set("dirty",!0)})}onDeselect(){return this.removeAll(),!1}toString(){return"#<ActiveSelection: (".concat(this.complexity(),")>")}shouldCache(){return!1}isOnACache(){return!1}_renderControls(t,e,i){t.save(),t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;const s=_(_({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()}}v(Li,"type","ActiveSelection"),v(Li,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),P.setClass(Li),P.setClass(Li,"activeSelection");class _m{constructor(){v(this,"resources",{})}applyFilters(t,e,i,s,r){const n=r.getContext("2d");if(!n)return;n.drawImage(e,0,0,i,s);const a={sourceWidth:i,sourceHeight:s,imageData:n.getImageData(0,0,i,s),originalEl:e,originalImageData:n.getImageData(0,0,i,s),canvasEl:r,ctx:n,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===i&&l.height===s||(r.width=l.width,r.height=l.height),n.putImageData(l,0,0),a}}class Qc{constructor(){let{tileSize:t=U.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};v(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),v(this,"resources",{}),this.tileSize=t,this.setupGLContext(t,t),this.captureGPUInfo()}setupGLContext(t,e){this.dispose(),this.createWebGLCanvas(t,e)}createWebGLCanvas(t,e){const i=ze({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,n){const a=this.gl,l=r.getContext("2d");if(!a||!l)return;let c;n&&(c=this.getCachedTexture(n,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:s,destinationWidth:i,destinationHeight:s,context:a,sourceTexture:this.createTexture(a,i,s,c?void 0:e),targetTexture:this.createTexture(a,i,s),originalTexture:c||this.createTexture(a,i,s,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:r},d=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,d),t.forEach(u=>{u&&u.applyTo(h)}),function(u){const g=u.targetCanvas,p=g.width,f=g.height,b=u.destinationWidth,m=u.destinationHeight;p===b&&f===m||(g.width=b,g.height=m)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(d),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,s,r){const{NEAREST:n,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:d,TEXTURE_MIN_FILTER:u,TEXTURE_WRAP_S:g,TEXTURE_WRAP_T:p}=t,f=t.createTexture();return t.bindTexture(a,f),t.texParameteri(a,d,r||n),t.texParameteri(a,u,r||n),t.texParameteri(a,g,h),t.texParameteri(a,p,h),s?t.texImage2D(a,0,l,l,c,s):t.texImage2D(a,0,l,e,i,0,l,c,null),f}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 n=i.height-s.height;r.drawImage(i,0,n,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,n=s*r*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,n),l=new Uint8ClampedArray(this.imageBuffer,0,n);t.readPixels(0,0,s,r,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,s,r);i.putImageData(c,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 No;function ym(){const{WebGLProbe:o}=Re();return o.queryWebGL(Oe()),U.enableGLFiltering&&o.isSupported(U.textureSize)?new Qc({tileSize:U.textureSize}):new _m}function Vo(){return!No&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(No=ym()),No}const xm=["filters","resizeFilter","src","crossOrigin","type"],th=["cropX","cropY"];class Kt extends Nt{static getDefaults(){return _(_({},super.getDefaults()),Kt.ownDefaults)}constructor(t,e){super(),v(this,"_lastScaleX",1),v(this,"_lastScaleY",1),v(this,"_filterScalingX",1),v(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Kt.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(_i()),this.setElement(typeof t=="string"?(this.canvas&&Se(this.canvas.getElement())||as()).getElementById(t):t,e)}getElement(){return this._element}setElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.removeTexture(this.cacheKey),this.removeTexture("".concat(this.cacheKey,"_filtered")),this._element=t,this._originalElement=t,this._setWidthHeight(e),t.classList.add(Kt.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=Vo(!1);e instanceof Qc&&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&&Re().dispose(e),this[t]=void 0})}getCrossOrigin(){return this._originalElement&&(this._originalElement.crossOrigin||null)}getOriginalSize(){const t=this.getElement();return t?{width:t.naturalWidth||t.width,height:t.naturalHeight||t.height}:{width:0,height:0}}_stroke(t){if(!this.stroke||this.strokeWidth===0)return;const e=this.width/2,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&&arguments[0]!==void 0?arguments[0]:[];const e=[];return this.filters.forEach(i=>{i&&e.push(i.toObject())}),_(_({},super.toObject([...th,...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=[],n=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=_i();r.push('<clipPath id="imageCrop_'+c+`">
2672
2679
  `,' <rect x="'+i+'" y="'+s+'" width="'+this.width+'" height="'+this.height+`" />
2673
2680
  `,`</clipPath>
2674
2681
  `),a=' clip-path="url(#imageCrop_'+c+')" '}if(this.imageSmoothing||(l=' image-rendering="optimizeSpeed"'),t.push(" <image ","COMMON_PARTS",'xlink:href="'.concat(this.getSvgSrc(!0),'" x="').concat(i-this.cropX,'" y="').concat(s-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
2675
2682
  `)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,n=[' <rect x="'.concat(i,'" y="').concat(s,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
2676
- `)],this.fill=c}return r=this.paintFirst!==Pt?r.concat(n,t):r.concat(t,n),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&&arguments[1]!==void 0?arguments[1]:{};return Mr(t,{crossOrigin:e,signal:i}).then(s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,r=i.y,n=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=n,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const a=Re(n),{width:l,height:c}=n;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,Vo().applyFilters([t],n,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter(r=>r&&!r.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const r=Re({width:i,height:s});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Vo().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,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,r=this.width,n=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,g=Math.min(r*i,c-d),p=Math.min(n*s,h-u),f=-r/2,b=-n/2,m=Math.min(r,c/i-a),y=Math.min(n,h/s-l);e&&t.drawImage(e,d,u,g,p,f,b,m,y)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=ig(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,n=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,g=0;return!t||t.alignX===se&&t.alignY===se?(l=e/n,c=i/a):(t.meetOrSlice==="meet"&&(l=c=Ef(this._element,s),r=(e-n*l)/2,t.alignX==="Min"&&(h=-r),t.alignX==="Max"&&(h=r),r=(i-a*c)/2,t.alignY==="Min"&&(d=-r),t.alignY==="Max"&&(d=r)),t.meetOrSlice==="slice"&&(l=c=kf(this._element,s),r=n-e/l,t.alignX==="Mid"&&(u=r/2),t.alignX==="Max"&&(u=r),r=a-i/c,t.alignY==="Mid"&&(g=r/2),t.alignY==="Max"&&(g=r),n=e/l,a=i/c)),{width:n,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:g}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:n,type:a}=t,l=it(t,xm);return Promise.all([Mr(r,_(_({},e),{},{crossOrigin:n})),i&&zs(i,e),s&&zs([s],e),ho(l,e)]).then(c=>{let[h,d=[],[u]=[],g={}]=c;return new this(h,_(_({},l),{},{src:r,filters:d,resizeFilter:u},g))})}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Mr(t,{crossOrigin:e,signal:i}).then(r=>new this(r,s))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=ri(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"],e,s).catch(r=>(bi("log","Unable to parse Image",r),null))}}v(Kt,"type","Image"),v(Kt,"cacheProperties",[...si,...th]),v(Kt,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(Kt,"CSS_CANVAS","canvas-img"),v(Kt,"ATTRIBUTE_NAMES",[...wi,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),P.setClass(Kt),P.setSVGClass(Kt);po(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const bo=o=>o.webgl!==void 0,Xn="precision highp float",wm=`
2683
+ `)],this.fill=c}return r=this.paintFirst!==Ot?r.concat(n,t):r.concat(t,n),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&&arguments[1]!==void 0?arguments[1]:{};return Mr(t,{crossOrigin:e,signal:i}).then(s=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(s)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),s=i.x,r=i.y,n=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||s>e&&r>e)return this._element=n,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=s,void(this._lastScaleY=r);const a=ze(n),{width:l,height:c}=n;this._element=a,this._lastScaleX=t.scaleX=s,this._lastScaleY=t.scaleY=r,Vo().applyFilters([t],n,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter(r=>r&&!r.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,s=e.naturalHeight||e.height;if(this._element===this._originalElement){const r=ze({width:i,height:s});this._element=r,this._filteredEl=r}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,s),this._lastScaleX=1,this._lastScaleY=1);Vo().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,this.isMoving!==!0&&this.resizeFilter&&this._needsResize()&&this.applyResizeFilters(),this._stroke(t),this._renderPaintInOrder(t)}drawCacheOnCanvas(t){t.imageSmoothingEnabled=this.imageSmoothing,super.drawCacheOnCanvas(t)}shouldCache(){return this.needsItsOwnCache()}_renderFill(t){const e=this._element;if(!e)return;const i=this._filterScalingX,s=this._filterScalingY,r=this.width,n=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,d=a*i,u=l*s,g=Math.min(r*i,c-d),p=Math.min(n*s,h-u),f=-r/2,b=-n/2,m=Math.min(r,c/i-a),y=Math.min(n,h/s-l);e&&t.drawImage(e,d,u,g,p,f,b,m,y)}_needsResize(){const t=this.getTotalObjectScaling();return t.x!==this._lastScaleX||t.y!==this._lastScaleY}_resetWidthHeight(){this.set(this.getOriginalSize())}_setWidthHeight(){let{width:t,height:e}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=this.getOriginalSize();this.width=t||i.width,this.height=e||i.height}parsePreserveAspectRatioAttribute(){const t=ig(this.preserveAspectRatio||""),e=this.width,i=this.height,s={width:e,height:i};let r,n=this._element.width,a=this._element.height,l=1,c=1,h=0,d=0,u=0,g=0;return!t||t.alignX===se&&t.alignY===se?(l=e/n,c=i/a):(t.meetOrSlice==="meet"&&(l=c=Ef(this._element,s),r=(e-n*l)/2,t.alignX==="Min"&&(h=-r),t.alignX==="Max"&&(h=r),r=(i-a*c)/2,t.alignY==="Min"&&(d=-r),t.alignY==="Max"&&(d=r)),t.meetOrSlice==="slice"&&(l=c=kf(this._element,s),r=n-e/l,t.alignX==="Mid"&&(u=r/2),t.alignX==="Max"&&(u=r),r=a-i/c,t.alignY==="Mid"&&(g=r/2),t.alignY==="Max"&&(g=r),n=e/l,a=i/c)),{width:n,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:d,cropX:u,cropY:g}}static fromObject(t,e){let{filters:i,resizeFilter:s,src:r,crossOrigin:n,type:a}=t,l=it(t,xm);return Promise.all([Mr(r,_(_({},e),{},{crossOrigin:n})),i&&Hs(i,e),s&&Hs([s],e),ho(l,e)]).then(c=>{let[h,d=[],[u]=[],g={}]=c;return new this(h,_(_({},l),{},{src:r,filters:d,resizeFilter:u},g))})}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;return Mr(t,{crossOrigin:e,signal:i}).then(r=>new this(r,s))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const s=ni(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(s["xlink:href"],e,s).catch(r=>(vi("log","Unable to parse Image",r),null))}}v(Kt,"type","Image"),v(Kt,"cacheProperties",[...oi,...th]),v(Kt,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),v(Kt,"CSS_CANVAS","canvas-img"),v(Kt,"ATTRIBUTE_NAMES",[...Ci,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),P.setClass(Kt),P.setSVGClass(Kt);po(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const bo=o=>o.webgl!==void 0,Xn="precision highp float",wm=`
2677
2684
  `.concat(Xn,`;
2678
2685
  varying vec2 vTexCoord;
2679
2686
  uniform sampler2D uTexture;
2680
2687
  void main() {
2681
2688
  gl_FragColor = texture2D(uTexture, vTexCoord);
2682
- }`),Cm=["type"],Sm=["type"],Tm=new RegExp(Xn,"g");class At{get type(){return this.constructor.type}constructor(){let t=it(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Cm);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return wm}getVertexSource(){return`
2689
+ }`),Cm=["type"],Sm=["type"],Tm=new RegExp(Xn,"g");class Dt{get type(){return this.constructor.type}constructor(){let t=it(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Cm);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return wm}getVertexSource(){return`
2683
2690
  attribute vec2 aPosition;
2684
2691
  varying vec2 vTexCoord;
2685
2692
  void main() {
2686
2693
  vTexCoord = aPosition;
2687
2694
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
2688
- }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Be();s!=="highp"&&(e=e.replace(Tm,Xn.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),n=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!r||!n||!a)throw new Fe("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new Fe("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new Fe("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new Fe('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const 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){bo(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);t.pass===0&&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=Re({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return _({type:this.type},t.reduce((e,i)=>(e[i]=this[i],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(it(t,Sm))}}v(At,"type","BaseFilter"),v(At,"uniformLocations",[]);const Em={multiply:`gl_FragColor.rgb *= uColor.rgb;
2695
+ }`}createProgram(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.getFragmentSource(),i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.getVertexSource();const{WebGLProbe:{GLPrecision:s="highp"}}=Re();s!=="highp"&&(e=e.replace(Tm,Xn.replace("highp",s)));const r=t.createShader(t.VERTEX_SHADER),n=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!r||!n||!a)throw new je("Vertex, fragment shader or program creation error");if(t.shaderSource(r,i),t.compileShader(r),!t.getShaderParameter(r,t.COMPILE_STATUS))throw new je("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(r)));if(t.shaderSource(n,e),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))throw new je("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(n)));if(t.attachShader(a,r),t.attachShader(a,n),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new je('Shader link error for "'.concat(this.type,'" ').concat(t.getProgramInfoLog(a)));const l=this.getUniformLocations(t,a)||{};return l.uStepW=t.getUniformLocation(a,"uStepW"),l.uStepH=t.getUniformLocation(a,"uStepH"),{program:a,attributeLocations:this.getAttributeLocations(t,a),uniformLocations:l}}getAttributeLocations(t,e){return{aPosition:t.getAttribLocation(e,"aPosition")}}getUniformLocations(t,e){const 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){bo(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);t.pass===0&&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=ze({width:e,height:i});t.helpLayer=s}}toObject(){const t=Object.keys(this.constructor.defaults||{});return _({type:this.type},t.reduce((e,i)=>(e[i]=this[i],e),{}))}toJSON(){return this.toObject()}static async fromObject(t,e){return new this(it(t,Sm))}}v(Dt,"type","BaseFilter"),v(Dt,"uniformLocations",[]);const Em={multiply:`gl_FragColor.rgb *= uColor.rgb;
2689
2696
  `,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
2690
2697
  `,add:`gl_FragColor.rgb += uColor.rgb;
2691
2698
  `,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
@@ -2712,7 +2719,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2712
2719
  `,tint:`
2713
2720
  gl_FragColor.rgb *= (1.0 - uColor.a);
2714
2721
  gl_FragColor.rgb += uColor.rgb;
2715
- `};class pr extends At{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
2722
+ `};class pr extends Dt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
2716
2723
  precision highp float;
2717
2724
  uniform sampler2D uTexture;
2718
2725
  uniform vec4 uColor;
@@ -2750,7 +2757,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2750
2757
  color.a = color2.a;
2751
2758
  gl_FragColor = color;
2752
2759
  }
2753
- `},Om=["type","image"];class gr extends At{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return km[this.mode]}getVertexSource(){return`
2760
+ `},Om=["type","image"];class gr extends Dt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return km[this.mode]}getVertexSource(){return`
2754
2761
  attribute vec2 aPosition;
2755
2762
  varying vec2 vTexCoord;
2756
2763
  varying vec2 vTexCoord2;
@@ -2760,7 +2767,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2760
2767
  vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
2761
2768
  gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
2762
2769
  }
2763
- `}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 n=this.image;r.blendImage||(r.blendImage=ke());const a=r.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(n.scaleX,0,0,n.scaleY,n.left,n.top),l.drawImage(n.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const d=e[h],u=e[h+1],g=e[h+2],p=e[h+3],f=c[h],b=c[h+1],m=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=d*f/255,e[h+1]=u*b/255,e[h+2]=g*m/255,e[h+3]=p*y/255;break;case"mask":e[h+3]=y}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return _(_({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=it(t,Om);return Kt.fromObject(s,e).then(n=>new this(_(_({},r),{},{image:n})))}}v(gr,"type","BlendImage"),v(gr,"defaults",{mode:"multiply",alpha:1}),v(gr,"uniformLocations",["uTransformMatrix","uImage"]),P.setClass(gr);class fr extends At{getFragmentSource(){return`
2770
+ `}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 n=this.image;r.blendImage||(r.blendImage=Oe());const a=r.blendImage,l=a.getContext("2d");a.width!==i||a.height!==s?(a.width=i,a.height=s):l.clearRect(0,0,i,s),l.setTransform(n.scaleX,0,0,n.scaleY,n.left,n.top),l.drawImage(n.getElement(),0,0,i,s);const c=l.getImageData(0,0,i,s).data;for(let h=0;h<e.length;h+=4){const d=e[h],u=e[h+1],g=e[h+2],p=e[h+3],f=c[h],b=c[h+1],m=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=d*f/255,e[h+1]=u*b/255,e[h+2]=g*m/255,e[h+3]=p*y/255;break;case"mask":e[h+3]=y}}}sendUniformData(t,e){const i=this.calculateMatrix();t.uniform1i(e.uImage,1),t.uniformMatrix3fv(e.uTransformMatrix,!1,i)}toObject(){return _(_({},super.toObject()),{},{image:this.image&&this.image.toObject()})}static async fromObject(t,e){let{type:i,image:s}=t,r=it(t,Om);return Kt.fromObject(s,e).then(n=>new this(_(_({},r),{},{image:n})))}}v(gr,"type","BlendImage"),v(gr,"defaults",{mode:"multiply",alpha:1}),v(gr,"uniformLocations",["uTransformMatrix","uImage"]),P.setClass(gr);class fr extends Dt{getFragmentSource(){return`
2764
2771
  precision highp float;
2765
2772
  uniform sampler2D uTexture;
2766
2773
  uniform vec2 uDelta;
@@ -2783,7 +2790,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2783
2790
  }
2784
2791
  gl_FragColor = color / total;
2785
2792
  }
2786
- `}applyTo(t){bo(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:n}=i;s.blurLayer1||(s.blurLayer1=ke(),s.blurLayer2=ke());const a=s.blurLayer1,l=s.blurLayer2;a.width===r&&a.height===n||(l.width=a.width=r,l.height=a.height=n);const c=a.getContext("2d"),h=l.getContext("2d"),d=15,u=.06*this.blur*.5;let g,p,f,b;for(c.putImageData(i,0,0),h.clearRect(0,0,r,n),b=-15;b<=d;b++)g=(Math.random()-.5)/4,p=b/d,f=u*p*r+g,h.globalAlpha=1-Math.abs(p),h.drawImage(a,f,g),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);for(b=-15;b<=d;b++)g=(Math.random()-.5)/4,p=b/d,f=u*p*n+g,h.globalAlpha=1-Math.abs(p),h.drawImage(a,g,f),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);e.drawImage(a,0,0);const m=e.getImageData(0,0,a.width,a.height);return c.globalAlpha=1,c.clearRect(0,0,a.width,a.height),m}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}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}}v(fr,"type","Blur"),v(fr,"defaults",{blur:0}),v(fr,"uniformLocations",["uDelta"]),P.setClass(fr);class mr extends At{getFragmentSource(){return`
2793
+ `}applyTo(t){bo(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:n}=i;s.blurLayer1||(s.blurLayer1=Oe(),s.blurLayer2=Oe());const a=s.blurLayer1,l=s.blurLayer2;a.width===r&&a.height===n||(l.width=a.width=r,l.height=a.height=n);const c=a.getContext("2d"),h=l.getContext("2d"),d=15,u=.06*this.blur*.5;let g,p,f,b;for(c.putImageData(i,0,0),h.clearRect(0,0,r,n),b=-15;b<=d;b++)g=(Math.random()-.5)/4,p=b/d,f=u*p*r+g,h.globalAlpha=1-Math.abs(p),h.drawImage(a,f,g),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);for(b=-15;b<=d;b++)g=(Math.random()-.5)/4,p=b/d,f=u*p*n+g,h.globalAlpha=1-Math.abs(p),h.drawImage(a,g,f),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);e.drawImage(a,0,0);const m=e.getImageData(0,0,a.width,a.height);return c.globalAlpha=1,c.clearRect(0,0,a.width,a.height),m}sendUniformData(t,e){const i=this.chooseRightDelta();t.uniform2fv(e.uDelta,i)}isNeutralState(){return this.blur===0}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}}v(fr,"type","Blur"),v(fr,"defaults",{blur:0}),v(fr,"uniformLocations",["uDelta"]),P.setClass(fr);class mr extends Dt{getFragmentSource(){return`
2787
2794
  precision highp float;
2788
2795
  uniform sampler2D uTexture;
2789
2796
  uniform float uBrightness;
@@ -2793,7 +2800,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2793
2800
  color.rgb += uBrightness;
2794
2801
  gl_FragColor = color;
2795
2802
  }
2796
- `}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 this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}v(mr,"type","Brightness"),v(mr,"defaults",{brightness:0}),v(mr,"uniformLocations",["uBrightness"]),P.setClass(mr);const eh={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ji extends At{getFragmentSource(){return`
2803
+ `}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 this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}v(mr,"type","Brightness"),v(mr,"defaults",{brightness:0}),v(mr,"uniformLocations",["uBrightness"]),P.setClass(mr);const eh={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class Ji extends Dt{getFragmentSource(){return`
2797
2804
  precision highp float;
2798
2805
  uniform sampler2D uTexture;
2799
2806
  varying vec2 vTexCoord;
@@ -2804,7 +2811,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2804
2811
  color *= uColorMatrix;
2805
2812
  color += uConstants;
2806
2813
  gl_FragColor = color;
2807
- }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const n=e[r],a=e[r+1],l=e[r+2];if(e[r]=n*i[0]+a*i[1]+l*i[2]+255*i[4],e[r+1]=n*i[5]+a*i[6]+l*i[7]+255*i[9],e[r+2]=n*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[r+3];e[r]+=c*i[3],e[r+1]+=c*i[8],e[r+2]+=c*i[13],e[r+3]=n*i[15]+a*i[16]+l*i[17]+c*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 _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function Vi(o,t){var e;const i=(v(e=class extends Ji{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",o),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return P.setClass(i,o),i}v(Ji,"type","ColorMatrix"),v(Ji,"defaults",eh),v(Ji,"uniformLocations",["uColorMatrix","uConstants"]),P.setClass(Ji);Vi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);Vi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);Vi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);Vi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);Vi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);Vi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);Vi("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 xl extends At{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){bo(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(i=>P.getClass(i.type).fromObject(i,e))).then(i=>new this({subFilters:i}))}}v(xl,"type","Composed"),P.setClass(xl);class br extends At{getFragmentSource(){return`
2814
+ }`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,s=this.colorsOnly;for(let r=0;r<e.length;r+=4){const n=e[r],a=e[r+1],l=e[r+2];if(e[r]=n*i[0]+a*i[1]+l*i[2]+255*i[4],e[r+1]=n*i[5]+a*i[6]+l*i[7]+255*i[9],e[r+2]=n*i[10]+a*i[11]+l*i[12]+255*i[14],!s){const c=e[r+3];e[r]+=c*i[3],e[r+1]+=c*i[8],e[r+2]+=c*i[13],e[r+3]=n*i[15]+a*i[16]+l*i[17]+c*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 _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function Vi(o,t){var e;const i=(v(e=class extends Ji{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",o),v(e,"defaults",{colorsOnly:!1,matrix:t}),e);return P.setClass(i,o),i}v(Ji,"type","ColorMatrix"),v(Ji,"defaults",eh),v(Ji,"uniformLocations",["uColorMatrix","uConstants"]),P.setClass(Ji);Vi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);Vi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);Vi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);Vi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);Vi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);Vi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);Vi("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 xl extends Dt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){bo(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(i=>P.getClass(i.type).fromObject(i,e))).then(i=>new this({subFilters:i}))}}v(xl,"type","Composed"),P.setClass(xl);class br extends Dt{getFragmentSource(){return`
2808
2815
  precision highp float;
2809
2816
  uniform sampler2D uTexture;
2810
2817
  uniform float uContrast;
@@ -2958,7 +2965,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
2958
2965
  gl_FragColor = color;
2959
2966
  gl_FragColor.a = alpha;
2960
2967
  }
2961
- `};class vr extends At{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Pm[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,g,p,f,b,m,y,w,T,k,O,E,S;for(O=0;O<l;O++)for(k=0;k<a;k++){for(b=4*(O*a+k),u=0,g=0,p=0,f=0,S=0;S<r;S++)for(E=0;E<r;E++)y=O+S-n,m=k+E-n,y<0||y>=l||m<0||m>=a||(w=4*(y*a+m),T=s[S*r+E],u+=i[w]*T,g+=i[w+1]*T,p+=i[w+2]*T,d||(f+=i[w+3]*T));h[b]=u,h[b+1]=g,h[b+2]=p,h[b+3]=d?i[b+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(vr,"type","Convolute"),v(vr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(vr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),P.setClass(vr);const ih="Gamma";class _r extends At{getFragmentSource(){return`
2968
+ `};class vr extends Dt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Pm[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,s=this.matrix,r=Math.round(Math.sqrt(s.length)),n=Math.floor(r/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,d=this.opaque?1:0;let u,g,p,f,b,m,y,w,T,k,O,E,S;for(O=0;O<l;O++)for(k=0;k<a;k++){for(b=4*(O*a+k),u=0,g=0,p=0,f=0,S=0;S<r;S++)for(E=0;E<r;E++)y=O+S-n,m=k+E-n,y<0||y>=l||m<0||m>=a||(w=4*(y*a+m),T=s[S*r+E],u+=i[w]*T,g+=i[w+1]*T,p+=i[w+2]*T,d||(f+=i[w+3]*T));h[b]=u,h[b+1]=g,h[b+2]=p,h[b+3]=d?i[b+3]:f}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}v(vr,"type","Convolute"),v(vr,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),v(vr,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),P.setClass(vr);const ih="Gamma";class _r extends Dt{getFragmentSource(){return`
2962
2969
  precision highp float;
2963
2970
  uniform sampler2D uTexture;
2964
2971
  uniform vec3 uGamma;
@@ -3001,7 +3008,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3001
3008
  float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
3002
3009
  gl_FragColor = vec4(average, average, average, col.a);
3003
3010
  }
3004
- `};class yr extends At{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const r=e[s],n=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(r+n+a)/3;break;case"lightness":i=(Math.min(r,n,a)+Math.max(r,n,a))/2;break;case"luminosity":i=.21*r+.72*n+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Dm[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(yr,"type","Grayscale"),v(yr,"defaults",{mode:"average"}),v(yr,"uniformLocations",["uMode"]),P.setClass(yr);const Am=_(_({},eh),{},{rotation:0});class Uo extends Ji{calculateMatrix(){const t=this.rotation*Math.PI,e=ti(t),i=ei(t),s=1/3,r=Math.sqrt(s)*i,n=1-e;this.matrix=[e+n/3,s*n-r,s*n+r,0,0,s*n+r,e+s*n,s*n-r,0,0,s*n-r,s*n+r,e+s*n,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(Uo,"type","HueRotation"),v(Uo,"defaults",Am),P.setClass(Uo);class xr extends At{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`
3011
+ `};class yr extends Dt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,s=0;s<e.length;s+=4){const r=e[s],n=e[s+1],a=e[s+2];switch(this.mode){case"average":i=(r+n+a)/3;break;case"lightness":i=(Math.min(r,n,a)+Math.max(r,n,a))/2;break;case"luminosity":i=.21*r+.72*n+.07*a}e[s+2]=e[s+1]=e[s]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Dm[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}v(yr,"type","Grayscale"),v(yr,"defaults",{mode:"average"}),v(yr,"uniformLocations",["uMode"]),P.setClass(yr);const Am=_(_({},eh),{},{rotation:0});class Uo extends Ji{calculateMatrix(){const t=this.rotation*Math.PI,e=ii(t),i=si(t),s=1/3,r=Math.sqrt(s)*i,n=1-e;this.matrix=[e+n/3,s*n-r,s*n+r,0,0,s*n+r,e+s*n,s*n-r,0,0,s*n-r,s*n+r,e+s*n,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}v(Uo,"type","HueRotation"),v(Uo,"defaults",Am),P.setClass(Uo);class xr extends Dt{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`
3005
3012
  precision highp float;
3006
3013
  uniform sampler2D uTexture;
3007
3014
  uniform int uInvert;
@@ -3019,7 +3026,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3019
3026
  gl_FragColor = color;
3020
3027
  }
3021
3028
  }
3022
- `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}v(xr,"type","Invert"),v(xr,"defaults",{alpha:!1,invert:!0}),v(xr,"uniformLocations",["uInvert","uAlpha"]),P.setClass(xr);class wr extends At{getFragmentSource(){return`
3029
+ `}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}v(xr,"type","Invert"),v(xr,"defaults",{alpha:!1,invert:!0}),v(xr,"uniformLocations",["uInvert","uAlpha"]),P.setClass(xr);class wr extends Dt{getFragmentSource(){return`
3023
3030
  precision highp float;
3024
3031
  uniform sampler2D uTexture;
3025
3032
  uniform float uStepH;
@@ -3034,7 +3041,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3034
3041
  color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
3035
3042
  gl_FragColor = color;
3036
3043
  }
3037
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let s=0;s<e.length;s+=4){const r=(.5-Math.random())*i;e[s]+=r,e[s+1]+=r,e[s+2]+=r}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}v(wr,"type","Noise"),v(wr,"defaults",{noise:0}),v(wr,"uniformLocations",["uNoise","uSeed"]),P.setClass(wr);class Cr extends At{applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;for(let r=0;r<s;r+=this.blocksize)for(let n=0;n<i;n+=this.blocksize){const a=4*r*i+4*n,l=e[a],c=e[a+1],h=e[a+2],d=e[a+3];for(let u=r;u<Math.min(r+this.blocksize,s);u++)for(let g=n;g<Math.min(n+this.blocksize,i);g++){const p=4*u*i+4*g;e[p]=l,e[p+1]=c,e[p+2]=h,e[p+3]=d}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
3044
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let s=0;s<e.length;s+=4){const r=(.5-Math.random())*i;e[s]+=r,e[s+1]+=r,e[s+2]+=r}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}v(wr,"type","Noise"),v(wr,"defaults",{noise:0}),v(wr,"uniformLocations",["uNoise","uSeed"]),P.setClass(wr);class Cr extends Dt{applyTo2d(t){let{imageData:{data:e,width:i,height:s}}=t;for(let r=0;r<s;r+=this.blocksize)for(let n=0;n<i;n+=this.blocksize){const a=4*r*i+4*n,l=e[a],c=e[a+1],h=e[a+2],d=e[a+3];for(let u=r;u<Math.min(r+this.blocksize,s);u++)for(let g=n;g<Math.min(n+this.blocksize,i);g++){const p=4*u*i+4*g;e[p]=l,e[p+1]=c,e[p+2]=h,e[p+3]=d}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
3038
3045
  precision highp float;
3039
3046
  uniform sampler2D uTexture;
3040
3047
  uniform float uBlocksize;
@@ -3052,7 +3059,7 @@ Resulting to default behavior: removing object from previous canvas and adding t
3052
3059
  vec4 color = texture2D(uTexture, squareCoords);
3053
3060
  gl_FragColor = color;
3054
3061
  }
3055
- `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}v(Cr,"type","Pixelate"),v(Cr,"defaults",{blocksize:4}),v(Cr,"uniformLocations",["uBlocksize"]),P.setClass(Cr);class Sr extends At{getFragmentSource(){return`
3062
+ `}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}v(Cr,"type","Pixelate"),v(Cr,"defaults",{blocksize:4}),v(Cr,"uniformLocations",["uBlocksize"]),P.setClass(Cr);class Sr extends Dt{getFragmentSource(){return`
3056
3063
  precision highp float;
3057
3064
  uniform sampler2D uTexture;
3058
3065
  uniform vec4 uLow;
@@ -3064,7 +3071,7 @@ void main() {
3064
3071
  gl_FragColor.a = 0.0;
3065
3072
  }
3066
3073
  }
3067
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new X(this.color).getSource(),r=[s[0]-i,s[1]-i,s[2]-i],n=[s[0]+i,s[1]+i,s[2]+i];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>r[0]&&c>r[1]&&h>r[2]&&l<n[0]&&c<n[1]&&h<n[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new X(this.color).getSource(),s=this.distance,r=[0+i[0]/255-s,0+i[1]/255-s,0+i[2]/255-s,1],n=[i[0]/255+s,i[1]/255+s,i[2]/255+s,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,n)}}v(Sr,"type","RemoveColor"),v(Sr,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),v(Sr,"uniformLocations",["uLow","uHigh"]),P.setClass(Sr);class Tr extends At{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`
3074
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,s=new X(this.color).getSource(),r=[s[0]-i,s[1]-i,s[2]-i],n=[s[0]+i,s[1]+i,s[2]+i];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>r[0]&&c>r[1]&&h>r[2]&&l<n[0]&&c<n[1]&&h<n[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new X(this.color).getSource(),s=this.distance,r=[0+i[0]/255-s,0+i[1]/255-s,0+i[2]/255-s,1],n=[i[0]/255+s,i[1]/255+s,i[2]/255+s,1];t.uniform4fv(e.uLow,r),t.uniform4fv(e.uHigh,n)}}v(Sr,"type","RemoveColor"),v(Sr,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),v(Sr,"uniformLocations",["uLow","uHigh"]),P.setClass(Sr);class Tr extends Dt{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`
3068
3075
  precision highp float;
3069
3076
  uniform sampler2D uTexture;
3070
3077
  uniform vec2 uDelta;
@@ -3080,7 +3087,7 @@ void main() {
3080
3087
  `),`
3081
3088
  gl_FragColor = color / sum;
3082
3089
  }
3083
- `)}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){bo(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const 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,n=e.height,a=Math.round(r*i),l=Math.round(n*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,r,n,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,r,n,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,r,n,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,r,n,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,r){const n=t.imageData,a=.5;let l=!1,c=!1,h=e*a,d=i*a;const u=t.filterBackend.resources;let g=0,p=0;const f=e;let b=0;u.sliceByTwo||(u.sliceByTwo=ke());const m=u.sliceByTwo;(m.width<1.5*e||m.height<i)&&(m.width=1.5*e,m.height=i);const y=m.getContext("2d");for(y.clearRect(0,0,1.5*e,i),y.putImageData(n,0,0),s=Math.floor(s),r=Math.floor(r);!l||!c;)e=h,i=d,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),r<Math.floor(d*a)?d=Math.floor(d*a):(d=r,c=!0),y.drawImage(m,g,p,e,i,f,b,h,d),g=f,p=b,b+=d;return y.getImageData(g,p,s,r)}lanczosResize(t,e,i,s,r){const n=t.imageData.data,a=t.ctx.createImageData(s,r),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,d=this.rcpScaleY,u=2/this.rcpScaleX,g=2/this.rcpScaleY,p=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(d*this.lanczosLobes/2),b={},m={x:0,y:0},y={x:0,y:0};return function w(T){let k,O,E,S,D,I,M,B,R,F,Y;for(m.x=(T+.5)*h,y.x=Math.floor(m.x),k=0;k<r;k++){for(m.y=(k+.5)*d,y.y=Math.floor(m.y),D=0,I=0,M=0,B=0,R=0,O=y.x-p;O<=y.x+p;O++)if(!(O<0||O>=e)){F=Math.floor(1e3*Math.abs(O-m.x)),b[F]||(b[F]={});for(let tt=y.y-f;tt<=y.y+f;tt++)tt<0||tt>=i||(Y=Math.floor(1e3*Math.abs(tt-m.y)),b[F][Y]||(b[F][Y]=c(Math.sqrt(Math.pow(F*u,2)+Math.pow(Y*g,2))/1e3)),E=b[F][Y],E>0&&(S=4*(tt*e+O),D+=E,I+=E*n[S],M+=E*n[S+1],B+=E*n[S+2],R+=E*n[S+3]))}S=4*(k*s+T),l[S]=I/D,l[S+1]=M/D,l[S+2]=B/D,l[S+3]=R/D}return++T<s?w(T):a}(0)}bilinearFiltering(t,e,i,s,r){let n,a,l,c,h,d,u,g,p,f,b,m,y,w=0;const T=this.rcpScaleX,k=this.rcpScaleY,O=4*(e-1),E=t.imageData.data,S=t.ctx.createImageData(s,r),D=S.data;for(u=0;u<r;u++)for(g=0;g<s;g++)for(h=Math.floor(T*g),d=Math.floor(k*u),p=T*g-h,f=k*u-d,y=4*(d*e+h),b=0;b<4;b++)n=E[y+b],a=E[y+4+b],l=E[y+O+b],c=E[y+O+4+b],m=n*(1-p)*(1-f)+a*p*(1-f)+l*f*(1-p)+c*p*f,D[w++]=m;return S}hermiteFastResize(t,e,i,s,r){const n=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(n/2),c=Math.ceil(a/2),h=t.imageData.data,d=t.ctx.createImageData(s,r),u=d.data;for(let g=0;g<r;g++)for(let p=0;p<s;p++){const f=4*(p+g*s);let b=0,m=0,y=0,w=0,T=0,k=0,O=0;const E=(g+.5)*a;for(let S=Math.floor(g*a);S<(g+1)*a;S++){const D=Math.abs(E-(S+.5))/c,I=(p+.5)*n,M=D*D;for(let B=Math.floor(p*n);B<(p+1)*n;B++){let R=Math.abs(I-(B+.5))/l;const F=Math.sqrt(M+R*R);F>1&&F<-1||(b=2*F*F*F-3*F*F+1,b>0&&(R=4*(B+S*e),O+=b*h[R+3],y+=b,h[R+3]<255&&(b=b*h[R+3]/250),w+=b*h[R],T+=b*h[R+1],k+=b*h[R+2],m+=b))}}u[f]=w/m,u[f+1]=T/m,u[f+2]=k/m,u[f+3]=O/y}return d}}v(Tr,"type","Resize"),v(Tr,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(Tr,"uniformLocations",["uDelta","uTaps"]),P.setClass(Tr);class Er extends At{getFragmentSource(){return`
3090
+ `)}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){bo(t)?this.applyToForWebgl(t):this.applyTo2d(t)}isNeutralState(){return this.scaleX===1&&this.scaleY===1}lanczosCreate(t){return e=>{if(e>=t||e<=-t)return 0;if(e<11920929e-14&&e>-11920929e-14)return 1;const 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,n=e.height,a=Math.round(r*i),l=Math.round(n*s);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,r,n,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,r,n,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,r,n,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,r,n,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,s,r){const n=t.imageData,a=.5;let l=!1,c=!1,h=e*a,d=i*a;const u=t.filterBackend.resources;let g=0,p=0;const f=e;let b=0;u.sliceByTwo||(u.sliceByTwo=Oe());const m=u.sliceByTwo;(m.width<1.5*e||m.height<i)&&(m.width=1.5*e,m.height=i);const y=m.getContext("2d");for(y.clearRect(0,0,1.5*e,i),y.putImageData(n,0,0),s=Math.floor(s),r=Math.floor(r);!l||!c;)e=h,i=d,s<Math.floor(h*a)?h=Math.floor(h*a):(h=s,l=!0),r<Math.floor(d*a)?d=Math.floor(d*a):(d=r,c=!0),y.drawImage(m,g,p,e,i,f,b,h,d),g=f,p=b,b+=d;return y.getImageData(g,p,s,r)}lanczosResize(t,e,i,s,r){const n=t.imageData.data,a=t.ctx.createImageData(s,r),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,d=this.rcpScaleY,u=2/this.rcpScaleX,g=2/this.rcpScaleY,p=Math.ceil(h*this.lanczosLobes/2),f=Math.ceil(d*this.lanczosLobes/2),b={},m={x:0,y:0},y={x:0,y:0};return function w(T){let k,O,E,S,D,I,M,B,R,F,Y;for(m.x=(T+.5)*h,y.x=Math.floor(m.x),k=0;k<r;k++){for(m.y=(k+.5)*d,y.y=Math.floor(m.y),D=0,I=0,M=0,B=0,R=0,O=y.x-p;O<=y.x+p;O++)if(!(O<0||O>=e)){F=Math.floor(1e3*Math.abs(O-m.x)),b[F]||(b[F]={});for(let tt=y.y-f;tt<=y.y+f;tt++)tt<0||tt>=i||(Y=Math.floor(1e3*Math.abs(tt-m.y)),b[F][Y]||(b[F][Y]=c(Math.sqrt(Math.pow(F*u,2)+Math.pow(Y*g,2))/1e3)),E=b[F][Y],E>0&&(S=4*(tt*e+O),D+=E,I+=E*n[S],M+=E*n[S+1],B+=E*n[S+2],R+=E*n[S+3]))}S=4*(k*s+T),l[S]=I/D,l[S+1]=M/D,l[S+2]=B/D,l[S+3]=R/D}return++T<s?w(T):a}(0)}bilinearFiltering(t,e,i,s,r){let n,a,l,c,h,d,u,g,p,f,b,m,y,w=0;const T=this.rcpScaleX,k=this.rcpScaleY,O=4*(e-1),E=t.imageData.data,S=t.ctx.createImageData(s,r),D=S.data;for(u=0;u<r;u++)for(g=0;g<s;g++)for(h=Math.floor(T*g),d=Math.floor(k*u),p=T*g-h,f=k*u-d,y=4*(d*e+h),b=0;b<4;b++)n=E[y+b],a=E[y+4+b],l=E[y+O+b],c=E[y+O+4+b],m=n*(1-p)*(1-f)+a*p*(1-f)+l*f*(1-p)+c*p*f,D[w++]=m;return S}hermiteFastResize(t,e,i,s,r){const n=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(n/2),c=Math.ceil(a/2),h=t.imageData.data,d=t.ctx.createImageData(s,r),u=d.data;for(let g=0;g<r;g++)for(let p=0;p<s;p++){const f=4*(p+g*s);let b=0,m=0,y=0,w=0,T=0,k=0,O=0;const E=(g+.5)*a;for(let S=Math.floor(g*a);S<(g+1)*a;S++){const D=Math.abs(E-(S+.5))/c,I=(p+.5)*n,M=D*D;for(let B=Math.floor(p*n);B<(p+1)*n;B++){let R=Math.abs(I-(B+.5))/l;const F=Math.sqrt(M+R*R);F>1&&F<-1||(b=2*F*F*F-3*F*F+1,b>0&&(R=4*(B+S*e),O+=b*h[R+3],y+=b,h[R+3]<255&&(b=b*h[R+3]/250),w+=b*h[R],T+=b*h[R+1],k+=b*h[R+2],m+=b))}}u[f]=w/m,u[f+1]=T/m,u[f+2]=k/m,u[f+3]=O/y}return d}}v(Tr,"type","Resize"),v(Tr,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),v(Tr,"uniformLocations",["uDelta","uTaps"]),P.setClass(Tr);class Er extends Dt{getFragmentSource(){return`
3084
3091
  precision highp float;
3085
3092
  uniform sampler2D uTexture;
3086
3093
  uniform float uSaturation;
@@ -3094,7 +3101,7 @@ void main() {
3094
3101
  color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
3095
3102
  gl_FragColor = color;
3096
3103
  }
3097
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let s=0;s<e.length;s+=4){const r=e[s],n=e[s+1],a=e[s+2],l=Math.max(r,n,a);e[s]+=l!==r?(l-r)*i:0,e[s+1]+=l!==n?(l-n)*i:0,e[s+2]+=l!==a?(l-a)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}v(Er,"type","Saturation"),v(Er,"defaults",{saturation:0}),v(Er,"uniformLocations",["uSaturation"]),P.setClass(Er);class kr extends At{getFragmentSource(){return`
3104
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let s=0;s<e.length;s+=4){const r=e[s],n=e[s+1],a=e[s+2],l=Math.max(r,n,a);e[s]+=l!==r?(l-r)*i:0,e[s+1]+=l!==n?(l-n)*i:0,e[s+2]+=l!==a?(l-a)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}v(Er,"type","Saturation"),v(Er,"defaults",{saturation:0}),v(Er,"uniformLocations",["uSaturation"]),P.setClass(Er);class kr extends Dt{getFragmentSource(){return`
3098
3105
  precision highp float;
3099
3106
  uniform sampler2D uTexture;
3100
3107
  uniform float uVibrance;
@@ -3109,8 +3116,8 @@ void main() {
3109
3116
  color.b += max != color.b ? (max - color.b) * amt : 0.00;
3110
3117
  gl_FragColor = color;
3111
3118
  }
3112
- `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const r=e[s],n=e[s+1],a=e[s+2],l=Math.max(r,n,a),c=(r+n+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==r?(l-r)*h:0,e[s+1]+=l!==n?(l-n)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(kr,"type","Vibrance"),v(kr,"defaults",{vibrance:0}),v(kr,"uniformLocations",["uVibrance"]),P.setClass(kr);var Mm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,kt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Im(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Mm(t,e,s),s};let ct=class extends yt{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.imgLoading=!1,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 i=this.textBox.textLines;i.length>12&&this.textBox.set("text",i.slice(0,12).join(`
3113
- `)),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),this.imgLoading=!0,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.imgLoading=!1}),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 jt({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 Ke(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,textAlign:"left",selectable:!1,objectCaching:!1,paintFirst:"stroke",strokeWidth:.5}),this.canvas.add(this.textBox))}firstUpdated(){this.canvas=new qr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",selection:!1}),this.imgLoading=!0,this.backgroundImageUrl?this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{this.imgLoading=!1}).then(()=>{this.updateTextAreaPosition(),this.canvas.renderAll()}):(this.updateTextAreaPosition(),this.canvas.renderAll())}async appendBackgroundImageToCanvas(t,e){const i=await Kt.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),this.canvas.renderAll(),e&&e()}render(){return L`
3119
+ `}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let s=0;s<e.length;s+=4){const r=e[s],n=e[s+1],a=e[s+2],l=Math.max(r,n,a),c=(r+n+a)/3,h=2*Math.abs(l-c)/255*i;e[s]+=l!==r?(l-r)*h:0,e[s+1]+=l!==n?(l-n)*h:0,e[s+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}v(kr,"type","Vibrance"),v(kr,"defaults",{vibrance:0}),v(kr,"uniformLocations",["uVibrance"]),P.setClass(kr);var Mm=Object.defineProperty,Im=Object.getOwnPropertyDescriptor,Et=(o,t,e,i)=>{for(var s=i>1?void 0:i?Im(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Mm(t,e,s),s};let ht=class extends gt{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.imgLoading=!1,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 i=this.textBox.textLines;i.length>12&&this.textBox.set("text",i.slice(0,12).join(`
3120
+ `)),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),this.imgLoading=!0,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.imgLoading=!1}),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 jt({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 Je(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,textAlign:"left",selectable:!1,objectCaching:!1,paintFirst:"stroke",strokeWidth:.5}),this.canvas.add(this.textBox))}firstUpdated(){this.canvas=new qr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",selection:!1}),this.imgLoading=!0,this.backgroundImageUrl?this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{this.imgLoading=!1}).then(()=>{this.updateTextAreaPosition(),this.canvas.renderAll()}):(this.updateTextAreaPosition(),this.canvas.renderAll())}async appendBackgroundImageToCanvas(t,e){const i=await Kt.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),this.canvas.renderAll(),e&&e()}render(){return L`
3114
3121
  <div
3115
3122
  class="${pe({"type-canvas-container":!0,"image-loading":this.imgLoading})}
3116
3123
  "
@@ -3118,7 +3125,7 @@ void main() {
3118
3125
  <canvas class="base-canvas"></canvas>
3119
3126
  <pbo-image skeleton></pbo-image>
3120
3127
  </div>
3121
- `}};ct.styles=[pt,Vp];kt([C({attribute:"background-url"})],ct.prototype,"backgroundImageUrl",2);kt([C()],ct.prototype,"message",2);kt([C()],ct.prototype,"font",2);kt([C()],ct.prototype,"color",2);kt([C()],ct.prototype,"alignment",2);kt([V(".base-canvas")],ct.prototype,"baseCanvas",2);kt([$()],ct.prototype,"canvas",2);kt([$()],ct.prototype,"backgroundImage",2);kt([$()],ct.prototype,"backgroundFabImg",2);kt([$()],ct.prototype,"rect",2);kt([$()],ct.prototype,"textBox",2);kt([$()],ct.prototype,"areaPosition",2);kt([$()],ct.prototype,"imgLoading",2);kt([$()],ct.prototype,"areaSize",2);kt([N("alignment")],ct.prototype,"handleAlignmentChange",1);kt([N("color")],ct.prototype,"handleColorChange",1);kt([N("font")],ct.prototype,"handleFontChange",1);kt([N("message")],ct.prototype,"handleMessageChange",1);kt([N("backgroundImageUrl")],ct.prototype,"handleBackgroundImageUrlChange",1);ct=kt([ht("pbo-type-canvas")],ct);const Lb=ct,Lm=Q`
3128
+ `}};ht.styles=[pt,Vp];Et([C({attribute:"background-url"})],ht.prototype,"backgroundImageUrl",2);Et([C()],ht.prototype,"message",2);Et([C()],ht.prototype,"font",2);Et([C()],ht.prototype,"color",2);Et([C()],ht.prototype,"alignment",2);Et([H(".base-canvas")],ht.prototype,"baseCanvas",2);Et([$()],ht.prototype,"canvas",2);Et([$()],ht.prototype,"backgroundImage",2);Et([$()],ht.prototype,"backgroundFabImg",2);Et([$()],ht.prototype,"rect",2);Et([$()],ht.prototype,"textBox",2);Et([$()],ht.prototype,"areaPosition",2);Et([$()],ht.prototype,"imgLoading",2);Et([$()],ht.prototype,"areaSize",2);Et([V("alignment")],ht.prototype,"handleAlignmentChange",1);Et([V("color")],ht.prototype,"handleColorChange",1);Et([V("font")],ht.prototype,"handleFontChange",1);Et([V("message")],ht.prototype,"handleMessageChange",1);Et([V("backgroundImageUrl")],ht.prototype,"handleBackgroundImageUrlChange",1);ht=Et([dt("pbo-type-canvas")],ht);const Lb=ht,Lm=Q`
3122
3129
  :host {
3123
3130
  display: block;
3124
3131
  height: 100%;
@@ -3158,7 +3165,7 @@ void main() {
3158
3165
  .close-button svg:hover {
3159
3166
  scale: 1.1;
3160
3167
  }
3161
- `;var Fm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,Zs=(o,t,e,i)=>{for(var s=i>1?void 0:i?jm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Fm(t,e,s),s};let _i=class extends yt{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 L`
3168
+ `;var Fm=Object.defineProperty,jm=Object.getOwnPropertyDescriptor,Zs=(o,t,e,i)=>{for(var s=i>1?void 0:i?jm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Fm(t,e,s),s};let yi=class extends gt{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 L`
3162
3169
  <div class="panel">
3163
3170
  <div class="zoomed-preview">
3164
3171
  <div
@@ -3177,7 +3184,7 @@ void main() {
3177
3184
  </svg>
3178
3185
  </div>
3179
3186
  </div>
3180
- `}};_i.styles=[pt,Lm];Zs([C()],_i.prototype,"formData",2);Zs([C()],_i.prototype,"cardUrl",2);Zs([C()],_i.prototype,"close",2);Zs([C()],_i.prototype,"handwrittenPreviewProps",2);_i=Zs([ht("pbo-zoomed-preview")],_i);const jb=_i,$m=Q`
3187
+ `}};yi.styles=[pt,Lm];Zs([C()],yi.prototype,"formData",2);Zs([C()],yi.prototype,"cardUrl",2);Zs([C()],yi.prototype,"close",2);Zs([C()],yi.prototype,"handwrittenPreviewProps",2);yi=Zs([dt("pbo-zoomed-preview")],yi);const jb=yi,$m=Q`
3181
3188
  :host {
3182
3189
  display: block;
3183
3190
  }
@@ -3214,7 +3221,7 @@ void main() {
3214
3221
  background-color: rgb(255, 255, 255) !important;
3215
3222
  border-radius: 3.75px !important;
3216
3223
  }
3217
- `;var Bm=Object.defineProperty,Rm=Object.getOwnPropertyDescriptor,us=(o,t,e,i)=>{for(var s=i>1?void 0:i?Rm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Bm(t,e,s),s};let ii=class extends yt{constructor(){super(...arguments),this.hasSlotController=new zi(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1,this._handleDocumentClick=t=>{var i;const e=t.composedPath();this&&!e.includes(this)&&((i=this._choices)==null||i.hideDropdown())}}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():(t=this._choices)==null||t.enable()}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new Wl(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
3224
+ `;var Bm=Object.defineProperty,Rm=Object.getOwnPropertyDescriptor,ps=(o,t,e,i)=>{for(var s=i>1?void 0:i?Rm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Bm(t,e,s),s};let ri=class extends gt{constructor(){super(...arguments),this.hasSlotController=new zi(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1,this._handleDocumentClick=t=>{var i;const e=t.composedPath();this&&!e.includes(this)&&((i=this._choices)==null||i.hideDropdown())}}handleDisabledChanged(){var t;this._choices&&this.disabled?this._choices.disable():(t=this._choices)==null||t.enable()}get value(){var t;return(t=this._choices)==null?void 0:t.getValue().value}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged(),document.addEventListener("click",this._handleDocumentClick,!0)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._handleDocumentClick,!0)}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new Wl(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
3218
3225
  <div class="choice-wrapper">
3219
3226
  <span class="label">Type message
3220
3227
  <svg
@@ -3293,7 +3300,7 @@ void main() {
3293
3300
  ></path>
3294
3301
  </svg>
3295
3302
  </span>
3296
- </div>`}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.dispatchEvent(new CustomEvent("pbo-change",{detail:{value:i.value},bubbles:!0,composed:!0}))})}render(){const t=this.hasSlotController.test("label"),e=this.label?!0:!!t;return L` <div
3303
+ </div>`}],placeholder:!1,shouldSortItems:!1,itemSelectText:""}),this.choiceEl.addEventListener("change",e=>{const i=e.target;this.emit("pbo-editor-selector-change",{detail:{editor:i.value}})})}render(){const t=this.hasSlotController.test("label"),e=this.label?!0:!!t;return L` <div
3297
3304
  class=${pe({"form-control":!0,"form-control--small":this.size==="small","form-control--medium":this.size==="medium","form-control--large":this.size==="large","form-control--radio-group":!0,"form-control--has-label":e})}
3298
3305
  >
3299
3306
  <label
@@ -3305,7 +3312,7 @@ void main() {
3305
3312
  <slot name="label">${this.label}</slot>
3306
3313
  </label>
3307
3314
  </div>
3308
- <select part="base" class="js-choice"></select>`}};ii.styles=[pt,$m,Us,Zr(Gl)];us([C()],ii.prototype,"size",2);us([C()],ii.prototype,"label",2);us([C({type:Boolean,reflect:!0})],ii.prototype,"disabled",2);us([N("disabled",{waitUntilFirstUpdate:!0})],ii.prototype,"handleDisabledChanged",1);us([V(".js-choice")],ii.prototype,"choiceEl",2);ii=us([ht("pbo-editor-selector")],ii);const Bb=ii,zm=Q`
3315
+ <select part="base" class="js-choice"></select>`}};ri.styles=[pt,$m,Ws,Zr(Gl)];ps([C()],ri.prototype,"size",2);ps([C()],ri.prototype,"label",2);ps([C({type:Boolean,reflect:!0})],ri.prototype,"disabled",2);ps([V("disabled",{waitUntilFirstUpdate:!0})],ri.prototype,"handleDisabledChanged",1);ps([H(".js-choice")],ri.prototype,"choiceEl",2);ri=ps([dt("pbo-editor-selector")],ri);const Bb=ri,zm=Q`
3309
3316
  :host {
3310
3317
  display: block;
3311
3318
  }
@@ -3394,14 +3401,14 @@ void main() {
3394
3401
  display: flex;
3395
3402
  align-items: center;
3396
3403
  }
3397
- `;var Nm=Object.defineProperty,Vm=Object.getOwnPropertyDescriptor,Js=(o,t,e,i)=>{for(var s=i>1?void 0:i?Vm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Nm(t,e,s),s};let ze=class extends yt{constructor(){super(...arguments),this.loading=!1,this.loadingTime=0,this.loadingPattern="random",this.progress=0,this.loadingInterval=null,this.startTime=0,this.PHASES={QUICK:{target:90,duration:15e3},SLOW:{target:98,duration:3e4},FINAL:{target:100,duration:1e3}}}startLoading(){this.startTime=Date.now(),this.progress=0,this.loadingInterval&&clearInterval(this.loadingInterval),this.loadingInterval=window.setInterval(()=>{const t=Date.now()-this.startTime;if(this.progress<this.PHASES.QUICK.target)this.progress=Math.min(this.PHASES.QUICK.target,t/this.PHASES.QUICK.duration*this.PHASES.QUICK.target);else if(this.progress<this.PHASES.SLOW.target){const e=(t-this.PHASES.QUICK.duration)/this.PHASES.SLOW.duration;this.progress=Math.min(this.PHASES.SLOW.target,this.PHASES.QUICK.target+e*(this.PHASES.SLOW.target-this.PHASES.QUICK.target))}this.requestUpdate()},50)}completeLoading(){this.loadingInterval&&clearInterval(this.loadingInterval);const t=this.progress,e=Date.now();this.loadingInterval=window.setInterval(()=>{const i=Date.now()-e,s=Math.min(100,t+i/this.PHASES.FINAL.duration*(100-t));this.progress=s,s>=100&&this.stopLoading(),this.requestUpdate()},16)}stopLoading(){this.loadingInterval&&(clearInterval(this.loadingInterval),this.loadingInterval=null)}updated(t){t.has("loading")&&(this.loading?this.startLoading():this.completeLoading())}disconnectedCallback(){super.disconnectedCallback(),this.stopLoading()}render(){return L`<div
3404
+ `;var Nm=Object.defineProperty,Vm=Object.getOwnPropertyDescriptor,Js=(o,t,e,i)=>{for(var s=i>1?void 0:i?Vm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Nm(t,e,s),s};let He=class extends gt{constructor(){super(...arguments),this.loading=!1,this.loadingTime=0,this.loadingPattern="random",this.progress=0,this.loadingInterval=null,this.startTime=0,this.PHASES={QUICK:{target:90,duration:15e3},SLOW:{target:98,duration:3e4},FINAL:{target:100,duration:1e3}}}startLoading(){this.startTime=Date.now(),this.progress=0,this.loadingInterval&&clearInterval(this.loadingInterval),this.loadingInterval=window.setInterval(()=>{const t=Date.now()-this.startTime;if(this.progress<this.PHASES.QUICK.target)this.progress=Math.min(this.PHASES.QUICK.target,t/this.PHASES.QUICK.duration*this.PHASES.QUICK.target);else if(this.progress<this.PHASES.SLOW.target){const e=(t-this.PHASES.QUICK.duration)/this.PHASES.SLOW.duration;this.progress=Math.min(this.PHASES.SLOW.target,this.PHASES.QUICK.target+e*(this.PHASES.SLOW.target-this.PHASES.QUICK.target))}this.requestUpdate()},50)}completeLoading(){this.loadingInterval&&clearInterval(this.loadingInterval);const t=this.progress,e=Date.now();this.loadingInterval=window.setInterval(()=>{const i=Date.now()-e,s=Math.min(100,t+i/this.PHASES.FINAL.duration*(100-t));this.progress=s,s>=100&&this.stopLoading(),this.requestUpdate()},16)}stopLoading(){this.loadingInterval&&(clearInterval(this.loadingInterval),this.loadingInterval=null)}updated(t){t.has("loading")&&(this.loading?this.startLoading():this.completeLoading())}disconnectedCallback(){super.disconnectedCallback(),this.stopLoading()}render(){return L`<div
3398
3405
  class="${pe({"fake-loading":!0,"fake-loading--linear":this.loadingPattern==="linear","fake-loading--random":this.loadingPattern==="random","fake-loading--loading":!0})}"
3399
3406
  >
3400
3407
  <pbo-spinner
3401
3408
  style="${ue({"--track-width":"3px","--indicator-color":"black"})}"
3402
3409
  ></pbo-spinner>
3403
3410
  <span>${Math.round(this.progress)}%</span>
3404
- </div>`}};ze.styles=[pt,Hm];ze.dependencies={"pbo-spinner":ss};Js([C({type:Boolean,reflect:!0})],ze.prototype,"loading",2);Js([C({type:Number})],ze.prototype,"loadingTime",2);Js([C()],ze.prototype,"loadingPattern",2);Js([$()],ze.prototype,"progress",2);ze=Js([ht("pbo-fake-loading")],ze);var Um=Object.defineProperty,Wm=Object.getOwnPropertyDescriptor,dt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Wm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Um(t,e,s),s};let Z=class extends yt{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),{masked_img:"",uid:""}),this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isProcessingError=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={uid:null,masked_img: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)}setButtonsError(t){this.uploadButton&&this.saveButton&&(this.uploadButton.variant=t?"danger":"primary",this.saveButton.variant=t?"danger":"primary",this.uploadButton.value=t?"Error uploading image":"Upload Handwritten Image")}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleProcessingErrorChange(){this.setButtonsError(this.isProcessingError)}handleSourceImgChange(t,e){this.processedImg={uid:null,masked_img:null},this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing),this.emit("pbo-image-processing",{detail:{isLoading:this.isImageProcessing}})}get formData(){var s,r,n,a;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={pboCardId:((s=this.card)==null?void 0:s.pboId)||"Unknown",productId:(r=this.card)==null?void 0:r.productId,sku:(n=this.card)==null?void 0:n.sku,variantId:(a=this.card)==null?void 0:a.variantId,pred_image_uid:this.processedImg.uid||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return Kl(i)}setDimensions(t){this.handwrittenDimensions=t}handleProcessedImgChange(){this.processedImg.masked_img&&this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:this.processedImg.masked_img}})}async handleFileChange(t){var i,s;this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.isProcessingError=!1;const e=(s=(i=t.target)==null?void 0:i.files)==null?void 0:s[0];if(e!=null){this.sourceImg=e,this.isImageProcessing=!0,this.updateComplete.then(()=>{this.uploadButton.scrollIntoView(!0)});try{const r=await this.getProcessedImg(e);console.log(r),this.processedImg={masked_img:`data:image/png;base64,${r.masked_img}`,uid:r.uid}}catch{this.isProcessingError=!0}finally{this.isImageProcessing=!1}}}async handleSubmit(t){t.preventDefault(),this.isSubmitLoading=!0,this.isSubmitDisabled=!0;try{await this.submitHandwrittenForm(this.formData)}catch(e){console.error("Error submitting handwritten form:",e)}finally{this.isSubmitLoading=!1,this.isSubmitDisabled=!1}}render(){return L`
3411
+ </div>`}};He.styles=[pt,Hm];He.dependencies={"pbo-spinner":rs};Js([C({type:Boolean,reflect:!0})],He.prototype,"loading",2);Js([C({type:Number})],He.prototype,"loadingTime",2);Js([C()],He.prototype,"loadingPattern",2);Js([$()],He.prototype,"progress",2);He=Js([dt("pbo-fake-loading")],He);var Um=Object.defineProperty,Wm=Object.getOwnPropertyDescriptor,st=(o,t,e,i)=>{for(var s=i>1?void 0:i?Wm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Um(t,e,s),s};let Z=class extends gt{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),{masked_img:"",uid:""}),this.onClose=()=>{console.warn("onClose not implemented")},this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isProcessingError=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={uid:null,masked_img: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)}setButtonsError(t){this.uploadButton&&this.saveButton&&(this.uploadButton.variant=t?"danger":"primary",this.saveButton.variant=t?"danger":"primary",this.uploadButton.value=t?"Error uploading image":"Upload Handwritten Image")}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleProcessingErrorChange(){this.setButtonsError(this.isProcessingError)}handleSourceImgChange(t,e){this.processedImg={uid:null,masked_img:null},this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing),this.emit("pbo-image-processing",{detail:{isLoading:this.isImageProcessing}})}get formData(){var s,r,n,a;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={pboCardId:((s=this.card)==null?void 0:s.pboId)||"Unknown",productId:(r=this.card)==null?void 0:r.productId,sku:(n=this.card)==null?void 0:n.sku,variantId:(a=this.card)==null?void 0:a.variantId,pred_image_uid:this.processedImg.uid||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return Kl(i)}setDimensions(t){this.handwrittenDimensions=t}handleProcessedImgChange(){this.processedImg.masked_img&&this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:this.processedImg.masked_img}})}async handleFileChange(t){var i,s;this.sourceImg===null&&this.processedImg.masked_img===null?this.emit("pbo_edit_handwritten_form",{detail:{action:"upload"}}):this.emit("pbo_edit_handwritten_form",{detail:{action:"reupload"}}),this.sourceImg=null,this.processedImg={uid:null,masked_img:null},this.isProcessingError=!1;const e=(s=(i=t.target)==null?void 0:i.files)==null?void 0:s[0];if(e!=null){this.sourceImg=e,this.isImageProcessing=!0,this.updateComplete.then(()=>{this.uploadButton.scrollIntoView(!0)});try{const r=await this.getProcessedImg(e);console.log(r),this.processedImg={masked_img:`data:image/png;base64,${r.masked_img}`,uid:r.uid}}catch{this.isProcessingError=!0}finally{this.isImageProcessing=!1}}}async handleSubmit(t){t.preventDefault(),this.isSubmitLoading=!0,this.isSubmitDisabled=!0;try{await this.submitHandwrittenForm(this.formData),this.onClose(),this.emit("pbo-handwritten-form-submitted")}catch(e){console.error("Error submitting handwritten form:",e)}finally{this.isSubmitLoading=!1,this.isSubmitDisabled=!1}}render(){return L`
3405
3412
  <form name="handwritten-form" class="handwritten-form" @submit=${this.handleSubmit}>
3406
3413
  <div class="handwritten-tutorials">
3407
3414
  <section>
@@ -3465,6 +3472,7 @@ void main() {
3465
3472
  >
3466
3473
  Save and Continue
3467
3474
  </pbo-button>
3475
+
3468
3476
  <!-- Reupload button -->
3469
3477
  <pbo-button
3470
3478
  exportparts="base:cta-link-button-base, label:cta-link-button-label"
@@ -3479,7 +3487,7 @@ void main() {
3479
3487
  </pbo-button>
3480
3488
  </div>
3481
3489
  </form>
3482
- `}};Z.styles=[pt,zm];Z.dependencies={"pbo-button":et,"pbo-fake-loading":ze};dt([C()],Z.prototype,"card",2);dt([C()],Z.prototype,"submitHandwrittenForm",2);dt([C()],Z.prototype,"getProcessedImg",2);dt([C({type:Boolean,reflect:!0,attribute:"loading"})],Z.prototype,"isSubmitLoading",2);dt([C({type:Boolean,reflect:!0,attribute:"disabled"})],Z.prototype,"isSubmitDisabled",2);dt([V(".pixel-input")],Z.prototype,"imageInput",2);dt([V(".handwritten-form")],Z.prototype,"handwrittenForm",2);dt([V("pbo-button[name='upload']")],Z.prototype,"uploadButton",2);dt([V("pbo-button[name='save']")],Z.prototype,"saveButton",2);dt([V("pbo-button[name='reupload']")],Z.prototype,"reuploadButton",2);dt([$()],Z.prototype,"isProcessingError",2);dt([$()],Z.prototype,"isImageProcessing",2);dt([$()],Z.prototype,"sourceImg",2);dt([$()],Z.prototype,"processedImg",2);dt([$()],Z.prototype,"handwrittenDimensions",2);dt([N("isSubmitLoading")],Z.prototype,"handleSubmitLoadingChange",1);dt([N("isSubmitDisabled")],Z.prototype,"handleSubmitDisabledChange",1);dt([N("isProcessingError")],Z.prototype,"handleProcessingErrorChange",1);dt([N("sourceImg")],Z.prototype,"handleSourceImgChange",1);dt([N("processedFileUrl")],Z.prototype,"handleProcessImageChange",1);dt([N("isImageProcessing")],Z.prototype,"handleImageProcessingChange",1);dt([N("processedImg")],Z.prototype,"handleProcessedImgChange",1);Z=dt([ht("pbo-handwritten-form")],Z);const Hb=Z,Gm=Q`
3490
+ `}};Z.styles=[pt,zm];Z.dependencies={"pbo-button":et,"pbo-fake-loading":He};st([C()],Z.prototype,"card",2);st([C()],Z.prototype,"submitHandwrittenForm",2);st([C()],Z.prototype,"getProcessedImg",2);st([C({type:Function})],Z.prototype,"onClose",2);st([C({type:Boolean,reflect:!0,attribute:"loading"})],Z.prototype,"isSubmitLoading",2);st([C({type:Boolean,reflect:!0,attribute:"disabled"})],Z.prototype,"isSubmitDisabled",2);st([H(".pixel-input")],Z.prototype,"imageInput",2);st([H(".handwritten-form")],Z.prototype,"handwrittenForm",2);st([H("pbo-button[name='upload']")],Z.prototype,"uploadButton",2);st([H("pbo-button[name='save']")],Z.prototype,"saveButton",2);st([H("pbo-button[name='reupload']")],Z.prototype,"reuploadButton",2);st([$()],Z.prototype,"isProcessingError",2);st([$()],Z.prototype,"isImageProcessing",2);st([$()],Z.prototype,"sourceImg",2);st([$()],Z.prototype,"processedImg",2);st([$()],Z.prototype,"handwrittenDimensions",2);st([V("isSubmitLoading")],Z.prototype,"handleSubmitLoadingChange",1);st([V("isSubmitDisabled")],Z.prototype,"handleSubmitDisabledChange",1);st([V("isProcessingError")],Z.prototype,"handleProcessingErrorChange",1);st([V("sourceImg")],Z.prototype,"handleSourceImgChange",1);st([V("processedFileUrl")],Z.prototype,"handleProcessImageChange",1);st([V("isImageProcessing")],Z.prototype,"handleImageProcessingChange",1);st([V("processedImg")],Z.prototype,"handleProcessedImgChange",1);Z=st([dt("pbo-handwritten-form")],Z);const Hb=Z,Gm=Q`
3483
3491
  :host {
3484
3492
  display: block;
3485
3493
  width: 100%;
@@ -3507,7 +3515,7 @@ void main() {
3507
3515
  display: block;
3508
3516
  object-fit: contain;
3509
3517
  }
3510
- `;var Ym=Object.defineProperty,Xm=Object.getOwnPropertyDescriptor,Mt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Xm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Ym(t,e,s),s};let ut=class extends yt{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.uploadingText=void 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 Kt.fromURL(e),this.handwrittenImage.selectable=!0,this.handwrittenImage.lockRotation=!0,this.handwrittenImage.lockScalingFlip=!0,this.handwrittenImage.noScaleCache=!1;const i=this.areaSize.width/this.handwrittenImage.width,s=this.areaSize.height/this.handwrittenImage.height,r=Math.min(i,s);this.handwrittenImage.set({transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerSize:this.areaSize.width*(ui()?.06:.03),cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",touchCornerSize:this.areaSize.width*(ui()?.2:.06),scalingLimitations:"preserveAspectRatio",left:this.areaPosition.left,top:this.areaPosition.top,scaleX:r,scaleY:r,bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*r,width:this.handwrittenImage.width*r}),this.handwrittenImage.setControlsVisibility({tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1});const n=new jt({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:n}),this.handwrittenImage.on("scaling",a=>{const{top:l,left:c,height:h,width:d,scaleX:u,scaleY:g}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c,height:h*g,width:d*u})}),this.handwrittenImage.on("moving",a=>{const{top:l,left:c}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c})}),this.handwrittenImage.on("selected",()=>{var a,l;(a=this.rect)==null||a.set("visible",!0),(l=this.handwrittenImage)==null||l.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 a,l,c;(a=this.rect)==null||a.set("visible",!1),(l=this.handwrittenImage)==null||l.set({clipPath:n}),(c=this.clipMaskOverlay)==null||c.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:n}=this.areaSize,a="rgba(0,0,0,0.1)",l=new jt({left:0,top:0,width:t,height:s,fill:a,selectable:!1,evented:!1}),c=new jt({left:0,top:s+n,width:t,height:e-(s+n),fill:a,selectable:!1,evented:!1}),h=new jt({left:0,top:s,width:i,height:n,fill:a,selectable:!1,evented:!1}),d=new jt({left:i+r,top:s,width:t-(i+r),height:n,fill:a,selectable:!1,evented:!1});return new gi([l,c,h,d],{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 jt({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 i,s,r;this.applyHandwrittenImageDimensions(),(i=this.canvas)==null||i.renderAll(),this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft,top:this.imageTop,width:this.imageWidth,height:this.imageHeight,cardHeight:((s=this.backgroundFabImg)==null?void 0:s.height)||0,cardWidth:((r=this.backgroundFabImg)==null?void 0:r.width)||0}})},300)}applyHandwrittenImageDimensions(){!xs(this.handwrittenImage)||!xs(this.imageLeft)||!xs(this.imageTop)||!xs(this.imageWidth)||!xs(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;if(!e&&!i&&!s&&!r){console.warn("Invalid dimensions provided for handwritten image");return}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)}firstUpdated(){this.canvas=new qr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0}),this.backgroundImageUrl?this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}).then(()=>{this.updateProcessedImgAreaPosition(),this.uploadingText=new Ke("Uploading",{left:this.areaPosition.left,top:this.areaPosition.top+this.areaSize.height/2-this.areaSize.height/13/1.1,width:this.areaSize.width,textAlign:"center",fontSize:this.areaSize.height/13/1.1,fontFamily:"Arial",selectable:!1,evented:!1}),this.canvas.renderAll()}):(this.updateProcessedImgAreaPosition(),this.canvas.renderAll()),document.addEventListener("pbo-image-processing",t=>{const e=t.detail.isLoading;this.uploadingText&&(e?this.canvas.add(this.uploadingText):this.canvas.remove(this.uploadingText),this.canvas.renderAll())})}async appendBackgroundImageToCanvas(t,e){const i=await Kt.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),this.canvas.renderAll(),e&&e()}render(){return L`<canvas class="base-canvas"></canvas> `}};ut.styles=[pt,Gm];Mt([C({attribute:"background-url"})],ut.prototype,"backgroundImageUrl",2);Mt([C({attribute:"handwritten-url"})],ut.prototype,"handwrittenImageUrl",2);Mt([C({type:Number,reflect:!0,attribute:"height"})],ut.prototype,"imageHeight",2);Mt([C({type:Number,reflect:!0,attribute:"width"})],ut.prototype,"imageWidth",2);Mt([C({type:Number,reflect:!0,attribute:"left"})],ut.prototype,"imageLeft",2);Mt([C({type:Number,reflect:!0,attribute:"top"})],ut.prototype,"imageTop",2);Mt([V(".base-canvas")],ut.prototype,"baseCanvas",2);Mt([$()],ut.prototype,"canvas",2);Mt([$()],ut.prototype,"backgroundFabImg",2);Mt([$()],ut.prototype,"rect",2);Mt([$()],ut.prototype,"areaPosition",2);Mt([$()],ut.prototype,"uploadingText",2);Mt([$()],ut.prototype,"handwrittenImage",2);Mt([$()],ut.prototype,"clipMaskOverlay",2);Mt([$()],ut.prototype,"areaSize",2);Mt([N("backgroundImageUrl")],ut.prototype,"handleBackgroundImageUrlChange",1);Mt([N("handwrittenImageUrl")],ut.prototype,"handleHandwrittenImageUrlChange",1);Mt([N("imageLeft"),N("imageTop"),N("imageWidth"),N("imageHeight")],ut.prototype,"handleHandwrittenImageDimensionsChange",1);ut=Mt([ht("pbo-handwritten-canvas")],ut);const Vb=ut,qm=Q`
3518
+ `;var Ym=Object.defineProperty,Xm=Object.getOwnPropertyDescriptor,Mt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Xm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Ym(t,e,s),s};let ut=class extends gt{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.uploadingText=void 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 Kt.fromURL(e),this.handwrittenImage.selectable=!0,this.handwrittenImage.lockRotation=!0,this.handwrittenImage.lockScalingFlip=!0,this.handwrittenImage.noScaleCache=!1;const i=this.areaSize.width/this.handwrittenImage.width,s=this.areaSize.height/this.handwrittenImage.height,r=Math.min(i,s);this.handwrittenImage.set({transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerSize:this.areaSize.width*(gi()?.06:.03),cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",touchCornerSize:this.areaSize.width*(gi()?.2:.06),scalingLimitations:"preserveAspectRatio",left:this.areaPosition.left,top:this.areaPosition.top,scaleX:r,scaleY:r,bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*r,width:this.handwrittenImage.width*r}),this.handwrittenImage.setControlsVisibility({tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1});const n=new jt({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:n}),this.handwrittenImage.on("scaling",a=>{const{top:l,left:c,height:h,width:d,scaleX:u,scaleY:g}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c,height:h*g,width:d*u})}),this.handwrittenImage.on("moving",a=>{const{top:l,left:c}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c})}),this.handwrittenImage.on("selected",()=>{var a,l;(a=this.rect)==null||a.set("visible",!0),(l=this.handwrittenImage)==null||l.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 a,l,c;(a=this.rect)==null||a.set("visible",!1),(l=this.handwrittenImage)==null||l.set({clipPath:n}),(c=this.clipMaskOverlay)==null||c.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:n}=this.areaSize,a="rgba(0,0,0,0.1)",l=new jt({left:0,top:0,width:t,height:s,fill:a,selectable:!1,evented:!1}),c=new jt({left:0,top:s+n,width:t,height:e-(s+n),fill:a,selectable:!1,evented:!1}),h=new jt({left:0,top:s,width:i,height:n,fill:a,selectable:!1,evented:!1}),d=new jt({left:i+r,top:s,width:t-(i+r),height:n,fill:a,selectable:!1,evented:!1});return new mi([l,c,h,d],{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 jt({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 i,s,r;this.applyHandwrittenImageDimensions(),(i=this.canvas)==null||i.renderAll(),this.emit("handwritten-image-dimensions-changed",{detail:{left:this.imageLeft,top:this.imageTop,width:this.imageWidth,height:this.imageHeight,cardHeight:((s=this.backgroundFabImg)==null?void 0:s.height)||0,cardWidth:((r=this.backgroundFabImg)==null?void 0:r.width)||0}})},300)}applyHandwrittenImageDimensions(){!ws(this.handwrittenImage)||!ws(this.imageLeft)||!ws(this.imageTop)||!ws(this.imageWidth)||!ws(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;if(!e&&!i&&!s&&!r){console.warn("Invalid dimensions provided for handwritten image");return}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)}firstUpdated(){this.canvas=new qr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0}),this.backgroundImageUrl?this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}).then(()=>{this.updateProcessedImgAreaPosition(),this.uploadingText=new Je("Uploading",{left:this.areaPosition.left,top:this.areaPosition.top+this.areaSize.height/2-this.areaSize.height/13/1.1,width:this.areaSize.width,textAlign:"center",fontSize:this.areaSize.height/13/1.1,fontFamily:"Arial",selectable:!1,evented:!1}),this.canvas.renderAll()}):(this.updateProcessedImgAreaPosition(),this.canvas.renderAll()),document.addEventListener("pbo-image-processing",t=>{const e=t.detail.isLoading;this.uploadingText&&(e?this.canvas.add(this.uploadingText):this.canvas.remove(this.uploadingText),this.canvas.renderAll())})}async appendBackgroundImageToCanvas(t,e){const i=await Kt.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),this.canvas.renderAll(),e&&e()}render(){return L`<canvas class="base-canvas"></canvas> `}};ut.styles=[pt,Gm];Mt([C({attribute:"background-url"})],ut.prototype,"backgroundImageUrl",2);Mt([C({attribute:"handwritten-url"})],ut.prototype,"handwrittenImageUrl",2);Mt([C({type:Number,reflect:!0,attribute:"height"})],ut.prototype,"imageHeight",2);Mt([C({type:Number,reflect:!0,attribute:"width"})],ut.prototype,"imageWidth",2);Mt([C({type:Number,reflect:!0,attribute:"left"})],ut.prototype,"imageLeft",2);Mt([C({type:Number,reflect:!0,attribute:"top"})],ut.prototype,"imageTop",2);Mt([H(".base-canvas")],ut.prototype,"baseCanvas",2);Mt([$()],ut.prototype,"canvas",2);Mt([$()],ut.prototype,"backgroundFabImg",2);Mt([$()],ut.prototype,"rect",2);Mt([$()],ut.prototype,"areaPosition",2);Mt([$()],ut.prototype,"uploadingText",2);Mt([$()],ut.prototype,"handwrittenImage",2);Mt([$()],ut.prototype,"clipMaskOverlay",2);Mt([$()],ut.prototype,"areaSize",2);Mt([V("backgroundImageUrl")],ut.prototype,"handleBackgroundImageUrlChange",1);Mt([V("handwrittenImageUrl")],ut.prototype,"handleHandwrittenImageUrlChange",1);Mt([V("imageLeft"),V("imageTop"),V("imageWidth"),V("imageHeight")],ut.prototype,"handleHandwrittenImageDimensionsChange",1);ut=Mt([dt("pbo-handwritten-canvas")],ut);const Vb=ut,qm=Q`
3511
3519
  :host {
3512
3520
  display: block;
3513
3521
  width: auto;
@@ -3565,7 +3573,7 @@ void main() {
3565
3573
  resize: vertical;
3566
3574
  min-height: 96px;
3567
3575
  }
3568
- `;var Km=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,Rt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Zm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Km(t,e,s),s};let _t=class extends yt{constructor(){super(...arguments),this.hasSlotController=new zi(this,"is-gift-label","premium-card-label","free-message-label"),this.hidden=!1,this.expand=!1,this.divided=!1,this.freeMessage="",this.isGift=!1,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.debouncedFreeMessageChange=()=>{}}handleOnFreeMessageChange(){this.onFreeMessageChange&&(this.debouncedFreeMessageChange=Nu(this.onFreeMessageChange,300))}handleIsGiftChange(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1}handleIsFreeMessageCheckedChange(){var t;console.debug("isFreeMessageChecked",this.isFreeMessageChecked),this.isFreeMessageChecked&&(this.isPremiumChecked=!1),this.isFreeMessageChecked||(this.freeMessage="",console.debug("freeMessage is empty"),console.debug("onFreeMessageClear",this.onFreeMessageClear),(t=this.onFreeMessageClear)==null||t.call(this))}handleIsPremiumCheckedChange(){var t;this.isPremiumChecked?(this.isFreeMessageChecked=!1,this.emit("pbo-open-drawer")):this.emit("pbo-close-drawer"),(t=this.onPremiumSelected)==null||t.call(this,this.isPremiumChecked)}handleFreeMessageChange(){var t;this.freeMessage===""?(console.debug("freeMessage is empty"),(t=this.onFreeMessageClear)==null||t.call(this)):this.debouncedFreeMessageChange&&this.debouncedFreeMessageChange(this.freeMessage)}firstUpdated(){this.expand&&(this.isGift=!0)}setGiftOptionEnabled(t){this.isGift=t}setPremiumEnabled(t){this.isPremiumChecked=t}setFreeMessageEnabled(t){this.isFreeMessageChecked=t}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("premium-card-description"),s=this.hasSlotController.test("free-message-label");return L`
3576
+ `;var Km=Object.defineProperty,Zm=Object.getOwnPropertyDescriptor,Rt=(o,t,e,i)=>{for(var s=i>1?void 0:i?Zm(t,e):t,r=o.length-1,n;r>=0;r--)(n=o[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&Km(t,e,s),s};let yt=class extends gt{constructor(){super(...arguments),this.hasSlotController=new zi(this,"is-gift-label","premium-card-label","free-message-label"),this.hidden=!1,this.expand=!1,this.divided=!1,this.freeMessage="",this.isGift=!1,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.debouncedFreeMessageChange=()=>{}}handleOnFreeMessageChange(){this.onFreeMessageChange&&(this.debouncedFreeMessageChange=Nu(this.onFreeMessageChange,300))}handleIsGiftChange(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.emit("pbo_toggle_is_gift",{detail:{is_checked:this.isGift}})}handleIsFreeMessageCheckedChange(){var t;console.debug("isFreeMessageChecked",this.isFreeMessageChecked),this.isFreeMessageChecked&&(this.isPremiumChecked=!1),this.isFreeMessageChecked||(this.freeMessage="",console.debug("freeMessage is empty"),console.debug("onFreeMessageClear",this.onFreeMessageClear),(t=this.onFreeMessageClear)==null||t.call(this)),this.emit("pbo_toggle_free_message",{detail:{is_checked:this.isFreeMessageChecked}})}handleIsPremiumCheckedChange(){var t;this.isPremiumChecked?(this.isFreeMessageChecked=!1,this.emit("pbo-open-drawer")):this.emit("pbo-close-drawer"),(t=this.onPremiumSelected)==null||t.call(this,this.isPremiumChecked),this.emit("pbo_toggle_is_premium_card",{detail:{is_checked:this.isPremiumChecked}})}handleFreeMessageChange(){var t;this.freeMessage===""?(console.debug("freeMessage is empty"),(t=this.onFreeMessageClear)==null||t.call(this)):this.debouncedFreeMessageChange&&this.debouncedFreeMessageChange(this.freeMessage)}firstUpdated(){this.expand&&(this.isGift=!0)}setGiftOptionEnabled(t){this.isGift=t}setPremiumEnabled(t){this.isPremiumChecked=t}setFreeMessageEnabled(t){this.isFreeMessageChecked=t}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("premium-card-description"),s=this.hasSlotController.test("free-message-label");return L`
3569
3577
  <div part="base" class="gift-options" ?hidden=${this.hidden}>
3570
3578
  <!-- 🎁 Is this a gift -->
3571
3579
  <div class="is-gift" part="is-gift option-container" ?hidden=${!t}>
@@ -3625,4 +3633,4 @@ void main() {
3625
3633
  </div>
3626
3634
  <hr part="divider" class="divider" ?hidden=${!this.divided||!this.isGift} />
3627
3635
  </div>
3628
- `}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};_t.styles=[pt,qm];_t.dependencies={"pbo-textarea":lt};Rt([C({type:Function})],_t.prototype,"onPremiumSelected",2);Rt([C({type:Function})],_t.prototype,"onFreeMessageChange",2);Rt([C({type:Function})],_t.prototype,"onFreeMessageClear",2);Rt([C({type:Boolean,reflect:!0})],_t.prototype,"hidden",2);Rt([C({type:Boolean,reflect:!0})],_t.prototype,"expand",2);Rt([C({type:Boolean,reflect:!0})],_t.prototype,"divided",2);Rt([C()],_t.prototype,"freeMessage",2);Rt([C()],_t.prototype,"isGift",2);Rt([C()],_t.prototype,"isPremiumChecked",2);Rt([C()],_t.prototype,"isFreeMessageChecked",2);Rt([$()],_t.prototype,"debouncedFreeMessageChange",2);Rt([N("onFreeMessageChange")],_t.prototype,"handleOnFreeMessageChange",1);Rt([N("isGift")],_t.prototype,"handleIsGiftChange",1);Rt([N("isFreeMessageChecked")],_t.prototype,"handleIsFreeMessageCheckedChange",1);Rt([N("isPremiumChecked")],_t.prototype,"handleIsPremiumCheckedChange",1);Rt([N("freeMessage")],_t.prototype,"handleFreeMessageChange",1);_t=Rt([ht("pbo-gift-options")],_t);const Wb=_t,Gb=ss,Yb=oe,Xb=ze;export{jr as MessageSelector,hb as PboButton,ub as PboButtonGroup,Mb as PboCardSelection,kb as PboCategory,Ob as PboDrawer,Cb as PboEditor,Tb as PboEditorCardSlider,Bb as PboEditorSelector,Xb as PboFakeLoading,je as PboFontSelector,Wb as PboGiftOption,Vb as PboHandwrittenCanvas,Hb as PboHandwrittenForm,Yb as PboImage,Ab as PboPageManager,gb as PboRadioButton,mb as PboRadioGroup,Gb as PboSpinner,vb as PboTextarea,Lb as PboTypeCanvas,Sb as PboTypeForm,jb as PboZoomedPreview};
3636
+ `}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};yt.styles=[pt,qm];yt.dependencies={"pbo-textarea":ct};Rt([C({type:Function})],yt.prototype,"onPremiumSelected",2);Rt([C({type:Function})],yt.prototype,"onFreeMessageChange",2);Rt([C({type:Function})],yt.prototype,"onFreeMessageClear",2);Rt([C({type:Boolean,reflect:!0})],yt.prototype,"hidden",2);Rt([C({type:Boolean,reflect:!0})],yt.prototype,"expand",2);Rt([C({type:Boolean,reflect:!0})],yt.prototype,"divided",2);Rt([C()],yt.prototype,"freeMessage",2);Rt([C()],yt.prototype,"isGift",2);Rt([C()],yt.prototype,"isPremiumChecked",2);Rt([C()],yt.prototype,"isFreeMessageChecked",2);Rt([$()],yt.prototype,"debouncedFreeMessageChange",2);Rt([V("onFreeMessageChange")],yt.prototype,"handleOnFreeMessageChange",1);Rt([V("isGift")],yt.prototype,"handleIsGiftChange",1);Rt([V("isFreeMessageChecked")],yt.prototype,"handleIsFreeMessageCheckedChange",1);Rt([V("isPremiumChecked")],yt.prototype,"handleIsPremiumCheckedChange",1);Rt([V("freeMessage")],yt.prototype,"handleFreeMessageChange",1);yt=Rt([dt("pbo-gift-options")],yt);const Wb=yt,Gb=rs,Yb=oe,Xb=He;export{jr as MessageSelector,hb as PboButton,ub as PboButtonGroup,Mb as PboCardSelection,kb as PboCategory,Ob as PboDrawer,Cb as PboEditor,Tb as PboEditorCardSlider,Bb as PboEditorSelector,Xb as PboFakeLoading,$e as PboFontSelector,Wb as PboGiftOption,Vb as PboHandwrittenCanvas,Hb as PboHandwrittenForm,Yb as PboImage,Ab as PboPageManager,gb as PboRadioButton,mb as PboRadioGroup,Gb as PboSpinner,vb as PboTextarea,Lb as PboTypeCanvas,Sb as PboTypeForm,jb as PboZoomedPreview};