@pairbo/ui-kit 0.2.5 → 0.2.6
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/README.md +186 -0
- package/dist/assets/page-manager.component-Dzd6xKY5.js +307 -0
- package/dist/defaultTheme.css +1 -0
- package/dist/pboBridge.js +1 -0
- package/dist/ui-kit.js +2902 -0
- package/package.json +8 -10
- package/dist/pairbo.es.js +0 -21415
- package/dist/pairbo.umd.js +0 -2616
package/dist/ui-kit.js
ADDED
|
@@ -0,0 +1,2902 @@
|
|
|
1
|
+
import{e as ou,i as vt,r as Xo,x as X,t as Ot,c as Pt,n as O,a as q,b as $,w as et,d as kn,f as ni,E as Ko,P as Bt,g as qo,h as Zo,j as Fi,T as Rr,Z as au,B as lu,k as cu,l as hu}from"./assets/page-manager.component-Dzd6xKY5.js";/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2017 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/let uu;function Jo(n){return(t,e)=>ou(t,e,{get(){return(this.renderRoot??uu??(uu=document.createDocumentFragment())).querySelectorAll(n)}})}const du=vt`
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
font-family: Arial, sans-serif;
|
|
9
|
+
}
|
|
10
|
+
.message-selector {
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
padding: 1rem;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
background-color: #fff;
|
|
15
|
+
color: black;
|
|
16
|
+
}
|
|
17
|
+
`;var pu=Object.getOwnPropertyDescriptor,fu=(n,t,e,i)=>{for(var r=i>1?void 0:i?pu(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};let hn=class extends Xo{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 n=(t=this.shadowRoot)==null?void 0:t.querySelector(".message-selector");n&&n.classList.toggle("message-selector-hidden")}_onGiftChange(n){const t=n.target;this.giftSelected=t.checked,this.giftSelected||(this.premiumSelected=!1,this.freeMessageSelected=!1)}_onPremiumChange(n){n.target.checked?(this.premiumSelected=!0,this.freeMessageSelected=!1):this.premiumSelected=!1}_onFreeMessageChange(n){n.target.checked?(this.freeMessageSelected=!0,this.premiumSelected=!1):this.freeMessageSelected=!1}render(){return X`
|
|
18
|
+
<div class="message-selector">
|
|
19
|
+
<!-- Gift Checkbox: Always visible -->
|
|
20
|
+
<div>
|
|
21
|
+
<input
|
|
22
|
+
type="checkbox"
|
|
23
|
+
id="is-gift"
|
|
24
|
+
name="is-gift"
|
|
25
|
+
.checked=${this.giftSelected}
|
|
26
|
+
@change=${this._onGiftChange}
|
|
27
|
+
/>
|
|
28
|
+
<label for="is-gift">${this.giftLabel}</label>
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<!-- Premium and Free Message Options: Only visible if gift is selected -->
|
|
32
|
+
${this.giftSelected?X`
|
|
33
|
+
<div>
|
|
34
|
+
<input
|
|
35
|
+
type="checkbox"
|
|
36
|
+
id="premium-card"
|
|
37
|
+
name="premium-card"
|
|
38
|
+
value="premium-card"
|
|
39
|
+
.checked=${this.premiumSelected}
|
|
40
|
+
@change=${this._onPremiumChange}
|
|
41
|
+
/>
|
|
42
|
+
<label for="premium-card">${this.premiumLabel}</label>
|
|
43
|
+
<p class="description">${this.premiumDescription}</p>
|
|
44
|
+
</div>
|
|
45
|
+
<div>
|
|
46
|
+
<input
|
|
47
|
+
type="checkbox"
|
|
48
|
+
id="free-message"
|
|
49
|
+
name="free-message"
|
|
50
|
+
value="free-message"
|
|
51
|
+
.checked=${this.freeMessageSelected}
|
|
52
|
+
@change=${this._onFreeMessageChange}
|
|
53
|
+
/>
|
|
54
|
+
<label for="free-message">${this.noteLabel}</label>
|
|
55
|
+
</div>
|
|
56
|
+
`:null}
|
|
57
|
+
|
|
58
|
+
<!-- Display current selection summary -->
|
|
59
|
+
<div class="current-selection">
|
|
60
|
+
<strong>Current Selection:</strong>
|
|
61
|
+
<ul>
|
|
62
|
+
<li>Gift: ${this.giftSelected?"Yes":"No"}</li>
|
|
63
|
+
<li>Premium Card: ${this.premiumSelected?"Yes":"No"}</li>
|
|
64
|
+
<li>Free Message: ${this.freeMessageSelected?"Yes":"No"}</li>
|
|
65
|
+
</ul>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
`}};hn.styles=[du,vt`
|
|
69
|
+
.message-selector {
|
|
70
|
+
text-align: left;
|
|
71
|
+
}
|
|
72
|
+
.message-selector > div {
|
|
73
|
+
margin-bottom: 1rem;
|
|
74
|
+
}
|
|
75
|
+
.message-selector-hidden {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
pre {
|
|
79
|
+
background: #f7f7f7;
|
|
80
|
+
padding: 1rem;
|
|
81
|
+
border: 1px solid #ddd;
|
|
82
|
+
border-radius: 4px;
|
|
83
|
+
overflow-x: auto;
|
|
84
|
+
margin-top: 1rem;
|
|
85
|
+
}
|
|
86
|
+
code {
|
|
87
|
+
font-family: monospace;
|
|
88
|
+
}
|
|
89
|
+
`];hn.properties={giftLabel:{type:String},premiumLabel:{type:String},premiumDescription:{type:String},noteLabel:{type:String},giftSelected:{type:Boolean},premiumSelected:{type:Boolean},freeMessageSelected:{type:Boolean}};hn=fu([Ot("pairbo-message-selector")],hn);function b(n,t,e){return(t=function(i){var r=function(s,o){if(typeof s!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var l=a.call(s,o);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(o==="string"?String:Number)(s)}(i,"string");return typeof r=="symbol"?r:r+""}(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Ba(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,i)}return e}function _(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Ba(Object(e),!0).forEach(function(i){b(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Ba(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function ht(n,t){if(n==null)return{};var e,i,r=function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.indexOf(c)>=0)continue;l[c]=o[c]}return l}(n,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i<s.length;i++)e=s[i],t.indexOf(e)>=0||{}.propertyIsEnumerable.call(n,e)&&(r[e]=n[e])}return r}function ki(n,t){return t||(t=n.slice(0)),Object.freeze(Object.defineProperties(n,{raw:{value:Object.freeze(t)}}))}let Na=class{constructor(){b(this,"browserShadowBlurConstant",1),b(this,"DPI",96),b(this,"devicePixelRatio",typeof window<"u"?window.devicePixelRatio:1),b(this,"perfLimitSizeTotal",2097152),b(this,"maxCacheSideLimit",4096),b(this,"minCacheSideLimit",256),b(this,"disableStyleCopyPaste",!1),b(this,"enableGLFiltering",!0),b(this,"textureSize",4096),b(this,"forceGLPutImageData",!1),b(this,"cachesBoundsOfCurve",!1),b(this,"fontPaths",{}),b(this,"NUM_FRACTION_DIGITS",4)}};const Q=new class extends Na{constructor(n){super(),this.configure(n)}configure(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Object.assign(this,n)}addFonts(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.fontPaths=_(_({},this.fontPaths),n)}removeFonts(){(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).forEach(n=>{delete this.fontPaths[n]})}clearFonts(){this.fontPaths={}}restoreDefaults(n){const t=new Na,e=(n==null?void 0:n.reduce((i,r)=>(i[r]=t[r],i),{}))||t;this.configure(e)}},yi=function(n){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[n]("fabric",...e)};let je=class extends Error{constructor(t,e){super("fabric: ".concat(t),e)}};class gu extends je{constructor(t){super("".concat(t," 'options.signal' is in 'aborted' state"))}}let mu=class{},vu=class extends mu{testPrecision(t,e){const i="precision ".concat(e,` float;
|
|
90
|
+
void main(){}`),r=t.createShader(t.FRAGMENT_SHADER);return!!r&&(t.shaderSource(r,i),t.compileShader(r),!!t.getShaderParameter(r,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(),yi("log","WebGL: max texture size ".concat(this.maxTextureSize)))}isSupported(t){return!!this.maxTextureSize&&this.maxTextureSize>=t}};const bu={};let za;const Be=()=>za||(za={document,window,isTouchSupported:"ontouchstart"in window||"ontouchstart"in document||window&&window.navigator&&window.navigator.maxTouchPoints>0,WebGLProbe:new vu,dispose(){},copyPasteData:bu}),vr=()=>Be().document,Qo=()=>Be().window,sc=()=>{var n;return Math.max((n=Q.devicePixelRatio)!==null&&n!==void 0?n:Qo().devicePixelRatio,1)},zr=new class{constructor(){b(this,"charWidthsCache",{}),b(this,"boundsOfCurveCache",{})}getFontCache(n){let{fontFamily:t,fontStyle:e,fontWeight:i}=n;t=t.toLowerCase(),this.charWidthsCache[t]||(this.charWidthsCache[t]={});const r=this.charWidthsCache[t],s="".concat(e.toLowerCase(),"_").concat((i+"").toLowerCase());return r[s]||(r[s]={}),r[s]}clearFontCache(n){(n=(n||"").toLowerCase())?this.charWidthsCache[n]&&delete this.charWidthsCache[n]:this.charWidthsCache={}}limitDimsByArea(n){const{perfLimitSizeTotal:t}=Q,e=Math.sqrt(t*n);return[Math.floor(e),Math.floor(t/e)]}},xo="6.5.4";function tn(){}const cs=Math.PI/2,un=2*Math.PI,ta=Math.PI/180,Qt=Object.freeze([1,0,0,1,0,0]),ea=16,fi=.4477152502,K="center",it="left",ne="top",wo="bottom",xt="right",oe="none",ia=/\r?\n/,nc="moving",Dn="scaling",oc="rotating",ra="rotate",ac="skewing",Yr="resizing",_u="modifyPoly",yu="modifyPath",dn="changed",Pn="scale",le="scaleX",xe="scaleY",br="skewX",_r="skewY",It="fill",ae="stroke",pn="modified",Ji="json",Jn="svg",R=new class{constructor(){this[Ji]=new Map,this[Jn]=new Map}has(n){return this[Ji].has(n)}getClass(n){const t=this[Ji].get(n);if(!t)throw new je("No class registered for ".concat(n));return t}setClass(n,t){t?this[Ji].set(t,n):(this[Ji].set(n.type,n),this[Ji].set(n.type.toLowerCase(),n))}getSVGClass(n){return this[Jn].get(n)}setSVGClass(n,t){this[Jn].set(t??n.type.toLowerCase(),n)}},fn=new class extends Array{remove(n){const t=this.indexOf(n);t>-1&&this.splice(t,1)}cancelAll(){const n=this.splice(0);return n.forEach(t=>t.abort()),n}cancelByCanvas(n){if(!n)return[];const t=this.filter(e=>{var i;return e.target===n||typeof e.target=="object"&&((i=e.target)===null||i===void 0?void 0:i.canvas)===n});return t.forEach(e=>e.abort()),t}cancelByTarget(n){if(!n)return[];const t=this.filter(e=>e.target===n);return t.forEach(e=>e.abort()),t}};class xu{constructor(){b(this,"__eventListeners",{})}on(t,e){if(this.__eventListeners||(this.__eventListeners={}),typeof t=="object")return Object.entries(t).forEach(i=>{let[r,s]=i;this.on(r,s)}),()=>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(r=>{let[s,o]=r;i.push(this.once(s,o))}),()=>i.forEach(r=>r())}if(e){const i=this.on(t,function(){for(var r=arguments.length,s=new Array(r),o=0;o<r;o++)s[o]=arguments[o];e.call(this,...s),i()});return i}return()=>!1}_removeEventListener(t,e){if(this.__eventListeners[t])if(e){const i=this.__eventListeners[t],r=i.indexOf(e);r>-1&&i.splice(r,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[r,s]=i;this._removeEventListener(r,s)}):this._removeEventListener(t,e)}fire(t,e){var i;if(!this.__eventListeners)return;const r=(i=this.__eventListeners[t])===null||i===void 0?void 0:i.concat();if(r)for(let s=0;s<r.length;s++)r[s].call(this,e||{})}}const tr=(n,t)=>{const e=n.indexOf(t);return e!==-1&&n.splice(e,1),n},oi=n=>{if(n===0)return 1;switch(Math.abs(n)/cs){case 1:case 3:return 0;case 2:return-1}return Math.cos(n)},ai=n=>{if(n===0)return 0;const t=n/cs,e=Math.sign(n);switch(t){case 1:return e;case 2:return 0;case 3:return-e}return Math.sin(n)};class w{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;typeof t=="object"?(this.x=t.x,this.y=t.y):(this.x=t,this.y=e)}add(t){return new w(this.x+t.x,this.y+t.y)}addEquals(t){return this.x+=t.x,this.y+=t.y,this}scalarAdd(t){return new w(this.x+t,this.y+t)}scalarAddEquals(t){return this.x+=t,this.y+=t,this}subtract(t){return new w(this.x-t.x,this.y-t.y)}subtractEquals(t){return this.x-=t.x,this.y-=t.y,this}scalarSubtract(t){return new w(this.x-t,this.y-t)}scalarSubtractEquals(t){return this.x-=t,this.y-=t,this}multiply(t){return new w(this.x*t.x,this.y*t.y)}scalarMultiply(t){return new w(this.x*t,this.y*t)}scalarMultiplyEquals(t){return this.x*=t,this.y*=t,this}divide(t){return new w(this.x/t.x,this.y/t.y)}scalarDivide(t){return new w(this.x/t,this.y/t)}scalarDivideEquals(t){return this.x/=t,this.y/=t,this}eq(t){return this.x===t.x&&this.y===t.y}lt(t){return this.x<t.x&&this.y<t.y}lte(t){return this.x<=t.x&&this.y<=t.y}gt(t){return this.x>t.x&&this.y>t.y}gte(t){return this.x>=t.x&&this.y>=t.y}lerp(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:.5;return e=Math.max(Math.min(1,e),0),new w(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)}distanceFrom(t){const e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)}midPointFrom(t){return this.lerp(t)}min(t){return new w(Math.min(this.x,t.x),Math.min(this.y,t.y))}max(t){return new w(Math.max(this.x,t.x),Math.max(this.y,t.y))}toString(){return"".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 w(this.x,this.y)}rotate(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:sa;const i=ai(t),r=oi(t),s=this.subtract(e);return new w(s.x*r-s.y*i,s.x*i+s.y*r).add(e)}transform(t){let e=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return new w(t[0]*this.x+t[2]*this.y+(e?0:t[4]),t[1]*this.x+t[3]*this.y+(e?0:t[5]))}}const sa=new w(0,0),en=n=>!!n&&Array.isArray(n._objects);function lc(n){class t extends n{constructor(){super(...arguments),b(this,"_objects",[])}_onObjectAdded(i){}_onObjectRemoved(i){}_onStackOrderChanged(i){}add(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];const o=this._objects.push(...r);return r.forEach(a=>this._onObjectAdded(a)),o}insertAt(i){for(var r=arguments.length,s=new Array(r>1?r-1:0),o=1;o<r;o++)s[o-1]=arguments[o];return this._objects.splice(i,0,...s),s.forEach(a=>this._onObjectAdded(a)),this._objects.length}remove(){const i=this._objects,r=[];for(var s=arguments.length,o=new Array(s),a=0;a<s;a++)o[a]=arguments[a];return o.forEach(l=>{const c=i.indexOf(l);c!==-1&&(i.splice(c,1),r.push(l),this._onObjectRemoved(l))}),r}forEachObject(i){this.getObjects().forEach((r,s,o)=>i(r,s,o))}getObjects(){for(var i=arguments.length,r=new Array(i),s=0;s<i;s++)r[s]=arguments[s];return r.length===0?[...this._objects]:this._objects.filter(o=>o.isType(...r))}item(i){return this._objects[i]}isEmpty(){return this._objects.length===0}size(){return this._objects.length}contains(i,r){return!!this._objects.includes(i)||!!r&&this._objects.some(s=>s instanceof t&&s.contains(i,!0))}complexity(){return this._objects.reduce((i,r)=>i+=r.complexity?r.complexity():0,0)}sendObjectToBack(i){return!(!i||i===this._objects[0])&&(tr(this._objects,i),this._objects.unshift(i),this._onStackOrderChanged(i),!0)}bringObjectToFront(i){return!(!i||i===this._objects[this._objects.length-1])&&(tr(this._objects,i),this._objects.push(i),this._onStackOrderChanged(i),!0)}sendObjectBackwards(i,r){if(!i)return!1;const s=this._objects.indexOf(i);if(s!==0){const o=this.findNewLowerIndex(i,s,r);return tr(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}bringObjectForward(i,r){if(!i)return!1;const s=this._objects.indexOf(i);if(s!==this._objects.length-1){const o=this.findNewUpperIndex(i,s,r);return tr(this._objects,i),this._objects.splice(o,0,i),this._onStackOrderChanged(i),!0}return!1}moveObjectTo(i,r){return i!==this._objects[r]&&(tr(this._objects,i),this._objects.splice(r,0,i),this._onStackOrderChanged(i),!0)}findNewLowerIndex(i,r,s){let o;if(s){o=r;for(let a=r-1;a>=0;--a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=r-1;return o}findNewUpperIndex(i,r,s){let o;if(s){o=r;for(let a=r+1;a<this._objects.length;++a)if(i.isOverlapping(this._objects[a])){o=a;break}}else o=r+1;return o}collectObjects(i){let{left:r,top:s,width:o,height:a}=i,{includeIntersecting:l=!0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const c=[],h=new w(r,s),u=h.add(new w(o,a));for(let d=this._objects.length-1;d>=0;d--){const p=this._objects[d];p.selectable&&p.visible&&(l&&p.intersectsWithRect(h,u)||p.isContainedWithinRect(h,u)||l&&p.containsPoint(h)||l&&p.containsPoint(u))&&c.push(p)}return c}}return t}class cc extends xu{_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 rn(n){return Qo().requestAnimationFrame(n)}function wu(n){return Qo().cancelAnimationFrame(n)}let Cu=0;const xi=()=>Cu++,Ae=()=>{const n=vr().createElement("canvas");if(!n||n.getContext===void 0)throw new je("Failed to create `canvas` element");return n},Su=()=>vr().createElement("img"),Ne=n=>{const t=Ae();return t.width=n.width,t.height=n.height,t},hc=(n,t,e)=>n.toDataURL("image/".concat(t),e),Ct=n=>n*ta,Wi=n=>n/ta,Tu=n=>n.every((t,e)=>t===Qt[e]),re=(n,t,e)=>new w(n).transform(t,e),ke=n=>{const t=1/(n[0]*n[3]-n[1]*n[2]),e=[t*n[3],-t*n[1],-t*n[2],t*n[0],0,0],{x:i,y:r}=new w(n[4],n[5]).transform(e,!0);return e[4]=-i,e[5]=-r,e},Ht=(n,t,e)=>[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],e?0:n[0]*t[4]+n[2]*t[5]+n[4],e?0:n[1]*t[4]+n[3]*t[5]+n[5]],na=(n,t)=>n.reduceRight((e,i)=>i&&e?Ht(i,e,t):i||e,void 0)||Qt.concat(),uc=n=>{let[t,e]=n;return Math.atan2(e,t)},gn=n=>{const t=uc(n),e=Math.pow(n[0],2)+Math.pow(n[1],2),i=Math.sqrt(e),r=(n[0]*n[3]-n[2]*n[1])/i,s=Math.atan2(n[0]*n[2]+n[1]*n[3],e);return{angle:Wi(t),scaleX:i,scaleY:r,skewX:Wi(s),skewY:0,translateX:n[4]||0,translateY:n[5]||0}},hs=function(n){return[1,0,0,1,n,arguments.length>1&&arguments[1]!==void 0?arguments[1]:0]};function us(){let{angle:n=0}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},{x:t=0,y:e=0}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const i=Ct(n),r=oi(i),s=ai(i);return[r,s,-s,r,t?t-(r*t-s*e):0,e?e-(s*t+r*e):0]}const oa=function(n){return[n,0,0,arguments.length>1&&arguments[1]!==void 0?arguments[1]:n,0,0]},dc=n=>Math.tan(Ct(n)),pc=n=>[1,0,dc(n),1,0,0],fc=n=>[1,dc(n),0,1,0,0],An=n=>{let{scaleX:t=1,scaleY:e=1,flipX:i=!1,flipY:r=!1,skewX:s=0,skewY:o=0}=n,a=oa(i?-t:t,r?-e:e);return s&&(a=Ht(a,pc(s),!0)),o&&(a=Ht(a,fc(o),!0)),a},Eu=n=>{const{translateX:t=0,translateY:e=0,angle:i=0}=n;let r=hs(t,e);i&&(r=Ht(r,us({angle:i})));const s=An(n);return Tu(s)||(r=Ht(r,s)),r},sn=function(n){let{signal:t,crossOrigin:e=null}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise(function(i,r){if(t&&t.aborted)return r(new gu("loadImage"));const s=Su();let o;t&&(o=function(l){s.src="",r(l)},t.addEventListener("abort",o,{once:!0}));const a=function(){s.onload=s.onerror=null,o&&(t==null||t.removeEventListener("abort",o)),i(s)};n?(s.onload=a,s.onerror=function(){o&&(t==null||t.removeEventListener("abort",o)),r(new je("Error loading ".concat(s.src)))},e&&(s.crossOrigin=e),s.src=n):a()})},Xr=function(n){let{signal:t,reviver:e=tn}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((i,r)=>{const s=[];t&&t.addEventListener("abort",r,{once:!0}),Promise.all(n.map(o=>R.getClass(o.type).fromObject(o,{signal:t}).then(a=>(e(o,a),s.push(a),a)))).then(i).catch(o=>{s.forEach(a=>{a.dispose&&a.dispose()}),r(o)}).finally(()=>{t&&t.removeEventListener("abort",r)})})},Mn=function(n){let{signal:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((e,i)=>{const r=[];t&&t.addEventListener("abort",i,{once:!0});const s=Object.values(n).map(a=>a&&a.type&&R.has(a.type)?Xr([a],{signal:t}).then(l=>{let[c]=l;return r.push(c),c}):a),o=Object.keys(n);Promise.all(s).then(a=>a.reduce((l,c,h)=>(l[o[h]]=c,l),{})).then(e).catch(a=>{r.forEach(l=>{l.dispose&&l.dispose()}),i(a)}).finally(()=>{t&&t.removeEventListener("abort",i)})})},yr=function(n){return(arguments.length>1&&arguments[1]!==void 0?arguments[1]:[]).reduce((t,e)=>(e in n&&(t[e]=n[e]),t),{})},aa=(n,t)=>Object.keys(n).reduce((e,i)=>(t(n[i],i,n)&&(e[i]=n[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"},Qn=(n,t,e)=>(e<0&&(e+=1),e>1&&(e-=1),e<1/6?n+6*(t-n)*e:e<.5?t:e<2/3?n+(t-n)*(2/3-e)*6:n),Ha=(n,t,e,i)=>{n/=255,t/=255,e/=255;const r=Math.max(n,t,e),s=Math.min(n,t,e);let o,a;const l=(r+s)/2;if(r===s)o=a=0;else{const c=r-s;switch(a=l>.5?c/(2-r-s):c/(r+s),r){case n:o=(t-e)/c+(t<e?6:0);break;case t:o=(e-n)/c+2;break;case e:o=(n-t)/c+4}o/=6}return[Math.round(360*o),Math.round(100*a),Math.round(100*l),i]},$a=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"1";return parseFloat(n)/(n.endsWith("%")?100:1)},Ts=n=>Math.min(Math.round(n),255).toString(16).toUpperCase().padStart(2,"0"),Wa=n=>{let[t,e,i,r=1]=n;const s=Math.round(.3*t+.59*e+.11*i);return[s,s,s,r]};class rt{constructor(t){if(b(this,"isUnrecognised",!1),t)if(t instanceof rt)this.setSource([...t._source]);else if(Array.isArray(t)){const[e,i,r,s=1]=t;this.setSource([e,i,r,s])}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]:rt.sourceFromHex(t)||rt.sourceFromRgb(t)||rt.sourceFromHsl(t)||(this.isUnrecognised=!0)&&[0,0,0,1]}getSource(){return this._source}setSource(t){this._source=t}toRgb(){const[t,e,i]=this.getSource();return"rgb(".concat(t,",").concat(e,",").concat(i,")")}toRgba(){return"rgba(".concat(this.getSource().join(","),")")}toHsl(){const[t,e,i]=Ha(...this.getSource());return"hsl(".concat(t,",").concat(e,"%,").concat(i,"%)")}toHsla(){const[t,e,i,r]=Ha(...this.getSource());return"hsla(".concat(t,",").concat(e,"%,").concat(i,"%,").concat(r,")")}toHex(){return this.toHexa().slice(0,6)}toHexa(){const[t,e,i,r]=this.getSource();return"".concat(Ts(t)).concat(Ts(e)).concat(Ts(i)).concat(Ts(Math.round(255*r)))}getAlpha(){return this.getSource()[3]}setAlpha(t){return this._source[3]=t,this}toGrayscale(){return this.setSource(Wa(this.getSource())),this}toBlackWhite(t){const[e,,,i]=Wa(this.getSource()),r=e<(t||127)?0:255;return this.setSource([r,r,r,i]),this}overlayWith(t){t instanceof rt||(t=new rt(t));const e=this.getSource(),i=t.getSource(),[r,s,o]=e.map((a,l)=>Math.round(.5*a+.5*i[l]));return this.setSource([r,s,o,e[3]]),this}static fromRgb(t){return rt.fromRgba(t)}static fromRgba(t){return new rt(rt.sourceFromRgb(t))}static sourceFromRgb(t){const e=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,r,s]=e.slice(1,4).map(o=>{const a=parseFloat(o);return o.endsWith("%")?Math.round(2.55*a):a});return[i,r,s,$a(e[4])]}}static fromHsl(t){return rt.fromHsla(t)}static fromHsla(t){return new rt(rt.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=(rt.parseAngletoDegrees(e[1])%360+360)%360/360,r=parseFloat(e[2])/100,s=parseFloat(e[3])/100;let o,a,l;if(r===0)o=a=l=s;else{const c=s<=.5?s*(r+1):s+r-s*r,h=2*s-c;o=Qn(h,c,i+1/3),a=Qn(h,c,i),l=Qn(h,c,i-1/3)}return[Math.round(255*o),Math.round(255*a),Math.round(255*l),$a(e[4])]}static fromHex(t){return new rt(rt.sourceFromHex(t))}static sourceFromHex(t){if(t.match(/^#?(([0-9a-f]){3,4}|([0-9a-f]{2}){3,4})$/i)){const e=t.slice(t.indexOf("#")+1);let i;i=e.length<=4?e.split("").map(l=>l+l):e.match(/.{2}/g);const[r,s,o,a=255]=i.map(l=>parseInt(l,16));return[r,s,o,a/255]}}static parseAngletoDegrees(t){const e=t.toLowerCase(),i=parseFloat(e);return e.includes("rad")?Wi(i):e.includes("turn")?360*i:i}}const ft=(n,t)=>parseFloat(Number(n).toFixed(t)),cr=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ea;const e=/\D{0,2}$/.exec(n),i=parseFloat(n),r=Q.DPI;switch(e==null?void 0:e[0]){case"mm":return i*r/25.4;case"cm":return i*r/2.54;case"in":return i*r;case"pt":return i*r/72;case"pc":return i*r/72*12;case"em":return i*t;default:return i}},Ou=n=>{const[t,e]=n.trim().split(" "),[i,r]=(s=t)&&s!==oe?[s.slice(1,4),s.slice(5,8)]:s===oe?[s,s]:["Mid","Mid"];var s;return{meetOrSlice:e||"meet",alignX:i,alignY:r}},mn=n=>"matrix("+n.map(t=>ft(t,Q.NUM_FRACTION_DIGITS)).join(" ")+")",Kr=function(n,t){let e,i,r=!(arguments.length>2&&arguments[2]!==void 0)||arguments[2];if(t)if(t.toLive)e="url(#SVGID_".concat(t.id,")");else{const s=new rt(t),o=s.getAlpha();e=s.toRgb(),o!==1&&(i=o.toString())}else e="none";return r?"".concat(n,": ").concat(e,"; ").concat(i?"".concat(n,"-opacity: ").concat(i,"; "):""):"".concat(n,'="').concat(e,'" ').concat(i?"".concat(n,'-opacity="').concat(i,'" '):"")},_e=n=>!!n&&n.toLive!==void 0,Ga=n=>!!n&&typeof n.toObject=="function",Ua=n=>!!n&&n.offsetX!==void 0&&"source"in n,ji=n=>!!n&&"multiSelectionStacking"in n;function gc(n){const t=n&&Oe(n);let e=0,i=0;if(!n||!t)return{left:e,top:i};let r=n;const s=t.documentElement,o=t.body||{scrollLeft:0,scrollTop:0};for(;r&&(r.parentNode||r.host)&&(r=r.parentNode||r.host,r===t?(e=o.scrollLeft||s.scrollLeft||0,i=o.scrollTop||s.scrollTop||0):(e+=r.scrollLeft||0,i+=r.scrollTop||0),r.nodeType!==1||r.style.position!=="fixed"););return{left:e,top:i}}const Oe=n=>n.ownerDocument||null,mc=n=>{var t;return((t=n.ownerDocument)===null||t===void 0?void 0:t.defaultView)||null},vc=function(n,t,e){let{width:i,height:r}=e,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:1;n.width=i,n.height=r,s>1&&(n.setAttribute("width",(i*s).toString()),n.setAttribute("height",(r*s).toString()),t.scale(s,s))},Co=(n,t)=>{let{width:e,height:i}=t;e&&(n.style.width=typeof e=="number"?"".concat(e,"px"):e),i&&(n.style.height=typeof i=="number"?"".concat(i,"px"):i)};function Ya(n){return n.onselectstart!==void 0&&(n.onselectstart=()=>!1),n.style.userSelect=oe,n}class bc{constructor(t){b(this,"_originalCanvasStyle",void 0),b(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&&vr().getElementById(t)||Ae();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:r}=this.lower;r.classList.remove("lower-canvas"),r.removeAttribute("data-fabric"),r.setAttribute("width","".concat(e)),r.setAttribute("height","".concat(i)),r.style.cssText=this._originalCanvasStyle||"",this._originalCanvasStyle=void 0}setDimensions(t,e){const{el:i,ctx:r}=this.lower;vc(i,r,t,e)}setCSSDimensions(t){Co(this.lower.el,t)}calcOffset(){return function(t){var e;const i=t&&Oe(t),r={left:0,top:0};if(!i)return r;const s=((e=mc(t))===null||e===void 0?void 0:e.getComputedStyle(t,null))||{};r.left+=parseInt(s.borderLeftWidth,10)||0,r.top+=parseInt(s.borderTopWidth,10)||0,r.left+=parseInt(s.paddingLeft,10)||0,r.top+=parseInt(s.paddingTop,10)||0;let o={left:0,top:0};const a=i.documentElement;t.getBoundingClientRect!==void 0&&(o=t.getBoundingClientRect());const l=gc(t);return{left:o.left+l.left-(a.clientLeft||0)+r.left,top:o.top+l.top-(a.clientTop||0)+r.top}}(this.lower.el)}dispose(){Be().dispose(this.lower.el),delete this.lower}}const ku={backgroundVpt:!0,backgroundColor:"",overlayVpt:!0,overlayColor:"",includeDefaultValues:!0,svgViewportTransformation:!0,renderOnAddRemove:!0,skipOffscreen:!0,enableRetinaScaling:!0,imageSmoothingEnabled:!0,controlsAboveOverlay:!1,allowTouchScrolling:!1,viewportTransform:[...Qt]};class ds extends lc(cc){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 ds.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 bc(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),r=1;r<e;r++)i[r-1]=arguments[r];const s=super.insertAt(t,...i);return i.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),s}remove(){const t=super.remove(...arguments);return t.length>0&&this.renderOnAddRemove&&this.requestRenderAll(),t}_onObjectAdded(t){t.canvas&&t.canvas!==this&&(yi("warn",`Canvas is trying to add an object that belongs to a different canvas.
|
|
91
|
+
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?sc():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 r=_({width:this.width,height:this.height},t);this.elements.setDimensions(r,this.getRetinaScaling()),this.hasLostContext=!0,this.width=r.width,this.height=r.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,r=[...this.viewportTransform],s=re(t,ke(r));r[0]=e,r[3]=e;const o=re(s,r);r[4]+=i.x-o.x,r[5]+=i.y-o.y,this.setViewportTransform(r)}setZoom(t){this.zoomToPoint(new w(0,0),t)}absolutePan(t){const e=[...this.viewportTransform];return e[4]=-t.x,e[5]=-t.y,this.setViewportTransform(e)}relativePan(t){return this.absolutePan(new w(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))}getElement(){return this.elements.lower.el}clearContext(t){t.clearRect(0,0,this.width,this.height)}getContext(){return this.elements.lower.ctx}clear(){this.remove(...this.getObjects()),this.backgroundImage=void 0,this.overlayImage=void 0,this.backgroundColor="",this.overlayColor="",this.clearContext(this.getContext()),this.fire("canvas:cleared"),this.renderOnAddRemove&&this.requestRenderAll()}renderAll(){this.cancelRequestedRender(),this.destroyed||this.renderCanvas(this.getContext(),this._objects)}renderAndReset(){this.nextRenderHandle=0,this.renderAll()}requestRenderAll(){this.nextRenderHandle||this.disposed||this.destroyed||(this.nextRenderHandle=rn(()=>this.renderAndReset()))}calcViewportBoundaries(){const t=this.width,e=this.height,i=ke(this.viewportTransform),r=re({x:0,y:0},i),s=re({x:t,y:e},i),o=r.min(s),a=r.max(s);return this.vptCoords={tl:o,tr:new w(a.x,o.y),bl:new w(o.x,a.y),br:a}}cancelRequestedRender(){this.nextRenderHandle&&(wu(this.nextRenderHandle),this.nextRenderHandle=0)}drawControls(t){}renderCanvas(t,e){if(this.destroyed)return;const i=this.viewportTransform,r=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),r&&(r._set("canvas",this),r.shouldCache(),r._transformDone=!0,r.renderCache({forClipping:!0}),this.drawClipPathOnCanvas(t,r)),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,r=e.length;i<r;++i)e[i]&&e[i].render(t)}_renderBackgroundOrOverlay(t,e){const i=this["".concat(e,"Color")],r=this["".concat(e,"Image")],s=this.viewportTransform,o=this["".concat(e,"Vpt")];if(!i&&!r)return;const a=_e(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,o&&t.transform(...s),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(r){t.save();const{skipOffscreen:l}=this;this.skipOffscreen=o,o&&t.transform(...s),r.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 w(this.width/2,this.height/2)}centerObjectH(t){return this._centerObject(t,new w(this.getCenterPoint().x,t.getCenterPoint().y))}centerObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getCenterPoint().y))}centerObject(t){return this._centerObject(t,this.getCenterPoint())}viewportCenterObject(t){return this._centerObject(t,this.getVpCenter())}viewportCenterObjectH(t){return this._centerObject(t,new w(this.getVpCenter().x,t.getCenterPoint().y))}viewportCenterObjectV(t){return this._centerObject(t,new w(t.getCenterPoint().x,this.getVpCenter().y))}getVpCenter(){return re(this.getCenterPoint(),ke(this.viewportTransform))}_centerObject(t,e){t.setXY(e,K,K),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,r=i&&!i.excludeFromExport?this._toObject(i,t,e):null;return _(_(_({version:xo},yr(this,e)),{},{objects:this._objects.filter(s=>!s.excludeFromExport).map(s=>this._toObject(s,t,e))},this.__serializeBgOverlay(t,e)),r?{clipPath:r}:null)}_toObject(t,e,i){let r;this.includeDefaultValues||(r=t.includeDefaultValues,t.includeDefaultValues=!1);const s=t[e](i);return this.includeDefaultValues||(t.includeDefaultValues=!!r),s}__serializeBgOverlay(t,e){const i={},r=this.backgroundImage,s=this.overlayImage,o=this.backgroundColor,a=this.overlayColor;return _e(o)?o.excludeFromExport||(i.background=o.toObject(e)):o&&(i.background=o),_e(a)?a.excludeFromExport||(i.overlay=a.toObject(e)):a&&(i.overlay=a),r&&!r.excludeFromExport&&(i.backgroundImage=this._toObject(r,t,e)),s&&!s.excludeFromExport&&(i.overlayImage=this._toObject(s,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,`)" >
|
|
92
|
+
`)),this._setSVGBgOverlayColor(i,"background"),this._setSVGBgOverlayImage(i,"backgroundImage",e),this._setSVGObjects(i,e),this.clipPath&&i.push(`</g>
|
|
93
|
+
`),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" ?>
|
|
94
|
+
`,'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ',`"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
95
|
+
`)}_setSVGHeader(t,e){const i=e.width||"".concat(this.width),r=e.height||"".concat(this.height),s=Q.NUM_FRACTION_DIGITS,o=e.viewBox;let a;if(o)a='viewBox="'.concat(o.x," ").concat(o.y," ").concat(o.width," ").concat(o.height,'" ');else if(this.svgViewportTransformation){const l=this.viewportTransform;a='viewBox="'.concat(ft(-l[4]/l[0],s)," ").concat(ft(-l[5]/l[3],s)," ").concat(ft(this.width/l[0],s)," ").concat(ft(this.height/l[3],s),'" ')}else a='viewBox="0 0 '.concat(this.width," ").concat(this.height,'" ');t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',r,'" ',a,`xml:space="preserve">
|
|
96
|
+
`,"<desc>Created with Fabric.js ",xo,`</desc>
|
|
97
|
+
`,`<defs>
|
|
98
|
+
`,this.createSVGFontFacesMarkup(),this.createSVGRefElementsMarkup(),this.createSVGClipPathMarkup(e),`</defs>
|
|
99
|
+
`)}createSVGClipPathMarkup(t){const e=this.clipPath;return e?(e.clipPathId="CLIPPATH_".concat(xi()),'<clipPath id="'.concat(e.clipPathId,`" >
|
|
100
|
+
`).concat(e.toClipPathSVG(t.reviver),`</clipPath>
|
|
101
|
+
`)):""}createSVGRefElementsMarkup(){return["background","overlay"].map(t=>{const e=this["".concat(t,"Color")];if(_e(e)){const i=this["".concat(t,"Vpt")],r=this.viewportTransform,s={isType:()=>!1,width:this.width/(i?r[0]:1),height:this.height/(i?r[3]:1)};return e.toSVG(s,{additionalTransform:i?mn(r):""})}}).join("")}createSVGFontFacesMarkup(){const t=[],e={},i=Q.fontPaths;this._objects.forEach(function s(o){t.push(o),en(o)&&o._objects.forEach(s)}),t.forEach(s=>{if(!(o=s)||typeof o._renderText!="function")return;var o;const{styles:a,fontFamily:l}=s;!e[l]&&i[l]&&(e[l]=!0,a&&Object.values(a).forEach(c=>{Object.values(c).forEach(h=>{let{fontFamily:u=""}=h;!e[u]&&i[u]&&(e[u]=!0)})}))});const r=Object.keys(e).map(s=>` @font-face {
|
|
102
|
+
font-family: '`.concat(s,`';
|
|
103
|
+
src: url('`).concat(i[s],`');
|
|
104
|
+
}
|
|
105
|
+
`)).join("");return r?` <style type="text/css"><![CDATA[
|
|
106
|
+
`.concat(r,`]]></style>
|
|
107
|
+
`):""}_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 r=this[e];r&&!r.excludeFromExport&&r.toSVG&&t.push(r.toSVG(i))}_setSVGBgOverlayColor(t,e){const i=this["".concat(e,"Color")];if(i)if(_e(i)){const r=i.repeat||"",s=this.width,o=this.height,a=this["".concat(e,"Vpt")]?mn(ke(this.viewportTransform)):"";t.push('<rect transform="'.concat(a," translate(").concat(s/2,",").concat(o/2,')" x="').concat(i.offsetX-s/2,'" y="').concat(i.offsetY-o/2,'" width="').concat(r!=="repeat-y"&&r!=="no-repeat"||!Ua(i)?s:i.source.width,'" height="').concat(r!=="repeat-x"&&r!=="no-repeat"||!Ua(i)?o:i.source.height,'" fill="url(#SVGID_').concat(i.id,`)"></rect>
|
|
108
|
+
`))}else t.push('<rect x="0" y="0" width="100%" height="100%" ','fill="',i,'"',`></rect>
|
|
109
|
+
`)}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 r=typeof t=="string"?JSON.parse(t):t,{objects:s=[],backgroundImage:o,background:a,overlayImage:l,overlay:c,clipPath:h}=r,u=this.renderOnAddRemove;return this.renderOnAddRemove=!1,Promise.all([Xr(s,{reviver:e,signal:i}),Mn({backgroundImage:o,backgroundColor:a,overlayImage:l,overlayColor:c,clipPath:h},{signal:i})]).then(d=>{let[p,f]=d;return this.clear(),this.add(...p),this.set(r),this.set(f),this.renderOnAddRemove=u,this})}clone(t){const e=this.toObject(t);return this.cloneWithoutData().loadFromJSON(e)}cloneWithoutData(){const t=Ne(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:r=1,enableRetinaScaling:s=!1}=t,o=r*(s?this.getRetinaScaling():1);return hc(this.toCanvasElement(o,t),e,i)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,{width:e,height:i,left:r,top:s,filter:o}=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,u=this.height,d=this.skipControlsDrawing,p=c*t,f=this.viewportTransform,g=[p,0,0,p,(f[4]-(r||0))*t,(f[5]-(s||0))*t],m=this.enableRetinaScaling,v=Ne({width:a,height:l}),y=o?this._objects.filter(x=>o(x)):this._objects;return this.enableRetinaScaling=!1,this.viewportTransform=g,this.width=a,this.height=l,this.skipControlsDrawing=!0,this.calcViewportBoundaries(),this.renderCanvas(v.getContext("2d"),y),this.viewportTransform=f,this.width=h,this.height=u,this.calcViewportBoundaries(),this.enableRetinaScaling=m,this.skipControlsDrawing=d,v}dispose(){return!this.disposed&&this.elements.cleanupDOM({width:this.width,height:this.height}),fn.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," }>")}}b(ds,"ownDefaults",ku);const Du=["touchstart","touchmove","touchend"],Pu=n=>{const t=gc(n.target),e=function(i){const r=i.changedTouches;return r&&r[0]?r[0]:i}(n);return new w(e.clientX+t.left,e.clientY+t.top)},So=n=>Du.includes(n.type)||n.pointerType==="touch",To=n=>{n.preventDefault(),n.stopPropagation()},ii=n=>{let t=0,e=0,i=0,r=0;for(let s=0,o=n.length;s<o;s++){const{x:a,y:l}=n[s];(a>i||!s)&&(i=a),(a<t||!s)&&(t=a),(l>r||!s)&&(r=l),(l<e||!s)&&(e=l)}return{left:t,top:e,width:i-t,height:r-e}},Au=["translateX","translateY","scaleX","scaleY"],Mu=(n,t)=>vn(n,Ht(t,n.calcOwnMatrix())),vn=(n,t)=>{const e=gn(t),{translateX:i,translateY:r,scaleX:s,scaleY:o}=e,a=ht(e,Au),l=new w(i,r);n.flipX=!1,n.flipY=!1,Object.assign(n,a),n.set({scaleX:s,scaleY:o}),n.setPositionByOrigin(l,K,K)},Iu=n=>{n.scaleX=1,n.scaleY=1,n.skewX=0,n.skewY=0,n.flipX=!1,n.flipY=!1,n.rotate(0)},_c=n=>({scaleX:n.scaleX,scaleY:n.scaleY,skewX:n.skewX,skewY:n.skewY,angle:n.angle,left:n.left,flipX:n.flipX,flipY:n.flipY,top:n.top}),la=(n,t,e)=>{const i=n/2,r=t/2,s=[new w(-i,-r),new w(i,-r),new w(-i,r),new w(i,r)].map(a=>a.transform(e)),o=ii(s);return new w(o.width,o.height)},In=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qt;return Ht(ke(arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt),n)},hr=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qt;return n.transform(In(t,e))},Lu=function(n){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt,e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qt;return n.transform(In(t,e),!0)},Fu=(n,t,e)=>{const i=In(t,e);return vn(n,Ht(i,n.calcOwnMatrix())),i},yc=(n,t)=>{var e;const{transform:{target:i}}=t;(e=i.canvas)===null||e===void 0||e.fire("object:".concat(n),_(_({},t),{},{target:i})),i.fire(n,t)},ju={left:-.5,top:-.5,center:0,bottom:.5,right:.5},Dt=n=>typeof n=="string"?ju[n]:n-.5,bn="not-allowed";function xc(n){return Dt(n.originX)===Dt(K)&&Dt(n.originY)===Dt(K)}function Xa(n){return .5-Dt(n)}const Pe=(n,t)=>n[t],wc=(n,t,e,i)=>({e:n,transform:t,pointer:new w(e,i)});function Cc(n,t){const e=n.getTotalAngle()+Wi(Math.atan2(t.y,t.x))+360;return Math.round(e%360/45)}function ca(n,t,e,i,r){var s;let{target:o,corner:a}=n;const l=o.controls[a],c=((s=o.canvas)===null||s===void 0?void 0:s.getZoom())||1,h=o.padding/c,u=function(d,p,f,g){const m=d.getRelativeCenterPoint(),v=f!==void 0&&g!==void 0?d.translateToGivenOrigin(m,K,K,f,g):new w(d.left,d.top);return(d.angle?p.rotate(-Ct(d.angle),m):p).subtract(v)}(o,new w(i,r),t,e);return u.x>=h&&(u.x-=h),u.x<=-h&&(u.x+=h),u.y>=h&&(u.y-=h),u.y<=h&&(u.y+=h),u.x-=l.offsetX,u.y-=l.offsetY,u}const Ru=(n,t,e,i)=>{const{target:r,offsetX:s,offsetY:o}=t,a=e-s,l=i-o,c=!Pe(r,"lockMovementX")&&r.left!==a,h=!Pe(r,"lockMovementY")&&r.top!==l;return c&&r.set(it,a),h&&r.set(ne,l),(c||h)&&yc(nc,wc(n,t,e,i)),c||h};class Sc{getSvgStyles(t){const e=this.fillRule?this.fillRule:"nonzero",i=this.strokeWidth?this.strokeWidth:"0",r=this.strokeDashArray?this.strokeDashArray.join(" "):oe,s=this.strokeDashOffset?this.strokeDashOffset:"0",o=this.strokeLineCap?this.strokeLineCap:"butt",a=this.strokeLineJoin?this.strokeLineJoin:"miter",l=this.strokeMiterLimit?this.strokeMiterLimit:"4",c=this.opacity!==void 0?this.opacity:"1",h=this.visible?"":" visibility: hidden;",u=t?"":this.getSvgFilter(),d=Kr(It,this.fill);return[Kr(ae,this.stroke),"stroke-width: ",i,"; ","stroke-dasharray: ",r,"; ","stroke-linecap: ",o,"; ","stroke-dashoffset: ",s,"; ","stroke-linejoin: ",a,"; ","stroke-miterlimit: ",l,"; ",d,"fill-rule: ",e,"; ","opacity: ",c,";",u,h].join("")}getSvgFilter(){return this.shadow?"filter: url(#SVGID_".concat(this.shadow.id,");"):""}getSvgCommons(){return[this.id?'id="'.concat(this.id,'" '):"",this.clipPath?'clip-path="url(#'.concat(this.clipPath.clipPathId,')" '):""].join("")}getSvgTransform(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const i=t?this.calcTransformMatrix():this.calcOwnMatrix(),r='transform="'.concat(mn(i));return"".concat(r).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 r=[this.getSvgTransform(!0,i),this.getSvgCommons()].join(""),s=t.indexOf("COMMON_PARTS");return t[s]=r,e?e(t.join("")):t.join("")}_createBaseSVGMarkup(t){let{noStyle:e,reviver:i,withShadow:r,additionalTransform:s}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const o=e?"":'style="'.concat(this.getSvgStyles(),'" '),a=r?'style="'.concat(this.getSvgFilter(),'" '):"",l=this.clipPath,c=this.strokeUniform?'vector-effect="non-scaling-stroke" ':"",h=l&&l.absolutePositioned,u=this.stroke,d=this.fill,p=this.shadow,f=[],g=t.indexOf("COMMON_PARTS");let m;l&&(l.clipPathId="CLIPPATH_".concat(xi()),m='<clipPath id="'.concat(l.clipPathId,`" >
|
|
110
|
+
`).concat(l.toClipPathSVG(i),`</clipPath>
|
|
111
|
+
`)),h&&f.push("<g ",a,this.getSvgCommons(),` >
|
|
112
|
+
`),f.push("<g ",this.getSvgTransform(!1),h?"":a+this.getSvgCommons(),` >
|
|
113
|
+
`);const v=[o,c,e?"":this.addPaintOrder()," ",s?'transform="'.concat(s,'" '):""].join("");return t[g]=v,_e(d)&&f.push(d.toSVG(this)),_e(u)&&f.push(u.toSVG(this)),p&&f.push(p.toSVG(this)),l&&f.push(m),f.push(t.join("")),f.push(`</g>
|
|
114
|
+
`),h&&f.push(`</g>
|
|
115
|
+
`),i?i(f.join("")):f.join("")}addPaintOrder(){return this.paintFirst!==It?' paint-order="'.concat(this.paintFirst,'" '):""}}function Ln(n){return new RegExp("^("+n.join("|")+")\\b","i")}var Ka;const Gi=String.raw(Ka||(Ka=ki(["(?:[-+]?(?:d*.d+|d+.?)(?:[eE][-+]?d+)?)"],["(?:[-+]?(?:\\d*\\.\\d+|\\d+\\.?)(?:[eE][-+]?\\d+)?)"]))),Bu=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+Gi+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+Gi+"))?\\s+(.*)"),Nu={cx:it,x:it,r:"radius",cy:ne,y:ne,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"},to="font-size",eo="clip-path";Ln(["path","circle","polygon","polyline","ellipse","rect","line","image","text"]);Ln(["symbol","image","marker","pattern","view","svg"]);const qa=Ln(["symbol","g","a","svg","clipPath","defs"]),zu=new w(1,0),Tc=new w,Ec=(n,t)=>n.rotate(t),Eo=(n,t)=>new w(t).subtract(n),Oo=n=>n.distanceFrom(Tc),ko=(n,t)=>Math.atan2(Vr(n,t),Hu(n,t)),Vu=n=>ko(zu,n),ha=n=>n.eq(Tc)?n:n.scalarDivide(Oo(n)),Oc=function(n){let t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return ha(new w(-n.y,n.x).scalarMultiply(t?1:-1))},Vr=(n,t)=>n.x*t.y-n.y*t.x,Hu=(n,t)=>n.x*t.x+n.y*t.y,Za=(n,t,e)=>{if(n.eq(t)||n.eq(e))return!0;const i=Vr(t,e),r=Vr(t,n),s=Vr(e,n);return i>=0?r>=0&&s<=0:!(r<=0&&s>=0)},Ja="(-?\\d+(?:\\.\\d*)?(?:px)?(?:\\s?|$))?",Qa=new RegExp("(?:\\s|^)"+Ja+Ja+"("+Gi+"?(?:px)?)?(?:\\s?|$)(?:$|\\s)");class ri{constructor(t){const e=typeof t=="string"?ri.parseShadow(t):t;Object.assign(this,ri.ownDefaults,e),this.id=xi()}static parseShadow(t){const e=t.trim(),[,i=0,r=0,s=0]=(Qa.exec(e)||[]).map(o=>parseFloat(o)||0);return{color:(e.replace(Qa,"")||"rgb(0,0,0)").trim(),offsetX:i,offsetY:r,blur:s}}toString(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")}toSVG(t){const e=Ec(new w(this.offsetX,this.offsetY),Ct(-t.angle)),i=new rt(this.color);let r=40,s=40;return t.width&&t.height&&(r=100*ft((Math.abs(e.x)+this.blur)/t.width,Q.NUM_FRACTION_DIGITS)+20,s=100*ft((Math.abs(e.y)+this.blur)/t.height,Q.NUM_FRACTION_DIGITS)+20),t.flipX&&(e.x*=-1),t.flipY&&(e.y*=-1),'<filter id="SVGID_'.concat(this.id,'" y="-').concat(s,'%" height="').concat(100+2*s,'%" x="-').concat(r,'%" width="').concat(100+2*r,`%" >
|
|
116
|
+
<feGaussianBlur in="SourceAlpha" stdDeviation="`).concat(ft(this.blur?this.blur/2:0,Q.NUM_FRACTION_DIGITS),`"></feGaussianBlur>
|
|
117
|
+
<feOffset dx="`).concat(ft(e.x,Q.NUM_FRACTION_DIGITS),'" dy="').concat(ft(e.y,Q.NUM_FRACTION_DIGITS),`" result="oBlur" ></feOffset>
|
|
118
|
+
<feFlood flood-color="`).concat(i.toRgb(),'" flood-opacity="').concat(i.getAlpha(),`"/>
|
|
119
|
+
<feComposite in2="oBlur" operator="in" />
|
|
120
|
+
<feMerge>
|
|
121
|
+
<feMergeNode></feMergeNode>
|
|
122
|
+
<feMergeNode in="SourceGraphic"></feMergeNode>
|
|
123
|
+
</feMerge>
|
|
124
|
+
</filter>
|
|
125
|
+
`)}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=ri.ownDefaults;return this.includeDefaultValues?t:aa(t,(i,r)=>i!==e[r])}static async fromObject(t){return new this(t)}}b(ri,"ownDefaults",{color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:!1,includeDefaultValues:!0,nonScaling:!1}),b(ri,"type","shadow"),R.setClass(ri,"shadow");const fr=(n,t,e)=>Math.max(n,Math.min(t,e)),$u=[ne,it,le,xe,"flipX","flipY","originX","originY","angle","opacity","globalCompositeOperation","shadow","visible",br,_r],ui=[It,ae,"strokeWidth","strokeDashArray","width","height","paintFirst","strokeUniform","strokeLineCap","strokeDashOffset","strokeLineJoin","strokeMiterLimit","backgroundColor","clipPath"],Wu={top:0,left:0,width:0,height:0,angle:0,flipX:!1,flipY:!1,scaleX:1,scaleY:1,minScaleLimit:0,skewX:0,skewY:0,originX:it,originY:ne,strokeWidth:1,strokeUniform:!1,padding:0,opacity:1,paintFirst:It,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},Gu=(n,t,e,i)=>-e*Math.cos(n/i*cs)+e+t,Uu=()=>!1;class ua{constructor(t){let{startValue:e,byValue:i,duration:r=500,delay:s=0,easing:o=Gu,onStart:a=tn,onChange:l=tn,onComplete:c=tn,abort:h=Uu,target:u}=t;b(this,"_state","pending"),b(this,"durationProgress",0),b(this,"valueProgress",0),this.tick=this.tick.bind(this),this.duration=r,this.delay=s,this.easing=o,this._onStart=a,this._onChange=l,this._onComplete=c,this._abort=h,this.target=u,this.startValue=e,this.byValue=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(()=>rn(t),this.delay):rn(t)}tick(t){const e=(t||+new Date)-this.startTime,i=Math.min(e,this.duration);this.durationProgress=i/this.duration;const{value:r,valueProgress:s}=this.calculate(i);this.value=Object.freeze(r),this.valueProgress=s,this._state!=="aborted"&&(this._abort(this.value,this.valueProgress,this.durationProgress)?(this._state="aborted",this.unregister()):e>=this.duration?(this.durationProgress=this.valueProgress=1,this._onChange(this.endValue,this.valueProgress,this.durationProgress),this._state="completed",this._onComplete(this.endValue,this.valueProgress,this.durationProgress),this.unregister()):(this._onChange(this.value,this.valueProgress,this.durationProgress),rn(this.tick)))}register(){fn.push(this)}unregister(){fn.remove(this)}abort(){this._state="aborted",this.unregister()}}const Yu=["startValue","endValue"];class Xu extends ua{constructor(t){let{startValue:e=0,endValue:i=100}=t;super(_(_({},ht(t,Yu)),{},{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 Ku=["startValue","endValue"];class qu extends ua{constructor(t){let{startValue:e=[0],endValue:i=[100]}=t;super(_(_({},ht(t,Ku)),{},{startValue:e,byValue:i.map((r,s)=>r-e[s])}))}calculate(t){const e=this.startValue.map((i,r)=>this.easing(t,i,this.byValue[r],this.duration,r));return{value:e,valueProgress:Math.abs((e[0]-this.startValue[0])/this.byValue[0])}}}const Zu=["startValue","endValue","easing","onChange","onComplete","abort"],Ju=(n,t,e,i)=>t+e*(1-Math.cos(n/i*cs)),io=n=>n&&((t,e,i)=>n(new rt(t).toRgba(),e,i));class Qu extends ua{constructor(t){let{startValue:e,endValue:i,easing:r=Ju,onChange:s,onComplete:o,abort:a}=t,l=ht(t,Zu);const c=new rt(e).getSource(),h=new rt(i).getSource();super(_(_({},l),{},{startValue:c,byValue:h.map((u,d)=>u-c[d]),easing:r,onChange:io(s),onComplete:io(o),abort:io(a)}))}calculate(t){const[e,i,r,s]=this.startValue.map((a,l)=>this.easing(t,a,this.byValue[l],this.duration,l)),o=[...[e,i,r].map(Math.round),fr(0,s,1)];return{value:o,valueProgress:o.map((a,l)=>this.byValue[l]!==0?Math.abs((a-this.startValue[l])/this.byValue[l]):0).find(a=>a!==0)||0}}}function kc(n){const t=(e=>Array.isArray(e.startValue)||Array.isArray(e.endValue))(n)?new qu(n):new Xu(n);return t.start(),t}function td(n){const t=new Qu(n);return t.start(),t}class pt{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(r=>!this.includes(r))),this}static isPointContained(t,e,i){let r=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&&(r||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&&(r||t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x));{const s=Eo(e,i),o=Eo(e,t).divide(s);return r?Math.abs(o.x)===Math.abs(o.y):o.x===o.y&&o.x>=0&&o.x<=1}}static isPointInPolygon(t,e){const i=new w(t).setX(Math.min(t.x-1,...e.map(s=>s.x)));let r=0;for(let s=0;s<e.length;s++){const o=this.intersectSegmentSegment(e[s],e[(s+1)%e.length],t,i);if(o.includes(t))return!0;r+=+(o.status==="Intersection")}return r%2==1}static intersectLineLine(t,e,i,r){let s=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],o=!(arguments.length>5&&arguments[5]!==void 0)||arguments[5];const a=e.x-t.x,l=e.y-t.y,c=r.x-i.x,h=r.y-i.y,u=t.x-i.x,d=t.y-i.y,p=c*d-h*u,f=a*d-l*u,g=h*a-c*l;if(g!==0){const m=p/g,v=f/g;return(s||0<=m&&m<=1)&&(o||0<=v&&v<=1)?new pt("Intersection").append(new w(t.x+m*a,t.y+m*l)):new pt}if(p===0||f===0){const m=s||o||pt.isPointContained(t,i,r)||pt.isPointContained(e,i,r)||pt.isPointContained(i,t,e)||pt.isPointContained(r,t,e);return new pt(m?"Coincident":void 0)}return new pt("Parallel")}static intersectSegmentLine(t,e,i,r){return pt.intersectLineLine(t,e,i,r,!1,!0)}static intersectSegmentSegment(t,e,i,r){return pt.intersectLineLine(t,e,i,r,!1,!1)}static intersectLinePolygon(t,e,i){let r=!(arguments.length>3&&arguments[3]!==void 0)||arguments[3];const s=new pt,o=i.length;for(let a,l,c,h=0;h<o;h++){if(a=i[h],l=i[(h+1)%o],c=pt.intersectLineLine(t,e,a,l,r,!1),c.status==="Coincident")return c;s.append(...c.points)}return s.points.length>0&&(s.status="Intersection"),s}static intersectSegmentPolygon(t,e,i){return pt.intersectLinePolygon(t,e,i,!1)}static intersectPolygonPolygon(t,e){const i=new pt,r=t.length,s=[];for(let o=0;o<r;o++){const a=t[o],l=t[(o+1)%r],c=pt.intersectSegmentPolygon(a,l,e);c.status==="Coincident"?(s.push(c),i.append(a,l)):i.append(...c.points)}return s.length>0&&s.length===t.length?new pt("Coincident"):(i.points.length>0&&(i.status="Intersection"),i)}static intersectPolygonRectangle(t,e,i){const r=e.min(i),s=e.max(i),o=new w(s.x,r.y),a=new w(r.x,s.y);return pt.intersectPolygonPolygon(t,[r,o,s,a])}}class ed extends cc{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?re(t,this.group.calcTransformMatrix()):t}setXY(t,e,i){this.group&&(t=re(t,ke(this.group.calcTransformMatrix()))),this.setRelativeXY(t,e,i)}getRelativeXY(){return new w(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:r}=this.aCoords||(this.aCoords=this.calcACoords()),s=[t,e,i,r];if(this.group){const o=this.group.calcTransformMatrix();return s.map(a=>re(a,o))}return s}intersectsWithRect(t,e){return pt.intersectPolygonRectangle(this.getCoords(),t,e).status==="Intersection"}intersectsWithObject(t){const e=pt.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:r,width:s,height:o}=this.getBoundingRect();return i>=t.x&&i+s<=e.x&&r>=t.y&&r+o<=e.y}isOverlapping(t){return this.intersectsWithObject(t)||this.isContainedWithinObject(t)||t.isContainedWithinObject(this)}containsPoint(t){return pt.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 ii(this.getCoords())}getScaledWidth(){return this._getTransformedDimensions().x}getScaledHeight(){return this._getTransformedDimensions().y}scale(t){this._set(le,t),this._set(xe,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?Wi(uc(this.calcTransformMatrix())):this.angle}getViewportTransform(){var t;return((t=this.canvas)===null||t===void 0?void 0:t.viewportTransform)||Qt.concat()}calcACoords(){const t=us({angle:this.angle}),{x:e,y:i}=this.getRelativeCenterPoint(),r=hs(e,i),s=Ht(r,t),o=this._getTransformedDimensions(),a=o.x/2,l=o.y/2;return{tl:re({x:-a,y:-l},s),tr:re({x:a,y:-l},s),bl:re({x:-a,y:l},s),br:re({x:a,y:l},s)}}setCoords(){this.aCoords=this.calcACoords()}transformMatrixKey(){let t=arguments.length>0&&arguments[0]!==void 0&&arguments[0],e=[];return!t&&this.group&&(e=this.group.transformMatrixKey(t)),e.push(this.top,this.left,this.width,this.height,this.scaleX,this.scaleY,this.angle,this.strokeWidth,this.skewX,this.skewY,+this.flipX,+this.flipY,Dt(this.originX),Dt(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),r=this.matrixCache;return r&&r.key.every((s,o)=>s===i[o])?r.value:(this.group&&(e=Ht(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(),r={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},s=Eu(r);return this.ownMatrixCache={key:t,value:s},s}_getNonTransformedDimensions(){return new w(this.width,this.height).scalarAdd(this.strokeWidth)}_calculateCurrentDimensions(t){return this._getTransformedDimensions(t).transform(this.getViewportTransform(),!0).scalarAdd(2*this.padding)}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,width:this.width,height:this.height,strokeWidth:this.strokeWidth},t),i=e.strokeWidth;let r=i,s=0;this.strokeUniform&&(r=0,s=i);const o=e.width+r,a=e.height+r;let l;return l=e.skewX===0&&e.skewY===0?new w(o*e.scaleX,a*e.scaleY):la(o,a,An(e)),l.scalarAdd(s)}translateToGivenOrigin(t,e,i,r,s){let o=t.x,a=t.y;const l=Dt(r)-Dt(e),c=Dt(s)-Dt(i);if(l||c){const h=this._getTransformedDimensions();o+=l*h.x,a+=c*h.y}return new w(o,a)}translateToCenterPoint(t,e,i){if(e===K&&i===K)return t;const r=this.translateToGivenOrigin(t,e,i,K,K);return this.angle?r.rotate(Ct(this.angle),t):r}translateToOriginPoint(t,e,i){const r=this.translateToGivenOrigin(t,K,K,e,i);return this.angle?r.rotate(Ct(this.angle),t):r}getCenterPoint(){const t=this.getRelativeCenterPoint();return this.group?re(t,this.group.calcTransformMatrix()):t}getRelativeCenterPoint(){return this.translateToCenterPoint(new w(this.left,this.top),this.originX,this.originY)}getPointByOrigin(t,e){return this.translateToOriginPoint(this.getRelativeCenterPoint(),t,e)}setPositionByOrigin(t,e,i){const r=this.translateToCenterPoint(t,e,i),s=this.translateToOriginPoint(r,this.originX,this.originY);this.set({left:s.x,top:s.y})}_getLeftTopCoords(){return this.translateToOriginPoint(this.getRelativeCenterPoint(),it,ne)}}const id=["type"],rd=["extraParam"];let Ye=class nn extends ed{static getDefaults(){return nn.ownDefaults}get type(){const t=this.constructor.type;return t==="FabricObject"?"object":t.toLowerCase()}set type(t){yi("warn","Setting type has no effect",t)}constructor(t){super(),b(this,"_cacheContext",null),Object.assign(this,nn.ownDefaults),this.setOptions(t)}_createCacheCanvas(){this._cacheCanvas=Ae(),this._cacheContext=this._cacheCanvas.getContext("2d"),this._updateCacheCanvas(),this.dirty=!0}_limitCacheSize(t){const e=t.width,i=t.height,r=Q.maxCacheSideLimit,s=Q.minCacheSideLimit;if(e<=r&&i<=r&&e*i<=Q.perfLimitSizeTotal)return e<s&&(t.width=s),i<s&&(t.height=s),t;const o=e/i,[a,l]=zr.limitDimsByArea(o),c=fr(s,a,r),h=fr(s,l,r);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,r=e.y*t.y/this.scaleY;return{width:Math.ceil(i+2),height:Math.ceil(r+2),zoomX:t.x,zoomY:t.y,x:i,y:r}}_updateCacheCanvas(){const t=this._cacheCanvas,e=this._cacheContext,{width:i,height:r,zoomX:s,zoomY:o,x:a,y:l}=this._limitCacheSize(this._getCacheCanvasDimensions()),c=i!==t.width||r!==t.height,h=this.zoomX!==s||this.zoomY!==o;if(!t||!e)return!1;if(c||h){i!==t.width||r!==t.height?(t.width=i,t.height=r):(e.setTransform(1,0,0,1,0,0),e.clearRect(0,0,t.width,t.height));const u=a/2,d=l/2;return this.cacheTranslationX=Math.round(t.width/2-u)+u,this.cacheTranslationY=Math.round(t.height/2-d)+d,e.translate(this.cacheTranslationX,this.cacheTranslationY),e.scale(s,o),this.zoomX=s,this.zoomY=o,!0}return!1}setOptions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this._setOptions(t)}transform(t){const e=this.group&&!this.group._transformDone||this.group&&this.canvas&&t===this.canvas.contextTop,i=this.calcTransformMatrix(!e);t.transform(i[0],i[1],i[2],i[3],i[4],i[5])}getObjectScaling(){if(!this.group)return new w(Math.abs(this.scaleX),Math.abs(this.scaleY));const t=gn(this.calcTransformMatrix());return new w(Math.abs(t.scaleX),Math.abs(t.scaleY))}getTotalObjectScaling(){const t=this.getObjectScaling();if(this.canvas){const e=this.canvas.getZoom(),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!==le&&t!==xe||(e=this._constrainScale(e)),t===le&&e<0?(this.flipX=!this.flipX,e*=-1):t==="scaleY"&&e<0?(this.flipY=!this.flipY,e*=-1):t!=="shadow"||!e||e instanceof ri||(e=new ri(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:r,cacheTranslationY:s}=this,{width:o,height:a}=this._cacheCanvas;this.drawObject(this._cacheContext,t.forClipping,{zoomX:e,zoomY:i,cacheTranslationX:r,cacheTranslationY:s,width:o,height:a,parentClipPaths:[]}),this.dirty=!1}}_removeCacheCanvas(){this._cacheCanvas=void 0,this._cacheContext=null}hasStroke(){return this.stroke&&this.stroke!=="transparent"&&this.strokeWidth!==0}hasFill(){return this.fill&&this.fill!=="transparent"}needsItsOwnCache(){return!!(this.paintFirst===ae&&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 r=this.fill,s=this.stroke;e?(this.fill="black",this.stroke="",this._setClippingProperties(t)):this._renderBackground(t),this._render(t),this._drawClipPath(t,this.clipPath,i),this.fill=r,this.stroke=s}createClipPathLayer(t,e){const i=Ne(e),r=i.getContext("2d");if(r.translate(e.cacheTranslationX,e.cacheTranslationY),r.scale(e.zoomX,e.zoomY),t._cacheCanvas=i,e.parentClipPaths.forEach(s=>{s.transform(r)}),e.parentClipPaths.push(t),t.absolutePositioned){const s=ke(this.calcTransformMatrix());r.transform(s[0],s[1],s[2],s[3],s[4],s[5])}return t.transform(r),t.drawObject(r,!0,e),i}_drawClipPath(t,e,i){if(!e)return;e._transformDone=!0;const r=this.createClipPathLayer(e,i);this.drawClipPathOnCache(t,e,r)}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,_e(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&&(_e(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,r=this.getCanvasRetinaScaling(),[s,,,o]=(i==null?void 0:i.viewportTransform)||Qt,a=s*r,l=o*r,c=e.nonScaling?new w(1,1):this.getObjectScaling();t.shadowColor=e.color,t.shadowBlur=e.blur*Q.browserShadowBlurConstant*(a+l)*(c.x+c.y)/4,t.shadowOffsetX=e.offsetX*a*c.x,t.shadowOffsetY=e.offsetY*l*c.y}_removeShadow(t){this.shadow&&(t.shadowColor="",t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0)}_applyPatternGradientTransform(t,e){if(!_e(e))return{offsetX:0,offsetY:0};const i=e.gradientTransform||e.patternTransform,r=-this.width/2+e.offsetX||0,s=-this.height/2+e.offsetY||0;return e.gradientUnits==="percentage"?t.transform(this.width,0,0,this.height,r,s):t.transform(1,0,0,1,r,s),i&&t.transform(i[0],i[1],i[2],i[3],i[4],i[5]),{offsetX:r,offsetY:s}}_renderPaintInOrder(t){this.paintFirst===ae?(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 r=this._limitCacheSize(this._getCacheCanvasDimensions()),s=this.getCanvasRetinaScaling(),o=r.x/this.scaleX/s,a=r.y/this.scaleY/s,l=Ne({width:Math.ceil(o),height:Math.ceil(a)}),c=l.getContext("2d");c&&(c.beginPath(),c.moveTo(0,0),c.lineTo(o,0),c.lineTo(o,a),c.lineTo(0,a),c.closePath(),c.translate(o/2,a/2),c.scale(r.zoomX/this.scaleX/s,r.zoomY/this.scaleY/s),this._applyPatternGradientTransform(c,e),c.fillStyle=e.toLive(t),c.fill(),t.translate(-this.width/2-this.strokeWidth/2,-this.height/2-this.strokeWidth/2),t.scale(s*this.scaleX/r.zoomX,s*this.scaleY/r.zoomY),t.strokeStyle=(i=c.createPattern(l,"no-repeat"))!==null&&i!==void 0?i:"")}_findCenterFromElement(){return new w(this.left+this.width/2,this.top+this.height/2)}clone(t){const e=this.toObject(t);return this.constructor.fromObject(e)}cloneAsImage(t){const e=this.toCanvasElement(t);return new(R.getClass("image"))(e)}toCanvasElement(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const e=_c(this),i=this.group,r=this.shadow,s=Math.abs,o=t.enableRetinaScaling?sc():1,a=(t.multiplier||1)*o,l=t.canvasProvider||(y=>new ds(y,{enableRetinaScaling:!1,renderOnAddRemove:!1,skipOffscreen:!1}));delete this.group,t.withoutTransform&&Iu(this),t.withoutShadow&&(this.shadow=null),t.viewportTransform&&Fu(this,this.getViewportTransform()),this.setCoords();const c=Ae(),h=this.getBoundingRect(),u=this.shadow,d=new w;if(u){const y=u.blur,x=u.nonScaling?new w(1,1):this.getObjectScaling();d.x=2*Math.round(s(u.offsetX)+y)*s(x.x),d.y=2*Math.round(s(u.offsetY)+y)*s(x.y)}const p=h.width+d.x,f=h.height+d.y;c.width=Math.ceil(p),c.height=Math.ceil(f);const g=l(c);t.format==="jpeg"&&(g.backgroundColor="#fff"),this.setPositionByOrigin(new w(g.width/2,g.height/2),K,K);const m=this.canvas;g._objects=[this],this.set("canvas",g),this.setCoords();const v=g.toCanvasElement(a||1,t);return this.set("canvas",m),this.shadow=r,i&&(this.group=i),this.set(e),this.setCoords(),g._objects=[],g.destroy(),v}toDataURL(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return hc(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:r}=this;if(e){const{x:s,y:o}=this.getRelativeCenterPoint();this.originX=K,this.originY=K,this.left=s,this.top=o}if(this.set("angle",t),e){const{x:s,y:o}=this.translateToOriginPoint(this.getRelativeCenterPoint(),i,r);this.left=s,this.top=o,this.originX=i,this.originY=r}}setOnGroup(){}_setupCompositeOperation(t){this.globalCompositeOperation&&(t.globalCompositeOperation=this.globalCompositeOperation)}dispose(){fn.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,r)=>{let[s,o]=r;return i[s]=this._animate(s,o,e),i},{})}_animate(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.split("."),s=this.constructor.colorProperties.includes(r[r.length-1]),{abort:o,startValue:a,onChange:l,onComplete:c}=i,h=_(_({},i),{},{target:this,startValue:a??r.reduce((u,d)=>u[d],this),endValue:e,abort:o==null?void 0:o.bind(this),onChange:(u,d,p)=>{r.reduce((f,g,m)=>(m===r.length-1&&(f[g]=u),f[g]),this),l&&l(u,d,p)},onComplete:(u,d,p)=>{this.setCoords(),c&&c(u,d,p)}});return s?td(h):kc(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 r,s=0;s<e.length;s++){if(r=e[s],r===t)return{fork:[this,...e.slice(0,s)],otherFork:[],common:e.slice(s)};for(let o=0;o<i.length;o++){if(this===i[o])return{fork:[],otherFork:[t,...i.slice(0,o)],common:[this,...e]};if(r===i[o])return{fork:[this,...e.slice(0,s)],otherFork:[t,...i.slice(0,o)],common:e.slice(s)}}}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 r=e.fork.pop(),s=e.otherFork.pop(),o=i._objects.indexOf(r),a=i._objects.indexOf(s);return o>-1&&o>a}toObject(){const t=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:[]).concat(nn.customProperties,this.constructor.customProperties||[]);let e;const i=Q.NUM_FRACTION_DIGITS,{clipPath:r,fill:s,stroke:o,shadow:a,strokeDashArray:l,left:c,top:h,originX:u,originY:d,width:p,height:f,strokeWidth:g,strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:T,scaleX:E,scaleY:A,angle:C,flipX:S,flipY:F,opacity:j,visible:D,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:V,skewX:Y,skewY:Z}=this;r&&!r.excludeFromExport&&(e=r.toObject(t.concat("inverted","absolutePositioned")));const B=M=>ft(M,i),N=_(_({},yr(this,t)),{},{type:this.constructor.type,version:xo,originX:u,originY:d,left:B(c),top:B(h),width:B(p),height:B(f),fill:Ga(s)?s.toObject():s,stroke:Ga(o)?o.toObject():o,strokeWidth:B(g),strokeDashArray:l&&l.concat(),strokeLineCap:m,strokeDashOffset:v,strokeLineJoin:y,strokeUniform:x,strokeMiterLimit:B(T),scaleX:B(E),scaleY:B(A),angle:B(C),flipX:S,flipY:F,opacity:B(j),shadow:a&&a.toObject(),visible:D,backgroundColor:k,fillRule:P,paintFirst:L,globalCompositeOperation:V,skewX:B(Y),skewY:B(Z)},e?{clipPath:e}:null);return this.includeDefaultValues?N:this._removeDefaultValues(N)}toDatalessObject(t){return this.toObject(t)}_removeDefaultValues(t){const e=this.constructor.getDefaults(),i=Object.keys(e).length>0?e:Object.getPrototypeOf(this);return aa(t,(r,s)=>{if(s===it||s===ne||s==="type")return!0;const o=i[s];return r!==o&&!(Array.isArray(r)&&Array.isArray(o)&&r.length===0&&o.length===0)})}toString(){return"#<".concat(this.constructor.type,">")}static _fromObject(t){let e=ht(t,id),i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{extraParam:r}=i,s=ht(i,rd);return Mn(e,s).then(o=>r?(delete o[r],new this(e[r],o)):new this(o))}static fromObject(t,e){return this._fromObject(t,e)}};b(Ye,"stateProperties",$u),b(Ye,"cacheProperties",ui),b(Ye,"ownDefaults",Wu),b(Ye,"type","FabricObject"),b(Ye,"colorProperties",[It,ae,"backgroundColor"]),b(Ye,"customProperties",[]),R.setClass(Ye),R.setClass(Ye,"object");const xr=(n,t,e)=>(i,r,s,o)=>{const a=t(i,r,s,o);return a&&yc(n,_(_({},wc(i,r,s,o)),e)),a};function wr(n){return(t,e,i,r)=>{const{target:s,originX:o,originY:a}=e,l=s.getRelativeCenterPoint(),c=s.translateToOriginPoint(l,o,a),h=n(t,e,i,r);return s.setPositionByOrigin(c,e.originX,e.originY),h}}const tl=xr(Yr,wr((n,t,e,i)=>{const r=ca(t,t.originX,t.originY,e,i);if(Dt(t.originX)===Dt(K)||Dt(t.originX)===Dt(xt)&&r.x<0||Dt(t.originX)===Dt(it)&&r.x>0){const{target:s}=t,o=s.strokeWidth/(s.strokeUniform?s.scaleX:1),a=xc(t)?2:1,l=s.width,c=Math.abs(r.x*a/s.scaleX)-o;return s.set("width",Math.max(c,1)),l!==s.width}return!1}));function sd(n,t,e,i,r){i=i||{};const s=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:r.transparentCorners,l=a?ae:It,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor);let h,u=t,d=e;n.save(),n.fillStyle=i.cornerColor||r.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",s>o?(h=s,n.scale(1,o/s),d=e*s/o):o>s?(h=o,n.scale(s/o,1),u=t*o/s):h=s,n.beginPath(),n.arc(u,d,h/2,0,un,!1),n[l](),c&&n.stroke(),n.restore()}function nd(n,t,e,i,r){i=i||{};const s=this.sizeX||i.cornerSize||r.cornerSize,o=this.sizeY||i.cornerSize||r.cornerSize,a=i.transparentCorners!==void 0?i.transparentCorners:r.transparentCorners,l=a?ae:It,c=!a&&(i.cornerStrokeColor||r.cornerStrokeColor),h=s/2,u=o/2;n.save(),n.fillStyle=i.cornerColor||r.cornerColor||"",n.strokeStyle=i.cornerStrokeColor||r.cornerStrokeColor||"",n.translate(t,e);const d=r.getTotalAngle();n.rotate(Ct(d)),n["".concat(l,"Rect")](-h,-u,s,o),c&&n.strokeRect(-h,-u,s,o),n.restore()}class Se{constructor(t){b(this,"visible",!0),b(this,"actionName",Pn),b(this,"angle",0),b(this,"x",0),b(this,"y",0),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"sizeX",0),b(this,"sizeY",0),b(this,"touchSizeX",0),b(this,"touchSizeY",0),b(this,"cursorStyle","crosshair"),b(this,"withConnection",!1),Object.assign(this,t)}shouldActivate(t,e,i,r){var s;let{tl:o,tr:a,br:l,bl:c}=r;return((s=e.canvas)===null||s===void 0?void 0:s.getActiveObject())===e&&e.isControlVisible(t)&&pt.isPointInPolygon(i,[o,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,r;return(i=(r=t._controlsVisibility)===null||r===void 0?void 0:r[e])!==null&&i!==void 0?i:this.visible}setVisibility(t,e,i){this.visible=t}positionHandler(t,e,i,r){return new w(this.x*t.x+this.offsetX,this.y*t.y+this.offsetY).transform(e)}calcCornerCoords(t,e,i,r,s,o){const a=na([hs(i,r),us({angle:t}),oa((s?this.touchSizeX:this.sizeX)||e,(s?this.touchSizeY:this.sizeY)||e)]);return{tl:new w(-.5,-.5).transform(a),tr:new w(.5,-.5).transform(a),br:new w(.5,.5).transform(a),bl:new w(-.5,.5).transform(a)}}render(t,e,i,r,s){((r=r||{}).cornerStyle||s.cornerStyle)==="circle"?sd.call(this,t,e,i,r,s):nd.call(this,t,e,i,r,s)}}const od=(n,t,e)=>e.lockRotation?bn:t.cursorStyle,ad=xr(oc,wr((n,t,e,i)=>{let{target:r,ex:s,ey:o,theta:a,originX:l,originY:c}=t;const h=r.translateToOriginPoint(r.getRelativeCenterPoint(),l,c);if(Pe(r,"lockRotation"))return!1;const u=Math.atan2(o-h.y,s-h.x),d=Math.atan2(i-h.y,e-h.x);let p=Wi(d-u+a);if(r.snapAngle&&r.snapAngle>0){const g=r.snapAngle,m=r.snapThreshold||g,v=Math.ceil(p/g)*g,y=Math.floor(p/g)*g;Math.abs(p-y)<m?p=y:Math.abs(p-v)<m&&(p=v)}p<0&&(p=360+p),p%=360;const f=r.angle!==p;return r.angle=p,f}));function Dc(n,t){const e=t.canvas,i=n[e.uniScaleKey];return e.uniformScaling&&!i||!e.uniformScaling&&i}function Pc(n,t,e){const i=Pe(n,"lockScalingX"),r=Pe(n,"lockScalingY");if(i&&r||!t&&(i||r)&&e||i&&t==="x"||r&&t==="y")return!0;const{width:s,height:o,strokeWidth:a}=n;return s===0&&a===0&&t!=="y"||o===0&&a===0&&t!=="x"}const ld=["e","se","s","sw","w","nw","n","ne","e"],Br=(n,t,e)=>{const i=Dc(n,e);if(Pc(e,t.x!==0&&t.y===0?"x":t.x===0&&t.y!==0?"y":"",i))return bn;const r=Cc(e,t);return"".concat(ld[r],"-resize")};function da(n,t,e,i){let r=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{};const s=t.target,o=r.by,a=Dc(n,s);let l,c,h,u,d,p;if(Pc(s,o,a))return!1;if(t.gestureScale)c=t.scaleX*t.gestureScale,h=t.scaleY*t.gestureScale;else{if(l=ca(t,t.originX,t.originY,e,i),d=o!=="y"?Math.sign(l.x||t.signX||1):1,p=o!=="x"?Math.sign(l.y||t.signY||1):1,t.signX||(t.signX=d),t.signY||(t.signY=p),Pe(s,"lockScalingFlip")&&(t.signX!==d||t.signY!==p))return!1;if(u=s._getTransformedDimensions(),a&&!o){const m=Math.abs(l.x)+Math.abs(l.y),{original:v}=t,y=m/(Math.abs(u.x*v.scaleX/s.scaleX)+Math.abs(u.y*v.scaleY/s.scaleY));c=v.scaleX*y,h=v.scaleY*y}else c=Math.abs(l.x*s.scaleX/u.x),h=Math.abs(l.y*s.scaleY/u.y);xc(t)&&(c*=2,h*=2),t.signX!==d&&o!=="y"&&(t.originX=Xa(t.originX),c*=-1,t.signX=d),t.signY!==p&&o!=="x"&&(t.originY=Xa(t.originY),h*=-1,t.signY=p)}const f=s.scaleX,g=s.scaleY;return o?(o==="x"&&s.set(le,c),o==="y"&&s.set(xe,h)):(!Pe(s,"lockScalingX")&&s.set(le,c),!Pe(s,"lockScalingY")&&s.set(xe,h)),f!==s.scaleX||g!==s.scaleY}const Es=xr(Dn,wr((n,t,e,i)=>da(n,t,e,i))),cd=xr(Dn,wr((n,t,e,i)=>da(n,t,e,i,{by:"x"}))),hd=xr(Dn,wr((n,t,e,i)=>da(n,t,e,i,{by:"y"}))),ud=["target","ex","ey","skewingSide"],ro={x:{counterAxis:"y",scale:le,skew:br,lockSkewing:"lockSkewingX",origin:"originX",flip:"flipX"},y:{counterAxis:"x",scale:xe,skew:_r,lockSkewing:"lockSkewingY",origin:"originY",flip:"flipY"}},dd=["ns","nesw","ew","nwse"],pd=(n,t,e)=>{if(t.x!==0&&Pe(e,"lockSkewingY")||t.y!==0&&Pe(e,"lockSkewingX"))return bn;const i=Cc(e,t)%4;return"".concat(dd[i],"-resize")};function Ac(n,t,e,i,r){const{target:s}=e,{counterAxis:o,origin:a,lockSkewing:l,skew:c,flip:h}=ro[n];if(Pe(s,l))return!1;const{origin:u,flip:d}=ro[o],p=Dt(e[u])*(s[d]?-1:1),f=-Math.sign(p)*(s[h]?-1:1),g=.5*-((s[c]===0&&ca(e,K,K,i,r)[n]>0||s[c]>0?1:-1)*f)+.5;return xr(ac,wr((v,y,x,T)=>function(E,A,C){let{target:S,ex:F,ey:j,skewingSide:D}=A,k=ht(A,ud);const{skew:P}=ro[E],L=C.subtract(new w(F,j)).divide(new w(S.scaleX,S.scaleY))[E],V=S[P],Y=k[P],Z=Math.tan(Ct(Y)),B=E==="y"?S._getTransformedDimensions({scaleX:1,scaleY:1,skewX:0}).x:S._getTransformedDimensions({scaleX:1,scaleY:1}).y,N=2*L*D/Math.max(B,1)+Z,M=Wi(Math.atan(N));S.set(P,M);const H=V!==S[P];if(H&&E==="y"){const{skewX:J,scaleX:bt}=S,nt=S._getTransformedDimensions({skewY:V}),he=S._getTransformedDimensions(),I=J!==0?nt.x/he.x:1;I!==1&&S.set(le,I*bt)}return H}(n,y,new w(x,T))))(t,_(_({},e),{},{[a]:g,skewingSide:f}),i,r)}const fd=(n,t,e,i)=>Ac("x",n,t,e,i),gd=(n,t,e,i)=>Ac("y",n,t,e,i);function Fn(n,t){return n[t.canvas.altActionKey]}const Os=(n,t,e)=>{const i=Fn(n,e);return t.x===0?i?br:xe:t.y===0?i?_r:le:""},rr=(n,t,e)=>Fn(n,e)?pd(0,t,e):Br(n,t,e),el=(n,t,e,i)=>Fn(n,t.target)?gd(n,t,e,i):cd(n,t,e,i),il=(n,t,e,i)=>Fn(n,t.target)?fd(n,t,e,i):hd(n,t,e,i),Mc=()=>({ml:new Se({x:-.5,y:0,cursorStyleHandler:rr,actionHandler:el,getActionName:Os}),mr:new Se({x:.5,y:0,cursorStyleHandler:rr,actionHandler:el,getActionName:Os}),mb:new Se({x:0,y:.5,cursorStyleHandler:rr,actionHandler:il,getActionName:Os}),mt:new Se({x:0,y:-.5,cursorStyleHandler:rr,actionHandler:il,getActionName:Os}),tl:new Se({x:-.5,y:-.5,cursorStyleHandler:Br,actionHandler:Es}),tr:new Se({x:.5,y:-.5,cursorStyleHandler:Br,actionHandler:Es}),bl:new Se({x:-.5,y:.5,cursorStyleHandler:Br,actionHandler:Es}),br:new Se({x:.5,y:.5,cursorStyleHandler:Br,actionHandler:Es}),mtr:new Se({x:0,y:-.5,actionHandler:ad,cursorStyleHandler:od,offsetY:-40,withConnection:!0,actionName:ra})}),md=()=>({mr:new Se({x:.5,y:0,actionHandler:tl,cursorStyleHandler:rr,actionName:Yr}),ml:new Se({x:-.5,y:0,actionHandler:tl,cursorStyleHandler:rr,actionName:Yr})}),vd=()=>_(_({},Mc()),md());class qr extends Ye{static getDefaults(){return _(_({},super.getDefaults()),qr.ownDefaults)}constructor(t){super(),Object.assign(this,this.constructor.createControls(),qr.ownDefaults),this.setOptions(t)}static createControls(){return{controls:Mc()}}_updateCacheCanvas(){const t=this.canvas;if(this.noScaleCache&&t&&t._currentTransform){const e=t._currentTransform,i=e.target,r=e.action;if(this===i&&r&&r.startsWith(Pn))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 r=i.length-1;r>=0;r--){const[s,o]=i[r],a=this.controls[s];if(a.shouldActivate(s,this,t,e?o.touchCorner:o.corner))return this.__corner=s,{key:s,control:a,coord:this.oCoords[s]}}}calcOCoords(){const t=this.getViewportTransform(),e=this.getCenterPoint(),i=hs(e.x,e.y),r=us({angle:this.getTotalAngle()-(this.group&&this.flipX?180:0)}),s=Ht(i,r),o=Ht(t,s),a=Ht(o,[1/t[0],0,0,1/t[3],0,0]),l=this.group?gn(this.calcTransformMatrix()):void 0;l&&(l.scaleX=Math.abs(l.scaleX),l.scaleY=Math.abs(l.scaleY));const c=this._calculateCurrentDimensions(l),h={};return this.forEachControl((u,d)=>{const p=u.positionHandler(c,a,this,u);h[d]=Object.assign(p,this._calcCornerCoords(u,p))}),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(),r=this.getViewportTransform();t.translate(e.x,e.y),t.scale(1/r[0],1/r[3]),t.rotate(Ct(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 r=_({hasControls:this.hasControls,borderColor:this.borderColor,borderDashArray:this.borderDashArray},i);t.save(),t.strokeStyle=r.borderColor,this._setLineDash(t,r.borderDashArray),this.strokeBorders(t,e),r.hasControls&&this.drawControlsConnectingLines(t,e),t.restore()}_renderControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{hasBorders:i,hasControls:r}=this,s=_({hasBorders:i,hasControls:r},e),o=this.getViewportTransform(),a=s.hasBorders,l=s.hasControls,c=Ht(o,this.calcTransformMatrix()),h=gn(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(Ct(this.group?h.angle:this.angle)),a&&this.drawBorders(t,h,e),l&&this.drawControls(t,e),t.restore()}drawBorders(t,e,i){let r;if(i&&i.forActiveSelection||this.group){const s=la(this.width,this.height,An(e)),o=this.isStrokeAccountedForInDimensions()?sa:(this.strokeUniform?new w().scalarAdd(this.canvas?this.canvas.getZoom():1):new w(e.scaleX,e.scaleY)).scalarMultiply(this.strokeWidth);r=s.add(o).scalarAdd(this.borderScaleFactor).scalarAdd(2*this.padding)}else r=this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);this._drawBorders(t,r,i)}drawControlsConnectingLines(t,e){let i=!1;t.beginPath(),this.forEachControl((r,s)=>{r.withConnection&&r.getVisibility(this,s)&&(i=!0,t.moveTo(r.x*e.x,r.y*e.y),t.lineTo(r.x*e.x+r.offsetX,r.y*e.y+r.offsetY))}),i&&t.stroke()}drawControls(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};t.save();const i=this.getCanvasRetinaScaling(),{cornerStrokeColor:r,cornerDashArray:s,cornerColor:o}=this,a=_({cornerStrokeColor:r,cornerDashArray:s,cornerColor:o},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,r]=e;return this.setControlVisible(i,r)})}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 r=this.width+4,s=this.height+4;return e.clearRect(-r/2,-s/2,r,s),t||e.restore(),e}onDeselect(t){return!1}onSelect(t){return!1}shouldStartDragging(t){return!1}onDragStart(t){return!1}canDrop(t){return!1}renderDragSourceEffect(t){}renderDropTargetEffect(t){}}function Ic(n,t){return t.forEach(e=>{Object.getOwnPropertyNames(e.prototype).forEach(i=>{i!=="constructor"&&Object.defineProperty(n.prototype,i,Object.getOwnPropertyDescriptor(e.prototype,i)||Object.create(null))})}),n}b(qr,"ownDefaults",{noScaleCache:!0,lockMovementX:!1,lockMovementY:!1,lockRotation:!1,lockScalingX:!1,lockScalingY:!1,lockSkewingX:!1,lockSkewingY:!1,lockScalingFlip:!1,cornerSize:13,touchCornerSize:24,transparentCorners:!0,cornerColor:"rgb(178,204,255)",cornerStrokeColor:"",cornerStyle:"rect",cornerDashArray:null,hasControls:!0,borderColor:"rgb(178,204,255)",borderDashArray:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,hasBorders:!0,selectionBackgroundColor:"",selectable:!0,evented:!0,perPixelTargetFind:!1,activeOn:"down",hoverCursor:null,moveCursor:null});class Yt extends qr{}Ic(Yt,[Sc]),R.setClass(Yt),R.setClass(Yt,"object");const bd=(n,t,e,i)=>{const r=2*(i=Math.round(i))+1,{data:s}=n.getImageData(t-i,e-i,r,r);for(let o=3;o<s.length;o+=4)if(s[o]>0)return!1;return!0};class Lc{constructor(t){this.options=t,this.strokeProjectionMagnitude=this.options.strokeWidth/2,this.scale=new w(this.options.scaleX,this.options.scaleY),this.strokeUniformScalar=this.options.strokeUniform?new w(1/this.options.scaleX,1/this.options.scaleY):new w(1,1)}createSideVector(t,e){const i=Eo(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 w(t);return e.y+=e.x*Math.tan(Ct(this.options.skewY)),e.x+=e.y*Math.tan(Ct(this.options.skewX)),e}scaleUnitVector(t,e){return t.multiply(this.strokeUniformScalar).scalarMultiply(e)}}const _d=new w;class ur extends Lc{static getOrthogonalRotationFactor(t,e){const i=e?ko(t,e):Vu(t);return Math.abs(i)<cs?-1:1}constructor(t,e,i,r){super(r),b(this,"AB",void 0),b(this,"AC",void 0),b(this,"alpha",void 0),b(this,"bisector",void 0),this.A=new w(t),this.B=new w(e),this.C=new w(i),this.AB=this.createSideVector(this.A,this.B),this.AC=this.createSideVector(this.A,this.C),this.alpha=ko(this.AB,this.AC),this.bisector=ha(Ec(this.AB.eq(_d)?this.AC:this.AB,this.alpha/2))}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const r=this.createSideVector(t,e),s=Oc(r),o=ur.getOrthogonalRotationFactor(s,this.bisector);return this.scaleUnitVector(s,i*o)}projectBevel(){const t=[];return(this.alpha%un==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),r=this.scaleUnitVector(this.bisector,-this.strokeProjectionMagnitude*i),s=this.options.strokeUniform?Oo(this.scaleUnitVector(this.bisector,this.options.strokeMiterLimit)):this.options.strokeMiterLimit;return Oo(r)/this.strokeProjectionMagnitude<=s&&t.push(this.applySkew(this.A.add(r))),t.push(...this.projectBevel()),t}projectRoundNoSkew(t,e){const i=[],r=new w(ur.getOrthogonalRotationFactor(this.bisector),ur.getOrthogonalRotationFactor(new w(this.bisector.y,this.bisector.x)));return[new w(1,0).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(r),new w(0,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar).multiply(r)].forEach(s=>{Za(s,t,e)&&i.push(this.A.add(s))}),i}projectRoundWithSkew(t,e){const i=[],{skewX:r,skewY:s,scaleX:o,scaleY:a,strokeUniform:l}=this.options,c=new w(Math.tan(Ct(r)),Math.tan(Ct(s))),h=this.strokeProjectionMagnitude,u=l?h/a/Math.sqrt(1/a**2+1/o**2*c.y**2):h/Math.sqrt(1+c.y**2),d=new w(Math.sqrt(Math.max(h**2-u**2,0)),u),p=l?h/Math.sqrt(1+c.x**2*(1/a)**2/(1/o+1/o*c.x*c.y)**2):h/Math.sqrt(1+c.x**2/(1+c.x*c.y)**2),f=new w(p,Math.sqrt(Math.max(h**2-p**2,0)));return[f,f.scalarMultiply(-1),d,d.scalarMultiply(-1)].map(g=>this.applySkew(l?g.multiply(this.strokeUniformScalar):g)).forEach(g=>{Za(g,t,e)&&i.push(this.applySkew(this.A).add(g))}),i}projectRound(){const t=[];t.push(...this.projectBevel());const e=this.alpha%un==0,i=this.applySkew(this.A),r=t[e?0:2].subtract(i),s=t[e?1:0].subtract(i),o=e?this.applySkew(this.AB.scalarMultiply(-1)):this.applySkew(this.bisector.multiply(this.strokeUniformScalar).scalarMultiply(-1)),a=Vr(r,o)>0,l=a?r:s,c=a?s:r;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 rl extends Lc{constructor(t,e,i){super(i),this.A=new w(t),this.T=new w(e)}calcOrthogonalProjection(t,e){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:this.strokeProjectionMagnitude;const r=this.createSideVector(t,e);return this.scaleUnitVector(Oc(r),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 w(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.applySkew(this.A.add(e)),this.applySkew(this.A.subtract(e)))}else t.push(...new ur(this.A,this.T,this.T,this.options).projectRound());return t}projectSquare(){const t=[];if(this.A.eq(this.T)){const e=new w(1,1).scalarMultiply(this.strokeProjectionMagnitude).multiply(this.strokeUniformScalar);t.push(this.A.add(e),this.A.subtract(e))}else{const e=this.calcOrthogonalProjection(this.A,this.T,this.strokeProjectionMagnitude),i=this.scaleUnitVector(ha(this.createSideVector(this.A,this.T)),-this.strokeProjectionMagnitude),r=this.A.add(i);t.push(r.add(e),r.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 yd=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const i=[];if(n.length===0)return i;const r=n.reduce((s,o)=>(s[s.length-1].eq(o)||s.push(new w(o)),s),[new w(n[0])]);if(r.length===1)e=!0;else if(!e){const s=r[0],o=((a,l)=>{for(let c=a.length-1;c>=0;c--)if(l(a[c],c,a))return c;return-1})(r,a=>!a.eq(s));r.splice(o+1)}return r.forEach((s,o,a)=>{let l,c;o===0?(c=a[1],l=e?s:a[a.length-1]):o===a.length-1?(l=a[o-1],c=e?s:a[0]):(l=a[o-1],c=a[o+1]),e&&a.length===1?i.push(...new rl(s,s,t).project()):!e||o!==0&&o!==a.length-1?i.push(...new ur(s,l,c,t).project()):i.push(...new rl(s,o===0?c:l,t).project())}),i},pa=n=>{const t={};return Object.keys(n).forEach(e=>{t[e]={},Object.keys(n[e]).forEach(i=>{t[e][i]=_({},n[e][i])})}),t},xd=n=>n.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">"),fa=n=>{const t=[];for(let e,i=0;i<n.length;i++)(e=wd(n,i))!==!1&&t.push(e);return t},wd=(n,t)=>{const e=n.charCodeAt(t);if(isNaN(e))return"";if(e<55296||e>57343)return n.charAt(t);if(55296<=e&&e<=56319){if(n.length<=t+1)throw"High surrogate without following low surrogate";const r=n.charCodeAt(t+1);if(56320>r||r>57343)throw"High surrogate without following low surrogate";return n.charAt(t)+n.charAt(t+1)}if(t===0)throw"Low surrogate without preceding high surrogate";const i=n.charCodeAt(t-1);if(55296>i||i>56319)throw"Low surrogate without preceding high surrogate";return!1},ga=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0&&arguments[2];return n.fill!==t.fill||n.stroke!==t.stroke||n.strokeWidth!==t.strokeWidth||n.fontSize!==t.fontSize||n.fontFamily!==t.fontFamily||n.fontWeight!==t.fontWeight||n.fontStyle!==t.fontStyle||n.textBackgroundColor!==t.textBackgroundColor||n.deltaY!==t.deltaY||e&&(n.overline!==t.overline||n.underline!==t.underline||n.linethrough!==t.linethrough)},Cd=(n,t)=>{const e=t.split(`
|
|
126
|
+
`),i=[];let r=-1,s={};n=pa(n);for(let o=0;o<e.length;o++){const a=fa(e[o]);if(n[o])for(let l=0;l<a.length;l++){r++;const c=n[o][l];c&&Object.keys(c).length>0&&(ga(s,c,!0)?i.push({start:r,end:r+1,style:c}):i[i.length-1].end++),s=c||{}}else r+=a.length,s={}}return i},Sd=(n,t)=>{if(!Array.isArray(n))return pa(n);const e=t.split(ia),i={};let r=-1,s=0;for(let o=0;o<e.length;o++){const a=fa(e[o]);for(let l=0;l<a.length;l++)r++,n[s]&&n[s].start<=r&&r<n[s].end&&(i[o]=i[o]||{},i[o][l]=_({},n[s].style),r===n[s].end-1&&s++)}return i},Di=["display","transform",It,"fill-opacity","fill-rule","opacity",ae,"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 sl(n,t){const e=n.nodeName,i=n.getAttribute("class"),r=n.getAttribute("id"),s="(?![a-zA-Z\\-]+)";let o;if(o=new RegExp("^"+e,"i"),t=t.replace(o,""),r&&t.length&&(o=new RegExp("#"+r+s,"i"),t=t.replace(o,"")),i&&t.length){const a=i.split(" ");for(let l=a.length;l--;)o=new RegExp("\\."+a[l]+s,"i"),t=t.replace(o,"")}return t.length===0}function Td(n,t){let e=!0;const i=sl(n,t.pop());return i&&t.length&&(e=function(r,s){let o,a=!0;for(;r.parentElement&&r.parentElement.nodeType===1&&s.length;)a&&(o=s.pop()),a=sl(r=r.parentElement,o);return s.length===0}(n,t)),i&&e&&t.length===0}const Ed=n=>{var t;return(t=Nu[n])!==null&&t!==void 0?t:n},Od=new RegExp("(".concat(Gi,")"),"gi"),kd=n=>n.replace(Od," $1 ").replace(/,/gi," ").replace(/\s+/gi," ");var nl,ol,al,ll,cl,hl,ul;const Jt="(".concat(Gi,")"),Dd=String.raw(nl||(nl=ki(["(skewX)(",")"],["(skewX)\\(","\\)"])),Jt),Pd=String.raw(ol||(ol=ki(["(skewY)(",")"],["(skewY)\\(","\\)"])),Jt),Ad=String.raw(al||(al=ki(["(rotate)(","(?: "," ",")?)"],["(rotate)\\(","(?: "," ",")?\\)"])),Jt,Jt,Jt),Md=String.raw(ll||(ll=ki(["(scale)(","(?: ",")?)"],["(scale)\\(","(?: ",")?\\)"])),Jt,Jt),Id=String.raw(cl||(cl=ki(["(translate)(","(?: ",")?)"],["(translate)\\(","(?: ",")?\\)"])),Jt,Jt),Ld=String.raw(hl||(hl=ki(["(matrix)("," "," "," "," "," ",")"],["(matrix)\\("," "," "," "," "," ","\\)"])),Jt,Jt,Jt,Jt,Jt,Jt),ma="(?:".concat(Ld,"|").concat(Id,"|").concat(Ad,"|").concat(Md,"|").concat(Dd,"|").concat(Pd,")"),Fd="(?:".concat(ma,"*)"),jd=String.raw(ul||(ul=ki(["^s*(?:","?)s*$"],["^\\s*(?:","?)\\s*$"])),Fd),Rd=new RegExp(jd),Bd=new RegExp(ma),Nd=new RegExp(ma,"g");function Do(n){const t=[];if(!(n=kd(n).replace(/\s*([()])\s*/gi,"$1"))||n&&!Rd.test(n))return[...Qt];for(const e of n.matchAll(Nd)){const i=Bd.exec(e[0]);if(!i)continue;let r=Qt;const s=i.filter(f=>!!f),[,o,...a]=s,[l,c,h,u,d,p]=a.map(f=>parseFloat(f));switch(o){case"translate":r=hs(l,c);break;case ra:r=us({angle:l},{x:c,y:h});break;case Pn:r=oa(l,c);break;case br:r=pc(l);break;case _r:r=fc(l);break;case"matrix":r=[l,c,h,u,d,p]}t.push(r)}return na(t)}function zd(n,t,e,i){const r=Array.isArray(t);let s,o=t;if(n!==It&&n!==ae||t!==oe){if(n==="strokeUniform")return t==="non-scaling-stroke";if(n==="strokeDashArray")o=t===oe?null:t.replace(/,/g," ").split(/\s+/).map(parseFloat);else if(n==="transformMatrix")o=e&&e.transformMatrix?Ht(e.transformMatrix,Do(t)):Do(t);else if(n==="visible")o=t!==oe&&t!=="hidden",e&&e.visible===!1&&(o=!1);else if(n==="opacity")o=parseFloat(t),e&&e.opacity!==void 0&&(o*=e.opacity);else if(n==="textAnchor")o=t==="start"?it:t==="end"?xt:K;else if(n==="charSpacing")s=cr(t,i)/i*1e3;else if(n==="paintFirst"){const a=t.indexOf(It),l=t.indexOf(ae);o=It,(a>-1&&l>-1&&l<a||a===-1&&l>-1)&&(o=ae)}else{if(n==="href"||n==="xlink:href"||n==="font"||n==="id")return t;if(n==="imageSmoothing")return t==="optimizeQuality";s=r?t.map(cr):cr(t,i)}}else o="";return!r&&isNaN(s)?o:s}function Vd(n,t){const e=n.match(Bu);if(!e)return;const i=e[1],r=e[3],s=e[4],o=e[5],a=e[6];i&&(t.fontStyle=i),r&&(t.fontWeight=isNaN(parseFloat(r))?r:parseFloat(r)),s&&(t.fontSize=cr(s)),a&&(t.fontFamily=a),o&&(t.lineHeight=o==="normal"?1:o)}function Hd(n,t){n.replace(/;\s*$/,"").split(";").forEach(e=>{if(!e)return;const[i,r]=e.split(":");t[i.trim().toLowerCase()]=r.trim()})}function $d(n){const t={},e=n.getAttribute("style");return e&&(typeof e=="string"?Hd(e,t):function(i,r){Object.entries(i).forEach(s=>{let[o,a]=s;a!==void 0&&(r[o.toLowerCase()]=a)})}(e,t)),t}const Wd={stroke:"strokeOpacity",fill:"fillOpacity"};function di(n,t,e){if(!n)return{};let i,r={},s=ea;n.parentNode&&qa.test(n.parentNode.nodeName)&&(r=di(n.parentElement,t,e),r.fontSize&&(i=s=cr(r.fontSize)));const o=_(_(_({},t.reduce((c,h)=>{const u=n.getAttribute(h);return u&&(c[h]=u),c},{})),function(c){let h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},u={};for(const d in h)Td(c,d.split(" "))&&(u=_(_({},u),h[d]));return u}(n,e)),$d(n));o[eo]&&n.setAttribute(eo,o[eo]),o[to]&&(i=cr(o[to],s),o[to]="".concat(i));const a={};for(const c in o){const h=Ed(c),u=zd(h,o[c],r,i);a[h]=u}a&&a.font&&Vd(a.font,a);const l=_(_({},r),a);return qa.test(n.nodeName)?l:function(c){const h=Yt.getDefaults();return Object.entries(Wd).forEach(u=>{let[d,p]=u;if(c[p]===void 0||c[d]==="")return;if(c[d]===void 0){if(!h[d])return;c[d]=h[d]}if(c[d].indexOf("url(")===0)return;const f=new rt(c[d]);c[d]=f.setAlpha(ft(f.getAlpha()*c[p],2)).toRgba()}),c}(l)}const Gd=["left","top","width","height","visible"],Fc=["rx","ry"];class Rt extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Rt.ownDefaults)}constructor(t){super(),Object.assign(this,Rt.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,r=-e/2,s=-i/2,o=this.rx?Math.min(this.rx,e/2):0,a=this.ry?Math.min(this.ry,i/2):0,l=o!==0||a!==0;t.beginPath(),t.moveTo(r+o,s),t.lineTo(r+e-o,s),l&&t.bezierCurveTo(r+e-fi*o,s,r+e,s+fi*a,r+e,s+a),t.lineTo(r+e,s+i-a),l&&t.bezierCurveTo(r+e,s+i-fi*a,r+e-fi*o,s+i,r+e-o,s+i),t.lineTo(r+o,s+i),l&&t.bezierCurveTo(r+fi*o,s+i,r,s+i-fi*a,r,s+i-a),t.lineTo(r,s+a),l&&t.bezierCurveTo(r,s+fi*a,r+fi*o,s,r+o,s),t.closePath(),this._renderPaintInOrder(t)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Fc,...t])}_toSVG(){const{width:t,height:e,rx:i,ry:r}=this;return["<rect ","COMMON_PARTS",'x="'.concat(-t/2,'" y="').concat(-e/2,'" rx="').concat(i,'" ry="').concat(r,'" width="').concat(t,'" height="').concat(e,`" />
|
|
127
|
+
`)]}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i),{left:s=0,top:o=0,width:a=0,height:l=0,visible:c=!0}=r,h=ht(r,Gd);return new this(_(_(_({},e),h),{},{left:s,top:o,width:a,height:l,visible:!!(c&&a&&l)}))}}b(Rt,"type","Rect"),b(Rt,"cacheProperties",[...ui,...Fc]),b(Rt,"ownDefaults",{rx:0,ry:0}),b(Rt,"ATTRIBUTE_NAMES",[...Di,"x","y","rx","ry","width","height"]),R.setClass(Rt),R.setSVGClass(Rt);const Ze="initialization",_n="added",va="removed",yn="imperative",jc=(n,t)=>{const{strokeUniform:e,strokeWidth:i,width:r,height:s,group:o}=t,a=o&&o!==n?In(o.calcTransformMatrix(),n.calcTransformMatrix()):null,l=a?t.getRelativeCenterPoint().transform(a):t.getRelativeCenterPoint(),c=!t.isStrokeAccountedForInDimensions(),h=e&&c?Lu(new w(i,i),void 0,n.calcTransformMatrix()):sa,u=!e&&c?i:0,d=la(r+u,s+u,na([a,t.calcOwnMatrix()],!0)).add(h).scalarDivide(2);return[l.subtract(d),l.add(d)]};class jn{calcLayoutResult(t,e){if(this.shouldPerformLayout(t))return this.calcBoundingBox(e,t)}shouldPerformLayout(t){let{type:e,prevStrategy:i,strategy:r}=t;return e===Ze||e===yn||!!i&&r!==i}shouldLayoutClipPath(t){let{type:e,target:{clipPath:i}}=t;return e!==Ze&&i&&!i.absolutePositioned}getInitialSize(t,e){return e.size}calcBoundingBox(t,e){const{type:i,target:r}=e;if(i===yn&&e.overrides)return e.overrides;if(t.length===0)return;const{left:s,top:o,width:a,height:l}=ii(t.map(u=>jc(r,u)).reduce((u,d)=>u.concat(d),[])),c=new w(a,l),h=new w(s,o).add(c.scalarDivide(2));if(i===Ze){const u=this.getInitialSize(e,{size:c,center:h});return{center:h,relativeCorrection:new w(0,0),size:u}}return{center:h.transform(r.calcOwnMatrix()),size:c}}}b(jn,"type","strategy");class Po extends jn{shouldPerformLayout(t){return!0}}b(Po,"type","fit-content"),R.setClass(Po);const Ud=["strategy"],Yd=["target","strategy","bubbles","prevStrategy"],Rc="layoutManager";class Zr{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:new Po;b(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[pn,nc,Yr,oc,Dn,ac,dn,_u,yu].map(r=>t.on(r,s=>this.performLayout(r===pn?{type:"object_modified",trigger:r,e:s,target:i}:{type:"object_modifying",trigger:r,e:s,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:r}=e;if(i===Ze||i===_n?this.subscribeTargets(t):i===va&&this.unsubscribeTargets(t),e.fire("layout:before",{context:t}),r&&r.fire("object:layout:before",{target:e,context:t}),i===yn&&t.deep){const s=ht(t,Ud);e.forEachObject(o=>o.layoutManager&&o.layoutManager.performLayout(_(_({},s),{},{bubbles:!1,target:o})))}}getLayoutResult(t){const{target:e,strategy:i,type:r}=t,s=i.calcLayoutResult(t,e.getObjects());if(!s)return;const o=r===Ze?new w:e.getRelativeCenterPoint(),{center:a,correction:l=new w,relativeCorrection:c=new w}=s,h=o.subtract(a).add(l).transform(r===Ze?Qt:ke(e.calcOwnMatrix()),!0).add(c);return{result:s,prevCenter:o,nextCenter:a,offset:h}}commitLayout(t,e){const{target:i}=t,{result:{size:r},nextCenter:s}=e;var o,a;i.set({width:r.x,height:r.y}),this.layoutObjects(t,e),t.type===Ze?i.set({left:(o=t.x)!==null&&o!==void 0?o:s.x+r.x*Dt(i.originX),top:(a=t.y)!==null&&a!==void 0?a:s.y+r.y*Dt(i.originY)}):(i.setPositionByOrigin(s,K,K),i.setCoords(),i.set("dirty",!0))}layoutObjects(t,e){const{target:i}=t;i.forEachObject(r=>{r.group===i&&this.layoutObject(t,e,r)}),t.strategy.shouldLayoutClipPath(t)&&this.layoutObject(t,e,i.clipPath)}layoutObject(t,e,i){let{offset:r}=e;i.set({left:i.left+r.x,top:i.top+r.y})}onAfterLayout(t,e){const{target:i,strategy:r,bubbles:s,prevStrategy:o}=t,a=ht(t,Yd),{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;s&&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:Rc,strategy:this.strategy.constructor.type}}toJSON(){return this.toObject()}}R.setClass(Zr,Rc);const Xd=["type","objects","layoutManager"];class Kd extends Zr{performLayout(){}}class _i extends lc(Yt){static getDefaults(){return _(_({},super.getDefaults()),_i.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"_activeObjects",[]),b(this,"__objectSelectionTracker",void 0),b(this,"__objectSelectionDisposer",void 0),Object.assign(this,_i.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(r=>{this.enterGroup(r,!1)}),this.layoutManager=(i=e.layoutManager)!==null&&i!==void 0?i:new Zr,this.layoutManager.performLayout({type:Ze,target:this,targets:[...t],x:e.left,y:e.top})}canEnterGroup(t){return t===this||this.isDescendantOf(t)?(yi("error","Group: circular object trees are not supported, this call has no effect"),!1):this._objects.indexOf(t)===-1||(yi("error","Group: duplicate objects are not supported inside group, this call has no effect"),!1)}_filterObjectsBeforeEnteringGroup(t){return t.filter((e,i,r)=>this.canEnterGroup(e)&&r.indexOf(e)===i)}add(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];const r=this._filterObjectsBeforeEnteringGroup(e),s=super.add(...r);return this._onAfterObjectsChange(_n,r),s}insertAt(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),r=1;r<e;r++)i[r-1]=arguments[r];const s=this._filterObjectsBeforeEnteringGroup(i),o=super.insertAt(t,...s);return this._onAfterObjectsChange(_n,s),o}remove(){const t=super.remove(...arguments);return this._onAfterObjectsChange(va,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(r=>{r._set(t,e)}),this}_shouldSetNestedCoords(){return this.subTargetCheck}removeAll(){return this._activeObjects=[],this.remove(...this._objects)}__objectSelectionMonitor(t,e){let{target:i}=e;const r=this._activeObjects;if(t)r.push(i),this._set("dirty",!0);else if(r.length>0){const s=r.indexOf(i);s>-1&&(r.splice(s,1),this._set("dirty",!0))}}_watchObject(t,e){t&&this._watchObject(!1,e),t?(e.on("selected",this.__objectSelectionTracker),e.on("deselected",this.__objectSelectionDisposer)):(e.off("selected",this.__objectSelectionTracker),e.off("deselected",this.__objectSelectionDisposer))}enterGroup(t,e){t.group&&t.group.remove(t),t._set("parent",this),this._enterGroup(t,e)}_enterGroup(t,e){e&&vn(t,Ht(ke(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||(vn(t,Ht(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=Yt.prototype.shouldCache.call(this);if(t){for(let e=0;e<this._objects.length;e++)if(this._objects[e].willDrawShadow())return this.ownCaching=!1,!1}return t}willDrawShadow(){if(super.willDrawShadow())return!0;for(let t=0;t<this._objects.length;t++)if(this._objects[t].willDrawShadow())return!0;return!1}isOnACache(){return this.ownCaching||!!this.parent&&this.parent.isOnACache()}drawObject(t,e,i){this._renderBackground(t);for(let s=0;s<this._objects.length;s++){var r;const o=this._objects[s];(r=this.canvas)!==null&&r!==void 0&&r.preserveObjectStacking&&o.group!==this?(t.save(),t.transform(...ke(this.calcTransformMatrix())),o.render(t),t.restore()):o.group===this&&o.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:yn},t))}render(t){this._transformDone=!0,super.render(t),this._transformDone=!1}__serializeObjects(t,e){const i=this.includeDefaultValues;return this._objects.filter(function(r){return!r.excludeFromExport}).map(function(r){const s=r.includeDefaultValues;r.includeDefaultValues=i;const o=r[t||"toObject"](e);return r.includeDefaultValues=s,o})}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];const e=this.layoutManager.toObject();return _(_(_({},super.toObject(["subTargetCheck","interactive",...t])),e.strategy!=="fit-content"||this.includeDefaultValues?{layoutManager:e}:{}),{},{objects:this.__serializeObjects("toObject",t)})}toString(){return"#<Group: (".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=Rt.prototype._toSVG.call(this),i=e.indexOf("COMMON_PARTS");e[i]='for="group" ';const r=e.join("");return t?t(r):r}_toSVG(t){const e=["<g ","COMMON_PARTS",` >
|
|
128
|
+
`],i=this._createSVGBgRect(t);i&&e.push(" ",i);for(let r=0;r<this._objects.length;r++)e.push(" ",this._objects[r].toSVG(t));return e.push(`</g>
|
|
129
|
+
`),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 r=0;r<this._objects.length;r++)e.push(" ",this._objects[r].toClipPathSVG(t));return this._createBaseClipPathSVGMarkup(e,{reviver:t})}static fromObject(t,e){let{type:i,objects:r=[],layoutManager:s}=t,o=ht(t,Xd);return Promise.all([Xr(r,e),Mn(o,e)]).then(a=>{let[l,c]=a;const h=new this(l,_(_(_({},o),c),{},{layoutManager:new Kd}));if(s){const u=R.getClass(s.type),d=R.getClass(s.strategy);h.layoutManager=new u(new d)}else h.layoutManager=new Zr;return h.layoutManager.subscribeTargets({type:Ze,target:h,targets:h.getObjects()}),h.setCoords(),h})}}b(_i,"type","Group"),b(_i,"ownDefaults",{strokeWidth:0,subTargetCheck:!1,interactive:!1}),R.setClass(_i);const qd=(n,t)=>Math.min(t.width/n.width,t.height/n.height),Zd=(n,t)=>Math.max(t.width/n.width,t.height/n.height),Ao="\\s*,?\\s*",Dr="".concat(Ao,"(").concat(Gi,")"),Jd="".concat(Dr).concat(Dr).concat(Dr).concat(Ao,"([01])").concat(Ao,"([01])").concat(Dr).concat(Dr),Qd={m:"l",M:"L"},tp=(n,t,e,i,r,s,o,a,l,c,h)=>{const u=oi(n),d=ai(n),p=oi(t),f=ai(t),g=e*r*p-i*s*f+o,m=i*r*p+e*s*f+a;return["C",c+l*(-e*r*d-i*s*u),h+l*(-i*r*d+e*s*u),g+l*(e*r*f+i*s*p),m+l*(i*r*f-e*s*p),g,m]},dl=(n,t,e,i)=>{const r=Math.atan2(t,n),s=Math.atan2(i,e);return s>=r?s-r:2*Math.PI-(r-s)};function pl(n,t,e,i,r,s,o,a){let l;if(Q.cachesBoundsOfCurve&&(l=[...arguments].join(),zr.boundsOfCurveCache[l]))return zr.boundsOfCurveCache[l];const c=Math.sqrt,h=Math.abs,u=[],d=[[0,0],[0,0]];let p=6*n-12*e+6*r,f=-3*n+9*e-9*r+3*o,g=3*e-3*n;for(let T=0;T<2;++T){if(T>0&&(p=6*t-12*i+6*s,f=-3*t+9*i-9*s+3*a,g=3*i-3*t),h(f)<1e-12){if(h(p)<1e-12)continue;const F=-g/p;0<F&&F<1&&u.push(F);continue}const E=p*p-4*g*f;if(E<0)continue;const A=c(E),C=(-p+A)/(2*f);0<C&&C<1&&u.push(C);const S=(-p-A)/(2*f);0<S&&S<1&&u.push(S)}let m=u.length;const v=m,y=Bc(n,t,e,i,r,s,o,a);for(;m--;){const{x:T,y:E}=y(u[m]);d[0][m]=T,d[1][m]=E}d[0][v]=n,d[1][v]=t,d[0][v+1]=o,d[1][v+1]=a;const x=[new w(Math.min(...d[0]),Math.min(...d[1])),new w(Math.max(...d[0]),Math.max(...d[1]))];return Q.cachesBoundsOfCurve&&(zr.boundsOfCurveCache[l]=x),x}const ep=(n,t,e)=>{let[i,r,s,o,a,l,c,h]=e;const u=((d,p,f,g,m,v,y)=>{if(f===0||g===0)return[];let x=0,T=0,E=0;const A=Math.PI,C=y*ta,S=ai(C),F=oi(C),j=.5*(-F*d-S*p),D=.5*(-F*p+S*d),k=f**2,P=g**2,L=D**2,V=j**2,Y=k*P-k*L-P*V;let Z=Math.abs(f),B=Math.abs(g);if(Y<0){const lt=Math.sqrt(1-Y/(k*P));Z*=lt,B*=lt}else E=(m===v?-1:1)*Math.sqrt(Y/(k*L+P*V));const N=E*Z*D/B,M=-E*B*j/Z,H=F*N-S*M+.5*d,J=S*N+F*M+.5*p;let bt=dl(1,0,(j-N)/Z,(D-M)/B),nt=dl((j-N)/Z,(D-M)/B,(-j-N)/Z,(-D-M)/B);v===0&&nt>0?nt-=2*A:v===1&&nt<0&&(nt+=2*A);const he=Math.ceil(Math.abs(nt/A*2)),I=[],tt=nt/he,$t=8/3*Math.sin(tt/4)*Math.sin(tt/4)/Math.sin(tt/2);let at=bt+tt;for(let lt=0;lt<he;lt++)I[lt]=tp(bt,at,F,S,Z,B,H,J,$t,x,T),x=I[lt][5],T=I[lt][6],bt=at,at+=tt;return I})(c-n,h-t,r,s,a,l,o);for(let d=0,p=u.length;d<p;d++)u[d][1]+=n,u[d][2]+=t,u[d][3]+=n,u[d][4]+=t,u[d][5]+=n,u[d][6]+=t;return u},ip=n=>{let t=0,e=0,i=0,r=0;const s=[];let o,a=0,l=0;for(const c of n){const h=[...c];let u;switch(h[0]){case"l":h[1]+=t,h[2]+=e;case"L":t=h[1],e=h[2],u=["L",t,e];break;case"h":h[1]+=t;case"H":t=h[1],u=["L",t,e];break;case"v":h[1]+=e;case"V":e=h[1],u=["L",t,e];break;case"m":h[1]+=t,h[2]+=e;case"M":t=h[1],e=h[2],i=h[1],r=h[2],u=["M",t,e];break;case"c":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e,h[5]+=t,h[6]+=e;case"C":a=h[3],l=h[4],t=h[5],e=h[6],u=["C",h[1],h[2],a,l,t,e];break;case"s":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"S":o==="C"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[3],e=h[4],u=["C",a,l,h[1],h[2],t,e],a=u[3],l=u[4];break;case"q":h[1]+=t,h[2]+=e,h[3]+=t,h[4]+=e;case"Q":a=h[1],l=h[2],t=h[3],e=h[4],u=["Q",a,l,t,e];break;case"t":h[1]+=t,h[2]+=e;case"T":o==="Q"?(a=2*t-a,l=2*e-l):(a=t,l=e),t=h[1],e=h[2],u=["Q",a,l,t,e];break;case"a":h[6]+=t,h[7]+=e;case"A":ep(t,e,h).forEach(d=>s.push(d)),t=h[6],e=h[7];break;case"z":case"Z":t=i,e=r,u=["Z"]}u?(s.push(u),o=u[0]):o=""}return s},xn=(n,t,e,i)=>Math.sqrt((e-n)**2+(i-t)**2),Bc=(n,t,e,i,r,s,o,a)=>l=>{const c=l**3,h=(p=>3*p**2*(1-p))(l),u=(p=>3*p*(1-p)**2)(l),d=(p=>(1-p)**3)(l);return new w(o*c+r*h+e*u+n*d,a*c+s*h+i*u+t*d)},Nc=n=>n**2,zc=n=>2*n*(1-n),Vc=n=>(1-n)**2,rp=(n,t,e,i,r,s,o,a)=>l=>{const c=Nc(l),h=zc(l),u=Vc(l),d=3*(u*(e-n)+h*(r-e)+c*(o-r)),p=3*(u*(i-t)+h*(s-i)+c*(a-s));return Math.atan2(p,d)},sp=(n,t,e,i,r,s)=>o=>{const a=Nc(o),l=zc(o),c=Vc(o);return new w(r*a+e*l+n*c,s*a+i*l+t*c)},np=(n,t,e,i,r,s)=>o=>{const a=1-o,l=2*(a*(e-n)+o*(r-e)),c=2*(a*(i-t)+o*(s-i));return Math.atan2(c,l)},fl=(n,t,e)=>{let i=new w(t,e),r=0;for(let s=1;s<=100;s+=1){const o=n(s/100);r+=xn(i.x,i.y,o.x,o.y),i=o}return r},op=(n,t)=>{let e,i=0,r=0,s={x:n.x,y:n.y},o=_({},s),a=.01,l=0;const c=n.iterator,h=n.angleFinder;for(;r<t&&a>1e-4;)o=c(i),l=i,e=xn(s.x,s.y,o.x,o.y),e+r>t?(i-=a,a/=2):(s=o,i+=a,r+=e);return _(_({},o),{},{angle:h(l)})},Hc=n=>{let t,e,i=0,r=0,s=0,o=0,a=0;const l=[];for(const c of n){const h={x:r,y:s,command:c[0],length:0};switch(c[0]){case"M":e=h,e.x=o=r=c[1],e.y=a=s=c[2];break;case"L":e=h,e.length=xn(r,s,c[1],c[2]),r=c[1],s=c[2];break;case"C":t=Bc(r,s,c[1],c[2],c[3],c[4],c[5],c[6]),e=h,e.iterator=t,e.angleFinder=rp(r,s,c[1],c[2],c[3],c[4],c[5],c[6]),e.length=fl(t,r,s),r=c[5],s=c[6];break;case"Q":t=sp(r,s,c[1],c[2],c[3],c[4]),e=h,e.iterator=t,e.angleFinder=np(r,s,c[1],c[2],c[3],c[4]),e.length=fl(t,r,s),r=c[3],s=c[4];break;case"Z":e=h,e.destX=o,e.destY=a,e.length=xn(r,s,o,a),r=o,s=a}i+=e.length,l.push(e)}return l.push({length:i,x:r,y:s}),l},ap=function(n,t){let e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Hc(n),i=0;for(;t-e[i].length>0&&i<e.length-2;)t-=e[i].length,i++;const r=e[i],s=t/r.length,o=n[i];switch(r.command){case"M":return{x:r.x,y:r.y,angle:0};case"Z":return _(_({},new w(r.x,r.y).lerp(new w(r.destX,r.destY),s)),{},{angle:Math.atan2(r.destY-r.y,r.destX-r.x)});case"L":return _(_({},new w(r.x,r.y).lerp(new w(o[1],o[2]),s)),{},{angle:Math.atan2(o[2]-r.y,o[1]-r.x)});case"C":case"Q":return op(r,t)}},lp=new RegExp("[mzlhvcsqta][^mzlhvcsqta]*","gi"),gl=new RegExp(Jd,"g"),cp=new RegExp(Gi,"gi"),hp={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},up=n=>{var t;const e=[],i=(t=n.match(lp))!==null&&t!==void 0?t:[];for(const r of i){const s=r[0];if(s==="z"||s==="Z"){e.push([s]);continue}const o=hp[s.toLowerCase()];let a=[];if(s==="a"||s==="A"){gl.lastIndex=0;for(let l=null;l=gl.exec(r);)a.push(...l.slice(1))}else a=r.match(cp)||[];for(let l=0;l<a.length;l+=o){const c=new Array(o),h=Qd[s];c[0]=l>0&&h?h:s;for(let u=0;u<o;u++)c[u+1]=parseFloat(a[l+u]);e.push(c)}}return e},dp=(n,t)=>n.map(e=>e.map((i,r)=>r===0||t===void 0?i:ft(i,t)).join(" ")).join(" ");function Mo(n,t){const e=n.style;e&&t&&(typeof t=="string"?e.cssText+=";"+t:Object.entries(t).forEach(i=>{let[r,s]=i;return e.setProperty(r,s)}))}class pp extends bc{constructor(t){let{allowTouchScrolling:e=!1,containerClass:i=""}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(t),b(this,"upper",void 0),b(this,"container",void 0);const{el:r}=this.lower,s=this.createUpperCanvas();this.upper={el:s,ctx:s.getContext("2d")},this.applyCanvasStyle(r,{allowTouchScrolling:e}),this.applyCanvasStyle(s,{allowTouchScrolling:e,styles:{position:"absolute",left:"0",top:"0"}});const o=this.createContainerElement();o.classList.add(i),r.parentNode&&r.parentNode.replaceChild(o,r),o.append(r,s),this.container=o}createUpperCanvas(){const{el:t}=this.lower,e=Ae();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=vr().createElement("div");return t.setAttribute("data-fabric","wrapper"),Mo(t,{position:"relative"}),Ya(t),t}applyCanvasStyle(t,e){const{styles:i,allowTouchScrolling:r}=e;Mo(t,_(_({},i),{},{"touch-action":r?"manipulation":oe})),Ya(t)}setDimensions(t,e){super.setDimensions(t,e);const{el:i,ctx:r}=this.upper;vc(i,r,t,e)}setCSSDimensions(t){super.setCSSDimensions(t),Co(this.upper.el,t),Co(this.container,t)}cleanupDOM(t){const e=this.container,{el:i}=this.lower,{el:r}=this.upper;super.cleanupDOM(t),e.removeChild(r),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 Rn extends ds{constructor(){super(...arguments),b(this,"targets",[]),b(this,"_hoveredTargets",[]),b(this,"_objectsToRender",void 0),b(this,"_currentTransform",null),b(this,"_groupSelector",null),b(this,"contextTopDirty",!1)}static getDefaults(){return _(_({},super.getDefaults()),Rn.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 pp(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 r=this.targetFindTolerance,s=this.pixelFindContext;this.clearContext(s),s.save(),s.translate(-e+r,-i+r),s.transform(...this.viewportTransform);const o=t.selectionBackgroundColor;t.selectionBackgroundColor="",t.render(s),t.selectionBackgroundColor=o,s.restore();const a=Math.round(r*this.getRetinaScaling());return bd(s,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(),r=this._activeObject;return!!(!e||e&&r&&i.length>1&&i.indexOf(e)===-1&&r!==e&&!this._isSelectionKeyPressed(t)||e&&!e.evented||e&&!e.selectable&&r&&r!==e)}_shouldCenterTransform(t,e,i){if(!t)return;let r;return e===Pn||e===le||e===xe||e===Yr?r=this.centeredScaling||t.centeredScaling:e===ra&&(r=this.centeredRotation||t.centeredRotation),r?!i:i}_getOriginFromCorner(t,e){const i={x:t.originX,y:t.originY};return e&&(["ml","tl","bl"].includes(e)?i.x=xt:["mr","tr","br"].includes(e)&&(i.x=it),["tl","mt","tr"].includes(e)?i.y=wo:["bl","mb","br"].includes(e)&&(i.y=ne)),i}_setupCurrentTransform(t,e,i){var r;const s=e.group?hr(this.getScenePoint(t),void 0,e.group.calcTransformMatrix()):this.getScenePoint(t),{key:o="",control:a}=e.getActiveControl()||{},l=i&&a?(r=a.getActionHandler(t,e,a))===null||r===void 0?void 0:r.bind(a):Ru,c=((p,f,g,m)=>{if(!f||!p)return"drag";const v=m.controls[f];return v.getActionName(g,v,m)})(i,o,t,e),h=t[this.centeredKey],u=this._shouldCenterTransform(e,c,h)?{x:K,y:K}:this._getOriginFromCorner(e,o),d={target:e,action:c,actionHandler:l,actionPerformed:!1,corner:o,scaleX:e.scaleX,scaleY:e.scaleY,skewX:e.skewX,skewY:e.skewY,offsetX:s.x-e.left,offsetY:s.y-e.top,originX:u.x,originY:u.y,ex:s.x,ey:s.y,lastX:s.x,lastY:s.y,theta:Ct(e.angle),width:e.width,height:e.height,shiftKey:t.shiftKey,altKey:h,original:_(_({},_c(e)),{},{originX:u.x,originY:u.y})};this._currentTransform=d,this.fire("before:transform",{e:t,transform:d})}setCursor(t){this.upperCanvasEl.style.cursor=t}_drawSelection(t){const{x:e,y:i,deltaX:r,deltaY:s}=this._groupSelector,o=new w(e,i).transform(this.viewportTransform),a=new w(e+r,i+s).transform(this.viewportTransform),l=this.selectionLineWidth/2;let c=Math.min(o.x,a.x),h=Math.min(o.y,a.y),u=Math.max(o.x,a.x),d=Math.max(o.y,a.y);this.selectionColor&&(t.fillStyle=this.selectionColor,t.fillRect(c,h,u-c,d-h)),this.selectionLineWidth&&this.selectionBorderColor&&(t.lineWidth=this.selectionLineWidth,t.strokeStyle=this.selectionBorderColor,c+=l,h+=l,u-=l,d-=l,Yt.prototype._setLineDash.call(this,t,this.selectionDashArray),t.strokeRect(c,h,u-c,d-h))}findTarget(t){if(this.skipTargetFind)return;const e=this.getViewportPoint(t),i=this._activeObject,r=this.getActiveObjects();if(this.targets=[],i&&r.length>=1){if(i.findControl(e,So(t))||r.length>1&&this.searchPossibleTargets([i],e))return i;if(i===this.searchPossibleTargets([i],e)){if(this.preserveObjectStacking){const s=this.targets;this.targets=[];const o=this.searchPossibleTargets(this._objects,e);return t[this.altSelectionKey]&&o&&o!==i?(this.targets=s,i):o}return i}}return this.searchPossibleTargets(this._objects,e)}_pointIsInObjectSelectionArea(t,e){let i=t.getCoords();const r=this.getZoom(),s=t.padding/r;if(s){const[o,a,l,c]=i,h=Math.atan2(a.y-o.y,a.x-o.x),u=oi(h)*s,d=ai(h)*s,p=u+d,f=u-d;i=[new w(o.x-f,o.y-p),new w(a.x+p,a.y-f),new w(l.x+f,l.y+p),new w(c.x-p,c.y+f)]}return pt.isPointInPolygon(e,i)}_checkTarget(t,e){return!!(t&&t.visible&&t.evented&&this._pointIsInObjectSelectionArea(t,hr(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 r=t[i];if(this._checkTarget(r,e)){if(en(r)&&r.subTargetCheck){const s=this._searchPossibleTargets(r._objects,e);s&&this.targets.push(s)}return r}}}searchPossibleTargets(t,e){const i=this._searchPossibleTargets(t,e);if(i&&en(i)&&i.interactive&&this.targets[0]){const r=this.targets;for(let s=r.length-1;s>0;s--){const o=r[s];if(!en(o)||!o.interactive)return o}return r[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,r=i.getBoundingClientRect();let s=Pu(t),o=r.width||0,a=r.height||0;o&&a||(ne in r&&wo in r&&(a=Math.abs(r.top-r.bottom)),xt in r&&it in r&&(o=Math.abs(r.right-r.left))),this.calcOffset(),s.x=s.x-this._offset.left,s.y=s.y-this._offset.top,e||(s=hr(s,void 0,this.viewportTransform));const l=this.getRetinaScaling();l!==1&&(s.x/=l,s.y/=l);const c=o===0||a===0?new w(1,1):new w(i.width/o,i.height/a);return s.multiply(c)}_setDimensionsImpl(t,e){this._resetTransformEventData(),super._setDimensionsImpl(t,e),this._isCurrentlyDrawing&&this.freeDrawingBrush&&this.freeDrawingBrush._setBrushStyles(this.contextTop)}_createCacheCanvas(){this.pixelFindCanvasEl=Ae(),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 ji(t)?t.getObjects():t?[t]:[]}_fireSelectionEvents(t,e){let i=!1,r=!1;const s=this.getActiveObjects(),o=[],a=[];t.forEach(l=>{s.includes(l)||(i=!0,l.fire("deselected",{e,target:l}),a.push(l))}),s.forEach(l=>{t.includes(l)||(i=!0,l.fire("selected",{e,target:l}),o.push(l))}),t.length>0&&s.length>0?(r=!0,i&&this.fire("selection:updated",{e,selected:o,deselected:a})):s.length>0?(r=!0,this.fire("selection:created",{e,selected:o})):t.length>0&&(r=!0,this.fire("selection:cleared",{e,deselected:a})),r&&(this._objectsToRender=void 0)}setActiveObject(t,e){const i=this.getActiveObjects(),r=this._setActiveObject(t,e);return this._fireSelectionEvents(i,e),r}_setActiveObject(t,e){const i=this._activeObject;return i!==t&&!(!this._discardActiveObject(e,t)&&this._activeObject)&&!t.onSelect({e})&&(this._activeObject=t,ji(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),ji(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 r=this._discardActiveObject(t);return this._fireSelectionEvents(e,t),r}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,r={e:t,target:i,transform:e,action:e.action};i._scaling&&(i._scaling=!1),i.setCoords(),e.actionPerformed&&(this.fire("object:modified",r),i.fire(pn,r))}setViewportTransform(t){super.setViewportTransform(t);const e=this._activeObject;e&&e.setCoords()}destroy(){const t=this._activeObject;ji(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 r=this._realizeGroupTransformOnObject(t),s=super._toObject(t,e,i);return t.set(r),s}_realizeGroupTransformOnObject(t){const{group:e}=t;if(e&&ji(e)&&this._activeObject===e){const i=yr(t,["angle","flipX","flipY",it,le,xe,br,_r,ne]);return Mu(t,e.calcOwnMatrix()),i}return{}}_setSVGObject(t,e,i){const r=this._realizeGroupTransformOnObject(e);super._setSVGObject(t,e,i),e.set(r)}}b(Rn,"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 fp{constructor(t){b(this,"targets",[]),b(this,"__disposer",void 0);const e=()=>{const{hiddenTextarea:r}=t.getActiveObject()||{};r&&r.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),tr(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 gp=["target","oldTarget","fireCanvas","e"],ue={passive:!1},Qi=(n,t)=>{const e=n.getViewportPoint(t),i=n.getScenePoint(t);return{viewportPoint:e,scenePoint:i,pointer:e,absolutePointer:i}},gi=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.addEventListener(...e)},ve=function(n){for(var t=arguments.length,e=new Array(t>1?t-1:0),i=1;i<t;i++)e[i-1]=arguments[i];return n.removeEventListener(...e)},mp={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 Jr extends Rn{constructor(t){super(t,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}),b(this,"_isClick",void 0),b(this,"textEditingManager",new fp(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(gi,"add")}_getEventPrefix(){return this.enablePointerEvents?"pointer":"mouse"}addOrRemove(t,e){const i=this.upperCanvasEl,r=this._getEventPrefix();t(mc(i),"resize",this._onResize),t(i,r+"down",this._onMouseDown),t(i,"".concat(r,"move"),this._onMouseMove,ue),t(i,"".concat(r,"out"),this._onMouseOut),t(i,"".concat(r,"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,ue)}removeListeners(){this.addOrRemove(ve,"remove");const t=this._getEventPrefix(),e=Oe(this.upperCanvasEl);ve(e,"".concat(t,"up"),this._onMouseUp),ve(e,"touchend",this._onTouchEnd,ue),ve(e,"".concat(t,"move"),this._onMouseMove,ue),ve(e,"touchmove",this._onMouseMove,ue),clearTimeout(this._willAddMouseDown)}_onMouseWheel(t){this.__onMouseWheel(t)}_onMouseOut(t){const e=this._hoveredTarget,i=_({e:t},Qi(this,t));this.fire("mouse:out",_(_({},i),{},{target:e})),this._hoveredTarget=void 0,e&&e.fire("mouseout",_({},i)),this._hoveredTargets.forEach(r=>{this.fire("mouse:out",_(_({},i),{},{target:r})),r&&r.fire("mouseout",_({},i))}),this._hoveredTargets=[]}_onMouseEnter(t){this._currentTransform||this.findTarget(t)||(this.fire("mouse:over",_({e:t},Qi(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 gi(this.upperCanvasEl,"drag",this._onDragProgress)}To(t)}_renderDragEffects(t,e,i){let r=!1;const s=this._dropTarget;s&&s!==e&&s!==i&&(s.clearContextTop(),r=!0),e==null||e.clearContextTop(),i!==e&&(i==null||i.clearContextTop());const o=this.contextTop;o.save(),o.transform(...this.viewportTransform),e&&(o.save(),e.transform(o),e.renderDragSourceEffect(t),o.restore(),r=!0),i&&(o.save(),i.transform(o),i.renderDropTargetEffect(t),o.restore(),r=!0),o.restore(),r&&(this.contextTopDirty=!0)}_onDragEnd(t){const e=!!t.dataTransfer&&t.dataTransfer.dropEffect!==oe,i=e?this._activeObject:void 0,r={e:t,target:this._dragSource,subTargets:this.targets,dragSource:this._dragSource,didDrop:e,dropTarget:i};ve(this.upperCanvasEl,"drag",this._onDragProgress),this.fire("dragend",r),this._dragSource&&this._dragSource.fire("dragend",r),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:r}=this.findDragTargets(t),s=this._dragSource,o={e:t,target:i,subTargets:r,dragSource:s,canDrop:!1,dropTarget:void 0};let a;this.fire(e,o),this._fireEnterLeaveEvents(i,o),i&&(i.canDrop(t)&&(a=i),i.fire(e,o));for(let l=0;l<r.length;l++){const c=r[l];c.canDrop(t)&&(a=c),c.fire(e,o)}this._renderDragEffects(t,s,a),this._dropTarget=a}_onDragEnter(t){const{target:e,targets:i}=this.findDragTargets(t),r={e:t,target:e,subTargets:i,dragSource:this._dragSource};this.fire("dragenter",r),this._fireEnterLeaveEvents(e,r)}_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),r=this._basicEventHandler("drop:before",_({e:t,target:e,subTargets:i,dragSource:this._dragSource},Qi(this,t)));r.didDrop=!1,r.dropTarget=void 0,this._basicEventHandler("drop",r),this.fire("drop:after",r)}_onContextMenu(t){const e=this.findTarget(t),i=this.targets||[],r=this._basicEventHandler("contextmenu:before",{e:t,target:e,subTargets:i});return this.stopContextMenu&&To(t),this._basicEventHandler("contextmenu",r),!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 r=this.upperCanvasEl,s=this._getEventPrefix(),o=Oe(r);gi(o,"touchend",this._onTouchEnd,ue),e&&gi(o,"touchmove",this._onMouseMove,ue),ve(r,"".concat(s,"down"),this._onMouseDown)}_onMouseDown(t){this.__onMouseDown(t),this._resetTransformEventData();const e=this.upperCanvasEl,i=this._getEventPrefix();ve(e,"".concat(i,"move"),this._onMouseMove,ue);const r=Oe(e);gi(r,"".concat(i,"up"),this._onMouseUp),gi(r,"".concat(i,"move"),this._onMouseMove,ue)}_onTouchEnd(t){if(t.touches.length>0)return;this.__onMouseUp(t),this._resetTransformEventData(),delete this.mainTouchId;const e=this._getEventPrefix(),i=Oe(this.upperCanvasEl);ve(i,"touchend",this._onTouchEnd,ue),ve(i,"touchmove",this._onMouseMove,ue),this._willAddMouseDown&&clearTimeout(this._willAddMouseDown),this._willAddMouseDown=setTimeout(()=>{gi(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 r=Oe(this.upperCanvasEl);ve(r,"".concat(i,"up"),this._onMouseUp),ve(r,"".concat(i,"move"),this._onMouseMove,ue),gi(e,"".concat(i,"move"),this._onMouseMove,ue)}}_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,r=this._isClick,s=this._target,{button:o}=t;if(o)return(this.fireMiddleClick&&o===1||this.fireRightClick&&o===2)&&this._handleEvent(t,"up"),void this._resetTransformEventData();if(this.isDrawingMode&&this._isCurrentlyDrawing)return void this._onMouseUpInDrawingMode(t);if(!this._isMainEvent(t))return;let a,l,c=!1;if(i&&(this._finalizeCurrentTransform(t),c=i.actionPerformed),!r){const h=s===this._activeObject;this.handleSelection(t),c||(c=this._shouldRender(s)||!h&&s===this._activeObject)}if(s){const h=s.findControl(this.getViewportPoint(t),So(t)),{key:u,control:d}=h||{};if(l=u,s.selectable&&s!==this._activeObject&&s.activeOn==="up")this.setActiveObject(s,t),c=!0;else if(d){const p=d.getMouseUpHandler(t,s,d);p&&(a=this.getScenePoint(t),p.call(d,t,i,a.x,a.y))}s.isMoving=!1}if(i&&(i.target!==s||i.corner!==l)){const h=i.target&&i.target.controls[i.corner],u=h&&h.getMouseUpHandler(t,i.target,h);a=a||this.getScenePoint(t),u&&u.call(h,t,i,a.x,a.y)}this._setCursorFromEvent(t,s),this._handleEvent(t,"up"),this._groupSelector=null,this._currentTransform=null,s&&(s.__corner=void 0),c?this.requestRenderAll():r||(e=this._activeObject)!==null&&e!==void 0&&e.isEditing||this.renderTop()}_basicEventHandler(t,e){const{target:i,subTargets:r=[]}=e;this.fire(t,e),i&&i.fire(t,e);for(let s=0;s<r.length;s++)r[s]!==i&&r[s].fire(t,e);return e}_handleEvent(t,e){const i=this._target,r=this.targets||[],s=_(_({e:t,target:i,subTargets:r},Qi(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),s),i&&i.fire("mouse".concat(e),s);for(let o=0;o<r.length;o++)r[o]!==i&&r[o].fire("mouse".concat(e),s)}_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 r=this._shouldRender(e),s=!1;if(this.handleMultiSelection(t,e)?(e=this._activeObject,s=!0,r=!0):this._shouldClearSelection(t,e)&&this.discardActiveObject(t),this.selection&&(!e||!e.selectable&&!e.isEditing&&e!==this._activeObject)){const o=this.getScenePoint(t);this._groupSelector={x:o.x,y:o.y,deltaY:0,deltaX:0}}if(e){const o=e===this._activeObject;e.selectable&&e.activeOn==="down"&&this.setActiveObject(e,t);const a=e.findControl(this.getViewportPoint(t),So(t));if(e===this._activeObject&&(a||!s)){this._setupCurrentTransform(t,e,o);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)}}r&&(this._objectsToRender=void 0),this._handleEvent(t,"down"),r&&this.requestRenderAll()}_resetTransformEventData(){this._target=this._pointer=this._absolutePointer=void 0}_cacheTransformEventData(t){this._resetTransformEventData(),this._pointer=this.getViewportPoint(t),this._absolutePointer=hr(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,r=this._hoveredTargets,s=this.targets,o=Math.max(r.length,s.length);this.fireSyntheticInOutEvents("mouse",{e:t,target:e,oldTarget:i,fireCanvas:!0});for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("mouse",{e:t,target:s[a],oldTarget:r[a]});this._hoveredTarget=e,this._hoveredTargets=this.targets.concat()}_fireEnterLeaveEvents(t,e){const i=this._draggedoverTarget,r=this._hoveredTargets,s=this.targets,o=Math.max(r.length,s.length);this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:t,oldTarget:i,fireCanvas:!0}));for(let a=0;a<o;a++)this.fireSyntheticInOutEvents("drag",_(_({},e),{},{target:s[a],oldTarget:r[a]}));this._draggedoverTarget=t}fireSyntheticInOutEvents(t,e){let{target:i,oldTarget:r,fireCanvas:s,e:o}=e,a=ht(e,gp);const{targetIn:l,targetOut:c,canvasIn:h,canvasOut:u}=mp[t],d=r!==i;if(r&&d){const p=_(_({},a),{},{e:o,target:r,nextTarget:i},Qi(this,o));s&&this.fire(u,p),r.fire(c,p)}if(i&&d){const p=_(_({},a),{},{e:o,target:i,previousTarget:r},Qi(this,o));s&&this.fire(h,p),i.fire(l,p)}}__onMouseWheel(t){this._cacheTransformEventData(t),this._handleEvent(t,"wheel"),this._resetTransformEventData()}_transformObject(t){const e=this.getScenePoint(t),i=this._currentTransform,r=i.target,s=r.group?hr(e,void 0,r.group.calcTransformMatrix()):e;i.shiftKey=t.shiftKey,i.altKey=!!this.centeredKey&&t[this.centeredKey],this._performTransformAction(t,i,s),i.actionPerformed&&this.requestRenderAll()}_performTransformAction(t,e,i){const{action:r,actionHandler:s,target:o}=e,a=!!s&&s(t,e,i.x,i.y);a&&o.setCoords(),r==="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 r=ji(this._activeObject)?this._activeObject:null,s=(!r||e.group!==r)&&e.findControl(this.getViewportPoint(t));if(s){const o=s.control;this.setCursor(o.cursorStyleHandler(t,o,e))}else e.subTargetCheck&&this.targets.concat().reverse().map(o=>{i=o.hoverCursor||i}),this.setCursor(i)}handleMultiSelection(t,e){const i=this._activeObject,r=ji(i);if(i&&this._isSelectionKeyPressed(t)&&this.selection&&e&&e.selectable&&(i!==e||r)&&(r||!e.isDescendantOf(i)&&!i.isDescendantOf(e))&&!e.onSelect({e:t})&&!i.getActiveControl()){if(r){const s=i.getObjects();if(e===i){const o=this.getViewportPoint(t);if(!(e=this.searchPossibleTargets(s,o)||this.searchPossibleTargets(this._objects,o))||!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(s,t)}else{i.isEditing&&i.exitEditing();const s=new(R.getClass("ActiveSelection"))([],{canvas:this});s.multiSelectAdd(i,e),this._hoveredTarget=s,this._setActiveObject(s,t),this._fireSelectionEvents([i],t)}return!0}return!1}handleSelection(t){if(!this.selection||!this._groupSelector)return!1;const{x:e,y:i,deltaX:r,deltaY:s}=this._groupSelector,o=new w(e,i),a=o.add(new w(r,s)),l=o.min(a),c=o.max(a).subtract(l),h=this.collectObjects({left:l.x,top:l.y,width:c.x,height:c.y},{includeIntersecting:!this.selectionFullyContained}),u=o.eq(a)?h[0]?[h[0]]:[]:h.length>1?h.filter(d=>!d.onSelect({e:t})).reverse():h;if(u.length===1)this.setActiveObject(u[0],t);else if(u.length>1){const d=R.getClass("ActiveSelection");this.setActiveObject(new d(u,{canvas:this}),t)}return this._groupSelector=null,!0}clear(){this.textEditingManager.clear(),super.clear()}destroy(){this.removeListeners(),this.textEditingManager.dispose(),super.destroy()}}const $c={x1:0,y1:0,x2:0,y2:0},vp=_(_({},$c),{},{r1:0,r2:0}),sr=(n,t)=>isNaN(n)&&typeof t=="number"?t:n,bp=/^(\d+\.\d+)%|(\d+)%$/;function Wc(n){return n&&bp.test(n)}function Gc(n,t){const e=typeof n=="number"?n:typeof n=="string"?parseFloat(n)/(Wc(n)?100:1):NaN;return fr(0,sr(e,t),1)}const _p=/\s*;\s*/,yp=/\s*:\s*/;function xp(n,t){let e,i;const r=n.getAttribute("style");if(r){const o=r.split(_p);o[o.length-1]===""&&o.pop();for(let a=o.length;a--;){const[l,c]=o[a].split(yp).map(h=>h.trim());l==="stop-color"?e=c:l==="stop-opacity"&&(i=c)}}const s=new rt(e||n.getAttribute("stop-color")||"rgb(0,0,0)");return{offset:Gc(n.getAttribute("offset"),0),color:s.toRgb(),opacity:sr(parseFloat(i||n.getAttribute("stop-opacity")||""),1)*s.getAlpha()*t}}function wp(n,t){const e=[],i=n.getElementsByTagName("stop"),r=Gc(t,1);for(let s=i.length;s--;)e.push(xp(i[s],r));return e}function Uc(n){return n.nodeName==="linearGradient"||n.nodeName==="LINEARGRADIENT"?"linear":"radial"}function Yc(n){return n.getAttribute("gradientUnits")==="userSpaceOnUse"?"pixels":"percentage"}function Ce(n,t){return n.getAttribute(t)}function Cp(n,t){return function(e,i){let r,{width:s,height:o,gradientUnits:a}=i;return Object.keys(e).reduce((l,c)=>{const h=e[c];return h==="Infinity"?r=1:h==="-Infinity"?r=0:(r=typeof h=="string"?parseFloat(h):h,typeof h=="string"&&Wc(h)&&(r*=.01,a==="pixels"&&(c!=="x1"&&c!=="x2"&&c!=="r2"||(r*=s),c!=="y1"&&c!=="y2"||(r*=o)))),l[c]=r,l},{})}(Uc(n)==="linear"?function(e){return{x1:Ce(e,"x1")||0,y1:Ce(e,"y1")||0,x2:Ce(e,"x2")||"100%",y2:Ce(e,"y2")||0}}(n):function(e){return{x1:Ce(e,"fx")||Ce(e,"cx")||"50%",y1:Ce(e,"fy")||Ce(e,"cy")||"50%",r1:0,x2:Ce(e,"cx")||"50%",y2:Ce(e,"cy")||"50%",r2:Ce(e,"r")||"50%"}}(n),_(_({},t),{},{gradientUnits:Yc(n)}))}class ks{constructor(t){const{type:e="linear",gradientUnits:i="pixels",coords:r={},colorStops:s=[],offsetX:o=0,offsetY:a=0,gradientTransform:l,id:c}=t||{};Object.assign(this,{type:e,gradientUnits:i,coords:_(_({},e==="radial"?vp:$c),r),colorStops:s,offsetX:o,offsetY:a,gradientTransform:l,id:c?"".concat(c,"_").concat(xi()):xi()})}addColorStop(t){for(const e in t){const i=new rt(t[e]);this.colorStops.push({offset:parseFloat(e),color:i.toRgb(),opacity:i.getAlpha()})}return this}toObject(t){return _(_({},yr(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=[],r=this.gradientTransform?this.gradientTransform.concat():Qt.concat(),s=this.gradientUnits==="pixels"?"userSpaceOnUse":"objectBoundingBox",o=this.colorStops.map(u=>_({},u)).sort((u,d)=>u.offset-d.offset);let a=-this.offsetX,l=-this.offsetY;var c;s==="objectBoundingBox"?(a/=t.width,l/=t.height):(a+=t.width/2,l+=t.height/2),(c=t)&&typeof c._renderPathCommands=="function"&&this.gradientUnits!=="percentage"&&(a-=t.pathOffset.x,l-=t.pathOffset.y),r[4]-=a,r[5]-=l;const h=['id="SVGID_'.concat(this.id,'"'),'gradientUnits="'.concat(s,'"'),'gradientTransform="'.concat(e?e+" ":"").concat(mn(r),'"'),""].join(" ");if(this.type==="linear"){const{x1:u,y1:d,x2:p,y2:f}=this.coords;i.push("<linearGradient ",h,' x1="',u,'" y1="',d,'" x2="',p,'" y2="',f,`">
|
|
130
|
+
`)}else if(this.type==="radial"){const{x1:u,y1:d,x2:p,y2:f,r1:g,r2:m}=this.coords,v=g>m;i.push("<radialGradient ",h,' cx="',v?u:p,'" cy="',v?d:f,'" r="',v?g:m,'" fx="',v?p:u,'" fy="',v?f:d,`">
|
|
131
|
+
`),v&&(o.reverse(),o.forEach(x=>{x.offset=1-x.offset}));const y=Math.min(g,m);if(y>0){const x=y/Math.max(g,m);o.forEach(T=>{T.offset+=x*(1-T.offset)})}}return o.forEach(u=>{let{color:d,offset:p,opacity:f}=u;i.push("<stop ",'offset="',100*p+"%",'" style="stop-color:',d,f!==void 0?";stop-opacity: "+f:";",`"/>
|
|
132
|
+
`)}),i.push(this.type==="linear"?"</linearGradient>":"</radialGradient>",`
|
|
133
|
+
`),i.join("")}toLive(t){const{x1:e,y1:i,x2:r,y2:s,r1:o,r2:a}=this.coords,l=this.type==="linear"?t.createLinearGradient(e,i,r,s):t.createRadialGradient(e,i,o,r,s,a);return this.colorStops.forEach(c=>{let{color:h,opacity:u,offset:d}=c;l.addColorStop(d,u!==void 0?new rt(h).setAlpha(u).toRgba():h)}),l}static async fromObject(t){const{colorStops:e,gradientTransform:i}=t;return new this(_(_({},t),{},{colorStops:e?e.map(r=>_({},r)):void 0,gradientTransform:i?[...i]:void 0}))}static fromElement(t,e,i){const r=Yc(t),s=e._findCenterFromElement();return new this(_({id:t.getAttribute("id")||void 0,type:Uc(t),coords:Cp(t,{width:i.viewBoxWidth||i.width,height:i.viewBoxHeight||i.height}),colorStops:wp(t,i.opacity),gradientUnits:r,gradientTransform:Do(t.getAttribute("gradientTransform")||"")},r==="pixels"?{offsetX:e.width/2-s.x,offsetY:e.height/2-s.y}:{offsetX:0,offsetY:0}))}}b(ks,"type","Gradient"),R.setClass(ks,"gradient"),R.setClass(ks,"linear"),R.setClass(ks,"radial");const Sp=["type","source","patternTransform"];class so{get type(){return"pattern"}set type(t){yi("warn","Setting type has no effect",t)}constructor(t){b(this,"repeat","repeat"),b(this,"offsetX",0),b(this,"offsetY",0),b(this,"crossOrigin",""),this.id=xi(),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 _(_({},yr(this,t)),{},{type:"pattern",source:this.sourceToString(),repeat:e,crossOrigin:i,offsetX:ft(this.offsetX,Q.NUM_FRACTION_DIGITS),offsetY:ft(this.offsetY,Q.NUM_FRACTION_DIGITS),patternTransform:this.patternTransform?[...this.patternTransform]:null})}toSVG(t){let{width:e,height:i}=t;const{source:r,repeat:s,id:o}=this,a=sr(this.offsetX/e,0),l=sr(this.offsetY/i,0),c=s==="repeat-y"||s==="no-repeat"?1+Math.abs(a||0):sr(r.width/e,0),h=s==="repeat-x"||s==="no-repeat"?1+Math.abs(l||0):sr(r.height/i,0);return['<pattern id="SVGID_'.concat(o,'" x="').concat(a,'" y="').concat(l,'" width="').concat(c,'" height="').concat(h,'">'),'<image x="0" y="0" width="'.concat(r.width,'" height="').concat(r.height,'" xlink:href="').concat(this.sourceToString(),'"></image>'),"</pattern>",""].join(`
|
|
134
|
+
`)}static async fromObject(t,e){let{type:i,source:r,patternTransform:s}=t,o=ht(t,Sp);const a=await sn(r,_(_({},e),{},{crossOrigin:o.crossOrigin}));return new this(_(_({},o),{},{patternTransform:s&&s.slice(0),source:a}))}}b(so,"type","Pattern"),R.setClass(so),R.setClass(so,"pattern");const Tp=["path","left","top"],Ep=["d"];class Ri extends Yt{constructor(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{path:i,left:r,top:s}=e,o=ht(e,Tp);super(),Object.assign(this,Ri.ownDefaults),this.setOptions(o),this._setPath(t||[],!0),typeof r=="number"&&this.set(it,r),typeof s=="number"&&this.set(ne,s)}_setPath(t,e){this.path=ip(Array.isArray(t)?t:up(t)),this.setBoundingBox(e)}_findCenterFromElement(){const t=this._calcBoundsFromPath();return new w(t.left+t.width/2,t.top+t.height/2)}_renderPathCommands(t){const e=-this.pathOffset.x,i=-this.pathOffset.y;t.beginPath();for(const r of this.path)switch(r[0]){case"L":t.lineTo(r[1]+e,r[2]+i);break;case"M":t.moveTo(r[1]+e,r[2]+i);break;case"C":t.bezierCurveTo(r[1]+e,r[2]+i,r[3]+e,r[4]+i,r[5]+e,r[6]+i);break;case"Q":t.quadraticCurveTo(r[1]+e,r[2]+i,r[3]+e,r[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=dp(this.path,Q.NUM_FRACTION_DIGITS);return["<path ","COMMON_PARTS",'d="'.concat(t,`" stroke-linecap="round" />
|
|
135
|
+
`)]}_getOffsetTransform(){const t=Q.NUM_FRACTION_DIGITS;return" translate(".concat(ft(-this.pathOffset.x,t),", ").concat(ft(-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:r}=this._calcDimensions();this.set({width:e,height:i,pathOffset:r}),t&&this.setPositionByOrigin(r,K,K)}_calcBoundsFromPath(){const t=[];let e=0,i=0,r=0,s=0;for(const o of this.path)switch(o[0]){case"L":r=o[1],s=o[2],t.push({x:e,y:i},{x:r,y:s});break;case"M":r=o[1],s=o[2],e=r,i=s;break;case"C":t.push(...pl(r,s,o[1],o[2],o[3],o[4],o[5],o[6])),r=o[5],s=o[6];break;case"Q":t.push(...pl(r,s,o[1],o[2],o[1],o[2],o[3],o[4])),r=o[3],s=o[4];break;case"Z":r=e,s=i}return ii(t)}_calcDimensions(){const t=this._calcBoundsFromPath();return _(_({},t),{},{pathOffset:new w(t.left+t.width/2,t.top+t.height/2)})}static fromObject(t){return this._fromObject(t,{extraParam:"path"})}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i),{d:s}=r;return new this(s,_(_(_({},ht(r,Ep)),e),{},{left:void 0,top:void 0}))}}b(Ri,"type","Path"),b(Ri,"cacheProperties",[...ui,"path","fillRule"]),b(Ri,"ATTRIBUTE_NAMES",[...Di,"d"]),R.setClass(Ri),R.setSVGClass(Ri);const Op=["left","top","radius"],Xc=["radius","startAngle","endAngle","counterClockwise"];class Xe extends Yt{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,Ct(this.startAngle),Ct(this.endAngle),this.counterClockwise),this._renderPaintInOrder(t)}getRadiusX(){return this.get("radius")*this.get(le)}getRadiusY(){return this.get("radius")*this.get(xe)}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([...Xc,...t])}_toSVG(){const t=(this.endAngle-this.startAngle)%360;if(t===0)return["<circle ","COMMON_PARTS",'cx="0" cy="0" ','r="',"".concat(this.radius),`" />
|
|
136
|
+
`];{const{radius:e}=this,i=Ct(this.startAngle),r=Ct(this.endAngle),s=oi(i)*e,o=ai(i)*e,a=oi(r)*e,l=ai(r)*e,c=t>180?1:0,h=this.counterClockwise?0:1;return['<path d="M '.concat(s," ").concat(o," A ").concat(e," ").concat(e," 0 ").concat(c," ").concat(h," ").concat(a," ").concat(l,'" '),"COMMON_PARTS",` />
|
|
137
|
+
`]}}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i),{left:s=0,top:o=0,radius:a=0}=r;return new this(_(_({},ht(r,Op)),{},{radius:a,left:s-a,top:o-a}))}static fromObject(t){return super._fromObject(t)}}b(Xe,"type","Circle"),b(Xe,"cacheProperties",[...ui,...Xc]),b(Xe,"ownDefaults",{radius:0,startAngle:0,endAngle:360,counterClockwise:!1}),b(Xe,"ATTRIBUTE_NAMES",["cx","cy","r",...Di]),R.setClass(Xe),R.setSVGClass(Xe);const kp=["x1","y1","x2","y2"],Dp=["x1","y1","x2","y2"],Io=["x1","x2","y1","y2"];class Bi extends Yt{constructor(){let[t,e,i,r]=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[0,0,0,0],s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),Object.assign(this,Bi.ownDefaults),this.setOptions(s),this.x1=t,this.x2=i,this.y1=e,this.y2=r,this._setWidthHeight();const{left:o,top:a}=s;typeof o=="number"&&this.set(it,o),typeof a=="number"&&this.set(ne,a)}_setWidthHeight(){const{x1:t,y1:e,x2:i,y2:r}=this;this.width=Math.abs(i-t),this.height=Math.abs(r-e);const{left:s,top:o,width:a,height:l}=ii([{x:t,y:e},{x:i,y:r}]),c=new w(s+a/2,o+l/2);this.setPositionByOrigin(c,K,K)}_set(t,e){return super._set(t,e),Io.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 r;_e(this.stroke)?t.strokeStyle=this.stroke.toLive(t):t.strokeStyle=(r=this.stroke)!==null&&r!==void 0?r:t.fillStyle,this.stroke&&this._renderStroke(t),t.strokeStyle=i}_findCenterFromElement(){return new w((this.x1+this.x2)/2,(this.y1+this.y2)/2)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject(t)),this.calcLinePoints())}_getNonTransformedDimensions(){const t=super._getNonTransformedDimensions();return this.strokeLineCap==="butt"&&(this.width===0&&(t.y-=this.strokeWidth),this.height===0&&(t.x-=this.strokeWidth)),t}calcLinePoints(){const{x1:t,x2:e,y1:i,y2:r,width:s,height:o}=this,a=t<=e?-1:1,l=i<=r?-1:1;return{x1:a*s/2,x2:a*-s/2,y1:l*o/2,y2:l*-o/2}}_toSVG(){const{x1:t,x2:e,y1:i,y2:r}=this.calcLinePoints();return["<line ","COMMON_PARTS",'x1="'.concat(t,'" y1="').concat(i,'" x2="').concat(e,'" y2="').concat(r,`" />
|
|
138
|
+
`)]}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i),{x1:s=0,y1:o=0,x2:a=0,y2:l=0}=r;return new this([s,o,a,l],ht(r,kp))}static fromObject(t){let{x1:e,y1:i,x2:r,y2:s}=t,o=ht(t,Dp);return this._fromObject(_(_({},o),{},{points:[e,i,r,s]}),{extraParam:"points"})}}b(Bi,"type","Line"),b(Bi,"cacheProperties",[...ui,...Io]),b(Bi,"ATTRIBUTE_NAMES",Di.concat(Io)),R.setClass(Bi),R.setSVGClass(Bi);class zi extends Yt{static getDefaults(){return _(_({},super.getDefaults()),zi.ownDefaults)}constructor(t){super(),Object.assign(this,zi.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),'" />']}}b(zi,"type","Triangle"),b(zi,"ownDefaults",{width:100,height:100}),R.setClass(zi),R.setSVGClass(zi);const Kc=["rx","ry"];class Ke extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Ke.ownDefaults)}constructor(t){super(),Object.assign(this,Ke.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(le)}getRy(){return this.get("ry")*this.get(xe)}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return super.toObject([...Kc,...t])}_toSVG(){return["<ellipse ","COMMON_PARTS",'cx="0" cy="0" rx="'.concat(this.rx,'" ry="').concat(this.ry,`" />
|
|
139
|
+
`)]}_render(t){t.beginPath(),t.save(),t.transform(1,0,0,this.ry/this.rx,0,0),t.arc(0,0,this.rx,0,un,!1),t.restore(),this._renderPaintInOrder(t)}static async fromElement(t,e,i){const r=di(t,this.ATTRIBUTE_NAMES,i);return r.left=(r.left||0)-r.rx,r.top=(r.top||0)-r.ry,new this(r)}}function Pp(n){if(!n)return[];const t=n.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}b(Ke,"type","Ellipse"),b(Ke,"cacheProperties",[...ui,...Kc]),b(Ke,"ownDefaults",{rx:0,ry:0}),b(Ke,"ATTRIBUTE_NAMES",[...Di,"cx","cy","rx","ry"]),R.setClass(Ke),R.setSVGClass(Ke);const Ap=["left","top"],qc={exactBoundingBox:!1};class Te extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Te.ownDefaults)}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),b(this,"strokeDiff",void 0),Object.assign(this,Te.ownDefaults),this.setOptions(e),this.points=t;const{left:i,top:r}=e;this.initialized=!0,this.setBoundingBox(!0),typeof i=="number"&&this.set(it,i),typeof r=="number"&&this.set(ne,r)}isOpen(){return!0}_projectStrokeOnPoints(t){return yd(this.points,t,this.isOpen())}_calcDimensions(t){t=_({scaleX:this.scaleX,scaleY:this.scaleY,skewX:this.skewX,skewY:this.skewY,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:this.strokeMiterLimit,strokeUniform:this.strokeUniform,strokeWidth:this.strokeWidth},t||{});const e=this.exactBoundingBox?this._projectStrokeOnPoints(t).map(c=>c.projectedPoint):this.points;if(e.length===0)return{left:0,top:0,width:0,height:0,pathOffset:new w,strokeOffset:new w,strokeDiff:new w};const i=ii(e),r=An(_(_({},t),{},{scaleX:1,scaleY:1})),s=ii(this.points.map(c=>re(c,r,!0))),o=new w(this.scaleX,this.scaleY);let a=i.left+i.width/2,l=i.top+i.height/2;return this.exactBoundingBox&&(a-=l*Math.tan(Ct(this.skewX)),l-=a*Math.tan(Ct(this.skewY))),_(_({},i),{},{pathOffset:new w(a,l),strokeOffset:new w(s.left,s.top).subtract(new w(i.left,i.top)).multiply(o),strokeDiff:new w(i.width,i.height).subtract(new w(s.width,s.height)).multiply(o)})}_findCenterFromElement(){const t=ii(this.points);return new w(t.left+t.width/2,t.top+t.height/2)}setDimensions(){this.setBoundingBox()}setBoundingBox(t){const{left:e,top:i,width:r,height:s,pathOffset:o,strokeOffset:a,strokeDiff:l}=this._calcDimensions();this.set({width:r,height:s,pathOffset:o,strokeOffset:a,strokeDiff:l}),t&&this.setPositionByOrigin(new w(e+r/2,i+s/2),K,K)}isStrokeAccountedForInDimensions(){return this.exactBoundingBox}_getNonTransformedDimensions(){return this.exactBoundingBox?new w(this.width,this.height):super._getNonTransformedDimensions()}_getTransformedDimensions(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(this.exactBoundingBox){let o;if(Object.keys(t).some(a=>this.strokeUniform||this.constructor.layoutProperties.includes(a))){var e,i;const{width:a,height:l}=this._calcDimensions(t);o=new w((e=t.width)!==null&&e!==void 0?e:a,(i=t.height)!==null&&i!==void 0?i:l)}else{var r,s;o=new w((r=t.width)!==null&&r!==void 0?r:this.width,(s=t.height)!==null&&s!==void 0?s:this.height)}return o.multiply(new w(t.scaleX||this.scaleX,t.scaleY||this.scaleY))}return super._getTransformedDimensions(t)}_set(t,e){const i=this.initialized&&this[t]!==e,r=super._set(t,e);return this.exactBoundingBox&&i&&((t===le||t===xe)&&this.strokeUniform&&this.constructor.layoutProperties.includes("strokeUniform")||this.constructor.layoutProperties.includes(t))&&this.setDimensions(),r}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:r}=e;return{x:i,y:r}})})}_toSVG(){const t=[],e=this.pathOffset.x,i=this.pathOffset.y,r=Q.NUM_FRACTION_DIGITS;for(let s=0,o=this.points.length;s<o;s++)t.push(ft(this.points[s].x-e,r),",",ft(this.points[s].y-i,r)," ");return["<".concat(this.constructor.type.toLowerCase()," "),"COMMON_PARTS",'points="'.concat(t.join(""),`" />
|
|
140
|
+
`)]}_render(t){const e=this.points.length,i=this.pathOffset.x,r=this.pathOffset.y;if(e&&!isNaN(this.points[e-1].y)){t.beginPath(),t.moveTo(this.points[0].x-i,this.points[0].y-r);for(let s=0;s<e;s++){const o=this.points[s];t.lineTo(o.x-i,o.y-r)}!this.isOpen()&&t.closePath(),this._renderPaintInOrder(t)}}complexity(){return this.points.length}static async fromElement(t,e,i){return new this(Pp(t.getAttribute("points")),_(_({},ht(di(t,this.ATTRIBUTE_NAMES,i),Ap)),e))}static fromObject(t){return this._fromObject(t,{extraParam:"points"})}}b(Te,"ownDefaults",qc),b(Te,"type","Polyline"),b(Te,"layoutProperties",[br,_r,"strokeLineCap","strokeLineJoin","strokeMiterLimit","strokeWidth","strokeUniform","points"]),b(Te,"cacheProperties",[...ui,"points"]),b(Te,"ATTRIBUTE_NAMES",[...Di]),R.setClass(Te),R.setSVGClass(Te);class Ds extends Te{isOpen(){return!1}}b(Ds,"ownDefaults",qc),b(Ds,"type","Polygon"),R.setClass(Ds),R.setSVGClass(Ds);const Zc=["fontSize","fontWeight","fontFamily","fontStyle"],Jc=["underline","overline","linethrough"],Qc=[...Zc,"lineHeight","text","charSpacing","textAlign","styles","path","pathStartOffset","pathSide","pathAlign"],th=[...Qc,...Jc,"textBackgroundColor","direction"],Mp=[...Zc,...Jc,ae,"strokeWidth",It,"deltaY","textBackgroundColor"],Ip={_reNewline:ia,_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:it,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:it,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",wn="justify-left",Hr="justify-right",$r="justify-center";class eh extends Yt{isEmptyStyles(t){if(!this.styles||t!==void 0&&!this.styles[t])return!0;const e=t===void 0?this.styles:{line:this.styles[t]};for(const i in e)for(const r in e[i])for(const s in e[i][r])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 r in i)for(const s in i[r])if(i[r][s][t]!==void 0)return!0;return!1}cleanStyle(t){if(!this.styles)return!1;const e=this.styles;let i,r,s=0,o=!0,a=0;for(const l in e){i=0;for(const c in e[l]){const h=e[l][c]||{};s++,h[t]!==void 0?(r?h[t]!==r&&(o=!1):r=h[t],h[t]===this[t]&&delete h[t]):o=!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;o&&s===a&&(this[t]=r,this.removeStyle(t))}removeStyle(t){if(!this.styles)return;const e=this.styles;let i,r,s;for(r in e){for(s in i=e[r],i)delete i[s][t],Object.keys(i[s]).length===0&&delete i[s];Object.keys(i).length===0&&delete e[r]}}_extendStyles(t,e){const{lineIndex:i,charIndex:r}=this.get2DCursorLocation(t);this._getLineStyle(i)||this._setLineStyle(i);const s=aa(_(_({},this._getStyleDeclaration(i,r)),e),o=>o!==void 0);this._setStyleDeclaration(i,r,s)}getSelectionStyles(t,e,i){const r=[];for(let s=t;s<(e||t);s++)r.push(this.getStyleAtPosition(s,i));return r}getStyleAtPosition(t,e){const{lineIndex:i,charIndex:r}=this.get2DCursorLocation(t);return e?this.getCompleteStyleDeclaration(i,r):this._getStyleDeclaration(i,r)}setSelectionStyles(t,e,i){for(let r=e;r<(i||e);r++)this._extendStyles(r,t);this._forceClearCache=!0}_getStyleDeclaration(t,e){var i;const r=this.styles&&this.styles[t];return r&&(i=r[e])!==null&&i!==void 0?i:{}}getCompleteStyleDeclaration(t,e){return _(_({},yr(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]}}b(eh,"_styleProperties",Mp);const Lp=/ +/g,Fp=/"/g;function no(n,t,e,i,r){return" ".concat(function(s,o){let{left:a,top:l,width:c,height:h}=o,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Q.NUM_FRACTION_DIGITS;const d=Kr(It,s,!1),[p,f,g,m]=[a,l,c,h].map(v=>ft(v,u));return"<rect ".concat(d,' x="').concat(p,'" y="').concat(f,'" width="').concat(g,'" height="').concat(m,'"></rect>')}(n,{left:t,top:e,width:i,height:r}),`
|
|
141
|
+
`)}const jp=["textAnchor","textDecoration","dx","dy","top","left","fontSize","strokeWidth"];let oo;class Zt extends eh{static getDefaults(){return _(_({},super.getDefaults()),Zt.ownDefaults)}constructor(t,e){super(),b(this,"__charBounds",[]),Object.assign(this,Zt.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=Hc(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,r,s,o,a;for(let l=0,c=this._textLines.length;l<c;l++)if((this.textAlign===Le||l!==c-1&&!this.isEndOfWrapping(l))&&(r=0,s=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<=s.length;h++)o=this.__charBounds[l][h],this._reSpaceAndTab.test(s[h])?(o.width+=t,o.kernedWidth+=t,o.left+=r,r+=t):o.left+=r}}isEndOfWrapping(t){return t===this._textLines.length-1}missingNewlineOffset(t){return 1}get2DCursorLocation(t,e){const i=e?this._unwrappedTextLines:this._textLines;let r;for(r=0;r<i.length;r++){if(t<=i[r].length)return{lineIndex:r,charIndex:t};t-=i[r].length+this.missingNewlineOffset(r,e)}return{lineIndex:r-1,charIndex:i[r-1].length<t?i[r-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===ae?(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 K:t.textBaseline="middle";break;case"ascender":t.textBaseline=ne;break;case"descender":t.textBaseline=wo}t.font=this._getFontDeclaration(e,i)}calcTextWidth(){let t=this.getLineWidth(0);for(let e=1,i=this._textLines.length;e<i;e++){const r=this.getLineWidth(e);r>t&&(t=r)}return t}_renderTextLine(t,e,i,r,s,o){this._renderChars(t,e,i,r,s,o)}_renderTextLinesBackground(t){if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor"))return;const e=t.fillStyle,i=this._getLeftOffset();let r=this._getTopOffset();for(let s=0,o=this._textLines.length;s<o;s++){const a=this.getHeightOfLine(s);if(!this.textBackgroundColor&&!this.styleHas("textBackgroundColor",s)){r+=a;continue}const l=this._textLines[s].length,c=this._getLineLeftOffset(s);let h,u,d=0,p=0,f=this.getValueOfPropertyAt(s,0,"textBackgroundColor");for(let g=0;g<l;g++){const m=this.__charBounds[s][g];u=this.getValueOfPropertyAt(s,g,"textBackgroundColor"),this.path?(t.save(),t.translate(m.renderLeft,m.renderTop),t.rotate(m.angle),t.fillStyle=u,u&&t.fillRect(-m.width/2,-a/this.lineHeight*(1-this._fontSizeFraction),m.width,a/this.lineHeight),t.restore()):u!==f?(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=f,f&&t.fillRect(h,r,d,a/this.lineHeight),p=m.left,d=m.width,f=u):d+=m.kernedWidth}u&&!this.path&&(h=i+c+p,this.direction==="rtl"&&(h=this.width-h-d),t.fillStyle=u,t.fillRect(h,r,d,a/this.lineHeight)),r+=a}t.fillStyle=e,this._removeShadow(t)}_measureChar(t,e,i,r){const s=zr.getFontCache(e),o=this._getFontDeclaration(e),a=i+t,l=i&&o===this._getFontDeclaration(r),c=e.fontSize/this.CACHE_FONT_SIZE;let h,u,d,p;if(i&&s[i]!==void 0&&(d=s[i]),s[t]!==void 0&&(p=h=s[t]),l&&s[a]!==void 0&&(u=s[a],p=u-d),h===void 0||d===void 0||u===void 0){const f=function(){return oo||(oo=Ne({width:0,height:0}).getContext("2d")),oo}();this._setTextStyles(f,e,!0),h===void 0&&(p=h=f.measureText(t).width,s[t]=h),d===void 0&&l&&i&&(d=f.measureText(i).width,s[i]=d),l&&u===void 0&&(u=f.measureText(a).width,s[a]=u,p=u-d)}return{width:h*c,kernedWidth:p*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,r=0;const s=this.pathSide===xt,o=this.path,a=this._textLines[t],l=a.length,c=new Array(l);this.__charBounds[t]=c;for(let h=0;h<l;h++){const u=a[h];i=this._getGraphemeBox(u,t,h,e),c[h]=i,r+=i.kernedWidth,e=u}if(c[l]={left:i?i.left+i.width:0,width:0,kernedWidth:0,height:this.fontSize,deltaY:0},o&&o.segmentsInfo){let h=0;const u=o.segmentsInfo[o.segmentsInfo.length-1].length;switch(this.textAlign){case it:h=s?u-r:0;break;case K:h=(u-r)/2;break;case xt:h=s?0:u-r}h+=this.pathStartOffset*(s?-1:1);for(let d=s?l-1:0;s?d>=0:d<l;s?d--:d++)i=c[d],h>u?h%=u:h<0&&(h+=u),this._setGraphemeOnPath(h,i),h+=i.kernedWidth}return{width:r,numOfSpaces:0}}_setGraphemeOnPath(t,e){const i=t+e.kernedWidth/2,r=this.path,s=ap(r.path,i,r.segmentsInfo);e.renderLeft=s.x-r.pathOffset.x,e.renderTop=s.y-r.pathOffset.y,e.angle=s.angle+(this.pathSide===xt?Math.PI:0)}_getGraphemeBox(t,e,i,r,s){const o=this.getCompleteStyleDeclaration(e,i),a=r?this.getCompleteStyleDeclaration(e,i-1):{},l=this._measureChar(t,o,r,a);let c,h=l.kernedWidth,u=l.width;this.charSpacing!==0&&(c=this._getWidthOfCharSpacing(),u+=c,h+=c);const d={width:u,left:0,height:o.fontSize,kernedWidth:h,deltaY:o.deltaY};if(i>0&&!s){const p=this.__charBounds[e][i-1];d.left=p.left+p.width+l.kernedWidth-l.width}return d}getHeightOfLine(t){if(this.__lineHeights[t])return this.__lineHeights[t];let e=this.getHeightOfChar(t,0);for(let i=1,r=this._textLines[t].length;i<r;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,r=this._textLines.length;i<r;i++)t=this.getHeightOfLine(i),e+=i===r-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 r=this._getLeftOffset(),s=this._getTopOffset();for(let o=0,a=this._textLines.length;o<a;o++){const l=this.getHeightOfLine(o),c=l/this.lineHeight,h=this._getLineLeftOffset(o);this._renderTextLine(e,t,this._textLines[o],r+h,s+i+c,o),i+=l}t.restore()}_renderTextFill(t){(this.fill||this.styleHas(It))&&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,r,s,o){const a=this.getHeightOfLine(o),l=this.textAlign.includes(Le),c=this.path,h=!l&&this.charSpacing===0&&this.isEmptyStyles(o)&&!c,u=this.direction==="ltr",d=this.direction==="ltr"?1:-1,p=e.direction;let f,g,m,v,y,x="",T=0;if(e.save(),p!==this.direction&&(e.canvas.setAttribute("dir",u?"ltr":"rtl"),e.direction=u?"ltr":"rtl",e.textAlign=u?it:xt),s-=a*this._fontSizeFraction/this.lineHeight,h)return this._renderChar(t,e,o,0,i.join(""),r,s),void e.restore();for(let E=0,A=i.length-1;E<=A;E++)v=E===A||this.charSpacing||c,x+=i[E],m=this.__charBounds[o][E],T===0?(r+=d*(m.kernedWidth-m.width),T+=m.width):T+=m.kernedWidth,l&&!v&&this._reSpaceAndTab.test(i[E])&&(v=!0),v||(f=f||this.getCompleteStyleDeclaration(o,E),g=this.getCompleteStyleDeclaration(o,E+1),v=ga(f,g,!1)),v&&(c?(e.save(),e.translate(m.renderLeft,m.renderTop),e.rotate(m.angle),this._renderChar(t,e,o,E,x,-T/2,0),e.restore()):(y=r,this._renderChar(t,e,o,E,x,y,s)),x="",f=g,r+=d*T,T=0);e.restore()}_applyPatternGradientTransformText(t){const e=this.width+this.strokeWidth,i=this.height+this.strokeWidth,r=Ne({width:e,height:i}),s=r.getContext("2d");return r.width=e,r.height=i,s.beginPath(),s.moveTo(0,0),s.lineTo(e,0),s.lineTo(e,i),s.lineTo(0,i),s.closePath(),s.translate(e/2,i/2),s.fillStyle=t.toLive(s),this._applyPatternGradientTransform(s,t),s.fill(),s.createPattern(r,"no-repeat")}handleFiller(t,e,i){let r,s;return _e(i)?i.gradientUnits==="percentage"||i.gradientTransform||i.patternTransform?(r=-this.width/2,s=-this.height/2,t.translate(r,s),t[e]=this._applyPatternGradientTransformText(i),{offsetX:r,offsetY:s}):(t[e]=i.toLive(t),this._applyPatternGradientTransform(t,i)):(t[e]=i,{offsetX:0,offsetY:0})}_setStrokeStyles(t,e){let{stroke:i,strokeWidth:r}=e;return t.lineWidth=r,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,r,s,o,a){const l=this._getStyleDeclaration(i,r),c=this.getCompleteStyleDeclaration(i,r),h=t==="fillText"&&c.fill,u=t==="strokeText"&&c.stroke&&c.strokeWidth;if(u||h){if(e.save(),e.font=this._getFontDeclaration(c),l.textBackgroundColor&&this._removeShadow(e),l.deltaY&&(a+=l.deltaY),h){const d=this._setFillStyles(e,c);e.fillText(s,o-d.offsetX,a-d.offsetY)}if(u){const d=this._setStrokeStyles(e,c);e.strokeText(s,o-d.offsetX,a-d.offsetY)}e.restore()}}setSuperscript(t,e){this._setScript(t,e,this.superscript)}setSubscript(t,e){this._setScript(t,e,this.subscript)}_setScript(t,e,i){const r=this.get2DCursorLocation(t,!0),s=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"fontSize"),o=this.getValueOfPropertyAt(r.lineIndex,r.charIndex,"deltaY"),a={fontSize:s*i.size,deltaY:o+s*i.baseline};this.setSelectionStyles(a,t,e)}_getLineLeftOffset(t){const e=this.getLineWidth(t),i=this.width-e,r=this.textAlign,s=this.direction,o=this.isEndOfWrapping(t);let a=0;return r===Le||r===$r&&!o||r===Hr&&!o||r===wn&&!o?0:(r===K&&(a=i/2),r===xt&&(a=i),r===$r&&(a=i/2),r===Hr&&(a=i),s==="rtl"&&(r===xt||r===Le||r===Hr?a=0:r===it||r===wn?a=-i:r!==K&&r!==$r||(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 r;return(r=this._getStyleDeclaration(t,e)[i])!==null&&r!==void 0?r:this[i]}_renderTextDecoration(t,e){if(!this[e]&&!this.styleHas(e))return;let i=this._getTopOffset();const r=this._getLeftOffset(),s=this.path,o=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 u=this._textLines[l],d=h/this.lineHeight,p=this._getLineLeftOffset(l);let f,g,m=0,v=0,y=this.getValueOfPropertyAt(l,0,e),x=this.getValueOfPropertyAt(l,0,It);const T=i+d*(1-this._fontSizeFraction);let E=this.getHeightOfChar(l,0),A=this.getValueOfPropertyAt(l,0,"deltaY");for(let S=0,F=u.length;S<F;S++){const j=this.__charBounds[l][S];f=this.getValueOfPropertyAt(l,S,e),g=this.getValueOfPropertyAt(l,S,It);const D=this.getHeightOfChar(l,S),k=this.getValueOfPropertyAt(l,S,"deltaY");if(s&&f&&g)t.save(),t.fillStyle=x,t.translate(j.renderLeft,j.renderTop),t.rotate(j.angle),t.fillRect(-j.kernedWidth/2,a*D+k,j.kernedWidth,this.fontSize/15),t.restore();else if((f!==y||g!==x||D!==E||k!==A)&&v>0){let P=r+p+m;this.direction==="rtl"&&(P=this.width-P-v),y&&x&&(t.fillStyle=x,t.fillRect(P,T+a*E+A,v,this.fontSize/15)),m=j.left,v=j.width,y=f,x=g,E=D,A=k}else v+=j.kernedWidth}let C=r+p+m;this.direction==="rtl"&&(C=this.width-C-v),t.fillStyle=g,f&&g&&t.fillRect(C,T+a*E+A,v-o,this.fontSize/15),i+=h}this._removeShadow(t)}_getFontDeclaration(){let{fontFamily:t=this.fontFamily,fontStyle:e=this.fontStyle,fontWeight:i=this.fontWeight,fontSize:r=this.fontSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;const o=t.includes("'")||t.includes('"')||t.includes(",")||Zt.genericFonts.includes(t.toLowerCase())?t:'"'.concat(t,'"');return[e,i,"".concat(s?this.CACHE_FONT_SIZE:r,"px"),o].join(" ")}render(t){this.visible&&(this.canvas&&this.canvas.skipOffscreen&&!this.group&&!this.isOnScreen()||(this._forceClearCache&&this.initDimensions(),super.render(t)))}graphemeSplit(t){return fa(t)}_splitTextIntoLines(t){const e=t.split(this._reNewline),i=new Array(e.length),r=[`
|
|
142
|
+
`];let s=[];for(let o=0;o<e.length;o++)i[o]=this.graphemeSplit(e[o]),s=s.concat(i[o],r);return s.pop(),{_unwrappedLines:i,lines:e,graphemeText:s,graphemeLines:i}}toObject(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return _(_({},super.toObject([...th,...t])),{},{styles:Cd(this.styles,this.text)},this.path?{path:this.path.toObject()}:{})}set(t,e){const{textLayoutProperties:i}=this.constructor;super.set(t,e);let r=!1,s=!1;if(typeof t=="object")for(const o in t)o==="path"&&this.setPathInfo(),r=r||i.includes(o),s=s||o==="path";else r=i.includes(t),s=t==="path";return s&&this.setPathInfo(),r&&this.initialized&&(this.initDimensions(),this.setCoords()),this}complexity(){return 1}static async fromElement(t,e,i){const r=di(t,Zt.ATTRIBUTE_NAMES,i),s=_(_({},e),r),{textAnchor:o=it,textDecoration:a="",dx:l=0,dy:c=0,top:h=0,left:u=0,fontSize:d=ea,strokeWidth:p=1}=s,f=ht(s,jp),g=new this((t.textContent||"").replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," "),_({left:u+l,top:h+c,underline:a.includes("underline"),overline:a.includes("overline"),linethrough:a.includes("line-through"),strokeWidth:0,fontSize:d},f)),m=g.getScaledHeight()/g.height,v=((g.height+g.strokeWidth)*g.lineHeight-g.height)*m,y=g.getScaledHeight()+v;let x=0;return o===K&&(x=g.getScaledWidth()/2),o===xt&&(x=g.getScaledWidth()),g.set({left:g.left-x,top:g.top-(y-g.fontSize*(.07+g._fontSizeFraction))/g.lineHeight,strokeWidth:p}),g}static fromObject(t){return this._fromObject(_(_({},t),{},{styles:Sd(t.styles||{},t.text)}),{extraParam:"text"})}}b(Zt,"textLayoutProperties",Qc),b(Zt,"cacheProperties",[...ui,...th]),b(Zt,"ownDefaults",Ip),b(Zt,"type","Text"),b(Zt,"genericFonts",["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]),b(Zt,"ATTRIBUTE_NAMES",Di.concat("x","y","dx","dy","font-family","font-style","font-weight","font-size","letter-spacing","text-decoration","text-anchor")),Ic(Zt,[class extends Sc{_toSVG(){const n=this._getSVGLeftTopOffsets(),t=this._getSVGTextAndBg(n.textTop,n.textLeft);return this._wrapSVGTextAndBg(t)}toSVG(n){return this._createBaseSVGMarkup(this._toSVG(),{reviver:n,noStyle:!0,withShadow:!0})}_getSVGLeftTopOffsets(){return{textLeft:-this.width/2,textTop:-this.height/2,lineTop:this.getHeightOfLine(0)}}_wrapSVGTextAndBg(n){let{textBgRects:t,textSpans:e}=n;const i=this.getSvgTextDecoration(this);return[t.join(""),' <text xml:space="preserve" ',this.fontFamily?'font-family="'.concat(this.fontFamily.replace(Fp,"'"),'" '):"",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>
|
|
143
|
+
`]}_getSVGTextAndBg(n,t){const e=[],i=[];let r,s=n;this.backgroundColor&&i.push(...no(this.backgroundColor,-this.width/2,-this.height/2,this.width,this.height));for(let o=0,a=this._textLines.length;o<a;o++)r=this._getLineLeftOffset(o),this.direction==="rtl"&&(r+=this.width),(this.textBackgroundColor||this.styleHas("textBackgroundColor",o))&&this._setSVGTextLineBg(i,o,t+r,s),this._setSVGTextLineText(e,o,t+r,s),s+=this.getHeightOfLine(o);return{textSpans:e,textBgRects:i}}_createTextCharSpan(n,t,e,i){const r=this.getSvgSpanStyles(t,n!==n.trim()||!!n.match(Lp)),s=r?'style="'.concat(r,'"'):"",o=t.deltaY,a=o?' dy="'.concat(ft(o,Q.NUM_FRACTION_DIGITS),'" '):"";return'<tspan x="'.concat(ft(e,Q.NUM_FRACTION_DIGITS),'" y="').concat(ft(i,Q.NUM_FRACTION_DIGITS),'" ').concat(a).concat(s,">").concat(xd(n),"</tspan>")}_setSVGTextLineText(n,t,e,i){const r=this.getHeightOfLine(t),s=this.textAlign.includes(Le),o=this._textLines[t];let a,l,c,h,u,d="",p=0;i+=r*(1-this._fontSizeFraction)/this.lineHeight;for(let f=0,g=o.length-1;f<=g;f++)u=f===g||this.charSpacing,d+=o[f],c=this.__charBounds[t][f],p===0?(e+=c.kernedWidth-c.width,p+=c.width):p+=c.kernedWidth,s&&!u&&this._reSpaceAndTab.test(o[f])&&(u=!0),u||(a=a||this.getCompleteStyleDeclaration(t,f),l=this.getCompleteStyleDeclaration(t,f+1),u=ga(a,l,!0)),u&&(h=this._getStyleDeclaration(t,f),n.push(this._createTextCharSpan(d,h,e,i)),d="",a=l,this.direction==="rtl"?e-=p:e+=p,p=0)}_setSVGTextLineBg(n,t,e,i){const r=this._textLines[t],s=this.getHeightOfLine(t)/this.lineHeight;let o,a=0,l=0,c=this.getValueOfPropertyAt(t,0,"textBackgroundColor");for(let h=0;h<r.length;h++){const{left:u,width:d,kernedWidth:p}=this.__charBounds[t][h];o=this.getValueOfPropertyAt(t,h,"textBackgroundColor"),o!==c?(c&&n.push(...no(c,e+l,i,a,s)),l=u,a=d,c=o):a+=p}o&&n.push(...no(c,e+l,i,a,s))}_getSVGLineTopOffset(n){let t,e=0;for(t=0;t<n;t++)e+=this.getHeightOfLine(t);const i=this.getHeightOfLine(t);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}}getSvgStyles(n){return"".concat(super.getSvgStyles(n)," white-space: pre;")}getSvgSpanStyles(n,t){const{fontFamily:e,strokeWidth:i,stroke:r,fill:s,fontSize:o,fontStyle:a,fontWeight:l,deltaY:c}=n,h=this.getSvgTextDecoration(n);return[r?Kr(ae,r):"",i?"stroke-width: ".concat(i,"; "):"",e?"font-family: ".concat(e.includes("'")||e.includes('"')?e:"'".concat(e,"'"),"; "):"",o?"font-size: ".concat(o,"px; "):"",a?"font-style: ".concat(a,"; "):"",l?"font-weight: ".concat(l,"; "):"",h&&"text-decoration: ".concat(h,"; "),s?Kr(It,s):"",c?"baseline-shift: ".concat(-c,"; "):"",t?"white-space: pre; ":""].join("")}getSvgTextDecoration(n){return["overline","underline","line-through"].filter(t=>n[t.replace("-","")]).join(" ")}}]),R.setClass(Zt),R.setSVGClass(Zt);class Rp{constructor(t){b(this,"target",void 0),b(this,"__mouseDownInPlace",!1),b(this,"__dragStartFired",!1),b(this,"__isDraggingOver",!1),b(this,"__dragStartSelection",void 0),b(this,"__dragImageDisposer",void 0),b(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:r,selectionEnd:s}=e;const o=this.target,a=o.canvas,l=new w(o.flipX?-1:1,o.flipY?-1:1),c=o._getCursorBoundaries(r),h=new w(c.left+c.leftOffset,c.top+c.topOffset).multiply(l).transform(o.calcTransformMatrix()),u=a.getScenePoint(t).subtract(h),d=o.getCanvasRetinaScaling(),p=o.getBoundingRect(),f=h.subtract(new w(p.left,p.top)),g=a.viewportTransform,m=f.add(u).transform(g,!0),v=o.backgroundColor,y=pa(o.styles);o.backgroundColor="";const x={stroke:"transparent",fill:"transparent",textBackgroundColor:"transparent"};o.setSelectionStyles(x,0,r),o.setSelectionStyles(x,s,o.text.length),o.dirty=!0;const T=o.toCanvasElement({enableRetinaScaling:a.enableRetinaScaling,viewportTransform:!0});o.backgroundColor=v,o.styles=y,o.dirty=!0,Mo(T,{position:"fixed",left:"".concat(-T.width,"px"),border:oe,width:"".concat(T.width/d,"px"),height:"".concat(T.height/d,"px")}),this.__dragImageDisposer&&this.__dragImageDisposer(),this.__dragImageDisposer=()=>{T.remove()},Oe(t.target||this.target.hiddenTextarea).body.appendChild(T),(i=t.dataTransfer)===null||i===void 0||i.setDragImage(T,m.x,m.y)}onDragStart(t){this.__dragStartFired=!0;const e=this.target,i=this.isActive();if(i&&t.dataTransfer){const r=this.__dragStartSelection={selectionStart:e.selectionStart,selectionEnd:e.selectionEnd},s=e._text.slice(r.selectionStart,r.selectionEnd).join(""),o=_({text:e.text,value:s},r);t.dataTransfer.setData("text/plain",s),t.dataTransfer.setData("application/fabric",JSON.stringify({value:s,styles:e.getSelectionStyles(r.selectionStart,r.selectionEnd,!0)})),t.dataTransfer.effectAllowed="copyMove",this.setDragImage(t,o)}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,r=i.defaultPrevented;this.__isDraggingOver=!1,i.preventDefault();let s=(e=i.dataTransfer)===null||e===void 0?void 0:e.getData("text/plain");if(s&&!r){const o=this.target,a=o.canvas;let l=o.getSelectionStartFromPointer(i);const{styles:c}=i.dataTransfer.types.includes("application/fabric")?JSON.parse(i.dataTransfer.getData("application/fabric")):{},h=s[Math.max(0,s.length-1)],u=0;if(this.__dragStartSelection){const d=this.__dragStartSelection.selectionStart,p=this.__dragStartSelection.selectionEnd;l>d&&l<=p?l=d:l>p&&(l-=p-d),o.removeChars(d,p),delete this.__dragStartSelection}o._reNewline.test(h)&&(o._reNewline.test(o._text[l])||l===o._text.length)&&(s=s.trimEnd()),t.didDrop=!0,t.dropTarget=o,o.insertChars(s,c,l),a.setActiveObject(o),o.enterEditing(i),o.selectionStart=Math.min(l+u,o._text.length),o.selectionEnd=Math.min(o.selectionStart+s.length,o._text.length),o.hiddenTextarea.value=o.text,o._updateTextarea(),o.hiddenTextarea.focus(),o.fire(dn,{index:l+u,action:"drop"}),a.fire("text:changed",{target:o}),a.contextTopDirty=!0,a.requestRenderAll()}}dragEndHandler(t){let{e}=t;if(this.isActive()&&this.__dragStartFired&&this.__dragStartSelection){var i;const r=this.target,s=this.target.canvas,{selectionStart:o,selectionEnd:a}=this.__dragStartSelection,l=((i=e.dataTransfer)===null||i===void 0?void 0:i.dropEffect)||oe;l===oe?(r.selectionStart=o,r.selectionEnd=a,r._updateTextarea(),r.hiddenTextarea.focus()):(r.clearContextTop(),l==="move"&&(r.removeChars(o,a),r.selectionStart=r.selectionEnd=o,r.hiddenTextarea&&(r.hiddenTextarea.value=r.text),r._updateTextarea(),r.fire(dn,{index:o,action:"dragend"}),s.fire("text:changed",{target:r}),s.requestRenderAll()),r.exitEditing())}this.__dragImageDisposer&&this.__dragImageDisposer(),delete this.__dragImageDisposer,delete this.__dragStartSelection,this.__isDraggingOver=!1}dispose(){this._dispose&&this._dispose()}}const ml=/[ \n\.,;!\?\-]/;class Bp extends Zt{constructor(){super(...arguments),b(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:r,onComplete:s}=t;return kc({startValue:this._currentCursorOpacity,endValue:e,duration:i,delay:r,onComplete:s,abort:()=>!this.canvas||this.selectionStart!==this.selectionEnd,onChange:o=>{this._currentCursorOpacity=o,this.renderCursorOrSelection()}})}_tick(t){this._currentTickState=this._animateCursor({toValue:0,duration:this.cursorDuration/2,delay:Math.max(t||0,100),onComplete:this._onTickComplete})}_onTickComplete(){var t;(t=this._currentTickCompleteState)===null||t===void 0||t.abort(),this._currentTickCompleteState=this._animateCursor({toValue:1,duration:this.cursorDuration,onComplete:this._tick})}initDelayedCursor(t){this.abortCursorAnimation(),this._tick(t?0:this.cursorDelay)}abortCursorAnimation(){let t=!1;[this._currentTickState,this._currentTickCompleteState].forEach(e=>{e&&!e.isDone()&&(t=!0,e.abort())}),this._currentCursorOpacity=1,t&&this.clearContextTop()}restartCursorIfNeeded(){[this._currentTickState,this._currentTickCompleteState].some(t=>!t||t.isDone())&&this.initDelayedCursor()}selectAll(){return this.selectionStart=0,this.selectionEnd=this._text.length,this._fireSelectionChanged(),this._updateTextarea(),this}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 r=t>0&&this._reSpace.test(i[t])&&(e===-1||!ia.test(i[t-1]))?t-1:t,s=i[r];for(;r>0&&r<i.length&&!ml.test(s);)r+=e,s=i[r];return e===-1&&ml.test(s)&&r++,r}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;Oe(e).activeElement!==e&&e.focus();const i=this.getSelectionStartFromPointer(t),r=this.selectionStart,s=this.selectionEnd;(i===this.__selectionStartOnMouseDown&&r!==s||r!==i&&s!==i)&&(i>this.__selectionStartOnMouseDown?(this.selectionStart=this.__selectionStartOnMouseDown,this.selectionEnd=i):(this.selectionStart=i,this.selectionEnd=this.__selectionStartOnMouseDown),this.selectionStart===r&&this.selectionEnd===s||(this._fireSelectionChanged(),this._updateTextarea(),this.renderCursorOrSelection()))}_setEditingProps(){this.hoverCursor="text",this.canvas&&(this.canvas.defaultCursor=this.canvas.moveCursor="text"),this.borderColor=this.editingBorderColor,this.hasControls=this.selectable=!1,this.lockMovementX=this.lockMovementY=!0}fromStringToGraphemeSelection(t,e,i){const r=i.slice(0,t),s=this.graphemeSplit(r).length;if(t===e)return{selectionStart:s,selectionEnd:s};const o=i.slice(t,e);return{selectionStart:s,selectionEnd:s+this.graphemeSplit(o).length}}fromGraphemeToStringSelection(t,e,i){const r=i.slice(0,t).join("").length;return t===e?{selectionStart:r,selectionEnd:r}:{selectionStart:r,selectionEnd:r+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),r=i.lineIndex,s=i.charIndex,o=this.getValueOfPropertyAt(r,s,"fontSize")*this.lineHeight,a=e.leftOffset,l=this.getCanvasRetinaScaling(),c=this.canvas.upperCanvasEl,h=c.width/l,u=c.height/l,d=h-o,p=u-o,f=new w(e.left+a,e.top+e.topOffset+o).transform(this.calcTransformMatrix()).transform(this.canvas.viewportTransform).multiply(new w(c.clientWidth/h,c.clientHeight/u));return f.x<0&&(f.x=0),f.x>d&&(f.x=d),f.y<0&&(f.y=0),f.y>p&&(f.y=p),f.x+=this.canvas._offset.left,f.y+=this.canvas._offset.top,{left:"".concat(f.x,"px"),top:"".concat(f.y,"px"),fontSize:"".concat(o,"px"),charHeight:o}}_saveEditingProps(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,selectable:this.selectable,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}}_restoreEditingProps(){this._savedProps&&(this.hoverCursor=this._savedProps.hoverCursor,this.hasControls=this._savedProps.hasControls,this.borderColor=this._savedProps.borderColor,this.selectable=this._savedProps.selectable,this.lockMovementX=this._savedProps.lockMovementX,this.lockMovementY=this._savedProps.lockMovementY,this.canvas&&(this.canvas.defaultCursor=this._savedProps.defaultCursor||this.canvas.defaultCursor,this.canvas.moveCursor=this._savedProps.moveCursor||this.canvas.moveCursor),delete this._savedProps)}_exitEditing(){const t=this.hiddenTextarea;this.selected=!1,this.isEditing=!1,t&&(t.blur&&t.blur(),t.parentNode&&t.parentNode.removeChild(t)),this.hiddenTextarea=null,this.abortCursorAnimation(),this.selectionStart!==this.selectionEnd&&this.clearContextTop()}exitEditingImpl(){this._exitEditing(),this.selectionEnd=this.selectionStart,this._restoreEditingProps(),this._forceClearCache&&(this.initDimensions(),this.setCoords())}exitEditing(){const t=this._textBeforeEdit!==this.text;return this.exitEditingImpl(),this.fire("editing:exited"),t&&this.fire(pn),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:r}=this.get2DCursorLocation(t,!0),{lineIndex:s,charIndex:o}=this.get2DCursorLocation(e,!0);if(i!==s){if(this.styles[i])for(let a=r;a<this._unwrappedTextLines[i].length;a++)delete this.styles[i][a];if(this.styles[s])for(let a=o;a<this._unwrappedTextLines[s].length;a++){const l=this.styles[s][a];l&&(this.styles[i]||(this.styles[i]={}),this.styles[i][r+a-o]=l)}for(let a=i+1;a<=s;a++)delete this.styles[a];this.shiftLineStyles(s,i-s)}else if(this.styles[i]){const a=this.styles[i],l=o-r;for(let c=r;c<o;c++)delete a[c];for(const c in this.styles[i]){const h=parseInt(c,10);h>=o&&(a[h-l]=a[c],delete a[c])}}}shiftLineStyles(t,e){const i=Object.assign({},this.styles);for(const r in this.styles){const s=parseInt(r,10);s>t&&(this.styles[s+e]=i[s],i[s-e]||delete this.styles[s])}}insertNewlineStyleObject(t,e,i,r){const s={},o=this._unwrappedTextLines[t].length,a=o===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 u in this.styles[t]){const d=parseInt(u,10);d>=e&&(l=!0,s[d-e]=this.styles[t][u],a&&e===0||delete this.styles[t][u])}let h=!1;for(l&&!a&&(this.styles[t+i]=s,h=!0),(h||o>e)&&i--;i>0;)r&&r[i-1]?this.styles[t+i]={0:_({},r[i-1])}:c?this.styles[t+i]={0:_({},c)}:delete this.styles[t+i],i--;this._forceClearCache=!0}insertCharStyleObject(t,e,i,r){this.styles||(this.styles={});const s=this.styles[t],o=s?_({},s):{};i||(i=1);for(const l in o){const c=parseInt(l,10);c>=e&&(s[c+i]=o[c],o[c-i]||delete s[c])}if(this._forceClearCache=!0,r){for(;i--;)Object.keys(r[i]).length&&(this.styles[t]||(this.styles[t]={}),this.styles[t][e+i]=_({},r[i]));return}if(!s)return;const a=s[e?e-1:1];for(;a&&i--;)this.styles[t][e+i]=_({},a)}insertNewStyleBlock(t,e,i){const r=this.get2DCursorLocation(e,!0),s=[0];let o,a=0;for(let l=0;l<t.length;l++)t[l]===`
|
|
144
|
+
`?(a++,s[a]=0):s[a]++;for(s[0]>0&&(this.insertCharStyleObject(r.lineIndex,r.charIndex,s[0],i),i=i&&i.slice(s[0]+1)),a&&this.insertNewlineStyleObject(r.lineIndex,r.charIndex+s[0],a),o=1;o<a;o++)s[o]>0?this.insertCharStyleObject(r.lineIndex+o,0,s[o],i):i&&this.styles[r.lineIndex+o]&&i[0]&&(this.styles[r.lineIndex+o][0]=i[0]),i=i&&i.slice(s[o]+1);s[o]>0&&this.insertCharStyleObject(r.lineIndex+o,0,s[o],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 r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:i;r>i&&this.removeStyleFromTo(i,r);const s=this.graphemeSplit(t);this.insertNewStyleBlock(s,i,e),this._text=[...this._text.slice(0,i),...s,...this._text.slice(r)],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=it:this._selectionDirection===xt&&(this._selectionDirection=it,this.selectionEnd=t),this.selectionStart=i):i>t&&i<e?this._selectionDirection===xt?this.selectionEnd=i:this.selectionStart=i:(e===t?this._selectionDirection=xt:this._selectionDirection===it&&(this._selectionDirection=xt,this.selectionStart=e),this.selectionEnd=i)}}class Np extends Bp{initHiddenTextarea(){const t=this.canvas&&Oe(this.canvas.getElement())||vr(),e=t.createElement("textarea");Object.entries({autocapitalize:"off",autocorrect:"off",autocomplete:"off",spellcheck:"false","data-fabric":"textarea",wrap:"off"}).map(o=>{let[a,l]=o;return e.setAttribute(a,l)});const{top:i,left:r,fontSize:s}=this._calcTextareaPosition();e.style.cssText="position: absolute; top: ".concat(i,"; left: ").concat(r,"; z-index: -999; opacity: 0; width: 1px; height: 1px; font-size: 1px; padding-top: ").concat(s,";"),(this.hiddenTextareaContainer||t.body).appendChild(e),Object.entries({blur:"blur",keydown:"onKeyDown",keyup:"onKeyUp",input:"onInput",copy:"copy",cut:"copy",paste:"paste",compositionstart:"onCompositionStart",compositionupdate:"onCompositionUpdate",compositionend:"onCompositionEnd"}).map(o=>{let[a,l]=o;return e.addEventListener(a,this[l].bind(this))}),this.hiddenTextarea=e}blur(){this.abortCursorAnimation()}onKeyDown(t){if(!this.isEditing)return;const e=this.direction==="rtl"?this.keysMapRtl:this.keysMap;if(t.keyCode in e)this[e[t.keyCode]](t);else{if(!(t.keyCode in this.ctrlKeysMapDown)||!t.ctrlKey&&!t.metaKey)return;this[this.ctrlKeysMapDown[t.keyCode]](t)}t.stopImmediatePropagation(),t.preventDefault(),t.keyCode>=33&&t.keyCode<=40?(this.inCompositionMode=!1,this.clearContextTop(),this.renderCursorOrSelection()):this.canvas&&this.canvas.requestRenderAll()}onKeyUp(t){!this.isEditing||this._copyDone||this.inCompositionMode?this._copyDone=!1:t.keyCode in this.ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)&&(this[this.ctrlKeysMapUp[t.keyCode]](t),t.stopImmediatePropagation(),t.preventDefault(),this.canvas&&this.canvas.requestRenderAll())}onInput(t){const e=this.fromPaste;if(this.fromPaste=!1,t&&t.stopPropagation(),!this.isEditing)return;const i=()=>{this.updateFromTextArea(),this.fire(dn),this.canvas&&(this.canvas.fire("text:changed",{target:this}),this.canvas.requestRenderAll())};if(this.hiddenTextarea.value==="")return this.styles={},void i();const r=this._splitTextIntoLines(this.hiddenTextarea.value).graphemeText,s=this._text.length,o=r.length,a=this.selectionStart,l=this.selectionEnd,c=a!==l;let h,u,d,p,f=o-s;const g=this.fromStringToGraphemeSelection(this.hiddenTextarea.selectionStart,this.hiddenTextarea.selectionEnd,this.hiddenTextarea.value),m=a>g.selectionStart;c?(u=this._text.slice(a,l),f+=l-a):o<s&&(u=m?this._text.slice(l+f,l):this._text.slice(a,a-f));const v=r.slice(g.selectionEnd-f,g.selectionEnd);if(u&&u.length&&(v.length&&(h=this.getSelectionStyles(a,a+1,!1),h=v.map(()=>h[0])),c?(d=a,p=l):m?(d=l-u.length,p=l):(d=l,p=l+u.length),this.removeStyleFromTo(d,p)),v.length){const{copyPasteData:y}=Be();e&&v.join("")===y.copiedText&&!Q.disableStyleCopyPaste&&(h=y.copiedTextStyle),this.insertNewStyleBlock(v,a,h)}i()}onCompositionStart(){this.inCompositionMode=!0}onCompositionEnd(){this.inCompositionMode=!1}onCompositionUpdate(t){let{target:e}=t;const{selectionStart:i,selectionEnd:r}=e;this.compositionStart=i,this.compositionEnd=r,this.updateTextareaPosition()}copy(){if(this.selectionStart===this.selectionEnd)return;const{copyPasteData:t}=Be();t.copiedText=this.getSelectedText(),Q.disableStyleCopyPaste?t.copiedTextStyle=void 0:t.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd,!0),this._copyDone=!0}paste(){this.fromPaste=!0}_getWidthBeforeCursor(t,e){let i,r=this._getLineLeftOffset(t);return e>0&&(i=this.__charBounds[t][e-1],r+=i.left+i.width),r}getDownCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===this._textLines.length-1||t.metaKey||t.keyCode===34)return this._text.length-i;const o=r.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s+1,a);return this._textLines[s].slice(o).length+l+1+this.missingNewlineOffset(s)}_getSelectionForOffset(t,e){return t.shiftKey&&this.selectionStart!==this.selectionEnd&&e?this.selectionEnd:this.selectionStart}getUpCursorOffset(t,e){const i=this._getSelectionForOffset(t,e),r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===0||t.metaKey||t.keyCode===33)return-i;const o=r.charIndex,a=this._getWidthBeforeCursor(s,o),l=this._getIndexOnLine(s-1,a),c=this._textLines[s].slice(0,o),h=this.missingNewlineOffset(s-1);return-this._textLines[s-1].length+l-c.length+(1-h)}_getIndexOnLine(t,e){const i=this._textLines[t];let r,s,o=this._getLineLeftOffset(t),a=0;for(let l=0,c=i.length;l<c;l++)if(r=this.__charBounds[t][l].width,o+=r,o>e){s=!0;const h=o-r,u=o,d=Math.abs(h-e);a=Math.abs(u-e)<d?l:l-1;break}return s||(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===xt);if(e.shiftKey?this.moveCursorWithShift(i):this.moveCursorWithoutShift(i),i!==0){const r=this.text.length;this.selectionStart=fr(0,this.selectionStart,r),this.selectionEnd=fr(0,this.selectionEnd,r),this.abortCursorAnimation(),this.initDelayedCursor(),this._fireSelectionChanged(),this._updateTextarea()}}moveCursorWithShift(t){const e=this._selectionDirection===it?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 r;if(t.altKey)r=this["findWordBoundary".concat(i)](this[e]);else{if(!t.metaKey&&t.keyCode!==35&&t.keyCode!==36)return this[e]+=i==="Left"?-1:1,!0;r=this["findLineBoundary".concat(i)](this[e])}return r!==void 0&&this[e]!==r&&(this[e]=r,!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=it,this.selectionEnd===this.selectionStart&&this.selectionStart!==0&&(e=this._moveLeft(t,"selectionStart")),this.selectionEnd=this.selectionStart,e}moveCursorLeftWithShift(t){return this._selectionDirection===xt&&this.selectionStart!==this.selectionEnd?this._moveLeft(t,"selectionEnd"):this.selectionStart!==0?(this._selectionDirection=it,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===it&&this.selectionStart!==this.selectionEnd?this._moveRight(t,"selectionStart"):this.selectionEnd!==this._text.length?(this._selectionDirection=xt,this._moveRight(t,"selectionEnd")):void 0}moveCursorRightWithoutShift(t){let e=!0;return this._selectionDirection=xt,this.selectionStart===this.selectionEnd?(e=this._moveRight(t,"selectionStart"),this.selectionEnd=this.selectionStart):this.selectionStart=this.selectionEnd,e}}const ao=n=>!!n.button;class zp extends Np{constructor(){super(...arguments),b(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 Rp(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),To(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&&!ao(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&&!ao(e)&&(this.selected=this===this.canvas._activeObject)}mouseUpHandler(t){let{e,transform:i}=t;const r=this.draggableTextDelegate.end(e);if(this.canvas){this.canvas.textEditingManager.unregister(this);const s=this.canvas._activeObject;if(s&&s!==this)return}!this.editable||this.group&&!this.group.interactive||i&&i.actionPerformed||ao(e)||r||(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,r=this.selectionEnd;t.shiftKey?this.setSelectionStartEndWithShift(i,r,e):(this.selectionStart=e,this.selectionEnd=e),this.isEditing&&(this._fireSelectionChanged(),this._updateTextarea())}getSelectionStartFromPointer(t){const e=this.canvas.getScenePoint(t).transform(ke(this.calcTransformMatrix())).add(new w(-this._getLeftOffset(),-this._getTopOffset()));let i=0,r=0,s=0;for(let c=0;c<this._textLines.length&&i<=e.y;c++)i+=this.getHeightOfLine(c),s=c,c>0&&(r+=this._textLines[c-1].length+this.missingNewlineOffset(c-1));let o=Math.abs(this._getLineLeftOffset(s));const a=this._textLines[s].length,l=this.__charBounds[s];for(let c=0;c<a;c++){const h=o+l[c].kernedWidth;if(e.x<=h){Math.abs(e.x-h)<=Math.abs(e.x-o)&&r++;break}o=h,r++}return Math.min(this.flipX?a-r:r,this._text.length)}}const Ps="moveCursorUp",As="moveCursorDown",Ms="moveCursorLeft",Is="moveCursorRight",Ls="exitEditing",Vp=_({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:Ls,27:Ls,33:Ps,34:As,35:Is,36:Ms,37:Ms,38:Ps,39:Is,40:As},keysMapRtl:{9:Ls,27:Ls,33:Ps,34:As,35:Ms,36:Is,37:Is,38:Ps,39:Ms,40:As},ctrlKeysMapDown:{65:"selectAll"},ctrlKeysMapUp:{67:"copy",88:"cut"}},{_selectionDirection:null,_reSpace:/\s|\r?\n/,inCompositionMode:!1});class Je extends zp{static getDefaults(){return _(_({},super.getDefaults()),Je.ownDefaults)}get type(){const t=super.type;return t==="itext"?"i-text":t}constructor(t,e){super(t,_(_({},Je.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 Jr&&this.canvas.textEditingManager.remove(this),e instanceof Jr&&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(),r=this._getTopOffset(),s=this._getCursorBoundariesOffsets(t,e);return{left:i,top:r,leftOffset:s.left,topOffset:s.top}}_getCursorBoundariesOffsets(t,e){return e?this.__getCursorBoundariesOffsets(t):this.cursorOffsetCache&&"top"in this.cursorOffsetCache?this.cursorOffsetCache:this.cursorOffsetCache=this.__getCursorBoundariesOffsets(t)}__getCursorBoundariesOffsets(t){let e=0,i=0;const{charIndex:r,lineIndex:s}=this.get2DCursorLocation(t);for(let c=0;c<s;c++)e+=this.getHeightOfLine(c);const o=this._getLineLeftOffset(s),a=this.__charBounds[s][r];a&&(i=a.left),this.charSpacing!==0&&r===this._textLines[s].length&&(i-=this._getWidthOfCharSpacing());const l={top:e,left:o+(i>0?i:0)};return this.direction==="rtl"&&(this.textAlign===xt||this.textAlign===Le||this.textAlign===Hr?l.left*=-1:this.textAlign===it||this.textAlign===wn?l.left=o-(i>0?i:0):this.textAlign!==K&&this.textAlign!==$r||(l.left=o-(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),r=i.lineIndex,s=i.charIndex>0?i.charIndex-1:0,o=this.getValueOfPropertyAt(r,s,"fontSize"),a=this.getObjectScaling().x*this.canvas.getZoom(),l=this.cursorWidth/a,c=this.getValueOfPropertyAt(r,s,"deltaY"),h=e.topOffset+(1-this._fontSizeFraction)*this.getHeightOfLine(r)/this.lineHeight-o*(1-this._fontSizeFraction);return{color:this.cursorColor||this.getValueOfPropertyAt(r,s,"fill"),opacity:this._currentCursorOpacity,left:e.left+e.leftOffset-l/2,top:h+e.top+c,width:l,height:o}}_renderCursor(t,e,i){const{color:r,opacity:s,left:o,top:a,width:l,height:c}=this.getCursorRenderingData(i,e);t.fillStyle=r,t.globalAlpha=s,t.fillRect(o,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 r=e.selectionStart,s=e.selectionEnd,o=this.textAlign.includes(Le),a=this.get2DCursorLocation(r),l=this.get2DCursorLocation(s),c=a.lineIndex,h=l.lineIndex,u=a.charIndex<0?0:a.charIndex,d=l.charIndex<0?0:l.charIndex;for(let p=c;p<=h;p++){const f=this._getLineLeftOffset(p)||0;let g=this.getHeightOfLine(p),m=0,v=0,y=0;if(p===c&&(v=this.__charBounds[c][u].left),p>=c&&p<h)y=o&&!this.isEndOfWrapping(p)?this.width:this.getLineWidth(p)||5;else if(p===h)if(d===0)y=this.__charBounds[h][d].left;else{const C=this._getWidthOfCharSpacing();y=this.__charBounds[h][d-1].left+this.__charBounds[h][d-1].width-C}m=g,(this.lineHeight<1||p===h&&this.lineHeight>1)&&(g/=this.lineHeight);let x=i.left+f+v,T=g,E=0;const A=y-v;this.inCompositionMode?(t.fillStyle=this.compositionColor||"black",T=1,E=g):t.fillStyle=this.selectionColor,this.direction==="rtl"&&(this.textAlign===xt||this.textAlign===Le||this.textAlign===Hr?x=this.width-x-A:this.textAlign===it||this.textAlign===wn?x=i.left+f-y:this.textAlign!==K&&this.textAlign!==$r||(x=i.left+f-y)),t.fillRect(x,i.top+i.topOffset+E,A,T),i.topOffset+=m}}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,It)}_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()}}b(Je,"ownDefaults",Vp),b(Je,"type","IText"),R.setClass(Je),R.setClass(Je,"i-text");class Qe extends Je{static getDefaults(){return _(_({},super.getDefaults()),Qe.ownDefaults)}constructor(t,e){super(t,_(_({},Qe.ownDefaults),e))}static createControls(){return{controls:vd()}}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,r=0;const s={};for(let o=0;o<t.graphemeLines.length;o++)t.graphemeText[r]===`
|
|
145
|
+
`&&o>0?(i=0,r++,e++):!this.splitByGrapheme&&this._reSpaceAndTab.test(t.graphemeText[r])&&o>0&&(i++,r++),s[o]={line:e,offset:i},r+=t.graphemeLines[o].length,i+=t.graphemeLines[o].length;return s}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,r=t+1,s=!1;const o=this._styleMap[t],a=this._styleMap[t+1];o&&(t=o.line,i=o.offset),a&&(r=a.line,s=r===t,e=a.offset);const l=t===void 0?this.styles:{line:this.styles[t]};for(const c in l)for(const h in l[c]){const u=parseInt(h,10);if(u>=i&&(!s||u<e))for(const d 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 r=this._styleMap[t];super._setStyleDeclaration(r.line,r.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),r=[];for(let s=0;s<i.wordsData.length;s++)r.push(...this._wrapLine(s,e,i));return this.isWrapping=!1,r}getGraphemeDataForRender(t){const e=this.splitByGrapheme,i=e?"":" ";let r=0;return{wordsData:t.map((s,o)=>{let a=0;const l=e?this.graphemeSplit(s):this.wordSplit(s);return l.length===0?[{word:[],width:0}]:l.map(c=>{const h=e?[c]:this.graphemeSplit(c),u=this._measureWord(h,o,a);return r=Math.max(u,r),a+=h.length+i.length,{word:h,width:u}})}),largestWordWidth:r}}_measureWord(t,e){let i,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=0;for(let o=0,a=t.length;o<a;o++)s+=this._getGraphemeBox(t[o],e,o+r,i,!0).kernedWidth,i=t[o];return s}wordSplit(t){return t.split(this._wordJoiners)}_wrapLine(t,e,i){let{largestWordWidth:r,wordsData:s}=i,o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0;const a=this._getWidthOfCharSpacing(),l=this.splitByGrapheme,c=[],h=l?"":" ";let u=0,d=[],p=0,f=0,g=!0;e-=o;const m=Math.max(e,r,this.dynamicMinWidth),v=s[t];let y;for(p=0,y=0;y<v.length;y++){const{word:x,width:T}=v[y];p+=x.length,u+=f+T-a,u>m&&!g?(c.push(d),d=[],u=T,g=!0):u+=a,g||l||d.push(h),d=d.concat(x),f=l?0:this._measureWord([h],t,p),p++,g=!1}return y&&c.push(d),r+o>this.dynamicMinWidth&&(this.dynamicMinWidth=r-a+o),c}isEndOfWrapping(t){return!this._styleMap[t+1]||this._styleMap[t+1].line!==this._styleMap[t].line}missingNewlineOffset(t,e){return this.splitByGrapheme&&!e?this.isEndOfWrapping(t)?1:0:1}_splitTextIntoLines(t){const e=super._splitTextIntoLines(t),i=this._wrapText(e.lines,this.width),r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=i[s].join("");return e.lines=r,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 r=this._styleMap[e].line;t.set("".concat(r),!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])}}b(Qe,"type","Textbox"),b(Qe,"textLayoutProperties",[...Je.textLayoutProperties,"width"]),b(Qe,"ownDefaults",{minWidth:20,dynamicMinWidth:2,lockScalingFlip:!0,noScaleCache:!1,_wordJoiners:/[ \t\r]/,splitByGrapheme:!1}),R.setClass(Qe);class vl extends jn{shouldPerformLayout(t){return!!t.target.clipPath&&super.shouldPerformLayout(t)}shouldLayoutClipPath(){return!1}calcLayoutResult(t,e){const{target:i}=t,{clipPath:r,group:s}=i;if(!r||!this.shouldPerformLayout(t))return;const{width:o,height:a}=ii(jc(i,r)),l=new w(o,a);if(r.absolutePositioned)return{center:hr(r.getRelativeCenterPoint(),void 0,s?s.calcTransformMatrix():void 0),size:l};{const c=r.getRelativeCenterPoint().transform(i.calcOwnMatrix(),!0);if(this.shouldPerformLayout(t)){const{center:h=new w,correction:u=new w}=this.calcBoundingBox(e,t)||{};return{center:h.add(c),correction:u.subtract(c),size:l}}return{center:i.getRelativeCenterPoint().add(c),size:l}}}}b(vl,"type","clip-path"),R.setClass(vl);class bl extends jn{getInitialSize(t,e){let{target:i}=t,{size:r}=e;return new w(i.width||r.x,i.height||r.y)}}b(bl,"type","fixed"),R.setClass(bl);class Hp extends Zr{subscribeTargets(t){const e=t.target;t.targets.reduce((i,r)=>(r.parent&&i.add(r.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((r,s)=>(s.parent&&r.add(s.parent),r),new Set).forEach(r=>{!i.some(s=>s.parent===r)&&r.layoutManager.unsubscribeTargets({target:r,targets:[e]})})}}class Vi extends _i{static getDefaults(){return _(_({},super.getDefaults()),Vi.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,Vi.ownDefaults),this.setOptions(e);const{left:i,top:r,layoutManager:s}=e;this.groupInit(t,{left:i,top:r,layoutManager:s??new Hp})}_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(r=>{const s=this._objects.findIndex(a=>a.isInFrontOf(r)),o=s===-1?this.size():s;this.insertAt(o,r)})}canEnterGroup(t){return this.getObjects().some(e=>e.isDescendantOf(t)||t.isDescendantOf(e))?(yi("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(r=>{const{parent:s}=r;s&&i.add(s)}),t===va?i.forEach(r=>{r._onAfterObjectsChange(_n,e)}):i.forEach(r=>{r._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 r=_(_({hasControls:!1},i),{},{forActiveSelection:!0});for(let s=0;s<this._objects.length;s++)this._objects[s]._renderControls(t,r);super._renderControls(t,e),t.restore()}}b(Vi,"type","ActiveSelection"),b(Vi,"ownDefaults",{multiSelectionStacking:"canvas-stacking"}),R.setClass(Vi),R.setClass(Vi,"activeSelection");class $p{constructor(){b(this,"resources",{})}applyFilters(t,e,i,r,s){const o=s.getContext("2d");if(!o)return;o.drawImage(e,0,0,i,r);const a={sourceWidth:i,sourceHeight:r,imageData:o.getImageData(0,0,i,r),originalEl:e,originalImageData:o.getImageData(0,0,i,r),canvasEl:s,ctx:o,filterBackend:this};t.forEach(c=>{c.applyTo(a)});const{imageData:l}=a;return l.width===i&&l.height===r||(s.width=l.width,s.height=l.height),o.putImageData(l,0,0),a}}class ih{constructor(){let{tileSize:t=Q.textureSize}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};b(this,"aPosition",new Float32Array([0,0,0,1,1,0,1,1])),b(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=Ne({width:t,height:e}),r=i.getContext("webgl",{alpha:!0,premultipliedAlpha:!1,depth:!1,stencil:!1,antialias:!1});r&&(r.clearColor(0,0,0,0),this.canvas=i,this.gl=r)}applyFilters(t,e,i,r,s,o){const a=this.gl,l=s.getContext("2d");if(!a||!l)return;let c;o&&(c=this.getCachedTexture(o,e));const h={originalWidth:e.width||e.naturalWidth||0,originalHeight:e.height||e.naturalHeight||0,sourceWidth:i,sourceHeight:r,destinationWidth:i,destinationHeight:r,context:a,sourceTexture:this.createTexture(a,i,r,c?void 0:e),targetTexture:this.createTexture(a,i,r),originalTexture:c||this.createTexture(a,i,r,c?void 0:e),passes:t.length,webgl:!0,aPosition:this.aPosition,programCache:this.programCache,pass:0,filterBackend:this,targetCanvas:s},u=a.createFramebuffer();return a.bindFramebuffer(a.FRAMEBUFFER,u),t.forEach(d=>{d&&d.applyTo(h)}),function(d){const p=d.targetCanvas,f=p.width,g=p.height,m=d.destinationWidth,v=d.destinationHeight;f===m&&g===v||(p.width=m,p.height=v)}(h),this.copyGLTo2D(a,h),a.bindTexture(a.TEXTURE_2D,null),a.deleteTexture(h.sourceTexture),a.deleteTexture(h.targetTexture),a.deleteFramebuffer(u),l.setTransform(1,0,0,1,0,0),h}dispose(){this.canvas&&(this.canvas=null,this.gl=null),this.clearWebGLCaches()}clearWebGLCaches(){this.programCache={},this.textureCache={}}createTexture(t,e,i,r,s){const{NEAREST:o,TEXTURE_2D:a,RGBA:l,UNSIGNED_BYTE:c,CLAMP_TO_EDGE:h,TEXTURE_MAG_FILTER:u,TEXTURE_MIN_FILTER:d,TEXTURE_WRAP_S:p,TEXTURE_WRAP_T:f}=t,g=t.createTexture();return t.bindTexture(a,g),t.texParameteri(a,u,s||o),t.texParameteri(a,d,s||o),t.texParameteri(a,p,h),t.texParameteri(a,f,h),r?t.texImage2D(a,0,l,l,c,r):t.texImage2D(a,0,l,e,i,0,l,c,null),g}getCachedTexture(t,e,i){const{textureCache:r}=this;if(r[t])return r[t];{const s=this.createTexture(this.gl,e.width,e.height,e,i);return s&&(r[t]=s),s}}evictCachesForKey(t){this.textureCache[t]&&(this.gl.deleteTexture(this.textureCache[t]),delete this.textureCache[t])}copyGLTo2D(t,e){const i=t.canvas,r=e.targetCanvas,s=r.getContext("2d");if(!s)return;s.translate(0,r.height),s.scale(1,-1);const o=i.height-r.height;s.drawImage(i,0,o,r.width,r.height,0,0,r.width,r.height)}copyGLTo2DPutImageData(t,e){const i=e.targetCanvas.getContext("2d"),r=e.destinationWidth,s=e.destinationHeight,o=r*s*4;if(!i)return;const a=new Uint8Array(this.imageBuffer,0,o),l=new Uint8ClampedArray(this.imageBuffer,0,o);t.readPixels(0,0,r,s,t.RGBA,t.UNSIGNED_BYTE,a);const c=new ImageData(l,r,s);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 r=t.getParameter(i.UNMASKED_RENDERER_WEBGL),s=t.getParameter(i.UNMASKED_VENDOR_WEBGL);r&&(e.renderer=r.toLowerCase()),s&&(e.vendor=s.toLowerCase())}return this.gpuInfo=e,e}}let lo;function Wp(){const{WebGLProbe:n}=Be();return n.queryWebGL(Ae()),Q.enableGLFiltering&&n.isSupported(Q.textureSize)?new ih({tileSize:Q.textureSize}):new $p}function co(){return!lo&&(!(arguments.length>0&&arguments[0]!==void 0)||arguments[0])&&(lo=Wp()),lo}const Gp=["filters","resizeFilter","src","crossOrigin","type"],rh=["cropX","cropY"];class Ut extends Yt{static getDefaults(){return _(_({},super.getDefaults()),Ut.ownDefaults)}constructor(t,e){super(),b(this,"_lastScaleX",1),b(this,"_lastScaleY",1),b(this,"_filterScalingX",1),b(this,"_filterScalingY",1),this.filters=[],Object.assign(this,Ut.ownDefaults),this.setOptions(e),this.cacheKey="texture".concat(xi()),this.setElement(typeof t=="string"?(this.canvas&&Oe(this.canvas.getElement())||vr()).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(Ut.CSS_CANVAS),this.filters.length!==0&&this.applyFilters(),this.resizeFilter&&this.applyResizeFilters()}removeTexture(t){const e=co(!1);e instanceof ih&&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([...rh,...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,r=-this.height/2;let s=[],o=[],a="",l="";if(!e)return[];if(this.hasCrop()){const c=xi();s.push('<clipPath id="imageCrop_'+c+`">
|
|
146
|
+
`,' <rect x="'+i+'" y="'+r+'" width="'+this.width+'" height="'+this.height+`" />
|
|
147
|
+
`,`</clipPath>
|
|
148
|
+
`),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(r-this.cropY,'" width="').concat(e.width||e.naturalWidth,'" height="').concat(e.height||e.naturalHeight,'"').concat(l).concat(a,`></image>
|
|
149
|
+
`)),this.stroke||this.strokeDashArray){const c=this.fill;this.fill=null,o=[' <rect x="'.concat(i,'" y="').concat(r,'" width="').concat(this.width,'" height="').concat(this.height,'" style="').concat(this.getSvgStyles(),`" />
|
|
150
|
+
`)],this.fill=c}return s=this.paintFirst!==It?s.concat(o,t):s.concat(t,o),s}getSrc(t){const e=t?this._element:this._originalElement;return e?e.toDataURL?e.toDataURL():this.srcFromAttribute?e.getAttribute("src")||"":e.src:this.src||""}getSvgSrc(t){return this.getSrc(t)}setSrc(t){let{crossOrigin:e,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return sn(t,{crossOrigin:e,signal:i}).then(r=>{e!==void 0&&this.set({crossOrigin:e}),this.setElement(r)})}toString(){return'#<Image: { src: "'.concat(this.getSrc(),'" }>')}applyResizeFilters(){const t=this.resizeFilter,e=this.minimumScaleTrigger,i=this.getTotalObjectScaling(),r=i.x,s=i.y,o=this._filteredEl||this._originalElement;if(this.group&&this.set("dirty",!0),!t||r>e&&s>e)return this._element=o,this._filterScalingX=1,this._filterScalingY=1,this._lastScaleX=r,void(this._lastScaleY=s);const a=Ne(o),{width:l,height:c}=o;this._element=a,this._lastScaleX=t.scaleX=r,this._lastScaleY=t.scaleY=s,co().applyFilters([t],o,l,c,this._element),this._filterScalingX=a.width/this._originalElement.width,this._filterScalingY=a.height/this._originalElement.height}applyFilters(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.filters||[];if(t=t.filter(s=>s&&!s.isNeutralState()),this.set("dirty",!0),this.removeTexture("".concat(this.cacheKey,"_filtered")),t.length===0)return this._element=this._originalElement,this._filteredEl=void 0,this._filterScalingX=1,void(this._filterScalingY=1);const e=this._originalElement,i=e.naturalWidth||e.width,r=e.naturalHeight||e.height;if(this._element===this._originalElement){const s=Ne({width:i,height:r});this._element=s,this._filteredEl=s}else this._filteredEl&&(this._element=this._filteredEl,this._filteredEl.getContext("2d").clearRect(0,0,i,r),this._lastScaleX=1,this._lastScaleY=1);co().applyFilters(t,this._originalElement,i,r,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,r=this._filterScalingY,s=this.width,o=this.height,a=Math.max(this.cropX,0),l=Math.max(this.cropY,0),c=e.naturalWidth||e.width,h=e.naturalHeight||e.height,u=a*i,d=l*r,p=Math.min(s*i,c-u),f=Math.min(o*r,h-d),g=-s/2,m=-o/2,v=Math.min(s,c/i-a),y=Math.min(o,h/r-l);e&&t.drawImage(e,u,d,p,f,g,m,v,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=Ou(this.preserveAspectRatio||""),e=this.width,i=this.height,r={width:e,height:i};let s,o=this._element.width,a=this._element.height,l=1,c=1,h=0,u=0,d=0,p=0;return!t||t.alignX===oe&&t.alignY===oe?(l=e/o,c=i/a):(t.meetOrSlice==="meet"&&(l=c=qd(this._element,r),s=(e-o*l)/2,t.alignX==="Min"&&(h=-s),t.alignX==="Max"&&(h=s),s=(i-a*c)/2,t.alignY==="Min"&&(u=-s),t.alignY==="Max"&&(u=s)),t.meetOrSlice==="slice"&&(l=c=Zd(this._element,r),s=o-e/l,t.alignX==="Mid"&&(d=s/2),t.alignX==="Max"&&(d=s),s=a-i/c,t.alignY==="Mid"&&(p=s/2),t.alignY==="Max"&&(p=s),o=e/l,a=i/c)),{width:o,height:a,scaleX:l,scaleY:c,offsetLeft:h,offsetTop:u,cropX:d,cropY:p}}static fromObject(t,e){let{filters:i,resizeFilter:r,src:s,crossOrigin:o,type:a}=t,l=ht(t,Gp);return Promise.all([sn(s,_(_({},e),{},{crossOrigin:o})),i&&Xr(i,e),r&&Xr([r],e),Mn(l,e)]).then(c=>{let[h,u=[],[d]=[],p={}]=c;return new this(h,_(_({},l),{},{src:s,filters:u,resizeFilter:d},p))})}static fromURL(t){let{crossOrigin:e=null,signal:i}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0;return sn(t,{crossOrigin:e,signal:i}).then(s=>new this(s,r))}static async fromElement(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;const r=di(t,this.ATTRIBUTE_NAMES,i);return this.fromURL(r["xlink:href"],e,r).catch(s=>(yi("log","Unable to parse Image",s),null))}}b(Ut,"type","Image"),b(Ut,"cacheProperties",[...ui,...rh]),b(Ut,"ownDefaults",{strokeWidth:0,srcFromAttribute:!1,minimumScaleTrigger:.5,cropX:0,cropY:0,imageSmoothing:!0}),b(Ut,"CSS_CANVAS","canvas-img"),b(Ut,"ATTRIBUTE_NAMES",[...Di,"x","y","width","height","preserveAspectRatio","xlink:href","crossOrigin","image-rendering"]),R.setClass(Ut),R.setSVGClass(Ut);Ln(["pattern","defs","symbol","metadata","clipPath","mask","desc"]);const Bn=n=>n.webgl!==void 0,ba="precision highp float",Up=`
|
|
151
|
+
`.concat(ba,`;
|
|
152
|
+
varying vec2 vTexCoord;
|
|
153
|
+
uniform sampler2D uTexture;
|
|
154
|
+
void main() {
|
|
155
|
+
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
156
|
+
}`),Yp=["type"],Xp=["type"],Kp=new RegExp(ba,"g");class Lt{get type(){return this.constructor.type}constructor(){let t=ht(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},Yp);Object.assign(this,this.constructor.defaults,t)}getFragmentSource(){return Up}getVertexSource(){return`
|
|
157
|
+
attribute vec2 aPosition;
|
|
158
|
+
varying vec2 vTexCoord;
|
|
159
|
+
void main() {
|
|
160
|
+
vTexCoord = aPosition;
|
|
161
|
+
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
162
|
+
}`}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:r="highp"}}=Be();r!=="highp"&&(e=e.replace(Kp,ba.replace("highp",r)));const s=t.createShader(t.VERTEX_SHADER),o=t.createShader(t.FRAGMENT_SHADER),a=t.createProgram();if(!s||!o||!a)throw new je("Vertex, fragment shader or program creation error");if(t.shaderSource(s,i),t.compileShader(s),!t.getShaderParameter(s,t.COMPILE_STATUS))throw new je("Vertex shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(s)));if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new je("Fragment shader compile error for ".concat(this.type,": ").concat(t.getShaderInfoLog(o)));if(t.attachShader(a,s),t.attachShader(a,o),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new 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,r={};for(let s=0;s<i.length;s++)r[i[s]]=t.getUniformLocation(e,i[s]);return r}sendAttributeData(t,e,i){const r=e.aPosition,s=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,s),t.enableVertexAttribArray(r),t.vertexAttribPointer(r,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,r=t.destinationHeight;t.sourceWidth===i&&t.sourceHeight===r||(e.deleteTexture(t.targetTexture),t.targetTexture=t.filterBackend.createTexture(e,i,r)),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){Bn(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,r=Ne({width:e,height:i});t.helpLayer=r}}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(ht(t,Xp))}}b(Lt,"type","BaseFilter"),b(Lt,"uniformLocations",[]);const qp={multiply:`gl_FragColor.rgb *= uColor.rgb;
|
|
163
|
+
`,screen:`gl_FragColor.rgb = 1.0 - (1.0 - gl_FragColor.rgb) * (1.0 - uColor.rgb);
|
|
164
|
+
`,add:`gl_FragColor.rgb += uColor.rgb;
|
|
165
|
+
`,difference:`gl_FragColor.rgb = abs(gl_FragColor.rgb - uColor.rgb);
|
|
166
|
+
`,subtract:`gl_FragColor.rgb -= uColor.rgb;
|
|
167
|
+
`,lighten:`gl_FragColor.rgb = max(gl_FragColor.rgb, uColor.rgb);
|
|
168
|
+
`,darken:`gl_FragColor.rgb = min(gl_FragColor.rgb, uColor.rgb);
|
|
169
|
+
`,exclusion:`gl_FragColor.rgb += uColor.rgb - 2.0 * (uColor.rgb * gl_FragColor.rgb);
|
|
170
|
+
`,overlay:`
|
|
171
|
+
if (uColor.r < 0.5) {
|
|
172
|
+
gl_FragColor.r *= 2.0 * uColor.r;
|
|
173
|
+
} else {
|
|
174
|
+
gl_FragColor.r = 1.0 - 2.0 * (1.0 - gl_FragColor.r) * (1.0 - uColor.r);
|
|
175
|
+
}
|
|
176
|
+
if (uColor.g < 0.5) {
|
|
177
|
+
gl_FragColor.g *= 2.0 * uColor.g;
|
|
178
|
+
} else {
|
|
179
|
+
gl_FragColor.g = 1.0 - 2.0 * (1.0 - gl_FragColor.g) * (1.0 - uColor.g);
|
|
180
|
+
}
|
|
181
|
+
if (uColor.b < 0.5) {
|
|
182
|
+
gl_FragColor.b *= 2.0 * uColor.b;
|
|
183
|
+
} else {
|
|
184
|
+
gl_FragColor.b = 1.0 - 2.0 * (1.0 - gl_FragColor.b) * (1.0 - uColor.b);
|
|
185
|
+
}
|
|
186
|
+
`,tint:`
|
|
187
|
+
gl_FragColor.rgb *= (1.0 - uColor.a);
|
|
188
|
+
gl_FragColor.rgb += uColor.rgb;
|
|
189
|
+
`};class Fs extends Lt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return`
|
|
190
|
+
precision highp float;
|
|
191
|
+
uniform sampler2D uTexture;
|
|
192
|
+
uniform vec4 uColor;
|
|
193
|
+
varying vec2 vTexCoord;
|
|
194
|
+
void main() {
|
|
195
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
196
|
+
gl_FragColor = color;
|
|
197
|
+
if (color.a > 0.0) {
|
|
198
|
+
`.concat(qp[this.mode],`
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
`)}applyTo2d(t){let{imageData:{data:e}}=t;const i=new rt(this.color).getSource(),r=this.alpha,s=i[0]*r,o=i[1]*r,a=i[2]*r,l=1-r;for(let c=0;c<e.length;c+=4){const h=e[c],u=e[c+1],d=e[c+2];let p,f,g;switch(this.mode){case"multiply":p=h*s/255,f=u*o/255,g=d*a/255;break;case"screen":p=255-(255-h)*(255-s)/255,f=255-(255-u)*(255-o)/255,g=255-(255-d)*(255-a)/255;break;case"add":p=h+s,f=u+o,g=d+a;break;case"difference":p=Math.abs(h-s),f=Math.abs(u-o),g=Math.abs(d-a);break;case"subtract":p=h-s,f=u-o,g=d-a;break;case"darken":p=Math.min(h,s),f=Math.min(u,o),g=Math.min(d,a);break;case"lighten":p=Math.max(h,s),f=Math.max(u,o),g=Math.max(d,a);break;case"overlay":p=s<128?2*h*s/255:255-2*(255-h)*(255-s)/255,f=o<128?2*u*o/255:255-2*(255-u)*(255-o)/255,g=a<128?2*d*a/255:255-2*(255-d)*(255-a)/255;break;case"exclusion":p=s+h-2*s*h/255,f=o+u-2*o*u/255,g=a+d-2*a*d/255;break;case"tint":p=s+h*l,f=o+u*l,g=a+d*l}e[c]=p,e[c+1]=f,e[c+2]=g}}sendUniformData(t,e){const i=new rt(this.color).getSource();i[0]=this.alpha*i[0]/255,i[1]=this.alpha*i[1]/255,i[2]=this.alpha*i[2]/255,i[3]=this.alpha,t.uniform4fv(e.uColor,i)}}b(Fs,"defaults",{color:"#F95C63",mode:"multiply",alpha:1}),b(Fs,"type","BlendColor"),b(Fs,"uniformLocations",["uColor"]),R.setClass(Fs);const Zp={multiply:`
|
|
202
|
+
precision highp float;
|
|
203
|
+
uniform sampler2D uTexture;
|
|
204
|
+
uniform sampler2D uImage;
|
|
205
|
+
uniform vec4 uColor;
|
|
206
|
+
varying vec2 vTexCoord;
|
|
207
|
+
varying vec2 vTexCoord2;
|
|
208
|
+
void main() {
|
|
209
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
210
|
+
vec4 color2 = texture2D(uImage, vTexCoord2);
|
|
211
|
+
color.rgba *= color2.rgba;
|
|
212
|
+
gl_FragColor = color;
|
|
213
|
+
}
|
|
214
|
+
`,mask:`
|
|
215
|
+
precision highp float;
|
|
216
|
+
uniform sampler2D uTexture;
|
|
217
|
+
uniform sampler2D uImage;
|
|
218
|
+
uniform vec4 uColor;
|
|
219
|
+
varying vec2 vTexCoord;
|
|
220
|
+
varying vec2 vTexCoord2;
|
|
221
|
+
void main() {
|
|
222
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
223
|
+
vec4 color2 = texture2D(uImage, vTexCoord2);
|
|
224
|
+
color.a = color2.a;
|
|
225
|
+
gl_FragColor = color;
|
|
226
|
+
}
|
|
227
|
+
`},Jp=["type","image"];class js extends Lt{getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return Zp[this.mode]}getVertexSource(){return`
|
|
228
|
+
attribute vec2 aPosition;
|
|
229
|
+
varying vec2 vTexCoord;
|
|
230
|
+
varying vec2 vTexCoord2;
|
|
231
|
+
uniform mat3 uTransformMatrix;
|
|
232
|
+
void main() {
|
|
233
|
+
vTexCoord = aPosition;
|
|
234
|
+
vTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;
|
|
235
|
+
gl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);
|
|
236
|
+
}
|
|
237
|
+
`}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:r},filterBackend:{resources:s}}=t;const o=this.image;s.blendImage||(s.blendImage=Ae());const a=s.blendImage,l=a.getContext("2d");a.width!==i||a.height!==r?(a.width=i,a.height=r):l.clearRect(0,0,i,r),l.setTransform(o.scaleX,0,0,o.scaleY,o.left,o.top),l.drawImage(o.getElement(),0,0,i,r);const c=l.getImageData(0,0,i,r).data;for(let h=0;h<e.length;h+=4){const u=e[h],d=e[h+1],p=e[h+2],f=e[h+3],g=c[h],m=c[h+1],v=c[h+2],y=c[h+3];switch(this.mode){case"multiply":e[h]=u*g/255,e[h+1]=d*m/255,e[h+2]=p*v/255,e[h+3]=f*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:r}=t,s=ht(t,Jp);return Ut.fromObject(r,e).then(o=>new this(_(_({},s),{},{image:o})))}}b(js,"type","BlendImage"),b(js,"defaults",{mode:"multiply",alpha:1}),b(js,"uniformLocations",["uTransformMatrix","uImage"]),R.setClass(js);class Rs extends Lt{getFragmentSource(){return`
|
|
238
|
+
precision highp float;
|
|
239
|
+
uniform sampler2D uTexture;
|
|
240
|
+
uniform vec2 uDelta;
|
|
241
|
+
varying vec2 vTexCoord;
|
|
242
|
+
const float nSamples = 15.0;
|
|
243
|
+
vec3 v3offset = vec3(12.9898, 78.233, 151.7182);
|
|
244
|
+
float random(vec3 scale) {
|
|
245
|
+
/* use the fragment position for a different seed per-pixel */
|
|
246
|
+
return fract(sin(dot(gl_FragCoord.xyz, scale)) * 43758.5453);
|
|
247
|
+
}
|
|
248
|
+
void main() {
|
|
249
|
+
vec4 color = vec4(0.0);
|
|
250
|
+
float total = 0.0;
|
|
251
|
+
float offset = random(v3offset);
|
|
252
|
+
for (float t = -nSamples; t <= nSamples; t++) {
|
|
253
|
+
float percent = (t + offset - 0.5) / nSamples;
|
|
254
|
+
float weight = 1.0 - abs(percent);
|
|
255
|
+
color += texture2D(uTexture, vTexCoord + uDelta * percent) * weight;
|
|
256
|
+
total += weight;
|
|
257
|
+
}
|
|
258
|
+
gl_FragColor = color / total;
|
|
259
|
+
}
|
|
260
|
+
`}applyTo(t){Bn(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:r}}=t;const{width:s,height:o}=i;r.blurLayer1||(r.blurLayer1=Ae(),r.blurLayer2=Ae());const a=r.blurLayer1,l=r.blurLayer2;a.width===s&&a.height===o||(l.width=a.width=s,l.height=a.height=o);const c=a.getContext("2d"),h=l.getContext("2d"),u=15,d=.06*this.blur*.5;let p,f,g,m;for(c.putImageData(i,0,0),h.clearRect(0,0,s,o),m=-15;m<=u;m++)p=(Math.random()-.5)/4,f=m/u,g=d*f*s+p,h.globalAlpha=1-Math.abs(f),h.drawImage(a,g,p),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);for(m=-15;m<=u;m++)p=(Math.random()-.5)/4,f=m/u,g=d*f*o+p,h.globalAlpha=1-Math.abs(f),h.drawImage(a,p,g),c.drawImage(l,0,0),h.globalAlpha=1,h.clearRect(0,0,l.width,l.height);e.drawImage(a,0,0);const v=e.getImageData(0,0,a.width,a.height);return c.globalAlpha=1,c.clearRect(0,0,a.width,a.height),v}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}}b(Rs,"type","Blur"),b(Rs,"defaults",{blur:0}),b(Rs,"uniformLocations",["uDelta"]),R.setClass(Rs);class Bs extends Lt{getFragmentSource(){return`
|
|
261
|
+
precision highp float;
|
|
262
|
+
uniform sampler2D uTexture;
|
|
263
|
+
uniform float uBrightness;
|
|
264
|
+
varying vec2 vTexCoord;
|
|
265
|
+
void main() {
|
|
266
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
267
|
+
color.rgb += uBrightness;
|
|
268
|
+
gl_FragColor = color;
|
|
269
|
+
}
|
|
270
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.round(255*this.brightness);for(let r=0;r<e.length;r+=4)e[r]+=i,e[r+1]+=i,e[r+2]+=i}isNeutralState(){return this.brightness===0}sendUniformData(t,e){t.uniform1f(e.uBrightness,this.brightness)}}b(Bs,"type","Brightness"),b(Bs,"defaults",{brightness:0}),b(Bs,"uniformLocations",["uBrightness"]),R.setClass(Bs);const sh={matrix:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],colorsOnly:!0};class nr extends Lt{getFragmentSource(){return`
|
|
271
|
+
precision highp float;
|
|
272
|
+
uniform sampler2D uTexture;
|
|
273
|
+
varying vec2 vTexCoord;
|
|
274
|
+
uniform mat4 uColorMatrix;
|
|
275
|
+
uniform vec4 uConstants;
|
|
276
|
+
void main() {
|
|
277
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
278
|
+
color *= uColorMatrix;
|
|
279
|
+
color += uConstants;
|
|
280
|
+
gl_FragColor = color;
|
|
281
|
+
}`}applyTo2d(t){const e=t.imageData.data,i=this.matrix,r=this.colorsOnly;for(let s=0;s<e.length;s+=4){const o=e[s],a=e[s+1],l=e[s+2];if(e[s]=o*i[0]+a*i[1]+l*i[2]+255*i[4],e[s+1]=o*i[5]+a*i[6]+l*i[7]+255*i[9],e[s+2]=o*i[10]+a*i[11]+l*i[12]+255*i[14],!r){const c=e[s+3];e[s]+=c*i[3],e[s+1]+=c*i[8],e[s+2]+=c*i[13],e[s+3]=o*i[15]+a*i[16]+l*i[17]+c*i[18]+255*i[19]}}}sendUniformData(t,e){const i=this.matrix,r=[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]],s=[i[4],i[9],i[14],i[19]];t.uniformMatrix4fv(e.uColorMatrix,!1,r),t.uniform4fv(e.uConstants,s)}toObject(){return _(_({},super.toObject()),{},{matrix:[...this.matrix]})}}function Xi(n,t){var e;const i=(b(e=class extends nr{toObject(){return{type:this.type,colorsOnly:this.colorsOnly}}},"type",n),b(e,"defaults",{colorsOnly:!1,matrix:t}),e);return R.setClass(i,n),i}b(nr,"type","ColorMatrix"),b(nr,"defaults",sh),b(nr,"uniformLocations",["uColorMatrix","uConstants"]),R.setClass(nr);Xi("Brownie",[.5997,.34553,-.27082,0,.186,-.0377,.86095,.15059,0,-.1449,.24113,-.07441,.44972,0,-.02965,0,0,0,1,0]);Xi("Vintage",[.62793,.32021,-.03965,0,.03784,.02578,.64411,.03259,0,.02926,.0466,-.08512,.52416,0,.02023,0,0,0,1,0]);Xi("Kodachrome",[1.12855,-.39673,-.03992,0,.24991,-.16404,1.08352,-.05498,0,.09698,-.16786,-.56034,1.60148,0,.13972,0,0,0,1,0]);Xi("Technicolor",[1.91252,-.85453,-.09155,0,.04624,-.30878,1.76589,-.10601,0,-.27589,-.2311,-.75018,1.84759,0,.12137,0,0,0,1,0]);Xi("Polaroid",[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0]);Xi("Sepia",[.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0]);Xi("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 _l extends Lt{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.subFilters=t.subFilters||[]}applyTo(t){Bn(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=>R.getClass(i.type).fromObject(i,e))).then(i=>new this({subFilters:i}))}}b(_l,"type","Composed"),R.setClass(_l);class Ns extends Lt{getFragmentSource(){return`
|
|
282
|
+
precision highp float;
|
|
283
|
+
uniform sampler2D uTexture;
|
|
284
|
+
uniform float uContrast;
|
|
285
|
+
varying vec2 vTexCoord;
|
|
286
|
+
void main() {
|
|
287
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
288
|
+
float contrastF = 1.015 * (uContrast + 1.0) / (1.0 * (1.015 - uContrast));
|
|
289
|
+
color.rgb = contrastF * (color.rgb - 0.5) + 0.5;
|
|
290
|
+
gl_FragColor = color;
|
|
291
|
+
}`}isNeutralState(){return this.contrast===0}applyTo2d(t){let{imageData:{data:e}}=t;const i=Math.floor(255*this.contrast),r=259*(i+255)/(255*(259-i));for(let s=0;s<e.length;s+=4)e[s]=r*(e[s]-128)+128,e[s+1]=r*(e[s+1]-128)+128,e[s+2]=r*(e[s+2]-128)+128}sendUniformData(t,e){t.uniform1f(e.uContrast,this.contrast)}}b(Ns,"type","Contrast"),b(Ns,"defaults",{contrast:0}),b(Ns,"uniformLocations",["uContrast"]),R.setClass(Ns);const Qp={Convolute_3_1:`
|
|
292
|
+
precision highp float;
|
|
293
|
+
uniform sampler2D uTexture;
|
|
294
|
+
uniform float uMatrix[9];
|
|
295
|
+
uniform float uStepW;
|
|
296
|
+
uniform float uStepH;
|
|
297
|
+
varying vec2 vTexCoord;
|
|
298
|
+
void main() {
|
|
299
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
300
|
+
for (float h = 0.0; h < 3.0; h+=1.0) {
|
|
301
|
+
for (float w = 0.0; w < 3.0; w+=1.0) {
|
|
302
|
+
vec2 matrixPos = vec2(uStepW * (w - 1), uStepH * (h - 1));
|
|
303
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 3.0 + w)];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
gl_FragColor = color;
|
|
307
|
+
}
|
|
308
|
+
`,Convolute_3_0:`
|
|
309
|
+
precision highp float;
|
|
310
|
+
uniform sampler2D uTexture;
|
|
311
|
+
uniform float uMatrix[9];
|
|
312
|
+
uniform float uStepW;
|
|
313
|
+
uniform float uStepH;
|
|
314
|
+
varying vec2 vTexCoord;
|
|
315
|
+
void main() {
|
|
316
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
317
|
+
for (float h = 0.0; h < 3.0; h+=1.0) {
|
|
318
|
+
for (float w = 0.0; w < 3.0; w+=1.0) {
|
|
319
|
+
vec2 matrixPos = vec2(uStepW * (w - 1.0), uStepH * (h - 1.0));
|
|
320
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 3.0 + w)];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
324
|
+
gl_FragColor = color;
|
|
325
|
+
gl_FragColor.a = alpha;
|
|
326
|
+
}
|
|
327
|
+
`,Convolute_5_1:`
|
|
328
|
+
precision highp float;
|
|
329
|
+
uniform sampler2D uTexture;
|
|
330
|
+
uniform float uMatrix[25];
|
|
331
|
+
uniform float uStepW;
|
|
332
|
+
uniform float uStepH;
|
|
333
|
+
varying vec2 vTexCoord;
|
|
334
|
+
void main() {
|
|
335
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
336
|
+
for (float h = 0.0; h < 5.0; h+=1.0) {
|
|
337
|
+
for (float w = 0.0; w < 5.0; w+=1.0) {
|
|
338
|
+
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
|
339
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 5.0 + w)];
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
gl_FragColor = color;
|
|
343
|
+
}
|
|
344
|
+
`,Convolute_5_0:`
|
|
345
|
+
precision highp float;
|
|
346
|
+
uniform sampler2D uTexture;
|
|
347
|
+
uniform float uMatrix[25];
|
|
348
|
+
uniform float uStepW;
|
|
349
|
+
uniform float uStepH;
|
|
350
|
+
varying vec2 vTexCoord;
|
|
351
|
+
void main() {
|
|
352
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
353
|
+
for (float h = 0.0; h < 5.0; h+=1.0) {
|
|
354
|
+
for (float w = 0.0; w < 5.0; w+=1.0) {
|
|
355
|
+
vec2 matrixPos = vec2(uStepW * (w - 2.0), uStepH * (h - 2.0));
|
|
356
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 5.0 + w)];
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
360
|
+
gl_FragColor = color;
|
|
361
|
+
gl_FragColor.a = alpha;
|
|
362
|
+
}
|
|
363
|
+
`,Convolute_7_1:`
|
|
364
|
+
precision highp float;
|
|
365
|
+
uniform sampler2D uTexture;
|
|
366
|
+
uniform float uMatrix[49];
|
|
367
|
+
uniform float uStepW;
|
|
368
|
+
uniform float uStepH;
|
|
369
|
+
varying vec2 vTexCoord;
|
|
370
|
+
void main() {
|
|
371
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
372
|
+
for (float h = 0.0; h < 7.0; h+=1.0) {
|
|
373
|
+
for (float w = 0.0; w < 7.0; w+=1.0) {
|
|
374
|
+
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
|
375
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 7.0 + w)];
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
gl_FragColor = color;
|
|
379
|
+
}
|
|
380
|
+
`,Convolute_7_0:`
|
|
381
|
+
precision highp float;
|
|
382
|
+
uniform sampler2D uTexture;
|
|
383
|
+
uniform float uMatrix[49];
|
|
384
|
+
uniform float uStepW;
|
|
385
|
+
uniform float uStepH;
|
|
386
|
+
varying vec2 vTexCoord;
|
|
387
|
+
void main() {
|
|
388
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
389
|
+
for (float h = 0.0; h < 7.0; h+=1.0) {
|
|
390
|
+
for (float w = 0.0; w < 7.0; w+=1.0) {
|
|
391
|
+
vec2 matrixPos = vec2(uStepW * (w - 3.0), uStepH * (h - 3.0));
|
|
392
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 7.0 + w)];
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
396
|
+
gl_FragColor = color;
|
|
397
|
+
gl_FragColor.a = alpha;
|
|
398
|
+
}
|
|
399
|
+
`,Convolute_9_1:`
|
|
400
|
+
precision highp float;
|
|
401
|
+
uniform sampler2D uTexture;
|
|
402
|
+
uniform float uMatrix[81];
|
|
403
|
+
uniform float uStepW;
|
|
404
|
+
uniform float uStepH;
|
|
405
|
+
varying vec2 vTexCoord;
|
|
406
|
+
void main() {
|
|
407
|
+
vec4 color = vec4(0, 0, 0, 0);
|
|
408
|
+
for (float h = 0.0; h < 9.0; h+=1.0) {
|
|
409
|
+
for (float w = 0.0; w < 9.0; w+=1.0) {
|
|
410
|
+
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
|
411
|
+
color += texture2D(uTexture, vTexCoord + matrixPos) * uMatrix[int(h * 9.0 + w)];
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
gl_FragColor = color;
|
|
415
|
+
}
|
|
416
|
+
`,Convolute_9_0:`
|
|
417
|
+
precision highp float;
|
|
418
|
+
uniform sampler2D uTexture;
|
|
419
|
+
uniform float uMatrix[81];
|
|
420
|
+
uniform float uStepW;
|
|
421
|
+
uniform float uStepH;
|
|
422
|
+
varying vec2 vTexCoord;
|
|
423
|
+
void main() {
|
|
424
|
+
vec4 color = vec4(0, 0, 0, 1);
|
|
425
|
+
for (float h = 0.0; h < 9.0; h+=1.0) {
|
|
426
|
+
for (float w = 0.0; w < 9.0; w+=1.0) {
|
|
427
|
+
vec2 matrixPos = vec2(uStepW * (w - 4.0), uStepH * (h - 4.0));
|
|
428
|
+
color.rgb += texture2D(uTexture, vTexCoord + matrixPos).rgb * uMatrix[int(h * 9.0 + w)];
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
float alpha = texture2D(uTexture, vTexCoord).a;
|
|
432
|
+
gl_FragColor = color;
|
|
433
|
+
gl_FragColor.a = alpha;
|
|
434
|
+
}
|
|
435
|
+
`};class zs extends Lt{getCacheKey(){return"".concat(this.type,"_").concat(Math.sqrt(this.matrix.length),"_").concat(this.opaque?1:0)}getFragmentSource(){return Qp[this.getCacheKey()]}applyTo2d(t){const e=t.imageData,i=e.data,r=this.matrix,s=Math.round(Math.sqrt(r.length)),o=Math.floor(s/2),a=e.width,l=e.height,c=t.ctx.createImageData(a,l),h=c.data,u=this.opaque?1:0;let d,p,f,g,m,v,y,x,T,E,A,C,S;for(A=0;A<l;A++)for(E=0;E<a;E++){for(m=4*(A*a+E),d=0,p=0,f=0,g=0,S=0;S<s;S++)for(C=0;C<s;C++)y=A+S-o,v=E+C-o,y<0||y>=l||v<0||v>=a||(x=4*(y*a+v),T=r[S*s+C],d+=i[x]*T,p+=i[x+1]*T,f+=i[x+2]*T,u||(g+=i[x+3]*T));h[m]=d,h[m+1]=p,h[m+2]=f,h[m+3]=u?i[m+3]:g}t.imageData=c}sendUniformData(t,e){t.uniform1fv(e.uMatrix,this.matrix)}toObject(){return _(_({},super.toObject()),{},{opaque:this.opaque,matrix:[...this.matrix]})}}b(zs,"type","Convolute"),b(zs,"defaults",{opaque:!1,matrix:[0,0,0,0,1,0,0,0,0]}),b(zs,"uniformLocations",["uMatrix","uOpaque","uHalfSize","uSize"]),R.setClass(zs);const nh="Gamma";class Vs extends Lt{getFragmentSource(){return`
|
|
436
|
+
precision highp float;
|
|
437
|
+
uniform sampler2D uTexture;
|
|
438
|
+
uniform vec3 uGamma;
|
|
439
|
+
varying vec2 vTexCoord;
|
|
440
|
+
void main() {
|
|
441
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
442
|
+
vec3 correction = (1.0 / uGamma);
|
|
443
|
+
color.r = pow(color.r, correction.r);
|
|
444
|
+
color.g = pow(color.g, correction.g);
|
|
445
|
+
color.b = pow(color.b, correction.b);
|
|
446
|
+
gl_FragColor = color;
|
|
447
|
+
gl_FragColor.rgb *= color.a;
|
|
448
|
+
}
|
|
449
|
+
`}constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};super(t),this.gamma=t.gamma||this.constructor.defaults.gamma.concat()}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.gamma,r=1/i[0],s=1/i[1],o=1/i[2];this.rgbValues||(this.rgbValues={r:new Uint8Array(256),g:new Uint8Array(256),b:new Uint8Array(256)});const a=this.rgbValues;for(let l=0;l<256;l++)a.r[l]=255*Math.pow(l/255,r),a.g[l]=255*Math.pow(l/255,s),a.b[l]=255*Math.pow(l/255,o);for(let l=0;l<e.length;l+=4)e[l]=a.r[e[l]],e[l+1]=a.g[e[l+1]],e[l+2]=a.b[e[l+2]]}sendUniformData(t,e){t.uniform3fv(e.uGamma,this.gamma)}isNeutralState(){const{gamma:t}=this;return t[0]===1&&t[1]===1&&t[2]===1}toObject(){return{type:nh,gamma:this.gamma.concat()}}}b(Vs,"type",nh),b(Vs,"defaults",{gamma:[1,1,1]}),b(Vs,"uniformLocations",["uGamma"]),R.setClass(Vs);const tf={average:`
|
|
450
|
+
precision highp float;
|
|
451
|
+
uniform sampler2D uTexture;
|
|
452
|
+
varying vec2 vTexCoord;
|
|
453
|
+
void main() {
|
|
454
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
455
|
+
float average = (color.r + color.b + color.g) / 3.0;
|
|
456
|
+
gl_FragColor = vec4(average, average, average, color.a);
|
|
457
|
+
}
|
|
458
|
+
`,lightness:`
|
|
459
|
+
precision highp float;
|
|
460
|
+
uniform sampler2D uTexture;
|
|
461
|
+
uniform int uMode;
|
|
462
|
+
varying vec2 vTexCoord;
|
|
463
|
+
void main() {
|
|
464
|
+
vec4 col = texture2D(uTexture, vTexCoord);
|
|
465
|
+
float average = (max(max(col.r, col.g),col.b) + min(min(col.r, col.g),col.b)) / 2.0;
|
|
466
|
+
gl_FragColor = vec4(average, average, average, col.a);
|
|
467
|
+
}
|
|
468
|
+
`,luminosity:`
|
|
469
|
+
precision highp float;
|
|
470
|
+
uniform sampler2D uTexture;
|
|
471
|
+
uniform int uMode;
|
|
472
|
+
varying vec2 vTexCoord;
|
|
473
|
+
void main() {
|
|
474
|
+
vec4 col = texture2D(uTexture, vTexCoord);
|
|
475
|
+
float average = 0.21 * col.r + 0.72 * col.g + 0.07 * col.b;
|
|
476
|
+
gl_FragColor = vec4(average, average, average, col.a);
|
|
477
|
+
}
|
|
478
|
+
`};class Hs extends Lt{applyTo2d(t){let{imageData:{data:e}}=t;for(let i,r=0;r<e.length;r+=4){const s=e[r],o=e[r+1],a=e[r+2];switch(this.mode){case"average":i=(s+o+a)/3;break;case"lightness":i=(Math.min(s,o,a)+Math.max(s,o,a))/2;break;case"luminosity":i=.21*s+.72*o+.07*a}e[r+2]=e[r+1]=e[r]=i}}getCacheKey(){return"".concat(this.type,"_").concat(this.mode)}getFragmentSource(){return tf[this.mode]}sendUniformData(t,e){t.uniform1i(e.uMode,1)}isNeutralState(){return!1}}b(Hs,"type","Grayscale"),b(Hs,"defaults",{mode:"average"}),b(Hs,"uniformLocations",["uMode"]),R.setClass(Hs);const ef=_(_({},sh),{},{rotation:0});class ho extends nr{calculateMatrix(){const t=this.rotation*Math.PI,e=oi(t),i=ai(t),r=1/3,s=Math.sqrt(r)*i,o=1-e;this.matrix=[e+o/3,r*o-s,r*o+s,0,0,r*o+s,e+r*o,r*o-s,0,0,r*o-s,r*o+s,e+r*o,0,0,0,0,0,1,0]}isNeutralState(){return this.rotation===0}applyTo(t){this.calculateMatrix(),super.applyTo(t)}toObject(){return{type:this.type,rotation:this.rotation}}}b(ho,"type","HueRotation"),b(ho,"defaults",ef),R.setClass(ho);class $s extends Lt{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`
|
|
479
|
+
precision highp float;
|
|
480
|
+
uniform sampler2D uTexture;
|
|
481
|
+
uniform int uInvert;
|
|
482
|
+
uniform int uAlpha;
|
|
483
|
+
varying vec2 vTexCoord;
|
|
484
|
+
void main() {
|
|
485
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
486
|
+
if (uInvert == 1) {
|
|
487
|
+
if (uAlpha == 1) {
|
|
488
|
+
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,1.0 -color.a);
|
|
489
|
+
} else {
|
|
490
|
+
gl_FragColor = vec4(1.0 - color.r,1.0 -color.g,1.0 -color.b,color.a);
|
|
491
|
+
}
|
|
492
|
+
} else {
|
|
493
|
+
gl_FragColor = color;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
`}isNeutralState(){return!this.invert}sendUniformData(t,e){t.uniform1i(e.uInvert,Number(this.invert)),t.uniform1i(e.uAlpha,Number(this.alpha))}}b($s,"type","Invert"),b($s,"defaults",{alpha:!1,invert:!0}),b($s,"uniformLocations",["uInvert","uAlpha"]),R.setClass($s);class Ws extends Lt{getFragmentSource(){return`
|
|
497
|
+
precision highp float;
|
|
498
|
+
uniform sampler2D uTexture;
|
|
499
|
+
uniform float uStepH;
|
|
500
|
+
uniform float uNoise;
|
|
501
|
+
uniform float uSeed;
|
|
502
|
+
varying vec2 vTexCoord;
|
|
503
|
+
float rand(vec2 co, float seed, float vScale) {
|
|
504
|
+
return fract(sin(dot(co.xy * vScale ,vec2(12.9898 , 78.233))) * 43758.5453 * (seed + 0.01) / 2.0);
|
|
505
|
+
}
|
|
506
|
+
void main() {
|
|
507
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
508
|
+
color.rgb += (0.5 - rand(vTexCoord, uSeed, 0.1 / uStepH)) * uNoise;
|
|
509
|
+
gl_FragColor = color;
|
|
510
|
+
}
|
|
511
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=this.noise;for(let r=0;r<e.length;r+=4){const s=(.5-Math.random())*i;e[r]+=s,e[r+1]+=s,e[r+2]+=s}}sendUniformData(t,e){t.uniform1f(e.uNoise,this.noise/255),t.uniform1f(e.uSeed,Math.random())}isNeutralState(){return this.noise===0}}b(Ws,"type","Noise"),b(Ws,"defaults",{noise:0}),b(Ws,"uniformLocations",["uNoise","uSeed"]),R.setClass(Ws);class Gs extends Lt{applyTo2d(t){let{imageData:{data:e,width:i,height:r}}=t;for(let s=0;s<r;s+=this.blocksize)for(let o=0;o<i;o+=this.blocksize){const a=4*s*i+4*o,l=e[a],c=e[a+1],h=e[a+2],u=e[a+3];for(let d=s;d<Math.min(s+this.blocksize,r);d++)for(let p=o;p<Math.min(o+this.blocksize,i);p++){const f=4*d*i+4*p;e[f]=l,e[f+1]=c,e[f+2]=h,e[f+3]=u}}}isNeutralState(){return this.blocksize===1}getFragmentSource(){return`
|
|
512
|
+
precision highp float;
|
|
513
|
+
uniform sampler2D uTexture;
|
|
514
|
+
uniform float uBlocksize;
|
|
515
|
+
uniform float uStepW;
|
|
516
|
+
uniform float uStepH;
|
|
517
|
+
varying vec2 vTexCoord;
|
|
518
|
+
void main() {
|
|
519
|
+
float blockW = uBlocksize * uStepW;
|
|
520
|
+
float blockH = uBlocksize * uStepH;
|
|
521
|
+
int posX = int(vTexCoord.x / blockW);
|
|
522
|
+
int posY = int(vTexCoord.y / blockH);
|
|
523
|
+
float fposX = float(posX);
|
|
524
|
+
float fposY = float(posY);
|
|
525
|
+
vec2 squareCoords = vec2(fposX * blockW, fposY * blockH);
|
|
526
|
+
vec4 color = texture2D(uTexture, squareCoords);
|
|
527
|
+
gl_FragColor = color;
|
|
528
|
+
}
|
|
529
|
+
`}sendUniformData(t,e){t.uniform1f(e.uBlocksize,this.blocksize)}}b(Gs,"type","Pixelate"),b(Gs,"defaults",{blocksize:4}),b(Gs,"uniformLocations",["uBlocksize"]),R.setClass(Gs);class Us extends Lt{getFragmentSource(){return`
|
|
530
|
+
precision highp float;
|
|
531
|
+
uniform sampler2D uTexture;
|
|
532
|
+
uniform vec4 uLow;
|
|
533
|
+
uniform vec4 uHigh;
|
|
534
|
+
varying vec2 vTexCoord;
|
|
535
|
+
void main() {
|
|
536
|
+
gl_FragColor = texture2D(uTexture, vTexCoord);
|
|
537
|
+
if(all(greaterThan(gl_FragColor.rgb,uLow.rgb)) && all(greaterThan(uHigh.rgb,gl_FragColor.rgb))) {
|
|
538
|
+
gl_FragColor.a = 0.0;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=255*this.distance,r=new rt(this.color).getSource(),s=[r[0]-i,r[1]-i,r[2]-i],o=[r[0]+i,r[1]+i,r[2]+i];for(let a=0;a<e.length;a+=4){const l=e[a],c=e[a+1],h=e[a+2];l>s[0]&&c>s[1]&&h>s[2]&&l<o[0]&&c<o[1]&&h<o[2]&&(e[a+3]=0)}}sendUniformData(t,e){const i=new rt(this.color).getSource(),r=this.distance,s=[0+i[0]/255-r,0+i[1]/255-r,0+i[2]/255-r,1],o=[i[0]/255+r,i[1]/255+r,i[2]/255+r,1];t.uniform4fv(e.uLow,s),t.uniform4fv(e.uHigh,o)}}b(Us,"type","RemoveColor"),b(Us,"defaults",{color:"#FFFFFF",distance:.02,useAlpha:!1}),b(Us,"uniformLocations",["uLow","uHigh"]),R.setClass(Us);class Ys extends Lt{sendUniformData(t,e){t.uniform2fv(e.uDelta,this.horizontal?[1/this.width,0]:[0,1/this.height]),t.uniform1fv(e.uTaps,this.taps)}getFilterWindow(){const t=this.tempScale;return Math.ceil(this.lanczosLobes/t)}getCacheKey(){const t=this.getFilterWindow();return"".concat(this.type,"_").concat(t)}getFragmentSource(){const t=this.getFilterWindow();return this.generateShader(t)}getTaps(){const t=this.lanczosCreate(this.lanczosLobes),e=this.tempScale,i=this.getFilterWindow(),r=new Array(i);for(let s=1;s<=i;s++)r[s-1]=t(s*e);return r}generateShader(t){const e=new Array(t);for(let i=1;i<=t;i++)e[i-1]="".concat(i,".0 * uDelta");return`
|
|
542
|
+
precision highp float;
|
|
543
|
+
uniform sampler2D uTexture;
|
|
544
|
+
uniform vec2 uDelta;
|
|
545
|
+
varying vec2 vTexCoord;
|
|
546
|
+
uniform float uTaps[`.concat(t,`];
|
|
547
|
+
void main() {
|
|
548
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
549
|
+
float sum = 1.0;
|
|
550
|
+
`).concat(e.map((i,r)=>`
|
|
551
|
+
color += texture2D(uTexture, vTexCoord + `.concat(i,") * uTaps[").concat(r,"] + texture2D(uTexture, vTexCoord - ").concat(i,") * uTaps[").concat(r,`];
|
|
552
|
+
sum += 2.0 * uTaps[`).concat(r,`];
|
|
553
|
+
`)).join(`
|
|
554
|
+
`),`
|
|
555
|
+
gl_FragColor = color / sum;
|
|
556
|
+
}
|
|
557
|
+
`)}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){Bn(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,r=this.scaleY;this.rcpScaleX=1/i,this.rcpScaleY=1/r;const s=e.width,o=e.height,a=Math.round(s*i),l=Math.round(o*r);let c;c=this.resizeType==="sliceHack"?this.sliceByTwo(t,s,o,a,l):this.resizeType==="hermite"?this.hermiteFastResize(t,s,o,a,l):this.resizeType==="bilinear"?this.bilinearFiltering(t,s,o,a,l):this.resizeType==="lanczos"?this.lanczosResize(t,s,o,a,l):new ImageData(a,l),t.imageData=c}sliceByTwo(t,e,i,r,s){const o=t.imageData,a=.5;let l=!1,c=!1,h=e*a,u=i*a;const d=t.filterBackend.resources;let p=0,f=0;const g=e;let m=0;d.sliceByTwo||(d.sliceByTwo=Ae());const v=d.sliceByTwo;(v.width<1.5*e||v.height<i)&&(v.width=1.5*e,v.height=i);const y=v.getContext("2d");for(y.clearRect(0,0,1.5*e,i),y.putImageData(o,0,0),r=Math.floor(r),s=Math.floor(s);!l||!c;)e=h,i=u,r<Math.floor(h*a)?h=Math.floor(h*a):(h=r,l=!0),s<Math.floor(u*a)?u=Math.floor(u*a):(u=s,c=!0),y.drawImage(v,p,f,e,i,g,m,h,u),p=g,f=m,m+=u;return y.getImageData(p,f,r,s)}lanczosResize(t,e,i,r,s){const o=t.imageData.data,a=t.ctx.createImageData(r,s),l=a.data,c=this.lanczosCreate(this.lanczosLobes),h=this.rcpScaleX,u=this.rcpScaleY,d=2/this.rcpScaleX,p=2/this.rcpScaleY,f=Math.ceil(h*this.lanczosLobes/2),g=Math.ceil(u*this.lanczosLobes/2),m={},v={x:0,y:0},y={x:0,y:0};return function x(T){let E,A,C,S,F,j,D,k,P,L,V;for(v.x=(T+.5)*h,y.x=Math.floor(v.x),E=0;E<s;E++){for(v.y=(E+.5)*u,y.y=Math.floor(v.y),F=0,j=0,D=0,k=0,P=0,A=y.x-f;A<=y.x+f;A++)if(!(A<0||A>=e)){L=Math.floor(1e3*Math.abs(A-v.x)),m[L]||(m[L]={});for(let Y=y.y-g;Y<=y.y+g;Y++)Y<0||Y>=i||(V=Math.floor(1e3*Math.abs(Y-v.y)),m[L][V]||(m[L][V]=c(Math.sqrt(Math.pow(L*d,2)+Math.pow(V*p,2))/1e3)),C=m[L][V],C>0&&(S=4*(Y*e+A),F+=C,j+=C*o[S],D+=C*o[S+1],k+=C*o[S+2],P+=C*o[S+3]))}S=4*(E*r+T),l[S]=j/F,l[S+1]=D/F,l[S+2]=k/F,l[S+3]=P/F}return++T<r?x(T):a}(0)}bilinearFiltering(t,e,i,r,s){let o,a,l,c,h,u,d,p,f,g,m,v,y,x=0;const T=this.rcpScaleX,E=this.rcpScaleY,A=4*(e-1),C=t.imageData.data,S=t.ctx.createImageData(r,s),F=S.data;for(d=0;d<s;d++)for(p=0;p<r;p++)for(h=Math.floor(T*p),u=Math.floor(E*d),f=T*p-h,g=E*d-u,y=4*(u*e+h),m=0;m<4;m++)o=C[y+m],a=C[y+4+m],l=C[y+A+m],c=C[y+A+4+m],v=o*(1-f)*(1-g)+a*f*(1-g)+l*g*(1-f)+c*f*g,F[x++]=v;return S}hermiteFastResize(t,e,i,r,s){const o=this.rcpScaleX,a=this.rcpScaleY,l=Math.ceil(o/2),c=Math.ceil(a/2),h=t.imageData.data,u=t.ctx.createImageData(r,s),d=u.data;for(let p=0;p<s;p++)for(let f=0;f<r;f++){const g=4*(f+p*r);let m=0,v=0,y=0,x=0,T=0,E=0,A=0;const C=(p+.5)*a;for(let S=Math.floor(p*a);S<(p+1)*a;S++){const F=Math.abs(C-(S+.5))/c,j=(f+.5)*o,D=F*F;for(let k=Math.floor(f*o);k<(f+1)*o;k++){let P=Math.abs(j-(k+.5))/l;const L=Math.sqrt(D+P*P);L>1&&L<-1||(m=2*L*L*L-3*L*L+1,m>0&&(P=4*(k+S*e),A+=m*h[P+3],y+=m,h[P+3]<255&&(m=m*h[P+3]/250),x+=m*h[P],T+=m*h[P+1],E+=m*h[P+2],v+=m))}}d[g]=x/v,d[g+1]=T/v,d[g+2]=E/v,d[g+3]=A/y}return u}}b(Ys,"type","Resize"),b(Ys,"defaults",{resizeType:"hermite",scaleX:1,scaleY:1,lanczosLobes:3}),b(Ys,"uniformLocations",["uDelta","uTaps"]),R.setClass(Ys);class Xs extends Lt{getFragmentSource(){return`
|
|
558
|
+
precision highp float;
|
|
559
|
+
uniform sampler2D uTexture;
|
|
560
|
+
uniform float uSaturation;
|
|
561
|
+
varying vec2 vTexCoord;
|
|
562
|
+
void main() {
|
|
563
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
564
|
+
float rgMax = max(color.r, color.g);
|
|
565
|
+
float rgbMax = max(rgMax, color.b);
|
|
566
|
+
color.r += rgbMax != color.r ? (rgbMax - color.r) * uSaturation : 0.00;
|
|
567
|
+
color.g += rgbMax != color.g ? (rgbMax - color.g) * uSaturation : 0.00;
|
|
568
|
+
color.b += rgbMax != color.b ? (rgbMax - color.b) * uSaturation : 0.00;
|
|
569
|
+
gl_FragColor = color;
|
|
570
|
+
}
|
|
571
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.saturation;for(let r=0;r<e.length;r+=4){const s=e[r],o=e[r+1],a=e[r+2],l=Math.max(s,o,a);e[r]+=l!==s?(l-s)*i:0,e[r+1]+=l!==o?(l-o)*i:0,e[r+2]+=l!==a?(l-a)*i:0}}sendUniformData(t,e){t.uniform1f(e.uSaturation,-this.saturation)}isNeutralState(){return this.saturation===0}}b(Xs,"type","Saturation"),b(Xs,"defaults",{saturation:0}),b(Xs,"uniformLocations",["uSaturation"]),R.setClass(Xs);class Ks extends Lt{getFragmentSource(){return`
|
|
572
|
+
precision highp float;
|
|
573
|
+
uniform sampler2D uTexture;
|
|
574
|
+
uniform float uVibrance;
|
|
575
|
+
varying vec2 vTexCoord;
|
|
576
|
+
void main() {
|
|
577
|
+
vec4 color = texture2D(uTexture, vTexCoord);
|
|
578
|
+
float max = max(color.r, max(color.g, color.b));
|
|
579
|
+
float avg = (color.r + color.g + color.b) / 3.0;
|
|
580
|
+
float amt = (abs(max - avg) * 2.0) * uVibrance;
|
|
581
|
+
color.r += max != color.r ? (max - color.r) * amt : 0.00;
|
|
582
|
+
color.g += max != color.g ? (max - color.g) * amt : 0.00;
|
|
583
|
+
color.b += max != color.b ? (max - color.b) * amt : 0.00;
|
|
584
|
+
gl_FragColor = color;
|
|
585
|
+
}
|
|
586
|
+
`}applyTo2d(t){let{imageData:{data:e}}=t;const i=-this.vibrance;for(let r=0;r<e.length;r+=4){const s=e[r],o=e[r+1],a=e[r+2],l=Math.max(s,o,a),c=(s+o+a)/3,h=2*Math.abs(l-c)/255*i;e[r]+=l!==s?(l-s)*h:0,e[r+1]+=l!==o?(l-o)*h:0,e[r+2]+=l!==a?(l-a)*h:0}}sendUniformData(t,e){t.uniform1f(e.uVibrance,-this.vibrance)}isNeutralState(){return this.vibrance===0}}b(Ks,"type","Vibrance"),b(Ks,"defaults",{vibrance:0}),b(Ks,"uniformLocations",["uVibrance"]),R.setClass(Ks);const rf=vt`
|
|
587
|
+
:host {
|
|
588
|
+
display: block;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
.fabric-container {
|
|
592
|
+
max-width: 24rem;
|
|
593
|
+
width: 100% !important;
|
|
594
|
+
height: auto !important;
|
|
595
|
+
object-fit: contain;
|
|
596
|
+
display: block;
|
|
597
|
+
margin-left: auto;
|
|
598
|
+
margin-right: auto;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
.fabric-container canvas {
|
|
602
|
+
max-width: 24rem;
|
|
603
|
+
width: 100% !important;
|
|
604
|
+
height: auto !important;
|
|
605
|
+
display: block;
|
|
606
|
+
object-fit: contain;
|
|
607
|
+
}
|
|
608
|
+
`;var sf=Object.defineProperty,nf=Object.getOwnPropertyDescriptor,At=(n,t,e,i)=>{for(var r=i>1?void 0:i?nf(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&sf(t,e,r),r};let ut=class extends Xo{constructor(){super(),this.backgroundUrl="https://upload.wikimedia.org/wikipedia/commons/0/06/Daedalus_Spaceship_concept.jpg",this.message=`Dear fridends,
|
|
609
|
+
|
|
610
|
+
My name is xxxxx. sadf;lkasdf
|
|
611
|
+
good aklsdfja`,this.alignment="left",this.fontFamily="Arial",this.color="#000",this._backgroundImg=new Image,this._natureSize={width:0,height:0},this._scale=1,this._lineHeight=0,this._fontSize=0,this._backgroundImg=new Image}connectedCallback(){super.connectedCallback(),new ResizeObserver(()=>{this.adjustCanvasElements()}).observe(this),this._backgroundImg.src="https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821",this._backgroundImg.onload=()=>{this._natureSize={width:this._backgroundImg.naturalWidth,height:this._backgroundImg.naturalHeight}},this._canvasElement=document.createElement("canvas")}disconnectedCallback(){super.disconnectedCallback()}formatTextbox(n){var e;let t=n.textLines;if(t.length>12){const i=t.slice(0,12);n.set("text",i.join(`
|
|
612
|
+
`)),n.setSelectionStart(n.text.length),n.setSelectionEnd(n.text.length),(e=this._canvas)==null||e.renderAll()}}firstUpdated(){var t;const n=document.createElement("canvas");(t=this.shadowRoot)==null||t.appendChild(n),this._backgroundImg.onload=()=>{const e=new Ut(this._backgroundImg);this._canvas=new Jr(n,{backgroundImage:e,containerClass:"fabric-container"}),this._canvas.setDimensions({width:this._backgroundImg.width,height:this._backgroundImg.height}),this._lineHeight=.45*this._backgroundImg.height/12,this._fontSize=this._lineHeight/1.16;const i={fontSize:(this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width)/12*.8,left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,hasControls:!1,editable:!1,breakWords:!1,splitByGrapheme:!1,textAlign:this.alignment,lockMovementX:!0,lockMovementY:!0};this._textbox=new Qe(this.message,i),this._textbox.set("fill",this.color),this._textbox.on("changed",()=>{var l;if(!this._textbox)return;let o=this._textbox.text.split(`
|
|
613
|
+
`),a=[];o.forEach(c=>{if(c.length>20){const h=c.split(" ");let u="",d=0;h.forEach(p=>{d+p.length>20?(a.push(u.trim()),u=p+" ",d=p.length+1):(u+=p+" ",d+=p.length+1)}),u.trim().length>0&&a.push(u.trim())}else a.push(c)}),a.length>12&&(a=a.slice(0,12)),this._textbox.text=a.join(`
|
|
614
|
+
`),this._textbox.setSelectionStart(this._textbox.text.length),this._textbox.setSelectionEnd(this._textbox.text.length),(l=this._canvas)==null||l.renderAll()}),this._rect=new Rt({left:.084*this._canvas.width,top:.4874*this._canvas.height,width:.832*this._canvas.width,height:this._canvas.width-.4874*this._canvas.width-.084*this._canvas.width,fill:"red",selectable:!1}),this._canvas.add(this._textbox),this._canvas.centerObject(this._textbox),this._canvas.add(this._rect),this._canvas.renderAll()},window.addEventListener("resize",()=>{var e;n.width=this._fabricContainer.clientWidth,n.height=this._fabricContainer.clientHeight,this.adjustCanvasElements(),(e=this._canvas)==null||e.renderAll()}),setTimeout(()=>this.adjustCanvasElements(),100)}adjustCanvasElements(){var h,u;if(!this._canvas||!this._textbox||!this._backgroundImg||!this._backgroundImg.complete)return;const n=(h=this.shadowRoot)==null?void 0:h.querySelector(".fabric-container");if(!n)return;const t=n.clientWidth,e=n.clientHeight,i=this._backgroundImg.naturalWidth,r=this._backgroundImg.naturalHeight;let s;const o=t/e,a=i/r;e===0||t===0?s=t/i:o>a?s=e/r:s=t/i;const l=i*s,c=r*s;this._canvas.setDimensions({width:l,height:c}),this._canvas.backgroundImage&&(this._canvas.backgroundImage.scaleToWidth(l),this._canvas.backgroundImage.scaleToHeight(c)),this._textbox.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l,fontSize:(c-.4874*c-.084*l)/12*.8,lineHeight:this._lineHeight*s}),(u=this._rect)==null||u.set({left:.084*l,top:.4874*c,width:.832*l,height:c-.4874*c-.084*l}),this._canvas.renderAll()}handleMessageChange(n,t){var e;this._textbox&&(this._textbox.set("text",t),this.formatTextbox(this._textbox),(e=this._canvas)==null||e.renderAll())}handleAlignmentChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("textAlign",t),(i=this._canvas)==null||i.renderAll())}handleFontFamilyChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("fontFamily",t),(i=this._canvas)==null||i.renderAll())}handleColorChange(n,t){var e,i;this._textbox&&((e=this._textbox)==null||e.set("fill",t),(i=this._canvas)==null||i.renderAll())}render(){var n,t,e,i;return X` <div
|
|
615
|
+
style="position: fixed; top: 0; left: 0; padding: 1rem; z-index: 1000; background: rgba(255, 255, 255, 0.5); color: rgba(0, 0, 0, 0.5);"
|
|
616
|
+
>
|
|
617
|
+
background image url: ${this.backgroundUrl} <br />
|
|
618
|
+
Nature font size: ${this._fontSize} <br />
|
|
619
|
+
Nature line height: ${this._lineHeight} <br />
|
|
620
|
+
Line height: ${(n=this._textbox)==null?void 0:n.get("lineHeight")} <br />
|
|
621
|
+
Font size: ${(t=this._textbox)==null?void 0:t.get("fontSize")} <br />
|
|
622
|
+
real textbox width: ${this._backgroundImg.width*.382} <br />
|
|
623
|
+
real textbox height: ${this._backgroundImg.height*.45} <br />
|
|
624
|
+
Textbox width: ${(e=this._textbox)==null?void 0:e.width} <br />
|
|
625
|
+
Textbox height: ${(i=this._textbox)==null?void 0:i.height} <br />
|
|
626
|
+
</div>`}};ut.styles=[Pt,rf];At([O()],ut.prototype,"backgroundUrl",2);At([O()],ut.prototype,"message",2);At([O({type:String,reflect:!0})],ut.prototype,"alignment",2);At([O({type:String})],ut.prototype,"fontFamily",2);At([O({type:String})],ut.prototype,"color",2);At([q(".fabric-container")],ut.prototype,"_fabricContainer",2);At([$()],ut.prototype,"_canvas",2);At([$()],ut.prototype,"_canvasElement",2);At([$()],ut.prototype,"_textbox",2);At([$()],ut.prototype,"_backgroundImg",2);At([$()],ut.prototype,"_natureSize",2);At([$()],ut.prototype,"_scale",2);At([$()],ut.prototype,"_lineHeight",2);At([$()],ut.prototype,"_fontSize",2);At([$()],ut.prototype,"_rect",2);At([et("message")],ut.prototype,"handleMessageChange",1);At([et("alignment")],ut.prototype,"handleAlignmentChange",1);At([et("fontFamily")],ut.prototype,"handleFontFamilyChange",1);At([et("color")],ut.prototype,"handleColorChange",1);ut=At([Ot("fabric-example")],ut);const of=vt`
|
|
627
|
+
:host {
|
|
628
|
+
display: block;
|
|
629
|
+
}
|
|
630
|
+
.is-open {
|
|
631
|
+
background-color: red;
|
|
632
|
+
}
|
|
633
|
+
.choices__item {
|
|
634
|
+
font-size: 1rem;
|
|
635
|
+
}
|
|
636
|
+
`;/*! choices.js v11.0.3 | © 2024 Josh Johnson | https://github.com/jshjohnson/Choices#readme */var Lo=function(n,t){return Lo=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])},Lo(n,t)};function oh(n,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Lo(n,t);function e(){this.constructor=n}n.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}var ie=function(){return ie=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},ie.apply(this,arguments)};function af(n,t,e){for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))}var wt={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"},ee={showDropdown:"showDropdown",hideDropdown:"hideDropdown",change:"change",choice:"choice",search:"search",addItem:"addItem",removeItem:"removeItem",highlightItem:"highlightItem",highlightChoice:"highlightChoice",unhighlightItem:"unhighlightItem"},Wt={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},lf=["fuseOptions","classNames"],vi={Text:"text",SelectOne:"select-one",SelectMultiple:"select-multiple"},cf=function(n){return{type:wt.ADD_CHOICE,choice:n}},yl=function(n){return{type:wt.REMOVE_CHOICE,choice:n}},hf=function(n){return{type:wt.FILTER_CHOICES,results:n}},uf=function(n){return{type:wt.ACTIVATE_CHOICES,active:n}},df=function(n){return{type:wt.ADD_GROUP,group:n}},pf=function(n){return{type:wt.ADD_ITEM,item:n}},xl=function(n){return{type:wt.REMOVE_ITEM,item:n}},qs=function(n,t){return{type:wt.HIGHLIGHT_ITEM,item:n,highlighted:t}},ff=function(n,t){return Math.floor(Math.random()*(t-n)+n)},wl=function(n){return Array.from({length:n},function(){return ff(0,36).toString(36)}).join("")},gf=function(n,t){var e=n.id||n.name&&"".concat(n.name,"-").concat(wl(2))||wl(4);return e=e.replace(/(:|\.|\[|\]|,)/g,""),e="".concat(t,"-").concat(e),e},mf=function(n,t,e){e===void 0&&(e=1);for(var i="".concat(e>0?"next":"previous","ElementSibling"),r=n[i];r;){if(r.matches(t))return r;r=r[i]}return null},vf=function(n,t,e){e===void 0&&(e=1);var i;return e>0?i=t.scrollTop+t.offsetHeight>=n.offsetTop+n.offsetHeight:i=n.offsetTop>=t.scrollTop,i},Nn=function(n){if(typeof n!="string"){if(n==null)return"";if(typeof n=="object"){if("raw"in n)return Nn(n.raw);if("trusted"in n)return n.trusted}return n}return n.replace(/&/g,"&").replace(/>/g,">").replace(/</g,"<").replace(/'/g,"'").replace(/"/g,""")},bf=function(){var n=document.createElement("div");return function(t){n.innerHTML=t.trim();for(var e=n.children[0];n.firstChild;)n.removeChild(n.firstChild);return e}}(),Wr=function(n,t){return typeof n=="function"?n(Nn(t),t):n},Cl=function(n){return typeof n=="function"?n():n},Hi=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("trusted"in n)return n.trusted;if("raw"in n)return n.raw}return""},_f=function(n){if(typeof n=="string")return n;if(typeof n=="object"){if("escaped"in n)return n.escaped;if("trusted"in n)return n.trusted}return""},_a=function(n,t){return n?_f(t):Nn(t)},Ue=function(n,t,e){n.innerHTML=_a(t,e)},yf=function(n,t){var e=n.value,i=n.label,r=i===void 0?e:i,s=t.value,o=t.label,a=o===void 0?s:o;return Hi(r).localeCompare(Hi(a),[],{sensitivity:"base",ignorePunctuation:!0,numeric:!0})},xf=function(n,t){return n.rank-t.rank},wf=function(n,t,e){e===void 0&&(e=null);var i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return n.dispatchEvent(i)},Cf=function(n,t){var e=Object.keys(n).sort(),i=Object.keys(t).sort();return e.filter(function(r){return i.indexOf(r)<0})},zn=function(n){return Array.isArray(n)?n:[n]},Pr=function(n){return n&&Array.isArray(n)?n.map(function(t){return".".concat(t)}).join(""):".".concat(n)},G=function(n,t){var e;(e=n.classList).add.apply(e,zn(t))},Fe=function(n,t){var e;(e=n.classList).remove.apply(e,zn(t))},Sf=function(n){if(typeof n<"u")try{return JSON.parse(n)}catch{return n}return{}},Tf=function(n,t,e){var i=n.itemEl;i&&(Fe(i,e),G(i,t))},Ef=function(){function n(t){var e=t.element,i=t.type,r=t.classNames;this.element=e,this.classNames=r,this.type=i,this.isActive=!1}return n.prototype.show=function(){return G(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","true"),this.isActive=!0,this},n.prototype.hide=function(){return Fe(this.element,this.classNames.activeState),this.element.setAttribute("aria-expanded","false"),this.isActive=!1,this},n}(),Sl=function(){function n(t){var e=t.element,i=t.type,r=t.classNames,s=t.position;this.element=e,this.classNames=r,this.type=i,this.position=s,this.isOpen=!1,this.isFlipped=!1,this.isDisabled=!1,this.isLoading=!1}return n.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},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype.open=function(t,e){G(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","true"),this.isOpen=!0,this.shouldFlip(t,e)&&(G(this.element,this.classNames.flippedState),this.isFlipped=!0)},n.prototype.close=function(){Fe(this.element,this.classNames.openState),this.element.setAttribute("aria-expanded","false"),this.removeActiveDescendant(),this.isOpen=!1,this.isFlipped&&(Fe(this.element,this.classNames.flippedState),this.isFlipped=!1)},n.prototype.addFocusState=function(){G(this.element,this.classNames.focusState)},n.prototype.removeFocusState=function(){Fe(this.element,this.classNames.focusState)},n.prototype.enable=function(){Fe(this.element,this.classNames.disabledState),this.element.removeAttribute("aria-disabled"),this.type===vi.SelectOne&&this.element.setAttribute("tabindex","0"),this.isDisabled=!1},n.prototype.disable=function(){G(this.element,this.classNames.disabledState),this.element.setAttribute("aria-disabled","true"),this.type===vi.SelectOne&&this.element.setAttribute("tabindex","-1"),this.isDisabled=!0},n.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)},n.prototype.unwrap=function(t){var e=this.element,i=e.parentNode;i&&(i.insertBefore(t,e),i.removeChild(e))},n.prototype.addLoadingState=function(){G(this.element,this.classNames.loadingState),this.element.setAttribute("aria-busy","true"),this.isLoading=!0},n.prototype.removeLoadingState=function(){Fe(this.element,this.classNames.loadingState),this.element.removeAttribute("aria-busy"),this.isLoading=!1},n}(),Of=function(){function n(t){var e=t.element,i=t.type,r=t.classNames,s=t.preventPaste;this.element=e,this.type=i,this.classNames=r,this.preventPaste=s,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(n.prototype,"placeholder",{set:function(t){this.element.placeholder=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.value=t},enumerable:!1,configurable:!0}),n.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})},n.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)},n.prototype.enable=function(){var t=this.element;t.removeAttribute("disabled"),this.isDisabled=!1},n.prototype.disable=function(){var t=this.element;t.setAttribute("disabled",""),this.isDisabled=!0},n.prototype.focus=function(){this.isFocussed||this.element.focus()},n.prototype.blur=function(){this.isFocussed&&this.element.blur()},n.prototype.clear=function(t){return t===void 0&&(t=!0),this.element.value="",t&&this.setWidth(),this},n.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")},n.prototype.setActiveDescendant=function(t){this.element.setAttribute("aria-activedescendant",t)},n.prototype.removeActiveDescendant=function(){this.element.removeAttribute("aria-activedescendant")},n.prototype._onInput=function(){this.type!==vi.SelectOne&&this.setWidth()},n.prototype._onPaste=function(t){this.preventPaste&&t.preventDefault()},n.prototype._onFocus=function(){this.isFocussed=!0},n.prototype._onBlur=function(){this.isFocussed=!1},n}(),kf=4,Tl=function(){function n(t){var e=t.element;this.element=e,this.scrollPos=this.element.scrollTop,this.height=this.element.offsetHeight}return n.prototype.prepend=function(t){var e=this.element.firstElementChild;e?this.element.insertBefore(t,e):this.element.append(t)},n.prototype.scrollToTop=function(){this.element.scrollTop=0},n.prototype.scrollToChildElement=function(t,e){var i=this;if(t){var r=this.element.offsetHeight,s=this.element.scrollTop+r,o=t.offsetHeight,a=t.offsetTop+o,l=e>0?this.element.scrollTop+a-s:t.offsetTop;requestAnimationFrame(function(){i._animateScroll(l,e)})}},n.prototype._scrollDown=function(t,e,i){var r=(i-t)/e,s=r>1?r:1;this.element.scrollTop=t+s},n.prototype._scrollUp=function(t,e,i){var r=(t-i)/e,s=r>1?r:1;this.element.scrollTop=t-s},n.prototype._animateScroll=function(t,e){var i=this,r=kf,s=this.element.scrollTop,o=!1;e>0?(this._scrollDown(s,r,t),s<t&&(o=!0)):(this._scrollUp(s,r,t),s>t&&(o=!0)),o&&requestAnimationFrame(function(){i._animateScroll(t,e)})},n}(),ah=function(){function n(t){var e=t.element,i=t.classNames;this.element=e,this.classNames=i,this.isDisabled=!1}return Object.defineProperty(n.prototype,"isActive",{get:function(){return this.element.dataset.choice==="active"},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"dir",{get:function(){return this.element.dir},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"value",{get:function(){return this.element.value},set:function(t){this.element.setAttribute("value",t),this.element.value=t},enumerable:!1,configurable:!0}),n.prototype.conceal=function(){var t=this.element;G(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")},n.prototype.reveal=function(){var t=this.element;Fe(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")},n.prototype.enable=function(){this.element.removeAttribute("disabled"),this.element.disabled=!1,this.isDisabled=!1},n.prototype.disable=function(){this.element.setAttribute("disabled",""),this.element.disabled=!0,this.isDisabled=!0},n.prototype.triggerEvent=function(t,e){wf(this.element,t,e||{})},n}(),Df=function(n){oh(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t}(ah),Nr=function(n,t){return t===void 0&&(t=!0),typeof n>"u"?t:!!n},lh=function(n){if(typeof n=="string"&&(n=n.split(" ").filter(function(t){return t.length})),Array.isArray(n)&&n.length)return n},Ie=function(n,t,e){if(e===void 0&&(e=!0),typeof n=="string"){var i=Nn(n),r=e||i===n?n:{escaped:i,raw:n},s=Ie({value:n,label:r,selected:!0},!1);return s}var o=n;if("choices"in o){if(!t)throw new TypeError("optGroup is not allowed");var a=o,l=a.choices.map(function(d){return Ie(d,!1)}),c={id:0,label:Hi(a.label)||a.value,active:!!l.length,disabled:!!a.disabled,choices:l};return c}var h=o,u={id:0,group:null,score:0,rank:0,value:h.value,label:h.label||h.value,active:Nr(h.active),selected:Nr(h.selected,!1),disabled:Nr(h.disabled,!1),placeholder:Nr(h.placeholder,!1),highlighted:!1,labelClass:lh(h.labelClass),labelDescription:h.labelDescription,customProperties:h.customProperties};return u},Pf=function(n){return n.tagName==="INPUT"},ch=function(n){return n.tagName==="SELECT"},Af=function(n){return n.tagName==="OPTION"},Mf=function(n){return n.tagName==="OPTGROUP"},If=function(n){oh(t,n);function t(e){var i=e.element,r=e.classNames,s=e.template,o=e.extractPlaceholder,a=n.call(this,{element:i,classNames:r})||this;return a.template=s,a.extractPlaceholder=o,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,r=document.createDocumentFragment();e.forEach(function(s){var o=s;if(!o.element){var a=i.template(o);r.appendChild(a),o.element=a}}),this.element.appendChild(r)},t.prototype.optionsAsChoices=function(){var e=this,i=[];return this.element.querySelectorAll(":scope > option, :scope > optgroup").forEach(function(r){Af(r)?i.push(e._optionToChoice(r)):Mf(r)&&i.push(e._optgroupToChoice(r))}),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"?lh(e.dataset.labelClass):void 0,labelDescription:typeof e.dataset.labelDescription<"u"?e.dataset.labelDescription:void 0,customProperties:Sf(e.dataset.customProperties)}},t.prototype._optgroupToChoice=function(e){var i=this,r=e.querySelectorAll("option"),s=Array.from(r).map(function(o){return i._optionToChoice(o)});return{id:0,label:e.label||"",element:e,active:!!s.length,disabled:e.disabled,choices:s}},t}(ah),Lf={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"]},El={items:[],choices:[],silent:!1,renderChoiceLimit:-1,maxItemCount:-1,closeDropdownOnSelect:"auto",singleModeForMultiSelect:!1,addChoices:!1,addItems:!0,addItemFilter:function(n){return!!n&&n!==""},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:yf,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(n){return'Press Enter to add <b>"'.concat(n,'"</b>')},removeItemIconText:function(){return"Remove item"},removeItemLabelText:function(n){return"Remove item: ".concat(n)},maxItemText:function(n){return"Only ".concat(n," values can be added")},valueComparer:function(n,t){return n===t},fuseOptions:{includeScore:!0},labelId:"",callbackOnInit:null,callbackOnCreateTemplates:null,classNames:Lf,appendGroupInSearch:!1},Ol=function(n){var t=n.itemEl;t&&(t.remove(),n.itemEl=void 0)};function Ff(n,t,e){var i=n,r=!0;switch(t.type){case wt.ADD_ITEM:{t.item.selected=!0;var s=t.item.element;s&&(s.selected=!0,s.setAttribute("selected","")),i.push(t.item);break}case wt.REMOVE_ITEM:{t.item.selected=!1;var s=t.item.element;if(s){s.selected=!1,s.removeAttribute("selected");var o=s.parentElement;o&&ch(o)&&o.type===vi.SelectOne&&(o.value="")}Ol(t.item),i=i.filter(function(h){return h.id!==t.item.id});break}case wt.REMOVE_CHOICE:{Ol(t.choice),i=i.filter(function(c){return c.id!==t.choice.id});break}case wt.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&&Tf(l,a?e.classNames.highlightedState:e.classNames.selectedState,a?e.classNames.selectedState:e.classNames.highlightedState));break}default:{r=!1;break}}return{state:i,update:r}}function jf(n,t){var e=n,i=!0;switch(t.type){case wt.ADD_GROUP:{e.push(t.group);break}case wt.CLEAR_CHOICES:{e=[];break}default:{i=!1;break}}return{state:e,update:i}}function Rf(n,t,e){var i=n,r=!0;switch(t.type){case wt.ADD_CHOICE:{i.push(t.choice);break}case wt.REMOVE_CHOICE:{t.choice.choiceEl=void 0,t.choice.group&&(t.choice.group.choices=t.choice.group.choices.filter(function(o){return o.id!==t.choice.id})),i=i.filter(function(o){return o.id!==t.choice.id});break}case wt.ADD_ITEM:case wt.REMOVE_ITEM:{t.item.choiceEl=void 0;break}case wt.FILTER_CHOICES:{var s=[];t.results.forEach(function(o){s[o.item.id]=o}),i.forEach(function(o){var a=s[o.id];a!==void 0?(o.score=a.score,o.rank=a.rank,o.active=!0):(o.score=0,o.rank=0,o.active=!1),e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case wt.ACTIVATE_CHOICES:{i.forEach(function(o){o.active=t.active,e&&e.appendGroupInSearch&&(o.choiceEl=void 0)});break}case wt.CLEAR_CHOICES:{i=[];break}default:{r=!1;break}}return{state:i,update:r}}var kl={groups:jf,items:Ff,choices:Rf},Bf=function(){function n(t){this._state=this.defaultState,this._listeners=[],this._txn=0,this._context=t}return Object.defineProperty(n.prototype,"defaultState",{get:function(){return{groups:[],items:[],choices:[]}},enumerable:!1,configurable:!0}),n.prototype.changeSet=function(t){return{groups:t,items:t,choices:t}},n.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)})},n.prototype.subscribe=function(t){return this._listeners.push(t),this},n.prototype.dispatch=function(t){var e=this,i=this._state,r=!1,s=this._changeSet||this.changeSet(!1);Object.keys(kl).forEach(function(o){var a=kl[o](i[o],t,e._context);a.update&&(r=!0,s[o]=!0,i[o]=a.state)}),r&&(this._txn?this._changeSet=s:this._listeners.forEach(function(o){return o(s)}))},n.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(n.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"items",{get:function(){return this.state.items},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"highlightedActiveItems",{get:function(){return this.items.filter(function(t){return!t.disabled&&t.active&&t.highlighted})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"choices",{get:function(){return this.state.choices},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeChoices",{get:function(){return this.choices.filter(function(t){return t.active})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"searchableChoices",{get:function(){return this.choices.filter(function(t){return!t.disabled&&!t.placeholder})},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groups",{get:function(){return this.state.groups},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"activeGroups",{get:function(){var t=this;return this.state.groups.filter(function(e){var i=e.active&&!e.disabled,r=t.state.choices.some(function(s){return s.active&&!s.disabled});return i&&r},[])},enumerable:!1,configurable:!0}),n.prototype.inTxn=function(){return this._txn>0},n.prototype.getChoiceById=function(t){return this.activeChoices.find(function(e){return e.id===t})},n.prototype.getGroupById=function(t){return this.groups.find(function(e){return e.id===t})},n}(),Gt={noChoices:"no-choices",noResults:"no-results",addChoice:"add-choice",generic:""};function Nf(n,t,e){return(t=Vf(t))in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}function Dl(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),e.push.apply(e,i)}return e}function or(n){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?Dl(Object(e),!0).forEach(function(i){Nf(n,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):Dl(Object(e)).forEach(function(i){Object.defineProperty(n,i,Object.getOwnPropertyDescriptor(e,i))})}return n}function zf(n,t){if(typeof n!="object"||!n)return n;var e=n[Symbol.toPrimitive];if(e!==void 0){var i=e.call(n,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(n)}function Vf(n){var t=zf(n,"string");return typeof t=="symbol"?t:t+""}function li(n){return Array.isArray?Array.isArray(n):dh(n)==="[object Array]"}function Hf(n){if(typeof n=="string")return n;let t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function $f(n){return n==null?"":Hf(n)}function Re(n){return typeof n=="string"}function hh(n){return typeof n=="number"}function Wf(n){return n===!0||n===!1||Gf(n)&&dh(n)=="[object Boolean]"}function uh(n){return typeof n=="object"}function Gf(n){return uh(n)&&n!==null}function de(n){return n!=null}function uo(n){return!n.trim().length}function dh(n){return n==null?n===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(n)}const Uf="Incorrect 'index' type",Yf=n=>`Invalid value for key ${n}`,Xf=n=>`Pattern length exceeds max of ${n}.`,Kf=n=>`Missing ${n} property in key`,qf=n=>`Property 'weight' in key '${n}' must be a positive integer`,Pl=Object.prototype.hasOwnProperty;class Zf{constructor(t){this._keys=[],this._keyMap={};let e=0;t.forEach(i=>{let r=ph(i);this._keys.push(r),this._keyMap[r.id]=r,e+=r.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 ph(n){let t=null,e=null,i=null,r=1,s=null;if(Re(n)||li(n))i=n,t=Al(n),e=Fo(n);else{if(!Pl.call(n,"name"))throw new Error(Kf("name"));const o=n.name;if(i=o,Pl.call(n,"weight")&&(r=n.weight,r<=0))throw new Error(qf(o));t=Al(o),e=Fo(o),s=n.getFn}return{path:t,id:e,weight:r,src:i,getFn:s}}function Al(n){return li(n)?n:n.split(".")}function Fo(n){return li(n)?n.join("."):n}function Jf(n,t){let e=[],i=!1;const r=(s,o,a)=>{if(de(s))if(!o[a])e.push(s);else{let l=o[a];const c=s[l];if(!de(c))return;if(a===o.length-1&&(Re(c)||hh(c)||Wf(c)))e.push($f(c));else if(li(c)){i=!0;for(let h=0,u=c.length;h<u;h+=1)r(c[h],o,a+1)}else o.length&&r(c,o,a+1)}};return r(n,Re(t)?t.split("."):t,0),i?e:e[0]}const Qf={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},tg={isCaseSensitive:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(n,t)=>n.score===t.score?n.idx<t.idx?-1:1:n.score<t.score?-1:1},eg={location:0,threshold:.6,distance:100},ig={useExtendedSearch:!1,getFn:Jf,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1};var W=or(or(or(or({},tg),Qf),eg),ig);const rg=/[^ ]+/g;function sg(n=1,t=3){const e=new Map,i=Math.pow(10,t);return{get(r){const s=r.match(rg).length;if(e.has(s))return e.get(s);const o=1/Math.pow(s,.5*n),a=parseFloat(Math.round(o*i)/i);return e.set(s,a),a},clear(){e.clear()}}}class ya{constructor({getFn:t=W.getFn,fieldNormWeight:e=W.fieldNormWeight}={}){this.norm=sg(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,Re(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();Re(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)||uo(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((r,s)=>{let o=r.getFn?r.getFn(t):this.getFn(t,r.path);if(de(o)){if(li(o)){let a=[];const l=[{nestedArrIndex:-1,value:o}];for(;l.length;){const{nestedArrIndex:c,value:h}=l.pop();if(de(h))if(Re(h)&&!uo(h)){let u={v:h,i:c,n:this.norm.get(h)};a.push(u)}else li(h)&&h.forEach((u,d)=>{l.push({nestedArrIndex:d,value:u})})}i.$[s]=a}else if(Re(o)&&!uo(o)){let a={v:o,n:this.norm.get(o)};i.$[s]=a}}}),this.records.push(i)}toJSON(){return{keys:this.keys,records:this.records}}}function fh(n,t,{getFn:e=W.getFn,fieldNormWeight:i=W.fieldNormWeight}={}){const r=new ya({getFn:e,fieldNormWeight:i});return r.setKeys(n.map(ph)),r.setSources(t),r.create(),r}function ng(n,{getFn:t=W.getFn,fieldNormWeight:e=W.fieldNormWeight}={}){const{keys:i,records:r}=n,s=new ya({getFn:t,fieldNormWeight:e});return s.setKeys(i),s.setIndexRecords(r),s}function Zs(n,{errors:t=0,currentLocation:e=0,expectedLocation:i=0,distance:r=W.distance,ignoreLocation:s=W.ignoreLocation}={}){const o=t/n.length;if(s)return o;const a=Math.abs(i-e);return r?o+a/r:a?1:o}function og(n=[],t=W.minMatchCharLength){let e=[],i=-1,r=-1,s=0;for(let o=n.length;s<o;s+=1){let a=n[s];a&&i===-1?i=s:!a&&i!==-1&&(r=s-1,r-i+1>=t&&e.push([i,r]),i=-1)}return n[s-1]&&s-i>=t&&e.push([i,s-1]),e}const Ni=32;function ag(n,t,e,{location:i=W.location,distance:r=W.distance,threshold:s=W.threshold,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,includeMatches:l=W.includeMatches,ignoreLocation:c=W.ignoreLocation}={}){if(t.length>Ni)throw new Error(Xf(Ni));const h=t.length,u=n.length,d=Math.max(0,Math.min(i,u));let p=s,f=d;const g=a>1||l,m=g?Array(u):[];let v;for(;(v=n.indexOf(t,f))>-1;){let C=Zs(t,{currentLocation:v,expectedLocation:d,distance:r,ignoreLocation:c});if(p=Math.min(C,p),f=v+h,g){let S=0;for(;S<h;)m[v+S]=1,S+=1}}f=-1;let y=[],x=1,T=h+u;const E=1<<h-1;for(let C=0;C<h;C+=1){let S=0,F=T;for(;S<F;)Zs(t,{errors:C,currentLocation:d+F,expectedLocation:d,distance:r,ignoreLocation:c})<=p?S=F:T=F,F=Math.floor((T-S)/2+S);T=F;let j=Math.max(1,d-F+1),D=o?u:Math.min(d+F,u)+h,k=Array(D+2);k[D+1]=(1<<C)-1;for(let L=D;L>=j;L-=1){let V=L-1,Y=e[n.charAt(V)];if(g&&(m[V]=+!!Y),k[L]=(k[L+1]<<1|1)&Y,C&&(k[L]|=(y[L+1]|y[L])<<1|1|y[L+1]),k[L]&E&&(x=Zs(t,{errors:C,currentLocation:V,expectedLocation:d,distance:r,ignoreLocation:c}),x<=p)){if(p=x,f=V,f<=d)break;j=Math.max(1,2*d-f)}}if(Zs(t,{errors:C+1,currentLocation:d,expectedLocation:d,distance:r,ignoreLocation:c})>p)break;y=k}const A={isMatch:f>=0,score:Math.max(.001,x)};if(g){const C=og(m,a);C.length?l&&(A.indices=C):A.isMatch=!1}return A}function lg(n){let t={};for(let e=0,i=n.length;e<i;e+=1){const r=n.charAt(e);t[r]=(t[r]||0)|1<<i-e-1}return t}class gh{constructor(t,{location:e=W.location,threshold:i=W.threshold,distance:r=W.distance,includeMatches:s=W.includeMatches,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,isCaseSensitive:l=W.isCaseSensitive,ignoreLocation:c=W.ignoreLocation}={}){if(this.options={location:e,threshold:i,distance:r,includeMatches:s,findAllMatches:o,minMatchCharLength:a,isCaseSensitive:l,ignoreLocation:c},this.pattern=l?t:t.toLowerCase(),this.chunks=[],!this.pattern.length)return;const h=(d,p)=>{this.chunks.push({pattern:d,alphabet:lg(d),startIndex:p})},u=this.pattern.length;if(u>Ni){let d=0;const p=u%Ni,f=u-p;for(;d<f;)h(this.pattern.substr(d,Ni),d),d+=Ni;if(p){const g=u-Ni;h(this.pattern.substr(g),g)}}else h(this.pattern,0)}searchIn(t){const{isCaseSensitive:e,includeMatches:i}=this.options;if(e||(t=t.toLowerCase()),this.pattern===t){let f={isMatch:!0,score:0};return i&&(f.indices=[[0,t.length-1]]),f}const{location:r,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options;let h=[],u=0,d=!1;this.chunks.forEach(({pattern:f,alphabet:g,startIndex:m})=>{const{isMatch:v,score:y,indices:x}=ag(t,f,g,{location:r+m,distance:s,threshold:o,findAllMatches:a,minMatchCharLength:l,includeMatches:i,ignoreLocation:c});v&&(d=!0),u+=y,v&&x&&(h=[...h,...x])});let p={isMatch:d,score:d?u/this.chunks.length:1};return d&&i&&(p.indices=h),p}}class Pi{constructor(t){this.pattern=t}static isMultiMatch(t){return Ml(t,this.multiRegex)}static isSingleMatch(t){return Ml(t,this.singleRegex)}search(){}}function Ml(n,t){const e=n.match(t);return e?e[1]:null}class cg extends Pi{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 hg extends Pi{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 ug extends Pi{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 dg extends Pi{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 pg extends Pi{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 fg extends Pi{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 mh extends Pi{constructor(t,{location:e=W.location,threshold:i=W.threshold,distance:r=W.distance,includeMatches:s=W.includeMatches,findAllMatches:o=W.findAllMatches,minMatchCharLength:a=W.minMatchCharLength,isCaseSensitive:l=W.isCaseSensitive,ignoreLocation:c=W.ignoreLocation}={}){super(t),this._bitapSearch=new gh(t,{location:e,threshold:i,distance:r,includeMatches:s,findAllMatches:o,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 vh extends Pi{constructor(t){super(t)}static get type(){return"include"}static get multiRegex(){return/^'"(.*)"$/}static get singleRegex(){return/^'(.*)$/}search(t){let e=0,i;const r=[],s=this.pattern.length;for(;(i=t.indexOf(this.pattern,e))>-1;)e=i+s,r.push([i,e-1]);const o=!!r.length;return{isMatch:o,score:o?0:1,indices:r}}}const jo=[cg,vh,ug,dg,fg,pg,hg,mh],Il=jo.length,gg=/ +(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,mg="|";function vg(n,t={}){return n.split(mg).map(e=>{let i=e.trim().split(gg).filter(s=>s&&!!s.trim()),r=[];for(let s=0,o=i.length;s<o;s+=1){const a=i[s];let l=!1,c=-1;for(;!l&&++c<Il;){const h=jo[c];let u=h.isMultiMatch(a);u&&(r.push(new h(u,t)),l=!0)}if(!l)for(c=-1;++c<Il;){const h=jo[c];let u=h.isSingleMatch(a);if(u){r.push(new h(u,t));break}}}return r})}const bg=new Set([mh.type,vh.type]);class _g{constructor(t,{isCaseSensitive:e=W.isCaseSensitive,includeMatches:i=W.includeMatches,minMatchCharLength:r=W.minMatchCharLength,ignoreLocation:s=W.ignoreLocation,findAllMatches:o=W.findAllMatches,location:a=W.location,threshold:l=W.threshold,distance:c=W.distance}={}){this.query=null,this.options={isCaseSensitive:e,includeMatches:i,minMatchCharLength:r,findAllMatches:o,ignoreLocation:s,location:a,threshold:l,distance:c},this.pattern=e?t:t.toLowerCase(),this.query=vg(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:r}=this.options;t=r?t:t.toLowerCase();let s=0,o=[],a=0;for(let l=0,c=e.length;l<c;l+=1){const h=e[l];o.length=0,s=0;for(let u=0,d=h.length;u<d;u+=1){const p=h[u],{isMatch:f,indices:g,score:m}=p.search(t);if(f){if(s+=1,a+=m,i){const v=p.constructor.type;bg.has(v)?o=[...o,...g]:o.push(g)}}else{a=0,s=0,o.length=0;break}}if(s){let u={isMatch:!0,score:a/s};return i&&(u.indices=o),u}}return{isMatch:!1,score:1}}}const Ro=[];function yg(...n){Ro.push(...n)}function Bo(n,t){for(let e=0,i=Ro.length;e<i;e+=1){let r=Ro[e];if(r.condition(n,t))return new r(n,t)}return new gh(n,t)}const Cn={AND:"$and",OR:"$or"},No={PATH:"$path",PATTERN:"$val"},zo=n=>!!(n[Cn.AND]||n[Cn.OR]),xg=n=>!!n[No.PATH],wg=n=>!li(n)&&uh(n)&&!zo(n),Ll=n=>({[Cn.AND]:Object.keys(n).map(t=>({[t]:n[t]}))});function bh(n,t,{auto:e=!0}={}){const i=r=>{let s=Object.keys(r);const o=xg(r);if(!o&&s.length>1&&!zo(r))return i(Ll(r));if(wg(r)){const l=o?r[No.PATH]:s[0],c=o?r[No.PATTERN]:r[l];if(!Re(c))throw new Error(Yf(l));const h={keyId:Fo(l),pattern:c};return e&&(h.searcher=Bo(c,t)),h}let a={children:[],operator:s[0]};return s.forEach(l=>{const c=r[l];li(c)&&c.forEach(h=>{a.children.push(i(h))})}),a};return zo(n)||(n=Ll(n)),i(n)}function Cg(n,{ignoreFieldNorm:t=W.ignoreFieldNorm}){n.forEach(e=>{let i=1;e.matches.forEach(({key:r,norm:s,score:o})=>{const a=r?r.weight:null;i*=Math.pow(o===0&&a?Number.EPSILON:o,(a||1)*(t?1:s))}),e.score=i})}function Sg(n,t){const e=n.matches;t.matches=[],de(e)&&e.forEach(i=>{if(!de(i.indices)||!i.indices.length)return;const{indices:r,value:s}=i;let o={indices:r,value:s};i.key&&(o.key=i.key.src),i.idx>-1&&(o.refIndex=i.idx),t.matches.push(o)})}function Tg(n,t){t.score=n.score}function Eg(n,t,{includeMatches:e=W.includeMatches,includeScore:i=W.includeScore}={}){const r=[];return e&&r.push(Sg),i&&r.push(Tg),n.map(s=>{const{idx:o}=s,a={item:t[o],refIndex:o};return r.length&&r.forEach(l=>{l(s,a)}),a})}class Cr{constructor(t,e={},i){this.options=or(or({},W),e),this.options.useExtendedSearch,this._keyStore=new Zf(this.options.keys),this.setCollection(t,i)}setCollection(t,e){if(this._docs=t,e&&!(e instanceof ya))throw new Error(Uf);this._myIndex=e||fh(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,r=this._docs.length;i<r;i+=1){const s=this._docs[i];t(s,i)&&(this.removeAt(i),i-=1,r-=1,e.push(s))}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:r,shouldSort:s,sortFn:o,ignoreFieldNorm:a}=this.options;let l=Re(t)?Re(this._docs[0])?this._searchStringList(t):this._searchObjectList(t):this._searchLogical(t);return Cg(l,{ignoreFieldNorm:a}),s&&l.sort(o),hh(e)&&e>-1&&(l=l.slice(0,e)),Eg(l,this._docs,{includeMatches:i,includeScore:r})}_searchStringList(t){const e=Bo(t,this.options),{records:i}=this._myIndex,r=[];return i.forEach(({v:s,i:o,n:a})=>{if(!de(s))return;const{isMatch:l,score:c,indices:h}=e.searchIn(s);l&&r.push({item:s,idx:o,matches:[{score:c,value:s,norm:a,indices:h}]})}),r}_searchLogical(t){const e=bh(t,this.options),i=(a,l,c)=>{if(!a.children){const{keyId:u,searcher:d}=a,p=this._findMatches({key:this._keyStore.get(u),value:this._myIndex.getValueForItemAtKeyId(l,u),searcher:d});return p&&p.length?[{idx:c,item:l,matches:p}]:[]}const h=[];for(let u=0,d=a.children.length;u<d;u+=1){const p=a.children[u],f=i(p,l,c);if(f.length)h.push(...f);else if(a.operator===Cn.AND)return[]}return h},r=this._myIndex.records,s={},o=[];return r.forEach(({$:a,i:l})=>{if(de(a)){let c=i(e,a,l);c.length&&(s[l]||(s[l]={idx:l,item:a,matches:[]},o.push(s[l])),c.forEach(({matches:h})=>{s[l].matches.push(...h)}))}}),o}_searchObjectList(t){const e=Bo(t,this.options),{keys:i,records:r}=this._myIndex,s=[];return r.forEach(({$:o,i:a})=>{if(!de(o))return;let l=[];i.forEach((c,h)=>{l.push(...this._findMatches({key:c,value:o[h],searcher:e}))}),l.length&&s.push({idx:a,item:o,matches:l})}),s}_findMatches({key:t,value:e,searcher:i}){if(!de(e))return[];let r=[];if(li(e))e.forEach(({v:s,i:o,n:a})=>{if(!de(s))return;const{isMatch:l,score:c,indices:h}=i.searchIn(s);l&&r.push({score:c,key:t,value:s,idx:o,norm:a,indices:h})});else{const{v:s,n:o}=e,{isMatch:a,score:l,indices:c}=i.searchIn(s);a&&r.push({score:l,key:t,value:s,norm:o,indices:c})}return r}}Cr.version="7.0.0";Cr.createIndex=fh;Cr.parseIndex=ng;Cr.config=W;Cr.parseQuery=bh;yg(_g);var Og=function(){function n(t){this._haystack=[],this._fuseOptions=ie(ie({},t.fuseOptions),{keys:af([],t.searchFields),includeMatches:!0})}return n.prototype.index=function(t){this._haystack=t,this._fuse&&this._fuse.setCollection(t)},n.prototype.reset=function(){this._haystack=[],this._fuse=void 0},n.prototype.isEmptyIndex=function(){return!this._haystack.length},n.prototype.search=function(t){this._fuse||(this._fuse=new Cr(this._haystack,this._fuseOptions));var e=this._fuse.search(t);return e.map(function(i,r){return{item:i.item,score:i.score||0,rank:r+1}})},n}();function kg(n){return new Og(n)}var Dg=function(n){for(var t in n)if(Object.prototype.hasOwnProperty.call(n,t))return!1;return!0},po=function(n,t,e){var i=n.dataset,r=t.customProperties,s=t.labelClass,o=t.labelDescription;s&&(i.labelClass=zn(s).join(" ")),o&&(i.labelDescription=o),e&&r&&(typeof r=="string"?i.customProperties=r:typeof r=="object"&&!Dg(r)&&(i.customProperties=JSON.stringify(r)))},Fl=function(n,t,e){var i=t&&n.querySelector("label[for='".concat(t,"']")),r=i&&i.innerText;r&&e.setAttribute("aria-label",r)},Pg={containerOuter:function(n,t,e,i,r,s,o){var a=n.classNames.containerOuter,l=document.createElement("div");return G(l,a),l.dataset.type=s,t&&(l.dir=t),i&&(l.tabIndex=0),e&&(l.setAttribute("role",r?"combobox":"listbox"),r?l.setAttribute("aria-autocomplete","list"):o||Fl(this._docRoot,this.passedElement.element.id,l),l.setAttribute("aria-haspopup","true"),l.setAttribute("aria-expanded","false")),o&&l.setAttribute("aria-labelledby",o),l},containerInner:function(n){var t=n.classNames.containerInner,e=document.createElement("div");return G(e,t),e},itemList:function(n,t){var e=n.searchEnabled,i=n.classNames,r=i.list,s=i.listSingle,o=i.listItems,a=document.createElement("div");return G(a,r),G(a,t?s:o),this._isSelectElement&&e&&a.setAttribute("role","listbox"),a},placeholder:function(n,t){var e=n.allowHTML,i=n.classNames.placeholder,r=document.createElement("div");return G(r,i),Ue(r,e,t),r},item:function(n,t,e){var i=n.allowHTML,r=n.removeItemButtonAlignLeft,s=n.removeItemIconText,o=n.removeItemLabelText,a=n.classNames,l=a.item,c=a.button,h=a.highlightedState,u=a.itemSelectable,d=a.placeholder,p=Hi(t.value),f=document.createElement("div");if(G(f,l),t.labelClass){var g=document.createElement("span");Ue(g,i,t.label),G(g,t.labelClass),f.appendChild(g)}else Ue(f,i,t.label);if(f.dataset.item="",f.dataset.id=t.id,f.dataset.value=p,po(f,t,!0),(t.disabled||this.containerOuter.isDisabled)&&f.setAttribute("aria-disabled","true"),this._isSelectElement&&(f.setAttribute("aria-selected","true"),f.setAttribute("role","option")),t.placeholder&&(G(f,d),f.dataset.placeholder=""),G(f,t.highlighted?h:u),e){t.disabled&&Fe(f,u),f.dataset.deletable="";var m=document.createElement("button");m.type="button",G(m,c),Ue(m,!0,Wr(s,t.value));var v=Wr(o,t.value);v&&m.setAttribute("aria-label",v),m.dataset.button="",r?f.insertAdjacentElement("afterbegin",m):f.appendChild(m)}return f},choiceList:function(n,t){var e=n.classNames.list,i=document.createElement("div");return G(i,e),t||i.setAttribute("aria-multiselectable","true"),i.setAttribute("role","listbox"),i},choiceGroup:function(n,t){var e=n.allowHTML,i=n.classNames,r=i.group,s=i.groupHeading,o=i.itemDisabled,a=t.id,l=t.label,c=t.disabled,h=Hi(l),u=document.createElement("div");G(u,r),c&&G(u,o),u.setAttribute("role","group"),u.dataset.group="",u.dataset.id=a,u.dataset.value=h,c&&u.setAttribute("aria-disabled","true");var d=document.createElement("div");return G(d,s),Ue(d,e,l||""),u.appendChild(d),u},choice:function(n,t,e,i){var r=n.allowHTML,s=n.classNames,o=s.item,a=s.itemChoice,l=s.itemSelectable,c=s.selectedState,h=s.itemDisabled,u=s.description,d=s.placeholder,p=t.label,f=Hi(t.value),g=document.createElement("div");g.id=t.elementId,G(g,o),G(g,a),i&&typeof p=="string"&&(p=_a(r,p),p+=" (".concat(i,")"),p={trusted:p});var m=g;if(t.labelClass){var v=document.createElement("span");Ue(v,r,p),G(v,t.labelClass),m=v,g.appendChild(v)}else Ue(g,r,p);if(t.labelDescription){var y="".concat(t.elementId,"-description");m.setAttribute("aria-describedby",y);var x=document.createElement("span");Ue(x,r,t.labelDescription),x.id=y,G(x,u),g.appendChild(x)}return t.selected&&G(g,c),t.placeholder&&G(g,d),g.setAttribute("role",t.group?"treeitem":"option"),g.dataset.choice="",g.dataset.id=t.id,g.dataset.value=f,e&&(g.dataset.selectText=e),t.group&&(g.dataset.groupId="".concat(t.group.id)),po(g,t,!1),t.disabled?(G(g,h),g.dataset.choiceDisabled="",g.setAttribute("aria-disabled","true")):(G(g,l),g.dataset.choiceSelectable=""),g},input:function(n,t){var e=n.classNames,i=e.input,r=e.inputCloned,s=n.labelId,o=document.createElement("input");return o.type="search",G(o,i),G(o,r),o.autocomplete="off",o.autocapitalize="off",o.spellcheck=!1,o.setAttribute("role","textbox"),o.setAttribute("aria-autocomplete","list"),t?o.setAttribute("aria-label",t):s||Fl(this._docRoot,this.passedElement.element.id,o),o},dropdown:function(n){var t=n.classNames,e=t.list,i=t.listDropdown,r=document.createElement("div");return G(r,e),G(r,i),r.setAttribute("aria-expanded","false"),r},notice:function(n,t,e){var i=n.classNames,r=i.item,s=i.itemChoice,o=i.addChoice,a=i.noResults,l=i.noChoices,c=i.notice;e===void 0&&(e=Gt.generic);var h=document.createElement("div");switch(Ue(h,!0,t),G(h,r),G(h,s),G(h,c),e){case Gt.addChoice:G(h,o);break;case Gt.noResults:G(h,a);break;case Gt.noChoices:G(h,l);break}return e===Gt.addChoice&&(h.dataset.choiceSelectable="",h.dataset.choice=""),h},option:function(n){var t=Hi(n.label),e=new Option(t,n.value,!1,n.selected);return po(e,n,!0),e.disabled=n.disabled,n.selected&&e.setAttribute("selected",""),e}},Ag="-ms-scroll-limit"in document.documentElement.style&&"-ms-ime-align"in document.documentElement.style,Mg={},fo=function(n){if(n)return n.dataset.id?parseInt(n.dataset.id,10):void 0},Ar="[data-choice-selectable]",_h=function(){function n(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 r=n.defaults;this.config=ie(ie(ie({},r.allOptions),r.options),e),lf.forEach(function(v){i.config[v]=ie(ie(ie({},r.allOptions[v]),r.options[v]),e[v])});var s=this.config;s.silent||this._validateConfig();var o=s.shadowRoot||document.documentElement;this._docRoot=o;var a=typeof t=="string"?o.querySelector(t):t;if(!a||typeof a!="object"||!(Pf(a)||ch(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===vi.Text;(c||s.maxItemCount!==1)&&(s.singleModeForMultiSelect=!1),s.singleModeForMultiSelect&&(l=vi.SelectMultiple);var h=l===vi.SelectOne,u=l===vi.SelectMultiple,d=h||u;if(this._elementType=l,this._isTextElement=c,this._isSelectOneElement=h,this._isSelectMultipleElement=u,this._isSelectElement=h||u,this._canAddUserChoices=c&&s.addItems||d&&s.addChoices,typeof s.renderSelectedChoices!="boolean"&&(s.renderSelectedChoices=s.renderSelectedChoices==="always"||h),s.closeDropdownOnSelect==="auto"?s.closeDropdownOnSelect=c||h||s.singleModeForMultiSelect:s.closeDropdownOnSelect=Nr(s.closeDropdownOnSelect),s.placeholder&&(s.placeholderValue?this._hasNonChoicePlaceholder=!0:a.dataset.placeholder&&(this._hasNonChoicePlaceholder=!0,s.placeholderValue=a.dataset.placeholder)),e.addItemFilter&&typeof e.addItemFilter!="function"){var p=e.addItemFilter instanceof RegExp?e.addItemFilter:new RegExp(e.addItemFilter);s.addItemFilter=p.test.bind(p)}if(this._isTextElement)this.passedElement=new Df({element:a,classNames:s.classNames});else{var f=a;this.passedElement=new If({element:f,classNames:s.classNames,template:function(v){return i._templates.option(v)},extractPlaceholder:s.placeholder&&!this._hasNonChoicePlaceholder})}if(this.initialised=!1,this._store=new Bf(s),this._currentValue="",s.searchEnabled=!c&&s.searchEnabled||u,this._canSearch=s.searchEnabled,this._isScrollingOnIe=!1,this._highlightPosition=0,this._wasTap=!0,this._placeholderValue=this._generatePlaceholderValue(),this._baseId=gf(a,"choices-"),this._direction=a.dir,!this._direction){var g=window.getComputedStyle(a).direction,m=window.getComputedStyle(document.documentElement).direction;g!==m&&(this._direction=g)}if(this._idNames={itemChoice:"item-choice"},this._templates=r.templates,this._render=this._render.bind(this),this._onFocus=this._onFocus.bind(this),this._onBlur=this._onBlur.bind(this),this._onKeyUp=this._onKeyUp.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onInput=this._onInput.bind(this),this._onClick=this._onClick.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onFormReset=this._onFormReset.bind(this),this._onSelectKey=this._onSelectKey.bind(this),this._onEnterKey=this._onEnterKey.bind(this),this._onEscapeKey=this._onEscapeKey.bind(this),this._onDirectionKey=this._onDirectionKey.bind(this),this._onDeleteKey=this._onDeleteKey.bind(this),this.passedElement.isActive){s.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(v){return v.value})}return Object.defineProperty(n,"defaults",{get:function(){return Object.preventExtensions({get options(){return Mg},get allOptions(){return El},get templates(){return Pg}})},enumerable:!1,configurable:!0}),n.prototype.init=function(){if(!(this.initialised||this.initialisedOK!==void 0)){this._searcher=kg(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)}},n.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=n.defaults.templates,this.initialised=!1,this.initialisedOK=void 0)},n.prototype.enable=function(){return this.passedElement.isDisabled&&this.passedElement.enable(),this.containerOuter.isDisabled&&(this._addEventListeners(),this.input.enable(),this.containerOuter.enable()),this},n.prototype.disable=function(){return this.passedElement.isDisabled||this.passedElement.disable(),this.containerOuter.isDisabled||(this._removeEventListeners(),this.input.disable(),this.containerOuter.disable()),this},n.prototype.highlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(r){return r.id===t.id});return!i||i.highlighted?this:(this._store.dispatch(qs(i,!0)),e&&this.passedElement.triggerEvent(ee.highlightItem,this._getChoiceForOutput(i)),this)},n.prototype.unhighlightItem=function(t,e){if(e===void 0&&(e=!0),!t||!t.id)return this;var i=this._store.items.find(function(r){return r.id===t.id});return!i||!i.highlighted?this:(this._store.dispatch(qs(i,!1)),e&&this.passedElement.triggerEvent(ee.unhighlightItem,this._getChoiceForOutput(i)),this)},n.prototype.highlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted||(t._store.dispatch(qs(e,!0)),t.passedElement.triggerEvent(ee.highlightItem,t._getChoiceForOutput(e)))})}),this},n.prototype.unhighlightAll=function(){var t=this;return this._store.withTxn(function(){t._store.items.forEach(function(e){e.highlighted&&(t._store.dispatch(qs(e,!1)),t.passedElement.triggerEvent(ee.highlightItem,t._getChoiceForOutput(e)))})}),this},n.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},n.prototype.removeActiveItems=function(t){var e=this;return this._store.withTxn(function(){e._store.items.filter(function(i){var r=i.id;return r!==t}).forEach(function(i){return e._removeItem(i)})}),this},n.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},n.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(ee.showDropdown)}),this)},n.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(ee.hideDropdown)}),this):this},n.prototype.getValue=function(t){var e=this,i=this._store.items.map(function(r){return t?r.value:e._getChoiceForOutput(r)});return this._isSelectOneElement||this.config.singleModeForMultiSelect?i[0]:i},n.prototype.setValue=function(t){var e=this;return this.initialisedOK?(this._store.withTxn(function(){t.forEach(function(i){i&&e._addChoice(Ie(i,!1))})}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setValue"),this)},n.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(r){return e._findAndSelectChoiceByValue(r)}),e.unhighlightAll()}),this._searcher.reset(),this):(this._warnChoicesInitFailed("setChoiceByValue"),this)},n.prototype.setChoices=function(t,e,i,r,s){var o=this;if(t===void 0&&(t=[]),e===void 0&&(e="value"),i===void 0&&(i="label"),r===void 0&&(r=!1),s===void 0&&(s=!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(r&&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 o._handleLoadingState(!0)}).then(function(){return a}).then(function(l){return o.setChoices(l,e,i,r)}).catch(function(l){o.config.silent||console.error(l)}).then(function(){return o._handleLoadingState(!1)}).then(function(){return o});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(){s&&(o._isSearching=!1);var l=e==="value",c=i==="label";t.forEach(function(h){if("choices"in h){var u=h;c||(u=ie(ie({},u),{label:u[i]})),o._addGroup(Ie(u,!0))}else{var d=h;(!c||!l)&&(d=ie(ie({},d),{value:d[e],label:d[i]})),o._addChoice(Ie(d,!1))}}),o.unhighlightAll()}),this._searcher.reset(),this},n.prototype.refresh=function(t,e,i){var r=this;return t===void 0&&(t=!1),e===void 0&&(e=!1),i===void 0&&(i=!1),this._isSelectElement?(this._store.withTxn(function(){var s=r.passedElement.optionsAsChoices(),o={};i||r._store.items.forEach(function(l){l.id&&l.active&&l.selected&&!l.disabled&&(o[l.value]=!0)}),r.clearStore(!1);var a=function(l){i?r._store.dispatch(xl(l)):o[l.value]&&(l.selected=!0)};s.forEach(function(l){if("choices"in l){l.choices.forEach(a);return}a(l)}),r._addPredefinedChoices(s,e,t),r._isSearching&&r._searchChoices(r.input.value)}),this):(this.config.silent||console.warn("refresh method can only be used on choices backed by a <select> element"),this)},n.prototype.removeChoice=function(t){var e=this._store.choices.find(function(i){return i.value===t});return e?(this._clearNotice(),this._store.dispatch(yl(e)),this._searcher.reset(),e.selected&&this.passedElement.triggerEvent(ee.removeItem,this._getChoiceForOutput(e)),this):this},n.prototype.clearChoices=function(){var t=this;return this._store.withTxn(function(){t._store.choices.forEach(function(e){e.selected||t._store.dispatch(yl(e))})}),this._searcher.reset(),this},n.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},n.prototype.clearInput=function(){var t=!this._isSelectOneElement;return this.input.clear(t),this._stopSearch(),this},n.prototype._validateConfig=function(){var t=this.config,e=Cf(t,El);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"))},n.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())},n.prototype._renderChoices=function(){var t=this;if(this._canAddItems()){var e=this,i=e.config,r=e._isSearching,s=this._store,o=s.activeGroups,a=s.activeChoices,l=0;if(r&&i.searchResultLimit>0?l=i.searchResultLimit:i.renderChoiceLimit>0&&(l=i.renderChoiceLimit),this._isSelectElement){var c=a.filter(function(f){return!f.element});c.length&&this.passedElement.addOptions(c)}var h=document.createDocumentFragment(),u=function(f){return f.filter(function(g){return!g.placeholder&&(r?!!g.rank:i.renderSelectedChoices||!g.selected)})},d=!1,p=function(f,g,m){r?f.sort(xf):i.shouldSort&&f.sort(i.sorter);var v=f.length;v=!g&&l&&v>l?l:v,v--,f.every(function(y,x){var T=y.choiceEl||t._templates.choice(i,y,i.itemSelectText,m);return y.choiceEl=T,h.appendChild(T),!y.disabled&&(r||!y.selected)&&(d=!0),x<v})};a.length&&(i.resetScrollPosition&&requestAnimationFrame(function(){return t.choiceList.scrollToTop()}),!this._hasNonChoicePlaceholder&&!r&&this._isSelectOneElement&&p(a.filter(function(f){return f.placeholder&&!f.group}),!1,void 0),o.length&&!r?(i.shouldSort&&o.sort(i.sorter),p(a.filter(function(f){return!f.placeholder&&!f.group}),!1,void 0),o.forEach(function(f){var g=u(f.choices);if(g.length){if(f.label){var m=f.groupEl||t._templates.choiceGroup(t.config,f);f.groupEl=m,m.remove(),h.appendChild(m)}p(g,!0,i.appendGroupInSearch&&r?f.label:void 0)}})):p(u(a),!1,void 0)),d||(this._notice||(this._notice={text:Cl(r?i.noResultsText:i.noChoicesText),type:r?Gt.noResults:Gt.noChoices}),h.replaceChildren("")),this._renderNotice(h),this.choiceList.element.replaceChildren(h),d&&this._highlightChoice()}},n.prototype._renderItems=function(){var t=this,e=this._store.items||[],i=this.itemList.element,r=this.config,s=document.createDocumentFragment(),o=function(u){return i.querySelector('[data-item][data-id="'.concat(u.id,'"]'))},a=function(u){var d=u.itemEl;d&&d.parentElement||(d=o(u)||t._templates.item(r,u,r.removeItemButton),u.itemEl=d,s.appendChild(d))};e.forEach(a);var l=!!s.childNodes.length;if(this._isSelectOneElement&&this._hasNonChoicePlaceholder){var c=i.children.length;if(l||c>1){var h=i.querySelector(Pr(r.classNames.placeholder));h&&h.remove()}else c||(l=!0,a(Ie({selected:!0,value:"",label:r.placeholderValue||"",placeholder:!0},!1)))}l&&(i.append(s),r.shouldSortItems&&!this._isSelectOneElement&&(e.sort(r.sorter),e.forEach(function(u){var d=o(u);d&&(d.remove(),s.append(d))}),i.append(s))),this._isTextElement&&(this.passedElement.value=e.map(function(u){var d=u.value;return d}).join(r.delimiter))},n.prototype._displayNotice=function(t,e,i){i===void 0&&(i=!0);var r=this._notice;if(r&&(r.type===e&&r.text===t||r.type===Gt.addChoice&&(e===Gt.noResults||e===Gt.noChoices))){i&&this.showDropdown(!0);return}this._clearNotice(),this._notice=t?{text:t,type:e}:void 0,this._renderNotice(),i&&t&&this.showDropdown(!0)},n.prototype._clearNotice=function(){if(this._notice){var t=this.choiceList.element.querySelector(Pr(this.config.classNames.notice));t&&t.remove(),this._notice=void 0}},n.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)}},n.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}},n.prototype._triggerChange=function(t){t!=null&&this.passedElement.triggerEvent(ee.change,{value:t})},n.prototype._handleButtonAction=function(t){var e=this,i=this._store.items;if(!(!i.length||!this.config.removeItems||!this.config.removeItemButton)){var r=t&&fo(t.parentElement),s=r&&i.find(function(o){return o.id===r});s&&this._store.withTxn(function(){if(e._removeItem(s),e._triggerChange(s.value),e._isSelectOneElement&&!e._hasNonChoicePlaceholder){var o=e._store.choices.reverse().find(function(a){return!a.disabled&&a.placeholder});o&&(e._addItem(o),e.unhighlightAll(),o.value&&e._triggerChange(o.value))}})}},n.prototype._handleItemAction=function(t,e){var i=this;e===void 0&&(e=!1);var r=this._store.items;if(!(!r.length||!this.config.removeItems||this._isSelectOneElement)){var s=fo(t);s&&(r.forEach(function(o){o.id===s&&!o.highlighted?i.highlightItem(o):!e&&o.highlighted&&i.unhighlightItem(o)}),this.input.focus())}},n.prototype._handleChoiceAction=function(t){var e=this,i=fo(t),r=i&&this._store.getChoiceById(i);if(!r||r.disabled)return!1;var s=this.dropdown.isActive;if(!r.selected){if(!this._canAddItems())return!0;this._store.withTxn(function(){e._addItem(r,!0,!0),e.clearInput(),e.unhighlightAll()}),this._triggerChange(r.value)}return s&&this.config.closeDropdownOnSelect&&(this.hideDropdown(!0),this.containerOuter.element.focus()),!0},n.prototype._handleBackspace=function(t){var e=this.config;if(!(!e.removeItems||!t.length)){var i=t[t.length-1],r=t.some(function(s){return s.highlighted});e.editItems&&!r&&i?(this.input.value=i.value,this.input.setWidth(),this._removeItem(i),this._triggerChange(i.value)):(r||this.highlightItem(i,!1),this.removeHighlightedItems(!0))}},n.prototype._loadChoices=function(){var t,e=this,i=this.config;if(this._isTextElement){if(this._presetChoices=i.items.map(function(o){return Ie(o,!1)}),this.passedElement.value){var r=this.passedElement.value.split(i.delimiter).map(function(o){return Ie(o,!1,e.config.allowHtmlUserInput)});this._presetChoices=this._presetChoices.concat(r)}this._presetChoices.forEach(function(o){o.selected=!0})}else if(this._isSelectElement){this._presetChoices=i.choices.map(function(o){return Ie(o,!0)});var s=this.passedElement.optionsAsChoices();s&&(t=this._presetChoices).push.apply(t,s)}},n.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||"")},n.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(ee.search,{value:t,resultCount:e})}else this._store.choices.some(function(i){return!i.active})&&this._stopSearch()},n.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,Gt.addChoice),!1):!0},n.prototype._canCreateItem=function(t){var e=this.config,i=!0,r="";if(i&&typeof e.addItemFilter=="function"&&!e.addItemFilter(t)&&(i=!1,r=Wr(e.customAddItemText,t)),i){var s=this._store.choices.find(function(o){return e.valueComparer(o.value,t)});if(this._isSelectElement){if(s)return this._displayNotice("",Gt.addChoice),!1}else this._isTextElement&&!e.duplicateItemsAllowed&&s&&(i=!1,r=Wr(e.uniqueItemText,t))}return i&&(r=Wr(e.addItemText,t)),r&&this._displayNotice(r,Gt.addChoice),i},n.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 r=i.search(e);this._currentValue=e,this._highlightPosition=0,this._isSearching=!0;var s=this._notice,o=s&&s.type;return o!==Gt.addChoice&&(r.length?this._clearNotice():this._displayNotice(Cl(this.config.noResultsText),Gt.noResults)),this._store.dispatch(hf(r)),r.length},n.prototype._stopSearch=function(){this._isSearching&&(this._currentValue="",this._isSearching=!1,this._clearNotice(),this._store.dispatch(uf(!0)),this.passedElement.triggerEvent(ee.search,{value:"",resultCount:0}))},n.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()},n.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()},n.prototype._onKeyDown=function(t){var e=t.keyCode,i=this.dropdown.isActive,r=t.key.length===1||t.key.length===2&&t.key.charCodeAt(0)>=55296||t.key==="Unidentified";switch(!this._isTextElement&&!i&&e!==Wt.ESC_KEY&&e!==Wt.TAB_KEY&&e!==Wt.SHIFT_KEY&&(this.showDropdown(),!this.input.isFocussed&&r&&(this.input.value+=t.key,t.key===" "&&t.preventDefault())),e){case Wt.A_KEY:return this._onSelectKey(t,this.itemList.element.hasChildNodes());case Wt.ENTER_KEY:return this._onEnterKey(t,i);case Wt.ESC_KEY:return this._onEscapeKey(t,i);case Wt.UP_KEY:case Wt.PAGE_UP_KEY:case Wt.DOWN_KEY:case Wt.PAGE_DOWN_KEY:return this._onDirectionKey(t,i);case Wt.DELETE_KEY:case Wt.BACK_KEY:return this._onDeleteKey(t,this._store.items,this.input.isFocussed)}},n.prototype._onKeyUp=function(){this._canSearch=this.config.searchEnabled},n.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())))},n.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()}},n.prototype._onEnterKey=function(t,e){var i=this,r=this.input.value,s=t.target;if(t.preventDefault(),s&&s.hasAttribute("data-button")){this._handleButtonAction(s);return}if(!e){(this._isSelectElement||this._notice)&&this.showDropdown();return}var o=this.dropdown.element.querySelector(Pr(this.config.classNames.highlightedState));if(!(o&&this._handleChoiceAction(o))){if(!s||!r){this.hideDropdown(!0);return}if(this._canAddItems()){var a=!1;this._store.withTxn(function(){if(a=i._findAndSelectChoiceByValue(r,!0),!a){if(!i._canAddUserChoices||!i._canCreateItem(r))return;i._addChoice(Ie(r,!1,i.config.allowHtmlUserInput),!0,!0),a=!0}i.clearInput(),i.unhighlightAll()}),a&&(this._triggerChange(r),this.config.closeDropdownOnSelect&&this.hideDropdown(!0))}}},n.prototype._onEscapeKey=function(t,e){e&&(t.stopPropagation(),this.hideDropdown(!0),this._stopSearch(),this.containerOuter.element.focus())},n.prototype._onDirectionKey=function(t,e){var i=t.keyCode;if(e||this._isSelectOneElement){this.showDropdown(),this._canSearch=!1;var r=i===Wt.DOWN_KEY||i===Wt.PAGE_DOWN_KEY?1:-1,s=t.metaKey||i===Wt.PAGE_DOWN_KEY||i===Wt.PAGE_UP_KEY,o=void 0;if(s)r>0?o=this.dropdown.element.querySelector("".concat(Ar,":last-of-type")):o=this.dropdown.element.querySelector(Ar);else{var a=this.dropdown.element.querySelector(Pr(this.config.classNames.highlightedState));a?o=mf(a,Ar,r):o=this.dropdown.element.querySelector(Ar)}o&&(vf(o,this.choiceList.element,r)||this.choiceList.scrollToChildElement(o,r),this._highlightChoice(o)),t.preventDefault()}},n.prototype._onDeleteKey=function(t,e,i){!this._isSelectOneElement&&!t.target.value&&i&&(this._handleBackspace(e),t.preventDefault())},n.prototype._onTouchMove=function(){this._wasTap&&(this._wasTap=!1)},n.prototype._onTouchEnd=function(t){var e=(t||t.touches[0]).target,i=this._wasTap&&this.containerOuter.element.contains(e);if(i){var r=e===this.containerOuter.element||e===this.containerInner.element;r&&(this._isTextElement?this.input.focus():this._isSelectMultipleElement&&this.showDropdown()),t.stopPropagation()}this._wasTap=!0},n.prototype._onMouseDown=function(t){var e=t.target;if(e instanceof HTMLElement){if(Ag&&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 r=e.closest("[data-button],[data-item],[data-choice]");r instanceof HTMLElement&&("button"in r.dataset?this._handleButtonAction(r):"item"in r.dataset?this._handleItemAction(r,t.shiftKey):"choice"in r.dataset&&this._handleChoiceAction(r)),t.preventDefault()}}},n.prototype._onMouseOver=function(t){var e=t.target;e instanceof HTMLElement&&"choice"in e.dataset&&this._highlightChoice(e)},n.prototype._onClick=function(t){var e=t.target,i=this.containerOuter,r=i.element.contains(e);r?!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())},n.prototype._onFocus=function(t){var e=t.target,i=this.containerOuter,r=e&&i.element.contains(e);if(r){var s=e===this.input.element;this._isTextElement?s&&i.addFocusState():this._isSelectMultipleElement?s&&(this.showDropdown(!0),i.addFocusState()):(i.addFocusState(),s&&this.showDropdown(!0))}},n.prototype._onBlur=function(t){var e=t.target,i=this.containerOuter,r=e&&i.element.contains(e);r&&!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())},n.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)})},n.prototype._highlightChoice=function(t){t===void 0&&(t=null);var e=Array.from(this.dropdown.element.querySelectorAll(Ar));if(e.length){var i=t,r=this.config.classNames.highlightedState,s=Array.from(this.dropdown.element.querySelectorAll(Pr(r)));s.forEach(function(o){Fe(o,r),o.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])),G(i,r),i.setAttribute("aria-selected","true"),this.passedElement.triggerEvent(ee.highlightChoice,{el:i}),this.dropdown.isActive&&(this.input.setActiveDescendant(i.id),this.containerOuter.setActiveDescendant(i.id))}},n.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(pf(t)),e&&(this.passedElement.triggerEvent(ee.addItem,this._getChoiceForOutput(t)),i&&this.passedElement.triggerEvent(ee.choice,this._getChoiceForOutput(t)))},n.prototype._removeItem=function(t){if(t.id){this._store.dispatch(xl(t));var e=this._notice;e&&e.type===Gt.noChoices&&this._clearNotice(),this.passedElement.triggerEvent(ee.removeItem,this._getChoiceForOutput(t))}},n.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 r=this.config;if(!((this._isSelectElement||!r.duplicateItemsAllowed)&&this._store.choices.find(function(a){return r.valueComparer(a.value,t.value)}))){this._lastAddedChoiceId++,t.id=this._lastAddedChoiceId,t.elementId="".concat(this._baseId,"-").concat(this._idNames.itemChoice,"-").concat(t.id);var s=r.prependValue,o=r.appendValue;s&&(t.value=s+t.value),o&&(t.value+=o.toString()),(s||o)&&t.element&&(t.element.value=t.value),this._clearNotice(),this._store.dispatch(cf(t)),t.selected&&this._addItem(t,e,i)}},n.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(df(t)),t.choices&&(this._lastAddedGroupId++,t.id=this._lastAddedGroupId,t.choices.forEach(function(r){r.group=t,t.disabled&&(r.disabled=!0),i._addChoice(r,e)}))},n.prototype._createTemplates=function(){var t=this,e=this.config.callbackOnCreateTemplates,i={};typeof e=="function"&&(i=e.call(this,bf,_a,zn));var r={};Object.keys(this._templates).forEach(function(s){s in i?r[s]=i[s].bind(t):r[s]=t._templates[s].bind(t)}),this._templates=r},n.prototype._createElements=function(){var t=this._templates,e=this,i=e.config,r=e._isSelectOneElement,s=i.position,o=i.classNames,a=this._elementType;this.containerOuter=new Sl({element:t.containerOuter(i,this._direction,this._isSelectElement,r,i.searchEnabled,a,i.labelId),classNames:o,type:a,position:s}),this.containerInner=new Sl({element:t.containerInner(i),classNames:o,type:a,position:s}),this.input=new Of({element:t.input(i,this._placeholderValue),classNames:o,type:a,preventPaste:!i.paste}),this.choiceList=new Tl({element:t.choiceList(i,r)}),this.itemList=new Tl({element:t.itemList(i,r)}),this.dropdown=new Ef({element:t.dropdown(i),classNames:o,type:a})},n.prototype._createStructure=function(){var t=this,e=t.containerInner,i=t.containerOuter,r=t.passedElement,s=this.dropdown.element;r.conceal(),e.wrap(r.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(s),e.element.appendChild(this.itemList.element),s.appendChild(this.choiceList.element),this._isSelectOneElement?this.config.searchEnabled&&s.insertBefore(this.input.element,s.firstChild):e.element.appendChild(this.input.element),this._highlightPosition=0,this._isSearching=!1},n.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()},n.prototype._addPredefinedChoices=function(t,e,i){var r=this;if(e===void 0&&(e=!1),i===void 0&&(i=!0),e){var s=t.findIndex(function(o){return o.selected})===-1;s&&t.some(function(o){return o.disabled||"choices"in o?!1:(o.selected=!0,!0)})}t.forEach(function(o){"choices"in o?r._isSelectElement&&r._addGroup(o,i):r._addChoice(o,i)})},n.prototype._findAndSelectChoiceByValue=function(t,e){var i=this;e===void 0&&(e=!1);var r=this._store.choices.find(function(s){return i.config.valueComparer(s.value,t)});return r&&!r.disabled&&!r.selected?(this._addItem(r,!0,e),!0):!1},n.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},n.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"))},n.version="11.0.3",n}();const yh='.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 Ki{constructor(t,...e){this.slotNames=[],this.handleSlotChange=i=>{const r=i.target;(this.slotNames.includes("[default]")&&!r.name||r.name&&this.slotNames.includes(r.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)}}const ps=vt`
|
|
637
|
+
.form-control .form-control__label {
|
|
638
|
+
display: none;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.form-control .form-control__help-text {
|
|
642
|
+
display: none;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
/* Label */
|
|
646
|
+
.form-control--has-label .form-control__label {
|
|
647
|
+
display: inline-block;
|
|
648
|
+
color: var(--pbo-input-label-color);
|
|
649
|
+
margin-bottom: var(--pbo-spacing-2x-small);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
.form-control--has-label.form-control--small .form-control__label {
|
|
653
|
+
font-size: var(--pbo-input-label-font-size-small);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.form-control--has-label.form-control--medium .form-control__label {
|
|
657
|
+
font-size: var(--pbo-input-label-font-size-medium);
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
.form-control--has-label.form-control--large .form-control__label {
|
|
661
|
+
font-size: var(--pbo-input-label-font-size-large);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
:host([required]) .form-control--has-label .form-control__label::after {
|
|
665
|
+
content: var(--pbo-input-required-content);
|
|
666
|
+
margin-inline-start: var(--pbo-input-required-content-offset);
|
|
667
|
+
color: var(--pbo-input-required-content-color);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/* Help text */
|
|
671
|
+
.form-control--has-help-text .form-control__help-text {
|
|
672
|
+
display: block;
|
|
673
|
+
color: var(--pbo-input-help-text-color);
|
|
674
|
+
margin-top: var(--pbo-spacing-3x-small);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
.form-control--has-help-text.form-control--small .form-control__help-text {
|
|
678
|
+
font-size: var(--pbo-input-help-text-font-size-small);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.form-control--has-help-text.form-control--medium .form-control__help-text {
|
|
682
|
+
font-size: var(--pbo-input-help-text-font-size-medium);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.form-control--has-help-text.form-control--large .form-control__help-text {
|
|
686
|
+
font-size: var(--pbo-input-help-text-font-size-large);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.form-control--has-help-text.form-control--radio-group .form-control__help-text {
|
|
690
|
+
margin-top: var(--pbo-spacing-2x);
|
|
691
|
+
}
|
|
692
|
+
`;var Ig=Object.defineProperty,Lg=Object.getOwnPropertyDescriptor,qi=(n,t,e,i)=>{for(var r=i>1?void 0:i?Lg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Ig(t,e,r),r};let ze=class extends Xo{constructor(){super(...arguments),this.hasSlotController=new Ki(this,"help-text","label"),this.fonts=[{value:"comic",label:"🖊️ Comic Sans",font:"'Comic Sans MS', cursive"},{value:"times",label:"🔤 Times New Roman",font:"'Times New Roman', serif"},{value:"arial",label:"📜 Arial",font:"'Arial', sans-serif"},{value:"mono",label:"💻 Monospace",font:"'Courier New', monospace"}],this.disabled=!1,this.size="medium",this.label=""}get value(){var n;return(n=this._choices)==null?void 0:n.getValue().value}handleDisabledChanged(){var n;this._choices&&this.disabled?this._choices.disable():(n=this._choices)==null||n.enable()}firstUpdated(){this._initializeChoices(),this.handleDisabledChanged()}_initializeChoices(){var n;(n=this._choices)==null||n.destroy(),this._choices=new _h(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:r},s)=>{var a;const o=[i(r.item).join(" "),i(s.highlighted?r.highlightedState:r.itemSelectable).join(" ")].join(" ");return t(`
|
|
693
|
+
<div
|
|
694
|
+
class="${o}"
|
|
695
|
+
data-item
|
|
696
|
+
data-id="${s.id}"
|
|
697
|
+
data-value="${e(s.value)}"
|
|
698
|
+
${s.active?'aria-selected="true"':""}
|
|
699
|
+
${s.disabled?'aria-disabled="true"':""}
|
|
700
|
+
style="font-family: ${((a=s.customProperties)==null?void 0:a.font)||"inherit"}"
|
|
701
|
+
>
|
|
702
|
+
${s.label}
|
|
703
|
+
</div>
|
|
704
|
+
`)},choice:({classNames:r},s)=>{var a;const o=[i(r.item).join(" "),i(r.itemChoice).join(" "),i(s.disabled?r.itemDisabled:r.itemSelectable).join(" ")].join(" ");return t(`
|
|
705
|
+
<div class="${o}"
|
|
706
|
+
data-select-text="${this.config.itemSelectText}"
|
|
707
|
+
data-choice ${s.disabled?'data-choice-disabled aria-disabled="true"':"data-choice-selectable"}
|
|
708
|
+
data-id="${s.id}"
|
|
709
|
+
data-value="${e(s.value)}"
|
|
710
|
+
${s.groupId>0?'role="treeitem"':'role="option"'}
|
|
711
|
+
style="font-family: ${((a=s.customProperties)==null?void 0:a.font)||"inherit"}"
|
|
712
|
+
>
|
|
713
|
+
${s.label}
|
|
714
|
+
</div>
|
|
715
|
+
`)}}}}),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 n=this.hasSlotController.test("label"),t=this.label?!0:!!n;return X` <div
|
|
716
|
+
class=${ni({"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})}
|
|
717
|
+
>
|
|
718
|
+
<label
|
|
719
|
+
part="form-control-label"
|
|
720
|
+
id="label"
|
|
721
|
+
class="form-control__label"
|
|
722
|
+
aria-hidden=${t?"false":"true"}
|
|
723
|
+
>
|
|
724
|
+
<slot name="label">${this.label}</slot>
|
|
725
|
+
</label>
|
|
726
|
+
</div>
|
|
727
|
+
<select part="base" class="js-choice"></select>`}};ze.styles=[Pt,of,ps,kn(yh)];qi([O({type:Array})],ze.prototype,"fonts",2);qi([O({type:Boolean,reflect:!0})],ze.prototype,"disabled",2);qi([O()],ze.prototype,"size",2);qi([O()],ze.prototype,"label",2);qi([q(".js-choice")],ze.prototype,"choiceEl",2);qi([et("disabled",{waitUntilFirstUpdate:!0})],ze.prototype,"handleDisabledChanged",1);ze=qi([Ot("pbo-selector")],ze);const xh=vt`
|
|
728
|
+
:host {
|
|
729
|
+
display: inline-block;
|
|
730
|
+
position: relative;
|
|
731
|
+
width: auto;
|
|
732
|
+
cursor: pointer;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
.button {
|
|
736
|
+
display: inline-flex;
|
|
737
|
+
align-items: stretch;
|
|
738
|
+
justify-content: center;
|
|
739
|
+
width: 100%;
|
|
740
|
+
border-style: solid;
|
|
741
|
+
border-width: var(--pbo-input-border-width);
|
|
742
|
+
font-family: var(--pbo-input-font-family);
|
|
743
|
+
font-weight: var(--pbo-font-weight-semibold);
|
|
744
|
+
text-decoration: none;
|
|
745
|
+
user-select: none;
|
|
746
|
+
-webkit-user-select: none;
|
|
747
|
+
white-space: nowrap;
|
|
748
|
+
vertical-align: middle;
|
|
749
|
+
padding: 0;
|
|
750
|
+
transition:
|
|
751
|
+
var(--pbo-transition-x-fast) background-color,
|
|
752
|
+
var(--pbo-transition-x-fast) color,
|
|
753
|
+
var(--pbo-transition-x-fast) border,
|
|
754
|
+
var(--pbo-transition-x-fast) box-shadow;
|
|
755
|
+
cursor: inherit;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
.button::-moz-focus-inner {
|
|
759
|
+
border: 0;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
.button:focus {
|
|
763
|
+
outline: none;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
.button:focus-visible {
|
|
767
|
+
outline: var(--pbo-focus-ring);
|
|
768
|
+
outline-offset: var(--pbo-focus-ring-offset);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.button--disabled {
|
|
772
|
+
opacity: 0.5;
|
|
773
|
+
cursor: not-allowed;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/* When disabled, prevent mouse events from bubbling up from children */
|
|
777
|
+
.button--disabled * {
|
|
778
|
+
pointer-events: none;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
.button__prefix,
|
|
782
|
+
.button__suffix {
|
|
783
|
+
flex: 0 0 auto;
|
|
784
|
+
display: flex;
|
|
785
|
+
align-items: center;
|
|
786
|
+
pointer-events: none;
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.button__label {
|
|
790
|
+
display: inline-block;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/*
|
|
794
|
+
* Standard buttons
|
|
795
|
+
*/
|
|
796
|
+
|
|
797
|
+
/* Default */
|
|
798
|
+
.button--standard.button--default {
|
|
799
|
+
background-color: var(--pbo-color-neutral-0);
|
|
800
|
+
border-color: var(--pbo-input-border-color);
|
|
801
|
+
color: var(--pbo-color-neutral-700);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
.button--standard.button--default:hover:not(.button--disabled) {
|
|
805
|
+
background-color: var(--pbo-color-primary-50);
|
|
806
|
+
border-color: var(--pbo-color-primary-300);
|
|
807
|
+
color: var(--pbo-color-primary-700);
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
.button--standard.button--default:active:not(.button--disabled) {
|
|
811
|
+
background-color: var(--pbo-color-primary-100);
|
|
812
|
+
border-color: var(--pbo-color-primary-400);
|
|
813
|
+
color: var(--pbo-color-primary-700);
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
/* Primary */
|
|
817
|
+
.button--standard.button--primary {
|
|
818
|
+
background-color: #0d6efd;
|
|
819
|
+
border-color: #0d6efd;
|
|
820
|
+
color: var(--pbo-color-neutral-0);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
.button--standard.button--primary:hover:not(.button--disabled) {
|
|
824
|
+
background-color: #0b5ed7;
|
|
825
|
+
border-color: #0b5ed7;
|
|
826
|
+
color: var(--pbo-color-neutral-0);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
.button--standard.button--primary:active:not(.button--disabled) {
|
|
830
|
+
background-color: var(--pbo-color-primary-600);
|
|
831
|
+
border-color: var(--pbo-color-primary-600);
|
|
832
|
+
color: var(--pbo-color-neutral-0);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/* Success */
|
|
836
|
+
.button--standard.button--success {
|
|
837
|
+
background-color: var(--pbo-color-success-600);
|
|
838
|
+
border-color: var(--pbo-color-success-600);
|
|
839
|
+
color: var(--pbo-color-neutral-0);
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
.button--standard.button--success:hover:not(.button--disabled) {
|
|
843
|
+
background-color: var(--pbo-color-success-500);
|
|
844
|
+
border-color: var(--pbo-color-success-500);
|
|
845
|
+
color: var(--pbo-color-neutral-0);
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
.button--standard.button--success:active:not(.button--disabled) {
|
|
849
|
+
background-color: var(--pbo-color-success-600);
|
|
850
|
+
border-color: var(--pbo-color-success-600);
|
|
851
|
+
color: var(--pbo-color-neutral-0);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
/* Neutral */
|
|
855
|
+
.button--standard.button--neutral {
|
|
856
|
+
background-color: var(--pbo-color-neutral-600);
|
|
857
|
+
border-color: var(--pbo-color-neutral-600);
|
|
858
|
+
color: var(--pbo-color-neutral-0);
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
.button--standard.button--neutral:hover:not(.button--disabled) {
|
|
862
|
+
background-color: var(--pbo-color-neutral-500);
|
|
863
|
+
border-color: var(--pbo-color-neutral-500);
|
|
864
|
+
color: var(--pbo-color-neutral-0);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
.button--standard.button--neutral:active:not(.button--disabled) {
|
|
868
|
+
background-color: var(--pbo-color-neutral-600);
|
|
869
|
+
border-color: var(--pbo-color-neutral-600);
|
|
870
|
+
color: var(--pbo-color-neutral-0);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
/* Warning */
|
|
874
|
+
.button--standard.button--warning {
|
|
875
|
+
background-color: var(--pbo-color-warning-600);
|
|
876
|
+
border-color: var(--pbo-color-warning-600);
|
|
877
|
+
color: var(--pbo-color-neutral-0);
|
|
878
|
+
}
|
|
879
|
+
.button--standard.button--warning:hover:not(.button--disabled) {
|
|
880
|
+
background-color: var(--pbo-color-warning-500);
|
|
881
|
+
border-color: var(--pbo-color-warning-500);
|
|
882
|
+
color: var(--pbo-color-neutral-0);
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
.button--standard.button--warning:active:not(.button--disabled) {
|
|
886
|
+
background-color: var(--pbo-color-warning-600);
|
|
887
|
+
border-color: var(--pbo-color-warning-600);
|
|
888
|
+
color: var(--pbo-color-neutral-0);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/* Danger */
|
|
892
|
+
.button--standard.button--danger {
|
|
893
|
+
background-color: #fb2c36;
|
|
894
|
+
border-color: #fb2c36;
|
|
895
|
+
color: var(--pbo-color-neutral-0);
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
.button--standard.button--danger:hover:not(.button--disabled) {
|
|
899
|
+
background-color: #e7000b;
|
|
900
|
+
border-color: #e7000b;
|
|
901
|
+
color: var(--pbo-color-neutral-0);
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
.button--standard.button--danger:active:not(.button--disabled) {
|
|
905
|
+
background-color: #e7000b;
|
|
906
|
+
border-color: #e7000b;
|
|
907
|
+
color: var(--pbo-color-neutral-0);
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
/*
|
|
911
|
+
* Outline buttons
|
|
912
|
+
*/
|
|
913
|
+
|
|
914
|
+
.button--outline {
|
|
915
|
+
background: none;
|
|
916
|
+
border: solid 1px;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/* Default */
|
|
920
|
+
.button--outline.button--default {
|
|
921
|
+
border-color: var(--pbo-input-border-color);
|
|
922
|
+
color: var(--pbo-color-neutral-700);
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
.button--outline.button--default:hover:not(.button--disabled),
|
|
926
|
+
.button--outline.button--default.button--checked:not(.button--disabled) {
|
|
927
|
+
border-color: var(--pbo-color-primary-600);
|
|
928
|
+
background-color: var(--pbo-color-primary-600);
|
|
929
|
+
color: var(--pbo-color-neutral-0);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
.button--outline.button--default:active:not(.button--disabled) {
|
|
933
|
+
border-color: var(--pbo-color-primary-700);
|
|
934
|
+
background-color: var(--pbo-color-primary-700);
|
|
935
|
+
color: var(--pbo-color-neutral-0);
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
/* Primary */
|
|
939
|
+
.button--outline.button--primary {
|
|
940
|
+
border-color: var(--pbo-color-primary-600);
|
|
941
|
+
color: var(--pbo-color-primary-600);
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
.button--outline.button--primary:hover:not(.button--disabled),
|
|
945
|
+
.button--outline.button--primary.button--checked:not(.button--disabled) {
|
|
946
|
+
background-color: var(--pbo-color-primary-600);
|
|
947
|
+
color: var(--pbo-color-neutral-0);
|
|
948
|
+
}
|
|
949
|
+
|
|
950
|
+
.button--outline.button--primary:active:not(.button--disabled) {
|
|
951
|
+
border-color: var(--pbo-color-primary-700);
|
|
952
|
+
background-color: var(--pbo-color-primary-700);
|
|
953
|
+
color: var(--pbo-color-neutral-0);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
/* Success */
|
|
957
|
+
.button--outline.button--success {
|
|
958
|
+
border-color: var(--pbo-color-success-600);
|
|
959
|
+
color: var(--pbo-color-success-600);
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
.button--outline.button--success:hover:not(.button--disabled),
|
|
963
|
+
.button--outline.button--success.button--checked:not(.button--disabled) {
|
|
964
|
+
background-color: var(--pbo-color-success-600);
|
|
965
|
+
color: var(--pbo-color-neutral-0);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
.button--outline.button--success:active:not(.button--disabled) {
|
|
969
|
+
border-color: var(--pbo-color-success-700);
|
|
970
|
+
background-color: var(--pbo-color-success-700);
|
|
971
|
+
color: var(--pbo-color-neutral-0);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/* Neutral */
|
|
975
|
+
.button--outline.button--neutral {
|
|
976
|
+
border-color: var(--pbo-color-neutral-600);
|
|
977
|
+
color: var(--pbo-color-neutral-600);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
.button--outline.button--neutral:hover:not(.button--disabled),
|
|
981
|
+
.button--outline.button--neutral.button--checked:not(.button--disabled) {
|
|
982
|
+
background-color: var(--pbo-color-neutral-600);
|
|
983
|
+
color: var(--pbo-color-neutral-0);
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
.button--outline.button--neutral:active:not(.button--disabled) {
|
|
987
|
+
border-color: var(--pbo-color-neutral-700);
|
|
988
|
+
background-color: var(--pbo-color-neutral-700);
|
|
989
|
+
color: var(--pbo-color-neutral-0);
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/* Warning */
|
|
993
|
+
.button--outline.button--warning {
|
|
994
|
+
border-color: var(--pbo-color-warning-600);
|
|
995
|
+
color: var(--pbo-color-warning-600);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
.button--outline.button--warning:hover:not(.button--disabled),
|
|
999
|
+
.button--outline.button--warning.button--checked:not(.button--disabled) {
|
|
1000
|
+
background-color: var(--pbo-color-warning-600);
|
|
1001
|
+
color: var(--pbo-color-neutral-0);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
.button--outline.button--warning:active:not(.button--disabled) {
|
|
1005
|
+
border-color: var(--pbo-color-warning-700);
|
|
1006
|
+
background-color: var(--pbo-color-warning-700);
|
|
1007
|
+
color: var(--pbo-color-neutral-0);
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
/* Danger */
|
|
1011
|
+
.button--outline.button--danger {
|
|
1012
|
+
border-color: var(--pbo-color-danger-600);
|
|
1013
|
+
color: var(--pbo-color-danger-600);
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
.button--outline.button--danger:hover:not(.button--disabled),
|
|
1017
|
+
.button--outline.button--danger.button--checked:not(.button--disabled) {
|
|
1018
|
+
background-color: var(--pbo-color-danger-600);
|
|
1019
|
+
color: var(--pbo-color-neutral-0);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
.button--outline.button--danger:active:not(.button--disabled) {
|
|
1023
|
+
border-color: var(--pbo-color-danger-700);
|
|
1024
|
+
background-color: var(--pbo-color-danger-700);
|
|
1025
|
+
color: var(--pbo-color-neutral-0);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
@media (forced-colors: active) {
|
|
1029
|
+
.button.button--outline.button--checked:not(.button--disabled) {
|
|
1030
|
+
outline: solid 2px transparent;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/*
|
|
1035
|
+
* Text buttons
|
|
1036
|
+
*/
|
|
1037
|
+
|
|
1038
|
+
.button--text {
|
|
1039
|
+
background-color: transparent;
|
|
1040
|
+
border-color: transparent;
|
|
1041
|
+
color: var(--pbo-color-primary-600);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.button--text:hover:not(.button--disabled) {
|
|
1045
|
+
background-color: transparent;
|
|
1046
|
+
border-color: transparent;
|
|
1047
|
+
color: var(--pbo-color-primary-500);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
.button--text:focus-visible:not(.button--disabled) {
|
|
1051
|
+
background-color: transparent;
|
|
1052
|
+
border-color: transparent;
|
|
1053
|
+
color: var(--pbo-color-primary-500);
|
|
1054
|
+
}
|
|
1055
|
+
|
|
1056
|
+
.button--text:active:not(.button--disabled) {
|
|
1057
|
+
background-color: transparent;
|
|
1058
|
+
border-color: transparent;
|
|
1059
|
+
color: var(--pbo-color-primary-700);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/*
|
|
1063
|
+
* Size modifiers
|
|
1064
|
+
*/
|
|
1065
|
+
|
|
1066
|
+
.button--small {
|
|
1067
|
+
height: auto;
|
|
1068
|
+
min-height: var(--pbo-input-height-small);
|
|
1069
|
+
font-size: var(--pbo-button-font-size-small);
|
|
1070
|
+
line-height: calc(var(--pbo-input-height-small) - var(--pbo-input-border-width) * 2);
|
|
1071
|
+
border-radius: var(--pbo-input-border-radius-small);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
.button--medium {
|
|
1075
|
+
height: auto;
|
|
1076
|
+
min-height: var(--pbo-input-height-medium);
|
|
1077
|
+
font-size: var(--pbo-button-font-size-medium);
|
|
1078
|
+
line-height: calc(var(--pbo-input-height-medium) - var(--pbo-input-border-width) * 2);
|
|
1079
|
+
border-radius: var(--pbo-input-border-radius-medium);
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
.button--large {
|
|
1083
|
+
height: auto;
|
|
1084
|
+
min-height: var(--pbo-input-height-large);
|
|
1085
|
+
font-size: var(--pbo-button-font-size-large);
|
|
1086
|
+
line-height: calc(var(--pbo-input-height-large) - var(--pbo-input-border-width) * 2);
|
|
1087
|
+
border-radius: var(--pbo-input-border-radius-large);
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
/*
|
|
1091
|
+
* Pill modifier
|
|
1092
|
+
*/
|
|
1093
|
+
|
|
1094
|
+
.button--pill.button--small {
|
|
1095
|
+
border-radius: var(--pbo-input-height-small);
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
.button--pill.button--medium {
|
|
1099
|
+
border-radius: var(--pbo-input-height-medium);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
.button--pill.button--large {
|
|
1103
|
+
border-radius: var(--pbo-input-height-large);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
/*
|
|
1107
|
+
* Circle modifier
|
|
1108
|
+
*/
|
|
1109
|
+
|
|
1110
|
+
.button--circle {
|
|
1111
|
+
padding-left: 0;
|
|
1112
|
+
padding-right: 0;
|
|
1113
|
+
border-radius: 100%;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
.button--circle.button--small {
|
|
1117
|
+
width: var(--pbo-input-height-small);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
.button--circle.button--medium {
|
|
1121
|
+
width: var(--pbo-input-height-medium);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
.button--circle.button--large {
|
|
1125
|
+
width: var(--pbo-input-height-large);
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
.button--circle .button__prefix,
|
|
1129
|
+
.button--circle .button__suffix,
|
|
1130
|
+
.button--circle .button__caret {
|
|
1131
|
+
display: none;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/*
|
|
1135
|
+
* Color block modifier
|
|
1136
|
+
*/
|
|
1137
|
+
|
|
1138
|
+
.button--outline.button--default.button--color-block {
|
|
1139
|
+
border-color: var(--pbo-color-gray-300);
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
.button--outline.button--default:hover:not(.button--disabled).button--color-block,
|
|
1143
|
+
.button--outline.button--default.button--checked:not(.button--disabled).button--color-block {
|
|
1144
|
+
border-color: var(--pbo-color-gray-300);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
.button--color-block {
|
|
1148
|
+
padding-left: 0;
|
|
1149
|
+
padding-right: 0;
|
|
1150
|
+
border-radius: 5px;
|
|
1151
|
+
border-width: 1.5px;
|
|
1152
|
+
height: 22px !important;
|
|
1153
|
+
width: 22px !important;
|
|
1154
|
+
min-height: 22px;
|
|
1155
|
+
min-width: 22px;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
.button--color-block.button--small {
|
|
1159
|
+
width: var(--pbo-input-height-small);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
.button--color-block.button--medium {
|
|
1163
|
+
width: var(--pbo-input-height-medium);
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
.button--color-block.button--large {
|
|
1167
|
+
width: var(--pbo-input-height-large);
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
.button--color-block .button__prefix,
|
|
1171
|
+
.button--color-block .button__suffix,
|
|
1172
|
+
.button--color-block .button__caret {
|
|
1173
|
+
display: none;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
/*
|
|
1177
|
+
* Caret modifier
|
|
1178
|
+
*/
|
|
1179
|
+
|
|
1180
|
+
.button--caret .button__suffix {
|
|
1181
|
+
display: none;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
.button--caret .button__caret {
|
|
1185
|
+
height: auto;
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/*
|
|
1189
|
+
* Loading modifier
|
|
1190
|
+
*/
|
|
1191
|
+
|
|
1192
|
+
.button--loading {
|
|
1193
|
+
position: relative;
|
|
1194
|
+
cursor: wait;
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
.button--loading .button__prefix,
|
|
1198
|
+
.button--loading .button__label,
|
|
1199
|
+
.button--loading .button__suffix,
|
|
1200
|
+
.button--loading .button__caret {
|
|
1201
|
+
visibility: hidden;
|
|
1202
|
+
}
|
|
1203
|
+
.button--loading pbo-spinner {
|
|
1204
|
+
--indicator-color: currentColor;
|
|
1205
|
+
position: absolute;
|
|
1206
|
+
font-size: 1em;
|
|
1207
|
+
height: 1em;
|
|
1208
|
+
width: 1em;
|
|
1209
|
+
top: calc(50% - 0.5em);
|
|
1210
|
+
left: calc(50% - 0.5em);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/*
|
|
1214
|
+
* Badges
|
|
1215
|
+
*/
|
|
1216
|
+
|
|
1217
|
+
.button ::slotted(pbo-badge) {
|
|
1218
|
+
position: absolute;
|
|
1219
|
+
top: 0;
|
|
1220
|
+
right: 0;
|
|
1221
|
+
translate: 50% -50%;
|
|
1222
|
+
pointer-events: none;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
.button--rtl ::slotted(pbo-badge) {
|
|
1226
|
+
right: auto;
|
|
1227
|
+
left: 0;
|
|
1228
|
+
translate: -50% -50%;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
/*
|
|
1232
|
+
* Button spacing
|
|
1233
|
+
*/
|
|
1234
|
+
|
|
1235
|
+
.button--has-label.button--small .button__label {
|
|
1236
|
+
padding: 0 var(--pbo-spacing-small);
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
.button--has-label.button--medium .button__label {
|
|
1240
|
+
padding: 0 var(--pbo-spacing-medium);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
.button--has-label.button--large .button__label {
|
|
1244
|
+
padding: 0 var(--pbo-spacing-large);
|
|
1245
|
+
}
|
|
1246
|
+
|
|
1247
|
+
.button--has-prefix.button--small {
|
|
1248
|
+
padding-inline-start: var(--pbo-spacing-x-small);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
.button--has-prefix.button--small .button__label {
|
|
1252
|
+
padding-inline-start: var(--pbo-spacing-x-small);
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
.button--has-prefix.button--medium {
|
|
1256
|
+
padding-inline-start: var(--pbo-spacing-small);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
.button--has-prefix.button--medium .button__label {
|
|
1260
|
+
padding-inline-start: var(--pbo-spacing-small);
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
.button--has-prefix.button--large {
|
|
1264
|
+
padding-inline-start: var(--pbo-spacing-small);
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
.button--has-prefix.button--large .button__label {
|
|
1268
|
+
padding-inline-start: var(--pbo-spacing-small);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
.button--has-suffix.button--small,
|
|
1272
|
+
.button--caret.button--small {
|
|
1273
|
+
padding-inline-end: var(--pbo-spacing-x-small);
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
.button--has-suffix.button--small .button__label,
|
|
1277
|
+
.button--caret.button--small .button__label {
|
|
1278
|
+
padding-inline-end: var(--pbo-spacing-x-small);
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
.button--has-suffix.button--medium,
|
|
1282
|
+
.button--caret.button--medium {
|
|
1283
|
+
padding-inline-end: var(--pbo-spacing-small);
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
.button--has-suffix.button--medium .button__label,
|
|
1287
|
+
.button--caret.button--medium .button__label {
|
|
1288
|
+
padding-inline-end: var(--pbo-spacing-small);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
.button--has-suffix.button--large,
|
|
1292
|
+
.button--caret.button--large {
|
|
1293
|
+
padding-inline-end: var(--pbo-spacing-small);
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
.button--has-suffix.button--large .button__label,
|
|
1297
|
+
.button--caret.button--large .button__label {
|
|
1298
|
+
padding-inline-end: var(--pbo-spacing-small);
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/*
|
|
1302
|
+
* Button groups support a variety of button types (e.g. buttons with tooltips, buttons as dropdown triggers, etc.).
|
|
1303
|
+
* This means buttons aren't always direct descendants of the button group, thus we can't target them with the
|
|
1304
|
+
* ::slotted selector. To work around this, the button group component does some magic to add these special classes to
|
|
1305
|
+
* buttons and we style them here instead.
|
|
1306
|
+
*/
|
|
1307
|
+
|
|
1308
|
+
:host([data-pbo-button-group__button--first]:not([data-pbo-button-group__button--last]))
|
|
1309
|
+
.button:not(.button--circle) {
|
|
1310
|
+
border-start-end-radius: 0;
|
|
1311
|
+
border-end-end-radius: 0;
|
|
1312
|
+
}
|
|
1313
|
+
|
|
1314
|
+
:host([data-pbo-button-group__button--inner]) .button {
|
|
1315
|
+
border-radius: 0;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
:host([data-pbo-button-group__button--last]:not([data-pbo-button-group__button--first]))
|
|
1319
|
+
.button:not(.button--circle) {
|
|
1320
|
+
border-start-start-radius: 0;
|
|
1321
|
+
border-end-start-radius: 0;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1324
|
+
/* All except the first */
|
|
1325
|
+
:host([data-pbo-button-group__button]:not([data-pbo-button-group__button--first])) {
|
|
1326
|
+
margin-inline-start: calc(-1 * var(--pbo-input-border-width));
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
:host([data-pbo-button-group__button]:not([data-pbo-button-group__button--last])) .button--circle {
|
|
1330
|
+
margin-right: var(--pbo-spacing-x-small);
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/* Add a visual separator between solid buttons */
|
|
1334
|
+
:host(
|
|
1335
|
+
[data-pbo-button-group__button]:not(
|
|
1336
|
+
[data-pbo-button-group__button--first],
|
|
1337
|
+
[data-pbo-button-group__button--radio],
|
|
1338
|
+
[variant="default"]
|
|
1339
|
+
):not(:hover)
|
|
1340
|
+
)
|
|
1341
|
+
.button:after {
|
|
1342
|
+
content: "";
|
|
1343
|
+
position: absolute;
|
|
1344
|
+
top: 0;
|
|
1345
|
+
inset-inline-start: 0;
|
|
1346
|
+
bottom: 0;
|
|
1347
|
+
border-left: solid 1px rgb(128 128 128 / 33%);
|
|
1348
|
+
mix-blend-mode: multiply;
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
/*Icon button*/
|
|
1352
|
+
.button--icon {
|
|
1353
|
+
background-color: transparent;
|
|
1354
|
+
border-color: transparent;
|
|
1355
|
+
outline: none !important;
|
|
1356
|
+
min-height: auto;
|
|
1357
|
+
padding: 0.4rem 0.4rem;
|
|
1358
|
+
}
|
|
1359
|
+
.button--icon:hover {
|
|
1360
|
+
background-color: #e2e8f0 !important;
|
|
1361
|
+
border-color: transparent;
|
|
1362
|
+
outline: none !important;
|
|
1363
|
+
}
|
|
1364
|
+
.button--icon .button__label {
|
|
1365
|
+
padding: 0 !important;
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/*Button group for icon buttons*/
|
|
1369
|
+
:host([data-pbo-button-group__button]) .button--icon {
|
|
1370
|
+
height: auto;
|
|
1371
|
+
border-radius: 0.625rem !important;
|
|
1372
|
+
border-color: transparent !important;
|
|
1373
|
+
margin-inline-start: 0 !important;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
:host([data-pbo-button-group__button]) .button--icon.button--checked {
|
|
1377
|
+
border-color: #cbd5e1;
|
|
1378
|
+
background-color: #cbd5e1;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/* Bump hovered, focused, and checked buttons up so their focus ring isn't clipped */
|
|
1382
|
+
:host([data-pbo-button-group__button--hover]) {
|
|
1383
|
+
z-index: 1;
|
|
1384
|
+
}
|
|
1385
|
+
`;/**
|
|
1386
|
+
* @license
|
|
1387
|
+
* Copyright 2020 Google LLC
|
|
1388
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1389
|
+
*/const wh=Symbol.for(""),Fg=n=>{if((n==null?void 0:n.r)===wh)return n==null?void 0:n._$litStatic$},jl=(n,...t)=>({_$litStatic$:t.reduce((e,i,r)=>e+(s=>{if(s._$litStatic$!==void 0)return s._$litStatic$;throw Error(`Value passed to 'literal' function must be a 'literal' result: ${s}. Use 'unsafeStatic' to pass non-literal values, but
|
|
1390
|
+
take care to ensure page security.`)})(i)+n[r+1],n[0]),r:wh}),Rl=new Map,jg=n=>(t,...e)=>{const i=e.length;let r,s;const o=[],a=[];let l,c=0,h=!1;for(;c<i;){for(l=t[c];c<i&&(s=e[c],(r=Fg(s))!==void 0);)l+=r+t[++c],h=!0;c!==i&&a.push(s),o.push(l),c++}if(c===i&&o.push(t[i]),h){const u=o.join("$$lit$$");(t=Rl.get(u))===void 0&&(o.raw=o,Rl.set(u,t=o)),e=a}return n(t,...e)},Bl=jg(X),Mr=new WeakMap,Ir=new WeakMap,Lr=new WeakMap,go=new WeakSet,Js=new WeakMap;class xa{constructor(t,e){this.handleFormData=i=>{const r=this.options.disabled(this.host),s=this.options.name(this.host),o=this.options.value(this.host),a=this.host.tagName.toLowerCase()==="pbo-button";this.host.isConnected&&!r&&!a&&typeof s=="string"&&s.length>0&&typeof o<"u"&&(Array.isArray(o)?o.forEach(l=>{i.formData.append(s,l.toString())}):i.formData.append(s,o.toString()))},this.handleFormSubmit=i=>{var o;const r=this.options.disabled(this.host),s=this.options.reportValidity;this.form&&!this.form.noValidate&&((o=Mr.get(this.form))==null||o.forEach(a=>{this.setUserInteracted(a,!0)})),this.form&&!this.form.noValidate&&!r&&!s(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),Js.set(this.host,[])},this.handleInteraction=i=>{const r=Js.get(this.host);r.includes(i.type)||r.push(i.type),r.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 r of i)if(typeof r.checkValidity=="function"&&!r.checkValidity())return!1}return!0},this.doAction=(i,r)=>{if(this.form){const s=document.createElement("button");s.type=i,s.style.position="absolute",s.style.width="0",s.style.height="0",s.style.clipPath="inset(50%)",s.style.overflow="hidden",s.style.whiteSpace="nowrap",r&&(s.name=r.name,s.value=r.value,["formation","formenctype","formmethod","formnovalidate","formtarget"].forEach(o=>{r.hasAttribute(o)&&s.setAttribute(o,r.getAttribute(o))})),this.form.append(s),s.click(),s.remove()}},(this.host=t).addController(this),this.options={form:i=>{const r=i.form;if(r){const o=i.getRootNode().querySelector(`#${r}`);if(o)return o}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,r)=>i.value=r,assumeInteractionOn:["pbo-input"],...e}}hostConnected(){const t=this.options.form(this.host);t&&this.attachForm(t),Js.set(this.host,[]),this.options.assumeInteractionOn.forEach(e=>{this.host.addEventListener(e,this.handleInteraction)})}hostDisconnected(){this.detachForm(),Js.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,Mr.has(this.form)?Mr.get(this.form).add(this.host):Mr.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),Ir.has(this.form)||(Ir.set(this.form,this.form.reportValidity),this.form.reportValidity=()=>this.reportFormValidity()),Lr.has(this.form)||(Lr.set(this.form,this.form.checkValidity),this.form.checkValidity=()=>this.checkFormValidity())):this.form=void 0}detachForm(){if(!this.form)return;const t=Mr.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),Ir.has(this.form)&&(this.form.reportValidity=Ir.get(this.form),Ir.delete(this.form)),Lr.has(this.form)&&(this.form.checkValidity=Lr.get(this.form),Lr.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?go.add(t):go.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=!!go.has(e),r=!!e.required;e.toggleAttribute("data-required",r),e.toggleAttribute("data-optional",!r),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 Vn=Object.freeze({badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:!0,valueMissing:!1}),Rg=Object.freeze({...Vn,valid:!1,valueMissing:!1}),Bg=Object.freeze({...Vn,valid:!1,customError:!0});/**
|
|
1391
|
+
* @license
|
|
1392
|
+
* Copyright 2018 Google LLC
|
|
1393
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1394
|
+
*/const mi=n=>n??Ko,Ng=vt`
|
|
1395
|
+
:host {
|
|
1396
|
+
--track-width: 2px;
|
|
1397
|
+
--track-color: rgb(128 128 128 / 25%);
|
|
1398
|
+
--indicator-color: var(--pbo-color-primary-600);
|
|
1399
|
+
--speed: 2s;
|
|
1400
|
+
|
|
1401
|
+
display: inline-flex;
|
|
1402
|
+
width: 1em;
|
|
1403
|
+
height: 1em;
|
|
1404
|
+
flex: none;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
.spinner {
|
|
1408
|
+
flex: 1 1 auto;
|
|
1409
|
+
height: 100%;
|
|
1410
|
+
width: 100%;
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
.spinner__track,
|
|
1414
|
+
.spinner__indicator {
|
|
1415
|
+
fill: none;
|
|
1416
|
+
stroke-width: var(--track-width);
|
|
1417
|
+
r: calc(0.5em - var(--track-width) / 2);
|
|
1418
|
+
cx: 0.5em;
|
|
1419
|
+
cy: 0.5em;
|
|
1420
|
+
transform-origin: 50% 50%;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
.spinner__track {
|
|
1424
|
+
stroke: var(--track-color);
|
|
1425
|
+
transform-origin: 0% 0%;
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
.spinner__indicator {
|
|
1429
|
+
stroke: var(--indicator-color);
|
|
1430
|
+
stroke-linecap: round;
|
|
1431
|
+
stroke-dasharray: 150% 75%;
|
|
1432
|
+
animation: spin var(--speed) linear infinite;
|
|
1433
|
+
}
|
|
1434
|
+
|
|
1435
|
+
@keyframes spin {
|
|
1436
|
+
0% {
|
|
1437
|
+
transform: rotate(0deg);
|
|
1438
|
+
stroke-dasharray: 0.05em, 3em;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
50% {
|
|
1442
|
+
transform: rotate(450deg);
|
|
1443
|
+
stroke-dasharray: 1.375em, 1.375em;
|
|
1444
|
+
}
|
|
1445
|
+
|
|
1446
|
+
100% {
|
|
1447
|
+
transform: rotate(1080deg);
|
|
1448
|
+
stroke-dasharray: 0.05em, 3em;
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
`;var zg=Object.getOwnPropertyDescriptor,Vg=(n,t,e,i)=>{for(var r=i>1?void 0:i?zg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=o(r)||r);return r};let Qr=class extends Bt{render(){return X`
|
|
1452
|
+
<svg part="base" class="spinner" role="progressbar" aria-label="loading">
|
|
1453
|
+
<circle class="spinner__track"></circle>
|
|
1454
|
+
<circle class="spinner__indicator"></circle>
|
|
1455
|
+
</svg>
|
|
1456
|
+
`}};Qr.styles=[Pt,Ng];Qr=Vg([Ot("pbo-spinner")],Qr);var Hg=Object.defineProperty,$g=Object.getOwnPropertyDescriptor,Xt=(n,t,e,i)=>{for(var r=i>1?void 0:i?$g(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Hg(t,e,r),r};let St=class extends Bt{constructor(){super(...arguments),this.formControlController=new xa(this,{assumeInteractionOn:["click"]}),this.hasSlotController=new Ki(this,"[prefix]","prefix","suffix"),this.disabled=!1,this.href="",this.name="",this.value="",this.variant="default",this.outline=!1,this.size="medium",this.circle=!1,this.type="button",this.colorBlock=!1,this.loading=!1,this.isIconButton=!1,this.hasFocus=!1}get validity(){return this.isButton()?this.button.validity:Vn}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?jl`a`:jl`button`;return Bl`
|
|
1457
|
+
<${e}
|
|
1458
|
+
part="base"
|
|
1459
|
+
class= ${ni({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})}
|
|
1460
|
+
?disabled=${mi(t?void 0:this.disabled)}
|
|
1461
|
+
tabindex=${this.disabled?"-1":"0"}
|
|
1462
|
+
href="${this.href}"
|
|
1463
|
+
name=${mi(t?void 0:this.name)}
|
|
1464
|
+
@blur=${this.handleBlur}
|
|
1465
|
+
@focus=${this.handleFocus}
|
|
1466
|
+
@invalid=${this.isButton()?this.handleInvalid:null}
|
|
1467
|
+
@click=${this.handleClick}
|
|
1468
|
+
>
|
|
1469
|
+
<slot name="prefix" part="prefix" class="button__prefix"></slot>
|
|
1470
|
+
<slot part="label" class="button__label"></slot>
|
|
1471
|
+
<slot name="suffix" part="suffix" class="button__suffix"></slot>
|
|
1472
|
+
${this.loading?Bl`<pbo-spinner part="spinner"></pbo-spinner>`:""}
|
|
1473
|
+
</${e}>`}};St.styles=[Pt,xh];St.dependencies={"pbo-spinner":Qr};Xt([q(".button")],St.prototype,"button",2);Xt([q(".button--loading pbo-spinner")],St.prototype,"spinner",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"disabled",2);Xt([O()],St.prototype,"href",2);Xt([O()],St.prototype,"name",2);Xt([O()],St.prototype,"value",2);Xt([O({reflect:!0})],St.prototype,"variant",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"outline",2);Xt([O({reflect:!0})],St.prototype,"size",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"circle",2);Xt([O({reflect:!0})],St.prototype,"type",2);Xt([O({type:Boolean,reflect:!0,attribute:"color-block"})],St.prototype,"colorBlock",2);Xt([O({type:Boolean,reflect:!0})],St.prototype,"loading",2);Xt([$()],St.prototype,"isIconButton",2);Xt([$()],St.prototype,"hasFocus",2);St=Xt([Ot("pbo-button")],St);const mb=St,Wg=vt`
|
|
1474
|
+
:host {
|
|
1475
|
+
display: inline-block;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
.button-group {
|
|
1479
|
+
/* display: flex; */
|
|
1480
|
+
/* flex-wrap: nowrap; */
|
|
1481
|
+
}
|
|
1482
|
+
`;var Gg=Object.defineProperty,Ug=Object.getOwnPropertyDescriptor,Hn=(n,t,e,i)=>{for(var r=i>1?void 0:i?Ug(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Gg(t,e,r),r};let wi=class extends Bt{constructor(){super(...arguments),this.disableRole=!1,this.label=""}handleFocus(t){const e=Fr(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!0)}handleBlur(t){const e=Fr(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--focus",!1)}handleMouseOver(t){const e=Fr(t.target);e==null||e.toggleAttribute("data-pbo-button-group__button--hover",!0)}handleMouseOut(t){const e=Fr(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),r=Fr(e);r&&(r.toggleAttribute("data-pbo-button-group__button",!0),r.toggleAttribute("data-pbo-button-group__button--first",i===0),r.toggleAttribute("data-pbo-button-group__button--inner",i>0&&i<t.length-1),r.toggleAttribute("data-pbo-button-group__button--last",i===t.length-1),r.toggleAttribute("data-pbo-button-group__button--radio",r.tagName.toLowerCase()==="pbo-radio-button"))})}render(){return X`
|
|
1483
|
+
<div
|
|
1484
|
+
part="base"
|
|
1485
|
+
class=${ni({"button-group":!0})}
|
|
1486
|
+
role="${this.disableRole?"presentation":"group"}"
|
|
1487
|
+
aria-label=${this.label}
|
|
1488
|
+
@focusout=${this.handleBlur}
|
|
1489
|
+
@focusin=${this.handleFocus}
|
|
1490
|
+
@mouseover=${this.handleMouseOver}
|
|
1491
|
+
@mouseout=${this.handleMouseOut}
|
|
1492
|
+
>
|
|
1493
|
+
<slot @slotchange=${this.handleSlotChange}></slot>
|
|
1494
|
+
</div>
|
|
1495
|
+
`}};wi.styles=[Pt,Wg];Hn([q("slot")],wi.prototype,"defaultSlot",2);Hn([$()],wi.prototype,"disableRole",2);Hn([O()],wi.prototype,"label",2);wi=Hn([Ot("pbo-button-group")],wi);function Fr(n){const t="pbo-button, pbo-radio-button";return n.closest(t)??n.querySelector(t)}const bb=wi,Yg=vt`
|
|
1496
|
+
${xh}
|
|
1497
|
+
|
|
1498
|
+
.button__prefix,
|
|
1499
|
+
.button__suffix,
|
|
1500
|
+
.button__label {
|
|
1501
|
+
display: inline-flex;
|
|
1502
|
+
position: relative;
|
|
1503
|
+
align-items: center;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
.button--checked.button--circle {
|
|
1507
|
+
/* border-width: 5px; */
|
|
1508
|
+
/* border-color: rgb(13, 110, 253, 0.5) !important; */
|
|
1509
|
+
outline: 3px solid rgb(13, 110, 253, 0.5);
|
|
1510
|
+
padding: 2px;
|
|
1511
|
+
}
|
|
1512
|
+
`;/**
|
|
1513
|
+
* @license
|
|
1514
|
+
* Copyright 2018 Google LLC
|
|
1515
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1516
|
+
*/const Ch="important",Xg=" !"+Ch,pe=qo(class extends Zo{constructor(n){var t;if(super(n),n.type!==Fi.ATTRIBUTE||n.name!=="style"||((t=n.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(n){return Object.keys(n).reduce((t,e)=>{const i=n[e];return i==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${i};`},"")}update(n,[t]){const{style:e}=n.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 r=t[i];if(r!=null){this.ft.add(i);const s=typeof r=="string"&&r.endsWith(Xg);i.includes("-")||s?e.setProperty(i,s?r.slice(0,-11):r,s?Ch:""):e[i]=r}}return Rr}});var Kg=Object.defineProperty,qg=Object.getOwnPropertyDescriptor,$e=(n,t,e,i)=>{for(var r=i>1?void 0:i?qg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Kg(t,e,r),r};let fe=class extends Bt{constructor(){super(...arguments),this.hasSlotController=new Ki(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 X`
|
|
1517
|
+
<div part="base" role="presentation">
|
|
1518
|
+
<button
|
|
1519
|
+
part="${`button${this.checked?"button--checked":""}`}"
|
|
1520
|
+
role="radio"
|
|
1521
|
+
aria-checked="${this.checked}"
|
|
1522
|
+
class=${ni({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})}
|
|
1523
|
+
type="button"
|
|
1524
|
+
value=${mi(this.value)}
|
|
1525
|
+
@blur=${this.handleBlur}
|
|
1526
|
+
@click=${this.handleClick}
|
|
1527
|
+
@focus=${this.handleFocus}
|
|
1528
|
+
style=${pe({backgroundColor:this.isColorString(this.value)?this.value:""})}
|
|
1529
|
+
>
|
|
1530
|
+
<slot name="prefix" part="prefix" class="button__prefix"></slot>
|
|
1531
|
+
<slot part="label" class="button__label"></slot>
|
|
1532
|
+
<slot name="suffix" part="suffix" class="button__suffix"></slot>
|
|
1533
|
+
</button>
|
|
1534
|
+
</div>
|
|
1535
|
+
`}};fe.styles=[Pt,Yg];$e([q(".button")],fe.prototype,"input",2);$e([q(".hidden-input")],fe.prototype,"hiddenInput",2);$e([O({type:Boolean,reflect:!0})],fe.prototype,"checked",2);$e([O()],fe.prototype,"value",2);$e([O({type:Boolean,reflect:!0})],fe.prototype,"disabled",2);$e([O({reflect:!0})],fe.prototype,"size",2);$e([O({type:Boolean,reflect:!0})],fe.prototype,"circle",2);$e([O({type:Boolean,reflect:!0,attribute:"icon-only"})],fe.prototype,"iconOnly",2);$e([$()],fe.prototype,"hasFocus",2);fe=$e([Ot("pbo-radio-button")],fe);const yb=fe,Zg=vt`
|
|
1536
|
+
:host {
|
|
1537
|
+
display: block;
|
|
1538
|
+
}
|
|
1539
|
+
.form-control {
|
|
1540
|
+
position: relative;
|
|
1541
|
+
border: none;
|
|
1542
|
+
padding: 0;
|
|
1543
|
+
margin: 0;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
.visually-hidden {
|
|
1547
|
+
position: absolute;
|
|
1548
|
+
width: 1px;
|
|
1549
|
+
height: 1px;
|
|
1550
|
+
padding: 0;
|
|
1551
|
+
margin: -1px;
|
|
1552
|
+
overflow: hidden;
|
|
1553
|
+
clip: rect(0, 0, 0, 0);
|
|
1554
|
+
white-space: nowrap;
|
|
1555
|
+
border: 0;
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
.form-control-input pbo-button-group {
|
|
1559
|
+
padding: 0.25rem;
|
|
1560
|
+
}
|
|
1561
|
+
|
|
1562
|
+
.radio-icon-group .form-control-input pbo-button-group {
|
|
1563
|
+
background-color: #f3f4f6;
|
|
1564
|
+
padding: 0.25rem;
|
|
1565
|
+
border-radius: 1rem;
|
|
1566
|
+
}
|
|
1567
|
+
`;var Jg=Object.defineProperty,Qg=Object.getOwnPropertyDescriptor,Kt=(n,t,e,i)=>{for(var r=i>1?void 0:i?Qg(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Jg(t,e,r),r};let gt=class extends Bt{constructor(){super(...arguments),this.formControlController=new xa(this),this.hasSlotController=new Ki(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!==""?Bg:t?Rg:Vn}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(),r=this.value;!e||e.disabled||(this.value=e.value,i.forEach(s=>s.checked=s===e),this.value!==r&&(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,r=this.label?!0:!!t;return X`
|
|
1568
|
+
<fieldset
|
|
1569
|
+
role="radiogroup"
|
|
1570
|
+
part="form-control"
|
|
1571
|
+
class=${ni({"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":r,"form-control--has-help-text":i,"radio-icon-group":this.iconGroup})}
|
|
1572
|
+
role="radiogroup"
|
|
1573
|
+
aria-labelledby="label"
|
|
1574
|
+
aria-describedby="help-text"
|
|
1575
|
+
aria-errormessage="error-message"
|
|
1576
|
+
>
|
|
1577
|
+
<label
|
|
1578
|
+
part="form-control-label"
|
|
1579
|
+
id="label"
|
|
1580
|
+
class="form-control__label"
|
|
1581
|
+
aria-hidden=${r?"false":"true"}
|
|
1582
|
+
@click=${this.handleLabelClick}
|
|
1583
|
+
>
|
|
1584
|
+
<slot name="label">${this.label}</slot>
|
|
1585
|
+
</label>
|
|
1586
|
+
|
|
1587
|
+
<div part="form-control-input" class="form-control-input">
|
|
1588
|
+
<div class="visually-hidden">
|
|
1589
|
+
<div id="error-message" aria-live="assertive">${this.errorMessage}</div>
|
|
1590
|
+
<label class="radio-group__validation">
|
|
1591
|
+
<input
|
|
1592
|
+
type="text"
|
|
1593
|
+
class="radio-group__validation-input"
|
|
1594
|
+
?required=${this.required}
|
|
1595
|
+
tabindex="-1"
|
|
1596
|
+
hidden
|
|
1597
|
+
@invalid=${this.handleInvalid}
|
|
1598
|
+
/>
|
|
1599
|
+
</label>
|
|
1600
|
+
</div>
|
|
1601
|
+
<pbo-button-group part="button-group" exportparts="base:button-group__base" role="presentation">
|
|
1602
|
+
<slot @slotchange=${this.syncRadios} @click=${this.handleRadioClick} @keydown=${this.handleKeyDown}></slot>
|
|
1603
|
+
</pbo-button-group>
|
|
1604
|
+
</div>
|
|
1605
|
+
<div
|
|
1606
|
+
part="form-control-help-text"
|
|
1607
|
+
id="help-text"
|
|
1608
|
+
class="form-control__help-text"
|
|
1609
|
+
aria-hidden=${i?"false":"true"}
|
|
1610
|
+
>
|
|
1611
|
+
<slot name="help-text">${this.helpText}</slot>
|
|
1612
|
+
</div>
|
|
1613
|
+
</fieldset>
|
|
1614
|
+
`}};gt.styles=[Pt,Zg,ps];gt.dependencies={"pbo-button-group":wi};Kt([q("slot:not([name])")],gt.prototype,"defaultSlot",2);Kt([q(".radio-group__validation-input")],gt.prototype,"validationInput",2);Kt([$()],gt.prototype,"hasButtonGroup",2);Kt([$()],gt.prototype,"errorMessage",2);Kt([$()],gt.prototype,"defaultValue",2);Kt([O({type:Boolean,reflect:!0})],gt.prototype,"required",2);Kt([O()],gt.prototype,"name",2);Kt([O({reflect:!0})],gt.prototype,"value",2);Kt([O({attribute:"help-text"})],gt.prototype,"helpText",2);Kt([O()],gt.prototype,"label",2);Kt([O({type:Boolean,reflect:!0,attribute:"icon-group"})],gt.prototype,"iconGroup",2);Kt([O()],gt.prototype,"size",2);Kt([O({type:Boolean,reflect:!0})],gt.prototype,"disabled",2);Kt([O({reflect:!0})],gt.prototype,"form",2);Kt([et("value")],gt.prototype,"handleValueChange",1);gt=Kt([Ot("pbo-radio-group")],gt);const wb=gt,tm=vt`
|
|
1615
|
+
:host {
|
|
1616
|
+
display: block;
|
|
1617
|
+
position: relative;
|
|
1618
|
+
}
|
|
1619
|
+
.form-control__help-text {
|
|
1620
|
+
position: absolute;
|
|
1621
|
+
right: 0px;
|
|
1622
|
+
}
|
|
1623
|
+
.textarea {
|
|
1624
|
+
display: grid;
|
|
1625
|
+
align-items: center;
|
|
1626
|
+
position: relative;
|
|
1627
|
+
width: 100%;
|
|
1628
|
+
font-family: var(--pbo-input-font-family);
|
|
1629
|
+
font-weight: var(--pbo-input-font-weight);
|
|
1630
|
+
line-height: var(--pbo-line-height-normal);
|
|
1631
|
+
letter-spacing: var(--pbo-input-letter-spacing);
|
|
1632
|
+
vertical-align: middle;
|
|
1633
|
+
transition:
|
|
1634
|
+
var(--pbo-transition-fast) color,
|
|
1635
|
+
var(--pbo-transition-fast) border,
|
|
1636
|
+
var(--pbo-transition-fast) box-shadow,
|
|
1637
|
+
var(--pbo-transition-fast) background-color;
|
|
1638
|
+
cursor: text;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
/* Standard textareas */
|
|
1642
|
+
.textarea--standard {
|
|
1643
|
+
background-color: var(--pbo-input-background-color);
|
|
1644
|
+
border: solid var(--pbo-input-border-width) var(--pbo-input-border-color);
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
.textarea--standard:hover:not(.textarea--disabled) {
|
|
1648
|
+
background-color: var(--pbo-input-background-color-hover);
|
|
1649
|
+
border-color: var(--pbo-input-border-color-hover);
|
|
1650
|
+
}
|
|
1651
|
+
.textarea--standard:hover:not(.textarea--disabled) .textarea__control {
|
|
1652
|
+
color: var(--pbo-input-color-hover);
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
.textarea--standard.textarea--focused:not(.textarea--disabled) {
|
|
1656
|
+
background-color: var(--pbo-input-background-color-focus);
|
|
1657
|
+
border-color: var(--pbo-input-border-color-focus);
|
|
1658
|
+
color: var(--pbo-input-color-focus);
|
|
1659
|
+
box-shadow: 0 0 0 var(--pbo-focus-ring-width) var(--pbo-input-focus-ring-color);
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
.textarea--standard.textarea--focused:not(.textarea--disabled) .textarea__control {
|
|
1663
|
+
color: var(--pbo-input-color-focus);
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
.textarea--standard.textarea--disabled {
|
|
1667
|
+
background-color: var(--pbo-input-background-color-disabled);
|
|
1668
|
+
border-color: var(--pbo-input-border-color-disabled);
|
|
1669
|
+
opacity: 0.5;
|
|
1670
|
+
cursor: not-allowed;
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1673
|
+
.textarea__control,
|
|
1674
|
+
.textarea__size-adjuster {
|
|
1675
|
+
grid-area: 1 / 1 / 2 / 2;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
.textarea__size-adjuster {
|
|
1679
|
+
visibility: hidden;
|
|
1680
|
+
pointer-events: none;
|
|
1681
|
+
opacity: 0;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
.textarea--standard.textarea--disabled .textarea__control {
|
|
1685
|
+
color: var(--pbo-input-color-disabled);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
.textarea--standard.textarea--disabled .textarea__control::placeholder {
|
|
1689
|
+
color: var(--pbo-input-placeholder-color-disabled);
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
/* Filled textareas */
|
|
1693
|
+
.textarea--filled {
|
|
1694
|
+
border: none;
|
|
1695
|
+
background-color: var(--pbo-input-filled-background-color);
|
|
1696
|
+
color: var(--pbo-input-color);
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
.textarea--filled:hover:not(.textarea--disabled) {
|
|
1700
|
+
background-color: var(--pbo-input-filled-background-color-hover);
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
.textarea--filled.textarea--focused:not(.textarea--disabled) {
|
|
1704
|
+
background-color: var(--pbo-input-filled-background-color-focus);
|
|
1705
|
+
outline: var(--pbo-focus-ring);
|
|
1706
|
+
outline-offset: var(--pbo-focus-ring-offset);
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
.textarea--filled.textarea--disabled {
|
|
1710
|
+
background-color: var(--pbo-input-filled-background-color-disabled);
|
|
1711
|
+
opacity: 0.5;
|
|
1712
|
+
cursor: not-allowed;
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
.textarea__control {
|
|
1716
|
+
font-family: inherit;
|
|
1717
|
+
font-size: inherit;
|
|
1718
|
+
font-weight: inherit;
|
|
1719
|
+
line-height: 1.4;
|
|
1720
|
+
color: var(--pbo-input-color);
|
|
1721
|
+
border: none;
|
|
1722
|
+
background: none;
|
|
1723
|
+
box-shadow: none;
|
|
1724
|
+
cursor: inherit;
|
|
1725
|
+
-webkit-appearance: none;
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
.textarea__control::-webkit-search-decoration,
|
|
1729
|
+
.textarea__control::-webkit-search-cancel-button,
|
|
1730
|
+
.textarea__control::-webkit-search-results-button,
|
|
1731
|
+
.textarea__control::-webkit-search-results-decoration {
|
|
1732
|
+
-webkit-appearance: none;
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
.textarea__control::placeholder {
|
|
1736
|
+
color: var(--pbo-input-placeholder-color);
|
|
1737
|
+
user-select: none;
|
|
1738
|
+
-webkit-user-select: none;
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
.textarea__control:focus {
|
|
1742
|
+
outline: none;
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/*
|
|
1746
|
+
* Size modifiers
|
|
1747
|
+
*/
|
|
1748
|
+
|
|
1749
|
+
.textarea--small {
|
|
1750
|
+
border-radius: var(--pbo-input-border-radius-small);
|
|
1751
|
+
font-size: var(--pbo-input-font-size-small);
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
.textarea--small .textarea__control {
|
|
1755
|
+
padding: 0.5em var(--pbo-input-spacing-small);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
.textarea--medium {
|
|
1759
|
+
border-radius: var(--pbo-input-border-radius-medium);
|
|
1760
|
+
font-size: var(--pbo-input-font-size-medium);
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
.textarea--medium .textarea__control {
|
|
1764
|
+
padding: 0.5em 11.5px;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
.textarea--large {
|
|
1768
|
+
border-radius: var(--pbo-input-border-radius-large);
|
|
1769
|
+
font-size: var(--pbo-input-font-size-large);
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
.textarea--large .textarea__control {
|
|
1773
|
+
padding: 0.5em var(--pbo-input-spacing-large);
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/*
|
|
1777
|
+
* Resize types
|
|
1778
|
+
*/
|
|
1779
|
+
|
|
1780
|
+
.textarea--resize-none .textarea__control {
|
|
1781
|
+
resize: none;
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
.textarea--resize-vertical .textarea__control {
|
|
1785
|
+
resize: vertical;
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1788
|
+
.textarea--resize-auto .textarea__control {
|
|
1789
|
+
height: auto;
|
|
1790
|
+
resize: none;
|
|
1791
|
+
overflow-y: hidden;
|
|
1792
|
+
}
|
|
1793
|
+
|
|
1794
|
+
.form-control__help-text {
|
|
1795
|
+
margin-top: var(--pbo-spacing-2x-small) !important;
|
|
1796
|
+
display: flex !important;
|
|
1797
|
+
justify-content: end !important;
|
|
1798
|
+
}
|
|
1799
|
+
`;/**
|
|
1800
|
+
* @license
|
|
1801
|
+
* Copyright 2020 Google LLC
|
|
1802
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1803
|
+
*/const{I:em}=au,Nl=(n,t)=>(n==null?void 0:n._$litType$)!==void 0,im=n=>{var t;return((t=n==null?void 0:n._$litType$)==null?void 0:t.h)!=null},rm=n=>n.strings===void 0,zl=()=>document.createComment(""),Vl=(n,t,e)=>{var s;const i=n._$AA.parentNode,r=n._$AB;if(e===void 0){const o=i.insertBefore(zl(),r),a=i.insertBefore(zl(),r);e=new em(o,a,n,n.options)}else{const o=e._$AB.nextSibling,a=e._$AM,l=a!==n;if(l){let c;(s=e._$AQ)==null||s.call(e,n),e._$AM=n,e._$AP!==void 0&&(c=n._$AU)!==a._$AU&&e._$AP(c)}if(o!==r||l){let c=e._$AA;for(;c!==o;){const h=c.nextSibling;i.insertBefore(c,r),c=h}}}return e},sm={},Vo=(n,t=sm)=>n._$AH=t,Hl=n=>n._$AH,nm=n=>{n._$AR()};/**
|
|
1804
|
+
* @license
|
|
1805
|
+
* Copyright 2020 Google LLC
|
|
1806
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
1807
|
+
*/const om=qo(class extends Zo{constructor(n){if(super(n),n.type!==Fi.PROPERTY&&n.type!==Fi.ATTRIBUTE&&n.type!==Fi.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!rm(n))throw Error("`live` bindings can only contain a single expression")}render(n){return n}update(n,[t]){if(t===Rr||t===Ko)return t;const e=n.element,i=n.name;if(n.type===Fi.PROPERTY){if(t===e[i])return Rr}else if(n.type===Fi.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(i))return Rr}else if(n.type===Fi.ATTRIBUTE&&e.getAttribute(i)===t+"")return Rr;return Vo(n),t}});var am=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,Nt=(n,t,e,i)=>{for(var r=i>1?void 0:i?lm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&am(t,e,r),r};let _t=class extends Bt{constructor(){super(...arguments),this.formControlController=new xa(this,{assumeInteractionOn:["pbo-input"]}),this.hasSlotController=new Ki(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,r="preserve"){const s=e??this.input.selectionStart,o=i??this.input.selectionEnd;this.input.setRangeText(t,s,o,r),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 X` <div
|
|
1808
|
+
part="form-control"
|
|
1809
|
+
class=${ni({"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})}
|
|
1810
|
+
>
|
|
1811
|
+
<div part="form-control-input" class="form-control-input">
|
|
1812
|
+
<div
|
|
1813
|
+
part="base"
|
|
1814
|
+
class=${ni({textarea:!0,"textarea--small":this.size==="small","textarea--medium":this.size==="medium","textarea--large":this.size==="large","textarea--standard":!this.filled,"textarea--filled":this.filled,"textarea--disabled":this.disabled,"textarea--focused":this.hasFocus,"textarea--empty":!this.value,"textarea--resize-none":this.resize==="none","textarea--resize-vertical":this.resize==="vertical","textarea--resize-auto":this.resize==="auto"})}
|
|
1815
|
+
>
|
|
1816
|
+
<textarea
|
|
1817
|
+
part="textarea"
|
|
1818
|
+
id="input"
|
|
1819
|
+
class="textarea__control"
|
|
1820
|
+
title=${this.title}
|
|
1821
|
+
name=${mi(this.name)}
|
|
1822
|
+
.value=${om(this.value)}
|
|
1823
|
+
?disabled=${this.disabled}
|
|
1824
|
+
?readonly=${this.readonly}
|
|
1825
|
+
?required=${this.required}
|
|
1826
|
+
placeholder=${mi(this.placeholder)}
|
|
1827
|
+
rows=${mi(this.rows)}
|
|
1828
|
+
minlength=${mi(this.minlength)}
|
|
1829
|
+
maxlength=${mi(this.maxlength)}
|
|
1830
|
+
aria-describedby="help-text"
|
|
1831
|
+
@change=${this.handleChange}
|
|
1832
|
+
@input=${this.handleInput}
|
|
1833
|
+
@invalid=${this.handleInvalid}
|
|
1834
|
+
@focus=${this.handleFocus}
|
|
1835
|
+
@blur=${this.handleBlur}
|
|
1836
|
+
></textarea>
|
|
1837
|
+
<!-- This "adjuster" exists to prevent layout shifting. https://github.com/shoelace-style/shoelace/issues/2180 -->
|
|
1838
|
+
<div part="textarea-adjuster" class="textarea__size-adjuster" ?hidden=${this.resize!=="auto"}></div>
|
|
1839
|
+
</div>
|
|
1840
|
+
</div>
|
|
1841
|
+
<div
|
|
1842
|
+
part="form-control-help-text"
|
|
1843
|
+
id="help-text"
|
|
1844
|
+
class="form-control__help-text"
|
|
1845
|
+
aria-hidden=${e?"false":"true"}
|
|
1846
|
+
>
|
|
1847
|
+
<slot name="help-text">${this.helpText}</slot>
|
|
1848
|
+
</div>
|
|
1849
|
+
</div>`}};_t.styles=[Pt,tm,ps];Nt([q(".textarea__control")],_t.prototype,"input",2);Nt([q(".textarea__size-adjuster")],_t.prototype,"sizeAdjuster",2);Nt([$()],_t.prototype,"hasFocus",2);Nt([O()],_t.prototype,"name",2);Nt([O()],_t.prototype,"value",2);Nt([O({reflect:!0})],_t.prototype,"size",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"filled",2);Nt([O()],_t.prototype,"placeholder",2);Nt([O({type:Number})],_t.prototype,"rows",2);Nt([O()],_t.prototype,"resize",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"disabled",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"readonly",2);Nt([O({reflect:!0})],_t.prototype,"form",2);Nt([O({type:Boolean,reflect:!0})],_t.prototype,"required",2);Nt([O({type:Number})],_t.prototype,"minlength",2);Nt([O({type:Number})],_t.prototype,"maxlength",2);Nt([O({attribute:"help-text"})],_t.prototype,"helpText",2);_t=Nt([Ot("pbo-textarea")],_t);const Sb=_t,cm=vt`
|
|
1850
|
+
:host {
|
|
1851
|
+
display: block;
|
|
1852
|
+
width: 100%;
|
|
1853
|
+
height: 100%;
|
|
1854
|
+
}
|
|
1855
|
+
@media screen and (min-width: 640px) {
|
|
1856
|
+
:host {
|
|
1857
|
+
display: block;
|
|
1858
|
+
height: 100%;
|
|
1859
|
+
width: 100%;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1863
|
+
.editor {
|
|
1864
|
+
height: 100%;
|
|
1865
|
+
width: 100%;
|
|
1866
|
+
display: flex;
|
|
1867
|
+
flex-direction: column;
|
|
1868
|
+
gap: var(--pbo-spacing-large);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
.editor__form {
|
|
1872
|
+
display: flex;
|
|
1873
|
+
flex-direction: column;
|
|
1874
|
+
gap: var(--pbo-spacing-x-small);
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
@media screen and (min-width: 640px) {
|
|
1878
|
+
.editor {
|
|
1879
|
+
width: 100%;
|
|
1880
|
+
height: 100%;
|
|
1881
|
+
display: grid;
|
|
1882
|
+
grid-template-columns: repeat(12, 1fr);
|
|
1883
|
+
gap: 1rem;
|
|
1884
|
+
}
|
|
1885
|
+
|
|
1886
|
+
.editor__card {
|
|
1887
|
+
grid-column: 1 / 7;
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
.editor__form {
|
|
1891
|
+
grid-column: 7 / 13;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
@media screen and (min-width: 768px) {
|
|
1896
|
+
.editor__card {
|
|
1897
|
+
grid-column: 2 / 7;
|
|
1898
|
+
}
|
|
1899
|
+
.editor__form {
|
|
1900
|
+
grid-column: 7 / 12;
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
@media screen and (min-width: 1536px) {
|
|
1905
|
+
.editor__card {
|
|
1906
|
+
grid-column: 3 / 7;
|
|
1907
|
+
}
|
|
1908
|
+
.editor__form {
|
|
1909
|
+
grid-column: 7 / 11;
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
`,hm=vt`
|
|
1913
|
+
:host {
|
|
1914
|
+
display: block;
|
|
1915
|
+
}
|
|
1916
|
+
.typing-form {
|
|
1917
|
+
display: flex;
|
|
1918
|
+
flex-direction: column;
|
|
1919
|
+
gap: var(--pbo-spacing-medium);
|
|
1920
|
+
}
|
|
1921
|
+
|
|
1922
|
+
.color-alignment-container {
|
|
1923
|
+
display: grid;
|
|
1924
|
+
grid-template-columns: repeat(2, 1fr);
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
.cta-buttons {
|
|
1928
|
+
display: flex;
|
|
1929
|
+
flex-direction: column;
|
|
1930
|
+
}
|
|
1931
|
+
|
|
1932
|
+
.cta-buttons pbo-button::part(base) {
|
|
1933
|
+
font-size: var(--pbo-font-size-medium);
|
|
1934
|
+
}
|
|
1935
|
+
`,ar=()=>/Mobi|Android|iPhone|iPad|iPod/i.test(navigator.userAgent),jr=n=>n!=null,Sh=n=>Object.entries(n).reduce((t,[e,i])=>(i==null||(t[e]=i),t),{});var um=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,zt=(n,t,e,i)=>{for(var r=i>1?void 0:i?dm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&um(t,e,r),r};let st=class extends Bt{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=st.CTA_STATES.primary,this.handleResize=()=>{this.resizeTimeout&&window.clearTimeout(this.resizeTimeout),this.resizeTimeout=window.setTimeout(()=>{this.windowHeight=window.innerHeight},50)}}isLoadingChanged(){this.ctaButtons.forEach(t=>{t.loading=this.loading})}disabledChanged(){this.greetingText.disabled=this.disabled,this.fontSelector.disabled=this.disabled,this.textColor.childNodes.forEach(t=>{t.disabled=this.disabled}),this.textAlignment.childNodes.forEach(t=>{t.disabled=this.disabled}),this.ctaButtons.forEach(t=>{t.disabled=this.disabled})}firstUpdated(){this.disabledChanged(),this.isLoadingChanged(),this.textArea.addEventListener("invalid",()=>{alert("Please add a message to continue")})}get formData(){var e,i,r,s,o,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:(r=this.card)==null?void 0:r.sku,variantId:(s=this.card)==null?void 0:s.variantId,font:((o=this.fontSelector)==null?void 0:o.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 Sh(t)}handleFormChange(t){this.ctaButtonState=st.CTA_STATES.primary,this.emit("pbo-change",{detail:this.formData})}hostConnected(){this.addEventListener("pbo-change",this.handleFormChange)}hostDisconnected(){this.removeEventListener("pbo-change",this.handleFormChange)}submitFormHandler(t){var i;t.preventDefault();const e=(i=t.submitter)==null?void 0:i.name;if(this.ctaButtonState.type==="danger"){e==="skip"&&this.submitTypeForm(this.formData);return}if(this.greetingText.value===""||this.greetingText.value===null||this.greetingText.value===void 0){this.ctaButtonState=st.CTA_STATES.danger,this.greetingText.focus();return}this.submitTypeForm(this.formData)}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",this.handleResize)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("resize",this.handleResize),this.resizeTimeout&&window.clearTimeout(this.resizeTimeout)}render(){const t=223-this.formData.text.length;return X`
|
|
1936
|
+
<form class="typing-form" @submit=${this.submitFormHandler}>
|
|
1937
|
+
<pbo-textarea
|
|
1938
|
+
class="greeting-text"
|
|
1939
|
+
@pbo-input=${this.handleFormChange}
|
|
1940
|
+
help-text=${t>1?`${t} characters`:`${t} character`}
|
|
1941
|
+
maxlength="223"
|
|
1942
|
+
rows="${window.innerHeight>=800?12:8}"
|
|
1943
|
+
placeholder="Type your message here"
|
|
1944
|
+
resize="none"
|
|
1945
|
+
>
|
|
1946
|
+
</pbo-textarea>
|
|
1947
|
+
|
|
1948
|
+
<pbo-selector
|
|
1949
|
+
label="Font"
|
|
1950
|
+
class="font-selector"
|
|
1951
|
+
.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"}]}"
|
|
1952
|
+
@pbo-change=${this.handleFormChange}
|
|
1953
|
+
size="large"
|
|
1954
|
+
disabled="${this.disabled}"
|
|
1955
|
+
></pbo-selector>
|
|
1956
|
+
|
|
1957
|
+
<div class="color-alignment-container">
|
|
1958
|
+
<pbo-radio-group
|
|
1959
|
+
class="text-color"
|
|
1960
|
+
@pbo-change=${this.handleFormChange}
|
|
1961
|
+
value="rgb(0,0,0)"
|
|
1962
|
+
label="Color"
|
|
1963
|
+
size="large"
|
|
1964
|
+
>
|
|
1965
|
+
<pbo-radio-button disabled="${this.disabled}" value="rgb(0,0,0)" size="small" circle></pbo-radio-button>
|
|
1966
|
+
<pbo-radio-button disabled="${this.disabled}" value="rgb(255,255,255)" size="small" circle></pbo-radio-button>
|
|
1967
|
+
</pbo-radio-group>
|
|
1968
|
+
|
|
1969
|
+
<pbo-radio-group
|
|
1970
|
+
class="text-alignment"
|
|
1971
|
+
@pbo-change=${this.handleFormChange}
|
|
1972
|
+
value="left"
|
|
1973
|
+
label="Align"
|
|
1974
|
+
size="large"
|
|
1975
|
+
icon-group
|
|
1976
|
+
>
|
|
1977
|
+
<pbo-radio-button value="left" icon-only>
|
|
1978
|
+
<svg
|
|
1979
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1980
|
+
height="1rem"
|
|
1981
|
+
viewBox="0 -960 960 960"
|
|
1982
|
+
width="1rem"
|
|
1983
|
+
fill="#1f1f1f"
|
|
1984
|
+
>
|
|
1985
|
+
<path
|
|
1986
|
+
d="M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z"
|
|
1987
|
+
/>
|
|
1988
|
+
</svg>
|
|
1989
|
+
</pbo-radio-button>
|
|
1990
|
+
<pbo-radio-button value="center" icon-only>
|
|
1991
|
+
<svg
|
|
1992
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
1993
|
+
height="1rem"
|
|
1994
|
+
viewBox="0 -960 960 960"
|
|
1995
|
+
width="1rem"
|
|
1996
|
+
fill="#1f1f1f"
|
|
1997
|
+
>
|
|
1998
|
+
<path
|
|
1999
|
+
d="M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z"
|
|
2000
|
+
/>
|
|
2001
|
+
</svg>
|
|
2002
|
+
</pbo-radio-button>
|
|
2003
|
+
<pbo-radio-button value="right" icon-only>
|
|
2004
|
+
<svg
|
|
2005
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2006
|
+
height="1rem"
|
|
2007
|
+
viewBox="0 -960 960 960"
|
|
2008
|
+
width="1rem"
|
|
2009
|
+
fill="#1f1f1f"
|
|
2010
|
+
>
|
|
2011
|
+
<path
|
|
2012
|
+
d="M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z"
|
|
2013
|
+
/>
|
|
2014
|
+
</svg>
|
|
2015
|
+
</pbo-radio-button>
|
|
2016
|
+
</-alignment-radio-group>
|
|
2017
|
+
</div>
|
|
2018
|
+
<div class="cta-buttons">
|
|
2019
|
+
<pbo-button
|
|
2020
|
+
name="main-cta"
|
|
2021
|
+
type="submit"
|
|
2022
|
+
class="submit"
|
|
2023
|
+
variant="${this.ctaButtonState.type}"
|
|
2024
|
+
>
|
|
2025
|
+
${this.ctaButtonState.message}
|
|
2026
|
+
</pbo-button>
|
|
2027
|
+
${this.ctaButtonState.type==="danger"?X`<pbo-button name="skip" type="submit" variant="text" size="small" class="skip">Skip</pbo-button>`:""}
|
|
2028
|
+
</div>
|
|
2029
|
+
</form>
|
|
2030
|
+
`}};st.styles=[Pt,ps,hm];st.dependencies={"pbo-selector":ze,"pbo-textarea":_t,"pbo-color-radio-group":gt,"pbo-radio-group":gt,"pbo-radio-button":gt,"pbo-button":St};st.CTA_STATES={danger:{type:"danger",message:"Add a message to Continue"},primary:{type:"primary",message:"Save and Continue"}};zt([O({type:String,reflect:!0})],st.prototype,"cardInnerImageUrl",2);zt([O()],st.prototype,"card",2);zt([O()],st.prototype,"submitTypeForm",2);zt([O({type:Boolean,reflect:!0})],st.prototype,"loading",2);zt([O({type:Boolean,reflect:!0})],st.prototype,"disabled",2);zt([q(".greeting-text")],st.prototype,"greetingText",2);zt([q(".font-selector")],st.prototype,"fontSelector",2);zt([q(".text-color")],st.prototype,"textColor",2);zt([q(".text-alignment")],st.prototype,"textAlignment",2);zt([q(".typing-form")],st.prototype,"typingForm",2);zt([q("pbo-textarea")],st.prototype,"textArea",2);zt([Jo(".cta-buttons pbo-button")],st.prototype,"ctaButtons",2);zt([$()],st.prototype,"windowHeight",2);zt([$()],st.prototype,"charsNum",2);zt([$()],st.prototype,"ctaButtonState",2);zt([et("loading",{waitUntilFirstUpdate:!0})],st.prototype,"isLoadingChanged",1);zt([et("disabled",{waitUntilFirstUpdate:!0})],st.prototype,"disabledChanged",1);st=zt([Ot("pbo-type-form")],st);/**
|
|
2031
|
+
* @license
|
|
2032
|
+
* Copyright 2017 Google LLC
|
|
2033
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2034
|
+
*/const $l=n=>im(n)?n._$litType$.h:n.strings,mo=qo(class extends Zo{constructor(n){super(n),this.et=new WeakMap}render(n){return[n]}update(n,[t]){const e=Nl(this.it)?$l(this.it):null,i=Nl(t)?$l(t):null;if(e!==null&&(i===null||e!==i)){const r=Hl(n).pop();let s=this.et.get(e);if(s===void 0){const o=document.createDocumentFragment();s=lu(Ko,o),s.setConnected(!1),this.et.set(e,s)}Vo(s,[r]),Vl(s,void 0,r)}if(i!==null){if(e===null||e!==i){const r=this.et.get(i);if(r!==void 0){const s=Hl(r).pop();nm(n),Vl(n,void 0,s),Vo(n,[s])}}this.it=t}else this.it=void 0;return this.render(t)}}),pm=vt`
|
|
2035
|
+
:host {
|
|
2036
|
+
display: block;
|
|
2037
|
+
width: 100%;
|
|
2038
|
+
height: auto;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
.main-slide-container {
|
|
2042
|
+
display: inline;
|
|
2043
|
+
position: relative;
|
|
2044
|
+
width: 80%;
|
|
2045
|
+
height: 100%;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
.zoomed-preview-open-button {
|
|
2049
|
+
position: absolute;
|
|
2050
|
+
right: 0;
|
|
2051
|
+
bottom: 0;
|
|
2052
|
+
padding: 0.5rem;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
.zoomed-preview-open-button svg:hover {
|
|
2056
|
+
cursor: pointer;
|
|
2057
|
+
scale: 1.3;
|
|
2058
|
+
}
|
|
2059
|
+
|
|
2060
|
+
/* Main slide styles */
|
|
2061
|
+
.main-slide {
|
|
2062
|
+
display: none;
|
|
2063
|
+
width: 100%;
|
|
2064
|
+
height: 100%;
|
|
2065
|
+
background-color: var(--pbo-color-gray-100);
|
|
2066
|
+
border: 2px solid var(--pbo-color-gray-100);
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
@media screen and (min-width: 640px) {
|
|
2070
|
+
.main-slide {
|
|
2071
|
+
background-color: transparent;
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
.main-slide img {
|
|
2076
|
+
max-height: 100%;
|
|
2077
|
+
max-width: 100%;
|
|
2078
|
+
width: 100%;
|
|
2079
|
+
height: auto;
|
|
2080
|
+
object-fit: contain;
|
|
2081
|
+
display: block;
|
|
2082
|
+
margin-left: auto;
|
|
2083
|
+
margin-right: auto;
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
.card--slider--wrapper {
|
|
2087
|
+
display: flex;
|
|
2088
|
+
aspect-ratio: 4.5/3;
|
|
2089
|
+
gap: 3%;
|
|
2090
|
+
width: 100%;
|
|
2091
|
+
height: 100%;
|
|
2092
|
+
}
|
|
2093
|
+
|
|
2094
|
+
@media screen and (min-width: 640px) {
|
|
2095
|
+
.card--slider--wrapper {
|
|
2096
|
+
aspect-ratio: unset;
|
|
2097
|
+
}
|
|
2098
|
+
}
|
|
2099
|
+
|
|
2100
|
+
img {
|
|
2101
|
+
-webkit-user-drag: none;
|
|
2102
|
+
pointer-events: none;
|
|
2103
|
+
}
|
|
2104
|
+
|
|
2105
|
+
.thumbnails {
|
|
2106
|
+
width: 20%;
|
|
2107
|
+
display: flex;
|
|
2108
|
+
flex-direction: column;
|
|
2109
|
+
gap: 1.9%;
|
|
2110
|
+
justify-content: start;
|
|
2111
|
+
overflow-y: auto;
|
|
2112
|
+
box-sizing: border-box;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
.thumbnail {
|
|
2116
|
+
cursor: pointer;
|
|
2117
|
+
opacity: 0.35;
|
|
2118
|
+
width: 100%;
|
|
2119
|
+
box-sizing: border-box;
|
|
2120
|
+
border: 2px solid var(--pbo-color-gray-300);
|
|
2121
|
+
}
|
|
2122
|
+
|
|
2123
|
+
.thumbnail.active {
|
|
2124
|
+
opacity: 1;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
.main-slide.active {
|
|
2128
|
+
display: block;
|
|
2129
|
+
}
|
|
2130
|
+
|
|
2131
|
+
.thumbnail img,
|
|
2132
|
+
.thumbnail pbo-image {
|
|
2133
|
+
display: block;
|
|
2134
|
+
width: 100%;
|
|
2135
|
+
height: auto;
|
|
2136
|
+
}
|
|
2137
|
+
`,Th=".splide__container{box-sizing:border-box;position:relative}.splide__list{backface-visibility:hidden;display:-ms-flexbox;display:flex;height:100%;margin:0!important;padding:0!important}.splide.is-initialized:not(.is-active) .splide__list{display:block}.splide__pagination{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-pack:center;justify-content:center;margin:0;pointer-events:none}.splide__pagination li{display:inline-block;line-height:1;list-style-type:none;margin:0;pointer-events:auto}.splide:not(.is-overflow) .splide__pagination{display:none}.splide__progress__bar{width:0}.splide{position:relative;visibility:hidden}.splide.is-initialized,.splide.is-rendered{visibility:visible}.splide__slide{backface-visibility:hidden;box-sizing:border-box;-ms-flex-negative:0;flex-shrink:0;list-style-type:none!important;margin:0;position:relative}.splide__slide img{vertical-align:bottom}.splide__spinner{animation:splide-loading 1s linear infinite;border:2px solid #999;border-left-color:transparent;border-radius:50%;bottom:0;contain:strict;display:inline-block;height:20px;left:0;margin:auto;position:absolute;right:0;top:0;width:20px}.splide__sr{clip:rect(0 0 0 0);border:0;height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.splide__toggle.is-active .splide__toggle__play,.splide__toggle__pause{display:none}.splide__toggle.is-active .splide__toggle__pause{display:inline}.splide__track{overflow:hidden;position:relative;z-index:0}@keyframes splide-loading{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.splide__track--draggable{-webkit-touch-callout:none;-webkit-user-select:none;-ms-user-select:none;user-select:none}.splide__track--fade>.splide__list>.splide__slide{margin:0!important;opacity:0;z-index:0}.splide__track--fade>.splide__list>.splide__slide.is-active{opacity:1;z-index:1}.splide--rtl{direction:rtl}.splide__track--ttb>.splide__list{display:block}.splide__arrow{-ms-flex-align:center;align-items:center;background:#ccc;border:0;border-radius:50%;cursor:pointer;display:-ms-flexbox;display:flex;height:2em;-ms-flex-pack:center;justify-content:center;opacity:.7;padding:0;position:absolute;top:50%;transform:translateY(-50%);width:2em;z-index:1}.splide__arrow svg{fill:#000;height:1.2em;width:1.2em}.splide__arrow:hover:not(:disabled){opacity:.9}.splide__arrow:disabled{opacity:.3}.splide__arrow:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide__arrow--prev{left:1em}.splide__arrow--prev svg{transform:scaleX(-1)}.splide__arrow--next{right:1em}.splide.is-focus-in .splide__arrow:focus{outline:3px solid #0bf;outline-offset:3px}.splide__pagination{bottom:.5em;left:0;padding:0 1em;position:absolute;right:0;z-index:1}.splide__pagination__page{background:#ccc;border:0;border-radius:50%;display:inline-block;height:8px;margin:3px;opacity:.7;padding:0;position:relative;transition:transform .2s linear;width:8px}.splide__pagination__page.is-active{background:#fff;transform:scale(1.4);z-index:1}.splide__pagination__page:hover{cursor:pointer;opacity:.9}.splide__pagination__page:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__pagination__page:focus{outline:3px solid #0bf;outline-offset:3px}.splide__progress__bar{background:#ccc;height:3px}.splide__slide{-webkit-tap-highlight-color:rgba(0,0,0,0)}.splide__slide:focus{outline:0}@supports (outline-offset:-3px){.splide__slide:focus-visible{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide__slide:focus-visible{border:3px solid #0bf}}@supports (outline-offset:-3px){.splide.is-focus-in .splide__slide:focus{outline:3px solid #0bf;outline-offset:-3px}}@media screen and (-ms-high-contrast:none){.splide.is-focus-in .splide__slide:focus{border:3px solid #0bf}.splide.is-focus-in .splide__track>.splide__list>.splide__slide:focus{border-color:#0bf}}.splide__toggle{cursor:pointer}.splide__toggle:focus-visible{outline:3px solid #0bf;outline-offset:3px}.splide.is-focus-in .splide__toggle:focus{outline:3px solid #0bf;outline-offset:3px}.splide__track--nav>.splide__list>.splide__slide{border:3px solid transparent;cursor:pointer}.splide__track--nav>.splide__list>.splide__slide.is-active{border:3px solid #000}.splide__arrows--rtl .splide__arrow--prev{left:auto;right:1em}.splide__arrows--rtl .splide__arrow--prev svg{transform:scaleX(1)}.splide__arrows--rtl .splide__arrow--next{left:1em;right:auto}.splide__arrows--rtl .splide__arrow--next svg{transform:scaleX(-1)}.splide__arrows--ttb .splide__arrow{left:50%;transform:translate(-50%)}.splide__arrows--ttb .splide__arrow--prev{top:1em}.splide__arrows--ttb .splide__arrow--prev svg{transform:rotate(-90deg)}.splide__arrows--ttb .splide__arrow--next{bottom:1em;top:auto}.splide__arrows--ttb .splide__arrow--next svg{transform:rotate(90deg)}.splide__pagination--ttb{bottom:0;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:auto;padding:1em 0;right:.5em;top:0}",fm=vt`
|
|
2138
|
+
:host,
|
|
2139
|
+
:host * {
|
|
2140
|
+
max-height: 100%;
|
|
2141
|
+
max-width: 100%;
|
|
2142
|
+
width: 100%;
|
|
2143
|
+
height: auto;
|
|
2144
|
+
object-fit: contain;
|
|
2145
|
+
display: block;
|
|
2146
|
+
margin-left: auto;
|
|
2147
|
+
margin-right: auto;
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
.skeleton {
|
|
2151
|
+
background: #f3f3f3;
|
|
2152
|
+
animation: pulse 1.5s infinite;
|
|
2153
|
+
height: auto;
|
|
2154
|
+
width: 100%;
|
|
2155
|
+
aspect-ratio: 3 / 4;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
img {
|
|
2159
|
+
width: 100%;
|
|
2160
|
+
height: auto;
|
|
2161
|
+
opacity: 0;
|
|
2162
|
+
transition: opacity 0.3s ease-in-out;
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
img.hidden {
|
|
2166
|
+
display: none;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
img.loaded {
|
|
2170
|
+
opacity: 1;
|
|
2171
|
+
display: block;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
@keyframes pulse {
|
|
2175
|
+
0% {
|
|
2176
|
+
background-color: #f3f3f3;
|
|
2177
|
+
}
|
|
2178
|
+
50% {
|
|
2179
|
+
background-color: #e0e0e0;
|
|
2180
|
+
}
|
|
2181
|
+
100% {
|
|
2182
|
+
background-color: #f3f3f3;
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
`;var gm=Object.defineProperty,mm=Object.getOwnPropertyDescriptor,pi=(n,t,e,i)=>{for(var r=i>1?void 0:i?mm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&gm(t,e,r),r};let ge=class extends Bt{constructor(){super(...arguments),this.skeletonHeight="2000px",this.skeletonWidth="1429px",this.src="",this.alt="",this.placeholder="",this.loaded=!1}handleSrcChange(){this.loaded=!1}handleError(){this.loaded=!0,this.placeholder&&(this.src=this.placeholder)}handleOnLoad(){this.loaded=!0}firstUpdated(){this.imgEl.onload=()=>this.handleOnLoad()}render(){return X`
|
|
2186
|
+
${this.loaded?"":X` <div class="skeleton"></div>`}
|
|
2187
|
+
<img
|
|
2188
|
+
src=${this.src}
|
|
2189
|
+
alt=${this.alt}
|
|
2190
|
+
class=${ni({loaded:this.loaded,hidden:!this.loaded})}
|
|
2191
|
+
@error=${()=>this.handleError()}
|
|
2192
|
+
/>
|
|
2193
|
+
`}};ge.styles=[Pt,fm];pi([O()],ge.prototype,"skeletonHeight",2);pi([O()],ge.prototype,"skeletonWidth",2);pi([O()],ge.prototype,"src",2);pi([O()],ge.prototype,"alt",2);pi([O()],ge.prototype,"placeholder",2);pi([$()],ge.prototype,"loaded",2);pi([q("img")],ge.prototype,"imgEl",2);pi([et("src")],ge.prototype,"handleSrcChange",1);ge=pi([Ot("pbo-image")],ge);var vm=Object.defineProperty,bm=Object.getOwnPropertyDescriptor,qt=(n,t,e,i)=>{for(var r=i>1?void 0:i?bm(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&vm(t,e,r),r};let Tt=class extends Bt{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(!ar()){t.preventDefault(),t.stopPropagation();return}this.openZoomedPreview()}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",e=>{var o,a;const{detail:i}=e,r=(o=this.shadowRoot)==null?void 0:o.querySelector("#handwritten-main-canvas"),s=(a=this.shadowRoot)==null?void 0:a.querySelector("#handwritten-zoomed-preview-canvas");r&&s&&(r.imageWidth=i.width,r.imageHeight=i.height,r.imageTop=i.top,r.imageLeft=i.left,s.imageWidth=i.width,s.imageHeight=i.height,s.imageTop=i.top,s.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,r,s,o;e&&(this.mainImageTemplates=[X`<pbo-image src="${e.medias.cover.url||"https://picsum.photos/id/1/300/400"}" alt="" />`,X`<pbo-type-canvas
|
|
2194
|
+
background-url=${e.medias.insert.url}
|
|
2195
|
+
message=${(i=this.livePreviewProps)==null?void 0:i.text}
|
|
2196
|
+
alignment=${((r=this.livePreviewProps)==null?void 0:r.alignment)||"left"}
|
|
2197
|
+
color=${(s=this.livePreviewProps)==null?void 0:s.color}
|
|
2198
|
+
font=${(o=this.livePreviewProps)==null?void 0:o.font}
|
|
2199
|
+
@click="${this.handleOpenZoomedClick}"
|
|
2200
|
+
></pbo-type-canvas>`,X`<pbo-image src="${e.medias.rendered_2.url||"https://picsum.photos/id/10/300/400"}" alt="" />`])}handleFocusIndexChange(t,e){var i,r,s,o;this.thumbnailElements.length!==0&&t!==e&&((i=this.thumbnailElements[t])==null||i.classList.remove("active"),(r=this.thumbnailElements[e])==null||r.classList.add("active"),(s=this.mainSlideElements[t])==null||s.classList.remove("active"),(o=this.mainSlideElements[e])==null||o.classList.add("active"),this.requestUpdate())}focusOn(t){if(t<0||t>=this.thumbnailElements.length){console.warn("Invalid index:",t);return}this.focusIndex=t}get mainSlides(){return this.card?[X`<pbo-image src="${this.card.medias.cover.url}" alt="" />`,X`<pbo-type-canvas
|
|
2201
|
+
background-url=${this.card.medias.insert.url}
|
|
2202
|
+
message=${this.livePreviewProps.text}
|
|
2203
|
+
alignment=${this.livePreviewProps.alignment}
|
|
2204
|
+
color=${this.livePreviewProps.color}
|
|
2205
|
+
font=${this.livePreviewProps.font}
|
|
2206
|
+
@click="${this.handleOpenZoomedClick}"
|
|
2207
|
+
></pbo-type-canvas>`,X`<img src="${this.card.medias.rendered_2.url}" alt="" />`][this.focusIndex]:[]}render(){var t,e,i,r,s,o,a,l,c,h,u,d,p,f,g,m,v,y,x,T;return X`
|
|
2208
|
+
<div class="card--slider--wrapper">
|
|
2209
|
+
<div id="thumbnails" class="thumbnails">
|
|
2210
|
+
<div class="thumbnail">
|
|
2211
|
+
<pbo-image src="${((t=this.card)==null?void 0:t.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
|
|
2212
|
+
</div>
|
|
2213
|
+
<div class="thumbnail">
|
|
2214
|
+
<pbo-image src="${((e=this.card)==null?void 0:e.medias.rendered_1.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
|
|
2215
|
+
</div>
|
|
2216
|
+
<div class="thumbnail">
|
|
2217
|
+
<pbo-image src="${((i=this.card)==null?void 0:i.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
|
|
2218
|
+
</div>
|
|
2219
|
+
</div>
|
|
2220
|
+
|
|
2221
|
+
<div class="main-slide-container">
|
|
2222
|
+
<div>
|
|
2223
|
+
<div class="main-slide" @click="${this.handleOpenZoomedClick}">
|
|
2224
|
+
<pbo-image src="${((r=this.card)==null?void 0:r.medias.cover.url)||"https://picsum.photos/id/1/300/400"}" alt="" />
|
|
2225
|
+
${ar()?X`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
|
|
2226
|
+
<svg
|
|
2227
|
+
stroke="currentColor"
|
|
2228
|
+
fill="none"
|
|
2229
|
+
stroke-width="2"
|
|
2230
|
+
viewBox="0 0 24 24"
|
|
2231
|
+
stroke-linecap="round"
|
|
2232
|
+
stroke-linejoin="round"
|
|
2233
|
+
height="1.25rem"
|
|
2234
|
+
width="1.25rem"
|
|
2235
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2236
|
+
style="color: rgb(74, 74, 74);"
|
|
2237
|
+
>
|
|
2238
|
+
<circle cx="11" cy="11" r="8"></circle>
|
|
2239
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
2240
|
+
<line x1="11" y1="8" x2="11" y2="14"></line>
|
|
2241
|
+
<line x1="8" y1="11" x2="14" y2="11"></line>
|
|
2242
|
+
</svg>
|
|
2243
|
+
</div>`:""}
|
|
2244
|
+
</div>
|
|
2245
|
+
<div class="main-slide" @click="${this.handleOpenZoomedClick}">
|
|
2246
|
+
${mo(this.type==="type"?X`<pbo-type-canvas
|
|
2247
|
+
background-url=${(s=this.card)==null?void 0:s.medias.insert.url}
|
|
2248
|
+
message=${(o=this.livePreviewProps)==null?void 0:o.text}
|
|
2249
|
+
alignment=${((a=this.livePreviewProps)==null?void 0:a.alignment)||"left"}
|
|
2250
|
+
color=${(l=this.livePreviewProps)==null?void 0:l.color}
|
|
2251
|
+
font=${(c=this.livePreviewProps)==null?void 0:c.font}
|
|
2252
|
+
@click="${this.handleOpenZoomedClick}"
|
|
2253
|
+
></pbo-type-canvas>`:X`<pbo-handwritten-canvas
|
|
2254
|
+
id="handwritten-main-canvas"
|
|
2255
|
+
background-url=${(h=this.card)==null?void 0:h.medias.insert.url}
|
|
2256
|
+
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
2257
|
+
@click="${this.handleOpenZoomedClick}"
|
|
2258
|
+
></pbo-handwritten-canvas>`)}
|
|
2259
|
+
${ar()?X`<div class="zoomed-preview-open-button">
|
|
2260
|
+
<svg
|
|
2261
|
+
stroke="currentColor"
|
|
2262
|
+
fill="none"
|
|
2263
|
+
stroke-width="2"
|
|
2264
|
+
viewBox="0 0 24 24"
|
|
2265
|
+
stroke-linecap="round"
|
|
2266
|
+
stroke-linejoin="round"
|
|
2267
|
+
height="1.25rem"
|
|
2268
|
+
width="1.25rem"
|
|
2269
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2270
|
+
style="color: rgb(74, 74, 74);"
|
|
2271
|
+
>
|
|
2272
|
+
<circle cx="11" cy="11" r="8"></circle>
|
|
2273
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
2274
|
+
<line x1="11" y1="8" x2="11" y2="14"></line>
|
|
2275
|
+
<line x1="8" y1="11" x2="14" y2="11"></line>
|
|
2276
|
+
</svg>
|
|
2277
|
+
</div>`:""}
|
|
2278
|
+
</div>
|
|
2279
|
+
<div class="main-slide" @click=${this.handleOpenZoomedClick}>
|
|
2280
|
+
<pbo-image src="${((u=this.card)==null?void 0:u.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}" alt="" />
|
|
2281
|
+
${ar()?X`<div class="zoomed-preview-open-button" @click="${this.handleOpenZoomedClick}">
|
|
2282
|
+
<svg
|
|
2283
|
+
stroke="currentColor"
|
|
2284
|
+
fill="none"
|
|
2285
|
+
stroke-width="2"
|
|
2286
|
+
viewBox="0 0 24 24"
|
|
2287
|
+
stroke-linecap="round"
|
|
2288
|
+
stroke-linejoin="round"
|
|
2289
|
+
height="1.25rem"
|
|
2290
|
+
width="1.25rem"
|
|
2291
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2292
|
+
style="color: rgb(74, 74, 74);"
|
|
2293
|
+
>
|
|
2294
|
+
<circle cx="11" cy="11" r="8"></circle>
|
|
2295
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
|
|
2296
|
+
<line x1="11" y1="8" x2="11" y2="14"></line>
|
|
2297
|
+
<line x1="8" y1="11" x2="14" y2="11"></line>
|
|
2298
|
+
</svg>
|
|
2299
|
+
</div>`:""}
|
|
2300
|
+
</div>
|
|
2301
|
+
</div>
|
|
2302
|
+
</div>
|
|
2303
|
+
</div>
|
|
2304
|
+
<pbo-drawer
|
|
2305
|
+
placement="bottom"
|
|
2306
|
+
style="${pe({"--size":"100%","--panel-background-color":"#454545ca"})}"
|
|
2307
|
+
contained
|
|
2308
|
+
class="editor__zoomed"
|
|
2309
|
+
>
|
|
2310
|
+
<pbo-zoomed-preview
|
|
2311
|
+
.close=${this.closeZoomedPreview}
|
|
2312
|
+
.formData=${this.livePreviewProps}
|
|
2313
|
+
.cardUrl=${(d=this.card)==null?void 0:d.medias.insert.url}
|
|
2314
|
+
>
|
|
2315
|
+
<img
|
|
2316
|
+
src="${((p=this.card)==null?void 0:p.medias.cover.url)||"https://picsum.photos/id/1/300/400"}"
|
|
2317
|
+
alt=""
|
|
2318
|
+
style=${pe({display:this.focusIndex===0?"block":"none"})}
|
|
2319
|
+
/>
|
|
2320
|
+
${mo(this.type==="type"?X`<pbo-type-canvas
|
|
2321
|
+
background-url=${(f=this.card)==null?void 0:f.medias.insert.url}
|
|
2322
|
+
message=${(g=this.livePreviewProps)==null?void 0:g.text}
|
|
2323
|
+
alignment=${((m=this.livePreviewProps)==null?void 0:m.alignment)||"left"}
|
|
2324
|
+
color=${(v=this.livePreviewProps)==null?void 0:v.color}
|
|
2325
|
+
font=${(y=this.livePreviewProps)==null?void 0:y.font}
|
|
2326
|
+
@click="${this.handleOpenZoomedClick}"
|
|
2327
|
+
style=${pe({display:this.focusIndex===1?"block":"none"})}
|
|
2328
|
+
></pbo-type-canvas>`:"")}
|
|
2329
|
+
${mo(this.type==="handwritten"?X`<pbo-handwritten-canvas
|
|
2330
|
+
id="handwritten-zoomed-preview-canvas"
|
|
2331
|
+
background-url=${(x=this.card)==null?void 0:x.medias.insert.url}
|
|
2332
|
+
handwritten-url=${this.handwrittenPreviewProps.processedFileUrl}
|
|
2333
|
+
@click="${this.handleOpenZoomedClick}"
|
|
2334
|
+
style=${pe({display:this.focusIndex===1?"block":"none"})}
|
|
2335
|
+
></pbo-handwritten-canvas>`:"")}
|
|
2336
|
+
<img
|
|
2337
|
+
src="${((T=this.card)==null?void 0:T.medias.rendered_2.url)||"https://picsum.photos/id/10/300/400"}"
|
|
2338
|
+
alt=""
|
|
2339
|
+
style=${pe({display:this.focusIndex===2?"block":"none"})}
|
|
2340
|
+
/>
|
|
2341
|
+
</pbo-zoomed-preview>
|
|
2342
|
+
</pbo-drawer>
|
|
2343
|
+
`}};Tt.styles=[Pt,pm,kn(Th)];Tt.dependencies={"fabric-example":ut,"pbo-image":ge};qt([O({type:Object})],Tt.prototype,"card",2);qt([O({type:Number,reflect:!0})],Tt.prototype,"focusIndex",2);qt([O({type:Object})],Tt.prototype,"livePreviewProps",2);qt([O()],Tt.prototype,"handwrittenPreviewProps",2);qt([O()],Tt.prototype,"type",2);qt([q("#thumbnails")],Tt.prototype,"thumbnailCarousel",2);qt([q("#main-carousel")],Tt.prototype,"mainCarousel",2);qt([q(".editor__zoomed")],Tt.prototype,"zoomedPreview",2);qt([q(".main-slide.active")],Tt.prototype,"activeMainSlide",2);qt([q("pbo-type-canvas")],Tt.prototype,"typeCanvas",2);qt([Jo(".thumbnail")],Tt.prototype,"thumbnailElements",2);qt([Jo(".main-slide")],Tt.prototype,"mainSlideElements",2);qt([$()],Tt.prototype,"mainImageTemplates",2);qt([et("card")],Tt.prototype,"handleCardChange",1);qt([et("focusIndex")],Tt.prototype,"handleFocusIndexChange",1);Tt=qt([Ot("pbo-editor-card-slider")],Tt);var _m=Object.defineProperty,ym=Object.getOwnPropertyDescriptor,te=(n,t,e,i)=>{for(var r=i>1?void 0:i?ym(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&_m(t,e,r),r};let Ft=class extends Bt{constructor(){super(...arguments),this.cardInnerImageUrl="../../../public/Greeting Card from Pairbo.png",this.card=null,this.formData={font:"Monsieur La Doulaise",text:"",color:"rgb(0,0,0)",alignment:"left"},this.handwrittenFormState={isLoading:!1,processedFileUrl:""},this.editorType="type",this.handleTypingFormChange=()=>{this.formData=this.typeForm.formData,this.slider.focusOn(1)},this.handelHandwrittenFormChange=t=>{this.handwrittenFormState=t.detail,this.slider.focusOn(1)},this.openZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!0)},this.closeZoomedPreview=()=>{this.zoomedPreview&&(this.zoomedPreview.open=!1)},this.handleEditorChange=t=>{this.editorType=t.detail.value}}firstUpdated(){this.addEventListener("handwritten-image-dimensions-changed",t=>{this.handwrittenForm.setDimensions(t.detail)}),this.typeForm.addEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.addEventListener("pbo-change",this.handelHandwrittenFormChange),document.addEventListener("pbo-zoomed-preview-open",()=>{this.openZoomedPreview()})}handleCardInnerImageUrlChange(){this.requestUpdate()}handleCardChange(){this.card&&(this.slider.card=this.card,this.requestUpdate(),this.typeForm.card=this.card,this.handwrittenForm.card=this.card)}disconnectedCallback(){this.typeForm.removeEventListener("pbo-change",this.handleTypingFormChange),this.handwrittenForm.removeEventListener("pbo-change",this.handelHandwrittenFormChange)}render(){var t;return X`
|
|
2344
|
+
<div class="editor">
|
|
2345
|
+
<div class="editor__card">
|
|
2346
|
+
<pbo-editor-card-slider
|
|
2347
|
+
focusIndex="0"
|
|
2348
|
+
.livePreviewProps=${this.formData}
|
|
2349
|
+
.handwrittenPreviewProps=${this.handwrittenFormState}
|
|
2350
|
+
type=${this.editorType}
|
|
2351
|
+
></pbo-editor-card-slider>
|
|
2352
|
+
</div>
|
|
2353
|
+
|
|
2354
|
+
<div class="editor__form">
|
|
2355
|
+
<pbo-editor-selector @pbo-change=${this.handleEditorChange}></pbo-editor-selector>
|
|
2356
|
+
<pbo-type-form
|
|
2357
|
+
.submitTypeForm=${this.submitTypeForm}
|
|
2358
|
+
style=${pe({display:this.editorType==="type"?"block":"none"})}
|
|
2359
|
+
></pbo-type-form>
|
|
2360
|
+
<pbo-handwritten-form
|
|
2361
|
+
style=${pe({display:this.editorType==="handwritten"?"block":"none"})}
|
|
2362
|
+
.submitHandwrittenForm=${this.submitHandwrittenForm}
|
|
2363
|
+
.getProcessedImg=${this.getProcessedImg}
|
|
2364
|
+
></pbo-handwritten-form>
|
|
2365
|
+
</div>
|
|
2366
|
+
</div>
|
|
2367
|
+
|
|
2368
|
+
<pbo-drawer
|
|
2369
|
+
placement="bottom"
|
|
2370
|
+
style="${pe({"--size":"100%","--panel-background-color":"#454545ca"})}"
|
|
2371
|
+
contained
|
|
2372
|
+
class="editor__zoomed"
|
|
2373
|
+
>
|
|
2374
|
+
<pbo-zoomed-preview
|
|
2375
|
+
.formData=${this.formData}
|
|
2376
|
+
.handwrittenPreviewProps=${this.handwrittenFormState}
|
|
2377
|
+
.cardUrl=${(t=this.card)==null?void 0:t.medias.insert.url}
|
|
2378
|
+
.close=${this.closeZoomedPreview}
|
|
2379
|
+
></pbo-zoomed-preview>
|
|
2380
|
+
</pbo-drawer>
|
|
2381
|
+
`}};Ft.styles=[Pt,cm];Ft.dependencies={"editor-card-slider":Tt,"fabric-example":ut,"pbo-type-form":st};te([O({type:String,reflect:!0})],Ft.prototype,"cardInnerImageUrl",2);te([O({type:Object})],Ft.prototype,"card",2);te([O()],Ft.prototype,"submitTypeForm",2);te([O()],Ft.prototype,"submitHandwrittenForm",2);te([O()],Ft.prototype,"getProcessedImg",2);te([q("pbo-type-form")],Ft.prototype,"typeForm",2);te([q("pbo-handwritten-form")],Ft.prototype,"handwrittenForm",2);te([q("pbo-editor-card-slider")],Ft.prototype,"slider",2);te([q(".editor__zoomed")],Ft.prototype,"zoomedPreview",2);te([$()],Ft.prototype,"formData",2);te([$()],Ft.prototype,"handwrittenFormState",2);te([$()],Ft.prototype,"editorType",2);te([et("cardInnerImageUrl")],Ft.prototype,"handleCardInnerImageUrlChange",1);te([et("card")],Ft.prototype,"handleCardChange",1);Ft=te([Ot("pbo-editor")],Ft);const Db=Ft,Pb=st,Ab=Tt,xm=vt`
|
|
2382
|
+
:host {
|
|
2383
|
+
display: block;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
::slotted([slot="title"]) {
|
|
2387
|
+
font-size: var(--pbo-font-size-x-large);
|
|
2388
|
+
font-weight: var(--pbo-font-weight-normal);
|
|
2389
|
+
margin-top: var(--pbo-spacing-medium);
|
|
2390
|
+
margin-bottom: var(--pbo-spacing-x-small);
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
:host(:first-of-type) ::slotted([slot="title"]) {
|
|
2394
|
+
margin-top: 0; /* Remove top margin for first category */
|
|
2395
|
+
}
|
|
2396
|
+
.category-container {
|
|
2397
|
+
margin-left: auto;
|
|
2398
|
+
margin-right: auto;
|
|
2399
|
+
}
|
|
2400
|
+
.splide {
|
|
2401
|
+
margin: 0 auto;
|
|
2402
|
+
width: 100%;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
.splide__slide {
|
|
2406
|
+
width: 100%;
|
|
2407
|
+
aspect-ratio: 3/4;
|
|
2408
|
+
position: relative;
|
|
2409
|
+
overflow: hidden;
|
|
2410
|
+
border: 2px solid var(--pbo-color-gray-200);
|
|
2411
|
+
}
|
|
2412
|
+
|
|
2413
|
+
.splide__slide::before {
|
|
2414
|
+
content: "";
|
|
2415
|
+
position: absolute;
|
|
2416
|
+
top: 0;
|
|
2417
|
+
left: 0;
|
|
2418
|
+
width: 100%;
|
|
2419
|
+
height: 100%;
|
|
2420
|
+
background: transparent;
|
|
2421
|
+
box-shadow: inset 0 0 0 0 rgba(0, 0, 0, 0.1);
|
|
2422
|
+
transition: all 0.3s ease;
|
|
2423
|
+
z-index: 1;
|
|
2424
|
+
pointer-events: none;
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
.splide__slide:hover::before {
|
|
2428
|
+
box-shadow: inset 0 0 20px 3px rgba(0, 0, 0, 0.3);
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
.splide__slide img {
|
|
2432
|
+
position: absolute;
|
|
2433
|
+
top: 0;
|
|
2434
|
+
left: 0;
|
|
2435
|
+
width: 100%;
|
|
2436
|
+
height: auto;
|
|
2437
|
+
object-fit: contain;
|
|
2438
|
+
cursor: pointer;
|
|
2439
|
+
transition: all 0.3s ease;
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
.splide__slide img:hover {
|
|
2443
|
+
transform: scale(1.1);
|
|
2444
|
+
}
|
|
2445
|
+
`;function wm(n,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(n,i.key,i)}}function Cm(n,t,e){return t&&wm(n.prototype,t),Object.defineProperty(n,"prototype",{writable:!1}),n}/*!
|
|
2446
|
+
* Splide.js
|
|
2447
|
+
* Version : 4.1.4
|
|
2448
|
+
* License : MIT
|
|
2449
|
+
* Copyright: 2022 Naotoshi Fujita
|
|
2450
|
+
*/var Wl="(prefers-reduced-motion: reduce)",lr=1,Sm=2,gr=3,Sr=4,fs=5,on=6,Sn=7,Tm={CREATED:lr,MOUNTED:Sm,IDLE:gr,MOVING:Sr,SCROLLING:fs,DRAGGING:on,DESTROYED:Sn};function ci(n){n.length=0}function Ai(n,t,e){return Array.prototype.slice.call(n,t,e)}function ot(n){return n.bind.apply(n,[null].concat(Ai(arguments,1)))}var Eh=setTimeout,Ho=function(){};function Gl(n){return requestAnimationFrame(n)}function $n(n,t){return typeof t===n}function ts(n){return!Ca(n)&&$n("object",n)}var wa=Array.isArray,Oh=ot($n,"function"),Ci=ot($n,"string"),gs=ot($n,"undefined");function Ca(n){return n===null}function kh(n){try{return n instanceof(n.ownerDocument.defaultView||window).HTMLElement}catch{return!1}}function ms(n){return wa(n)?n:[n]}function we(n,t){ms(n).forEach(t)}function Sa(n,t){return n.indexOf(t)>-1}function an(n,t){return n.push.apply(n,ms(t)),n}function ti(n,t,e){n&&we(t,function(i){i&&n.classList[e?"add":"remove"](i)})}function Ve(n,t){ti(n,Ci(t)?t.split(" "):t,!0)}function vs(n,t){we(t,n.appendChild.bind(n))}function Ta(n,t){we(n,function(e){var i=(t||e).parentNode;i&&i.insertBefore(e,t)})}function es(n,t){return kh(n)&&(n.msMatchesSelector||n.matches).call(n,t)}function Dh(n,t){var e=n?Ai(n.children):[];return t?e.filter(function(i){return es(i,t)}):e}function bs(n,t){return t?Dh(n,t)[0]:n.firstElementChild}var is=Object.keys;function $i(n,t,e){return n&&(e?is(n).reverse():is(n)).forEach(function(i){i!=="__proto__"&&t(n[i],i)}),n}function rs(n){return Ai(arguments,1).forEach(function(t){$i(t,function(e,i){n[i]=t[i]})}),n}function bi(n){return Ai(arguments,1).forEach(function(t){$i(t,function(e,i){wa(e)?n[i]=e.slice():ts(e)?n[i]=bi({},ts(n[i])?n[i]:{},e):n[i]=e})}),n}function Ul(n,t){we(t||is(n),function(e){delete n[e]})}function He(n,t){we(n,function(e){we(t,function(i){e&&e.removeAttribute(i)})})}function U(n,t,e){ts(t)?$i(t,function(i,r){U(n,r,i)}):we(n,function(i){Ca(e)||e===""?He(i,t):i.setAttribute(t,String(e))})}function dr(n,t,e){var i=document.createElement(n);return t&&(Ci(t)?Ve(i,t):U(i,t)),e&&vs(e,i),i}function Ee(n,t,e){if(gs(e))return getComputedStyle(n)[t];Ca(e)||(n.style[t]=""+e)}function ss(n,t){Ee(n,"display",t)}function Ph(n){n.setActive&&n.setActive()||n.focus({preventScroll:!0})}function De(n,t){return n.getAttribute(t)}function Yl(n,t){return n&&n.classList.contains(t)}function be(n){return n.getBoundingClientRect()}function Ui(n){we(n,function(t){t&&t.parentNode&&t.parentNode.removeChild(t)})}function Ah(n){return bs(new DOMParser().parseFromString(n,"text/html").body)}function qe(n,t){n.preventDefault(),t&&(n.stopPropagation(),n.stopImmediatePropagation())}function Mh(n,t){return n&&n.querySelector(t)}function Ea(n,t){return t?Ai(n.querySelectorAll(t)):[]}function ei(n,t){ti(n,t,!1)}function $o(n){return n.timeStamp}function Li(n){return Ci(n)?n:n?n+"px":""}var _s="splide",Oa="data-"+_s;function Gr(n,t){if(!n)throw new Error("["+_s+"] "+(t||""))}var Si=Math.min,Tn=Math.max,En=Math.floor,ns=Math.ceil,se=Math.abs;function Ih(n,t,e){return se(n-t)<e}function ln(n,t,e,i){var r=Si(t,e),s=Tn(t,e);return i?r<n&&n<s:r<=n&&n<=s}function er(n,t,e){var i=Si(t,e),r=Tn(t,e);return Si(Tn(i,n),r)}function Wo(n){return+(n>0)-+(n<0)}function Go(n,t){return we(t,function(e){n=n.replace("%s",""+e)}),n}function ka(n){return n<10?"0"+n:""+n}var Xl={};function Em(n){return""+n+ka(Xl[n]=(Xl[n]||0)+1)}function Lh(){var n=[];function t(o,a,l,c){r(o,a,function(h,u,d){var p="addEventListener"in h,f=p?h.removeEventListener.bind(h,u,l,c):h.removeListener.bind(h,l);p?h.addEventListener(u,l,c):h.addListener(l),n.push([h,u,d,l,f])})}function e(o,a,l){r(o,a,function(c,h,u){n=n.filter(function(d){return d[0]===c&&d[1]===h&&d[2]===u&&(!l||d[3]===l)?(d[4](),!1):!0})})}function i(o,a,l){var c,h=!0;return typeof CustomEvent=="function"?c=new CustomEvent(a,{bubbles:h,detail:l}):(c=document.createEvent("CustomEvent"),c.initCustomEvent(a,h,!1,l)),o.dispatchEvent(c),c}function r(o,a,l){we(o,function(c){c&&we(a,function(h){h.split(" ").forEach(function(u){var d=u.split(".");l(c,d[0],d[1])})})})}function s(){n.forEach(function(o){o[4]()}),ci(n)}return{bind:t,unbind:e,dispatch:i,destroy:s}}var Zi="mounted",Kl="ready",Ti="move",ys="moved",Fh="click",Om="active",km="inactive",Dm="visible",Pm="hidden",Mt="refresh",ce="updated",os="resize",Da="resized",Am="drag",Mm="dragging",Im="dragged",Pa="scroll",Tr="scrolled",Lm="overflow",jh="destroy",Fm="arrows:mounted",jm="arrows:updated",Rm="pagination:mounted",Bm="pagination:updated",Rh="navigation:mounted",Bh="autoplay:play",Nm="autoplay:playing",Nh="autoplay:pause",zh="lazyload:loaded",Vh="sk",Hh="sh",On="ei";function mt(n){var t=n?n.event.bus:document.createDocumentFragment(),e=Lh();function i(s,o){e.bind(t,ms(s).join(" "),function(a){o.apply(o,wa(a.detail)?a.detail:[])})}function r(s){e.dispatch(t,s,Ai(arguments,1))}return n&&n.event.on(jh,e.destroy),rs(e,{bus:t,on:i,off:ot(e.unbind,t),emit:r})}function Wn(n,t,e,i){var r=Date.now,s,o=0,a,l=!0,c=0;function h(){if(!l){if(o=n?Si((r()-s)/n,1):1,e&&e(o),o>=1&&(t(),s=r(),i&&++c>=i))return d();a=Gl(h)}}function u(v){v||f(),s=r()-(v?o*n:0),l=!1,a=Gl(h)}function d(){l=!0}function p(){s=r(),o=0,e&&e(o)}function f(){a&&cancelAnimationFrame(a),o=0,a=0,l=!0}function g(v){n=v}function m(){return l}return{start:u,rewind:p,pause:d,cancel:f,set:g,isPaused:m}}function zm(n){var t=n;function e(r){t=r}function i(r){return Sa(ms(r),t)}return{set:e,is:i}}function Vm(n,t){var e=Wn(0,n,null,1);return function(){e.isPaused()&&e.start()}}function Hm(n,t,e){var i=n.state,r=e.breakpoints||{},s=e.reducedMotion||{},o=Lh(),a=[];function l(){var f=e.mediaQuery==="min";is(r).sort(function(g,m){return f?+g-+m:+m-+g}).forEach(function(g){h(r[g],"("+(f?"min":"max")+"-width:"+g+"px)")}),h(s,Wl),u()}function c(f){f&&o.destroy()}function h(f,g){var m=matchMedia(g);o.bind(m,"change",u),a.push([f,m])}function u(){var f=i.is(Sn),g=e.direction,m=a.reduce(function(v,y){return bi(v,y[1].matches?y[0]:{})},{});Ul(e),p(m),e.destroy?n.destroy(e.destroy==="completely"):f?(c(!0),n.mount()):g!==e.direction&&n.refresh()}function d(f){matchMedia(Wl).matches&&(f?bi(e,s):Ul(e,is(s)))}function p(f,g,m){bi(e,f),g&&bi(Object.getPrototypeOf(e),f),(m||!i.is(lr))&&n.emit(ce,e)}return{setup:l,destroy:c,reduce:d,set:p}}var Gn="Arrow",Un=Gn+"Left",Yn=Gn+"Right",$h=Gn+"Up",Wh=Gn+"Down",ql="rtl",Xn="ttb",vo={width:["height"],left:["top","right"],right:["bottom","left"],x:["y"],X:["Y"],Y:["X"],ArrowLeft:[$h,Yn],ArrowRight:[Wh,Un]};function $m(n,t,e){function i(s,o,a){a=a||e.direction;var l=a===ql&&!o?1:a===Xn?0:-1;return vo[s]&&vo[s][l]||s.replace(/width|left|right/i,function(c,h){var u=vo[c.toLowerCase()][l]||c;return h>0?u.charAt(0).toUpperCase()+u.slice(1):u})}function r(s){return s*(e.direction===ql?1:-1)}return{resolve:i,orient:r}}var si="role",pr="tabindex",Wm="disabled",Me="aria-",xs=Me+"controls",Gh=Me+"current",Zl=Me+"selected",ye=Me+"label",Aa=Me+"labelledby",Uh=Me+"hidden",Ma=Me+"orientation",as=Me+"roledescription",Jl=Me+"live",Ql=Me+"busy",tc=Me+"atomic",Ia=[si,pr,Wm,xs,Gh,ye,Aa,Uh,Ma,as],We=_s+"__",Mi="is-",bo=_s,ec=We+"track",Gm=We+"list",Kn=We+"slide",Yh=Kn+"--clone",Um=Kn+"__container",La=We+"arrows",qn=We+"arrow",Xh=qn+"--prev",Kh=qn+"--next",Zn=We+"pagination",qh=Zn+"__page",Ym=We+"progress",Xm=Ym+"__bar",Km=We+"toggle",qm=We+"spinner",Zm=We+"sr",Jm=Mi+"initialized",Yi=Mi+"active",Zh=Mi+"prev",Jh=Mi+"next",Uo=Mi+"visible",Yo=Mi+"loading",Qh=Mi+"focus-in",tu=Mi+"overflow",Qm=[Yi,Uo,Zh,Jh,Yo,Qh,tu],tv={slide:Kn,clone:Yh,arrows:La,arrow:qn,prev:Xh,next:Kh,pagination:Zn,page:qh,spinner:qm};function ev(n,t){if(Oh(n.closest))return n.closest(t);for(var e=n;e&&e.nodeType===1&&!es(e,t);)e=e.parentElement;return e}var iv=5,ic=200,eu="touchstart mousedown",_o="touchmove mousemove",yo="touchend touchcancel mouseup click";function rv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=n.root,a=e.i18n,l={},c=[],h=[],u=[],d,p,f;function g(){x(),T(),y()}function m(){r(Mt,v),r(Mt,g),r(ce,y),s(document,eu+" keydown",function(C){f=C.type==="keydown"},{capture:!0}),s(o,"focusin",function(){ti(o,Qh,!!f)})}function v(C){var S=Ia.concat("style");ci(c),ei(o,h),ei(d,u),He([d,p],S),He(o,C?S:["style",as])}function y(){ei(o,h),ei(d,u),h=A(bo),u=A(ec),Ve(o,h),Ve(d,u),U(o,ye,e.label),U(o,Aa,e.labelledby)}function x(){d=E("."+ec),p=bs(d,"."+Gm),Gr(d&&p,"A track/list element is missing."),an(c,Dh(p,"."+Kn+":not(."+Yh+")")),$i({arrows:La,pagination:Zn,prev:Xh,next:Kh,bar:Xm,toggle:Km},function(C,S){l[S]=E("."+C)}),rs(l,{root:o,track:d,list:p,slides:c})}function T(){var C=o.id||Em(_s),S=e.role;o.id=C,d.id=d.id||C+"-track",p.id=p.id||C+"-list",!De(o,si)&&o.tagName!=="SECTION"&&S&&U(o,si,S),U(o,as,a.carousel),U(p,si,"presentation")}function E(C){var S=Mh(o,C);return S&&ev(S,"."+bo)===o?S:void 0}function A(C){return[C+"--"+e.type,C+"--"+e.direction,e.drag&&C+"--draggable",e.isNavigation&&C+"--nav",C===bo&&Yi]}return rs(l,{setup:g,mount:m,destroy:v})}var mr="slide",Er="loop",ws="fade";function sv(n,t,e,i){var r=mt(n),s=r.on,o=r.emit,a=r.bind,l=n.Components,c=n.root,h=n.options,u=h.isNavigation,d=h.updateOnMove,p=h.i18n,f=h.pagination,g=h.slideFocus,m=l.Direction.resolve,v=De(i,"style"),y=De(i,ye),x=e>-1,T=bs(i,"."+Um),E;function A(){x||(i.id=c.id+"-slide"+ka(t+1),U(i,si,f?"tabpanel":"group"),U(i,as,p.slide),U(i,ye,y||Go(p.slideLabel,[t+1,n.length]))),C()}function C(){a(i,"click",ot(o,Fh,B)),a(i,"keydown",ot(o,Vh,B)),s([ys,Hh,Tr],D),s(Rh,F),d&&s(Ti,j)}function S(){E=!0,r.destroy(),ei(i,Qm),He(i,Ia),U(i,"style",v),U(i,ye,y||"")}function F(){var N=n.splides.map(function(M){var H=M.splide.Components.Slides.getAt(t);return H?H.slide.id:""}).join(" ");U(i,ye,Go(p.slideX,(x?e:t)+1)),U(i,xs,N),U(i,si,g?"button":""),g&&He(i,as)}function j(){E||D()}function D(){if(!E){var N=n.index;k(),P(),ti(i,Zh,t===N-1),ti(i,Jh,t===N+1)}}function k(){var N=V();N!==Yl(i,Yi)&&(ti(i,Yi,N),U(i,Gh,u&&N||""),o(N?Om:km,B))}function P(){var N=Y(),M=!N&&(!V()||x);if(n.state.is([Sr,fs])||U(i,Uh,M||""),U(Ea(i,h.focusableNodes||""),pr,M?-1:""),g&&U(i,pr,M?-1:0),N!==Yl(i,Uo)&&(ti(i,Uo,N),o(N?Dm:Pm,B)),!N&&document.activeElement===i){var H=l.Slides.getAt(n.index);H&&Ph(H.slide)}}function L(N,M,H){Ee(H&&T||i,N,M)}function V(){var N=n.index;return N===t||h.cloneStatus&&N===e}function Y(){if(n.is(ws))return V();var N=be(l.Elements.track),M=be(i),H=m("left",!0),J=m("right",!0);return En(N[H])<=ns(M[H])&&En(M[J])<=ns(N[J])}function Z(N,M){var H=se(N-t);return!x&&(h.rewind||n.is(Er))&&(H=Si(H,n.length-H)),H<=M}var B={index:t,slideIndex:e,slide:i,container:T,isClone:x,mount:A,destroy:S,update:D,style:L,isWithin:Z};return B}function nv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=i.bind,a=t.Elements,l=a.slides,c=a.list,h=[];function u(){d(),r(Mt,p),r(Mt,d)}function d(){l.forEach(function(D,k){g(D,k,-1)})}function p(){E(function(D){D.destroy()}),ci(h)}function f(){E(function(D){D.update()})}function g(D,k,P){var L=sv(n,k,P,D);L.mount(),h.push(L),h.sort(function(V,Y){return V.index-Y.index})}function m(D){return D?A(function(k){return!k.isClone}):h}function v(D){var k=t.Controller,P=k.toIndex(D),L=k.hasFocus()?1:e.perPage;return A(function(V){return ln(V.index,P,P+L-1)})}function y(D){return A(D)[0]}function x(D,k){we(D,function(P){if(Ci(P)&&(P=Ah(P)),kh(P)){var L=l[k];L?Ta(P,L):vs(c,P),Ve(P,e.classes.slide),S(P,ot(s,os))}}),s(Mt)}function T(D){Ui(A(D).map(function(k){return k.slide})),s(Mt)}function E(D,k){m(k).forEach(D)}function A(D){return h.filter(Oh(D)?D:function(k){return Ci(D)?es(k.slide,D):Sa(ms(D),k.index)})}function C(D,k,P){E(function(L){L.style(D,k,P)})}function S(D,k){var P=Ea(D,"img"),L=P.length;L?P.forEach(function(V){o(V,"load error",function(){--L||k()})}):k()}function F(D){return D?l.length:h.length}function j(){return h.length>e.perPage}return{mount:u,destroy:p,update:f,register:g,get:m,getIn:v,getAt:y,add:x,remove:T,forEach:E,filter:A,style:C,getLength:F,isEnough:j}}function ov(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.emit,a=t.Slides,l=t.Direction.resolve,c=t.Elements,h=c.root,u=c.track,d=c.list,p=a.getAt,f=a.style,g,m,v;function y(){x(),s(window,"resize load",Vm(ot(o,os))),r([ce,Mt],x),r(os,T)}function x(){g=e.direction===Xn,Ee(h,"maxWidth",Li(e.width)),Ee(u,l("paddingLeft"),E(!1)),Ee(u,l("paddingRight"),E(!0)),T(!0)}function T(B){var N=be(h);(B||m.width!==N.width||m.height!==N.height)&&(Ee(u,"height",A()),f(l("marginRight"),Li(e.gap)),f("width",S()),f("height",F(),!0),m=N,o(Da),v!==(v=Z())&&(ti(h,tu,v),o(Lm,v)))}function E(B){var N=e.padding,M=l(B?"right":"left");return N&&Li(N[M]||(ts(N)?0:N))||"0px"}function A(){var B="";return g&&(B=C(),Gr(B,"height or heightRatio is missing."),B="calc("+B+" - "+E(!1)+" - "+E(!0)+")"),B}function C(){return Li(e.height||be(d).width*e.heightRatio)}function S(){return e.autoWidth?null:Li(e.fixedWidth)||(g?"":j())}function F(){return Li(e.fixedHeight)||(g?e.autoHeight?null:j():C())}function j(){var B=Li(e.gap);return"calc((100%"+(B&&" + "+B)+")/"+(e.perPage||1)+(B&&" - "+B)+")"}function D(){return be(d)[l("width")]}function k(B,N){var M=p(B||0);return M?be(M.slide)[l("width")]+(N?0:V()):0}function P(B,N){var M=p(B);if(M){var H=be(M.slide)[l("right")],J=be(d)[l("left")];return se(H-J)+(N?0:V())}return 0}function L(B){return P(n.length-1)-P(0)+k(0,B)}function V(){var B=p(0);return B&&parseFloat(Ee(B.slide,l("marginRight")))||0}function Y(B){return parseFloat(Ee(u,l("padding"+(B?"Right":"Left"))))||0}function Z(){return n.is(ws)||L(!0)>D()}return{mount:y,resize:T,listSize:D,slideSize:k,sliderSize:L,totalSize:P,getPadding:Y,isOverflow:Z}}var av=2;function lv(n,t,e){var i=mt(n),r=i.on,s=t.Elements,o=t.Slides,a=t.Direction.resolve,l=[],c;function h(){r(Mt,u),r([ce,os],p),(c=m())&&(f(c),t.Layout.resize(!0))}function u(){d(),h()}function d(){Ui(l),ci(l),i.destroy()}function p(){var v=m();c!==v&&(c<v||!v)&&i.emit(Mt)}function f(v){var y=o.get().slice(),x=y.length;if(x){for(;y.length<v;)an(y,y);an(y.slice(-v),y.slice(0,v)).forEach(function(T,E){var A=E<v,C=g(T.slide,E);A?Ta(C,y[0].slide):vs(s.list,C),an(l,C),o.register(C,E-v+(A?0:x),T.index)})}}function g(v,y){var x=v.cloneNode(!0);return Ve(x,e.classes.clone),x.id=n.root.id+"-clone"+ka(y+1),x}function m(){var v=e.clones;if(!n.is(Er))v=0;else if(gs(v)){var y=e[a("fixedWidth")]&&t.Layout.slideSize(0),x=y&&ns(be(s.track)[a("width")]/y);v=x||e[a("autoWidth")]&&n.length||e.perPage*av}return v}return{mount:h,destroy:d}}function cv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=n.state.set,a=t.Layout,l=a.slideSize,c=a.getPadding,h=a.totalSize,u=a.listSize,d=a.sliderSize,p=t.Direction,f=p.resolve,g=p.orient,m=t.Elements,v=m.list,y=m.track,x;function T(){x=t.Transition,r([Zi,Da,ce,Mt],E)}function E(){t.Controller.isBusy()||(t.Scroll.cancel(),C(n.index),t.Slides.update())}function A(M,H,J,bt){M!==H&&B(M>J)&&(D(),S(j(L(),M>J),!0)),o(Sr),s(Ti,H,J,M),x.start(H,function(){o(gr),s(ys,H,J,M),bt&&bt()})}function C(M){S(P(M,!0))}function S(M,H){if(!n.is(ws)){var J=H?M:F(M);Ee(v,"transform","translate"+f("X")+"("+J+"px)"),M!==J&&s(Hh)}}function F(M){if(n.is(Er)){var H=k(M),J=H>t.Controller.getEnd(),bt=H<0;(bt||J)&&(M=j(M,J))}return M}function j(M,H){var J=M-Z(H),bt=d();return M-=g(bt*(ns(se(J)/bt)||1))*(H?1:-1),M}function D(){S(L(),!0),x.cancel()}function k(M){for(var H=t.Slides.get(),J=0,bt=1/0,nt=0;nt<H.length;nt++){var he=H[nt].index,I=se(P(he,!0)-M);if(I<=bt)bt=I,J=he;else break}return J}function P(M,H){var J=g(h(M-1)-Y(M));return H?V(J):J}function L(){var M=f("left");return be(v)[M]-be(y)[M]+g(c(!1))}function V(M){return e.trimSpace&&n.is(mr)&&(M=er(M,0,g(d(!0)-u()))),M}function Y(M){var H=e.focus;return H==="center"?(u()-l(M,!0))/2:+H*l(M)||0}function Z(M){return P(M?t.Controller.getEnd():0,!!e.trimSpace)}function B(M){var H=g(j(L(),M));return M?H>=0:H<=v[f("scrollWidth")]-be(y)[f("width")]}function N(M,H){H=gs(H)?L():H;var J=M!==!0&&g(H)<g(Z(!1)),bt=M!==!1&&g(H)>g(Z(!0));return J||bt}return{mount:T,move:A,jump:C,translate:S,shift:j,cancel:D,toIndex:k,toPosition:P,getPosition:L,getLimit:Z,exceededLimit:N,reposition:E}}function hv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=t.Move,a=o.getPosition,l=o.getLimit,c=o.toPosition,h=t.Slides,u=h.isEnough,d=h.getLength,p=e.omitEnd,f=n.is(Er),g=n.is(mr),m=ot(L,!1),v=ot(L,!0),y=e.start||0,x,T=y,E,A,C;function S(){F(),r([ce,Mt,On],F),r(Da,j)}function F(){E=d(!0),A=e.perMove,C=e.perPage,x=B();var I=er(y,0,p?x:E-1);I!==y&&(y=I,o.reposition())}function j(){x!==B()&&s(On)}function D(I,tt,$t){if(!he()){var at=P(I),lt=Z(at);lt>-1&&(tt||lt!==y)&&(J(lt),o.move(at,lt,T,$t))}}function k(I,tt,$t,at){t.Scroll.scroll(I,tt,$t,function(){var lt=Z(o.toIndex(a()));J(p?Si(lt,x):lt),at&&at()})}function P(I){var tt=y;if(Ci(I)){var $t=I.match(/([+\-<>])(\d+)?/)||[],at=$t[1],lt=$t[2];at==="+"||at==="-"?tt=V(y+ +(""+at+(+lt||1)),y):at===">"?tt=lt?N(+lt):m(!0):at==="<"&&(tt=v(!0))}else tt=f?I:er(I,0,x);return tt}function L(I,tt){var $t=A||(nt()?1:C),at=V(y+$t*(I?-1:1),y,!(A||nt()));return at===-1&&g&&!Ih(a(),l(!I),1)?I?0:x:tt?at:Z(at)}function V(I,tt,$t){if(u()||nt()){var at=Y(I);at!==I&&(tt=I,I=at,$t=!1),I<0||I>x?!A&&(ln(0,I,tt,!0)||ln(x,tt,I,!0))?I=N(M(I)):f?I=$t?I<0?-(E%C||C):E:I:e.rewind?I=I<0?x:0:I=-1:$t&&I!==tt&&(I=N(M(tt)+(I<tt?-1:1)))}else I=-1;return I}function Y(I){if(g&&e.trimSpace==="move"&&I!==y)for(var tt=a();tt===c(I,!0)&&ln(I,0,n.length-1,!e.rewind);)I<y?--I:++I;return I}function Z(I){return f?(I+E)%E||0:I}function B(){for(var I=E-(nt()||f&&A?1:C);p&&I-- >0;)if(c(E-1,!0)!==c(I,!0)){I++;break}return er(I,0,E-1)}function N(I){return er(nt()?I:C*I,0,x)}function M(I){return nt()?Si(I,x):En((I>=x?E-1:I)/C)}function H(I){var tt=o.toIndex(I);return g?er(tt,0,x):tt}function J(I){I!==y&&(T=y,y=I)}function bt(I){return I?T:y}function nt(){return!gs(e.focus)||e.isNavigation}function he(){return n.state.is([Sr,fs])&&!!e.waitForTransition}return{mount:S,go:D,scroll:k,getNext:m,getPrev:v,getAdjacent:L,getEnd:B,setIndex:J,getIndex:bt,toIndex:N,toPage:M,toDest:H,hasFocus:nt,isBusy:he}}var uv="http://www.w3.org/2000/svg",dv="m15.5 0.932-4.3 4.38 14.5 14.6-14.5 14.5 4.3 4.4 14.6-14.6 4.4-4.3-4.4-4.4-14.6-14.6z",Qs=40;function pv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.emit,a=e.classes,l=e.i18n,c=t.Elements,h=t.Controller,u=c.arrows,d=c.track,p=u,f=c.prev,g=c.next,m,v,y={};function x(){E(),r(ce,T)}function T(){A(),x()}function E(){var k=e.arrows;k&&!(f&&g)&&F(),f&&g&&(rs(y,{prev:f,next:g}),ss(p,k?"":"none"),Ve(p,v=La+"--"+e.direction),k&&(C(),D(),U([f,g],xs,d.id),o(Fm,f,g)))}function A(){i.destroy(),ei(p,v),m?(Ui(u?[f,g]:p),f=g=null):He([f,g],Ia)}function C(){r([Zi,ys,Mt,Tr,On],D),s(g,"click",ot(S,">")),s(f,"click",ot(S,"<"))}function S(k){h.go(k,!0)}function F(){p=u||dr("div",a.arrows),f=j(!0),g=j(!1),m=!0,vs(p,[f,g]),!u&&Ta(p,d)}function j(k){var P='<button class="'+a.arrow+" "+(k?a.prev:a.next)+'" type="button"><svg xmlns="'+uv+'" viewBox="0 0 '+Qs+" "+Qs+'" width="'+Qs+'" height="'+Qs+'" focusable="false"><path d="'+(e.arrowPath||dv)+'" />';return Ah(P)}function D(){if(f&&g){var k=n.index,P=h.getPrev(),L=h.getNext(),V=P>-1&&k<P?l.last:l.prev,Y=L>-1&&k>L?l.first:l.next;f.disabled=P<0,g.disabled=L<0,U(f,ye,V),U(g,ye,Y),o(jm,f,g,P,L)}}return{arrows:y,mount:x,destroy:A,update:D}}var fv=Oa+"-interval";function gv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.emit,a=Wn(e.interval,n.go.bind(n,">"),C),l=a.isPaused,c=t.Elements,h=t.Elements,u=h.root,d=h.toggle,p=e.autoplay,f,g,m=p==="pause";function v(){p&&(y(),d&&U(d,xs,c.track.id),m||x(),A())}function y(){e.pauseOnHover&&s(u,"mouseenter mouseleave",function(F){f=F.type==="mouseenter",E()}),e.pauseOnFocus&&s(u,"focusin focusout",function(F){g=F.type==="focusin",E()}),d&&s(d,"click",function(){m?x():T(!0)}),r([Ti,Pa,Mt],a.rewind),r(Ti,S)}function x(){l()&&t.Slides.isEnough()&&(a.start(!e.resetProgress),g=f=m=!1,A(),o(Bh))}function T(F){F===void 0&&(F=!0),m=!!F,A(),l()||(a.pause(),o(Nh))}function E(){m||(f||g?T(!1):x())}function A(){d&&(ti(d,Yi,!m),U(d,ye,e.i18n[m?"play":"pause"]))}function C(F){var j=c.bar;j&&Ee(j,"width",F*100+"%"),o(Nm,F)}function S(F){var j=t.Slides.getAt(F);a.set(j&&+De(j.slide,fv)||e.interval)}return{mount:v,destroy:a.cancel,play:x,pause:T,isPaused:l}}function mv(n,t,e){var i=mt(n),r=i.on;function s(){e.cover&&(r(zh,ot(a,!0)),r([Zi,ce,Mt],ot(o,!0)))}function o(l){t.Slides.forEach(function(c){var h=bs(c.container||c.slide,"img");h&&h.src&&a(l,h,c)})}function a(l,c,h){h.style("background",l?'center/cover no-repeat url("'+c.src+'")':"",!0),ss(c,l?"none":"")}return{mount:s,destroy:ot(o,!1)}}var vv=10,bv=600,_v=.6,yv=1.5,xv=800;function wv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=n.state.set,a=t.Move,l=a.getPosition,c=a.getLimit,h=a.exceededLimit,u=a.translate,d=n.is(mr),p,f,g=1;function m(){r(Ti,T),r([ce,Mt],E)}function v(C,S,F,j,D){var k=l();if(T(),F&&(!d||!h())){var P=t.Layout.sliderSize(),L=Wo(C)*P*En(se(C)/P)||0;C=a.toPosition(t.Controller.toDest(C%P))+L}var V=Ih(k,C,1);g=1,S=V?0:S||Tn(se(C-k)/yv,xv),f=j,p=Wn(S,y,ot(x,k,C,D),1),o(fs),s(Pa),p.start()}function y(){o(gr),f&&f(),s(Tr)}function x(C,S,F,j){var D=l(),k=C+(S-C)*A(j),P=(k-D)*g;u(D+P),d&&!F&&h()&&(g*=_v,se(P)<vv&&v(c(h(!0)),bv,!1,f,!0))}function T(){p&&p.cancel()}function E(){p&&!p.isPaused()&&(T(),y())}function A(C){var S=e.easingFunc;return S?S(C):1-Math.pow(1-C,4)}return{mount:m,destroy:T,scroll:v,cancel:E}}var ir={passive:!1,capture:!0};function Cv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=i.bind,a=i.unbind,l=n.state,c=t.Move,h=t.Scroll,u=t.Controller,d=t.Elements.track,p=t.Media.reduce,f=t.Direction,g=f.resolve,m=f.orient,v=c.getPosition,y=c.exceededLimit,x,T,E,A,C,S=!1,F,j,D;function k(){o(d,_o,Ho,ir),o(d,yo,Ho,ir),o(d,eu,L,ir),o(d,"click",Z,{capture:!0}),o(d,"dragstart",qe),r([Zi,ce],P)}function P(){var z=e.drag;Ra(!z),A=z==="free"}function L(z){if(F=!1,!j){var ct=lt(z);at(z.target)&&(ct||!z.button)&&(u.isBusy()?qe(z,!0):(D=ct?d:window,C=l.is([Sr,fs]),E=null,o(D,_o,V,ir),o(D,yo,Y,ir),c.cancel(),h.cancel(),B(z)))}}function V(z){if(l.is(on)||(l.set(on),s(Am)),z.cancelable)if(C){c.translate(x+$t(nt(z)));var ct=he(z)>ic,Ii=S!==(S=y());(ct||Ii)&&B(z),F=!0,s(Mm),qe(z)}else H(z)&&(C=M(z),qe(z))}function Y(z){l.is(on)&&(l.set(gr),s(Im)),C&&(N(z),qe(z)),a(D,_o,V),a(D,yo,Y),C=!1}function Z(z){!j&&F&&qe(z,!0)}function B(z){E=T,T=z,x=v()}function N(z){var ct=J(z),Ii=bt(ct),kr=e.rewind&&e.rewindByDrag;p(!1),A?u.scroll(Ii,0,e.snap):n.is(ws)?u.go(m(Wo(ct))<0?kr?"<":"-":kr?">":"+"):n.is(mr)&&S&&kr?u.go(y(!0)?">":"<"):u.go(u.toDest(Ii),!0),p(!0)}function M(z){var ct=e.dragMinThreshold,Ii=ts(ct),kr=Ii&&ct.mouse||0,nu=(Ii?ct.touch:+ct)||10;return se(nt(z))>(lt(z)?nu:kr)}function H(z){return se(nt(z))>se(nt(z,!0))}function J(z){if(n.is(Er)||!S){var ct=he(z);if(ct&&ct<ic)return nt(z)/ct}return 0}function bt(z){return v()+Wo(z)*Si(se(z)*(e.flickPower||600),A?1/0:t.Layout.listSize()*(e.flickMaxPages||1))}function nt(z,ct){return tt(z,ct)-tt(I(z),ct)}function he(z){return $o(z)-$o(I(z))}function I(z){return T===z&&E||T}function tt(z,ct){return(lt(z)?z.changedTouches[0]:z)["page"+g(ct?"Y":"X")]}function $t(z){return z/(S&&n.is(mr)?iv:1)}function at(z){var ct=e.noDrag;return!es(z,"."+qh+", ."+qn)&&(!ct||!es(z,ct))}function lt(z){return typeof TouchEvent<"u"&&z instanceof TouchEvent}function su(){return C}function Ra(z){j=z}return{mount:k,disable:Ra,isDragging:su}}var Sv={Spacebar:" ",Right:Yn,Left:Un,Up:$h,Down:Wh};function Fa(n){return n=Ci(n)?n:n.key,Sv[n]||n}var rc="keydown";function Tv(n,t,e){var i=mt(n),r=i.on,s=i.bind,o=i.unbind,a=n.root,l=t.Direction.resolve,c,h;function u(){d(),r(ce,p),r(ce,d),r(Ti,g)}function d(){var v=e.keyboard;v&&(c=v==="global"?window:a,s(c,rc,m))}function p(){o(c,rc)}function f(v){h=v}function g(){var v=h;h=!0,Eh(function(){h=v})}function m(v){if(!h){var y=Fa(v);y===l(Un)?n.go("<"):y===l(Yn)&&n.go(">")}}return{mount:u,destroy:p,disable:f}}var Ur=Oa+"-lazy",cn=Ur+"-srcset",Ev="["+Ur+"], ["+cn+"]";function Ov(n,t,e){var i=mt(n),r=i.on,s=i.off,o=i.bind,a=i.emit,l=e.lazyLoad==="sequential",c=[ys,Tr],h=[];function u(){e.lazyLoad&&(d(),r(Mt,d))}function d(){ci(h),p(),l?v():(s(c),r(c,f),f())}function p(){t.Slides.forEach(function(y){Ea(y.slide,Ev).forEach(function(x){var T=De(x,Ur),E=De(x,cn);if(T!==x.src||E!==x.srcset){var A=e.classes.spinner,C=x.parentElement,S=bs(C,"."+A)||dr("span",A,C);h.push([x,y,S]),x.src||ss(x,"none")}})})}function f(){h=h.filter(function(y){var x=e.perPage*((e.preloadPages||1)+1)-1;return y[1].isWithin(n.index,x)?g(y):!0}),h.length||s(c)}function g(y){var x=y[0];Ve(y[1].slide,Yo),o(x,"load error",ot(m,y)),U(x,"src",De(x,Ur)),U(x,"srcset",De(x,cn)),He(x,Ur),He(x,cn)}function m(y,x){var T=y[0],E=y[1];ei(E.slide,Yo),x.type!=="error"&&(Ui(y[2]),ss(T,""),a(zh,T,E),a(os)),l&&v()}function v(){h.length&&g(h.shift())}return{mount:u,destroy:ot(ci,h),check:f}}function kv(n,t,e){var i=mt(n),r=i.on,s=i.emit,o=i.bind,a=t.Slides,l=t.Elements,c=t.Controller,h=c.hasFocus,u=c.getIndex,d=c.go,p=t.Direction.resolve,f=l.pagination,g=[],m,v;function y(){x(),r([ce,Mt,On],y);var j=e.pagination;f&&ss(f,j?"":"none"),j&&(r([Ti,Pa,Tr],F),T(),F(),s(Rm,{list:m,items:g},S(n.index)))}function x(){m&&(Ui(f?Ai(m.children):m),ei(m,v),ci(g),m=null),i.destroy()}function T(){var j=n.length,D=e.classes,k=e.i18n,P=e.perPage,L=h()?c.getEnd()+1:ns(j/P);m=f||dr("ul",D.pagination,l.track.parentElement),Ve(m,v=Zn+"--"+C()),U(m,si,"tablist"),U(m,ye,k.select),U(m,Ma,C()===Xn?"vertical":"");for(var V=0;V<L;V++){var Y=dr("li",null,m),Z=dr("button",{class:D.page,type:"button"},Y),B=a.getIn(V).map(function(M){return M.slide.id}),N=!h()&&P>1?k.pageX:k.slideX;o(Z,"click",ot(E,V)),e.paginationKeyboard&&o(Z,"keydown",ot(A,V)),U(Y,si,"presentation"),U(Z,si,"tab"),U(Z,xs,B.join(" ")),U(Z,ye,Go(N,V+1)),U(Z,pr,-1),g.push({li:Y,button:Z,page:V})}}function E(j){d(">"+j,!0)}function A(j,D){var k=g.length,P=Fa(D),L=C(),V=-1;P===p(Yn,!1,L)?V=++j%k:P===p(Un,!1,L)?V=(--j+k)%k:P==="Home"?V=0:P==="End"&&(V=k-1);var Y=g[V];Y&&(Ph(Y.button),d(">"+V),qe(D,!0))}function C(){return e.paginationDirection||e.direction}function S(j){return g[c.toPage(j)]}function F(){var j=S(u(!0)),D=S(u());if(j){var k=j.button;ei(k,Yi),He(k,Zl),U(k,pr,-1)}if(D){var P=D.button;Ve(P,Yi),U(P,Zl,!0),U(P,pr,"")}s(Bm,{list:m,items:g},j,D)}return{items:g,mount:y,destroy:x,getAt:S,update:F}}var Dv=[" ","Enter"];function Pv(n,t,e){var i=e.isNavigation,r=e.slideFocus,s=[];function o(){n.splides.forEach(function(f){f.isParent||(c(n,f.splide),c(f.splide,n))}),i&&h()}function a(){s.forEach(function(f){f.destroy()}),ci(s)}function l(){a(),o()}function c(f,g){var m=mt(f);m.on(Ti,function(v,y,x){g.go(g.is(Er)?x:v)}),s.push(m)}function h(){var f=mt(n),g=f.on;g(Fh,d),g(Vh,p),g([Zi,ce],u),s.push(f),f.emit(Rh,n.splides)}function u(){U(t.Elements.list,Ma,e.direction===Xn?"vertical":"")}function d(f){n.go(f.index)}function p(f,g){Sa(Dv,Fa(g))&&(d(f),qe(g))}return{setup:ot(t.Media.set,{slideFocus:gs(r)?i:r},!0),mount:o,destroy:a,remount:l}}function Av(n,t,e){var i=mt(n),r=i.bind,s=0;function o(){e.wheel&&r(t.Elements.track,"wheel",a,ir)}function a(c){if(c.cancelable){var h=c.deltaY,u=h<0,d=$o(c),p=e.wheelMinThreshold||0,f=e.wheelSleep||0;se(h)>p&&d-s>f&&(n.go(u?"<":">"),s=d),l(u)&&qe(c)}}function l(c){return!e.releaseWheel||n.state.is(Sr)||t.Controller.getAdjacent(c)!==-1}return{mount:o}}var Mv=90;function Iv(n,t,e){var i=mt(n),r=i.on,s=t.Elements.track,o=e.live&&!e.isNavigation,a=dr("span",Zm),l=Wn(Mv,ot(h,!1));function c(){o&&(d(!t.Autoplay.isPaused()),U(s,tc,!0),a.textContent="…",r(Bh,ot(d,!0)),r(Nh,ot(d,!1)),r([ys,Tr],ot(h,!0)))}function h(p){U(s,Ql,p),p?(vs(s,a),l.start()):(Ui(a),l.cancel())}function u(){He(s,[Jl,tc,Ql]),Ui(a)}function d(p){o&&U(s,Jl,p?"off":"polite")}return{mount:c,disable:d,destroy:u}}var Lv=Object.freeze({__proto__:null,Media:Hm,Direction:$m,Elements:rv,Slides:nv,Layout:ov,Clones:lv,Move:cv,Controller:hv,Arrows:pv,Autoplay:gv,Cover:mv,Scroll:wv,Drag:Cv,Keyboard:Tv,LazyLoad:Ov,Pagination:kv,Sync:Pv,Wheel:Av,Live:Iv}),Fv={prev:"Previous slide",next:"Next slide",first:"Go to first slide",last:"Go to last slide",slideX:"Go to slide %s",pageX:"Go to page %s",play:"Start autoplay",pause:"Pause autoplay",carousel:"carousel",slide:"slide",select:"Select a slide to show",slideLabel:"%s of %s"},jv={type:"slide",role:"region",speed:400,perPage:1,cloneStatus:!0,arrows:!0,pagination:!0,paginationKeyboard:!0,interval:5e3,pauseOnHover:!0,pauseOnFocus:!0,resetProgress:!0,easing:"cubic-bezier(0.25, 1, 0.5, 1)",drag:!0,direction:"ltr",trimSpace:!0,focusableNodes:"a, button, textarea, input, select, iframe",live:!0,classes:tv,i18n:Fv,reducedMotion:{speed:0,rewindSpeed:0,autoplay:"pause"}};function Rv(n,t,e){var i=t.Slides;function r(){mt(n).on([Zi,Mt],s)}function s(){i.forEach(function(a){a.style("transform","translateX(-"+100*a.index+"%)")})}function o(a,l){i.style("transition","opacity "+e.speed+"ms "+e.easing),Eh(l)}return{mount:r,start:o,cancel:Ho}}function Bv(n,t,e){var i=t.Move,r=t.Controller,s=t.Scroll,o=t.Elements.list,a=ot(Ee,o,"transition"),l;function c(){mt(n).bind(o,"transitionend",function(p){p.target===o&&l&&(u(),l())})}function h(p,f){var g=i.toPosition(p,!0),m=i.getPosition(),v=d(p);se(g-m)>=1&&v>=1?e.useScroll?s.scroll(g,v,!1,f):(a("transform "+v+"ms "+e.easing),i.translate(g,!0),l=f):(i.jump(p),f())}function u(){a(""),s.cancel()}function d(p){var f=e.rewindSpeed;if(n.is(mr)&&f){var g=r.getIndex(!0),m=r.getEnd();if(g===0&&p>=m||g>=m&&p===0)return f}return e.speed}return{mount:c,start:h,cancel:u}}var Nv=function(){function n(e,i){this.event=mt(),this.Components={},this.state=zm(lr),this.splides=[],this._o={},this._E={};var r=Ci(e)?Mh(document,e):e;Gr(r,r+" is invalid."),this.root=r,i=bi({label:De(r,ye)||"",labelledby:De(r,Aa)||""},jv,n.defaults,i||{});try{bi(i,JSON.parse(De(r,Oa)))}catch{Gr(!1,"Invalid JSON")}this._o=Object.create(bi({},i))}var t=n.prototype;return t.mount=function(i,r){var s=this,o=this.state,a=this.Components;Gr(o.is([lr,Sn]),"Already mounted!"),o.set(lr),this._C=a,this._T=r||this._T||(this.is(ws)?Rv:Bv),this._E=i||this._E;var l=rs({},Lv,this._E,{Transition:this._T});return $i(l,function(c,h){var u=c(s,a,s._o);a[h]=u,u.setup&&u.setup()}),$i(a,function(c){c.mount&&c.mount()}),this.emit(Zi),Ve(this.root,Jm),o.set(gr),this.emit(Kl),this},t.sync=function(i){return this.splides.push({splide:i}),i.splides.push({splide:this,isParent:!0}),this.state.is(gr)&&(this._C.Sync.remount(),i.Components.Sync.remount()),this},t.go=function(i){return this._C.Controller.go(i),this},t.on=function(i,r){return this.event.on(i,r),this},t.off=function(i){return this.event.off(i),this},t.emit=function(i){var r;return(r=this.event).emit.apply(r,[i].concat(Ai(arguments,1))),this},t.add=function(i,r){return this._C.Slides.add(i,r),this},t.remove=function(i){return this._C.Slides.remove(i),this},t.is=function(i){return this._o.type===i},t.refresh=function(){return this.emit(Mt),this},t.destroy=function(i){i===void 0&&(i=!0);var r=this.event,s=this.state;return s.is(lr)?mt(this).on(Kl,this.destroy.bind(this,i)):($i(this._C,function(o){o.destroy&&o.destroy(i)},!0),r.emit(jh),r.destroy(),i&&ci(this.splides),s.set(Sn)),this},Cm(n,[{key:"options",get:function(){return this._o},set:function(i){this._C.Media.set(i,!0,!0)}},{key:"length",get:function(){return this._C.Slides.getLength(!0)}},{key:"index",get:function(){return this._C.Controller.getIndex()}}]),n}(),ja=Nv;ja.defaults={};ja.STATES=Tm;/**
|
|
2451
|
+
* @license
|
|
2452
|
+
* Copyright 2021 Google LLC
|
|
2453
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
2454
|
+
*/function*iu(n,t){if(n!==void 0){let e=0;for(const i of n)yield t(i,e++)}}var zv=Object.defineProperty,Vv=Object.getOwnPropertyDescriptor,Cs=(n,t,e,i)=>{for(var r=i>1?void 0:i?Vv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&zv(t,e,r),r};let Ei=class extends Bt{constructor(){super(...arguments),this.slides=[],this.cards=[],this.firstUpdated=()=>{this.imageSplide=new ja(this.imageCarousel,{perPage:2,perMove:1,autoHeight:!0,gap:"0.6%",rewind:!1,pagination:!1,isNavigation:!1,mediaQuery:"min",breakpoints:{640:{perPage:4,gap:"1rem"}}}),this.imageSplide.on("arrows:mounted arrows:updated",()=>{this.updateArrowVisibility()}),this.imageSplide.mount()},this.disconnectedCallback=()=>{var t;super.disconnectedCallback(),(t=this.imageSplide)==null||t.destroy()},this.clickHandler=t=>{const e=t.target;this.emit("pbo-category-card-selected",{detail:{cardId:e.dataset.cardId}})}}updateArrowVisibility(){const t=this.imageCarousel.querySelector(".splide__arrow--next"),e=this.imageCarousel.querySelector(".splide__arrow--prev");t.style.visibility=t.disabled?"hidden":"visible",e.style.visibility=e.disabled?"hidden":"visible"}render(){return X`
|
|
2455
|
+
<div class="category-container">
|
|
2456
|
+
<slot name="title"></slot>
|
|
2457
|
+
<div
|
|
2458
|
+
id="category-carousel"
|
|
2459
|
+
class="splide"
|
|
2460
|
+
aria-label="The carousel with thumbnails. Selecting a thumbnail will change the Beautiful Gallery carousel."
|
|
2461
|
+
>
|
|
2462
|
+
<div class="splide__track">
|
|
2463
|
+
<ul class="splide__list">
|
|
2464
|
+
${iu(this.cards,t=>X`
|
|
2465
|
+
<li class="splide__slide">
|
|
2466
|
+
<img
|
|
2467
|
+
src=${t.medias.cover.url}
|
|
2468
|
+
alt="${t.medias.cover.alt}"
|
|
2469
|
+
@click=${this.clickHandler}
|
|
2470
|
+
data-card-id="${t.pboId}"
|
|
2471
|
+
/>
|
|
2472
|
+
</li>
|
|
2473
|
+
`)}
|
|
2474
|
+
</ul>
|
|
2475
|
+
</div>
|
|
2476
|
+
</div>
|
|
2477
|
+
</div>
|
|
2478
|
+
`}};Ei.styles=[Pt,xm,kn(Th)];Cs([q("#category-carousel")],Ei.prototype,"imageCarousel",2);Cs([$()],Ei.prototype,"imageSplide",2);Cs([$()],Ei.prototype,"slides",2);Cs([O({type:Array,converter:{fromAttribute(n){try{return JSON.parse(n||"[]")}catch{return console.error("Invalid JSON for 'cards':",n),[]}},toAttribute(n){return JSON.stringify(n)}}})],Ei.prototype,"cards",2);Ei=Cs([Ot("pbo-category")],Ei);const Ib=Ei,Lb=cu,Fb=hu,Hv=vt`
|
|
2479
|
+
:host {
|
|
2480
|
+
display: block;
|
|
2481
|
+
}
|
|
2482
|
+
`;var $v=Object.defineProperty,Wv=Object.getOwnPropertyDescriptor,ru=(n,t,e,i)=>{for(var r=i>1?void 0:i?Wv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&$v(t,e,r),r};let ls=class extends Bt{constructor(){super(...arguments),this.categories=[]}render(){return X`
|
|
2483
|
+
${iu(this.categories,t=>X`<pbo-category .cards=${t.cards} .name=${t.name}>
|
|
2484
|
+
<h3 slot="title">${t.name}</h3>
|
|
2485
|
+
</pbo-category>`)}
|
|
2486
|
+
`}};ls.styles=[Pt,Hv];ru([O({type:Array})],ls.prototype,"categories",2);ls=ru([Ot("pbo-card-selection")],ls);const Rb=ls,Gv=vt`
|
|
2487
|
+
:host {
|
|
2488
|
+
display: block;
|
|
2489
|
+
width: 100%;
|
|
2490
|
+
height: 100%;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
.fabric-container {
|
|
2494
|
+
max-width: 100%;
|
|
2495
|
+
max-height: 100%;
|
|
2496
|
+
width: 100% !important;
|
|
2497
|
+
height: 100% !important;
|
|
2498
|
+
object-fit: contain;
|
|
2499
|
+
display: flex;
|
|
2500
|
+
margin-left: auto;
|
|
2501
|
+
margin-right: auto;
|
|
2502
|
+
flex-direction: column;
|
|
2503
|
+
justify-content: center;
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
.fabric-container canvas {
|
|
2507
|
+
max-width: 100% !important;
|
|
2508
|
+
max-height: 100% !important;
|
|
2509
|
+
width: 100% !important;
|
|
2510
|
+
height: auto !important;
|
|
2511
|
+
display: block;
|
|
2512
|
+
object-fit: contain;
|
|
2513
|
+
}
|
|
2514
|
+
`;var Uv=Object.defineProperty,Yv=Object.getOwnPropertyDescriptor,jt=(n,t,e,i)=>{for(var r=i>1?void 0:i?Yv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Uv(t,e,r),r};let yt=class extends Bt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.message="",this.font="Arial",this.color="#000",this.alignment="left",this.backgroundImage=void 0,this.backgroundFabImg=void 0,this.rect=void 0,this.textBox=void 0,this.areaPosition={left:0,top:0},this.areaSize={width:0,height:0}}handleAlignmentChange(t,e){t!==e&&this.textBox&&(this.textBox.set("textAlign",e),this.canvas.renderAll())}handleColorChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fill",e),this.canvas.renderAll())}handleFontChange(t,e){t!==e&&this.textBox&&(this.textBox.set("fontFamily",e),this.canvas.renderAll())}handleMessageChange(t,e){if(this.textBox){this.textBox.set("text",e);const i=this.textBox.textLines;i.length>12&&this.textBox.set("text",i.slice(0,12).join(`
|
|
2515
|
+
`)),this.updateTextAreaPosition(),this.canvas.renderAll()}}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateTextAreaPosition(),this.canvas.renderAll())}updateTextAreaPosition(){this.areaPosition={left:.084*this.canvas.getWidth(),top:.4874*this.canvas.getHeight()},this.areaSize={width:.832*this.canvas.getWidth(),height:this.canvas.getHeight()-this.areaPosition.top-this.areaPosition.left},this.rect?(this.rect.set("left",this.areaPosition.left),this.rect.set("top",this.areaPosition.top),this.rect.set("width",this.areaSize.width),this.rect.set("height",this.areaSize.height)):(this.rect=new Rt({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 Qe(this.message,{left:this.areaPosition.left,top:this.areaPosition.top,width:this.areaSize.width,height:this.areaSize.height,lineHeight:1.1,fontSize:this.areaSize.height/13/1.1,alignment:"left",selectable:!1,objectCaching:!1,paintFirst:"stroke",strokeWidth:.5}),this.canvas.add(this.textBox))}async firstUpdated(){this.canvas=new Jr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",selection:!1}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}),this.updateTextAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await Ut.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return X`<canvas class="base-canvas"></canvas> `}};yt.styles=[Pt,Gv];jt([O({attribute:"background-url"})],yt.prototype,"backgroundImageUrl",2);jt([O()],yt.prototype,"message",2);jt([O()],yt.prototype,"font",2);jt([O()],yt.prototype,"color",2);jt([O()],yt.prototype,"alignment",2);jt([q(".base-canvas")],yt.prototype,"baseCanvas",2);jt([$()],yt.prototype,"canvas",2);jt([$()],yt.prototype,"backgroundImage",2);jt([$()],yt.prototype,"backgroundFabImg",2);jt([$()],yt.prototype,"rect",2);jt([$()],yt.prototype,"textBox",2);jt([$()],yt.prototype,"areaPosition",2);jt([$()],yt.prototype,"areaSize",2);jt([et("alignment")],yt.prototype,"handleAlignmentChange",1);jt([et("color")],yt.prototype,"handleColorChange",1);jt([et("font")],yt.prototype,"handleFontChange",1);jt([et("message")],yt.prototype,"handleMessageChange",1);jt([et("backgroundImageUrl")],yt.prototype,"handleBackgroundImageUrlChange",1);yt=jt([Ot("pbo-type-canvas")],yt);const Nb=yt,Xv=vt`
|
|
2516
|
+
:host {
|
|
2517
|
+
display: block;
|
|
2518
|
+
height: 100%;
|
|
2519
|
+
width: 100%;
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
.zoomed-preview {
|
|
2523
|
+
padding: 1.5rem;
|
|
2524
|
+
height: 100%;
|
|
2525
|
+
width: 100%;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
.panel {
|
|
2529
|
+
width: 100%;
|
|
2530
|
+
height: 100%;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
::slotted(img) {
|
|
2534
|
+
width: 100%;
|
|
2535
|
+
max-height: 100%;
|
|
2536
|
+
object-fit: contain;
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
.close-button {
|
|
2540
|
+
position: absolute;
|
|
2541
|
+
right: 1em;
|
|
2542
|
+
top: 1em;
|
|
2543
|
+
cursor: pointer;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
.close-button svg {
|
|
2547
|
+
height: 2rem;
|
|
2548
|
+
width: 2rem;
|
|
2549
|
+
fill: #d7d7d7;
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
.close-button svg:hover {
|
|
2553
|
+
fill: #fff9f9;
|
|
2554
|
+
scale: 1.1;
|
|
2555
|
+
}
|
|
2556
|
+
`;var Kv=Object.defineProperty,qv=Object.getOwnPropertyDescriptor,Ss=(n,t,e,i)=>{for(var r=i>1?void 0:i?qv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Kv(t,e,r),r};let Oi=class extends Bt{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 X`
|
|
2557
|
+
<div class="panel">
|
|
2558
|
+
<div class="zoomed-preview">
|
|
2559
|
+
<div
|
|
2560
|
+
style=${pe({display:"flex","justify-content":"center",flexDirection:"column",height:"100%"})}
|
|
2561
|
+
>
|
|
2562
|
+
<slot part="base"></slot>
|
|
2563
|
+
</div>
|
|
2564
|
+
</div>
|
|
2565
|
+
|
|
2566
|
+
<div class="close-button" @click=${this.close}>
|
|
2567
|
+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#F3F3F3">
|
|
2568
|
+
<path
|
|
2569
|
+
d="m336-280 144-144 144 144 56-56-144-144 144-144-56-56-144 144-144-144-56 56 144 144-144 144 56 56ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"
|
|
2570
|
+
/>
|
|
2571
|
+
</svg>
|
|
2572
|
+
</div>
|
|
2573
|
+
</div>
|
|
2574
|
+
`}};Oi.styles=[Pt,Xv];Ss([O()],Oi.prototype,"formData",2);Ss([O()],Oi.prototype,"cardUrl",2);Ss([O()],Oi.prototype,"close",2);Ss([O()],Oi.prototype,"handwrittenPreviewProps",2);Oi=Ss([Ot("pbo-zoomed-preview")],Oi);const Vb=Oi,Zv=vt`
|
|
2575
|
+
:host {
|
|
2576
|
+
display: block;
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
.label {
|
|
2580
|
+
line-height: normal;
|
|
2581
|
+
font-size: 1rem;
|
|
2582
|
+
}
|
|
2583
|
+
.label svg {
|
|
2584
|
+
vertical-align: middle;
|
|
2585
|
+
}
|
|
2586
|
+
.icon {
|
|
2587
|
+
/* display: inline; */
|
|
2588
|
+
vertical-align: top;
|
|
2589
|
+
}
|
|
2590
|
+
.choice-wrapper {
|
|
2591
|
+
display: inline-flex;
|
|
2592
|
+
}
|
|
2593
|
+
`;var Jv=Object.defineProperty,Qv=Object.getOwnPropertyDescriptor,Or=(n,t,e,i)=>{for(var r=i>1?void 0:i?Qv(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&Jv(t,e,r),r};let hi=class extends Bt{constructor(){super(...arguments),this.hasSlotController=new Ki(this,"help-text","label"),this.size="medium",this.label="",this.disabled=!1}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()}_initializeChoices(){var t;(t=this._choices)==null||t.destroy(),this._choices=new _h(this.choiceEl,{allowHTML:!0,searchEnabled:!1,shouldSort:!1,removeItemButton:!1,shadowRoot:this.shadowRoot,choices:[{value:"type",label:`
|
|
2594
|
+
<div class="choice-wrapper">
|
|
2595
|
+
<span class="label">Type message
|
|
2596
|
+
<svg
|
|
2597
|
+
stroke="currentColor"
|
|
2598
|
+
fill="none"
|
|
2599
|
+
stroke-width="0"
|
|
2600
|
+
viewBox="0 0 24 24"
|
|
2601
|
+
height="1.6em"
|
|
2602
|
+
width="1.6em"
|
|
2603
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2604
|
+
>
|
|
2605
|
+
<path d="M6.5 3H3V6.5H4V4H6.5V3Z" fill="currentColor"></path>
|
|
2606
|
+
<path d="M8.5 4V3H11V4H8.5Z" fill="currentColor"></path>
|
|
2607
|
+
<path d="M13 4H15.5V3H13V4Z" fill="currentColor"></path>
|
|
2608
|
+
<path d="M17.5 3V4H20V6.5H21V3H17.5Z" fill="currentColor"></path>
|
|
2609
|
+
<path d="M21 8.5H20V11H21V8.5Z" fill="currentColor"></path>
|
|
2610
|
+
<path d="M21 13H20V15.5H21V13Z" fill="currentColor"></path>
|
|
2611
|
+
<path d="M21 17.5H20V20H17.5V21H21V17.5Z" fill="currentColor"></path>
|
|
2612
|
+
<path d="M15.5 21V20H13V21H15.5Z" fill="currentColor"></path>
|
|
2613
|
+
<path d="M11 21V20H8.5V21H11Z" fill="currentColor"></path>
|
|
2614
|
+
<path d="M6.5 21V20H4V17.5H3V21H6.5Z" fill="currentColor"></path>
|
|
2615
|
+
<path d="M3 15.5H4V13H3V15.5Z" fill="currentColor"></path>
|
|
2616
|
+
<path d="M3 11H4V8.5H3V11Z" fill="currentColor"></path>
|
|
2617
|
+
<path d="M11 9.5H7V7.5H17V9.5H13V16.5H11V9.5Z" fill="currentColor"></path>
|
|
2618
|
+
</svg>
|
|
2619
|
+
</span>`},{value:"handwritten",label:`
|
|
2620
|
+
<div class="choice-wrapper">
|
|
2621
|
+
<span class="label">Upload handwritten message
|
|
2622
|
+
<svg
|
|
2623
|
+
stroke="currentColor"
|
|
2624
|
+
fill="none"
|
|
2625
|
+
stroke-width="0"
|
|
2626
|
+
viewBox="0 0 24 24"
|
|
2627
|
+
height="1.6em"
|
|
2628
|
+
width="1.6em"
|
|
2629
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2630
|
+
>
|
|
2631
|
+
<path
|
|
2632
|
+
fill-rule="evenodd"
|
|
2633
|
+
clip-rule="evenodd"
|
|
2634
|
+
d="M21.2635 2.29289C20.873 1.90237 20.2398 1.90237 19.8493 2.29289L18.9769 3.16525C17.8618 2.63254 16.4857 2.82801 15.5621 3.75165L4.95549 14.3582L10.6123 20.0151L21.2189 9.4085C22.1426 8.48486 22.338 7.1088 21.8053 5.99367L22.6777 5.12132C23.0682 4.7308 23.0682 4.09763 22.6777 3.70711L21.2635 2.29289ZM16.9955 10.8035L10.6123 17.1867L7.78392 14.3582L14.1671 7.9751L16.9955 10.8035ZM18.8138 8.98525L19.8047 7.99429C20.1953 7.60376 20.1953 6.9706 19.8047 6.58007L18.3905 5.16586C18 4.77534 17.3668 4.77534 16.9763 5.16586L15.9853 6.15683L18.8138 8.98525Z"
|
|
2635
|
+
fill="currentColor"
|
|
2636
|
+
></path>
|
|
2637
|
+
<path d="M2 22.9502L4.12171 15.1717L9.77817 20.8289L2 22.9502Z" fill="currentColor"></path>
|
|
2638
|
+
</svg>
|
|
2639
|
+
<svg
|
|
2640
|
+
stroke="currentColor"
|
|
2641
|
+
fill="currentColor"
|
|
2642
|
+
stroke-width="0"
|
|
2643
|
+
viewBox="0 0 512 512"
|
|
2644
|
+
height="1.6em"
|
|
2645
|
+
width="1.6em"
|
|
2646
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2647
|
+
>
|
|
2648
|
+
<circle cx="256" cy="275" r="57.5"></circle>
|
|
2649
|
+
<path
|
|
2650
|
+
d="M417.5 160H363c-4.6 0-8.9-2-12-5.4-28.4-31.8-39.1-42.6-50.7-42.6h-85.5c-11.7 0-23.2 10.8-51.7 42.7-3 3.4-7.4 5.3-11.9 5.3h-4.1v-8c0-4.4-3.6-8-8-8h-26c-4.4 0-8 3.6-8 8v8h-7.5C79.9 160 64 173.2 64 190.7v176c0 17.5 15.9 33.3 33.5 33.3h320c17.6 0 30.5-15.8 30.5-33.3v-176c0-17.5-12.9-30.7-30.5-30.7zM260 360.4c-50.3 2.3-91.7-39.1-89.4-89.4 2-43.9 37.5-79.4 81.4-81.4 50.3-2.3 91.7 39.1 89.4 89.4-2 43.9-37.5 79.4-81.4 81.4zM352 218c-7.2 0-13-5.8-13-13s5.8-13 13-13 13 5.8 13 13-5.8 13-13 13z"
|
|
2651
|
+
></path>
|
|
2652
|
+
</svg>
|
|
2653
|
+
<svg
|
|
2654
|
+
stroke="currentColor"
|
|
2655
|
+
fill="currentColor"
|
|
2656
|
+
stroke-width="0"
|
|
2657
|
+
viewBox="0 0 512 512"
|
|
2658
|
+
height="1.6em"
|
|
2659
|
+
width="1.6em"
|
|
2660
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
2661
|
+
>
|
|
2662
|
+
<path
|
|
2663
|
+
fill="none"
|
|
2664
|
+
stroke-linecap="round"
|
|
2665
|
+
stroke-linejoin="round"
|
|
2666
|
+
stroke-width="32"
|
|
2667
|
+
d="M336 192h40a40 40 0 0 1 40 40v192a40 40 0 0 1-40 40H136a40 40 0 0 1-40-40V232a40 40 0 0 1 40-40h40m160-64-80-80-80 80m80 193V48"
|
|
2668
|
+
></path>
|
|
2669
|
+
</svg>
|
|
2670
|
+
</span>`}],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 X` <div
|
|
2671
|
+
class=${ni({"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})}
|
|
2672
|
+
>
|
|
2673
|
+
<label
|
|
2674
|
+
part="form-control-label"
|
|
2675
|
+
id="label"
|
|
2676
|
+
class="form-control__label"
|
|
2677
|
+
aria-hidden=${e?"false":"true"}
|
|
2678
|
+
>
|
|
2679
|
+
<slot name="label">${this.label}</slot>
|
|
2680
|
+
</label>
|
|
2681
|
+
</div>
|
|
2682
|
+
<select part="base" class="js-choice"></select>`}};hi.styles=[Pt,Zv,ps,kn(yh)];Or([O()],hi.prototype,"size",2);Or([O()],hi.prototype,"label",2);Or([O({type:Boolean,reflect:!0})],hi.prototype,"disabled",2);Or([et("disabled",{waitUntilFirstUpdate:!0})],hi.prototype,"handleDisabledChanged",1);Or([q(".js-choice")],hi.prototype,"choiceEl",2);hi=Or([Ot("pbo-editor-selector")],hi);const $b=hi,tb=vt`
|
|
2683
|
+
:host {
|
|
2684
|
+
display: block;
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
.pixel-input {
|
|
2688
|
+
display: none;
|
|
2689
|
+
height: 1;
|
|
2690
|
+
width: 1;
|
|
2691
|
+
opacity: 0;
|
|
2692
|
+
}
|
|
2693
|
+
.buttons-container {
|
|
2694
|
+
display: flex;
|
|
2695
|
+
flex-direction: column;
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
.buttons-container pbo-button::part(base) {
|
|
2699
|
+
font-size: var(--pbo-font-size-medium);
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
.handwritten-form section h1 {
|
|
2703
|
+
margin: 0;
|
|
2704
|
+
font-size: var(--pbo-font-size-large);
|
|
2705
|
+
}
|
|
2706
|
+
|
|
2707
|
+
.handwritten-form section:not(:last-child) p {
|
|
2708
|
+
margin-bottom: var(--pbo-spacing-medium);
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2711
|
+
.handwritten-form section:first-child {
|
|
2712
|
+
margin-top: var(--pbo-spacing-medium);
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
.handwritten-form section p {
|
|
2716
|
+
margin-top: var(--pbo-spacing-2x-small);
|
|
2717
|
+
font-size: var(--pbo-font-size-medium);
|
|
2718
|
+
}
|
|
2719
|
+
`;var eb=Object.defineProperty,ib=Object.getOwnPropertyDescriptor,kt=(n,t,e,i)=>{for(var r=i>1?void 0:i?ib(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&eb(t,e,r),r};let dt=class extends Bt{constructor(){super(...arguments),this.card=null,this.submitHandwrittenForm=async t=>{console.warn("submitHandwrittenForm not implemented",t)},this.getProcessedImg=async t=>(console.warn("getProcessedImg not implemented",t.name),{pred_image_uid:"",masked_img:""}),this.isSubmitLoading=!1,this.isSubmitDisabled=!1,this.isImageProcessing=!1,this.sourceImg=null,this.processedImg={fileUrl:null,imgId:null},this.processedFileUrl=null,this.handwrittenDimensions={top:null,left:null,width:null,height:null,cardHeight:null,cardWidth:null}}showPicker(){this.imageInput.showPicker()}setButtonsDisabled(t){this.uploadButton&&this.saveButton&&this.reuploadButton&&(this.uploadButton.disabled=t,this.saveButton.disabled=t,this.reuploadButton.disabled=t)}setButtonsLoading(t){this.uploadButton&&this.saveButton&&(this.uploadButton.loading=t,this.saveButton.loading=t)}handleSubmitLoadingChange(){this.setButtonsLoading(this.isSubmitLoading)}handleSubmitDisabledChange(){this.setButtonsDisabled(this.isSubmitDisabled)}handleSourceImgChange(t,e){this.processedFileUrl=null,t!==e&&this.emit("pbo-change",{detail:{isLoading:!0,processedFileUrl:null}})}handleProcessImageChange(t,e){!e||t===e||this.emit("pbo-change",{detail:{isLoading:!1,processedFileUrl:e}})}handleImageProcessingChange(){this.setButtonsDisabled(this.isImageProcessing),this.setButtonsLoading(this.isImageProcessing)}get formData(){var r,s,o,a;const t=177.8/this.handwrittenDimensions.cardHeight,e=127/this.handwrittenDimensions.cardWidth,i={pboCardId:((r=this.card)==null?void 0:r.pboId)||"Unknown",productId:(s=this.card)==null?void 0:s.productId,sku:(o=this.card)==null?void 0:o.sku,variantId:(a=this.card)==null?void 0:a.variantId,pred_image_uid:this.processedImg.imgId||"",position_x:this.handwrittenDimensions.top*e,position_y:this.handwrittenDimensions.left*t,height:this.handwrittenDimensions.height*t,width:this.handwrittenDimensions.width*e};return Sh(i)}setDimensions(t){this.handwrittenDimensions=t}get form(){return{isLoading:this.sourceImg&&!this.processedFileUrl,processedFileUrl:this.processedFileUrl}}async handleFileChange(t){var r,s;const e=(s=(r=t.target)==null?void 0:r.files)==null?void 0:s[0];if(e==null)return;this.sourceImg=e,this.isImageProcessing=!0;const i=await this.getProcessedImg(e);this.isImageProcessing=!1,this.processedFileUrl=`data:image/png;base64,${i.masked_img}`}handleSubmit(t){t.preventDefault(),this.submitHandwrittenForm(this.formData)}render(){return X`
|
|
2720
|
+
<form name="handwritten-form" class="handwritten-form" @submit=${this.handleSubmit}>
|
|
2721
|
+
<section>
|
|
2722
|
+
<h1>Step 1</h1>
|
|
2723
|
+
<p>Write your message and signature on a white sheet of paper</p>
|
|
2724
|
+
</section>
|
|
2725
|
+
|
|
2726
|
+
<section>
|
|
2727
|
+
<h1>Step 2</h1>
|
|
2728
|
+
<p>Take a well-lit photo on your phone, then crop and save it</p>
|
|
2729
|
+
</section>
|
|
2730
|
+
|
|
2731
|
+
<section>
|
|
2732
|
+
<h1>Step 3</h1>
|
|
2733
|
+
<p>Upload photo (PNG or JPEG), then adjust it to fit inside the card</p>
|
|
2734
|
+
</section>
|
|
2735
|
+
<input
|
|
2736
|
+
id="handwritten-file-input"
|
|
2737
|
+
class="pixel-input"
|
|
2738
|
+
type="file"
|
|
2739
|
+
accept=".png, .jpeg, .jpg"
|
|
2740
|
+
@change=${this.handleFileChange}
|
|
2741
|
+
required
|
|
2742
|
+
/>
|
|
2743
|
+
<div class="buttons-container">
|
|
2744
|
+
<pbo-button
|
|
2745
|
+
name="upload"
|
|
2746
|
+
class="upload button"
|
|
2747
|
+
size="medium"
|
|
2748
|
+
variant="primary"
|
|
2749
|
+
@click=${this.showPicker}
|
|
2750
|
+
style=${pe({display:this.processedFileUrl?"none":"block"})}
|
|
2751
|
+
>
|
|
2752
|
+
Upload Handwritten Image
|
|
2753
|
+
</pbo-button>
|
|
2754
|
+
|
|
2755
|
+
<pbo-button
|
|
2756
|
+
name="save"
|
|
2757
|
+
type="submit"
|
|
2758
|
+
variant="primary"
|
|
2759
|
+
class="submit-cta"
|
|
2760
|
+
style=${pe({display:this.sourceImg&&this.processedFileUrl&&!this.isImageProcessing?"block":"none"})}
|
|
2761
|
+
>
|
|
2762
|
+
Save and Continue
|
|
2763
|
+
</pbo-button>
|
|
2764
|
+
<pbo-button
|
|
2765
|
+
name="reupload"
|
|
2766
|
+
variant="text"
|
|
2767
|
+
class="submit-cta"
|
|
2768
|
+
@click=${this.showPicker}
|
|
2769
|
+
size="small"
|
|
2770
|
+
style=${pe({display:this.sourceImg&&this.processedFileUrl?"block":"none"})}
|
|
2771
|
+
>
|
|
2772
|
+
reupload image
|
|
2773
|
+
</pbo-button>
|
|
2774
|
+
</div>
|
|
2775
|
+
</form>
|
|
2776
|
+
`}};dt.styles=[Pt,tb];kt([O()],dt.prototype,"card",2);kt([O()],dt.prototype,"submitHandwrittenForm",2);kt([O()],dt.prototype,"getProcessedImg",2);kt([O({type:Boolean,reflect:!0,attribute:"loading"})],dt.prototype,"isSubmitLoading",2);kt([O({type:Boolean,reflect:!0,attribute:"disabled"})],dt.prototype,"isSubmitDisabled",2);kt([q(".pixel-input")],dt.prototype,"imageInput",2);kt([q(".handwritten-form")],dt.prototype,"handwrittenForm",2);kt([q("pbo-button[name='upload']")],dt.prototype,"uploadButton",2);kt([q("pbo-button[name='save']")],dt.prototype,"saveButton",2);kt([q("pbo-button[name='reupload']")],dt.prototype,"reuploadButton",2);kt([$()],dt.prototype,"isImageProcessing",2);kt([$()],dt.prototype,"sourceImg",2);kt([$()],dt.prototype,"processedImg",2);kt([$()],dt.prototype,"processedFileUrl",2);kt([$()],dt.prototype,"handwrittenDimensions",2);kt([et("isSubmitLoading")],dt.prototype,"handleSubmitLoadingChange",1);kt([et("isSubmitDisabled")],dt.prototype,"handleSubmitDisabledChange",1);kt([et("sourceImg")],dt.prototype,"handleSourceImgChange",1);kt([et("processedFileUrl")],dt.prototype,"handleProcessImageChange",1);kt([et("isImageProcessing")],dt.prototype,"handleImageProcessingChange",1);dt=kt([Ot("pbo-handwritten-form")],dt);const Gb=dt,rb=vt`
|
|
2777
|
+
:host {
|
|
2778
|
+
display: block;
|
|
2779
|
+
width: 100%;
|
|
2780
|
+
height: 100%;
|
|
2781
|
+
}
|
|
2782
|
+
|
|
2783
|
+
.fabric-container {
|
|
2784
|
+
max-width: 100%;
|
|
2785
|
+
max-height: 100%;
|
|
2786
|
+
width: 100% !important;
|
|
2787
|
+
height: 100% !important;
|
|
2788
|
+
object-fit: contain;
|
|
2789
|
+
margin-left: auto;
|
|
2790
|
+
margin-right: auto;
|
|
2791
|
+
display: flex;
|
|
2792
|
+
flex-direction: column;
|
|
2793
|
+
justify-content: center;
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
.fabric-container canvas {
|
|
2797
|
+
max-width: 100% !important;
|
|
2798
|
+
max-height: 100% !important;
|
|
2799
|
+
width: 100% !important;
|
|
2800
|
+
height: auto !important;
|
|
2801
|
+
display: block;
|
|
2802
|
+
object-fit: contain;
|
|
2803
|
+
}
|
|
2804
|
+
`;var sb=Object.defineProperty,nb=Object.getOwnPropertyDescriptor,Vt=(n,t,e,i)=>{for(var r=i>1?void 0:i?nb(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&sb(t,e,r),r};let Et=class extends Bt{constructor(){super(...arguments),this.backgroundImageUrl=void 0,this.handwrittenImageUrl=void 0,this.imageHeight=null,this.imageWidth=null,this.imageLeft=null,this.imageTop=null,this.backgroundFabImg=void 0,this.rect=void 0,this.areaPosition={left:0,top:0},this.handwrittenImage=void 0,this.clipMaskOverlay=void 0,this.areaSize={width:0,height:0},this._dimensionsUpdateTimeout=void 0}async handleBackgroundImageUrlChange(){this.canvas&&(this.backgroundFabImg&&this.canvas.remove(this.backgroundFabImg),await this.appendBackgroundImageToCanvas(this.backgroundImageUrl||"https://cdn.shopify.com/s/files/1/1956/2323/files/insert_86e8bcd5-3e82-4910-b350-485fa6958502.png?v=1726598821"),this.updateProcessedImgAreaPosition(),this.canvas.renderAll())}async handleHandwrittenImageUrlChange(t,e){if(this.canvas){if(this.handwrittenImage&&this.canvas.remove(this.handwrittenImage),e){this.handwrittenImage=await Ut.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,r=this.areaSize.height/this.handwrittenImage.height,s=Math.min(i,r);this.handwrittenImage.set({transparentCorners:!1,cornerColor:"#4287f5",cornerStyle:"circle",cornerSize:this.areaSize.width*(ar()?.06:.03),cornerStrokeWidth:2,cornerStrokeColor:"#2563eb",touchCornerSize:this.areaSize.width*(ar()?.2:.06),scalingLimitations:"preserveAspectRatio",left:this.areaPosition.left,top:this.areaPosition.top,scaleX:s,scaleY:s,bringToFrontOnSelect:!1,borderColor:"#4287f5",borderScaleFactor:10}),this.setHandwrittenImageDimensions({top:this.areaPosition.top,left:this.areaPosition.left,height:this.handwrittenImage.height*s,width:this.handwrittenImage.width*s}),this.handwrittenImage.setControlsVisibility({tl:!0,tr:!0,bl:!0,br:!0,mt:!1,mb:!1,ml:!1,mr:!1,mtr:!1});const o=new Rt({width:this.areaSize.width,height:this.areaSize.height,left:this.areaPosition.left,top:this.areaPosition.top,absolutePositioned:!0});this.handwrittenImage.set({clipPath:o}),this.handwrittenImage.on("scaling",a=>{const{top:l,left:c,height:h,width:u,scaleX:d,scaleY:p}=a.transform.target;this.setHandwrittenImageDimensions({top:l,left:c,height:h*p,width:u*d})}),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:o}),(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:r}=this.areaPosition,{width:s,height:o}=this.areaSize,a="rgba(0,0,0,0.1)",l=new Rt({left:0,top:0,width:t,height:r,fill:a,selectable:!1,evented:!1}),c=new Rt({left:0,top:r+o,width:t,height:e-(r+o),fill:a,selectable:!1,evented:!1}),h=new Rt({left:0,top:r,width:i,height:o,fill:a,selectable:!1,evented:!1}),u=new Rt({left:i+s,top:r,width:t-(i+s),height:o,fill:a,selectable:!1,evented:!1});return new _i([l,c,h,u],{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 Rt({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,r,s;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:((r=this.backgroundFabImg)==null?void 0:r.height)||0,cardWidth:((s=this.backgroundFabImg)==null?void 0:s.width)||0}})},300)}applyHandwrittenImageDimensions(){!jr(this.handwrittenImage)||!jr(this.imageLeft)||!jr(this.imageTop)||!jr(this.imageWidth)||!jr(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:r=null,width:s=null}=t;if(!e&&!i&&!r&&!s){console.warn("Invalid dimensions provided for handwritten image");return}i&&this.imageLeft!==i&&(this.imageLeft=i),e&&this.imageTop!==e&&(this.imageTop=e),r&&this.imageHeight!==r&&(this.imageHeight=r),s&&this.imageWidth!==s&&(this.imageWidth=s)}async firstUpdated(){this.canvas=new Jr(this.baseCanvas,{width:500,height:500,containerClass:"fabric-container",preserveObjectStacking:!0}),this.backgroundImageUrl&&await this.appendBackgroundImageToCanvas(this.backgroundImageUrl,()=>{}),this.updateProcessedImgAreaPosition(),this.canvas.renderAll()}async appendBackgroundImageToCanvas(t,e){const i=await Ut.fromURL(t);i.selectable=!1,this.backgroundFabImg=i,this.canvas.setDimensions({width:i.width,height:i.height}),this.canvas.add(i),this.canvas.sendObjectToBack(i),await this.canvas.renderAll(),e&&e()}render(){return X`<canvas class="base-canvas"></canvas> `}};Et.styles=[Pt,rb];Vt([O({attribute:"background-url"})],Et.prototype,"backgroundImageUrl",2);Vt([O({attribute:"handwritten-url"})],Et.prototype,"handwrittenImageUrl",2);Vt([O({type:Number,reflect:!0,attribute:"height"})],Et.prototype,"imageHeight",2);Vt([O({type:Number,reflect:!0,attribute:"width"})],Et.prototype,"imageWidth",2);Vt([O({type:Number,reflect:!0,attribute:"left"})],Et.prototype,"imageLeft",2);Vt([O({type:Number,reflect:!0,attribute:"top"})],Et.prototype,"imageTop",2);Vt([q(".base-canvas")],Et.prototype,"baseCanvas",2);Vt([$()],Et.prototype,"canvas",2);Vt([$()],Et.prototype,"backgroundFabImg",2);Vt([$()],Et.prototype,"rect",2);Vt([$()],Et.prototype,"areaPosition",2);Vt([$()],Et.prototype,"handwrittenImage",2);Vt([$()],Et.prototype,"clipMaskOverlay",2);Vt([$()],Et.prototype,"areaSize",2);Vt([et("backgroundImageUrl")],Et.prototype,"handleBackgroundImageUrlChange",1);Vt([et("handwrittenImageUrl")],Et.prototype,"handleHandwrittenImageUrlChange",1);Vt([et("imageLeft"),et("imageTop"),et("imageWidth"),et("imageHeight")],Et.prototype,"handleHandwrittenImageDimensionsChange",1);Et=Vt([Ot("pbo-handwritten-canvas")],Et);const Yb=Et,ob=vt`
|
|
2805
|
+
:host {
|
|
2806
|
+
display: block;
|
|
2807
|
+
width: auto;
|
|
2808
|
+
color: #1f1f1f;
|
|
2809
|
+
}
|
|
2810
|
+
|
|
2811
|
+
.gift-options {
|
|
2812
|
+
display: flex;
|
|
2813
|
+
flex-direction: column;
|
|
2814
|
+
gap: 1rem;
|
|
2815
|
+
padding: 1rem 0;
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
/* 🎁 Gift section - top checkbox with border */
|
|
2819
|
+
.gift-options > div:first-of-type {
|
|
2820
|
+
border-bottom: 1px dashed #ccc;
|
|
2821
|
+
padding-bottom: 0.5rem;
|
|
2822
|
+
margin-bottom: 0.5rem;
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
label {
|
|
2826
|
+
display: flex;
|
|
2827
|
+
align-items: center;
|
|
2828
|
+
gap: 0.4rem;
|
|
2829
|
+
font-size: 0.95rem;
|
|
2830
|
+
cursor: pointer;
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2833
|
+
input[type="checkbox"] {
|
|
2834
|
+
accent-color: #0070f3;
|
|
2835
|
+
cursor: pointer;
|
|
2836
|
+
}
|
|
2837
|
+
|
|
2838
|
+
/* 📝 Free message textarea */
|
|
2839
|
+
textarea {
|
|
2840
|
+
margin-left: 1.5rem;
|
|
2841
|
+
margin-top: 0.25rem;
|
|
2842
|
+
padding: 0.5rem;
|
|
2843
|
+
font-size: 0.9rem;
|
|
2844
|
+
line-height: 1.4;
|
|
2845
|
+
width: 100%;
|
|
2846
|
+
max-width: 500px;
|
|
2847
|
+
border: 1px solid #ccc;
|
|
2848
|
+
border-radius: 4px;
|
|
2849
|
+
resize: vertical;
|
|
2850
|
+
min-height: 6rem;
|
|
2851
|
+
}
|
|
2852
|
+
`;var ab=Object.defineProperty,lb=Object.getOwnPropertyDescriptor,Ge=(n,t,e,i)=>{for(var r=i>1?void 0:i?lb(t,e):t,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(t,e,r):o(r))||r);return i&&r&&ab(t,e,r),r};let me=class extends Bt{constructor(){super(...arguments),this.hasSlotController=new Ki(this,"is-gift-label","premium-card-label","free-message-label"),this.freeMessage="",this.hidden=!1,this.expand=!1,this.isGift=!0,this.isPremiumChecked=!1,this.isFreeMessageChecked=!1}setGiftOptionEnabled(t){var e;this.isGift=t,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="",(e=this.onFreeMessageClear)==null||e.call(this))}firstUpdated(t){}setPremiumEnabled(t){var e;this.isPremiumChecked=t,this.isPremiumChecked&&(this.isFreeMessageChecked=!1,(e=this.onFreeMessageClear)==null||e.call(this)),this.isPremiumChecked?this.emit("pbo-open-drawer"):this.emit("pbo-close-drawer"),this.onPremiumSelected&&this.onPremiumSelected(t)}setFreeMessageEnabled(t){var e;this.isFreeMessageChecked=t,this.isFreeMessageChecked||(this.freeMessage="",(e=this.onFreeMessageClear)==null||e.call(this))}handlePremiumChange(t){const e=t.target.checked;this.setPremiumEnabled(e)}render(){const t=this.hasSlotController.test("is-gift-label"),e=this.hasSlotController.test("premium-card-label"),i=this.hasSlotController.test("free-message-label");return X`
|
|
2853
|
+
<div part="base" class="gift-options" ?hidden=${this.hidden}>
|
|
2854
|
+
<!-- 🎁 Is this a gift -->
|
|
2855
|
+
<div class="is-gift" part="is-gift" ?hidden=${!t}>
|
|
2856
|
+
<label class="is-gift-label">
|
|
2857
|
+
<input
|
|
2858
|
+
type="checkbox"
|
|
2859
|
+
?checked=${this.isGift}
|
|
2860
|
+
@change=${r=>{const s=r.target.checked;this.isGift=s,this.isGift||(this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage="")}}
|
|
2861
|
+
/>
|
|
2862
|
+
<slot name="is-gift-label" part="is-gift-label"></slot>
|
|
2863
|
+
<span class="is-gift-icon">
|
|
2864
|
+
<slot name="is-gift-icon" part="is-gift-icon"></slot>
|
|
2865
|
+
</span>
|
|
2866
|
+
</label>
|
|
2867
|
+
</div>
|
|
2868
|
+
|
|
2869
|
+
<!-- 💌 Premium Card -->
|
|
2870
|
+
<div class="premium-card" part="premium-card" ?hidden=${!this.isGift||!e}>
|
|
2871
|
+
<label class="premium-card-label">
|
|
2872
|
+
<input type="checkbox" .checked=${this.isPremiumChecked} @change=${this.handlePremiumChange} />
|
|
2873
|
+
<slot name="premium-card-label" part="premium-card-label"></slot>
|
|
2874
|
+
</label>
|
|
2875
|
+
<p class="premium-card-description">
|
|
2876
|
+
<slot name="premium-card-description" part="premium-card-description"></slot>
|
|
2877
|
+
</p>
|
|
2878
|
+
</div>
|
|
2879
|
+
|
|
2880
|
+
<!-- 📝 Free Message -->
|
|
2881
|
+
<div class="free-message" part="free-message" ?hidden=${!this.isGift||!i}>
|
|
2882
|
+
<label class="free-message-label" part="free-message-label">
|
|
2883
|
+
<input
|
|
2884
|
+
type="checkbox"
|
|
2885
|
+
.checked=${this.isFreeMessageChecked}
|
|
2886
|
+
@change=${()=>{var r;this.isFreeMessageChecked=!this.isFreeMessageChecked,this.isFreeMessageChecked?this.isPremiumChecked=!1:(this.freeMessage="",(r=this.onFreeMessageClear)==null||r.call(this))}}
|
|
2887
|
+
/>
|
|
2888
|
+
<slot name="free-message-label"></slot>
|
|
2889
|
+
</label>
|
|
2890
|
+
|
|
2891
|
+
<pbo-textarea
|
|
2892
|
+
class="free-message-textarea"
|
|
2893
|
+
part="free-message-textarea"
|
|
2894
|
+
placeholder="Leave your message"
|
|
2895
|
+
.value=${this.freeMessage}
|
|
2896
|
+
?hidden=${!this.isFreeMessageChecked}
|
|
2897
|
+
@input=${r=>{var s;this.freeMessage=r.target.value,(s=this.onFreeMessageChange)==null||s.call(this,this.freeMessage)}}
|
|
2898
|
+
></pbo-textarea>
|
|
2899
|
+
<div></div>
|
|
2900
|
+
</div>
|
|
2901
|
+
</div>
|
|
2902
|
+
`}clear(){this.isPremiumChecked=!1,this.isFreeMessageChecked=!1,this.freeMessage=""}};me.styles=[Pt,ob];Ge([O()],me.prototype,"freeMessage",2);Ge([O({type:Function})],me.prototype,"onPremiumSelected",2);Ge([O({type:Function})],me.prototype,"onFreeMessageChange",2);Ge([O({type:Function})],me.prototype,"onFreeMessageClear",2);Ge([O({type:Boolean,reflect:!0})],me.prototype,"hidden",2);Ge([O({type:Boolean,reflect:!0})],me.prototype,"expand",2);Ge([$()],me.prototype,"isGift",2);Ge([$()],me.prototype,"isPremiumChecked",2);Ge([$()],me.prototype,"isFreeMessageChecked",2);me=Ge([Ot("pbo-gift-options")],me);const Kb=me,qb=Qr,Zb=ge;export{ut as FabricExample,hn as MessageSelector,mb as PboButton,bb as PboButtonGroup,Rb as PboCardSelection,Ib as PboCategory,Lb as PboDrawer,Db as PboEditor,Ab as PboEditorCardSlider,$b as PboEditorSelector,Kb as PboGiftOption,Yb as PboHandwrittenCanvas,Gb as PboHandwrittenForm,Zb as PboImage,Fb as PboPageManager,yb as PboRadioButton,wb as PboRadioGroup,ze as PboSelector,qb as PboSpinner,Sb as PboTextarea,Nb as PboTypeCanvas,Pb as PboTypeForm,Vb as PboZoomedPreview};
|