superdoc 2.0.0-next.25 β 2.0.0-next.26
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.26",
|
|
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.26",
|
|
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
|
|
@@ -84,8 +84,10 @@ export interface DeletedBlockSummary {
|
|
|
84
84
|
export interface BlocksSplitInput {
|
|
85
85
|
/** Paragraph-shaped block to split. Only `paragraph` / `heading` / `listItem` are supported. */
|
|
86
86
|
target: BlockNodeAddress;
|
|
87
|
-
/** Char offset inside the target paragraph
|
|
87
|
+
/** Char offset inside the target paragraph in the declared coordinate space. */
|
|
88
88
|
offset: number;
|
|
89
|
+
/** Include deleted tracked text in the offset ruler. Defaults to `visible`. */
|
|
90
|
+
coordinateSpace?: 'visible' | 'tracked';
|
|
89
91
|
}
|
|
90
92
|
export interface BlocksSplitSuccessResult {
|
|
91
93
|
success: true;
|
package/dist/superdoc.cjs
CHANGED
|
@@ -34443,7 +34443,7 @@ var SuperDoc = class extends require_eventemitter3.import_eventemitter3.default
|
|
|
34443
34443
|
this.config.colors = shuffleArray(this.config.colors);
|
|
34444
34444
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
34445
34445
|
this.colorIndex = 0;
|
|
34446
|
-
this.version = "2.0.0-next.
|
|
34446
|
+
this.version = "2.0.0-next.26";
|
|
34447
34447
|
this.#log("π¦ [superdoc] Using SuperDoc version:", this.version);
|
|
34448
34448
|
this.superdocId = config.superdocId || require_uuid.v4_default();
|
|
34449
34449
|
this.colors = this.config.colors ?? [];
|
package/dist/superdoc.es.js
CHANGED
|
@@ -34161,7 +34161,7 @@ var SuperDoc = class extends import_eventemitter3.default {
|
|
|
34161
34161
|
this.config.colors = shuffleArray(this.config.colors);
|
|
34162
34162
|
this.userColorMap = /* @__PURE__ */ new Map();
|
|
34163
34163
|
this.colorIndex = 0;
|
|
34164
|
-
this.version = "2.0.0-next.
|
|
34164
|
+
this.version = "2.0.0-next.26";
|
|
34165
34165
|
this.#log("π¦ [superdoc] Using SuperDoc version:", this.version);
|
|
34166
34166
|
this.superdocId = config.superdocId || v4_default();
|
|
34167
34167
|
this.colors = this.config.colors ?? [];
|
package/dist-cdn/superdoc.min.js
CHANGED
|
@@ -99,7 +99,7 @@ js: import "konva/skia-backend";
|
|
|
99
99
|
`,a4=()=>{if(typeof document>"u")throw new Error(CD)},mi=class nk{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 nk(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 d=Math.sqrt(t*t+n*n);l.rotation=n>0?Math.acos(t/d):-Math.acos(t/d),l.scaleX=d,l.scaleY=a/d,l.skewX=(t*r+n*o)/a,l.skewY=0}else if(r!=0||o!=0){const d=Math.sqrt(r*r+o*o);l.rotation=Math.PI/2-(o>0?Math.acos(-r/d):-Math.acos(r/d)),l.scaleX=a/d,l.scaleY=d,l.skewX=0,l.skewY=(t*r+n*o)/a}return l.rotation=Ae._getRotation(l.rotation),l}},_D="[object Array]",SD="[object Number]",kD="[object String]",AD="[object Boolean]",ID=Math.PI/180,ED=180/Math.PI,Md="#",xD="",TD="0",RD="Konva warning: ",l4="Konva error: ",MD="rgb(",py={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]},LD=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Kh=[],Ld=null,DD=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)===_D},_isNumber(e){return Object.prototype.toString.call(e)===SD&&!isNaN(e)&&isFinite(e)},_isString(e){return Object.prototype.toString.call(e)===kD},_isBoolean(e){return Object.prototype.toString.call(e)===AD},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){Kh.push(e),Kh.length===1&&DD(function(){const t=Kh;Kh=[],t.forEach(function(n){n()})})},createCanvasElement(){a4();const e=document.createElement("canvas");try{e.style=e.style||{}}catch{}return e},createImageElement(){return a4(),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(Md,xD);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=TD+e;return Md+e},isCanvasFarblingActive(){if(Ld!==null)return Ld;if(typeof document>"u")return Ld=!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 Ld=r,this.releaseCanvas(e),Ld},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),Md+this._rgbToHex(e,t,n)},getSnappedHexColor(e){const t=this._hexToRgb(e);return Md+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 py?(t=py[e],{r:t[0],g:t[1],b:t[2]}):e[0]===Md?this._hexToRgb(e.substring(1)):e.substr(0,4)===MD?(t=LD.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=py[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 d=2*i-s,c=[0,0,0];for(let u=0;u<3;u++)a=r+1/3*-(u-1),a<0&&a++,a>1&&a--,6*a<1?l=d+(s-d)*6*a:2*a<1?l=s:3*a<2?l=d+(s-d)*(2/3-a)*6:l=d,c[u]=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*ID},radToDeg(e){return e*ED},_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 dt.angleDeg?Ae.radToDeg(e):e},_capitalize(e){return e.charAt(0).toUpperCase()+e.slice(1)},throw(e){throw new Error(l4+e)},error(e){console.error(l4+e)},warn(e){dt.showWarnings&&console.warn(RD+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 d=(e-n)*(e-n)+(t-r)*(t-r);if(d==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))/d;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),d=l[0],c=l[1],u=l[2];u<o&&(r.x=d,r.y=c,o=u)}),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){dt.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,d=0;typeof r=="number"?s=a=l=d=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),d=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-d),e.arc(o+t-d,i+n-d,d,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],d={x:a.x-s.x,y:a.y-s.y},c={x:l.x-a.x,y:l.y-a.y},u=Math.hypot(d.x,d.y),h=Math.hypot(c.x,c.y);let p;typeof o=="number"?p=o:p=i<o.length?o[i]:0,p=r*Math.cos(Math.PI/n)*Math.min(1,p/r*2);const f={x:d.x/u,y:d.y/u},g={x:c.x/h,y:c.y/h},w={x:a.x-f.x*p,y:a.y-f.y*p},C={x:a.x+g.x*p,y:a.y+g.y*p};i===0?e.moveTo(w.x,w.y):e.lineTo(w.x,w.y),e.arcTo(a.x,a.y,C.x,C.y,p)}}};function PD(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 c4=",",OD="(",FD=")",ND="([",BD="])",zD=";",HD="()",UD="=",u4=["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"],VD=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled","filter"],jD=100,qh=null;function d4(){if(qh!==null)return qh;try{const e=Ae.createCanvasElement().getContext("2d");return e?!!e&&"filter"in e:(qh=!1,!1)}catch{return qh=!1,!1}}var Yh=class{constructor(e){this.canvas=e,dt.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+=HD:Ae._isArray(l[0])?o+=ND+l.join(c4)+BD:(t&&(l=l.map(d=>typeof d=="number"?Math.floor(d):d)),o+=OD+l.join(c4)+FD)):(o+=s.property,e||(o+=UD+s.val)),o+=zD;return o}clearTrace(){this.traceArr=[]}_trace(e){let t=this.traceArr,n;t.push(e),n=t.length,n>=jD&&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 d=arguments,c=this._context;d.length===3?c.drawImage(e,t,n):d.length===5?c.drawImage(e,t,n,r,o):d.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=u4.length,n=this.setAttr,r,o;const i=function(s){let a=e[s],l;e[s]=function(){return o=PD(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(u4[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)}};VD.forEach(function(e){Object.defineProperty(Yh.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})});var GD=class extends Yh{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(),d=a.x*l,c=a.y*l;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",i*Math.min(Math.abs(d),Math.abs(c))),this.setAttr("shadowOffsetX",s.x*d),this.setAttr("shadowOffsetY",s.y*c)}},WD=class extends Yh{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()}}},Xh;function KD(){if(Xh)return Xh;const e=Ae.createCanvasElement(),t=e.getContext("2d");return Xh=(function(){return(dt._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1)})(),Ae.releaseCanvas(e),Xh}var my=class{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1,this.pixelRatio=(e||{}).pixelRatio||dt.pixelRatio||KD(),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."),""}}}},ka=class extends my{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new GD(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}},gy=class extends my{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new WD(this),this.setSize(e.width,e.height)}};const bn={get isDragging(){let e=!1;return bn._dragElements.forEach(t=>{t.dragStatus==="dragging"&&(e=!0)}),e},justDragged:!1,get node(){let e;return bn._dragElements.forEach(t=>{e=t.node}),e},_dragElements:new Map,_drag(e){const t=[];bn._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=[];bn._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")&&(bn.justDragged=!0,dt._mouseListenClick=!1,dt._touchListenClick=!1,dt._pointerListenClick=!1,n.dragStatus="stopped");const i=n.node.getLayer()||n.node instanceof dt.Stage&&n.node;i&&t.indexOf(i)===-1&&t.push(i)}),t.forEach(n=>{n.draw()})},_endDragAfter(e){bn._dragElements.forEach((t,n)=>{t.dragStatus==="stopped"&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),t.dragStatus!=="dragging"&&bn._dragElements.delete(n)})}};dt.isBrowser&&(window.addEventListener("mouseup",bn._endDragBefore,!0),window.addEventListener("touchend",bn._endDragBefore,!0),window.addEventListener("touchcancel",bn._endDragBefore,!0),window.addEventListener("mousemove",bn._drag),window.addEventListener("touchmove",bn._drag),window.addEventListener("mouseup",bn._endDragAfter,!1),window.addEventListener("touchend",bn._endDragAfter,!1),window.addEventListener("touchcancel",bn._endDragAfter,!1));function Aa(e){return Ae._isString(e)?'"'+e+'"':Object.prototype.toString.call(e)==="[object Number]"||Ae._isBoolean(e)?e:Object.prototype.toString.call(e)}function f4(e){return e>255?255:e<0?0:Math.round(e)}function ot(){if(dt.isUnminified)return function(e,t){return Ae._isNumber(e)||Ae.warn(Aa(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function Qh(e){if(dt.isUnminified)return function(t,n){let r=Ae._isNumber(t),o=Ae._isArray(t)&&t.length==e;return!r&&!o&&Ae.warn(Aa(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function vy(){if(dt.isUnminified)return function(e,t){return Ae._isNumber(e)||e==="auto"||Ae.warn(Aa(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Sl(){if(dt.isUnminified)return function(e,t){return Ae._isString(e)||Ae.warn(Aa(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function h4(){if(dt.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(Aa(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function qD(){if(dt.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(Aa(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}function gi(){if(dt.isUnminified)return function(e,t){return e===!0||e===!1||Ae.warn(Aa(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}function YD(e){if(dt.isUnminified)return function(t,n){return t==null||Ae.isObject(t)||Ae.warn(Aa(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}var Dd="get",Pd="set";const se={addGetterSetter(e,t,n,r,o){se.addGetter(e,t,n),se.addSetter(e,t,r,o),se.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){const r=Dd+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=Pd+Ae._capitalize(t);e.prototype[o]||se.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){const o=Pd+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=Dd+s(t),l=Pd+s(t);e.prototype[a]=function(){const c={};for(let u=0;u<i;u++){const h=n[u];c[h]=this.getAttr(t+s(h))}return c};const d=YD(n);e.prototype[l]=function(c){const u=this.attrs[t];r&&(c=r.call(this,c,t)),d&&d.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,u,c),o&&o.call(this),this},se.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){const n=Ae._capitalize(t),r=Pd+n,o=Dd+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=Dd+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},se.addSetter(e,t,r,function(){Ae.error(i)}),se.addOverloadedGetterSetter(e,t)},backCompat(e,t){Ae.each(t,function(n,r){const o=e.prototype[r],i=Dd+Ae._capitalize(n),s=Pd+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 XD(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=dt.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=dt.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=dt.Filters;l&&l.Contrast&&l.Contrast.call(this,s)}}case"grayscale":return function(i){const s=dt.Filters;s&&s.Grayscale&&s.Grayscale.call(this,i)};case"sepia":return function(i){const s=dt.Filters;s&&s.Sepia&&s.Sepia.call(this,i)};case"invert":return function(i){const s=dt.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 Zh="absoluteOpacity",p4="allEventListeners",Fs="absoluteTransform",m4="absoluteScale",kl="canvas",QD="Change",ZD="children",JD="konva",yy="listening",$D="mouseenter",eP="mouseleave",tP="pointerenter",nP="pointerleave",rP="touchenter",oP="touchleave",g4="set",v4="Shape",Jh=" ",y4="stage",Ia="transform",iP="Stage",by="visible",sP=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(Jh),aP=1,ft=class rf{constructor(t){this._id=aP++,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===Ia||t===Fs)&&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===Ia||t===Fs)&&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(Jh);this.on(o,()=>{this._clearCache(t)}),this._attachedDepsListeners.set(t,!0)}return this._getCache(t,r)}_getCanvasCache(){return this._cache.get(kl)}_clearSelfAndDescendantCache(t){this._clearCache(t),t===Fs&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(kl)){const{scene:t,filter:n,hit:r}=this._cache.get(kl);Ae.releaseCanvas(t._canvas,n._canvas,r._canvas),this._cache.delete(kl)}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,d=n.offset||0,c=n.drawBorder||!1,u=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,p=Math.abs(Math.round(r.y)-l)>.5?1:0;o+=d*2+h,i+=d*2+p,a-=d,l-=d;const f=new ka({pixelRatio:s,width:o,height:i}),g=new ka({pixelRatio:s,width:0,height:0,willReadFrequently:!0}),w=new gy({pixelRatio:u,width:o,height:i}),C=f.getContext(),S=w.getContext(),y=new ka({width:f.width/f.pixelRatio+Math.abs(a),height:f.height/f.pixelRatio+Math.abs(l),pixelRatio:f.pixelRatio}),b=y.getContext();return w.isCache=!0,f.isCache=!0,this._cache.delete(kl),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(f.getContext()._context.imageSmoothingEnabled=!1,g.getContext()._context.imageSmoothingEnabled=!1),C.save(),S.save(),b.save(),C.translate(-a,-l),S.translate(-a,-l),b.translate(-a,-l),y.x=a,y.y=l,this._isUnderCache=!0,this._clearSelfAndDescendantCache(Zh),this._clearSelfAndDescendantCache(m4),this.drawScene(f,this,y),this.drawHit(w,this),this._isUnderCache=!1,C.restore(),S.restore(),c&&(C.save(),C.beginPath(),C.rect(0,0,o,i),C.closePath(),C.setAttr("strokeStyle","red"),C.setAttr("lineWidth",5),C.stroke(),C.restore()),Ae.releaseCanvas(y._canvas),this._cache.set(kl,{scene:f,filter:g,hit:w,x:a,y:l}),this._requestDraw(),this}isCached(){return this._cache.has(kl)}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(d){const c=l.point(d);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,d;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"&&d4(),typeof t[h]!="string"||!d4()){c=!1;break}const u=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()/u,r.getHeight()/u),i.restore(),this._filterUpToDate=!0,o}try{for(s=t.length,i.clear(),i.drawImage(r._canvas,0,0,r.getWidth()/u,r.getHeight()/u),a=i.getImageData(0,0,o.getWidth(),o.getHeight()),l=0;l<s;l++)d=t[l],typeof d=="string"&&(d=XD(d)),d.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(p4),t.length===3)return this._delegate.apply(this,t);const o=n.split(Jh);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(Jh),o=r.length,i,s,a,l,d,c;if(this._cache&&this._cache.delete(p4),!t)for(s in this.eventListeners)this._off(s);for(i=0;i<o;i++)if(a=r[i],l=a.split("."),d=l[0],c=l[1],d)this.eventListeners[d]&&this._off(d,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(),bn._dragElements.delete(this._id),bn._dragElements.forEach((t,n)=>{this.isAncestorOf(t.node)&&bn._dragElements.delete(n)}),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(Fs),this._clearSelfAndDescendantCache(Zh),this._clearSelfAndDescendantCache(m4),this._clearSelfAndDescendantCache(y4),this._clearSelfAndDescendantCache(by),this._clearSelfAndDescendantCache(yy)}_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!==ZD&&(r=g4+Ae._capitalize(n),Ae._isFunction(this[r])?this[r](t[n]):this._setAttr(n,t[n]))}),this}isListening(){return this._getCache(yy,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(by,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;bn._dragElements.forEach(s=>{s.dragStatus==="dragging"&&(s.node.nodeType==="Stage"||s.node.getLayer()===r)&&(o=!0)});const i=!n&&!dt.hitOnDragEnabled&&(o||dt.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!==v4&&(o=o.concat(a.getChildren().slice())),a._id===n._id&&(s=i);o.length>0&&o[0].getDepth()<=t&&l(o)}const d=this.getStage();return n.nodeType!==iP&&d&&l(d.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(Ia),this._clearSelfAndDescendantCache(Fs)),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 mi,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(Ia);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(Ia),this._clearSelfAndDescendantCache(Fs),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(Zh,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(y4,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(Fs,this._getAbsoluteTransform)}_getAbsoluteTransform(t){let n;if(t)return n=new mi,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(Fs)||new mi,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(Ia,this._getTransform)}_getTransform(){var t,n;const r=this._cache.get(Ia)||new mi;r.reset();const o=this.x(),i=this.y(),s=dt.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,d=this.attrs.skewX||0,c=this.attrs.skewY||0,u=this.attrs.offsetX||0,h=this.attrs.offsetY||0;return(o!==0||i!==0)&&r.translate(o,i),s!==0&&r.rotate(s),(d!==0||c!==0)&&r.skew(d,c),(a!==1||l!==1)&&r.scale(a,l),(u!==0||h!==0)&&r.translate(-1*u,-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(JD)<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 ka({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(),d=new ka({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,d),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():dt.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+QD,{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[g4+Ae._capitalize(t)];return Ae._isFunction(r)?r.call(this,n):this._setAttr(t,n),this}_requestDraw(){if(dt.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===v4&&(n.target=this);const o=[$D,eP,tP,nP,rP,oP];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=rf.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,rf.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;bn._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){bn._dragElements.has(this._id)||this._createDragElement(t);const r=bn._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=bn._dragElements.get(this._id);n&&(n.dragStatus="stopped"),bn._endDragBefore(t),bn._endDragAfter(t)}setDraggable(t){this._setAttr("draggable",t),this._dragChange()}isDragging(){const t=bn._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||dt.dragButtons.indexOf(t.evt.button)>=0)||this.isDragging())return;let n=!1;bn._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=bn._dragElements.get(this._id),n=t&&t.dragStatus==="dragging",r=t&&t.dragStatus==="ready";n?this.stopDrag():r&&bn._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=rf.prototype.getClassName.call(t),o=t.children,i,s,a;n&&(t.attrs.container=n),dt[r]||(Ae.warn('Can not find a node with class name "'+r+'". Fallback to "Shape".'),r="Shape");const l=dt[r];if(i=new l(t.attrs),o)for(s=o.length,a=0;a<s;a++)i.add(rf._createNode(o[a]));return i}};ft.protoListenerMap=new Map,ft.prototype.nodeType="Node",ft.prototype._attrsAffectingSize=[],ft.prototype.eventListeners={},ft.prototype.on(sP,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(Ia),this._clearSelfAndDescendantCache(Fs)}),ft.prototype.on("visibleChange.konva",function(){this._clearSelfAndDescendantCache(by)}),ft.prototype.on("listeningChange.konva",function(){this._clearSelfAndDescendantCache(yy)}),ft.prototype.on("opacityChange.konva",function(){this._clearSelfAndDescendantCache(Zh)});var Bn=se.addGetterSetter;Bn(ft,"zIndex"),Bn(ft,"absolutePosition"),Bn(ft,"position"),Bn(ft,"x",0,ot()),Bn(ft,"y",0,ot()),Bn(ft,"globalCompositeOperation","source-over",Sl()),Bn(ft,"opacity",1,ot()),Bn(ft,"name","",Sl()),Bn(ft,"id","",Sl()),Bn(ft,"rotation",0,ot()),se.addComponentsGetterSetter(ft,"scale",["x","y"]),Bn(ft,"scaleX",1,ot()),Bn(ft,"scaleY",1,ot()),se.addComponentsGetterSetter(ft,"skew",["x","y"]),Bn(ft,"skewX",0,ot()),Bn(ft,"skewY",0,ot()),se.addComponentsGetterSetter(ft,"offset",["x","y"]),Bn(ft,"offsetX",0,ot()),Bn(ft,"offsetY",0,ot()),Bn(ft,"dragDistance",void 0,ot()),Bn(ft,"width",0,ot()),Bn(ft,"height",0,ot()),Bn(ft,"listening",!0,gi()),Bn(ft,"preventDefault",!0,gi()),Bn(ft,"filters",void 0,function(e){return this._filterUpToDate=!1,e}),Bn(ft,"visible",!0,gi()),Bn(ft,"transformsEnabled","all",Sl()),Bn(ft,"size"),Bn(ft,"dragBoundFunc"),Bn(ft,"draggable",!1,gi()),se.backCompat(ft,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Po=class extends ft{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=ft.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=ft.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 d=this.getAbsoluteTransform(t).getMatrix();i.transform(d[0],d[1],d[2],d[3],d[4],d[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(),d=typeof s=="number"&&typeof a=="number"||l,c=n===this;if(d){i.save();const h=this.getAbsoluteTransform(n);let p=h.getMatrix();i.transform(p[0],p[1],p[2],p[3],p[4],p[5]),i.beginPath();let f;if(l)f=l.call(this,i,this);else{const g=this.clipX(),w=this.clipY();i.rect(g||0,w||0,s,a)}i.clip.apply(i,f),p=h.copy().invert().getMatrix(),i.transform(p[0],p[1],p[2],p[3],p[4],p[5])}const u=!c&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";u&&(i.save(),i._applyGlobalCompositeOperation(this)),(o=this.children)===null||o===void 0||o.forEach(function(h){h[e](t,n,r)}),u&&i.restore(),d&&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 d=this;(t=this.children)===null||t===void 0||t.forEach(function(h){if(!h.visible())return;const p=h.getClientRect({relativeTo:d,skipShadow:e.skipShadow,skipStroke:e.skipStroke});p.width===0&&p.height===0||(o===void 0?(o=p.x,i=p.y,s=p.x+p.width,a=p.y+p.height):(o=Math.min(o,p.x),i=Math.min(i,p.y),s=Math.max(s,p.x+p.width),a=Math.max(a,p.y+p.height)))});const c=this.find("Shape");let u=!1;for(let h=0;h<c.length;h++)if(c[h]._isVisible(this)){u=!0;break}return u&&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)}};se.addComponentsGetterSetter(Po,"clip",["x","y","width","height"]),se.addGetterSetter(Po,"clipX",void 0,ot()),se.addGetterSetter(Po,"clipY",void 0,ot()),se.addGetterSetter(Po,"clipWidth",void 0,ot()),se.addGetterSetter(Po,"clipHeight",void 0,ot()),se.addGetterSetter(Po,"clipFunc");var Od=new Map,b4=dt._global.PointerEvent!==void 0;function wy(e){return Od.get(e)}function Cy(e){return{evt:e,pointerId:e.pointerId}}function w4(e,t){return Od.get(e)===t}function C4(e,t){Fd(e),t.getStage()&&(Od.set(e,t),b4&&t._fire("gotpointercapture",Cy(new PointerEvent("gotpointercapture"))))}function Fd(e,t){const n=Od.get(e);if(!n)return;const r=n.getStage();r&&r.content,Od.delete(e),b4&&n._fire("lostpointercapture",Cy(new PointerEvent("lostpointercapture")))}var lP="Stage",cP="string",_4="px",uP="mouseout",S4="mouseleave",k4="mouseover",A4="mouseenter",I4="mousemove",E4="mousedown",x4="mouseup",Nd="pointermove",Bd="pointerdown",Vc="pointerup",zd="pointercancel",dP="lostpointercapture",$h="pointerout",Hd="pointerleave",ep="pointerover",tp="pointerenter",_y="contextmenu",T4="touchstart",R4="touchend",M4="touchmove",L4="touchcancel",Sy="wheel",fP=5,hP=[[A4,"_pointerenter"],[E4,"_pointerdown"],[I4,"_pointermove"],[x4,"_pointerup"],[S4,"_pointerleave"],[T4,"_pointerdown"],[M4,"_pointermove"],[R4,"_pointerup"],[L4,"_pointercancel"],[k4,"_pointerover"],[Sy,"_wheel"],[_y,"_contextmenu"],[Bd,"_pointerdown"],[Nd,"_pointermove"],[Vc,"_pointerup"],[zd,"_pointercancel"],[Hd,"_pointerleave"],[dP,"_lostpointercapture"]],ky={mouse:{[$h]:uP,[Hd]:S4,[ep]:k4,[tp]:A4,[Nd]:I4,[Bd]:E4,[Vc]:x4,[zd]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[$h]:"touchout",[Hd]:"touchleave",[ep]:"touchover",[tp]:"touchenter",[Nd]:M4,[Bd]:T4,[Vc]:R4,[zd]:L4,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[$h]:$h,[Hd]:Hd,[ep]:ep,[tp]:tp,[Nd]:Nd,[Bd]:Bd,[Vc]:Vc,[zd]:zd,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},Ud=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",jc=e=>{const t=Ud(e);if(t==="pointer")return dt.pointerEventsEnabled&&ky.pointer;if(t==="touch")return ky.touch;if(t==="mouse")return ky.mouse};function D4(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&Ae.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}var pP="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 Vd=[];var np=class extends Po{constructor(e){super(D4(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),Vd.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{D4(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===cP){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"),Po.prototype.clone.call(this,e)}destroy(){super.destroy();const e=this.content;e&&Ae._isInDocument(e)&&this.container().removeChild(e);const t=Vd.indexOf(this);return t>-1&&Vd.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(pP),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 ka({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+_4,this.content.style.height=t+_4),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>fP&&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(),dt.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return w4(e,this)}setPointerCapture(e){C4(e,this)}releaseCapture(e){Fd(e,this)}getLayers(){return this.children}_bindContentEvents(){dt.isBrowser&&hP.forEach(([e,t])=>{this.content.addEventListener(e,n=>{this[t](n)},{passive:!1})})}_pointerenter(e){this.setPointersPositions(e);const t=jc(e.type);t&&this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=jc(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=jc(e.type),n=Ud(e.type);if(!t)return;this.setPointersPositions(e);const r=this._getTargetShape(n),o=!(dt.isDragging()||dt.isTransforming())||dt.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=jc(e.type),n=Ud(e.type);if(!t)return;this.setPointersPositions(e);let r=!1;this._changedPointerPositions.forEach(o=>{const i=this.getIntersection(o);if(bn.justDragged=!1,dt["_"+n+"ListenClick"]=!0,!i||!i.isListening()){this[n+"ClickStartShape"]=void 0;return}dt.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=jc(e.type),n=Ud(e.type);if(!t)return;const r=e.type.indexOf("touch")>=0||e.pointerType==="touch";if(dt.isDragging()&&bn.node.preventDefault()&&e.cancelable&&r&&e.preventDefault(),this.setPointersPositions(e),!(!(dt.isDragging()||dt.isTransforming())||dt.hitOnDragEnabled))return;const o={};let i=!1;const s=this._getTargetShape(n);this._changedPointerPositions.forEach(a=>{const l=wy(a.id)||this.getIntersection(a),d=a.id,c={evt:e,pointerId:d},u=s!==l;if(u&&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,u&&(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:d}),this[n+"targetShape"]=null)}),i||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=jc(e.type),n=Ud(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=wy(a.id)||this.getIntersection(a);if(l){if(l.releaseCapture(a.id),i[l._id])return;i[l._id]=!0}const d=a.id,c={evt:e,pointerId:d};let u=!1;dt["_"+n+"InDblClickWindow"]?(u=!0,clearTimeout(this[n+"DblTimeout"])):bn.justDragged||(dt["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout(function(){dt["_"+n+"InDblClickWindow"]=!1},dt.dblClickWindow),l&&l.isListening()?(s=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,{...c}),dt["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,{...c}),u&&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),dt["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:d}),u&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:d}))}),s||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),dt["_"+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(_y,{evt:e}):this._fire(_y,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);const t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Sy,{evt:e}):this._fire(Sy,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=wy(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(Vc,Cy(e)),Fd(e.pointerId)}_lostpointercapture(e){Fd(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 ka({width:this.width(),height:this.height()}),this.bufferHitCanvas=new gy({pixelRatio:1,width:this.width(),height:this.height()}),!dt.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}};np.prototype.nodeType=lP,rr(np),se.addGetterSetter(np,"container"),dt.isBrowser&&document.addEventListener("visibilitychange",()=>{Vd.forEach(e=>{e.batchDraw()})});var P4="hasShadow",O4="shadowRGBA",F4="patternImage",N4="linearGradient",B4="radialGradient",rp;function Ay(){return rp||(rp=Ae.createCanvasElement().getContext("2d"),rp)}const jd={};function mP(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function gP(e){e.stroke()}function vP(e){const t=this.attrs.fillRule;t?e.fill(t):e.fill()}function yP(e){e.stroke()}function bP(){this._clearCache(P4)}function wP(){this._clearCache(O4)}function CP(){this._clearCache(F4)}function _P(){this._clearCache(N4)}function SP(){this._clearCache(B4)}var nt=class extends ft{constructor(e){super(e);let t,n=0;for(;t=Ae.getHitColor(),!(t&&!(t in jd));)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,jd[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(P4,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(F4,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=Ay().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new mi;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(dt.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(N4,this.__getLinearGradient)}__getLinearGradient(){const e=this.fillLinearGradientColorStops();if(e){const t=Ay(),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(B4,this.__getRadialGradient)}__getRadialGradient(){const e=this.fillRadialGradientColorStops();if(e){const t=Ay(),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(O4,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 ft.prototype.destroy.call(this),delete jd[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,d=!e.skipShadow&&this.hasShadow(),c=d?this.shadowOffsetX():0,u=d?this.shadowOffsetY():0,h=a+Math.abs(c),p=l+Math.abs(u),f=d&&this.shadowBlur()||0,g={width:h+f*2,height:p+f*2,x:-(s/2+f)+Math.min(c,0)+i.x,y:-(s/2+f)+Math.min(u,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 d=t===this;if(!this.isVisible()&&!d)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,u=c.getContext();n?(u.save(),u.setTransform(1,0,0,1,0,0),u.clearRect(0,0,c.width,c.height),u.restore()):u.clear(),u.save(),u._applyLineJoin(this),u._applyMiterLimit(this);const h=this.getAbsoluteTransform(t).getMatrix();u.transform(h[0],h[1],h[2],h[3],h[4],h[5]),s.call(this,u,this),u.restore();const p=c.pixelRatio;a&&o._applyShadow(this),d||(o._applyOpacity(this),o._applyGlobalCompositeOperation(this)),o.drawImage(c._canvas,c.x||0,c.y||0,c.width/p,c.height/p)}else{if(o._applyLineJoin(this),o._applyMiterLimit(this),!d){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 d=this.getAbsoluteTransform(t).getMatrix();return i.transform(d[0],d[1],d[2],d[3],d[4],d[5]),this._drawCachedHitCanvas(i),i.restore(),this}if(!s)return this;if(i.save(),i._applyLineJoin(this),i._applyMiterLimit(this),this!==t){const d=this.getAbsoluteTransform(t).getMatrix();i.transform(d[0],d[1],d[2],d[3],d[4],d[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,d=l.length,c=Ae._hexToRgb(this.colorKey);for(let u=0;u<d;u+=4)l[u+3]>e?(l[u]=c.r,l[u+1]=c.g,l[u+2]=c.b,l[u+3]=255):l[u+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 w4(e,this)}setPointerCapture(e){C4(e,this)}releaseCapture(e){Fd(e,this)}};nt.prototype._fillFunc=mP,nt.prototype._strokeFunc=gP,nt.prototype._fillFuncHit=vP,nt.prototype._strokeFuncHit=yP,nt.prototype._centroid=!1,nt.prototype.nodeType="Shape",rr(nt),nt.prototype.eventListeners={},nt.prototype.on("shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",bP),nt.prototype.on("shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",wP),nt.prototype.on("fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",CP),nt.prototype.on("fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",_P),nt.prototype.on("fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",SP),se.addGetterSetter(nt,"stroke",void 0,h4()),se.addGetterSetter(nt,"strokeWidth",2,ot()),se.addGetterSetter(nt,"fillAfterStrokeEnabled",!1),se.addGetterSetter(nt,"hitStrokeWidth","auto",vy()),se.addGetterSetter(nt,"strokeHitEnabled",!0,gi()),se.addGetterSetter(nt,"perfectDrawEnabled",!0,gi()),se.addGetterSetter(nt,"shadowForStrokeEnabled",!0,gi()),se.addGetterSetter(nt,"lineJoin"),se.addGetterSetter(nt,"lineCap"),se.addGetterSetter(nt,"miterLimit"),se.addGetterSetter(nt,"sceneFunc"),se.addGetterSetter(nt,"hitFunc"),se.addGetterSetter(nt,"dash"),se.addGetterSetter(nt,"dashOffset",0,ot()),se.addGetterSetter(nt,"shadowColor",void 0,Sl()),se.addGetterSetter(nt,"shadowBlur",0,ot()),se.addGetterSetter(nt,"shadowOpacity",1,ot()),se.addComponentsGetterSetter(nt,"shadowOffset",["x","y"]),se.addGetterSetter(nt,"shadowOffsetX",0,ot()),se.addGetterSetter(nt,"shadowOffsetY",0,ot()),se.addGetterSetter(nt,"fillPatternImage"),se.addGetterSetter(nt,"fill",void 0,h4()),se.addGetterSetter(nt,"fillPatternX",0,ot()),se.addGetterSetter(nt,"fillPatternY",0,ot()),se.addGetterSetter(nt,"fillLinearGradientColorStops"),se.addGetterSetter(nt,"strokeLinearGradientColorStops"),se.addGetterSetter(nt,"fillRadialGradientStartRadius",0),se.addGetterSetter(nt,"fillRadialGradientEndRadius",0),se.addGetterSetter(nt,"fillRadialGradientColorStops"),se.addGetterSetter(nt,"fillPatternRepeat","repeat"),se.addGetterSetter(nt,"fillEnabled",!0),se.addGetterSetter(nt,"strokeEnabled",!0),se.addGetterSetter(nt,"shadowEnabled",!0),se.addGetterSetter(nt,"dashEnabled",!0),se.addGetterSetter(nt,"strokeScaleEnabled",!0),se.addGetterSetter(nt,"fillPriority","color"),se.addComponentsGetterSetter(nt,"fillPatternOffset",["x","y"]),se.addGetterSetter(nt,"fillPatternOffsetX",0,ot()),se.addGetterSetter(nt,"fillPatternOffsetY",0,ot()),se.addComponentsGetterSetter(nt,"fillPatternScale",["x","y"]),se.addGetterSetter(nt,"fillPatternScaleX",1,ot()),se.addGetterSetter(nt,"fillPatternScaleY",1,ot()),se.addComponentsGetterSetter(nt,"fillLinearGradientStartPoint",["x","y"]),se.addComponentsGetterSetter(nt,"strokeLinearGradientStartPoint",["x","y"]),se.addGetterSetter(nt,"fillLinearGradientStartPointX",0),se.addGetterSetter(nt,"strokeLinearGradientStartPointX",0),se.addGetterSetter(nt,"fillLinearGradientStartPointY",0),se.addGetterSetter(nt,"strokeLinearGradientStartPointY",0),se.addComponentsGetterSetter(nt,"fillLinearGradientEndPoint",["x","y"]),se.addComponentsGetterSetter(nt,"strokeLinearGradientEndPoint",["x","y"]),se.addGetterSetter(nt,"fillLinearGradientEndPointX",0),se.addGetterSetter(nt,"strokeLinearGradientEndPointX",0),se.addGetterSetter(nt,"fillLinearGradientEndPointY",0),se.addGetterSetter(nt,"strokeLinearGradientEndPointY",0),se.addComponentsGetterSetter(nt,"fillRadialGradientStartPoint",["x","y"]),se.addGetterSetter(nt,"fillRadialGradientStartPointX",0),se.addGetterSetter(nt,"fillRadialGradientStartPointY",0),se.addComponentsGetterSetter(nt,"fillRadialGradientEndPoint",["x","y"]),se.addGetterSetter(nt,"fillRadialGradientEndPointX",0),se.addGetterSetter(nt,"fillRadialGradientEndPointY",0),se.addGetterSetter(nt,"fillPatternRotation",0),se.addGetterSetter(nt,"fillRule",void 0,Sl()),se.backCompat(nt,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var kP="beforeDraw",AP="draw",z4=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],IP=z4.length,Al=class extends Po{constructor(e){super(e),this.canvas=new ka,this.hitCanvas=new gy({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(){ft.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(!ft.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(ft.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(ft.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 ft.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(),ft.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<IP;r++){const o=z4[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=jd[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(kP,{node:this}),this.clearBeforeDraw()&&o.getContext().clear(),Po.prototype.drawScene.call(this,o,t,n),this._fire(AP,{node:this}),this}drawHit(e,t){const n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Po.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()}};Al.prototype.nodeType="Layer",rr(Al),se.addGetterSetter(Al,"imageSmoothingEnabled",!0),se.addGetterSetter(Al,"clearBeforeDraw",!0),se.addGetterSetter(Al,"hitGraphEnabled",!0,gi());var Iy=class extends Al{constructor(e){super(e),this.listening(!1),Ae.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}};Iy.prototype.nodeType="FastLayer",rr(Iy);var Gc=class extends Po{_validateAdd(e){const t=e.getType();t!=="Group"&&t!=="Shape"&&Ae.throw("You may only add groups and shapes to groups.")}};Gc.prototype.nodeType="Group",rr(Gc);var Ey=(function(){return _l.performance&&_l.performance.now?function(){return _l.performance.now()}:function(){return new Date().getTime()}})(),Wc=class uu{constructor(t,n){this.id=uu.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Ey(),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=uu.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=Ey(),uu._addAnimation(this),this}stop(){return uu._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(Ey());const a=i.length;let l;if(s?l=s.call(o,o.frame)!==!1:l=!0,!!l)for(let d=0;d<a;d++){const c=i[d];c._id!==void 0&&(t[c._id]=c)}}for(const r in t)t.hasOwnProperty(r)&&t[r].batchDraw()}static _animationLoop(){const t=uu;t.animations.length?(t._runFrames(),Ae.requestAnimFrame(t._animationLoop)):t.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Ae.requestAnimFrame(this._animationLoop))}};Wc.animations=[],Wc.animIdCounter=0,Wc.animRunning=!1;var EP={node:1,duration:1,easing:1,onFinish:1,yoyo:1},xP=1,H4=2,U4=3,V4=["fill","stroke","shadowColor"],TP=0,RP=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=H4,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=U4,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===H4?this.setTime(e):this.state===U4&&this.setTime(this.duration-e)}pause(){this.state=xP,this.fire("onPause")}getTimer(){return new Date().getTime()}},op=class fr{constructor(t){const n=this,r=t.node,o=r._id,i=t.easing||Gd.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=TP++;const d=r.getLayer()||(r instanceof dt.Stage?r.getLayers():null);d||Ae.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new Wc(function(){n.tween.onEnterFrame()},d),this.tween=new RP(l,function(c){n._tweenFunc(c)},i,0,1,a*1e3,s),this._addListeners(),fr.attrs[o]||(fr.attrs[o]={}),fr.attrs[o][this._id]||(fr.attrs[o][this._id]={}),fr.tweens[o]||(fr.tweens[o]={});for(l in t)EP[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,d;const c=fr.tweens[o][t];c&&delete fr.attrs[o][c][t];let u=r.getAttr(t);if(Ae._isArray(n))if(i=[],s=Math.max(n.length,u.length),t==="points"&&n.length!==u.length&&(n.length>u.length?(l=u,u=Ae._prepareArrayForTween(u,n,r.closed())):(a=n,n=Ae._prepareArrayForTween(n,u,r.closed()))),t.indexOf("fill")===0)for(let h=0;h<s;h++)if(h%2===0)i.push(n[h]-u[h]);else{const p=Ae.colorToRGBA(u[h]);d=Ae.colorToRGBA(n[h]),u[h]=p,i.push({r:d.r-p.r,g:d.g-p.g,b:d.b-p.b,a:d.a-p.a})}else for(let h=0;h<s;h++)i.push(n[h]-u[h]);else V4.indexOf(t)!==-1?(u=Ae.colorToRGBA(u),d=Ae.colorToRGBA(n),i={r:d.r-u.r,g:d.g-u.g,b:d.b-u.b,a:d.a-u.a}):i=n-u;fr.attrs[o][this._id][t]={start:u,diff:i,end:n,trueEnd:a,trueStart:l},fr.tweens[o][t]=this._id}_tweenFunc(t){const n=this.node,r=fr.attrs[n._id][this._id];let o,i,s,a,l,d,c,u;for(o in r){if(i=r[o],s=i.start,a=i.diff,u=i.end,Ae._isArray(s))if(l=[],c=Math.max(s.length,u.length),o.indexOf("fill")===0)for(d=0;d<c;d++)d%2===0?l.push((s[d]||0)+a[d]*t):l.push("rgba("+Math.round(s[d].r+a[d].r*t)+","+Math.round(s[d].g+a[d].g*t)+","+Math.round(s[d].b+a[d].b*t)+","+(s[d].a+a[d].a*t)+")");else for(d=0;d<c;d++)l.push((s[d]||0)+a[d]*t);else V4.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=fr.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=fr.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=fr.tweens[t];this.pause(),this.anim&&this.anim.stop();for(const o in r)delete fr.tweens[t][o];delete fr.attrs[t][n],fr.tweens[t]&&(Object.keys(fr.tweens[t]).length===0&&delete fr.tweens[t],Object.keys(fr.attrs[t]).length===0&&delete fr.attrs[t])}};op.attrs={},op.tweens={},ft.prototype.to=function(e){const t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new op(e).play()};const Gd={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-Gd.BounceEaseOut(r-e,0,n,r)+t},BounceEaseInOut(e,t,n,r){return e<r/2?Gd.BounceEaseIn(e*2,0,n,r)*.5+t:Gd.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}},j4=Ae._assign(dt,{Util:Ae,Transform:mi,Node:ft,Container:Po,Stage:np,stages:Vd,Layer:Al,FastLayer:Iy,Group:Gc,DD:bn,Shape:nt,shapes:jd,Animation:Wc,Tween:op,Easings:Gd,Context:Yh,Canvas:my});var Ns=class extends nt{_sceneFunc(e){const t=dt.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=dt.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),d=i*(i>0?t:e),c=s*(s>0?e:t),u=a*(a>0?t:e);return{x:l,y:n?-1*u:c,width:d-l,height:u-c}}};Ns.prototype._centroid=!0,Ns.prototype.className="Arc",Ns.prototype._attrsAffectingSize=["innerRadius","outerRadius","angle","clockwise"],rr(Ns),se.addGetterSetter(Ns,"innerRadius",0,ot()),se.addGetterSetter(Ns,"outerRadius",0,ot()),se.addGetterSetter(Ns,"angle",0,ot()),se.addGetterSetter(Ns,"clockwise",!1,gi());function xy(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)),d=s*a/(a+l),c=s*l/(a+l);return[n-d*(o-e),r-d*(i-t),n+c*(o-e),r+c*(i-t)]}function G4(e,t){const n=e.length,r=[];for(let o=2;o<n-2;o+=2){const i=xy(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 MP(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 Bs=class extends nt{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():G4(this.points(),this.tension())}_getTensionPointsClosed(){const e=this.points(),t=e.length,n=this.tension(),r=xy(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),o=xy(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),i=G4(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],...MP(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}}};Bs.prototype.className="Line",Bs.prototype._attrsAffectingSize=["points","bezier","tension"],rr(Bs),se.addGetterSetter(Bs,"closed",!1),se.addGetterSetter(Bs,"bezier",!1),se.addGetterSetter(Bs,"tension",0,ot()),se.addGetterSetter(Bs,"points",[],qD());const LP=[[],[],[-.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]],DP=[[],[],[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]],PP=[[1],[1,1],[1,2,1],[1,3,3,1]],W4=(e,t,n)=>{let r,o;const s=n/2;r=0;for(let a=0;a<20;a++)o=s*LP[20][a]+s,r+=DP[20][a]*OP(e,t,o);return s*r},K4=(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),d=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),u=d/a,h=n+c,p=u-c*c,f=h*h+p>0?Math.sqrt(h*h+p):0,g=c*c+p>0?Math.sqrt(c*c+p):0,w=c+Math.sqrt(c*c+p)!==0?p*Math.log(Math.abs((h+f)/(c+g))):0;return Math.sqrt(a)/2*(h*f-c*g+w)};function OP(e,t,n){const r=Ty(1,n,e),o=Ty(1,n,t),i=r*r+o*o;return Math.sqrt(i)}var Ty=(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+=PP[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 Ty(e-1,t,o)}};const q4=(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 d=n(o-i),c=Math.abs(e-d)/t;c<r?(r=c,o-=i):i/=2}if(s++,s>500)break}return o};var Xo=class xo extends nt{constructor(t){super(t),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=xo.parsePathData(this.data()),this.pathLength=xo.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],d=s[2],c=s[3],u=s[4],h=s[5],p=s[6],f=s[7],g=d>c?d:c,w=d>c?1:d/c,C=d>c?c/d:1;t.translate(a,l),t.rotate(p),t.scale(w,C),t.arc(0,0,g,u,u+h,1-f),t.scale(1/w,1/C),t.rotate(-p),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 d=l.points[4],c=l.points[5],u=l.points[4]+c;let h=Math.PI/180;if(Math.abs(d-u)<h&&(h=Math.abs(d-u)),c<0)for(let p=d-h;p>u;p-=h){const f=xo.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],p,0);t.push(f.x,f.y)}else for(let p=d+h;p<u;p+=h){const f=xo.getPointOnEllipticalArc(l.points[0],l.points[1],l.points[2],l.points[3],p,0);t.push(f.x,f.y)}}else if(l.command==="C")for(let d=0;d<=1;d+=.01){const c=xo.getPointOnCubicBezier(d,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 xo.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 xo.getPointOnLine(t,s.start.x,s.start.y,a[0],a[1]);case"C":return xo.getPointOnCubicBezier(q4(t,xo.getPathLength(n),g=>W4([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 xo.getPointOnQuadraticBezier(q4(t,xo.getPathLength(n),g=>K4([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],d=a[1],c=a[2],u=a[3],h=a[5],p=a[6];let f=a[4];return f+=h*t/s.pathLength,xo.getPointOnEllipticalArc(l,d,c,u,f,p)}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 d=(i-r)/(o-n),c=Math.sqrt(t*t/(1+d*d))*(o<n?-1:1),u=d*c;if(Math.abs(a-r-d*(s-n))<1e-10)return{x:s+c,y:a+u};const h=((s-n)*(o-n)+(a-r)*(i-r))/(l*l),p=n+h*(o-n),f=r+h*(i-r),g=this.getLineLength(s,a,p,f),w=Math.sqrt(t*t-g*g),C=Math.sqrt(w*w/(1+d*d))*(o<n?-1:1),S=d*C;return{x:p+C,y:f+S}}static getPointOnCubicBezier(t,n,r,o,i,s,a,l,d){function c(f){return f*f*f}function u(f){return 3*f*f*(1-f)}function h(f){return 3*f*(1-f)*(1-f)}function p(f){return(1-f)*(1-f)*(1-f)}return{x:l*c(t)+s*u(t)+o*h(t)+n*p(t),y:d*c(t)+a*u(t)+i*h(t)+r*p(t)}}static getPointOnQuadraticBezier(t,n,r,o,i,s,a){function l(u){return u*u}function d(u){return 2*u*(1-u)}function c(u){return(1-u)*(1-u)}return{x:s*l(t)+o*d(t)+n*c(t),y:a*l(t)+i*d(t)+r*c(t)}}static getPointOnEllipticalArc(t,n,r,o,i,s){const a=Math.cos(s),l=Math.sin(s),d={x:r*Math.cos(i),y:o*Math.sin(i)};return{x:t+(d.x*a-d.y*l),y:n+(d.x*l+d.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 u=0;u<r.length;u++)n=n.replace(new RegExp(r[u],"g"),"|"+r[u]);const o=n.split("|"),i=[],s=[];let a=0,l=0;const d=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;let c;for(let u=1;u<o.length;u++){let h=o[u],p=h.charAt(0);for(h=h.slice(1),s.length=0;c=d.exec(h);)s.push(c[0]);let f=[],g=p==="A"||p==="a"?0:-1;for(let w=0,C=s.length;w<C;w++){const S=s[w];if(S==="00"){f.push(0,0),g>=0&&(g+=2,g>=7&&(g-=7));continue}if(g>=0){if(g===3){if(/^[01]{2}\d+(?:\.\d+)?$/.test(S)){f.push(parseInt(S[0],10)),f.push(parseInt(S[1],10)),f.push(parseFloat(S.slice(2))),g+=3,g>=7&&(g-=7);continue}if(S==="11"||S==="10"||S==="01"){f.push(parseInt(S[0],10)),f.push(parseInt(S[1],10)),g+=2,g>=7&&(g-=7);continue}if(S==="0"||S==="1"){f.push(parseInt(S,10)),g+=1,g>=7&&(g-=7);continue}}else if(g===4){if(/^[01]\d+(?:\.\d+)?$/.test(S)){f.push(parseInt(S[0],10)),f.push(parseFloat(S.slice(1))),g+=2,g>=7&&(g-=7);continue}if(S==="0"||S==="1"){f.push(parseInt(S,10)),g+=1,g>=7&&(g-=7);continue}}const y=parseFloat(S);isNaN(y)?f.push(0):f.push(y),g+=1,g>=7&&(g-=7)}else{const y=parseFloat(S);isNaN(y)?f.push(0):f.push(y)}}for(;f.length>0&&!isNaN(f[0]);){let w="",C=[];const S=a,y=l;let b,I,R,O,B,L,z,Q,x,N;switch(p){case"l":a+=f.shift(),l+=f.shift(),w="L",C.push(a,l);break;case"L":a=f.shift(),l=f.shift(),C.push(a,l);break;case"m":const A=f.shift(),U=f.shift();if(a+=A,l+=U,w="M",i.length>2&&i[i.length-1].command==="z"){for(let Y=i.length-2;Y>=0;Y--)if(i[Y].command==="M"){a=i[Y].points[0]+A,l=i[Y].points[1]+U;break}}C.push(a,l),p="l";break;case"M":a=f.shift(),l=f.shift(),w="M",C.push(a,l),p="L";break;case"h":a+=f.shift(),w="L",C.push(a,l);break;case"H":a=f.shift(),w="L",C.push(a,l);break;case"v":l+=f.shift(),w="L",C.push(a,l);break;case"V":l=f.shift(),w="L",C.push(a,l);break;case"C":C.push(f.shift(),f.shift(),f.shift(),f.shift()),a=f.shift(),l=f.shift(),C.push(a,l);break;case"c":C.push(a+f.shift(),l+f.shift(),a+f.shift(),l+f.shift()),a+=f.shift(),l+=f.shift(),w="C",C.push(a,l);break;case"S":I=a,R=l,b=i[i.length-1],b.command==="C"&&(I=a+(a-b.points[2]),R=l+(l-b.points[3])),C.push(I,R,f.shift(),f.shift()),a=f.shift(),l=f.shift(),w="C",C.push(a,l);break;case"s":I=a,R=l,b=i[i.length-1],b.command==="C"&&(I=a+(a-b.points[2]),R=l+(l-b.points[3])),C.push(I,R,a+f.shift(),l+f.shift()),a+=f.shift(),l+=f.shift(),w="C",C.push(a,l);break;case"Q":C.push(f.shift(),f.shift()),a=f.shift(),l=f.shift(),C.push(a,l);break;case"q":C.push(a+f.shift(),l+f.shift()),a+=f.shift(),l+=f.shift(),w="Q",C.push(a,l);break;case"T":I=a,R=l,b=i[i.length-1],b.command==="Q"&&(I=a+(a-b.points[0]),R=l+(l-b.points[1])),a=f.shift(),l=f.shift(),w="Q",C.push(I,R,a,l);break;case"t":I=a,R=l,b=i[i.length-1],b.command==="Q"&&(I=a+(a-b.points[0]),R=l+(l-b.points[1])),a+=f.shift(),l+=f.shift(),w="Q",C.push(I,R,a,l);break;case"A":O=f.shift(),B=f.shift(),L=f.shift(),z=f.shift(),Q=f.shift(),x=a,N=l,a=f.shift(),l=f.shift(),w="A",C=this.convertEndpointToCenterParameterization(x,N,a,l,z,Q,O,B,L);break;case"a":O=f.shift(),B=f.shift(),L=f.shift(),z=f.shift(),Q=f.shift(),x=a,N=l,a+=f.shift(),l+=f.shift(),w="A",C=this.convertEndpointToCenterParameterization(x,N,a,l,z,Q,O,B,L);break}i.push({command:w||p,points:C,start:{x:S,y},pathLength:this.calcLength(S,y,w||p,C)})}(p==="z"||p==="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 d=xo;switch(r){case"L":return d.getLineLength(t,n,o[0],o[1]);case"C":return W4([t,o[0],o[2],o[4]],[n,o[1],o[3],o[5]],1);case"Q":return K4([t,o[0],o[2]],[n,o[1],o[3]],1);case"A":i=0;const c=o[4],u=o[5],h=o[4]+u;let p=Math.PI/180;if(Math.abs(c-h)<p&&(p=Math.abs(c-h)),s=d.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],c,0),u<0)for(l=c-p;l>h;l-=p)a=d.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=d.getLineLength(s.x,s.y,a.x,a.y),s=a;else for(l=c+p;l<h;l+=p)a=d.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],l,0),i+=d.getLineLength(s.x,s.y,a.x,a.y),s=a;return a=d.getPointOnEllipticalArc(o[0],o[1],o[2],o[3],h,0),i+=d.getLineLength(s.x,s.y,a.x,a.y),i}return 0}static convertEndpointToCenterParameterization(t,n,r,o,i,s,a,l,d){const c=d*(Math.PI/180),u=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,p=u*u/(a*a)+h*h/(l*l);p>1&&(a*=Math.sqrt(p),l*=Math.sqrt(p));let f=Math.sqrt((a*a*(l*l)-a*a*(h*h)-l*l*(u*u))/(a*a*(h*h)+l*l*(u*u)));i===s&&(f*=-1),isNaN(f)&&(f=0);const g=f*a*h/l,w=f*-l*u/a,C=(t+r)/2+Math.cos(c)*g-Math.sin(c)*w,S=(n+o)/2+Math.sin(c)*g+Math.cos(c)*w,y=function(z){return Math.sqrt(z[0]*z[0]+z[1]*z[1])},b=function(z,Q){return(z[0]*Q[0]+z[1]*Q[1])/(y(z)*y(Q))},I=function(z,Q){return(z[0]*Q[1]<z[1]*Q[0]?-1:1)*Math.acos(b(z,Q))},R=I([1,0],[(u-g)/a,(h-w)/l]),O=[(u-g)/a,(h-w)/l],B=[(-1*u-g)/a,(-1*h-w)/l];let L=I(O,B);return b(O,B)<=-1&&(L=Math.PI),b(O,B)>=1&&(L=0),s===0&&L>0&&(L=L-2*Math.PI),s===1&&L<0&&(L=L+2*Math.PI),[C,S,a,l,R,L,c,s]}};Xo.prototype.className="Path",Xo.prototype._attrsAffectingSize=["data"],rr(Xo),se.addGetterSetter(Xo,"data");var Il=class extends Bs{_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 u=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[s-2],n[s-1]],h=Xo.calcLength(r[r.length-4],r[r.length-3],"C",u),p=Xo.getPointOnQuadraticBezier(Math.min(1,1-i/h),u[0],u[1],u[2],u[3],u[4],u[5]);a=n[s-2]-p.x,l=n[s-1]-p.y}else a=n[s-2]-n[s-4],l=n[s-1]-n[s-3];const d=(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(d),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}}};Il.prototype.className="Arrow",rr(Il),se.addGetterSetter(Il,"pointerLength",10,ot()),se.addGetterSetter(Il,"pointerWidth",10,ot()),se.addGetterSetter(Il,"pointerAtBeginning",!1),se.addGetterSetter(Il,"pointerAtEnding",!0);var Kc=class extends nt{_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)}};Kc.prototype._centroid=!0,Kc.prototype.className="Circle",Kc.prototype._attrsAffectingSize=["radius"],rr(Kc),se.addGetterSetter(Kc,"radius",0,ot());var Ea=class extends nt{_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)}};Ea.prototype.className="Ellipse",Ea.prototype._centroid=!0,Ea.prototype._attrsAffectingSize=["radiusX","radiusY"],rr(Ea),se.addComponentsGetterSetter(Ea,"radius",["x","y"]),se.addGetterSetter(Ea,"radiusX",0,ot()),se.addGetterSetter(Ea,"radiusY",0,ot());var vi=class rk extends nt{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 rk({image:o}))},o.onerror=r,o.crossOrigin="Anonymous",o.src=t}};vi.prototype.className="Image",vi.prototype._attrsAffectingSize=["image"],rr(vi),se.addGetterSetter(vi,"cornerRadius",0,Qh(4)),se.addGetterSetter(vi,"image"),se.addComponentsGetterSetter(vi,"crop",["x","y","width","height"]),se.addGetterSetter(vi,"cropX",0,ot()),se.addGetterSetter(vi,"cropY",0,ot()),se.addGetterSetter(vi,"cropWidth",0,ot()),se.addGetterSetter(vi,"cropHeight",0,ot());var Y4=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],FP="Change.konva",NP="none",Ry="up",My="right",Ly="down",Dy="left",BP=Y4.length,Py=class extends Gc{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<BP;n++)e.on(Y4[n]+FP,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 Ry:s=n/2,a=-1*l;break;case My:s=n+i,a=r/2;break;case Ly:s=n/2,a=r+l;break;case Dy: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})}}};Py.prototype.className="Label",rr(Py);var El=class extends nt{_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,d=0,c=0;typeof s=="number"?a=l=d=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),d=Math.min(s[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(a,0),r===Ry&&(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===My&&(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===Ly&&(e.lineTo((t+o)/2,n),e.lineTo(t/2,n+i),e.lineTo((t-o)/2,n)),e.lineTo(d,n),e.arc(d,n-d,d,Math.PI/2,Math.PI,!1),r===Dy&&(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===Ry?(t-=r,s+=r):o===Ly?s+=r:o===Dy?(e-=n*1.5,i+=n):o===My&&(i+=n*1.5),{x:e,y:t,width:i,height:s}}};El.prototype.className="Tag",rr(El),se.addGetterSetter(El,"pointerDirection",NP),se.addGetterSetter(El,"pointerWidth",0,ot()),se.addGetterSetter(El,"pointerHeight",0,ot()),se.addGetterSetter(El,"cornerRadius",0,Qh(4));var Wd=class extends nt{_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)}};Wd.prototype.className="Rect",rr(Wd),se.addGetterSetter(Wd,"cornerRadius",0,Qh(4));var xa=class extends nt{_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)}};xa.prototype.className="RegularPolygon",xa.prototype._centroid=!0,xa.prototype._attrsAffectingSize=["radius"],rr(xa),se.addGetterSetter(xa,"radius",0,ot()),se.addGetterSetter(xa,"sides",0,ot()),se.addGetterSetter(xa,"cornerRadius",0,Qh(4));var X4=Math.PI*2,xl=class extends nt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,X4,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),X4,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)}};xl.prototype.className="Ring",xl.prototype._centroid=!0,xl.prototype._attrsAffectingSize=["innerRadius","outerRadius"],rr(xl),se.addGetterSetter(xl,"innerRadius",0,ot()),se.addGetterSetter(xl,"outerRadius",0,ot());var qi=class extends nt{constructor(e){super(e),this._updated=!0,this.anim=new Wc(()=>{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],d=o[r+3],c=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,d),e.closePath(),e.fillStrokeShape(this)),c)if(i){const u=i[t],h=n*2;e.drawImage(c,s,a,l,d,u[h+0],u[h+1],l,d)}else e.drawImage(c,s,a,l,d,0,0,l,d)}_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],d=n*2;e.rect(l[d+0],l[d+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)}};qi.prototype.className="Sprite",rr(qi),se.addGetterSetter(qi,"animation"),se.addGetterSetter(qi,"animations"),se.addGetterSetter(qi,"frameOffsets"),se.addGetterSetter(qi,"image"),se.addGetterSetter(qi,"frameIndex",0,ot()),se.addGetterSetter(qi,"frameRate",17,ot()),se.backCompat(qi,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Ta=class extends nt{_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)}};Ta.prototype.className="Star",Ta.prototype._centroid=!0,Ta.prototype._attrsAffectingSize=["innerRadius","outerRadius"],rr(Ta),se.addGetterSetter(Ta,"numPoints",5,ot()),se.addGetterSetter(Ta,"innerRadius",0,ot()),se.addGetterSetter(Ta,"outerRadius",0,ot());function Ra(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 qc="auto",zP="center",Q4="inherit",Kd="justify",HP="Change.konva",Z4="2d",J4="-",$4="left",UP="text",VP="Text",jP="top",GP="bottom",eS="middle",tS="normal",WP="px ",ip=" ",KP="right",nS="rtl",qP="word",YP="char",rS="none",Oy="β¦",oS=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],XP=oS.length,qd=null;function QP(){if(qd!==null)return qd;qd=!1;try{const e=document.createElement("canvas");e.width=10,e.height=10;const t=e.getContext(Z4);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){qd=!0;break}}}catch{}return qd}function ZP(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 sp;function Fy(){return sp||(sp=Ae.createCanvasElement().getContext(Z4),sp)}function JP(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)}function $P(e){e.setAttr("miterLimit",2),e.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function eO(e){return e=e||{},!e.fillLinearGradientColorStops&&!e.fillRadialGradientColorStops&&!e.fillPatternImage&&(e.fill=e.fill||"black"),e}var jn=class extends nt{constructor(e){super(eO(e)),this._partialTextX=0,this._partialTextY=0;for(let t=0;t<XP;t++)this.on(oS[t]+HP,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(),d=this.direction(),c=0,u=this.align(),h=this.getWidth(),p=this.letterSpacing(),f=this.charRenderFunc(),g=this.fill(),w=this.textDecoration(),C=this.underlineOffset(),S=w.indexOf("underline")!==-1,y=w.indexOf("line-through")!==-1,b;d=d===Q4?e.direction:d;let I=a/2,R=eS;if(!dt.legacyTextRendering){const O=this.measureSize("M");R="alphabetic",I=(((t=O.fontBoundingBoxAscent)!==null&&t!==void 0?t:O.actualBoundingBoxAscent)-((n=O.fontBoundingBoxDescent)!==null&&n!==void 0?n:O.actualBoundingBoxDescent))/2+a/2}for(d===nS&&e.setAttr("direction",d),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",R),e.setAttr("textAlign",$4),l===eS?c=(this.getHeight()-o*a-i*2)/2:l===GP&&(c=this.getHeight()-o*a-i*2),e.translate(i,c+i),b=0;b<o;b++){let O=0,B=0;const L=r[b],z=L.text,Q=L.width,x=L.lastInParagraph;if(e.save(),u===KP?O+=h-Q-i*2:u===zP&&(O+=(h-Q-i*2)/2),S){e.save(),e.beginPath();const A=C??(dt.legacyTextRendering?Math.round(s/2):Math.round(s/4)),U=O,Y=I+B+A;e.moveTo(U,Y);const Z=u===Kd&&!x?h-i*2:Q;e.lineTo(U+Math.round(Z),Y),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||g,e.stroke(),e.restore()}const N=O;if(d!==nS&&(p!==0||u===Kd||f)){const A=z.split(" ").length-1,U=Ra(z);for(let Y=0;Y<U.length;Y++){const Z=U[Y];if(Z===" "&&!x&&u===Kd&&(O+=(h-i*2-Q)/A),this._partialTextX=O,this._partialTextY=I+B,this._partialText=Z,f){e.save();const ue=r.slice(0,b).reduce((ce,De)=>ce+Ra(De.text).length,0);f({char:Z,index:Y+ue,x:O,y:I+B,lineIndex:b,column:Y,isLastInLine:x,width:this.measureSize(Z).width,context:e})}e.fillStrokeShape(this),f&&e.restore(),O+=this.measureSize(Z).width+p}}else p!==0&&e.setAttr("letterSpacing",`${p}px`),this._partialTextX=O,this._partialTextY=I+B,this._partialText=z,e.fillStrokeShape(this);if(y){e.save(),e.beginPath();const A=dt.legacyTextRendering?0:-Math.round(s/4),U=N;e.moveTo(U,I+B+A);const Y=u===Kd&&!x?h-i*2:Q;e.lineTo(U+Math.round(Y),I+B+A),e.lineWidth=s/15,e.strokeStyle=this._getLinearGradient()||g,e.stroke(),e.restore()}e.restore(),o>1&&(I+=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(UP,t),this}getWidth(){return this.attrs.width===qc||this.attrs.width===void 0?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){return this.attrs.height===qc||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,d,c,u;let h=Fy(),p=this.fontSize(),f;h.save(),h.font=this._getContextFont(),f=h.measureText(e),h.restore();const g=p/100;return{actualBoundingBoxAscent:(t=f.actualBoundingBoxAscent)!==null&&t!==void 0?t:71.58203125*g,actualBoundingBoxDescent:(n=f.actualBoundingBoxDescent)!==null&&n!==void 0?n:0,actualBoundingBoxLeft:(r=f.actualBoundingBoxLeft)!==null&&r!==void 0?r:-7.421875*g,actualBoundingBoxRight:(o=f.actualBoundingBoxRight)!==null&&o!==void 0?o:75.732421875*g,alphabeticBaseline:(i=f.alphabeticBaseline)!==null&&i!==void 0?i:0,emHeightAscent:(s=f.emHeightAscent)!==null&&s!==void 0?s:100*g,emHeightDescent:(a=f.emHeightDescent)!==null&&a!==void 0?a:-20*g,fontBoundingBoxAscent:(l=f.fontBoundingBoxAscent)!==null&&l!==void 0?l:91*g,fontBoundingBoxDescent:(d=f.fontBoundingBoxDescent)!==null&&d!==void 0?d:21*g,hangingBaseline:(c=f.hangingBaseline)!==null&&c!==void 0?c:72.80000305175781*g,ideographicBaseline:(u=f.ideographicBaseline)!==null&&u!==void 0?u:-21*g,width:f.width,height:p}}_getContextFont(){return this.fontStyle()+ip+this.fontVariant()+ip+(this.fontSize()+WP)+ZP(this.fontFamily())}_addTextLine(e){this.align()===Kd&&(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 Fy().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!==qc&&o!==void 0,a=i!==qc&&i!==void 0,l=this.padding(),d=o-l*2,c=i-l*2,u=0,h=this.wrap(),p=h!==YP&&h!==rS,f=this.ellipsis();this.textArr=[],Fy().font=this._getContextFont();const g=f?this._getTextWidth(Oy):0;for(let w=0,C=e.length;w<C;++w){let S=e[w],y=this._getTextWidth(S);if(s&&y>d)for(;S.length>0;){let b=0,I=Ra(S).length,R="",O=0;for(;b<I;){const B=b+I>>>1,L=Ra(S).slice(0,B+1).join(""),z=this._getTextWidth(L);(f&&a&&u+r>c?z+g:z)<=d?(b=B+1,R=L,O=z):I=B}if(R){if(p){const B=Ra(S),L=Ra(R),z=B[L.length],Q=z===ip||z===J4;let x;if(Q&&O<=d)x=L.length;else{const N=L.lastIndexOf(ip),A=L.lastIndexOf(J4);x=Math.max(N,A)+1}x>0&&(b=x,R=B.slice(0,b).join(""),O=this._getTextWidth(R))}if(R=R.trimRight(),this._addTextLine(R),n=Math.max(n,O),u+=r,this._shouldHandleEllipsis(u)){this._tryToAddEllipsisToLastLine();break}if(S=Ra(S).slice(b).join("").trimLeft(),S.length>0&&(y=this._getTextWidth(S),y<=d)){this._addTextLine(S),u+=r,n=Math.max(n,y);break}}else break}else this._addTextLine(S),u+=r,n=Math.max(n,y),this._shouldHandleEllipsis(u)&&w<C-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),a&&u+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!==qc&&r!==void 0,i=r-this.padding()*2;return this.wrap()===rS||o&&e+n>i}_tryToAddEllipsisToLastLine(){const e=this.attrs.width,t=e!==qc&&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+Oy)<n||(o.text=o.text.slice(0,o.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(o.text+Oy))}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&&QP()?!0:super._useBufferCanvas()}};jn.prototype._fillFunc=JP,jn.prototype._strokeFunc=$P,jn.prototype.className=VP,jn.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],rr(jn),se.overWriteSetter(jn,"width",vy()),se.overWriteSetter(jn,"height",vy()),se.addGetterSetter(jn,"direction",Q4),se.addGetterSetter(jn,"fontFamily","Arial"),se.addGetterSetter(jn,"fontSize",12,ot()),se.addGetterSetter(jn,"fontStyle",tS),se.addGetterSetter(jn,"fontVariant",tS),se.addGetterSetter(jn,"padding",0,ot()),se.addGetterSetter(jn,"align",$4),se.addGetterSetter(jn,"verticalAlign",jP),se.addGetterSetter(jn,"lineHeight",1,ot()),se.addGetterSetter(jn,"wrap",qP),se.addGetterSetter(jn,"ellipsis",!1,gi()),se.addGetterSetter(jn,"letterSpacing",0,ot()),se.addGetterSetter(jn,"text","",Sl()),se.addGetterSetter(jn,"textDecoration",""),se.addGetterSetter(jn,"underlineOffset",void 0,ot()),se.addGetterSetter(jn,"charRenderFunc",void 0);var tO="",iS="normal";function sS(e){e.fillText(this.partialText,0,0)}function aS(e){e.strokeText(this.partialText,0,0)}var Ir=class extends nt{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 Xo.getPathLength(this.dataArray)}_getPointAtLength(e){return!this.attrs.data||e>this.pathLength?null:Xo.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Xo.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 jn.prototype.setText.call(this,e)}_getContextFont(){return jn.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=Ra(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),d=Math.max(this.textWidth+((this.attrs.text||"").length-1)*i,0);let c=0;s==="center"&&(c=Math.max(0,this.pathLength/2-d/2)),s==="right"&&(c=Math.max(0,this.pathLength-d));let u=c;for(let h=0;h<t.length;h++){const p=this._getPointAtLength(u);if(!p)return;const f=t[h].char;let g=t[h].width+i;if(f===" "&&s==="justify"){const R=this.text().split(" ").length-1;g+=(this.pathLength-d)/R}const w=u+g,C=this._getPointAtLength(w>this.pathLength&&w-this.pathLength<=l?this.pathLength:w);if(!C)return;const S=Xo.getLineLength(p.x,p.y,C.x,C.y);let y=0;if(a)try{y=a(t[h-1].char,f)*this.fontSize()}catch{y=0}p.x+=y,C.x+=y,this.textWidth+=y;const b=Xo.getPointOnLine(y+S/2,p.x,p.y,C.x,C.y),I=Math.atan2(C.y-p.y,C.x-p.x);this.glyphInfo.push({transposeX:b.x,transposeY:b.y,text:e[h],rotation:I,p0:p,p1:C,width:S}),u+=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()}};Ir.prototype._fillFunc=sS,Ir.prototype._strokeFunc=aS,Ir.prototype._fillFuncHit=sS,Ir.prototype._strokeFuncHit=aS,Ir.prototype.className="TextPath",Ir.prototype._attrsAffectingSize=["text","fontSize","data"],rr(Ir),se.addGetterSetter(Ir,"data"),se.addGetterSetter(Ir,"fontFamily","Arial"),se.addGetterSetter(Ir,"fontSize",12,ot()),se.addGetterSetter(Ir,"fontStyle",iS),se.addGetterSetter(Ir,"align","left"),se.addGetterSetter(Ir,"letterSpacing",0,ot()),se.addGetterSetter(Ir,"textBaseline","middle"),se.addGetterSetter(Ir,"fontVariant",iS),se.addGetterSetter(Ir,"text",tO),se.addGetterSetter(Ir,"textDecoration",""),se.addGetterSetter(Ir,"kerningFunc",void 0);var lS="tr-konva",nO=["resizeEnabledChange","rotateAnchorOffsetChange","rotateAnchorAngleChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(e=>e+`.${lS}`).join(" "),cS="nodesRect",rO=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange","draggableChange"],oO={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135},iO="ontouchstart"in dt._global;function sO(e,t,n){if(e==="rotater")return n;t+=Ae.degToRad(oO[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 ap=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],uS=1e8;function aO(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 dS(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 lO(e,t){return dS(e,t,aO(e))}function cO(e,t,n){let r=t;for(let o=0;o<e.length;o++){const i=dt.getAngle(e[o]),s=Math.abs(i-t)%(Math.PI*2);Math.min(s,Math.PI*2-s)<n&&(r=i)}return r}var Ny=0,hn=class extends Gc{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(nO,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 lS+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(rO.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(cS),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(cS,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=(dt.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2);return dS({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},-dt.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-uS,y:-uS,width:0,height:0,rotation:0};const e=[];this.nodes().map(a=>{const l=a.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),d=[{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();d.forEach(function(u){const h=c.point(u);e.push(h)})});const t=new mi;t.rotate(-dt.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:dt.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(),ap.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater"),this._elementsCreated=!0}_createAnchor(e){const t=new Wd({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:iO?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=sO(e,dt.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 nt({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(),d=Ae.degToRad(a),c=Math.sin(d),u=-Math.cos(d),h=i/2,p=s/2;let f=1/0;u<0?f=Math.min(f,-p/u):u>0&&(f=Math.min(f,(s-p)/u)),c<0?f=Math.min(f,-h/c):c>0&&(f=Math.min(f,(i-h)/c));const g=h+c*f,w=p+u*f,C=Ae._sign(s),S=g+c*l*C,y=w+u*l*C;t.moveTo(g,w),t.lineTo(S,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},Ny++,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 d=o.getAbsolutePosition();if(l.x===d.x&&l.y===d.y)return;if(this._movingAnchorName==="rotater"){const C=this._getNodeRect();t=o.x()-C.width/2,n=-o.y()+C.height/2;const S=dt.getAngle(this.rotateAnchorAngle());let y=Math.atan2(-n,t)+Math.PI/2-S;C.height<0&&(y-=Math.PI);const b=dt.getAngle(this.rotation())+y,I=dt.getAngle(this.rotationSnapTolerance()),R=lO(C,cO(this.rotationSnaps(),b,I)-C.rotation);this._fitNodesInto(R,e);return}const c=this.shiftBehavior();let u;c==="inverted"?u=this.keepRatio()&&!e.shiftKey:c==="none"?u=this.keepRatio():u=this.keepRatio()||e.shiftKey;let h=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(u){const C=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(C.x-o.x(),2)+Math.pow(C.y-o.y(),2));const S=this.findOne(".top-left").x()>C.x?-1:1,y=this.findOne(".top-left").y()>C.y?-1:1;t=r*this.cos*S,n=r*this.sin*y,this.findOne(".top-left").x(C.x-t),this.findOne(".top-left").y(C.y-n)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(u){const C=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()-C.x,2)+Math.pow(C.y-o.y(),2));const S=this.findOne(".top-right").x()<C.x?-1:1,y=this.findOne(".top-right").y()>C.y?-1:1;t=r*this.cos*S,n=r*this.sin*y,this.findOne(".top-right").x(C.x+t),this.findOne(".top-right").y(C.y-n)}var p=o.position();this.findOne(".top-left").y(p.y),this.findOne(".bottom-right").x(p.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(u){const C=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(C.x-o.x(),2)+Math.pow(o.y()-C.y,2));const S=C.x<o.x()?-1:1,y=o.y()<C.y?-1:1;t=r*this.cos*S,n=r*this.sin*y,o.x(C.x-t),o.y(C.y+n)}p=o.position(),this.findOne(".top-left").x(p.x),this.findOne(".bottom-right").y(p.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(u){const C=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()-C.x,2)+Math.pow(o.y()-C.y,2));const S=this.findOne(".bottom-right").x()<C.x?-1:1,y=this.findOne(".bottom-right").y()<C.y?-1:1;t=r*this.cos*S,n=r*this.sin*y,this.findOne(".bottom-right").x(C.x+t),this.findOne(".bottom-right").y(C.y+n)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(h=this.centeredScaling()||e.altKey,h){const C=this.findOne(".top-left"),S=this.findOne(".bottom-right"),y=C.x(),b=C.y(),I=this.getWidth()-S.x(),R=this.getHeight()-S.y();S.move({x:-y,y:-b}),C.move({x:I,y:R})}const f=this.findOne(".top-left").getAbsolutePosition();t=f.x,n=f.y;const g=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),w=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:g,height:w,rotation:dt.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();Ny--,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 mi;if(o.rotate(dt.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const u=o.point({x:-this.padding()*2,y:0});e.x+=u.x,e.y+=u.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const u=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const u=o.point({x:0,y:-this.padding()*2});e.x+=u.x,e.y+=u.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const u=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=u.x,this._anchorDragOffset.y-=u.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const u=this.boundBoxFunc()(n,e);u?e=u:Ae.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const i=1e7,s=new mi;s.translate(n.x,n.y),s.rotate(n.rotation),s.scale(n.width/i,n.height/i);const a=new mi,l=e.width/i,d=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(d))):(a.translate(e.x,e.y),a.rotate(e.rotation),a.scale(l,d));const c=a.multiply(s.invert());this._nodes.forEach(u=>{var h;if(!u.getStage())return;const p=u.getParent().getAbsoluteTransform(),f=u.getTransform().copy();f.translate(u.offsetX(),u.offsetY());const g=new mi;g.multiply(p.copy().invert()).multiply(c).multiply(p).multiply(f);const w=g.decompose();u.setAttrs(w),(h=u.getLayer())===null||h===void 0||h.batchDraw()}),this.rotation(Ae._getRotation(e.rotation)),this._nodes.forEach(u=>{this._fire("transform",{evt:t,target:u}),u._fire("transform",{evt:t,target:u})}),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(I=>{I.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 d=this.rotateAnchorAngle(),c=this.rotateAnchorOffset(),u=Ae.degToRad(d),h=Math.sin(u),p=-Math.cos(u),f=n/2,g=r/2;let w=1/0;p<0?w=Math.min(w,-g/p):p>0&&(w=Math.min(w,(r-g)/p)),h<0?w=Math.min(w,-f/h):h>0&&(w=Math.min(w,(n-f)/h));const C=f+h*w,S=g+p*w,y=Ae._sign(r);this._batchChangeChild(".rotater",{x:C+h*c*y,y:S+p*c*y-s*p,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(I=>I.draggable()),x:0,y:0});const b=this.anchorStyleFunc();b&&l.forEach(I=>{b(I)}),(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=""),Gc.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 ft.prototype.toObject.call(this)}clone(e){return ft.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}};hn.isTransforming=()=>Ny>0;function uO(e){return e instanceof Array||Ae.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach(function(t){ap.indexOf(t)===-1&&Ae.warn("Unknown anchor name: "+t+". Available names are: "+ap.join(", "))}),e||[]}hn.prototype.className="Transformer",rr(hn),se.addGetterSetter(hn,"enabledAnchors",ap,uO),se.addGetterSetter(hn,"flipEnabled",!0,gi()),se.addGetterSetter(hn,"resizeEnabled",!0),se.addGetterSetter(hn,"anchorSize",10,ot()),se.addGetterSetter(hn,"rotateEnabled",!0),se.addGetterSetter(hn,"rotateLineVisible",!0),se.addGetterSetter(hn,"rotationSnaps",[]),se.addGetterSetter(hn,"rotateAnchorOffset",50,ot()),se.addGetterSetter(hn,"rotateAnchorAngle",0,ot()),se.addGetterSetter(hn,"rotateAnchorCursor","crosshair"),se.addGetterSetter(hn,"rotationSnapTolerance",5,ot()),se.addGetterSetter(hn,"borderEnabled",!0),se.addGetterSetter(hn,"anchorStroke","rgb(0, 161, 255)"),se.addGetterSetter(hn,"anchorStrokeWidth",1,ot()),se.addGetterSetter(hn,"anchorFill","white"),se.addGetterSetter(hn,"anchorCornerRadius",0,ot()),se.addGetterSetter(hn,"borderStroke","rgb(0, 161, 255)"),se.addGetterSetter(hn,"borderStrokeWidth",1,ot()),se.addGetterSetter(hn,"borderDash"),se.addGetterSetter(hn,"keepRatio",!0),se.addGetterSetter(hn,"shiftBehavior","default"),se.addGetterSetter(hn,"centeredScaling",!1),se.addGetterSetter(hn,"ignoreStroke",!1),se.addGetterSetter(hn,"padding",0,ot()),se.addGetterSetter(hn,"nodes"),se.addGetterSetter(hn,"node"),se.addGetterSetter(hn,"boundBoxFunc"),se.addGetterSetter(hn,"anchorDragBoundFunc"),se.addGetterSetter(hn,"anchorStyleFunc"),se.addGetterSetter(hn,"shouldOverdrawWholeArea",!1),se.addGetterSetter(hn,"useSingleNodeRotation",!0),se.backCompat(hn,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var zs=class extends nt{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,dt.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)}};zs.prototype.className="Wedge",zs.prototype._centroid=!0,zs.prototype._attrsAffectingSize=["radius"],rr(zs),se.addGetterSetter(zs,"radius",0,ot()),se.addGetterSetter(zs,"angle",0,ot()),se.addGetterSetter(zs,"clockwise",!1),se.backCompat(zs,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});function fS(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var dO=[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],fO=[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 hO(e,t){const n=e.data,r=e.width,o=e.height;let i,s,a,l,d,c,u,h,p,f,g,w,C,S,y,b,I,R,O,B;const L=t+t+1,z=r-1,Q=o-1,x=t+1,N=x*(x+1)/2,A=new fS,U=dO[t],Y=fO[t];let Z=null,ue=A,ce=null,De=null;for(let ae=1;ae<L;ae++)ue=ue.next=new fS,ae===x&&(Z=ue);ue.next=A,a=s=0;for(let ae=0;ae<o;ae++){w=C=S=y=l=d=c=u=0,h=x*(b=n[s]),p=x*(I=n[s+1]),f=x*(R=n[s+2]),g=x*(O=n[s+3]),l+=N*b,d+=N*I,c+=N*R,u+=N*O,ue=A;for(let de=0;de<x;de++)ue.r=b,ue.g=I,ue.b=R,ue.a=O,ue=ue.next;for(let de=1;de<x;de++)i=s+((z<de?z:de)<<2),l+=(ue.r=b=n[i])*(B=x-de),d+=(ue.g=I=n[i+1])*B,c+=(ue.b=R=n[i+2])*B,u+=(ue.a=O=n[i+3])*B,w+=b,C+=I,S+=R,y+=O,ue=ue.next;ce=A,De=Z;for(let de=0;de<r;de++)n[s+3]=O=u*U>>Y,O!==0?(O=255/O,n[s]=(l*U>>Y)*O,n[s+1]=(d*U>>Y)*O,n[s+2]=(c*U>>Y)*O):n[s]=n[s+1]=n[s+2]=0,l-=h,d-=p,c-=f,u-=g,h-=ce.r,p-=ce.g,f-=ce.b,g-=ce.a,i=a+((i=de+t+1)<z?i:z)<<2,w+=ce.r=n[i],C+=ce.g=n[i+1],S+=ce.b=n[i+2],y+=ce.a=n[i+3],l+=w,d+=C,c+=S,u+=y,ce=ce.next,h+=b=De.r,p+=I=De.g,f+=R=De.b,g+=O=De.a,w-=b,C-=I,S-=R,y-=O,De=De.next,s+=4;a+=r}for(let ae=0;ae<r;ae++){C=S=y=w=d=c=u=l=0,s=ae<<2,h=x*(b=n[s]),p=x*(I=n[s+1]),f=x*(R=n[s+2]),g=x*(O=n[s+3]),l+=N*b,d+=N*I,c+=N*R,u+=N*O,ue=A;for(let fe=0;fe<x;fe++)ue.r=b,ue.g=I,ue.b=R,ue.a=O,ue=ue.next;let de=r;for(let fe=1;fe<=t;fe++)s=de+ae<<2,l+=(ue.r=b=n[s])*(B=x-fe),d+=(ue.g=I=n[s+1])*B,c+=(ue.b=R=n[s+2])*B,u+=(ue.a=O=n[s+3])*B,w+=b,C+=I,S+=R,y+=O,ue=ue.next,fe<Q&&(de+=r);s=ae,ce=A,De=Z;for(let fe=0;fe<o;fe++)i=s<<2,n[i+3]=O=u*U>>Y,O>0?(O=255/O,n[i]=(l*U>>Y)*O,n[i+1]=(d*U>>Y)*O,n[i+2]=(c*U>>Y)*O):n[i]=n[i+1]=n[i+2]=0,l-=h,d-=p,c-=f,u-=g,h-=ce.r,p-=ce.g,f-=ce.b,g-=ce.a,i=ae+((i=fe+x)<Q?i:Q)*r<<2,l+=w+=ce.r=n[i],d+=C+=ce.g=n[i+1],c+=S+=ce.b=n[i+2],u+=y+=ce.a=n[i+3],ce=ce.next,h+=b=De.r,p+=I=De.g,f+=R=De.b,g+=O=De.a,w-=b,C-=I,S-=R,y-=O,De=De.next,s+=r}}const pO=function(t){const n=Math.round(this.blurRadius());n>0&&hO(t,n)};se.addGetterSetter(ft,"blurRadius",0,ot(),se.afterSetFilter);const mO=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};se.addGetterSetter(ft,"brightness",0,ot(),se.afterSetFilter);const gO=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)},vO=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};se.addGetterSetter(ft,"contrast",0,ot(),se.afterSetFilter);const yO=function(e){var t,n,r,o,i,s,a,l,d;const c=e.data,u=e.width,h=e.height,p=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)),f=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,w=!!((d=(l=this.embossBlend)===null||l===void 0?void 0:l.call(this))!==null&&d!==void 0&&d),C=p*10,S=f*255,y=g*Math.PI/180,b=Math.cos(y),I=Math.sin(y),R=128/1020*C,O=new Uint8ClampedArray(c),B=new Float32Array(u*h);for(let N=0,A=0;A<c.length;A+=4,N++)B[N]=.2126*O[A]+.7152*O[A+1]+.0722*O[A+2];const L=[-1,0,1,-2,0,2,-1,0,1],z=[-1,-2,-1,0,0,0,1,2,1],Q=[-u-1,-u,-u+1,-1,0,1,u-1,u,u+1],x=N=>N<0?0:N>255?255:N;for(let N=1;N<h-1;N++)for(let A=1;A<u-1;A++){const U=N*u+A;let Y=0,Z=0;Y+=B[U+Q[0]]*L[0],Z+=B[U+Q[0]]*z[0],Y+=B[U+Q[1]]*L[1],Z+=B[U+Q[1]]*z[1],Y+=B[U+Q[2]]*L[2],Z+=B[U+Q[2]]*z[2],Y+=B[U+Q[3]]*L[3],Z+=B[U+Q[3]]*z[3],Y+=B[U+Q[5]]*L[5],Z+=B[U+Q[5]]*z[5],Y+=B[U+Q[6]]*L[6],Z+=B[U+Q[6]]*z[6],Y+=B[U+Q[7]]*L[7],Z+=B[U+Q[7]]*z[7],Y+=B[U+Q[8]]*L[8],Z+=B[U+Q[8]]*z[8];const ue=x(S+(b*Y+I*Z)*R),ce=U*4;if(w){const De=ue-S;c[ce]=x(O[ce]+De),c[ce+1]=x(O[ce+1]+De),c[ce+2]=x(O[ce+2]+De),c[ce+3]=O[ce+3]}else c[ce]=c[ce+1]=c[ce+2]=ue,c[ce+3]=O[ce+3]}for(let N=0;N<u;N++){let A=N*4,U=((h-1)*u+N)*4;c[A]=O[A],c[A+1]=O[A+1],c[A+2]=O[A+2],c[A+3]=O[A+3],c[U]=O[U],c[U+1]=O[U+1],c[U+2]=O[U+2],c[U+3]=O[U+3]}for(let N=1;N<h-1;N++){let A=N*u*4,U=(N*u+(u-1))*4;c[A]=O[A],c[A+1]=O[A+1],c[A+2]=O[A+2],c[A+3]=O[A+3],c[U]=O[U],c[U+1]=O[U+1],c[U+2]=O[U+2],c[U+3]=O[U+3]}return e};se.addGetterSetter(ft,"embossStrength",.5,ot(),se.afterSetFilter),se.addGetterSetter(ft,"embossWhiteLevel",.5,ot(),se.afterSetFilter),se.addGetterSetter(ft,"embossDirection","top-left",void 0,se.afterSetFilter),se.addGetterSetter(ft,"embossBlend",!1,void 0,se.afterSetFilter);function By(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 bO=function(e){const t=e.data,n=t.length;let r=t[0],o=r,i,s=t[1],a=s,l,d=t[2],c=d,u;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),u=t[y+2],u<d?d=u:u>c&&(c=u);o===r&&(o=255,r=0),a===s&&(a=255,s=0),c===d&&(c=255,d=0);let p,f,g,w,C,S;if(h>0)p=o+h*(255-o),f=r-h*(r-0),g=a+h*(255-a),w=s-h*(s-0),C=c+h*(255-c),S=d-h*(d-0);else{const y=(o+r)*.5;p=o+h*(o-y),f=r+h*(r-y);const b=(a+s)*.5;g=a+h*(a-b),w=s+h*(s-b);const I=(c+d)*.5;C=c+h*(c-I),S=d+h*(d-I)}for(let y=0;y<n;y+=4)t[y+0]=By(t[y+0],r,o,f,p),t[y+1]=By(t[y+1],s,a,w,g),t[y+2]=By(t[y+2],d,c,S,C)};se.addGetterSetter(ft,"enhance",0,ot(),se.afterSetFilter);const wO=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}};se.addGetterSetter(ft,"hue",0,ot(),se.afterSetFilter),se.addGetterSetter(ft,"saturation",0,ot(),se.afterSetFilter),se.addGetterSetter(ft,"luminance",0,ot(),se.afterSetFilter);const CO=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),d=.299*r+.701*a+.167*l,c=.587*r-.587*a+.33*l,u=.114*r-.114*a-.497*l,h=.299*r-.299*a-.328*l,p=.587*r+.413*a+.035*l,f=.114*r-.114*a+.293*l,g=.299*r-.3*a+1.25*l,w=.587*r-.586*a-1.05*l,C=.114*r+.886*a-.2*l;let S,y,b,I;for(let R=0;R<n;R+=4)S=t[R+0],y=t[R+1],b=t[R+2],I=t[R+3],t[R+0]=d*S+c*y+u*b+s,t[R+1]=h*S+p*y+f*b+s,t[R+2]=g*S+w*y+C*b+s,t[R+3]=I},_O=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,d=.587*r-.587*s+.33*a,c=.114*r-.114*s-.497*a,u=.299*r-.299*s-.328*a,h=.587*r+.413*s+.035*a,p=.114*r-.114*s+.293*a,f=.299*r-.3*s+1.25*a,g=.587*r-.586*s-1.05*a,w=.114*r+.886*s-.2*a;for(let C=0;C<n;C+=4){const S=t[C+0],y=t[C+1],b=t[C+2],I=t[C+3];t[C+0]=l*S+d*y+c*b,t[C+1]=u*S+h*y+p*b,t[C+2]=f*S+g*y+w*b,t[C+3]=I}};se.addGetterSetter(ft,"hue",0,ot(),se.afterSetFilter),se.addGetterSetter(ft,"saturation",0,ot(),se.afterSetFilter),se.addGetterSetter(ft,"value",0,ot(),se.afterSetFilter);const SO=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 kO=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 d=Math.sqrt(a*a+l*l),c=i-a,u=s-l;const h=Math.sqrt(c*c+u*u);d=h>d?h:d;const p=s,f=i,g=360/f*Math.PI/180;for(let w=0;w<f;w+=1){const C=Math.sin(w*g),S=Math.cos(w*g);for(let y=0;y<p;y+=1){c=Math.floor(a+d*y/p*S),u=Math.floor(l+d*y/p*C);let b=(u*i+c)*4;const I=r[b+0],R=r[b+1],O=r[b+2],B=r[b+3];b=(w+y*i)*4,o[b+0]=I,o[b+1]=R,o[b+2]=O,o[b+3]=B}}},AO=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 d=Math.sqrt(a*a+l*l),c=i-a,u=s-l;const h=Math.sqrt(c*c+u*u);d=h>d?h:d;const p=s,f=i,g=n.polarRotation||0;let w,C;for(c=0;c<i;c+=1)for(u=0;u<s;u+=1){const S=c-a,y=u-l,b=Math.sqrt(S*S+y*y)*p/d;let I=(Math.atan2(y,S)*180/Math.PI+360+g)%360;I=I*f/360,w=Math.floor(I),C=Math.floor(b);let R=(C*i+w)*4;const O=r[R+0],B=r[R+1],L=r[R+2],z=r[R+3];R=(u*i+c)*4,o[R+0]=O,o[R+1]=B,o[R+2]=L,o[R+3]=z}};const IO=function(e){const t=e.width,n=e.height;let r,o,i,s,a,l,d,c,u,h,p=Math.round(this.kaleidoscopePower());const f=Math.round(this.kaleidoscopeAngle()),g=Math.floor(t*(f%360)/360);if(p<1)return;const w=Ae.createCanvasElement();w.width=t,w.height=n;const C=w.getContext("2d").getImageData(0,0,t,n);Ae.releaseCanvas(w),kO(e,C,{polarCenterX:t/2,polarCenterY:n/2});let S=t/Math.pow(2,p);for(;S<=8;)S=S*2,p-=1;S=Math.ceil(S);let y=S,b=0,I=y,R=1;for(g+S>t&&(b=y,I=0,R=-1),o=0;o<n;o+=1)for(r=b;r!==I;r+=R)i=Math.round(r+g)%t,u=(t*o+i)*4,a=C.data[u+0],l=C.data[u+1],d=C.data[u+2],c=C.data[u+3],h=(t*o+r)*4,C.data[h+0]=a,C.data[h+1]=l,C.data[h+2]=d,C.data[h+3]=c;for(o=0;o<n;o+=1)for(y=Math.floor(S),s=0;s<p;s+=1){for(r=0;r<y+1;r+=1)u=(t*o+r)*4,a=C.data[u+0],l=C.data[u+1],d=C.data[u+2],c=C.data[u+3],h=(t*o+y*2-r-1)*4,C.data[h+0]=a,C.data[h+1]=l,C.data[h+2]=d,C.data[h+3]=c;y*=2}AO(C,e,{polarRotation:0})};se.addGetterSetter(ft,"kaleidoscopePower",2,ot(),se.afterSetFilter),se.addGetterSetter(ft,"kaleidoscopeAngle",0,ot(),se.afterSetFilter);function lp(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 Yd(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 EO(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 xO(e,t){const n=lp(e,0,0),r=lp(e,e.width-1,0),o=lp(e,0,e.height-1),i=lp(e,e.width-1,e.height-1),s=t||10;if(Yd(n,r)<s&&Yd(r,i)<s&&Yd(i,o)<s&&Yd(o,n)<s){const a=EO([r,n,i,o]),l=[];for(let d=0;d<e.width*e.height;d++)l[d]=Yd(a,[e.data[d*4],e.data[d*4+1],e.data[d*4+2]])<s?0:255;return l}}function TO(e,t){for(let n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}function RO(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 d=a*t+l;let c=0;for(let u=0;u<o;u++)for(let h=0;h<o;h++){const p=a+u-i,f=l+h-i;if(p>=0&&p<n&&f>=0&&f<t){const g=p*t+f,w=r[u*o+h];c+=e[g]*w}}s[d]=c===2040?255:0}return s}function MO(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 d=a*t+l;let c=0;for(let u=0;u<o;u++)for(let h=0;h<o;h++){const p=a+u-i,f=l+h-i;if(p>=0&&p<n&&f>=0&&f<t){const g=p*t+f,w=r[u*o+h];c+=e[g]*w}}s[d]=c>=1020?255:0}return s}function LO(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 d=a*t+l;let c=0;for(let u=0;u<o;u++)for(let h=0;h<o;h++){const p=a+u-i,f=l+h-i;if(p>=0&&p<n&&f>=0&&f<t){const g=p*t+f,w=r[u*o+h];c+=e[g]*w}}s[d]=c}return s}const DO=function(e){let t=xO(e,this.threshold());return t&&(t=RO(t,e.width,e.height),t=MO(t,e.width,e.height),t=LO(t,e.width,e.height),TO(e,t)),e};se.addGetterSetter(ft,"threshold",0,ot(),se.afterSetFilter);const PO=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()};se.addGetterSetter(ft,"noise",.2,ot(),se.afterSetFilter);const OO=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 d=0,c=0,u=0,h=0;const p=a*t,f=p+t,g=l*t,w=g+t;let C=0;for(let S=p;S<f;S+=1)if(!(S>=n))for(let y=g;y<w;y+=1){if(y>=r)continue;const b=(n*y+S)*4;d+=s[b+0],c+=s[b+1],u+=s[b+2],h+=s[b+3],C+=1}d=d/C,c=c/C,u=u/C,h=h/C;for(let S=p;S<f;S+=1)if(!(S>=n))for(let y=g;y<w;y+=1){if(y>=r)continue;const b=(n*y+S)*4;s[b+0]=d,s[b+1]=c,s[b+2]=u,s[b+3]=h}}};se.addGetterSetter(ft,"pixelSize",8,ot(),se.afterSetFilter);const FO=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};se.addGetterSetter(ft,"levels",.5,ot(),se.afterSetFilter);const NO=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]}};se.addGetterSetter(ft,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),se.addGetterSetter(ft,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),se.addGetterSetter(ft,"blue",0,f4,se.afterSetFilter);const BO=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}};se.addGetterSetter(ft,"red",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),se.addGetterSetter(ft,"green",0,function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)}),se.addGetterSetter(ft,"blue",0,f4,se.afterSetFilter),se.addGetterSetter(ft,"alpha",1,function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e});const zO=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)}},HO=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},UO=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};se.addGetterSetter(ft,"threshold",.5,ot(),se.afterSetFilter);var VO=j4.Util._assign(j4,{Arc:Ns,Arrow:Il,Circle:Kc,Ellipse:Ea,Image:vi,Label:Py,Tag:El,Line:Bs,Path:Xo,Rect:Wd,RegularPolygon:xa,Ring:xl,Sprite:qi,Star:Ta,Text:jn,TextPath:Ir,Transformer:hn,Wedge:zs,Filters:{Blur:pO,Brightness:gO,Brighten:mO,Contrast:vO,Emboss:yO,Enhance:bO,Grayscale:wO,HSL:CO,HSV:_O,Invert:SO,Kaleidoscope:IO,Mask:DO,Noise:PO,Pixelate:OO,Posterize:FO,RGB:NO,RGBA:BO,Sepia:zO,Solarize:HO,Threshold:UO}});wt();var jO=["dialog","floating"],hS=["top-right","top-left","bottom-right","bottom-left","top-center","bottom-center"];function GO(e){if(!e||typeof e!="object")throw new Error("SurfaceManager: request must be a non-null object.");if(!jO.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&&!hS.includes(e.floating.placement))throw new Error(`SurfaceManager: floating.placement must be one of ${hS.join(", ")}, got "${e.floating.placement}".`)}var WO=class{activeDialog=kr(null);activeFloating=kr(null);#t=!1;#n=1;#e;constructor({getModuleConfig:e}){this.#e=e}open(e){if(this.#t)return this.#r(e);GO(e);const t=this.#u(e),{component:n,props:r,render:o}=this.#d(t);let i,s=!1;const a=new Promise(p=>{i=f=>s?!1:(s=!0,p(f),!0)});let l;const d=p=>{i({status:"submitted",data:p})&&this.#i(l)},c=p=>{i({status:"closed",reason:p})&&this.#i(l)};l={id:t.id,mode:t.mode,request:t,component:n,props:r,render:o,resolve:d,close:c,settle:p=>i(p),get settled(){return s}};const u=t.mode==="dialog"?"activeDialog":"activeFloating",h=this[u].value;return h&&!h.settled&&h.settle({status:"replaced",replacedBy:t.id}),this[u].value=l,{id:t.id,mode:t.mode,close:p=>this.#o(l,p),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"})}}},KO="https://docs.superdoc.dev/guides/migration/document-api",pS=new Set;function qO(e,t){pS.has(e)||(pS.add(e),console.warn(t))}var YO={state:"editor.state",view:"editor.view",schema:"editor.schema",commands:"editor.commands",chain:"editor.chain()",can:"editor.can()",dispatch:"editor.dispatch()"},mS=Symbol.for("superdoc:rawEditor"),gS=new WeakMap;function vS(e){return!e||e[mS]?e:new Proxy(e,{get(t,n){if(n===mS)return t;const r=YO[n];r&&qO(`deprecated:${String(n)}`,`[SuperDoc] ${r} is deprecated and will be removed in a future version. Use the Document API (editor.doc) instead. See ${KO}`);const o=Reflect.get(t,n,t);if(typeof o=="function"){let i=gS.get(t);return i||(i=new Map,gS.set(t,i)),i.has(n)||i.set(n,o.bind(t)),i.get(n)}return o}})}var yS=["review","original","final","off"],XO=["paired","independent"],bS=Symbol.for("@superdoc/trackChanges:normalized"),wS=new Set;function CS(e,t){wS.has(e)||(wS.add(e),console.warn(`[SuperDoc] ${e} is deprecated β use ${t} instead.`))}function _S(e,t,n){return typeof e=="boolean"?e:typeof t=="boolean"?t:n}function QO(e,t,n){return typeof e=="string"&&yS.includes(e)?e:typeof t=="string"&&yS.includes(t)?t:n}function ZO(e){return typeof e=="string"&&XO.includes(e)?e:null}function Tl(e){return!e||typeof e!="object"||Array.isArray(e)?null:e}function JO(e){const t=e[bS]===!0;Tl(e.modules)||(e.modules={});const n=Tl(e.modules.trackChanges),r=Tl(e.trackChanges),o=Tl(e.layoutEngineOptions?.trackedChanges);t||(r&&CS("config.trackChanges","config.modules.trackChanges"),o&&CS("config.layoutEngineOptions.trackedChanges","config.modules.trackChanges"));const i=_S(n?.visible,r?.visible,!1),s=_S(n?.enabled,o?.enabled,!0),a=ZO(n?.replacements)??"paired",l=Tl(n?.authorColors)?n.authorColors:void 0,d=Tl(n?.semanticColors)?n.semanticColors:void 0,c=e.documentMode==="viewing"?i?"review":"original":"review",u=QO(n?.mode,o?.mode,c),h={visible:i,mode:u,enabled:s,replacements:a};return l&&(h.authorColors=l),d&&(h.semanticColors=d),e.modules.trackChanges=h,e.trackChanges={visible:i},Tl(e.layoutEngineOptions)||(e.layoutEngineOptions={}),e.layoutEngineOptions.trackedChanges={mode:u,enabled:s},Object.defineProperty(e,bS,{value:!0,writable:!0,configurable:!0,enumerable:!1}),h}const zy=Object.freeze({id:null,name:"Default SuperDoc user",email:null});function $O(e){return!e||typeof e!="object"?{...zy}:{...zy,...e}}var eF=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(`[${Nh}]`);if(!n)return null;const r=n.getAttribute(Nh),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{}}},tF=["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 SS=[{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:tF,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 kS=new Map(SS.map(e=>[e.name,e]));const GH=SS.map(e=>e.name);function Hy(e){return kS.get(e)??null}function nF(e){const t=kS.get(e);return t?.disposition==="controller-routed"?t.commandId:null}const rF=".png,.jpg,.jpeg,image/png,image/jpeg";var AS=new Set(["image/png","image/jpeg","image/jpg"]),oF=/\.(png|jpe?g)$/i;function iF(e){if(!e)return!1;const t=typeof e.type=="string"?e.type.toLowerCase():"";return t?AS.has(t):oF.test(String(e.name??""))}function IS(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(sF(String(r.result),e)),r.onerror=()=>n(r.error??new Error("image-read-failed")),r.readAsDataURL(e)})}function sF(e,t){const n=/^data:([^;,]*);base64,/.exec(e);if(!n)return e;const r=n[1].toLowerCase();if(AS.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 aF(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:lF(n,e)}return IS(e)}async function lF(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 IS(o?Object.assign(r,{name:o}):r)}function cF({ownerDocument:e=document,onPick:t,onError:n}={}){const r=e.createElement("input");return r.type="file",r.accept=rF,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(!iF(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 uF=(e,t)=>{let n=e.replace(/[^0-9.]/g,"");return n=parseFloat(n),isNaN(n)&&(n=t),n=parseFloat(n),n},dF=(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=(...d)=>{const c=Date.now();!s&&n.leading===!1&&(s=c);const u=t-(c-s);return o=d,u<=0||u>t?(r&&(clearTimeout(r),r=null),s=c,i=e(...d),r||(o=null)):!r&&n.trailing!==!1&&(r=setTimeout(a,u)),i};return l.cancel=function(){clearTimeout(r),s=0,r=o=null},l};wt(),nn();var fF={class:"sd-toolbar-icon"},hF=["innerHTML"],pF={__name:"ToolbarButtonIcon",props:{name:{type:String,required:!0},color:{type:String,default:null},icon:{type:String,default:null}},setup(e){const t=e,n=Ie(()=>{if(t.name==="color")return{backgroundColor:t.color||"#111111"};if(t.name==="highlight")return{backgroundColor:t.color||"#D6D6D6"}}),r=Ie(()=>["color","highlight"].includes(t.name));return(o,i)=>(pe(),_e("div",fF,[Le("div",{class:Yt(["sd-toolbar-icon__icon",[`sd-toolbar-icon__icon--${t.name}`]]),innerHTML:e.icon},null,10,hF),r.value?(pe(),_e("div",{key:0,class:"color-bar",style:rn(n.value)},null,4)):rt("",!0)]))}},ES=en(pF,[["__scopeId","data-v-d7d79424"]]);wt(),nn();var mF=["role","aria-label"],gF=["data-item"],vF=["data-item"],yF={key:1,class:"sd-button-label"},bF=["data-item","aria-label"],wF=["innerHTML"],CF={key:2},_F=["onKeydown","id"],SF=["placeholder","onKeydown","id","data-item"],kF=["data-item","innerHTML"],AF={"aria-live":"polite",class:"sd-visually-hidden"},IF={__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}=qn(),o=e,{name:i,active:s,icon:a,label:l,hideLabel:d,iconColor:c,hasCaret:u,splitButton:h,disabled:p,expand:f,inlineTextInputVisible:g,hasInlineTextInput:w,minWidth:C,style:S,attributes:y}=o.toolbarItem,b=Ie(()=>!!h?.value&&!!u?.value),I=Ie(()=>i?.value??""),R=$(""),O=$(null),{isHighContrastMode:B}=fi();xt(()=>l?.value,ye=>{document.activeElement!==O.value&&(R.value=ye==null?"":String(ye))},{immediate:!0});const L=()=>{w&&yt(()=>{O.value?.focus(),O.value?.select()}),n("buttonClick")},z=ye=>{p?.value||(ye?.stopPropagation(),n("mainClick"))},Q=()=>{b.value||L()},x=ye=>{if(b.value){z(ye);return}L()},N=ye=>{o.allowEnterPropagation||ye.stopPropagation(),x(ye)},A=ye=>{const te=o.toolbarItem?.nestedOptions?.value??[],Ee=ye.trim();if(!Ee)return"";const Re=te.find(We=>typeof We?.label=="string"&&We.label.toLowerCase()===Ee.toLowerCase());return Re?.label?Re.label:te.find(We=>typeof We?.label=="string"&&We.label.toLowerCase().startsWith(Ee.toLowerCase()))?.label??Ee},U=()=>{const ye=String(R.value??"").trim();let te=ye;if(I.value==="fontSize"){const Ee=Number.parseFloat(ye);te=ye.match(/^\d+(\.5)?$/)?ye:Number.isFinite(Ee)?Math.floor(Ee).toString():""}else I.value==="fontFamily"&&(te=A(ye));return te?(n("textSubmit",te),R.value=te,!0):!1},Y=ye=>{const te=ye?.currentTarget;te instanceof HTMLInputElement&&(te.focus({preventScroll:!0}),te.select())},Z=ye=>{requestAnimationFrame(()=>{const te=document.getElementById(`inlineTextInput-${ye}`);te instanceof HTMLInputElement&&(te.focus({preventScroll:!0}),te.select())})},ue=()=>{const ye=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return ye instanceof HTMLElement?(ye.focus({preventScroll:!0}),!0):!1},ce=()=>{const ye=r?.$toolbar?.pendingSelectionCapture,te=()=>{ye&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(ye)};if(ue()){te();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),te())},De=()=>{U()&&ce()},ae=ye=>{if(U(),ye.shiftKey){I.value==="fontSize"&&(ye.preventDefault(),yt(()=>Z("fontFamily")));return}if(ye.preventDefault(),I.value==="fontFamily"){yt(()=>Z("fontSize"));return}I.value==="fontSize"&&yt(ce)},de=Ie(()=>S.value?S.value:{minWidth:o.minWidth}),fe=Ie(()=>f?.value?Vn.dropdownCaretUp:Vn.dropdownCaretDown);return(ye,te)=>(pe(),_e("div",{class:Yt(["sd-toolbar-item",Ve(y).className]),style:rn(de.value),role:e.isOverflowItem?"menuitem":"button","aria-label":Ve(y).ariaLabel,"data-sd-part":"toolbar-item",onClick:Q,onKeydown:te[9]||(te[9]=_o(Ee=>N(Ee),["enter"])),tabindex:"0"},[Le("div",{class:Yt(["sd-toolbar-button",{"sd-active":Ve(s),"sd-disabled":Ve(p),narrow:e.isNarrow,wide:e.isWide,split:b.value,"has-inline-text-input":Ve(w),"high-contrast":Ve(B)}]),"data-item":`btn-${Ve(i)||""}`},[b.value?(pe(),_e("div",{key:0,class:"sd-toolbar-button__main","data-item":`btn-${Ve(i)||""}-main`,onClick:te[0]||(te[0]=Ee=>z(Ee))},[Ve(a)?(pe(),$t(ES,{key:0,color:Ve(c),class:"sd-toolbar-icon",icon:Ve(a),name:Ve(i)},null,8,["color","icon","name"])):rt("",!0),Ve(l)&&!Ve(d)&&!Ve(g)?(pe(),_e("div",yF,Lt(Ve(l)),1)):rt("",!0)],8,vF)):rt("",!0),b.value?(pe(),_e("div",{key:1,class:"sd-toolbar-button__caret","data-item":`btn-${Ve(i)||""}-caret`,"aria-label":`${Ve(y).ariaLabel} options`,role:"button"},[Le("div",{class:"sd-dropdown-caret",innerHTML:fe.value,style:rn({opacity:Ve(p)?.6:1})},null,12,wF)],8,bF)):(pe(),_e(Bt,{key:2},[Ve(a)?(pe(),$t(ES,{key:0,color:Ve(c),class:"sd-toolbar-icon",icon:Ve(a),name:Ve(i)},null,8,["color","icon","name"])):rt("",!0),Ve(l)&&!Ve(d)&&(!Ve(g)||I.value==="fontFamily")?(pe(),_e("div",{key:1,class:Yt(["sd-button-label",{"sd-visually-hidden":Ve(g)&&I.value==="fontFamily"}])},Lt(Ve(l)),3)):rt("",!0),Ve(g)?(pe(),_e("span",CF,[Ve(i)==="fontSize"?ms((pe(),_e("input",{key:0,"onUpdate:modelValue":te[1]||(te[1]=Ee=>R.value=Ee),onKeydown:[_o(Gt(De,["stop","prevent"]),["enter"]),te[2]||(te[2]=_o(Ee=>ae(Ee),["tab"]))],onClick:te[3]||(te[3]=Gt(Ee=>Y(Ee),["stop"])),onFocus:te[4]||(te[4]=Ee=>Y(Ee)),type:"text",class:Yt(["button-text-input button-text-input--font-size",{"high-contrast":Ve(B)}]),id:"inlineTextInput-"+Ve(i),autocomplete:"off",ref_key:"inlineInput",ref:O},null,42,_F)),[[qo,R.value]]):ms((pe(),_e("input",{key:1,"onUpdate:modelValue":te[5]||(te[5]=Ee=>R.value=Ee),placeholder:Ve(l),onKeydown:[_o(Gt(De,["stop","prevent"]),["enter"]),te[6]||(te[6]=_o(Ee=>ae(Ee),["tab"]))],onClick:te[7]||(te[7]=Gt(Ee=>Y(Ee),["stop"])),onFocus:te[8]||(te[8]=Ee=>Y(Ee)),type:"text",class:Yt(["button-text-input",{"button-text-input--font-family":I.value==="fontFamily","high-contrast":Ve(B)}]),id:"inlineTextInput-"+Ve(i),"data-item":I.value==="fontFamily"?`btn-${Ve(i)}-input`:void 0,autocomplete:"off",ref_key:"inlineInput",ref:O},null,42,SF)),[[qo,R.value]])])):rt("",!0),Ve(u)?(pe(),_e("div",{key:3,class:"sd-dropdown-caret","data-item":`btn-${Ve(i)||""}-toggle`,innerHTML:fe.value,style:rn({opacity:Ve(p)?.6:1})},null,12,kF)):rt("",!0)],64)),Le("div",AF,Lt(`${Ve(y).ariaLabel} ${Ve(s)?"selected":"unset"}`),1)],10,gF)],46,mF))}},Uy=en(IF,[["__scopeId","data-v-dbdea151"]]);wt(),nn();var EF={class:"toolbar-separator",role:"separator","aria-label":"Toolbar separator"},xF={__name:"ToolbarSeparator",props:{active:{type:Boolean,default:!1}},emits:["command"],setup(e,{emit:t}){const{isHighContrastMode:n}=fi(),r=()=>n.value?"#000":"var(--sd-ui-border, #dbdbdb)";return(o,i)=>(pe(),_e("div",EF,[Le("div",{class:"separator-inner",style:rn({backgroundColor:r()})},null,4)]))}},TF=en(xF,[["__scopeId","data-v-cb82253a"]]);wt(),nn();var RF={class:"overflow-menu"},MF={class:"overflow-menu-trigger"},LF={key:0,class:"overflow-menu_items",role:"group"},DF={__name:"OverflowMenu",props:{toolbarItem:{type:Object,required:!0},overflowItems:{type:Array,required:!0}},emits:["buttonClick","close"],setup(e,{emit:t}){const{proxy:n}=qn(),r=t,o=e,i=Ie(()=>o.toolbarItem.expand.value),s=$(!1),a=Ie(()=>({...o.toolbarItem,active:i.value})),l=()=>{r("buttonClick",o.toolbarItem)},d=({item:u,argument:h})=>{n.$toolbar.emitCommand({item:u,argument:h})},c=u=>{u.key==="Escape"&&i.value&&!s.value&&(u.preventDefault(),r("close"))};return _n(()=>{document.addEventListener("keydown",c,!0)}),Kn(()=>{document.removeEventListener("keydown",c,!0)}),(u,h)=>(pe(),_e("div",RF,[Le("div",MF,[Ft(Uy,{"toolbar-item":a.value,onButtonClick:l},null,8,["toolbar-item"])]),i.value?(pe(),_e("div",LF,[Ft(fp,{class:"superdoc-toolbar-overflow","toolbar-items":e.overflowItems,"from-overflow":"",onCommand:d,onDropdownUpdateShow:h[0]||(h[0]=p=>s.value=p)},null,8,["toolbar-items"])])):rt("",!0)]))}},PF=en(DF,[["__scopeId","data-v-504ecd05"]]);wt(),nn();var OF={class:"toolbar-dropdown"},FF=["onClick"],NF={key:0,class:"toolbar-dropdown-option__icon"},BF={class:"toolbar-dropdown-option__label"},cp='button, [href], input, select, textarea, [role="button"], [tabindex]:not([tabindex="-1"])',zF={__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=$(null),i=$(null),s=$({top:"0px",left:"0px",maxHeight:"none"}),a=$([]),l=$(-1),d=Ie(()=>!!n.show),c=Ie(()=>n.options.some(te=>te?.type==="render")),u=Ie(()=>typeof n.menuProps!="function"?{}:n.menuProps()||{}),h=Ie(()=>{const{class:te,style:Ee,...Re}=u.value;return Re}),p=Ie(()=>{const te=u.value.class,Ee=n.options.length>0&&n.options.every(Re=>Re&&Re.type==="render");return["toolbar-dropdown-menu",te,{"toolbar-dropdown-menu--render-only":Ee}]}),f=Ie(()=>{const te=u.value.style||{};return{...n.contentStyle,...te}}),g=Ie(()=>({...f.value,position:"fixed",top:s.value.top,left:s.value.left,maxHeight:s.value.maxHeight,zIndex:2e3})),w=te=>{r("update:show",te)},C=()=>{d.value&&w(!1)},S=()=>{if(!o.value)return;const te=o.value.getBoundingClientRect(),Ee=i.value,Re=Ee?.offsetWidth??0,We=Ee?.scrollHeight??Ee?.offsetHeight??0,vt=window.innerWidth||document.documentElement.clientWidth||0,we=window.innerHeight||document.documentElement.clientHeight||0,Be=8,Ge=4,X=te.bottom+Ge,_=te.top-Ge,M=Math.max(0,we-X-Be),ee=Math.max(0,_-Be),j=M<We&&ee>M,H=j?ee:M,V=We?Math.min(We,H):H,q=j?Math.max(Be,_-V):X;let W=te.left;n.placement==="bottom-end"&&(W=te.right-Re);const G=Math.max(Be,vt-Re-Be);W=Math.min(Math.max(Be,W),G),s.value={top:`${q}px`,left:`${W}px`,maxHeight:`${H}px`}},y=()=>{n.disabled||w(!d.value)},b=te=>typeof n.nodeProps!="function"?{}:n.nodeProps(te)||{},I=te=>{te?.disabled||te?.type!=="render"&&(r("select",te?.key,te),C())},R=te=>te?.type==="render",O=te=>!te?.disabled&&te?.type!=="render",B=te=>typeof te?.icon=="function"||!!te?.icon,L=te=>typeof te?.icon=="function"?te.icon(te):te?.icon||null,z=te=>te?typeof te=="string"?te.split(/\s+/).includes("sd-selected"):Array.isArray(te)?te.some(z):typeof te=="object"?!!te["sd-selected"]:!1:!1,Q=te=>z(te?.props?.class)||z(te?.class),x=()=>n.options.map((te,Ee)=>O(te)?Ee:-1).filter(te=>te>=0),N=()=>{const te=n.options.findIndex(Ee=>O(Ee)&&Q(Ee));return te>=0?te:x()[0]??-1},A=(te,Ee)=>{if(!te){delete a.value[Ee];return}a.value[Ee]=te},U=()=>{a.value.forEach((Ee,Re)=>{Ee&&Ee.setAttribute("tabindex",Re===l.value?"0":"-1")});const te=a.value[l.value];te&&typeof te.focus=="function"&&(te.focus(),te.scrollIntoView?.({block:"nearest",inline:"nearest"}))},Y=te=>{const Ee=x();if(!Ee.length){l.value=-1;return}const Re=Ee.indexOf(l.value);if(Re<0){l.value=te>0?Ee[0]:Ee[Ee.length-1];return}l.value=Ee[(Re+te+Ee.length)%Ee.length]},Z=()=>{let te=n.options[l.value];if(!O(te)){const Ee=x()[0];te=Ee===void 0?null:n.options[Ee]}te&&I(te)},ue=al({name:"ToolbarDropdownRenderOption",props:{option:{type:Object,required:!0}},setup(te){return()=>typeof te.option.render!="function"?null:te.option.render()}}),ce=al({name:"ToolbarDropdownOptionIcon",props:{option:{type:Object,required:!0}},setup(te){return()=>L(te.option)}}),De=te=>{if(!d.value)return;const Ee=te.target;if(!(Ee instanceof Element))return;const Re=o.value?.contains(Ee),We=i.value?.contains(Ee);Re||We||C()},ae=$(null),de=()=>{const te=o.value,Ee=document.activeElement;if(te&&Ee instanceof HTMLElement&&te.contains(Ee)){ae.value=Ee;return}ae.value=te?.matches?.(cp)?te:te?.querySelector(cp)},fe=()=>{const te=ae.value;if(te instanceof HTMLElement&&document.contains(te)){te.focus();return}const Ee=o.value;if(!Ee)return;const Re=Ee.matches?.(cp)?Ee:Ee.querySelector(cp);if(Re instanceof HTMLElement){Re.focus();return}Ee.setAttribute("tabindex","-1"),Ee.focus()},ye=te=>{if(!d.value)return;const{key:Ee}=te;if(["Escape","ArrowDown","ArrowUp","Enter"].includes(Ee)){if(Ee==="Escape"){te.preventDefault(),C(),yt(()=>{requestAnimationFrame(fe)});return}if(!c.value){if(te.preventDefault(),Ee==="ArrowDown"){Y(1),U();return}if(Ee==="ArrowUp"){Y(-1),U();return}Ee==="Enter"&&Z()}}};return xt(d,async te=>{if(!te){l.value=-1,a.value=[];return}de(),await yt(),S(),!c.value&&(l.value=N(),await yt(),U())},{immediate:!0}),xt(d,te=>{te?(document.addEventListener("pointerdown",De,!0),document.addEventListener("keydown",ye,!0),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0)):(document.removeEventListener("pointerdown",De,!0),document.removeEventListener("keydown",ye,!0),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0))},{immediate:!0}),Kn(()=>{document.removeEventListener("pointerdown",De,!0),document.removeEventListener("keydown",ye,!0),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}),(te,Ee)=>(pe(),_e("div",OF,[Le("div",{ref_key:"triggerRef",ref:o,class:"toolbar-dropdown-trigger","data-sd-part":"dropdown-trigger",onClick:y},[Pu(te.$slots,"trigger",{},void 0,!0)],512),(pe(),$t(ca,{to:"body"},[Ft(Yf,{name:"fade-in-scale-up-transition"},{default:Zr(()=>[d.value?(pe(),_e("div",Oi({key:0,ref_key:"menuRef",ref:i,"data-sd-part":"dropdown-menu",class:p.value,style:g.value},h.value),[(pe(!0),_e(Bt,null,Wn(e.options,(Re,We)=>(pe(),_e("div",Oi({key:Re.key,ref_for:!0,ref:vt=>A(vt,We),class:["toolbar-dropdown-option",[Re.class,Re.props?.class,{"sd-disabled":Re.disabled,"sd-render":R(Re)}]],tabindex:"-1",onClick:vt=>I(Re)},{ref_for:!0},{...Re.props,...b(Re)}),[R(Re)?(pe(),$t(Ve(ue),{key:0,option:Re},null,8,["option"])):(pe(),_e(Bt,{key:1},[B(Re)?(pe(),_e("span",NF,[Ft(Ve(ce),{option:Re},null,8,["option"])])):rt("",!0),Le("span",BF,Lt(Re.label),1)],64))],16,FF))),128))],16)):rt("",!0)]),_:1})]))]))}},HF=en(zF,[["__scopeId","data-v-fef410f7"]]),xS=e=>String(e??"").trim().toLowerCase();const up=(e,t)=>{const n=xS(e);if(!n)return-1;for(let r=0;r<t.length;r+=1)if(xS(t[r]).startsWith(n))return r;return-1},UF=(e,t,{autocomplete:n=!0}={})=>{const r=String(e??""),o=up(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 VF=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},jF=e=>e<=31||e===127,GF=e=>e===32||e===160||e===65279,WF=e=>Array.from(String(e)).filter(t=>!jF(t.charCodeAt(0))).join(""),KF=e=>{let t="",n=!1;for(const r of String(e)){if(GF(r.charCodeAt(0))){n=t.length>0;continue}n&&(t+=" "),n=!1,t+=r}return t};const qF=e=>KF(VF(WF(String(e??"").split(",")[0]??""))).trim();var YF=1,XF=1638;const QF=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<YF?"":String(Math.min(r,XF))};wt(),nn();var ZF=["data-item"],JF=["id","value","disabled","aria-label","aria-expanded","aria-controls","aria-activedescendant","data-item"],$F=["data-item","aria-label","disabled"],eN=["innerHTML"],tN=["id","aria-label"],nN=["id","aria-selected","aria-label","onMousedown","onMouseenter"],rN={class:"toolbar-dropdown-option__label"},oN={class:"sd-button-label sd-font-combobox__legacy-label","aria-hidden":"true"},iN={__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}=fi(),i=$(null),s=$(null),a=$(null),l=$([]),d=$(!1),c=$(!1),u=$(-1),h=$(""),p=$(""),f=$(!1),g=$({top:"0px",left:"0px",minWidth:"0px",maxHeight:"none"}),w=Ie(()=>n.item.nestedOptions?.value??[]),C=Ie(()=>w.value.map(W=>String(W?.label??""))),S=Ie(()=>String(n.item.label?.value??"")),y=Ie(()=>!!n.item.disabled?.value),b=Ie(()=>String(n.item.name?.value??"")),I=Ie(()=>n.item.attributes?.value?.ariaLabel??"Font family"),R=Ie(()=>d.value?p.value:S.value),O=Ie(()=>`sd-${b.value||"combobox"}-listbox-${n.item.id?.value??"default"}`),B=W=>`${O.value}-option-${W}`,L=Ie(()=>c.value&&u.value>=0?B(u.value):void 0),z=Ie(()=>c.value?Vn.dropdownCaretUp:Vn.dropdownCaretDown),Q=W=>{const G=String(W??"").trim().toLowerCase();return w.value.find(ve=>String(ve?.label??"").trim().toLowerCase()===G)?.props?.style?.fontFamily||W||n.uiFontFamily},x=Ie(()=>n.showPreview?{fontFamily:Q(d.value?p.value:S.value)}:{fontFamily:n.uiFontFamily}),N=()=>{const W=n.item.selectedValue?.value;if(W){const G=w.value.findIndex(ve=>ve?.key===W);if(G>=0)return G}return C.value.findIndex(G=>G.toLowerCase()===S.value.toLowerCase())},A=(W,G)=>{const ve=i.value;if(!(!ve||typeof ve.setSelectionRange!="function"))try{ve.setSelectionRange(W,G)}catch{}},U=()=>{l.value[u.value]?.scrollIntoView?.({block:"nearest",inline:"nearest"})},Y=()=>{l.value[u.value]?.focus?.()},Z=()=>{const W=s.value;if(!W)return;const G=W.getBoundingClientRect(),ve=a.value,Se=ve?.scrollHeight??ve?.offsetHeight??0,ke=window.innerHeight||document.documentElement.clientHeight||0,Fe=window.innerWidth||document.documentElement.clientWidth||0,Ze=8,Ke=4,bt=G.bottom+Ke,St=G.top-Ke,it=Math.max(0,ke-bt-Ze),xe=Math.max(0,St-Ze),Me=it<Se&&xe>it,Pe=Me?xe:it,at=Se?Math.min(Se,Pe):Pe,pt=Me?Math.max(Ze,St-at):bt,be=Math.min(Math.max(Ze,G.left),Math.max(Ze,Fe-G.width-Ze));g.value={top:`${pt}px`,left:`${be}px`,minWidth:`${G.width}px`,maxHeight:`${Pe}px`}},ue=Ie(()=>({position:"fixed",top:g.value.top,left:g.value.left,minWidth:g.value.minWidth,maxHeight:g.value.maxHeight,fontFamily:n.uiFontFamily,zIndex:2e3})),ce=W=>{n.item.expand&&typeof n.item.expand=="object"&&"value"in n.item.expand&&(n.item.expand.value=W)},De=(W,{focusInput:G=!1,focusOption:ve=!1}={})=>{if(y.value||!w.value.length){ce(!1);return}c.value=!0,ce(!0),u.value=W??-1,G&&(d.value=!0,p.value=S.value,i.value?.focus()),yt(()=>{Z(),U(),ve&&Y()})},ae=({syncItem:W=!0}={})=>{c.value=!1,u.value=-1,W&&ce(!1)},de=()=>{ae(),d.value=!1,h.value="",p.value=S.value},fe=()=>{y.value||(c.value||r("item-clicked"),d.value=!0,h.value="",p.value=S.value,yt(()=>A(0,p.value.length)))},ye=W=>{if(y.value)return;const G=document.activeElement===i.value;if(r("item-clicked"),d.value=!0,G||(h.value="",p.value=S.value,W.preventDefault(),i.value?.focus(),A(0,S.value.length)),!c.value){const ve=N();De(ve>=0?ve:0)}},te=W=>{const G=W.relatedTarget;G instanceof Node&&s.value?.contains(G)||G instanceof Node&&a.value?.contains(G)||de()},Ee=W=>{if(f.value)return;const G=W.target,ve=G.value,Se=typeof G.selectionStart=="number"?G.selectionStart:ve.length,ke=typeof G.selectionEnd=="number"?G.selectionEnd:Se,Fe=typeof W.inputType=="string"&&W.inputType.startsWith("delete"),Ze=Se===ve.length&&ke===ve.length;h.value=ve;const Ke=UF(ve,C.value,{autocomplete:!Fe&&Ze});p.value=Ke.display,G.value=Ke.display,Ke.display===ve&&!Ze?A(Se,ke):A(Ke.selectionStart,Ke.selectionEnd),c.value&&(u.value=Ke.matchIndex,yt(U))},Re=W=>{f.value=!1,Ee(W)},We=W=>{if(!w.value.length)return;const G=w.value.length;u.value=((u.value<0?W>0?-1:0:u.value)+W+G)%G,yt(U)},vt=(W,G)=>{r("item-clicked"),r("command",{item:n.item,argument:W,option:G}),G&&(n.item.selectedValue.value=G.key)},we=W=>{W&&(vt(W.label,W),d.value=!1,h.value="",p.value=W.label,ae())},Be=()=>{if(c.value&&u.value>=0)return we(w.value[u.value]),!0;const W=up(h.value,C.value);if(W>=0)return we(w.value[W]),!0;const G=n.normalizeValue(h.value);return G?(vt(G,null),d.value=!1,h.value="",p.value=G,ae(),!0):!1},Ge=W=>{if(!(W.isComposing||f.value||W.keyCode===229)&&!(W.ctrlKey||W.metaKey||W.altKey))switch(W.key){case"ArrowDown":if(W.preventDefault(),c.value)Y();else{const G=up(h.value,C.value),ve=G>=0?G:N();De(ve>=0?ve:0,{focusOption:!0})}break;case"ArrowUp":if(W.preventDefault(),c.value)Y();else{const G=up(h.value,C.value),ve=G>=0?G:N();De(ve>=0?ve:w.value.length-1,{focusOption:!0})}break;case"Enter":W.preventDefault(),Be()&&r("editor-handoff"),i.value?.blur();break;case"Tab":W.preventDefault(),Be(),ae(),i.value?.blur(),r("tab-out",W);break;case"Escape":W.preventDefault(),de(),yt(()=>i.value?.focus());break;default:break}},X=W=>{if(W.preventDefault(),!y.value)if(r("item-clicked"),c.value)ae(),i.value?.focus();else{const G=N();De(G>=0?G:0,{focusOption:!0})}},_=(W,G)=>{W.preventDefault(),we(G),r("editor-handoff"),i.value?.blur()},M=W=>{u.value=W},ee=W=>{if(!(W.ctrlKey||W.metaKey||W.altKey))switch(W.key){case"ArrowDown":W.preventDefault(),We(1),Y();break;case"ArrowUp":W.preventDefault(),We(-1),Y();break;case"Enter":W.preventDefault(),u.value>=0&&(we(w.value[u.value]),r("editor-handoff"));break;case"Escape":W.preventDefault(),de(),yt(()=>i.value?.focus());break;case"Tab":W.preventDefault(),u.value>=0?we(w.value[u.value]):ae(),r("tab-out",{shiftKey:W.shiftKey,target:i.value});break;default:break}},j=W=>{if(!c.value)return;const G=W.target;G instanceof Element&&(s.value?.contains(G)||a.value?.contains(G)||de())};xt(c,W=>{W?(document.addEventListener("pointerdown",j,!0),window.addEventListener("resize",Z),window.addEventListener("scroll",Z,!0)):(document.removeEventListener("pointerdown",j,!0),window.removeEventListener("resize",Z),window.removeEventListener("scroll",Z,!0),l.value=[])},{immediate:!0}),Kn(()=>{document.removeEventListener("pointerdown",j,!0),window.removeEventListener("resize",Z),window.removeEventListener("scroll",Z,!0)});const H=(W,G)=>{if(!W){delete l.value[G];return}l.value[G]=W},V=W=>W===u.value,q=W=>W?.key&&W.key===n.item.selectedValue?.value;return xt(S,W=>{d.value||(p.value=W)}),xt(()=>!!n.item.expand?.value,W=>{if(W&&!c.value){const G=N();De(G>=0?G:0,{focusInput:!0});return}!W&&c.value&&ae({syncItem:!1})}),(W,G)=>(pe(),_e("div",{ref_key:"rootRef",ref:s,class:Yt(["sd-font-combobox sd-toolbar-split-field",{"sd-disabled":y.value,"high-contrast":Ve(o)}]),style:rn(n.item.style?.value),"data-item":`btn-${b.value}`},[Le("span",{class:"sd-font-combobox__field sd-toolbar-split-field__main",onMousedown:ye},[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:rn(x.value),disabled:y.value,"aria-label":I.value,"aria-expanded":c.value?"true":"false","aria-controls":O.value,"aria-activedescendant":L.value,"aria-haspopup":"listbox","aria-autocomplete":"both","data-item":`btn-${b.value}-input`,onFocus:fe,onBlur:te,onInput:Ee,onKeydown:Ge,onCompositionstart:G[0]||(G[0]=ve=>f.value=!0),onCompositionend:Re},null,44,JF)],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":`${I.value} options`,disabled:y.value,onMousedown:X},[Le("span",{class:"sd-dropdown-caret",innerHTML:z.value},null,8,eN)],40,$F),(pe(),$t(ca,{to:"body"},[c.value?(pe(),_e("div",{key:0,ref_key:"popupRef",ref:a,role:"listbox",id:O.value,"aria-label":I.value,class:Yt(["sd-font-combobox__listbox",{"high-contrast":Ve(o)}]),style:rn(ue.value)},[(pe(!0),_e(Bt,null,Wn(w.value,(ve,Se)=>(pe(),_e("div",Oi({key:ve.key,ref_for:!0,ref:ke=>H(ke,Se),id:B(Se),role:"option",tabindex:"-1",class:["toolbar-dropdown-option sd-font-combobox__option",{"sd-active":V(Se),"sd-selected":q(ve)}],"aria-selected":q(ve)?"true":"false","aria-label":`${I.value} - ${ve.label}`},{ref_for:!0},ve.props,{onMousedown:ke=>_(ke,ve),onMouseenter:ke=>M(Se),onKeydown:ee}),[Le("span",rN,Lt(ve.label),1)],16,nN))),128))],14,tN)):rt("",!0)])),Le("span",oN,Lt(S.value),1)],14,ZF))}},TS=en(iN,[["__scopeId","data-v-c08c573e"]]);wt();var sN={__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)=>(pe(),$t(TS,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!0,"normalize-value":Ve(qF),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"]))}},aN=sN;wt();var lN={__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)=>(pe(),$t(TS,{item:n.item,"ui-font-family":n.uiFontFamily,"show-preview":!1,"normalize-value":Ve(QF),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"]))}},cN=lN;wt(),nn();var uN=2500,dN=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=b2(),r=$(!1),o=$(null),i=$(null),s=$({top:"0px",left:"0px"});let a=null,l=null,d=null;const c=Ie(()=>["sd-tooltip-content",n.class]),u=Ie(()=>({...t.contentStyle,...n.style||{},position:"fixed",top:s.value.top,left:s.value.left,zIndex:2100})),h=()=>{a&&(window.clearTimeout(a),a=null)},p=()=>{l&&(window.clearTimeout(l),l=null)},f=()=>{d&&(window.clearTimeout(d),d=null)},g=()=>{f(),d=window.setTimeout(()=>{d=null,S()},uN)},w=()=>{if(!o.value||!i.value)return;const z=o.value.getBoundingClientRect(),Q=i.value.offsetWidth,x=i.value.offsetHeight,N=window.innerWidth||document.documentElement.clientWidth||0,A=8;let U=z.left+z.width/2-Q/2;U=Math.max(A,Math.min(U,N-Q-A)),s.value={top:`${z.top-x-10}px`,left:`${U}px`}},C=async()=>{t.disabled||(h(),p(),!r.value&&(r.value=!0,g(),await yt(),w()))},S=()=>{p(),h(),f(),r.value&&(r.value=!1)},y=()=>{if(h(),p(),!r.value){if(t.delay===0){C();return}l=window.setTimeout(()=>{l=null,C()},t.delay)}},b=()=>{if(p(),h(),!!r.value){if(t.duration===0){S();return}a=window.setTimeout(()=>{a=null,S()},t.duration)}},I=()=>{t.trigger==="hover"&&y()},R=()=>{t.trigger==="hover"&&b()},O=()=>{p(),h()},B=()=>{b()},L=z=>{z.key==="Escape"&&S()};return xt(()=>t.disabled,z=>{z&&S()}),xt(r,z=>{z?(window.addEventListener("resize",w),window.addEventListener("scroll",w,!0),document.addEventListener("keydown",L,!0)):(window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),document.removeEventListener("keydown",L,!0))}),Kn(()=>{p(),h(),f(),window.removeEventListener("resize",w),window.removeEventListener("scroll",w,!0),document.removeEventListener("keydown",L,!0)}),(z,Q)=>(pe(),_e(Bt,null,[Le("span",{ref_key:"triggerRef",ref:o,class:"sd-tooltip-trigger",onMouseenter:I,onMouseleave:R,onFocusin:I,onFocusout:R},[Pu(z.$slots,"trigger",{},void 0,!0)],544),(pe(),$t(ca,{to:"body"},[Ft(Yf,{name:"fade-in-scale-up-transition"},{default:Zr(()=>[r.value&&!e.disabled?(pe(),_e("div",{key:0,ref_key:"contentRef",ref:i,class:Yt(c.value),style:rn(u.value),onMouseenter:O,onMouseleave:B},[Q[0]||(Q[0]=Le("span",{class:"sd-tooltip-arrow","aria-hidden":"true"},null,-1)),Pu(z.$slots,"default",{},void 0,!0)],38)):rt("",!0)]),_:3})]))],64))}}),dp=en(dN,[["__scopeId","data-v-2a872eae"]]);wt(),nn();var fN=["onKeydown","tabindex","data-item-id"],hN={key:0},pN={key:0},mN={key:0},gN={key:0},vN={key:0},yN={__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}=qn(),o=$([]),i=$(null),s=e,a=$(null),{isHighContrastMode:l}=fi(),d=window.matchMedia("(max-width: 768px)").matches,c=Ie(()=>s.position==="left"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-start"}:s.position==="right"?{minWidth:s.compactSideGroups?"auto":"120px",justifyContent:"flex-end"}:{flexGrow:d?0:1,justifyContent:"center"}),u=we=>we.type==="button",h=we=>we.type==="dropdown",p=we=>we.type==="dropdown"&&we.name?.value==="fontFamily",f=we=>we.type==="dropdown"&&we.name?.value==="fontSize",g=we=>we.type==="separator",w=we=>we.type==="overflow",C=we=>!!we.nestedOptions?.value?.length,S=we=>{if(!we)return!1;const Be=we.expand;return typeof Be=="object"&&Be!==null&&"value"in Be?!!Be.value:!!Be},y=(we,Be)=>{we?.expand&&(we.expand.value=Be)},b=(we,Be=void 0)=>{if(we.disabled.value)return;if(w(we)){const X=!S(we);X&&O(),y(we,X),a.value=X?we:null,n("item-clicked");return}if(h(we))return;a.value&&h(a.value)&&S(a.value)&&O(),n("item-clicked");const Ge=Be!==void 0?Be:we.argument?.value;n("command",Ge===void 0?{item:we}:{item:we,argument:Ge})},I=(we,Be)=>{we.disabled.value||(a.value=null,n("command",{item:we,argument:Be}))},R=we=>{if(we.disabled.value)return;O();const Be=we.splitButtonCommand,Ge=we.command,X=Be||Ge;if(!X)return;const _={...we,command:X};n("item-clicked"),n("command",{item:_})},O=()=>{const we=r?.$toolbar?.toolbarItems||[],Be=r?.$toolbar?.overflowItems||[],Ge=[...we,...Be];(Ge.length?Ge:s.toolbarItems).forEach(X=>{const _=w(X)&&!s.fromOverflow;(h(X)||_)&&y(X,!1)}),a.value=null},B=(we,Be)=>{O(),n("command",{item:we,argument:we.dropdownValueKey.value?Be[we.dropdownValueKey.value]:Be.label,option:Be}),we.selectedValue.value=Be.key},L=we=>{n("command",we)},z=()=>{O(),n("item-clicked")},Q=()=>{const we=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');return we instanceof HTMLElement?(we.focus({preventScroll:!0}),!0):!1},x=()=>{const we=r?.$toolbar?.pendingSelectionCapture,Be=()=>{we&&typeof r?.$toolbar?.ui?.selection?.restore=="function"&&r.$toolbar.ui.selection.restore(we)};if(Q()){Be();return}typeof r?.$toolbar?.superdoc?.focus=="function"&&(r.$toolbar.superdoc.focus(),Be())},N=we=>!(we instanceof HTMLElement)||we.classList.contains("sd-disabled")?null:we.querySelector("input:not([disabled]), textarea:not([disabled]), select:not([disabled])")||we.querySelector('button:not([disabled]), [role="button"]:not(.sd-disabled), [tabindex]:not([tabindex="-1"])'),A=(we,Be)=>{const Ge=we?.target?.closest?.(".sd-toolbar-item-ctn");if(!(Ge instanceof HTMLElement))return!1;let X=Be>0?Ge.nextElementSibling:Ge.previousElementSibling;for(;X;){const _=N(X);if(_ instanceof HTMLElement)return Ge.setAttribute("tabindex","-1"),X.setAttribute("tabindex","0"),_.focus(),!0;X=Be>0?X.nextElementSibling:X.previousElementSibling}return!1},U=we=>{O(),A(we,we?.shiftKey?-1:1)||x()},Y=we=>{if(O(),we?.shiftKey){A(we,-1)||x();return}x()},Z=()=>{x()},ue=we=>we.nestedOptions?.value?.length?we.nestedOptions.value.map(Be=>{const Ge=Be?.type!=="render"&&we.selectedValue.value===Be.key;return{...Be,props:{...Be.props,class:Ge?"sd-selected":""}}}):[],ce=(we,Be)=>({role:"menuitem",ariaLabel:`${Be.attributes.value.ariaLabel} - ${we.label}`}),De=we=>{const Be=we.target,Ge=we.target.closest(".sd-toolbar-item-ctn").nextElementSibling;Ge&&(Be.setAttribute("tabindex","-1"),Ge.setAttribute("tabindex","0"),Ge.focus())},ae=we=>{const Be=we.target,Ge=we.target.closest(".sd-toolbar-item-ctn").previousElementSibling;Ge&&(Be.setAttribute("tabindex","-1"),Ge.setAttribute("tabindex","0"),Ge.focus())},de=we=>{const Be=we.target.closest(".button-group").nextElementSibling;if(Be)Be.setAttribute("tabindex","0"),Be.focus();else{const Ge=document.querySelector(".ProseMirror");Ge&&Ge.focus()}},fe=we=>{const Be=we.target.closest(".button-group").previousElementSibling;Be&&(Be.setAttribute("tabindex","0"),Be.focus())},ye=we=>{if(!we.disabled.value){if(h(we)){Re(!S(we),we);return}b(we)}},te=(we,Be)=>{const Ge=we.target.nodeName==="INPUT"||we.target.nodeName==="TEXTAREA",X=Be.name.value==="fontSize"||Be.name.value==="fontFamily";if(!(Ge&&X)&&["Enter"," ","Spacebar","Escape","ArrowRight","ArrowLeft","Tab"].includes(we.key))switch(we.preventDefault(),we.key){case"Enter":case" ":case"Spacebar":ye(Be);break;case"Escape":O();break;case"ArrowRight":O(),De(we);break;case"ArrowLeft":O(),ae(we);break;case"Tab":we.shiftKey?fe(we):de(we);break;default:break}},Ee=we=>{const Be=o.value.find(Ge=>!Ge.classList.contains("sd-disabled"));Be&&(Be.setAttribute("tabindex","0"),Be.focus())},Re=(we,Be)=>{if(n("item-clicked"),!we){O(),n("dropdown-update-show",!1);return}O(),a.value=Be,y(Be,!0),n("dropdown-update-show",!0)},We=we=>{if(!a.value)return;const Be=we.target;Be instanceof Element&&(Be.closest(".sd-toolbar-dropdown-menu")||i.value?.contains(Be)||O())};return xt(()=>S(a.value),we=>{we?document.addEventListener("pointerdown",We,!0):document.removeEventListener("pointerdown",We,!0)},{immediate:!0}),Kn(()=>{document.removeEventListener("pointerdown",We,!0)}),(we,Be)=>(pe(),_e("div",{style:rn(c.value),class:"button-group",role:"group",onFocus:Ee,ref_key:"buttonGroupRef",ref:i},[(pe(!0),_e(Bt,null,Wn(e.toolbarItems,(Ge,X)=>(pe(),_e("div",{key:Ge.id.value,class:Yt([{narrow:Ge.isNarrow.value,wide:Ge.isWide.value,"sd-disabled":Ge.disabled.value},"sd-toolbar-item-ctn"]),onKeydown:_=>te(_,Ge),ref_for:!0,ref_key:"toolbarItemRefs",ref:o,tabindex:X===0?0:-1,"data-item-id":Ge.id.value},[g(Ge)?(pe(),$t(TF,{key:0,style:{width:"20px"}})):rt("",!0),p(Ge)&&C(Ge)?(pe(),$t(dp,{key:1,trigger:"hover",disabled:!Ge.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Zr(()=>[Ft(aN,{item:Ge,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:L,onItemClicked:z,onTabOut:Be[0]||(Be[0]=_=>U(_)),onEditorHandoff:Z},null,8,["item","ui-font-family"])]),default:Zr(()=>[Le("div",null,[li(Lt(Ge.tooltip)+" ",1),Ge.disabled.value?(pe(),_e("span",hN,"(disabled)")):rt("",!0)])]),_:2},1032,["disabled","content-style"])):f(Ge)&&C(Ge)?(pe(),$t(dp,{key:2,trigger:"hover",disabled:!Ge.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Zr(()=>[Ft(cN,{item:Ge,"ui-font-family":s.uiFontFamily,class:"sd-toolbar-button sd-editor-toolbar-dropdown",onCommand:L,onItemClicked:z,onTabOut:Be[1]||(Be[1]=_=>Y(_)),onEditorHandoff:Z},null,8,["item","ui-font-family"])]),default:Zr(()=>[Le("div",null,[li(Lt(Ge.tooltip)+" ",1),Ge.disabled.value?(pe(),_e("span",pN,"(disabled)")):rt("",!0)])]),_:2},1032,["disabled","content-style"])):h(Ge)&&Ge.nestedOptions?.value?.length?(pe(),$t(HF,{key:3,options:ue(Ge),disabled:Ge.disabled.value,show:S(Ge),"content-style":{fontFamily:s.uiFontFamily},placement:"bottom-start",class:"sd-toolbar-button sd-editor-toolbar-dropdown",onSelect:(_,M)=>B(Ge,M),"onUpdate:show":_=>Re(_,Ge),style:rn(Ge.dropdownStyles.value),"menu-props":()=>({role:"menu",style:{fontFamily:s.uiFontFamily},class:["sd-toolbar-dropdown-menu",{"high-contrast":Ve(l)}]}),"node-props":_=>ce(_,Ge)},{trigger:Zr(()=>[Ft(dp,{trigger:"hover",disabled:!Ge.tooltip?.value,"content-style":{fontFamily:s.uiFontFamily}},{trigger:Zr(()=>[Ft(Uy,{"toolbar-item":Ge,disabled:Ge.disabled.value,"allow-enter-propagation":!0,onTextSubmit:_=>I(Ge,_),onMainClick:_=>R(Ge)},null,8,["toolbar-item","disabled","onTextSubmit","onMainClick"])]),default:Zr(()=>[Le("div",null,[li(Lt(Ge.tooltip)+" ",1),Ge.disabled.value?(pe(),_e("span",mN,"(disabled)")):rt("",!0)])]),_:2},1032,["disabled","content-style"])]),_:2},1032,["options","disabled","show","content-style","onSelect","onUpdate:show","style","menu-props","node-props"])):u(Ge)?(pe(),$t(dp,{key:4,trigger:"hover",class:"sd-editor-toolbar-tooltip","content-style":{fontFamily:s.uiFontFamily}},{trigger:Zr(()=>[Ft(Uy,{"toolbar-item":Ge,"is-overflow-item":e.fromOverflow,onTextSubmit:_=>I(Ge,_),onButtonClick:_=>b(Ge)},null,8,["toolbar-item","is-overflow-item","onTextSubmit","onButtonClick"])]),default:Zr(()=>[Ge.tooltip?(pe(),_e("div",gN,[li(Lt(Ge.tooltip)+" ",1),Ge.disabled.value?(pe(),_e("span",vN,"(disabled)")):rt("",!0)])):rt("",!0)]),_:2},1032,["content-style"])):rt("",!0),w(Ge)&&e.overflowItems.length?(pe(),$t(PF,{key:5,"toolbar-item":Ge,onButtonClick:_=>b(Ge),"overflow-items":e.overflowItems,onClose:O},null,8,["toolbar-item","onButtonClick","overflow-items"])):rt("",!0)],42,fN))),128))],36))}},fp=en(yN,[["__scopeId","data-v-590293ab"]]),bN=[["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 wN=bN.map(([e,t])=>({label:e,key:e,fontWeight:400,props:{style:{fontFamily:`${e}, ${t}`},"data-item":"btn-fontFamily-option"}}));function CN(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 _N=[{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"}}],Xd={sm:768,md:1024,lg:1280,xl:1410},Vy={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"},RS={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"},MS=Object.values(RS),WH=[...new Set([...Object.values(Vy),...MS])];var SN=new Set(["link"]);const KH=new Set(Object.keys(Vy).filter(e=>!SN.has(e)));wt(),nn();var kN="Arial, Helvetica, sans-serif",AN={__name:"Toolbar",emits:["command","toggle","select"],setup(e,{emit:t}){const{proxy:n}=qn();let r=$(1);const o=$(0),i=$(!1);let s=null,a=null;const l=Ie(()=>{const B=n?.$toolbar?.config?.uiDisplayFallbackFont;return typeof B=="string"&&B.trim()?B.trim():kN}),d=n.$toolbar.config?.toolbarGroups?.includes("left"),c=n.$toolbar.config?.toolbarGroups?.includes("right"),u=n.$toolbar.config?.toolbarButtonsExclude||[],h=B=>(o.value,n.$toolbar.getToolbarItemByGroup(B).filter(L=>!u.includes(L.name.value))),p=()=>{i.value=n.$toolbar.getAvailableWidth()<=Xd.lg},g=dF(async()=>{await n.$toolbar.onToolbarResize(),p(),r.value+=1},300),w=()=>{r.value+=1},C=()=>{o.value+=1};function S(){window.removeEventListener("resize",g),n.$toolbar.off?.("toolbar-items-changed",w),n.$toolbar.off?.("toolbar-state-change",C),s?.disconnect(),s=null}function y(){S(),window.addEventListener("resize",g),n.$toolbar.on?.("toolbar-items-changed",w),n.$toolbar.on?.("toolbar-state-change",C),typeof ResizeObserver<"u"&&n.$toolbar.config?.responsiveToContainer&&n.$toolbar.toolbarContainer&&(s=new ResizeObserver(()=>{g()}),s.observe(n.$toolbar.toolbarContainer)),p()}_n(y),am(y),lm(S),Kn(S);const b=()=>{if(!n.$toolbar.activeEditor){a=null,n.$toolbar.pendingSelectionCapture=null;return}a=n.$toolbar.ui?.selection?.capture?.()??null,n.$toolbar.pendingSelectionCapture=a},I=({item:B,argument:L,option:z})=>{R(),n.$toolbar.emitCommand({item:B,argument:L,option:z})},R=()=>{const B=n.$toolbar.activeEditor;if(!B)return;const L=n.$toolbar.pendingSelectionCapture??a;if(L&&typeof n.$toolbar.ui?.selection?.restore=="function"){n.$toolbar.ui.selection.restore(L);return}B.commands?.restoreSelection?.()},O=B=>{b(),!B.target.closest('input, textarea, [contenteditable="true"]')&&B.preventDefault()};return(B,L)=>(pe(),_e("div",{class:"superdoc-toolbar",key:Ve(r),role:"toolbar","aria-label":"Toolbar","data-sd-part":"toolbar","data-editor-ui-surface":"",onMousedown:O},[Ve(d)?(pe(),$t(fp,{key:0,tabindex:"0","toolbar-items":h("left"),"overflow-items":Ve(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"left",onCommand:I,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):rt("",!0),Ft(fp,{tabindex:"0","toolbar-items":h("center"),"overflow-items":Ve(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"center",onCommand:I},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"]),Ve(c)?(pe(),$t(fp,{key:1,tabindex:"0","toolbar-items":h("right"),"overflow-items":Ve(n).$toolbar.overflowItems,"compact-side-groups":i.value,"ui-font-family":l.value,position:"right",onCommand:I,class:"superdoc-toolbar-group-side"},null,8,["toolbar-items","overflow-items","compact-side-groups","ui-font-family"])):rt("",!0)],32))}},IN=en(AN,[["__scopeId","data-v-55b5af7a"]]);const EN=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"}}};wt();const un=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=$(Ri()),n=e.type,r=$(e.name),o=e.command,i=e.noArgumentCommand,s=$(e.icon),a=$(e.group||"center"),l=$(e.allowWithoutEditor),d=$(e.attributes||{}),c=e.disabled||!1,u=$(e.disabled),h=$(!1),p=$(!1),f=$(e.style),g=$(e.isNarrow),w=$(e.isWide),C=$(e.minWidth),S=$(e.suppressActiveHighlight||!1),y=$(e.argument),b=$(null),I=$(null),R=$(e.iconColor),O=$(e.hasCaret),B=$(!!e.splitButton),L=e.splitButtonCommand,z=!!e.restoreEditorFocus,Q=$(e.dropdownStyles),x=$(e.tooltip),N=$(e.tooltipVisible),A=$(e.tooltipTimeout),U=$(e.defaultLabel),Y=$(e.label),Z=$(e.hideLabel),ue=$(e.inlineTextInputVisible),ce=$(e.hasInlineTextInput),De=$(e.markName),ae=$(e.labelAttr),de=$(e.selectedValue),fe=$(e.dropdownValueKey),ye=$(e.inputRef||null),te=$([]);if(e.options){if(!Array.isArray(e.options))throw new Error("Invalid toolbar item options - "+e.options);te.value?.push(...e.options)}const Ee=(_={},...M)=>{we(_,...M),!S.value&&(h.value=!0)},Re=()=>{Be(),h.value=!1},We=_=>{u.value=_},vt=()=>{u.value=c},we=e.onActivate||(()=>null),Be=e.onDeactivate||(()=>null),Ge=()=>{const _={};return Object.keys(X).forEach(M=>{X[M].value!==void 0&&(_[M]=X[M].value)}),_},X={id:t,name:r,type:n,command:o,noArgumentCommand:i,icon:s,tooltip:x,group:a,attributes:d,disabled:u,active:h,expand:p,nestedOptions:te,style:f,isNarrow:g,isWide:w,minWidth:C,argument:y,parentItem:I,iconColor:R,hasCaret:O,splitButton:B,splitButtonCommand:L,dropdownStyles:Q,tooltipVisible:N,tooltipTimeout:A,defaultLabel:U,label:Y,hideLabel:Z,inlineTextInputVisible:ue,hasInlineTextInput:ce,restoreEditorFocus:z,markName:De,labelAttr:ae,childItem:b,allowWithoutEditor:l,dropdownValueKey:fe,selectedValue:de,inputRef:ye};return{...X,unref:Ge,activate:Ee,deactivate:Re,setDisabled:We,resetDisabled:vt,onActivate:we,onDeactivate:Be}};wt(),nn();var xN=["onClick","innerHTML","aria-label","onKeydown"],TN={__name:"AlignmentButtons",emits:["select"],setup(e,{emit:t}){const{isHighContrastMode:n}=fi(),r=t,o=$([]),i=[{key:"left",ariaLabel:"Align left",icon:Vn.alignLeft},{key:"center",ariaLabel:"Align center",icon:Vn.alignCenter},{key:"right",ariaLabel:"Align right",icon:Vn.alignRight},{key:"justify",ariaLabel:"Justify",icon:Vn.alignJustify}],s=c=>{r("select",c)},a=c=>{if(c===o.value.length-1)return;const u=o.value[c+1];u&&(u.setAttribute("tabindex","0"),u.focus())},l=c=>{if(c===0)return;const u=o.value[c-1];u&&(u.setAttribute("tabindex","0"),u.focus())},d=(c,u)=>{switch(c.key){case"ArrowLeft":l(u);break;case"ArrowRight":a(u);break;case"Enter":s(i[u].key);break;default:break}};return _n(()=>{const c=o.value[0];c&&(c.setAttribute("tabindex","0"),c.focus())}),(c,u)=>(pe(),_e("div",{class:Yt(["alignment-buttons",{"high-contrast":Ve(n)}])},[(pe(),_e(Bt,null,Wn(i,(h,p)=>Le("div",{key:h.key,class:"sd-button-icon",onClick:f=>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:Gt(f=>d(f,p),["prevent"])},null,40,xN)),64))],2))}},RN=en(TN,[["__scopeId","data-v-13e5f7a4"]]);wt(),nn();var MN=["onClick","innerHTML","aria-label","onKeydown"],LN={__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}=fi(),r=t,o=e,i=$([]),s=Ie(()=>({width:`${o.iconSize}px`,height:`${o.iconSize}px`})),a=u=>{r("select",u)},l=u=>{if(u===i.value.length-1)return;const h=i.value[u+1];h&&(h.setAttribute("tabindex","0"),h.focus())},d=u=>{if(u===0)return;const h=i.value[u-1];h&&(h.setAttribute("tabindex","0"),h.focus())},c=(u,h)=>{switch(u.key){case"ArrowLeft":d(h);break;case"ArrowRight":l(h);break;case"Enter":a(o.buttons[h].key);break;default:break}};return _n(()=>{const u=i.value[0];u&&(u.setAttribute("tabindex","0"),u.focus())}),(u,h)=>(pe(),_e("div",{class:Yt(["style-buttons-list",{"high-contrast":Ve(n)}])},[(pe(!0),_e(Bt,null,Wn(o.buttons,(p,f)=>(pe(),_e("div",{key:p.key,class:Yt(["sd-button-icon",{"sd-selected":o.selectedStyle===p.key}]),style:rn(s.value),onClick:g=>a(p.key),innerHTML:p.icon,role:"menuitem","aria-label":p.ariaLabel,ref_for:!0,ref_key:"buttonRefs",ref:i,onKeydown:Gt(g=>c(g,f),["prevent"])},null,46,MN))),128))],2))}},LS=en(LN,[["__scopeId","data-v-44f37ff6"]]);const DN=[{key:"disc",icon:Vn.bulletListDisc,ariaLabel:"Opaque circle"},{key:"circle",icon:Vn.bulletListCircle,ariaLabel:"Outline circle"},{key:"square",icon:Vn.bulletListSquare,ariaLabel:"Opaque square"}],PN=[{key:"decimal",icon:Vn.numberedListDecimal,ariaLabel:"1. 2. 3."},{key:"decimal-paren",icon:Vn.numberedListDecimalParen,ariaLabel:"1) 2) 3)"},{key:"upper-roman",icon:Vn.numberedListUpperRoman,ariaLabel:"I. II. III."},{key:"lower-roman",icon:Vn.numberedListLowerRoman,ariaLabel:"i. ii. iii."},{key:"upper-alpha",icon:Vn.numberedListUpperAlpha,ariaLabel:"A. B. C."},{key:"upper-alpha-paren",icon:Vn.numberedListUpperAlphaParen,ariaLabel:"A) B) C)"},{key:"lower-alpha",icon:Vn.numberedListLowerAlpha,ariaLabel:"a. b. c."},{key:"lower-alpha-paren",icon:Vn.numberedListLowerAlphaParen,ariaLabel:"a) b) c)"}];wt(),nn();var ON=["onClick","onKeydown"],FN={class:"document-mode-column icon-column"},NN=["innerHTML"],BN={class:"document-mode-column text-column"},zN={class:"document-mode-type"},HN={class:"document-mode-description"},UN={__name:"DocumentMode",props:{options:{type:Array}},emits:["select"],setup(e,{emit:t}){const n=t,r=$([]),{isHighContrastMode:o}=fi(),i=e,s=c=>{n("select",c)},a=c=>{if(c===r.value.length-1)return;const u=r.value[c+1];u&&(u.setAttribute("tabindex","0"),u.focus())},l=c=>{if(c===0)return;const u=r.value[c-1];u&&(u.setAttribute("tabindex","0"),u.focus())},d=(c,u)=>{switch(c.key){case"ArrowDown":a(u);break;case"ArrowUp":l(u);break;case"Enter":s(i.options[u]);break;default:break}};return _n(()=>{r.value[0].setAttribute("tabindex","0"),r.value[0].focus()}),(c,u)=>(pe(),_e("div",{class:Yt(["document-mode",{"high-contrast":Ve(o)}])},[(pe(!0),_e(Bt,null,Wn(e.options,(h,p)=>(pe(),_e("div",{class:Yt(["sd-option-item",{"sd-disabled":h.disabled}]),onClick:f=>s(h),"data-item":"btn-documentMode-option",role:"menuitem",ref_for:!0,ref_key:"documentModeRefs",ref:r,onKeydown:Gt(f=>d(f,p),["prevent"])},[Le("div",FN,[Le("div",{class:"icon-column__icon",innerHTML:h.icon},null,8,NN)]),Le("div",BN,[Le("div",zN,Lt(h.label),1),Le("div",HN,Lt(h.description),1)])],42,ON))),256))],2))}},VN=en(UN,[["__scopeId","data-v-bee14d7a"]]);wt(),nn();var jN={class:"linked-style-buttons","data-editor-ui-surface":""},GN=["onClick","onKeydown","aria-label"],WN={__name:"LinkedStyle",props:{styles:{type:Array,default:()=>[]},selectedOption:{type:String,default:null}},emits:["select"],setup(e,{emit:t}){const n=t,r=$([]),o=e,i=u=>{n("select",u)},s=u=>{if(u===r.value.length-1)return;const h=r.value[u+1];h.setAttribute("tabindex","0"),h.focus()},a=u=>{if(u===0)return;const h=r.value[u-1];h.setAttribute("tabindex","0"),h.focus()},l=(u,h,p)=>{switch(u.key){case"ArrowDown":s(h);break;case"ArrowUp":a(h);break;case"Enter":u.preventDefault(),i(p);break;default:break}},d=u=>u?.name??u?.id??"",c=u=>{const h=u?.preview?.css;return h&&typeof h=="object"?h:void 0};return _n(()=>{r.value[0]&&(r.value[0].setAttribute("tabindex","0"),r.value[0].focus())}),(u,h)=>(pe(),_e("div",jN,[(pe(!0),_e(Bt,null,Wn(o.styles,(p,f)=>(pe(),_e("div",{key:p.id??f,class:Yt(["style-item",{selected:e.selectedOption===p.id}]),onClick:g=>i(p),onKeydown:g=>l(g,f,p),"aria-label":`Linked style - ${p.id??d(p)}`,ref_for:!0,ref_key:"styleRefs",ref:r},[Le("div",{class:"style-name","data-item":"btn-linkedStyles-option",style:rn(c(p))},Lt(d(p)),5)],42,GN))),128))]))}},KN=en(WN,[["__scopeId","data-v-43b5dcca"]]);wt(),nn();var qN=["placeholder"],YN={class:"sd-ai-writer__footer"},XN={key:0,class:"sd-ai-writer__error",role:"alert"},QN=["disabled"],ZN="https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights",JN="You are an expert copywriter and you are immersed in a document editor. Only write what is asked for.",$N={__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=$(""),r=$(!1),o=$(""),i=$(null),s=Ie(()=>t.selectedText?"Insert prompt to update text":"Insert prompt to generate text"),a=Ie(()=>n.value.trim().length>0&&!r.value);_n(()=>{yt(()=>{i.value?.focus()})});function l(f){if(typeof f=="string")return f;if(!f||typeof f!="object")return"";const g=f.custom_prompt;if(Array.isArray(g)){const w=g[0];if(w&&typeof w.value=="string")return w.value}return g&&typeof g=="object"&&typeof g.value=="string"?g.value:typeof f.value=="string"?f.value:typeof f.text=="string"?f.text:""}async function d(f){const g={"Content-Type":"application/json"};t.apiKey&&(g["x-api-key"]=t.apiKey);const w=t.selectedText.trim(),C=w?`Rewrite the following text: "${w}" using these instructions: ${f}`:`Generate text based on the following prompt: ${f}`,S=await fetch(t.endpoint||ZN,{method:"POST",headers:g,body:JSON.stringify({stream:!1,context:JN,insights:[{type:"custom_prompt",name:w?"text_rewrite":"text_generation",message:C,format:[{value:""}]}]})});if(!S.ok){const b=await S.text().catch(()=>"");throw new Error(b||`AI request failed with ${S.status}`)}const y=l((S.headers.get("content-type")||"").includes("application/json")?await S.json():await S.text()).trim();if(!y)throw new Error("AI returned no text.");return y}function c(f){return!f||typeof f!="object"?!0:!(f.success===!1||f.ok===!1)}function u(f){const g=t.doc;if(!g)throw new Error("Document API is unavailable.");t.restoreSelection?.();let w=null,C=!1;if(t.selectedText&&t.target&&typeof g.replace=="function"?(w=g.replace({target:t.target,text:f}),C=!0):t.target&&typeof g.insert=="function"?(w=g.insert({target:t.target,value:f,type:"text"}),C=!0):typeof g.insert=="function"&&(w=g.insert({value:f,type:"text"}),C=!0),!C)throw new Error("Document text insertion is unavailable.");if(!c(w))throw new Error("Unable to insert generated text.")}async function h(){if(a.value){o.value="",r.value=!0;try{u(await d(n.value.trim())),t.handleClose()}catch(f){o.value=f instanceof Error?f.message:String(f)}finally{r.value=!1}}}function p(f){f.key!=="Enter"||f.shiftKey||(f.preventDefault(),h())}return(f,g)=>(pe(),_e("form",{class:"sd-ai-writer","data-item":"ai-writer",onSubmit:Gt(h,["prevent"])},[ms(Le("textarea",{ref_key:"textareaRef",ref:i,"onUpdate:modelValue":g[0]||(g[0]=w=>n.value=w),class:"sd-ai-writer__input",placeholder:s.value,rows:"4",onKeydown:p},null,40,qN),[[qo,n.value]]),Le("div",YN,[o.value?(pe(),_e("p",XN,Lt(o.value),1)):rt("",!0),Le("button",{class:"sd-ai-writer__submit",type:"submit",disabled:!a.value},Lt(r.value?"Generating":"Generate"),9,QN)])],32))}},eB=en($N,[["__scopeId","data-v-67f6c6f7"]]);wt(),nn();var tB=["aria-label","onClick","onKeydown"],nB=["innerHTML"],rB=["innerHTML"],hp=7,oB={__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=Ie(()=>f=>r.activeColor.value?r.activeColor.value.toUpperCase()===f.value:!1),i=(f,g)=>g===5||["#FFFFFF","#FAFF09"].includes(f)?{color:"#000"}:{color:"#FFF"},s=f=>{n("select",f.value)},a=$([]),l=$([]);_n(()=>{if(!r.icons.every(g=>Array.isArray(g)))throw new Error("icon props must be 2d array");const f=l.value[0];f&&(f.setAttribute("tabindex","0"),f.focus())});const d=(f,g)=>{const w=hp*f+g+1,C=l.value[w];C&&(C.setAttribute("tabindex","0"),C.focus())},c=(f,g)=>{const w=hp*f+g-1,C=l.value[w];C&&(C.setAttribute("tabindex","0"),C.focus())},u=(f,g)=>{const w=g+hp*(f+1),C=l.value[w];C&&(C.setAttribute("tabindex","0"),C.focus())},h=(f,g)=>{const w=g+hp*(f-1),C=l.value[w];C&&(C.setAttribute("tabindex","0"),C.focus())},p=(f,g,w,C)=>{switch(f.key){case"ArrowRight":d(g,w);break;case"ArrowLeft":c(g,w);break;case"ArrowDown":u(g,w);break;case"ArrowUp":h(g,w);break;case"Enter":s(C);break;case"Escape":n("clickoutside");break;default:break}};return(f,g)=>(pe(!0),_e(Bt,null,Wn(e.icons,(w,C)=>(pe(),_e("div",{class:"sd-option-row",key:C,role:"group",ref_for:!0,ref_key:"rowRefs",ref:a},[(pe(!0),_e(Bt,null,Wn(w,(S,y)=>(pe(),_e("div",{class:"sd-option",key:y,"aria-label":S.label,role:"menuitem",ref_for:!0,ref_key:"iconRefs",ref:l,onClick:Gt(b=>s(S),["stop","prevent"]),onKeydown:Gt(b=>p(b,C,y,S),["prevent"])},[Le("div",{class:"sd-option__icon",innerHTML:S.icon,style:rn(S.style)},null,12,nB),o.value(S)?(pe(),_e("div",{key:0,class:"sd-option__check",innerHTML:Ve(Vn).colorOptionCheck,style:rn(i(S.value,y))},null,12,rB)):rt("",!0)],40,tB))),128))]))),128))}},DS=en(oB,[["__scopeId","data-v-5f3db0a9"]]),iB=`<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
|
`;wt(),nn();var sB={class:"options-grid-wrap"},aB=["innerHTML"],lB={class:"option-grid-ctn"},cB={__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)=>(pe(),_e("div",sB,[e.hasNoneIcon?(pe(),_e("div",{key:0,class:"none-option",role:"menuitem","aria-label":"Clear color selection",onClick:i[0]||(i[0]=s=>r("none"))},[Le("span",{innerHTML:Ve(iB),class:"none-icon"},null,8,aB),i[1]||(i[1]=li(" None ",-1))])):rt("",!0),Le("div",lB,[Ft(DS,{icons:e.icons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"]),e.customIcons.flat().length?(pe(),_e(Bt,{key:0},[i[2]||(i[2]=Le("span",{class:"option-grid-ctn__subtitle"},"Custom colors",-1)),Ft(DS,{icons:e.customIcons,"active-color":e.activeColor,onSelect:r},null,8,["icons","active-color"])],64)):rt("",!0)])]))}},uB=en(cB,[["__scopeId","data-v-52b0283a"]]);const PS=e=>{const t=e?.superdoc?.focus??e?.activeEditor?.focus;if(typeof t=="function"){t.call(e?.superdoc??e?.activeEditor);return}const n=document.querySelector('[role="textbox"][aria-label*="SuperDoc body"], .ProseMirror');n instanceof HTMLElement&&n.focus({preventScroll:!0})};wt();var dB=e=>{e.expand.value=!1};const Dt=(e,t=null)=>({label:t,icon:Vn.colorOption,value:e,style:{color:e,boxShadow:"0 0 5px 1px rgba(0, 0, 0, 0.1)",borderRadius:"50%"}}),jy=(e,t,n=[],r=!1)=>{const o=i=>{t.iconColor.value=i,e.emitCommand({item:t,argument:i}),dB(t),PS(e)};return yr("div",{},[yr(uB,{icons:fB,customIcons:n,activeColor:t.iconColor,hasNoneIcon:r,onSelect:o})])},fB=[[Dt("#111111","black"),Dt("#333333","dark gray"),Dt("#5C5C5C","medium gray"),Dt("#858585","light gray"),Dt("#ADADAD","very light gray"),Dt("#D6D6D6","transparent gray"),Dt("#FFFFFF","white")],[Dt("#860028","dark red"),Dt("#D2003F","red"),Dt("#DB3365","coral red"),Dt("#E4668C","light red"),Dt("#ED99B2","pale pink"),Dt("#F6CCD9","transparent pink"),Dt("#FF004D","bright pink")],[Dt("#83015E","dark purple"),Dt("#CD0194","purple"),Dt("#D734A9","orchid"),Dt("#E167BF","light purple"),Dt("#EB99D4","lavender"),Dt("#F5CCEA","transparent pink"),Dt("#FF00A8","neon pink")],[Dt("#8E220A","maroon"),Dt("#DD340F","red-orange"),Dt("#E45C3F","burnt orange"),Dt("#EB856F","peach"),Dt("#F1AE9F","pale peach"),Dt("#F8D6CF","transparent peach"),Dt("#FF7A00","orange")],[Dt("#947D02","olive"),Dt("#E7C302","mustard yellow"),Dt("#ECCF35","yellow"),Dt("#F1DB67","light yellow"),Dt("#F5E79A","very pale yellow"),Dt("#FAF3CC","transparent yellow"),Dt("#FAFF09","neon yellow")],[Dt("#055432","forest green"),Dt("#07834F","green"),Dt("#399C72","medium green"),Dt("#6AB595","light green"),Dt("#9CCDB9","mint"),Dt("#CDE6DC","transparent mint"),Dt("#05F38F","bright teal")],[Dt("#063E7E","navy blue"),Dt("#0A60C5","blue"),Dt("#3B80D1","sky blue"),Dt("#6CA0DC","cornflower blue"),Dt("#9DBFE8","light blue"),Dt("#CEDFF3","very light blue"),Dt("#21c8ce","cyan")],[Dt("#3E027A","deep purple"),Dt("#6103BF","indigo"),Dt("#8136CC","violet"),Dt("#A068D9","lavender pink"),Dt("#C09AE6","light lilac"),Dt("#DFCDF2","transparent lilac"),Dt("#A91DFF","neon purple")]];wt(),nn();var hB=["data-cols","data-rows","onKeydown","onClick"],pB=["aria-valuetext"],pp=5,mB={__name:"TableGrid",emits:["select","clickoutside"],setup(e,{emit:t}){const n=t,r=$(0),o=$(0),{isHighContrastMode:i}=fi(),s=$([]),a=u=>{let h=u.target;h.dataset.grid||l([...h.parentElement.querySelectorAll("[data-item]")],parseInt(h.dataset.cols,10),parseInt(h.dataset.rows,10))},l=(u,h,p)=>{o.value=h,r.value=p;for(let f=0;f<u.length;f++){let g=u[f],w=parseInt(g.dataset.cols,10),C=parseInt(g.dataset.rows,10);w<=h&&C<=p?g.classList.add("sd-selected"):g.classList.remove("sd-selected")}},d=({cols:u,rows:h})=>{n("select",{cols:u,rows:h})},c=(u,h,p)=>{let f=h-1,g=p-1;switch(u.key){case"ArrowRight":{if(f>=4)return;const w=g*pp;s.value[w+f+1].setAttribute("tabindex","0"),s.value[w+f+1].focus(),l(s.value,h+1,p);break}case"ArrowLeft":{if(f<=0)return;const w=g*pp;s.value[w+f-1].setAttribute("tabindex","0"),s.value[w+f-1].focus(),l(s.value,h-1,p);break}case"ArrowDown":{if(g>=4)return;const w=(g+1)*pp;s.value[w+f].setAttribute("tabindex","0"),s.value[w+f].focus(),l(s.value,h,p+1);break}case"ArrowUp":{if(g<=0)return;const w=(g-1)*pp;s.value[w+f].setAttribute("tabindex","0"),s.value[w+f].focus(),l(s.value,h,p-1);break}case"Enter":d({cols:h,rows:p});break;default:break}};return _n(()=>{s.value[0].setAttribute("tabindex","0"),s.value[0].focus(),l(s.value,1,1)}),(u,h)=>(pe(),_e("div",{class:Yt(["toolbar-table-grid-wrapper",{"high-contrast":Ve(i)}])},[Le("div",{class:"toolbar-table-grid",onMouseover:a,"data-grid":"true"},[(pe(),_e(Bt,null,Wn(5,p=>(pe(),_e(Bt,{key:p},[(pe(),_e(Bt,null,Wn(5,f=>Le("div",{class:"toolbar-table-grid__item",key:`${p}_${f}`,"data-cols":f,"data-rows":p,"data-item":"true",ref_for:!0,ref_key:"tableGridItems",ref:s,onKeydown:Gt(g=>c(g,f,p),["prevent"]),onClick:Gt(g=>d({cols:f,rows:p}),["stop","prevent"])},null,40,hB)),64))],64))),64))],32),Le("div",{class:"toolbar-table-grid-value","aria-valuetext":`${r.value} x ${o.value}`},Lt(r.value)+" x "+Lt(o.value),9,pB)],2))}},gB=en(mB,[["__scopeId","data-v-b87d6ca2"]]);wt(),nn();var vB={class:"toolbar-table-actions"},yB=["onClick","data-item","ariaLabel"],bB={class:"toolbar-table-actions__icon"},wB=["innerHTML"],CB={class:"toolbar-table-actions__label"},_B={__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)=>(pe(),_e("div",vB,[(pe(!0),_e(Bt,null,Wn(e.options,s=>(pe(),_e("div",{class:Yt(["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",bB,[Le("div",{class:"toolbar-table-actions__icon-wrapper",innerHTML:s.icon},null,8,wB)]),Le("div",CB,Lt(s.label),1)],10,yB))),256))]))}},SB=en(_B,[["__scopeId","data-v-0cdad084"]]),kB=`<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
|
-
`;wt();var Yi=e=>{e.expand.value=!1};function OS(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 AB(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function FS(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function IB(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function EB(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const xB=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=un({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),d=(r??wN).map(EN),c=un({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:d,onActivate:({fontFamily:be}={},lt=!1)=>{if(lt){c.label.value="",c.selectedValue.value="";return}if(!be)return;be=be.split(",")[0],c.label.value=be;const Ct=d.find(Nt=>Nt.label===c.defaultLabel.value),Rt=d.find(Nt=>Nt.label===be);Rt?c.selectedValue.value=Rt.key:Ct?c.selectedValue.value=Ct.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const be=d.find(lt=>lt.label===c.defaultLabel.value);be?c.selectedValue.value=be.key:c.selectedValue.value=""}}),u=un({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(u)}]});function h(be){const lt=FS(e),Ct=lt?.selectionTarget??OS(lt?.target),Rt=lt?.empty?"":AB(lt),Nt=EB(e),En=()=>Yi(be),xn=()=>{const Tn=e.pendingSelectionCapture;Tn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Tn)};return yr("div",{},[yr(eB,{handleClose:En,selectedText:Rt,target:Ct,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Nt?.apiKey||e.config?.aiApiKey||"",endpoint:Nt?.endpoint||e.config?.aiEndpoint||"",restoreSelection:xn})])}const p=_N,f=un({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:p,onActivate:({fontSize:be},lt=!1)=>{if(lt){f.label.value="",f.selectedValue.value="";return}const Ct=p.find(xn=>xn.label===String(f.defaultLabel.value));if(!be){f.label.value=f.defaultLabel.value,Ct?f.selectedValue.value=Ct.key:f.selectedValue.value="";return}let Rt=uF(be,12);Rt<8&&(Rt=8),Rt>96&&(Rt=96);let Nt=String(Rt);const En=p.find(xn=>xn.label===Nt||xn.key===Nt);En?f.selectedValue.value=En.key:f.selectedValue.value="",f.label.value=Nt},onDeactivate:()=>{f.label.value=f.defaultLabel.value;const be=p.find(lt=>lt.label===String(f.defaultLabel.value));be?f.selectedValue.value=be.key:f.selectedValue.value=""}}),g=un({type:"separator",name:"separator",isNarrow:!0}),w=un({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),C=un({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),S=un({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=un({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:()=>jy(e,y,[],!0)}],onActivate:({color:be})=>{y.iconColor.value=be||""},onDeactivate:()=>y.iconColor.value=""}),b=un({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:()=>jy(e,b)}],onActivate:({color:be})=>{b.iconColor.value=be},onDeactivate:()=>b.iconColor.value="#000"}),I=un({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=un({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>O(R)}],onActivate:({href:be})=>{be?R.attributes.value={href:be}:R.attributes.value={}},onDeactivate:()=>{R.attributes.value={},R.expand.value=!1}});function O(be){const lt=FS(e),Ct=lt?.selectionTarget??OS(lt?.target),Rt=()=>{const Nt=e.pendingSelectionCapture;Nt&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Nt)};return yr("div",{},[yr(KC,{ui:e.ui,linkItem:be,textTarget:Ct,restoreSelection:Rt,closePopover:()=>Yi(be),goToAnchor:()=>{Yi(be);const Nt=be.attributes.value?.href;if(!Nt)return;const En=Nt.slice(1),xn=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${En}']`);xn&&Cd(xn)}})])}const B=un({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=B,B.parentItem=R;const L=un({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),z=un({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Q=un({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:()=>x(Q)}]});function x(be){return yr("div",{},[yr(gB,{onSelect:Ct=>{e.emitCommand({item:be,argument:Ct}),Yi(be),PS(e)}})])}const N=un({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>U(N)}]}),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 U(be){return yr(SB,{options:A,onSelect:lt=>{Yi(be);const{command:Ct}=lt;e.emitCommand({item:be,argument:{command:Ct}})}})}const Y=un({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:()=>yr("div",{},[yr(RN,{onSelect:lt=>{Yi(Y);const Ct={...Y,command:"setTextAlign"};Ct.command="setTextAlign",e.emitCommand({item:Ct,argument:lt}),Z(Y,lt)}})]),key:"alignment"}],onActivate:({textAlign:be})=>{Z(Y,be)},onDeactivate:()=>{Z(Y,"left")}}),Z=(be,lt)=>{let Ct=lt==="both"?"justify":lt,Rt={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Nt=Rt[Ct]??Rt.left;be.icon.value=Nt},ue=un({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 be=lt=>{Yi(ue);const Ct={...ue,command:"toggleBulletListStyle"};e.emitCommand({item:Ct,argument:lt})};return yr(LS,{buttons:DN,iconSize:25,selectedStyle:ue.selectedValue.value,onSelect:be})}}]}),ce=un({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 be=lt=>{Yi(ce);const Ct={...ce,command:"toggleOrderedListStyle"};e.emitCommand({item:Ct,argument:lt})};return yr(LS,{buttons:PN,iconSize:30,selectedStyle:ce.selectedValue.value,onSelect:be})}}]}),De=un({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),ae=un({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),de=un({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),fe=un({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:be})=>{be&&(fe.label.value=be)}}),ye=un({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:be})=>{be&&(ye.label.value=be)}}),te=un({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Ee=un({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),Re=un({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),We=un({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),vt=un({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),we=un({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Be=(be,lt)=>be==="editor"?lt:be==="suggester"?lt.filter(Ct=>Ct.value==="suggesting"):lt.filter(Ct=>Ct.value==="viewing"),Ge=be=>be==="editor"?"Editing":be==="suggester"?"Suggesting":"Viewing",X=un({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:Ge(s),label:Ge(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:()=>M(X)}]}),_=[{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 M(be){return yr(VN,{options:Be(s,_),onSelect:lt=>{Yi(be);const{label:Ct,icon:Rt,value:Nt}=lt;X.label.value=Ct,X.icon.value=Rt,e.emitCommand({item:X,argument:Nt})}})}const ee=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),j=["search","ruler","undo","overflow","documentMode"],H=un({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),V=un({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),q=un({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 be=Ct=>{Yi(q);const Rt=typeof Ct=="string"?Ct:Ct?.id??null;if(!Rt)return;const Nt={...q,command:"setLinkedStyle"};e.emitCommand({item:Nt,argument:Rt})},lt=e.getActiveLinkedStyleId?.()??null;return yr("div",{},[yr(KN,{styles:e.getLinkedStyleOptions?.()??[],onSelect:be,selectedOption:lt})])}}],onActivate:({styleId:be,styleName:lt})=>{const Ct=lt||be;q.label.value=be&&be!=="Normal"?String(Ct):n.formatText,q.disabled.value=!1},onDeactivate:()=>{q.disabled.value=!0,q.label.value=n.formatText}}),W=(be,lt)=>{if(lt.value==be)return yr("div",{innerHTML:kB,class:"dropdown-select-icon"})},G=un({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(be=>({label:be.toFixed(2),key:be,icon:()=>W(be,G.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),ve=20,Se=32,ke=j.reduce((be,lt)=>be+(ee.get(lt)||ee.get("default")),0),Fe=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],Ze=["zoom","fontFamily","fontSize","redo"],Ke=i<=Xd.lg,bt=e.config?.showFormattingMarksButton===!0,St=e.config?.showTableOfContentsButton===!0;Ke&&(X.attributes.value={...X.attributes.value,className:`${X.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),Ke&&(q.attributes.value={...q.attributes.value,className:`${q.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let it=[te,Ee,Re,We,I,fe,c,g,f,g,l,w,C,S,b,y,g,R,L,...St?[z]:[],Q,N,g,Y,ue,ce,De,ae,G,g,q,g,H,ye,...bt?[V]:[],we,vt,...IB(e)?[u]:[],de,X];if(i<=Xd.md&&o&&(it=it.filter(be=>be.type!=="separator")),e.config.mode!=="docx"){const be=it.findIndex(Ct=>Ct.name.value==="linkedStyles");it.splice(be-1,2);const lt=["ruler","zoom","undo","redo"];it=it.filter(Ct=>!lt.includes(Ct.name.value))}const xe=[];a||(s==="viewer"&&xe.push(Re,We),it=it.filter(be=>!xe.includes(be)));const Me=be=>j.includes(be.name.value),Pe=[],at=[];let pt=Se+ke;return it.forEach(be=>{const lt=ee.get(be.name.value)||ee.get("default");if(i<Xd.xl+ve&&Fe.includes(be.name.value)&&o){if(Pe.push(be),be.name.value==="linkedStyles"){const Ct=it.findIndex(Rt=>Rt.name.value==="linkedStyles");it.splice(Ct+1,1)}return}if(i<Xd.sm&&Ze.includes(be.name.value)&&o){Pe.push(be);return}if(Me(be)){at.push(be),pt+=lt;return}pt<i||!o?(at.push(be),pt+=lt):Pe.push(be)}),{defaultItems:at,overflowItems:Pe.filter(be=>be.type!=="separator")}},NS={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"},TB=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;wt();function BS(e){return nF(e)??Vy[e]??null}function mp(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 RB=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),MB=new Set(["list","numberedlist"]);function LB(e,t){if(e==="fontFamily"||e==="fontSize"||MB.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!RB.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function zS(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function DB(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var PB=class extends Ap.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Vn},texts:{...NS},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={...Vn,...e.icons},this.config.texts={...NS,...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=TB(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=ml(IN),this.app.directive("click-outside",xg),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}#e(){this.superdoc&&(this.ui=cy({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||CN(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#r(){const e=this.getAvailableWidth(),{defaultItems:t,overflowItems:n}=xB({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)),d=o.filter(c=>l.has(c.group?.value||"center")).map(c=>c.name.value);i=[...new Set([...a,...d])]}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 d of s)l.includes(d.name.value)&&(d.group.value=a);this.toolbarItems=s,this.overflowItems=n.filter(a=>i.includes(a.name.value))}#f(e){const t=un({...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:()=>jy(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=MS.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(Hy(t)?.disposition==="host-routed")return e.setDisabled(!this.#C(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=BS(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];LB(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=RS[t?.command];return i?mp(this.ui,i,void 0,r):!1}if(Hy(n)?.disposition==="unsupported")return!0;const o=BS(n);return o?mp(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=cF({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await aF(e,this.superdoc?.config?.handleImageUpload);mp(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=>{zS(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!zS(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}DB(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(Hy(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(!mp(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 OB(e){return new PB(e)}wt();var FB=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 NB(e,t){const n=new h5.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function Gy(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function HS(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function BB(e,t){if(!e)return()=>{};if(Gy(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=()=>{HS(e),s()},l=d=>{d!==!1&&(d===!0||Gy(e))&&(HS(e),s())};return n("synced",a),n("sync",l),Gy(e)&&s(),i}function Qo(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function zB(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 US(e){return typeof e=="string"&&e.length>0?e:null}function Wy(e){return e?Qo(e)?US(e.documentId??e.options?.documentId??null):US(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function HB(e){if(!e||Qo(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function yi(e){if(!e)return null;if(Qo(e))return e.fonts??null;const t=HB(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 gp=class extends Ap.default{static{this.allowedTypes=[mr,gl,$f]}#t=!1;#n=!1;#e=null;#o=null;#i=null;#s=null;#u=null;#d;#r=new eF;#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:{...zy},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 WO({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),JO(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=$O(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=I7(this.config.modules.comments),this.config.colors=C5(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.0.0-next.25",this.#b("π¦ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||Ri(),this.colors=this.config.colors??[],this.#w(),await AE(),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 yD({Renderer:VO,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===mr).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=rd(this.config.document);this.config.documents=[{id:Ri(),...s}]}else if(n)this.config.documents=[{id:Ri(),type:mr,url:this.config.document,name:"document.docx"}];else if(r){const s=rd(this.config.document);this.config.documents=[{id:Ri(),...s}]}else if(o){const s=rd(this.config.document);this.config.documents=[{id:Ri(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=rd(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||Ri()}}))}#_(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=sD({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&&dE(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:Ri(),type:mr,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=Sr(e),this.provider=Sr(t),this.#P();const n=this.config;this._cleanupAwareness=sE(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(),Qo(e)&&(this.#R(e),this.#S(e))}#R(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=pD(()=>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
|
+
`;wt();var Yi=e=>{e.expand.value=!1};function OS(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 AB(e){return typeof e?.quotedText=="string"?e.quotedText:typeof e?.text=="string"?e.text:""}function FS(e){return e.ui?.selection?.get?.()??e.ui?.selection?.current?.()??null}function IB(e){return!!(e.config?.superdoc?.config?.modules?.ai||e.superdoc?.config?.modules?.ai)}function EB(e){return e.config?.superdoc?.config?.modules?.ai??e.superdoc?.config?.modules?.ai??{}}const xB=({superToolbar:e,toolbarIcons:t,toolbarTexts:n,toolbarFonts:r,hideButtons:o,availableWidth:i,role:s,isDev:a=!1}={})=>{const l=un({type:"button",name:"bold",command:"toggleBold",icon:t.bold,tooltip:n.bold,attributes:{ariaLabel:"Bold"}}),d=(r??wN).map(EN),c=un({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:d,onActivate:({fontFamily:be}={},lt=!1)=>{if(lt){c.label.value="",c.selectedValue.value="";return}if(!be)return;be=be.split(",")[0],c.label.value=be;const Ct=d.find(Nt=>Nt.label===c.defaultLabel.value),Rt=d.find(Nt=>Nt.label===be);Rt?c.selectedValue.value=Rt.key:Ct?c.selectedValue.value=Ct.key:c.selectedValue.value=""},onDeactivate:()=>{c.label.value=c.defaultLabel.value;const be=d.find(lt=>lt.label===c.defaultLabel.value);be?c.selectedValue.value=be.key:c.selectedValue.value=""}}),u=un({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(u)}]});function h(be){const lt=FS(e),Ct=lt?.selectionTarget??OS(lt?.target),Rt=lt?.empty?"":AB(lt),Nt=EB(e),En=()=>Yi(be),xn=()=>{const Tn=e.pendingSelectionCapture;Tn&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Tn)};return yr("div",{},[yr(eB,{handleClose:En,selectedText:Rt,target:Ct,doc:e.superdoc?.activeEditor?.doc??null,apiKey:Nt?.apiKey||e.config?.aiApiKey||"",endpoint:Nt?.endpoint||e.config?.aiEndpoint||"",restoreSelection:xn})])}const p=_N,f=un({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:p,onActivate:({fontSize:be},lt=!1)=>{if(lt){f.label.value="",f.selectedValue.value="";return}const Ct=p.find(xn=>xn.label===String(f.defaultLabel.value));if(!be){f.label.value=f.defaultLabel.value,Ct?f.selectedValue.value=Ct.key:f.selectedValue.value="";return}let Rt=uF(be,12);Rt<8&&(Rt=8),Rt>96&&(Rt=96);let Nt=String(Rt);const En=p.find(xn=>xn.label===Nt||xn.key===Nt);En?f.selectedValue.value=En.key:f.selectedValue.value="",f.label.value=Nt},onDeactivate:()=>{f.label.value=f.defaultLabel.value;const be=p.find(lt=>lt.label===String(f.defaultLabel.value));be?f.selectedValue.value=be.key:f.selectedValue.value=""}}),g=un({type:"separator",name:"separator",isNarrow:!0}),w=un({type:"button",name:"italic",command:"toggleItalic",icon:t.italic,active:!1,tooltip:n.italic,attributes:{ariaLabel:"Italic"}}),C=un({type:"button",name:"underline",command:"toggleUnderline",icon:t.underline,active:!1,tooltip:n.underline,attributes:{ariaLabel:"Underline"}}),S=un({type:"button",name:"strike",command:"toggleStrike",icon:t.strikethrough,active:!1,tooltip:n.strikethrough,attributes:{ariaLabel:"Strikethrough"}}),y=un({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:()=>jy(e,y,[],!0)}],onActivate:({color:be})=>{y.iconColor.value=be||""},onDeactivate:()=>y.iconColor.value=""}),b=un({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:()=>jy(e,b)}],onActivate:({color:be})=>{b.iconColor.value=be},onDeactivate:()=>b.iconColor.value="#000"}),I=un({type:"button",name:"search",allowWithoutEditor:!0,active:!1,icon:t.search,tooltip:n.search,group:"right",attributes:{ariaLabel:"Search"}}),R=un({type:"dropdown",name:"link",markName:"link",icon:t.link,active:!1,tooltip:n.link,attributes:{ariaLabel:"Link dropdown"},options:[{type:"render",key:"linkDropdown",render:()=>O(R)}],onActivate:({href:be})=>{be?R.attributes.value={href:be}:R.attributes.value={}},onDeactivate:()=>{R.attributes.value={},R.expand.value=!1}});function O(be){const lt=FS(e),Ct=lt?.selectionTarget??OS(lt?.target),Rt=()=>{const Nt=e.pendingSelectionCapture;Nt&&typeof e.ui?.selection?.restore=="function"&&e.ui.selection.restore(Nt)};return yr("div",{},[yr(KC,{ui:e.ui,linkItem:be,textTarget:Ct,restoreSelection:Rt,closePopover:()=>Yi(be),goToAnchor:()=>{Yi(be);const Nt=be.attributes.value?.href;if(!Nt)return;const En=Nt.slice(1),xn=(e.ui?.viewport?.getHost?.()??null)?.querySelector?.(`a[name='${En}']`);xn&&Cd(xn)}})])}const B=un({type:"options",name:"linkInput",command:"toggleLink",active:!1});R.childItem=B,B.parentItem=R;const L=un({type:"button",name:"image",command:"startImageUpload",icon:t.image,active:!1,tooltip:n.image,disabled:!1,attributes:{ariaLabel:"Image"}}),z=un({type:"button",name:"tableOfContents",command:"insertTableOfContents",icon:t.tableOfContents,active:!1,tooltip:n.tableOfContents,disabled:!1,attributes:{ariaLabel:"Table of contents"}}),Q=un({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:()=>x(Q)}]});function x(be){return yr("div",{},[yr(gB,{onSelect:Ct=>{e.emitCommand({item:be,argument:Ct}),Yi(be),PS(e)}})])}const N=un({type:"dropdown",name:"tableActions",command:"executeTableCommand",tooltip:n.tableActions,icon:t.tableActions,hideLabel:!0,disabled:!0,attributes:{ariaLabel:"Table actions"},options:[{type:"render",render:()=>U(N)}]}),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 U(be){return yr(SB,{options:A,onSelect:lt=>{Yi(be);const{command:Ct}=lt;e.emitCommand({item:be,argument:{command:Ct}})}})}const Y=un({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:()=>yr("div",{},[yr(RN,{onSelect:lt=>{Yi(Y);const Ct={...Y,command:"setTextAlign"};Ct.command="setTextAlign",e.emitCommand({item:Ct,argument:lt}),Z(Y,lt)}})]),key:"alignment"}],onActivate:({textAlign:be})=>{Z(Y,be)},onDeactivate:()=>{Z(Y,"left")}}),Z=(be,lt)=>{let Ct=lt==="both"?"justify":lt,Rt={left:t.alignLeft,right:t.alignRight,center:t.alignCenter,justify:t.alignJustify},Nt=Rt[Ct]??Rt.left;be.icon.value=Nt},ue=un({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 be=lt=>{Yi(ue);const Ct={...ue,command:"toggleBulletListStyle"};e.emitCommand({item:Ct,argument:lt})};return yr(LS,{buttons:DN,iconSize:25,selectedStyle:ue.selectedValue.value,onSelect:be})}}]}),ce=un({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 be=lt=>{Yi(ce);const Ct={...ce,command:"toggleOrderedListStyle"};e.emitCommand({item:Ct,argument:lt})};return yr(LS,{buttons:PN,iconSize:30,selectedStyle:ce.selectedValue.value,onSelect:be})}}]}),De=un({type:"button",name:"indentleft",command:"decreaseTextIndent",icon:t.indentLeft,active:!1,tooltip:n.indentLeft,disabled:!1,attributes:{ariaLabel:"Left indent"}}),ae=un({type:"button",name:"indentright",command:"increaseTextIndent",icon:t.indentRight,active:!1,tooltip:n.indentRight,disabled:!1,attributes:{ariaLabel:"Right indent"}}),de=un({type:"overflow",name:"overflow",command:null,icon:t.overflow,active:!1,disabled:!1,attributes:{ariaLabel:"Overflow items"}}),fe=un({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:be})=>{be&&(fe.label.value=be)}}),ye=un({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:be})=>{be&&(ye.label.value=be)}}),te=un({type:"button",name:"undo",disabled:!0,tooltip:n.undo,command:"undo",icon:t.undo,group:"left",attributes:{ariaLabel:"Undo"}}),Ee=un({type:"button",disabled:!0,name:"redo",tooltip:n.redo,command:"redo",icon:t.redo,group:"left",attributes:{ariaLabel:"Redo"}}),Re=un({type:"button",disabled:!1,name:"acceptTrackedChangeBySelection",tooltip:n.trackChangesAccept,command:"acceptTrackedChangeFromToolbar",icon:t.trackChangesAccept,group:"left",attributes:{ariaLabel:"Accept tracked changes"}}),We=un({type:"button",disabled:!1,name:"rejectTrackedChangeOnSelection",tooltip:n.trackChangesReject,command:"rejectTrackedChangeFromToolbar",icon:t.trackChangesReject,group:"left",attributes:{ariaLabel:"Reject tracked changes"}}),vt=un({type:"button",name:"clearFormatting",command:"clearFormat",tooltip:n.clearFormatting,icon:t.clearFormatting,attributes:{ariaLabel:"Clear formatting"}}),we=un({type:"button",name:"copyFormat",tooltip:n.copyFormat,icon:t.copyFormat,command:"copyFormat",active:!1,attributes:{ariaLabel:"Copy formatting"}}),Be=(be,lt)=>be==="editor"?lt:be==="suggester"?lt.filter(Ct=>Ct.value==="suggesting"):lt.filter(Ct=>Ct.value==="viewing"),Ge=be=>be==="editor"?"Editing":be==="suggester"?"Suggesting":"Viewing",X=un({type:"dropdown",name:"documentMode",command:"setDocumentMode",allowWithoutEditor:!0,icon:t.documentMode,defaultLabel:Ge(s),label:Ge(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:()=>M(X)}]}),_=[{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 M(be){return yr(VN,{options:Be(s,_),onSelect:lt=>{Yi(be);const{label:Ct,icon:Rt,value:Nt}=lt;X.label.value=Ct,X.icon.value=Rt,e.emitCommand({item:X,argument:Nt})}})}const ee=new Map([["separator",20],["zoom",71],["measurementUnit",52],["fontFamily",118],["fontSize",57],["textAlign",40],["linkedStyles",142],["documentMode",47],["default",32]]),j=["search","ruler","undo","overflow","documentMode"],H=un({type:"button",name:"ruler",command:"toggleRuler",allowWithoutEditor:!0,icon:t.ruler,active:!1,tooltip:n.ruler,attributes:{ariaLabel:"Ruler"}}),V=un({type:"button",name:"formattingMarks",command:"toggleFormattingMarks",allowWithoutEditor:!0,icon:t.formattingMarks,active:!1,tooltip:n.formattingMarks,attributes:{ariaLabel:"Formatting marks"}}),q=un({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 be=Ct=>{Yi(q);const Rt=typeof Ct=="string"?Ct:Ct?.id??null;if(!Rt)return;const Nt={...q,command:"setLinkedStyle"};e.emitCommand({item:Nt,argument:Rt})},lt=e.getActiveLinkedStyleId?.()??null;return yr("div",{},[yr(KN,{styles:e.getLinkedStyleOptions?.()??[],onSelect:be,selectedOption:lt})])}}],onActivate:({styleId:be,styleName:lt})=>{const Ct=lt||be;q.label.value=be&&be!=="Normal"?String(Ct):n.formatText,q.disabled.value=!1},onDeactivate:()=>{q.disabled.value=!0,q.label.value=n.formatText}}),W=(be,lt)=>{if(lt.value==be)return yr("div",{innerHTML:kB,class:"dropdown-select-icon"})},G=un({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(be=>({label:be.toFixed(2),key:be,icon:()=>W(be,G.selectedValue),props:{"data-item":"btn-lineHeight-option"}}))}),ve=20,Se=32,ke=j.reduce((be,lt)=>be+(ee.get(lt)||ee.get("default")),0),Fe=["linkedStyles","clearFormatting","copyFormat","formattingMarks"],Ze=["zoom","fontFamily","fontSize","redo"],Ke=i<=Xd.lg,bt=e.config?.showFormattingMarksButton===!0,St=e.config?.showTableOfContentsButton===!0;Ke&&(X.attributes.value={...X.attributes.value,className:`${X.attributes.value.className} sd-toolbar-item--doc-mode-compact`}),Ke&&(q.attributes.value={...q.attributes.value,className:`${q.attributes.value.className} sd-toolbar-item--linked-styles-compact`});let it=[te,Ee,Re,We,I,fe,c,g,f,g,l,w,C,S,b,y,g,R,L,...St?[z]:[],Q,N,g,Y,ue,ce,De,ae,G,g,q,g,H,ye,...bt?[V]:[],we,vt,...IB(e)?[u]:[],de,X];if(i<=Xd.md&&o&&(it=it.filter(be=>be.type!=="separator")),e.config.mode!=="docx"){const be=it.findIndex(Ct=>Ct.name.value==="linkedStyles");it.splice(be-1,2);const lt=["ruler","zoom","undo","redo"];it=it.filter(Ct=>!lt.includes(Ct.name.value))}const xe=[];a||(s==="viewer"&&xe.push(Re,We),it=it.filter(be=>!xe.includes(be)));const Me=be=>j.includes(be.name.value),Pe=[],at=[];let pt=Se+ke;return it.forEach(be=>{const lt=ee.get(be.name.value)||ee.get("default");if(i<Xd.xl+ve&&Fe.includes(be.name.value)&&o){if(Pe.push(be),be.name.value==="linkedStyles"){const Ct=it.findIndex(Rt=>Rt.name.value==="linkedStyles");it.splice(Ct+1,1)}return}if(i<Xd.sm&&Ze.includes(be.name.value)&&o){Pe.push(be);return}if(Me(be)){at.push(be),pt+=lt;return}pt<i||!o?(at.push(be),pt+=lt):Pe.push(be)}),{defaultItems:at,overflowItems:Pe.filter(be=>be.type!=="separator")}},NS={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"},TB=e=>e?typeof e!="string"?e instanceof HTMLElement?e:null:e.startsWith("#")||e.startsWith(".")?document.querySelector(e):document.getElementById(e):null;wt();function BS(e){return nF(e)??Vy[e]??null}function mp(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 RB=new Set(["bold","italic","underline","strike","color","highlight","link","clearFormatting","textAlign","list","numberedlist","indentleft","indentright","lineHeight","linkedStyles"]),MB=new Set(["list","numberedlist"]);function LB(e,t){if(e==="fontFamily"||e==="fontSize"||MB.has(e)&&t?.disabled&&t?.supported!==!1&&t?.reason==null)return!0;if(!RB.has(e))return!1;const n=t?.reason;return n==="range-selection-required"||n==="selection-required"}function zS(e){return!!e?.closest?.("[data-editor-ui-surface], .toolbar-dropdown-menu, .sd-toolbar-dropdown-menu, .sd-tooltip-content")}function DB(e){return["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key)}var PB=class extends Ap.default{config={selector:null,toolbarGroups:["left","center","right"],role:"editor",icons:{...Vn},texts:{...NS},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={...Vn,...e.icons},this.config.texts={...NS,...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=TB(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=ml(IN),this.app.directive("click-outside",xg),this.app.config.globalProperties.$toolbar=this,this.toolbar=this.app.mount(this.toolbarContainer),this.updateToolbarState()}#e(){this.superdoc&&(this.ui=cy({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||CN(this.superdoc?.fonts?.getFontFamilyOptions?.()??[])}#r(){const e=this.getAvailableWidth(),{defaultItems:t,overflowItems:n}=xB({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)),d=o.filter(c=>l.has(c.group?.value||"center")).map(c=>c.name.value);i=[...new Set([...a,...d])]}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 d of s)l.includes(d.name.value)&&(d.group.value=a);this.toolbarItems=s,this.overflowItems=n.filter(a=>i.includes(a.name.value))}#f(e){const t=un({...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:()=>jy(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=MS.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(Hy(t)?.disposition==="host-routed")return e.setDisabled(!this.#C(t)),this.#g(t)?e.activate():e.deactivate(),!0;const n=BS(t);if(!n)return!1;const r=this.snapshot?.commands?.[n];LB(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=RS[t?.command];return i?mp(this.ui,i,void 0,r):!1}if(Hy(n)?.disposition==="unsupported")return!0;const o=BS(n);return o?mp(this.ui,o,t,r):!1}#T(){return this.snapshot?.commands?.image?.disabled||(this.#t||(this.#t=cF({ownerDocument:this.toolbarContainer?.ownerDocument??document,onPick:async e=>{const t=await aF(e,this.superdoc?.config?.handleImageUpload);mp(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=>{zS(i.target)||this.ui.formatPainter.setPointerSelecting(!0)},n=i=>{this.ui.formatPainter.setPointerSelecting(!1),!zS(i.target)&&this.ui.formatPainter.notifyPointerUp()},r=i=>{if(i.key==="Escape"){this.ui.formatPainter.cancel();return}DB(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(Hy(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(!mp(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 OB(e){return new PB(e)}wt();var FB=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 NB(e,t){const n=new h5.default;return e.forEach((r,o)=>{n.file(t[o],r)}),n.generateAsync({type:"blob",compression:"DEFLATE"})}function Gy(e){return!!(e&&(e.synced===!0||e.isSynced===!0))}function HS(e){try{e.synced=!0}catch{}try{e.isSynced=!0}catch{}}function BB(e,t){if(!e)return()=>{};if(Gy(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=()=>{HS(e),s()},l=d=>{d!==!1&&(d===!0||Gy(e))&&(HS(e),s())};return n("synced",a),n("sync",l),Gy(e)&&s(),i}function Qo(e){return!!(e&&typeof e=="object"&&e.editorVersion===2)}function zB(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 US(e){return typeof e=="string"&&e.length>0?e:null}function Wy(e){return e?Qo(e)?US(e.documentId??e.options?.documentId??null):US(typeof e.getDocumentId=="function"?e.getDocumentId():e.options?.documentId):null}function HB(e){if(!e||Qo(e))return null;const t=e;return t.documentRenderer??t.presentationEditor??null}function yi(e){if(!e)return null;if(Qo(e))return e.fonts??null;const t=HB(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 gp=class extends Ap.default{static{this.allowedTypes=[mr,gl,$f]}#t=!1;#n=!1;#e=null;#o=null;#i=null;#s=null;#u=null;#d;#r=new eF;#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:{...zy},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 WO({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),JO(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=$O(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=I7(this.config.modules.comments),this.config.colors=C5(this.config.colors),this.userColorMap=new Map,this.colorIndex=0,this.version="2.0.0-next.26",this.#b("π¦ [superdoc] Using SuperDoc version:",this.version),this.superdocId=e.superdocId||Ri(),this.colors=this.config.colors??[],this.#w(),await AE(),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 yD({Renderer:VO,superdoc:this,enabled:t}),this.emit("whiteboard:init",{whiteboard:this.whiteboard})}get requiredNumberOfEditors(){return this.#h("requiredNumberOfEditors").documents.filter(e=>e.type===mr).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=rd(this.config.document);this.config.documents=[{id:Ri(),...s}]}else if(n)this.config.documents=[{id:Ri(),type:mr,url:this.config.document,name:"document.docx"}];else if(r){const s=rd(this.config.document);this.config.documents=[{id:Ri(),...s}]}else if(o){const s=rd(this.config.document);this.config.documents=[{id:Ri(),...s}]}Array.isArray(this.config.documents)&&this.config.documents.length>0&&(this.config.documents=this.config.documents.map(s=>{const a=rd(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||Ri()}}))}#_(){const{app:e,pinia:t,superdocStore:n,commentsStore:r,highContrastModeStore:o}=sD({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&&dE(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:Ri(),type:mr,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=Sr(e),this.provider=Sr(t),this.#P();const n=this.config;this._cleanupAwareness=sE(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(),Qo(e)&&(this.#R(e),this.#S(e))}#R(e){const t=e.presence;if(!t||typeof t.subscribe!="function")return;const n=pD(()=>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:FB,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.#O(),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}}#O(){const e=this.config.documents.find(r=>r.type===mr),t=this.superdocStore?.documents.find(r=>r.id===e.id)??null,n=t?tn(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===mr);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.#N(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.`)}#F(e,t){const n=this.superdocStore?.documents;if(Array.isArray(n))for(const r of n){const o=tn(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=tn(e).v2Collaboration;if(n&&typeof n=="object"&&"value"in n){n.value=t;return}e.v2Collaboration=t}#N(e){const t=tn(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}#B(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===mr),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.#B({...e,roomMode:"create"});return n.data=t,n.v2Collaboration=o,r.data=t,this.#k(r,o),this.isCollaborative=!0,this.readyEditors=0,this.#N(r),{configDoc:n,storeDoc:r}}#Y(e,t){const n=this.#B({...t,roomMode:"join"});e.configDoc.v2Collaboration=n,this.#k(e.storeDoc,n)}async#X(){const e=this.activeEditor;if(Qo(e)&&typeof e.save=="function"){const r=await e.save();return this.#L(r)}const t=this.config.documents.find(r=>r.type===mr),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:mr})}if(e instanceof ArrayBuffer)return new Blob([e],{type:mr});throw new Error("SuperDoc: active v2 editor returned an unsupported DOCX save payload")}#J(e,t){const n=Wy(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.#F(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 d=l?.editor;Qo(d)&&Wy(d)===e&&(!d.presence&&!d.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=BB(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===mr);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(!Qo(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=O_({v2Collaboration:e.v2Collaboration??this.#ue(r.v2Collaboration)??i?.v2Collaboration??i?.v2??null,legacyCollaboration:s,documentType:mr,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===mr),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=gc({actor:e});t&&this.users.some(n=>gc({actor:n})===t)||this.users.push(e)}removeSharedUser(e){this.#y("removeSharedUser");const t=typeof e=="string"?Ig(e):"",n=typeof e=="string"?`email:${t}`:gc({actor:e});this.users=this.users.filter(r=>{const o=gc({actor:r});return n?o!==n:t?Ig(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:vS(e)})}broadcastEditorCreate(e){this.readyEditors++,this.broadcastReady(),this.#fe(e),this.emit("editorCreate",{editor:vS(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:()=>yi(this.activeEditor)?.getReport()??[],getMissingFonts:()=>yi(this.activeEditor)?.getMissingFonts()??[],getDocumentFontOptions:()=>yi(this.activeEditor)?.getDocumentFontOptions()??[],getFontFamilyOptions:()=>yi(this.activeEditor)?.getFontFamilyOptions()??[],getDocumentFonts:()=>yi(this.activeEditor)?.getDocumentFonts()??[],onReport:e=>{const t=this.activeEditor,n=t?yi(t)?.getLastFontsChangedPayload?.()??null:this.#te??null;return n&&e(n),this.on("fonts-changed",e),()=>this.off("fonts-changed",e)},map:e=>{const t=yi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.map requires an active editor");t.map(e)},unmap:e=>{const t=yi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.unmap requires an active editor");t.unmap(e)},add:e=>{const t=yi(this.activeEditor);if(!t)throw new Error("superdoc.fonts.add requires an active editor");t.add(e)},preload:e=>{const t=yi(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=yi(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"&&Qo(t)?this.#re(t):this.#H()}finally{this.#p=!1}}#re(e){if(Qo(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 Os(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=OB({...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 zT(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=q3(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(Qo(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=o4(n||this.config.title),d=await this.exportEditorsToDOCX({commentsType:t,isFinalDoc:i,fieldsHighlightColor:a}),c=[...r],u=[...o];if(e.includes("docx")&&d.forEach(p=>{c.push(p),u.push(`${l}.docx`)}),c.length===1)return s?r4(c[0],l,e[0]):c[0];const h=await NB(c,u);return s?r4(h,l,"zip"):h}async replaceFile(e){const t=this.activeEditor;if(Qo(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&&!Qo(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=d=>{"editor"in d&&d.error&&typeof d.error=="object"&&a.add(d.error)};this.on("exception",l);try{const d=this.#h("exportEditorsToDOCX").documents.map(async c=>{if(!c||c.type!=="application/vnd.openxmlformats-officedocument.wordprocessingml.document")return null;const u=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(!u||typeof u.exportDocx!="function")return h();const p=u.editorVersion===2;try{const f=await u.exportDocx(p?{isFinalDoc:t,commentsType:e,fieldsHighlightColor:n}:{isFinalDoc:t,comments:s(),commentsType:e,fieldsHighlightColor:n});if(f)return f}catch(f){if((!f||typeof f!="object"||!a.has(f))&&this.emit("exception",{error:f,document:c}),p&&(e==="clean"||zB(f)))throw f}return h()});return(await Promise.all(d)).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=Wy(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 yt(),!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))}};wt();const VS="__SUPERDOC_V2_BROWSER_RUNTIME__";function UB(e=globalThis){const t=e[VS];return t&&typeof t=="object"?t:null}function VB(e={},t=globalThis){const n=UB(t)??{},r={...n,...e,vue:e.vue??n.vue??u5};return t[VS]=r,r}VB();var jB={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"},GB=0;function jS(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-${++GB}`}`,l=[];if(i)for(const[d,c]of Object.entries(i)){if(c==null)continue;const u=jB[d];u&&l.push(` ${u}: ${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[d,c]of Object.entries(s))c!=null&&l.push(` ${d}: ${c};`);return{className:a,css:l.length>0?`.${a} {
|