superdoc 2.0.0-next.36 β 2.0.0-next.38
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.
|
@@ -7,7 +7,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
|
|
|
7
7
|
var PRIVATE_ENGINE_INFO = (0, __superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
|
|
8
8
|
var ENGINE_INFO = Object.freeze({
|
|
9
9
|
...PRIVATE_ENGINE_INFO,
|
|
10
|
-
superdocVersion: "2.0.0-next.
|
|
10
|
+
superdocVersion: "2.0.0-next.38",
|
|
11
11
|
roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
|
|
12
12
|
supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
|
|
13
13
|
supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
|
|
@@ -6,7 +6,7 @@ const COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
|
|
|
6
6
|
var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
|
|
7
7
|
var ENGINE_INFO = Object.freeze({
|
|
8
8
|
...PRIVATE_ENGINE_INFO,
|
|
9
|
-
superdocVersion: "2.0.0-next.
|
|
9
|
+
superdocVersion: "2.0.0-next.38",
|
|
10
10
|
roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
|
|
11
11
|
supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
|
|
12
12
|
supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
|
package/dist/superdoc.cjs
CHANGED
|
@@ -34695,7 +34695,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
|
|
|
34695
34695
|
this.config.colors = shuffleArray(this.config.colors);
|
|
34696
34696
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
34697
34697
|
this.colorIndex = 0;
|
|
34698
|
-
this.version = "2.0.0-next.
|
|
34698
|
+
this.version = "2.0.0-next.38";
|
|
34699
34699
|
this.#log("π¦ [superdoc] Using SuperDoc version:", this.version);
|
|
34700
34700
|
this.superdocId = config.superdocId || require_uuid.v4_default();
|
|
34701
34701
|
this.colors = this.config.colors ?? [];
|
package/dist/superdoc.es.js
CHANGED
|
@@ -34632,7 +34632,7 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
34632
34632
|
this.config.colors = shuffleArray(this.config.colors);
|
|
34633
34633
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
34634
34634
|
this.colorIndex = 0;
|
|
34635
|
-
this.version = "2.0.0-next.
|
|
34635
|
+
this.version = "2.0.0-next.38";
|
|
34636
34636
|
this.#log("π¦ [superdoc] Using SuperDoc version:", this.version);
|
|
34637
34637
|
this.superdocId = config.superdocId || v4_default();
|
|
34638
34638
|
this.colors = this.config.colors ?? [];
|
package/dist-cdn/superdoc.min.js
CHANGED
|
@@ -99,10 +99,10 @@ js: import "konva/skia-backend";
|
|
|
99
99
|
`,X4=()=>{if(typeof document>"u")throw new Error(IP)},xi=class Xk{constructor(t=[1,0,0,1,0,0]){this.dirty=!1,this.m=t&&t.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Xk(this.m)}copyInto(t){t.m[0]=this.m[0],t.m[1]=this.m[1],t.m[2]=this.m[2],t.m[3]=this.m[3],t.m[4]=this.m[4],t.m[5]=this.m[5]}point(t){const n=this.m;return{x:n[0]*t.x+n[2]*t.y+n[4],y:n[1]*t.x+n[3]*t.y+n[5]}}translate(t,n){return this.m[4]+=this.m[0]*t+this.m[2]*n,this.m[5]+=this.m[1]*t+this.m[3]*n,this}scale(t,n){return this.m[0]*=t,this.m[1]*=t,this.m[2]*=n,this.m[3]*=n,this}rotate(t){const n=Math.cos(t),r=Math.sin(t),o=this.m[0]*n+this.m[2]*r,i=this.m[1]*n+this.m[3]*r,s=this.m[0]*-r+this.m[2]*n,a=this.m[1]*-r+this.m[3]*n;return this.m[0]=o,this.m[1]=i,this.m[2]=s,this.m[3]=a,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(t,n){const r=this.m[0]+this.m[2]*n,o=this.m[1]+this.m[3]*n,i=this.m[2]+this.m[0]*t,s=this.m[3]+this.m[1]*t;return this.m[0]=r,this.m[1]=o,this.m[2]=i,this.m[3]=s,this}multiply(t){const n=this.m[0]*t.m[0]+this.m[2]*t.m[1],r=this.m[1]*t.m[0]+this.m[3]*t.m[1],o=this.m[0]*t.m[2]+this.m[2]*t.m[3],i=this.m[1]*t.m[2]+this.m[3]*t.m[3],s=this.m[0]*t.m[4]+this.m[2]*t.m[5]+this.m[4],a=this.m[1]*t.m[4]+this.m[3]*t.m[5]+this.m[5];return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}invert(){const t=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),n=this.m[3]*t,r=-this.m[1]*t,o=-this.m[2]*t,i=this.m[0]*t,s=t*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),a=t*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=n,this.m[1]=r,this.m[2]=o,this.m[3]=i,this.m[4]=s,this.m[5]=a,this}getMatrix(){return this.m}decompose(){const t=this.m[0],n=this.m[1],r=this.m[2],o=this.m[3],i=this.m[4],s=this.m[5],a=t*o-n*r,l={x:i,y:s,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(t!=0||n!=0){const u=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/u):-Math.acos(t/u),l.scaleX=u,l.scaleY=a/u,l.skewX=(t*r+n*o)/a,l.skewY=0}else if(r!=0||o!=0){const u=Math.sqrt(r*r+o*o);l.rotation=Math.PI/2-(o>0?Math.acos(-r/u):-Math.acos(r/u)),l.scaleX=a/u,l.scaleY=u,l.skewX=0,l.skewY=(t*r+n*o)/a}return l.rotation=Ae._getRotation(l.rotation),l}},EP="[object Array]",xP="[object Number]",TP="[object String]",RP="[object Boolean]",MP=Math.PI/180,LP=180/Math.PI,Xd="#",DP="",PP="0",FP="Konva warning: ",Q4="Konva error: ",OP="rgb(",Xy={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},BP=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Cp=[],Qd=null,NP=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(e){setTimeout(e,16)};const Ae={_isElement(e){return!!(e&&e.nodeType==1)},_isFunction(e){return!!(e&&e.constructor&&e.call&&e.apply)},_isPlainObject(e){return!!e&&e.constructor===Object},_isArray(e){return Object.prototype.toString.call(e)===EP},_isNumber(e){return Object.prototype.toString.call(e)===xP&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===TP},_isBoolean(e){return Object.prototype.toString.call(e)===RP},isObject(e){return e instanceof Object},isValidSelector(e){if(typeof e!="string")return!1;const t=e[0];return t==="#"||t==="."||t===t.toUpperCase()},_sign(e){return e===0||e>0?1:-1},requestAnimFrame(e){Cp.push(e),Cp.length===1&&NP(function(){const t=Cp;Cp=[],t.forEach(function(n){n()})})},createCanvasElement(){X4();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return X4(),document.createElement("img")},_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){const n=Ae.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex(e,t,n){return((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1)},_hexToRgb(e){e=e.replace(Xd,DP);const t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:t&255}},getRandomColor(){let e=(Math.random()*16777215<<0).toString(16);for(;e.length<6;)e=PP+e;return Xd+e},isCanvasFarblingActive(){if(Qd!==null)return Qd;if(typeof document>"u")return Qd=!1,!1;const e=this.createCanvasElement();e.width=10,e.height=10;const t=e.getContext("2d",{willReadFrequently:!0});t.clearRect(0,0,10,10),t.fillStyle="#282828",t.fillRect(0,0,10,10);const n=t.getImageData(0,0,10,10).data;let r=!1;for(let o=0;o<100;o++)if(n[o*4]!==40||n[o*4+1]!==40||n[o*4+2]!==40||n[o*4+3]!==255){r=!0;break}return Qd=r,this.releaseCanvas(e),Qd},getHitColor(){const e=this.getRandomColor();return this.isCanvasFarblingActive()?this.getSnappedHexColor(e):e},getHitColorKey(e,t,n){return this.isCanvasFarblingActive()&&(e=Math.round(e/5)*5,t=Math.round(t/5)*5,n=Math.round(n/5)*5),Xd+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return Xd+this._rgbToHex(Math.round(t.r/5)*5,Math.round(t.g/5)*5,Math.round(t.b/5)*5)},getRGB(e){let t;return e in Xy?(t=Xy[e],{r:t[0],g:t[1],b:t[2]}):e[0]===Xd?this._hexToRgb(e.substring(1)):e.substr(0,4)===OP?(t=BP.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA(e){return e=e||"black",Ae._namedColorToRBA(e)||Ae._hex3ColorToRGBA(e)||Ae._hex4ColorToRGBA(e)||Ae._hex6ColorToRGBA(e)||Ae._hex8ColorToRGBA(e)||Ae._rgbColorToRGBA(e)||Ae._rgbaColorToRGBA(e)||Ae._hslColorToRGBA(e)},_namedColorToRBA(e){const t=Xy[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(e.indexOf("rgb(")===0){e=e.match(/rgb\(([^)]+)\)/)[1];const t=e.split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(e.indexOf("rgba(")===0){e=e.match(/rgba\(([^)]+)\)/)[1];const t=e.split(/ *, */).map((n,r)=>n.slice(-1)==="%"?r===3?parseInt(n)/100:parseInt(n)/100*255:Number(n));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if(e[0]==="#"&&e.length===9)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if(e[0]==="#"&&e.length===7)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if(e[0]==="#"&&e.length===5)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if(e[0]==="#"&&e.length===4)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,o=Number(n[1])/100,i=Number(n[2])/100;let s,a,l;if(o===0)return l=i*255,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};i<.5?s=i*(1+o):s=i+o-i*o;const u=2*i-s,c=[0,0,0];for(let d=0;d<3;d++)a=r+1/3*-(d-1),a<0&&a++,a>1&&a--,6*a<1?l=u+(s-u)*6*a:2*a<1?l=s:3*a<2?l=u+(s-u)*(2/3-a)*6:l=u,c[d]=l*255;return{r:Math.round(c[0]),g:Math.round(c[1]),b:Math.round(c[2]),a:1}}},haveIntersection(e,t){return!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y)},cloneObject(e){const t={};for(const n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray(e){return e.slice(0)},degToRad(e){return e*MP},radToDeg(e){return e*LP},_degToRad(e){return Ae.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),Ae.degToRad(e)},_radToDeg(e){return Ae.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),Ae.radToDeg(e)},_getRotation(e){return vt.angleDeg?Ae.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(Q4+e)},error(e){console.error(Q4+e)},warn(e){vt.showWarnings&&console.warn(FP+e)},each(e,t){for(const n in e)t(n,e[n])},_inRange(e,t,n){return t<=e&&e<n},_getProjectionToSegment(e,t,n,r,o,i){let s,a,l;const u=(e-n)*(e-n)+(t-r)*(t-r);if(u==0)s=e,a=t,l=(o-n)*(o-n)+(i-r)*(i-r);else{const c=((o-e)*(n-e)+(i-t)*(r-t))/u;c<0?(s=e,a=t,l=(e-o)*(e-o)+(t-i)*(t-i)):c>1?(s=n,a=r,l=(n-o)*(n-o)+(r-i)*(r-i)):(s=e+c*(n-e),a=t+c*(r-t),l=(s-o)*(s-o)+(a-i)*(a-i))}return[s,a,l]},_getProjectionToLine(e,t,n){const r=Ae.cloneObject(e);let o=Number.MAX_VALUE;return t.forEach(function(i,s){if(!n&&s===t.length-1)return;const a=t[(s+1)%t.length],l=Ae._getProjectionToSegment(i.x,i.y,a.x,a.y,e.x,e.y),u=l[0],c=l[1],d=l[2];d<o&&(r.x=u,r.y=c,o=d)}),r},_prepareArrayForTween(e,t,n){const r=[],o=[];if(e.length>t.length){const s=t;t=e,e=s}for(let s=0;s<e.length;s+=2)r.push({x:e[s],y:e[s+1]});for(let s=0;s<t.length;s+=2)o.push({x:t[s],y:t[s+1]});const i=[];return o.forEach(function(s){const a=Ae._getProjectionToLine(s,r,n);i.push(a.x),i.push(a.y)}),i},_prepareToStringify(e){let t;e.visitedByCircularReferenceRemoval=!0;for(const n in e)if(e.hasOwnProperty(n)&&e[n]&&typeof e[n]=="object"){if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||Ae._isElement(e[n]))if(t.configurable)delete e[n];else return null;else if(Ae._prepareToStringify(e[n])===null)if(t.configurable)delete e[n];else return null}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(const n in t)e[n]=t[n];return e},_getFirstPointerId(e){return e.touches?e.changedTouches[0].identifier:e.pointerId||999},releaseCanvas(...e){vt.releaseCanvasOnDestroy&&e.forEach(t=>{t.width=0,t.height=0})},drawRoundedRectPath(e,t,n,r){let o=t<0?t:0,i=n<0?n:0;t=Math.abs(t),n=Math.abs(n);let s=0,a=0,l=0,u=0;typeof r=="number"?s=a=l=u=Math.min(r,t/2,n/2):(s=Math.min(r[0]||0,t/2,n/2),a=Math.min(r[1]||0,t/2,n/2),u=Math.min(r[2]||0,t/2,n/2),l=Math.min(r[3]||0,t/2,n/2)),e.moveTo(o+s,i),e.lineTo(o+t-a,i),e.arc(o+t-a,i+a,a,Math.PI*3/2,0,!1),e.lineTo(o+t,i+n-u),e.arc(o+t-u,i+n-u,u,0,Math.PI/2,!1),e.lineTo(o+l,i+n),e.arc(o+l,i+n-l,l,Math.PI/2,Math.PI,!1),e.lineTo(o,i+s),e.arc(o+s,i+s,s,Math.PI,Math.PI*3/2,!1)},drawRoundedPolygonPath(e,t,n,r,o){r=Math.abs(r);for(let i=0;i<n;i++){const s=t[(i-1+n)%n],a=t[i],l=t[(i+1)%n],u={x:a.x-s.x,y:a.y-s.y},c={x:l.x-a.x,y:l.y-a.y},d=Math.hypot(u.x,u.y),h=Math.hypot(c.x,c.y);let m;typeof o=="number"?m=o:m=i<o.length?o[i]:0,m=r*Math.cos(Math.PI/n)*Math.min(1,m/r*2);const p={x:u.x/d,y:u.y/d},g={x:c.x/h,y:c.y/h},C={x:a.x-p.x*m,y:a.y-p.y*m},_={x:a.x+g.x*m,y:a.y+g.y*m};i===0?e.moveTo(C.x,C.y):e.lineTo(C.x,C.y),e.arcTo(a.x,a.y,_.x,_.y,m)}}};function zP(e){const t=[],n=e.length,r=Ae;for(let o=0;o<n;o++){let i=e[o];r._isNumber(i)?i=Math.round(i*1e3)/1e3:r._isString(i)||(i=i+""),t.push(i)}return t}var Z4=",",HP="(",UP=")",VP="([",jP="])",GP=";",WP="()",KP="=",J4=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","roundRect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],qP=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],YP=100,_p=null;function $4(){if(_p!==null)return _p;try{const e=Ae.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(_p=!1,!1)}catch{return _p=!1,!1}}var Sp=class{constructor(e){this.canvas=e,vt.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){let n=this.traceArr,r=n.length,o="",i,s,a,l;for(i=0;i<r;i++)s=n[i],a=s.method,a?(l=s.args,o+=a,e?o+=WP:Ae._isArray(l[0])?o+=VP+l.join(Z4)+jP:(t&&(l=l.map(u=>typeof u=="number"?Math.floor(u):u)),o+=HP+l.join(Z4)+UP)):(o+=s.property,e||(o+=KP+s.val)),o+=GP;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=YP&&t.shift()}reset(){const e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){const t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){const t=e.getAbsoluteOpacity();t!==1&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}_applyMiterLimit(e){const t=e.attrs.miterLimit;t!=null&&this.setAttr("miterLimit",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,o,i){this._context.arc(e,t,n,r,o,i)}arcTo(e,t,n,r,o){this._context.arcTo(e,t,n,r,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,o,i){this._context.bezierCurveTo(e,t,n,r,o,i)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,t){const n=arguments;if(n.length===2)return this._context.createImageData(e,t);if(n.length===1)return this._context.createImageData(e)}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,o,i){return this._context.createRadialGradient(e,t,n,r,o,i)}drawImage(e,t,n,r,o,i,s,a,l){const u=arguments,c=this._context;u.length===3?c.drawImage(e,t,n):u.length===5?c.drawImage(e,t,n,r,o):u.length===9&&c.drawImage(e,t,n,r,o,i,s,a,l)}ellipse(e,t,n,r,o,i,s,a){this._context.ellipse(e,t,n,r,o,i,s,a)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}roundRect(e,t,n,r,o){this._context.roundRect(e,t,n,r,o)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,o,i){this._context.setTransform(e,t,n,r,o,i)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,o,i){this._context.transform(e,t,n,r,o,i)}translate(e,t){this._context.translate(e,t)}_enableTrace(){let e=this,t=J4.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=zP(Array.prototype.slice.call(arguments,0)),l=a.apply(e,arguments),e._trace({method:s,args:o}),l}};for(r=0;r<t;r++)i(J4[r]);e.setAttr=function(){n.apply(e,arguments);const s=arguments[0];let a=arguments[1];(s==="shadowOffsetX"||s==="shadowOffsetY"||s==="shadowBlur")&&(a=a/this.canvas.getPixelRatio()),e._trace({property:s,val:a})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||t==="source-over"||this.setAttr("globalCompositeOperation",t)}};qP.forEach(function(e){Object.defineProperty(Sp.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var XP=class extends Sp{constructor(e,{willReadFrequently:t=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:t})}_fillColor(e){const t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){const t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&n==="color"){this._fillColor(e);return}const r=e.getFillPatternImage();if(r&&n==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&n==="linear-gradient"){this._fillLinearGradient(e);return}const i=e.getFillRadialGradientColorStops();if(i&&n==="radial-gradient"){this._fillRadialGradient(e);return}t?this._fillColor(e):r?this._fillPattern(e):o?this._fillLinearGradient(e):i&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(let i=0;i<r.length;i+=2)o.addColorStop(r[i],r[i+1]);this.setAttr("strokeStyle",o)}}_stroke(e){const t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();const r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r;const o=(t=e.getShadowRGBA())!==null&&t!==void 0?t:"black",i=(n=e.getShadowBlur())!==null&&n!==void 0?n:5,s=(r=e.getShadowOffset())!==null&&r!==void 0?r:{x:0,y:0},a=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),u=a.x*l,c=a.y*l;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",i*Math.min(Math.abs(u),Math.abs(c))),this.setAttr("shadowOffsetX",s.x*u),this.setAttr("shadowOffsetY",s.y*c)}},QP=class extends Sp{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const t=e.getStrokeScaleEnabled();if(!t){this.save();const o=this.getCanvas().getPixelRatio();this.setTransform(o,0,0,o,0,0)}this._applyLineCap(e);const n=e.hitStrokeWidth(),r=n==="auto"?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),t||this.restore()}}},kp;function ZP(){if(kp)return kp;const e=Ae.createCanvasElement(),t=e.getContext("2d");return kp=(function(){return(vt._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),Ae.releaseCanvas(e),kp}var Qy=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||vt.pixelRatio||ZP(),this._canvas=Ae.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){const t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";const t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch{try{return this._canvas.toDataURL()}catch(r){return Ae.error("Unable to get data URL. "+r.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}},ja=class extends Qy{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new XP(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},Zy=class extends Qy{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new QP(this),this.setSize(e.width,e.height)}};const Cn={get isDragging(){let e=!1;return Cn._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return Cn._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];Cn._dragElements.forEach((n,r)=>{const{node:o}=n,i=o.getStage();i.setPointersPositions(e),n.pointerId===void 0&&(n.pointerId=Ae._getFirstPointerId(e));const s=i._changedPointerPositions.find(a=>a.id===n.pointerId);if(s){if(n.dragStatus!=="dragging"){const a=o.dragDistance();if(Math.max(Math.abs(s.x-n.startPointerPos.x),Math.abs(s.y-n.startPointerPos.y))<a||(o.startDrag({evt:e}),!o.isDragging()))return}o._setDragPosition(e,n),t.push(o)}}),t.forEach(n=>{n.getStage()&&n.fire("dragmove",{type:"dragmove",target:n,evt:e},!0)})},_endDragBefore(e){const t=[];Cn._dragElements.forEach(n=>{const{node:r}=n,o=r.getStage();if(e&&o.setPointersPositions(e),!o._changedPointerPositions.find(s=>s.id===n.pointerId))return;(n.dragStatus==="dragging"||n.dragStatus==="stopped")&&(Cn.justDragged=!0,vt._mouseListenClick=!1,vt._touchListenClick=!1,vt._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof vt.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){Cn._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&Cn._dragElements.delete(n)})}};vt.isBrowser&&(window.addEventListener("mouseup",Cn._endDragBefore,!0),window.addEventListener("touchend",Cn._endDragBefore,!0),window.addEventListener("touchcancel",Cn._endDragBefore,!0),window.addEventListener("mousemove",Cn._drag),window.addEventListener("touchmove",Cn._drag),window.addEventListener("mouseup",Cn._endDragAfter,!1),window.addEventListener("touchend",Cn._endDragAfter,!1),window.addEventListener("touchcancel",Cn._endDragAfter,!1));function Ga(e){return Ae._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||Ae._isBoolean(e)?e:Object.prototype.toString.call(e)}function eS(e){return e>255?255:e<0?0:Math.round(e)}function ut(){if(vt.isUnminified)return function(e,t){return Ae._isNumber(e)||Ae.warn(Ga(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function Ap(e){if(vt.isUnminified)return function(t,n){let r=Ae._isNumber(t),o=Ae._isArray(t)&&t.length==e;return!r&&!o&&Ae.warn(Ga(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function Jy(){if(vt.isUnminified)return function(e,t){return Ae._isNumber(e)||e==="auto"||Ae.warn(Ga(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function jl(){if(vt.isUnminified)return function(e,t){return Ae._isString(e)||Ae.warn(Ga(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function tS(){if(vt.isUnminified)return function(e,t){const n=Ae._isString(e),r=Object.prototype.toString.call(e)==="[object CanvasGradient]"||e&&e.addColorStop;return n||r||Ae.warn(Ga(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function JP(){if(vt.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(Ae._isArray(e)?e.forEach(function(r){Ae._isNumber(r)||Ae.warn('"'+t+'" attribute has non numeric element '+r+". Make sure that all elements are numbers.")}):Ae.warn(Ga(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function Ti(){if(vt.isUnminified)return function(e,t){return e===!0||e===!1||Ae.warn(Ga(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function $P(e){if(vt.isUnminified)return function(t,n){return t==null||Ae.isObject(t)||Ae.warn(Ga(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var Zd="get",Jd="set";const le={addGetterSetter(e,t,n,r,o){le.addGetter(e,t,n),le.addSetter(e,t,r,o),le.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=Zd+Ae._capitalize(t);e.prototype[r]=e.prototype[r]||function(){const o=this.attrs[t];return o===void 0?n:o}},addSetter(e,t,n,r){const o=Jd+Ae._capitalize(t);e.prototype[o]||le.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=Jd+Ae._capitalize(t);e.prototype[o]=function(i){return n&&i!==void 0&&i!==null&&(i=n.call(this,i,t)),this._setAttr(t,i),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,o){const i=n.length,s=Ae._capitalize,a=Zd+s(t),l=Jd+s(t);e.prototype[a]=function(){const c={};for(let d=0;d<i;d++){const h=n[d];c[h]=this.getAttr(t+s(h))}return c};const u=$P(n);e.prototype[l]=function(c){const d=this.attrs[t];r&&(c=r.call(this,c,t)),u&&u.call(this,c,t);for(const h in c)c.hasOwnProperty(h)&&this._setAttr(t+s(h),c[h]);return c||n.forEach(h=>{this._setAttr(t+s(h),void 0)}),this._fireChangeEvent(t,d,c),o&&o.call(this),this},le.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=Ae._capitalize(t),r=Jd+n,o=Zd+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[o]()}},addDeprecatedGetterSetter(e,t,n,r){Ae.error("Adding deprecated "+t);const o=Zd+Ae._capitalize(t),i=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[o]=function(){Ae.error(i);const s=this.attrs[t];return s===void 0?n:s},le.addSetter(e,t,r,function(){Ae.error(i)}),le.addOverloadedGetterSetter(e,t)},backCompat(e,t){Ae.each(t,function(n,r){const o=e.prototype[r],i=Zd+Ae._capitalize(n),s=Jd+Ae._capitalize(n);function a(){o.apply(this,arguments),Ae.error('"'+n+'" method is deprecated and will be removed soon. Use ""'+r+'" instead.')}e.prototype[n]=a,e.prototype[i]=a,e.prototype[s]=a})},afterSetFilter(){this._filterUpToDate=!1}};function eF(e){const t=/(\w+)\(([^)]+)\)/g;let n;for(;(n=t.exec(e))!==null;){const[,r,o]=n;switch(r){case"blur":{const i=parseFloat(o.replace("px",""));return function(s){this.blurRadius(i*.5);const a=vt.Filters;a&&a.Blur&&a.Blur.call(this,s)}}case"brightness":{const i=o.includes("%")?parseFloat(o)/100:parseFloat(o);return function(s){this.brightness(i);const a=vt.Filters;a&&a.Brightness&&a.Brightness.call(this,s)}}case"contrast":{const i=parseFloat(o);return function(s){const a=100*(Math.sqrt(i)-1);this.contrast(a);const l=vt.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=vt.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=vt.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=vt.Filters;s&&s.Invert&&s.Invert.call(this,i)};default:Ae.warn(`CSS filter "${r}" is not supported in fallback mode. Consider using function filters for better compatibility.`);break}}return()=>{}}var Ip="absoluteOpacity",nS="allEventListeners",Js="absoluteTransform",rS="absoluteScale",Gl="canvas",tF="Change",nF="children",rF="konva",$y="listening",oF="mouseenter",iF="mouseleave",sF="pointerenter",aF="pointerleave",lF="touchenter",cF="touchleave",oS="set",iS="Shape",Ep=" ",sS="stage",Wa="transform",uF="Stage",e0="visible",dF=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Ep),fF=1,yt=class Tf{constructor(t){this._id=fF++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(t),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(t){(t===Wa||t===Js)&&this._cache.get(t)?this._cache.get(t).dirty=!0:t?this._cache.delete(t):this._cache.clear()}_getCache(t,n){let r=this._cache.get(t);return(r===void 0||(t===Wa||t===Js)&&r.dirty===!0)&&(r=n.call(this),this._cache.set(t,r)),r}_calculate(t,n,r){if(!this._attachedDepsListeners.get(t)){const o=n.map(i=>i+"Change.konva").join(Ep);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(Gl)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Js&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(Gl)){const{scene:t,filter:n,hit:r}=this._cache.get(Gl);Ae.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(Gl)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(t){const n=t||{};let r={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(r=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));let o=Math.ceil(n.width||r.width),i=Math.ceil(n.height||r.height),s=n.pixelRatio,a=n.x===void 0?Math.floor(r.x):n.x,l=n.y===void 0?Math.floor(r.y):n.y,u=n.offset||0,c=n.drawBorder||!1,d=n.hitCanvasPixelRatio||1;if(!o||!i){Ae.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}const h=Math.abs(Math.round(r.x)-a)>.5?1:0,m=Math.abs(Math.round(r.y)-l)>.5?1:0;o+=u*2+h,i+=u*2+m,a-=u,l-=u;const p=new ja({pixelRatio:s,width:o,height:i}),g=new ja({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),C=new Zy({pixelRatio:d,width:o,height:i}),_=p.getContext(),k=C.getContext(),y=new ja({width:p.width/p.pixelRatio+Math.abs(a),height:p.height/p.pixelRatio+Math.abs(l),pixelRatio:p.pixelRatio}),b=y.getContext();return C.isCache=!0,p.isCache=!0,this._cache.delete(Gl),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(p.getContext()._context.imageSmoothingEnabled=!1,g.getContext()._context.imageSmoothingEnabled=!1),_.save(),k.save(),b.save(),_.translate(-a,-l),k.translate(-a,-l),b.translate(-a,-l),y.x=a,y.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(Ip),this._clearSelfAndDescendantCache(rS),this.drawScene(p,this,y),this.drawHit(C,this),this._isUnderCache=!1,_.restore(),k.restore(),c&&(_.save(),_.beginPath(),_.rect(0,0,o,i),_.closePath(),_.setAttr("strokeStyle","red"),_.setAttr("lineWidth",5),_.stroke(),_.restore()),Ae.releaseCanvas(y._canvas),this._cache.set(Gl,{scene:p,filter:g,hit:C,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(Gl)}getClientRect(t){throw new Error('abstract "getClientRect" method call')}_transformedRect(t,n){const r=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];let o=1/0,i=1/0,s=-1/0,a=-1/0;const l=this.getAbsoluteTransform(n);return r.forEach(function(u){const c=l.point(u);o===void 0&&(o=s=c.x,i=a=c.y),o=Math.min(o,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x),a=Math.max(a,c.y)}),{x:o,y:i,width:s-o,height:a-i}}_drawCachedSceneCanvas(t){t.save(),t._applyOpacity(this),t._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();t.translate(n.x,n.y);const r=this._getCachedSceneCanvas(),o=r.pixelRatio;t.drawImage(r._canvas,0,0,r.width/o,r.height/o),t.restore()}_drawCachedHitCanvas(t){const n=this._getCanvasCache(),r=n.hit;t.save(),t.translate(n.x,n.y),t.drawImage(r._canvas,0,0,r.width/r.pixelRatio,r.height/r.pixelRatio),t.restore()}_getCachedSceneCanvas(){let t=this.filters(),n=this._getCanvasCache(),r=n.scene,o=n.filter,i=o.getContext(),s,a,l,u;if(!t||t.length===0)return r;if(this._filterUpToDate)return o;let c=!0;for(let h=0;h<t.length;h++)if(typeof t[h]=="string"&&$4(),typeof t[h]!="string"||!$4()){c=!1;break}const d=r.pixelRatio;if(o.setSize(r.width/r.pixelRatio,r.height/r.pixelRatio),c){const h=t.join(" ");return i.save(),i.setAttr("filter",h),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),i.restore(),this._filterUpToDate=!0,o}try{for(s=t.length,i.clear(),i.drawImage(r._canvas,0,0,r.getWidth()/d,r.getHeight()/d),a=i.getImageData(0,0,o.getWidth(),o.getHeight()),l=0;l<s;l++)u=t[l],typeof u=="string"&&(u=eF(u)),u.call(this,a),i.putImageData(a,0,0)}catch(h){Ae.error("Unable to apply filter. "+h.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}return this._filterUpToDate=!0,o}on(...t){const n=t[0],r=t[1];if(t[2],this._cache&&this._cache.delete(nS),t.length===3)return this._delegate.apply(this,t);const o=n.split(Ep);for(let i=0;i<o.length;i++){const s=o[i].split("."),a=s[0],l=s[1]||"";this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:l,handler:r})}return this}off(t,n){let r=(t||"").split(Ep),o=r.length,i,s,a,l,u,c;if(this._cache&&this._cache.delete(nS),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<o;i++)if(a=r[i],l=a.split("."),u=l[0],c=l[1],u)this.eventListeners[u]&&this._off(u,c,n);else for(s in this.eventListeners)this._off(s,c,n);return this}dispatchEvent(t){const n={target:this,type:t.type,evt:t};return this.fire(t.type,n),this}addEventListener(t,n){return this.on(t,function(r){n.call(this,r.evt)}),this}removeEventListener(t){return this.off(t),this}_delegate(t,n,r){const o=this;return this.on(t,function(i){const s=i.target.findAncestors(n,!0,o);for(let a=0;a<s.length;a++)i=Ae.cloneObject(i),i.currentTarget=s[a],r.call(s[a],i)}),this}remove(){return this.isDragging()&&this.stopDrag(),Cn._dragElements.delete(this._id),Cn._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&Cn._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Js),this._clearSelfAndDescendantCache(Ip),this._clearSelfAndDescendantCache(rS),this._clearSelfAndDescendantCache(sS),this._clearSelfAndDescendantCache(e0),this._clearSelfAndDescendantCache($y)}_remove(){this._clearCaches();const t=this.getParent();t&&t.children&&(t.children.splice(this.index,1),t._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(t){const n="get"+Ae._capitalize(t);return Ae._isFunction(this[n])?this[n]():this.attrs[t]}getAncestors(){let t=this.getParent(),n=[];for(;t;)n.push(t),t=t.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(t){return this._batchTransformChanges(()=>{let n,r;if(!t)return this;for(n in t)n!==nF&&(r=oS+Ae._capitalize(n),Ae._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache($y,this._isListening)}_isListening(t){if(!this.listening())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isListening(t):!0}isVisible(){return this._getCache(e0,this._isVisible)}_isVisible(t){if(!this.visible())return!1;const n=this.getParent();return n&&n!==t&&this!==t?n._isVisible(t):!0}shouldDrawHit(t,n=!1){if(t)return this._isVisible(t)&&this._isListening(t);const r=this.getLayer();let o=!1;Cn._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!vt.hitOnDragEnabled&&(o||vt.isTransforming());return this.isListening()&&this.isVisible()&&!i}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){let t=this.getDepth(),n=this,r=0,o,i,s,a;function l(c){for(o=[],i=c.length,s=0;s<i;s++)a=c[s],r++,a.nodeType!==iS&&(o=o.concat(a.getChildren().slice())),a._id===n._id&&(s=i);o.length>0&&o[0].getDepth()<=t&&l(o)}const u=this.getStage();return n.nodeType!==uF&&u&&l(u.getChildren()),r}getDepth(){let t=0,n=this.parent;for(;n;)t++,n=n.parent;return t}_batchTransformChanges(t){this._batchingTransformChange=!0,t(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Wa),this._clearSelfAndDescendantCache(Js)),this._needClearTransformCache=!1}setPosition(t){return this._batchTransformChanges(()=>{this.x(t.x),this.y(t.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const t=this.getStage();if(!t)return null;const n=t.getPointerPosition();if(!n)return null;const r=this.getAbsoluteTransform().copy();return r.invert(),r.point(n)}getAbsolutePosition(t){let n=!1,r=this.parent;for(;r;){if(r.isCached()){n=!0;break}r=r.parent}n&&!t&&(t=!0);const o=this.getAbsoluteTransform(t).getMatrix(),i=new xi,s=this.offset();return i.m=o.slice(),i.translate(s.x,s.y),i.getTranslation()}setAbsolutePosition(t){const{x:n,y:r,...o}=this._clearTransform();this.attrs.x=n,this.attrs.y=r,this._clearCache(Wa);const i=this._getAbsoluteTransform().copy();return i.invert(),i.translate(t.x,t.y),t={x:this.attrs.x+i.getTranslation().x,y:this.attrs.y+i.getTranslation().y},this._setTransform(o),this.setPosition({x:t.x,y:t.y}),this._clearCache(Wa),this._clearSelfAndDescendantCache(Js),this}_setTransform(t){let n;for(n in t)this.attrs[n]=t[n]}_clearTransform(){const t={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,t}move(t){let n=t.x,r=t.y,o=this.x(),i=this.y();return n!==void 0&&(o+=n),r!==void 0&&(i+=r),this.setPosition({x:o,y:i}),this}_eachAncestorReverse(t,n){let r=[],o=this.getParent(),i,s;if(!(n&&n._id===this._id)){for(r.unshift(this);o&&(!n||o._id!==n._id);)r.unshift(o),o=o.parent;for(i=r.length,s=0;s<i;s++)t(r[s])}}rotate(t){return this.rotation(this.rotation()+t),this}moveToTop(){if(!this.parent)return Ae.warn("Node has no parent. moveToTop function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Ae.warn("Node has no parent. moveUp function is ignored."),!1;const t=this.index;return t<this.parent.getChildren().length-1?(this.parent.children.splice(t,1),this.parent.children.splice(t+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Ae.warn("Node has no parent. moveDown function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.splice(t-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Ae.warn("Node has no parent. moveToBottom function is ignored."),!1;const t=this.index;return t>0?(this.parent.children.splice(t,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(t){if(!this.parent)return Ae.warn("Node has no parent. zIndex parameter is ignored."),this;(t<0||t>=this.parent.children.length)&&Ae.warn("Unexpected value "+t+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");const n=this.index;return this.parent.children.splice(n,1),this.parent.children.splice(t,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(Ip,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){let t=this.opacity();const n=this.getParent();return n&&!n._isUnderCache&&(t*=n.getAbsoluteOpacity()),t}moveTo(t){return this.getParent()!==t&&(this._remove(),t.add(this)),this}toObject(){let t=this.getAttrs(),n,r,o,i,s;const a={attrs:{},className:this.getClassName()};for(n in t)r=t[n],s=Ae.isObject(r)&&!Ae._isPlainObject(r)&&!Ae._isArray(r),!s&&(o=typeof this[n]=="function"&&this[n],delete t[n],i=o?o.call(this):null,t[n]=r,i!==r&&(a.attrs[n]=r));return Ae._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(t,n,r){const o=[];n&&this._isMatch(t)&&o.push(this);let i=this.parent;for(;i;){if(i===r)return o;i._isMatch(t)&&o.push(i),i=i.parent}return o}isAncestorOf(t){return!1}findAncestor(t,n,r){return this.findAncestors(t,n,r)[0]}_isMatch(t){if(!t)return!1;if(typeof t=="function")return t(this);let n=t.replace(/ /g,"").split(","),r=n.length,o,i;for(o=0;o<r;o++)if(i=n[o],Ae.isValidSelector(i)||(Ae.warn('Selector "'+i+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Ae.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Ae.warn("Konva is awesome, right?")),i.charAt(0)==="#"){if(this.id()===i.slice(1))return!0}else if(i.charAt(0)==="."){if(this.hasName(i.slice(1)))return!0}else if(this.className===i||this.nodeType===i)return!0;return!1}getLayer(){const t=this.getParent();return t?t.getLayer():null}getStage(){return this._getCache(sS,this._getStage)}_getStage(){const t=this.getParent();return t?t.getStage():null}fire(t,n={},r){return n.target=n.target||this,r?this._fireAndBubble(t,n):this._fire(t,n),this}getAbsoluteTransform(t){return t?this._getAbsoluteTransform(t):this._getCache(Js,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new xi,this._eachAncestorReverse(function(r){const o=r.transformsEnabled();o==="all"?n.multiply(r.getTransform()):o==="position"&&n.translate(r.x()-r.offsetX(),r.y()-r.offsetY())},t),n;{n=this._cache.get(Js)||new xi,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();const r=this.transformsEnabled();if(r==="all")n.multiply(this.getTransform());else if(r==="position"){const o=this.attrs.x||0,i=this.attrs.y||0,s=this.attrs.offsetX||0,a=this.attrs.offsetY||0;n.translate(o-s,i-a)}return n.dirty=!1,n}}getAbsoluteScale(t){let n=this;for(;n;)n._isUnderCache&&(t=n),n=n.getParent();const r=this.getAbsoluteTransform(t).decompose();return{x:r.scaleX,y:r.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Wa,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(Wa)||new xi;r.reset();const o=this.x(),i=this.y(),s=vt.getAngle(this.rotation()),a=(t=this.attrs.scaleX)!==null&&t!==void 0?t:1,l=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,u=this.attrs.skewX||0,c=this.attrs.skewY||0,d=this.attrs.offsetX||0,h=this.attrs.offsetY||0;return(o!==0||i!==0)&&r.translate(o,i),s!==0&&r.rotate(s),(u!==0||c!==0)&&r.skew(u,c),(a!==1||l!==1)&&r.scale(a,l),(d!==0||h!==0)&&r.translate(-1*d,-1*h),r.dirty=!1,r}clone(t){let n=Ae.cloneObject(this.attrs),r,o,i,s,a;for(r in t)n[r]=t[r];const l=new this.constructor(n);for(r in this.eventListeners)for(o=this.eventListeners[r],i=o.length,s=0;s<i;s++)a=o[s],a.name.indexOf(rF)<0&&(l.eventListeners[r]||(l.eventListeners[r]=[]),l.eventListeners[r].push(a));return l}_toKonvaCanvas(t){t=t||{};const n=this.getClientRect(),r=this.getStage(),o=t.x!==void 0?t.x:Math.floor(n.x),i=t.y!==void 0?t.y:Math.floor(n.y),s=t.pixelRatio||1,a=new ja({width:t.width||Math.ceil(n.width)||(r?r.width():0),height:t.height||Math.ceil(n.height)||(r?r.height():0),pixelRatio:s}),l=a.getContext(),u=new ja({width:a.width/a.pixelRatio+Math.abs(o),height:a.height/a.pixelRatio+Math.abs(i),pixelRatio:a.pixelRatio});return t.imageSmoothingEnabled===!1&&(l._context.imageSmoothingEnabled=!1),l.save(),(o||i)&&l.translate(-1*o,-1*i),this.drawScene(a,void 0,u),l.restore(),a}toCanvas(t){return this._toKonvaCanvas(t)._canvas}toDataURL(t){t=t||{};const n=t.mimeType||null,r=t.quality||null,o=this._toKonvaCanvas(t).toDataURL(n,r);return t.callback&&t.callback(o),o}toImage(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,Ae._urlToImage(this.toDataURL(t),function(i){n(i),o?.(i)})}catch(o){r(o)}})}toBlob(t){return new Promise((n,r)=>{try{const o=t?.callback;o&&delete t.callback,this.toCanvas(t).toBlob(i=>{n(i),o?.(i)},t?.mimeType,t?.quality)}catch(o){r(o)}})}setSize(t){return this.width(t.width),this.height(t.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():vt.dragDistance}_off(t,n,r){let o=this.eventListeners[t],i,s,a;for(i=0;i<o.length;i++)if(s=o[i].name,a=o[i].handler,(s!=="konva"||n==="konva")&&(!n||s===n)&&(!r||r===a)){if(o.splice(i,1),o.length===0){delete this.eventListeners[t];break}i--}}_fireChangeEvent(t,n,r){this._fire(t+tF,{oldVal:n,newVal:r})}addName(t){if(!this.hasName(t)){const n=this.name(),r=n?n+" "+t:t;this.name(r)}return this}hasName(t){if(!t)return!1;const n=this.name();return n?(n||"").split(/\s/g).indexOf(t)!==-1:!1}removeName(t){const n=(this.name()||"").split(/\s/g),r=n.indexOf(t);return r!==-1&&(n.splice(r,1),this.name(n.join(" "))),this}setAttr(t,n){const r=this[oS+Ae._capitalize(t)];return Ae._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(vt.autoDrawEnabled){const t=this.getLayer()||this.getStage();t?.batchDraw()}}_setAttr(t,n){const r=this.attrs[t];r===n&&!Ae.isObject(n)||(n==null?delete this.attrs[t]:this.attrs[t]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(t,r,n),this._requestDraw())}_setComponentAttr(t,n,r){let o;r!==void 0&&(o=this.attrs[t],o||(this.attrs[t]=this.getAttr(t)),this.attrs[t][n]=r,this._fireChangeEvent(t,o,r))}_fireAndBubble(t,n,r){n&&this.nodeType===iS&&(n.target=this);const o=[oF,iF,sF,aF,lF,cF];if(!(o.indexOf(t)!==-1&&(r&&(this===r||this.isAncestorOf&&this.isAncestorOf(r))||this.nodeType==="Stage"&&!r))){this._fire(t,n);const i=o.indexOf(t)!==-1&&r&&r.isAncestorOf&&r.isAncestorOf(this)&&!r.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!i&&(r&&r.parent?this._fireAndBubble.call(this.parent,t,n,r):this._fireAndBubble.call(this.parent,t,n))}}_getProtoListeners(t){var n,r;const{nodeType:o}=this,i=Tf.protoListenerMap.get(o)||{};let s=i?.[t];if(s===void 0){s=[];let a=Object.getPrototypeOf(this);for(;a;){const l=(r=(n=a.eventListeners)===null||n===void 0?void 0:n[t])!==null&&r!==void 0?r:[];s.push(...l),a=Object.getPrototypeOf(a)}i[t]=s,Tf.protoListenerMap.set(o,i)}return s}_fire(t,n){n=n||{},n.currentTarget=this,n.type=t;const r=this._getProtoListeners(t);if(r){const i=r.slice();for(let s=0;s<i.length;s++)i[s].handler.call(this,n)}const o=this.eventListeners[t];if(o){const i=o.slice(),s=i.length;for(let l=0;l<i.length;l++)i[l].handler.call(this,n);const a=this.eventListeners[t];if(a)for(let l=s;l<a.length;l++)a[l].handler.call(this,n)}}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(t){const n=t?t.pointerId:void 0,r=this.getStage(),o=this.getAbsolutePosition();if(!r)return;const i=r._getPointerById(n)||r._changedPointerPositions[0]||o;Cn._dragElements.set(this._id,{node:this,startPointerPos:i,offset:{x:i.x-o.x,y:i.y-o.y},dragStatus:"ready",pointerId:n,startEvent:t})}startDrag(t,n=!0){Cn._dragElements.has(this._id)||this._createDragElement(t);const r=Cn._dragElements.get(this._id);r.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:r.startEvent&&r.startEvent.evt||t&&t.evt},n)}_setDragPosition(t,n){const r=this.getStage()._getPointerById(n.pointerId);if(!r)return;let o={x:r.x-n.offset.x,y:r.y-n.offset.y};const i=this.dragBoundFunc();if(i!==void 0){const s=i.call(this,o,t);s?o=s:Ae.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==o.x||this._lastPos.y!==o.y)&&(this.setAbsolutePosition(o),this._requestDraw()),this._lastPos=o}stopDrag(t){const n=Cn._dragElements.get(this._id);n&&(n.dragStatus="stopped"),Cn._endDragBefore(t),Cn._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=Cn._dragElements.get(this._id);return t?t.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(t){if(!(t.evt.button===void 0||vt.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;Cn._dragElements.forEach(r=>{this.isAncestorOf(r.node)&&(n=!0)}),n||this._createDragElement(t)})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const t=Cn._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&Cn._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(t={x:0,y:0}){const n=this.getStage();if(!n)return!1;const r={x:-t.x,y:-t.y,width:n.width()+2*t.x,height:n.height()+2*t.y};return Ae.haveIntersection(r,this.getClientRect())}static create(t,n){return Ae._isString(t)&&(t=JSON.parse(t)),this._createNode(t,n)}static _createNode(t,n){let r=Tf.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),vt[r]||(Ae.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=vt[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(Tf._createNode(o[a]));return i}};yt.protoListenerMap=new Map,yt.prototype.nodeType="Node",yt.prototype._attrsAffectingSize=[],yt.prototype.eventListeners={},yt.prototype.on(dF,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Wa),this._clearSelfAndDescendantCache(Js)}),yt.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(e0)}),yt.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache($y)}),yt.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(Ip)});var Hn=le.addGetterSetter;Hn(yt,"zIndex"),Hn(yt,"absolutePosition"),Hn(yt,"position"),Hn(yt,"x",0,ut()),Hn(yt,"y",0,ut()),Hn(yt,"globalCompositeOperation","source-over",jl()),Hn(yt,"opacity",1,ut()),Hn(yt,"name","",jl()),Hn(yt,"id","",jl()),Hn(yt,"rotation",0,ut()),le.addComponentsGetterSetter(yt,"scale",["x","y"]),Hn(yt,"scaleX",1,ut()),Hn(yt,"scaleY",1,ut()),le.addComponentsGetterSetter(yt,"skew",["x","y"]),Hn(yt,"skewX",0,ut()),Hn(yt,"skewY",0,ut()),le.addComponentsGetterSetter(yt,"offset",["x","y"]),Hn(yt,"offsetX",0,ut()),Hn(yt,"offsetY",0,ut()),Hn(yt,"dragDistance",void 0,ut()),Hn(yt,"width",0,ut()),Hn(yt,"height",0,ut()),Hn(yt,"listening",!0,Ti()),Hn(yt,"preventDefault",!0,Ti()),Hn(yt,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),Hn(yt,"visible",!0,Ti()),Hn(yt,"transformsEnabled","all",jl()),Hn(yt,"size"),Hn(yt,"dragBoundFunc"),Hn(yt,"draggable",!1,Ti()),le.backCompat(yt,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var $o=class extends yt{constructor(){super(...arguments),this.children=[]}getChildren(e){const t=this.children||[];return e?t.filter(e):t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(let n=0;n<e.length;n++)this.add(e[n]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){const t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){const n=[];return this._descendants(r=>{const o=r._isMatch(e);return o&&n.push(r),!!(o&&t)}),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){const e=yt.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(t=>{e.children.push(t.toObject())}),e}isAncestorOf(e){let t=e.getParent();for(;t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){const t=yt.prototype.clone.call(this,e);return this.getChildren().forEach(function(n){t.add(n.clone())}),t}getAllIntersections(e){const t=[];return this.find("Shape").forEach(n=>{n.isVisible()&&n.intersects(e)&&t.push(n)}),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),!this.isCached()&&((t=this.children)===null||t===void 0||t.forEach(function(n){n._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(t,n){t.index=n}),this._requestDraw()}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas(),i=o&&o.getContext(),s=this._getCanvasCache(),a=s&&s.scene,l=o&&o.isCache;if(!this.isVisible()&&!l)return this;if(a){i.save();const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(i),i.restore()}else this._drawChildren("drawScene",o,t,n);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;const n=this.getLayer(),r=e||n&&n.hitCanvas,o=r&&r.getContext(),i=this._getCanvasCache();if(i&&i.hit){o.save();const s=this.getAbsoluteTransform(t).getMatrix();o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n,r){var o;const i=t&&t.getContext(),s=this.clipWidth(),a=this.clipHeight(),l=this.clipFunc(),u=typeof s=="number"&&typeof a=="number"||l,c=n===this;if(u){i.save();const h=this.getAbsoluteTransform(n);let m=h.getMatrix();i.transform(m[0],m[1],m[2],m[3],m[4],m[5]),i.beginPath();let p;if(l)p=l.call(this,i,this);else{const g=this.clipX(),C=this.clipY();i.rect(g||0,C||0,s,a)}i.clip.apply(i,p),m=h.copy().invert().getMatrix(),i.transform(m[0],m[1],m[2],m[3],m[4],m[5])}const d=!c&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";d&&(i.save(),i._applyGlobalCompositeOperation(this)),(o=this.children)===null||o===void 0||o.forEach(function(h){h[e](t,n,r)}),d&&i.restore(),u&&i.restore()}getClientRect(e={}){var t;const n=e.skipTransform,r=e.relativeTo;let o,i,s,a,l={x:1/0,y:1/0,width:0,height:0};const u=this;(t=this.children)===null||t===void 0||t.forEach(function(h){if(!h.visible())return;const m=h.getClientRect({relativeTo:u,skipShadow:e.skipShadow,skipStroke:e.skipStroke});m.width===0&&m.height===0||(o===void 0?(o=m.x,i=m.y,s=m.x+m.width,a=m.y+m.height):(o=Math.min(o,m.x),i=Math.min(i,m.y),s=Math.max(s,m.x+m.width),a=Math.max(a,m.y+m.height)))});const c=this.find("Shape");let d=!1;for(let h=0;h<c.length;h++)if(c[h]._isVisible(this)){d=!0;break}return d&&o!==void 0?l={x:o,y:i,width:s-o,height:a-i}:l={x:0,y:0,width:0,height:0},n?l:this._transformedRect(l,r)}};le.addComponentsGetterSetter($o,"clip",["x","y","width","height"]),le.addGetterSetter($o,"clipX",void 0,ut()),le.addGetterSetter($o,"clipY",void 0,ut()),le.addGetterSetter($o,"clipWidth",void 0,ut()),le.addGetterSetter($o,"clipHeight",void 0,ut()),le.addGetterSetter($o,"clipFunc");var $d=new Map,aS=vt._global.PointerEvent!==void 0;function t0(e){return $d.get(e)}function n0(e){return{evt:e,pointerId:e.pointerId}}function lS(e,t){return $d.get(e)===t}function cS(e,t){ef(e),t.getStage()&&($d.set(e,t),aS&&t._fire("gotpointercapture",n0(new PointerEvent("gotpointercapture"))))}function ef(e,t){const n=$d.get(e);if(!n)return;const r=n.getStage();r&&r.content,$d.delete(e),aS&&n._fire("lostpointercapture",n0(new PointerEvent("lostpointercapture")))}var hF="Stage",pF="string",uS="px",mF="mouseout",dS="mouseleave",fS="mouseover",hS="mouseenter",pS="mousemove",mS="mousedown",gS="mouseup",tf="pointermove",nf="pointerdown",su="pointerup",rf="pointercancel",gF="lostpointercapture",xp="pointerout",of="pointerleave",Tp="pointerover",Rp="pointerenter",r0="contextmenu",vS="touchstart",yS="touchend",bS="touchmove",wS="touchcancel",o0="wheel",vF=5,yF=[[hS,"_pointerenter"],[mS,"_pointerdown"],[pS,"_pointermove"],[gS,"_pointerup"],[dS,"_pointerleave"],[vS,"_pointerdown"],[bS,"_pointermove"],[yS,"_pointerup"],[wS,"_pointercancel"],[fS,"_pointerover"],[o0,"_wheel"],[r0,"_contextmenu"],[nf,"_pointerdown"],[tf,"_pointermove"],[su,"_pointerup"],[rf,"_pointercancel"],[of,"_pointerleave"],[gF,"_lostpointercapture"]],i0={mouse:{[xp]:mF,[of]:dS,[Tp]:fS,[Rp]:hS,[tf]:pS,[nf]:mS,[su]:gS,[rf]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[xp]:"touchout",[of]:"touchleave",[Tp]:"touchover",[Rp]:"touchenter",[tf]:bS,[nf]:vS,[su]:yS,[rf]:wS,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[xp]:xp,[of]:of,[Tp]:Tp,[Rp]:Rp,[tf]:tf,[nf]:nf,[su]:su,[rf]:rf,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},sf=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",au=e=>{const t=sf(e);if(t==="pointer")return vt.pointerEventsEnabled&&i0.pointer;if(t==="touch")return i0.touch;if(t==="mouse")return i0.mouse};function CS(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&Ae.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var bF="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";const af=[];var Mp=class extends $o{constructor(e){super(CS(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),af.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{CS(this.attrs)}),this._checkVisibility()}_validateAdd(e){const t=e.getType()==="Layer",n=e.getType()==="FastLayer";t||n||Ae.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if(typeof e===pF){let t;if(e.charAt(0)==="."){const n=e.slice(1);e=document.getElementsByClassName(n)[0]}else e.charAt(0)!=="#"?t=e:t=e.slice(1),e=document.getElementById(t);if(!e)throw"Can not find container in document with id "+t}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){const e=this.children,t=e.length;for(let n=0;n<t;n++)e[n].clear();return this}clone(e){return e||(e={}),e.container=typeof document<"u"&&document.createElement("div"),$o.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&Ae._isInDocument(e)&&this.container().removeChild(e);const t=af.indexOf(this);return t>-1&&af.splice(t,1),Ae.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(Ae.warn(bF),null)}_getPointerById(e){return this._pointerPositions.find(t=>t.id===e)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){e={...e},e.x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();const t=new ja({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach(function(o){if(!o.isVisible())return;const i=o._toKonvaCanvas(e);n.drawImage(i._canvas,e.x,e.y,i.getWidth()/i.getPixelRatio(),i.getHeight()/i.getPixelRatio())}),t}getIntersection(e){if(!e)return null;const t=this.children,n=t.length-1;for(let r=n;r>=0;r--){const o=t[r].getIntersection(e);if(o)return o}return null}_resizeDOM(){const e=this.width(),t=this.height();this.content&&(this.content.style.width=e+uS,this.content.style.height=t+uS),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach(n=>{n.setSize({width:e,height:t}),n.draw()})}add(e,...t){if(arguments.length>1){for(let r=0;r<arguments.length;r++)this.add(arguments[r]);return this}super.add(e);const n=this.children.length;return n>vF&&Ae.warn("The stage has "+n+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),vt.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return lS(e,this)}setPointerCapture(e){cS(e,this)}releaseCapture(e){ef(e,this)}getLayers(){return this.children}_bindContentEvents(){vt.isBrowser&&yF.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=au(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=au(e.type);t&&this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=au(e.type),n=sf(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(vt.isDragging()||vt.isTransforming())||vt.hitOnDragEnabled;r&&o?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):o&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}_pointerdown(e){const t=au(e.type),n=sf(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if(Cn.justDragged=!1,vt["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}vt.capturePointerEventsEnabled&&i.setPointerCapture(o.id),this[n+"ClickStartShape"]=i,i._fireAndBubble(t.pointerdown,{evt:e,pointerId:o.id}),r=!0;const s=e.type.indexOf("touch")>=0;i.preventDefault()&&e.cancelable&&s&&e.preventDefault()}),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}_pointermove(e){const t=au(e.type),n=sf(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(vt.isDragging()&&Cn.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(vt.isDragging()||vt.isTransforming())||vt.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=t0(a.id)||this.getIntersection(a),u=a.id,c={evt:e,pointerId:u},d=s!==l;if(d&&s&&(s._fireAndBubble(t.pointerout,{...c},l),s._fireAndBubble(t.pointerleave,{...c},l)),l){if(o[l._id])return;o[l._id]=!0}l&&l.isListening()?(i=!0,d&&(l._fireAndBubble(t.pointerover,{...c},s),l._fireAndBubble(t.pointerenter,{...c},s),this[n+"targetShape"]=l),l._fireAndBubble(t.pointermove,{...c})):s&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:u}),this[n+"targetShape"]=null)}),i||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=au(e.type),n=sf(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],o=this[n+"ClickEndShape"],i={};let s=!1;this._changedPointerPositions.forEach(a=>{const l=t0(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),i[l._id])return;i[l._id]=!0}const u=a.id,c={evt:e,pointerId:u};let d=!1;vt["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):Cn.justDragged||(vt["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){vt["_"+n+"InDblClickWindow"]=!1},vt.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...c}),vt["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...c}),d&&o&&o===l&&l._fireAndBubble(t.pointerdblclick,{...c}))):(this[n+"ClickEndShape"]=null,s||(this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),s=!0),vt["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:u}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:u}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),vt["_"+n+"ListenClick"]=!1,e.cancelable&&n!=="touch"&&n!=="pointer"&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(r0,{evt:e}):this._fire(r0,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(o0,{evt:e}):this._fire(o0,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=t0(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(su,n0(e)),ef(e.pointerId)}_lostpointercapture(e){ef(e.pointerId)}setPointersPositions(e){const t=this._getContentPosition();let n=null,r=null;e=e||window.event,e.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,o=>{this._pointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})}),Array.prototype.forEach.call(e.changedTouches||e.touches,o=>{this._changedPointerPositions.push({id:o.identifier,x:(o.clientX-t.left)/t.scaleX,y:(o.clientY-t.top)/t.scaleY})})):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:Ae._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:Ae._getFirstPointerId(e)}])}_setPointerPosition(e){Ae.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};const e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new ja({width:this.width(),height:this.height()}),this.bufferHitCanvas=new Zy({pixelRatio:1,width:this.width(),height:this.height()}),!vt.isBrowser)return;const e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}cache(){return Ae.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(e){e.batchDraw()}),this}};Mp.prototype.nodeType=hF,cr(Mp),le.addGetterSetter(Mp,"container"),vt.isBrowser&&document.addEventListener("visibilitychange",()=>{af.forEach(e=>{e.batchDraw()})});var _S="hasShadow",SS="shadowRGBA",kS="patternImage",AS="linearGradient",IS="radialGradient",Lp;function s0(){return Lp||(Lp=Ae.createCanvasElement().getContext("2d"),Lp)}const lf={};function wF(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function CF(e){e.stroke()}function _F(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function SF(e){e.stroke()}function kF(){this._clearCache(_S)}function AF(){this._clearCache(SS)}function IF(){this._clearCache(kS)}function EF(){this._clearCache(AS)}function xF(){this._clearCache(IS)}var lt=class extends yt{constructor(e){super(e);let t,n=0;for(;t=Ae.getHitColor(),!(t&&!(t in lf));)if(n++,n>=1e4){Ae.warn("Failed to find a unique color key for a shape. Konva may work incorrectly. Most likely your browser is using canvas farbling. Consider disabling it."),t=Ae.getRandomColor();break}this.colorKey=t,lf[t]=this}getContext(){return Ae.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return Ae.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(_S,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(kS,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=s0().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new xi;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(vt.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r=typeof DOMMatrix>"u"?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(AS,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=s0(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),o=t.createLinearGradient(n.x,n.y,r.x,r.y);for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}_getRadialGradient(){return this._getCache(IS,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=s0(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),o=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius());for(let i=0;i<e.length;i+=2)o.addColorStop(e[i],e[i+1]);return o}}getShadowRGBA(){return this._getCache(SS,this._getShadowRGBA)}_getShadowRGBA(){if(!this.hasShadow())return;const e=Ae.colorToRGBA(this.shadowColor());if(e)return"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")"}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const e=this.hitStrokeWidth();return e==="auto"?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){const t=this.getStage();if(!t)return!1;const n=t.bufferHitCanvas;return n.getContext().clear(),this.drawHit(n,void 0,!0),n.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return yt.prototype.destroy.call(this),delete lf[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!(!((t=this.attrs.perfectDrawEnabled)!==null&&t!==void 0)||t))return!1;const n=e||this.hasFill(),r=this.hasStroke(),o=this.getAbsoluteOpacity()!==1;if(n&&r&&o)return!0;const i=this.hasShadow(),s=this.shadowForStrokeEnabled();return!!(n&&r&&i&&s)}setStrokeHitEnabled(e){Ae.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){const e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){let t=!1,n=this.getParent();for(;n;){if(n.isCached()){t=!0;break}n=n.getParent()}const r=e.skipTransform,o=e.relativeTo||t&&this.getStage()||void 0,i=this.getSelfRect(),s=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,a=i.width+s,l=i.height+s,u=!e.skipShadow&&this.hasShadow(),c=u?this.shadowOffsetX():0,d=u?this.shadowOffsetY():0,h=a+Math.abs(c),m=l+Math.abs(d),p=u&&this.shadowBlur()||0,g={width:h+p*2,height:m+p*2,x:-(s/2+p)+Math.min(c,0)+i.x,y:-(s/2+p)+Math.min(d,0)+i.y};return r?g:this._transformedRect(g,o)}drawScene(e,t,n){const r=this.getLayer(),o=(e||r.getCanvas()).getContext(),i=this._getCanvasCache(),s=this.getSceneFunc(),a=this.hasShadow();let l;const u=t===this;if(!this.isVisible()&&!u)return this;if(i){o.save();const c=this.getAbsoluteTransform(t).getMatrix();return o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(o),o.restore(),this}if(!s)return this;if(o.save(),this._useBufferCanvas()){l=this.getStage();const c=n||l.bufferCanvas,d=c.getContext();n?(d.save(),d.setTransform(1,0,0,1,0,0),d.clearRect(0,0,c.width,c.height),d.restore()):d.clear(),d.save(),d._applyLineJoin(this),d._applyMiterLimit(this);const h=this.getAbsoluteTransform(t).getMatrix();d.transform(h[0],h[1],h[2],h[3],h[4],h[5]),s.call(this,d,this),d.restore();const m=c.pixelRatio;a&&o._applyShadow(this),u||(o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),o.drawImage(c._canvas,c.x||0,c.y||0,c.width/m,c.height/m)}else{if(o._applyLineJoin(this),o._applyMiterLimit(this),!u){const c=this.getAbsoluteTransform(t).getMatrix();o.transform(c[0],c[1],c[2],c[3],c[4],c[5]),o._applyOpacity(this),o._applyGlobalCompositeOperation(this)}a&&o._applyShadow(this),s.call(this,o,this)}return o.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;const r=this.getLayer(),o=e||r.hitCanvas,i=o&&o.getContext(),s=this.hitFunc()||this.sceneFunc(),a=this._getCanvasCache(),l=a&&a.hit;if(this.colorKey||Ae.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){i.save();const u=this.getAbsoluteTransform(t).getMatrix();return i.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){const u=this.getAbsoluteTransform(t).getMatrix();i.transform(u[0],u[1],u[2],u[3],u[4],u[5])}return s.call(this,i,this),i.restore(),this}drawHitFromCache(e=0){const t=this._getCanvasCache(),n=this._getCachedSceneCanvas(),r=t.hit,o=r.getContext(),i=r.getWidth(),s=r.getHeight();o.clear(),o.drawImage(n._canvas,0,0,i,s);try{const a=o.getImageData(0,0,i,s),l=a.data,u=l.length,c=Ae._hexToRgb(this.colorKey);for(let d=0;d<u;d+=4)l[d+3]>e?(l[d]=c.r,l[d+1]=c.g,l[d+2]=c.b,l[d+3]=255):l[d+3]=0;o.putImageData(a,0,0)}catch(a){Ae.error("Unable to draw hit graph from cached scene canvas. "+a.message)}return this}hasPointerCapture(e){return lS(e,this)}setPointerCapture(e){cS(e,this)}releaseCapture(e){ef(e,this)}};lt.prototype._fillFunc=wF,lt.prototype._strokeFunc=CF,lt.prototype._fillFuncHit=_F,lt.prototype._strokeFuncHit=SF,lt.prototype._centroid=!1,lt.prototype.nodeType="Shape",cr(lt),lt.prototype.eventListeners={},lt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",kF),lt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",AF),lt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",IF),lt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",EF),lt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",xF),le.addGetterSetter(lt,"stroke",void 0,tS()),le.addGetterSetter(lt,"strokeWidth",2,ut()),le.addGetterSetter(lt,"fillAfterStrokeEnabled",!1),le.addGetterSetter(lt,"hitStrokeWidth","auto",Jy()),le.addGetterSetter(lt,"strokeHitEnabled",!0,Ti()),le.addGetterSetter(lt,"perfectDrawEnabled",!0,Ti()),le.addGetterSetter(lt,"shadowForStrokeEnabled",!0,Ti()),le.addGetterSetter(lt,"lineJoin"),le.addGetterSetter(lt,"lineCap"),le.addGetterSetter(lt,"miterLimit"),le.addGetterSetter(lt,"sceneFunc"),le.addGetterSetter(lt,"hitFunc"),le.addGetterSetter(lt,"dash"),le.addGetterSetter(lt,"dashOffset",0,ut()),le.addGetterSetter(lt,"shadowColor",void 0,jl()),le.addGetterSetter(lt,"shadowBlur",0,ut()),le.addGetterSetter(lt,"shadowOpacity",1,ut()),le.addComponentsGetterSetter(lt,"shadowOffset",["x","y"]),le.addGetterSetter(lt,"shadowOffsetX",0,ut()),le.addGetterSetter(lt,"shadowOffsetY",0,ut()),le.addGetterSetter(lt,"fillPatternImage"),le.addGetterSetter(lt,"fill",void 0,tS()),le.addGetterSetter(lt,"fillPatternX",0,ut()),le.addGetterSetter(lt,"fillPatternY",0,ut()),le.addGetterSetter(lt,"fillLinearGradientColorStops"),le.addGetterSetter(lt,"strokeLinearGradientColorStops"),le.addGetterSetter(lt,"fillRadialGradientStartRadius",0),le.addGetterSetter(lt,"fillRadialGradientEndRadius",0),le.addGetterSetter(lt,"fillRadialGradientColorStops"),le.addGetterSetter(lt,"fillPatternRepeat","repeat"),le.addGetterSetter(lt,"fillEnabled",!0),le.addGetterSetter(lt,"strokeEnabled",!0),le.addGetterSetter(lt,"shadowEnabled",!0),le.addGetterSetter(lt,"dashEnabled",!0),le.addGetterSetter(lt,"strokeScaleEnabled",!0),le.addGetterSetter(lt,"fillPriority","color"),le.addComponentsGetterSetter(lt,"fillPatternOffset",["x","y"]),le.addGetterSetter(lt,"fillPatternOffsetX",0,ut()),le.addGetterSetter(lt,"fillPatternOffsetY",0,ut()),le.addComponentsGetterSetter(lt,"fillPatternScale",["x","y"]),le.addGetterSetter(lt,"fillPatternScaleX",1,ut()),le.addGetterSetter(lt,"fillPatternScaleY",1,ut()),le.addComponentsGetterSetter(lt,"fillLinearGradientStartPoint",["x","y"]),le.addComponentsGetterSetter(lt,"strokeLinearGradientStartPoint",["x","y"]),le.addGetterSetter(lt,"fillLinearGradientStartPointX",0),le.addGetterSetter(lt,"strokeLinearGradientStartPointX",0),le.addGetterSetter(lt,"fillLinearGradientStartPointY",0),le.addGetterSetter(lt,"strokeLinearGradientStartPointY",0),le.addComponentsGetterSetter(lt,"fillLinearGradientEndPoint",["x","y"]),le.addComponentsGetterSetter(lt,"strokeLinearGradientEndPoint",["x","y"]),le.addGetterSetter(lt,"fillLinearGradientEndPointX",0),le.addGetterSetter(lt,"strokeLinearGradientEndPointX",0),le.addGetterSetter(lt,"fillLinearGradientEndPointY",0),le.addGetterSetter(lt,"strokeLinearGradientEndPointY",0),le.addComponentsGetterSetter(lt,"fillRadialGradientStartPoint",["x","y"]),le.addGetterSetter(lt,"fillRadialGradientStartPointX",0),le.addGetterSetter(lt,"fillRadialGradientStartPointY",0),le.addComponentsGetterSetter(lt,"fillRadialGradientEndPoint",["x","y"]),le.addGetterSetter(lt,"fillRadialGradientEndPointX",0),le.addGetterSetter(lt,"fillRadialGradientEndPointY",0),le.addGetterSetter(lt,"fillPatternRotation",0),le.addGetterSetter(lt,"fillRule",void 0,jl()),le.backCompat(lt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var TF="beforeDraw",RF="draw",ES=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],MF=ES.length,Wl=class extends $o{constructor(e){super(e),this.canvas=new ja,this.hitCanvas=new Zy({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);const t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){yt.prototype.moveToTop.call(this);const e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!yt.prototype.moveUp.call(this))return!1;const e=this.getStage();return!e||!e.content?!1:(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(yt.prototype.moveDown.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(yt.prototype.moveToBottom.call(this)){const e=this.getStage();if(e){const t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){const e=this.getNativeCanvasElement();return yt.prototype.remove.call(this),e&&e.parentNode&&Ae._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Ae.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e={...e},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),yt.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Ae.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Ae.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Ae.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;let t=1,n=!1;for(;;){for(let r=0;r<MF;r++){const o=ES[r],i=this._getIntersection({x:e.x+o.x*t,y:e.y+o.y*t}),s=i.shape;if(s)return s;if(n=!!i.antialiased,!i.antialiased)break}if(n)t+=1;else return null}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(r===255){const o=lf[Ae.getHitColorKey(n[0],n[1],n[2])];return o?{shape:o}:{antialiased:!0}}else if(r>0)return{antialiased:!0};return{}}drawScene(e,t,n){const r=this.getLayer(),o=e||r&&r.getCanvas();return this._fire(TF,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),$o.prototype.drawScene.call(this,o,t,n),this._fire(RF,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),$o.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Ae.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Ae.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!this.parent||!this.parent.content)return;const e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}destroy(){return Ae.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Wl.prototype.nodeType="Layer",cr(Wl),le.addGetterSetter(Wl,"imageSmoothingEnabled",!0),le.addGetterSetter(Wl,"clearBeforeDraw",!0),le.addGetterSetter(Wl,"hitGraphEnabled",!0,Ti());var a0=class extends Wl{constructor(e){super(e),this.listening(!1),Ae.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};a0.prototype.nodeType="FastLayer",cr(a0);var lu=class extends $o{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Ae.throw("You may only add groups and shapes to groups.")}};lu.prototype.nodeType="Group",cr(lu);var l0=(function(){return Vl.performance&&Vl.performance.now?function(){return Vl.performance.now()}:function(){return new Date().getTime()}})(),cu=class Mu{constructor(t,n){this.id=Mu.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:l0(),frameRate:0},this.func=t,this.setLayers(n)}setLayers(t){let n=[];return t&&(n=Array.isArray(t)?t:[t]),this.layers=n,this}getLayers(){return this.layers}addLayer(t){const n=this.layers,r=n.length;for(let o=0;o<r;o++)if(n[o]._id===t._id)return!1;return this.layers.push(t),!0}isRunning(){const t=Mu.animations,n=t.length;for(let r=0;r<n;r++)if(t[r].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=l0(),Mu._addAnimation(this),this}stop(){return Mu._removeAnimation(this),this}_updateFrameObject(t){this.frame.timeDiff=t-this.frame.lastTime,this.frame.lastTime=t,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(t){this.animations.push(t),this._handleAnimation()}static _removeAnimation(t){const n=t.id,r=this.animations,o=r.length;for(let i=0;i<o;i++)if(r[i].id===n){this.animations.splice(i,1);break}}static _runFrames(){const t={},n=this.animations;for(let r=0;r<n.length;r++){const o=n[r],i=o.layers,s=o.func;o._updateFrameObject(l0());const a=i.length;let l;if(s?l=s.call(o,o.frame)!==!1:l=!0,!!l)for(let u=0;u<a;u++){const c=i[u];c._id!==void 0&&(t[c._id]=c)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=Mu;t.animations.length?(t._runFrames(),Ae.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ae.requestAnimFrame(this._animationLoop))}};cu.animations=[],cu.animIdCounter=0,cu.animRunning=!1;var LF={node:1,duration:1,easing:1,onFinish:1,yoyo:1},DF=1,xS=2,TS=3,RS=["fill","stroke","shadowColor"],PF=0,FF=class{constructor(e,t,n,r,o,i,s){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=i,this._change=0,this.prevPos=0,this.yoyo=s,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=o-this.begin,this.pause()}fire(e){const t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return e===void 0&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=xS,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=TS,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){const e=this.getTimer()-this._startTime;this.state===xS?this.setTime(e):this.state===TS&&this.setTime(this.duration-e)}pause(){this.state=DF,this.fire("onPause")}getTimer(){return new Date().getTime()}},Dp=class vr{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||cf.Linear,s=!!t.yoyo;let a,l;typeof t.duration>"u"?a=.3:t.duration===0?a=.001:a=t.duration,this.node=r,this._id=PF++;const u=r.getLayer()||(r instanceof vt.Stage?r.getLayers():null);u||Ae.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new cu(function(){n.tween.onEnterFrame()},u),this.tween=new FF(l,function(c){n._tweenFunc(c)},i,0,1,a*1e3,s),this._addListeners(),vr.attrs[o]||(vr.attrs[o]={}),vr.attrs[o][this._id]||(vr.attrs[o][this._id]={}),vr.tweens[o]||(vr.tweens[o]={});for(l in t)LF[l]===void 0&&this._addAttr(l,t[l]);this.reset(),this.onFinish=t.onFinish,this.onReset=t.onReset,this.onUpdate=t.onUpdate}_addAttr(t,n){const r=this.node,o=r._id;let i,s,a,l,u;const c=vr.tweens[o][t];c&&delete vr.attrs[o][c][t];let d=r.getAttr(t);if(Ae._isArray(n))if(i=[],s=Math.max(n.length,d.length),t==="points"&&n.length!==d.length&&(n.length>d.length?(l=d,d=Ae._prepareArrayForTween(d,n,r.closed())):(a=n,n=Ae._prepareArrayForTween(n,d,r.closed()))),t.indexOf("fill")===0)for(let h=0;h<s;h++)if(h%2===0)i.push(n[h]-d[h]);else{const m=Ae.colorToRGBA(d[h]);u=Ae.colorToRGBA(n[h]),d[h]=m,i.push({r:u.r-m.r,g:u.g-m.g,b:u.b-m.b,a:u.a-m.a})}else for(let h=0;h<s;h++)i.push(n[h]-d[h]);else RS.indexOf(t)!==-1?(d=Ae.colorToRGBA(d),u=Ae.colorToRGBA(n),i={r:u.r-d.r,g:u.g-d.g,b:u.b-d.b,a:u.a-d.a}):i=n-d;vr.attrs[o][this._id][t]={start:d,diff:i,end:n,trueEnd:a,trueStart:l},vr.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=vr.attrs[n._id][this._id];let o,i,s,a,l,u,c,d;for(o in r){if(i=r[o],s=i.start,a=i.diff,d=i.end,Ae._isArray(s))if(l=[],c=Math.max(s.length,d.length),o.indexOf("fill")===0)for(u=0;u<c;u++)u%2===0?l.push((s[u]||0)+a[u]*t):l.push("rgba("+Math.round(s[u].r+a[u].r*t)+","+Math.round(s[u].g+a[u].g*t)+","+Math.round(s[u].b+a[u].b*t)+","+(s[u].a+a[u].a*t)+")");else for(u=0;u<c;u++)l.push((s[u]||0)+a[u]*t);else RS.indexOf(o)!==-1?l="rgba("+Math.round(s.r+a.r*t)+","+Math.round(s.g+a.g*t)+","+Math.round(s.b+a.b*t)+","+(s.a+a.a*t)+")":l=s+a*t;n.setAttr(o,l)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{const t=this.node,n=vr.attrs[t._id][this._id];n.points&&n.points.trueEnd&&t.setAttr("points",n.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{const t=this.node,n=vr.attrs[t._id][this._id];n.points&&n.points.trueStart&&t.points(n.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(t){return this.tween.seek(t*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){const t=this.node._id,n=this._id,r=vr.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete vr.tweens[t][o];delete vr.attrs[t][n],vr.tweens[t]&&(Object.keys(vr.tweens[t]).length===0&&delete vr.tweens[t],Object.keys(vr.attrs[t]).length===0&&delete vr.attrs[t])}};Dp.attrs={},Dp.tweens={},yt.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new Dp(e).play()};const cf={BackEaseIn(e,t,n,r){return n*(e/=r)*e*((1.70158+1)*e-1.70158)+t},BackEaseOut(e,t,n,r){return n*((e=e/r-1)*e*((1.70158+1)*e+1.70158)+1)+t},BackEaseInOut(e,t,n,r){let o=1.70158;return(e/=r/2)<1?n/2*(e*e*(((o*=1.525)+1)*e-o))+t:n/2*((e-=2)*e*(((o*=1.525)+1)*e+o)+2)+t},ElasticEaseIn(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),-(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t)},ElasticEaseOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r)===1?t+n:(i||(i=r*.3),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),o*Math.pow(2,-10*e)*Math.sin((e*r-s)*(2*Math.PI)/i)+n+t)},ElasticEaseInOut(e,t,n,r,o,i){let s=0;return e===0?t:(e/=r/2)===2?t+n:(i||(i=r*(.3*1.5)),!o||o<Math.abs(n)?(o=n,s=i/4):s=i/(2*Math.PI)*Math.asin(n/o),e<1?-.5*(o*Math.pow(2,10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i))+t:o*Math.pow(2,-10*(e-=1))*Math.sin((e*r-s)*(2*Math.PI)/i)*.5+n+t)},BounceEaseOut(e,t,n,r){return(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t},BounceEaseIn(e,t,n,r){return n-cf.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?cf.BounceEaseIn(e*2,0,n,r)*.5+t:cf.BounceEaseOut(e*2-r,0,n,r)*.5+n*.5+t},EaseIn(e,t,n,r){return n*(e/=r)*e+t},EaseOut(e,t,n,r){return-n*(e/=r)*(e-2)+t},EaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t},StrongEaseIn(e,t,n,r){return n*(e/=r)*e*e*e*e+t},StrongEaseOut(e,t,n,r){return n*((e=e/r-1)*e*e*e*e+1)+t},StrongEaseInOut(e,t,n,r){return(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t},Linear(e,t,n,r){return n*e/r+t}},MS=Ae._assign(vt,{Util:Ae,Transform:xi,Node:yt,Container:$o,Stage:Mp,stages:af,Layer:Wl,FastLayer:a0,Group:lu,DD:Cn,Shape:lt,shapes:lf,Animation:cu,Tween:Dp,Easings:cf,Context:Sp,Canvas:Qy});var $s=class extends lt{_sceneFunc(e){const t=vt.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=vt.getAngle(n?360-this.angle():this.angle()),o=Math.cos(Math.min(r,Math.PI)),i=1,s=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),a=Math.sin(Math.min(r,Math.PI/2)),l=o*(o>0?e:t),u=i*(i>0?t:e),c=s*(s>0?e:t),d=a*(a>0?t:e);return{x:l,y:n?-1*d:c,width:u-l,height:d-c}}};$s.prototype._centroid=!0,$s.prototype.className="Arc",$s.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],cr($s),le.addGetterSetter($s,"innerRadius",0,ut()),le.addGetterSetter($s,"outerRadius",0,ut()),le.addGetterSetter($s,"angle",0,ut()),le.addGetterSetter($s,"clockwise",!1,Ti());function c0(e,t,n,r,o,i,s){const a=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(o-n,2)+Math.pow(i-r,2)),u=s*a/(a+l),c=s*l/(a+l);return[n-u*(o-e),r-u*(i-t),n+c*(o-e),r+c*(i-t)]}function LS(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=c0(e[o-2],e[o-1],e[o],e[o+1],e[o+2],e[o+3],t);isNaN(i[0])||(r.push(i[0]),r.push(i[1]),r.push(e[o]),r.push(e[o+1]),r.push(i[2]),r.push(i[3]))}return r}function OF(e){const t=[[e[0],e[2],e[4],e[6]],[e[1],e[3],e[5],e[7]]],n=[];for(const r of t){const o=-3*r[0]+9*r[1]-9*r[2]+3*r[3];if(o!==0){const i=6*r[0]-12*r[1]+6*r[2],s=-3*r[0]+3*r[1],a=i*i-4*o*s;if(a>=0){const l=Math.sqrt(a);n.push((-i+l)/(2*o)),n.push((-i-l)/(2*o))}}}return n.filter(r=>r>0&&r<1).flatMap(r=>t.map(o=>{const i=1-r;return i*i*i*o[0]+3*i*i*r*o[1]+3*i*r*r*o[2]+r*r*r*o[3]}))}var ea=class extends lt{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){const t=this.points(),n=t.length,r=this.tension(),o=this.closed(),i=this.bezier();if(!n)return;let s=0;if(e.beginPath(),e.moveTo(t[0],t[1]),r!==0&&n>4){const a=this.getTensionPoints(),l=a.length;for(s=o?0:4,o||e.quadraticCurveTo(a[0],a[1],a[2],a[3]);s<l-2;)e.bezierCurveTo(a[s++],a[s++],a[s++],a[s++],a[s++],a[s++]);o||e.quadraticCurveTo(a[l-2],a[l-1],t[n-2],t[n-1])}else if(i)for(s=2;s<n;)e.bezierCurveTo(t[s++],t[s++],t[s++],t[s++],t[s++],t[s++]);else for(s=2;s<n;s+=2)e.lineTo(t[s],t[s+1]);o?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():LS(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=c0(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=c0(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=LS(e,n);return[r[2],r[3]].concat(i).concat([o[0],o[1],e[t-2],e[t-1],o[2],o[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){let e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.bezier()?e=[e[0],e[1],...OF(this.points()),e[e.length-2],e[e.length-1]]:e=this.points();let t=e[0],n=e[0],r=e[1],o=e[1],i,s;for(let a=0;a<e.length/2;a++)i=e[a*2],s=e[a*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);return{x:t,y:r,width:n-t,height:o-r}}};ea.prototype.className="Line",ea.prototype._attrsAffectingSize=["points","bezier","tension"],cr(ea),le.addGetterSetter(ea,"closed",!1),le.addGetterSetter(ea,"bezier",!1),le.addGetterSetter(ea,"tension",0,ut()),le.addGetterSetter(ea,"points",[],JP());const BF=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],NF=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],zF=[[1],[1,1],[1,2,1],[1,3,3,1]],DS=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*BF[20][a]+s,r+=NF[20][a]*HF(e,t,o);return s*r},PS=(e,t,n)=>{n===void 0&&(n=1);const r=e[0]-2*e[1]+e[2],o=t[0]-2*t[1]+t[2],i=2*e[1]-2*e[0],s=2*t[1]-2*t[0],a=4*(r*r+o*o),l=4*(r*i+o*s),u=i*i+s*s;if(a===0)return n*Math.sqrt(Math.pow(e[2]-e[0],2)+Math.pow(t[2]-t[0],2));const c=l/(2*a),d=u/a,h=n+c,m=d-c*c,p=h*h+m>0?Math.sqrt(h*h+m):0,g=c*c+m>0?Math.sqrt(c*c+m):0,C=c+Math.sqrt(c*c+m)!==0?m*Math.log(Math.abs((h+p)/(c+g))):0;return Math.sqrt(a)/2*(h*p-c*g+C)};function HF(e,t,n){const r=u0(1,n,e),o=u0(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var u0=(e,t,n)=>{const r=n.length-1;let o,i;if(r===0)return 0;if(e===0){i=0;for(let s=0;s<=r;s++)i+=zF[r][s]*Math.pow(1-t,r-s)*Math.pow(t,s)*n[s];return i}else{o=new Array(r);for(let s=0;s<r;s++)o[s]=r*(n[s+1]-n[s]);return u0(e-1,t,o)}};const FS=(e,t,n)=>{let r=1,o=e/t,i=(e-n(o))/t,s=0;for(;r>.001;){const a=n(o+i),l=Math.abs(e-a)/t;if(l<r)r=l,o+=i;else{const u=n(o-i),c=Math.abs(e-u)/t;c<r?(r=c,o-=i):i/=2}if(s++,s>500)break}return o};var di=class Ko extends lt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Ko.parsePathData(this.data()),this.pathLength=Ko.getPathLength(this.dataArray)}_sceneFunc(t){const n=this.dataArray;t.beginPath();let r=!1;for(let o=0;o<n.length;o++){const i=n[o].command,s=n[o].points;switch(i){case"L":t.lineTo(s[0],s[1]);break;case"M":t.moveTo(s[0],s[1]);break;case"C":t.bezierCurveTo(s[0],s[1],s[2],s[3],s[4],s[5]);break;case"Q":t.quadraticCurveTo(s[0],s[1],s[2],s[3]);break;case"A":const a=s[0],l=s[1],u=s[2],c=s[3],d=s[4],h=s[5],m=s[6],p=s[7],g=u>c?u:c,C=u>c?1:u/c,_=u>c?c/u:1;t.translate(a,l),t.rotate(m),t.scale(C,_),t.arc(0,0,g,d,d+h,1-p),t.scale(1/C,1/_),t.rotate(-m),t.translate(-a,-l);break;case"z":r=!0,t.closePath();break}}!r&&!this.hasFill()?t.strokeShape(this):t.fillStrokeShape(this)}getSelfRect(){let t=[];this.dataArray.forEach(function(l){if(l.command==="A"){const u=l.points[4],c=l.points[5],d=l.points[4]+c;let h=Math.PI/180;if(Math.abs(u-d)<h&&(h=Math.abs(u-d)),c<0)for(let m=u-h;m>d;m-=h){const p=Ko.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],m,0);t.push(p.x,p.y)}else for(let m=u+h;m<d;m+=h){const p=Ko.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],m,0);t.push(p.x,p.y)}}else if(l.command==="C")for(let u=0;u<=1;u+=.01){const c=Ko.getPointOnCubicBezier(u,l.start.x,l.start.y,l.points[0],l.points[1],l.points[2],l.points[3],l.points[4],l.points[5]);t.push(c.x,c.y)}else t=t.concat(l.points)});let n=t[0],r=t[0],o=t[1],i=t[1],s,a;for(let l=0;l<t.length/2;l++)s=t[l*2],a=t[l*2+1],isNaN(s)||(n=Math.min(n,s),r=Math.max(r,s)),isNaN(a)||(o=Math.min(o,a),i=Math.max(i,a));return{x:n,y:o,width:r-n,height:i-o}}getLength(){return this.pathLength}getPointAtLength(t){return Ko.getPointAtLengthOfDataArray(t,this.dataArray)}static getLineLength(t,n,r,o){return Math.sqrt((r-t)*(r-t)+(o-n)*(o-n))}static getPathLength(t){let n=0;for(let r=0;r<t.length;++r)n+=t[r].pathLength;return n}static getPointAtLengthOfDataArray(t,n){let r,o=0,i=n.length;if(!i)return null;for(;o<i&&t>n[o].pathLength;)t-=n[o].pathLength,++o;if(o===i)return r=n[o-1].points.slice(-2),{x:r[0],y:r[1]};if(t<.01)return n[o].command==="M"?(r=n[o].points.slice(0,2),{x:r[0],y:r[1]}):{x:n[o].start.x,y:n[o].start.y};const s=n[o],a=s.points;switch(s.command){case"L":return Ko.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return Ko.getPointOnCubicBezier(FS(t,Ko.getPathLength(n),g=>DS([s.start.x,a[0],a[2],a[4]],[s.start.y,a[1],a[3],a[5]],g)),s.start.x,s.start.y,a[0],a[1],a[2],a[3],a[4],a[5]);case"Q":return Ko.getPointOnQuadraticBezier(FS(t,Ko.getPathLength(n),g=>PS([s.start.x,a[0],a[2]],[s.start.y,a[1],a[3]],g)),s.start.x,s.start.y,a[0],a[1],a[2],a[3]);case"A":const l=a[0],u=a[1],c=a[2],d=a[3],h=a[5],m=a[6];let p=a[4];return p+=h*t/s.pathLength,Ko.getPointOnEllipticalArc(l,u,c,d,p,m)}return null}static getPointOnLine(t,n,r,o,i,s,a){s=s??n,a=a??r;const l=this.getLineLength(n,r,o,i);if(l<1e-10)return{x:n,y:r};if(o===n)return{x:s,y:a+(i>r?t:-t)};const u=(i-r)/(o-n),c=Math.sqrt(t*t/(1+u*u))*(o<n?-1:1),d=u*c;if(Math.abs(a-r-u*(s-n))<1e-10)return{x:s+c,y:a+d};const h=((s-n)*(o-n)+(a-r)*(i-r))/(l*l),m=n+h*(o-n),p=r+h*(i-r),g=this.getLineLength(s,a,m,p),C=Math.sqrt(t*t-g*g),_=Math.sqrt(C*C/(1+u*u))*(o<n?-1:1),k=u*_;return{x:m+_,y:p+k}}static getPointOnCubicBezier(t,n,r,o,i,s,a,l,u){function c(p){return p*p*p}function d(p){return 3*p*p*(1-p)}function h(p){return 3*p*(1-p)*(1-p)}function m(p){return(1-p)*(1-p)*(1-p)}return{x:l*c(t)+s*d(t)+o*h(t)+n*m(t),y:u*c(t)+a*d(t)+i*h(t)+r*m(t)}}static getPointOnQuadraticBezier(t,n,r,o,i,s,a){function l(d){return d*d}function u(d){return 2*d*(1-d)}function c(d){return(1-d)*(1-d)}return{x:s*l(t)+o*u(t)+n*c(t),y:a*l(t)+i*u(t)+r*c(t)}}static getPointOnEllipticalArc(t,n,r,o,i,s){const a=Math.cos(s),l=Math.sin(s),u={x:r*Math.cos(i),y:o*Math.sin(i)};return{x:t+(u.x*a-u.y*l),y:n+(u.x*l+u.y*a)}}static parsePathData(t){if(!t)return[];let n=t;const r=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(let d=0;d<r.length;d++)n=n.replace(new RegExp(r[d],"g"),"|"+r[d]);const o=n.split("|"),i=[],s=[];let a=0,l=0;const u=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(let d=1;d<o.length;d++){let h=o[d],m=h.charAt(0);for(h=h.slice(1),s.length=0;c=u.exec(h);)s.push(c[0]);let p=[],g=m==="A"||m==="a"?0:-1;for(let C=0,_=s.length;C<_;C++){const k=s[C];if(k==="00"){p.push(0,0),g>=0&&(g+=2,g>=7&&(g-=7));continue}if(g>=0){if(g===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(k)){p.push(parseInt(k[0],10)),p.push(parseInt(k[1],10)),p.push(parseFloat(k.slice(2))),g+=3,g>=7&&(g-=7);continue}if(k==="11"||k==="10"||k==="01"){p.push(parseInt(k[0],10)),p.push(parseInt(k[1],10)),g+=2,g>=7&&(g-=7);continue}if(k==="0"||k==="1"){p.push(parseInt(k,10)),g+=1,g>=7&&(g-=7);continue}}else if(g===4){if(/^[01]\d+(?:\.\d+)?$/.test(k)){p.push(parseInt(k[0],10)),p.push(parseFloat(k.slice(1))),g+=2,g>=7&&(g-=7);continue}if(k==="0"||k==="1"){p.push(parseInt(k,10)),g+=1,g>=7&&(g-=7);continue}}const y=parseFloat(k);isNaN(y)?p.push(0):p.push(y),g+=1,g>=7&&(g-=7)}else{const y=parseFloat(k);isNaN(y)?p.push(0):p.push(y)}}for(;p.length>0&&!isNaN(p[0]);){let C="",_=[];const k=a,y=l;let b,x,R,D,H,B,z,Y,O,M;switch(m){case"l":a+=p.shift(),l+=p.shift(),C="L",_.push(a,l);break;case"L":a=p.shift(),l=p.shift(),_.push(a,l);break;case"m":const A=p.shift(),N=p.shift();if(a+=A,l+=N,C="M",i.length>2&&i[i.length-1].command==="z"){for(let X=i.length-2;X>=0;X--)if(i[X].command==="M"){a=i[X].points[0]+A,l=i[X].points[1]+N;break}}_.push(a,l),m="l";break;case"M":a=p.shift(),l=p.shift(),C="M",_.push(a,l),m="L";break;case"h":a+=p.shift(),C="L",_.push(a,l);break;case"H":a=p.shift(),C="L",_.push(a,l);break;case"v":l+=p.shift(),C="L",_.push(a,l);break;case"V":l=p.shift(),C="L",_.push(a,l);break;case"C":_.push(p.shift(),p.shift(),p.shift(),p.shift()),a=p.shift(),l=p.shift(),_.push(a,l);break;case"c":_.push(a+p.shift(),l+p.shift(),a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),C="C",_.push(a,l);break;case"S":x=a,R=l,b=i[i.length-1],b.command==="C"&&(x=a+(a-b.points[2]),R=l+(l-b.points[3])),_.push(x,R,p.shift(),p.shift()),a=p.shift(),l=p.shift(),C="C",_.push(a,l);break;case"s":x=a,R=l,b=i[i.length-1],b.command==="C"&&(x=a+(a-b.points[2]),R=l+(l-b.points[3])),_.push(x,R,a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),C="C",_.push(a,l);break;case"Q":_.push(p.shift(),p.shift()),a=p.shift(),l=p.shift(),_.push(a,l);break;case"q":_.push(a+p.shift(),l+p.shift()),a+=p.shift(),l+=p.shift(),C="Q",_.push(a,l);break;case"T":x=a,R=l,b=i[i.length-1],b.command==="Q"&&(x=a+(a-b.points[0]),R=l+(l-b.points[1])),a=p.shift(),l=p.shift(),C="Q",_.push(x,R,a,l);break;case"t":x=a,R=l,b=i[i.length-1],b.command==="Q"&&(x=a+(a-b.points[0]),R=l+(l-b.points[1])),a+=p.shift(),l+=p.shift(),C="Q",_.push(x,R,a,l);break;case"A":D=p.shift(),H=p.shift(),B=p.shift(),z=p.shift(),Y=p.shift(),O=a,M=l,a=p.shift(),l=p.shift(),C="A",_=this.convertEndpointToCenterParameterization(O,M,a,l,z,Y,D,H,B);break;case"a":D=p.shift(),H=p.shift(),B=p.shift(),z=p.shift(),Y=p.shift(),O=a,M=l,a+=p.shift(),l+=p.shift(),C="A",_=this.convertEndpointToCenterParameterization(O,M,a,l,z,Y,D,H,B);break}i.push({command:C||m,points:_,start:{x:k,y},pathLength:this.calcLength(k,y,C||m,_)})}(m==="z"||m==="Z")&&i.push({command:"z",points:[],start:void 0,pathLength:0})}return i}static calcLength(t,n,r,o){let i,s,a,l;const u=Ko;switch(r){case"L":return u.getLineLength(t,n,o[0],o[1]);case"C":return DS([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return PS([t,o[0],o[2]],[n,o[1],o[3]],1);case"A":i=0;const c=o[4],d=o[5],h=o[4]+d;let m=Math.PI/180;if(Math.abs(c-h)<m&&(m=Math.abs(c-h)),s=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],c,0),d<0)for(l=c-m;l>h;l-=m)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=c+m;l<h;l+=m)a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=u.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],h,0),i+=u.getLineLength(s.x,s.y,a.x,a.y),i}return 0}static convertEndpointToCenterParameterization(t,n,r,o,i,s,a,l,u){const c=u*(Math.PI/180),d=Math.cos(c)*(t-r)/2+Math.sin(c)*(n-o)/2,h=-1*Math.sin(c)*(t-r)/2+Math.cos(c)*(n-o)/2,m=d*d/(a*a)+h*h/(l*l);m>1&&(a*=Math.sqrt(m),l*=Math.sqrt(m));let p=Math.sqrt((a*a*(l*l)-a*a*(h*h)-l*l*(d*d))/(a*a*(h*h)+l*l*(d*d)));i===s&&(p*=-1),isNaN(p)&&(p=0);const g=p*a*h/l,C=p*-l*d/a,_=(t+r)/2+Math.cos(c)*g-Math.sin(c)*C,k=(n+o)/2+Math.sin(c)*g+Math.cos(c)*C,y=function(z){return Math.sqrt(z[0]*z[0]+z[1]*z[1])},b=function(z,Y){return(z[0]*Y[0]+z[1]*Y[1])/(y(z)*y(Y))},x=function(z,Y){return(z[0]*Y[1]<z[1]*Y[0]?-1:1)*Math.acos(b(z,Y))},R=x([1,0],[(d-g)/a,(h-C)/l]),D=[(d-g)/a,(h-C)/l],H=[(-1*d-g)/a,(-1*h-C)/l];let B=x(D,H);return b(D,H)<=-1&&(B=Math.PI),b(D,H)>=1&&(B=0),s===0&&B>0&&(B=B-2*Math.PI),s===1&&B<0&&(B=B+2*Math.PI),[_,k,a,l,R,B,c,s]}};di.prototype.className="Path",di.prototype._attrsAffectingSize=["data"],cr(di),le.addGetterSetter(di,"data");var Kl=class extends ea{_sceneFunc(e){super._sceneFunc(e);const t=Math.PI*2,n=this.points();let r=n;const o=this.tension()!==0&&n.length>4;o&&(r=this.getTensionPoints());const i=this.pointerLength(),s=n.length;let a,l;if(o){const d=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],h=di.calcLength(r[r.length-4],r[r.length-3],"C",d),m=di.getPointOnQuadraticBezier(Math.min(1,1-i/h),d[0],d[1],d[2],d[3],d[4],d[5]);a=n[s-2]-m.x,l=n[s-1]-m.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const u=(Math.atan2(l,a)+t)%t,c=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[s-2],n[s-1]),e.rotate(u),e.moveTo(0,0),e.lineTo(-i,c/2),e.lineTo(-i,-c/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),o?(a=(r[0]+r[2])/2-n[0],l=(r[1]+r[3])/2-n[1]):(a=n[2]-n[0],l=n[3]-n[1]),e.rotate((Math.atan2(-l,-a)+t)%t),e.moveTo(0,0),e.lineTo(-i,c/2),e.lineTo(-i,-c/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){const t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x,y:e.y-t,width:e.width,height:e.height+t*2}}};Kl.prototype.className="Arrow",cr(Kl),le.addGetterSetter(Kl,"pointerLength",10,ut()),le.addGetterSetter(Kl,"pointerWidth",10,ut()),le.addGetterSetter(Kl,"pointerAtBeginning",!1),le.addGetterSetter(Kl,"pointerAtEnding",!0);var uu=class extends lt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}};uu.prototype._centroid=!0,uu.prototype.className="Circle",uu.prototype._attrsAffectingSize=["radius"],cr(uu),le.addGetterSetter(uu,"radius",0,ut());var Ka=class extends lt{_sceneFunc(e){const t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}};Ka.prototype.className="Ellipse",Ka.prototype._centroid=!0,Ka.prototype._attrsAffectingSize=["radiusX","radiusY"],cr(Ka),le.addComponentsGetterSetter(Ka,"radius",["x","y"]),le.addGetterSetter(Ka,"radiusX",0,ut()),le.addGetterSetter(Ka,"radiusY",0,ut());var Ri=class Qk extends lt{constructor(t){super(t),this._loadListener=()=>{this._requestDraw()},this.on("imageChange.konva",n=>{this._removeImageLoad(n.oldVal),this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const t=this.image();t&&t.complete||t&&t.readyState===4||t&&t.addEventListener&&t.addEventListener("load",this._loadListener)}_removeImageLoad(t){t&&t.removeEventListener&&t.removeEventListener("load",this._loadListener)}destroy(){return this._removeImageLoad(this.image()),super.destroy(),this}_useBufferCanvas(){const t=!!this.cornerRadius(),n=this.hasShadow();return t&&n?!0:super._useBufferCanvas(!0)}_sceneFunc(t){const n=this.getWidth(),r=this.getHeight(),o=this.cornerRadius(),i=this.attrs.image;let s;if(i){const a=this.attrs.cropWidth,l=this.attrs.cropHeight;a&&l?s=[i,this.cropX(),this.cropY(),a,l,0,0,n,r]:s=[i,0,0,n,r]}(this.hasFill()||this.hasStroke()||o)&&(t.beginPath(),o?Ae.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)),i&&(o&&t.clip(),t.drawImage.apply(t,s))}_hitFunc(t){const n=this.width(),r=this.height(),o=this.cornerRadius();t.beginPath(),o?Ae.drawRoundedRectPath(t,n,r,o):t.rect(0,0,n,r),t.closePath(),t.fillStrokeShape(this)}getWidth(){var t,n,r;return(r=(t=this.attrs.width)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.width)!==null&&r!==void 0?r:0}getHeight(){var t,n,r;return(r=(t=this.attrs.height)!==null&&t!==void 0?t:(n=this.image())===null||n===void 0?void 0:n.height)!==null&&r!==void 0?r:0}static fromURL(t,n,r=null){const o=Ae.createImageElement();o.onload=function(){n(new Qk({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};Ri.prototype.className="Image",Ri.prototype._attrsAffectingSize=["image"],cr(Ri),le.addGetterSetter(Ri,"cornerRadius",0,Ap(4)),le.addGetterSetter(Ri,"image"),le.addComponentsGetterSetter(Ri,"crop",["x","y","width","height"]),le.addGetterSetter(Ri,"cropX",0,ut()),le.addGetterSetter(Ri,"cropY",0,ut()),le.addGetterSetter(Ri,"cropWidth",0,ut()),le.addGetterSetter(Ri,"cropHeight",0,ut());var OS=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],UF="Change.konva",VF="none",d0="up",f0="right",h0="down",p0="left",jF=OS.length,m0=class extends lu{constructor(e){super(e),this.on("add.konva",function(t){this._addListeners(t.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){let t=this,n;const r=function(){t._sync()};for(n=0;n<jF;n++)e.on(OS[n]+UF,r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){let e=this.getText(),t=this.getTag(),n,r,o,i,s,a,l;if(e&&t){switch(n=e.width(),r=e.height(),o=t.pointerDirection(),i=t.pointerWidth(),l=t.pointerHeight(),s=0,a=0,o){case d0:s=n/2,a=-1*l;break;case f0:s=n+i,a=r/2;break;case h0:s=n/2,a=r+l;break;case p0:s=-1*i,a=r/2;break}t.setAttrs({x:-1*s,y:-1*a,width:n,height:r}),e.setAttrs({x:-1*s,y:-1*a})}}};m0.prototype.className="Label",cr(m0);var ql=class extends lt{_sceneFunc(e){const t=this.width(),n=this.height(),r=this.pointerDirection(),o=this.pointerWidth(),i=this.pointerHeight(),s=this.cornerRadius();let a=0,l=0,u=0,c=0;typeof s=="number"?a=l=u=c=Math.min(s,t/2,n/2):(a=Math.min(s[0]||0,t/2,n/2),l=Math.min(s[1]||0,t/2,n/2),c=Math.min(s[2]||0,t/2,n/2),u=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===d0&&(e.lineTo((t-o)/2,0),e.lineTo(t/2,-1*i),e.lineTo((t+o)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,Math.PI*3/2,0,!1),r===f0&&(e.lineTo(t,(n-i)/2),e.lineTo(t+o,n/2),e.lineTo(t,(n+i)/2)),e.lineTo(t,n-c),e.arc(t-c,n-c,c,0,Math.PI/2,!1),r===h0&&(e.lineTo((t+o)/2,n),e.lineTo(t/2,n+i),e.lineTo((t-o)/2,n)),e.lineTo(u,n),e.arc(u,n-u,u,Math.PI/2,Math.PI,!1),r===p0&&(e.lineTo(0,(n+i)/2),e.lineTo(-1*o,n/2),e.lineTo(0,(n-i)/2)),e.lineTo(0,a),e.arc(a,a,a,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){let e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),o=this.pointerDirection(),i=this.width(),s=this.height();return o===d0?(t-=r,s+=r):o===h0?s+=r:o===p0?(e-=n*1.5,i+=n):o===f0&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};ql.prototype.className="Tag",cr(ql),le.addGetterSetter(ql,"pointerDirection",VF),le.addGetterSetter(ql,"pointerWidth",0,ut()),le.addGetterSetter(ql,"pointerHeight",0,ut()),le.addGetterSetter(ql,"cornerRadius",0,Ap(4));var uf=class extends lt{_sceneFunc(e){const t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?Ae.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}};uf.prototype.className="Rect",cr(uf),le.addGetterSetter(uf,"cornerRadius",0,Ap(4));var qa=class extends lt{_sceneFunc(e){const t=this._getPoints(),n=this.radius(),r=this.sides(),o=this.cornerRadius();if(e.beginPath(),o)Ae.drawRoundedPolygonPath(e,t,r,n,o);else{e.moveTo(t[0].x,t[0].y);for(let i=1;i<t.length;i++)e.lineTo(t[i].x,t[i].y)}e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(let r=0;r<e;r++)n.push({x:t*Math.sin(r*2*Math.PI/e),y:-1*t*Math.cos(r*2*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();let t=e[0].x,n=e[0].x,r=e[0].y,o=e[0].y;return e.forEach(i=>{t=Math.min(t,i.x),n=Math.max(n,i.x),r=Math.min(r,i.y),o=Math.max(o,i.y)}),{x:t,y:r,width:n-t,height:o-r}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};qa.prototype.className="RegularPolygon",qa.prototype._centroid=!0,qa.prototype._attrsAffectingSize=["radius"],cr(qa),le.addGetterSetter(qa,"radius",0,ut()),le.addGetterSetter(qa,"sides",0,ut()),le.addGetterSetter(qa,"cornerRadius",0,Ap(4));var BS=Math.PI*2,Yl=class extends lt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,BS,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),BS,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Yl.prototype.className="Ring",Yl.prototype._centroid=!0,Yl.prototype._attrsAffectingSize=["innerRadius","outerRadius"],cr(Yl),le.addGetterSetter(Yl,"innerRadius",0,ut()),le.addGetterSetter(Yl,"outerRadius",0,ut());var ns=class extends lt{constructor(e){super(e),this._updated=!0,this.anim=new cu(()=>{const t=this._updated;return this._updated=!1,t}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+0],a=o[r+1],l=o[r+2],u=o[r+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,u),e.closePath(),e.fillStrokeShape(this)),c)if(i){const d=i[t],h=n*2;e.drawImage(c,s,a,l,u,d[h+0],d[h+1],l,u)}else e.drawImage(c,s,a,l,u,0,0,l,u)}_hitFunc(e){const t=this.animation(),n=this.frameIndex(),r=n*4,o=this.animations()[t],i=this.frameOffsets(),s=o[r+2],a=o[r+3];if(e.beginPath(),i){const l=i[t],u=n*2;e.rect(l[u+0],l[u+1],s,a)}else e.rect(0,0,s,a);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){const e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(this.isRunning())return;const e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){const e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}};ns.prototype.className="Sprite",cr(ns),le.addGetterSetter(ns,"animation"),le.addGetterSetter(ns,"animations"),le.addGetterSetter(ns,"frameOffsets"),le.addGetterSetter(ns,"image"),le.addGetterSetter(ns,"frameIndex",0,ut()),le.addGetterSetter(ns,"frameRate",17,ut()),le.backCompat(ns,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Ya=class extends lt{_sceneFunc(e){const t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(let o=1;o<r*2;o++){const i=o%2===0?n:t,s=i*Math.sin(o*Math.PI/r),a=-1*i*Math.cos(o*Math.PI/r);e.lineTo(s,a)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}};Ya.prototype.className="Star",Ya.prototype._centroid=!0,Ya.prototype._attrsAffectingSize=["innerRadius","outerRadius"],cr(Ya),le.addGetterSetter(Ya,"numPoints",5,ut()),le.addGetterSetter(Ya,"innerRadius",0,ut()),le.addGetterSetter(Ya,"outerRadius",0,ut());function Xa(e){return[...e].reduce((t,n,r,o)=>{if(/\p{Emoji}/u.test(n)){const i=o[r+1];i&&/\p{Emoji_Modifier}|\u200D/u.test(i)?(t.push(n+i),o[r+1]=""):t.push(n)}else/\p{Regional_Indicator}{2}/u.test(n+(o[r+1]||""))?t.push(n+o[r+1]):r>0&&/\p{Mn}|\p{Me}|\p{Mc}/u.test(n)?t[t.length-1]+=n:n&&t.push(n);return t},[])}var du="auto",GF="center",NS="inherit",df="justify",WF="Change.konva",zS="2d",HS="-",US="left",KF="text",qF="Text",YF="top",XF="bottom",VS="middle",jS="normal",QF="px ",Pp=" ",ZF="right",GS="rtl",JF="word",$F="char",WS="none",g0="β¦",KS=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],eO=KS.length,ff=null;function tO(){if(ff!==null)return ff;ff=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(zS);if(t){t.globalAlpha=0,t.shadowColor="black",t.shadowBlur=5,t.shadowOffsetX=5,t.shadowOffsetY=5,t.fillStyle="black",t.font="10px Arial",t.fillText("X",0,10);const n=t.getImageData(0,0,10,10).data;for(let r=3;r<n.length;r+=4)if(n[r]>0){ff=!0;break}}}catch{}return ff}function nO(e){return e.split(",").map(t=>{t=t.trim();const n=t.indexOf(" ")>=0,r=t.indexOf('"')>=0||t.indexOf("'")>=0;return n&&!r&&(t=`"${t}"`),t}).join(", ")}var Fp;function v0(){return Fp||(Fp=Ae.createCanvasElement().getContext(zS),Fp)}function rO(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function oO(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function iO(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var Kn=class extends lt{constructor(e){super(iO(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<eO;t++)this.on(KS[t]+WF,this._setTextData);this._setTextData()}_sceneFunc(e){var t,n;const r=this.textArr,o=r.length;if(!this.text())return;let i=this.padding(),s=this.fontSize(),a=this.lineHeight()*s,l=this.verticalAlign(),u=this.direction(),c=0,d=this.align(),h=this.getWidth(),m=this.letterSpacing(),p=this.charRenderFunc(),g=this.fill(),C=this.textDecoration(),_=this.underlineOffset(),k=C.indexOf("underline")!==-1,y=C.indexOf("line-through")!==-1,b;u=u===NS?e.direction:u;let x=a/2,R=VS;if(!vt.legacyTextRendering){const D=this.measureSize("M");R="alphabetic",x=(((t=D.fontBoundingBoxAscent)!==null&&t!==void 0?t:D.actualBoundingBoxAscent)-((n=D.fontBoundingBoxDescent)!==null&&n!==void 0?n:D.actualBoundingBoxDescent))/2+a/2}for(u===GS&&e.setAttr("direction",u),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",R),e.setAttr("textAlign",US),l===VS?c=(this.getHeight()-o*a-i*2)/2:l===XF&&(c=this.getHeight()-o*a-i*2),e.translate(i,c+i),b=0;b<o;b++){let D=0,H=0;const B=r[b],z=B.text,Y=B.width,O=B.lastInParagraph;if(e.save(),d===ZF?D+=h-Y-i*2:d===GF&&(D+=(h-Y-i*2)/2),k){e.save(),e.beginPath();const A=_??(vt.legacyTextRendering?Math.round(s/2):Math.round(s/4)),N=D,X=x+H+A;e.moveTo(N,X);const te=d===df&&!O?h-i*2:Y;e.lineTo(N+Math.round(te),X),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||g,e.stroke(),e.restore()}const M=D;if(u!==GS&&(m!==0||d===df||p)){const A=z.split(" ").length-1,N=Xa(z);for(let X=0;X<N.length;X++){const te=N[X];if(te===" "&&!O&&d===df&&(D+=(h-i*2-Y)/A),this._partialTextX=D,this._partialTextY=x+H,this._partialText=te,p){e.save();const ae=r.slice(0,b).reduce((me,He)=>me+Xa(He.text).length,0);p({char:te,index:X+ae,x:D,y:x+H,lineIndex:b,column:X,isLastInLine:O,width:this.measureSize(te).width,context:e})}e.fillStrokeShape(this),p&&e.restore(),D+=this.measureSize(te).width+m}}else m!==0&&e.setAttr("letterSpacing",`${m}px`),this._partialTextX=D,this._partialTextY=x+H,this._partialText=z,e.fillStrokeShape(this);if(y){e.save(),e.beginPath();const A=vt.legacyTextRendering?0:-Math.round(s/4),N=M;e.moveTo(N,x+H+A);const X=d===df&&!O?h-i*2:Y;e.lineTo(N+Math.round(X),x+H+A),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||g,e.stroke(),e.restore()}e.restore(),o>1&&(x+=a)}}_hitFunc(e){const t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){const t=Ae._isString(e)?e:e==null?"":e+"";return this._setAttr(KF,t),this}getWidth(){return this.attrs.width===du||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===du||this.attrs.height===void 0?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Ae.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n,r,o,i,s,a,l,u,c,d;let h=v0(),m=this.fontSize(),p;h.save(),h.font=this._getContextFont(),p=h.measureText(e),h.restore();const g=m/100;return{actualBoundingBoxAscent:(t=p.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*g,actualBoundingBoxDescent:(n=p.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=p.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*g,actualBoundingBoxRight:(o=p.actualBoundingBoxRight)!==null&&o!==void 0?o:75.732421875*g,alphabeticBaseline:(i=p.alphabeticBaseline)!==null&&i!==void 0?i:0,emHeightAscent:(s=p.emHeightAscent)!==null&&s!==void 0?s:100*g,emHeightDescent:(a=p.emHeightDescent)!==null&&a!==void 0?a:-20*g,fontBoundingBoxAscent:(l=p.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*g,fontBoundingBoxDescent:(u=p.fontBoundingBoxDescent)!==null&&u!==void 0?u:21*g,hangingBaseline:(c=p.hangingBaseline)!==null&&c!==void 0?c:72.80000305175781*g,ideographicBaseline:(d=p.ideographicBaseline)!==null&&d!==void 0?d:-21*g,width:p.width,height:m}}_getContextFont(){return this.fontStyle()+Pp+this.fontVariant()+Pp+(this.fontSize()+QF)+nO(this.fontFamily())}_addTextLine(e){this.align()===df&&(e=e.trim());const t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){const t=this.letterSpacing(),n=e.length;return v0().measureText(e).width+t*n}_setTextData(){let e=this.text().split(`
|
|
100
100
|
`),t=+this.fontSize(),n=0,r=this.lineHeight()*t,o=this.attrs.width,i=this.attrs.height,s=o!==du&&o!==void 0,a=i!==du&&i!==void 0,l=this.padding(),u=o-l*2,c=i-l*2,d=0,h=this.wrap(),m=h!==$F&&h!==WS,p=this.ellipsis();this.textArr=[],v0().font=this._getContextFont();const g=p?this._getTextWidth(g0):0;for(let C=0,_=e.length;C<_;++C){let k=e[C],y=this._getTextWidth(k);if(s&&y>u)for(;k.length>0;){let b=0,x=Xa(k).length,R="",D=0;for(;b<x;){const H=b+x>>>1,B=Xa(k).slice(0,H+1).join(""),z=this._getTextWidth(B);(p&&a&&d+r>c?z+g:z)<=u?(b=H+1,R=B,D=z):x=H}if(R){if(m){const H=Xa(k),B=Xa(R),z=H[B.length],Y=z===Pp||z===HS;let O;if(Y&&D<=u)O=B.length;else{const M=B.lastIndexOf(Pp),A=B.lastIndexOf(HS);O=Math.max(M,A)+1}O>0&&(b=O,R=H.slice(0,b).join(""),D=this._getTextWidth(R))}if(R=R.trimRight(),this._addTextLine(R),n=Math.max(n,D),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if(k=Xa(k).slice(b).join("").trimLeft(),k.length>0&&(y=this._getTextWidth(k),y<=u)){this._addTextLine(k),d+=r,n=Math.max(n,y);break}}else break}else this._addTextLine(k),d+=r,n=Math.max(n,y),this._shouldHandleEllipsis(d)&&C<_-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&d+r>c)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){const t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,o=r!==du&&r!==void 0,i=r-this.padding()*2;return this.wrap()===WS||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==du&&e!==void 0,n=e-this.padding()*2,r=this.ellipsis(),o=this.textArr[this.textArr.length-1];!o||!r||(t&&(this._getTextWidth(o.text+g0)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+g0))}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,t=this.hasShadow();return e&&t||t&&this.getAbsoluteOpacity()!==1&&tO()?!0:super._useBufferCanvas()}};Kn.prototype._fillFunc=rO,Kn.prototype._strokeFunc=oO,Kn.prototype.className=qF,Kn.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],cr(Kn),le.overWriteSetter(Kn,"width",Jy()),le.overWriteSetter(Kn,"height",Jy()),le.addGetterSetter(Kn,"direction",NS),le.addGetterSetter(Kn,"fontFamily","Arial"),le.addGetterSetter(Kn,"fontSize",12,ut()),le.addGetterSetter(Kn,"fontStyle",jS),le.addGetterSetter(Kn,"fontVariant",jS),le.addGetterSetter(Kn,"padding",0,ut()),le.addGetterSetter(Kn,"align",US),le.addGetterSetter(Kn,"verticalAlign",YF),le.addGetterSetter(Kn,"lineHeight",1,ut()),le.addGetterSetter(Kn,"wrap",JF),le.addGetterSetter(Kn,"ellipsis",!1,Ti()),le.addGetterSetter(Kn,"letterSpacing",0,ut()),le.addGetterSetter(Kn,"text","",jl()),le.addGetterSetter(Kn,"textDecoration",""),le.addGetterSetter(Kn,"underlineOffset",void 0,ut()),le.addGetterSetter(Kn,"charRenderFunc",void 0);var sO="",qS="normal";function YS(e){e.fillText(this.partialText,0,0)}function XS(e){e.strokeText(this.partialText,0,0)}var Or=class extends lt{constructor(e){super(e),this.dummyCanvas=Ae.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return di.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:di.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=di.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();const t=this.textDecoration(),n=this.fill(),r=this.fontSize(),o=this.glyphInfo,i=t.indexOf("underline")!==-1,s=t.indexOf("line-through")!==-1;i&&e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),this.partialText=o[a].text,e.fillStrokeShape(this),i&&(a===0&&e.moveTo(0,r/2+1),e.lineTo(o[a].width,r/2+1)),e.restore()}if(i&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),s){e.beginPath();for(let a=0;a<o.length;a++){e.save();const l=o[a].p0;e.translate(l.x,l.y),e.rotate(o[a].rotation),a===0&&e.moveTo(0,0),e.lineTo(o[a].width,0),e.restore()}e.strokeStyle=n,e.lineWidth=r/20,e.stroke()}e.restore()}_hitFunc(e){e.beginPath();const t=this.glyphInfo;if(t.length>=1){const n=t[0].p0;e.moveTo(n.x,n.y)}for(let n=0;n<t.length;n++){const r=t[n].p1;e.lineTo(r.x,r.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Ae.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Kn.prototype.setText.call(this,e)}_getContextFont(){return Kn.prototype._getContextFont.call(this)}_getTextSize(e){const t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();const n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const e=Xa(this.text()),t=[];let n=0;for(let h=0;h<e.length;h++)t.push({char:e[h],width:this._getTextSize(e[h]).width}),n+=t[h].width;const{width:r,height:o}=this._getTextSize(this.attrs.text);if(this.textWidth=n,this.textHeight=o,this.glyphInfo=[],!this.attrs.data)return null;const i=this.letterSpacing(),s=this.align(),a=this.kerningFunc(),l=Math.max(0,n-r),u=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let c=0;s==="center"&&(c=Math.max(0,this.pathLength/2-u/2)),s==="right"&&(c=Math.max(0,this.pathLength-u));let d=c;for(let h=0;h<t.length;h++){const m=this._getPointAtLength(d);if(!m)return;const p=t[h].char;let g=t[h].width+i;if(p===" "&&s==="justify"){const R=this.text().split(" ").length-1;g+=(this.pathLength-u)/R}const C=d+g,_=this._getPointAtLength(C>this.pathLength&&C-this.pathLength<=l?this.pathLength:C);if(!_)return;const k=di.getLineLength(m.x,m.y,_.x,_.y);let y=0;if(a)try{y=a(t[h-1].char,p)*this.fontSize()}catch{y=0}m.x+=y,_.x+=y,this.textWidth+=y;const b=di.getPointOnLine(y+k/2,m.x,m.y,_.x,_.y),x=Math.atan2(_.y-m.y,_.x-m.x);this.glyphInfo.push({transposeX:b.x,transposeY:b.y,text:e[h],rotation:x,p0:m,p1:_,width:k}),d+=g}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};const e=[];this.glyphInfo.forEach(function(l){e.push(l.p0.x),e.push(l.p0.y),e.push(l.p1.x),e.push(l.p1.y)});let t=e[0]||0,n=e[0]||0,r=e[1]||0,o=e[1]||0,i,s;for(let l=0;l<e.length/2;l++)i=e[l*2],s=e[l*2+1],t=Math.min(t,i),n=Math.max(n,i),r=Math.min(r,s),o=Math.max(o,s);const a=this.fontSize();return{x:t-a/2,y:r-a/2,width:n-t+a,height:o-r+a}}destroy(){return Ae.releaseCanvas(this.dummyCanvas),super.destroy()}};Or.prototype._fillFunc=YS,Or.prototype._strokeFunc=XS,Or.prototype._fillFuncHit=YS,Or.prototype._strokeFuncHit=XS,Or.prototype.className="TextPath",Or.prototype._attrsAffectingSize=["text","fontSize","data"],cr(Or),le.addGetterSetter(Or,"data"),le.addGetterSetter(Or,"fontFamily","Arial"),le.addGetterSetter(Or,"fontSize",12,ut()),le.addGetterSetter(Or,"fontStyle",qS),le.addGetterSetter(Or,"align","left"),le.addGetterSetter(Or,"letterSpacing",0,ut()),le.addGetterSetter(Or,"textBaseline","middle"),le.addGetterSetter(Or,"fontVariant",qS),le.addGetterSetter(Or,"text",sO),le.addGetterSetter(Or,"textDecoration",""),le.addGetterSetter(Or,"kerningFunc",void 0);var QS="tr-konva",aO=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${QS}`).join(" "),ZS="nodesRect",lO=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],cO={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},uO="ontouchstart"in vt._global;function dO(e,t,n){if(e==="rotater")return n;t+=Ae.degToRad(cO[e]||0);const r=(Ae.radToDeg(t)%360+360)%360;return Ae._inRange(r,337.5,360)||Ae._inRange(r,0,22.5)?"ns-resize":Ae._inRange(r,22.5,67.5)?"nesw-resize":Ae._inRange(r,67.5,112.5)?"ew-resize":Ae._inRange(r,112.5,157.5)?"nwse-resize":Ae._inRange(r,157.5,202.5)?"ns-resize":Ae._inRange(r,202.5,247.5)?"nesw-resize":Ae._inRange(r,247.5,292.5)?"ew-resize":Ae._inRange(r,292.5,337.5)?"nwse-resize":(Ae.error("Transformer has unknown angle for cursor detection: "+r),"pointer")}var Op=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],JS=1e8;function fO(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}function $S(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),o=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return{...e,rotation:e.rotation+t,x:r,y:o}}function hO(e,t){return $S(e,t,fO(e))}function pO(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=vt.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var y0=0,vn=class extends lu{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._elementsCreated=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(aO,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Ae.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return QS+this._id}setNodes(e=[]){return this._nodes&&this._nodes.length&&this.detach(),this._nodes=e=e.filter(t=>t.isAncestorOf(this)?(Ae.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0),e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(t=>{const n=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()};if(t._attrsAffectingSize.length){const r=t._attrsAffectingSize.map(o=>o+"Change."+this._getEventNamespace()).join(" ");t.on(r,n)}t.on(lO.map(r=>r+`.${this._getEventNamespace()}`).join(" "),n),t.on(`absoluteTransformChange.${this._getEventNamespace()}`,n),this._proxyDrag(t)}),this._resetTransformCache(),this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,n=>{t=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(n,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,n=>{if(!t)return;const r=e.getAbsolutePosition(),o=r.x-t.x,i=r.y-t.y;this.nodes().forEach(s=>{if(s===e||s.isDragging())return;const a=s.getAbsolutePosition();s.setAbsolutePosition({x:a.x+o,y:a.y+i}),s.startDrag(n)}),t=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(ZS),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(ZS,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){const r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(n),i=e.getAbsolutePosition(n),s=r.x*o.x-e.offsetX()*o.x,a=r.y*o.y-e.offsetY()*o.y,l=(vt.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return $S({x:i.x+s*Math.cos(l)+a*Math.sin(-l),y:i.y+a*Math.cos(l)+s*Math.sin(l),width:r.width*o.x,height:r.height*o.y,rotation:l},-vt.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-JS,y:-JS,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),u=[{x:l.x,y:l.y},{x:l.x+l.width,y:l.y},{x:l.x+l.width,y:l.y+l.height},{x:l.x,y:l.y+l.height}],c=a.getAbsoluteTransform();u.forEach(function(d){const h=c.point(d);e.push(h)})});const t=new xi;t.rotate(-vt.getAngle(this.rotation()));let n=1/0,r=1/0,o=-1/0,i=-1/0;e.forEach(function(a){const l=t.point(a);n===void 0&&(n=o=l.x,r=i=l.y),n=Math.min(n,l.x),r=Math.min(r,l.y),o=Math.max(o,l.x),i=Math.max(i,l.y)}),t.invert();const s=t.point({x:n,y:r});return{x:s.x,y:s.y,width:o-n,height:i-r,rotation:vt.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),Op.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new uf({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:uO?10:"auto"}),n=this;t.on("mousedown touchstart",function(r){n._handleMouseDown(r)}),t.on("dragstart",r=>{t.stopDrag(),r.cancelBubble=!0}),t.on("dragend",r=>{r.cancelBubble=!0}),t.on("mouseenter",()=>{const r=dO(e,vt.getAngle(this.rotation()),this.rotateAnchorCursor());t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0}),t.on("mouseout",()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(t)}_createBack(){const e=new lt({name:"back",width:0,height:0,sceneFunc(t,n){const r=n.getParent(),o=r.padding(),i=n.width(),s=n.height();if(t.beginPath(),t.rect(-o,-o,i+o*2,s+o*2),r.rotateEnabled()&&r.rotateLineVisible()){const a=r.rotateAnchorAngle(),l=r.rotateAnchorOffset(),u=Ae.degToRad(a),c=Math.sin(u),d=-Math.cos(u),h=i/2,m=s/2;let p=1/0;d<0?p=Math.min(p,-m/d):d>0&&(p=Math.min(p,(s-m)/d)),c<0?p=Math.min(p,-h/c):c>0&&(p=Math.min(p,(i-h)/c));const g=h+c*p,C=m+d*p,_=Ae._sign(s),k=g+c*l*_,y=C+d*l*_;t.moveTo(g,C),t.lineTo(k,y)}t.fillStrokeShape(n)},hitFunc:(t,n)=>{if(!this.shouldOverdrawWholeArea())return;const r=this.padding();t.beginPath(),t.rect(-r,-r,n.width()+r*2,n.height()+r*2),t.fillStrokeShape(n)}});this.add(e),this._proxyDrag(e),e.on("dragstart",t=>{t.cancelBubble=!0}),e.on("dragmove",t=>{t.cancelBubble=!0}),e.on("dragend",t=>{t.cancelBubble=!0}),this.on("dragmove",t=>{this.update()})}_handleMouseDown(e){if(this._transforming)return;this._movingAnchorName=e.target.name().split(" ")[0];const t=this._getNodeRect(),n=t.width,r=t.height,o=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/o),this.cos=Math.abs(n/o),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;const i=e.target.getAbsolutePosition(),s=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:s.x-i.x,y:s.y-i.y},y0++,this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(a=>{a._fire("transformstart",{evt:e.evt,target:a})})}_handleMouseMove(e){let t,n,r;const o=this.findOne("."+this._movingAnchorName),i=o.getStage();i.setPointersPositions(e);const s=i.getPointerPosition();let a={x:s.x-this._anchorDragOffset.x,y:s.y-this._anchorDragOffset.y};const l=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(a=this.anchorDragBoundFunc()(l,a,e)),o.setAbsolutePosition(a);const u=o.getAbsolutePosition();if(l.x===u.x&&l.y===u.y)return;if(this._movingAnchorName==="rotater"){const _=this._getNodeRect();t=o.x()-_.width/2,n=-o.y()+_.height/2;const k=vt.getAngle(this.rotateAnchorAngle());let y=Math.atan2(-n,t)+Math.PI/2-k;_.height<0&&(y-=Math.PI);const b=vt.getAngle(this.rotation())+y,x=vt.getAngle(this.rotationSnapTolerance()),R=hO(_,pO(this.rotationSnaps(),b,x)-_.rotation);this._fitNodesInto(R,e);return}const c=this.shiftBehavior();let d;c==="inverted"?d=this.keepRatio()&&!e.shiftKey:c==="none"?d=this.keepRatio():d=this.keepRatio()||e.shiftKey;let h=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(d){const _=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(_.x-o.x(),2)+Math.pow(_.y-o.y(),2));const k=this.findOne(".top-left").x()>_.x?-1:1,y=this.findOne(".top-left").y()>_.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,this.findOne(".top-left").x(_.x-t),this.findOne(".top-left").y(_.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(d){const _=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};r=Math.sqrt(Math.pow(o.x()-_.x,2)+Math.pow(_.y-o.y(),2));const k=this.findOne(".top-right").x()<_.x?-1:1,y=this.findOne(".top-right").y()>_.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,this.findOne(".top-right").x(_.x+t),this.findOne(".top-right").y(_.y-n)}var m=o.position();this.findOne(".top-left").y(m.y),this.findOne(".bottom-right").x(m.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(d){const _=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};r=Math.sqrt(Math.pow(_.x-o.x(),2)+Math.pow(o.y()-_.y,2));const k=_.x<o.x()?-1:1,y=o.y()<_.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,o.x(_.x-t),o.y(_.y+n)}m=o.position(),this.findOne(".top-left").x(m.x),this.findOne(".bottom-right").y(m.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(d){const _=h?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};r=Math.sqrt(Math.pow(o.x()-_.x,2)+Math.pow(o.y()-_.y,2));const k=this.findOne(".bottom-right").x()<_.x?-1:1,y=this.findOne(".bottom-right").y()<_.y?-1:1;t=r*this.cos*k,n=r*this.sin*y,this.findOne(".bottom-right").x(_.x+t),this.findOne(".bottom-right").y(_.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(h=this.centeredScaling()||e.altKey,h){const _=this.findOne(".top-left"),k=this.findOne(".bottom-right"),y=_.x(),b=_.y(),x=this.getWidth()-k.x(),R=this.getHeight()-k.y();k.move({x:-y,y:-b}),_.move({x,y:R})}const p=this.findOne(".top-left").getAbsolutePosition();t=p.x,n=p.y;const g=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),C=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:g,height:C,rotation:vt.getAngle(this.rotation())},e)}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){var t;if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));const n=this.getNode();y0--,this._fire("transformend",{evt:e,target:n}),(t=this.getLayer())===null||t===void 0||t.batchDraw(),n&&this._nodes.forEach(r=>{var o;r._fire("transformend",{evt:e,target:r}),(o=r.getLayer())===null||o===void 0||o.batchDraw()}),this._movingAnchorName=null}}_fitNodesInto(e,t){const n=this._getNodeRect(),r=1;if(Ae._inRange(e.width,-this.padding()*2-r,r)){this.update();return}if(Ae._inRange(e.height,-this.padding()*2-r,r)){this.update();return}const o=new xi;if(o.rotate(vt.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const d=o.point({x:-this.padding()*2,y:0});e.x+=d.x,e.y+=d.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const d=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const d=o.point({x:0,y:-this.padding()*2});e.x+=d.x,e.y+=d.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const d=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=d.x,this._anchorDragOffset.y-=d.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const d=this.boundBoxFunc()(n,e);d?e=d:Ae.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new xi;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new xi,l=e.width/i,u=e.height/i;this.flipEnabled()===!1?(a.translate(e.x,e.y),a.rotate(e.rotation),a.translate(e.width<0?e.width:0,e.height<0?e.height:0),a.scale(Math.abs(l),Math.abs(u))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,u));const c=a.multiply(s.invert());this._nodes.forEach(d=>{var h;if(!d.getStage())return;const m=d.getParent().getAbsoluteTransform(),p=d.getTransform().copy();p.translate(d.offsetX(),d.offsetY());const g=new xi;g.multiply(m.copy().invert()).multiply(c).multiply(m).multiply(p);const C=g.decompose();d.setAttrs(C),(h=d.getLayer())===null||h===void 0||h.batchDraw()}),this.rotation(Ae._getRotation(e.rotation)),this._nodes.forEach(d=>{this._fire("transform",{evt:t,target:d}),d._fire("transform",{evt:t,target:d})}),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e;const t=this._getNodeRect();this.rotation(Ae._getRotation(t.rotation));const n=t.width,r=t.height,o=this.enabledAnchors(),i=this.resizeEnabled(),s=this.padding(),a=this.anchorSize(),l=this.find("._anchor");l.forEach(x=>{x.setAttrs({width:a,height:a,offsetX:a/2,offsetY:a/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:a/2+s,offsetY:a/2+s,visible:i&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:a/2+s,visible:i&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:a/2-s,offsetY:a/2+s,visible:i&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:a/2+s,visible:i&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:a/2-s,visible:i&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:a/2+s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:a/2-s,visible:i&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:a/2-s,offsetY:a/2-s,visible:i&&o.indexOf("bottom-right")>=0});const u=this.rotateAnchorAngle(),c=this.rotateAnchorOffset(),d=Ae.degToRad(u),h=Math.sin(d),m=-Math.cos(d),p=n/2,g=r/2;let C=1/0;m<0?C=Math.min(C,-g/m):m>0&&(C=Math.min(C,(r-g)/m)),h<0?C=Math.min(C,-p/h):h>0&&(C=Math.min(C,(n-p)/h));const _=p+h*C,k=g+m*C,y=Ae._sign(r);this._batchChangeChild(".rotater",{x:_+h*c*y,y:k+m*c*y-s*m,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),draggable:this.nodes().some(x=>x.draggable()),x:0,y:0});const b=this.anchorStyleFunc();b&&l.forEach(x=>{b(x)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();const e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),lu.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}add(...e){return this._elementsCreated?(Ae.error("You cannot add external nodes to the Transformer. Use tr.nodes([node]) instead."),this):super.add(...e)}toObject(){return yt.prototype.toObject.call(this)}clone(e){return yt.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};vn.isTransforming=()=>y0>0;function mO(e){return e instanceof Array||Ae.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){Op.indexOf(t)===-1&&Ae.warn("Unknown anchor name: "+t+". Available names are: "+Op.join(", "))}),e||[]}vn.prototype.className="Transformer",cr(vn),le.addGetterSetter(vn,"enabledAnchors",Op,mO),le.addGetterSetter(vn,"flipEnabled",!0,Ti()),le.addGetterSetter(vn,"resizeEnabled",!0),le.addGetterSetter(vn,"anchorSize",10,ut()),le.addGetterSetter(vn,"rotateEnabled",!0),le.addGetterSetter(vn,"rotateLineVisible",!0),le.addGetterSetter(vn,"rotationSnaps",[]),le.addGetterSetter(vn,"rotateAnchorOffset",50,ut()),le.addGetterSetter(vn,"rotateAnchorAngle",0,ut()),le.addGetterSetter(vn,"rotateAnchorCursor","crosshair"),le.addGetterSetter(vn,"rotationSnapTolerance",5,ut()),le.addGetterSetter(vn,"borderEnabled",!0),le.addGetterSetter(vn,"anchorStroke","rgb(0, 161, 255)"),le.addGetterSetter(vn,"anchorStrokeWidth",1,ut()),le.addGetterSetter(vn,"anchorFill","white"),le.addGetterSetter(vn,"anchorCornerRadius",0,ut()),le.addGetterSetter(vn,"borderStroke","rgb(0, 161, 255)"),le.addGetterSetter(vn,"borderStrokeWidth",1,ut()),le.addGetterSetter(vn,"borderDash"),le.addGetterSetter(vn,"keepRatio",!0),le.addGetterSetter(vn,"shiftBehavior","default"),le.addGetterSetter(vn,"centeredScaling",!1),le.addGetterSetter(vn,"ignoreStroke",!1),le.addGetterSetter(vn,"padding",0,ut()),le.addGetterSetter(vn,"nodes"),le.addGetterSetter(vn,"node"),le.addGetterSetter(vn,"boundBoxFunc"),le.addGetterSetter(vn,"anchorDragBoundFunc"),le.addGetterSetter(vn,"anchorStyleFunc"),le.addGetterSetter(vn,"shouldOverdrawWholeArea",!1),le.addGetterSetter(vn,"useSingleNodeRotation",!0),le.backCompat(vn,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var ta=class extends lt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,vt.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}};ta.prototype.className="Wedge",ta.prototype._centroid=!0,ta.prototype._attrsAffectingSize=["radius"],cr(ta),le.addGetterSetter(ta,"radius",0,ut()),le.addGetterSetter(ta,"angle",0,ut()),le.addGetterSetter(ta,"clockwise",!1),le.backCompat(ta,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function ek(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var gO=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],vO=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function yO(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,u,c,d,h,m,p,g,C,_,k,y,b,x,R,D,H;const B=t+t+1,z=r-1,Y=o-1,O=t+1,M=O*(O+1)/2,A=new ek,N=gO[t],X=vO[t];let te=null,ae=A,me=null,He=null;for(let ce=1;ce<B;ce++)ae=ae.next=new ek,ce===O&&(te=ae);ae.next=A,a=s=0;for(let ce=0;ce<o;ce++){C=_=k=y=l=u=c=d=0,h=O*(b=n[s]),m=O*(x=n[s+1]),p=O*(R=n[s+2]),g=O*(D=n[s+3]),l+=M*b,u+=M*x,c+=M*R,d+=M*D,ae=A;for(let ve=0;ve<O;ve++)ae.r=b,ae.g=x,ae.b=R,ae.a=D,ae=ae.next;for(let ve=1;ve<O;ve++)i=s+((z<ve?z:ve)<<2),l+=(ae.r=b=n[i])*(H=O-ve),u+=(ae.g=x=n[i+1])*H,c+=(ae.b=R=n[i+2])*H,d+=(ae.a=D=n[i+3])*H,C+=b,_+=x,k+=R,y+=D,ae=ae.next;me=A,He=te;for(let ve=0;ve<r;ve++)n[s+3]=D=d*N>>X,D!==0?(D=255/D,n[s]=(l*N>>X)*D,n[s+1]=(u*N>>X)*D,n[s+2]=(c*N>>X)*D):n[s]=n[s+1]=n[s+2]=0,l-=h,u-=m,c-=p,d-=g,h-=me.r,m-=me.g,p-=me.b,g-=me.a,i=a+((i=ve+t+1)<z?i:z)<<2,C+=me.r=n[i],_+=me.g=n[i+1],k+=me.b=n[i+2],y+=me.a=n[i+3],l+=C,u+=_,c+=k,d+=y,me=me.next,h+=b=He.r,m+=x=He.g,p+=R=He.b,g+=D=He.a,C-=b,_-=x,k-=R,y-=D,He=He.next,s+=4;a+=r}for(let ce=0;ce<r;ce++){_=k=y=C=u=c=d=l=0,s=ce<<2,h=O*(b=n[s]),m=O*(x=n[s+1]),p=O*(R=n[s+2]),g=O*(D=n[s+3]),l+=M*b,u+=M*x,c+=M*R,d+=M*D,ae=A;for(let ue=0;ue<O;ue++)ae.r=b,ae.g=x,ae.b=R,ae.a=D,ae=ae.next;let ve=r;for(let ue=1;ue<=t;ue++)s=ve+ce<<2,l+=(ae.r=b=n[s])*(H=O-ue),u+=(ae.g=x=n[s+1])*H,c+=(ae.b=R=n[s+2])*H,d+=(ae.a=D=n[s+3])*H,C+=b,_+=x,k+=R,y+=D,ae=ae.next,ue<Y&&(ve+=r);s=ce,me=A,He=te;for(let ue=0;ue<o;ue++)i=s<<2,n[i+3]=D=d*N>>X,D>0?(D=255/D,n[i]=(l*N>>X)*D,n[i+1]=(u*N>>X)*D,n[i+2]=(c*N>>X)*D):n[i]=n[i+1]=n[i+2]=0,l-=h,u-=m,c-=p,d-=g,h-=me.r,m-=me.g,p-=me.b,g-=me.a,i=ce+((i=ue+O)<Y?i:Y)*r<<2,l+=C+=me.r=n[i],u+=_+=me.g=n[i+1],c+=k+=me.b=n[i+2],d+=y+=me.a=n[i+3],me=me.next,h+=b=He.r,m+=x=He.g,p+=R=He.b,g+=D=He.a,C-=b,_-=x,k-=R,y-=D,He=He.next,s+=r}}const bO=function(t){const n=Math.round(this.blurRadius());n>0&&yO(t,n)};le.addGetterSetter(yt,"blurRadius",0,ut(),le.afterSetFilter);const wO=function(e){const t=this.brightness()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]+=t,n[o+1]+=t,n[o+2]+=t};le.addGetterSetter(yt,"brightness",0,ut(),le.afterSetFilter);const CO=function(e){const t=this.brightness(),n=e.data,r=n.length;for(let o=0;o<r;o+=4)n[o]=Math.min(255,n[o]*t),n[o+1]=Math.min(255,n[o+1]*t),n[o+2]=Math.min(255,n[o+2]*t)},_O=function(e){const t=Math.pow((this.contrast()+100)/100,2),n=e.data,r=n.length;let o=150,i=150,s=150;for(let a=0;a<r;a+=4)o=n[a],i=n[a+1],s=n[a+2],o/=255,o-=.5,o*=t,o+=.5,o*=255,i/=255,i-=.5,i*=t,i+=.5,i*=255,s/=255,s-=.5,s*=t,s+=.5,s*=255,o=o<0?0:o>255?255:o,i=i<0?0:i>255?255:i,s=s<0?0:s>255?255:s,n[a]=o,n[a+1]=i,n[a+2]=s};le.addGetterSetter(yt,"contrast",0,ut(),le.afterSetFilter);const SO=function(e){var t,n,r,o,i,s,a,l,u;const c=e.data,d=e.width,h=e.height,m=Math.min(1,Math.max(0,(n=(t=this.embossStrength)===null||t===void 0?void 0:t.call(this))!==null&&n!==void 0?n:.5)),p=Math.min(1,Math.max(0,(o=(r=this.embossWhiteLevel)===null||r===void 0?void 0:r.call(this))!==null&&o!==void 0?o:.5)),g=(a={"top-left":315,top:270,"top-right":225,right:180,"bottom-right":135,bottom:90,"bottom-left":45,left:0}[(s=(i=this.embossDirection)===null||i===void 0?void 0:i.call(this))!==null&&s!==void 0?s:"top-left"])!==null&&a!==void 0?a:315,C=!!((u=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&u!==void 0&&u),_=m*10,k=p*255,y=g*Math.PI/180,b=Math.cos(y),x=Math.sin(y),R=128/1020*_,D=new Uint8ClampedArray(c),H=new Float32Array(d*h);for(let M=0,A=0;A<c.length;A+=4,M++)H[M]=.2126*D[A]+.7152*D[A+1]+.0722*D[A+2];const B=[-1,0,1,-2,0,2,-1,0,1],z=[-1,-2,-1,0,0,0,1,2,1],Y=[-d-1,-d,-d+1,-1,0,1,d-1,d,d+1],O=M=>M<0?0:M>255?255:M;for(let M=1;M<h-1;M++)for(let A=1;A<d-1;A++){const N=M*d+A;let X=0,te=0;X+=H[N+Y[0]]*B[0],te+=H[N+Y[0]]*z[0],X+=H[N+Y[1]]*B[1],te+=H[N+Y[1]]*z[1],X+=H[N+Y[2]]*B[2],te+=H[N+Y[2]]*z[2],X+=H[N+Y[3]]*B[3],te+=H[N+Y[3]]*z[3],X+=H[N+Y[5]]*B[5],te+=H[N+Y[5]]*z[5],X+=H[N+Y[6]]*B[6],te+=H[N+Y[6]]*z[6],X+=H[N+Y[7]]*B[7],te+=H[N+Y[7]]*z[7],X+=H[N+Y[8]]*B[8],te+=H[N+Y[8]]*z[8];const ae=O(k+(b*X+x*te)*R),me=N*4;if(C){const He=ae-k;c[me]=O(D[me]+He),c[me+1]=O(D[me+1]+He),c[me+2]=O(D[me+2]+He),c[me+3]=D[me+3]}else c[me]=c[me+1]=c[me+2]=ae,c[me+3]=D[me+3]}for(let M=0;M<d;M++){let A=M*4,N=((h-1)*d+M)*4;c[A]=D[A],c[A+1]=D[A+1],c[A+2]=D[A+2],c[A+3]=D[A+3],c[N]=D[N],c[N+1]=D[N+1],c[N+2]=D[N+2],c[N+3]=D[N+3]}for(let M=1;M<h-1;M++){let A=M*d*4,N=(M*d+(d-1))*4;c[A]=D[A],c[A+1]=D[A+1],c[A+2]=D[A+2],c[A+3]=D[A+3],c[N]=D[N],c[N+1]=D[N+1],c[N+2]=D[N+2],c[N+3]=D[N+3]}return e};le.addGetterSetter(yt,"embossStrength",.5,ut(),le.afterSetFilter),le.addGetterSetter(yt,"embossWhiteLevel",.5,ut(),le.afterSetFilter),le.addGetterSetter(yt,"embossDirection","top-left",void 0,le.afterSetFilter),le.addGetterSetter(yt,"embossBlend",!1,void 0,le.afterSetFilter);function b0(e,t,n,r,o){const i=n-t,s=o-r;if(i===0)return r+s/2;if(s===0)return r;let a=(e-t)/i;return a=s*a+r,a}const kO=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,u=t[2],c=u,d;const h=this.enhance();if(h===0)return;for(let y=0;y<n;y+=4)i=t[y+0],i<r?r=i:i>o&&(o=i),l=t[y+1],l<s?s=l:l>a&&(a=l),d=t[y+2],d<u?u=d:d>c&&(c=d);o===r&&(o=255,r=0),a===s&&(a=255,s=0),c===u&&(c=255,u=0);let m,p,g,C,_,k;if(h>0)m=o+h*(255-o),p=r-h*(r-0),g=a+h*(255-a),C=s-h*(s-0),_=c+h*(255-c),k=u-h*(u-0);else{const y=(o+r)*.5;m=o+h*(o-y),p=r+h*(r-y);const b=(a+s)*.5;g=a+h*(a-b),C=s+h*(s-b);const x=(c+u)*.5;_=c+h*(c-x),k=u+h*(u-x)}for(let y=0;y<n;y+=4)t[y+0]=b0(t[y+0],r,o,p,m),t[y+1]=b0(t[y+1],s,a,C,g),t[y+2]=b0(t[y+2],u,c,k,_)};le.addGetterSetter(yt,"enhance",0,ut(),le.afterSetFilter);const AO=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=.34*t[r]+.5*t[r+1]+.16*t[r+2];t[r]=o,t[r+1]=o,t[r+2]=o}};le.addGetterSetter(yt,"hue",0,ut(),le.afterSetFilter),le.addGetterSetter(yt,"saturation",0,ut(),le.afterSetFilter),le.addGetterSetter(yt,"luminance",0,ut(),le.afterSetFilter);const IO=function(e){const t=e.data,n=t.length,r=1,o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=this.luminance()*127,a=r*o*Math.cos(i*Math.PI/180),l=r*o*Math.sin(i*Math.PI/180),u=.299*r+.701*a+.167*l,c=.587*r-.587*a+.33*l,d=.114*r-.114*a-.497*l,h=.299*r-.299*a-.328*l,m=.587*r+.413*a+.035*l,p=.114*r-.114*a+.293*l,g=.299*r-.3*a+1.25*l,C=.587*r-.586*a-1.05*l,_=.114*r+.886*a-.2*l;let k,y,b,x;for(let R=0;R<n;R+=4)k=t[R+0],y=t[R+1],b=t[R+2],x=t[R+3],t[R+0]=u*k+c*y+d*b+s,t[R+1]=h*k+m*y+p*b+s,t[R+2]=g*k+C*y+_*b+s,t[R+3]=x},EO=function(e){const t=e.data,n=t.length,r=Math.pow(2,this.value()),o=Math.pow(2,this.saturation()),i=Math.abs(this.hue()+360)%360,s=r*o*Math.cos(i*Math.PI/180),a=r*o*Math.sin(i*Math.PI/180),l=.299*r+.701*s+.167*a,u=.587*r-.587*s+.33*a,c=.114*r-.114*s-.497*a,d=.299*r-.299*s-.328*a,h=.587*r+.413*s+.035*a,m=.114*r-.114*s+.293*a,p=.299*r-.3*s+1.25*a,g=.587*r-.586*s-1.05*a,C=.114*r+.886*s-.2*a;for(let _=0;_<n;_+=4){const k=t[_+0],y=t[_+1],b=t[_+2],x=t[_+3];t[_+0]=l*k+u*y+c*b,t[_+1]=d*k+h*y+m*b,t[_+2]=p*k+g*y+C*b,t[_+3]=x}};le.addGetterSetter(yt,"hue",0,ut(),le.afterSetFilter),le.addGetterSetter(yt,"saturation",0,ut(),le.afterSetFilter),le.addGetterSetter(yt,"value",0,ut(),le.afterSetFilter);const xO=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4)t[r]=255-t[r],t[r+1]=255-t[r+1],t[r+2]=255-t[r+2]};var TO=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let u=Math.sqrt(a*a+l*l),c=i-a,d=s-l;const h=Math.sqrt(c*c+d*d);u=h>u?h:u;const m=s,p=i,g=360/p*Math.PI/180;for(let C=0;C<p;C+=1){const _=Math.sin(C*g),k=Math.cos(C*g);for(let y=0;y<m;y+=1){c=Math.floor(a+u*y/m*k),d=Math.floor(l+u*y/m*_);let b=(d*i+c)*4;const x=r[b+0],R=r[b+1],D=r[b+2],H=r[b+3];b=(C+y*i)*4,o[b+0]=x,o[b+1]=R,o[b+2]=D,o[b+3]=H}}},RO=function(e,t,n){const r=e.data,o=t.data,i=e.width,s=e.height,a=n.polarCenterX||i/2,l=n.polarCenterY||s/2;let u=Math.sqrt(a*a+l*l),c=i-a,d=s-l;const h=Math.sqrt(c*c+d*d);u=h>u?h:u;const m=s,p=i,g=n.polarRotation||0;let C,_;for(c=0;c<i;c+=1)for(d=0;d<s;d+=1){const k=c-a,y=d-l,b=Math.sqrt(k*k+y*y)*m/u;let x=(Math.atan2(y,k)*180/Math.PI+360+g)%360;x=x*p/360,C=Math.floor(x),_=Math.floor(b);let R=(_*i+C)*4;const D=r[R+0],H=r[R+1],B=r[R+2],z=r[R+3];R=(d*i+c)*4,o[R+0]=D,o[R+1]=H,o[R+2]=B,o[R+3]=z}};const MO=function(e){const t=e.width,n=e.height;let r,o,i,s,a,l,u,c,d,h,m=Math.round(this.kaleidoscopePower());const p=Math.round(this.kaleidoscopeAngle()),g=Math.floor(t*(p%360)/360);if(m<1)return;const C=Ae.createCanvasElement();C.width=t,C.height=n;const _=C.getContext("2d").getImageData(0,0,t,n);Ae.releaseCanvas(C),TO(e,_,{polarCenterX:t/2,polarCenterY:n/2});let k=t/Math.pow(2,m);for(;k<=8;)k=k*2,m-=1;k=Math.ceil(k);let y=k,b=0,x=y,R=1;for(g+k>t&&(b=y,x=0,R=-1),o=0;o<n;o+=1)for(r=b;r!==x;r+=R)i=Math.round(r+g)%t,d=(t*o+i)*4,a=_.data[d+0],l=_.data[d+1],u=_.data[d+2],c=_.data[d+3],h=(t*o+r)*4,_.data[h+0]=a,_.data[h+1]=l,_.data[h+2]=u,_.data[h+3]=c;for(o=0;o<n;o+=1)for(y=Math.floor(k),s=0;s<m;s+=1){for(r=0;r<y+1;r+=1)d=(t*o+r)*4,a=_.data[d+0],l=_.data[d+1],u=_.data[d+2],c=_.data[d+3],h=(t*o+y*2-r-1)*4,_.data[h+0]=a,_.data[h+1]=l,_.data[h+2]=u,_.data[h+3]=c;y*=2}RO(_,e,{polarRotation:0})};le.addGetterSetter(yt,"kaleidoscopePower",2,ut(),le.afterSetFilter),le.addGetterSetter(yt,"kaleidoscopeAngle",0,ut(),le.afterSetFilter);function Bp(e,t,n){let r=(n*e.width+t)*4;const o=[];return o.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),o}function hf(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function LO(e){const t=[0,0,0];for(let n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}function DO(e,t){const n=Bp(e,0,0),r=Bp(e,e.width-1,0),o=Bp(e,0,e.height-1),i=Bp(e,e.width-1,e.height-1),s=t||10;if(hf(n,r)<s&&hf(r,i)<s&&hf(i,o)<s&&hf(o,n)<s){const a=LO([r,n,i,o]),l=[];for(let u=0;u<e.width*e.height;u++)l[u]=hf(a,[e.data[u*4],e.data[u*4+1],e.data[u*4+2]])<s?0:255;return l}}function PO(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function FO(e,t,n){const r=[1,1,1,1,0,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let h=0;h<o;h++){const m=a+d-i,p=l+h-i;if(m>=0&&m<n&&p>=0&&p<t){const g=m*t+p,C=r[d*o+h];c+=e[g]*C}}s[u]=c===2040?255:0}return s}function OO(e,t,n){const r=[1,1,1,1,1,1,1,1,1],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let h=0;h<o;h++){const m=a+d-i,p=l+h-i;if(m>=0&&m<n&&p>=0&&p<t){const g=m*t+p,C=r[d*o+h];c+=e[g]*C}}s[u]=c>=1020?255:0}return s}function BO(e,t,n){const r=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],o=Math.round(Math.sqrt(r.length)),i=Math.floor(o/2),s=[];for(let a=0;a<n;a++)for(let l=0;l<t;l++){const u=a*t+l;let c=0;for(let d=0;d<o;d++)for(let h=0;h<o;h++){const m=a+d-i,p=l+h-i;if(m>=0&&m<n&&p>=0&&p<t){const g=m*t+p,C=r[d*o+h];c+=e[g]*C}}s[u]=c}return s}const NO=function(e){let t=DO(e,this.threshold());return t&&(t=FO(t,e.width,e.height),t=OO(t,e.width,e.height),t=BO(t,e.width,e.height),PO(e,t)),e};le.addGetterSetter(yt,"threshold",0,ut(),le.afterSetFilter);const zO=function(e){const t=this.noise()*255,n=e.data,r=n.length,o=t/2;for(let i=0;i<r;i+=4)n[i+0]+=o-2*o*Math.random(),n[i+1]+=o-2*o*Math.random(),n[i+2]+=o-2*o*Math.random()};le.addGetterSetter(yt,"noise",.2,ut(),le.afterSetFilter);const HO=function(e){let t=Math.ceil(this.pixelSize()),n=e.width,r=e.height,o=Math.ceil(n/t),i=Math.ceil(r/t),s=e.data;if(t<=0){Ae.error("pixelSize value can not be <= 0");return}for(let a=0;a<o;a+=1)for(let l=0;l<i;l+=1){let u=0,c=0,d=0,h=0;const m=a*t,p=m+t,g=l*t,C=g+t;let _=0;for(let k=m;k<p;k+=1)if(!(k>=n))for(let y=g;y<C;y+=1){if(y>=r)continue;const b=(n*y+k)*4;u+=s[b+0],c+=s[b+1],d+=s[b+2],h+=s[b+3],_+=1}u=u/_,c=c/_,d=d/_,h=h/_;for(let k=m;k<p;k+=1)if(!(k>=n))for(let y=g;y<C;y+=1){if(y>=r)continue;const b=(n*y+k)*4;s[b+0]=u,s[b+1]=c,s[b+2]=d,s[b+3]=h}}};le.addGetterSetter(yt,"pixelSize",8,ut(),le.afterSetFilter);const UO=function(e){const t=Math.round(this.levels()*254)+1,n=e.data,r=n.length,o=255/t;for(let i=0;i<r;i+=1)n[i]=Math.floor(n[i]/o)*o};le.addGetterSetter(yt,"levels",.5,ut(),le.afterSetFilter);const VO=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue();for(let s=0;s<n;s+=4){const a=(.34*t[s]+.5*t[s+1]+.16*t[s+2])/255;t[s]=a*r,t[s+1]=a*o,t[s+2]=a*i,t[s+3]=t[s+3]}};le.addGetterSetter(yt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),le.addGetterSetter(yt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),le.addGetterSetter(yt,"blue",0,eS,le.afterSetFilter);const jO=function(e){const t=e.data,n=t.length,r=this.red(),o=this.green(),i=this.blue(),s=this.alpha();for(let a=0;a<n;a+=4){const l=1-s;t[a]=r*s+t[a]*l,t[a+1]=o*s+t[a+1]*l,t[a+2]=i*s+t[a+2]*l}};le.addGetterSetter(yt,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),le.addGetterSetter(yt,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),le.addGetterSetter(yt,"blue",0,eS,le.afterSetFilter),le.addGetterSetter(yt,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const GO=function(e){const t=e.data,n=t.length;for(let r=0;r<n;r+=4){const o=t[r+0],i=t[r+1],s=t[r+2];t[r+0]=Math.min(255,o*.393+i*.769+s*.189),t[r+1]=Math.min(255,o*.349+i*.686+s*.168),t[r+2]=Math.min(255,o*.272+i*.534+s*.131)}},WO=function(e){const n=e.data;for(let r=0;r<n.length;r+=4){const o=n[r],i=n[r+1],s=n[r+2];.2126*o+.7152*i+.0722*s>=128&&(n[r]=255-o,n[r+1]=255-i,n[r+2]=255-s)}return e},KO=function(e){const t=this.threshold()*255,n=e.data,r=n.length;for(let o=0;o<r;o+=1)n[o]=n[o]<t?0:255};le.addGetterSetter(yt,"threshold",.5,ut(),le.afterSetFilter);var qO=MS.Util._assign(MS,{Arc:$s,Arrow:Kl,Circle:uu,Ellipse:Ka,Image:Ri,Label:m0,Tag:ql,Line:ea,Path:di,Rect:uf,RegularPolygon:qa,Ring:Yl,Sprite:ns,Star:Ya,Text:Kn,TextPath:Or,Transformer:vn,Wedge:ta,Filters:{Blur:bO,Brightness:CO,Brighten:wO,Contrast:_O,Emboss:SO,Enhance:kO,Grayscale:AO,HSL:IO,HSV:EO,Invert:xO,Kaleidoscope:MO,Mask:NO,Noise:zO,Pixelate:HO,Posterize:UO,RGB:VO,RGBA:jO,Sepia:GO,Solarize:WO,Threshold:KO}});Et();var YO=["dialog","floating"],tk=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function XO(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!YO.includes(e.mode))throw new Error(`SurfaceManager: mode must be "dialog" or "floating", got "${e.mode}".`);const t="kind"in e&&e.kind!=null,n="component"in e&&e.component!=null,r="render"in e&&typeof e.render=="function";if(n&&r)throw new Error('SurfaceManager: request cannot provide both "component" and "render". Use one or the other.');if(!t&&!n&&!r)throw new Error('SurfaceManager: request must provide "kind" (intent-based) or "component"/"render" (direct-render).');if(e.mode==="floating"&&e.floating?.placement!=null&&!tk.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${tk.join(", ")}, got "${e.floating.placement}".`)}var QO=class{activeDialog=Fr(null);activeFloating=Fr(null);#t=!1;#n=1;#e;constructor({getModuleConfig:e}){this.#e=e}open(e){if(this.#t)return this.#r(e);XO(e);const t=this.#u(e),{component:n,props:r,render:o}=this.#d(t);let i,s=!1;const a=new Promise(m=>{i=p=>s?!1:(s=!0,m(p),!0)});let l;const u=m=>{i({status:"submitted",data:m})&&this.#i(l)},c=m=>{i({status:"closed",reason:m})&&this.#i(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:u,close:c,settle:m=>i(m),get settled(){return s}};const d=t.mode==="dialog"?"activeDialog":"activeFloating",h=this[d].value;return h&&!h.settled&&h.settle({status:"replaced",replacedBy:t.id}),this[d].value=l,{id:t.id,mode:t.mode,close:m=>this.#o(l,m),result:a}}close(e,t){if(e!=null){const o=this.#s(e);o&&this.#o(o,t);return}const n=this.activeDialog.value;if(n&&!n.settled){this.#o(n,t);return}const r=this.activeFloating.value;r&&!r.settled&&this.#o(r,t)}settleAll(e){for(const t of[this.activeDialog,this.activeFloating]){const n=t.value;n&&!n.settled&&n.settle(e),t.value=null}}destroy(){this.#t=!0,this.settleAll({status:"destroyed"})}#o(e,t){e.settled||(e.settle({status:"closed",reason:t}),this.#i(e))}#i(e){const t=e.mode==="dialog"?this.activeDialog:this.activeFloating;t.value===e&&(t.value=null)}#s(e){return this.activeDialog.value?.id===e?this.activeDialog.value:this.activeFloating.value?.id===e?this.activeFloating.value:null}#u(e){const t=e.id??`surface-${this.#n++}`,n=this.#e()??{},r=e.mode==="dialog"?n.dialog:n.floating,o=e.mode==="dialog"?{maxWidth:r?.maxWidth,...e.dialog}:e.dialog,i=e.mode==="floating"?{placement:r?.placement??"top-right",width:r?.width,maxWidth:r?.maxWidth,maxHeight:r?.maxHeight,autoFocus:r?.autoFocus??!0,closeOnOutsidePointerDown:r?.closeOnOutsidePointerDown??!1,...e.floating}:e.floating;return{...e,id:t,closeOnEscape:e.closeOnEscape??r?.closeOnEscape??!0,closeOnBackdrop:e.mode==="dialog"?e.closeOnBackdrop??r?.closeOnBackdrop??!0:!1,dialog:o,floating:i}}#d(e){if("component"in e&&e.component!=null)return{component:e.component,props:e.props};if("render"in e&&typeof e.render=="function")return{render:e.render};const t=this.#e()?.resolver;if(typeof t=="function"){const n=t(e);if(n!=null){if(n.type==="none")throw new Error(`SurfaceManager: resolver explicitly suppressed surface for kind "${e.kind}".`);if(n.type==="custom")return{component:n.component,props:n.props};if(n.type==="external")return{render:n.render}}}throw new Error(`SurfaceManager: no renderer resolved for kind "${e.kind}". Provide a resolver via modules.surfaces.resolver, or use a direct-render request.`)}#r(e){return{id:e?.id??`surface-${this.#n++}`,mode:e?.mode??"dialog",close:()=>{},result:Promise.resolve({status:"destroyed"})}}},ZO="https://docs.superdoc.dev/guides/migration/document-api",nk=new Set;function JO(e,t){nk.has(e)||(nk.add(e),console.warn(t))}var $O={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},rk=Symbol.for("superdoc:rawEditor"),ok=new WeakMap;function ik(e){return!e||e[rk]?e:new Proxy(e,{get(t,n){if(n===rk)return t;const r=$O[n];r&&JO(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${ZO}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=ok.get(t);return i||(i=new Map,ok.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var sk=["review","original","final","off"],eB=["paired","independent"],ak=Symbol.for("@superdoc/trackChanges:normalized"),lk=new Set;function ck(e,t){lk.has(e)||(lk.add(e),console.warn(`[SuperDoc] ${e} is deprecated β use ${t} instead.`))}function uk(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function tB(e,t,n){return typeof e=="string"&&sk.includes(e)?e:typeof t=="string"&&sk.includes(t)?t:n}function nB(e){return typeof e=="string"&&eB.includes(e)?e:null}function Xl(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function rB(e){const t=e[ak]===!0;Xl(e.modules)||(e.modules={});const n=Xl(e.modules.trackChanges),r=Xl(e.trackChanges),o=Xl(e.layoutEngineOptions?.trackedChanges);t||(r&&ck("config.trackChanges","config.modules.trackChanges"),o&&ck("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=uk(n?.visible,r?.visible,!1),s=uk(n?.enabled,o?.enabled,!0),a=nB(n?.replacements)??"paired",l=Xl(n?.authorColors)?n.authorColors:void 0,u=Xl(n?.semanticColors)?n.semanticColors:void 0,c=e.documentMode==="viewing"?i?"review":"original":"review",d=tB(n?.mode,o?.mode,c),h={visible:i,mode:d,enabled:s,replacements:a};return l&&(h.authorColors=l),u&&(h.semanticColors=u),e.modules.trackChanges=h,e.trackChanges={visible:i},Xl(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:d,enabled:s},Object.defineProperty(e,ak,{value:!0,writable:!0,configurable:!0,enumerable:!1}),h}const w0=Object.freeze({id:null,name:"Default SuperDoc user",email:null});function oB(e){return!e||typeof e!="object"?{...w0}:{...w0,...e}}var iB=class{#t=new Map;#n=new Map;#e=null;#o=new Set;register(e){if(this.#t.has(e.id))throw new Error(`EditorRuntimeRegistry: duplicate runtime id "${e.id}"`);const t=e.root,n=t?this.#n.get(t):void 0;if(n!==void 0&&n!==e.id)throw new Error(`EditorRuntimeRegistry: root element already registered to runtime "${n}"`);this.#t.set(e.id,e),t&&this.#n.set(t,e.id)}unregister(e){const t=this.#t.get(e);return t?(this.#t.delete(e),t.root&&this.#n.delete(t.root),this.#e===e&&(this.#e=null,this.#i({previousRuntimeId:e,nextRuntimeId:null,reason:"active-runtime-unregistered",legacyEditorProjection:null})),!0):!1}get(e){return this.#t.get(e)??null}getAll(){return Array.from(this.#t.values())}getAllByDocumentId(e){const t=[];for(const n of this.#t.values())n.documentId===e&&t.push(n);return t}getActive(){return this.#e===null?null:this.#t.get(this.#e)}getActiveId(){return this.#e}setActive(e,t){if(e!==null&&!this.#t.has(e))throw new Error(`EditorRuntimeRegistry: cannot activate unknown runtime "${e}"`);if(e===this.#e)return;const n=this.#e;this.#e=e;let r=null;e!==null&&(r=this.#t.get(e).getLegacyEditorProjection?.()??null),this.#i({previousRuntimeId:n,nextRuntimeId:e,reason:t,legacyEditorProjection:r})}resolveFromEventTarget(e){const t=e instanceof Element?e:e instanceof Node?e.parentElement:null;if(!t)return null;const n=t.closest(`[${up}]`);if(!n)return null;const r=n.getAttribute(up),o=r?this.get(r):null;return o&&o.root===n?o:null}subscribe(e){return this.#o.add(e),()=>{this.#o.delete(e)}}clear(){this.#t.clear(),this.#n.clear(),this.#e=null,this.#o.clear()}#i(e){for(const t of Array.from(this.#o))try{t(e)}catch{}}},sB=["table-add-row-before","table-add-row-after","table-delete-row","table-add-column-before","table-add-column-after","table-delete-column","table-delete","table-merge-cells","table-split-cell","table-remove-borders"];const dk=[{name:"bold",commandId:"bold",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"italic",commandId:"italic",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"underline",commandId:"underline",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"strike",commandId:"strikethrough",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"clearFormatting",commandId:"clear-formatting",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"copyFormat",commandId:"copy-format",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontFamily",commandId:"font-family",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"fontSize",commandId:"font-size",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"color",commandId:"text-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"highlight",commandId:"highlight-color",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"textAlign",commandId:"text-align",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"list",commandId:"bullet-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"numberedlist",commandId:"numbered-list",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentleft",commandId:"indent-decrease",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"indentright",commandId:"indent-increase",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"lineHeight",commandId:"line-height",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"linkedStyles",commandId:"linked-style",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"link",commandId:"link",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"image",commandId:"image",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"table",commandId:"table-insert",instanceMethod:null,disposition:"controller-routed",group:"center"},{name:"tableActions",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",memberCommandIds:sB,note:"table editing dropdown is shell chrome; its member commands are controller-routed through the shared table-context facade (ui.tables / host.getTableContext()) and fail closed with table-context-unavailable when the caret is not in a table"},{name:"undo",commandId:"undo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"redo",commandId:"redo",instanceMethod:null,disposition:"controller-routed",group:"left"},{name:"search",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"right",note:"built-in search button; opens the shared find/replace surface (the same one Cmd/Ctrl+F opens) by emitting a `search:open` event on the SuperDoc instance, which the shell handles. The surface reads/drives the controller search surface (ui.search), backed by the single V2 host search session (host.search) which owns query, navigation, reveal, and replace. Find/navigation are always available when the host exposes search; replace/replaceAll mutate through the host session and fail closed (document-readonly) in viewing/read-only mode. If a runtime cannot expose search, the surface fails closed with search-unavailable"},{name:"zoom",commandId:"zoom",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"measurementUnit",commandId:"measurement-unit",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"ruler",commandId:null,instanceMethod:"toggleRuler",disposition:"host-routed",group:"right",note:"built-in shell toggles ruler visibility through the public SuperDoc.toggleRuler() instance method; the controller also routes the ruler command through it so custom UIs drive the same chrome (active state from config.rulers)"},{name:"formattingMarks",commandId:null,instanceMethod:"toggleFormattingMarks",disposition:"host-routed",group:"right",note:"built-in shell toggles nonprinting marks through the public SuperDoc.toggleFormattingMarks()/setShowFormattingMarks() instance methods (not a controller command)"},{name:"documentMode",commandId:"document-mode",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"acceptTrackedChangeBySelection",commandId:"track-changes-accept-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"rejectTrackedChangeOnSelection",commandId:"track-changes-reject-selection",instanceMethod:null,disposition:"controller-routed",group:"right"},{name:"customButtons",commandId:null,instanceMethod:null,disposition:"shell-owned",group:"center",note:"consumer-defined buttons the rendered shell owns; their execution context surface is phase 2"}];var fk=new Map(dk.map(e=>[e.name,e]));const hV=dk.map(e=>e.name);function C0(e){return fk.get(e)??null}function aB(e){const t=fk.get(e);return t?.disposition==="controller-routed"?t.commandId:null}const lB=".png,.jpg,.jpeg,image/png,image/jpeg";var hk=new Set(["image/png","image/jpeg","image/jpg"]),cB=/\.(png|jpe?g)$/i;function uB(e){if(!e)return!1;const t=typeof e.type=="string"?e.type.toLowerCase():"";return t?hk.has(t):cB.test(String(e.name??""))}function pk(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(dB(String(r.result),e)),r.onerror=()=>n(r.error??new Error("image-read-failed")),r.readAsDataURL(e)})}function dB(e,t){const n=/^data:([^;,]*);base64,/.exec(e);if(!n)return e;const r=n[1].toLowerCase();if(hk.has(r))return e;const o=String(t?.name??""),i=/\.jpe?g$/i.test(o)?"image/jpeg":/\.png$/i.test(o)?"image/png":null;return i?`data:${i};base64,${e.slice(n[0].length)}`:e}async function fB(e,t){if(typeof t=="function"){const n=await t(e);if(typeof n!="string"||n.trim()==="")throw new Error("handleImageUpload returned an empty result");return n.startsWith("data:")?n:hB(n,e)}return pk(e)}async function hB(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`image fetch failed: ${n.status}`);const r=await n.blob(),o=(/\.(?:png|jpe?g)(?:$|[?#])/i.test(e)?e.split(/[?#]/)[0]:"")||t?.name||"";return pk(o?Object.assign(r,{name:o}):r)}function pB({ownerDocument:e=document,onPick:t,onError:n}={}){const r=e.createElement("input");return r.type="file",r.accept=lB,r.hidden=!0,r.tabIndex=-1,r.setAttribute("data-superdoc-image-picker","true"),r.setAttribute("aria-hidden","true"),r.addEventListener("change",()=>{const o=r.files&&r.files[0];if(r.value="",!!o){if(!uB(o)){n?.(new Error(`unsupported image type: ${o.type||o.name}`));return}try{const i=t?.(o);i&&typeof i.then=="function"&&i.catch(s=>n?.(s))}catch(i){n?.(i)}}}),e.body?.appendChild(r),{input:r,open(){r.click()},destroy(){r.remove()}}}var mB=(e,t)=>{let n=e.replace(/[^0-9.]/g,"");return n=parseFloat(n),isNaN(n)&&(n=t),n=parseFloat(n),n},gB=(e,t,n)=>{let r,o,i,s=0;n||(n={});const a=()=>{s=n.leading===!1?0:Date.now(),r=null,i=e(...o),r||(o=null)},l=(...u)=>{const c=Date.now();!s&&n.leading===!1&&(s=c);const d=t-(c-s);return o=u,d<=0||d>t?(r&&(clearTimeout(r),r=null),s=c,i=e(...u),r||(o=null)):!r&&n.trailing!==!1&&(r=setTimeout(a,d)),i};return l.cancel=function(){clearTimeout(r),s=0,r=o=null},l};Et(),an();var vB={class:"sd-toolbar-icon"},yB=["innerHTML"],bB={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=ke(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=ke(()=>["color","highlight"].includes(t.name));return(o,i)=>(ge(),Se("div",vB,[Le("div",{class:Xt(["sd-toolbar-icon__icon",[`sd-toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,yB),r.value?(ge(),Se("div",{key:0,class:"color-bar",style:un(n.value)},null,4)):ct("",!0)]))}},mk=nn(bB,[["__scopeId","data-v-d7d79424"]]);Et(),an();var wB=["role","aria-label"],CB=["data-item"],_B=["data-item"],SB={key:1,class:"sd-button-label"},kB=["data-item","aria-label"],AB=["innerHTML"],IB={key:2},EB=["onKeydown","id"],xB=["placeholder","onKeydown","id","data-item"],TB=["data-item","innerHTML"],RB={"aria-live":"polite",class:"sd-visually-hidden"},MB={__name:"ToolbarButton",props:{iconColor:{type:String,default:null},active:{type:Boolean,default:!1},isNarrow:{type:Boolean,default:!1},isWide:{type:Boolean,default:!1},toolbarItem:{type:Object,required:!0},defaultLabel:{type:String,default:null},isOverflowItem:{type:Boolean,default:!1},allowEnterPropagation:{type:Boolean,default:!1}},emits:["buttonClick","textSubmit","mainClick"],setup(e,{emit:t}){const n=t,{proxy:r}=Zn(),o=e,{name:i,active:s,icon:a,label:l,hideLabel:u,iconColor:c,hasCaret:d,splitButton:h,disabled:m,expand:p,inlineTextInputVisible:g,hasInlineTextInput:C,minWidth:_,style:k,attributes:y}=o.toolbarItem,b=ke(()=>!!h?.value&&!!d?.value),x=ke(()=>i?.value??""),R=ee(""),D=ee(null),{isHighContrastMode:H}=Ai();Mt(()=>l?.value,_e=>{document.activeElement!==D.value&&(R.value=_e==null?"":String(_e))},{immediate:!0});const B=()=>{C&&St(()=>{D.value?.focus(),D.value?.select()}),n("buttonClick")},z=_e=>{m?.value||(_e?.stopPropagation(),n("mainClick"))},Y=()=>{b.value||B()},O=_e=>{if(b.value){z(_e);return}B()},M=_e=>{o.allowEnterPropagation||_e.stopPropagation(),O(_e)},A=_e=>{const ie=o.toolbarItem?.nestedOptions?.value??[],Te=_e.trim();if(!Te)return"";const Ge=ie.find($e=>typeof $e?.label=="string"&&$e.label.toLowerCase()===Te.toLowerCase());return Ge?.label?Ge.label:ie.find($e=>typeof $e?.label=="string"&&$e.label.toLowerCase().startsWith(Te.toLowerCase()))?.label??Te},N=()=>{const _e=String(R.value??"").trim();let ie=_e;if(x.value==="fontSize"){const Te=Number.parseFloat(_e);ie=_e.match(/^\d+(\.5)?$/)?_e:Number.isFinite(Te)?Math.floor(Te).toString():""}else x.value==="fontFamily"&&(ie=A(_e));return ie?(n("textSubmit",ie),R.value=ie,!0):!1},X=_e=>{const ie=_e?.currentTarget;ie instanceof HTMLInputElement&&(ie.focus({preventScroll:!0}),ie.select())},te=_e=>{requestAnimationFrame(()=>{const ie=document.getElementById(`inlineTextInput-${_e}`);ie instanceof HTMLInputElement&&(ie.focus({preventScroll:!0}),ie.select())})},ae=()=>{const _e=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return _e instanceof HTMLElement?(_e.focus({preventScroll:!0}),!0):!1},me=()=>{const _e=r?.$toolbar?.pendingSelectionCapture,ie=()=>{_e&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(_e)};if(ae()){ie();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),ie())},He=()=>{N()&&me()},ce=_e=>{if(N(),_e.shiftKey){x.value==="fontSize"&&(_e.preventDefault(),St(()=>te("fontFamily")));return}if(_e.preventDefault(),x.value==="fontFamily"){St(()=>te("fontSize"));return}x.value==="fontSize"&&St(me)},ve=ke(()=>k.value?k.value:{minWidth:o.minWidth}),ue=ke(()=>p?.value?Wn.dropdownCaretUp:Wn.dropdownCaretDown);return(_e,ie)=>(ge(),Se("div",{class:Xt(["sd-toolbar-item",Xe(y).className]),style:un(ve.value),role:e.isOverflowItem?"menuitem":"button","aria-label":Xe(y).ariaLabel,"data-sd-part":"toolbar-item",onClick:Y,onKeydown:ie[9]||(ie[9]=No(Te=>M(Te),["enter"])),tabindex:"0"},[Le("div",{class:Xt(["sd-toolbar-button",{"sd-active":Xe(s),"sd-disabled":Xe(m),narrow:e.isNarrow,wide:e.isWide,split:b.value,"has-inline-text-input":Xe(C),"high-contrast":Xe(H)}]),"data-item":`btn-${Xe(i)||""}`},[b.value?(ge(),Se("div",{key:0,class:"sd-toolbar-button__main","data-item":`btn-${Xe(i)||""}-main`,onClick:ie[0]||(ie[0]=Te=>z(Te))},[Xe(a)?(ge(),tn(mk,{key:0,color:Xe(c),class:"sd-toolbar-icon",icon:Xe(a),name:Xe(i)},null,8,["color","icon","name"])):ct("",!0),Xe(l)&&!Xe(u)&&!Xe(g)?(ge(),Se("div",SB,Ft(Xe(l)),1)):ct("",!0)],8,_B)):ct("",!0),b.value?(ge(),Se("div",{key:1,class:"sd-toolbar-button__caret","data-item":`btn-${Xe(i)||""}-caret`,"aria-label":`${Xe(y).ariaLabel} options`,role:"button"},[Le("div",{class:"sd-dropdown-caret",innerHTML:ue.value,style:un({opacity:Xe(m)?.6:1})},null,12,AB)],8,kB)):(ge(),Se(Vt,{key:2},[Xe(a)?(ge(),tn(mk,{key:0,color:Xe(c),class:"sd-toolbar-icon",icon:Xe(a),name:Xe(i)},null,8,["color","icon","name"])):ct("",!0),Xe(l)&&!Xe(u)&&(!Xe(g)||x.value==="fontFamily")?(ge(),Se("div",{key:1,class:Xt(["sd-button-label",{"sd-visually-hidden":Xe(g)&&x.value==="fontFamily"}])},Ft(Xe(l)),3)):ct("",!0),Xe(g)?(ge(),Se("span",IB,[Xe(i)==="fontSize"?xs((ge(),Se("input",{key:0,"onUpdate:modelValue":ie[1]||(ie[1]=Te=>R.value=Te),onKeydown:[No(Wt(He,["stop","prevent"]),["enter"]),ie[2]||(ie[2]=No(Te=>ce(Te),["tab"]))],onClick:ie[3]||(ie[3]=Wt(Te=>X(Te),["stop"])),onFocus:ie[4]||(ie[4]=Te=>X(Te)),type:"text",class:Xt(["button-text-input button-text-input--font-size",{"high-contrast":Xe(H)}]),id:"inlineTextInput-"+Xe(i),autocomplete:"off",ref_key:"inlineInput",ref:D},null,42,EB)),[[ci,R.value]]):xs((ge(),Se("input",{key:1,"onUpdate:modelValue":ie[5]||(ie[5]=Te=>R.value=Te),placeholder:Xe(l),onKeydown:[No(Wt(He,["stop","prevent"]),["enter"]),ie[6]||(ie[6]=No(Te=>ce(Te),["tab"]))],onClick:ie[7]||(ie[7]=Wt(Te=>X(Te),["stop"])),onFocus:ie[8]||(ie[8]=Te=>X(Te)),type:"text",class:Xt(["button-text-input",{"button-text-input--font-family":x.value==="fontFamily","high-contrast":Xe(H)}]),id:"inlineTextInput-"+Xe(i),"data-item":x.value==="fontFamily"?`btn-${Xe(i)}-input`:void 0,autocomplete:"off",ref_key:"inlineInput",ref:D},null,42,xB)),[[ci,R.value]])])):ct("",!0),Xe(d)?(ge(),Se("div",{key:3,class:"sd-dropdown-caret","data-item":`btn-${Xe(i)||""}-toggle`,innerHTML:ue.value,style:un({opacity:Xe(m)?.6:1})},null,12,TB)):ct("",!0)],64)),Le("div",RB,Ft(`${Xe(y).ariaLabel} ${Xe(s)?"selected":"unset"}`),1)],10,CB)],46,wB))}},_0=nn(MB,[["__scopeId","data-v-dbdea151"]]);Et(),an();var LB={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},DB={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=Ai(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(ge(),Se("div",LB,[Le("div",{class:"separator-inner",style:un({backgroundColor:r()})},null,4)]))}},PB=nn(DB,[["__scopeId","data-v-cb82253a"]]);Et(),an();var FB={class:"overflow-menu"},OB={class:"overflow-menu-trigger"},BB={key:0,class:"overflow-menu_items",role:"group"},NB={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=Zn(),r=t,o=e,i=ke(()=>o.toolbarItem.expand.value),s=ee(!1),a=ke(()=>({...o.toolbarItem,active:i.value})),l=()=>{r("buttonClick",o.toolbarItem)},u=({item:d,argument:h})=>{n.$toolbar.emitCommand({item:d,argument:h})},c=d=>{d.key==="Escape"&&i.value&&!s.value&&(d.preventDefault(),r("close"))};return An(()=>{document.addEventListener("keydown",c,!0)}),Qn(()=>{document.removeEventListener("keydown",c,!0)}),(d,h)=>(ge(),Se("div",FB,[Le("div",OB,[Ht(_0,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),i.value?(ge(),Se("div",BB,[Ht(Up,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:u,onDropdownUpdateShow:h[0]||(h[0]=m=>s.value=m)},null,8,["toolbar-items"])])):ct("",!0)]))}},zB=nn(NB,[["__scopeId","data-v-504ecd05"]]);Et(),an();var HB={class:"toolbar-dropdown"},UB=["onClick"],VB={key:0,class:"toolbar-dropdown-option__icon"},jB={class:"toolbar-dropdown-option__label"},Np='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',GB={__name:"ToolbarDropdown",props:{options:{type:Array,default:()=>[]},show:{type:Boolean,required:!0},placement:{type:String,default:"bottom-start"},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})},menuProps:{type:Function,default:null},nodeProps:{type:Function,default:null}},emits:["update:show","select"],setup(e,{emit:t}){const n=e,r=t,o=ee(null),i=ee(null),s=ee({top:"0px",left:"0px",maxHeight:"none"}),a=ee([]),l=ee(-1),u=ke(()=>!!n.show),c=ke(()=>n.options.some(ie=>ie?.type==="render")),d=ke(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),h=ke(()=>{const{class:ie,style:Te,...Ge}=d.value;return Ge}),m=ke(()=>{const ie=d.value.class,Te=n.options.length>0&&n.options.every(Ge=>Ge&&Ge.type==="render");return["toolbar-dropdown-menu",ie,{"toolbar-dropdown-menu--render-only":Te}]}),p=ke(()=>{const ie=d.value.style||{};return{...n.contentStyle,...ie}}),g=ke(()=>({...p.value,position:"fixed",top:s.value.top,left:s.value.left,maxHeight:s.value.maxHeight,zIndex:2e3})),C=ie=>{r("update:show",ie)},_=()=>{u.value&&C(!1)},k=()=>{if(!o.value)return;const ie=o.value.getBoundingClientRect(),Te=i.value,Ge=Te?.offsetWidth??0,$e=Te?.scrollHeight??Te?.offsetHeight??0,ot=window.innerWidth||document.documentElement.clientWidth||0,xe=window.innerHeight||document.documentElement.clientHeight||0,Me=8,De=4,J=ie.bottom+De,w=ie.top-De,ne=Math.max(0,xe-J-Me),F=Math.max(0,w-Me),V=ne<$e&&F>ne,U=V?F:ne,G=$e?Math.min($e,U):U,Q=V?Math.max(Me,w-G):J;let K=ie.left;n.placement==="bottom-end"&&(K=ie.right-Ge);const W=Math.max(Me,ot-Ge-Me);K=Math.min(Math.max(Me,K),W),s.value={top:`${Q}px`,left:`${K}px`,maxHeight:`${U}px`}},y=()=>{n.disabled||C(!u.value)},b=ie=>typeof n.nodeProps!="function"?{}:n.nodeProps(ie)||{},x=ie=>{ie?.disabled||ie?.type!=="render"&&(r("select",ie?.key,ie),_())},R=ie=>ie?.type==="render",D=ie=>!ie?.disabled&&ie?.type!=="render",H=ie=>typeof ie?.icon=="function"||!!ie?.icon,B=ie=>typeof ie?.icon=="function"?ie.icon(ie):ie?.icon||null,z=ie=>ie?typeof ie=="string"?ie.split(/\s+/).includes("sd-selected"):Array.isArray(ie)?ie.some(z):typeof ie=="object"?!!ie["sd-selected"]:!1:!1,Y=ie=>z(ie?.props?.class)||z(ie?.class),O=()=>n.options.map((ie,Te)=>D(ie)?Te:-1).filter(ie=>ie>=0),M=()=>{const ie=n.options.findIndex(Te=>D(Te)&&Y(Te));return ie>=0?ie:O()[0]??-1},A=(ie,Te)=>{if(!ie){delete a.value[Te];return}a.value[Te]=ie},N=()=>{a.value.forEach((Te,Ge)=>{Te&&Te.setAttribute("tabindex",Ge===l.value?"0":"-1")});const ie=a.value[l.value];ie&&typeof ie.focus=="function"&&(ie.focus(),ie.scrollIntoView?.({block:"nearest",inline:"nearest"}))},X=ie=>{const Te=O();if(!Te.length){l.value=-1;return}const Ge=Te.indexOf(l.value);if(Ge<0){l.value=ie>0?Te[0]:Te[Te.length-1];return}l.value=Te[(Ge+ie+Te.length)%Te.length]},te=()=>{let ie=n.options[l.value];if(!D(ie)){const Te=O()[0];ie=Te===void 0?null:n.options[Te]}ie&&x(ie)},ae=Al({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(ie){return()=>typeof ie.option.render!="function"?null:ie.option.render()}}),me=Al({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(ie){return()=>B(ie.option)}}),He=ie=>{if(!u.value)return;const Te=ie.target;if(!(Te instanceof Element))return;const Ge=o.value?.contains(Te),$e=i.value?.contains(Te);Ge||$e||_()},ce=ee(null),ve=()=>{const ie=o.value,Te=document.activeElement;if(ie&&Te instanceof HTMLElement&&ie.contains(Te)){ce.value=Te;return}ce.value=ie?.matches?.(Np)?ie:ie?.querySelector(Np)},ue=()=>{const ie=ce.value;if(ie instanceof HTMLElement&&document.contains(ie)){ie.focus();return}const Te=o.value;if(!Te)return;const Ge=Te.matches?.(Np)?Te:Te.querySelector(Np);if(Ge instanceof HTMLElement){Ge.focus();return}Te.setAttribute("tabindex","-1"),Te.focus()},_e=ie=>{if(!u.value)return;const{key:Te}=ie;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(Te)){if(Te==="Escape"){ie.preventDefault(),_(),St(()=>{requestAnimationFrame(ue)});return}if(!c.value){if(ie.preventDefault(),Te==="ArrowDown"){X(1),N();return}if(Te==="ArrowUp"){X(-1),N();return}Te==="Enter"&&te()}}};return Mt(u,async ie=>{if(!ie){l.value=-1,a.value=[];return}ve(),await St(),k(),!c.value&&(l.value=M(),await St(),N())},{immediate:!0}),Mt(u,ie=>{ie?(document.addEventListener("pointerdown",He,!0),document.addEventListener("keydown",_e,!0),window.addEventListener("resize",k),window.addEventListener("scroll",k,!0)):(document.removeEventListener("pointerdown",He,!0),document.removeEventListener("keydown",_e,!0),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0))},{immediate:!0}),Qn(()=>{document.removeEventListener("pointerdown",He,!0),document.removeEventListener("keydown",_e,!0),window.removeEventListener("resize",k),window.removeEventListener("scroll",k,!0)}),(ie,Te)=>(ge(),Se("div",HB,[Le("div",{ref_key:"triggerRef",ref:o,class:"toolbar-dropdown-trigger","data-sd-part":"dropdown-trigger",onClick:y},[td(ie.$slots,"trigger",{},void 0,!0)],512),(ge(),tn(Aa,{to:"body"},[Ht(bh,{name:"fade-in-scale-up-transition"},{default:ho(()=>[u.value?(ge(),Se("div",Wi({key:0,ref_key:"menuRef",ref:i,"data-sd-part":"dropdown-menu",class:m.value,style:g.value},h.value),[(ge(!0),Se(Vt,null,Xn(e.options,(Ge,$e)=>(ge(),Se("div",Wi({key:Ge.key,ref_for:!0,ref:ot=>A(ot,$e),class:["toolbar-dropdown-option",[Ge.class,Ge.props?.class,{"sd-disabled":Ge.disabled,"sd-render":R(Ge)}]],tabindex:"-1",onClick:ot=>x(Ge)},{ref_for:!0},{...Ge.props,...b(Ge)}),[R(Ge)?(ge(),tn(Xe(ae),{key:0,option:Ge},null,8,["option"])):(ge(),Se(Vt,{key:1},[H(Ge)?(ge(),Se("span",VB,[Ht(Xe(me),{option:Ge},null,8,["option"])])):ct("",!0),Le("span",jB,Ft(Ge.label),1)],64))],16,UB))),128))],16)):ct("",!0)]),_:1})]))]))}},WB=nn(GB,[["__scopeId","data-v-fef410f7"]]),gk=e=>String(e??"").trim().toLowerCase();const zp=(e,t)=>{const n=gk(e);if(!n)return-1;for(let r=0;r<t.length;r+=1)if(gk(t[r]).startsWith(n))return r;return-1},KB=(e,t,{autocomplete:n=!0}={})=>{const r=String(e??""),o=zp(r,t),i=o>=0?String(t[o]??""):"";return n&&o>=0&&i.length>r.length?{matchIndex:o,display:i,selectionStart:r.length,selectionEnd:i.length}:{matchIndex:o,display:r,selectionStart:r.length,selectionEnd:r.length}};var qB=e=>{let t=String(e??"").trim();for(;t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"));)t=t.slice(1,-1).trim();return t},YB=e=>e<=31||e===127,XB=e=>e===32||e===160||e===65279,QB=e=>Array.from(String(e)).filter(t=>!YB(t.charCodeAt(0))).join(""),ZB=e=>{let t="",n=!1;for(const r of String(e)){if(XB(r.charCodeAt(0))){n=t.length>0;continue}n&&(t+=" "),n=!1,t+=r}return t};const JB=e=>ZB(qB(QB(String(e??"").split(",")[0]??""))).trim();var $B=1,eN=1638;const tN=e=>{const t=String(e??"").replace(/[^0-9.-]/g,""),n=Number.parseFloat(t);if(!Number.isFinite(n))return"";const r=Math.round(n*2)/2;return r<$B?"":String(Math.min(r,eN))};Et(),an();var nN=["data-item"],rN=["id","value","disabled","aria-label","aria-expanded","aria-controls","aria-activedescendant","data-item"],oN=["data-item","aria-label","disabled"],iN=["innerHTML"],sN=["id","aria-label"],aN=["id","aria-selected","aria-label","onMousedown","onMouseenter"],lN={class:"toolbar-dropdown-option__label"},cN={class:"sd-button-label sd-font-combobox__legacy-label","aria-hidden":"true"},uN={__name:"ToolbarComboBox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},showPreview:{type:Boolean,default:!1},normalizeValue:{type:Function,default:e=>String(e??"").trim()}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t,{isHighContrastMode:o}=Ai(),i=ee(null),s=ee(null),a=ee(null),l=ee([]),u=ee(!1),c=ee(!1),d=ee(-1),h=ee(""),m=ee(""),p=ee(!1),g=ee({top:"0px",left:"0px",minWidth:"0px",maxHeight:"none"}),C=ke(()=>n.item.nestedOptions?.value??[]),_=ke(()=>C.value.map(K=>String(K?.label??""))),k=ke(()=>String(n.item.label?.value??"")),y=ke(()=>!!n.item.disabled?.value),b=ke(()=>String(n.item.name?.value??"")),x=ke(()=>n.item.attributes?.value?.ariaLabel??"Font family"),R=ke(()=>u.value?m.value:k.value),D=ke(()=>`sd-${b.value||"combobox"}-listbox-${n.item.id?.value??"default"}`),H=K=>`${D.value}-option-${K}`,B=ke(()=>c.value&&d.value>=0?H(d.value):void 0),z=ke(()=>c.value?Wn.dropdownCaretUp:Wn.dropdownCaretDown),Y=K=>{const W=String(K??"").trim().toLowerCase();return C.value.find(de=>String(de?.label??"").trim().toLowerCase()===W)?.props?.style?.fontFamily||K||n.uiFontFamily},O=ke(()=>n.showPreview?{fontFamily:Y(u.value?m.value:k.value)}:{fontFamily:n.uiFontFamily}),M=()=>{const K=n.item.selectedValue?.value;if(K){const W=C.value.findIndex(de=>de?.key===K);if(W>=0)return W}return _.value.findIndex(W=>W.toLowerCase()===k.value.toLowerCase())},A=(K,W)=>{const de=i.value;if(!(!de||typeof de.setSelectionRange!="function"))try{de.setSelectionRange(K,W)}catch{}},N=()=>{l.value[d.value]?.scrollIntoView?.({block:"nearest",inline:"nearest"})},X=()=>{l.value[d.value]?.focus?.()},te=()=>{const K=s.value;if(!K)return;const W=K.getBoundingClientRect(),de=a.value,Ce=de?.scrollHeight??de?.offsetHeight??0,be=window.innerHeight||document.documentElement.clientHeight||0,Be=window.innerWidth||document.documentElement.clientWidth||0,rt=8,nt=4,wt=W.bottom+nt,Nt=W.top-nt,_t=Math.max(0,be-wt-rt),Tt=Math.max(0,Nt-rt),Dt=_t<Ce&&Tt>_t,rn=Dt?Tt:_t,mn=Ce?Math.min(Ce,rn):rn,Ut=Dt?Math.max(rt,Nt-mn):wt,Ke=Math.min(Math.max(rt,W.left),Math.max(rt,Be-W.width-rt));g.value={top:`${Ut}px`,left:`${Ke}px`,minWidth:`${W.width}px`,maxHeight:`${rn}px`}},ae=ke(()=>({position:"fixed",top:g.value.top,left:g.value.left,minWidth:g.value.minWidth,maxHeight:g.value.maxHeight,fontFamily:n.uiFontFamily,zIndex:2e3})),me=K=>{n.item.expand&&typeof n.item.expand=="object"&&"value"in n.item.expand&&(n.item.expand.value=K)},He=(K,{focusInput:W=!1,focusOption:de=!1}={})=>{if(y.value||!C.value.length){me(!1);return}c.value=!0,me(!0),d.value=K??-1,W&&(u.value=!0,m.value=k.value,i.value?.focus()),St(()=>{te(),N(),de&&X()})},ce=({syncItem:K=!0}={})=>{c.value=!1,d.value=-1,K&&me(!1)},ve=()=>{ce(),u.value=!1,h.value="",m.value=k.value},ue=()=>{y.value||(c.value||r("item-clicked"),u.value=!0,h.value="",m.value=k.value,St(()=>A(0,m.value.length)))},_e=K=>{if(y.value)return;const W=document.activeElement===i.value;if(r("item-clicked"),u.value=!0,W||(h.value="",m.value=k.value,K.preventDefault(),i.value?.focus(),A(0,k.value.length)),!c.value){const de=M();He(de>=0?de:0)}},ie=K=>{const W=K.relatedTarget;W instanceof Node&&s.value?.contains(W)||W instanceof Node&&a.value?.contains(W)||ve()},Te=K=>{if(p.value)return;const W=K.target,de=W.value,Ce=typeof W.selectionStart=="number"?W.selectionStart:de.length,be=typeof W.selectionEnd=="number"?W.selectionEnd:Ce,Be=typeof K.inputType=="string"&&K.inputType.startsWith("delete"),rt=Ce===de.length&&be===de.length;h.value=de;const nt=KB(de,_.value,{autocomplete:!Be&&rt});m.value=nt.display,W.value=nt.display,nt.display===de&&!rt?A(Ce,be):A(nt.selectionStart,nt.selectionEnd),c.value&&(d.value=nt.matchIndex,St(N))},Ge=K=>{p.value=!1,Te(K)},$e=K=>{if(!C.value.length)return;const W=C.value.length;d.value=((d.value<0?K>0?-1:0:d.value)+K+W)%W,St(N)},ot=(K,W)=>{r("item-clicked"),r("command",{item:n.item,argument:K,option:W}),W&&(n.item.selectedValue.value=W.key)},xe=K=>{K&&(ot(K.label,K),u.value=!1,h.value="",m.value=K.label,ce())},Me=()=>{if(c.value&&d.value>=0)return xe(C.value[d.value]),!0;const K=zp(h.value,_.value);if(K>=0)return xe(C.value[K]),!0;const W=n.normalizeValue(h.value);return W?(ot(W,null),u.value=!1,h.value="",m.value=W,ce(),!0):!1},De=K=>{if(!(K.isComposing||p.value||K.keyCode===229)&&!(K.ctrlKey||K.metaKey||K.altKey))switch(K.key){case"ArrowDown":if(K.preventDefault(),c.value)X();else{const W=zp(h.value,_.value),de=W>=0?W:M();He(de>=0?de:0,{focusOption:!0})}break;case"ArrowUp":if(K.preventDefault(),c.value)X();else{const W=zp(h.value,_.value),de=W>=0?W:M();He(de>=0?de:C.value.length-1,{focusOption:!0})}break;case"Enter":K.preventDefault(),Me()&&r("editor-handoff"),i.value?.blur();break;case"Tab":K.preventDefault(),Me(),ce(),i.value?.blur(),r("tab-out",K);break;case"Escape":K.preventDefault(),ve(),St(()=>i.value?.focus());break;default:break}},J=K=>{if(K.preventDefault(),!y.value)if(r("item-clicked"),c.value)ce(),i.value?.focus();else{const W=M();He(W>=0?W:0,{focusOption:!0})}},w=(K,W)=>{K.preventDefault(),xe(W),r("editor-handoff"),i.value?.blur()},ne=K=>{d.value=K},F=K=>{if(!(K.ctrlKey||K.metaKey||K.altKey))switch(K.key){case"ArrowDown":K.preventDefault(),$e(1),X();break;case"ArrowUp":K.preventDefault(),$e(-1),X();break;case"Enter":K.preventDefault(),d.value>=0&&(xe(C.value[d.value]),r("editor-handoff"));break;case"Escape":K.preventDefault(),ve(),St(()=>i.value?.focus());break;case"Tab":K.preventDefault(),d.value>=0?xe(C.value[d.value]):ce(),r("tab-out",{shiftKey:K.shiftKey,target:i.value});break;default:break}},V=K=>{if(!c.value)return;const W=K.target;W instanceof Element&&(s.value?.contains(W)||a.value?.contains(W)||ve())};Mt(c,K=>{K?(document.addEventListener("pointerdown",V,!0),window.addEventListener("resize",te),window.addEventListener("scroll",te,!0)):(document.removeEventListener("pointerdown",V,!0),window.removeEventListener("resize",te),window.removeEventListener("scroll",te,!0),l.value=[])},{immediate:!0}),Qn(()=>{document.removeEventListener("pointerdown",V,!0),window.removeEventListener("resize",te),window.removeEventListener("scroll",te,!0)});const U=(K,W)=>{if(!K){delete l.value[W];return}l.value[W]=K},G=K=>K===d.value,Q=K=>K?.key&&K.key===n.item.selectedValue?.value;return Mt(k,K=>{u.value||(m.value=K)}),Mt(()=>!!n.item.expand?.value,K=>{if(K&&!c.value){const W=M();He(W>=0?W:0,{focusInput:!0});return}!K&&c.value&&ce({syncItem:!1})}),(K,W)=>(ge(),Se("div",{ref_key:"rootRef",ref:s,class:Xt(["sd-font-combobox sd-toolbar-split-field",{"sd-disabled":y.value,"high-contrast":Xe(o)}]),style:un(n.item.style?.value),"data-item":`btn-${b.value}`},[Le("span",{class:"sd-font-combobox__field sd-toolbar-split-field__main",onMousedown:_e},[Le("input",{ref_key:"inputRef",ref:i,id:`inlineTextInput-${b.value}`,class:"button-text-input sd-font-combobox__input",type:"text",role:"combobox",autocomplete:"off",spellcheck:"false",value:R.value,style:un(O.value),disabled:y.value,"aria-label":x.value,"aria-expanded":c.value?"true":"false","aria-controls":D.value,"aria-activedescendant":B.value,"aria-haspopup":"listbox","aria-autocomplete":"both","data-item":`btn-${b.value}-input`,onFocus:ue,onBlur:ie,onInput:Te,onKeydown:De,onCompositionstart:W[0]||(W[0]=de=>p.value=!0),onCompositionend:Ge},null,44,rN)],32),Le("button",{type:"button",class:"sd-font-combobox__caret sd-toolbar-split-field__caret","data-item":`btn-${b.value}-toggle`,tabindex:"-1","aria-label":`${x.value} options`,disabled:y.value,onMousedown:J},[Le("span",{class:"sd-dropdown-caret",innerHTML:z.value},null,8,iN)],40,oN),(ge(),tn(Aa,{to:"body"},[c.value?(ge(),Se("div",{key:0,ref_key:"popupRef",ref:a,role:"listbox",id:D.value,"aria-label":x.value,class:Xt(["sd-font-combobox__listbox",{"high-contrast":Xe(o)}]),style:un(ae.value)},[(ge(!0),Se(Vt,null,Xn(C.value,(de,Ce)=>(ge(),Se("div",Wi({key:de.key,ref_for:!0,ref:be=>U(be,Ce),id:H(Ce),role:"option",tabindex:"-1",class:["toolbar-dropdown-option sd-font-combobox__option",{"sd-active":G(Ce),"sd-selected":Q(de)}],"aria-selected":Q(de)?"true":"false","aria-label":`${x.value} - ${de.label}`},{ref_for:!0},de.props,{onMousedown:be=>w(be,de),onMouseenter:be=>ne(Ce),onKeydown:F}),[Le("span",lN,Ft(de.label),1)],16,aN))),128))],14,sN)):ct("",!0)])),Le("span",cN,Ft(k.value),1)],14,nN))}},vk=nn(uN,[["__scopeId","data-v-c08c573e"]]);Et();var dN={__name:"FontFamilyCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(ge(),tn(vk,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!0,"normalize-value":Xe(JB),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}},fN=dN;Et();var hN={__name:"FontSizeCombobox",props:{item:{type:Object,required:!0},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"}},emits:["command","item-clicked","tab-out","editor-handoff"],setup(e,{emit:t}){const n=e,r=t;return(o,i)=>(ge(),tn(vk,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!1,"normalize-value":Xe(tN),onCommand:i[0]||(i[0]=s=>r("command",s)),onItemClicked:i[1]||(i[1]=s=>r("item-clicked")),onTabOut:i[2]||(i[2]=s=>r("tab-out",s)),onEditorHandoff:i[3]||(i[3]=s=>r("editor-handoff"))},null,8,["item","ui-font-family","normalize-value"]))}},pN=hN;Et(),an();var mN=2500,gN=Object.assign({inheritAttrs:!1},{__name:"SdTooltip",props:{trigger:{type:String,default:"hover"},delay:{type:Number,default:100},duration:{type:Number,default:100},disabled:{type:Boolean,default:!1},contentStyle:{type:Object,default:()=>({})}},setup(e){const t=e,n=ob(),r=ee(!1),o=ee(null),i=ee(null),s=ee({top:"0px",left:"0px"});let a=null,l=null,u=null;const c=ke(()=>["sd-tooltip-content",n.class]),d=ke(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),h=()=>{a&&(window.clearTimeout(a),a=null)},m=()=>{l&&(window.clearTimeout(l),l=null)},p=()=>{u&&(window.clearTimeout(u),u=null)},g=()=>{p(),u=window.setTimeout(()=>{u=null,k()},mN)},C=()=>{if(!o.value||!i.value)return;const z=o.value.getBoundingClientRect(),Y=i.value.offsetWidth,O=i.value.offsetHeight,M=window.innerWidth||document.documentElement.clientWidth||0,A=8;let N=z.left+z.width/2-Y/2;N=Math.max(A,Math.min(N,M-Y-A)),s.value={top:`${z.top-O-10}px`,left:`${N}px`}},_=async()=>{t.disabled||(h(),m(),!r.value&&(r.value=!0,g(),await St(),C()))},k=()=>{m(),h(),p(),r.value&&(r.value=!1)},y=()=>{if(h(),m(),!r.value){if(t.delay===0){_();return}l=window.setTimeout(()=>{l=null,_()},t.delay)}},b=()=>{if(m(),h(),!!r.value){if(t.duration===0){k();return}a=window.setTimeout(()=>{a=null,k()},t.duration)}},x=()=>{t.trigger==="hover"&&y()},R=()=>{t.trigger==="hover"&&b()},D=()=>{m(),h()},H=()=>{b()},B=z=>{z.key==="Escape"&&k()};return Mt(()=>t.disabled,z=>{z&&k()}),Mt(r,z=>{z?(window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),document.addEventListener("keydown",B,!0)):(window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0),document.removeEventListener("keydown",B,!0))}),Qn(()=>{m(),h(),p(),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0),document.removeEventListener("keydown",B,!0)}),(z,Y)=>(ge(),Se(Vt,null,[Le("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:x,onMouseleave:R,onFocusin:x,onFocusout:R},[td(z.$slots,"trigger",{},void 0,!0)],544),(ge(),tn(Aa,{to:"body"},[Ht(bh,{name:"fade-in-scale-up-transition"},{default:ho(()=>[r.value&&!e.disabled?(ge(),Se("div",{key:0,ref_key:"contentRef",ref:i,class:Xt(c.value),style:un(d.value),onMouseenter:D,onMouseleave:H},[Y[0]||(Y[0]=Le("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),td(z.$slots,"default",{},void 0,!0)],38)):ct("",!0)]),_:3})]))],64))}}),Hp=nn(gN,[["__scopeId","data-v-2a872eae"]]);Et(),an();var vN=["onKeydown","tabindex","data-item-id"],yN={key:0},bN={key:0},wN={key:0},CN={key:0},_N={key:0},SN={__name:"ButtonGroup",props:{toolbarItems:{type:Array,required:!0},overflowItems:{type:Array,default:()=>[]},uiFontFamily:{type:String,default:"Arial, Helvetica, sans-serif"},position:{type:String,default:"left"},fromOverflow:{type:Boolean,default:!1},compactSideGroups:{type:Boolean,default:!1}},emits:["command","item-clicked","dropdown-update-show"],setup(e,{emit:t}){const n=t,{proxy:r}=Zn(),o=ee([]),i=ee(null),s=e,a=ee(null),{isHighContrastMode:l}=Ai(),u=window.matchMedia("(max-width: 768px)").matches,c=ke(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:u?0:1,justifyContent:"center"}),d=xe=>xe.type==="button",h=xe=>xe.type==="dropdown",m=xe=>xe.type==="dropdown"&&xe.name?.value==="fontFamily",p=xe=>xe.type==="dropdown"&&xe.name?.value==="fontSize",g=xe=>xe.type==="separator",C=xe=>xe.type==="overflow",_=xe=>!!xe.nestedOptions?.value?.length,k=xe=>{if(!xe)return!1;const Me=xe.expand;return typeof Me=="object"&&Me!==null&&"value"in Me?!!Me.value:!!Me},y=(xe,Me)=>{xe?.expand&&(xe.expand.value=Me)},b=(xe,Me=void 0)=>{if(xe.disabled.value)return;if(C(xe)){const J=!k(xe);J&&D(),y(xe,J),a.value=J?xe:null,n("item-clicked");return}if(h(xe))return;a.value&&h(a.value)&&k(a.value)&&D(),n("item-clicked");const De=Me!==void 0?Me:xe.argument?.value;n("command",De===void 0?{item:xe}:{item:xe,argument:De})},x=(xe,Me)=>{xe.disabled.value||(a.value=null,n("command",{item:xe,argument:Me}))},R=xe=>{if(xe.disabled.value)return;D();const Me=xe.splitButtonCommand,De=xe.command,J=Me||De;if(!J)return;const w={...xe,command:J};n("item-clicked"),n("command",{item:w})},D=()=>{const xe=r?.$toolbar?.toolbarItems||[],Me=r?.$toolbar?.overflowItems||[],De=[...xe,...Me];(De.length?De:s.toolbarItems).forEach(J=>{const w=C(J)&&!s.fromOverflow;(h(J)||w)&&y(J,!1)}),a.value=null},H=(xe,Me)=>{D(),n("command",{item:xe,argument:xe.dropdownValueKey.value?Me[xe.dropdownValueKey.value]:Me.label,option:Me}),xe.selectedValue.value=Me.key},B=xe=>{n("command",xe)},z=()=>{D(),n("item-clicked")},Y=()=>{const xe=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return xe instanceof HTMLElement?(xe.focus({preventScroll:!0}),!0):!1},O=()=>{const xe=r?.$toolbar?.pendingSelectionCapture,Me=()=>{xe&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(xe)};if(Y()){Me();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),Me())},M=xe=>!(xe instanceof HTMLElement)||xe.classList.contains("sd-disabled")?null:xe.querySelector("input:not([disabled]), textarea:not([disabled]), select:not([disabled])")||xe.querySelector('button:not([disabled]), [role="button"]:not(.sd-disabled), [tabindex]:not([tabindex="-1"])'),A=(xe,Me)=>{const De=xe?.target?.closest?.(".sd-toolbar-item-ctn");if(!(De instanceof HTMLElement))return!1;let J=Me>0?De.nextElementSibling:De.previousElementSibling;for(;J;){const w=M(J);if(w instanceof HTMLElement)return De.setAttribute("tabindex","-1"),J.setAttribute("tabindex","0"),w.focus(),!0;J=Me>0?J.nextElementSibling:J.previousElementSibling}return!1},N=xe=>{D(),A(xe,xe?.shiftKey?-1:1)||O()},X=xe=>{if(D(),xe?.shiftKey){A(xe,-1)||O();return}O()},te=()=>{O()},ae=xe=>xe.nestedOptions?.value?.length?xe.nestedOptions.value.map(Me=>{const De=Me?.type!=="render"&&xe.selectedValue.value===Me.key;return{...Me,props:{...Me.props,class:De?"sd-selected":""}}}):[],me=(xe,Me)=>({role:"menuitem",ariaLabel:`${Me.attributes.value.ariaLabel} - ${xe.label}`}),He=xe=>{const Me=xe.target,De=xe.target.closest(".sd-toolbar-item-ctn").nextElementSibling;De&&(Me.setAttribute("tabindex","-1"),De.setAttribute("tabindex","0"),De.focus())},ce=xe=>{const Me=xe.target,De=xe.target.closest(".sd-toolbar-item-ctn").previousElementSibling;De&&(Me.setAttribute("tabindex","-1"),De.setAttribute("tabindex","0"),De.focus())},ve=xe=>{const Me=xe.target.closest(".button-group").nextElementSibling;if(Me)Me.setAttribute("tabindex","0"),Me.focus();else{const De=document.querySelector(".ProseMirror");De&&De.focus()}},ue=xe=>{const Me=xe.target.closest(".button-group").previousElementSibling;Me&&(Me.setAttribute("tabindex","0"),Me.focus())},_e=xe=>{if(!xe.disabled.value){if(h(xe)){Ge(!k(xe),xe);return}b(xe)}},ie=(xe,Me)=>{const De=xe.target.nodeName==="INPUT"||xe.target.nodeName==="TEXTAREA",J=Me.name.value==="fontSize"||Me.name.value==="fontFamily";if(!(De&&J)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(xe.key))switch(xe.preventDefault(),xe.key){case"Enter":case" ":case"Spacebar":_e(Me);break;case"Escape":D();break;case"ArrowRight":D(),He(xe);break;case"ArrowLeft":D(),ce(xe);break;case"Tab":xe.shiftKey?ue(xe):ve(xe);break;default:break}},Te=xe=>{const Me=o.value.find(De=>!De.classList.contains("sd-disabled"));Me&&(Me.setAttribute("tabindex","0"),Me.focus())},Ge=(xe,Me)=>{if(n("item-clicked"),!xe){D(),n("dropdown-update-show",!1);return}D(),a.value=Me,y(Me,!0),n("dropdown-update-show",!0)},$e=xe=>{if(!a.value)return;const Me=xe.target;Me instanceof Element&&(Me.closest(".sd-toolbar-dropdown-menu")||i.value?.contains(Me)||D())};return Mt(()=>k(a.value),xe=>{xe?document.addEventListener("pointerdown",$e,!0):document.removeEventListener("pointerdown",$e,!0)},{immediate:!0}),Qn(()=>{document.removeEventListener("pointerdown",$e,!0)}),(xe,Me)=>(ge(),Se("div",{style:un(c.value),class:"button-group",role:"group",onFocus:Te,ref_key:"buttonGroupRef",ref:i},[(ge(!0),Se(Vt,null,Xn(e.toolbarItems,(De,J)=>(ge(),Se("div",{key:De.id.value,class:Xt([{narrow:De.isNarrow.value,wide:De.isWide.value,"sd-disabled":De.disabled.value},"sd-toolbar-item-ctn"]),onKeydown:w=>ie(w,De),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:J===0?0:-1,"data-item-id":De.id.value},[g(De)?(ge(),tn(PB,{key:0,style:{width:"20px"}})):ct("",!0),m(De)&&_(De)?(ge(),tn(Hp,{key:1,trigger:"hover",disabled:!De.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[Ht(fN,{item:De,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:B,onItemClicked:z,onTabOut:Me[0]||(Me[0]=w=>N(w)),onEditorHandoff:te},null,8,["item","ui-font-family"])]),default:ho(()=>[Le("div",null,[Ci(Ft(De.tooltip)+" ",1),De.disabled.value?(ge(),Se("span",yN,"(disabled)")):ct("",!0)])]),_:2},1032,["disabled","content-style"])):p(De)&&_(De)?(ge(),tn(Hp,{key:2,trigger:"hover",disabled:!De.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[Ht(pN,{item:De,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:B,onItemClicked:z,onTabOut:Me[1]||(Me[1]=w=>X(w)),onEditorHandoff:te},null,8,["item","ui-font-family"])]),default:ho(()=>[Le("div",null,[Ci(Ft(De.tooltip)+" ",1),De.disabled.value?(ge(),Se("span",bN,"(disabled)")):ct("",!0)])]),_:2},1032,["disabled","content-style"])):h(De)&&De.nestedOptions?.value?.length?(ge(),tn(WB,{key:3,options:ae(De),disabled:De.disabled.value,show:k(De),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"sd-toolbar-button sd-editor-toolbar-dropdown",onSelect:(w,ne)=>H(De,ne),"onUpdate:show":w=>Ge(w,De),style:un(De.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":Xe(l)}]}),"node-props":w=>me(w,De)},{trigger:ho(()=>[Ht(Hp,{trigger:"hover",disabled:!De.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[Ht(_0,{"toolbar-item":De,disabled:De.disabled.value,"allow-enter-propagation":!0,onTextSubmit:w=>x(De,w),onMainClick:w=>R(De)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:ho(()=>[Le("div",null,[Ci(Ft(De.tooltip)+" ",1),De.disabled.value?(ge(),Se("span",wN,"(disabled)")):ct("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):d(De)?(ge(),tn(Hp,{key:4,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:ho(()=>[Ht(_0,{"toolbar-item":De,"is-overflow-item":e.fromOverflow,onTextSubmit:w=>x(De,w),onButtonClick:w=>b(De)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:ho(()=>[De.tooltip?(ge(),Se("div",CN,[Ci(Ft(De.tooltip)+" ",1),De.disabled.value?(ge(),Se("span",_N,"(disabled)")):ct("",!0)])):ct("",!0)]),_:2},1032,["content-style"])):ct("",!0),C(De)&&e.overflowItems.length?(ge(),tn(zB,{key:5,"toolbar-item":De,onButtonClick:w=>b(De),"overflow-items":e.overflowItems,onClose:D},null,8,["toolbar-item","onButtonClick","overflow-items"])):ct("",!0)],42,vN))),128))],36))}},Up=nn(SN,[["__scopeId","data-v-590293ab"]]),kN=[["Arial","sans-serif"],["Arial Black","sans-serif"],["Arial Narrow","sans-serif"],["Baskerville Old Face","serif"],["Bookman Old Style","serif"],["Brush Script MT","cursive"],["Calibri","sans-serif"],["Century","serif"],["Century Gothic","sans-serif"],["Comic Sans MS","sans-serif"],["Cooper Black","serif"],["Courier New","monospace"],["Garamond","serif"],["Georgia","serif"],["Gill Sans MT Condensed","sans-serif"],["Helvetica","sans-serif"],["Lucida Console","monospace"],["Segoe UI","sans-serif"],["Tahoma","sans-serif"],["Times New Roman","serif"],["Trebuchet MS","sans-serif"],["Verdana","sans-serif"]];const AN=kN.map(([e,t])=>({label:e,key:e,fontWeight:400,props:{style:{fontFamily:`${e}, ${t}`},"data-item":"btn-fontFamily-option"}}));function IN(e){if(e?.length)return e.map(t=>({label:t.label,key:t.value,fontWeight:400,props:{style:{fontFamily:t.previewFamily||t.label},"data-item":"btn-fontFamily-option"}}))}const EN=[{label:"8",key:"8pt",props:{"data-item":"btn-fontSize-option"}},{label:"9",key:"9pt",props:{"data-item":"btn-fontSize-option"}},{label:"10",key:"10pt",props:{"data-item":"btn-fontSize-option"}},{label:"11",key:"11pt",props:{"data-item":"btn-fontSize-option"}},{label:"12",key:"12pt",props:{"data-item":"btn-fontSize-option"}},{label:"14",key:"14pt",props:{"data-item":"btn-fontSize-option"}},{label:"18",key:"18pt",props:{"data-item":"btn-fontSize-option"}},{label:"24",key:"24pt",props:{"data-item":"btn-fontSize-option"}},{label:"30",key:"30pt",props:{"data-item":"btn-fontSize-option"}},{label:"36",key:"36pt",props:{"data-item":"btn-fontSize-option"}},{label:"48",key:"48pt",props:{"data-item":"btn-fontSize-option"}},{label:"60",key:"60pt",props:{"data-item":"btn-fontSize-option"}},{label:"72",key:"72pt",props:{"data-item":"btn-fontSize-option"}},{label:"96",key:"96pt",props:{"data-item":"btn-fontSize-option"}}],pf={sm:768,md:1024,lg:1280,xl:1410},S0={undo:"undo",redo:"redo",bold:"bold",italic:"italic",underline:"underline",strike:"strikethrough",acceptTrackedChangeBySelection:"track-changes-accept-selection",rejectTrackedChangeOnSelection:"track-changes-reject-selection",ruler:"ruler",formattingMarks:"formatting-marks",zoom:"zoom",measurementUnit:"measurement-unit",documentMode:"document-mode",link:"link",fontFamily:"font-family",fontSize:"font-size",list:"bullet-list",numberedlist:"numbered-list",table:"table-insert",image:"image",tableOfContents:"table-of-contents-insert",color:"text-color",highlight:"highlight-color",textAlign:"text-align",lineHeight:"line-height",linkedStyles:"linked-style",indentleft:"indent-decrease",indentright:"indent-increase",directionLtr:"direction-ltr",directionRtl:"direction-rtl",clearFormatting:"clear-formatting",copyFormat:"copy-format"},yk={addRowBefore:"table-add-row-before",addRowAfter:"table-add-row-after",deleteRow:"table-delete-row",addColumnBefore:"table-add-column-before",addColumnAfter:"table-add-column-after",deleteColumn:"table-delete-column",deleteTable:"table-delete",deleteCellAndTableBorders:"table-remove-borders",mergeCells:"table-merge-cells",splitCell:"table-split-cell",fixTables:"table-fix"},bk=Object.values(yk),pV=[...new Set([...Object.values(S0),...bk])];var xN=new Set(["link"]);const mV=new Set(Object.keys(S0).filter(e=>!xN.has(e)));Et(),an();var TN="Arial, Helvetica, sans-serif",RN={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=Zn();let r=ee(1);const o=ee(0),i=ee(!1);let s=null,a=null;const l=ke(()=>{const H=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof H=="string"&&H.trim()?H.trim():TN}),u=n.$toolbar.config?.toolbarGroups?.includes("left"),c=n.$toolbar.config?.toolbarGroups?.includes("right"),d=n.$toolbar.config?.toolbarButtonsExclude||[],h=H=>(o.value,n.$toolbar.getToolbarItemByGroup(H).filter(B=>!d.includes(B.name.value))),m=()=>{i.value=n.$toolbar.getAvailableWidth()<=pf.lg},g=gB(async()=>{await n.$toolbar.onToolbarResize(),m(),r.value+=1},300),C=()=>{r.value+=1},_=()=>{o.value+=1};function k(){window.removeEventListener("resize",g),n.$toolbar.off?.("toolbar-items-changed",C),n.$toolbar.off?.("toolbar-state-change",_),s?.disconnect(),s=null}function y(){k(),window.addEventListener("resize",g),n.$toolbar.on?.("toolbar-items-changed",C),n.$toolbar.on?.("toolbar-state-change",_),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(s=new ResizeObserver(()=>{g()}),s.observe(n.$toolbar.toolbarContainer)),m()}An(y),Km(y),qm(k),Qn(k);const b=()=>{if(!n.$toolbar.activeEditor){a=null,n.$toolbar.pendingSelectionCapture=null;return}a=n.$toolbar.ui?.selection?.capture?.()??null,n.$toolbar.pendingSelectionCapture=a},x=({item:H,argument:B,option:z})=>{R(),n.$toolbar.emitCommand({item:H,argument:B,option:z})},R=()=>{const H=n.$toolbar.activeEditor;if(!H)return;const B=n.$toolbar.pendingSelectionCapture??a;if(B&&typeof n.$toolbar.ui?.selection?.restore=="function"){n.$toolbar.ui.selection.restore(B);return}H.commands?.restoreSelection?.()},D=H=>{b(),!H.target.closest('input, textarea, [contenteditable="true"]')&&H.preventDefault()};return(H,B)=>(ge(),Se("div",{class:"superdoc-toolbar",key:Xe(r),role:"toolbar","aria-label":"Toolbar","data-sd-part":"toolbar","data-editor-ui-surface":"",onMousedown:D},[Xe(u)?(ge(),tn(Up,{key:0,tabindex:"0","toolbar-items":h("left"),"overflow-items":Xe(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"left",onCommand:x,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ct("",!0),Ht(Up,{tabindex:"0","toolbar-items":h("center"),"overflow-items":Xe(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"center",onCommand:x},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),Xe(c)?(ge(),tn(Up,{key:1,tabindex:"0","toolbar-items":h("right"),"overflow-items":Xe(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"right",onCommand:x,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):ct("",!0)],32))}},MN=nn(RN,[["__scopeId","data-v-55b5af7a"]]);const LN=e=>{if(!e)return e;const t=e.props?.style?.fontFamily??e.label??e.key;return{...e,props:{...e.props,style:{...e.props?.style,fontFamily:t},"data-item":e.props?.["data-item"]??"btn-fontFamily-option"}}};Et();const pn=e=>{if(!["button","options","separator","dropdown","overflow"].includes(e.type))throw new Error("Invalid toolbar item type - "+e.type);if(e.type==="button"&&!e.defaultLabel&&!e.icon)throw new Error("Toolbar button item needs either icon or label - "+e.name);if(!e.name)throw new Error("Invalid toolbar item name - "+e.name);const t=ee(Hi()),n=e.type,r=ee(e.name),o=e.command,i=e.noArgumentCommand,s=ee(e.icon),a=ee(e.group||"center"),l=ee(e.allowWithoutEditor),u=ee(e.attributes||{}),c=e.disabled||!1,d=ee(e.disabled),h=ee(!1),m=ee(!1),p=ee(e.style),g=ee(e.isNarrow),C=ee(e.isWide),_=ee(e.minWidth),k=ee(e.suppressActiveHighlight||!1),y=ee(e.argument),b=ee(null),x=ee(null),R=ee(e.iconColor),D=ee(e.hasCaret),H=ee(!!e.splitButton),B=e.splitButtonCommand,z=!!e.restoreEditorFocus,Y=ee(e.dropdownStyles),O=ee(e.tooltip),M=ee(e.tooltipVisible),A=ee(e.tooltipTimeout),N=ee(e.defaultLabel),X=ee(e.label),te=ee(e.hideLabel),ae=ee(e.inlineTextInputVisible),me=ee(e.hasInlineTextInput),He=ee(e.markName),ce=ee(e.labelAttr),ve=ee(e.selectedValue),ue=ee(e.dropdownValueKey),_e=ee(e.inputRef||null),ie=ee([]);if(e.options){if(!Array.isArray(e.options))throw new Error("Invalid toolbar item options - "+e.options);ie.value?.push(...e.options)}const Te=(w={},...ne)=>{xe(w,...ne),!k.value&&(h.value=!0)},Ge=()=>{Me(),h.value=!1},$e=w=>{d.value=w},ot=()=>{d.value=c},xe=e.onActivate||(()=>null),Me=e.onDeactivate||(()=>null),De=()=>{const w={};return Object.keys(J).forEach(ne=>{J[ne].value!==void 0&&(w[ne]=J[ne].value)}),w},J={id:t,name:r,type:n,command:o,noArgumentCommand:i,icon:s,tooltip:O,group:a,attributes:u,disabled:d,active:h,expand:m,nestedOptions:ie,style:p,isNarrow:g,isWide:C,minWidth:_,argument:y,parentItem:x,iconColor:R,hasCaret:D,splitButton:H,splitButtonCommand:B,dropdownStyles:Y,tooltipVisible:M,tooltipTimeout:A,defaultLabel:N,label:X,hideLabel:te,inlineTextInputVisible:ae,hasInlineTextInput:me,restoreEditorFocus:z,markName:He,labelAttr:ce,childItem:b,allowWithoutEditor:l,dropdownValueKey:ue,selectedValue:ve,inputRef:_e};return{...J,unref:De,activate:Te,deactivate:Ge,setDisabled:$e,resetDisabled:ot,onActivate:xe,onDeactivate:Me}};Et(),an();var DN=["onClick","innerHTML","aria-label","onKeydown"],PN={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Ai(),r=t,o=ee([]),i=[{key:"left",ariaLabel:"Align left",icon:Wn.alignLeft},{key:"center",ariaLabel:"Align center",icon:Wn.alignCenter},{key:"right",ariaLabel:"Align right",icon:Wn.alignRight},{key:"justify",ariaLabel:"Justify",icon:Wn.alignJustify}],s=c=>{r("select",c)},a=c=>{if(c===o.value.length-1)return;const d=o.value[c+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=c=>{if(c===0)return;const d=o.value[c-1];d&&(d.setAttribute("tabindex","0"),d.focus())},u=(c,d)=>{switch(c.key){case"ArrowLeft":l(d);break;case"ArrowRight":a(d);break;case"Enter":s(i[d].key);break;default:break}};return An(()=>{const c=o.value[0];c&&(c.setAttribute("tabindex","0"),c.focus())}),(c,d)=>(ge(),Se("div",{class:Xt(["alignment-buttons",{"high-contrast":Xe(n)}])},[(ge(),Se(Vt,null,Xn(i,(h,m)=>Le("div",{key:h.key,class:"sd-button-icon",onClick:p=>s(h.key),innerHTML:h.icon,"data-item":"btn-textAlign-option",role:"menuitem","aria-label":h.ariaLabel,ref_for:!0,ref_key:"alignmentButtonsRefs",ref:o,onKeydown:Wt(p=>u(p,m),["prevent"])},null,40,DN)),64))],2))}},FN=nn(PN,[["__scopeId","data-v-13e5f7a4"]]);Et(),an();var ON=["onClick","innerHTML","aria-label","onKeydown"],BN={__name:"StyleButtonsList",props:{buttons:{type:Array,required:!0},selectedStyle:{type:String,default:null},iconSize:{type:Number,default:25}},emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=Ai(),r=t,o=e,i=ee([]),s=ke(()=>({width:`${o.iconSize}px`,height:`${o.iconSize}px`})),a=d=>{r("select",d)},l=d=>{if(d===i.value.length-1)return;const h=i.value[d+1];h&&(h.setAttribute("tabindex","0"),h.focus())},u=d=>{if(d===0)return;const h=i.value[d-1];h&&(h.setAttribute("tabindex","0"),h.focus())},c=(d,h)=>{switch(d.key){case"ArrowLeft":u(h);break;case"ArrowRight":l(h);break;case"Enter":a(o.buttons[h].key);break;default:break}};return An(()=>{const d=i.value[0];d&&(d.setAttribute("tabindex","0"),d.focus())}),(d,h)=>(ge(),Se("div",{class:Xt(["style-buttons-list",{"high-contrast":Xe(n)}])},[(ge(!0),Se(Vt,null,Xn(o.buttons,(m,p)=>(ge(),Se("div",{key:m.key,class:Xt(["sd-button-icon",{"sd-selected":o.selectedStyle===m.key}]),style:un(s.value),onClick:g=>a(m.key),innerHTML:m.icon,role:"menuitem","aria-label":m.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:i,onKeydown:Wt(g=>c(g,p),["prevent"])},null,46,ON))),128))],2))}},wk=nn(BN,[["__scopeId","data-v-44f37ff6"]]);const NN=[{key:"disc",icon:Wn.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:Wn.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:Wn.bulletListSquare,ariaLabel:"Opaque square"}],zN=[{key:"decimal",icon:Wn.numberedListDecimal,ariaLabel:"1. 2. 3."},{key:"decimal-paren",icon:Wn.numberedListDecimalParen,ariaLabel:"1) 2) 3)"},{key:"upper-roman",icon:Wn.numberedListUpperRoman,ariaLabel:"I. II. III."},{key:"lower-roman",icon:Wn.numberedListLowerRoman,ariaLabel:"i. ii. iii."},{key:"upper-alpha",icon:Wn.numberedListUpperAlpha,ariaLabel:"A. B. C."},{key:"upper-alpha-paren",icon:Wn.numberedListUpperAlphaParen,ariaLabel:"A) B) C)"},{key:"lower-alpha",icon:Wn.numberedListLowerAlpha,ariaLabel:"a. b. c."},{key:"lower-alpha-paren",icon:Wn.numberedListLowerAlphaParen,ariaLabel:"a) b) c)"}];Et(),an();var HN=["onClick","onKeydown"],UN={class:"document-mode-column icon-column"},VN=["innerHTML"],jN={class:"document-mode-column text-column"},GN={class:"document-mode-type"},WN={class:"document-mode-description"},KN={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=ee([]),{isHighContrastMode:o}=Ai(),i=e,s=c=>{n("select",c)},a=c=>{if(c===r.value.length-1)return;const d=r.value[c+1];d&&(d.setAttribute("tabindex","0"),d.focus())},l=c=>{if(c===0)return;const d=r.value[c-1];d&&(d.setAttribute("tabindex","0"),d.focus())},u=(c,d)=>{switch(c.key){case"ArrowDown":a(d);break;case"ArrowUp":l(d);break;case"Enter":s(i.options[d]);break;default:break}};return An(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(c,d)=>(ge(),Se("div",{class:Xt(["document-mode",{"high-contrast":Xe(o)}])},[(ge(!0),Se(Vt,null,Xn(e.options,(h,m)=>(ge(),Se("div",{class:Xt(["sd-option-item",{"sd-disabled":h.disabled}]),onClick:p=>s(h),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:Wt(p=>u(p,m),["prevent"])},[Le("div",UN,[Le("div",{class:"icon-column__icon",innerHTML:h.icon},null,8,VN)]),Le("div",jN,[Le("div",GN,Ft(h.label),1),Le("div",WN,Ft(h.description),1)])],42,HN))),256))],2))}},qN=nn(KN,[["__scopeId","data-v-bee14d7a"]]);Et(),an();var YN={class:"linked-style-buttons","data-editor-ui-surface":""},XN=["onClick","onKeydown","aria-label"],QN={__name:"LinkedStyle",props:{styles:{type:Array,default:()=>[]},selectedOption:{type:String,default:null}},emits:["select"],setup(e,{emit:t}){const n=t,r=ee([]),o=e,i=d=>{n("select",d)},s=d=>{if(d===r.value.length-1)return;const h=r.value[d+1];h.setAttribute("tabindex","0"),h.focus()},a=d=>{if(d===0)return;const h=r.value[d-1];h.setAttribute("tabindex","0"),h.focus()},l=(d,h,m)=>{switch(d.key){case"ArrowDown":s(h);break;case"ArrowUp":a(h);break;case"Enter":d.preventDefault(),i(m);break;default:break}},u=d=>d?.name??d?.id??"",c=d=>{const h=d?.preview?.css;return h&&typeof h=="object"?h:void 0};return An(()=>{r.value[0]&&(r.value[0].setAttribute("tabindex","0"),r.value[0].focus())}),(d,h)=>(ge(),Se("div",YN,[(ge(!0),Se(Vt,null,Xn(o.styles,(m,p)=>(ge(),Se("div",{key:m.id??p,class:Xt(["style-item",{selected:e.selectedOption===m.id}]),onClick:g=>i(m),onKeydown:g=>l(g,p,m),"aria-label":`Linked style - ${m.id??u(m)}`,ref_for:!0,ref_key:"styleRefs",ref:r},[Le("div",{class:"style-name","data-item":"btn-linkedStyles-option",style:un(c(m))},Ft(u(m)),5)],42,XN))),128))]))}},ZN=nn(QN,[["__scopeId","data-v-43b5dcca"]]);Et(),an();var JN=["placeholder"],$N={class:"sd-ai-writer__footer"},ez={key:0,class:"sd-ai-writer__error",role:"alert"},tz=["disabled"],nz="https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights",rz="You are an expert copywriter and you are immersed in a document editor. Only write what is asked for.",oz={__name:"AIWriter",props:{selectedText:{type:String,default:""},target:{type:Object,default:null},doc:{type:Object,default:null},apiKey:{type:String,default:""},endpoint:{type:String,default:""},restoreSelection:{type:Function,default:null},handleClose:{type:Function,required:!0}},setup(e){const t=e,n=ee(""),r=ee(!1),o=ee(""),i=ee(null),s=ke(()=>t.selectedText?"Insert prompt to update text":"Insert prompt to generate text"),a=ke(()=>n.value.trim().length>0&&!r.value);An(()=>{St(()=>{i.value?.focus()})});function l(p){if(typeof p=="string")return p;if(!p||typeof p!="object")return"";const g=p.custom_prompt;if(Array.isArray(g)){const C=g[0];if(C&&typeof C.value=="string")return C.value}return g&&typeof g=="object"&&typeof g.value=="string"?g.value:typeof p.value=="string"?p.value:typeof p.text=="string"?p.text:""}async function u(p){const g={"Content-Type":"application/json"};t.apiKey&&(g["x-api-key"]=t.apiKey);const C=t.selectedText.trim(),_=C?`Rewrite the following text: "${C}" using these instructions: ${p}`:`Generate text based on the following prompt: ${p}`,k=await fetch(t.endpoint||nz,{method:"POST",headers:g,body:JSON.stringify({stream:!1,context:rz,insights:[{type:"custom_prompt",name:C?"text_rewrite":"text_generation",message:_,format:[{value:""}]}]})});if(!k.ok){const b=await k.text().catch(()=>"");throw new Error(b||`AI request failed with ${k.status}`)}const y=l((k.headers.get("content-type")||"").includes("application/json")?await k.json():await k.text()).trim();if(!y)throw new Error("AI returned no text.");return y}function c(p){return!p||typeof p!="object"?!0:!(p.success===!1||p.ok===!1)}function d(p){const g=t.doc;if(!g)throw new Error("Document API is unavailable.");t.restoreSelection?.();let C=null,_=!1;if(t.selectedText&&t.target&&typeof g.replace=="function"?(C=g.replace({target:t.target,text:p}),_=!0):t.target&&typeof g.insert=="function"?(C=g.insert({target:t.target,value:p,type:"text"}),_=!0):typeof g.insert=="function"&&(C=g.insert({value:p,type:"text"}),_=!0),!_)throw new Error("Document text insertion is unavailable.");if(!c(C))throw new Error("Unable to insert generated text.")}async function h(){if(a.value){o.value="",r.value=!0;try{d(await u(n.value.trim())),t.handleClose()}catch(p){o.value=p instanceof Error?p.message:String(p)}finally{r.value=!1}}}function m(p){p.key!=="Enter"||p.shiftKey||(p.preventDefault(),h())}return(p,g)=>(ge(),Se("form",{class:"sd-ai-writer","data-item":"ai-writer",onSubmit:Wt(h,["prevent"])},[xs(Le("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":g[0]||(g[0]=C=>n.value=C),class:"sd-ai-writer__input",placeholder:s.value,rows:"4",onKeydown:m},null,40,JN),[[ci,n.value]]),Le("div",$N,[o.value?(ge(),Se("p",ez,Ft(o.value),1)):ct("",!0),Le("button",{class:"sd-ai-writer__submit",type:"submit",disabled:!a.value},Ft(r.value?"Generating":"Generate"),9,tz)])],32))}},iz=nn(oz,[["__scopeId","data-v-67f6c6f7"]]);Et(),an();var sz=["aria-label","onClick","onKeydown"],az=["innerHTML"],lz=["innerHTML"],Vp=7,cz={__name:"IconGridRow",props:{icons:{type:Array,required:!0},activeColor:{type:Object,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=e,o=ke(()=>p=>r.activeColor.value?r.activeColor.value.toUpperCase()===p.value:!1),i=(p,g)=>g===5||["#FFFFFF","#FAFF09"].includes(p)?{color:"#000"}:{color:"#FFF"},s=p=>{n("select",p.value)},a=ee([]),l=ee([]);An(()=>{if(!r.icons.every(g=>Array.isArray(g)))throw new Error("icon props must be 2d array");const p=l.value[0];p&&(p.setAttribute("tabindex","0"),p.focus())});const u=(p,g)=>{const C=Vp*p+g+1,_=l.value[C];_&&(_.setAttribute("tabindex","0"),_.focus())},c=(p,g)=>{const C=Vp*p+g-1,_=l.value[C];_&&(_.setAttribute("tabindex","0"),_.focus())},d=(p,g)=>{const C=g+Vp*(p+1),_=l.value[C];_&&(_.setAttribute("tabindex","0"),_.focus())},h=(p,g)=>{const C=g+Vp*(p-1),_=l.value[C];_&&(_.setAttribute("tabindex","0"),_.focus())},m=(p,g,C,_)=>{switch(p.key){case"ArrowRight":u(g,C);break;case"ArrowLeft":c(g,C);break;case"ArrowDown":d(g,C);break;case"ArrowUp":h(g,C);break;case"Enter":s(_);break;case"Escape":n("clickoutside");break;default:break}};return(p,g)=>(ge(!0),Se(Vt,null,Xn(e.icons,(C,_)=>(ge(),Se("div",{class:"sd-option-row",key:_,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(ge(!0),Se(Vt,null,Xn(C,(k,y)=>(ge(),Se("div",{class:"sd-option",key:y,"aria-label":k.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:Wt(b=>s(k),["stop","prevent"]),onKeydown:Wt(b=>m(b,_,y,k),["prevent"])},[Le("div",{class:"sd-option__icon",innerHTML:k.icon,style:un(k.style)},null,12,az),o.value(k)?(ge(),Se("div",{key:0,class:"sd-option__check",innerHTML:Xe(Wn).colorOptionCheck,style:un(i(k.value,y))},null,12,lz)):ct("",!0)],40,sz))),128))]))),128))}},Ck=nn(cz,[["__scopeId","data-v-5f3db0a9"]]),uz=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M320 512c53.2 0 101.4-21.6 136.1-56.6l-298.3-235C140 257.1 128 292.3 128 320c0 106 86 192 192 192zM505.2 370.7c4.4-16.2 6.8-33.1 6.8-50.7c0-91.2-130.2-262.3-166.6-308.3C339.4 4.2 330.5 0 320.9 0l-1.8 0c-9.6 0-18.5 4.2-24.5 11.7C277.8 33 240.7 81.3 205.8 136L38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L505.2 370.7zM224 336c0 44.2 35.8 80 80 80c8.8 0 16 7.2 16 16s-7.2 16-16 16c-61.9 0-112-50.1-112-112c0-8.8 7.2-16 16-16s16 7.2 16 16z"/></svg>
|
|
101
101
|
`;Et(),an();var dz={class:"options-grid-wrap"},fz=["innerHTML"],hz={class:"option-grid-ctn"},pz={__name:"IconGrid",props:{icons:{type:Array,required:!0},customIcons:{type:Array,required:!1},activeColor:{type:Object,required:!1},hasNoneIcon:{type:Boolean,required:!1}},emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=o=>{n("select",o)};return(o,i)=>(ge(),Se("div",dz,[e.hasNoneIcon?(ge(),Se("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:i[0]||(i[0]=s=>r("none"))},[Le("span",{innerHTML:Xe(uz),class:"none-icon"},null,8,fz),i[1]||(i[1]=Ci(" None ",-1))])):ct("",!0),Le("div",hz,[Ht(Ck,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(ge(),Se(Vt,{key:0},[i[2]||(i[2]=Le("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),Ht(Ck,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):ct("",!0)])]))}},mz=nn(pz,[["__scopeId","data-v-52b0283a"]]);const k0=(e,t=null)=>{if(typeof t?.focus=="function"){t.focus();return}const n=e?.superdoc?.focus??e?.activeEditor?.focus;if(typeof n=="function"){n.call(e?.superdoc??e?.activeEditor);return}const r=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');r instanceof HTMLElement&&r.focus({preventScroll:!0})};Et();var gz=e=>{e.expand.value=!1};const Ot=(e,t=null)=>({label:t,icon:Wn.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),A0=(e,t,n=[],r=!1)=>{const o=i=>{t.iconColor.value=i,e.emitCommand({item:t,argument:i}),gz(t),k0(e)};return kr("div",{},[kr(mz,{icons:vz,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:o})])},vz=[[Ot("#111111","black"),Ot("#333333","dark gray"),Ot("#5C5C5C","medium gray"),Ot("#858585","light gray"),Ot("#ADADAD","very light gray"),Ot("#D6D6D6","transparent gray"),Ot("#FFFFFF","white")],[Ot("#860028","dark red"),Ot("#D2003F","red"),Ot("#DB3365","coral red"),Ot("#E4668C","light red"),Ot("#ED99B2","pale pink"),Ot("#F6CCD9","transparent pink"),Ot("#FF004D","bright pink")],[Ot("#83015E","dark purple"),Ot("#CD0194","purple"),Ot("#D734A9","orchid"),Ot("#E167BF","light purple"),Ot("#EB99D4","lavender"),Ot("#F5CCEA","transparent pink"),Ot("#FF00A8","neon pink")],[Ot("#8E220A","maroon"),Ot("#DD340F","red-orange"),Ot("#E45C3F","burnt orange"),Ot("#EB856F","peach"),Ot("#F1AE9F","pale peach"),Ot("#F8D6CF","transparent peach"),Ot("#FF7A00","orange")],[Ot("#947D02","olive"),Ot("#E7C302","mustard yellow"),Ot("#ECCF35","yellow"),Ot("#F1DB67","light yellow"),Ot("#F5E79A","very pale yellow"),Ot("#FAF3CC","transparent yellow"),Ot("#FAFF09","neon yellow")],[Ot("#055432","forest green"),Ot("#07834F","green"),Ot("#399C72","medium green"),Ot("#6AB595","light green"),Ot("#9CCDB9","mint"),Ot("#CDE6DC","transparent mint"),Ot("#05F38F","bright teal")],[Ot("#063E7E","navy blue"),Ot("#0A60C5","blue"),Ot("#3B80D1","sky blue"),Ot("#6CA0DC","cornflower blue"),Ot("#9DBFE8","light blue"),Ot("#CEDFF3","very light blue"),Ot("#21c8ce","cyan")],[Ot("#3E027A","deep purple"),Ot("#6103BF","indigo"),Ot("#8136CC","violet"),Ot("#A068D9","lavender pink"),Ot("#C09AE6","light lilac"),Ot("#DFCDF2","transparent lilac"),Ot("#A91DFF","neon purple")]];Et(),an();var yz=["data-cols","data-rows","onKeydown","onClick"],bz=["aria-valuetext"],jp=5,wz={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=ee(0),o=ee(0),{isHighContrastMode:i}=Ai(),s=ee([]),a=d=>{let h=d.target;h.dataset.grid||l([...h.parentElement.querySelectorAll("[data-item]")],parseInt(h.dataset.cols,10),parseInt(h.dataset.rows,10))},l=(d,h,m)=>{o.value=h,r.value=m;for(let p=0;p<d.length;p++){let g=d[p],C=parseInt(g.dataset.cols,10),_=parseInt(g.dataset.rows,10);C<=h&&_<=m?g.classList.add("sd-selected"):g.classList.remove("sd-selected")}},u=({cols:d,rows:h})=>{n("select",{cols:d,rows:h})},c=(d,h,m)=>{let p=h-1,g=m-1;switch(d.key){case"ArrowRight":{if(p>=4)return;const C=g*jp;s.value[C+p+1].setAttribute("tabindex","0"),s.value[C+p+1].focus(),l(s.value,h+1,m);break}case"ArrowLeft":{if(p<=0)return;const C=g*jp;s.value[C+p-1].setAttribute("tabindex","0"),s.value[C+p-1].focus(),l(s.value,h-1,m);break}case"ArrowDown":{if(g>=4)return;const C=(g+1)*jp;s.value[C+p].setAttribute("tabindex","0"),s.value[C+p].focus(),l(s.value,h,m+1);break}case"ArrowUp":{if(g<=0)return;const C=(g-1)*jp;s.value[C+p].setAttribute("tabindex","0"),s.value[C+p].focus(),l(s.value,h,m-1);break}case"Enter":u({cols:h,rows:m});break;default:break}};return An(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(d,h)=>(ge(),Se("div",{class:Xt(["toolbar-table-grid-wrapper",{"high-contrast":Xe(i)}])},[Le("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(ge(),Se(Vt,null,Xn(5,m=>(ge(),Se(Vt,{key:m},[(ge(),Se(Vt,null,Xn(5,p=>Le("div",{class:"toolbar-table-grid__item",key:`${m}_${p}`,"data-cols":p,"data-rows":m,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:Wt(g=>c(g,p,m),["prevent"]),onClick:Wt(g=>u({cols:p,rows:m}),["stop","prevent"])},null,40,yz)),64))],64))),64))],32),Le("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${o.value}`},Ft(r.value)+" x "+Ft(o.value),9,bz)],2))}},Cz=nn(wz,[["__scopeId","data-v-b87d6ca2"]]);Et(),an();var _z={class:"toolbar-table-actions"},Sz=["onClick","data-item","ariaLabel"],kz={class:"toolbar-table-actions__icon"},Az=["innerHTML"],Iz={class:"toolbar-table-actions__label"},Ez={__name:"TableActions",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=o=>{n("select",{command:o.command})};return(o,i)=>(ge(),Se("div",_z,[(ge(!0),Se(Vt,null,Xn(e.options,s=>(ge(),Se("div",{class:Xt(["toolbar-table-actions__item",{"toolbar-table-actions__item--border":s.bottomBorder}]),onClick:a=>r(s),"data-item":s.props?.["data-item"]||"",ariaLabel:s.props?.ariaLabel,role:"menuitem"},[Le("div",kz,[Le("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,Az)]),Le("div",Iz,Ft(s.label),1)],10,Sz))),256))]))}},xz=nn(Ez,[["__scopeId","data-v-0cdad084"]]),Tz=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z"/></svg>
|
|
102
|
-
`;Et();var rs=e=>{e.expand.value=!1};function _k(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function Rz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function Sk(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function Mz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function Lz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const Dz=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=pn({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),u=(r??AN).map(LN),c=pn({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:u,onActivate:({fontFamily:Ke}={},we=!1)=>{if(we){c.label.value="",c.selectedValue.value="";return}if(!Ke)return;Ke=Ke.split(",")[0],c.label.value=Ke;const Re=u.find(Ue=>Ue.label===c.defaultLabel.value),Oe=u.find(Ue=>Ue.label===Ke);Oe?c.selectedValue.value=Oe.key:Re?c.selectedValue.value=Re.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const Ke=u.find(we=>we.label===c.defaultLabel.value);Ke?c.selectedValue.value=Ke.key:c.selectedValue.value=""}}),d=pn({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>h(d)}]});function h(Ke){const we=Sk(e),Re=we?.selectionTarget??_k(we?.target),Oe=we?.empty?"":Rz(we),Ue=Lz(e),kt=()=>rs(Ke),It=()=>{const Qt=e.pendingSelectionCapture;Qt&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Qt)};return kr("div",{},[kr(iz,{handleClose:kt,selectedText:Oe,target:Re,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Ue?.apiKey||e.config?.aiApiKey||"",endpoint:Ue?.endpoint||e.config?.aiEndpoint||"",restoreSelection:It})])}const m=EN,p=pn({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:m,onActivate:({fontSize:Ke},we=!1)=>{if(we){p.label.value="",p.selectedValue.value="";return}const Re=m.find(It=>It.label===String(p.defaultLabel.value));if(!Ke){p.label.value=p.defaultLabel.value,Re?p.selectedValue.value=Re.key:p.selectedValue.value="";return}let Oe=mB(Ke,12);Oe<8&&(Oe=8),Oe>96&&(Oe=96);let Ue=String(Oe);const kt=m.find(It=>It.label===Ue||It.key===Ue);kt?p.selectedValue.value=kt.key:p.selectedValue.value="",p.label.value=Ue},onDeactivate:()=>{p.label.value=p.defaultLabel.value;const Ke=m.find(we=>we.label===String(p.defaultLabel.value));Ke?p.selectedValue.value=Ke.key:p.selectedValue.value=""}}),g=pn({type:"separator",name:"separator",isNarrow:!0}),C=pn({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),_=pn({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),k=pn({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=pn({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>A0(e,y,[],!0)}],onActivate:({color:Ke})=>{y.iconColor.value=Ke||""},onDeactivate:()=>y.iconColor.value=""}),b=pn({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>A0(e,b)}],onActivate:({color:Ke})=>{b.iconColor.value=Ke},onDeactivate:()=>b.iconColor.value="#000"}),x=pn({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=pn({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>D(R)}],onActivate:({href:Ke})=>{Ke?R.attributes.value={href:Ke}:R.attributes.value={}},onDeactivate:()=>{R.attributes.value={},R.expand.value=!1}});function D(Ke){const we=Sk(e),Re=we?.selectionTarget??_k(we?.target),Oe=()=>{const Ue=e.pendingSelectionCapture;Ue&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Ue)};return kr("div",{},[kr(F_,{ui:e.ui,linkItem:Ke,textTarget:Re,restoreSelection:Oe,closePopover:()=>rs(Ke),goToAnchor:()=>{rs(Ke);const Ue=Ke.attributes.value?.href;if(!Ue)return;const kt=Ue.slice(1),It=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${kt}']`);It&&jd(It)}})])}const H=pn({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=H,H.parentItem=R;const B=pn({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),z=pn({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Y=pn({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>O(Y)}]});function O(Ke){return kr("div",{},[kr(Cz,{onSelect:Re=>{e.emitCommand({item:Ke,argument:Re}),rs(Ke),k0(e)}})])}const M=pn({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>N(M)}]}),A=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function N(Ke){return kr(xz,{options:A,onSelect:we=>{rs(Ke);const{command:Re}=we;e.emitCommand({item:Ke,argument:{command:Re}})}})}const X=pn({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>kr("div",{},[kr(FN,{onSelect:we=>{rs(X);const Re={...X,command:"setTextAlign"};Re.command="setTextAlign",e.emitCommand({item:Re,argument:we}),te(X,we)}})]),key:"alignment"}],onActivate:({textAlign:Ke})=>{te(X,Ke)},onDeactivate:()=>{te(X,"left")}}),te=(Ke,we)=>{let Re=we==="both"?"justify":we,Oe={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Ue=Oe[Re]??Oe.left;Ke.icon.value=Ue},ae=pn({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Ke=we=>{rs(ae);const Re={...ae,command:"toggleBulletListStyle"};e.emitCommand({item:Re,argument:we})};return kr(wk,{buttons:NN,iconSize:25,selectedStyle:ae.selectedValue.value,onSelect:Ke})}}]}),me=pn({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Ke=we=>{rs(me);const Re={...me,command:"toggleOrderedListStyle"};e.emitCommand({item:Re,argument:we})};return kr(wk,{buttons:zN,iconSize:30,selectedStyle:me.selectedValue.value,onSelect:Ke})}}]}),He=pn({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),ce=pn({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ve=pn({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),ue=pn({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:Ke})=>{Ke&&(ue.label.value=Ke)}}),_e=pn({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:Ke})=>{Ke&&(_e.label.value=Ke)}}),ie=pn({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Te=pn({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),Ge=pn({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),$e=pn({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),ot=pn({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),xe=pn({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Me=(Ke,we)=>Ke==="editor"?we:Ke==="suggester"?we.filter(Re=>Re.value==="suggesting"):we.filter(Re=>Re.value==="viewing"),De=Ke=>Ke==="editor"?"Editing":Ke==="suggester"?"Suggesting":"Viewing",J=pn({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:De(s),label:De(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>ne(J)}]}),w=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function ne(Ke){return kr(qN,{options:Me(s,w),onSelect:we=>{const Re=e.superdoc?.activeEditor??e.activeEditor;rs(Ke);const{label:Oe,icon:Ue,value:kt}=we;J.label.value=Oe,J.icon.value=Ue,e.emitCommand({item:J,argument:kt}),k0(e,Re)}})}const F=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),V=["search","ruler","undo","overflow","documentMode"],U=pn({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),G=pn({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),Q=pn({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Ke=Re=>{rs(Q);const Oe=typeof Re=="string"?Re:Re?.id??null;if(!Oe)return;const Ue={...Q,command:"setLinkedStyle"};e.emitCommand({item:Ue,argument:Oe})},we=e.getActiveLinkedStyleId?.()??null;return kr("div",{},[kr(ZN,{styles:e.getLinkedStyleOptions?.()??[],onSelect:Ke,selectedOption:we})])}}],onActivate:({styleId:Ke,styleName:we})=>{const Re=we||Ke;Q.label.value=Ke&&Ke!=="Normal"?String(Re):n.formatText,Q.disabled.value=!1},onDeactivate:()=>{Q.disabled.value=!0,Q.label.value=n.formatText}}),K=(Ke,we)=>{if(we.value==Ke)return kr("div",{innerHTML:Tz,class:"dropdown-select-icon"})},W=pn({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(Ke=>({label:Ke.toFixed(2),key:Ke,icon:()=>K(Ke,W.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),de=20,Ce=32,be=V.reduce((Ke,we)=>Ke+(F.get(we)||F.get("default")),0),Be=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],rt=["zoom","fontFamily","fontSize","redo"],nt=i<=pf.lg,wt=e.config?.showFormattingMarksButton===!0,Nt=e.config?.showTableOfContentsButton===!0;nt&&(J.attributes.value={...J.attributes.value,className:`${J.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),nt&&(Q.attributes.value={...Q.attributes.value,className:`${Q.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let _t=[ie,Te,Ge,$e,x,ue,c,g,p,g,l,C,_,k,b,y,g,R,B,...Nt?[z]:[],Y,M,g,X,ae,me,He,ce,W,g,Q,g,U,_e,...wt?[G]:[],xe,ot,...Mz(e)?[d]:[],ve,J];if(i<=pf.md&&o&&(_t=_t.filter(Ke=>Ke.type!=="separator")),e.config.mode!=="docx"){const Ke=_t.findIndex(Re=>Re.name.value==="linkedStyles");_t.splice(Ke-1,2);const we=["ruler","zoom","undo","redo"];_t=_t.filter(Re=>!we.includes(Re.name.value))}const Tt=[];a||(s==="viewer"&&Tt.push(Ge,$e),_t=_t.filter(Ke=>!Tt.includes(Ke)));const Dt=Ke=>V.includes(Ke.name.value),rn=[],mn=[];let Ut=Ce+be;return _t.forEach(Ke=>{const we=F.get(Ke.name.value)||F.get("default");if(i<pf.xl+de&&Be.includes(Ke.name.value)&&o){if(rn.push(Ke),Ke.name.value==="linkedStyles"){const Re=_t.findIndex(Oe=>Oe.name.value==="linkedStyles");_t.splice(Re+1,1)}return}if(i<pf.sm&&rt.includes(Ke.name.value)&&o){rn.push(Ke);return}if(Dt(Ke)){mn.push(Ke),Ut+=we;return}Ut<i||!o?(mn.push(Ke),Ut+=we):rn.push(Ke)}),{defaultItems:mn,overflowItems:rn.filter(Ke=>Ke.type!=="separator")}},kk={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},Pz=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;Et();function Ak(e){return aB(e)??S0[e]??null}function Gp(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=n===void 0?o.call(e.commands,t):o.call(e.commands,t,n);return i&&typeof i.then=="function"&&Promise.resolve(i).then(()=>r.onSettled?.(),s=>{r.onError?.(s),r.onSettled?.()}),!0}var Fz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),Oz=new Set(["list","numberedlist"]);function Bz(e,t){if(e==="fontFamily"||e==="fontSize"||Oz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!Fz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function Ik(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Nz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var zz=class extends um.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Wn},texts:{...kk},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#t=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...Wn,...e.icons},this.config.texts={...kk,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=Pz(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}if(this.#e(),this.#u(),this.#r(),this.#i(),this._lastFontOptionsSignature=this.#a(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Dl(MN),this.app.directive("click-outside",hv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}#e(){this.superdoc&&(this.ui=Gy({superdoc:this.superdoc}),this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#R():this.#S()}))}#o(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#S();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear();try{this.ui?.destroy?.()}catch{}this.ui=null,this.snapshot=null}#i(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#a();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#s(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#u(){this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#d(e){return e||IN(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#r(){const e=this.getAvailableWidth(),{defaultItems:t,overflowItems:n}=Dz({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#d(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),r=this.config.customButtons||[],o=r.map(a=>this.#f(a));r.length&&t.push(...o);let i=[...t.map(a=>a.name.value),...n.map(a=>a.name.value)];if(this.config.groups){const a=Object.values(this.config.groups).flatMap(c=>c),l=new Set(Object.keys(this.config.groups)),u=o.filter(c=>l.has(c.group?.value||"center")).map(c=>c.name.value);i=[...new Set([...a,...u])]}const s=t.filter(a=>i.includes(a.name.value)).filter(a=>!this.config.excludeItems.includes(a.name.value));if(this.config.groups)for(const[a,l]of Object.entries(this.config.groups))for(const u of s)l.includes(u.name.value)&&(u.group.value=a);this.toolbarItems=s,this.overflowItems=n.filter(a=>i.includes(a.name.value))}#f(e){const t=pn({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};return n({...i,item:t,argument:s.argument,option:s.option})}});this._customCommandRegs.set(r,o)}}return t}#p(){this.#r(),this.emit("toolbar-items-changed")}#a(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#c().find(t=>t.name.value===e)}#c(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.ui?.styles?.getQuickGallery?.()??[]}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#a();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#r(),this.updateToolbarState()};#g(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#C(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#w(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#_(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>A0(this,e,[],!0)};e.nestedOptions.value=[t]}#l(e){return!!e?.active&&e?.value==null}#E(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=bk.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(!1),!0;if(C0(t)?.disposition==="host-routed")return e.setDisabled(!this.#C(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=Ak(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];Bz(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#w()},link:()=>{e.active.value=!!r?.active,e.attributes.value=r?.value?{href:r.value}:{}},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#E(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#l(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#w(),this.#_();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#V(),this.#c().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#c().forEach(n=>{n.resetDisabled(),this.#x(n)});const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#V(){this.#c().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#D(e,t){const n=this.superdoc;if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#A(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#m(i,n)};if(n==="image"&&t==null)return this.#T();if(n==="tableActions"){const i=yk[t?.command];return i?Gp(this.ui,i,void 0,r):!1}if(C0(n)?.disposition==="unsupported")return!0;const o=Ak(n);return o?Gp(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=pB({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await fB(e,this.superdoc?.config?.handleImageUpload);Gp(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#m(n,"image")})},onError:e=>this.#m(e,"image")})),this.#t.open()),!0}#R(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{Ik(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!Ik(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Nz(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#S(){this.#n&&(this.#n(),this.#n=null)}#m(e,t){const n=e instanceof Error?e:new Error(String(e));this.emit("exception",{error:n,originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null})}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(C0(r)?.disposition==="host-routed"){this.#D(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;this._customCommandRegs.has(s)&&this.ui?.commands?.execute?this.ui.commands.execute(s,{argument:t,option:n}):o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc}),this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!Gp(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#m(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#A(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#m(s,r)}}}destroy(){this.#S(),this.#t?.destroy(),this.#t=null,this.#s(),this.#o(),this.app?.unmount(),this.app=null,this.toolbar=null}};function Hz(e){return new zz(e)}Et();var Uz=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);async function Vz(e,t){const n=new sI.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function I0(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function Ek(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function jz(e,t){if(!e)return()=>{};if(I0(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{Ek(e),s()},l=u=>{u!==!1&&(u===!0||I0(e))&&(Ek(e),s())};return n("synced",a),n("sync",l),I0(e)&&s(),i}function fi(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function Gz(e){const t=e&&typeof e=="object"?e.code:null;return t==="comment-export-missing-story-reference"||t==="v2-worker-comment-export-mode-unsupported"}function xk(e){return typeof e=="string"&&e.length>0?e:null}function E0(e){return e?fi(e)?xk(e.documentId??e.options?.documentId??null):xk(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function Wz(e){if(!e||fi(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function Mi(e){if(!e)return null;if(fi(e))return e.fonts??null;const t=Wz(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var Wp=class extends um.default{static{this.allowedTypes=[wr,Pl,kh]}#t=!1;#n=!1;#e=null;#o=null;#i=null;#s=null;#u=null;#d;#r=new iB;#f=null;#p=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...w0},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#d=new QO({getModuleConfig:()=>this.config.modules?.surfaces}),this.#a(e,t)}async#a(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),rB(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#he(),this.config.user=oB(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=ER(this.config.modules.comments),this.config.colors=pI(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.0.0-next.36",this.#b("π¦ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||Hi(),this.colors=this.config.colors??[],this.#w(),await bx(),this.#t)return;if(await this.#x(this.config.modules),this.#t){this.#ae();return}this.config.cspNonce&&this.#C(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#f||(this.#f=this.#r.subscribe(i=>{this.#me(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#u=o,this.#E(),this.#g(),this.#ge(),this.#c()}#c(){if(this.#_(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#u)}#g(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new SP({Renderer:qO,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===wr).length}get state(){return{documents:this.#h("state").documents,users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#C(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#w(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("π¦ [superdoc] You can only provide one of document or documents"),t){const s=kd(this.config.document);this.config.documents=[{id:Hi(),...s}]}else if(n)this.config.documents=[{id:Hi(),type:wr,url:this.config.document,name:"document.docx"}];else if(r){const s=kd(this.config.document);this.config.documents=[{id:Hi(),...s}]}else if(o){const s=kd(this.config.document);this.config.documents=[{id:Hi(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=kd(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||Hi()}}))}#_(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=dP({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#d),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&ox(this),this.#se()}#l(e,t){t&&this.on(e,t)}#E(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("source:complete",this.config.onSourceComplete),this.#l("source:signals-complete",this.config.onSourceSignalsComplete),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:active-change",this.config.onContentControlActiveChange),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#T(e?.editor??null)),this.#l("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange)}async#x({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:Hi(),type:wr,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#V(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Pr(e),this.provider=Pr(t),this.#P();const n=this.config;this._cleanupAwareness=$8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#D(){this.#s=null,this.#A(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#A(){if(this.#o){try{this.#o()}catch{}this.#o=null}if(this.#i){try{this.#i()}catch{}this.#i=null}}#T(e){this.#A(),fi(e)&&(this.#R(e),this.#S(e))}#R(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=bP(()=>this.user),r=o=>{if(this.#t)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#o=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#S(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#t||this.#I(!!r.isLocked,this.#m(r.lockedBy??null))};try{if(this.#s&&typeof t.setLocked=="function"){const o=this.#s;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#s=null}const r=t.getSnapshot?.();r&&n(r),this.#i=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#m(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#j(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#I(e,t){this.isLocked===e&&this.#j(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#b("π¦ [superdoc] Locking superdoc:",e,t,`
|
|
102
|
+
`;Et();var rs=e=>{e.expand.value=!1};function _k(e){const t=Array.isArray(e?.segments)?e.segments:[];if(e?.kind!=="text"||!t.length)return null;const n=t[0],r=t[t.length-1];if(!n?.blockId||!r?.blockId||!n.range||!r.range)return null;const o=e.story;return{kind:"selection",start:{kind:"text",blockId:n.blockId,offset:n.range.start??0,...o?{story:o}:{}},end:{kind:"text",blockId:r.blockId,offset:r.range.end??0,...o?{story:o}:{}},...o?{story:o}:{}}}function Rz(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function Sk(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function Mz(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function Lz(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const Dz=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=pn({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),u=(r??AN).map(LN),c=pn({type:"dropdown",name:"fontFamily",tooltip:n.fontFamily,command:"setFontFamily",defaultLabel:"Arial",label:"Arial",markName:"textStyle",labelAttr:"fontFamily",hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,isWide:!0,style:{width:"116px"},suppressActiveHighlight:!0,attributes:{ariaLabel:"Font family"},options:u,onActivate:({fontFamily:Ke}={},we=!1)=>{if(we){c.label.value="",c.selectedValue.value="";return}if(!Ke)return;Ke=Ke.split(",")[0],c.label.value=Ke;const Re=u.find(Ue=>Ue.label===c.defaultLabel.value),Oe=u.find(Ue=>Ue.label===Ke);Oe?c.selectedValue.value=Oe.key:Re?c.selectedValue.value=Re.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const Ke=u.find(we=>we.label===c.defaultLabel.value);Ke?c.selectedValue.value=Ke.key:c.selectedValue.value=""}}),d=pn({type:"dropdown",name:"ai",dropdownStyles:{padding:0,outline:"none"},tooltip:n.ai,icon:t.ai,hideLabel:!0,hasCaret:!1,isWide:!0,suppressActiveHighlight:!0,attributes:{ariaLabel:"AI"},options:[{type:"render",key:"ai",render:()=>h(d)}]});function h(Ke){const we=Sk(e),Re=we?.selectionTarget??_k(we?.target),Oe=we?.empty?"":Rz(we),Ue=Lz(e),kt=()=>rs(Ke),It=()=>{const Qt=e.pendingSelectionCapture;Qt&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Qt)};return kr("div",{},[kr(iz,{handleClose:kt,selectedText:Oe,target:Re,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Ue?.apiKey||e.config?.aiApiKey||"",endpoint:Ue?.endpoint||e.config?.aiEndpoint||"",restoreSelection:It})])}const m=EN,p=pn({type:"dropdown",name:"fontSize",defaultLabel:"12",label:"12",style:{width:"56px"},markName:"textStyle",labelAttr:"fontSize",tooltip:n.fontSize,hasCaret:!0,hasInlineTextInput:!0,inlineTextInputVisible:!0,suppressActiveHighlight:!0,isWide:!0,command:"setFontSize",attributes:{ariaLabel:"Font size"},options:m,onActivate:({fontSize:Ke},we=!1)=>{if(we){p.label.value="",p.selectedValue.value="";return}const Re=m.find(It=>It.label===String(p.defaultLabel.value));if(!Ke){p.label.value=p.defaultLabel.value,Re?p.selectedValue.value=Re.key:p.selectedValue.value="";return}let Oe=mB(Ke,12);Oe<8&&(Oe=8),Oe>96&&(Oe=96);let Ue=String(Oe);const kt=m.find(It=>It.label===Ue||It.key===Ue);kt?p.selectedValue.value=kt.key:p.selectedValue.value="",p.label.value=Ue},onDeactivate:()=>{p.label.value=p.defaultLabel.value;const Ke=m.find(we=>we.label===String(p.defaultLabel.value));Ke?p.selectedValue.value=Ke.key:p.selectedValue.value=""}}),g=pn({type:"separator",name:"separator",isNarrow:!0}),C=pn({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),_=pn({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),k=pn({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=pn({type:"dropdown",name:"highlight",icon:t.highlight,hideLabel:!0,markName:"highlight",labelAttr:"color",active:!1,tooltip:n.highlight,command:"setHighlight",noArgumentCommand:"unsetHighlight",suppressActiveHighlight:!0,attributes:{ariaLabel:"Highlight"},options:[{key:"color",type:"render",render:()=>A0(e,y,[],!0)}],onActivate:({color:Ke})=>{y.iconColor.value=Ke||""},onDeactivate:()=>y.iconColor.value=""}),b=pn({type:"dropdown",name:"color",icon:t.color,hideLabel:!0,markName:"textStyle",labelAttr:"color",active:!1,tooltip:n.color,command:"setColor",suppressActiveHighlight:!0,attributes:{ariaLabel:"Color"},options:[{key:"color",type:"render",render:()=>A0(e,b)}],onActivate:({color:Ke})=>{b.iconColor.value=Ke},onDeactivate:()=>b.iconColor.value="#000"}),x=pn({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=pn({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>D(R)}],onActivate:({href:Ke})=>{Ke?R.attributes.value={href:Ke}:R.attributes.value={}},onDeactivate:()=>{R.attributes.value={},R.expand.value=!1}});function D(Ke){const we=Sk(e),Re=we?.selectionTarget??_k(we?.target),Oe=()=>{const Ue=e.pendingSelectionCapture;Ue&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Ue)};return kr("div",{},[kr(F_,{ui:e.ui,linkItem:Ke,textTarget:Re,restoreSelection:Oe,closePopover:()=>rs(Ke),goToAnchor:()=>{rs(Ke);const Ue=Ke.attributes.value?.href;if(!Ue)return;const kt=Ue.slice(1),It=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${kt}']`);It&&jd(It)}})])}const H=pn({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=H,H.parentItem=R;const B=pn({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),z=pn({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Y=pn({type:"dropdown",name:"table",icon:t.table,hideLabel:!0,labelAttr:"table",active:!1,tooltip:n.table,command:"insertTable",suppressActiveHighlight:!0,attributes:{ariaLabel:"Table"},options:[{key:"table",type:"render",render:()=>O(Y)}]});function O(Ke){return kr("div",{},[kr(Cz,{onSelect:Re=>{e.emitCommand({item:Ke,argument:Re}),rs(Ke),k0(e)}})])}const M=pn({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>N(M)}]}),A=[{label:n.addRowBefore,command:"addRowBefore",icon:t.addRowBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row before"}},{label:n.addRowAfter,command:"addRowAfter",icon:t.addRowAfter,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add row after"}},{label:n.addColumnBefore,command:"addColumnBefore",icon:t.addColumnBefore,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column before"}},{label:n.addColumnAfter,command:"addColumnAfter",icon:t.addColumnAfter,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Add column after"}},{label:n.deleteRow,command:"deleteRow",icon:t.deleteRow,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete row"}},{label:n.deleteColumn,command:"deleteColumn",icon:t.deleteColumn,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete column"}},{label:n.deleteTable,command:"deleteTable",icon:t.deleteTable,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete table"}},{label:n.removeBorders,command:"deleteCellAndTableBorders",icon:t.deleteBorders,bottomBorder:!0,props:{"data-item":"btn-tableActions-option",ariaLabel:"Delete cell and table borders"}},{label:n.mergeCells,command:"mergeCells",icon:t.mergeCells,props:{"data-item":"btn-tableActions-option",ariaLabel:"Merge cells"}},{label:n.splitCell,command:"splitCell",icon:t.splitCell,props:{"data-item":"btn-tableActions-option",ariaLabel:"Split cells"}},{label:n.fixTables,command:"fixTables",icon:t.fixTables,props:{"data-item":"btn-tableActions-option",ariaLabel:"Fix tables"}}];function N(Ke){return kr(xz,{options:A,onSelect:we=>{rs(Ke);const{command:Re}=we;e.emitCommand({item:Ke,argument:{command:Re}})}})}const X=pn({type:"dropdown",name:"textAlign",tooltip:n.textAlign,icon:t.alignLeft,command:"setTextAlign",hasCaret:!0,markName:"textAlign",labelAttr:"textAlign",suppressActiveHighlight:!0,attributes:{ariaLabel:"Text align"},options:[{type:"render",render:()=>kr("div",{},[kr(FN,{onSelect:we=>{rs(X);const Re={...X,command:"setTextAlign"};Re.command="setTextAlign",e.emitCommand({item:Re,argument:we}),te(X,we)}})]),key:"alignment"}],onActivate:({textAlign:Ke})=>{te(X,Ke)},onDeactivate:()=>{te(X,"left")}}),te=(Ke,we)=>{let Re=we==="both"?"justify":we,Oe={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Ue=Oe[Re]??Oe.left;Ke.icon.value=Ue},ae=pn({type:"dropdown",name:"list",command:"toggleBulletListStyle",splitButton:!0,splitButtonCommand:"toggleBulletList",icon:t.bulletList,hasCaret:!0,tooltip:n.bulletList,restoreEditorFocus:!0,attributes:{ariaLabel:"Bullet list"},options:[{type:"render",key:"bullet-style-buttons",render:()=>{const Ke=we=>{rs(ae);const Re={...ae,command:"toggleBulletListStyle"};e.emitCommand({item:Re,argument:we})};return kr(wk,{buttons:NN,iconSize:25,selectedStyle:ae.selectedValue.value,onSelect:Ke})}}]}),me=pn({type:"dropdown",name:"numberedlist",command:"toggleOrderedListStyle",splitButton:!0,splitButtonCommand:"toggleOrderedList",icon:t.numberedList,hasCaret:!0,tooltip:n.numberedList,restoreEditorFocus:!0,attributes:{ariaLabel:"Numbered list"},options:[{type:"render",key:"numbered-style-buttons",render:()=>{const Ke=we=>{rs(me);const Re={...me,command:"toggleOrderedListStyle"};e.emitCommand({item:Re,argument:we})};return kr(wk,{buttons:zN,iconSize:30,selectedStyle:me.selectedValue.value,onSelect:Ke})}}]}),He=pn({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),ce=pn({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),ve=pn({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),ue=pn({type:"dropdown",name:"zoom",allowWithoutEditor:!0,tooltip:n.zoom,defaultLabel:"100%",label:"100%",hasCaret:!0,command:"setZoom",isWide:!0,style:{width:"71px",minWidth:"71px"},inlineTextInputVisible:!1,hasInlineTextInput:!0,attributes:{ariaLabel:"Zoom"},options:[{label:"50%",key:.5,props:{"data-item":"btn-zoom-option"}},{label:"75%",key:.75,props:{"data-item":"btn-zoom-option"}},{label:"90%",key:.9,props:{"data-item":"btn-zoom-option"}},{label:"100%",key:1,props:{"data-item":"btn-zoom-option"}},{label:"125%",key:1.25,props:{"data-item":"btn-zoom-option"}},{label:"150%",key:1.5,props:{"data-item":"btn-zoom-option"}},{label:"200%",key:2,props:{"data-item":"btn-zoom-option"}}],onActivate:({zoom:Ke})=>{Ke&&(ue.label.value=Ke)}}),_e=pn({type:"dropdown",name:"measurementUnit",allowWithoutEditor:!0,tooltip:n.measurementUnit,defaultLabel:"in",label:"in",hasCaret:!0,command:"setMeasurementUnit",group:"right",style:{width:"52px",minWidth:"52px"},inlineTextInputVisible:!1,hasInlineTextInput:!1,attributes:{ariaLabel:"Measurement unit"},options:[{label:"Inches",key:"in",props:{"data-item":"btn-measurement-unit-option"}},{label:"Centimeters",key:"cm",props:{"data-item":"btn-measurement-unit-option"}}],onActivate:({measurementUnit:Ke})=>{Ke&&(_e.label.value=Ke)}}),ie=pn({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Te=pn({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),Ge=pn({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),$e=pn({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),ot=pn({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),xe=pn({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Me=(Ke,we)=>Ke==="editor"?we:Ke==="suggester"?we.filter(Re=>Re.value==="suggesting"):we.filter(Re=>Re.value==="viewing"),De=Ke=>Ke==="editor"?"Editing":Ke==="suggester"?"Suggesting":"Viewing",J=pn({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:De(s),label:De(s),hasCaret:s==="editor",isWide:!0,style:{display:"flex",justifyContent:"flex-end"},inlineTextInputVisible:!1,hasInlineTextInput:!1,group:"right",disabled:s!=="editor",attributes:{dropdownPosition:"right",className:"sd-toolbar-item--doc-mode",ariaLabel:"Document mode"},options:[{type:"render",render:()=>ne(J)}]}),w=[{label:n.documentEditingMode,value:"editing",icon:t.documentEditingMode,description:n.documentEditingModeDescription},{label:n.documentSuggestingMode,value:"suggesting",icon:t.documentSuggestingMode,description:n.documentSuggestingModeDescription},{label:n.documentViewingMode,value:"viewing",icon:t.documentViewingMode,description:n.documentViewingModeDescription}];function ne(Ke){return kr(qN,{options:Me(s,w),onSelect:we=>{const Re=e.superdoc?.activeEditor??e.activeEditor;rs(Ke);const{label:Oe,icon:Ue,value:kt}=we;J.label.value=Oe,J.icon.value=Ue,e.emitCommand({item:J,argument:kt}),k0(e,Re)}})}const F=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),V=["search","ruler","undo","overflow","documentMode"],U=pn({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),G=pn({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),Q=pn({type:"dropdown",name:"linkedStyles",command:"setLinkedStyle",tooltip:n.linkedStyles,icon:t.paintbrush,defaultLabel:n.formatText,label:n.formatText,hasCaret:!0,isWide:!0,style:{width:"140px"},suppressActiveHighlight:!0,disabled:!1,attributes:{className:"sd-toolbar-item--linked-styles",ariaLabel:"Linked styles"},options:[{type:"render",key:"linkedStyle",render:()=>{const Ke=Re=>{rs(Q);const Oe=typeof Re=="string"?Re:Re?.id??null;if(!Oe)return;const Ue={...Q,command:"setLinkedStyle"};e.emitCommand({item:Ue,argument:Oe})},we=e.getActiveLinkedStyleId?.()??null;return kr("div",{},[kr(ZN,{styles:e.getLinkedStyleOptions?.()??[],onSelect:Ke,selectedOption:we})])}}],onActivate:({styleId:Ke,styleName:we})=>{const Re=we||Ke;Q.label.value=Ke&&Ke!=="Normal"?String(Re):n.formatText,Q.disabled.value=!1},onDeactivate:()=>{Q.disabled.value=!0,Q.label.value=n.formatText}}),K=(Ke,we)=>{if(we.value==Ke)return kr("div",{innerHTML:Tz,class:"dropdown-select-icon"})},W=pn({type:"dropdown",name:"lineHeight",tooltip:n.lineHeight,icon:t.lineHeight,hasCaret:!1,hasInlineTextInput:!1,hideLabel:!0,inlineTextInputVisible:!1,suppressActiveHighlight:!0,isWide:!1,command:"setLineHeight",dropdownValueKey:"key",selectedValue:"1",attributes:{ariaLabel:"Line height"},options:[1,1.15,1.5,2,2.5,3].map(Ke=>({label:Ke.toFixed(2),key:Ke,icon:()=>K(Ke,W.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),de=20,Ce=32,be=V.reduce((Ke,we)=>Ke+(F.get(we)||F.get("default")),0),Be=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],rt=["zoom","fontFamily","fontSize","redo"],nt=i<=pf.lg,wt=e.config?.showFormattingMarksButton===!0,Nt=e.config?.showTableOfContentsButton===!0;nt&&(J.attributes.value={...J.attributes.value,className:`${J.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),nt&&(Q.attributes.value={...Q.attributes.value,className:`${Q.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let _t=[ie,Te,Ge,$e,x,ue,c,g,p,g,l,C,_,k,b,y,g,R,B,...Nt?[z]:[],Y,M,g,X,ae,me,He,ce,W,g,Q,g,U,_e,...wt?[G]:[],xe,ot,...Mz(e)?[d]:[],ve,J];if(i<=pf.md&&o&&(_t=_t.filter(Ke=>Ke.type!=="separator")),e.config.mode!=="docx"){const Ke=_t.findIndex(Re=>Re.name.value==="linkedStyles");_t.splice(Ke-1,2);const we=["ruler","zoom","undo","redo"];_t=_t.filter(Re=>!we.includes(Re.name.value))}const Tt=[];a||(s==="viewer"&&Tt.push(Ge,$e),_t=_t.filter(Ke=>!Tt.includes(Ke)));const Dt=Ke=>V.includes(Ke.name.value),rn=[],mn=[];let Ut=Ce+be;return _t.forEach(Ke=>{const we=F.get(Ke.name.value)||F.get("default");if(i<pf.xl+de&&Be.includes(Ke.name.value)&&o){if(rn.push(Ke),Ke.name.value==="linkedStyles"){const Re=_t.findIndex(Oe=>Oe.name.value==="linkedStyles");_t.splice(Re+1,1)}return}if(i<pf.sm&&rt.includes(Ke.name.value)&&o){rn.push(Ke);return}if(Dt(Ke)){mn.push(Ke),Ut+=we;return}Ut<i||!o?(mn.push(Ke),Ut+=we):rn.push(Ke)}),{defaultItems:mn,overflowItems:rn.filter(Ke=>Ke.type!=="separator")}},kk={bold:"Bold",fontFamily:"Font family",ai:"AI text generation",fontSize:"Font size",italic:"Italic",underline:"Underline",highlight:"Highlight color",strikethrough:"Strikethrough",color:"Text color",search:"Search",link:"Link",image:"Image",tableOfContents:"Table of contents",table:"Insert table",tableActions:"Table options",addRowBefore:"Insert row above",addRowAfter:"Insert row below",addColumnBefore:"Insert column left",addColumnAfter:"Insert column right",deleteRow:"Delete row",deleteColumn:"Delete column",deleteTable:"Delete table",removeBorders:"Remove borders",mergeCells:"Merge cells",splitCell:"Split cell",fixTables:"Fix tables",textAlign:"Alignment",bulletList:"Bullet list",numberedList:"Numbered list",indentLeft:"Left indent",indentRight:"Right indent",directionLtr:"Left-to-right",directionRtl:"Right-to-left",zoom:"Zoom",measurementUnit:"Measurement unit",undo:"Undo",redo:"Redo",trackChanges:"Track Changes",trackChangesAccept:"Accept changes under selection",trackChangesReject:"Reject changes under selection",trackChangesOriginal:"Toggle Show Original",trackChangesFinal:"Toggle Show Final",clearFormatting:"Clear formatting",copyFormat:"Format painter",lineHeight:"Line height",formatText:"Format text",ruler:"Show or hide ruler",formattingMarks:"Show or hide formatting marks",pageBreak:"Insert page break",documentEditingMode:"Editing",documentSuggestingMode:"Suggesting",documentViewingMode:"Viewing",documentEditingModeDescription:"Edit document directly",documentSuggestingModeDescription:"Edits become suggestions",documentViewingModeDescription:"View clean version of document only",linkedStyles:"Linked styles"},Pz=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;Et();function Ak(e){return aB(e)??S0[e]??null}function Gp(e,t,n,r={}){if(!e?.commands||!t||typeof e.commands.has=="function"&&!e.commands.has(t))return!1;const o=typeof e.commands.executeAsync=="function"?e.commands.executeAsync:e.commands.execute;if(typeof o!="function")return!1;const i=n===void 0?o.call(e.commands,t):o.call(e.commands,t,n);return i&&typeof i.then=="function"&&Promise.resolve(i).then(()=>r.onSettled?.(),s=>{r.onError?.(s),r.onSettled?.()}),!0}var Fz=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),Oz=new Set(["list","numberedlist"]);function Bz(e,t){if(e==="fontFamily"||e==="fontSize"||Oz.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!Fz.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function Ik(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function Nz(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var zz=class extends um.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Wn},texts:{...kk},fonts:null,hideButtons:!0,responsiveToContainer:!1,mode:"docx",excludeItems:[],groups:null,customButtons:[],showFormattingMarksButton:!1,showTableOfContentsButton:!1};toolbarItems=[];overflowItems=[];#t=null;#n=null;isDev=!1;role="editor";superdoc;toolbarContainer=null;toolbar=null;_detachFontsChanged=null;constructor(e={}){if(super(),this.config={...this.config,...e},this.toolbarItems=[],this.overflowItems=[],this.isDev=e.isDev||!1,this.superdoc=e.superdoc,this.role=e.role||"editor",this.toolbarContainer=null,this.config.icons={...Wn,...e.icons},this.config.texts={...kk,...e.texts},this.config.hideButtons=e.hideButtons??!0,this.config.responsiveToContainer=e.responsiveToContainer??!1,this.activeEditor=e.editor??this.superdoc?.activeEditor??null,this.ui=null,this.snapshot=null,this._unsubscribeController=null,this._detachFormatPainterModeChange=null,this._customCommandRegs=new Map,this._lastFontOptionsSignature="",!this.config.selector&&this.config.element&&(this.config.selector=this.config.element),this.toolbarContainer=Pz(this.config.selector),this.toolbarContainer){const t=(this.config?.uiDisplayFallbackFont||"").toString().trim()||"Arial, Helvetica, sans-serif";this.toolbarContainer.style.setProperty("--sd-ui-font-family",t)}if(this.#e(),this.#u(),this.#r(),this.#i(),this._lastFontOptionsSignature=this.#a(),!this.toolbarContainer){this.updateToolbarState();return}this.app=Dl(MN),this.app.directive("click-outside",hv),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}#e(){this.superdoc&&(this.ui=Gy({superdoc:this.superdoc}),this.snapshot=this.ui.toolbar.getSnapshot(),this._unsubscribeController=this.ui.toolbar.subscribe(()=>{this.snapshot=this.ui.toolbar.getSnapshot(),this.updateToolbarState()}),this._detachFormatPainterModeChange=this.ui.formatPainter.onModeChange(e=>{e==="armed"||e==="persistent"?this.#R():this.#S()}))}#o(){this._unsubscribeController?.(),this._unsubscribeController=null,this._detachFormatPainterModeChange?.(),this._detachFormatPainterModeChange=null,this.#S();for(const e of this._customCommandRegs.values())try{e.unregister?.()}catch{}this._customCommandRegs.clear();try{this.ui?.destroy?.()}catch{}this.ui=null,this.snapshot=null}#i(){if(!this.superdoc||typeof this.superdoc.on!="function"||typeof this.superdoc.off!="function")return;const e=()=>{const t=this.#a();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.updateToolbarState()};this.superdoc.on("fonts-changed",e),this._detachFontsChanged=()=>{this.superdoc?.off?.("fonts-changed",e)}}#s(){this._detachFontsChanged?.(),this._detachFontsChanged=null}#u(){this.config.groups&&!Array.isArray(this.config.groups)&&Object.keys(this.config.groups).length&&(this.config.toolbarGroups=Object.keys(this.config.groups))}getAvailableWidth(){const e=document.documentElement.clientWidth,t=this.toolbarContainer?.offsetWidth??0;return this.config.responsiveToContainer?t:e}#d(e){return e||IN(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#r(){const e=this.getAvailableWidth(),{defaultItems:t,overflowItems:n}=Dz({superToolbar:this,toolbarIcons:this.config.icons,toolbarTexts:this.config.texts,toolbarFonts:this.#d(this.config.fonts),hideButtons:this.config.hideButtons,availableWidth:e,role:this.role,isDev:this.isDev}),r=this.config.customButtons||[],o=r.map(a=>this.#f(a));r.length&&t.push(...o);let i=[...t.map(a=>a.name.value),...n.map(a=>a.name.value)];if(this.config.groups){const a=Object.values(this.config.groups).flatMap(c=>c),l=new Set(Object.keys(this.config.groups)),u=o.filter(c=>l.has(c.group?.value||"center")).map(c=>c.name.value);i=[...new Set([...a,...u])]}const s=t.filter(a=>i.includes(a.name.value)).filter(a=>!this.config.excludeItems.includes(a.name.value));if(this.config.groups)for(const[a,l]of Object.entries(this.config.groups))for(const u of s)l.includes(u.name.value)&&(u.group.value=a);this.toolbarItems=s,this.overflowItems=n.filter(a=>i.includes(a.name.value))}#f(e){const t=pn({...e});t.isCustomToolbarItem=!0;const n=e.command;if(typeof n=="function"&&this.ui?.commands?.register){const r=`__builtin_toolbar__${e.name}`;if(!this._customCommandRegs.has(r)){const o=this.ui.commands.register({id:r,execute:i=>{const s=i?.payload&&typeof i.payload=="object"?i.payload:{};return n({...i,item:t,argument:s.argument,option:s.option})}});this._customCommandRegs.set(r,o)}}return t}#p(){this.#r(),this.emit("toolbar-items-changed")}#a(){if(this.config.fonts)return"custom-fonts";const e=this.superdoc?.fonts?.getFontFamilyOptions?.()??[];return JSON.stringify(e.map(t=>[t.label,t.value,t.previewFamily]))}getToolbarItemByGroup(e){return this.toolbarItems.filter(t=>(t.group?.value||"center")===e)}getToolbarItemByName(e){return this.#c().find(t=>t.name.value===e)}#c(){return[...this.toolbarItems,...this.overflowItems]}getLinkedStyleOptions(){return this.ui?.styles?.getQuickGallery?.()??[]}getActiveLinkedStyleId(){return this.ui?.styles?.getActiveParagraphStyle?.()?.styleId??null}setActiveEditor(e){this.activeEditor=e;const t=this.#a();t!==this._lastFontOptionsSignature&&(this._lastFontOptionsSignature=t,this.#p()),this.ui&&(this.snapshot=this.ui.toolbar.getSnapshot()),this.updateToolbarState()}onToolbarResize=()=>{this.#r(),this.updateToolbarState()};#g(e){return e==="ruler"?!!this.superdoc?.config?.rulers:e==="formattingMarks"?!!this.superdoc?.config?.layoutEngineOptions?.showFormattingMarks:!1}#C(e){return e==="ruler"?typeof this.superdoc?.toggleRuler=="function":e==="formattingMarks"?typeof this.superdoc?.toggleFormattingMarks=="function"||typeof this.superdoc?.setShowFormattingMarks=="function":!1}#w(){const e=this.getToolbarItemByName("documentMode");if(!e)return;const t=(this.snapshot?.commands?.["document-mode"]?.value||"editing").toLowerCase(),n=this.config.texts||{},r=this.config.icons||{},o={editing:{label:n.documentEditingMode||"Editing",icon:r.documentEditingMode||r.documentMode},suggesting:{label:n.documentSuggestingMode||"Suggesting",icon:r.documentSuggestingMode||r.documentMode},viewing:{label:n.documentViewingMode||"Viewing",icon:r.documentViewingMode||r.documentMode}},i=o[t]||o.editing;e.label?.value!==void 0&&(e.label.value=i.label),e.defaultLabel?.value!==void 0&&(e.defaultLabel.value=i.label),e.icon?.value!==void 0&&i.icon&&(e.icon.value=i.icon)}#_(){const e=this.toolbarItems.find(n=>n.name.value==="highlight");if(!e)return;const t={key:"color",type:"render",render:()=>A0(this,e,[],!0)};e.nestedOptions.value=[t]}#l(e){return!!e?.active&&e?.value==null}#E(e){return!!e&&e.disabled===!1&&e.value==null}#x(e){const t=e.name.value;if(t==="tableActions"){const i=bk.map(s=>this.snapshot?.commands?.[s]).some(s=>s&&!s.disabled);return e.setDisabled(!i),!0}if(t==="search")return e.setDisabled(!1),!0;if(C0(t)?.disposition==="host-routed")return e.setDisabled(!this.#C(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=Ak(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];Bz(t,r)?e.setDisabled(!1):e.setDisabled(!!r?.disabled);const o={textAlign:()=>{r?.value?e.activate({textAlign:r.value}):e.deactivate()},lineHeight:()=>{e.selectedValue.value=r?.value!=null?r.value:""},zoom:()=>{if(r?.value!=null){const i=typeof r.value=="number"?`${r.value}%`:String(r.value);e.onActivate({zoom:i})}},measurementUnit:()=>{r?.value!=null&&e.onActivate({measurementUnit:String(r.value)})},documentMode:()=>{this.#w()},link:()=>{e.active.value=!!r?.active,e.attributes.value=r?.value?{href:r.value}:{}},fontFamily:()=>{if(r?.value!=null){e.activate({fontFamily:r.value});return}if(this.#E(r)){e.activate({},!0);return}e.deactivate()},fontSize:()=>{if(r?.value!=null){e.activate({fontSize:r.value});return}if(this.#l(r)){e.activate({},!0);return}e.deactivate()},color:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},highlight:()=>{r?.value!=null?e.activate({color:r.value}):e.deactivate()},linkedStyles:()=>{const i=r?.value,s=typeof i=="string"?i:i?.styleId,a=i&&typeof i=="object"?i.styleName:null;s?e.activate({styleId:s,styleName:a}):e.label.value=this.config.texts?.formatText||"Format text"},list:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},numberedlist:()=>{r?.active?(e.activate(),e.selectedValue.value=r.value):(e.deactivate(),e.selectedValue.value=null)},default:()=>{r?.active?e.activate():e.deactivate()}};return(o[t]??o.default)(),!0}updateToolbarState(){this.#w(),this.#_();const e=this.snapshot?.commands?.["document-mode"]?.value||"editing";!(this.snapshot&&(this.superdoc?.activeEditor??this.activeEditor))||e==="viewing"?(this.#V(),this.#c().forEach(n=>{n.allowWithoutEditor?.value&&this.#x(n)})):this.#c().forEach(n=>{n.resetDisabled(),this.#x(n)});const t=this.getToolbarItemByName("copyFormat");t&&(this.snapshot?.copyFormatActive?t.activate():t.deactivate()),this.emit("toolbar-state-change")}#V(){this.#c().forEach(e=>{const{allowWithoutEditor:t}=e;t?.value||e.setDisabled(!0)})}#D(e,t){const n=this.superdoc;if(e==="ruler")return typeof n?.toggleRuler=="function"?(n.toggleRuler(),!0):!1;if(e==="formattingMarks"){if(typeof t=="boolean"&&typeof n?.setShowFormattingMarks=="function")return n.setShowFormattingMarks(t),!0;if(typeof n?.toggleFormattingMarks=="function")return n.toggleFormattingMarks(),!0}return!1}#A(e,t){const n=e?.name?.value;if(!n)return!1;const r={onSettled:()=>this.updateToolbarState(),onError:i=>this.#m(i,n)};if(n==="image"&&t==null)return this.#T();if(n==="tableActions"){const i=yk[t?.command];return i?Gp(this.ui,i,void 0,r):!1}if(C0(n)?.disposition==="unsupported")return!0;const o=Ak(n);return o?Gp(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=pB({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await fB(e,this.superdoc?.config?.handleImageUpload);Gp(this.ui,"image",{src:t},{onSettled:()=>this.updateToolbarState(),onError:n=>this.#m(n,"image")})},onError:e=>this.#m(e,"image")})),this.#t.open()),!0}#R(){if(this.#n)return;const e=this.superdoc?.activeEditor?.container??document,t=i=>{Ik(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!Ik(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}Nz(i)&&this.ui.formatPainter.setKeyboardSelecting(!0)},o=()=>{this.ui.formatPainter.setKeyboardSelecting(!1),this.ui.formatPainter.notifyKeyUp()};e.addEventListener("pointerdown",t),e.addEventListener("pointerup",n),e.addEventListener("keydown",r),e.addEventListener("keyup",o),this.#n=()=>{e.removeEventListener("pointerdown",t),e.removeEventListener("pointerup",n),e.removeEventListener("keydown",r),e.removeEventListener("keyup",o)}}#S(){this.#n&&(this.#n(),this.#n=null)}#m(e,t){const n=e instanceof Error?e:new Error(String(e));this.emit("exception",{error:n,originalError:e,itemName:t??null,editor:this.superdoc?.activeEditor??this.activeEditor??null})}emitCommand({item:e,argument:t,option:n}){const r=e?.name?.value,{command:o}=e,i=t!=null;if(!(e?.type==="dropdown"&&!i&&(o==="setFontFamily"||o==="setFontSize"))){if(r==="search"){this.superdoc?.emit?.("search:open");return}try{if(C0(r)?.disposition==="host-routed"){this.#D(r,t),this.updateToolbarState();return}if(typeof o=="function"){const s=`__builtin_toolbar__${r}`;this._customCommandRegs.has(s)&&this.ui?.commands?.execute?this.ui.commands.execute(s,{argument:t,option:n}):o({item:e,argument:t,option:n,ui:this.ui,superdoc:this.superdoc}),this.updateToolbarState();return}if(e?.isCustomToolbarItem&&typeof o=="string"){if(!Gp(this.ui,o,t,{onSettled:()=>this.updateToolbarState(),onError:s=>this.#m(s,r)}))throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState();return}if(!this.#A(e,t)&&o)throw new Error(`[superdoc toolbar] Command not handled: ${String(o)}`);this.updateToolbarState()}catch(s){this.#m(s,r)}}}destroy(){this.#S(),this.#t?.destroy(),this.#t=null,this.#s(),this.#o(),this.app?.unmount(),this.app=null,this.toolbar=null}};function Hz(e){return new zz(e)}Et();var Uz=Object.freeze(["#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F","#BB8FCE","#85C1E2","#F1948A","#82E0AA","#F8C471","#AED6F1","#D7BDE2","#A3E4D7","#F0B27A","#AEB6BF","#E74C3C","#2ECC71","#3498DB","#E67E22","#1ABC9C","#9B59B6","#34495E","#F39C12"]);async function Vz(e,t){const n=new sI.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function I0(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function Ek(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function jz(e,t){if(!e)return()=>{};if(I0(e))return t(),()=>{};const n=typeof e.on=="function"?e.on.bind(e):null,r=typeof e.off=="function"?e.off.bind(e):null;if(!n)return t(),()=>{};let o=!1;const i=()=>{o||(o=!0,r?.("synced",a),r?.("sync",l))},s=()=>{o||(i(),t())},a=()=>{Ek(e),s()},l=u=>{u!==!1&&(u===!0||I0(e))&&(Ek(e),s())};return n("synced",a),n("sync",l),I0(e)&&s(),i}function fi(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function Gz(e){const t=e&&typeof e=="object"?e.code:null;return t==="comment-export-missing-story-reference"||t==="v2-worker-comment-export-mode-unsupported"}function xk(e){return typeof e=="string"&&e.length>0?e:null}function E0(e){return e?fi(e)?xk(e.documentId??e.options?.documentId??null):xk(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function Wz(e){if(!e||fi(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function Mi(e){if(!e)return null;if(fi(e))return e.fonts??null;const t=Wz(e);return t?{getReport:()=>t.getFontReport?.()??[],getMissingFonts:()=>t.getMissingFonts?.()??[],getDocumentFonts:()=>[...new Set((t.getFontReport?.()??[]).map(n=>n.logicalFamily))],getDocumentFontOptions:()=>t.getDocumentFontOptions?.()??[],getFontFamilyOptions:()=>t.getFontFamilyOptions?.()??[],getLastFontsChangedPayload:()=>t.getLastFontsChangedPayload?.()??null,map:n=>t.mapFonts(n),unmap:n=>t.unmapFonts(n),add:n=>t.addFonts(Array.isArray(n)?n:[n]),preload:n=>t.preloadFonts(n)}:null}var Wp=class extends um.default{static{this.allowedTypes=[wr,Pl,kh]}#t=!1;#n=!1;#e=null;#o=null;#i=null;#s=null;#u=null;#d;#r=new iB;#f=null;#p=!1;constructor(e){if(super(),this.version="0.0.0",this.users=[],this.whiteboard=null,this.colors=[],this.readyEditors=0,this.pendingCollaborationSaves=0,this.config={selector:"#superdoc",documentMode:"editing",allowSelectionInViewMode:!1,role:"editor",document:{},documents:[],editorExtensions:[],colors:[],users:[],user:{...w0},layoutEngineOptions:{},modules:{},licenseKey:void 0,telemetry:{enabled:!0},title:"SuperDoc",conversations:[],isInternal:!1,comments:{visible:!1},toolbarGroups:["left","center","right"],toolbarIcons:{},toolbarTexts:{},uiDisplayFallbackFont:"Arial, Helvetica, sans-serif",isDev:!1,disablePiniaDevtools:!1,onEditorBeforeCreate:()=>null,onEditorCreate:()=>null,onEditorDestroy:()=>null,onSourceComplete:()=>null,onSourceSignalsComplete:()=>null,onContentError:()=>null,onReady:()=>null,onCommentsUpdate:()=>null,onContentControlActiveChange:()=>null,onContentControlClick:()=>null,onAwarenessUpdate:()=>null,onLocked:()=>null,onPdfDocumentReady:()=>null,onSidebarToggle:()=>null,onCollaborationReady:()=>null,onEditorUpdate:()=>null,onCommentsListChange:()=>null,onException:()=>null,onListDefinitionsChange:()=>null,onPaginationUpdate:()=>null,onTransaction:()=>null,disableContextMenu:!1,viewOptions:{layout:"print"},useLayoutEngine:!0},!e.selector)throw new Error("SuperDoc: selector is required");const t=typeof e.selector=="string"?document.querySelector(e.selector):e.selector;if(!(t instanceof HTMLElement))throw new Error("SuperDoc: selector must be a valid CSS selector string or DOM element");this.#d=new QO({getModuleConfig:()=>this.config.modules?.surfaces}),this.#a(e,t)}async#a(e,t){this.config={...this.config,...e},!this.config.comments||typeof this.config.comments!="object"?this.config.comments={visible:!1}:typeof this.config.comments.visible!="boolean"&&(this.config.comments.visible=!1),rB(this.config),this.config.documents=this.config.documents||[],this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};const n=this.config.viewOptions?.layout==="web",r=this.config.layoutEngineOptions?.flowMode==="semantic";if(n&&this.config.useLayoutEngine&&!r&&(console.warn("[SuperDoc] Web layout uses PM fallback unless layoutEngineOptions.flowMode is set to 'semantic'. Automatically disabling layout engine."),this.config.useLayoutEngine=!1),!n&&r&&(console.warn("[SuperDoc] flowMode 'semantic' is only valid with web layout. Coercing to 'paginated'."),this.config.layoutEngineOptions.flowMode="paginated"),this.editorVersion=2,this.#he(),this.config.user=oB(this.config.user),this.config.layoutEngineOptions.virtualization||(this.config.layoutEngineOptions.virtualization={enabled:!0,window:5,overscan:1}),this.config.modules=this.config.modules||{},Object.prototype.hasOwnProperty.call(this.config.modules,"comments")||(this.config.modules.comments={}),this.config.modules.comments=ER(this.config.modules.comments),this.config.colors=pI(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.0.0-next.38",this.#b("π¦ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||Hi(),this.colors=this.config.colors??[],this.#w(),await bx(),this.#t)return;if(await this.#x(this.config.modules),this.#t){this.#ae();return}this.config.cspNonce&&this.#C(),this.user=this.config.user,this.users=this.config.users||[],this.socket=null,this.isDev=this.config.isDev||!1,this.activeEditor=null,this.comments=[],this.#f||(this.#f=this.#r.subscribe(i=>{this.#me(i.nextRuntimeId,i.legacyEditorProjection)})),this.isLocked=this.config.isLocked||!1,this.lockedBy=this.config.lockedBy||null;const o=document.createElement("div");o.style.display="contents",t.appendChild(o),this.#u=o,this.#E(),this.#g(),this.#ge(),this.#c()}#c(){if(this.#_(),this.readyEditors=0,!this.app)throw new Error("SuperDoc: #startRuntime called before #initVueApp populated this.app");this.app.mount(this.#u)}#g(){const e=this.config.modules?.whiteboard,t=e!==!1&&(e?.enabled??!1);this.whiteboard=new SP({Renderer:qO,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===wr).length}get state(){return{documents:this.#h("state").documents,users:this.users}}getDocumentRuntimeForDocument(e){return typeof e!="string"||e.length===0?null:(this.superdocStore?.documents??[]).find(t=>t?.getEditor?.()?.options?.documentId===e)?.getDocumentRuntime?.()??null}getComment(e){return typeof e!="string"||e.length===0?null:this.commentsStore?.getComment?.(e)??null}get element(){return typeof this.config.selector=="string"?document.querySelector(this.config.selector):this.config.selector}#C(){const e=this.config.cspNonce,t=document.createElement;document.createElement=function(n){const r=t.call(this,n);return n.toLowerCase()==="style"&&r.setAttribute("nonce",e),r}}#w(){const e=this.config.document,t=!!e&&typeof e=="object"&&Object.keys(e)?.length,n=!!e&&typeof e=="string"&&e.length>0,r=!!e&&typeof File=="function"&&e instanceof File,o=!!e&&e instanceof Blob&&!(e instanceof File),i=this.config.documents&&this.config.documents?.length;if(t&&i&&console.warn("π¦ [superdoc] You can only provide one of document or documents"),t){const s=kd(this.config.document);this.config.documents=[{id:Hi(),...s}]}else if(n)this.config.documents=[{id:Hi(),type:wr,url:this.config.document,name:"document.docx"}];else if(r){const s=kd(this.config.document);this.config.documents=[{id:Hi(),...s}]}else if(o){const s=kd(this.config.document);this.config.documents=[{id:Hi(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=kd(s);if(!a||typeof a!="object")return a;const l=typeof a=="object"&&"id"in a&&a.id||s&&typeof s=="object"&&"id"in s&&s.id;return{...a,id:l||Hi()}}))}#_(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=dP({disablePiniaDevtools:!!this.config.disablePiniaDevtools});this.app=e,this.pinia=t,this.app.config.globalProperties.$config=this.config,this.app.config.globalProperties.$documentMode=this.config.documentMode,this.app.config.globalProperties.$superdoc=this,this.app.provide("surfaceManager",this.#d),this.superdocStore=n,this.commentsStore=r,this.highContrastModeStore=o,typeof this.superdocStore.setExceptionHandler=="function"&&this.superdocStore.setExceptionHandler(s=>this.emit("exception",s)),this.superdocStore.init(this.config);const i=this.config.modules.comments;this.commentsStore.init(i||{}),this.isCollaborative&&ox(this),this.#se()}#l(e,t){t&&this.on(e,t)}#E(){this.#l("editorBeforeCreate",this.config.onEditorBeforeCreate),this.#l("editorCreate",this.config.onEditorCreate),this.#l("editorDestroy",this.config.onEditorDestroy),this.#l("source:complete",this.config.onSourceComplete),this.#l("source:signals-complete",this.config.onSourceSignalsComplete),this.#l("ready",this.config.onReady),this.#l("comments-update",this.config.onCommentsUpdate),this.#l("content-control:active-change",this.config.onContentControlActiveChange),this.#l("content-control:click",this.config.onContentControlClick),this.#l("awareness-update",this.config.onAwarenessUpdate),this.#l("locked",this.config.onLocked),this.#l("pdf:document-ready",this.config.onPdfDocumentReady),this.#l("sidebar-toggle",this.config.onSidebarToggle),this.#l("collaboration-ready",this.config.onCollaborationReady),this.on("collaboration-ready",e=>this.#T(e?.editor??null)),this.#l("editor-update",this.config.onEditorUpdate),this.on("content-error",this.onContentError),this.#l("exception",this.config.onException),this.#l("list-definitions-change",this.config.onListDefinitionsChange),this.#l("pagination-update",this.config.onPaginationUpdate),this.#l("fonts-resolved",this.config.onFontsResolved),this.#l("fonts-changed",this.config.onFontsChanged),this.#l("zoomChange",this.config.onZoomChange),this.#l("viewport-change",this.config.onViewportChange)}async#x({collaboration:e}={}){return e?(this.isCollaborative=!1,this.config.documents.length===0&&(this.config.documents=[{id:Hi(),type:wr,name:"document.docx"}]),this.config.v2CollaborationPreflightFailure={code:"collaboration-v1-config-unsupported",message:"SuperDoc v2 cannot use modules.collaboration because it is the SuperDoc v1 collaboration API. SuperDoc did not attach the provider or change the document. Configure Document.v2Collaboration with a v2 room instead."},this.config.documents):this.config.documents}#V(e,t){this.isCollaborative=!0,this._commentsCollabInitialized=!1,this.ydoc=Pr(e),this.provider=Pr(t),this.#P();const n=this.config;this._cleanupAwareness=$8(t,this,n.user),n.documents.forEach(r=>{r.ydoc=e,r.provider=t,r.role=this.config.role})}#D(){this.#s=null,this.#A(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null),this.isCollaborative=!1,this._commentsCollabInitialized=!1,this.ydoc=void 0,this.provider=void 0;const e=this.config;delete e.modules.collaboration,e.documents.forEach(t=>{delete t.ydoc,delete t.provider})}#A(){if(this.#o){try{this.#o()}catch{}this.#o=null}if(this.#i){try{this.#i()}catch{}this.#i=null}}#T(e){this.#A(),fi(e)&&(this.#R(e),this.#S(e))}#R(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=bP(()=>this.user),r=o=>{if(this.#t)return;const i=n.next(o);this.emit("awareness-update",{...i,superdoc:this})};try{const o=t.getSnapshot?.();o&&r(o),this.#o=t.subscribe(r)}catch(o){console.warn("[SuperDoc] v2 awareness bridge failed to subscribe",o)}}#S(e){const t=e.lock;if(!t||typeof t.subscribe!="function")return;const n=r=>{this.#t||this.#I(!!r.isLocked,this.#m(r.lockedBy??null))};try{if(this.#s&&typeof t.setLocked=="function"){const o=this.#s;t.setLocked(o.isLocked,o.isLocked?o.lockedBy:null),this.#s=null}const r=t.getSnapshot?.();r&&n(r),this.#i=t.subscribe(n)}catch(r){console.warn("[SuperDoc] v2 lock bridge failed to subscribe",r)}}#m(e){return!e||typeof e!="object"||Array.isArray(e)?null:{...e}}#j(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}#I(e,t){this.isLocked===e&&this.#j(this.lockedBy,t)||(this.isLocked=e,this.lockedBy=t,this.#b("π¦ [superdoc] Locking superdoc:",e,t,`
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
`),this.emit("locked",{isLocked:e,lockedBy:t}))}#P(){const e=this.config.user;if(!e||e.color)return;const t=this.colors.length>0?this.colors:Uz,n=e.id||e.email||e.name||"";let r=5381;for(let o=0;o<n.length;o++)r=(r<<5)+r^n.charCodeAt(o);e.color=t[Math.abs(r)%t.length]}async upgradeToCollaboration(e){const{target:t,mountedDocumentId:n}=this.#ce(e);this.#n=!0;try{const r=await this.#X(),o=this.#F(),i=this.#G();this.#W();let s=null;try{this.#s=i,s=this.#le(n);const a=this.#q(t,r);await s,this.#Y(a,t),this.#s=null}catch(a){if(s&&this.#e){const l=this.#e;this.#e=null,l(),await s.catch(()=>{})}throw this.#M(o),a}}finally{this.#e=null,this.#n=!1}}#G(){return{isLocked:this.isLocked,lockedBy:this.lockedBy?{...this.lockedBy}:null}}#F(){const e=this.config.documents.find(r=>r.type===wr),t=this.superdocStore?.documents.find(r=>r.id===e.id)??null,n=t?sn(t):null;return{isCollaborative:this.isCollaborative,configV2Collaboration:e.v2Collaboration??null,configData:e.data,storeDoc:t,storeV2Collaboration:this.#K(n),storeData:t?.data}}#M(e){this.#s=null;const t=this.config.documents.find(n=>n.type===wr);t.v2Collaboration=e.configV2Collaboration,t.data=e.configData,this.isCollaborative=e.isCollaborative,e.storeDoc&&(e.storeDoc.data=e.storeData,this.#k(e.storeDoc,e.storeV2Collaboration),this.#B(e.storeDoc))}#W(){if(this.#t)throw new Error("SuperDoc: instance was destroyed during upgrade")}#h(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.superdocStore}#v(e){if(!this.commentsStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`);return this.commentsStore}#y(e){if(!this.superdocStore)throw new Error(`SuperDoc: ${e} requires the instance to be ready; wait for the "ready" event before calling.`)}#O(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=sn(r);o.ydoc&&typeof o.ydoc=="object"&&"value"in o.ydoc&&(o.ydoc.value=e),o.provider&&typeof o.provider=="object"&&"value"in o.provider&&(o.provider.value=t)}}#K(e){if(!e)return null;const t=e.v2Collaboration;return t&&typeof t=="object"&&"value"in t?t.value:t??null}#k(e,t){const n=sn(e).v2Collaboration;if(n&&typeof n=="object"&&"value"in n){n.value=t;return}e.v2Collaboration=t}#B(e){const t=sn(e).editorMountNonce;if(t&&typeof t=="object"&&"value"in t&&typeof t.value=="number"){t.value+=1;return}const n=e;n.editorMountNonce=(typeof n.editorMountNonce=="number"?n.editorMountNonce:0)+1}#N(e){return e.providerFamily==="liveblocks"?{providerType:"liveblocks",documentId:e.documentId,roomMode:e.roomMode,...e.publicApiKey?{publicApiKey:e.publicApiKey}:{},...e.authEndpoint?{authEndpoint:e.authEndpoint}:{}}:e.providerFamily==="hocuspocus"?{providerType:"hocuspocus",documentId:e.documentId,roomMode:e.roomMode,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{},...e.token?{token:e.token}:{}}:{providerType:"y-websocket",documentId:e.documentId,roomMode:e.roomMode,...e.serverUrl?{serverUrl:e.serverUrl}:{},...e.params?{params:e.params}:{}}}#q(e,t){const n=this.config.documents.find(i=>i.type===wr),r=this.#h("upgradeToCollaboration").documents.find(i=>i.id===n.id);if(!r)throw new Error("SuperDoc: source document store entry is not available for upgrade");const o=this.#N({...e,roomMode:"create"});return n.data=t,n.v2Collaboration=o,r.data=t,this.#k(r,o),this.isCollaborative=!0,this.readyEditors=0,this.#B(r),{configDoc:n,storeDoc:r}}#Y(e,t){const n=this.#N({...t,roomMode:"join"});e.configDoc.v2Collaboration=n,this.#k(e.storeDoc,n)}async#X(){const e=this.activeEditor;if(fi(e)&&typeof e.save=="function"){const r=await e.save();return this.#L(r)}const t=this.config.documents.find(r=>r.type===wr),n=(this.superdocStore?.documents.find(r=>r.id===t.id)??null)?.data??t.data;if(n instanceof Blob)return n;if(n instanceof Uint8Array||n instanceof ArrayBuffer)return this.#L(n);throw new Error("SuperDoc: upgradeToCollaboration() requires a live v2 editor save or DOCX Blob source")}#L(e){if(e instanceof Blob)return e;if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),new Blob([t],{type:wr})}if(e instanceof ArrayBuffer)return new Blob([e],{type:wr});throw new Error("SuperDoc: active v2 editor returned an unsupported DOCX save payload")}#J(e,t){const n=E0(e),r=(n?this.config.documents.find(a=>a.id===n):null)??this.config.documents.find(a=>a.type==="application/vnd.openxmlformats-officedocument.wordprocessingml.document");if(!r)return;const o=this.#L(t),i=r.v2Collaboration&&typeof r.v2Collaboration=="object"&&r.v2Collaboration.roomMode==="create"?{...r.v2Collaboration,roomMode:"join"}:null;r.data=o,i&&(r.v2Collaboration=i);const s=this.superdocStore?.documents.find(a=>a.id===r.id)??null;s&&(s.data=o,i&&this.#k(s,i))}#we(){const e=this.superdocStore?.documents;if(!e?.length)throw new Error("SuperDoc: no store documents available for upgrade");const t=e[0].getDocumentRuntime?.()||e[0].getEditor?.();if(!t?.attachCollaboration)throw new Error("SuperDoc: editor does not support attachCollaboration");return t}#Ce(){this.#D(),this.#O(null,null)}#_e(e){const n=e.editor??e;return n.options?.collaborationIsReady?Promise.resolve():new Promise(r=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(s),typeof n.off=="function"&&n.off("collaborationReady",a))},s=setTimeout(()=>{i(),console.warn("[SuperDoc] collaborationReady did not fire within 10 s after collaboration attach. Continuing β collaboration is active but cursor/presence setup may be delayed."),r(void 0)},1e4),a=()=>{i(),r(void 0)};this.#e=()=>{i(),r(void 0)},typeof n.on=="function"?n.on("collaborationReady",a):(i(),r(void 0))})}#le(e){return new Promise((n,r)=>{let o=!1;const i=()=>{o||(o=!0,clearTimeout(a),this.off("collaboration-ready",s))},s=l=>{const u=l?.editor;fi(u)&&E0(u)===e&&(!u.presence&&!u.lock||(i(),n()))},a=setTimeout(()=>{i(),r(new Error(`SuperDoc: v2 collaboration runtime did not become ready within 20000 ms for mounted document "${e}".`))},2e4);this.on("collaboration-ready",s),this.#e=()=>{i(),r(new Error("SuperDoc: instance was destroyed during upgrade"))}})}#Se(e){return new Promise((n,r)=>{let o,i=!1,s=()=>{};const a=()=>{i=!0,clearTimeout(o),s()};s=jz(e,()=>{i||(a(),n())}),i||(o=setTimeout(()=>{a(),r(new Error("SuperDoc: collaboration provider did not sync within 10000 ms. The provider exposes on/off but never emitted sync(true) or synced."))},1e4)),this.#e=()=>{i||(a(),r(new Error("SuperDoc: instance was destroyed during upgrade")))}})}#ce(e){if(this.#t)throw new Error("SuperDoc: cannot upgrade a destroyed instance");if(this.#n)throw new Error("SuperDoc: upgrade already in progress");if(this.isCollaborative)throw new Error("SuperDoc: instance is already collaborative");const t=this.config,n=t.documents.filter(l=>l.type===wr);if(n.length===0)throw new Error("SuperDoc: no DOCX document found for upgrade");if(n.length>1)throw new Error("SuperDoc: upgradeToCollaboration() only supports a single DOCX document");if(t.documents.length!==n.length)throw new Error("SuperDoc: upgradeToCollaboration() only supports single-DOCX instances");if(!fi(this.#de()))throw new Error("SuperDoc: upgradeToCollaboration() requires a ready v2 DOCX editor");const r=n[0],o=r.id;if(typeof o!="string"||o.length===0)throw new Error("SuperDoc: source document is missing its mounted document identity");const i=t.modules?.collaboration,s=e.ydoc||e.provider?{ydoc:e.ydoc,provider:e.provider}:i?{...i}:null,a=S4({v2Collaboration:e.v2Collaboration??this.#ue(r.v2Collaboration)??i?.v2Collaboration??i?.v2??null,legacyCollaboration:s,documentType:wr,documentCount:t.documents.length,...typeof window<"u"?{authEndpointBaseUrl:window.location.href}:{}});if(!a.ok)throw new Error(`SuperDoc: upgradeToCollaboration() ${a.reason}: ${a.message}`);return{target:a.target,mountedDocumentId:o}}#ue(e){return e&&typeof e=="object"&&"value"in e?e.value:e}#de(){const e=this.config.documents.find(n=>n.type===wr),t=this.#h("upgradeToCollaboration").documents.find(n=>n.id===e.id)?.getEditor?.();if(!t)throw new Error("SuperDoc: source editor not yet created β wait for the ready event before upgrading");return t}addSharedUser(e){this.#y("addSharedUser");const t=Fc({actor:e});t&&this.users.some(n=>Fc({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#y("removeSharedUser");const t=typeof e=="string"?dv(e):"",n=typeof e=="string"?`email:${t}`:Fc({actor:e});this.users=this.users.filter(r=>{const o=Fc({actor:r});return n?o!==n:t?dv(r.email)!==t:!0})}onContentError({error:e,editor:t}){const n=t.options?.documentId,r=this.#h("onContentError").documents.find(i=>i.id===n),o=typeof r?.id=="string"?r.id:typeof n=="string"?n:"";this.config.onContentError?.({error:e,editor:t,documentId:o,file:r?.data})}broadcastPdfDocumentReady(){this.emit("pdf:document-ready")}broadcastReady(){this.readyEditors===this.requiredNumberOfEditors&&this.emit("ready",{superdoc:this})}broadcastEditorBeforeCreate(e){this.emit("editorBeforeCreate",{editor:ik(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#fe(e),this.emit("editorCreate",{editor:ik(e)})}broadcastSourceComplete(){this.emit("source:complete")}broadcastSourceSignalsComplete(){this.emit("source:signals-complete")}#$=new WeakSet;#fe(e){if(!e||typeof e.on!="function"||this.#$.has(e))return;this.#$.add(e),e.on("fonts-changed",n=>{this.#ee(e)&&this.#z(n)});const t=(e.documentRenderer??e.presentationEditor)?.getLastFontsChangedPayload?.();t&&this.#ee(e)&&this.#z(t)}#ee(e){return!this.activeEditor||e===this.activeEditor}#te=null;#z(e){this.#te=e,this.emit("fonts-changed",e)}broadcastEditorDestroy(){this.emit("editorDestroy")}broadcastSidebarToggle(e){this.emit("sidebar-toggle",e)}#he(){Array.isArray(this.config.editorExtensions)&&this.config.editorExtensions.length>0&&console.warn("[SuperDoc] `editorExtensions` is a legacy ProseMirror concept and is ignored by superdoc@2. Use `extensions` with `defineSuperDocExtension`; legacy ProseMirror extensions (Node.create, Mark.create, addPmPlugins, custom schema) do not run in v2.")}#b(...e){(console.debug?console.debug:console.log)("π¦ π¦ΈββοΈ [superdoc]",...e)}#Q=null;get fonts(){return this.#Q||(this.#Q={getReport:()=>Mi(this.activeEditor)?.getReport()??[],getMissingFonts:()=>Mi(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>Mi(this.activeEditor)?.getDocumentFontOptions()??[],getFontFamilyOptions:()=>Mi(this.activeEditor)?.getFontFamilyOptions()??[],getDocumentFonts:()=>Mi(this.activeEditor)?.getDocumentFonts()??[],onReport:e=>{const t=this.activeEditor,n=t?Mi(t)?.getLastFontsChangedPayload?.()??null:this.#te??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{const t=Mi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.map(e)},unmap:e=>{const t=Mi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmap(e)},add:e=>{const t=Mi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.add(e)},preload:e=>{const t=Mi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.preload requires an active editor");return t.preload(e)}}),this.#Q}#H(){this.#ne(),this.activeEditor=null,this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null)}#U=null;#ne(){if(this.#U){try{this.#U()}catch{}this.#U=null}}#pe(e){this.#ne();const t=Mi(e);if(!t?.onChanged)return;const n=t.getLastFontsChangedPayload?.();n&&this.#z(n),this.#U=t.onChanged(r=>this.#z(r))}#me(e,t){this.#p=!0;try{if(e===null){this.#H();return}this.#r.get(e)?.kind==="v2"&&fi(t)?this.#re(t):this.#H()}finally{this.#p=!1}}#re(e){if(fi(e)){!this.#p&&this.#r.getActive()&&this.#r.setActive(null,"set-active-v2-facade"),this.activeEditor=e,this.#pe(e),this.toolbar?.setActiveEditor?.(e);return}this.#H()}setActiveEditor(e){this.#re(e)}getV2FeatureMatrix(){return[{feature:"source.docx-bytes",status:"supported",reason:"SuperDoc normalizes File/Blob/ArrayBuffer/Uint8Array DOCX inputs for the separate DOCX Engine dependency"},{feature:"source.url",status:"supported",reason:"shell-owned source normalization resolves URL-backed DOCX inputs before opening the injected v2 editor"},{feature:"source.blank",status:"supported",reason:"shell-owned blank-document seeding resolves to DOCX bytes before mounting the injected v2 editor"},{feature:"execution.browser-worker",status:"supported",reason:"the shipped public v2 shell opens DOCX documents through the browser-worker path by default when collaboration is not active"},{feature:"distribution.cdn-iife",status:"supported",reason:"the CDN/IIFE distribution ships the public bundle plus the emitted v2 browser-worker asset and opens DOCX documents through the worker-backed v2 runtime"},{feature:"docx.open-render",status:"supported",reason:"superdoc@2 opens and renders DOCX documents through its DOCX Engine dependency"},{feature:"docx.review-handles",status:"supported",reason:"Comment/tracked-change list + decide via v2 host handles"},{feature:"shell.toolbar",status:"supported",reason:"new SuperDoc({ toolbar }) mounts the rendered built-in toolbar shell and the superdoc.toolbar handle, both backed by the V2 command controller and the internal compatibility catalog. Explicit item-level limits stay fail-closed in the shared command matrix (for example search replace and copyFormat)."},{feature:"shell.rich-formatting",status:"supported",reason:"Rich inline, paragraph, and list formatting route through the V2 command controller and public Document API (format.* / styles.* / lists.*): bold, italic, underline, strikethrough, font family/size, text/highlight color, alignment, line spacing, linked styles, bullet/numbered lists, indent, and clear formatting."},{feature:"shell.comments-sidebar",status:"supported",reason:"ui-phase3-002: v2 comments adapter routes create/reply/edit/resolve/delete through V2EditorHost.dispatch"},{feature:"shell.comments-sidebar.reopen",status:"supported",reason:'ui-phase3-002: v2 comments sidebar reopens resolved threads through the v2 comments adapter (activeEditor.doc.comments.patch({ status: "active" }))'},{feature:"shell.tracked-change-sidebar",status:"supported",reason:"SD-3722: v2 tracked-change adapter lists and decides exact body, header/footer-part, and note targets"},{feature:"shell.tracked-change-sidebar.bulk",status:"not-shipped",reason:"bulk-tracked-change-decisions-omitted: acceptAll/rejectAll are matrix-disabled by default in the v2 host"},{feature:"shell.tracked-change-sidebar.non-body",status:"supported",reason:"SD-3722: public v2 shell hydrates and targets header/footer-part and note tracked changes"},{feature:"shell.comments-sidebar.persistence",status:"supported",reason:"ui-phase3-004: comment create/reply/edit/resolve/delete persist through SuperDoc.export() β re-mount via the v2 host save bridge"},{feature:"shell.tracked-change-sidebar.persistence",status:"supported",reason:"ui-phase3-004: tracked-change accept/reject persist through SuperDoc.export() β re-mount via the v2 host save bridge"},{feature:"shell.comments-sidebar.author-required",status:"supported",reason:"ui-phase3-004: v2 comments adapter surfaces commentCommandsReason=author-required from the host capability matrix; write controls disable and forced dispatch reports ok:false"},{feature:"shell.find-replace",status:"supported",reason:"Ctrl/Cmd+F opens the SuperDoc find/replace surface in v2; find/navigation/replace/replaceAll route through the single host search session (host.search) via ui.search, with replace failing closed in viewing/read-only mode"},{feature:"shell.ai-writer",status:"supported",reason:"built-in toolbar renders the modules.ai-gated AI writer and applies generated text through the public Document API facade"},{feature:"shell.collaboration",status:"supported",reason:"v2 single-doc y-websocket collaboration is wired through document.v2Collaboration, including collaboration-ready, awareness-update, and locked event bridges; arbitrary external { ydoc, provider } adapters remain unsupported"},{feature:"shell.context-menu",status:"not-shipped",reason:"context-menu-omitted: public v2 shell disables the legacy context menu"},{feature:"shell.page-metrics",status:"supported",reason:"ui-phase4-001: v2 page metrics snapshot (editorVersion: 2, documentId, renderEpoch, layoutGeneration, zoom, pages[], capabilities) available via superdoc.activeEditor.pageMetrics.{ getSnapshot, subscribe, setZoom, scrollToPage, revealBodyTarget, pageIndexForBodyTarget }"},{feature:"shell.zoom",status:"supported",reason:"ui-phase4-001: SuperDoc.setZoom routes to V2EditorHost.setZoom in v2 mode; single CSS-transform wrapper applies scale to the painted document, page metrics viewport coords scale with the same zoom value"},{feature:"shell.ruler-page-margins",status:"supported",reason:"ui-phase4-002: v2 ruler renders against the V2PageMetricsSnapshot and dispatches margin drags through a narrow v2 page-layout bridge (`activeEditor.pageLayout.setMargins(...)`) backed by `doc.sections.setPageMargins(...)`. The v2 page metrics snapshot now reports `capabilities.marginEdit = { supported: true }`"},{feature:"shell.custom-extensions",status:"supported",reason:"superdoc@2 supports customer extensions through `extensions` + `defineSuperDocExtension`; command execution and diagnostics are exposed through the narrow `activeEditor.extensions` facet. Legacy ProseMirror `editorExtensions` are ignored in v2."},{feature:"pdf.viewer",status:"supported",reason:"editorVersion ignored for PDF documents"},{feature:"html.viewer",status:"supported",reason:"editorVersion ignored for HTML documents"}]}get v2(){return this.editorVersion!==2?null:{version:2,featureMatrix:this.getV2FeatureMatrix()}}registerEditorRuntime(e){this.#r.register(e)}unregisterEditorRuntime(e){return this.#r.unregister(e)}getActiveRuntime(){return this.#r.getActive()}setActiveRuntime(e,t){this.#r.setActive(e,t)}resolveRuntimeFromEventTarget(e){return this.#r.resolveFromEventTarget(e)}activateRuntimeFromEventTarget(e,t){const n=this.#r.resolveFromEventTarget(e);return n?(this.#r.setActive(n.id,t),!0):!1}toggleRuler(){const e=this.#h("toggleRuler");this.config.rulers=!this.config.rulers,e.documents.forEach(t=>{t.rulers=this.config.rulers}),this.toolbar?.updateToolbarState?.()}canPerformPermission({permission:e,role:t=this.config.role,isInternal:n=this.config.isInternal,comment:r=null,trackedChange:o=null}={}){if(!e)return!1;let i=r??o?.comment??null;const s=o?.commentId||o?.id;if(!i&&s&&this.commentsStore?.getComment){const a=this.commentsStore.getComment(s),l=a?.getValues;i=typeof l=="function"?l.call(a):a}return Ys(e,t,n,{superdoc:this,currentUser:this.config.user,comment:i??null,trackedChange:o??null})}#ge(){const e=this.config.modules?.toolbar,t=e&&typeof e=="object"?e:{};if(this.toolbarElement=t.selector||this.config.toolbar,!(this.config.toolbar||e===!0||e!=null&&typeof e=="object")){this.toolbar=null;return}try{this.toolbar=Hz({...t,selector:this.toolbarElement,superdoc:this,editor:this.activeEditor,role:this.config.role,isDev:this.isDev,documentMode:this.config.documentMode,toolbarGroups:t.toolbarGroups??this.config.toolbarGroups,icons:{...this.config.toolbarIcons,...t.icons},texts:{...this.config.toolbarTexts,...t.texts},uiDisplayFallbackFont:this.config.uiDisplayFallbackFont})}catch(n){console.warn("[SuperDoc] built-in toolbar mount failed",n),this.toolbar=null}}addCommentsList(e){!this.config?.modules?.comments||this.config.role==="viewer"||(e&&(this.config.modules.comments.element=e),this.commentsList=new B7(this.config.modules?.comments,this),this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!0}))}removeCommentsList(){this.commentsList&&(this.commentsList.close(),this.commentsList=null,this.config.onCommentsListChange&&this.config.onCommentsListChange({isRendered:!1}))}scrollToComment(e,t={}){if(!this.config?.modules?.comments||!e||typeof e!="string")return!1;const n=this.element||document,r=globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/"/g,'\\"'),o=n.querySelector(`[data-comment-ids*="${r}"]`);if(!o)return!1;const{behavior:i="smooth",block:s="start"}=t??{};return o.scrollIntoView({behavior:i,block:s}),this.commentsStore?.setActiveComment?.(this,e),!0}async navigateTo(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.navigateTo?n.navigateTo(e):!1}async scrollToElement(e){const t=this.superdocStore?.documents;if(!t?.length)return!1;const n=t[0].getDocumentRuntime?.();return n?.scrollToElement?n.scrollToElement(e):!1}setDisableContextMenu(e=!0){const t=!!e;this.config.disableContextMenu!==t&&(this.config.disableContextMenu=t,this.superdocStore?.documents?.forEach(n=>{const r=n.getDocumentRuntime?.();r?.setContextMenuDisabled&&r.setContextMenuDisabled(t);const o=n.getEditor?.();o?.setOptions&&o.setOptions({disableContextMenu:t})}))}setShowBookmarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showBookmarks!==t&&(n.showBookmarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowBookmarks?.(t)}))}setShowFormattingMarks(e=!0){const t=!!e,n=this.config.layoutEngineOptions=this.config.layoutEngineOptions||{};n.showFormattingMarks!==t&&(n.showFormattingMarks=t,this.superdocStore?.documents?.forEach(r=>{r.getDocumentRuntime?.()?.setShowFormattingMarks?.(t)}),this.emit("formatting-marks-change",{showFormattingMarks:t,superdoc:this}),this.toolbar?.updateToolbarState?.())}toggleFormattingMarks(){const e=!!this.config.layoutEngineOptions?.showFormattingMarks;this.setShowFormattingMarks(!e)}setDocumentMode(e){if(!e)return;this.#y("setDocumentMode"),e=e.toLowerCase(),this.config.documentMode=e,this.#se();const t={viewing:()=>this.#ie(),editing:()=>this.#ve(),suggesting:()=>this.#oe()};t[e]&&(t[e](),this.emit("document-mode-change",{documentMode:e}))}#Z(e,t){const n=typeof e.id=="string"&&e.id.length>0?e.id:null;if(n){const i=this.#r.getAllByDocumentId(n);if(i.length>0){for(const s of i)s.setDocumentMode(t);return}}const r=typeof e.getDocumentRuntime=="function"?e.getDocumentRuntime():null;if(typeof r?.setDocumentMode=="function"){r.setDocumentMode(t);return}const o=typeof e.getEditor=="function"?e.getEditor():null;o&&typeof o.setDocumentMode=="function"&&o.setDocumentMode(t)}setTrackedChangesPreferences(e){const t=e&&Object.keys(e).length?{...e}:void 0;this.config.layoutEngineOptions||(this.config.layoutEngineOptions={}),this.config.layoutEngineOptions.trackedChanges=t,this.superdocStore?.documents?.forEach(n=>{const r=typeof n.getDocumentRuntime=="function"?n.getDocumentRuntime():null;r?.setTrackedChangesOverrides&&r.setTrackedChangesOverrides(t)})}#ve(){if(this.config.role!=="editor")return this.#oe();const e=this.#h("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#Z(t,"editing")})}#oe(){if(!["editor","suggester"].includes(this.config.role??""))return this.#ie();const e=this.#h("setDocumentMode");if(e.documents.length>0){const t=e.documents[0]?.getEditor();t&&this.setActiveEditor(t)}this.setTrackedChangesPreferences({mode:"review",enabled:!0}),e.documents.forEach(t=>{t.restoreComments?.(),this.#Z(t,"suggesting")})}#ie(){const e=this.#h("setDocumentMode");this.toolbar?.setActiveEditor?this.toolbar.setActiveEditor(null):this.toolbar&&(this.toolbar.activeEditor=null);const t=this.config.comments?.visible===!0,n=this.config.trackChanges?.visible===!0;this.setTrackedChangesPreferences(n?{mode:"review",enabled:!0}:{mode:"original",enabled:!0}),!t&&!n&&this.commentsStore?.clearEditorCommentPositions?.(),e.documents.forEach(r=>{t||n?r.restoreComments?.():r.removeComments?.(),this.#Z(r,"viewing")})}#se(){const e=this.config.comments?.visible===!0,t=this.config.trackChanges?.visible===!0,n=this.config.documentMode==="viewing",r=e||t;this.commentsStore?.setViewingVisibility&&this.commentsStore.setViewingVisibility({documentMode:this.config.documentMode,commentsVisible:e,trackChangesVisible:t});const o=this.superdocStore?.documents;Array.isArray(o)&&o.length>0&&o.forEach(i=>{const s=typeof i.getDocumentRuntime=="function"?i.getDocumentRuntime():null;s?.setViewingCommentOptions&&s.setViewingCommentOptions({emitCommentPositionsInViewing:n&&r,enableCommentsInViewing:n&&e})})}search(e){const t=this.activeEditor?.commands,n=t?.search;if(typeof n=="function")return n.call(t,e,{searchModel:"visible"})}goToSearchResult(e){const t=this.activeEditor?.commands,n=t?.goToSearchResult;if(typeof n=="function")return!!n.call(t,e)}getZoom(){return this.superdocStore?.activeZoom??100}setZoom(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0){console.warn("[SuperDoc] setZoom expects a positive number representing percentage");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoom called before initialization; use config.zoom.initial for the starting zoom");return}this.superdocStore.activeZoom=e,this.superdocStore.zoomMode="manual",this.emit("zoomChange",{zoom:e,mode:"manual"})}setZoomMode(e){if(e!=="manual"&&e!=="fit-width"){console.warn("[SuperDoc] setZoomMode expects 'manual' or 'fit-width'");return}if(!this.superdocStore){console.warn("[SuperDoc] setZoomMode called before initialization; use config.zoom.mode for the starting mode");return}this.superdocStore.zoomMode!==e&&(this.superdocStore.zoomMode=e,this.emit("zoomChange",{zoom:this.getZoom(),mode:e}))}getZoomState(){const e=OC(this.config.zoom?.fitWidth);return{mode:this.superdocStore?.zoomMode??"manual",value:this.superdocStore?.activeZoom??100,fitZoom:this.superdocStore?.viewportMetrics?.fitZoom??null,min:e.min,max:e.max}}getViewportMetrics(){return this.superdocStore?.viewportMetrics??null}getMeasurementUnit(){return this.superdocStore?.measurementUnit??"in"}setMeasurementUnit(e){if(e!=="in"&&e!=="cm"){console.warn("[SuperDoc] setMeasurementUnit expects 'in' or 'cm'");return}if(!this.superdocStore){console.warn("[SuperDoc] setMeasurementUnit called before initialization; use config.measurementUnit for the starting unit");return}this.superdocStore.measurementUnit!==e&&(this.superdocStore.measurementUnit=e,this.emit("measurement-unit-change",{unit:e}))}setLocked(e=!0){const t=this.activeEditor;if(fi(t)&&typeof t.lock?.setLocked=="function"){t.lock.setLocked(e,e?{...this.user}:null);const n=t.lock.getSnapshot?.();n&&this.#I(!!n.isLocked,this.#m(n.lockedBy??null));return}this.config.documents.forEach(n=>{const r=n.ydoc;if(!r)return;const o=r.getMap("meta");r.transact(()=>{o.set("locked",e),e?o.set("lockedBy",this.user):o.delete("lockedBy")})}),this.#I(e,e?this.user:null)}getHTML(e={}){const t=[];return this.#h("getHTML").documents.forEach(n=>{const r=n.getEditor?.();r&&t.push(r)}),t.map(n=>n.getHTML(e))}lockSuperdoc(e=!1,t=null){this.#I(e,t)}async export({exportType:e=["docx"],commentsType:t="external",exportedName:n,additionalFiles:r=[],additionalFileNames:o=[],isFinalDoc:i=!1,triggerDownload:s=!0,fieldsHighlightColor:a=null}={}){const l=K4(n||this.config.title),u=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:i,fieldsHighlightColor:a}),c=[...r],d=[...o];if(e.includes("docx")&&u.forEach(m=>{c.push(m),d.push(`${l}.docx`)}),c.length===1)return s?W4(c[0],l,e[0]):c[0];const h=await Vz(c,d);return s?W4(h,l,"zip"):h}async replaceFile(e){const t=this.activeEditor;if(fi(t)&&typeof t.replaceFile=="function"){const r=await t.replaceFile(e),o=r&&typeof r=="object"?r.state:null;return(o===null||o==="review-ready"||o==="editing-ready")&&this.#J(t,e),r}const n=t&&!fi(t)?t.replaceFile:null;if(typeof n=="function"){const r=await n.call(t,e);return this.#J(t,e),r}throw new Error("SuperDoc: replaceFile is unavailable for the active editor")}async exportEditorsToDOCX({commentsType:e,isFinalDoc:t,fieldsHighlightColor:n}={}){const r=this.config?.modules?.comments!==!1;let o,i=!1;const s=()=>(i||(i=!0,e==="clean"?o=[]:r&&this.commentsStore&&typeof this.commentsStore.translateCommentsForExport=="function"&&(o=this.commentsStore.translateCommentsForExport(),Array.isArray(o)||(o=[]))),o),a=new WeakSet,l=u=>{"editor"in u&&u.error&&typeof u.error=="object"&&a.add(u.error)};this.on("exception",l);try{const u=this.#h("exportEditorsToDOCX").documents.map(async c=>{if(!c||c.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const d=typeof c.getEditor=="function"?c.getEditor():null,h=()=>!c.data||c.data.type&&c.data.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document"?null:c.data;if(!d||typeof d.exportDocx!="function")return h();const m=d.editorVersion===2;try{const p=await d.exportDocx(m?{isFinalDoc:t,commentsType:e,fieldsHighlightColor:n}:{isFinalDoc:t,comments:s(),commentsType:e,fieldsHighlightColor:n});if(p)return p}catch(p){if((!p||typeof p!="object"||!a.has(p))&&this.emit("exception",{error:p,document:c}),m&&(e==="clean"||Gz(p)))throw p}return h()});return(await Promise.all(u)).filter(c=>c!=null)}finally{this.off("exception",l)}}async#ye(){this.#b("π¦ [superdoc] Triggering collaboration saves");const e=this.#h("save");return new Promise(t=>{e.documents.forEach((n,r)=>{if(this.#b(`Before reset - Doc ${r}: pending = ${this.pendingCollaborationSaves}`),this.pendingCollaborationSaves=0,n.ydoc){this.pendingCollaborationSaves++,this.#b(`After increment - Doc ${r}: pending = ${this.pendingCollaborationSaves}`);const o=n.ydoc.getMap("meta");o.observe(i=>{i.changes.keys.has("immediate-save-finished")&&(this.pendingCollaborationSaves--,this.pendingCollaborationSaves<=0&&t())}),o.set("immediate-save",!0)}}),this.#b(`FINAL pending = ${this.pendingCollaborationSaves}, but we have ${e.documents.filter(n=>n.ydoc).length} docs!`)})}async save(){const e=[this.#ye()];this.#b("π¦ [superdoc] Saving superdoc"),await Promise.all(e),this.#b("π¦ [superdoc] Save complete")}#be(e,t){const n=e.provider;n&&n!==this.provider&&!t.some(o=>o.provider===n)&&(n.disconnect?.(),n.destroy?.());const r=e.ydoc;r&&r!==this.ydoc&&!t.some(o=>o.ydoc===r)&&r.destroy?.()}#ae(){this.#s=null,this.#A(),typeof this._cleanupAwareness=="function"&&(this._cleanupAwareness(),this._cleanupAwareness=null);const e=this.config;e.socket?.cancelWebsocketRetry?.(),e.socket?.disconnect(),e.socket?.destroy(),this.ydoc?.destroy(),this.provider?.disconnect?.(),this.provider?.destroy?.(),e.documents.forEach(t=>{t.provider?.disconnect?.(),t.provider?.destroy?.(),t.ydoc?.destroy()})}openSurface(e){return this.#d.open(e)}closeSurface(e){this.#d.close(e)}async removeDocument(e){const t=typeof e=="string"?e:String(e??"");if(!t)return!1;const n=this.#h("removeDocument"),r=this.activeEditor,o=E0(r);for(const s of this.#r.getAllByDocumentId(t))this.#r.unregister(s.id);o===t&&r!==null&&this.#H();const i=n.removeDocument(t);return i?(this.#be(i,n.documents),await St(),!0):!1}destroy(){this.#t=!0,this.#e&&(this.#e(),this.#e=null),this.#d&&this.#d.destroy(),this.toolbar?.destroy?.(),this.app&&(this.#b("[superdoc] Unmounting app"),this.superdocStore?.reset(),this.app.unmount(),this.removeAllListeners(),delete this.app.config.globalProperties.$config,delete this.app.config.globalProperties.$superdoc),this.#ae(),this.#f?.(),this.#f=null,this.#r.clear(),this.#u&&(this.#u.remove(),this.#u=null)}focus(){const e=this.getActiveRuntime();if(e?.getCapabilities().lifecycle.canFocus){e.focus().catch(t=>{console.warn("[SuperDoc] active editor runtime focus failed",t)});return}this.activeEditor?this.activeEditor.focus?.():this.#h("focus").documents.find(t=>{const n=t.getEditor?.();return n?(n.focus?.(),!0):!1})}setHighContrastMode(e){this.activeEditor&&(this.activeEditor.setHighContrastMode?.(e),this.highContrastModeStore?.setHighContrastMode(e))}};Et();const Tk="__SUPERDOC_V2_BROWSER_RUNTIME__";function Kz(e=globalThis){const t=e[Tk];return t&&typeof t=="object"?t:null}function qz(e={},t=globalThis){const n=Kz(t)??{},r={...n,...e,vue:e.vue??n.vue??rI};return t[Tk]=r,r}qz();var Yz={action:"--sd-ui-action",actionHover:"--sd-ui-action-hover",actionText:"--sd-ui-action-text",bg:"--sd-ui-bg",hoverBg:"--sd-ui-hover-bg",activeBg:"--sd-ui-active-bg",disabledBg:"--sd-ui-disabled-bg",text:"--sd-ui-text",textMuted:"--sd-ui-text-muted",textDisabled:"--sd-ui-text-disabled",border:"--sd-ui-border"},Xz=0;function Rk(e){const{name:t,font:n,radius:r,shadow:o,colors:i,vars:s}=e,a=`sd-theme-${(t?t.replace(/[^a-zA-Z0-9-_]/g,"-"):null)||`custom-${++Xz}`}`,l=[];if(i)for(const[u,c]of Object.entries(i)){if(c==null)continue;const d=Yz[u];d&&l.push(` ${d}: ${c};`)}if(n!=null&&l.push(` --sd-ui-font-family: ${n};`),r!=null&&l.push(` --sd-ui-radius: ${r};`),o!=null&&l.push(` --sd-ui-shadow: ${o};`),s)for(const[u,c]of Object.entries(s))c!=null&&l.push(` ${u}: ${c};`);return{className:a,css:l.length>0?`.${a} {
|
|
106
106
|
${l.join(`
|
|
107
107
|
`)}
|
|
108
|
-
}`:""}}function Qz(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function Zz(e){const{className:t,css:n}=Rk(e);return Qz(t,n),t}function Jz(e){return Rk(e)}function $z(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var eH=Lu({BlankDOCX:()=>hC,DOCX:()=>wr,HTML:()=>kh,PDF:()=>Pl,SuperDoc:()=>Wp,buildTheme:()=>Jz,compareVersions:()=>dI,createTheme:()=>Zz,defineSuperDocExtension:()=>$z,getFileObject:()=>fv},1),tH="SUPERDOC_ENGINE_CDN_BASE_URL",Mk=Symbol.for("superdoc.docx-engine.cdn-load-state"),Kp="superdocDocxEngineStatus";function nH(e,t,n=null){const r=e?.[tH],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return rH(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function rH(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function oH({engineVersion:e,buildBaseUrl:t}){vx(()=>{const n=nH(globalThis,e,t),r=globalThis[Mk],o=r instanceof Map?r:new Map;if(globalThis[Mk]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),iH(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function iH(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[Kp]==="loaded")return Promise.resolve();const r=n?.dataset[Kp]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(m,p)=>{a||(a=!0,l?.disconnect(),s.dataset[Kp]=m,p())},c=()=>u("loaded",o),d=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),h=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",c,{once:!0}),s.addEventListener("error",d,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(h),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[Kp]="loading",document.head.appendChild(s))})}oH({engineVersion:"0.2.0-next.
|
|
108
|
+
}`:""}}function Qz(e,t){if(typeof document>"u"||!t)return;let n=document.querySelector(`[data-sd-theme="${e}"]`);n||(n=document.createElement("style"),n.setAttribute("data-sd-theme",e),document.head.appendChild(n)),n.textContent=t}function Zz(e){const{className:t,css:n}=Rk(e);return Qz(t,n),t}function Jz(e){return Rk(e)}function $z(e){if(!e||typeof e!="object")throw new Error("defineSuperDocExtension requires an extension object.");if(typeof e.id!="string"||e.id.length===0)throw new Error("defineSuperDocExtension requires a non-empty string `id`.");if(typeof e.activate!="function")throw new Error(`defineSuperDocExtension("${e.id}") requires an \`activate(ctx)\` function.`);if(e.storage!==void 0&&typeof e.storage!="function")throw new Error(`defineSuperDocExtension("${e.id}") \`storage\` must be a function returning the initial storage object.`);return e}var eH=Lu({BlankDOCX:()=>hC,DOCX:()=>wr,HTML:()=>kh,PDF:()=>Pl,SuperDoc:()=>Wp,buildTheme:()=>Jz,compareVersions:()=>dI,createTheme:()=>Zz,defineSuperDocExtension:()=>$z,getFileObject:()=>fv},1),tH="SUPERDOC_ENGINE_CDN_BASE_URL",Mk=Symbol.for("superdoc.docx-engine.cdn-load-state"),Kp="superdocDocxEngineStatus";function nH(e,t,n=null){const r=e?.[tH],o=typeof r=="string"&&r.trim()?r:n;if(typeof o=="string"&&o.trim())return rH(o);if(!t)throw new Error("SuperDoc: the CDN build is missing its exact DOCX Engine version");return`https://cdn.jsdelivr.net/npm/@superdoc/docx-engine@${t}`}function rH(e){const t=e.trim().replace(/\/+$/,""),n=t.match(/^([a-z][a-z\d+.-]*):/iu)?.[1]?.toLowerCase();if(n&&n!=="http"&&n!=="https")throw new TypeError(`SuperDoc: unsupported DOCX Engine CDN URL scheme ${n}:`);return t}function oH({engineVersion:e,buildBaseUrl:t}){vx(()=>{const n=nH(globalThis,e,t),r=globalThis[Mk],o=r instanceof Map?r:new Map;if(globalThis[Mk]=o,!o.has(n)){const i=Promise.all([import(`${n}/dist-cdn/docx-engine.es.js`),iH(`${n}/dist-cdn/style.css`)]).then(([s])=>s);o.set(n,i),i.catch(()=>{o.get(n)===i&&o.delete(n)})}return o.get(n)})}function iH(e){if(typeof document>"u")return Promise.resolve();const t=new URL(e,document.baseURI).href,n=Array.from(document.querySelectorAll('link[rel~="stylesheet"]')).find(o=>o.href===t);if(n?.sheet||n?.dataset[Kp]==="loaded")return Promise.resolve();const r=n?.dataset[Kp]==="loading";return n&&!r&&n.remove(),new Promise((o,i)=>{const s=r?n:document.createElement("link");let a=!1,l;const u=(m,p)=>{a||(a=!0,l?.disconnect(),s.dataset[Kp]=m,p())},c=()=>u("loaded",o),d=()=>u("error",()=>i(new Error(`SuperDoc: failed to load DOCX Engine styles from ${t}`))),h=()=>{s.isConnected||u("error",()=>i(new Error(`SuperDoc: DOCX Engine stylesheet was removed while loading from ${t}`)))};s.addEventListener("load",c,{once:!0}),s.addEventListener("error",d,{once:!0}),typeof globalThis.MutationObserver=="function"&&(l=new globalThis.MutationObserver(h),l.observe(document.head,{childList:!0})),r||(s.rel="stylesheet",s.href=t,s.dataset.superdocDocxEngine="true",s.dataset[Kp]="loading",document.head.appendChild(s))})}oH({engineVersion:"0.2.0-next.10",buildBaseUrl:null});for(const[e,t]of Object.entries(eH))e==="SuperDoc"||e==="default"||Object.prototype.hasOwnProperty.call(Wp,e)||(Wp[e]=t);var sH=Wp;return sH})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "superdoc",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-next.
|
|
4
|
+
"version": "2.0.0-next.38",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"main": "./dist/superdoc.cjs",
|
|
76
76
|
"module": "./dist/superdoc.es.js",
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@superdoc/docx-engine": "0.2.0-next.
|
|
78
|
+
"@superdoc/docx-engine": "0.2.0-next.10",
|
|
79
79
|
"@types/mdast": "^4.0.4",
|
|
80
80
|
"@types/ws": "^8.18.1",
|
|
81
81
|
"buffer-crc32": "^1.0.0",
|