@idraw/core 1.0.0-alpha.2 → 1.0.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var iDrawCore=function(e){"use strict";const t="selectInGroup",i={CURSOR:"cursor",CHANGE:"change",CHANGING:"changing",RULER:"ruler",SCALE:"scale",CREATE:"create",CLEAR_CREATE:"clearCreate",SELECT_LAYOUT:"selectLayout",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:t,SNAP_TO_GRID:t,PATH_EDIT:"pathEdit",CLEAR_PATH_EDIT:"clearPathEdit",PATH_CREATE:"pathCreate",CLEAR_PATH_CREATE:"clearPathCreate",MODE_CHANGE:"modeChange"},o={};function r(e,t){if(1===t)return e;let i=1;const o=/^#[0-9a-f]{6,6}$/i;let r=e;if(o.test(e)?i=parseInt(e.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(e)&&(i=parseInt(e.substring(7,9).replace(/^#/,"0x")),r=e.substring(0,7)),i*=t,o.test(r)&&i>0&&i<1){const e=Math.max(0,Math.min(255,Math.ceil(256*i)));r=`${r.toUpperCase()}${e.toString(16).toUpperCase()}`}return r}function a(e){return(65536*(1+Math.random())|0).toString(16).substring(1)}function n(){return`${a()}${a()}-${a()}-${a()}-${a()}-${a()}${a()}${a()}`}function s(e,t){let i=0;for(let t=0;t<e.length;t++)i+=e.charCodeAt(t);return(i+t).toString(16).substring(0,4)}function l(e,t){const i=e.length,o=function(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i);return t}(t),r=Math.floor(i/2),a=e.substring(0,4).padStart(4,"0"),n=e.substring(0,4).padStart(4,"0");return`@assets/${s(i.toString(16).padStart(4,a),o).padStart(4,"0")}${s(e.substring(r-4,r).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-8,r-4).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-12,r-8).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-16,r-12).padStart(4,n),o).padStart(4,"0")}-${s(e.substring(r,r+4).padStart(4,n),o).padStart(4,"0")}${s(e.substring(r+4,r+8).padStart(4,n),o).padStart(4,"0")}${s(n.padStart(4,a).padStart(4,n),o)}`}function h(e){return/^@assets\/[0-9a-z-]{0,}$/.test(`${e}`)}function c(e){return function e(t){const i=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return t;if("Array"===i){const i=[];return t.forEach(t=>{i.push(e(t))}),i}if("Object"===i){const i={};Object.keys(t).forEach(o=>{i[o]=e(t[o])});return Object.getOwnPropertySymbols(t).forEach(o=>{i[o]=e(t[o])}),i}}(e)}function d(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}Object.keys(i).forEach(e=>{Object.defineProperty(o,e,{value:i[e],writable:!1})});const u={type(e,t){const i=d(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===d(e),json:e=>"Object"===d(e),function:e=>"Function"===d(e),asyncFunction:e=>"AsyncFunction"===d(e),boolean:e=>"Boolean"===d(e),string:e=>"String"===d(e),number:e=>"Number"===d(e),undefined:e=>"Undefined"===d(e),null:e=>"Null"===d(e),promise:e=>"Promise"===d(e)};const{Image:f}=window;function g(e){return new Promise((t,i)=>{const o=new f;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e})}async function m(e){const t=await(i=e,new Promise((e,t)=>{const o=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(o),r.onload=function(t){const i=t?.target?.result;e(i)},r.onerror=function(e){t(e)}}));var i;return await g(t)}async function p(e,t){e=e.replace(/&/gi,"&amp;");const i=await function(e,t){const{width:i,height:o}=t;return new Promise((t,r)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${o||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),n=new FileReader;n.readAsDataURL(a),n.onload=function(e){const i=e?.target?.result;t(i)},n.onerror=function(e){r(e)}})}(e,t);return await g(i)}function y(e){return"number"==typeof e&&e>=0}function x(e){return"number"==typeof e&&(e>0||e<=0)}function v(e){return x(e)}function w(e){return x(e)}function S(e){return y(e)}function b(e){return y(e)}function A(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function M(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}function I(e){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(e)}const C={positiveNum:y,data:function(e){return!!(Array(e?.materials)&&e?.materials.length>=0)},material:function(e){return!!e&&(I(e?.type)&&v(e?.x)&&w(e?.y)&&S(e?.w)&&b(e?.h))},layout:function(e){return!!e&&(v(e?.x)&&w(e?.y)&&S(e?.w)&&b(e?.h))},type:I,x:v,y:w,width:S,height:b,angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:x,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},strokeWidth:function(e){return y(e)||Array.isArray(e)&&y(e[0])&&y(e[1])&&y(e[2])&&y(e[3])},cornerRadius:function(e){return y(e)||Array.isArray(e)&&y(e[0])&&y(e[1])&&y(e[2])&&y(e[3])},color:function(e){return"string"==typeof(t=e)&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t));var t},imageSrc:function(e){return M(e)||A(e)},imageURL:A,imageBase64:M,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let i=document.createElement("div");i.innerHTML=e,i.children.length>0&&(t=!0),i=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return x(e)&&e>0},lineHeight:function(e){return x(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)}};class R{#e;#t;constructor(e,t){this.#e=e,this.#t={devicePixelRatio:1,offscreenCanvas:null,...t},this.$resetFont()}$undoPixelRatio(e){return e/this.#t.devicePixelRatio}$doPixelRatio(e){return this.#t.devicePixelRatio*e}$getContext(){return this.#e}$setContext(e){this.#e=e}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),this.#e.font=`${t.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return this.#t.offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:r}=e,{canvas:a}=this.#e;a.width=t*o,a.height=i*o,this.#t={...this.#t,devicePixelRatio:o},!0===r&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=this.#t,{width:t,height:i}=this.#e.canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return this.#e.canvas}get fillStyle(){return this.#e.fillStyle}set fillStyle(e){this.#e.fillStyle=e}get strokeStyle(){return this.#e.strokeStyle}set strokeStyle(e){this.#e.strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(this.#e.lineWidth)}set lineWidth(e){this.#e.lineWidth=this.$doPixelRatio(e)}get textAlign(){return this.#e.textAlign}set textAlign(e){this.#e.textAlign=e}get textBaseline(){return this.#e.textBaseline}set textBaseline(e){this.#e.textBaseline=e}get globalAlpha(){return this.#e.globalAlpha}set globalAlpha(e){this.#e.globalAlpha=e}get shadowColor(){return this.#e.shadowColor}set shadowColor(e){this.#e.shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(this.#e.shadowOffsetX)}set shadowOffsetX(e){this.#e.shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(this.#e.shadowOffsetY)}set shadowOffsetY(e){this.#e.shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(this.#e.shadowBlur)}set shadowBlur(e){this.#e.shadowBlur=this.$doPixelRatio(e)}get lineCap(){return this.#e.lineCap}set lineCap(e){this.#e.lineCap=e}get lineJoin(){return this.#e.lineJoin}set lineJoin(e){this.#e.lineJoin=e}get lineDashOffset(){return this.#e.lineDashOffset}set lineDashOffset(e){this.#e.lineDashOffset=e}get miterLimit(){return this.#e.miterLimit}set miterLimit(e){this.#e.miterLimit=e}get globalCompositeOperation(){return this.#e.globalCompositeOperation}set globalCompositeOperation(e){this.#e.globalCompositeOperation=e}fill(...e){return this.#e.fill(...e)}arc(e,t,i,o,r,a){return this.#e.arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,r,a)}rect(e,t,i,o){return this.#e.rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return this.#e.fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return this.#e.clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return this.#e.beginPath()}closePath(){return this.#e.closePath()}lineTo(e,t){return this.#e.lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return this.#e.moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,r){return this.#e.arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}bezierCurveTo(e,t,i,o,r,a){return this.#e.bezierCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}quadraticCurveTo(e,t,i,o){return this.#e.quadraticCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return this.#e.getLineDash()}setLineDash(e){const t=e.map(e=>this.$doPixelRatio(e));return this.#e.setLineDash(t)}stroke(e){return e?this.#e.stroke(e):this.#e.stroke()}translate(e,t){return this.#e.translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return this.#e.rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],r=e[3],a=e[4],n=e[e.length-4],s=e[e.length-3],l=e[e.length-2],h=e[e.length-1];return 9===e.length?this.#e.drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(n),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h)):this.#e.drawImage(t,this.$doPixelRatio(n),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h))}createPattern(e,t){return this.#e.createPattern(e,t)}measureText(e){return this.#e.measureText(e)}fillText(e,t,i,o){return void 0!==o?this.#e.fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):this.#e.fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?this.#e.strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):this.#e.strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){this.#e.save()}restore(){this.#e.restore()}scale(e,t){this.#e.scale(e,t)}circle(e,t,i,o,r,a,n,s){this.#e.ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,n,s)}ellipse(e,t,i,o,r,a,n,s){this.#e.ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,n,s)}isPointInPath(e,t){return this.#e.isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return this.#e.clip(...e)}setTransform(e,t,i,o,r,a){return this.#e.setTransform(e,t,i,o,r,a)}getTransform(){return this.#e.getTransform()}createLinearGradient(e,t,i,o){return this.#e.createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,r,a){return this.#e.createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(e,t,i){return this.#e.createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}}function E(e){const{width:t,height:i,devicePixelRatio:o}=e,r=new OffscreenCanvas(t*o,i*o),a=r.getContext("2d").canvas.getContext("2d");return new R(a,{devicePixelRatio:o,offscreenCanvas:r})}function z(e,t){const{width:i,height:o,devicePixelRatio:r}=t,a={width:i,height:o,devicePixelRatio:r},n=e.getContext("2d"),s=E(a),l=E(a),h=E(a),c=function(e){const{width:t,height:i,ctx:o,devicePixelRatio:r}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*r,e.height=i*r,a=e.getContext("2d")}return new R(a,e)}({ctx:n,...a}),d=E(a);return{underlayContext:h,viewContext:s,overlayContext:l,boardContext:c,tempContext:d,drawView:()=>{const{width:e,height:t}=s.$getSize();c.clearRect(0,0,e,t),c.drawImage(h.canvas,0,0,e,t),c.drawImage(s.canvas,0,0,e,t),c.drawImage(l.canvas,0,0,e,t),h.clearRect(0,0,e,t),s.clearRect(0,0,e,t),l.clearRect(0,0,e,t)}}}class L{#i;constructor(){this.#i=new Map}on(e,t){if(this.#i.has(e)){const i=this.#i.get(e)||[];i?.push(t),this.#i.set(e,i)}else this.#i.set(e,[t])}off(e,t){if(this.#i.has(e)){const i=this.#i.get(e);if(Array.isArray(i))for(let e=0;e<i?.length;e++)if(i[e]===t){i.splice(e,1);break}this.#i.set(e,i||[])}}trigger(e,t){const i=this.#i.get(e);return!!Array.isArray(i)&&(i.forEach(e=>{e(t)}),!0)}has(e){if(this.#i.has(e)){const t=this.#i.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#i.clear()}}function B(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}class k{#o;#r;#a;constructor(e){this.#r=c(e.defaultStorage),this.#o=this.#n(),this.#a=e.defaultStatic||{}}set(e,t){this.#o[e]=t}get(e){return this.#o[e]}setStatic(e,t){this.#a[e]=t}getStatic(e){return this.#a[e]}getSnapshot(e){return!0===e?.deepClone?c(this.#o):{...this.#o}}clear(){this.#o=this.#n()}destroy(){this.#o=null,this.#a=null}#n(){return c(this.#r)}}function P(e){const{activeStore:t}=e;return{scale:t?.scale,offsetTop:t?.offsetTop,offsetBottom:t?.offsetBottom,offsetLeft:t?.offsetLeft,offsetRight:t?.offsetRight}}function T(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:t?.width,height:t?.height,contextWidth:t?.contextWidth,contextHeight:t?.contextHeight}}function N(e,t){const i={};return e&&t.forEach(t=>{const o=e?.[t];"string"!=typeof o&&"number"!=typeof o||(i[t]=o)}),i}function D(e){return e/180*Math.PI}function $(e,t,i,o){const r=D(t||0);i&&(r>0||r<0)&&(e.translate(i.x,i.y),e.rotate(r),e.translate(-i.x,-i.y)),o(e),i&&(r>0||r<0)&&(e.translate(i.x,i.y),e.rotate(-r),e.translate(-i.x,-i.y))}function H(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function W(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return H({x:t,y:i,width:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,height:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function O(e,t){const i=t.x-e.x,o=t.y-e.y;if(0===i){if(o<0)return 0;if(o>0)return Math.PI}else if(0===o){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&o<0?Math.atan(Math.abs(i)/Math.abs(o)):i>0&&o>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):0}function V(e,t,i){let o=O(e,t)+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=function(e,t){const i=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===i?i:Math.sqrt(i)}(e,t);let a=0,n=0;return 0===o?(a=0,n=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,n=0-Math.cos(o)*r):o===Math.PI/2?(a=r,n=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,n=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,n=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,n=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,n=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,n=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,n=0-r),a+=e.x,n+=e.y,{x:a,y:n}}function Y(e,t){if(t?.length>0){let i=e.x,o=e.y;return t.forEach(e=>{const{x:t,y:r,width:a,height:n,angle:s=0}=e,l=V(H({x:t,y:r,width:a,height:n}),{x:i,y:o},D(s));i=l.x,o=l.y}),{x:i,y:o}}return e}function j(e,t,i){const{x:o,y:r,width:a,height:n}=e;let s={x:o,y:r},l={x:o+a,y:r},h={x:o+a,y:r+n},c={x:o,y:r+n};if(i&&(i>0||i<0)){const e=D(X(i));s=V(t,s,e),l=V(t,l,e),h=V(t,h,e),c=V(t,c,e)}return[s,l,h,c]}function G(e){const{angle:t=0}=e;return j(e,H(e),t)}function F(e,t,i){return[V(e,{x:t[0].x,y:t[0].y},i),V(e,{x:t[1].x,y:t[1].y},i),V(e,{x:t[2].x,y:t[2].y},i),V(e,{x:t[3].x,y:t[3].y},i)]}function X(e){if(!(e>0||e<0)||0===e||360===e)return 0;let t=e%360;return t<0?t+=360:360===e&&(t=0),t}function Q(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach(e=>{"string"==typeof e.id&&e.id?i.includes(e.id)?(t=!1,console.warn(`Duplicate ids: ${e.id}`)):i.push(e.id):(t=!1,console.warn("Material missing id",e)),"group"===e.type&&(t=Q(e?.children))})}return t}function U(e,t){const i={x:0,y:0,width:0,height:0};e.forEach(e=>{const t={x:e.x,y:e.y,width:e.width,height:e.height,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=G(t);if(4===e.length){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...i),t.y=Math.min(...o),t.width=Math.abs(Math.max(...i)-Math.min(...i)),t.height=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),r=Math.min(t.y,i.y),a=Math.max(t.x+t.width,i.x+i.width),n=Math.max(t.y+t.height,i.y+i.height);i.x=o,i.y=r,i.width=Math.abs(a-o),i.height=Math.abs(n-r)}),t?.extend&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.width,contextHeight:i.height};return t?.viewWidth&&t?.viewHeight&&t?.viewWidth>0&&t?.viewHeight>0&&(t.viewWidth>i.x+i.width&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.height&&(o.contextHeight=t.viewHeight-i.y)),o}function Z(e,t){const i=[];let o=null;const r=[];return function e(t,a){let n=null;for(let s=0;s<a.length;s++){const l=a[s];if(r.push(s),l.id===t){n=l,o=l;break}if(!n&&"group"===l.type){i.push(l);const o=e(t,l?.children||[]);if(o?.id===t){n=o;break}i.pop(),r.pop()}}return n}(e,t),{groupQueue:i,material:o,position:r}}function J(e,t){const i=[];let o=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const r=o[t[e]];if("group"!==r?.type||!Array.isArray(r?.children))return null;i.push(r),o=r.children}return i}function K(e){const{id:t,x:i,y:o,width:r,height:a,angle:n=0}=e;return{id:t,x:i,y:o,width:r,height:a,angle:n}}function q(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const r=o[e[t]];if(t<e.length-1&&"group"===r?.type)o=r.children;else{if(t!==e.length-1)break;i=r}}return i}function _(e,t){const i=[];let o=!1;const r=t=>{for(let a=0;a<t.length&&!0!==o;a++){i.push(a);const n=t[a];if(n.id===e){o=!0;break}if("group"===n.type&&r(n?.children||[]),o)break;i.pop()}};return r(t),i}function ee(e){const{x:t,y:i,height:o,width:r}=e;return[{x:t,y:i},{x:t+r,y:i},{x:t+r,y:i+o},{x:t,y:i+o}]}function te(e){const{x:t,y:i,width:o,height:r,angle:a=0}=e;return 0===a?ee(e):j(e,H({x:t,y:i,width:o,height:r}),a)}function ie(e,t){const{groupQueue:i}=t;if(!(i.length>0))return[te(e)];const o=function(e){const t=[];let i=0,o=0;const r=[],a=[...e];for(let e=0;e<a.length;e++){const{x:n,y:s,width:l,height:h,angle:c=0}=a[e];let d;if(i+=n,o+=s,0===e){const e={x:i,y:o,width:l,height:h};d=te({x:n,y:s,width:l,height:h,angle:c}),r.push({center:H(e),angle:c,radian:D(c)})}else{d=ee({x:i,y:o,width:l,height:h});for(let e=0;e<r.length;e++){const{center:t,radian:i}=r[e];d=F(t,d,i)}const e=W(d);(c>0||c<0)&&(d=F(e,d,D(c))),r.push({center:e,angle:c,radian:D(c)})}t.push(d)}return t}([...i,e]);return o}function oe(e,t){return ie(e,t).pop()||null}function re(e,t){const{viewScaleInfo:i}=t,{id:o,x:r,y:a,width:n,height:s,angle:l}=e,{scale:h=1,offsetTop:c=0,offsetLeft:d=0}=i;return{id:o,x:r*h+d,y:a*h+c,width:n*h,height:s*h,angle:l}}function ae(e,t){const{viewScaleInfo:i}=t,{x:o,y:r}=e,{scale:a,offsetTop:n,offsetLeft:s}=i;return{x:o*a+s,y:r*a+n}}function ne(e,t){const{viewScaleInfo:i}=t,{x:o,y:r}=e,{scale:a,offsetTop:n,offsetLeft:s}=i;return{x:(o-s)/a,y:(r-n)/a}}function se(e,t){const{context2d:i,material:o,viewScaleInfo:r}=t,{angle:a=0}=o,{x:n,y:s,width:l,height:h}=re(o,{viewScaleInfo:r}),c=G({x:n,y:s,width:l,height:h,angle:a});if(c.length>=2){i.beginPath(),i.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e++)i.lineTo(c[e].x,c[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function le(e,t,i){return function(e,t){const i=[t[0].x,t[1].x,t[2].x,t[3].x],o=[t[0].y,t[1].y,t[2].y,t[3].y],r=Math.min(...i),a=Math.max(...i),n=Math.min(...o),s=Math.max(...o);if(e.x>r&&e.x<a&&e.y>n&&e.y<s)return!0;return!1}(e,te(t))}function he(e,t){const{groupQueue:i}=t,o=oe(e,{groupQueue:i}),r=B(o[0],o[1]),a=B(o[1],o[2]),n=B(o[2],o[3]),s=B(o[3],o[0]),l=o[0],h=o[1],c=o[2],d=o[3],u=Math.max(l.x,h.x,c.x,d.x),f=Math.max(l.y,h.y,c.y,d.y);return{center:{x:(u+Math.min(l.x,h.x,c.x,d.x))/2,y:(f+Math.min(l.y,h.y,c.y,d.y))/2},topLeft:l,topRight:h,bottomLeft:d,bottomRight:c,top:r,right:a,left:s,bottom:n}}function ce(e){const t=Math.max(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),i=Math.max(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),o=Math.min(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),r=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},n={x:o,y:r},s={x:t,y:r},l={x:t,y:i},h={x:o,y:i},c=B(n,s),d=B(h,l),u=B(n,h);return{center:a,topLeft:n,topRight:s,bottomLeft:h,bottomRight:l,top:c,right:B(s,l),left:u,bottom:d}}function de(e){let t="";return e.forEach(e=>{t+=e.type+e.params?.join?.(" ")}),t}function ue(e,t){let i=2;return void 0!==t?.decimalPlaces&&t?.decimalPlaces>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}const fe="Text",ge="#787878",me=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(`<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200" fill="${ge}"><path d="M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zM338 304c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64z m513.9 437.1c-1.4 1.2-3.3 1.9-5.2 1.9H177.2c-4.4 0-8-3.6-8-8 0-1.9 0.7-3.7 1.9-5.2l170.3-202c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l99.4 118 158.1-187.5c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l229.6 271.6c2.6 3.3 2.2 8.4-1.2 11.2z" ></path></svg>`)}`;function pe(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:ge,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:fe,fontSize:12,fontFamily:"system-ui",fontWeight:"normal",fontStyle:"normal",textAnchor:"start",textDecoration:"none",letterSpacing:"normal",wordSpacing:"normal",writingMode:"horizontal-tb",textAlign:"left",verticalAlign:"top",href:me}}function ye(e,t="",i={},o){return Object.keys(e).forEach(r=>{const a=t?`${t}${function(e){return/^\d+$/.test(e)&&!isNaN(Number(e))}(r)?`[${r}]`:`.${r}`}`:r;if(!o?.ignorePaths?.includes(a)){const t=e[r];!function(e){return"object"==typeof e&&null!==e&&!(e instanceof Date)||Array.isArray(e)}(t)?i[a]=t:ye(t,(Array.isArray(t),a),i,o)}}),i}function xe(e,t){return"object"!=typeof e||null===e?{"":e}:ye(e,"",{},t)}function ve(e){return xe(e,{ignorePaths:["children"]})}function we(e){return xe(e)}function Se(e){return xe(e)}function be(e){return Array.isArray(e)?[...e]:e.split(/\.|\[|\]/).filter(e=>""!==e)}function Ae(e,t,i){if(!t)return;const o=be(t);let r=e;for(const e of o){if(null==r)return i;r=r[e]}return void 0!==r?r:i}function Me(e,t,i){const o=be(t);if(0===o.length)return e;let r=e;if(r)for(let e=0;e<o.length;e++){const t=o[e];if(e===o.length-1){r[t]=i;break}if(r&&(void 0===r?.[t]||"object"!=typeof r?.[t]||null===r?.[t])){const i=o[e+1],a=/^\d+$/.test(i);r[t]=a?[]:{}}r=r?.[t]}return e}function Ie(e,t){const i=be(t);if(0===i.length)return e;let o=e;if(o)for(let e=0;e<i.length;e++){const t=i[e];if(e===i.length-1){delete o[t];break}if(o&&(void 0===o?.[t]||"object"!=typeof o?.[t]||null===o?.[t])){const r=i[e+1],a=/^\d+$/.test(r);o[t]=a?[]:{}}o=o?.[t]}return e}const Ce=e=>ue(e,{decimalPlaces:4});function Re(e,t){const i={},o={},r={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:e.id,before:null,after:null}},{xRatio:a,yRatio:n,maxRatio:s}=t,l=(a+n)/2,{strokeWidth:h,cornerRadius:c,strokeDasharray:d,shadowOffsetX:u,shadowOffsetY:f,shadowBlur:g}=e;if("number"==typeof h)e.strokeWidth=Ce(h*l),i.strokeWidth=h,o.strokeWidth=e.strokeWidth;else if(Array.isArray(e.strokeWidth)){const t=h;e.strokeWidth=[Ce(t[0]*n),Ce(t[1]*a),Ce(t[2]*n),Ce(t[3]*a)],i.strokeWidth=[...t],o.strokeWidth=[...h]}if("number"==typeof c)e.cornerRadius=Ce(c*l),i.cornerRadius=c,o.cornerRadius=e.cornerRadius;else if(Array.isArray(e.cornerRadius)){const t=c;e.cornerRadius=[t[0]*a,t[1]*a,t[2]*n,t[3]*n],i.cornerRadius=[...t],o.cornerRadius=[...c]}return Array.isArray(d)&&(d.forEach((t,i)=>{e.strokeDasharray[i]=Ce(t*s)}),i.strokeDasharray=[...d],o.strokeDasharray=[...e.strokeDasharray]),"number"==typeof u&&(e.shadowOffsetX=Ce(u*s),i.shadowOffsetX=u,o.shadowOffsetX=e.shadowOffsetX),"number"==typeof f&&(e.shadowOffsetY=Ce(f*s),i.shadowOffsetY=f,o.shadowOffsetY=e.shadowOffsetY),"number"==typeof g&&(e.shadowBlur=Ce(g*s),i.shadowBlur=g,o.shadowBlur=e.shadowBlur),r.content.before=ve(i),r.content.after=ve(o),r}function Ee(e,t,i){const{type:o,id:r}=e,a=function(e,t){const{xRatio:i,yRatio:o}=t,{id:r,x:a,y:n,width:s,height:l}=e;e.x=Ce(a*i),e.y=Ce(n*o),e.width=Ce(s*i),e.height=Ce(l*o);const h={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:r,before:{x:a,y:n,width:s,height:l},after:{x:e.x,y:e.y,width:e.width,height:e.height}}},c=Re(e,t);return h.content.before={...h.content.before,...c.content.before},h.content.after={...h.content.after,...c.content.after},h}(e,t),n={...a.content.before,id:r},s={...a.content.after,id:r};if(i?.content.before.push(n),i?.content.after.push(s),"circle"===o);else if("text"===o){const i=function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:r,lineHeight:a}=e,n=(i+o)/2,s={},l={};return r&&r>0&&(e.fontSize=Ce(r*n),s.fontSize=r,l.fontSize=e.fontSize),a&&a>0&&(e.lineHeight=Ce(a*n),s.lineHeight=a,l.lineHeight=e.lineHeight),{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:e.id,before:s,after:l}}}(e,t);Object.keys(i.content.before||{}).forEach(e=>{n[e]=i.content.before?.[e]}),Object.keys(i.content.after||{}).forEach(e=>{s[e]=i.content.after?.[e]})}else"image"===o||"svgCode"===o||"foreignObject"===o||"path"===o||"group"===o&&Array.isArray(e.children)&&e.children.forEach(e=>{Ee(e,t,i)})}function ze(e,t,i){const o={type:"resizeMaterials",time:Date.now(),content:{method:"modifyMaterials",before:[],after:[]}},r=e.id,a=e.x,n=e.y,s=e.width,l=e.height,h=u.number(t.x)?t.x:e.x,c=u.number(t.y)?t.y:e.y,d=(t.width&&t.width>0?t.width:e.width)||0,f=(t.height&&t.height>0?t.height:e.height)||0,g={id:r,x:a,y:n,width:s,height:l},m={id:r,x:h,y:c,width:d,height:f};if("deepResize"===i?.resizeEffect){o.content.before.push(g),o.content.after.push(m);const t=d/e.width,i=f/e.height;if(t===i&&1===t)return o;const r=Math.min(t,i),a=Math.max(t,i);e.width=d,e.height=f;const n={xRatio:t,yRatio:i,minRatio:r,maxRatio:a};"group"===e.type&&Array.isArray(e.children)&&e.children.forEach(e=>{Ee(e,n,o)});const s=Re(e,n);return Object.keys(s.content.before||{}).forEach(e=>{g[e]=s.content.before?.[e]}),Object.keys(s.content.after||{}).forEach(e=>{m[e]=s.content.after?.[e]}),o}if("fixed"===i?.resizeEffect){o.content.before.push(g),o.content.after.push(m);const t=h-e.x,i=c-e.y,r=d-e.width;return function(e,t,i){if("group"!==e.type||!Array.isArray(e.children))return;const{moveX:o,moveY:r,moveH:a,moveW:n}=t;let s=0,l=0,h=!1;0===o&&0===r||0===a&&0===n||(h=!0,s=-o,l=-r),!0===h&&e.children.forEach(e=>{const{id:t,x:o,y:r}=e,a=o+s,n=r+l,h={id:t,x:o,y:r},c={id:t,x:a,y:n};e.x=a,e.y=n,i?.content.before.push(h),i?.content.after.push(c)})}(e,{moveX:t,moveY:i,moveH:f-e.height,moveW:r},o),e.width=d,e.height=f,e.x=h,e.y=c,o}return e.width=d,e.height=f,e.x=h,e.y=c,o.content.before.push(g),o.content.after.push(m),o}function Le(e,t,i){const o=function(e,t){let i=0,o=0,r=200,a=200;if(t){const{viewScaleInfo:n,viewSizeInfo:s}=t,{scale:l,offsetLeft:h,offsetTop:c}=n,{width:d,height:u}=s,f=d/4,g=u/4;r=200>=f?f/l:200/l,a=200>=g?g/l:200/l,["circle","svgCode","image"].includes(e)?r=a=Math.max(r,a):"text"===e&&(a=r/4*2),i=(0-h+d/2-r*l/2)/l,o=(0-c+u/2-a*l/2)/l}return{x:i,y:o,width:r,height:a}}(e,i);let r={};if("rect"===e)r={fill:pe().fill};else if("circle"===e)r={fill:pe().fill,cx:200,cy:200,r:100};else if("text"===e)r=function(e){const t=pe();return{text:fe,fill:t.fill,fontFamily:t.fontFamily,fontWeight:t.fontWeight,fontSize:e.width/4,textAlign:"center",verticalAlign:"middle"}}(o);else if("svgCode"===e)r={code:`<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="${ge}"></path></svg>`};else if("image"===e)r={href:me};else if("group"===e){r={children:[],fill:pe().fill,overflow:"hidden"};const e=t;Array.isArray(e.children)&&e.children.length>0&&(r.children=[...e.children])}return{id:n(),type:e,...o,...r,...t}}function Be(e,t,i){let o=!1;if(1===t.length){const r=t[0];i.splice(r,0,e),o=!0}else if(t.length>1){let r=i;for(let i=0;i<t.length;i++){const a=r[t[i]];if(i===t.length-1){const a=t[i];r.splice(a,0,e),o=!0}else{if(!(i<t.length-1&&"group"===a.type))break;r=a.children}}}return o}function ke(e,t){let i=!1;if(1===e.length){const o=e[0];t.splice(o,1),i=!0}else if(e.length>1){let o=t;for(let t=0;t<e.length;t++){const r=o[e[t]];if(t===e.length-1){const r=e[t];o.splice(r,1),i=!0}else{if(!(t<e.length-1&&"group"===r.type))break;o=r.children}}}return i}function Pe(e,t,i){const o=ve(t),r=["id","type"],a=Object.keys(o);if(a.forEach(t=>{if(!r.includes(t)){const i=o[t];Ie(e,t),void 0!==i&&Me(e,t,i)}}),!0===i?.onlyUpdateContent){const t=ve(e);Object.keys(t).forEach(t=>{r.includes(t)||a.includes(t)||Ie(e,t)})}return e.fill&&(e.fill=function(e){if(Array.isArray(e?.stops)){const t=[],i=e?.stops;for(let e=i.length-1;e>=0;e--){const o=i[e];o.color&&o.offset>=0||t.push(e)}t.forEach(e=>{i.splice(e,1)})}return e}(e.fill)),e}function Te(e,t,i){let o=null;for(let r=0;r<i.length;r++){const a=i[r];if(a.id===e){"group"===a.type&&a.operations?.resizeEffect&&ze(a,{...t},{resizeEffect:a.operations?.resizeEffect}),Pe(a,t),o=a;break}"group"===a.type&&(o=Te(e,t,a?.children||[]))}return o}function Ne(e,t,i,o){const r=q(e,i);return r&&("group"===r.type&&r.operations?.resizeEffect&&ze(r,{...t},{resizeEffect:r.operations?.resizeEffect}),Pe(r,t,o)),r}const De=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function $e(e){return[e,...De].join(", ")}function He(e,t,i){let o=t.x-e.x,r=t.y-e.y;const a=[];if(i.forEach(e=>{const{x:t,y:i,width:o,height:r,angle:n=0}=e;a.push({x:t,y:i,width:o,height:r,angle:0-n})}),i?.length>0){const i=Y(e,a),n=Y(t,a);o=n.x-i.x,r=n.y-i.y}return{moveX:o,moveY:r}}function We(e,t,i,o,r,a,n,s){const l=[];l.push({x:e,y:t}),l.push({x:n,y:s});const h=Ye(3*(3*i-e-3*r+n),6*(e-2*i+r),3*(i-e));for(const c of h)if(c>0&&c<1){const h=je(c,e,i,r,n),d=je(c,t,o,a,s);l.push({x:h,y:d})}const c=Ye(3*(3*o-t-3*a+s),6*(t-2*o+a),3*(o-t));for(const h of c)if(h>0&&h<1){const c=je(h,e,i,r,n),d=je(h,t,o,a,s);l.push({x:c,y:d})}return l}function Oe(e,t,i,o,r,a){const n=[];n.push({x:e,y:t}),n.push({x:r,y:a});const s=e-2*i+r;if(0!==s){const l=-(2*(i-e))/(2*s);if(l>0&&l<1){const s=Ge(l,e,i,r),h=Ge(l,t,o,a);n.push({x:s,y:h})}}const l=t-2*o+a;if(0!==l){const s=-(2*(o-t))/(2*l);if(s>0&&s<1){const l=Ge(s,e,i,r),h=Ge(s,t,o,a);n.push({x:l,y:h})}}return n}function Ve(e,t,i,o,r,a,n,s,l){const h=[],c=r*Math.PI/180,d=Math.cos(c),u=Math.sin(c),f=(e+s)/2,g=(t+l)/2,m=(e-s)/2,p=(t-l)/2,y=d*m+u*p,x=-u*m+d*p;let v=i,w=o;const S=y*y,b=x*x,A=S/(i*i)+b/(o*o);A>1&&(v=Math.sqrt(A)*i,w=Math.sqrt(A)*o);const M=a===n?-1:1,I=Math.max(0,v*v*w*w-v*v*b-w*w*S),C=v*v*b+w*w*S;let R=M*Math.sqrt(I/C);isNaN(R)&&(R=0);const E=R*(v*x/w),z=R*(-w*y/v),L=d*E-u*z+f,B=u*E+d*z+g,k=Math.atan2((x-z)/w,(y-E)/v);let P=Math.atan2((-x-z)/w,(-y-E)/v)-k;0===n&&P>0?P-=2*Math.PI:1===n&&P<0&&(P+=2*Math.PI);for(let e=0;e<=100;e++){const t=k+e/100*P,i=L+v*Math.cos(t)*d-w*Math.sin(t)*u,o=B+v*Math.cos(t)*u+w*Math.sin(t)*d;h.push({x:i,y:o})}return h}function Ye(e,t,i){const o=[];if(0===e){if(0!==t){const e=-i/t;e>=0&&e<=1&&o.push(e)}return o}const r=t*t-4*e*i;if(r>0){const i=Math.sqrt(r),a=(-t+i)/(2*e),n=(-t-i)/(2*e);a>=0&&a<=1&&o.push(a),n>=0&&n<=1&&o.push(n)}else if(0===r){const i=-t/(2*e);i>=0&&i<=1&&o.push(i)}return o}function je(e,t,i,o,r){const a=1-e;return a*a*a*t+3*a*a*e*i+3*a*e*e*o+e*e*e*r}function Ge(e,t,i,o){const r=1-e;return r*r*t+2*r*e*i+e*e*o}const Fe=()=>Math.random().toString(36).substring(2);function Xe(){return`${Fe()}${Fe()}`.substring(0,16)}function Qe(e,t,i){const o=[];return e.forEach(e=>{const r=function(e,t,i){const{type:o}=e,r=[...e.params],a=e.id;let n={id:a};if(e.start&&e.end){const o={...e.start},r={...e.end};o.x+=t,o.y+=i,r.x+=t,r.y+=i,n={id:a,start:o,end:r}}switch(o){case"M":case"L":case"T":return r[0]+=t,r[1]+=i,{type:o,params:r,...n};case"H":return r[0]+=t,{type:o,params:r,...n};case"V":return r[0]+=i,{type:o,params:r,...n};case"C":return r[0]+=t,r[1]+=i,r[2]+=t,r[3]+=i,r[4]+=t,r[5]+=i,{type:o,params:r,...n};case"S":case"Q":return r[0]+=t,r[1]+=i,r[2]+=t,r[3]+=i,{type:o,params:r,...n};case"A":return r[5]+=t,r[6]+=i,{type:o,params:r,...n};default:return{type:o,params:r,...n}}}(e,t,i);o.push(r)}),o}function Ue(e,t,i){return e.map(e=>{const{id:o,type:r,params:a}=e,n=[];let s={id:o};if(e.start&&e.end){const r={...e.start},a={...e.end};r.x*=t,r.y*=i,a.x*=t,a.y*=i,s={id:o,start:r,end:a}}switch(r.toUpperCase()){case"M":case"L":case"T":for(let e=0;e<a.length;e+=2)n.push(a[e]*t,a[e+1]*i);break;case"C":for(let e=0;e<a.length;e+=6)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i,a[e+4]*t,a[e+5]*i);break;case"S":for(let e=0;e<a.length;e+=4)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i);break;case"Q":for(let e=0;e<a.length;e+=4)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i);break;case"H":a.forEach(e=>n.push(e*t));break;case"V":a.forEach(e=>n.push(e*i));break;case"A":for(let e=0;e<a.length;e+=7)n.push(a[e]*t,a[e+1]*i,a[e+2],a[e+3],a[e+4],a[e+5]*t,a[e+6]*i);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let e=0;e<a.length;e++){const o="a"===r&&(e%7==0||e%7==5)||"h"===r||"v"!==r&&e%2==0;n.push(a[e]*(o?t:i))}break;default:return{type:r,params:[...a],...s}}return{type:r,params:n,...s}})}function Ze(e){const t=[];let i={x:0,y:0},o={x:0,y:0},r=null;for(const a of e){const e=a.type,n=a.params,s=e===e.toLowerCase(),l=e.toUpperCase(),h=a.id;switch(l){case"M":{const[e,a]=n,l=s?{x:i.x+e,y:i.y+a}:{x:e,y:a};t.push({id:h,type:"M",params:[l.x,l.y],start:{x:e,y:a},end:{x:e,y:a}}),i=l,o=l,r=null;break}case"L":{const[e,o]=n,a=s?{x:i.x+e,y:i.y+o}:{x:e,y:o};t.push({id:h,type:"L",params:[a.x,a.y],start:{...i},end:{...a}}),i=a,r=null;break}case"H":{const[e]=n,o=s?{x:i.x+e,y:i.y}:{x:e,y:i.y};t.push({id:h,type:"L",params:[o.x,o.y],start:{...i},end:{...o}}),i=o,r=null;break}case"V":{const[e]=n,o=s?{x:i.x,y:i.y+e}:{x:i.x,y:e};t.push({id:h,type:"L",params:[o.x,o.y],start:{...i},end:{...o}}),i=o,r=null;break}case"C":{const[e,o,a,l,c,d]=n,u=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},f=s?{x:i.x+a,y:i.y+l}:{x:a,y:l},g=s?{x:i.x+c,y:i.y+d}:{x:c,y:d};t.push({id:h,type:"C",params:[u.x,u.y,f.x,f.y,g.x,g.y],start:{...i},end:{...g}}),i=g,r=f;break}case"S":{const[e,o,a,l]=n,c=r?{x:2*i.x-r.x,y:2*i.y-r.y}:i,d=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},u=s?{x:i.x+a,y:i.y+l}:{x:a,y:l};t.push({id:h,type:"C",params:[c.x,c.y,d.x,d.y,u.x,u.y],start:{...i},end:{...u}}),i=u,r=d;break}case"Q":{const[e,o,a,l]=n,c=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},d=s?{x:i.x+a,y:i.y+l}:{x:a,y:l};t.push({id:h,type:"C",params:[i.x+2/3*(c.x-i.x),i.y+2/3*(c.y-i.y),d.x+2/3*(c.x-d.x),d.y+2/3*(c.y-d.y),d.x,d.y],start:{...i},end:{...d}}),i=d,r=c;break}case"T":{const[e,o]=n,a=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},l=r?{x:2*i.x-r.x,y:2*i.y-r.y}:i;t.push({id:h,type:"C",params:[i.x+2/3*(l.x-i.x),i.y+2/3*(l.y-i.y),a.x+2/3*(l.x-a.x),a.y+2/3*(l.y-a.y),a.x,a.y],start:{...i},end:{...a}}),i=a,r=l;break}case"A":{const[e,o,a,l,c,d,u]=n,f=s?{x:i.x+d,y:i.y+u}:{x:d,y:u};t.push({id:h,type:"A",params:[e,o,a,l,c,f.x,f.y],start:{...i},end:{...f}}),i=f,r=null;break}case"Z":t.push({id:h,type:"Z",params:[],start:{...i},end:{...o}}),i=o,r=null;break;default:throw new Error(`Unsupported command: ${e}`)}}return t}function Je(e,t){const i=t.x,o=t.y,r=e.x+(i-e.x)/3,a=e.y+(o-e.y)/3,n=e.x+2*(i-e.x)/3,s=e.y+2*(o-e.y)/3;return{id:Xe(),type:"C",params:[r,a,n,s,i,o]}}function Ke(e){let{x:t,y:i,width:o,height:r,...a}=e;const{commands:n}=a,s=function(e){let t=1/0,i=1/0,o=-1/0,r=-1/0,a={x:0,y:0},n={x:0,y:0},s=null;const l=e=>{t=Math.min(t,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),r=Math.max(r,e.y)};for(const t of e){const{type:e,params:i}=t,o=e===e.toLowerCase();switch(e.toLowerCase()){case"m":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];o&&(t+=a.x,r+=a.y),0===e&&(n={x:t,y:r}),a={x:t,y:r},l(a)}s=null;break;case"l":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];o&&(t+=a.x,r+=a.y),a={x:t,y:r},l(a)}s=null;break;case"h":for(let e=0;e<i.length;e++){let t=i[e];o&&(t+=a.x),a={x:t,y:a.y},l(a)}s=null;break;case"v":for(let e=0;e<i.length;e++){let t=i[e];o&&(t+=a.y),a={x:a.x,y:t},l(a)}s=null;break;case"c":if(i.length>=6)for(let e=0;e<i.length;e+=6){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3],c=i[e+4],d=i[e+5];o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y,c+=a.x,d+=a.y),s={x:n,y:h},We(a.x,a.y,t,r,n,h,c,d).forEach(l),l({x:c,y:d}),a={x:c,y:d}}break;case"s":if(i.length>=4)for(let e=0;e<i.length;e+=4){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3];const c=s?2*a.x-s.x:a.x,d=s?2*a.y-s.y:a.y;o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y),s={x:t,y:r},We(a.x,a.y,c,d,t,r,n,h).forEach(l),l({x:n,y:h}),a={x:n,y:h}}break;case"q":if(i.length>=4)for(let e=0;e<i.length;e+=4){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3];o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y),s={x:t,y:r},Oe(a.x,a.y,t,r,n,h).forEach(l),l({x:n,y:h}),a={x:n,y:h}}break;case"t":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];const n=s?2*a.x-s.x:a.x,h=s?2*a.y-s.y:a.y;o&&(t+=a.x,r+=a.y),s={x:n,y:h},Oe(a.x,a.y,n,h,t,r).forEach(l),l({x:t,y:r}),a={x:t,y:r}}break;case"a":if(i.length>=7)for(let e=0;e<i.length;e+=7){const t=Math.abs(i[e]),r=Math.abs(i[e+1]),n=i[e+2],h=i[e+3],c=i[e+4];let d=i[e+5],u=i[e+6];o&&(d+=a.x,u+=a.y),Ve(a.x,a.y,t,r,n,h,c,d,u).forEach(l),a={x:d,y:u},s=null}break;case"z":a={...n},l(a),s=null}}return t===1/0&&(t=i=o=r=0),{minX:t,minY:i,maxX:o,maxY:r,width:o-t,height:r-i,start:{x:t,y:i},end:{x:o,y:r}}}(n),{minX:l,minY:h,maxX:c,maxY:d}=s;return t+=l,i+=h,o=Math.abs(c-l),r=Math.abs(d-h),0===l&&0===h||(a.commands=Qe(n,0-l,0-h)),{...e,x:t,y:i,width:o,height:r,...a}}const qe={className:"class"},_e=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"];function et(e,t){t.forEach(t=>{if(!t)return;t.trim().split(" ").forEach(t=>{t&&!e.classList.contains(t)&&e.classList.add(t)})})}function tt(e,t){t.forEach(t=>{t&&e.classList.contains(t)&&e.classList.remove(t)})}function it(e,t){return Object.keys(t).forEach(i=>{const o=t[i];e.style[i]=((e,t)=>"number"==typeof t&&_e.includes(e)?`${t}px`:t)(i,o)}),e}function ot(e,t,i){const{children:o,...r}=t||{},a=i||o;return function(e,t){Object.entries(t).forEach(([t,i])=>{const o=qe[t]?qe[t]:t,r=o.replace(/([A-Z])/g,"-$1").toLowerCase(),a=i;if("style"===o)u.json(i)?it(e,i):"string"==typeof i&&e.setAttribute(r,i);else if("class"===o&&"string"==typeof i)et(e,i.split(" "));else{let t=a;null==t&&(t=""),e.setAttribute(r,String(t))}})}(e,r||{}),Array.isArray(a)?a?.forEach(t=>{(t instanceof Element||"string"==typeof t)&&e.append(t)}):(a instanceof Element||"string"==typeof a)&&e.append(a),e}function rt(e,t,i){return ot(document.createElement(e),t,i)}function at(e){const t=function(e){return e.replace(/<(script|iframe|object|embed)\b[^<]*(?:(?!<\/\1>)<[^<]*)*<\/\1>/gi,"")}(e),i=document.createElement("template");i.innerHTML=t.trim();return i.content.firstElementChild}function nt(e){const t=e.getBoundingClientRect(),i=window.pageXOffset||document.documentElement.scrollLeft,o=window.pageYOffset||document.documentElement.scrollTop;return{pageX:t.left+i,pageY:t.top+o,width:t.width,height:t.height}}const st=(e,t,i)=>{let o=e;const r=Object.keys(i),a=()=>{if(!o)return!1;for(let e=0;e<r.length;e++){const t=r[e],a=i[t];if("string"==typeof t&&t&&"string"==typeof a&&a){if("className"===t&&o?.classList.contains(a))continue;if(o.getAttribute(t)===a)continue;return!1}if("string"==typeof t&&t&&"boolean"==typeof a){if(o.hasAttribute(t)&&!0===a)continue;return!1}}return!0};for(;o;){if(a())return o;if(t===o)return null;if(!t.contains(o))return null;o=o.parentElement}return null};function lt(e,t){const{$root:i,rootClassName:o}=t;if(!i)return!1;const r=e.target;return!!st(r,i,{className:o})}const ht=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"],ct=(e,t)=>ht.includes(e)?`${t}px`:t;function dt(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function ut(e,t){const i=[],o=[];for(const r in e){let a=e[r];if("number"==typeof a&&(a=ct(r,a)),r.startsWith("@"))o.push(`${r} { ${ut(a,t)} }`);else if(r.startsWith("&")||r.startsWith(".")||r.startsWith("#")){const e=r.startsWith("&")?r.replace("&",t):`${t} ${r}`;o.push(ut(a,e))}else i.push(`${dt(r)}: ${a};`)}return[i.length?`${t} { ${i.join(" ")} }`:"",...o].filter(Boolean).join("\n")}const ft="data-idraw-style-id",gt={};function mt(e){const{styles:t,rootClassName:i,type:o}=e,r=ut(t,`.${i}`);if("element"===o){const e=document.createElement("style");e.setAttribute(ft,i),e.textContent=r;(document.head||document.body).appendChild(e)}else{const e=new CSSStyleSheet;e.replaceSync(r),gt[i]=e,document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]}}function pt(e){const{rootClassName:t,type:i}=e;if("element"===i){const e=document.querySelector(`[${ft}="${t}"]`);e?.remove()}else if(gt[t]){const e=gt[t],i=document.adoptedStyleSheets.filter(t=>t!==e);document.adoptedStyleSheets=i}}const yt="data-idraw-valid-watch";function xt(e,t,i){if("string"==typeof t)return t;const{viewMaterialSize:o,viewScaleInfo:a,opacity:n=1}=i,{x:s,y:l}=o,{scale:h}=a;if("linear-gradient"===t?.type){const{start:i,end:o,stops:a}=t,c={x:s+i.x*h,y:l+i.y*h},d={x:s+o.x*h,y:l+o.y*h},u=e.createLinearGradient(c.x,c.y,d.x,d.y);return a.forEach(e=>{e.offset>=0&&e.color&&u.addColorStop(e.offset,r(e.color,n))}),u}if("radial-gradient"===t?.type){const{inner:i,outer:o,stops:a}=t,c={x:s+i.x*h,y:l+i.y*h,radius:i.radius*h},d={x:s+o.x*h,y:l+o.y*h,radius:o.radius*h},u=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return a.forEach(e=>{u.addColorStop(e.offset,r(e.color,n))}),u}return"#000000"}let vt=pe();function wt(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r,calculator:a}=i,{opacity:n,fill:s,fillOpacity:l,fillRule:h,stroke:c,strokeWidth:d,strokeOpacity:u,strokeLinecap:f,strokeLinejoin:g,strokeDasharray:m,strokeDashoffset:p,strokeMiterlimit:y}={...vt,...t},{scale:x,offsetLeft:v,offsetTop:w}=o,{devicePixelRatio:S}=r,b=a.getVirtualItem(t.id),{commands:A,worldCenter:M}=b,{width:I,height:R}=t;let E=A;E=Ue(E,x,x),E=Qe(E,(v+(M.x-I/2)*x)*S,(w+(M.y-R/2)*x)*S);const z=e.globalAlpha,L=de(E),B=new Path2D(L);!function(e,t,i){const{...o}=t,{viewScaleInfo:r,viewSizeInfo:a,tempContext:n,path2d:s}=i,{width:l,height:h}=a,{shadowColor:c,shadowOffsetX:d,shadowOffsetY:u,shadowBlur:f}=o;C.number(f)&&c&&(n.clearRect(0,0,n.canvas.width,n.canvas.height),n.save(),n.shadowColor=c,n.shadowOffsetX=(d||0)*r.scale,n.shadowOffsetY=(u||0)*r.scale,n.shadowBlur=(f||0)*r.scale,n.fillStyle="#ffffff",n.fill(s),n.restore(),n.save(),n.globalCompositeOperation="destination-out",n.fillStyle="#ffffff",n.fill(s),n.restore(),e.drawImage(n.canvas,0,0,l,h),n.clearRect(0,0,n.canvas.width,n.canvas.height))}(e,t,{...i,path2d:B}),St(e,t,{path2d:B,viewScaleInfo:o,viewSizeInfo:r,calculator:a,renderContent:()=>{if(s){const i=re(t,{viewScaleInfo:o});"number"==typeof l&&l>0&&(e.globalAlpha=z*l*n),e.fillStyle=xt(e,s,{viewMaterialSize:i,viewScaleInfo:o,opacity:t.opacity||1}),e.fill(B,h),e.globalAlpha=z}if("number"==typeof d&&d>0){if("number"==typeof u&&u>0&&(e.globalAlpha=z*u*n),e.lineCap=f,e.lineJoin=g,e.lineDashOffset=p,e.miterLimit=y,Array.isArray(m)){const t=m.map(e=>x*e);e.setLineDash(t)}e.lineWidth=d*x,e.strokeStyle=c,e.stroke(B),e.setLineDash([]),e.lineCap=vt.strokeLinecap,e.lineJoin=vt.strokeLinejoin,e.lineDashOffset=vt.strokeDashoffset,e.miterLimit=vt.strokeMiterlimit,e.globalAlpha=z}}})}function St(e,t,i){const{renderContent:o,calculator:r,viewScaleInfo:a,viewSizeInfo:n}=i;if("hidden"===t.overflow){let s=i.path2d;if(!s){const{scale:e,offsetLeft:i,offsetTop:o}=a,{devicePixelRatio:l}=n,h=r.getVirtualItem(t.id),{commands:c,worldCenter:d}=h,{width:u,height:f}=t;let g=c;g=Ue(g,e,e),g=Qe(g,(i+(d.x-u/2)*e)*l,(o+(d.y-f/2)*e)*l);const m=de(g);s=new Path2D(m)}e.save(),e.clip(s,"nonzero"),o?.(),e.restore()}else o?.()}function bt(e,t,i,o){const{viewScaleInfo:r,calculator:a}=i,n=a?.getVirtualItem(t.id);if(n){const{worldAngle:i,worldCenter:a}=n,s=ae(a,{viewScaleInfo:r}),{scale:l}=r;$(e,i,s,()=>{const e=t.width*l,i=t.height*l,r={x:s.x-e/2,y:s.y-i/2,width:e,height:i};o({viewWorldCenter:s,viewWorldSize:r})})}}vt=function(e,t){const i={...e};for(const e of t)delete i[e];return i}(vt,["fill"]);const At=pe();function Mt(e,t,i){if(!0===t?.operations?.invisible)return;const{width:o,height:r}=t,{scale:a}=i.viewScaleInfo;if(a<1&&(o*a<.4||r*a<.4)||0===i.parentOpacity)return;const{overrideMaterialMap:n}=i;if(!n?.[t.id]?.operations?.invisible)try{switch(t.type){case"rect":case"circle":case"ellipse":case"path":!function(e,t,i){bt(e,t,i,()=>{wt(e,t,i)})}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r,calculator:a}=i,n=re(t,{viewScaleInfo:o})||t,{scale:s}=o;bt(e,t,i,({viewWorldSize:i})=>{{const l={...At,...t},{x:h,y:c}=i,d=(l.fontSize||At.fontSize)*o.scale,{opacity:u,fill:f,fillOpacity:g,stroke:m,strokeWidth:p,strokeOpacity:y,strokeLinecap:x,strokeLinejoin:v,strokeDasharray:w,strokeDashoffset:S,strokeMiterlimit:b}=l;if(d<2)return;const A=e.globalAlpha,M=a.getVirtualItem(t.id);e.textBaseline="top",e.$setFont({fontWeight:l.fontWeight,fontSize:d,fontFamily:$e(l.fontFamily)}),St(e,t,{viewScaleInfo:o,viewSizeInfo:r,calculator:a,renderContent:()=>{if(f&&("number"==typeof g&&g>0&&(e.globalAlpha=A*g*u),e.fillStyle=xt(e,f,{viewMaterialSize:n,viewScaleInfo:o,opacity:t.opacity||1}),Array.isArray(M?.textLines)&&M?.textLines?.length>0&&M?.textLines?.forEach(t=>{e.fillText(t.text,h+t.x*o.scale,c+t.y*o.scale)}),e.globalAlpha=A),"number"==typeof p&&p>0){if("number"==typeof y&&y>0&&(e.globalAlpha=A*y*u),e.lineCap=x,e.lineJoin=v,e.lineDashOffset=S,e.miterLimit=b,Array.isArray(w)){const t=w.map(e=>s*e);e.setLineDash(t)}e.lineWidth=p*s,e.strokeStyle=m,M?.textLines?.forEach(t=>{e.strokeText(t.text,h+t.x*o.scale,c+t.y*o.scale)}),e.setLineDash([]),e.lineCap=At.strokeLinecap,e.lineJoin=At.strokeLinejoin,e.lineDashOffset=At.strokeDashoffset,e.miterLimit=At.strokeMiterlimit,e.globalAlpha=A}}})}})}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r,parentOpacity:a}=i,{x:n,y:s,width:l,height:h,angle:c}=re(t,{viewScaleInfo:r})||t,d={...t,x:n,y:s,width:l,height:h,angle:c};bt(e,t,i,()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"image"===t.type&&o){e.globalAlpha=function(e){let t=1;return void 0!==e?.opacity&&e?.opacity>=0&&e?.opacity<=1&&(t=e?.opacity),t}(t)*a;const{x:i,y:r,width:n,height:s}=d,l=[0,0,0,0],h=t,{scaleMode:c,originW:u=0,originH:f=0}=h,g=e.$undoPixelRatio(u),m=e.$undoPixelRatio(f);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+l[0],r),e.arcTo(i+n,r,i+n,r+s,l[1]),e.arcTo(i+n,r+s,i,r+s,l[2]),e.arcTo(i,r+s,i,r,l[3]),e.arcTo(i,r,i+n,r,l[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero"),c&&f&&u){let a=0,l=0,h=g,d=m;const u=i,f=r,p=n,y=s;if(g>t.width||m>t.height)if("fill"===c){const e=Math.max(t.width/g,t.height/m),i=m*e;a=(g*e-t.width)/2/e,l=(i-t.height)/2/e,h=t.width/e,d=t.height/e}else if("tile"===c)a=0,l=0,h=t.width,d=t.height;else if("fit"===c){const e=Math.min(t.width/g,t.height/m);a=(g-t.width/e)/2,l=(m-t.height/e)/2,h=t.width/e,d=t.height/e}e.drawImage(o,a,l,h,d,u,f,p,y)}else e.drawImage(o,i,r,n,s);e.globalAlpha=a,e.restore()}})}(e,t,i);break;case"svgCode":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r}=i,{x:a,y:n,width:s,height:l}=re(t,{viewScaleInfo:r})||t;bt(e,t,i,()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"svgCode"===t.type&&o&&e.drawImage(o,a,n,s,l)})}(e,t,i);break;case"foreignObject":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r}=i,{x:a,y:n,width:s,height:l}=re(t,{viewScaleInfo:r})||t;bt(e,t,i,()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"foreignObject"===t.type&&o&&e.drawImage(o,a,n,s,l)})}(e,t,i);break;case"group":{const o={...i.materialAssets||{},...t.assets||{}};!function(e,t,i){if(bt(e,t,i,()=>{wt(e,t,i)}),Array.isArray(t.children)){const{parentMaterialSize:o}=i,r={x:o.x+t.x,y:o.y+t.y,width:t.width||o.width,height:t.height||o.height,angle:t.angle},{calculator:a}=i;for(let o=0;o<t.children.length;o++){let n=t.children[o];if(n={...n,x:r.x+n.x,y:r.y+n.y},!0===i.forceDrawAll||a?.needRender(n))try{Mt(e,n,i)}catch(e){console.error(e)}}}}(e,t,{...i,materialAssets:o});break}}}catch(e){console.error(e)}}const It=pe();function Ct(e,t,i){const{materials:o=[]}=t,{parentOpacity:r}=i;for(let t=0;t<o.length;t++){const a=o[t],n={...a,attributes:{...It,...a}};if(!0===i.forceDrawAll||i.calculator?.needRender(n))try{Mt(e,n,{...i,parentOpacity:r})}catch(e){console.error(e)}}}const Rt=["image","svgCode","foreignObject"],Et=e=>{let t=null;return"image"===e.type?t=e?.href||null:"svgCode"===e.type?t=e?.code||null:"foreignObject"===e.type&&(t=e?.content||null),"string"==typeof t&&t?h(t)?t:l(t,e.id):l(`${n()}-${e.id}-${n()}-${n()}`,e.id)};class zt extends L{#s={};#l={};#h={};#c=!1;constructor(){super(),this.#d("image",async(e,t)=>{const i=t[e.href]?.value||e.href,o=await g(i);return{id:e.id,lastModified:Date.now(),content:o}}),this.#d("foreignObject",async(e,t)=>{const i=t[e.content]?.value||e.content,o=await p(i,{width:e.originW||e.width,height:e.originH||e.height});return{id:e.id,lastModified:Date.now(),content:o}}),this.#d("svgCode",async(e,t)=>{const i=t[e.code]?.value||e.code,o=await m(i);return{id:e.id,lastModified:Date.now(),content:o}})}isDestroyed(){return this.#c}reset(){!0!==this.#c&&(this.#l={},this.#h={})}resetMaterialAsset(e){if(Rt.includes(e.type)){let t=null,i=null;"image"===e.type&&"string"==typeof e?.href?i=e.href:"svgCode"===e.type&&"string"==typeof e?.code?i=e.code:"foreignObject"===e.type&&"string"==typeof e?.content&&(i=e.content),"string"==typeof i&&(this.load(e,{}),h(i)?t=i:e.id&&(t=l(i,e.id))),t&&h(t)&&(delete this.#h[t],delete this.#l[t])}}destroy(){this.#c=!0,this.clear(),this.#s=null,this.#l=null,this.#h=null}#d(e,t){this.#s[e]=t}#u(e){let t=null;return"image"===e.type?t=e?.href||null:"svgCode"===e.type?t=e?.code||null:"foreignObject"===e.type&&(t=e?.content||null),t}#f(e){return{material:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this.#u(e)}}#g(e){const t=Et(e.material),i=this.#h[t];this.#c||(i?i.startTime<e.startTime&&(this.#h[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(this.#h[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))}#m(e){const t=Et(e.material),i=this.#h?.[t];this.#c||(i?i.startTime<e.startTime&&(this.#h[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(this.#h[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))}#p(e,t){const i=this.#f(e),o=Et(e);if(this.#l[o])return;this.#l[o]=i;const r=this.#s[e.type];"function"!=typeof r||this.#c||(i.startTime=Date.now(),r(e,t).then(e=>{this.#c||(i.content=e.content,i.endTime=Date.now(),i.status="load",this.#g(i))}).catch(t=>{console.warn(`Load material source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,this.#m(i)}))}#y(e){const t=Et(e),i=this.#l?.[t];return!(!i||"error"!==i.status||!i.source||i.source!==this.#u(e))}load(e,t){!0!==this.#c&&(this.#y(e)||Rt.includes(e.type)&&this.#p(e,t))}getContent(e){const t=Et(e);return this.#h?.[t]?.content||null}getLoadItemMap(){return this.#h}setLoadItemMap(e){this.#h=e}}function Lt(e,t){const i=t.width/2,o=t.height/2,r=e.x-i,a=e.y-o;let n=r,s=a;if("number"==typeof t.angle&&0!==t.angle){const e=t.angle*Math.PI/180,i=Math.cos(e),o=Math.sin(e);n=r*i-a*o,s=r*o+a*i}const l=s+o;return{x:n+i+t.x,y:l+t.y}}function Bt(e,t){const{groupQueue:i=[]}=t;let o=e.angle||0;i.forEach(e=>{o+=e.angle||0});return{worldCenter:function(e,t){if(!(t=[...t].reverse())||0===t.length)return{x:e.x+e.width/2,y:e.y+e.height/2};let i=e.x+e.width/2,o=e.y+e.height/2;for(let e=0;e<t.length;e++){const r=Lt({x:i,y:o},t[e]);i=r.x,o=r.y}return{x:i,y:o}}(e,i),worldAngle:X(o)}}function kt(e,t){const{dpr:i}=t;let{width:o,height:r,rx:a=0,ry:n=0}=e;const{cornerRadius:s}=e;r*=i,o*=i;const l=[];let h=0,c=0,d=0,u=0,f=0,g=0,m=0,p=0;if("number"==typeof a&&"number"==typeof n)a*=i,n*=i,h=a,c=a,d=a,u=a,f=n,g=n,m=n,p=n;else if(Array.isArray(s)&&4===s.length){const e=s.map(e=>e*i);h=e[0]||0,c=e[1]||0,d=e[2]||0,u=e[3]||0,f=e[0]||0,g=e[1]||0,m=e[2]||0,p=e[3]||0}else if("number"==typeof s){const e=s*i;h=e,c=e,d=e,u=e,f=e,g=e,m=e,p=e}const y=0+o,x=0+r;l.push({id:Xe(),type:"M",params:[0+h,0]}),c>0||g>0?(l.push({id:Xe(),type:"L",params:[y-c,0]}),l.push({id:Xe(),type:"A",params:[c,g,0,0,1,y,0+g]})):l.push({id:Xe(),type:"L",params:[y,0]}),d>0||m>0?(l.push({id:Xe(),type:"L",params:[y,x-m]}),l.push({id:Xe(),type:"A",params:[d,m,0,0,1,y-d,x]})):l.push({id:Xe(),type:"L",params:[y,x]}),u>0||p>0?(l.push({id:Xe(),type:"L",params:[0+u,x]}),l.push({id:Xe(),type:"A",params:[u,p,0,0,1,0,x-p]})):l.push({id:Xe(),type:"L",params:[0,x]}),h>0||f>0?(l.push({id:Xe(),type:"L",params:[0,0+f]}),l.push({id:Xe(),type:"A",params:[h,f,0,0,1,0+h,0]})):l.push({id:Xe(),type:"L",params:[0,0]}),l.push({id:Xe(),type:"Z",params:[]});return{...Bt(e,t),commands:l}}const Pt=pe();function Tt(e,t,i){return e>=t}function Nt(e,t){let i=null;switch(e.type){case"rect":case"group":i=kt(e,t);break;case"circle":i=function(e,t){const{dpr:i}=t,{width:o,height:r}=e;let{r:a}=e;const n=o/2*i,s=r/2*i;a*=i;const l=.55228475*a,h=[{type:"M",params:[n+a,s]},{type:"C",params:[n+a,s-l,n+l,s-a,n,s-a]},{type:"C",params:[n-l,s-a,n-a,s-l,n-a,s]},{type:"C",params:[n-a,s+l,n-l,s+a,n,s+a]},{type:"C",params:[n+l,s+a,n+a,s+l,n+a,s]},{type:"Z",params:[]}];return{...Bt(e,t),commands:h}}(e,t);break;case"ellipse":i=function(e,t){const{dpr:i}=t,{width:o,height:r}=e;let{rx:a,ry:n}=e;const s=o/2*i,l=r/2*i;a*=i,n*=i;const h=.55228475*a,c=.55228475*n,d=[{type:"M",params:[s+a,l]},{type:"C",params:[s+a,l-c,s+h,l-n,s,l-n]},{type:"C",params:[s-h,l-n,s-a,l-c,s-a,l]},{type:"C",params:[s-a,l+c,s-h,l+n,s,l+n]},{type:"C",params:[s+h,l+n,s+a,l+c,s+a,l]},{type:"Z",params:[]}];return{...Bt(e,t),commands:d}}(e,t);break;case"text":i=function(e,t){const{width:i,height:o}=e,r=t.tempContext,a=[],n={...Pt,...e},s=n.fontSize||Pt.fontSize,l=s,h=kt(e,t);if(l<2)return{...h,textLines:[]};const c=n.lineHeight||s;r.textBaseline="top",r.$setFont({fontWeight:n.fontWeight,fontSize:l,fontFamily:$e(n.fontFamily)});let d=n.text.replace(/\r\n/gi,"\n");"lowercase"===n.textTransform?d=d.toLowerCase():"uppercase"===n.textTransform&&(d=d.toUpperCase());const u=c,f=d.split("\n");let g=0;f.forEach((e,t)=>{if("maxContent"===n.minInlineSize){const t=r.measureText(e);a.push({x:0,y:0,text:e,width:r.$undoPixelRatio(t.width)})}else{let s="",l="",h=e.split(l);if("normal"===n.wordBreak){l=" ";const t=e.split(l);h=[],t.forEach((e,i)=>{h.push(e),i<t.length-1&&h.push(l)})}if(1===h.length&&"hidden"!==n.overflow)a.push({x:0,y:0,text:h[0],width:r.$undoPixelRatio(r.measureText(h[0]).width)});else if(h.length>0){for(let e=0;e<h.length;e++){if(Tt(r.$doPixelRatio(i),r.measureText(s+h[e]).width)?s+=h[e]||"":(a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s=h[e]||"",g++),g*u>=o&&"hidden"===n.overflow){s="";break}if(h.length-1===e&&(g+1)*u<=o){a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s="",t<f.length-1&&g++;break}}s&&(a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s="")}else a.push({x:0,y:0,text:"",width:0})}});let m=0,p=0;u>l&&(p=(u-l)/2),a.length*u<o&&("top"===n.verticalAlign?m=0:"bottom"===n.verticalAlign?m+=o-a.length*u:m+=(o-a.length*u)/2);{const e=0+m;a.forEach((t,o)=>{let r=0;"center"===n.textAlign?r=0+(i-t.width)/2:"right"===n.textAlign&&(r=i-t.width+0),a[o].x=r,a[o].y=e+u*o+p})}return{...h,textLines:a}}(e,t);break;case"path":i=function(e,t){const{dpr:i}=t,o={...Bt(e,t),anchorCommands:[]},r=Ze(e.commands||[]);return o.anchorCommands=r,o.commands=Ue(e.commands,i,i),o}(e,t);break;default:i=Bt(e,t)}return i}function Dt(e,t){const{viewScaleInfo:i,viewSizeInfo:o,tempContext:r}=t,a=function(e,t){const i={},o=[],r=a=>{const n={type:a.type,isVisibleInView:!0,position:[...o]};let s=null;const l=J(e,o);s=he(a,{groupQueue:l||[]});const h={...n,boundingInfo:s,rangeBoundingInfo:C.angle(a.angle)?ce(s):s,...Nt(a,{...t,groupQueue:l||[]})};i[a.id]=h,"group"===a.type&&a.children.forEach((e,t)=>{o.push(t),r(e),o.pop()})};return e.forEach((e,t)=>{o.push(t),r(e),o.pop()}),i}(e,{tempContext:r,dpr:o.devicePixelRatio});return $t(a,{viewScaleInfo:i,viewSizeInfo:o})}function $t(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:r,offsetLeft:a}=t,{width:n,height:s}=i,l=0-a/o,h=0-r/o,c=n/o,d=s/o,u=H({x:l,y:h,width:n,height:s}),f={x:l,y:h},g={x:l+c,y:h},m={x:l,y:h+d},p={x:l+c,y:h+d},y={x:l,y:u.y},x={x:u.x,y:h},v={x:l+c,y:u.y},w={x:u.x,y:h+d};return{center:u,topLeft:f,topRight:g,bottomLeft:m,bottomRight:p,left:y,top:x,right:v,bottom:w}}(t);let o=0,r=0;return Object.keys(e).forEach(t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=e.center.x,o=e.center.y,r=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),a=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),s=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),l=Math.abs(a-r),h=Math.abs(s-n),c=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x)-l,d=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x)+l,u=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y)-h,f=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y)+h;return i>=c&&i<=d&&o>=u&&o<=f}(a.rangeBoundingInfo,i),a.isVisibleInView?o++:r++}),{virtualItemMap:e,visibleCount:o,invisibleCount:r}}class Ht{#t;#x;constructor(e){this.#t=e,this.#x=new k({defaultStorage:{virtualItemMap:{},visibleCount:0,invisibleCount:0}})}toGridNum(e,t){return!0===t?.ignore?e:Math.round(e)}destroy(){this.#t=null}needRender(e){const t=this.#x.get("virtualItemMap")[e.id];return!t||t.isVisibleInView}forceVisiable(e){const t=this.#x.get("virtualItemMap")[e];t&&(t.isVisibleInView=!0)}getPointMaterial(e,t){return function(e,t){const{context2d:i,data:o,viewScaleInfo:r,groupQueue:a}=t,n={index:-1,material:null,groupQueueIndex:-1};if(a&&Array.isArray(a)&&a?.length>0)for(let t=a.length-1;t>=0;t--){let o=0,s=0,l=0;for(let e=0;e<=t;e++)o+=a[e].x,s+=a[e].y,l+=a[e].angle||0;const h=a[t];if(h&&"group"===h.type&&Array.isArray(h?.children))for(let c=0;c<h.children.length;c++){const d=h.children[c];if(!0!==d?.operations?.invisible){if(!d)break;if(se(e,{context2d:i,material:{x:o+d.x,y:s+d.y,width:d.width,height:d.height,angle:l+(d.angle||0)},viewScaleInfo:r})){n.material=d,(t<a.length-1||"group"!==d.type)&&(n.groupQueueIndex=t);break}}}if(n.material)break}if(n.material)return n;for(let t=o.materials.length-1;t>=0;t--){const a=o.materials[t];if(!0!==a?.operations?.invisible&&se(e,{context2d:i,material:a,viewScaleInfo:r})){n.index=t,n.material=a;break}}return n}(e,{...t,context2d:this.#t.tempContext})}resetVirtualItemMap(e,t){if(e){const{virtualItemMap:i,invisibleCount:o,visibleCount:r}=Dt(e.materials,{...t,tempContext:this.#t.tempContext});this.#x.set("virtualItemMap",i),this.#x.set("invisibleCount",o),this.#x.set("visibleCount",r)}}updateVisiableStatus(e){const{virtualItemMap:t,invisibleCount:i,visibleCount:o}=$t(this.#x.get("virtualItemMap"),e);this.#x.set("virtualItemMap",t),this.#x.set("invisibleCount",i),this.#x.set("visibleCount",o)}calcViewBoundingInfoFromOrigin(e,t){const i=this.#x.get("virtualItemMap")[e];if(!i?.boundingInfo)return null;const{checkVisible:o,viewScaleInfo:r,viewSizeInfo:a}=t,{center:n,left:s,right:l,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.boundingInfo;if(!0===o&&!1===i.isVisibleInView)return null;const m={viewScaleInfo:r};return{center:ae(n,m),left:ae(s,m),right:ae(l,m),bottom:ae(h,m),top:ae(c,m),topLeft:ae(d,m),topRight:ae(u,m),bottomLeft:ae(f,m),bottomRight:ae(g,m)}}calcViewBoundingInfoFromRange(e,t){const i=this.#x.get("virtualItemMap")[e];if(!i?.boundingInfo)return null;const{checkVisible:o,viewScaleInfo:r,viewSizeInfo:a}=t,{center:n,left:s,right:l,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.rangeBoundingInfo;if(!0===o&&!1===i.isVisibleInView)return null;const m={viewScaleInfo:r};return{center:ae(n,m),left:ae(s,m),right:ae(l,m),bottom:ae(h,m),top:ae(c,m),topLeft:ae(d,m),topRight:ae(u,m),bottomLeft:ae(f,m),bottomRight:ae(g,m)}}modifyVirtualAttributes(e,t){const{viewSizeInfo:i,groupQueue:o}=t,r=this.#x.get("virtualItemMap"),a=r[e.id],n=Nt(e,{tempContext:this.#t.tempContext,dpr:i.devicePixelRatio,groupQueue:o});if(n){const t=he(e,{groupQueue:o}),i={...a,...n,boundingInfo:t,rangeBoundingInfo:C.angle(e.angle)?ce(t):t};r[e.id]=i,this.#x.set("virtualItemMap",r)}}modifyVirtualItemMap(e,t){const{modifyInfo:i,viewScaleInfo:o,viewSizeInfo:r}=t,{type:a,content:n}=i,s=e.materials,l=this.#x.get("virtualItemMap");if("deleteMaterial"===a){const{material:e}=n,t=[],i=e=>{t.push(e.id),"group"===e.type&&Array.isArray(e.children)&&e.children.forEach(e=>{i(e)})};i(e),t.forEach(e=>{delete l[e]}),this.#x.set("virtualItemMap",l)}else if("addMaterial"===a||"updateMaterial"===a){const{position:t}=n,i=q(t,e.materials),h=J(s,t);if(i)if("updateMaterial"===a&&"group"===i.type)this.resetVirtualItemMap(e,{viewScaleInfo:o,viewSizeInfo:r});else{const e=he(i,{groupQueue:h||[]}),n={type:i.type,boundingInfo:e,rangeBoundingInfo:C.angle(i.angle)?ce(e):e,isVisibleInView:!0,position:[...t],...Nt(i,{tempContext:this.#t.tempContext,dpr:r.devicePixelRatio,groupQueue:h||[]})};l[i.id]=n,this.#x.set("virtualItemMap",l),"updateMaterial"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:r})}}else"moveMaterial"===a&&this.resetVirtualItemMap(e,{viewScaleInfo:o,viewSizeInfo:r})}getVirtualItem(e){return this.#x.get("virtualItemMap")[e]||null}}class Wt extends L{#t;#v=new zt;#w;#c=!1;constructor(e){super(),this.#t=e,this.#w=new Ht({tempContext:e.tempContext}),this.#S()}isDestroyed(){return this.#c}destroy(){this.clear(),this.#t=null,this.#v.destroy(),this.#v=null,this.#c=!0}#S(){const e=this.#v;e.on("load",e=>{this.trigger("load",e)}),e.on("error",e=>{console.error(e)})}updateOptions(e){this.#t=e}drawData(e,t){const i=this.#v,o=this.#w,{sharer:r}=this.#t,a=this.#t.viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const n={x:0,y:0,width:t.viewSizeInfo.width,height:t.viewSizeInfo.height};!0===t.forceDrawAll&&this.#w.resetVirtualItemMap(e,{viewScaleInfo:t.viewScaleInfo,viewSizeInfo:t.viewSizeInfo});const s={loader:i,calculator:o,parentMaterialSize:n,materialAssets:e.assets,parentOpacity:1,overrideMaterialMap:r?.getActiveOverrideMaterialMap(),tempContext:this.#t.tempContext,...t};!function(e,t,i){if("string"==typeof t?.fill){const{viewSizeInfo:o}=i,{width:r,height:a}=o;e.globalAlpha=1,e.fillStyle=t.fill,e.fillRect(0,0,r,a)}}(a,e.global,s),e.layout?function(e,t,i,o){const{parentOpacity:r}=i;e.globalAlpha=1;const{viewScaleInfo:a}=i,n={id:"layout",type:"group",...t},s=re(n,{viewScaleInfo:a})||n,l={...n,...s},{x:h,y:c,width:d,height:u,fill:f}=l,g=[0,0,0,0];e.save(),e.fillStyle=xt(e,f,{viewMaterialSize:s,viewScaleInfo:a,opacity:n.opacity||1}),e.beginPath(),e.moveTo(h+g[0],c),e.arcTo(h+d,c,h+d,c+u,g[1]),e.arcTo(h+d,c+u,h,c+u,g[2]),e.arcTo(h,c+u,h,c,g[3]),e.arcTo(h,c,h+d,c,g[0]),e.closePath(),e.fill("nonzero"),"hidden"===t.overflow&&e.clip("nonzero"),o(e),"hidden"===t.overflow&&e.restore(),e.globalAlpha=r}(a,e.layout,s,()=>{Ct(a,e,s)}):Ct(a,e,s)}scale(e){const{sharer:t}=this.#t;if(!t)return;const{data:i,offsetTop:o,offsetBottom:r,offsetLeft:a,offsetRight:n,width:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:r,offsetLeft:a,offsetRight:n},viewSizeInfo:{width:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){this.#v.setLoadItemMap(e)}getLoadItemMap(){return this.#v.getLoadItemMap()}getLoader(){return this.#v}getCalculator(){return this.#w}}function Ot(e){return e>0||e<0||0===e}class Vt extends L{#t;#x;#c=!1;constructor(e){super();const t=new k({defaultStorage:{hasPointDown:!1,inCanvas:!0}});this.#x=t,this.#t=e,this.#S()}#S(){this.onEvents()}onEvents(){if(!0===this.#t.disabled)return;if(this.#c)return;const e=window,t=this.#t?.container||this.#t.boardContent.boardContext.canvas;e.addEventListener("mousemove",this.#b),e.addEventListener("mouseup",this.#A),t.addEventListener("mousemove",this.#M),t.addEventListener("mousedown",this.#I),t.addEventListener("wheel",this.#C,{passive:!1}),t.addEventListener("click",this.#R),t.addEventListener("contextmenu",this.#E),t.addEventListener("dblclick",this.#z)}offEvents(){if(!0===this.#t.disabled)return;const e=window,t=this.#t?.container||this.#L();e.removeEventListener("mousemove",this.#b),e.removeEventListener("mouseup",this.#A),t.removeEventListener("mousemove",this.#M),t.removeEventListener("mousedown",this.#I),t.removeEventListener("wheel",this.#C),t.removeEventListener("click",this.#R),t.removeEventListener("contextmenu",this.#E),t.removeEventListener("dblclick",this.#z)}destroy(){this.offEvents(),this.#x.destroy(),this.#c=!0}#L(){return this.#t.boardContent.boardContext.canvas}#C=e=>{const t=e;if(!this.#B(e))return;const i=this.#k(e);if(!this.#P(i))return;e.preventDefault(),e.stopPropagation();const o=e.deltaX>0||e.deltaX<0?e.deltaX:0,r=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:o,deltaY:r,point:i,nativeEvent:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:o,deltaY:r,point:i,nativeEvent:t})};#E=e=>{const t=e;if(2!==e.button)return;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("contextMenu",{point:i,nativeEvent:t})};#R=e=>{const t=e;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("click",{point:i,nativeEvent:t})};#z=e=>{const t=e;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("doubleClick",{point:i,nativeEvent:t})};#T=e=>{const t=e;this.#x.set("hasPointDown",!1),e.preventDefault();const i=this.#k(e);this.trigger("pointLeave",{point:i,nativeEvent:t})};#A=e=>{const t=e;if(this.#x.set("hasPointDown",!1),!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.trigger("pointEnd",{point:i,nativeEvent:t})};#b=e=>{const t=e;if(!this.#B(e))return;e.preventDefault(),e.stopPropagation();const i=this.#k(e);this.#P(i)?!0===this.#x.get("hasPointDown")&&this.trigger("pointMove",{point:i,nativeEvent:t}):this.#x.get("hasPointDown")&&(this.trigger("pointLeave",{point:i,nativeEvent:t}),this.#x.set("hasPointDown",!1))};#I=e=>{const t=e;if(0!==e.button)return;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&(this.#x.set("hasPointDown",!0),this.trigger("pointStart",{point:i,nativeEvent:t}))};#M=e=>{const t=e;if(!this.#B(e))return void(!0===this.#x.get("inCanvas")&&(this.#x.set("inCanvas",!1),this.#T(e)));this.#x.set("inCanvas",!0),e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("hover",{point:i,nativeEvent:t})};#B(e){const t=e.target;if("true"===t.getAttribute(yt))return!0;if(t!==this.#L())return!1;const i=nt(this.#t.boardContent.boardContext.canvas);return e.pageX>=i.pageX&&e.pageX<=i.pageX+i.width&&e.pageY>=i.pageY&&e.pageY<=i.pageY+i.height}#k(e){const t=this.#t.boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}}#P(e){const t=this.#t.sharer.getActiveViewSizeInfo(),{width:i,height:o}=t;return!!(Ot(e.x)&&Ot(e.y)&&e.x<=i&&e.y<=o)}}const Yt={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:{materials:[]},scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideMaterialMap:null};class jt{#N;#D;constructor(){const e=new k({defaultStorage:Yt}),t=new k({defaultStorage:{}});this.#N=e,this.#D=t}getActiveStorage(e){return this.#N.get(e)}setActiveStorage(e,t){return this.#N.set(e,t)}getActiveStoreSnapshot(e){return this.#N.getSnapshot(e)}getSharedStorage(e){return this.#D.get(e)}setSharedStorage(e,t){return this.#D.set(e,t)}getSharedStoreSnapshot(e){return this.#D.getSnapshot(e)}getActiveViewScaleInfo(){return{scale:this.#N.get("scale"),offsetTop:this.#N.get("offsetTop"),offsetBottom:this.#N.get("offsetBottom"),offsetLeft:this.#N.get("offsetLeft"),offsetRight:this.#N.get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:r,offsetRight:a}=e;this.#N.set("scale",t),this.#N.set("offsetTop",i),this.#N.set("offsetBottom",o),this.#N.set("offsetLeft",r),this.#N.set("offsetRight",a)}setActiveViewSizeInfo(e){this.#N.set("width",e.width),this.#N.set("height",e.height),this.#N.set("devicePixelRatio",e.devicePixelRatio),this.#N.set("contextWidth",e.contextWidth),this.#N.set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:this.#N.get("width"),height:this.#N.get("height"),devicePixelRatio:this.#N.get("devicePixelRatio"),contextWidth:this.#N.get("contextWidth"),contextHeight:this.#N.get("contextHeight")}}getActiveOverrideMaterialMap(){return this.#N.get("overrideMaterialMap")}setActiveOverrideMaterialMap(e){this.#N.set("overrideMaterialMap",e)}}const{requestAnimationFrame:Gt}=window;class Ft extends L{#t;#$=[];#H="FREE";constructor(e){super(),this.#t=e,this.#S()}#S(){const{renderer:e}=this.#t;e.on("load",()=>{this.drawFrame()})}#W(){if("DRAWING"===this.#H||0===this.#$.length)return;this.#H="DRAWING";const e=this.#$.shift(),{renderer:t,boardContent:i,beforeDrawFrame:o,afterDrawFrame:r}=this.#t;if(e){const{scale:a,offsetTop:n,offsetBottom:s,offsetLeft:l,offsetRight:h,width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g}=e.activeStore,m={scale:a,offsetTop:n,offsetBottom:s,offsetLeft:l,offsetRight:h},p={width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g};e?.activeStore.data&&t.drawData(e.activeStore.data,{viewScaleInfo:m,viewSizeInfo:p}),o({snapshot:e}),i.drawView(),r({snapshot:e})}0!==this.#$.length?"DRAWING"===this.#H&&Gt(()=>{this.#W()}):this.#H="COMPLETE"}resetVirtualItemMap(e,t){e&&this.#t.calculator.resetVirtualItemMap(e,t)}drawFrame(){const{sharer:e}=this.#t,t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();this.#$.push({activeStore:t,sharedStore:i}),this.#W()}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:r}=this.#t,{moveX:a,moveY:n}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:r,offsetTop:a}=o,n=t/o.scale,s=i.x,l=i.y;return{moveX:s-s*n+(r*n-r),moveY:l-l*n+(a*n-a)}}({scale:t,point:i,viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()});return r.setActiveStorage("scale",t),o||this.#t.calculator.updateVisiableStatus({viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()}),{moveX:a,moveY:n}}scroll(e){const{sharer:t}=this.#t,i=t.getActiveViewScaleInfo(),{moveX:o,moveY:r,ignoreUpdateVisibleStatus:a}=e,n=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:r}=e,{scale:a}=o,{width:n,height:s,contextWidth:l,contextHeight:h}=r;let c=o.offsetLeft,d=o.offsetRight,u=o.offsetTop,f=o.offsetBottom;return c+=t,u+=i,d=n-(l*a+c),f=s-(h*a+u),{scale:a,offsetTop:u,offsetLeft:c,offsetRight:d,offsetBottom:f}}({moveX:o,moveY:r,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(n),a||this.#t.calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),n}updateViewScaleInfo(e){const{sharer:t}=this.#t,i=function(e,t){const{scale:i,offsetX:o,offsetY:r}=e,{viewSizeInfo:a}=t,{width:n,height:s,contextWidth:l,contextHeight:h}=a,c=0-o*i,d=0-r*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:n-(l*i+c/i),offsetBottom:s-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),this.#t.calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=this.#t,o={...i.getActiveViewSizeInfo(),...e},{width:r,height:a,devicePixelRatio:n}=o,{underlayContext:s,boardContext:l,overlayContext:h,viewContext:c}=this.#t.boardContent;return l.canvas.width=r*n,l.canvas.height=a*n,l.canvas.style.width=`${r}px`,l.canvas.style.height=`${a}px`,s.canvas.width=r*n,s.canvas.height=a*n,h.canvas.width=r*n,h.canvas.height=a*n,c.canvas.width=r*n,c.canvas.height=a*n,i.setActiveViewSizeInfo(o),t?.ignoreUpdateVisibleStatus||this.#t.calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),o}}class Xt{#t;#O=new Map;#V=[];#Y;#j;#G;#F;#w;#X=new L;#c=!1;constructor(e){const{boardContent:t,container:i}=e,o=new jt,r=new Vt({boardContent:t,sharer:o,disabled:e?.disableWatcher,container:i}),a=new Wt({viewContext:t.viewContext,tempContext:t.tempContext,sharer:o}),n=a.getCalculator();this.#t=e,this.#G=o,this.#Y=r,this.#j=a,this.#w=n,this.#F=new Ft({boardContent:e.boardContent,sharer:o,renderer:a,calculator:this.#w,beforeDrawFrame:e=>{this.#Q(e)},afterDrawFrame:e=>{this.#U(e)}}),this.#S(),this.#Z()}isDestroyed(){return this.#c}destroy(){this.#Y.destroy(),this.#j.destroy(),this.#w.destroy(),this.#X.destroy(),this.#c=!0}#S(){!0!==this.#t.disableWatcher&&(this.#Y.on("pointStart",this.#J.bind(this)),this.#Y.on("pointEnd",this.#K.bind(this)),this.#Y.on("pointMove",this.#q.bind(this)),this.#Y.on("pointLeave",this.#_.bind(this)),this.#Y.on("hover",this.#ee.bind(this)),this.#Y.on("wheel",this.#te.bind(this)),this.#Y.on("wheelScale",this.#ie.bind(this)),this.#Y.on("scrollX",this.#oe.bind(this)),this.#Y.on("scrollY",this.#re.bind(this)),this.#Y.on("resize",this.#ae.bind(this)),this.#Y.on("click",this.#ne.bind(this)),this.#Y.on("doubleClick",this.#se.bind(this)),this.#Y.on("contextMenu",this.#le.bind(this))),this.#j.on("load",()=>{this.#X.trigger("loadResource")})}#J(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointStart?.(e);if(!1===o)return}}#K(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointEnd?.(e);if(!1===o)return}}#q(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointMove?.(e);if(!1===o)return}}#_(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.pointLeave?.(e);if(!1===o)return}}#ee(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.hover?.(e);if(!1===o)return}}#ne(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.click?.(e);if(!1===o)return}}#se(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.doubleClick?.(e);if(!1===o)return}}#le(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.contextMenu?.(e);if(!1===o)return}}#te(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.wheel?.(e);if(!1===o)return}}#ie(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.wheelScale?.(e);if(!1===o)return}}#oe(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.scrollX?.(e);if(!1===o)return}}#re(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.scrollY?.(e);if(!1===o)return}}#ae(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.resize?.(e);if(!1===o)return}}#he(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.clear?.(e);if(!1===o)return}}#Q(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.beforeDrawFrame?.(e);if(!1===o)return}}#U(e){for(let t=0;t<this.#V.length;t++){const i=this.#V[t],o=i?.afterDrawFrame?.(e);if(!1===o)return}}#Z(){const e=[];for(const[t,i]of this.#O)"enable"===i?.status&&i?.middlewareObject&&e.push(i.middlewareObject);this.#V=e}getSharer(){return this.#G}getViewer(){return this.#F}getRenderer(){return this.#j}setData(e){const t=this.#G;this.#G.setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=t.getActiveViewScaleInfo(),r=U(e.materials,{viewWidth:i.width,viewHeight:i.height,extend:!0});this.#F.resetVirtualItemMap(e,{viewSizeInfo:i,viewScaleInfo:o}),this.#F.drawFrame();const a={...i,...r};return this.#G.setActiveViewSizeInfo(a),{viewSizeInfo:a}}getData(){const{data:e}=this.#G.getActiveStoreSnapshot();return e}use(e,t){if(this.#O.has(e)){const t=this.#O.get(e);return void(t&&"enable"!==t.status&&(t.status="enable",t.middlewareObject.use?.(),this.#Z()))}const{boardContent:i,container:o}=this.#t,r=e({boardContent:i,sharer:this.#G,viewer:this.#F,calculator:this.#w,eventHub:this.#X,container:o},t);r.use?.(),this.#O.set(e,{status:"enable",middlewareObject:r,config:t}),this.#Z()}disuse(e){if(this.#O.has(e)){const t=this.#O.get(e);t&&(t.middlewareObject.disuse?.(),t.status="disable"),this.#O.delete(e),this.#Z()}}resetMiddlewareConfig(e,t){if(this.#O.has(e)){const i=this.#O.get(e);i&&i.middlewareObject.resetConfig?.(t)}}scale(e){const t=this.#F,{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:r}=t.scale({...e,ignoreUpdateVisibleStatus:!0});t.scroll({moveX:o,moveY:r,ignoreUpdateVisibleStatus:i})}scroll(e){return this.#F.scroll(e)}updateViewScaleInfo(e){return this.#F.updateViewScaleInfo(e)}resize(e,t){const i=this.#F.resize(e,t),{width:o,height:r,devicePixelRatio:a}=e,{boardContent:n}=this.#t;n.viewContext.$resize({width:o,height:r,devicePixelRatio:a}),n.overlayContext.$resize({width:o,height:r,devicePixelRatio:a}),n.boardContext.$resize({width:o,height:r,devicePixelRatio:a}),n.underlayContext.$resize({width:o,height:r,devicePixelRatio:a}),this.#F.drawFrame(),this.#Y.trigger("resize",i),this.#G.setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=this.#t,{underlayContext:t,overlayContext:i,viewContext:o,boardContext:r}=e;t.clearRect(0,0,t.canvas.width,t.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),r.clearRect(0,0,r.canvas.width,r.canvas.height),this.#he()}getEventHub(){return this.#X}onWatcherEvents(){!0!==this.#t.disableWatcher&&this.#Y.onEvents()}offWatcherEvents(){!0!==this.#t.disableWatcher&&this.#Y.offEvents()}}const Qt="CREATOR",Ut=Symbol(`${Qt}_startPoint`),Zt=Symbol(`${Qt}_endPoint`),Jt=Symbol(`${Qt}_activeMaterialType`),Kt="idraw-middleware-creator",qt={zIndex:2,creationAreaBorderColor:"#1973ba"},_t={selectAfterCreated:!0},ei={creationAreaBox:`${Kt}-creationAreaBox`,creative:`${Kt}-creative`};function ti(e){return N(e,["zIndex","creationAreaBorderColor"])}function ii(e){!function(e,t){if(!e)return;const{className:i}=t;Array.from(e.getElementsByClassName(i)).forEach(e=>{e.remove()})}(e,{className:ei.creationAreaBox})}function oi(e,t){if(!e)return;const{start:i,end:o}=t;if(i&&o){const t=function(e){const t=e.getElementsByClassName(ei.creationAreaBox);if(t[0])return t[0];const i=rt("div",{[yt]:"true",className:ei.creationAreaBox});return ot(e,{},[i]),i}(e);it(t,{left:Math.min(i.x,o.x),top:Math.min(i.y,o.y),width:Math.abs(o.x-i.x),height:Math.abs(o.y-i.y)})}else ii(e)}function ri(e){const{start:t,end:i,viewScaleInfo:o,calculator:r}=e,a=ne(t,{viewScaleInfo:o}),n=ne(i,{viewScaleInfo:o});return{x:r.toGridNum(Math.min(a.x,n.x)),y:r.toGridNum(Math.min(a.y,n.y)),width:r.toGridNum(Math.abs(n.x-a.x)),height:r.toGridNum(Math.abs(n.y-a.y))}}function ai(e,t,i){"continuous"===i?e.trigger(o.CHANGING,t):"all"===i?(e.trigger(o.CHANGING,t),e.trigger(o.CHANGE,t)):e.trigger(o.CHANGE,t)}const ni="SELECTOR",si="idraw-middleware-selector",li="data-idraw-box-type",hi="data-idraw-material-id",ci="data-idraw-handler-type",di="box-group",ui="box-material",fi={materialBox:`${si}-materialBox`,groupBox:`${si}-groupBox`,nestedBox:`${si}-nestedBox`,nestedTargetBox:`${si}-nestedTargetBox`,hoverBox:`${si}-hoverBox`,hoverTargetBox:`${si}-hoverTargetBox`,lockedBox:`${si}-lockedBox`,lockedTargetBox:`${si}-lockedTargetBox`,selectedBox:`${si}-selectedBox`,selectedTargetBox:`${si}-selectedTargetBox`,hideHandler:`${si}-hideHandler`,edgeHandler:`${si}-edgeHandler`,edgeTopHandler:`${si}-edgeTopHandler`,edgeRightHandler:`${si}-edgeRightandler`,edgeBottomHandler:`${si}-edgeBottomHandler`,edgeLeftHandler:`${si}-edgeLeftHandler`,cornerHandler:`${si}-cornerHandler`,cornerTopLeftHandler:`${si}-cornerTopLeftHandler`,cornerTopRightHandler:`${si}-cornerTopRightHandler`,cornerBottomLeftHandler:`${si}-cornerBottomLeftHandler`,cornerBottomRightHandler:`${si}-cornerBottomRightHandler`,rotateHandler:`${si}-rotateHandler`,selectionAreaBox:`${si}-selectionAreaBox`},gi=Symbol(`${ni}_prevPoint`),mi=Symbol(`${ni}_pointStartMaterialSizeList`),pi=Symbol(`${ni}_moveOriginalStartPoint`),yi=Symbol(`${ni}_moveOriginalStartMaterialSize`),xi=Symbol(`${ni}_inBusyMode`),vi=Symbol(`${ni}_hasChangedData`),wi=Symbol(`${ni}_startResizeGroupRecord`),Si=Symbol(`${ni}_endResizeGroupRecord`),bi=Symbol(`${ni}_actionType`),Ai=Symbol(`${ni}_resizeType`),Mi=Symbol(`${ni}_areaStart`),Ii=Symbol(`${ni}_areaEnd`),Ci=Symbol(`${ni}_hoverMaterial`),Ri=Symbol(`${ni}_selectedMaterialList`),Ei=Symbol(`${ni}_selectedMaterialListVertexes`),zi=Symbol(`${ni}_selectedMaterialPosition`),Li=Symbol(`${ni}_groupQueue`),Bi=Symbol(`${ni}_isMoving`),ki=Symbol(`${ni}_enableSelectInGroup`),Pi=Symbol(`${ni}_enableSnapToGrid`),Ti={zIndex:1,activeColor:"#1973ba",handlerBorderColor:"#1973ba",handlerBackground:"#ffffff",handlerHoverBackground:"#aad4f6",handlerActiveBackground:"#63b8f8",selectionAreaBorderColor:"#1973ba",selectionAreaBackground:"#1973ba3f",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Ni(e){return e*Math.PI/180}function Di(e,t){return Math.sqrt(e*e+t*t)}function $i(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Hi(e,t){const{ctx:i,viewScaleInfo:o,vertexes:r}=t,a=ae(r[0],{viewScaleInfo:o}),n=ae(r[1],{viewScaleInfo:o}),s=ae(r[2],{viewScaleInfo:o}),l=ae(r[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(n.x,n.y),i.lineTo(s.x,s.y),i.lineTo(l.x,l.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Wi(e,t){const i={type:null,materials:[],materialVertexesList:[],groupQueue:[]},{ctx:o,data:r,calculator:a,selectedMaterials:n,viewScaleInfo:s,viewSizeInfo:l,areaSize:h,groupQueue:c,nativeEvent:d}=t,u=d.target;if(n&&1===n?.length&&u){const e=u;if(e?.hasAttribute(ci)){const t=e.getAttribute(ci);if("string"==typeof t)return i.type=`resize-${t}`,i.groupQueue=c||[],i.materials=[n[0]],i}}if(c&&Array.isArray(c)&&c.length>0){const t=c[c.length-1];if(t?.children&&Array.isArray(t?.children))for(let r=t.children.length-1;r>=0;r--){const a=t.children[r],n=oe(a,{groupQueue:c});if(n&&Hi(e,{ctx:o,vertexes:n,viewScaleInfo:s}))return i.type||(i.type="over-material"),i.groupQueue=c,i.materials=[a],i}return i}if(null!==i.type)return i;if(h&&Array.isArray(n)&&n?.length>1){const{x:t,y:o,width:r,height:a}=h;if(e.x>=t&&e.x<=t+r&&e.y>=o&&e.y<=o+a)return i.type="list-area",i.materials=n,i}if(r){const{index:t,material:o}=a.getPointMaterial(e,{data:r,viewScaleInfo:s,viewSizeInfo:l});if(t>=0&&o&&!0!==o?.operations?.invisible)return i.materials=[o],i.type="over-material",i}return i}function Oi(e,t){const{x:i,y:o,width:r,height:a,angle:n=0}=e,{center:s,start:l,end:h,viewScaleInfo:c,calculator:d}=t,u=ae(s,{viewScaleInfo:c}),f=X(n),g=function(e,t,i){const o=O(e,t),r=O(e,i);return null!==r&&null!==o?r-o:0}(u,l,h),m=X(f+g/Math.PI*180);return{x:d.toGridNum(i),y:d.toGridNum(o),width:d.toGridNum(r),height:d.toGridNum(a),angle:d.toGridNum(m)}}function Vi(e,t){if(!Array.isArray(e))return null;const i={x:0,y:0,width:0,height:0},{viewScaleInfo:o}=t;let r=null;for(let t=0;t<e.length;t++){const a=e[t];if(a?.operations?.invisible)continue;const n=re(a,{viewScaleInfo:o});if(n.angle&&(n.angle>0||n.angle<0)){const e=G(n);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];n.x=Math.min(...t),n.y=Math.min(...i),n.width=Math.abs(Math.max(...t)-Math.min(...t)),n.height=Math.abs(Math.max(...i)-Math.min(...i))}}if(r){const e=Math.min(n.x,i.x),t=Math.min(n.y,i.y),o=Math.max(n.x+n.width,i.x+i.width),r=Math.max(n.y+n.height,i.y+i.height);i.x=e,i.y=t,i.width=Math.abs(o-e),i.height=Math.abs(r-t)}else i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height;r=n}return i}function Yi(e){return{minX:e.topLeft.x,minY:e.topLeft.y,maxX:e.bottomRight.x,maxY:e.bottomRight.y,midX:e.center.x,midY:e.center.y}}const ji=(e,t)=>{if(0===e.length)throw null;if(1===e.length)return e[0];let i=0,o=e.length-1;for(;i<=o;){const r=Math.floor((i+o)/2);if(e[r]===t)return e[r];e[r]<t?i=r+1:o=r-1}return i>=e.length?e[o]:o<0?e[i]:Math.abs(e[o]-t)<=Math.abs(e[i]-t)?e[o]:e[i]},Gi=(e,t)=>Math.abs(e-t)<1e-5;function Fi(e,t){const{data:i,groupQueue:o,calculator:r,viewScaleInfo:a,viewSizeInfo:n}=t;let s=i.materials||[];o?.length>0&&(s=o[o.length-1]?.children||[]);const l=[];s.forEach(t=>{if(t.id!==e){const e=r.calcViewBoundingInfoFromRange(t.id,{checkVisible:!0,viewScaleInfo:a,viewSizeInfo:n});e&&l.push(e)}});const h=r.calcViewBoundingInfoFromRange(e,{viewScaleInfo:a,viewSizeInfo:n});if(!h)return null;const c={},d={},u=[],f=[];let g=[],m=[];const p=Yi(h);l.forEach(e=>{const t=Yi(e);c[t.minX]||(c[t.minX]=[]),c[t.midX]||(c[t.midX]=[]),c[t.maxX]||(c[t.maxX]=[]),d[t.minY]||(d[t.minY]=[]),d[t.midY]||(d[t.midY]=[]),d[t.maxY]||(d[t.maxY]=[]),c[t.minX]=[t.minY,t.midY,t.maxY],c[t.midX]=[t.minY,t.midY,t.maxY],c[t.maxX]=[t.minY,t.midY,t.maxY],g.push(t.minX),g.push(t.midX),g.push(t.maxX),d[t.minY]=[t.minX,t.midX,t.maxX],d[t.midY]=[t.minX,t.midX,t.maxX],d[t.maxY]=[t.minX,t.midX,t.maxX],m.push(t.minY),m.push(t.midY),m.push(t.maxY)}),g=g.sort((e,t)=>e-t),m=m.sort((e,t)=>e-t);let y=null,x=null,v=null,w=null,S=null,b=null,A=null,M=null;if(g.length>0){v=ji(g,p.minX),w=ji(g,p.midX),S=ji(g,p.maxX);const e=Math.abs(v-p.minX),t=Math.abs(w-p.midX),i=Math.abs(S-p.maxX),o=Math.min(e,t,i);o<=2/a.scale&&(Gi(o,e)?y=v-p.minX:Gi(o,t)?y=w-p.midX:Gi(o,i)&&(y=S-p.maxX))}if(m.length>0){b=ji(m,p.minY),A=ji(m,p.midY),M=ji(m,p.maxY);const e=Math.abs(b-p.minY),t=Math.abs(A-p.midY),i=Math.abs(M-p.maxY),o=Math.min(e,t,i);o<=2/a.scale&&(Gi(o,e)?x=b-p.minY:Gi(o,t)?x=A-p.midY:Gi(o,i)&&(x=M-p.maxY))}const I={...p};if(null!==y&&(I.minX+=y,I.midX+=y,I.maxX+=y),null!==x&&(I.minY+=x,I.midY+=x,I.maxY+=x),C.x(y)&&null!==y&&null!==v&&null!==w&&null!==S){if(Gi(y,v-p.minX)){const e={x:v,yList:[]};e.yList.push(I.minY),e.yList.push(I.maxY),e.yList.push(...d?.[v]||[]),u.push(e)}if(Gi(y,w-p.minX)){const e={x:w,yList:[]};e.yList.push(I.minY),e.yList.push(I.maxY),e.yList.push(...d?.[w]||[]),u.push(e)}if(Gi(y,S-p.minX)){const e={x:S,yList:[]};e.yList.push(I.minY),e.yList.push(I.maxY),e.yList.push(...d?.[S]||[]),u.push(e)}}if(C.y(x)&&null!==x&&null!==b&&null!==A&&null!==M){if(Gi(x,b-p.minY)){const e={y:b,xList:[]};e.xList.push(I.minX),e.xList.push(I.maxX),e.xList.push(...c?.[b]||[]),f.push(e)}if(Gi(x,A-p.midY)){const e={y:A,xList:[]};e.xList.push(I.minX),e.xList.push(I.maxX),e.xList.push(...c?.[b]||[]),f.push(e)}if(Gi(x,M-p.maxY)){const e={y:M,xList:[]};e.xList.push(I.minX),e.xList.push(I.maxX),e.xList.push(...c?.[M]||[]),f.push(e)}}const R=[];u?.length>0&&u.forEach((e,t)=>{R.push([]),e.yList.forEach(i=>{R[t].push({x:e.x,y:i})})});const E=[];return f?.length>0&&f.forEach((e,t)=>{E.push([]),e.xList.forEach(i=>{E[t].push({x:i,y:e.y})})}),{offsetX:y,offsetY:x,yLines:R,xLines:E}}const Xi="LAYOUT_SELECTOR",Qi=Symbol(`${Xi}_layoutActionType`),Ui=Symbol(`${Xi}_layoutControlType`),Zi=Symbol(`${Xi}_layoutIsHoverContent`),Ji=Symbol(`${Xi}_layoutIsHoverController`),Ki=Symbol(`${Xi}_layoutIsSelected`),qi=Symbol(`${Xi}_layoutIsSelected`),_i="idraw-middleware-layout-selector",eo="data-idraw-handler-type",to=1.5,io={zIndex:2,activeColor:"#b331c9",handlerBorderColor:"#b331c9",handlerBackground:"#ffffff",handlerHoverBackground:"#bb8fc3",handlerActiveBackground:"#b467c2"},oo={hover:`${_i}-hover`,edgeHandler:`${_i}-edgeHandler`,edgeTopHandler:`${_i}-edgeTopHandler`,edgeRightHandler:`${_i}-edgeRightandler`,edgeBottomHandler:`${_i}-edgeBottomHandler`,edgeLeftHandler:`${_i}-edgeLeftHandler`,cornerHandler:`${_i}-cornerHandler`,cornerTopLeftHandler:`${_i}-cornerTopLeftHandler`,cornerTopRightHandler:`${_i}-cornerTopRightHandler`,cornerBottomLeftHandler:`${_i}-cornerBottomLeftHandler`,cornerBottomRightHandler:`${_i}-cornerBottomRightHandler`};function ro(e,t){const{rootClassName:i}=t,o=e.getElementsByClassName(i);Array.from(o).forEach(e=>{e.remove()})}function ao(e,t){const{layout:i}=t;i?function(e,t){const i=e.querySelectorAll(`[${eo}]`),{rootClassName:o,layout:r,viewScaleInfo:a}=t;if(!r)return;const n=re(r,{viewScaleInfo:a}),{x:s,y:l,height:h,width:c}=n,d={left:s,top:l,height:h},u={left:s,top:l,width:c},f={left:s+c,top:l,height:h},g={left:s,top:l+h,width:c},m={left:s,top:l},p={left:s+c,top:l},y={left:s,top:l+h},x={left:s+c,top:l+h};if(i.length>0){const t=e.getElementsByClassName(oo.edgeLeftHandler)[0],i=e.getElementsByClassName(oo.edgeRightHandler)[0],o=e.getElementsByClassName(oo.edgeTopHandler)[0],r=e.getElementsByClassName(oo.edgeBottomHandler)[0],a=e.getElementsByClassName(oo.cornerTopLeftHandler)[0],n=e.getElementsByClassName(oo.cornerTopRightHandler)[0],s=e.getElementsByClassName(oo.cornerBottomLeftHandler)[0],l=e.getElementsByClassName(oo.cornerBottomRightHandler)[0];it(t,d),it(i,f),it(o,u),it(r,g),it(a,m),it(n,p),it(s,y),it(l,x)}else{const t=rt,i={[yt]:"true"};ot(e,{},[t("div",{[eo]:"left",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeLeftHandler}`,style:d}),t("div",{[eo]:"top",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeTopHandler}`,style:u}),t("div",{[eo]:"right",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeRightHandler}`,style:f}),t("div",{[eo]:"bottom",...i,className:`${o} ${oo.edgeHandler} ${oo.edgeBottomHandler}`,style:g}),t("div",{[eo]:"top-left",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerTopLeftHandler}`,style:m}),t("div",{[eo]:"top-right",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerTopRightHandler}`,style:p}),t("div",{[eo]:"bottom-left",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerBottomLeftHandler}`,style:y}),t("div",{[eo]:"bottom-right",...i,className:`${o} ${oo.cornerHandler} ${oo.cornerBottomRightHandler}`,style:x})])}Array.from(e.querySelectorAll(`[${eo}]`)).forEach(e=>{tt(e,[oo.hover])})}(e,t):ro(e,t)}const no="monospace";const so="@middleware/internal-event/show-info-angle",lo={textBackground:"#1973bac6",textColor:"#ffffff"};function ho(e){return N(e,["textBackground","textColor"])}const co=10;function uo(e){const{material:t,groupQueue:i,viewScaleInfo:o}=e;let r=t?K(t):null;const a=i.map(e=>K(e));if(Array.isArray(a)&&a.length>0){r=r?re(r,{viewScaleInfo:{scale:o.scale}}):null,a[0]=re(a[0],{viewScaleInfo:o});for(let e=1;e<a.length;e++)a[e]=re(a[e],{viewScaleInfo:{scale:o.scale}})}else r=r?re(r,{viewScaleInfo:o}):null;return{viewMaterialSize:r,viewGroupSizeQueue:a}}function fo(e,t){if(!e)return null;const{className:i,targetClassName:o,viewMaterialSize:r,viewGroupSizeQueue:a}=t,n=function(e){const{viewMaterialSize:t,viewGroupSizeQueue:i,className:o,targetClassName:r}=e;let a=null;t&&(a=rt("div",{[li]:ui,[yt]:"true",[hi]:t.id,className:fi.materialBox,style:{display:"block",position:"absolute",top:t.y,left:t.x,width:t.width,height:t.height,transform:`rotate(${t.angle||0}deg)`}}),et(a,[r]));let n=a;for(let e=i.length-1;e>=0;e--){const t=i[e],o=[];n&&o.push(n),n=rt("div",{[li]:di,[yt]:"true",[hi]:t.id,className:`${fi.materialBox} ${fi.groupBox}`,style:{position:"absolute",top:t.y,left:t.x,width:t.width,height:t.height,transform:`rotate(${t.angle||0}deg)`}},o)}return n&&et(n,[o]),n}({viewMaterialSize:r,viewGroupSizeQueue:a,className:i,targetClassName:o});return n&&ot(e,{},[n]),n}function go(e,t){if(!e)return null;const{className:i,targetClassName:o,renderTargetInner:r,destoryTargetInner:a,afterRender:n}=t,s=e.getElementsByClassName(i),{viewMaterialSize:l,viewGroupSizeQueue:h}=uo(t),c=()=>{Array.from(s).forEach(e=>{e.remove()})};if(l||h.length||c(),1===s.length){const e=s[0];if(et(e,[i]),h.length>0){let e=0,t=s[0],i=t.parentElement;for(;e<h.length;){const r=h[e];if(t?(tt(t,[o]),ot(t,{[li]:di,[yt]:"true",[hi]:r.id,style:{position:"absolute",top:r.y,left:r.x,width:r.width,height:r.height,transform:`rotate(${r.angle||0}deg)`}})):(t=rt("div",{[li]:di,[yt]:"true",[hi]:r.id,className:`${fi.materialBox} ${fi.groupBox}`,style:{position:"absolute",top:r.y,left:r.x,width:r.width,height:r.height,transform:`rotate(${r.angle||0}deg)`}}),i?.appendChild(t)),i=t,e+1===h.length)break;t=t?.children?.[0],e++}if(l){let e=t?.children?.[0];e||(e=rt("div"),i?.appendChild(e)),ot(e,{[li]:ui,[yt]:"true",[hi]:l.id,style:{display:"block",position:"absolute",top:l.y,left:l.x,width:l.width,height:l.height,transform:`rotate(${l.angle||0}deg)`}}),r?.(e)}else a?.(t)}else l?(a?.(e),ot(e,{[li]:ui,[yt]:"true",[hi]:l.id,style:{display:"block",position:"absolute",top:l.y,left:l.x,width:l.width,height:l.height,transform:`rotate(${l.angle||0}deg)`}}),et(e,[o]),r?.(e)):c();return n?.({$rootBox:e,viewGroupSizeQueue:h,viewMaterialSize:l}),e}{c();const t=fo(e,{viewMaterialSize:l,viewGroupSizeQueue:h,className:i,targetClassName:o});et(t,[o]),r?.(t),n?.({$rootBox:t,viewGroupSizeQueue:h,viewMaterialSize:l})}}function mo(e,t){if(!e)return;const{className:i}=t;Array.from(e.getElementsByClassName(i)).forEach(e=>{e.remove()})}function po(e,t){const{groupQueue:i}=t;Array.isArray(i)&&i.length?go(e,{...t,className:fi.nestedBox,targetClassName:fi.nestedTargetBox}):function(e){mo(e,{className:fi.nestedBox})}(e)}function yo(e){return mo(e,{className:fi.hoverBox})}function xo(e){return mo(e,{className:fi.lockedBox})}function vo(e,t){xo(e),function(e,t){if(!e)return null;const{className:i,targetClassName:o}=t,{viewMaterialSize:r,viewGroupSizeQueue:a}=uo(t);fo(e,{viewMaterialSize:r,viewGroupSizeQueue:a,className:i,targetClassName:o})}(e,{...t,className:fi.lockedBox,targetClassName:fi.lockedTargetBox})}function wo(e){if(e.querySelectorAll(`[${ci}]`).length>0)return;const t=rt,i={[yt]:"true"};ot(e,{},[t("div",{[ci]:"left",...i,className:`${fi.edgeHandler} ${fi.edgeLeftHandler}`}),t("div",{[ci]:"top",...i,className:`${fi.edgeHandler} ${fi.edgeTopHandler}`}),t("div",{[ci]:"right",...i,className:`${fi.edgeHandler} ${fi.edgeRightHandler}`}),t("div",{[ci]:"bottom",...i,className:`${fi.edgeHandler} ${fi.edgeBottomHandler}`}),t("div",{[ci]:"top-left",...i,className:`${fi.cornerHandler} ${fi.cornerTopLeftHandler}`}),t("div",{[ci]:"top-right",...i,className:`${fi.cornerHandler} ${fi.cornerTopRightHandler}`}),t("div",{[ci]:"bottom-left",...i,className:`${fi.cornerHandler} ${fi.cornerBottomLeftHandler}`}),t("div",{[ci]:"bottom-right",...i,className:`${fi.cornerHandler} ${fi.cornerBottomRightHandler}`}),t("div",{[ci]:"rotate",...i,className:fi.rotateHandler})])}function So(e,t){const{material:i}=t;i?go(e,{...t,className:fi.selectedBox,targetClassName:fi.selectedTargetBox,renderTargetInner:wo,destoryTargetInner:e=>e.innerHTML="",afterRender:({$rootBox:e,viewMaterialSize:t})=>{if(t&&e){const{width:i,height:o}=t;Math.min(i,o)>40?tt(e,[fi.hideHandler]):et(e,[fi.hideHandler])}}}):function(e){mo(e,{className:fi.selectedBox})}(e)}function bo(e,t){if(!e)return;const{areaStart:i,areaEnd:o,selectedMaterials:r,viewScaleInfo:a}=t;let n=null,s=null,l=!1;if(r.length>1||1===r.length&&i&&o){const e=function(e){const t={x:0,y:0,width:0,height:0};let i=null;for(let o=0;o<e.length;o++){const r=e[o];if(r?.operations?.invisible)continue;const a={x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const e=G(a);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];a.x=Math.min(...t),a.y=Math.min(...i),a.width=Math.abs(Math.max(...t)-Math.min(...t)),a.height=Math.abs(Math.max(...i)-Math.min(...i))}}if(i){const e=Math.min(a.x,t.x),i=Math.min(a.y,t.y),o=Math.max(a.x+a.width,t.x+t.width),r=Math.max(a.y+a.height,t.y+t.height);t.x=e,t.y=i,t.width=Math.abs(o-e),t.height=Math.abs(r-i)}else t.x=a.x,t.y=a.y,t.width=a.width,t.height=a.height;i=a}return{x:Math.floor(t.x),y:Math.floor(t.y),width:Math.ceil(t.width),height:Math.ceil(t.height)}}(r),{x:t,y:i,width:o,height:a}=e;n={x:t,y:i},s={x:t+o,y:i+a},l=!0}else i&&o&&(n={...i},s={...o});if(n&&s){const t=function(e){const t=e.getElementsByClassName(fi.selectionAreaBox);if(t[0])return t[0];const i=rt("div",{[yt]:"true",className:fi.selectionAreaBox});return ot(e,{},[i]),i}(e);l&&(n=ae(n,{viewScaleInfo:a}),s=ae(s,{viewScaleInfo:a})),it(t,{left:Math.min(n.x,s.x),top:Math.min(n.y,s.y),width:Math.abs(s.x-n.x),height:Math.abs(s.y-n.y)})}else!function(e){mo(e,{className:fi.selectionAreaBox})}(e)}function Ao(e,t){const{groupQueue:i,$root:o}=t;if(!(i&&i?.length>0&&o))return!1;const r=i[i.length-1].id,a=e.target;if("string"==typeof r&&r){if(a?.getAttribute(li)===di&&a?.getAttribute(hi)===r)return!0;const e=st(a,o,{[li]:di});if(e?.getAttribute(li)===di&&e?.getAttribute(hi)===r)return!0}return!1}function Mo(e){return N(e,["zIndex","activeColor","handlerBorderColor","handlerBackground","handlerHoverBackground","handlerActiveBackground","selectionAreaBackground","selectionAreaBorderColor","lockedColor","referenceColor"])}const Io=(e,t)=>{const{x:i,y:o,width:r,height:a}=t,n=e.width,s=e.height;if(e.x=i,e.y=o,e.width=r,e.height=a,"circle"===e.type)e.cx=i+r/2,e.cy=o+a/2,e.r=Math.min(r,a)/2;else if("ellipse"===e.type)e.cx=i+r/2,e.cy=o+a/2,e.rx=r/2,e.ry=a/2;else if("path"===e.type){const t=r/n,i=a/s,o=e;o.commands=Ue(o.commands,t,i)}};function Co(e,t,i,o){const{stroke:r,strokeWidth:a,lineDash:n}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=r,e.setLineDash(n),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function Ro(e,t,i){const{size:o,stroke:r,strokeWidth:a,lineDash:n}=i,s=t.x-o/2,l=t.x+o/2,h=t.y-o/2,c=t.y+o/2;!function(e,t,i){const{stroke:o,strokeWidth:r,lineDash:a}=i;e.setLineDash([]),e.lineWidth=r,e.strokeStyle=o,e.setLineDash(a),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[2].x,t[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(t[1].x,t[1].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}(e,[{x:s,y:h},{x:l,y:h},{x:l,y:c},{x:s,y:c}],{stroke:r,strokeWidth:a,lineDash:n})}function Eo(e,t){const{xLines:i,yLines:o,styles:r}=t,{referenceColor:a}=r,n={stroke:a,strokeWidth:1,lineDash:[]},s={...n,size:6};i&&i.forEach(t=>{t.forEach((i,o)=>{Ro(e,i,s),t[o+1]&&Co(e,t[o],t[o+1],n)})}),o&&o.forEach(t=>{t.forEach((i,o)=>{Ro(e,i,s),t[o+1]&&Co(e,t[o],t[o+1],n)})})}function zo({$root:e,styles:t,snapshot:i,sharer:o,calculator:r,boardContent:a}){const{activeStore:n,sharedStore:s}=i,{overlayContext:l}=a,{scale:h,offsetLeft:c,offsetTop:d,offsetRight:u,offsetBottom:f,width:g,height:m,contextHeight:p,contextWidth:y,devicePixelRatio:x}=n,v={scale:h,offsetLeft:c,offsetTop:d,offsetRight:u,offsetBottom:f},w={width:g,height:m,contextHeight:p,contextWidth:y,devicePixelRatio:x},S=s[Ri],b=S[0],A=s[Ci],M=s[bi],I=s[Mi],C=s[Ii],R=s[Li],E=s[Pi],z=!!A?.operations?.locked,L={material:null,groupQueue:R||[],viewScaleInfo:v,viewSizeInfo:w,calculator:r};if(po(e,L),yo(e),xo(e),A&&A?.id!==S[0]?.id&&(L.material=A,z?vo(e,L):function(e,t){yo(e),go(e,{...t,className:fi.hoverBox,targetClassName:fi.hoverTargetBox})}(e,L)),So(e,{...L,material:1===S.length?S[0]:null}),bo(e,{...L,areaStart:I,areaEnd:C,selectedMaterials:S}),R?.length>0){if(b&&["select","drag","resize"].includes(M)&&"drag"===M&&!0===E){const e=Fi(b.id,{calculator:r,data:n.data,groupQueue:R,viewScaleInfo:v,viewSizeInfo:w});if(e){const{offsetX:i,offsetY:o,xLines:r,yLines:a}=e;0!==i&&0!==o||Eo(l,{xLines:r,yLines:a,styles:t})}}}else if(b&&["select","drag","resize"].includes(M)){if("drag"===M&&!0===E){const e=Fi(b.id,{calculator:r,data:n.data,groupQueue:R,viewScaleInfo:v,viewSizeInfo:w});if(e){const{offsetX:i,offsetY:o,xLines:r,yLines:a}=e;0!==i&&0!==o||Eo(l,{xLines:r,yLines:a,styles:t})}}}else"area"===M&&I&&C||["drag-list","drag-list-end"].includes(M)&&Vi(o.getSharedStorage(Ri),{viewScaleInfo:o.getActiveViewScaleInfo(),viewSizeInfo:o.getActiveViewSizeInfo()})}const Lo="SCROLL",Bo=Symbol(`${Lo}_xThumbStyle`),ko=Symbol(`${Lo}_yThumbStyle`),Po=Symbol(`${Lo}_prevPoint`),To=Symbol(`${Lo}_activePoint`),No=Symbol(`${Lo}_activeThumbType`),Do="idraw-middleware-scroller",$o=16,Ho=40,Wo="data-idraw-thumb-type",Oo={zIndex:2,thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"},Vo={horizontal:`${Do}-horizontal`,vertical:`${Do}-vertical`,thumb:`${Do}-thumb`};function Yo(e){return N(e,["zIndex","thumbBackground","thumbBorderColor","hoverThumbBackground","hoverThumbBorderColor","activeThumbBackground","activeThumbBorderColor"])}function jo(e){const t=e.target;return!!(t?.classList?.contains(Vo.thumb)||t?.classList?.contains(Vo.horizontal)||t?.classList?.contains(Vo.vertical))}function Go(e){const{xThumbStyle:t,yThumbStyle:i,$horizontal:o,$vertical:r}=e;if(o&&t){const e=o.getElementsByClassName(Vo.thumb)[0];e&&it(e,t)}if(r&&i){const e=r.getElementsByClassName(Vo.thumb)[0];e&&it(e,i)}}function Fo(e){const t=e?.target;return t?.classList?.contains(Vo.thumb)&&t.hasAttribute(Wo)?t.getAttribute(Wo):null}const Xo=16,Qo="monospace",Uo={background:"#FFFFFFA8",stroke:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#19609780"};function Zo(e){return N(e,["background","stroke","scaleColor","textColor","gridColor","gridPrimaryColor","selectedAreaColor"])}const Jo=[1,2,5,10,20,50,100,200,500];function Ko(e){const{scale:t,viewLength:i,viewOffset:o}=e,r=[];let a=10;a=ue(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(Jo[0],Math.min(e,Jo[Jo.length-1]));for(let t=0;t<Jo.length-1;t++){const i=Jo[t],o=Jo[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const n=10*a,s=5*a;let l=0;const h=a*t,c=0-o,d=c%h,u=(c-d+h)/t,f=h-d+0;for(;f+l*h<i;){const e=ue(u+l*a,{decimalPlaces:0}),t={num:e,position:ue(f+l*h,{decimalPlaces:0}),showNum:e%n===0,isKeyNum:e%n===0,isSubKeyNum:e%s===0};r.push(t),l++}return{list:r,rulerUnit:a}}const qo="idraw-middleware-text-editor",_o={zIndex:1,boxBorderColor:"#0c8ce9"},er={textarea:`${qo}-textarea`,hide:`${qo}-hide`,canvasWrapper:`${qo}-canvas-wrapper`};function tr(e){return N(e,["zIndex","boxBorderColor"])}const ir=pe();const or=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:r,y:a,width:n,height:s}=t;return it(o,{position:"absolute",left:`${r}px`,top:`${a}px`,width:`${n}px`,height:`${s}px`,transform:`rotate(${X(t.angle||0)}deg)`}),i.appendChild(o),o},rr=Symbol("DRAG_prevPoint"),ar="idraw-middleware-path-creator",nr={hide:`${ar}-hide`,anchor:`${ar}-anchor`,director:`${ar}-director`,directorLines:`${ar}-director-lines`,pathLine:`${ar}-path-line`,selected:`${ar}-selected`},sr="data-uuid",lr="data-x",hr="data-y",cr="data-w",dr="data-h",ur="data-angle",fr="data-type",gr="data-helper-type",mr="data-anchor-cmd-type",pr="data-anchor-index",yr="data-anchor-id",xr="data-director-from-anchor-id",vr="data-director-control-type",wr="data-director-opened-by-anchor-id",Sr="material",br="anchor",Ar="director",Mr="director-line",Ir="path-preview",Cr="path-definition",Rr={zIndex:2,anchorSize:8,anchorSelectedSize:12,anchorBorderWidth:2,anchorBorderColor:"#0c8ce9",anchorBackground:"#ffffff",anchorHoverBorderColor:"#1671b8",anchorHoverBackground:"#cfe4f4",anchorActiveBorderColor:"#0d548c",anchorActiveBackground:"#88c0ec",directorSize:10,directorBorderWidth:2,directorBorderColor:"#7315d1ff",directorBackground:"#ffffff",directorHoverBorderColor:"#4716b8ff",directorHoverBackground:"#ebcff4ff",directorActiveBorderColor:"#510d8cff",directorActiveBackground:"#c988ecff",directorLineColor:"#7315d1ff",helperStrokeColor:"#0c8ce9",helperStrokeWidth:1};function Er(e){return N(e,["zIndex","anchorSize","anchorSelectedSize","anchorBorderWidth","anchorBorderColor","anchorBackground","anchorHoverBorderColor","anchorHoverBackground","anchorActiveBorderColor","anchorActiveBackground","directorSize","directorBorderWidth","directorBorderColor","directorBackground","directorHoverBorderColor","directorHoverBackground","directorActiveBorderColor","directorActiveBackground","directorLineColor","helperStrokeColor","helperStrokeWidth"])}const zr=(e,t)=>{const{size:i,parent:o}=e,{x:r,y:a,width:n,height:s}=i,l=X(i.angle||0),h=rt("div",{[yt]:"true",style:{position:"absolute",left:r,top:a,width:n,height:s,transform:`rotate(${l}deg)`},...t});return o.appendChild(h),h},Lr=e=>({id:e.getAttribute(sr)||"",type:e.getAttribute(fr)||"",x:parseFloat(e.getAttribute(lr)||"0"),y:parseFloat(e.getAttribute(hr)||"0"),w:parseFloat(e.getAttribute(cr)||"0"),h:parseFloat(e.getAttribute(dr)||"0"),angle:parseFloat(e.getAttribute(ur)||"0")}),Br=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}},kr=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}},Pr=e=>({type:e.getAttribute(vr),fromAnchorId:e.getAttribute(xr)||"",openedAnchorId:e.getAttribute(wr)||""}),Tr=e=>{const t=e.querySelectorAll(`[${gr}="${Mr}"]`);Array.from(t).forEach(e=>{e?.remove()})},Nr=(e,t)=>{const i=e.querySelector(`[${gr}="${Sr}"]`),o=e.querySelector(`[${gr}="${Ir}"]`);if(!i||!o)return;Tr(e);const{currentDirector:r,prevDirector:a,styles:n}=t;if(a||r){const e=((e,t)=>{const{styles:i}=t,o=`\n <svg\n width="100%"\n height="100%"\n overflow="visible"\n xmlns="http://www.w3.org/2000/svg" \n ${yt}="true"\n >\n ${e.map(e=>{if(!e)return"";const{anchorPoint:t,directPoint:o}=e,r=t.x,a=t.y;return`<line \n x1="${r}" \n x2="${o.x}" \n y1="${a}" \n y2="${o.y}" \n stroke="${i.directorLineColor}" \n stroke-width="2" \n ${yt}="true"\n />`}).join("")}\n </svg>\n `;return rt("div",{width:"100%",height:"100%",className:nr.directorLines,[gr]:Mr,[yt]:"true"},[at(o)])})([a,r],{styles:n});i.firstElementChild&&i.insertBefore(e,o)}},Dr=e=>{if(!e)return;const t=e.querySelectorAll(`[${gr}="${Ar}"]`);Array.from(t).forEach(e=>{e?.remove()}),Tr(e)},$r=(e,t)=>{const{selectedAnchorId:i,prevDirector:o,currentDirector:r,styles:a}=t,n=[];o&&n.push(o),r&&n.push(r);const s=Array.from(e.querySelectorAll(`[${gr}="${Ar}"]`));let l=!1;if(n.length===s.length)for(let e=0;e<s.length;e++){const t=s[e],o=n[e],r=Pr(s[e]);if(r.openedAnchorId!==i||r.fromAnchorId!==o.anchorId){l=!0;break}it(t,kr({x:o.directPoint.x,y:o.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth}))}else l=!0;l&&Hr(e,{prevDirector:o,currentDirector:r,styles:a})},Hr=(e,t)=>{if(!e)return;const i=e.querySelector(`[${gr}="${Sr}"]`);if(!i)return;Dr(e),Nr(e,t);const{currentDirector:o,prevDirector:r,styles:a}=t;if(r){const e=rt("div",{[gr]:Ar,[vr]:"curve-ctrl2",[xr]:r.anchorId,[wr]:r.openedByAnchorId,[yt]:"true",className:nr.director,style:{...kr({x:r.directPoint.x,y:r.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth})}});i.appendChild(e)}if(o){const e=rt("div",{[gr]:Ar,[vr]:"curve-ctrl1",[xr]:o.anchorId,[wr]:o.openedByAnchorId,[yt]:"true",className:nr.director,style:{...kr({x:o.directPoint.x,y:o.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth})}});i.appendChild(e)}},Wr=(e,t)=>{if(!e)return;const i=e.querySelector(`[${gr}="${Sr}"]`);if(!i)return;const o=rt("div",{className:nr.pathLine,[gr]:Ir,[yt]:"true"});i.firstElementChild&&i.insertBefore(o,i.firstElementChild),Vr(e,t)},Or=(e,t)=>{const i=e.querySelector(`[${gr}="${Ir}"]`);if(!i)return;const o=i.querySelector(`[${gr}="${Cr}"]`);if(o){const{anchorCommands:e}=t;ot(o,{d:de(e)})}else Vr(e,t)},Vr=(e,t)=>{const i=e.querySelector(`[${gr}="${Ir}"]`);if(!i)return;i?.children&&Array.from(i.children).forEach(e=>{e.remove()});const{anchorCommands:o,styles:r}=t;ot(i,{},[at(`\n <svg \n width="100%" \n height="100%" \n overflow="visible" \n fill="transparent"\n ${yt}="true"\n >\n <path \n ${gr}="${Cr}" \n d="${de(o)}" \n stroke="${r.helperStrokeColor}"\n stroke-width="${r.helperStrokeWidth}"\n ${yt}="true"\n />\n </svg>\n `)])};function Yr(e,t){const{pageX:i,pageY:o}=e,r=t.getBoundingClientRect(),a=window.scrollX||document.documentElement.scrollLeft,n=window.scrollY||document.documentElement.scrollTop;return{x:i-(r.left+a),y:o-(r.top+n)}}function jr(e,t){const{calculator:i}=t,{id:o}=e;return[...i.getVirtualItem(o).anchorCommands||[]]}const Gr="idraw-middleware-path-creator",Fr={hide:`${Gr}-hide`,anchor:`${Gr}-anchor`,selected:`${Gr}-selected`},Xr="data-x",Qr="data-y",Ur="data-helper-type",Zr="data-anchor-cmd-type",Jr="data-anchor-index",Kr="data-anchor-id",qr="anchor",_r={anchorSize:8,anchorBorderWidth:2,anchorBorderColor:"#157ed1",anchorBackground:"#ffffff",anchorHoverBorderColor:"#1671b8",anchorHoverBackground:"#cfe4f4",anchorActiveBorderColor:"#0d548c",anchorActiveBackground:"#88c0ec",defaultStroke:"#a0a0a0",defaultStrokeWidth:2};function ea(e){return N(e,["anchorSize","anchorBorderWidth","anchorBorderColor","anchorBackground","anchorHoverBorderColor","anchorHoverBackground","anchorActiveBorderColor","anchorActiveBackground","defaultStroke","defaultStrokeWidth"])}const ta=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}};function ia(e,t){const{point:i,viewScaleInfo:o,styles:r}=t,a=Array.from(e.querySelectorAll(`[${Ur}="${qr}"]`)),n=a.length,s=Xe(),l=function(e){const{id:t,index:i,point:o,commandType:r,viewScaleInfo:a,styles:n}=e,s=ae(o,{viewScaleInfo:a});return rt("div",{[Ur]:qr,[Zr]:r,[Jr]:i,[Kr]:t,[yt]:"true",[Xr]:o.x,[Qr]:o.y,className:Fr.anchor,style:{...ta({x:s.x,y:s.y,size:n.anchorSize,borderWidth:n.anchorBorderWidth}),display:"block"}})}({index:n,id:s,point:i,styles:r,viewScaleInfo:o,commandType:0===n?"M":"C"});if(0===n)e.appendChild(l);else{a[a.length-1].after(l)}return{id:s}}function oa(e,t){const{viewScaleInfo:i,styles:o}=t;Array.from(e.querySelectorAll(`[${Ur}="${qr}"]`)).forEach(e=>{const t={id:(r=e).getAttribute(Kr)||"",type:r.getAttribute(Ur)||"",x:parseFloat(r.getAttribute(Xr)||"0"),y:parseFloat(r.getAttribute(Qr)||"0")};var r;const a=ae({x:t.x,y:t.y},{viewScaleInfo:i});it(e,ta({...a,size:o.anchorSize,borderWidth:o.anchorBorderWidth}))})}const ra="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjIuMyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZURhdGU9IjIwMjMtMDktMTdUMTY6MzE6MjMrMDg6MDAiIHhtcDpNb2RpZnlEYXRlPSIyMDIzLTA5LTE3VD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Re2DtNI/QB93p4eJgQXUTqQbnwjjU1NdH09HSyra3t2+bm5kfoI0/LAbDDt3hcW1uj9fV1CiMMZHd3t+a8ZDJJ2SynBzWAiTcUA7acWbfKGYbxF8buqakp7ezs7E4GMpkMDQ0Nuc6RN9Td3U2FQqHiXDikeDxOyB1CDv1jmuY1Y4K6Brz/jdB3WltbP11dXf0Fk3Ih9tPp7e11cwBbUTMHEIwNBv4eHR39Gmx8CDtmu4EZ4EV485yjo6OrsbGx31taWh4DcQZ2ScfLYGbJHS8vL42FhYXv2tvbmzkyFvQAHiLj4+O/bm5uHqZSKffDhB3DxoaW4F/HMT0B2H28K4lPAWApOlKnp6dPoLxZDeQ1FiksmmLLyOVyRiWq0ab/29jY4MxkAKZyYqlrtskrlTrh5oCtEPHDa2VQUgYJ8pOU53K3M+V8lwvaMdtkAwFZARUQXAN0dW9JISqRX6HEOPhh4TYh6ANmDACsKgB48QsVjDiR9QVEsZwBqXRCmUk+7cE2nFKLcFZXbDQAVlAM8ChU3+RYgI1bOUDkNwpHvZSGI6xoylCeV/vyFZp1BaBQtnZQbxYOirwop9hWztlBJKKKg/QkIURtjam0oBi4U+r5HrihEsIRUmNjo1vhEomEzCvRbcprSthPsiB1sYuLi8cYP56ZmdGurq4IzYVQRf/F8XxGFWi+D2HKOQmboO+hUH2+srLyGyqmDjYsgNgcGRl5CCY+wfu3oVzrY2EXDivMc4NaPAMQrSxIhwQif4oK9z+en5F3CriecA7U/E2rB4AcxQcKBI/udwR5SStFKKuuayagLFqPyOeVnGmOkCOVY6crx5KMNSX0L5QSqWyOutbVvRQXk/wiE0qeA2qKq4lnbJY2AAAAAElFTkSuQmCC"};#ge={};constructor(e,t){this.#ce=e,this.#X=t.eventHub,this.#S(),this.#me(),Object.keys(this.#fe).forEach(e=>{const t=`${aa}-${e}`;this.#ge[e]=t;const i=this.#fe[e];this.#pe(e,t,i)})}#pe(e,t,i){const{offsetX:o,offsetY:r}=this.#ye(e);mt({rootClassName:t,type:"element",styles:{cursor:`image-set(url(${i})2x) ${o} ${r}, auto`}})}#S(){const e=this.#X;this.#xe("default"),e.on(o.CURSOR,e=>{"over-material"!==e.type&&e.type?"resize-rotate"===e.type?this.#xe("rotate"):"string"==typeof e.type&&e.type?.startsWith("resize-")?this.#ve(e):"drag-default"===e.type?this.#xe("drag-default"):"drag-active"===e.type?this.#xe("drag-active"):"pen"===e.type?this.#xe("pen"):"plus"===e.type?this.#xe("plus"):this.#xe("auto"):this.#xe("auto")})}#me(){g(ra).then(e=>{this.#ue=e}).catch(e=>{console.error(e)})}#ye(e){let t=0,i=0;return e.startsWith("rotate-")&&this.#fe[e]||"rotate"===e?(t=10,i=10):"plus"===e&&(t=5,i=3),{offsetX:t,offsetY:i}}#xe(e){if(this.#de===e)return;this.#de=e;const t=this.#ce,i=this.#ge[e]||this.#ge.auto;tt(t,Object.keys(this.#ge).map(e=>this.#ge[e])),et(t,[i])}#ve(e){let t=0;"resize-top"===e.type?t+=0:"resize-top-right"===e.type?t+=45:"resize-right"===e.type?t+=90:"resize-bottom-right"===e.type?t+=135:"resize-bottom"===e.type?t+=180:"resize-bottom-left"===e.type?t+=225:"resize-left"===e.type?t+=270:"resize-top-left"===e.type&&(t+=315),t+=X(e?.material?.angle||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach(e=>{t+=X(e.angle||0)}),t=X(t);const i=this.#we(t);this.#xe(i)}#we(e){const t=`rotate-${e}`;if(!this.#fe[t]){const i=this.#ue;if(i){const o=document.createElement("canvas"),r=i.width,a=i.height,n={x:r/2,y:a/2};o.width=r,o.height=a;const s=o.getContext("2d"),l=D(e);s.translate(n.x,n.y),s.rotate(l),s.translate(-n.x,-n.y),s.drawImage(i,0,0,r,a),s.translate(n.x,n.y),s.rotate(-l),s.translate(-n.x,-n.y);const h=o.toDataURL("image/png");this.#fe[t]=h;const c=`${aa}-${t}`;this.#ge[t]=c,this.#pe(t,c,h)}}return t}}function sa(e){const{modifiedMaterial:t,beforeMaterial:i}=e,{id:o,...r}=t,a=ve(r);let n={};Object.keys(a).forEach(e=>{let t=Ae(i,e);void 0===t&&/(cornerRadius|strokeWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=Ae(i,e)),n[e]=t}),n=ve(n);return{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:o,before:n,after:a}}}return e.Board=Xt,e.Calculator=Ht,e.Core=class{#Se;#be;#ce;constructor(e,t){const{devicePixelRatio:i=1,width:o,height:r,disableWatcher:a=!1}=t;it(e,{width:o,height:r}),this.#ce=e;const n=document.createElement("canvas");n.setAttribute("tabindex","0"),it(n,{margin:0,padding:0}),this.#be=n,this.#Ae(),e.appendChild(n);const s=z(n,{width:o,height:r,devicePixelRatio:i}),l=new Xt({boardContent:s,container:e,disableWatcher:a}),h=l.getSharer();h.setActiveViewSizeInfo({width:o,height:r,devicePixelRatio:i,contextWidth:o,contextHeight:r}),this.#Se=l,this.resize(h.getActiveViewSizeInfo());const c=l.getEventHub();new na(e,{eventHub:c})}isDestroyed(){return this.#Se.isDestroyed()}destroy(){this.#Se.destroy(),this.#be.remove()}#Ae(){it(this.#ce,{position:"relative",margin:"0px",padding:"0px",overflow:"hidden"})}use(e,t){this.#Se.use(e,t)}disuse(e){this.#Se.disuse(e)}resetMiddlewareConfig(e,t){this.#Se.resetMiddlewareConfig(e,t)}#Me(e){Q(e?.materials||[]),this.#Se.setData(e)}setData(e){this.#Se.getRenderer().getLoader().reset(),this.#Me(e)}getData(){return this.#Se.getData()}scale(e){this.#Se.scale(e);this.#Se.getViewer().drawFrame()}resize(e){const t=this.#Se,i=this.#ce,o={...t.getSharer().getActiveViewSizeInfo(),...e},{width:r,height:a}=o;it(i,{width:r,height:a}),t.resize(o)}clear(){this.#Se.clear()}on(e,t){this.#Se.getEventHub().on(e,t)}off(e,t){this.#Se.getEventHub().off(e,t)}trigger(e,t){this.#Se.getEventHub().trigger(e,t)}getViewInfo(){const e=this.#Se.getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){this.#Se.getViewer().drawFrame()}forceRender(){const e=this.#Se.getRenderer(),t=e.getCalculator(),i=e.getLoader(),o=this.getData();if(o){const{viewScaleInfo:e,viewSizeInfo:i}=this.getViewInfo();t.resetVirtualItemMap(o,{viewScaleInfo:e,viewSizeInfo:i})}i.reset(),this.refresh()}setViewScale(e){this.#Se.updateViewScaleInfo(e)}getLoadItemMap(){return this.#Se.getRenderer().getLoadItemMap()}onBoardWatcherEvents(){this.#Se.onWatcherEvents()}offBoardWatcherEvents(){this.#Se.offWatcherEvents()}createMaterial(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r}=this.getViewInfo();return Le(e,t||{},!0===i?.viewCenter?{viewScaleInfo:o,viewSizeInfo:r}:void 0)}updateMaterial(e){const t=this.getData()||{materials:[]},i=e.id,o=_(i,t.materials),r=q(o,t.materials);if(!r)return null;const a=ve(r),n=ve(Ne(o,e,t.materials,{onlyUpdateContent:!0}));this.#Se.getRenderer().getLoader().resetMaterialAsset(e),this.#Me(t),this.refresh();return{type:"updateMaterial",time:Date.now(),content:{method:"updateMaterial",id:i,before:a,after:n}}}modifyMaterial(e){const{id:t,...i}=e,o=this.getData()||{materials:[]},r=_(t,o.materials),a=q(r,o.materials);if(!a)return null;const n=sa({modifiedMaterial:e,beforeMaterial:a});Ne(r,i,o.materials);return this.#Se.getRenderer().getLoader().resetMaterialAsset({...e,type:a.type}),this.#Me(o),this.refresh(),n}modifyMaterials(e){const t=this.getData()||{materials:[]};let i=null;const o=[],r=[];return e.forEach(e=>{const{id:i,...a}=e,n=_(i,t.materials),s=q(n,t.materials);if(!s)return null;const l=sa({modifiedMaterial:e,beforeMaterial:s});l.content&&(o.push({...l.content.before,id:i}),r.push({...l.content.after,id:i})),Ne(n,a,t.materials)}),i={type:"modifyMaterials",time:Date.now(),content:{method:"modifyMaterials",before:o,after:r}},this.#Me(t),this.refresh(),i}addMaterial(e,t){const i=this.getData()||{materials:[]};if(t&&t?.position?.length){if(t?.position){Be(e,[...t?.position||[]],i.materials)}}else i.materials.push(e);const o=_(e.id,i.materials),r={type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:e.id,position:o,material:c(e)}};return this.#Me(i),this.refresh(),r}deleteMaterial(e){const t=this.getData()||{materials:[]},i=_(e,t.materials),o=q(i,t.materials),r={type:"deleteMaterial",time:Date.now(),content:{method:"deleteMaterial",id:e,position:i,material:o?c(o):null}};if(o){this.#Se.getRenderer().getLoader().resetMaterialAsset(o)}return function(e,t){ke(_(e,t),t)}(e,t.materials),this.#Me(t),this.refresh(),r}moveMaterial(e,t){const i=this.getData()||{materials:[]},o=_(e,i.materials),r={type:"moveMaterial",time:Date.now(),content:{method:"moveMaterial",id:e,from:[...o],to:[...t]}},{materials:a}=function(e,t){const i=[...t.from],o=[...t.to];if(0===i.length||0===o.length)return{materials:e,from:i,to:o};if(i.length<=o.length)for(let t=0;t<i.length;t++)if(o[t]!==i[t]);else if(t===i.length-1)return{materials:e,from:i,to:o};const r=q(i,e);if(r){if(!Be(r,o,e))return{materials:e,from:i,to:o};let t=-1,a=!1;if(i.length>=1&&o.length>=1){if(i.length<=o.length)if(1===i.length)i[0]<o[0]&&(a=!0);else for(let e=0;e<i.length&&i[e]===o[e];e++)if(i.length===i.length-1){a=!0;break}if(i.length>=o.length)if(1===o.length)o[0]<i[0]&&(a=!0);else for(let e=0;e<o.length&&(e===o.length-1&&o[e]<i[e]&&(a=!0),i[e]===o[e]);e++);}if(!0===a)for(let e=0;e<i.length&&o[e]>=0;e++)o[e]!==i[e]&&o[e]<i[e]&&e==o.length-1&&(t=e);t>=0&&(i[t]=i[t]+1),ke(i,e)}return{materials:e,from:i,to:o}}(i.materials,{from:o,to:t});return i.materials=a,this.#Me(i),this.refresh(),r}modifyLayout(e){const t=this.getData()||{materials:[]},i={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:null,after:null}};if(null===e)return t.layout?(i.content.before=we(t.layout),delete t.layout,this.#Me(t),this.refresh(),i):i;const o=t.layout;let r={};const a=we(e);return t.layout?(Object.keys(a).forEach(e=>{let t=Ae(o,e);void 0===t&&/(cornerRadius|strokeWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=Ae(o,e)),r[e]=t}),r=we(r),i.content.before=r):t.layout={},i.content.after=a,function(e,t){const i=we(t),o=[];Object.keys(i).forEach(t=>{if(!o.includes(t)){const o=i[t];Ie(e,t),void 0!==o&&Me(e,t,o)}})}(t.layout,e),this.#Me(t),this.refresh(),i}modifyGlobal(e){const t=this.getData()||{materials:[]},i={type:"modifyGlobal",time:Date.now(),content:{method:"modifyGlobal",before:null,after:null}};if(null===e)return t.global?(i.content.before=Se(t.global),delete t.global,this.#Me(t),this.refresh(),i):i;const o=t.global;let r={};const a=Se(e);return t.global?(Object.keys(a).forEach(e=>{r[e]=Ae(o,e)}),r=Se(r),i.content.before=r):t.global={},i.content.after=a,function(e,t){const i=Se(t),o=[];Object.keys(i).forEach(t=>{if(!o.includes(t)){const o=i[t];Ie(e,t),void 0!==o&&Me(e,t,o)}})}(t.global,e),this.#Me(t),this.refresh(),i}},e.MiddlewareCreator=(e,t)=>{const{sharer:i,viewer:r,calculator:a,eventHub:n}=e;let s={...qt,..._t,...t};const l=ti(s),h=`${Kt}-${Xe()}`;let d=null,u=null;const f=()=>{i.setSharedStorage(Ut,null),i.setSharedStorage(Zt,null),u=null};f();let g=!1;const m=({type:e})=>{g=!0,d&&(n.trigger(o.CURSOR,{type:"plus"}),i.setSharedStorage(Jt,e),et(d,[ei.creative]),n.trigger(o.CLEAR_SELECT))},p=()=>{n.trigger(o.CURSOR,{type:"auto"}),g=!1,d&&tt(d,[ei.creative])};return{name:"@middleware/creator",use(){!function(e,t){const i=e=>`.${e}`;mt({styles:{display:"none",zIndex:t.zIndex,position:"absolute",background:"transparent",top:0,bottom:0,left:0,right:0,overflow:"hidden",[`&${i(ei.creative)}`]:{display:"block"},[i(ei.creationAreaBox)]:{position:"absolute",outline:`1.5px solid ${t.creationAreaBorderColor}`,background:"#0000ff1f"}},rootClassName:e,type:"element"})}(h,l),d=function(e){const{rootClassName:t,$container:i}=e,o=rt("div",{className:t,[yt]:"true"},[]);return i.appendChild(o),o}({rootClassName:h,$container:e.container}),n.on(o.CREATE,m),n.on(o.CLEAR_CREATE,p)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),d?.remove(),d=null,n.trigger(o.CURSOR,{type:"auto"}),n.off(o.CREATE,m),n.off(o.CLEAR_CREATE,p)},resetConfig(e){s={...s,...e}},pointStart:e=>{f(),g&&i.setSharedStorage(Ut,e.point)},pointMove:e=>{if(!g)return;i.setSharedStorage(Zt,e.point);const t=i.getSharedStorage(Jt),o=i.getSharedStorage(Ut),n=i.getSharedStorage(Zt),s=i.getActiveViewScaleInfo(),l=i.getActiveViewSizeInfo(),h=i.getActiveStorage("data");u&&o&&n?(u=function(e,t){const i=ri(t),{type:o}=e,r={...e,...i};return"circle"===o?r.r=Math.min(i.width,i.height)/2:"ellipse"===o?(r.rx=i.width/2,r.ry=i.height/2):"text"===o&&(r.fontSize=Math.min(i.width,i.height)),r}(u,{start:o,end:n,viewScaleInfo:s,calculator:a}),Te(u.id,u,h.materials),a.modifyVirtualAttributes(u,{viewScaleInfo:s,viewSizeInfo:l,groupQueue:[]})):t&&o&&n&&(u=function(e,t){const{fill:i,text:o,href:r}=pe(),a={fill:i};return"circle"===e?a.r=1:"ellipse"===e?(a.rx=1,a.ry=1):"text"===e?(a.text=o,a.fontSize=1):"image"===e?a.href=r:"group"===e&&(a.children=[]),{id:Xe(),type:e,...a,...ri(t)}}(t,{start:o,end:n,viewScaleInfo:s,calculator:a}),h.materials.push(u),a.resetVirtualItemMap(h,{viewScaleInfo:s,viewSizeInfo:l})),r.drawFrame()},pointEnd:()=>{if(g){if(u){const e=i.getActiveStorage("data"),t={type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:u.id,position:[e.materials?.length],material:c(u)}};ai(n,{data:e,type:"addMaterial",modifyRecord:t},"all")}if(!0===s.selectAfterCreated&&u?.id){const e=u.id;n.trigger(o.SELECT,{ids:[e],type:"selectMaterial"})}s.afterCreated?.(),ii(d),p(),f()}},beforeDrawFrame(){const e=i.getSharedStorage(Ut),t=i.getSharedStorage(Zt);e&&t?oi(d,{start:e,end:t}):ii(d)}}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:r}=e;let a=!1;return{name:"@middleware/dragger",hover(){!0!==a&&t.trigger(o.CURSOR,{type:"drag-default"})},pointStart(e){const{point:r}=e;i.setSharedStorage(rr,r),a=!0,t.trigger(o.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,o=i.getSharedStorage(rr);if(t&&o){const e=t.x-o.x,i=t.y-o.y;r.scroll({moveX:e,moveY:i}),r.drawFrame()}i.setSharedStorage(rr,t)},pointEnd(){a=!1,i.setSharedStorage(rr,null),t.trigger(o.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o,eventHub:r}=e,{overlayContext:a}=i;let s={...lo,...t};const l=ho(s);let h=!0;const c=({show:e})=>{h=e};return{name:"@middleware/info",use(){r.on(so,c)},disuse(){r.off(so,c)},resetConfig(e){s={...s,...e}},beforeDrawFrame({snapshot:e}){const{sharedStore:t}=e,i=t[Ri],r=t[bi],s=t[Li]||[];if(1===i?.length){const t=i[0];if(t&&["select","drag","resize"].includes(r)){const i=P(e),r=T(e),{x:c,y:d,width:u,height:f,angle:g}=t,m=[...s,{id:n(),x:c,y:d,width:u,height:f,angle:g,type:"group",children:[]}],p={viewScaleInfo:i,viewSizeInfo:r},y=o.calcViewBoundingInfoFromOrigin(t.id,p);let x=0;m.forEach(e=>{x+=e.angle||0});const v=D(X(0-x));if(y){const e=y?.center,i={topLeft:V(e,y.topLeft,v),topRight:V(e,y.topRight,v),bottomRight:V(e,y.bottomRight,v),bottomLeft:V(e,y.bottomLeft,v),center:V(e,y.center,v),top:V(e,y.top,v),right:V(e,y.right,v),bottom:V(e,y.bottom,v),left:V(e,y.left,v)},o=ue(t.x,{decimalPlaces:2}),r=ue(t.y,{decimalPlaces:2}),n=ue(t.width,{decimalPlaces:2}),s=ue(t.height,{decimalPlaces:2}),c=`${ue(o,{decimalPlaces:0})},${ue(r,{decimalPlaces:0})}`,d=`${ue(n,{decimalPlaces:0})}x${ue(s,{decimalPlaces:0})}`,u=`${ue(X(t.angle||0),{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textColor:h,textBackground:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:no});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x-o/2-t,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=h,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.bottom.x,y:i.bottom.y+co},rotateCenter:i.center,angle:x,text:d,fontSize:co,lineHeight:16,styles:l}),function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textBackground:h,textColor:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:no});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.topLeft.x,y:i.topLeft.y-20},rotateCenter:i.center,angle:x,text:c,fontSize:co,lineHeight:16,styles:l}),h&&!1!==t.operations?.rotatable&&function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textBackground:h,textColor:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:no});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.top.x+co+4,y:i.top.y-20-18},rotateCenter:i.center,angle:x,text:u,fontSize:co,lineHeight:16,styles:l})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,calculator:r,viewer:a,eventHub:n}=e;let s={...io,...t};const l=function(e){return N(e,["zIndex","activeColor","handlerBorderColor","handlerBackground","handlerHoverBackground","handlerActiveBackground"])}(s),h=`${_i}-${Xe()}`;let c=null,d=null,u=null,f=null;const g=()=>{c=null,i.setSharedStorage(Qi,null),i.setSharedStorage(Ui,null),i.setSharedStorage(Zi,null),i.setSharedStorage(Ji,null),i.setSharedStorage(Ki,null),i.setSharedStorage(qi,null),d=null,u=null},m=()=>{const e=i.getSharedStorage(bi);return!(!e||"area"===e)&&(g(),!0)},p=()=>{const e=i.getActiveStorage("data");if(e?.layout){const{x:t,y:i,width:o,height:r}=e.layout;return{x:t,y:i,width:o,height:r}}return null},y=e=>{const t=p();if(t){const{x:o,y:r,width:a,height:n}=t;return le(e,re({x:o-5,y:r-5,width:a+10,height:n+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},x=e=>{const t=i.getActiveStorage("data"),r=e.nativeEvent.target;let a=null;if(r?.hasAttribute(eo)&&t?.layout&&e?.point){i.setSharedStorage(Ui,null);const e=r.getAttribute(eo);e&&(i.setSharedStorage(Ui,e),n.trigger(o.CLEAR_SELECT),a=e)}return a?i.setSharedStorage(Ji,!0):i.setSharedStorage(Ji,!1),a},v=e=>{!0!==i.getSharedStorage(qi)&&n.trigger(o.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],material:p()})};return{name:"@middleware/layout-selector",use:()=>{g(),function(e,t){const i=e=>`.${e}`;mt({styles:{zIndex:t.zIndex,position:"absolute",background:"transparent",[`&${i(oo.hover)}`]:{[`&${i(oo.cornerHandler)}`]:{display:"none"},[`&${i(oo.edgeHandler)}`]:{width:"1px",height:"1px",[`&${i(oo.edgeLeftHandler)}`]:{width:"1px"},[`&${i(oo.edgeRightHandler)}`]:{width:"1px"},[`&${i(oo.edgeTopHandler)}`]:{height:"1px"},[`&${i(oo.edgeBottomHandler)}`]:{height:"1px"}}},[`&${i(oo.cornerHandler)}`]:{outline:`1.5px solid ${t.handlerBorderColor}`,background:t.handlerBackground,width:"10px",height:"10px",top:"unset",bottom:"unset",left:"unset",right:"unset","&:hover":{background:t.handlerHoverBackground},"&:active":{background:t.handlerActiveBackground},[`&${i(oo.cornerTopLeftHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(oo.cornerTopRightHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(oo.cornerBottomLeftHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(oo.cornerBottomRightHandler)}`]:{transform:"translate(-50%, -50%)"}},[`&${i(oo.edgeHandler)}`]:{width:"10px",height:"10px","&:after":{position:"absolute",content:'""',background:t.handlerBorderColor},[`&${i(oo.edgeLeftHandler)}`]:{width:"10px",transform:"translateX(-50%)","&:after":{top:0,bottom:0,left:"50%",right:"unset",width:to}},[`&${i(oo.edgeRightHandler)}`]:{width:"10px",transform:"translateX(-50%)","&:after":{top:0,bottom:0,left:"50%",right:"unset",width:to}},[`&${i(oo.edgeTopHandler)}`]:{height:"10px",transform:"translateY(-50%)","&:after":{left:0,right:0,top:"50%",bottom:"unset",height:to}},[`&${i(oo.edgeBottomHandler)}`]:{height:"10px",transform:"translateY(-50%)","&:after":{left:0,right:0,top:"50%",bottom:"unset",height:to}}}},rootClassName:e,type:"element"})}(h,l)},disuse:()=>{g(),function(e){pt({rootClassName:e,type:"element"})}(h)},resetConfig(e){s={...s,...e}},hover:e=>{if(!0===i.getSharedStorage(qi))return;y(e.point)?i.setSharedStorage(Zi,!0):(i.setSharedStorage(Zi,!1),!0===d&&(a.drawFrame(),d=!1));const t=i.getSharedStorage(Qi),o=i.getActiveStorage("data");if(o?.layout)if("resize"!==t){const t=x(e);t?v(t):(v(),i.setSharedStorage(Qi,null))}else{const t=x(e);v(t)}},pointStart:t=>{y(t.point)?i.setSharedStorage(Ki,!0):(!0===u&&(e.container&&ro(e.container,{rootClassName:h}),g(),a.drawFrame()),i.setSharedStorage(Ki,!1));const r=i.getActiveStorage("data");f=r?.layout?K(r.layout):null;const s=x(t);if(c=t.point,s&&i.setSharedStorage(Qi,"resize"),!0!==i.getSharedStorage(Ki)||u||(a.drawFrame(),n.trigger(o.SELECT_LAYOUT)),u=i.getSharedStorage(Ki),!0===i.getSharedStorage(Ji))return!1},pointMove:e=>{if(!i.getSharedStorage(Ki)&&m())return;const t=i.getSharedStorage(Qi),o=i.getSharedStorage(Ui),n=i.getActiveStorage("data");if("resize"===t&&o&&n?.layout){if(c){i.setSharedStorage(qi,!0);const t=i.getActiveStorage("scale"),s=e.point.x-c.x,l=e.point.y-c.y,h=s/t,d=l/t,{x:u,y:f,width:g,height:m,operations:p={}}=n.layout,{position:y="absolute"}=p;"top"===o?"relative"===y?(n.layout.height=r.toGridNum(m-d),a.scroll({moveY:l})):(n.layout.y=r.toGridNum(f+d),n.layout.height=r.toGridNum(m-d)):"right"===o?n.layout.width=r.toGridNum(g+h):"bottom"===o?n.layout.height=r.toGridNum(m+d):"left"===o?"relative"===y?(n.layout.width=r.toGridNum(g-h),a.scroll({moveX:s})):(n.layout.x=r.toGridNum(u+h),n.layout.width=r.toGridNum(g-h)):"top-left"===o?"relative"===y?(n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m-d),a.scroll({moveX:s,moveY:l})):(n.layout.x=r.toGridNum(u+h),n.layout.y=r.toGridNum(f+d),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m-d)):"top-right"===o?"relative"===y?(a.scroll({moveY:l}),n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m-d)):(n.layout.y=r.toGridNum(f+d),n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m-d)):"bottom-right"===o?(n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m+d)):"bottom-left"===o&&("relative"===y?(a.scroll({moveX:s}),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m+d)):(n.layout.x=r.toGridNum(u+h),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m+d)))}return c=e.point,a.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{i.setSharedStorage(qi,!1);const e=i.getSharedStorage(Qi),t=i.getSharedStorage(Ui),o=i.getActiveStorage("data");if(o&&"resize"===e&&t){let e;f&&(e={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:we(f),after:we(K(o.layout))}}),ai(n,{type:"resizeLayout",data:o,modifyRecord:e})}if(f=null,i.setSharedStorage(Qi,null),i.setSharedStorage(Ui,null),!0===i.getSharedStorage(Ji))return!1},beforeDrawFrame:({snapshot:t})=>{if(m())return;const{activeStore:o}=t,r=i.getActiveViewScaleInfo();e.container&&o.data?.layout&&ao(e.container,{rootClassName:h,viewScaleInfo:r,layout:o.data?.layout})}}},e.MiddlewarePathCreator=(e,t)=>{const i={..._r,...t},{defaultStrokeWidth:r,defaultStroke:a}=i,s=ea(i),l=`${Gr}-${Xe()}`,{viewer:h,eventHub:d,sharer:u,calculator:f}=e,g=e.container,m=l;let p=null,y=-1,x=null,v=null;const w=()=>{!function(e){if(!e)return;Array.from(e.children).forEach(e=>{e.remove()})}(p),v=null,x=null,y=-1},S=()=>{if(!x)return;x=Ke(x);const e=u.getActiveStorage("data");Te(x.id,{x:x.x,y:x.y,width:x.width,height:x.height,commands:x.commands},e.materials),f.modifyVirtualAttributes(x,{viewScaleInfo:u.getActiveViewScaleInfo(),viewSizeInfo:u.getActiveViewSizeInfo(),groupQueue:[]}),f.forceVisiable(x.id),h.drawFrame()},b=e=>{const t=e.target;if(t.getAttribute(Ur)===qr){const e=function(e){const t=e.getAttribute(Jr);return"string"==typeof t?parseInt(t):t}(t);return void(0===e&&y>1&&x&&(x.commands.push({id:Xe(),type:"Z",params:[]}),S(),w()))}const i=nt(p),o={x:e.pageX-i.pageX,y:e.pageY-i.pageY},l=u.getActiveViewScaleInfo(),g=u.getActiveViewSizeInfo(),m=ne(o,{viewScaleInfo:l}),{id:b}=ia(p,{point:m,viewScaleInfo:l,styles:s});y<0||!x?(y=0,x={id:n(),type:"path",x:0,y:0,width:g.width,height:g.height,strokeWidth:r,stroke:a,commands:[{id:b,type:"M",params:[m.x,m.y]}]}):(y++,x.commands.push({...Je(v,m),id:b})),v=m,(()=>{if(!x)return;const e=u.getActiveStorage("data");if(y>0)Te(x.id,{x:x.x,y:x.y,width:x.width,height:x.height,commands:x.commands},e.materials);else{e.materials.push(x);const t={type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:x.id,position:[e.materials?.length],material:c(x)}};ai(d,{data:e,type:"addMaterial",modifyRecord:t})}f.modifyVirtualAttributes(x,{viewScaleInfo:u.getActiveViewScaleInfo(),viewSizeInfo:u.getActiveViewSizeInfo(),groupQueue:[]}),f.forceVisiable(x.id),h.drawFrame()})()},A=()=>{},M=()=>{window.removeEventListener("mousemove",A)},I=()=>{window.removeEventListener("mousemove",A)},C=()=>{p?.removeEventListener("mousedown",b),window.removeEventListener("mouseup",M),window.removeEventListener("mouseleave",I)},R=()=>{g&&(p=function(e,t){const{id:i,rootClassName:o}=t;if(!e)return;const r=rt("div",{id:i,className:[Fr.hide,o].join(" "),[yt]:"true"});return e.contains(r)||e.appendChild(r),r}(g,{id:m,rootClassName:l}),g.contains(p)||g.appendChild(p))},E=()=>{p?.addEventListener("mousedown",b),window.addEventListener("mouseup",M),window.addEventListener("mouseleave",I),h.drawFrame()},z=()=>{S(),C(),w()};return{name:"@middleware/pen-create",use(){!function(e,t){mt({styles:{display:"flex",position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",justifyContent:"center",alignItems:"center",[`.${Fr.anchor}`]:{position:"absolute",width:t.anchorSize,height:t.anchorSize,background:t.anchorBackground,border:`${t.anchorBorderWidth}px solid ${t.anchorBorderColor}`,borderRadius:"50%",overflow:"hidden","&:hover":{borderColor:t.anchorHoverBorderColor,background:t.anchorHoverBackground},"&:active":{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground},[`&.${Fr.selected}`]:{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground}}},rootClassName:e,type:"element"})}(l,s),d.on(o.PATH_CREATE,E),d.on(o.CLEAR_PATH_CREATE,z),R()},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(l),d.off(o.PATH_CREATE,E),d.off(o.CLEAR_PATH_CREATE,z),w(),h.drawFrame(),C(),p?.remove(),p=null},beforeDrawFrame(){oa(p,{viewScaleInfo:u.getActiveViewScaleInfo(),styles:s})},hover:()=>(d.trigger(o.CURSOR,{type:"pen"}),!1)}},e.MiddlewarePathEditor=(e,t)=>{const{viewer:i,eventHub:r,sharer:a,calculator:n}=e,s={...Rr,...t},{afterClickAway:l}=s,h=`${ar}-${Xe()}`,c=Er(s),d=e.container,u=`idraw-middleware-path-editor-${Xe()}`;let f=null,g=!1,m=!1,p=null,y=null,x=null,v=null,w=null,S=null,b=null,A=null,M=null,I=null;const C=()=>{R(),S=null,b=null,A=null},R=()=>{M=null,I=null},E=()=>{if(!f)return;Array.from(f.getElementsByClassName(nr.selected)).forEach(e=>{tt(e,[nr.selected])})},z=()=>{p=null,v=null,w=null},L=e=>{const t=e.target,o=t?.getAttribute(gr);if(o===br&&y){e.stopPropagation(),e.preventDefault(),C(),w=K(y);const o=Yr(e,f);v=o,p="dragging-anchor",S=t,b=(e=>{const t=e.getAttribute(yr)||"";return{index:parseFloat(e.getAttribute(pr)||"0"),id:t}})(t),A=jr(y,{calculator:n}),window.addEventListener("mousemove",B),et(S,[nr.selected]),i.drawFrame()}else if(o===Ar&&y){e.stopPropagation(),e.preventDefault(),R(),w=K(y);const o=Yr(e,f);v=o,p="dragging-director",M=t,I=Pr(t),A=jr(y,{calculator:n}),window.addEventListener("mousemove",B),et(M,[nr.selected]),i.drawFrame()}else H(),l?.()},B=e=>{if(v&&y&&w&&A){const t=Yr(e,f),o=[...x||[],{...w,type:"group",id:y.id,angle:y.angle,children:[]}],{moveX:r,moveY:s}=He(v,t,o),l=a.getActiveStorage("scale")||1,h=n.toGridNum(r/l),c=n.toGridNum(s/l),d=[...A];if(S&&b&&"dragging-anchor"===p){const e=function(e,t){const i=[],{index:o,moveX:r,moveY:a}=t;e.forEach(e=>{const{id:t,type:o,params:r}=e,a={id:t,type:o,params:[...r]};i.push(a)});const n=i[o],s=i[o-1];if(!s||!n)return Ze(i);switch("M"===n.type&&(n.params[0]+=r,n.params[1]+=a),"C"===n.type&&(n.params[0]+=r,n.params[1]+=a),s.type){case"M":case"L":case"Z":s.params[0]+=r,s.params[1]+=a;break;case"A":s.params[5]+=r,s.params[6]+=a;break;case"C":s.params[2]+=r,s.params[3]+=a,s.params[4]+=r,s.params[5]+=a}return Ze(i)}(d,{index:b.index,moveX:h,moveY:c}),t=a.getActiveStorage("data"),o=e.map(({id:e,type:t,params:i})=>({id:e,type:t,params:i}));Te(y.id,{commands:o},t.materials),y.commands=o,n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()}else if(M&&I&&"dragging-director"===p){const{type:e,fromAnchorId:t}=I,o=d.findIndex(e=>e.id===t),r=function(e,t){const i=[],{index:o,type:r,moveX:a,moveY:n}=t;e.forEach(e=>{const{id:t,type:o,params:r}=e,a={id:t,type:o,params:[...r]};i.push(a)});const s=i[o];return"C"===s.type&&("curve-ctrl1"===r?(s.params[0]+=a,s.params[1]+=n):"curve-ctrl2"===r&&(s.params[2]+=a,s.params[3]+=n)),Ze(i)}(d,{type:e,index:o,moveX:h,moveY:c}),s=a.getActiveStorage("data")||{materials:[]},l=r.map(({id:e,type:t,params:i})=>({id:e,type:t,params:i}));Te(y.id,{commands:l},s.materials),y.commands=l,n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()}}},k=()=>{if(!y)return;y=Ke(y);const e=a.getActiveStorage("data")||{materials:[]};Te(y.id,{x:y.x,y:y.y,width:y.width,height:y.height,commands:y.commands},e.materials),n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()},P=()=>{window.removeEventListener("mousemove",B),k(),E(),z()},T=()=>{window.removeEventListener("mousemove",B),k(),E(),z()},N=()=>{d&&(f=function(e,t){const{id:i,rootClassName:o}=t;if(!e)return;const r=rt("div",{id:i,className:[nr.hide,o].join(" "),[yt]:"true"});return e.contains(r)||e.appendChild(r),r}(d,{id:u,rootClassName:h}),d.contains(f)||d.appendChild(f),g=!0)},D=()=>{f?.removeEventListener("mousedown",L),window.removeEventListener("mouseup",P),window.removeEventListener("mouseleave",T),m=!1,f?.remove(),f=null,g=!1},$=e=>{N();const{id:t}=e;if("string"==typeof t&&t){const e=a.getActiveStorage("data"),{groupQueue:o,material:r}=Z(t,e.materials);if("path"===r?.type){y=r,x=[...o],((e,t)=>{const{material:i,calculator:o,viewScaleInfo:r,groupQueue:a,styles:n}=t;if(!e||!i)return;const{scale:s,offsetTop:l,offsetLeft:h}=r;e?.children&&Array.from(e.children).forEach(e=>{e.remove()}),tt(e,[nr.hide]);let c=e;for(let e=0;e<a.length;e++){const t=a[e],{x:i,y:o,width:r,height:n}=t,d={x:i*s,y:o*s,width:r*s,height:n*s,angle:X(t.angle||0)};0===e&&(d.x+=h,d.y+=l),c=zr({size:d,parent:c},{[sr]:t.id,[lr]:t.x,[hr]:t.y,[cr]:t.width,[dr]:t.height,[ur]:t.angle,[fr]:t.type,[gr]:"group"})}let d=i.x*s+h,u=i.y*s+l,f=i.width*s,g=i.height*s;a.length>0&&(d=i.x*s,u=i.y*s,f=i.width*s,g=i.height*s);const m=rt("div",{[sr]:i.id,[lr]:i.x,[hr]:i.y,[cr]:i.width,[dr]:i.height,[ur]:i.angle,[fr]:i.type,[gr]:Sr,[yt]:"true",style:{display:"inline-flex",flexDirection:"column",position:"absolute",left:d,top:u,width:f,height:g,transform:`rotate(${X(i.angle||0)}deg)`,boxSizing:"border-box",overflow:"visible",padding:"0",margin:"0",outline:"none"}}),p=Ue(o.getVirtualItem(i.id).anchorCommands||[],s,s);p.forEach((e,t)=>{const i=rt("div",{[gr]:br,[mr]:e.type,[pr]:t,[yr]:e.id,[yt]:"true",className:nr.anchor,style:{...Br({x:e.start.x,y:e.start.y,size:n.anchorSize,borderWidth:n.anchorBorderWidth}),display:"M"===e.type?"none":"block"}});m.appendChild(i)}),c.appendChild(m),Wr(e,{anchorCommands:p,styles:n})})(f,{material:r,groupQueue:o,calculator:n,viewScaleInfo:a.getActiveViewScaleInfo(),styles:c}),m||(f?.addEventListener("mousedown",L),window.addEventListener("mouseup",P),window.addEventListener("mouseleave",T),m=!0);const e=a.getActiveOverrideMaterialMap()||{};e[r.id]={operations:{renderPathTrace:!0}},a.setActiveOverrideMaterialMap(e),i.drawFrame()}}},H=()=>{const e=a.getActiveOverrideMaterialMap()||{};delete e[y?.id],a.setActiveOverrideMaterialMap(e),y=null,z(),C(),D(),i.drawFrame()};return{name:"@middleware/pen-edit",use(){!function(e,t){mt({styles:{display:"flex",position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0,bottom:0,overflow:"hidden",justifyContent:"center",alignItems:"center",[`&.${nr.hide}`]:{display:"none"},[`.${nr.anchor}`]:{position:"absolute",width:t.anchorSize,height:t.anchorSize,background:t.anchorBackground,border:`${t.anchorBorderWidth}px solid ${t.anchorBorderColor}`,borderRadius:"50%",overflow:"hidden","&:hover":{borderColor:t.anchorHoverBorderColor,background:t.anchorHoverBackground},"&:active":{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground},[`&.${nr.selected}`]:{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground}},[`.${nr.director}`]:{position:"absolute",width:t.directorSize,height:t.directorSize,background:t.directorBackground,border:`${t.directorBorderWidth}px solid ${t.directorBorderColor}`,overflow:"hidden","&:hover":{borderColor:t.directorHoverBorderColor,background:t.directorHoverBackground},"&:active":{borderColor:t.directorActiveBorderColor,background:t.directorActiveBackground},[`&.${nr.selected}`]:{borderColor:t.directorActiveBorderColor,background:t.directorActiveBackground}},[`.${nr.directorLines}`]:{position:"absolute",left:0,right:0,top:0,bottom:0}},rootClassName:e,type:"element"})}(h,c),r.on(o.PATH_EDIT,$),r.on(o.CLEAR_PATH_EDIT,H)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),r.off(o.PATH_EDIT,$),r.off(o.CLEAR_PATH_EDIT,H)},beforeDrawFrame(){((e,t)=>{if(!e)return;const{material:i,viewScaleInfo:o,calculator:r,selectedAnchorId:a,styles:n}=t;if(!i)return;const{scale:s,offsetTop:l,offsetLeft:h}=o;let c=e.children[0],d=0;for(;["group","material"].includes(c?.getAttribute(gr));){"material"===c?.getAttribute(gr)&&(it(c,{width:i.width,height:i.height,left:i.x,top:i.y}),ot(c,{[cr]:i.width,[dr]:i.height,[lr]:i.x,[hr]:i.y}));const{x:e,y:t,w:o,h:r,angle:a}=Lr(c),n={x:e*s,y:t*s,w:o*s,h:r*s,angle:a};if(0===d&&(n.x+=h,n.y+=l),it(c,{left:n.x,top:n.y,width:n.w,height:n.h,transform:`rotate(${n.angle}deg)`}),"material"!==c?.children?.[0]?.getAttribute(gr))break;c=c?.children?.[0],d++}const{id:u}=i,f=Ue(r.getVirtualItem(u).anchorCommands||[],s,s);if(Array.from(c.querySelectorAll(`[${gr}="${br}"]`)).forEach((e,t)=>{const i=f[t],o=e.getAttribute(yr)===a?n.anchorSelectedSize:n.anchorSize;it(e,{width:o,height:o,left:i.start.x-o/2-n.anchorBorderWidth,top:i.start.y-o/2-n.anchorBorderWidth})}),"string"==typeof a&&a){const t=f.findIndex(e=>e.id===a),i=f[t],o=f[t-1];let r=null,s=null;"C"===i.type&&(r={openedByAnchorId:a,anchorId:i.id,anchorPoint:{x:i.start.x,y:i.start.y},directPoint:{x:i.params[0],y:i.params[1]}}),"C"===o.type&&(s={openedByAnchorId:a,anchorId:o.id,anchorPoint:{x:o.end.x,y:o.end.y},directPoint:{x:o.params[2],y:o.params[3]}}),r||s?($r(e,{selectedAnchorId:a,currentDirector:r,prevDirector:s,styles:n}),Nr(e,{currentDirector:r,prevDirector:s,styles:n})):Dr(e)}Or(e,{anchorCommands:f,styles:n})})(f,{selectedAnchorId:b?.id,material:y,viewScaleInfo:a.getActiveViewScaleInfo(),calculator:n,styles:c})},hover:()=>!g,pointStart:()=>!g,pointMove:()=>!g,pointEnd:()=>!g,pointLeave:()=>!g,doubleClick:()=>!g,contextMenu:()=>!g,wheel:()=>!g,wheelScale:()=>!g,scrollX:()=>!g,scrollY:()=>!g,resize:()=>!g}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:r}=e,a=t.boardContext.canvas,n=e.container||document.body,s=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`;let l=document.createElement("div");return{name:"@middleware/pointer",use(){l.setAttribute("id",s),l.style.position="fixed",l.style.top="0",l.style.bottom="unset",l.style.left="0",l.style.right="unset",n.appendChild(l)},disuse(){n.removeChild(l),l.remove(),l=null},contextMenu(e){const{point:t}=e,{left:n,top:s}=(()=>{const e=a.getBoundingClientRect(),{left:t,top:i,width:o,height:r}=e;return{left:t,top:i,width:o,height:r}})();l.style.left=`${n+t.x}px`,l.style.top=`${s+t.y}px`;const h=r.getSharedStorage(Ri);i.trigger(o.CONTEXT_MENU,{pointerContainer:l,selectedMaterials:h||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:r,eventHub:a,calculator:n}=e,{overlayContext:s,underlayContext:l}=i;let h={...Uo,...t},c=Zo(h),d=!0,u=!0;const f=e=>{"boolean"==typeof e?.show&&(d=e.show),"boolean"==typeof e?.showGrid&&(u=e.showGrid),"boolean"!=typeof e?.show&&"boolean"!=typeof e?.showGrid||r.drawFrame()};return{name:"@middleware/ruler",use(){a.on(o.RULER,f)},disuse(){a.off(o.RULER,f)},resetConfig(e){h={...h,...e},c=Zo(h)},beforeDrawFrame:({snapshot:e})=>{if(!0===d){const t=P(e),i=T(e);!function(e,t){const{viewSizeInfo:i,styles:o}=t,{width:r,height:a}=i,{background:n,stroke:s}=o;e.beginPath();const l=-1;e.moveTo(l,l),e.lineTo(r+1,l),e.lineTo(r+1,Xo),e.lineTo(Xo,Xo),e.lineTo(Xo,a+1),e.lineTo(l,a+1),e.lineTo(l,l),e.closePath(),e.fillStyle=n,e.fill("nonzero"),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=s,e.stroke()}(s,{viewSizeInfo:i,styles:c}),function(e,t){const{snapshot:i,calculator:o,styles:r}=t,{sharedStore:a}=i,{selectedAreaColor:n}=r,s=a[Ri],l=a[bi];if(["select","drag","drag-list","drag-list-end"].includes(l)&&s.length>0){const t=P(i),r=T(i),a=[],l=[],h=[],c=[],d=[];if(s.forEach(e=>{const i=o.calcViewBoundingInfoFromRange(e.id,{viewScaleInfo:t,viewSizeInfo:r});i&&(a.push(i),l.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))}),!(a.length>0))return;const u=Math.min(...l),f=Math.max(...h),g=Math.min(...c),m=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(u,0),e.lineTo(f,0),e.lineTo(f,Xo),e.lineTo(u,Xo),e.fillStyle=n,e.closePath(),e.fill("nonzero"),e.beginPath(),e.moveTo(0,g),e.lineTo(Xo,g),e.lineTo(Xo,m),e.lineTo(0,m),e.fillStyle=n,e.closePath(),e.fill("nonzero")}}(s,{snapshot:e,calculator:n,styles:c});const{list:o,rulerUnit:r}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:r}=t,{width:a}=i;return Ko({scale:o,viewLength:a,viewOffset:r})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,styles:o}=t,{scaleColor:r,textColor:a}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<Xo||(e.beginPath(),e.moveTo(o.position,16),e.lineTo(o.position,o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8),e.closePath(),e.lineWidth=1,e.setLineDash([]),e.fillStyle=r,e.stroke(),o.isKeyNum&&(e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Qo}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(s,{scaleList:o,styles:c});const{list:a}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:r}=t,{height:a}=i;return Ko({scale:o,viewLength:a,viewOffset:r})}({viewScaleInfo:t,viewSizeInfo:i});if(function(e,t){const{scaleList:i,styles:o}=t,{scaleColor:r,textColor:a}=o,n=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<Xo)&&(e.beginPath(),e.moveTo(16,o.position),e.lineTo(o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8,o.position),e.closePath(),e.fillStyle=r,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=n,i=o.position+n,r=`${o.num}`;$(e,-90,{x:t,y:i},()=>{e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Qo}),e.fillText(r,13.2,o.position+n)})}}}(s,{scaleList:a,styles:c}),!0===u){!function(e,t){const{xList:i,yList:o,viewSizeInfo:r,styles:a}=t,{width:n,height:s}=r,{gridColor:l,gridPrimaryColor:h}=a;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,s),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=l,e.closePath(),e.lineWidth=1,e.setLineDash([]),e.stroke()}for(let t=0;t<o.length;t++){const i=o[t];e.beginPath(),e.moveTo(0,i.position),e.lineTo(n,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=l,e.lineWidth=1,e.closePath(),e.stroke()}}(1===r?s:l,{xList:o,yList:a,viewSizeInfo:i,styles:c})}}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:r}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:a,point:n}=e,{scale:s}=i.getActiveViewScaleInfo();let l=s;if(a<0?l=1.1*s:a>0&&(l=.9*s),l<.05||l>50)return;const{moveX:h,moveY:c}=t.scale({scale:l,point:n});t.scroll({moveX:h,moveY:c}),t.drawFrame();const d=ue(s);r.trigger(o.SCALE,{scale:d})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,sharer:r,eventHub:a}=e;let n=!1,s={...Oo,...t};const l=Yo(s),h=`${Do}-${Xe()}`;let c=null,d=null;const u=()=>{r.setSharedStorage(Po,null),r.setSharedStorage(To,null),r.setSharedStorage(No,null),n=!1};u();const f=()=>{const{xThumbStyle:e,yThumbStyle:t}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{width:o,height:r}=i,{offsetTop:a,offsetBottom:n,offsetLeft:s,offsetRight:l}=t,h=16;let c=0,d=0;c=Math.max(40,o-32-(Math.abs(s)+Math.abs(l))),c>=o&&(c=o),d=Math.max(40,r-32-(Math.abs(a)+Math.abs(n))),d>=r&&(d=r);let u=16;s>0?u=16:l>0?u=o-c-h:s<=0&&c>0&&(0!==s||0!==l)&&(u=16+(o-c)*Math.abs(s)/(Math.abs(s)+Math.abs(l)),u=Math.min(Math.max(0,u-16),o-c));let f=16;return a>0?f=16:n>0?f=r-d-h:a<=0&&d>0&&(0!==a||0!==n)&&(f=16+(r-d)*Math.abs(a)/(Math.abs(a)+Math.abs(n)),f=Math.min(Math.max(0,f-16),r-d)),{xThumbStyle:{left:u,width:c},yThumbStyle:{top:f,height:d}}}({viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()});r.setSharedStorage(Bo,e),r.setSharedStorage(ko,t)},g=e=>{const{thumbMoveX:t,thumbMoveY:i}=e,o=r.getSharedStorage(Bo),a=r.getSharedStorage(ko),n=r.getActiveViewSizeInfo();if(o&&(t>0||t<0)){const e=n.width-32,i=$o;let a=o.left-t;a=Math.min(n.width-$o-Ho,Math.max($o,a));let s=o.width;(a+s>=e||a<=i)&&(t<0?s+=t:s-=t),s=Math.min(e,Math.max(Ho,s)),o.left=a,o.width=s,r.setSharedStorage(Bo,o)}if(a&&(i>0||i<0)){const e=n.height-32,t=$o;let o=a.top-i;o=Math.min(n.height-$o-Ho,Math.max($o,o));let s=a.height;(o+s>=e||o<=t)&&(i<0?s+=i:s-=i),s=Math.min(e,Math.max(Ho,s)),a.top=o,a.height=s,r.setSharedStorage(ko,a)}};return{name:"@middleware/scroller",use(){!function(e,t){const i=e=>`.${e}`;mt({styles:{zIndex:t.zIndex,position:"absolute",background:"transparent",[i(Vo.thumb)]:{position:"absolute",background:t.thumbBackground,border:`1px solid ${t.thumbBorderColor}`,borderRadius:"4px",boxSizing:"border-box","&:hover":{background:t.hoverThumbBackground,border:`1px solid ${t.hoverThumbBorderColor}`},"&:active":{background:t.activeThumbBackground,border:`1px solid ${t.activeThumbBorderColor}`}},[`&${i(Vo.vertical)}`]:{top:0,bottom:0,right:0,left:"unset",width:$o,overflow:"hidden",[i(Vo.thumb)]:{top:$o,bottom:"unset",left:4,right:"unset",height:Ho,width:8}},[`&${i(Vo.horizontal)}`]:{left:0,right:0,top:"unset",bottom:0,height:$o,overflow:"hidden",[i(Vo.thumb)]:{top:4,bottom:"unset",left:$o,right:"unset",height:8,width:Ho}}},rootClassName:e,type:"element"})}(h,l);const t=function(e){const{rootClassName:t,$container:i}=e,o=rt,r=o("div",{className:`${t} ${Vo.horizontal}`,[yt]:"true"},[o("div",{className:Vo.thumb,[yt]:"true",[Wo]:"X"})]),a=o("div",{className:`${t} ${Vo.vertical}`,[yt]:"true"},[o("div",{className:Vo.thumb,[yt]:"true",[Wo]:"Y"})]);return i.appendChild(r),i.appendChild(a),{$horizontal:r,$vertical:a}}({rootClassName:h,$container:e.container});c=t.$horizontal,d=t.$vertical,f(),Go({xThumbStyle:r.getSharedStorage(Bo),yThumbStyle:r.getSharedStorage(ko),$horizontal:c,$vertical:d})},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),c?.remove(),c=null,d?.remove(),d=null},resetConfig(e){s={...s,...e}},wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),f(),i.drawFrame()},hover:e=>{if(!0===n)return!1;const{nativeEvent:t}=e,i=Fo(t);return"X"===i||"Y"===i?(a.trigger(o.CURSOR,{type:"default"}),!1):!jo(t)&&void 0},pointStart:e=>{const{point:t,nativeEvent:i}=e,o=Fo(i);return"X"===o||"Y"===o?(n=!0,r.setSharedStorage(No,o),r.setSharedStorage(Po,t),!1):!jo(i)&&void 0},pointMove:e=>{const{point:t,nativeEvent:o}=e,a=r.getSharedStorage(No);return"X"===a||"Y"===a?(r.setSharedStorage(To,t),"X"===a?(e=>{const t=r.getSharedStorage(Po);if(t){const{offsetLeft:o,offsetRight:a}=r.getActiveViewScaleInfo(),{width:n}=r.getActiveViewSizeInfo(),s=-(e.x-t.x),l=s*(n+Math.abs(o)+Math.abs(a))/n;i.scroll({moveX:l}),g({thumbMoveX:s,thumbMoveY:0}),i.drawFrame()}})(t):"Y"===a&&(e=>{const t=r.getSharedStorage(Po);if(t){const{offsetTop:o,offsetBottom:a}=r.getActiveViewScaleInfo(),{height:n}=r.getActiveViewSizeInfo(),s=-(e.y-t.y),l=s*(n+Math.abs(o)+Math.abs(a))/n;i.scroll({moveY:l}),g({thumbMoveX:0,thumbMoveY:s}),i.drawFrame()}})(t),r.setSharedStorage(Po,t),!1):!jo(o)&&void 0},pointEnd:()=>{n=!1;const e=r.getSharedStorage(No);if(u(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),f(),i.drawFrame(),!1},beforeDrawFrame(){Go({$horizontal:c,$vertical:d,xThumbStyle:r.getSharedStorage(Bo),yThumbStyle:r.getSharedStorage(ko)})}}},e.MiddlewareSelector=(e,t)=>{let i={...Ti,...t};const r=Mo(i),a=`${si}-${Xe()}`;let n=null;const{viewer:s,sharer:l,boardContent:h,calculator:c,eventHub:d}=e,{overlayContext:u}=h;l.setSharedStorage(bi,null),l.setSharedStorage(Pi,!0);const f=e=>{let t=l.getSharedStorage(Li);return Array.isArray(t)||(t=[]),t.length>0?!function(e,t){if("group"===t?.type&&Array.isArray(t?.children))for(let i=0;i<t.children.length;i++){const o=t.children[i];if(e.id===o.id)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e),l.setSharedStorage(Li,t),t.length>0},g=(e,t)=>{if(l.setSharedStorage(Ri,e),1===e.length?l.setSharedStorage(zi,_(e[0].id,l.getActiveStorage("data")?.materials||[])):l.setSharedStorage(zi,[]),!0===t?.triggerEvent){const t=e.map(e=>e.id),i=l.getActiveStorage("data"),r=function(e,t){const i=[],o={};let r=!1;const a=t=>{for(let n=0;n<t.length&&!0!==r;n++){i.push(n);const s=t[n];if(e.includes(s.id)){if(o[s.id]=[...i],Object.keys(o).length===e.length){r=!0;break}}else"group"===s.type&&a(s?.children||[]);if(r)break;i.pop()}};return a(t),o}(t,i?.materials||[]);d.trigger(o.SELECT,{type:"clickCanvas",ids:t,positions:e.map(e=>[...r[e.id]])})}},m=e=>({ctx:u,calculator:c,data:l.getActiveStorage("data"),selectedMaterials:l.getSharedStorage(Ri),viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo(),groupQueue:l.getSharedStorage(Li),areaSize:null,selectedMaterialPosition:l.getSharedStorage(zi),nativeEvent:e.nativeEvent}),p=()=>(e=>{e.setSharedStorage(wi,null),e.setSharedStorage(Si,null),e.setSharedStorage(bi,null),e.setSharedStorage(Ai,null),e.setSharedStorage(Mi,null),e.setSharedStorage(Ii,null),e.setSharedStorage(Li,[]),e.setSharedStorage(Ci,null),e.setSharedStorage(Ri,[]),e.setSharedStorage(Ei,null),e.setSharedStorage(zi,[]),e.setSharedStorage(Bi,null)})(l);p();const y=({ids:e=[],positions:t})=>{let i=[];const o=l.getSharedStorage(bi),r=l.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach(e=>{const o=q(e,t);o&&i.push(o)}),i}(t,r?.materials||[]):function(e,t){const i=[];return function t(o){for(let r=0;r<o.length;r++){const a=o[r];e.includes(a.id)?i.push(a):"group"===a.type&&t(a?.children||[])}}(t),i}(e,r?.materials||[]);let a=!1;if(o||1!==i.length?"select"===o&&1===i.length&&(a=!0):(l.setSharedStorage(bi,"select"),a=!0),a){const e=function(e,t){const{groupQueue:i}=Z(e,t);return i}(i[0].id,r?.materials||[]);l.setSharedStorage(Li,e),g(i),l.setSharedStorage(mi,[{...K(i[0]),id:i[0].id}]),s.drawFrame()}},x=()=>{p(),s.drawFrame()},v=e=>{l.setSharedStorage(Pi,!!e.enable)},w=e=>{l.setSharedStorage(ki,!!e.enable)};return{name:"@middleware/selector",use(){!function(e,t){const i=e=>`.${e}`;var o;mt({styles:{display:"flex",position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0,bottom:0,overflow:"hidden",[i(fi.hoverTargetBox)]:{position:"absolute",outline:`1px solid ${t.activeColor}`},[i(fi.nestedBox)]:{position:"absolute",[`&${i(fi.groupBox)}`]:{outline:`2px dashed ${t.activeColor}`},[i(fi.groupBox)]:{outline:`2px dashed ${t.activeColor}`}},[i(fi.lockedTargetBox)]:{position:"absolute",outline:`2px solid ${t.lockedColor}`},[i(fi.selectedBox)]:{position:"absolute",[`&${i(fi.hideHandler)}`]:{[i(fi.cornerHandler)]:{display:"none"},[i(fi.edgeHandler)]:{display:"none"},[i(fi.rotateHandler)]:{display:"none"}}},[i(fi.selectedTargetBox)]:{position:"absolute",outline:`1.5px solid ${t.handlerBorderColor}`,[i(fi.cornerHandler)]:{position:"absolute",outline:`1.5px solid ${t.handlerBorderColor}`,background:t.handlerBackground,width:"10px",height:"10px","&:hover":{background:t.handlerHoverBackground},"&:active":{background:t.handlerActiveBackground},[`&${i(fi.cornerTopLeftHandler)}`]:{top:"-5px",left:"-5px"},[`&${i(fi.cornerTopRightHandler)}`]:{top:"-5px",right:"-5px"},[`&${i(fi.cornerBottomLeftHandler)}`]:{bottom:"-5px",left:"-5px"},[`&${i(fi.cornerBottomRightHandler)}`]:{bottom:"-5px",right:"-5px"}},[i(fi.rotateHandler)]:{position:"absolute",top:-40,left:"50%",transform:"translateX(-50%)",width:20,height:20,background:"#FFFFFF",borderRadius:"10px","&::after":{display:"inline-block",content:'""',position:"absolute",top:0,bottom:0,left:0,right:0,backgroundImage:`url(data:image/svg+xml,${encodeURIComponent((o=t.activeColor,`<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200" fill="${o}" >\n <path d="M512 0c282.8 0 512 229.2 512 512s-229.2 512 -512 512S0 794.8 0 512 229.2 0 512 0zm309.8 253.8c0 -10.5 -6.5 -19.8 -15.7 -23.8 -9.7 -4 -21 -2 -28.2 5.6l-52.5 52c-56.9 -53.7 -133.9 -85.5 -213.4 -85.5 -170.7 0 -309.8 139.2 -309.8 309.8 0 170.6 139.2 309.8 309.8 309.8 92.4 0 179.5 -40.8 238.4 -111.8 4 -5.2 4 -12.9 -0.8 -17.3L694.3 637c-2.8 -2.4 -6.5 -3.6 -10.1 -3.6 -3.6 0.4 -7.3 2 -9.3 4.8 -39.5 51.2 -98.8 80.3 -163 80.3 -113.8 0 -206.5 -92.8 -206.5 -206.5 0 -113.8 92.8 -206.5 206.5 -206.5 52.8 0 102.9 20.2 140.8 55.3L597 416.5c-7.7 7.3 -9.7 18.6 -5.6 27.9 4 9.7 13.3 16.1 23.8 16.1H796c14.1 0 25.8 -11.7 25.8 -25.8V253.8z" />\n</svg>`))})`,backgroundPosition:"center",backgroundSize:"20px"}},[i(fi.edgeHandler)]:{position:"absolute",background:"transparent",[`&${i(fi.edgeLeftHandler)}`]:{width:"10px",top:"5px",left:"-5px",bottom:"5px"},[`&${i(fi.edgeRightHandler)}`]:{width:"10px",top:"5px",right:"-5px",bottom:"5px"},[`&${i(fi.edgeTopHandler)}`]:{height:"10px",top:"-5px",left:"5px",right:"5px"},[`&${i(fi.edgeBottomHandler)}`]:{height:"10px",bottom:"-5px",left:"5px",right:"5px"}}},[i(fi.selectionAreaBox)]:{position:"absolute",outline:`1px solid ${t.selectionAreaBorderColor}`,background:t.selectionAreaBackground}},rootClassName:e,type:"element"})}(a,r),n=function(e){const{rootClassName:t,$container:i}=e,o=rt("div",{className:t,[yt]:"true"});return i.appendChild(o),o}({rootClassName:a,$container:e.container}),d.on(o.SELECT,y),d.on(o.CLEAR_SELECT,x),d.on(o.SELECT_IN_GROUP,w),d.on(o.SNAP_TO_GRID,v)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(a),d.off(o.SELECT,y),d.off(o.CLEAR_SELECT,x),d.off(o.SELECT_IN_GROUP,w),d.off(o.SNAP_TO_GRID,v),n?.remove(),p(),i=null,n=null},resetConfig(e){i={...i,...e}},hover:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return void(l.getSharedStorage(Ci)&&(l.setSharedStorage(Ci,null),s.drawFrame()));const t=l.getSharedStorage(Ki);if(!0===l.getSharedStorage(qi))return;const i=l.getSharedStorage(Ai),r=l.getSharedStorage(bi),h=l.getSharedStorage(Li),c=e=>{if(!0===t)return;const i=e.type;null===l.getSharedStorage(xi)&&d.trigger(o.CURSOR,{type:i,groupQueue:e.groupQueue,material:e.materials[0]})};if(h?.length>0){if(!Ao(e.nativeEvent,{$root:n,groupQueue:l.getSharedStorage(Li)}))return l.setSharedStorage(Ci,null),void s.drawFrame();const t=Wi(e.point,m(e));return c(t),i||["area","drag","drag-list"].includes(r)?(l.setSharedStorage(Ci,null),void s.drawFrame()):1===t?.materials?.length?(l.setSharedStorage(Ci,t.materials[0]),void s.drawFrame()):(l.setSharedStorage(Ci,null),void s.drawFrame())}if(i||["area","drag","drag-list"].includes(r))return void l.setSharedStorage(Ci,null);if("drag"===r)return void l.setSharedStorage(Ci,null);const u=l.getSharedStorage(Ri),f=l.getActiveViewScaleInfo();l.getActiveViewSizeInfo();const g=Wi(e.point,{...m(e),areaSize:Vi(u,{viewScaleInfo:f})});if(c(g),null!==g.type){if(!("over-material"===g.type&&"select"===l.getSharedStorage(bi)&&1===g.materials.length&&g.materials[0].id===l.getSharedStorage(Ri)?.[0]?.id||"over-material"===g.type&&null===l.getSharedStorage(bi)&&1===g.materials.length&&g.materials[0].id===l.getSharedStorage(Ci)?.id))return"over-material"===g.type&&1===g?.materials?.length?(l.setSharedStorage(Ci,g.materials[0]),void s.drawFrame()):l.getSharedStorage(Ci)?(l.setSharedStorage(Ci,null),void s.drawFrame()):void 0}else l.getSharedStorage(Ci)&&(l.setSharedStorage(Ci,null),s.drawFrame())},pointStart:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(gi,e.point),l.setSharedStorage(pi,e.point),l.setSharedStorage(wi,null),l.setSharedStorage(Si,null),l.setSharedStorage(bi,null),l.setSharedStorage(Ai,null),l.setSharedStorage(Mi,null),l.setSharedStorage(Ii,null),l.setSharedStorage(Ci,null);const t=l.getSharedStorage(Li);if(t?.length>0){if(Ao(e.nativeEvent,{$root:n,groupQueue:t})){const t=Wi(e.point,m(e)),i=1===t?.materials?.length&&!0===t.materials[0]?.operations?.locked;l.setSharedStorage(Ci,null),1===t?.materials?.length&&l.setSharedStorage(yi,K(t?.materials[0])),!0===i?p():"over-material"===t.type&&1===t?.materials?.length?(g([t.materials[0]],{triggerEvent:!0}),l.setSharedStorage(bi,"drag"),l.setSharedStorage(mi,[{...K(t?.materials[0]),id:t?.materials[0].id}])):t.type?.startsWith("resize-")?(l.setSharedStorage(Ai,t.type),l.setSharedStorage(bi,"resize")):g([],{triggerEvent:!0})}else p();return void s.drawFrame()}const i=Vi(l.getSharedStorage(Ri),{viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()}),o=Wi(e.point,{...m(e),areaSize:i,groupQueue:[]}),r=1===o?.materials?.length&&!0===o.materials[0]?.operations?.locked;l.setSharedStorage(Ci,null),1===o?.materials?.length&&l.setSharedStorage(yi,K(o?.materials[0])),!0===r?(p(),l.setSharedStorage(Ci,o?.materials[0]),l.setSharedStorage(bi,"area"),l.setSharedStorage(Mi,e.point),g([],{triggerEvent:!0})):"list-area"===o.type?l.setSharedStorage(bi,"drag-list"):"over-material"===o.type&&1===o?.materials?.length?(g([o.materials[0]],{triggerEvent:!0}),l.setSharedStorage(bi,"drag"),l.setSharedStorage(mi,[{...K(o?.materials[0]),id:o?.materials[0].id}])):o.type?.startsWith("resize-")?(l.setSharedStorage(Ai,o.type),l.setSharedStorage(bi,"resize")):(p(),l.setSharedStorage(bi,"area"),l.setSharedStorage(Mi,e.point),g([],{triggerEvent:!0})),s.drawFrame()},pointMove:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(Bi,!0);const t=l.getActiveStorage("data"),i=l.getSharedStorage(Ri),o=l.getActiveStorage("scale")||1,r=l.getActiveViewScaleInfo(),h=l.getActiveViewSizeInfo(),u=l.getSharedStorage(gi),f=l.getSharedStorage(pi),m=e.point,p=l.getSharedStorage(Ai),y=l.getSharedStorage(bi),x=l.getSharedStorage(Li),v=l.getSharedStorage(Pi);let w="unknown";if("drag"===y){if(l.setSharedStorage(vi,!0),l.setSharedStorage(xi,"drag"),d.trigger(so,{show:!1}),t&&1===i?.length&&l.getSharedStorage(yi)&&f&&m&&!0!==i[0]?.operations?.locked){const{moveX:e,moveY:a}=He(f,m,x);let n=c.toGridNum(e/o),s=c.toGridNum(a/o);if(!0===v){const e=Fi(i[0].id,{calculator:c,data:t,groupQueue:x,viewScaleInfo:r,viewSizeInfo:h});try{e&&(C.x(e.offsetX)&&null!==e.offsetX&&(n=c.toGridNum(n+e.offsetX)),C.y(e.offsetY)&&null!==e.offsetY&&(s=c.toGridNum(s+e.offsetY)))}catch(e){console.error(e)}}const d=l.getSharedStorage(yi),u=c.toGridNum(d.x+n),p=c.toGridNum(d.y+s);Io(i[0],{x:u,y:p,width:i[0].width,height:i[0].height}),g([i[0]]),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i[0],position:l.getSharedStorage(zi)||[]}},viewSizeInfo:h,viewScaleInfo:r})}s.drawFrame()}else if("drag-list"===y){if(l.setSharedStorage(vi,!0),l.setSharedStorage(xi,"drag-list"),t&&f&&u&&m&&i?.length>1){const e=(m.x-u.x)/o,a=(m.y-u.y)/o;i.forEach(i=>{i&&!0!==i?.operations?.locked&&(i.x=c.toGridNum(i.x+e),i.y=c.toGridNum(i.y+a),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i,position:_(i.id,t.materials)||[]}},viewSizeInfo:h,viewScaleInfo:r}))}),l.setActiveStorage("data",t)}s.drawFrame()}else if("resize"===y){if(t&&1===i?.length&&f&&l.getSharedStorage(yi)&&p?.startsWith("resize-")){l.setSharedStorage(vi,!0),l.setSharedStorage(xi,"resize");const e=[];x.forEach(t=>{const{x:i,y:o,width:r,height:a,angle:n=0}=t;e.push({x:i,y:o,width:r,height:a,angle:0-n})});let a=f,n=m;if(x.length>0&&(a=Y(f,e),n=Y(m,e)),"resize-rotate"===p){const e=l.getSharedStorage(yi),t=c.getVirtualItem(i?.[0]?.id),o=t?.worldCenter,a=Oi(e,{center:o,viewScaleInfo:r,start:f,end:m,calculator:c});i[0].angle=c.toGridNum(a.angle||0)}else{const e=l.getSharedStorage(yi),t=function(e,t){let{x:i,y:o,width:r,height:a,angle:n=0}=e;const s=H({x:i,y:o,width:r,height:a});n=X(n);const l=D(n),h=!!e?.operations?.limitRatio,{start:c,end:d,resizeType:u,scale:f,calculator:g}=t;let m={...c},p={...d},y={x:m.x,y:s.y},x={x:p.x,y:s.y},v={...y},w={...x},S={x:s.x,y:m.y},b={x:s.x,y:p.y},A={...S},M={...b},I=(w.x-v.x)/f,C=(w.y-v.y)/f,R=Di(I,C),E=(M.x-A.x)/f,z=(M.y-A.y)/f,L=Di(E,z);(n>0||n<0)&&(m=V(s,c,0-l),p=V(s,d,0-l),y={x:m.x,y:s.y},x={x:p.x,y:s.y},v=V(s,y,l),w=V(s,x,l),S={x:s.x,y:m.y},b={x:s.x,y:p.y},A=V(s,S,l),M=V(s,b,l),I=(w.x-v.x)/f,C=(w.y-v.y)/f,R=Di(I,C),R=$i(R,C),E=(M.x-A.x)/f,z=(M.y-A.y)/f,L=Di(E,z),L=$i(L,z));let B=(d.x-c.x)/f,k=(d.y-c.y)/f;if(!0===h)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(u)){const t=Math.max(Math.abs(B),Math.abs(k));B=(B>=0?1:-1)*t,k=(k>=0?1:-1)*t/e.width*e.height;const i=Math.max(Math.abs(E),Math.abs(z));E=(E>=0?1:-1)*i,z=(z>=0?1:-1)*i/e.width*e.height;const o=Math.max(Math.abs(I),Math.abs(C));I=(I>=0?1:-1)*o,C=(C>=0?1:-1)*o/e.width*e.height}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(u)){{const t=Math.abs(B);B=(B>=0?1:-1)*t;const i=t/e.width*e.height;"resize-top-left"===u||"resize-bottom-right"===u?k=B>0?i:-i:"resize-top-right"!==u&&"resize-bottom-left"!==u||(k=B>0?-i:i)}R=Math.abs(R),L=R/e.width*e.height}switch(u){case"resize-top":if(0===n)a-k>0&&(o+=k,a-=k,!0===e.operations?.limitRatio&&(i+=k/e.height*e.width/2,r-=k/e.height*e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){L=0-$i(L,z);const e=Ni(n),i=L/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<180){L=$i(L,E);const e=Ni(n-90),i=L/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<270){L=$i(L,z);const e=Ni(n-180),i=L/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<360){L=0-$i(L,E);const e=Ni(n-270),i=L/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}a+L>0&&(!0===e.operations?.limitRatio&&(r+=L/e.height*e.width),a+=L,i=t-r/2,o=l-a/2)}break;case"resize-bottom":if(0===n)e.height+k>0&&(a+=k,!0===e.operations?.limitRatio&&(i-=k/e.height*e.width/2,r+=k/e.height*e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){L=$i(L,z);const e=Ni(n),i=L/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<180){L=0-$i(L,E);const e=Ni(n-90),i=L/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}else if(n<270){L=$i(L,E);const e=Ni(n-180),i=L/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<360){L=$i(L,E);const e=Ni(n-270),i=L/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}a+L>0&&(!0===e.operations?.limitRatio&&(r+=L/e.height*e.width),a+=L,i=t-r/2,o=l-a/2)}break;case"resize-left":if(0===n)e.width-B>0&&(i+=B,r-=B,!0===e.operations?.limitRatio&&(a-=B/e.width*e.height,o+=B/e.width*e.height/2));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){R=0-$i(R,I);const e=Ni(n),i=R/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}else if(n<180){R=$i(R,I);const e=Ni(n-90),i=R/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<270){R=$i(R,C);const e=Ni(n-180),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<360){R=$i(R,C);const e=Ni(n-270),i=R/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}r+R>0&&(!0===e.operations?.limitRatio&&(a+=R/e.width*e.height),r+=R,i=t-r/2,o=l-a/2)}break;case"resize-right":if(0===n)e.width+B>0&&(r+=B,!0===e.operations?.limitRatio&&(o-=B*e.height/e.width/2,a+=B*e.height/e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){R=$i(R,C);const e=Ni(n),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<180){R=$i(R,k);const e=Ni(n-90),i=R/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<270){R=$i(R,k);const e=Ni(n-180),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e),R=0-R}else if(n<360){R=$i(R,B);const e=Ni(n-270),i=R/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}r+R>0&&(!0===e.operations?.limitRatio&&(a+=R/e.width*e.height),r+=R,i=t-r/2,o=l-a/2)}break;case"resize-top-left":if(0===n)r-B>0&&(i+=B,r-=B),a-k>0&&(o+=k,a-=k);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=0-$i(L,z),R=0-$i(R,h?0-L:I);const i=L/2;e+=i*Math.sin(l),t-=i*Math.cos(l);const o=R/2;e-=o*Math.cos(l),t-=o*Math.sin(l)}else if(n<180){L=$i(L,E),R=$i(R,h?L:I);const i=Ni(n-90),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}else if(n<270){L=$i(L,z),R=$i(R,h?L:C);const i=Ni(n-180),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<360){L=0-$i(L,E),R=$i(R,h?L:C);const i=Ni(n-270),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-top-right":if(0===n)r+B>0&&(r+=B),a-k>0&&(o+=k,a-=k);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=0-$i(L,z),R=$i(R,h?L:C);const i=Ni(n),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<180){L=$i(L,E),R=$i(R,h?L:C);const i=Ni(n-90),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}else if(n<270){const i=Ni(n-180);L=$i(L,z),R=$i(R,h?L:0-I);const o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<360){L=0-$i(L,E),R=$i(R,h?L:I);const i=Ni(n-270),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-bottom-left":if(0===n)e.height+k>0&&(a+=k),e.width-B>0&&(i+=B,r-=B);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=$i(L,z),R=0-$i(R,h?0-L:I);const i=Ni(n),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<180){L=0-$i(L,E),R=$i(R,h?L:I);const i=Ni(n-90),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}else if(n<270){L=$i(L,E),R=$i(R,h?L:C);const i=Ni(n-180),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<360){L=$i(L,E),R=$i(R,h?L:C);const i=Ni(n-270),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-bottom-right":if(0===n)e.height+k>0&&(a+=k),e.width+B>0&&(r+=B);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=$i(L,z),R=$i(R,h?L:C);const i=Ni(n),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<180){L=0-$i(L,E),R=$i(R,h?L:k);const i=Ni(n-90),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}else if(n<270){L=$i(L,E),R=$i(R,h?L:0-C);const i=Ni(n-180),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<360){L=$i(L,E),R=$i(R,h?L:I);const i=Ni(n-270),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}}return{x:g.toGridNum(i),y:g.toGridNum(o),width:g.toGridNum(r),height:g.toGridNum(a),angle:g.toGridNum(e.angle||0)}}({...e,operations:i[0].operations},{scale:o,start:a,end:n,resizeType:p,calculator:c}),r={ignore:!!e.angle},s=c.toGridNum(t.x,r),h=c.toGridNum(t.y,r),d=c.toGridNum(t.width,r),u=c.toGridNum(t.height,r);"group"===i[0].type?(l.setSharedStorage(Si,ze(i[0],{x:s,y:h,width:d,height:u},{resizeEffect:i[0].operations?.resizeEffect})),l.getSharedStorage(wi)||l.setSharedStorage(wi,l.getSharedStorage(Si)),i[0].x=s,i[0].y=h):Io(i[0],{x:s,y:h,width:d,height:u})}g([i[0]]),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i[0],position:l.getSharedStorage(zi)||[]}},viewSizeInfo:h,viewScaleInfo:r}),s.drawFrame()}}else"area"===y&&(l.setSharedStorage(xi,"area"),l.setSharedStorage(Ii,e.point),s.drawFrame());const S=l.getSharedStorage(Ri);ai(d,{data:t,type:"updatingMaterial",selectedMaterials:S,hoverMaterial:null,modifyRecord:null},"continuous"),l.setSharedStorage(gi,e.point)},pointEnd(e){if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(xi,null),l.setSharedStorage(Bi,!1);const t=l.getActiveStorage("data"),i=l.getSharedStorage(Ri),o=l.getSharedStorage(Ci),r=l.getSharedStorage(Ai),h=l.getSharedStorage(bi),u=l.getActiveViewSizeInfo();let f=!1;if(l.setSharedStorage(gi,null),l.setSharedStorage(pi,null),l.setSharedStorage(yi,null),"drag"===h&&d.trigger(so,{show:!0}),"resize"===h&&r)l.setSharedStorage(Ai,null),f=!0;else if("area"===h){if(o?.operations?.locked?l.setSharedStorage(bi,"hover"):l.setSharedStorage(bi,null),t){const e=l.getSharedStorage(Mi),i=l.getSharedStorage(Ii);if(e&&i){const{materials:o}=function(e,t){const i=[],o=[],r=[],{viewScaleInfo:a,start:n,end:s}=t;if(!(Array.isArray(e.materials)&&n&&s))return{indexes:i,ids:o,materials:r};const l=Math.min(n.x,s.x),h=Math.max(n.x,s.x),c=Math.min(n.y,s.y),d=Math.max(n.y,s.y);for(let t=0;t<e.materials.length;t++){const n=e.materials[t];if(!0===n?.operations?.locked)continue;const s=re(n,{viewScaleInfo:a}),u=H(s);if(u.x>=l&&u.x<=h&&u.y>=c&&u.y<=d&&(i.push(t),o.push(n.id),r.push(n),s.angle&&(s.angle>0||s.angle<0))){const e=G(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.width=Math.abs(Math.max(...t)-Math.min(...t)),s.height=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:i,ids:o,materials:r}}(t,{start:e,end:i,viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()});o.length>0&&(l.setSharedStorage(bi,"drag-list"),g(o,{triggerEvent:!0}),f=!0)}}}else if("drag-list"===h)l.setSharedStorage(bi,"drag-list-end"),f=!0;else if(t){c.getPointMaterial(e.point,{data:t,viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()}).material?(l.setSharedStorage(bi,"select"),f=!0):l.setSharedStorage(bi,null)}null===l.getSharedStorage(bi)&&(p(),f=!0);(()=>{if(f){if(t&&Array.isArray(t?.materials)&&["drag","drag-list"].includes(h)){const e=function(e,t,i){const o=U(e,{viewWidth:t.width,viewHeight:t.height,extend:i?.extend});return o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight),{contextSize:o}}(t.materials,u,{extend:!0});l.setActiveStorage("contextHeight",e.contextSize.contextHeight),l.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(h)){let e="resizeMaterial";if(l.getSharedStorage(vi)){let r=null;const a=l.getSharedStorage(mi);if(Array.isArray(a)&&a.length){const e=a[0];if(1===i.length){r={type:"resizeMaterial",time:0,content:{method:"modifyMaterial",id:e.id,before:ve(e),after:ve(K(i[0]))}};const t=l.getSharedStorage(wi),o=l.getSharedStorage(Si);"group"===i[0].type&&t&&o&&(r={...o,content:{...o.content,before:t.content.before}})}else i.length>1&&(r={type:"resizeMaterials",time:0,content:{method:"modifyMaterials",before:a.map(e=>({...ve(e),id:e.id})),after:i.map(e=>({...ve(K(e)),id:e.id}))}})}ai(d,{data:t,type:e,selectedMaterials:i,hoverMaterial:o,modifyRecord:r}),l.setSharedStorage(vi,!1)}}s.drawFrame()}})()},pointLeave(){l.setSharedStorage(xi,null),l.setSharedStorage(Ai,null),d.trigger(o.CURSOR,{type:"default"})},doubleClick(e){if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;if(!1===l.getSharedStorage(ki))return;const t=Wi(e.point,m(e));if(l.setSharedStorage(Ri,[]),1!==t.materials.length||!0===t.materials[0]?.operations?.locked||!0===t.materials[0]?.operations?.invisible)return;const r=t.materials[0];if(i?.afterDoubleClickMaterial?.({material:r}),"group"===r?.type){if(!0===f(r))return l.setSharedStorage(bi,null),void s.drawFrame()}else"text"===r?.type&&d.trigger(o.TEXT_EDIT,{id:r.id});l.setSharedStorage(bi,null)},contextMenu:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;const t=l.getSharedStorage(Li);if(t?.length>0){if(Ao(e.nativeEvent,{$root:n,groupQueue:t})){const t=Wi(e.point,m(e));1===t?.materials?.length&&!0!==t.materials[0]?.operations?.locked?(p(),g([t.materials[0]],{triggerEvent:!0}),s.drawFrame()):t?.materials?.length||p()}return}const i=Vi(l.getSharedStorage(Ri),{viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()}),o=Wi(e.point,{...m(e),areaSize:i,groupQueue:[]});if(1===o?.materials?.length&&!0!==o.materials[0]?.operations?.locked)return p(),g([o.materials[0]],{triggerEvent:!0}),void s.drawFrame();o?.materials?.length||p()},beforeDrawFrame({snapshot:t}){zo({$root:n,styles:r,boardContent:h,snapshot:t,calculator:c,sharer:e.sharer})}}},e.MiddlewareTextEditor=(e,t)=>{const{eventHub:i,boardContent:r,viewer:a,sharer:n,calculator:s}=e,l=r.boardContext.canvas,h=e.container||document.body,c=tr({..._o,...t});let d=null,u=[],f="",g=!1;const m=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`,p=`${qo}-${Xe()}`;let y=null,x=null,v=null;const w=()=>{v?.remove()},S=e=>{v&&y&&(A(),((e,t,i)=>{if(!e||!t)return;const{viewScaleInfo:o,material:r,groupQueue:a}=i,{scale:n,offsetTop:s,offsetLeft:l}=o;t?.children&&Array.from(t.children).forEach(e=>{e.remove()});let h=t;for(let e=0;e<a.length;e++){const t=a[e],{x:i,y:o,width:r,height:c}=t,d={x:i*n,y:o*n,width:r*n,height:c*n,angle:X(t.angle||0)};0===e&&(d.x+=l,d.y+=s),h=or({size:d,parent:h})}const c={...ir,...r};let d=r.x*n+l,u=r.y*n+s,f=r.width*n,g=r.height*n;a.length>0&&(d=r.x*n,u=r.y*n,f=r.width*n,g=r.height*n);let m="center",p="center";"left"===c.textAlign?m="start":"right"===c.textAlign&&(m="end"),"top"===c.verticalAlign?p="start":"bottom"===c.verticalAlign&&(p="end"),it(e,{justifyContent:m,alignItems:p,transform:`rotate(${X(r.angle||0)}deg)`,left:d-1+"px",top:u-1+"px",width:`${f+2}px`,height:`${g+2}px`,cornerRadius:("number"==typeof c.cornerRadius?c.cornerRadius:0)*n+"px",color:`${c.fill||"#000000"}`,textStroke:"number"==typeof c.strokeWidth&&c.strokeWidth>0?`${c.strokeWidth}px ${c.stroke}`:"","-webkit-text-stroke":"number"==typeof c.strokeWidth&&c.strokeWidth>0?`${c.strokeWidth}px ${c.stroke}`:"",fontSize:c.fontSize*n+"px",lineHeight:(c.lineHeight||c.fontSize)*n+"px",fontFamily:$e(c.fontFamily),fontWeight:`${c.fontWeight}`,opacity:c.opacity||1}),e.innerText=c.text||"",h.appendChild(e)})(y,x,e),tt(v,[er.hide]),f="",g=!0,y.focus(),d?.id&&(n.setActiveOverrideMaterialMap({[d.id]:{operations:{invisible:!0}}}),f=d.text||"",a.drawFrame()))},b=()=>{if(d?.id){const e=n.getActiveOverrideMaterialMap();e&&delete e[d.id],n.setActiveOverrideMaterialMap(e),a.drawFrame()}v&&et(v,[er.hide]),d=null,u=[],g=!1,w()},A=()=>{if(!x)return;const{left:e,top:t,width:i,height:o}=(()=>{const e=l.getBoundingClientRect(),{left:t,top:i,width:o,height:r}=e;return{left:t,top:i,width:o,height:r}})();it(x,{position:"absolute",overflow:"hidden",top:`${t}px`,left:`${e}px`,width:`${i}px`,height:`${o}px`})},M=()=>{b()},I=e=>{e.stopPropagation(),e.preventDefault(),window?.getSelection()?.removeAllRanges()},C=e=>{2===e.attributes&&e.preventDefault()},R=()=>{if(y&&d&&u){d.text=y.innerText||"",i.trigger(o.TEXT_CHANGE,{material:{id:d.id,attributes:{text:d.text}},position:[...u||[]]});const e=s.getVirtualItem(d.id),t=n.getActiveStorage("data")||{materials:[]};s.modifyVirtualAttributes(d,{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:J(t.materials,e?.position||[])||[]}),a.drawFrame()}},E=()=>{if(d&&u){d.text=y?.innerText||"",i.trigger(o.TEXT_CHANGE,{material:{id:d.id,attributes:{text:d.text}},position:[...u]});const e=n.getActiveStorage("data")||{materials:[]},t={text:d.text};Te(d.id,t,e.materials),ai(i,{selectedMaterials:[{...d,...d,...t}],data:e,type:"modifyMaterial",modifyRecord:{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:d.id,before:{"attributes.text":f},after:{"attributes.text":d.text}}}});const r=s.getVirtualItem(d.id);s.modifyVirtualAttributes(d,{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:J(e.materials,r?.position||[])||[]}),a.drawFrame()}b()},z=e=>{e.stopPropagation()},L=e=>{e.stopPropagation(),e.preventDefault()},B=e=>{const{id:t}=e;if("string"!=typeof t||!t)return;!0!==g&&(y=rt("div",{className:er.textarea,contenteditable:"true"}),x=rt("div",{className:er.canvasWrapper},[y]),v=rt("div",{id:m,className:p},[x]),h.appendChild(v)),v?.addEventListener("click",M),y?.addEventListener("mousedown",z),y?.addEventListener("mouseover",z),y?.addEventListener("mouseenter",z),y?.addEventListener("mouseleave",z),y?.addEventListener("dblclick",I),y?.addEventListener("selectstart",C),y?.addEventListener("click",z),y?.addEventListener("input",R),y?.addEventListener("blur",E),y?.addEventListener("keydown",z),y?.addEventListener("keypress",z),y?.addEventListener("keyup",z),y?.addEventListener("wheel",L);const i=n.getActiveStorage("data"),{material:o,groupQueue:r,position:a}=Z(t,i.materials);"text"===o?.type&&(d=o,u=a,S({material:d,groupQueue:r,viewScaleInfo:n.getActiveViewScaleInfo()}))},k=()=>{if(!0===g)return!1};return{name:"@middleware/text-editor",use(){!function(e,t){mt({type:"element",rootClassName:e,styles:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",display:"block",zIndex:t.zIndex,[`&.${er.hide}`]:{display:"none"},[`.${er.textarea}`]:{display:"inline-flex",flexDirection:"column",position:"absolute",boxSizing:"border-box",overflow:"hidden",wordBreak:"break-all",padding:"0",margin:"0",outline:"none",border:`1px solid ${t.boxBorderColor}`,background:"transparent"},[`.${er.canvasWrapper}`]:{position:"absolute"}}})}(p,c),i.on(o.TEXT_EDIT,B)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(p),i.off(o.TEXT_EDIT,B),v?.removeEventListener("click",M),y?.removeEventListener("mousedown",z),y?.removeEventListener("mouseover",z),y?.removeEventListener("mouseenter",z),y?.removeEventListener("mouseleave",z),y?.removeEventListener("dblclick",I),y?.removeEventListener("selectstart",C),y?.removeEventListener("click",z),y?.removeEventListener("input",R),y?.removeEventListener("blur",E),y?.removeEventListener("keydown",z),y?.removeEventListener("keypress",z),y?.removeEventListener("keyup",z),y?.removeEventListener("wheel",L),w(),y=null,x=null,v=null,d=null,u=null,f=null},hover:k,pointStart:k,pointMove:k,pointEnd:k,pointLeave:k,doubleClick:k,contextMenu:k,wheel:k,wheelScale:k,scrollX:k,scrollY:k,resize:k}},e.Sharer=jt,e.coreEventKeys=o,e.getMiddlewareCreatorStyles=ti,e.getMiddlewareInfoStyles=ho,e.getMiddlewarePathCreatorStyles=ea,e.getMiddlewarePathEditorStyles=Er,e.getMiddlewareRulerStyles=Zo,e.getMiddlewareScrollerStyles=Yo,e.getMiddlewareSelectorStyles=Mo,e.getMiddlewareTextEditorStyles=tr,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),e}({});
1
+ var iDrawCore=function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var t="selectInGroup",i={CURSOR:"cursor",CHANGE:"change",CHANGING:"changing",RULER:"ruler",SCALE:"scale",CREATE:"create",CLEAR_CREATE:"clearCreate",SELECT_LAYOUT:"selectLayout",SELECT:"select",CLEAR_SELECT:"clearSelect",TEXT_EDIT:"textEdit",TEXT_CHANGE:"textChange",CONTEXT_MENU:"contextMenu",SELECT_IN_GROUP:t,SNAP_TO_GRID:t,PATH_EDIT:"pathEdit",CLEAR_PATH_EDIT:"clearPathEdit",PATH_CREATE:"pathCreate",CLEAR_PATH_CREATE:"clearPathCreate",MODE_CHANGE:"modeChange"},o={};function r(e,t){if(1===t)return e;let i=1;const o=/^#[0-9a-f]{6,6}$/i;let r=e;if(o.test(e)?i=parseInt(e.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(e)&&(i=parseInt(e.substring(7,9).replace(/^#/,"0x")),r=e.substring(0,7)),i*=t,o.test(r)&&i>0&&i<1){const e=Math.max(0,Math.min(255,Math.ceil(256*i)));r=`${r.toUpperCase()}${e.toString(16).toUpperCase()}`}return r}function a(e){return(65536*(1+Math.random())|0).toString(e||16).substring(1)}function n(){return`${a()}${a()}-${a()}-${a()}-${a()}-${a()}${a()}${a()}`}function s(e,t){let i=0;for(let t=0;t<e.length;t++)i+=e.charCodeAt(t);return(i+t).toString(16).substring(0,4)}function l(e,t){const i=e.length,o=function(e){let t=0;for(let i=0;i<e.length;i++)t+=e.charCodeAt(i);return t}(t),r=Math.floor(i/2),a=e.substring(0,4).padStart(4,"0"),n=e.substring(0,4).padStart(4,"0");return`@assets/${s(i.toString(16).padStart(4,a),o).padStart(4,"0")}${s(e.substring(r-4,r).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-8,r-4).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-12,r-8).padStart(4,a),o).padStart(4,"0")}-${s(e.substring(r-16,r-12).padStart(4,n),o).padStart(4,"0")}-${s(e.substring(r,r+4).padStart(4,n),o).padStart(4,"0")}${s(e.substring(r+4,r+8).padStart(4,n),o).padStart(4,"0")}${s(n.padStart(4,a).padStart(4,n),o)}`}function h(e){return/^@assets\/[0-9a-z-]{0,}$/.test(`${e}`)}function c(e){return function e(t){const i=function(e){return Object.prototype.toString.call(e).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(t);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return t;if("Array"===i){const i=[];return t.forEach(t=>{i.push(e(t))}),i}if("Object"===i){const i={};return Object.keys(t).forEach(o=>{i[o]=e(t[o])}),Object.getOwnPropertySymbols(t).forEach(o=>{i[o]=e(t[o])}),i}}(e)}function d(e){return(Object.prototype.toString.call(e)||"").replace(/(\[object|\])/gi,"").trim()}Object.keys(i).forEach(e=>{Object.defineProperty(o,e,{value:i[e],writable:!1})});var u={type(e,t){const i=d(e);return!0===t?i.toLocaleLowerCase():i},array:e=>"Array"===d(e),json:e=>"Object"===d(e),function:e=>"Function"===d(e),asyncFunction:e=>"AsyncFunction"===d(e),boolean:e=>"Boolean"===d(e),string:e=>"String"===d(e),number:e=>"Number"===d(e),undefined:e=>"Undefined"===d(e),null:e=>"Null"===d(e),promise:e=>"Promise"===d(e)};var{Image:f}=window;function g(e){return new Promise((t,i)=>{const o=new f;o.crossOrigin="anonymous",o.onload=function(){t(o)},o.onabort=i,o.onerror=i,o.src=e})}async function m(e){return await g(await function(e){return new Promise((t,i)=>{const o=new Blob([e],{type:"image/svg+xml;charset=utf-8"}),r=new FileReader;r.readAsDataURL(o),r.onload=function(e){const i=e?.target?.result;t(i)},r.onerror=function(e){i(e)}})}(e))}async function p(e,t){return e=e.replace(/&/gi,"&amp;"),await g(await function(e,t){const{width:i,height:o}=t;return new Promise((t,r)=>{const a=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${o||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${e}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),n=new FileReader;n.readAsDataURL(a),n.onload=function(e){const i=e?.target?.result;t(i)},n.onerror=function(e){r(e)}})}(e,t))}function y(e){return"number"==typeof e&&e>=0}function x(e){return"number"==typeof e&&(e>0||e<=0)}function v(e){return x(e)}function w(e){return x(e)}function S(e){return y(e)}function b(e){return y(e)}function A(e){return"string"==typeof e&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${e}`)}function M(e){return"string"==typeof e&&/^(data:image\/)/.test(`${e}`)}function I(e){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(e)}var C={positiveNum:y,data:function(e){return!!(Array(e?.materials)&&e?.materials.length>=0)},material:function(e){return!!e&&(I(e?.type)&&v(e?.x)&&w(e?.y)&&S(e?.w)&&b(e?.h))},layout:function(e){return!!e&&(v(e?.x)&&w(e?.y)&&S(e?.w)&&b(e?.h))},type:I,x:v,y:w,width:S,height:b,angle:function(e){return"number"==typeof e&&e>=-360&&e<=360},number:x,numberStr:function(e){return/^(-?\d+(?:\.\d+)?)$/.test(`${e}`)},strokeWidth:function(e){return y(e)||Array.isArray(e)&&y(e[0])&&y(e[1])&&y(e[2])&&y(e[3])},cornerRadius:function(e){return y(e)||Array.isArray(e)&&y(e[0])&&y(e[1])&&y(e[2])&&y(e[3])},color:function(e){return function(e){return"string"==typeof e&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e))}(e)},imageSrc:function(e){return M(e)||A(e)},imageURL:A,imageBase64:M,svg:function(e){return"string"==typeof e&&/^(<svg[\s]{1,}|<svg>)/i.test(`${e}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${e}`.trim())},html:function(e){let t=!1;if("string"==typeof e){let i=document.createElement("div");i.innerHTML=e,i.children.length>0&&(t=!0),i=null}return t},text:function(e){return"string"==typeof e},fontSize:function(e){return x(e)&&e>0},lineHeight:function(e){return x(e)&&e>0},textAlign:function(e){return["center","left","right"].includes(e)},fontFamily:function(e){return"string"==typeof e&&e.length>0},fontWeight:function(e){return["bold"].includes(e)}},R=class{#e;#t;constructor(e,t){this.#e=e,this.#t={devicePixelRatio:1,offscreenCanvas:null,...t},this.$resetFont()}$undoPixelRatio(e){return e/this.#t.devicePixelRatio}$doPixelRatio(e){return this.#t.devicePixelRatio*e}$getContext(){return this.#e}$setContext(e){this.#e=e}$setFont(e){const t=[];e.fontWeight&&t.push(`${e.fontWeight}`),t.push(`${this.$doPixelRatio(e.fontSize||12)}px`),t.push(`${e.fontFamily||"sans-serif"}`),this.#e.font=`${t.join(" ")}`}$resetFont(){this.$setFont({fontSize:12,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'",fontWeight:"400"})}$getOffscreenCanvas(){return this.#t.offscreenCanvas}$resize(e){const{width:t,height:i,devicePixelRatio:o,resetStyle:r}=e,{canvas:a}=this.#e;a.width=t*o,a.height=i*o,this.#t={...this.#t,devicePixelRatio:o},!0===r&&(a.style.width=`${t}px`,a.style.height=`${i}px`)}$getSize(){const{devicePixelRatio:e}=this.#t,{width:t,height:i}=this.#e.canvas;return{width:t/e,height:i/e,devicePixelRatio:e}}get canvas(){return this.#e.canvas}get fillStyle(){return this.#e.fillStyle}set fillStyle(e){this.#e.fillStyle=e}get strokeStyle(){return this.#e.strokeStyle}set strokeStyle(e){this.#e.strokeStyle=e}get lineWidth(){return this.$undoPixelRatio(this.#e.lineWidth)}set lineWidth(e){this.#e.lineWidth=this.$doPixelRatio(e)}get textAlign(){return this.#e.textAlign}set textAlign(e){this.#e.textAlign=e}get textBaseline(){return this.#e.textBaseline}set textBaseline(e){this.#e.textBaseline=e}get globalAlpha(){return this.#e.globalAlpha}set globalAlpha(e){this.#e.globalAlpha=e}get shadowColor(){return this.#e.shadowColor}set shadowColor(e){this.#e.shadowColor=e}get shadowOffsetX(){return this.$undoPixelRatio(this.#e.shadowOffsetX)}set shadowOffsetX(e){this.#e.shadowOffsetX=this.$doPixelRatio(e)}get shadowOffsetY(){return this.$undoPixelRatio(this.#e.shadowOffsetY)}set shadowOffsetY(e){this.#e.shadowOffsetY=this.$doPixelRatio(e)}get shadowBlur(){return this.$undoPixelRatio(this.#e.shadowBlur)}set shadowBlur(e){this.#e.shadowBlur=this.$doPixelRatio(e)}get lineCap(){return this.#e.lineCap}set lineCap(e){this.#e.lineCap=e}get lineJoin(){return this.#e.lineJoin}set lineJoin(e){this.#e.lineJoin=e}get lineDashOffset(){return this.#e.lineDashOffset}set lineDashOffset(e){this.#e.lineDashOffset=e}get miterLimit(){return this.#e.miterLimit}set miterLimit(e){this.#e.miterLimit=e}get globalCompositeOperation(){return this.#e.globalCompositeOperation}set globalCompositeOperation(e){this.#e.globalCompositeOperation=e}fill(...e){return this.#e.fill(...e)}arc(e,t,i,o,r,a){return this.#e.arc(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),o,r,a)}rect(e,t,i,o){return this.#e.rect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}fillRect(e,t,i,o){return this.#e.fillRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}clearRect(e,t,i,o){return this.#e.clearRect(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}beginPath(){return this.#e.beginPath()}closePath(){return this.#e.closePath()}lineTo(e,t){return this.#e.lineTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}moveTo(e,t){return this.#e.moveTo(this.$doPixelRatio(e),this.$doPixelRatio(t))}arcTo(e,t,i,o,r){return this.#e.arcTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r))}bezierCurveTo(e,t,i,o,r,a){return this.#e.bezierCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}quadraticCurveTo(e,t,i,o){return this.#e.quadraticCurveTo(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}getLineDash(){return this.#e.getLineDash()}setLineDash(e){const t=e.map(e=>this.$doPixelRatio(e));return this.#e.setLineDash(t)}stroke(e){return e?this.#e.stroke(e):this.#e.stroke()}translate(e,t){return this.#e.translate(this.$doPixelRatio(e),this.$doPixelRatio(t))}rotate(e){return this.#e.rotate(e)}drawImage(...e){const t=e[0],i=e[1],o=e[2],r=e[3],a=e[4],n=e[e.length-4],s=e[e.length-3],l=e[e.length-2],h=e[e.length-1];return 9===e.length?this.#e.drawImage(t,this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a),this.$doPixelRatio(n),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h)):this.#e.drawImage(t,this.$doPixelRatio(n),this.$doPixelRatio(s),this.$doPixelRatio(l),this.$doPixelRatio(h))}createPattern(e,t){return this.#e.createPattern(e,t)}measureText(e){return this.#e.measureText(e)}fillText(e,t,i,o){return void 0!==o?this.#e.fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):this.#e.fillText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}strokeText(e,t,i,o){return void 0!==o?this.#e.strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o)):this.#e.strokeText(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}save(){this.#e.save()}restore(){this.#e.restore()}scale(e,t){this.#e.scale(e,t)}circle(e,t,i,o,r,a,n,s){this.#e.ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,n,s)}ellipse(e,t,i,o,r,a,n,s){this.#e.ellipse(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),r,a,n,s)}isPointInPath(e,t){return this.#e.isPointInPath(this.$doPixelRatio(e),this.$doPixelRatio(t))}clip(...e){return this.#e.clip(...e)}setTransform(e,t,i,o,r,a){return this.#e.setTransform(e,t,i,o,r,a)}getTransform(){return this.#e.getTransform()}createLinearGradient(e,t,i,o){return this.#e.createLinearGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o))}createRadialGradient(e,t,i,o,r,a){return this.#e.createRadialGradient(this.$doPixelRatio(e),this.$doPixelRatio(t),this.$doPixelRatio(i),this.$doPixelRatio(o),this.$doPixelRatio(r),this.$doPixelRatio(a))}createConicGradient(e,t,i){return this.#e.createConicGradient(e,this.$doPixelRatio(t),this.$doPixelRatio(i))}};function z(e){const{width:t,height:i,devicePixelRatio:o}=e,r=new OffscreenCanvas(t*o,i*o);return new R(r.getContext("2d").canvas.getContext("2d"),{devicePixelRatio:o,offscreenCanvas:r})}function E(e,t){const{width:i,height:o,devicePixelRatio:r}=t,a={width:i,height:o,devicePixelRatio:r},n=e.getContext("2d"),s=z(a),l=z(a),h=z(a),c=function(e){const{width:t,height:i,ctx:o,devicePixelRatio:r}=e;let a=o;if(!a){const e=document.createElement("canvas");e.width=t*r,e.height=i*r,a=e.getContext("2d")}return new R(a,e)}({ctx:n,...a}),d=z(a);return{underlayContext:h,viewContext:s,overlayContext:l,boardContext:c,tempContext:d,drawView:()=>{const{width:e,height:t}=s.$getSize();c.clearRect(0,0,e,t),c.drawImage(h.canvas,0,0,e,t),c.drawImage(s.canvas,0,0,e,t),c.drawImage(l.canvas,0,0,e,t),h.clearRect(0,0,e,t),s.clearRect(0,0,e,t),l.clearRect(0,0,e,t)}}}var L=class{#i;constructor(){this.#i=new Map}on(e,t){if(this.#i.has(e)){const i=this.#i.get(e)||[];i?.push(t),this.#i.set(e,i)}else this.#i.set(e,[t])}off(e,t){if(this.#i.has(e)){const i=this.#i.get(e);if(Array.isArray(i))for(let e=0;e<i?.length;e++)if(i[e]===t){i.splice(e,1);break}this.#i.set(e,i||[])}}trigger(e,t){const i=this.#i.get(e);return!!Array.isArray(i)&&(i.forEach(e=>{e(t)}),!0)}has(e){if(this.#i.has(e)){const t=this.#i.get(e);if(Array.isArray(t)&&t.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#i.clear()}};function B(e,t){return{x:e.x+(t.x-e.x)/2,y:e.y+(t.y-e.y)/2}}var k=class{#o;#r;#a;constructor(e){this.#r=c(e.defaultStorage),this.#o=this.#n(),this.#a=e.defaultStatic||{}}set(e,t){this.#o[e]=t}get(e){return this.#o[e]}setStatic(e,t){this.#a[e]=t}getStatic(e){return this.#a[e]}getSnapshot(e){return!0===e?.deepClone?c(this.#o):{...this.#o}}clear(){this.#o=this.#n()}destroy(){this.#o=null,this.#a=null}#n(){return c(this.#r)}};function P(e){const{activeStore:t}=e;return{scale:t?.scale,offsetTop:t?.offsetTop,offsetBottom:t?.offsetBottom,offsetLeft:t?.offsetLeft,offsetRight:t?.offsetRight}}function T(e){const{activeStore:t}=e;return{devicePixelRatio:t.devicePixelRatio,width:t?.width,height:t?.height,contextWidth:t?.contextWidth,contextHeight:t?.contextHeight}}function N(e,t){const i={};return e&&t.forEach(t=>{const o=e?.[t];"string"!=typeof o&&"number"!=typeof o||(i[t]=o)}),i}function D(e){return e/180*Math.PI}function $(e,t,i,o){const r=D(t||0);i&&(r>0||r<0)&&(e.translate(i.x,i.y),e.rotate(r),e.translate(-i.x,-i.y)),o(e),i&&(r>0||r<0)&&(e.translate(i.x,i.y),e.rotate(-r),e.translate(-i.x,-i.y))}function H(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function W(e){const t=Math.min(e[0].x,e[1].x,e[2].x,e[3].x),i=Math.min(e[0].y,e[1].y,e[2].y,e[3].y);return H({x:t,y:i,width:Math.max(e[0].x,e[1].x,e[2].x,e[3].x)-t,height:Math.max(e[0].y,e[1].y,e[2].y,e[3].y)-i})}function O(e,t){const i=t.x-e.x,o=t.y-e.y;if(0===i){if(o<0)return 0;if(o>0)return Math.PI}else if(0===o){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&o<0?Math.atan(Math.abs(i)/Math.abs(o)):i>0&&o>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(o)):i<0&&o<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(o)):0}function Y(e,t,i){let o=O(e,t)+i;o>2*Math.PI?o-=2*Math.PI:o<0-2*Math.PI&&(o+=2*Math.PI),o<0&&(o+=2*Math.PI);const r=function(e,t){const i=(e.x-t.x)*(e.x-t.x)+(e.y-t.y)*(e.y-t.y);return 0===i?i:Math.sqrt(i)}(e,t);let a=0,n=0;return 0===o?(a=0,n=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,n=0-Math.cos(o)*r):o===Math.PI/2?(a=r,n=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,n=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,n=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,n=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,n=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,n=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,n=0-r),a+=e.x,n+=e.y,{x:a,y:n}}function V(e,t){if(t?.length>0){let i=e.x,o=e.y;return t.forEach(e=>{const{x:t,y:r,width:a,height:n,angle:s=0}=e,l=Y(H({x:t,y:r,width:a,height:n,angle:s}),{x:i,y:o},D(s));i=l.x,o=l.y}),{x:i,y:o}}return e}function j(e,t,i){const{x:o,y:r,width:a,height:n}=e;let s={x:o,y:r},l={x:o+a,y:r},h={x:o+a,y:r+n},c={x:o,y:r+n};if(i&&(i>0||i<0)){const e=D(X(i));s=Y(t,s,e),l=Y(t,l,e),h=Y(t,h,e),c=Y(t,c,e)}return[s,l,h,c]}function G(e){const{angle:t=0}=e;return j(e,H(e),t)}function F(e,t,i){return[Y(e,{x:t[0].x,y:t[0].y},i),Y(e,{x:t[1].x,y:t[1].y},i),Y(e,{x:t[2].x,y:t[2].y},i),Y(e,{x:t[3].x,y:t[3].y},i)]}function X(e){if(!(e>0||e<0)||0===e||360===e)return 0;let t=e%360;return t<0?t+=360:360===e&&(t=0),t}function Q(e){let t=!0;if(Array.isArray(e)){const i=[];e.forEach(e=>{"string"==typeof e.id&&e.id?i.includes(e.id)?(t=!1,console.warn(`Duplicate ids: ${e.id}`)):i.push(e.id):(t=!1,console.warn("Material missing id",e)),"group"===e.type&&(t=Q(e?.children))})}return t}function U(e,t){const i={x:0,y:0,width:0,height:0};e.forEach(e=>{const t={x:e.x,y:e.y,width:e.width,height:e.height,angle:e.angle};if(t.angle&&(t.angle>0||t.angle<0)){const e=G(t);if(4===e.length){const i=[e[0].x,e[1].x,e[2].x,e[3].x],o=[e[0].y,e[1].y,e[2].y,e[3].y];t.x=Math.min(...i),t.y=Math.min(...o),t.width=Math.abs(Math.max(...i)-Math.min(...i)),t.height=Math.abs(Math.max(...o)-Math.min(...o))}}const o=Math.min(t.x,i.x),r=Math.min(t.y,i.y),a=Math.max(t.x+t.width,i.x+i.width),n=Math.max(t.y+t.height,i.y+i.height);i.x=o,i.y=r,i.width=Math.abs(a-o),i.height=Math.abs(n-r)}),t?.extend&&(i.x=Math.min(i.x,0),i.y=Math.min(i.y,0));const o={contextWidth:i.width,contextHeight:i.height};return t?.viewWidth&&t?.viewHeight&&t?.viewWidth>0&&t?.viewHeight>0&&(t.viewWidth>i.x+i.width&&(o.contextWidth=t.viewWidth-i.x),t.viewHeight>i.y+i.height&&(o.contextHeight=t.viewHeight-i.y)),o}function Z(e,t){const i=[];let o=null;const r=[];return function e(t,a){let n=null;for(let s=0;s<a.length;s++){const l=a[s];if(r.push(s),l.id===t){n=l,o=l;break}if(!n&&"group"===l.type){i.push(l);const o=e(t,l?.children||[]);if(o?.id===t){n=o;break}i.pop(),r.pop()}}return n}(e,t),{groupQueue:i,material:o,position:r}}function J(e,t){const i=[];let o=e;if(t.length>1)for(let e=0;e<t.length-1;e++){const r=o[t[e]];if("group"!==r?.type||!Array.isArray(r?.children))return null;i.push(r),o=r.children}return i}function K(e){const{id:t,x:i,y:o,width:r,height:a,angle:n=0}=e;return{id:t,x:i,y:o,width:r,height:a,angle:n}}function q(e,t){let i=null,o=t;for(let t=0;t<e.length;t++){const r=o[e[t]];if(t<e.length-1&&"group"===r?.type)o=r.children;else{if(t!==e.length-1)break;i=r}}return i}function _(e,t){const i=[];let o=!1;const r=t=>{for(let a=0;a<t.length&&!0!==o;a++){i.push(a);const n=t[a];if(n.id===e){o=!0;break}if("group"===n.type&&r(n?.children||[]),o)break;i.pop()}};return r(t),i}function ee(e){const{x:t,y:i,height:o,width:r}=e;return[{x:t,y:i},{x:t+r,y:i},{x:t+r,y:i+o},{x:t,y:i+o}]}function te(e){const{x:t,y:i,width:o,height:r,angle:a=0}=e;return 0===a?ee(e):j(e,H({x:t,y:i,width:o,height:r,angle:a}),a)}function ie(e,t){const{groupQueue:i}=t;return i.length>0?function(e){const t=[];let i=0,o=0;const r=[],a=[...e];for(let e=0;e<a.length;e++){const{x:n,y:s,width:l,height:h,angle:c=0}=a[e];let d;if(i+=n,o+=s,0===e){const e={x:i,y:o,width:l,height:h,angle:c};d=te({x:n,y:s,width:l,height:h,angle:c}),r.push({center:H(e),angle:c,radian:D(c)})}else{d=ee({x:i,y:o,width:l,height:h,angle:c});for(let e=0;e<r.length;e++){const{center:t,radian:i}=r[e];d=F(t,d,i)}const e=W(d);(c>0||c<0)&&(d=F(e,d,D(c))),r.push({center:e,angle:c,radian:D(c)})}t.push(d)}return t}([...i,e]):[te(e)]}function oe(e,t){return ie(e,t).pop()||null}function re(e,t){const{viewScaleInfo:i}=t,{id:o,x:r,y:a,width:n,height:s,angle:l}=e,{scale:h=1,offsetTop:c=0,offsetLeft:d=0}=i;return{id:o,x:r*h+d,y:a*h+c,width:n*h,height:s*h,angle:l}}function ae(e,t){const{viewScaleInfo:i}=t,{x:o,y:r}=e,{scale:a,offsetTop:n,offsetLeft:s}=i;return{x:o*a+s,y:r*a+n}}function ne(e,t){const{viewScaleInfo:i}=t,{x:o,y:r}=e,{scale:a,offsetTop:n,offsetLeft:s}=i;return{x:(o-s)/a,y:(r-n)/a}}function se(e,t){const{context2d:i,material:o,viewScaleInfo:r}=t,{angle:a=0}=o,{x:n,y:s,width:l,height:h}=re(o,{viewScaleInfo:r}),c=G({x:n,y:s,width:l,height:h,angle:a});if(c.length>=2){i.beginPath(),i.moveTo(c[0].x,c[0].y);for(let e=1;e<c.length;e++)i.lineTo(c[e].x,c[e].y);i.closePath()}return!!i.isPointInPath(e.x,e.y)}function le(e,t,i){return function(e,t,i){const o=[t[0].x,t[1].x,t[2].x,t[3].x],r=[t[0].y,t[1].y,t[2].y,t[3].y],a=Math.min(...o),n=Math.max(...o),s=Math.min(...r),l=Math.max(...r);return e.x>a&&e.x<n&&e.y>s&&e.y<l||!0===i?.includeBorder&&(e.x===a||e.x===n||e.y===s||e.y===l)}(e,te(t),i)}function he(e,t){const{groupQueue:i}=t,o=oe(e,{groupQueue:i}),r=B(o[0],o[1]),a=B(o[1],o[2]),n=B(o[2],o[3]),s=B(o[3],o[0]),l=o[0],h=o[1],c=o[2],d=o[3],u=Math.max(l.x,h.x,c.x,d.x),f=Math.max(l.y,h.y,c.y,d.y);return{center:{x:(u+Math.min(l.x,h.x,c.x,d.x))/2,y:(f+Math.min(l.y,h.y,c.y,d.y))/2},topLeft:l,topRight:h,bottomLeft:d,bottomRight:c,top:r,right:a,left:s,bottom:n}}function ce(e){const t=Math.max(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),i=Math.max(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),o=Math.min(e.topLeft.x,e.topRight.x,e.bottomRight.x,e.bottomLeft.x),r=Math.min(e.topLeft.y,e.topRight.y,e.bottomRight.y,e.bottomLeft.y),a={x:e.center.x,y:e.center.y},n={x:o,y:r},s={x:t,y:r},l={x:t,y:i},h={x:o,y:i},c=B(n,s),d=B(h,l),u=B(n,h);return{center:a,topLeft:n,topRight:s,bottomLeft:h,bottomRight:l,top:c,right:B(s,l),left:u,bottom:d}}function de(e){let t="";return e.forEach(e=>{t+=e.type+e.params?.join?.(" ")}),t}function ue(e,t){let i=2;return void 0!==t?.decimalPlaces&&t?.decimalPlaces>=0&&(i=t.decimalPlaces),parseFloat(e.toFixed(i))}var fe="Text",ge="#787878",me=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(`<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200" fill="${ge}"><path d="M928 160H96c-17.7 0-32 14.3-32 32v640c0 17.7 14.3 32 32 32h832c17.7 0 32-14.3 32-32V192c0-17.7-14.3-32-32-32zM338 304c35.3 0 64 28.7 64 64s-28.7 64-64 64-64-28.7-64-64 28.7-64 64-64z m513.9 437.1c-1.4 1.2-3.3 1.9-5.2 1.9H177.2c-4.4 0-8-3.6-8-8 0-1.9 0.7-3.7 1.9-5.2l170.3-202c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l99.4 118 158.1-187.5c2.8-3.4 7.9-3.8 11.3-1 0.3 0.3 0.7 0.6 1 1l229.6 271.6c2.6 3.3 2.2 8.4-1.2 11.2z" ></path></svg>`)}`;function pe(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:ge,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:fe,fontSize:12,fontFamily:"system-ui",fontWeight:"normal",fontStyle:"normal",textAnchor:"start",textDecoration:"none",letterSpacing:"normal",wordSpacing:"normal",writingMode:"horizontal-tb",textAlign:"left",verticalAlign:"top",href:me}}function ye(e,t="",i={},o){return Object.keys(e).forEach(r=>{const a=t?`${t}${function(e){return/^\d+$/.test(e)&&!isNaN(Number(e))}(r)?`[${r}]`:`.${r}`}`:r;if(!o?.ignorePaths?.includes(a)){const t=e[r];!function(e){return"object"==typeof e&&null!==e&&!(e instanceof Date)||Array.isArray(e)}(t)?i[a]=t:ye(t,(Array.isArray(t),a),i,o)}}),i}function xe(e,t){return"object"!=typeof e||null===e?{"":e}:ye(e,"",{},t)}function ve(e){return xe(e,{ignorePaths:["children"]})}function we(e){return xe(e)}function Se(e){return xe(e)}function be(e){return Array.isArray(e)?[...e]:e.split(/\.|\[|\]/).filter(e=>""!==e)}function Ae(e,t,i){if(!t)return;const o=be(t);let r=e;for(const e of o){if(null==r)return i;r=r[e]}return void 0!==r?r:i}function Me(e,t,i){const o=be(t);if(0===o.length)return e;let r=e;if(r)for(let e=0;e<o.length;e++){const t=o[e];if(e===o.length-1){r[t]=i;break}if(r&&(void 0===r?.[t]||"object"!=typeof r?.[t]||null===r?.[t])){const i=o[e+1],a=/^\d+$/.test(i);r[t]=a?[]:{}}r=r?.[t]}return e}function Ie(e,t){const i=be(t);if(0===i.length)return e;let o=e;if(o)for(let e=0;e<i.length;e++){const t=i[e];if(e===i.length-1){delete o[t];break}if(o&&(void 0===o?.[t]||"object"!=typeof o?.[t]||null===o?.[t])){const r=i[e+1],a=/^\d+$/.test(r);o[t]=a?[]:{}}o=o?.[t]}return e}var Ce=e=>ue(e,{decimalPlaces:4});function Re(e,t){const i={},o={},r={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:e.id,before:null,after:null}},{xRatio:a,yRatio:n,maxRatio:s}=t,l=(a+n)/2,{strokeWidth:h,cornerRadius:c,strokeDasharray:d,shadowOffsetX:u,shadowOffsetY:f,shadowBlur:g}=e;if("number"==typeof h)e.strokeWidth=Ce(h*l),i.strokeWidth=h,o.strokeWidth=e.strokeWidth;else if(Array.isArray(e.strokeWidth)){const t=h;e.strokeWidth=[Ce(t[0]*n),Ce(t[1]*a),Ce(t[2]*n),Ce(t[3]*a)],i.strokeWidth=[...t],o.strokeWidth=[...h]}if("number"==typeof c)e.cornerRadius=Ce(c*l),i.cornerRadius=c,o.cornerRadius=e.cornerRadius;else if(Array.isArray(e.cornerRadius)){const t=c;e.cornerRadius=[t[0]*a,t[1]*a,t[2]*n,t[3]*n],i.cornerRadius=[...t],o.cornerRadius=[...c]}return Array.isArray(d)&&(d.forEach((t,i)=>{e.strokeDasharray[i]=Ce(t*s)}),i.strokeDasharray=[...d],o.strokeDasharray=[...e.strokeDasharray]),"number"==typeof u&&(e.shadowOffsetX=Ce(u*s),i.shadowOffsetX=u,o.shadowOffsetX=e.shadowOffsetX),"number"==typeof f&&(e.shadowOffsetY=Ce(f*s),i.shadowOffsetY=f,o.shadowOffsetY=e.shadowOffsetY),"number"==typeof g&&(e.shadowBlur=Ce(g*s),i.shadowBlur=g,o.shadowBlur=e.shadowBlur),r.content.before=ve(i),r.content.after=ve(o),r}function ze(e,t,i){const{type:o,id:r}=e,a=function(e,t){const{xRatio:i,yRatio:o}=t,{id:r,x:a,y:n,width:s,height:l}=e;e.x=Ce(a*i),e.y=Ce(n*o),e.width=Ce(s*i),e.height=Ce(l*o);const h={type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:r,before:{x:a,y:n,width:s,height:l},after:{x:e.x,y:e.y,width:e.width,height:e.height}}},c=Re(e,t);return h.content.before={...h.content.before,...c.content.before},h.content.after={...h.content.after,...c.content.after},h}(e,t),n={...a.content.before,id:r},s={...a.content.after,id:r};if(i?.content.before.push(n),i?.content.after.push(s),"circle"===o);else if("text"===o){const i=function(e,t){const{minRatio:i,maxRatio:o}=t,{fontSize:r,lineHeight:a}=e,n=(i+o)/2,s={},l={};return r&&r>0&&(e.fontSize=Ce(r*n),s.fontSize=r,l.fontSize=e.fontSize),a&&a>0&&(e.lineHeight=Ce(a*n),s.lineHeight=a,l.lineHeight=e.lineHeight),{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:e.id,before:s,after:l}}}(e,t);Object.keys(i.content.before||{}).forEach(e=>{n[e]=i.content.before?.[e]}),Object.keys(i.content.after||{}).forEach(e=>{s[e]=i.content.after?.[e]})}else"image"===o||"svgCode"===o||"foreignObject"===o||"path"===o||"group"===o&&Array.isArray(e.children)&&e.children.forEach(e=>{ze(e,t,i)})}function Ee(e,t,i){const o={type:"resizeMaterials",time:Date.now(),content:{method:"modifyMaterials",before:[],after:[]}},r=e.id,a=e.x,n=e.y,s=e.width,l=e.height,h=u.number(t.x)?t.x:e.x,c=u.number(t.y)?t.y:e.y,d=(t.width&&t.width>0?t.width:e.width)||0,f=(t.height&&t.height>0?t.height:e.height)||0,g={id:r,x:a,y:n,width:s,height:l},m={id:r,x:h,y:c,width:d,height:f};if("deepResize"===i?.resizeEffect){o.content.before.push(g),o.content.after.push(m);const t=d/e.width,i=f/e.height;if(t===i&&1===t)return o;const r=Math.min(t,i),a=Math.max(t,i);e.width=d,e.height=f;const n={xRatio:t,yRatio:i,minRatio:r,maxRatio:a};"group"===e.type&&Array.isArray(e.children)&&e.children.forEach(e=>{ze(e,n,o)});const s=Re(e,n);return Object.keys(s.content.before||{}).forEach(e=>{g[e]=s.content.before?.[e]}),Object.keys(s.content.after||{}).forEach(e=>{m[e]=s.content.after?.[e]}),o}if("fixed"===i?.resizeEffect){o.content.before.push(g),o.content.after.push(m);const t=h-e.x,i=c-e.y,r=d-e.width;return function(e,t,i){if("group"!==e.type||!Array.isArray(e.children))return;const{moveX:o,moveY:r,moveH:a,moveW:n}=t;let s=0,l=0,h=!1;0===o&&0===r||0===a&&0===n||(h=!0,s=-o,l=-r),!0===h&&e.children.forEach(e=>{const{id:t,x:o,y:r}=e,a=o+s,n=r+l,h={id:t,x:o,y:r},c={id:t,x:a,y:n};e.x=a,e.y=n,i?.content.before.push(h),i?.content.after.push(c)})}(e,{moveX:t,moveY:i,moveH:f-e.height,moveW:r},o),e.width=d,e.height=f,e.x=h,e.y=c,o}return e.width=d,e.height=f,e.x=h,e.y=c,o.content.before.push(g),o.content.after.push(m),o}function Le(e,t,i){const o=function(e,t){let i=0,o=0,r=200,a=200;if(t){const{viewScaleInfo:n,viewSizeInfo:s}=t,{scale:l,offsetLeft:h,offsetTop:c}=n,{width:d,height:u}=s,f=d/4,g=u/4;r=200>=f?f/l:200/l,a=200>=g?g/l:200/l,["circle","svgCode","image"].includes(e)?r=a=Math.max(r,a):"text"===e&&(a=r/4*2),i=(0-h+d/2-r*l/2)/l,o=(0-c+u/2-a*l/2)/l}return{x:i,y:o,width:r,height:a}}(e,i);let r={};if("rect"===e)r={fill:pe().fill};else if("circle"===e)r={fill:pe().fill,cx:200,cy:200,r:100};else if("text"===e)r=function(e){const t=pe();return{text:fe,fill:t.fill,fontFamily:t.fontFamily,fontWeight:t.fontWeight,fontSize:e.width/4,textAlign:"center",verticalAlign:"middle"}}(o);else if("svgCode"===e)r={code:`<svg t="1701004189871" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M908.1 353.1l-253.9-36.9L540.7 86.1c-3.1-6.3-8.2-11.4-14.5-14.5-15.8-7.8-35-1.3-42.9 14.5L369.8 316.2l-253.9 36.9c-7 1-13.4 4.3-18.3 9.3-12.3 12.7-12.1 32.9 0.6 45.3l183.7 179.1-43.4 252.9c-1.2 6.9-0.1 14.1 3.2 20.3 8.2 15.6 27.6 21.7 43.2 13.4L512 754l227.1 119.4c6.2 3.3 13.4 4.4 20.3 3.2 17.4-3 29.1-19.5 26.1-36.9l-43.4-252.9 183.7-179.1c5-4.9 8.3-11.3 9.3-18.3 2.7-17.5-9.5-33.7-27-36.3zM664.8 561.6l36.1 210.3L512 672.7 323.1 772l36.1-210.3-152.8-149L417.6 382 512 190.7 606.4 382l211.2 30.7-152.8 148.9z" fill="${ge}"></path></svg>`};else if("image"===e)r={href:me};else if("group"===e){r={children:[],fill:pe().fill,overflow:"hidden"};const e=t;Array.isArray(e.children)&&e.children.length>0&&(r.children=[...e.children])}return{id:n(),type:e,...o,...r,...t}}function Be(e,t,i){let o=!1;if(1===t.length){const r=t[0];i.splice(r,0,e),o=!0}else if(t.length>1){let r=i;for(let i=0;i<t.length;i++){const a=r[t[i]];if(i===t.length-1){const a=t[i];r.splice(a,0,e),o=!0}else{if(!(i<t.length-1&&"group"===a.type))break;r=a.children}}}return o}function ke(e,t){let i=!1;if(1===e.length){const o=e[0];t.splice(o,1),i=!0}else if(e.length>1){let o=t;for(let t=0;t<e.length;t++){const r=o[e[t]];if(t===e.length-1){const r=e[t];o.splice(r,1),i=!0}else{if(!(t<e.length-1&&"group"===r.type))break;o=r.children}}}return i}function Pe(e,t,i){const o=ve(t),r=["id","type"],a=Object.keys(o);if(a.forEach(t=>{if(!r.includes(t)){const i=o[t];Ie(e,t),void 0!==i&&Me(e,t,i)}}),!0===i?.onlyUpdateContent){const t=ve(e);Object.keys(t).forEach(t=>{r.includes(t)||a.includes(t)||Ie(e,t)})}return e.fill&&(e.fill=function(e){if(Array.isArray(e?.stops)){const t=[],i=e?.stops;for(let e=i.length-1;e>=0;e--){const o=i[e];o.color&&o.offset>=0||t.push(e)}t.forEach(e=>{i.splice(e,1)})}return e}(e.fill)),e}function Te(e,t,i){let o=null;for(let r=0;r<i.length;r++){const a=i[r];if(a.id===e){"group"===a.type&&a.operations?.resizeEffect&&Ee(a,{...t},{resizeEffect:a.operations?.resizeEffect}),Pe(a,t),o=a;break}"group"===a.type&&(o=Te(e,t,a?.children||[]))}return o}function Ne(e,t,i,o){const r=q(e,i);return r&&("group"===r.type&&r.operations?.resizeEffect&&Ee(r,{...t},{resizeEffect:r.operations?.resizeEffect}),Pe(r,t,o)),r}var De=["-apple-system","\"system-ui\""," \"Segoe UI\""," Roboto","\"Helvetica Neue\"","Arial","\"Noto Sans\""," sans-serif"];function $e(e){return[e,...De].join(", ")}function He(e,t,i){let o=t.x-e.x,r=t.y-e.y;const a=[];if(i.forEach(e=>{const{x:t,y:i,width:o,height:r,angle:n=0}=e;a.push({x:t,y:i,width:o,height:r,angle:0-n})}),i?.length>0){const i=V(e,a),n=V(t,a);o=n.x-i.x,r=n.y-i.y}return{moveX:o,moveY:r}}function We(e,t,i,o,r,a,n,s){const l=[];l.push({x:e,y:t}),l.push({x:n,y:s});const h=Ve(3*(3*i-e-3*r+n),6*(e-2*i+r),3*(i-e));for(const c of h)if(c>0&&c<1){const h=je(c,e,i,r,n),d=je(c,t,o,a,s);l.push({x:h,y:d})}const c=Ve(3*(3*o-t-3*a+s),6*(t-2*o+a),3*(o-t));for(const h of c)if(h>0&&h<1){const c=je(h,e,i,r,n),d=je(h,t,o,a,s);l.push({x:c,y:d})}return l}function Oe(e,t,i,o,r,a){const n=[];n.push({x:e,y:t}),n.push({x:r,y:a});const s=e-2*i+r;if(0!==s){const l=-(2*(i-e))/(2*s);if(l>0&&l<1){const s=Ge(l,e,i,r),h=Ge(l,t,o,a);n.push({x:s,y:h})}}const l=t-2*o+a;if(0!==l){const s=-(2*(o-t))/(2*l);if(s>0&&s<1){const l=Ge(s,e,i,r),h=Ge(s,t,o,a);n.push({x:l,y:h})}}return n}function Ye(e,t,i,o,r,a,n,s,l){const h=[],c=r*Math.PI/180,d=Math.cos(c),u=Math.sin(c),f=(e+s)/2,g=(t+l)/2,m=(e-s)/2,p=(t-l)/2,y=d*m+u*p,x=-u*m+d*p;let v=i,w=o;const S=y*y,b=x*x,A=S/(i*i)+b/(o*o);A>1&&(v=Math.sqrt(A)*i,w=Math.sqrt(A)*o);const M=a===n?-1:1,I=Math.max(0,v*v*w*w-v*v*b-w*w*S),C=v*v*b+w*w*S;let R=M*Math.sqrt(I/C);isNaN(R)&&(R=0);const z=R*(v*x/w),E=R*(-w*y/v),L=d*z-u*E+f,B=u*z+d*E+g,k=Math.atan2((x-E)/w,(y-z)/v);let P=Math.atan2((-x-E)/w,(-y-z)/v)-k;0===n&&P>0?P-=2*Math.PI:1===n&&P<0&&(P+=2*Math.PI);for(let e=0;e<=100;e++){const t=k+e/100*P,i=L+v*Math.cos(t)*d-w*Math.sin(t)*u,o=B+v*Math.cos(t)*u+w*Math.sin(t)*d;h.push({x:i,y:o})}return h}function Ve(e,t,i){const o=[];if(0===e){if(0!==t){const e=-i/t;e>=0&&e<=1&&o.push(e)}return o}const r=t*t-4*e*i;if(r>0){const i=Math.sqrt(r),a=(-t+i)/(2*e),n=(-t-i)/(2*e);a>=0&&a<=1&&o.push(a),n>=0&&n<=1&&o.push(n)}else if(0===r){const i=-t/(2*e);i>=0&&i<=1&&o.push(i)}return o}function je(e,t,i,o,r){const a=1-e;return a*a*a*t+3*a*a*e*i+3*a*e*e*o+e*e*e*r}function Ge(e,t,i,o){const r=1-e;return r*r*t+2*r*e*i+e*e*o}var Fe=()=>Math.random().toString(36).substring(2);function Xe(){return`${Fe()}${Fe()}`.substring(0,16)}function Qe(e,t,i){const o=[];return e.forEach(e=>{const r=function(e,t,i){const{type:o}=e,r=[...e.params],a=e.id;let n={id:a};if(e.start&&e.end){const o={...e.start},r={...e.end};o.x+=t,o.y+=i,r.x+=t,r.y+=i,n={id:a,start:o,end:r}}switch(o){case"M":case"L":case"T":return r[0]+=t,r[1]+=i,{type:o,params:r,...n};case"H":return r[0]+=t,{type:o,params:r,...n};case"V":return r[0]+=i,{type:o,params:r,...n};case"C":return r[0]+=t,r[1]+=i,r[2]+=t,r[3]+=i,r[4]+=t,r[5]+=i,{type:o,params:r,...n};case"S":case"Q":return r[0]+=t,r[1]+=i,r[2]+=t,r[3]+=i,{type:o,params:r,...n};case"A":return r[5]+=t,r[6]+=i,{type:o,params:r,...n};default:return{type:o,params:r,...n}}}(e,t,i);o.push(r)}),o}function Ue(e,t,i){return e.map(e=>{const{id:o,type:r,params:a}=e,n=[];let s={id:o};if(e.start&&e.end){const r={...e.start},a={...e.end};r.x*=t,r.y*=i,a.x*=t,a.y*=i,s={id:o,start:r,end:a}}switch(r.toUpperCase()){case"M":case"L":case"T":for(let e=0;e<a.length;e+=2)n.push(a[e]*t,a[e+1]*i);break;case"C":for(let e=0;e<a.length;e+=6)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i,a[e+4]*t,a[e+5]*i);break;case"S":for(let e=0;e<a.length;e+=4)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i);break;case"Q":for(let e=0;e<a.length;e+=4)n.push(a[e]*t,a[e+1]*i,a[e+2]*t,a[e+3]*i);break;case"H":a.forEach(e=>n.push(e*t));break;case"V":a.forEach(e=>n.push(e*i));break;case"A":for(let e=0;e<a.length;e+=7)n.push(a[e]*t,a[e+1]*i,a[e+2],a[e+3],a[e+4],a[e+5]*t,a[e+6]*i);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let e=0;e<a.length;e++){const o="a"===r&&(e%7==0||e%7==5)||"h"===r||"v"!==r&&e%2==0;n.push(a[e]*(o?t:i))}break;default:return{type:r,params:[...a],...s}}return{type:r,params:n,...s}})}function Ze(e){const t=[];let i={x:0,y:0},o={x:0,y:0},r=null;for(const a of e){const e=a.type,n=a.params,s=e===e.toLowerCase(),l=e.toUpperCase(),h=a.id;switch(l){case"M":{const[e,a]=n,l=s?{x:i.x+e,y:i.y+a}:{x:e,y:a};t.push({id:h,type:"M",params:[l.x,l.y],start:{x:e,y:a},end:{x:e,y:a}}),i=l,o=l,r=null;break}case"L":{const[e,o]=n,a=s?{x:i.x+e,y:i.y+o}:{x:e,y:o};t.push({id:h,type:"L",params:[a.x,a.y],start:{...i},end:{...a}}),i=a,r=null;break}case"H":{const[e]=n,o=s?{x:i.x+e,y:i.y}:{x:e,y:i.y};t.push({id:h,type:"L",params:[o.x,o.y],start:{...i},end:{...o}}),i=o,r=null;break}case"V":{const[e]=n,o=s?{x:i.x,y:i.y+e}:{x:i.x,y:e};t.push({id:h,type:"L",params:[o.x,o.y],start:{...i},end:{...o}}),i=o,r=null;break}case"C":{const[e,o,a,l,c,d]=n,u=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},f=s?{x:i.x+a,y:i.y+l}:{x:a,y:l},g=s?{x:i.x+c,y:i.y+d}:{x:c,y:d};t.push({id:h,type:"C",params:[u.x,u.y,f.x,f.y,g.x,g.y],start:{...i},end:{...g}}),i=g,r=f;break}case"S":{const[e,o,a,l]=n,c=r?{x:2*i.x-r.x,y:2*i.y-r.y}:i,d=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},u=s?{x:i.x+a,y:i.y+l}:{x:a,y:l};t.push({id:h,type:"C",params:[c.x,c.y,d.x,d.y,u.x,u.y],start:{...i},end:{...u}}),i=u,r=d;break}case"Q":{const[e,o,a,l]=n,c=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},d=s?{x:i.x+a,y:i.y+l}:{x:a,y:l};t.push({id:h,type:"C",params:[i.x+2/3*(c.x-i.x),i.y+2/3*(c.y-i.y),d.x+2/3*(c.x-d.x),d.y+2/3*(c.y-d.y),d.x,d.y],start:{...i},end:{...d}}),i=d,r=c;break}case"T":{const[e,o]=n,a=s?{x:i.x+e,y:i.y+o}:{x:e,y:o},l=r?{x:2*i.x-r.x,y:2*i.y-r.y}:i;t.push({id:h,type:"C",params:[i.x+2/3*(l.x-i.x),i.y+2/3*(l.y-i.y),a.x+2/3*(l.x-a.x),a.y+2/3*(l.y-a.y),a.x,a.y],start:{...i},end:{...a}}),i=a,r=l;break}case"A":{const[e,o,a,l,c,d,u]=n,f=s?{x:i.x+d,y:i.y+u}:{x:d,y:u};t.push({id:h,type:"A",params:[e,o,a,l,c,f.x,f.y],start:{...i},end:{...f}}),i=f,r=null;break}case"Z":t.push({id:h,type:"Z",params:[],start:{...i},end:{...o}}),i=o,r=null;break;default:throw new Error(`Unsupported command: ${e}`)}}return t}function Je(e,t){const i=t.x,o=t.y,r=e.x+(i-e.x)/3,a=e.y+(o-e.y)/3,n=e.x+2*(i-e.x)/3,s=e.y+2*(o-e.y)/3;return{id:Xe(),type:"C",params:[r,a,n,s,i,o]}}function Ke(e){let{x:t,y:i,width:o,height:r,...a}=e;const{commands:n}=a,{minX:s,minY:l,maxX:h,maxY:c}=function(e){let t=1/0,i=1/0,o=-1/0,r=-1/0,a={x:0,y:0},n={x:0,y:0},s=null;const l=e=>{t=Math.min(t,e.x),i=Math.min(i,e.y),o=Math.max(o,e.x),r=Math.max(r,e.y)};for(const t of e){const{type:e,params:i}=t,o=e===e.toLowerCase();switch(e.toLowerCase()){case"m":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];o&&(t+=a.x,r+=a.y),0===e&&(n={x:t,y:r}),a={x:t,y:r},l(a)}s=null;break;case"l":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];o&&(t+=a.x,r+=a.y),a={x:t,y:r},l(a)}s=null;break;case"h":for(let e=0;e<i.length;e++){let t=i[e];o&&(t+=a.x),a={x:t,y:a.y},l(a)}s=null;break;case"v":for(let e=0;e<i.length;e++){let t=i[e];o&&(t+=a.y),a={x:a.x,y:t},l(a)}s=null;break;case"c":if(i.length>=6)for(let e=0;e<i.length;e+=6){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3],c=i[e+4],d=i[e+5];o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y,c+=a.x,d+=a.y),s={x:n,y:h},We(a.x,a.y,t,r,n,h,c,d).forEach(l),l({x:c,y:d}),a={x:c,y:d}}break;case"s":if(i.length>=4)for(let e=0;e<i.length;e+=4){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3];const c=s?2*a.x-s.x:a.x,d=s?2*a.y-s.y:a.y;o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y),s={x:t,y:r},We(a.x,a.y,c,d,t,r,n,h).forEach(l),l({x:n,y:h}),a={x:n,y:h}}break;case"q":if(i.length>=4)for(let e=0;e<i.length;e+=4){let t=i[e],r=i[e+1],n=i[e+2],h=i[e+3];o&&(t+=a.x,r+=a.y,n+=a.x,h+=a.y),s={x:t,y:r},Oe(a.x,a.y,t,r,n,h).forEach(l),l({x:n,y:h}),a={x:n,y:h}}break;case"t":if(i.length>=2)for(let e=0;e<i.length;e+=2){let t=i[e],r=i[e+1];const n=s?2*a.x-s.x:a.x,h=s?2*a.y-s.y:a.y;o&&(t+=a.x,r+=a.y),s={x:n,y:h},Oe(a.x,a.y,n,h,t,r).forEach(l),l({x:t,y:r}),a={x:t,y:r}}break;case"a":if(i.length>=7)for(let e=0;e<i.length;e+=7){const t=Math.abs(i[e]),r=Math.abs(i[e+1]),n=i[e+2],h=i[e+3],c=i[e+4];let d=i[e+5],u=i[e+6];o&&(d+=a.x,u+=a.y),Ye(a.x,a.y,t,r,n,h,c,d,u).forEach(l),a={x:d,y:u},s=null}break;case"z":a={...n},l(a),s=null}}return t===1/0&&(t=i=o=r=0),{minX:t,minY:i,maxX:o,maxY:r,width:o-t,height:r-i,start:{x:t,y:i},end:{x:o,y:r}}}(n);return t+=s,i+=l,o=Math.abs(h-s),r=Math.abs(c-l),0===s&&0===l||(a.commands=Qe(n,0-s,0-l)),{...e,x:t,y:i,width:o,height:r,...a}}var qe={className:"class"},_e=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"];function et(e,t){t.forEach(t=>{t&&t.trim().split(" ").forEach(t=>{t&&!e.classList.contains(t)&&e.classList.add(t)})})}function tt(e,t){t.forEach(t=>{t&&e.classList.contains(t)&&e.classList.remove(t)})}function it(e,t){return Object.keys(t).forEach(i=>{const o=t[i];e.style[i]=((e,t)=>"number"==typeof t&&_e.includes(e)?`${t}px`:t)(i,o)}),e}function ot(e,t,i){const{children:o,...r}=t||{},a=i||o;return function(e,t){Object.entries(t).forEach(([t,i])=>{const o=qe[t]?qe[t]:t,r=o.replace(/([A-Z])/g,"-$1").toLowerCase(),a=i;if("style"===o)u.json(i)?it(e,i):"string"==typeof i&&e.setAttribute(r,i);else if("class"===o&&"string"==typeof i)et(e,i.split(" "));else{let t=a;null==t&&(t=""),e.setAttribute(r,String(t))}})}(e,r||{}),Array.isArray(a)?a?.forEach(t=>{(t instanceof Element||"string"==typeof t)&&e.append(t)}):(a instanceof Element||"string"==typeof a)&&e.append(a),e}function rt(e,t,i){return ot(document.createElement(e),t,i)}function at(e){const t=function(e){return e.replace(/<(script|iframe|object|embed)\b[^<]*(?:(?!<\/\1>)<[^<]*)*<\/\1>/gi,"")}(e),i=document.createElement("template");return i.innerHTML=t.trim(),i.content.firstElementChild}function nt(e){const t=e.getBoundingClientRect(),i=window.pageXOffset||document.documentElement.scrollLeft,o=window.pageYOffset||document.documentElement.scrollTop;return{pageX:t.left+i,pageY:t.top+o,width:t.width,height:t.height}}var st=(e,t,i)=>{let o=e;const r=Object.keys(i),a=()=>{if(!o)return!1;for(let e=0;e<r.length;e++){const t=r[e],a=i[t];if("string"==typeof t&&t&&"string"==typeof a&&a){if("className"===t&&o?.classList.contains(a))continue;if(o.getAttribute(t)===a)continue;return!1}if("string"==typeof t&&t&&"boolean"==typeof a){if(o.hasAttribute(t)&&!0===a)continue;return!1}}return!0};for(;o;){if(a())return o;if(t===o)return null;if(!t.contains(o))return null;o=o.parentElement}return null};function lt(e,t){const{$root:i,rootClassName:o}=t;if(!i)return!1;const r=e.target;return!!st(r,i,{className:o})}var ht=["width","height","left","right","top","bottom","margin","marginLeft","marginRight","marginTop","marginBottom","padding","paddingLeft","paddingRight","paddingTop","paddingBottom"],ct=(e,t)=>ht.includes(e)?`${t}px`:t;function dt(e){return e.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function ut(e,t){const i=[],o=[];for(const r in e){let a=e[r];if("number"==typeof a&&(a=ct(r,a)),r.startsWith("@"))o.push(`${r} { ${ut(a,t)} }`);else if(r.startsWith("&")||r.startsWith(".")||r.startsWith("#")){const e=r.startsWith("&")?r.replace("&",t):`${t} ${r}`;o.push(ut(a,e))}else i.push(`${dt(r)}: ${a};`)}return[i.length?`${t} { ${i.join(" ")} }`:"",...o].filter(Boolean).join("\n")}var ft="data-idraw-style-id",gt={};function mt(e){const{styles:t,rootClassName:i,type:o}=e,r=ut(t,`.${i}`);if("element"===o){const e=document.createElement("style");e.setAttribute(ft,i),e.textContent=r,(document.head||document.body).appendChild(e)}else{const e=new CSSStyleSheet;e.replaceSync(r),gt[i]=e,document.adoptedStyleSheets=[...document.adoptedStyleSheets,e]}}function pt(e){const{rootClassName:t,type:i}=e;if("element"===i)document.querySelector(`[${ft}="${t}"]`)?.remove();else if(gt[t]){const e=gt[t],i=document.adoptedStyleSheets.filter(t=>t!==e);document.adoptedStyleSheets=i}}var yt="data-idraw-valid-watch";function xt(e,t,i){if("string"==typeof t)return t;const{viewMaterialSize:o,viewScaleInfo:a,opacity:n=1}=i,{x:s,y:l}=o,{scale:h}=a;if("linear-gradient"===t?.type){const{start:i,end:o,stops:a}=t,c={x:s+i.x*h,y:l+i.y*h},d={x:s+o.x*h,y:l+o.y*h},u=e.createLinearGradient(c.x,c.y,d.x,d.y);return a.forEach(e=>{e.offset>=0&&e.color&&u.addColorStop(e.offset,r(e.color,n))}),u}if("radial-gradient"===t?.type){const{inner:i,outer:o,stops:a}=t,c={x:s+i.x*h,y:l+i.y*h,radius:i.radius*h},d={x:s+o.x*h,y:l+o.y*h,radius:o.radius*h},u=e.createRadialGradient(c.x,c.y,c.radius,d.x,d.y,d.radius);return a.forEach(e=>{u.addColorStop(e.offset,r(e.color,n))}),u}return"#000000"}var vt=pe();function wt(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r,calculator:a}=i,{opacity:n,fill:s,fillOpacity:l,fillRule:h,stroke:c,strokeWidth:d,strokeOpacity:u,strokeLinecap:f,strokeLinejoin:g,strokeDasharray:m,strokeDashoffset:p,strokeMiterlimit:y}={...vt,...t},{scale:x,offsetLeft:v,offsetTop:w}=o,{devicePixelRatio:S}=r,{commands:b,worldCenter:A}=a.getVirtualItem(t.id),{width:M,height:I}=t;let R=b;R=Ue(R,x,x),R=Qe(R,(v+(A.x-M/2)*x)*S,(w+(A.y-I/2)*x)*S);const z=e.globalAlpha,E=de(R),L=new Path2D(E);!function(e,t,i){const{...o}=t,{viewScaleInfo:r,viewSizeInfo:a,tempContext:n,path2d:s}=i,{width:l,height:h}=a,{shadowColor:c,shadowOffsetX:d,shadowOffsetY:u,shadowBlur:f}=o;C.number(f)&&c&&(n.clearRect(0,0,n.canvas.width,n.canvas.height),n.save(),n.shadowColor=c,n.shadowOffsetX=(d||0)*r.scale,n.shadowOffsetY=(u||0)*r.scale,n.shadowBlur=(f||0)*r.scale,n.fillStyle="#ffffff",n.fill(s),n.restore(),n.save(),n.globalCompositeOperation="destination-out",n.fillStyle="#ffffff",n.fill(s),n.restore(),e.drawImage(n.canvas,0,0,l,h),n.clearRect(0,0,n.canvas.width,n.canvas.height))}(e,t,{...i,path2d:L}),St(e,t,{path2d:L,viewScaleInfo:o,viewSizeInfo:r,calculator:a,renderContent:()=>{if(s){const i=re(t,{viewScaleInfo:o});"number"==typeof l&&l>0&&(e.globalAlpha=z*l*n),e.fillStyle=xt(e,s,{viewMaterialSize:i,viewScaleInfo:o,opacity:t.opacity||1}),e.fill(L,h),e.globalAlpha=z}if("number"==typeof d&&d>0){if("number"==typeof u&&u>0&&(e.globalAlpha=z*u*n),e.lineCap=f,e.lineJoin=g,e.lineDashOffset=p,e.miterLimit=y,Array.isArray(m)){const t=m.map(e=>x*e);e.setLineDash(t)}e.lineWidth=d*x,e.strokeStyle=c,e.stroke(L),e.setLineDash([]),e.lineCap=vt.strokeLinecap,e.lineJoin=vt.strokeLinejoin,e.lineDashOffset=vt.strokeDashoffset,e.miterLimit=vt.strokeMiterlimit,e.globalAlpha=z}}})}function St(e,t,i){const{renderContent:o,calculator:r,viewScaleInfo:a,viewSizeInfo:n}=i;if("hidden"===t.overflow){let s=i.path2d;if(!s){const{scale:e,offsetLeft:i,offsetTop:o}=a,{devicePixelRatio:l}=n,{commands:h,worldCenter:c}=r.getVirtualItem(t.id),{width:d,height:u}=t;let f=h;f=Ue(f,e,e),f=Qe(f,(i+(c.x-d/2)*e)*l,(o+(c.y-u/2)*e)*l);const g=de(f);s=new Path2D(g)}e.save(),e.clip(s,"nonzero"),o?.(),e.restore()}else o?.()}function bt(e,t,i,o){const{viewScaleInfo:r,calculator:a}=i,n=a?.getVirtualItem(t.id);if(n){const{worldAngle:i,worldCenter:a}=n,s=ae(a,{viewScaleInfo:r}),{scale:l}=r;$(e,i,s,()=>{const e=t.width*l,i=t.height*l;o({viewWorldCenter:s,viewWorldSize:{x:s.x-e/2,y:s.y-i/2,width:e,height:i}})})}}vt=function(e,t){const i={...e};for(const e of t)delete i[e];return i}(vt,["fill"]);var At=pe();function Mt(e,t,i){if(!0===t?.operations?.invisible)return;const{width:o,height:r}=t,{scale:a}=i.viewScaleInfo;if(a<1&&(o*a<.4||r*a<.4)||0===i.parentOpacity)return;const{overrideMaterialMap:n}=i;if(!n?.[t.id]?.operations?.invisible)try{switch(t.type){case"rect":case"circle":case"ellipse":case"path":!function(e,t,i){bt(e,t,i,()=>{wt(e,t,i)})}(e,t,i);break;case"text":!function(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r,calculator:a}=i,n=re(t,{viewScaleInfo:o})||t,{scale:s}=o;bt(e,t,i,({viewWorldSize:i})=>{{const l={...At,...t},{x:h,y:c}=i,d=(l.fontSize||At.fontSize)*o.scale,{opacity:u,fill:f,fillOpacity:g,stroke:m,strokeWidth:p,strokeOpacity:y,strokeLinecap:x,strokeLinejoin:v,strokeDasharray:w,strokeDashoffset:S,strokeMiterlimit:b}=l;if(d<2)return;const A=e.globalAlpha,M=a.getVirtualItem(t.id);e.textBaseline="top",e.$setFont({fontWeight:l.fontWeight,fontSize:d,fontFamily:$e(l.fontFamily)}),St(e,t,{viewScaleInfo:o,viewSizeInfo:r,calculator:a,renderContent:()=>{if(f&&("number"==typeof g&&g>0&&(e.globalAlpha=A*g*u),e.fillStyle=xt(e,f,{viewMaterialSize:n,viewScaleInfo:o,opacity:t.opacity||1}),Array.isArray(M?.textLines)&&M?.textLines?.length>0&&M?.textLines?.forEach(t=>{e.fillText(t.text,h+t.x*o.scale,c+t.y*o.scale)}),e.globalAlpha=A),"number"==typeof p&&p>0){if("number"==typeof y&&y>0&&(e.globalAlpha=A*y*u),e.lineCap=x,e.lineJoin=v,e.lineDashOffset=S,e.miterLimit=b,Array.isArray(w)){const t=w.map(e=>s*e);e.setLineDash(t)}e.lineWidth=p*s,e.strokeStyle=m,M?.textLines?.forEach(t=>{e.strokeText(t.text,h+t.x*o.scale,c+t.y*o.scale)}),e.setLineDash([]),e.lineCap=At.strokeLinecap,e.lineJoin=At.strokeLinejoin,e.lineDashOffset=At.strokeDashoffset,e.miterLimit=At.strokeMiterlimit,e.globalAlpha=A}}})}})}(e,t,i);break;case"image":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r,parentOpacity:a}=i,{x:n,y:s,width:l,height:h,angle:c}=re(t,{viewScaleInfo:r})||t,d={...t,x:n,y:s,width:l,height:h,angle:c};bt(e,t,i,()=>{if(o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"image"===t.type&&o){e.globalAlpha=function(e){let t=1;return void 0!==e?.opacity&&e?.opacity>=0&&e?.opacity<=1&&(t=e?.opacity),t}(t)*a;const{x:i,y:r,width:n,height:s}=d,l=[0,0,0,0],{scaleMode:h,originW:c=0,originH:u=0}=t,f=e.$undoPixelRatio(c),g=e.$undoPixelRatio(u);if(e.save(),e.fillStyle="transparent",e.beginPath(),e.moveTo(i+l[0],r),e.arcTo(i+n,r,i+n,r+s,l[1]),e.arcTo(i+n,r+s,i,r+s,l[2]),e.arcTo(i,r+s,i,r,l[3]),e.arcTo(i,r,i+n,r,l[0]),e.closePath(),e.fill("nonzero"),e.clip("nonzero"),h&&u&&c){let a=0,l=0,c=f,d=g;const u=i,m=r,p=n,y=s;if(f>t.width||g>t.height)if("fill"===h){const e=Math.max(t.width/f,t.height/g),i=g*e;a=(f*e-t.width)/2/e,l=(i-t.height)/2/e,c=t.width/e,d=t.height/e}else if("tile"===h)a=0,l=0,c=t.width,d=t.height;else if("fit"===h){const e=Math.min(t.width/f,t.height/g);a=(f-t.width/e)/2,l=(g-t.height/e)/2,c=t.width/e,d=t.height/e}e.drawImage(o,a,l,c,d,u,m,p,y)}else e.drawImage(o,i,r,n,s);e.globalAlpha=a,e.restore()}})}(e,t,i);break;case"svgCode":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r}=i,{x:a,y:n,width:s,height:l}=re(t,{viewScaleInfo:r})||t;bt(e,t,i,()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"svgCode"===t.type&&o&&e.drawImage(o,a,n,s,l)})}(e,t,i);break;case"foreignObject":!function(e,t,i){const o=i.loader.getContent(t),{viewScaleInfo:r}=i,{x:a,y:n,width:s,height:l}=re(t,{viewScaleInfo:r})||t;bt(e,t,i,()=>{o||i.loader.isDestroyed()||i.loader.load(t,i.materialAssets||{}),"foreignObject"===t.type&&o&&e.drawImage(o,a,n,s,l)})}(e,t,i);break;case"group":{const o={...i.materialAssets||{},...t.assets||{}};!function(e,t,i){if(bt(e,t,i,()=>{wt(e,t,i)}),Array.isArray(t.children)){const{parentMaterialSize:o}=i,r={x:o.x+t.x,y:o.y+t.y,width:t.width||o.width,height:t.height||o.height,angle:t.angle},{calculator:a}=i;for(let o=0;o<t.children.length;o++){let n=t.children[o];if(n={...n,x:r.x+n.x,y:r.y+n.y},!0===i.forceDrawAll||a?.needRender(n))try{Mt(e,n,i)}catch(e){console.error(e)}}}}(e,t,{...i,materialAssets:o});break}}}catch(e){console.error(e)}}var It=pe();function Ct(e,t,i){const{materials:o=[]}=t,{parentOpacity:r}=i;for(let t=0;t<o.length;t++){const a=o[t],n={...a,attributes:{...It,...a}};if(!0===i.forceDrawAll||i.calculator?.needRender(n))try{Mt(e,n,{...i,parentOpacity:r})}catch(e){console.error(e)}}}var Rt=["image","svgCode","foreignObject"],zt=e=>{let t=null;return"image"===e.type?t=e?.href||null:"svgCode"===e.type?t=e?.code||null:"foreignObject"===e.type&&(t=e?.content||null),"string"==typeof t&&t?h(t)?t:l(t,e.id):l(`${n()}-${e.id}-${n()}-${n()}`,e.id)},Et=class extends L{#s={};#l={};#h={};#c=!1;constructor(){super(),this.#d("image",async(e,t)=>{const i=await g(t[e.href]?.value||e.href);return{id:e.id,lastModified:Date.now(),content:i}}),this.#d("foreignObject",async(e,t)=>{const i=await p(t[e.content]?.value||e.content,{width:e.originW||e.width,height:e.originH||e.height});return{id:e.id,lastModified:Date.now(),content:i}}),this.#d("svgCode",async(e,t)=>{const i=await m(t[e.code]?.value||e.code);return{id:e.id,lastModified:Date.now(),content:i}})}isDestroyed(){return this.#c}reset(){!0!==this.#c&&(this.#l={},this.#h={})}resetMaterialAsset(e){if(Rt.includes(e.type)){let t=null,i=null;"image"===e.type&&"string"==typeof e?.href?i=e.href:"svgCode"===e.type&&"string"==typeof e?.code?i=e.code:"foreignObject"===e.type&&"string"==typeof e?.content&&(i=e.content),"string"==typeof i&&(this.load(e,{}),h(i)?t=i:e.id&&(t=l(i,e.id))),t&&h(t)&&(delete this.#h[t],delete this.#l[t])}}destroy(){this.#c=!0,this.clear(),this.#s=null,this.#l=null,this.#h=null}#d(e,t){this.#s[e]=t}#u(e){let t=null;return"image"===e.type?t=e?.href||null:"svgCode"===e.type?t=e?.code||null:"foreignObject"===e.type&&(t=e?.content||null),t}#f(e){return{material:e,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this.#u(e)}}#g(e){const t=zt(e.material),i=this.#h[t];this.#c||(i?i.startTime<e.startTime&&(this.#h[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})):(this.#h[t]=e,this.trigger("load",{...e,countTime:e.endTime-e.startTime})))}#m(e){const t=zt(e.material),i=this.#h?.[t];this.#c||(i?i.startTime<e.startTime&&(this.#h[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})):(this.#h[t]=e,this.trigger("error",{...e,countTime:e.endTime-e.startTime})))}#p(e,t){const i=this.#f(e),o=zt(e);if(this.#l[o])return;this.#l[o]=i;const r=this.#s[e.type];"function"!=typeof r||this.#c||(i.startTime=Date.now(),r(e,t).then(e=>{this.#c||(i.content=e.content,i.endTime=Date.now(),i.status="load",this.#g(i))}).catch(t=>{console.warn(`Load material source "${i.source}" fail`,t,e),i.endTime=Date.now(),i.status="error",i.error=t,this.#m(i)}))}#y(e){const t=zt(e),i=this.#l?.[t];return!(!i||"error"!==i.status||!i.source||i.source!==this.#u(e))}load(e,t){!0!==this.#c&&(this.#y(e)||Rt.includes(e.type)&&this.#p(e,t))}getContent(e){const t=zt(e);return this.#h?.[t]?.content||null}getLoadItemMap(){return this.#h}setLoadItemMap(e){this.#h=e}};function Lt(e,t){if(!(t=[...t].reverse())||0===t.length)return{x:e.x+e.width/2,y:e.y+e.height/2};let i=e.x+e.width/2,o=e.y+e.height/2;for(let e=0;e<t.length;e++){const r=Bt({x:i,y:o},t[e]);i=r.x,o=r.y}return{x:i,y:o}}function Bt(e,t){const i=t.width/2,o=t.height/2,r=e.x-i,a=e.y-o;let n=r,s=a;if("number"==typeof t.angle&&0!==t.angle){const e=t.angle*Math.PI/180,i=Math.cos(e),o=Math.sin(e);n=r*i-a*o,s=r*o+a*i}const l=s+o;return{x:n+i+t.x,y:l+t.y}}function kt(e,t){const{groupQueue:i=[]}=t;let o=e.angle||0;return i.forEach(e=>{o+=e.angle||0}),{worldCenter:Lt(e,i),worldAngle:X(o)}}function Pt(e,t){const{dpr:i}=t;let{width:o,height:r,rx:a=0,ry:n=0}=e;const{cornerRadius:s}=e;r*=i,o*=i;const l=[];let h=0,c=0,d=0,u=0,f=0,g=0,m=0,p=0;if("number"==typeof a&&"number"==typeof n)a*=i,n*=i,h=a,c=a,d=a,u=a,f=n,g=n,m=n,p=n;else if(Array.isArray(s)&&4===s.length){const e=s.map(e=>e*i);h=e[0]||0,c=e[1]||0,d=e[2]||0,u=e[3]||0,f=e[0]||0,g=e[1]||0,m=e[2]||0,p=e[3]||0}else if("number"==typeof s){const e=s*i;h=e,c=e,d=e,u=e,f=e,g=e,m=e,p=e}const y=0+o,x=0+r;return l.push({id:Xe(),type:"M",params:[0+h,0]}),c>0||g>0?(l.push({id:Xe(),type:"L",params:[y-c,0]}),l.push({id:Xe(),type:"A",params:[c,g,0,0,1,y,0+g]})):l.push({id:Xe(),type:"L",params:[y,0]}),d>0||m>0?(l.push({id:Xe(),type:"L",params:[y,x-m]}),l.push({id:Xe(),type:"A",params:[d,m,0,0,1,y-d,x]})):l.push({id:Xe(),type:"L",params:[y,x]}),u>0||p>0?(l.push({id:Xe(),type:"L",params:[0+u,x]}),l.push({id:Xe(),type:"A",params:[u,p,0,0,1,0,x-p]})):l.push({id:Xe(),type:"L",params:[0,x]}),h>0||f>0?(l.push({id:Xe(),type:"L",params:[0,0+f]}),l.push({id:Xe(),type:"A",params:[h,f,0,0,1,0+h,0]})):l.push({id:Xe(),type:"L",params:[0,0]}),l.push({id:Xe(),type:"Z",params:[]}),{...kt(e,t),commands:l}}var Tt=pe();function Nt(e,t,i){return i<.5&&e<t&&(e-t)/e>-.15||e>=t}function Dt(e,t){let i=null;switch(e.type){case"rect":case"group":i=Pt(e,t);break;case"circle":i=function(e,t){const{dpr:i}=t,{width:o,height:r}=e;let{r:a}=e;const n=o/2*i,s=r/2*i;a*=i;const l=.55228475*a,h=[{type:"M",params:[n+a,s]},{type:"C",params:[n+a,s-l,n+l,s-a,n,s-a]},{type:"C",params:[n-l,s-a,n-a,s-l,n-a,s]},{type:"C",params:[n-a,s+l,n-l,s+a,n,s+a]},{type:"C",params:[n+l,s+a,n+a,s+l,n+a,s]},{type:"Z",params:[]}];return{...kt(e,t),commands:h}}(e,t);break;case"ellipse":i=function(e,t){const{dpr:i}=t,{width:o,height:r}=e;let{rx:a,ry:n}=e;const s=o/2*i,l=r/2*i;a*=i,n*=i;const h=.55228475*a,c=.55228475*n,d=[{type:"M",params:[s+a,l]},{type:"C",params:[s+a,l-c,s+h,l-n,s,l-n]},{type:"C",params:[s-h,l-n,s-a,l-c,s-a,l]},{type:"C",params:[s-a,l+c,s-h,l+n,s,l+n]},{type:"C",params:[s+h,l+n,s+a,l+c,s+a,l]},{type:"Z",params:[]}];return{...kt(e,t),commands:d}}(e,t);break;case"text":i=function(e,t){const{width:i,height:o}=e,r=t.tempContext,a=[],n={...Tt,...e},s=n.fontSize||Tt.fontSize,l=s,h=Pt(e,t);if(l<2)return{...h,textLines:[]};const c=n.lineHeight||s;r.textBaseline="top",r.$setFont({fontWeight:n.fontWeight,fontSize:l,fontFamily:$e(n.fontFamily)});let d=n.text.replace(/\r\n/gi,"\n");"lowercase"===n.textTransform?d=d.toLowerCase():"uppercase"===n.textTransform&&(d=d.toUpperCase());const u=c,f=d.split("\n");let g=0;f.forEach((e,t)=>{if("maxContent"===n.minInlineSize){const t=r.measureText(e);a.push({x:0,y:0,text:e,width:r.$undoPixelRatio(t.width)})}else{let s="",l="",h=e.split(l);if("normal"===n.wordBreak){l=" ";const t=e.split(l);h=[],t.forEach((e,i)=>{h.push(e),i<t.length-1&&h.push(l)})}if(1===h.length&&"hidden"!==n.overflow)a.push({x:0,y:0,text:h[0],width:r.$undoPixelRatio(r.measureText(h[0]).width)});else if(h.length>0){for(let e=0;e<h.length;e++){if(Nt(r.$doPixelRatio(i),r.measureText(s+h[e]).width,1)?s+=h[e]||"":(a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s=h[e]||"",g++),g*u>=o&&"hidden"===n.overflow){s="";break}if(h.length-1===e&&(g+1)*u<=o){a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s="",t<f.length-1&&g++;break}}s&&(a.push({x:0,y:0,text:s,width:r.$undoPixelRatio(r.measureText(s).width)}),s="")}else a.push({x:0,y:0,text:"",width:0})}});let m=0,p=0;u>l&&(p=(u-l)/2),a.length*u<o&&("top"===n.verticalAlign?m=0:"bottom"===n.verticalAlign?m+=o-a.length*u:m+=(o-a.length*u)/2);{const e=0+m;a.forEach((t,o)=>{let r=0;"center"===n.textAlign?r=0+(i-t.width)/2:"right"===n.textAlign&&(r=i-t.width+0),a[o].x=r,a[o].y=e+u*o+p})}return{...h,textLines:a}}(e,t);break;case"path":i=function(e,t){const{dpr:i}=t,o={...kt(e,t),anchorCommands:[]};return o.anchorCommands=Ze(e.commands||[]),o.commands=Ue(e.commands,i,i),o}(e,t);break;default:i=kt(e,t)}return i}function $t(e,t){const{viewScaleInfo:i,viewSizeInfo:o,tempContext:r}=t;return Ht(function(e,t){const i={},o=[],r=a=>{const n={type:a.type,isVisibleInView:!0,position:[...o]};let s=null;const l=J(e,o);s=he(a,{groupQueue:l||[]});const h={...n,boundingInfo:s,rangeBoundingInfo:C.angle(a.angle)?ce(s):s,...Dt(a,{...t,groupQueue:l||[]})};i[a.id]=h,"group"===a.type&&a.children.forEach((e,t)=>{o.push(t),r(e),o.pop()})};return e.forEach((e,t)=>{o.push(t),r(e),o.pop()}),i}(e,{tempContext:r,dpr:o.devicePixelRatio}),{viewScaleInfo:i,viewSizeInfo:o})}function Ht(e,t){const i=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:r,offsetLeft:a}=t,{width:n,height:s}=i,l=0-a/o,h=0-r/o,c=n/o,d=s/o,u=H({x:l,y:h,width:n,height:s});return{center:u,topLeft:{x:l,y:h},topRight:{x:l+c,y:h},bottomLeft:{x:l,y:h+d},bottomRight:{x:l+c,y:h+d},left:{x:l,y:u.y},top:{x:u.x,y:h},right:{x:l+c,y:u.y},bottom:{x:u.x,y:h+d}}}(t);let o=0,r=0;return Object.keys(e).forEach(t=>{const a=e[t];a.isVisibleInView=function(e,t){const i=e.center.x,o=e.center.y,r=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),a=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x),n=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),s=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y),l=Math.abs(a-r),h=Math.abs(s-n),c=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x)-l,d=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x)+l,u=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y)-h,f=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y)+h;return i>=c&&i<=d&&o>=u&&o<=f}(a.rangeBoundingInfo,i),a.isVisibleInView?o++:r++}),{virtualItemMap:e,visibleCount:o,invisibleCount:r}}var Wt=class{#t;#x;constructor(e){this.#t=e,this.#x=new k({defaultStorage:{virtualItemMap:{},visibleCount:0,invisibleCount:0}})}toGridNum(e,t){return!0===t?.ignore?e:Math.round(e)}destroy(){this.#t=null}needRender(e){const t=this.#x.get("virtualItemMap")[e.id];return!t||t.isVisibleInView}forceVisiable(e){const t=this.#x.get("virtualItemMap")[e];t&&(t.isVisibleInView=!0)}getPointMaterial(e,t){return function(e,t){const{context2d:i,data:o,viewScaleInfo:r,viewSizeInfo:a,groupQueue:n}=t,s={index:-1,material:null,groupQueueIndex:-1};if(n&&Array.isArray(n)&&n?.length>0)for(let t=n.length-1;t>=0;t--){let o=0,l=0,h=0;for(let e=0;e<=t;e++)o+=n[e].x,l+=n[e].y,h+=n[e].angle||0;const c=n[t];if(c&&"group"===c.type&&Array.isArray(c?.children))for(let d=0;d<c.children.length;d++){const u=c.children[d];if(!0!==u?.operations?.invisible){if(!u)break;if(se(e,{context2d:i,material:{x:o+u.x,y:l+u.y,width:u.width,height:u.height,angle:h+(u.angle||0)},viewScaleInfo:r,viewSizeInfo:a})){s.material=u,(t<n.length-1||"group"!==u.type)&&(s.groupQueueIndex=t);break}}}if(s.material)break}if(s.material)return s;for(let t=o.materials.length-1;t>=0;t--){const n=o.materials[t];if(!0!==n?.operations?.invisible&&se(e,{context2d:i,material:n,viewScaleInfo:r,viewSizeInfo:a})){s.index=t,s.material=n;break}}return s}(e,{...t,context2d:this.#t.tempContext})}resetVirtualItemMap(e,t){if(e){const{virtualItemMap:i,invisibleCount:o,visibleCount:r}=$t(e.materials,{...t,tempContext:this.#t.tempContext});this.#x.set("virtualItemMap",i),this.#x.set("invisibleCount",o),this.#x.set("visibleCount",r)}}updateVisiableStatus(e){const{virtualItemMap:t,invisibleCount:i,visibleCount:o}=Ht(this.#x.get("virtualItemMap"),e);this.#x.set("virtualItemMap",t),this.#x.set("invisibleCount",i),this.#x.set("visibleCount",o)}calcViewBoundingInfoFromOrigin(e,t){const i=this.#x.get("virtualItemMap")[e];if(!i?.boundingInfo)return null;const{checkVisible:o,viewScaleInfo:r,viewSizeInfo:a}=t,{center:n,left:s,right:l,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.boundingInfo;if(!0===o&&!1===i.isVisibleInView)return null;const m={viewScaleInfo:r,viewSizeInfo:a};return{center:ae(n,m),left:ae(s,m),right:ae(l,m),bottom:ae(h,m),top:ae(c,m),topLeft:ae(d,m),topRight:ae(u,m),bottomLeft:ae(f,m),bottomRight:ae(g,m)}}calcViewBoundingInfoFromRange(e,t){const i=this.#x.get("virtualItemMap")[e];if(!i?.boundingInfo)return null;const{checkVisible:o,viewScaleInfo:r,viewSizeInfo:a}=t,{center:n,left:s,right:l,bottom:h,top:c,topLeft:d,topRight:u,bottomLeft:f,bottomRight:g}=i.rangeBoundingInfo;if(!0===o&&!1===i.isVisibleInView)return null;const m={viewScaleInfo:r,viewSizeInfo:a};return{center:ae(n,m),left:ae(s,m),right:ae(l,m),bottom:ae(h,m),top:ae(c,m),topLeft:ae(d,m),topRight:ae(u,m),bottomLeft:ae(f,m),bottomRight:ae(g,m)}}modifyVirtualAttributes(e,t){const{viewSizeInfo:i,groupQueue:o}=t,r=this.#x.get("virtualItemMap"),a=r[e.id],n=Dt(e,{tempContext:this.#t.tempContext,dpr:i.devicePixelRatio,groupQueue:o});if(n){const t=he(e,{groupQueue:o}),i={...a,...n,boundingInfo:t,rangeBoundingInfo:C.angle(e.angle)?ce(t):t};r[e.id]=i,this.#x.set("virtualItemMap",r)}}modifyVirtualItemMap(e,t){const{modifyInfo:i,viewScaleInfo:o,viewSizeInfo:r}=t,{type:a,content:n}=i,s=e.materials,l=this.#x.get("virtualItemMap");if("deleteMaterial"===a){const{material:e}=n,t=[],i=e=>{t.push(e.id),"group"===e.type&&Array.isArray(e.children)&&e.children.forEach(e=>{i(e)})};i(e),t.forEach(e=>{delete l[e]}),this.#x.set("virtualItemMap",l)}else if("addMaterial"===a||"updateMaterial"===a){const{position:t}=n,i=q(t,e.materials),h=J(s,t);if(i)if("updateMaterial"===a&&"group"===i.type)this.resetVirtualItemMap(e,{viewScaleInfo:o,viewSizeInfo:r});else{const e=he(i,{groupQueue:h||[]}),n={type:i.type,boundingInfo:e,rangeBoundingInfo:C.angle(i.angle)?ce(e):e,isVisibleInView:!0,position:[...t],...Dt(i,{tempContext:this.#t.tempContext,dpr:r.devicePixelRatio,groupQueue:h||[]})};l[i.id]=n,this.#x.set("virtualItemMap",l),"updateMaterial"===a&&this.updateVisiableStatus({viewScaleInfo:o,viewSizeInfo:r})}}else"moveMaterial"===a&&this.resetVirtualItemMap(e,{viewScaleInfo:o,viewSizeInfo:r})}getVirtualItem(e){return this.#x.get("virtualItemMap")[e]||null}},Ot=class extends L{#t;#v=new Et;#w;#c=!1;constructor(e){super(),this.#t=e,this.#w=new Wt({tempContext:e.tempContext}),this.#S()}isDestroyed(){return this.#c}destroy(){this.clear(),this.#t=null,this.#v.destroy(),this.#v=null,this.#c=!0}#S(){const e=this.#v;e.on("load",e=>{this.trigger("load",e)}),e.on("error",e=>{console.error(e)})}updateOptions(e){this.#t=e}drawData(e,t){const i=this.#v,o=this.#w,{sharer:r}=this.#t,a=this.#t.viewContext;a.clearRect(0,0,a.canvas.width,a.canvas.height);const n={x:0,y:0,width:t.viewSizeInfo.width,height:t.viewSizeInfo.height};!0===t.forceDrawAll&&this.#w.resetVirtualItemMap(e,{viewScaleInfo:t.viewScaleInfo,viewSizeInfo:t.viewSizeInfo});const s={loader:i,calculator:o,parentMaterialSize:n,materialAssets:e.assets,parentOpacity:1,overrideMaterialMap:r?.getActiveOverrideMaterialMap(),tempContext:this.#t.tempContext,...t};!function(e,t,i){if("string"==typeof t?.fill){const{viewSizeInfo:o}=i,{width:r,height:a}=o;e.globalAlpha=1,e.fillStyle=t.fill,e.fillRect(0,0,r,a)}}(a,e.global,s),e.layout?function(e,t,i,o){const{parentOpacity:r}=i;e.globalAlpha=1;const{viewScaleInfo:a}=i,n={id:"layout",type:"group",...t},s=re(n,{viewScaleInfo:a})||n,{x:l,y:h,width:c,height:d,fill:u}={...n,...s},f=[0,0,0,0];e.save(),e.fillStyle=xt(e,u,{viewMaterialSize:s,viewScaleInfo:a,opacity:n.opacity||1}),e.beginPath(),e.moveTo(l+f[0],h),e.arcTo(l+c,h,l+c,h+d,f[1]),e.arcTo(l+c,h+d,l,h+d,f[2]),e.arcTo(l,h+d,l,h,f[3]),e.arcTo(l,h,l+c,h,f[0]),e.closePath(),e.fill("nonzero"),"hidden"===t.overflow&&e.clip("nonzero"),o(e),"hidden"===t.overflow&&e.restore(),e.globalAlpha=r}(a,e.layout,s,()=>{Ct(a,e,s)}):Ct(a,e,s)}scale(e){const{sharer:t}=this.#t;if(!t)return;const{data:i,offsetTop:o,offsetBottom:r,offsetLeft:a,offsetRight:n,width:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}=t.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:e,offsetTop:o,offsetBottom:r,offsetLeft:a,offsetRight:n},viewSizeInfo:{width:s,height:l,contextHeight:h,contextWidth:c,devicePixelRatio:d}})}setLoadItemMap(e){this.#v.setLoadItemMap(e)}getLoadItemMap(){return this.#v.getLoadItemMap()}getLoader(){return this.#v}getCalculator(){return this.#w}};function Yt(e){return e>0||e<0||0===e}var Vt=class extends L{#t;#x;#c=!1;constructor(e){super(),this.#x=new k({defaultStorage:{hasPointDown:!1,inCanvas:!0}}),this.#t=e,this.#S()}#S(){this.onEvents()}onEvents(){if(!0===this.#t.disabled)return;if(this.#c)return;const e=window,t=this.#t?.container||this.#t.boardContent.boardContext.canvas;e.addEventListener("mousemove",this.#b),e.addEventListener("mouseup",this.#A),t.addEventListener("mousemove",this.#M),t.addEventListener("mousedown",this.#I),t.addEventListener("wheel",this.#C,{passive:!1}),t.addEventListener("click",this.#R),t.addEventListener("contextmenu",this.#z),t.addEventListener("dblclick",this.#E)}offEvents(){if(!0===this.#t.disabled)return;const e=window,t=this.#t?.container||this.#L();e.removeEventListener("mousemove",this.#b),e.removeEventListener("mouseup",this.#A),t.removeEventListener("mousemove",this.#M),t.removeEventListener("mousedown",this.#I),t.removeEventListener("wheel",this.#C),t.removeEventListener("click",this.#R),t.removeEventListener("contextmenu",this.#z),t.removeEventListener("dblclick",this.#E)}destroy(){this.offEvents(),this.#x.destroy(),this.#c=!0}#L(){return this.#t.boardContent.boardContext.canvas}#C=e=>{const t=e;if(!this.#B(e))return;const i=this.#k(e);if(!this.#P(i))return;e.preventDefault(),e.stopPropagation();const o=e.deltaX>0||e.deltaX<0?e.deltaX:0,r=e.deltaY>0||e.deltaY<0?e.deltaY:0;!0===e.ctrlKey&&this.has("wheelScale")?this.trigger("wheelScale",{deltaX:o,deltaY:r,point:i,nativeEvent:t}):this.has("wheel")&&this.trigger("wheel",{deltaX:o,deltaY:r,point:i,nativeEvent:t})};#z=e=>{const t=e;if(2!==e.button)return;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("contextMenu",{point:i,nativeEvent:t})};#R=e=>{const t=e;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("click",{point:i,nativeEvent:t})};#E=e=>{const t=e;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("doubleClick",{point:i,nativeEvent:t})};#T=e=>{const t=e;this.#x.set("hasPointDown",!1),e.preventDefault();const i=this.#k(e);this.trigger("pointLeave",{point:i,nativeEvent:t})};#A=e=>{const t=e;if(this.#x.set("hasPointDown",!1),!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.trigger("pointEnd",{point:i,nativeEvent:t})};#b=e=>{const t=e;if(!this.#B(e))return;e.preventDefault(),e.stopPropagation();const i=this.#k(e);this.#P(i)?!0===this.#x.get("hasPointDown")&&this.trigger("pointMove",{point:i,nativeEvent:t}):this.#x.get("hasPointDown")&&(this.trigger("pointLeave",{point:i,nativeEvent:t}),this.#x.set("hasPointDown",!1))};#I=e=>{const t=e;if(0!==e.button)return;if(!this.#B(e))return;e.preventDefault();const i=this.#k(e);this.#P(i)&&(this.#x.set("hasPointDown",!0),this.trigger("pointStart",{point:i,nativeEvent:t}))};#M=e=>{const t=e;if(!this.#B(e))return void(!0===this.#x.get("inCanvas")&&(this.#x.set("inCanvas",!1),this.#T(e)));this.#x.set("inCanvas",!0),e.preventDefault();const i=this.#k(e);this.#P(i)&&this.trigger("hover",{point:i,nativeEvent:t})};#B(e){const t=e.target;if("true"===t.getAttribute("data-idraw-valid-watch"))return!0;if(t!==this.#L())return!1;const i=nt(this.#t.boardContent.boardContext.canvas);return e.pageX>=i.pageX&&e.pageX<=i.pageX+i.width&&e.pageY>=i.pageY&&e.pageY<=i.pageY+i.height}#k(e){const t=this.#t.boardContent.boardContext.canvas.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top,t:Date.now()}}#P(e){const{width:t,height:i}=this.#t.sharer.getActiveViewSizeInfo();return!!(Yt(e.x)&&Yt(e.y)&&e.x<=t&&e.y<=i)}},jt={width:0,height:0,devicePixelRatio:1,contextWidth:0,contextHeight:0,data:{materials:[]},scale:1,offsetLeft:0,offsetRight:0,offsetTop:0,offsetBottom:0,overrideMaterialMap:null},Gt=class{#N;#D;constructor(){const e=new k({defaultStorage:jt}),t=new k({defaultStorage:{}});this.#N=e,this.#D=t}getActiveStorage(e){return this.#N.get(e)}setActiveStorage(e,t){return this.#N.set(e,t)}getActiveStoreSnapshot(e){return this.#N.getSnapshot(e)}getSharedStorage(e){return this.#D.get(e)}setSharedStorage(e,t){return this.#D.set(e,t)}getSharedStoreSnapshot(e){return this.#D.getSnapshot(e)}getActiveViewScaleInfo(){return{scale:this.#N.get("scale"),offsetTop:this.#N.get("offsetTop"),offsetBottom:this.#N.get("offsetBottom"),offsetLeft:this.#N.get("offsetLeft"),offsetRight:this.#N.get("offsetRight")}}setActiveViewScaleInfo(e){const{scale:t,offsetTop:i,offsetBottom:o,offsetLeft:r,offsetRight:a}=e;this.#N.set("scale",t),this.#N.set("offsetTop",i),this.#N.set("offsetBottom",o),this.#N.set("offsetLeft",r),this.#N.set("offsetRight",a)}setActiveViewSizeInfo(e){this.#N.set("width",e.width),this.#N.set("height",e.height),this.#N.set("devicePixelRatio",e.devicePixelRatio),this.#N.set("contextWidth",e.contextWidth),this.#N.set("contextHeight",e.contextHeight)}getActiveViewSizeInfo(){return{width:this.#N.get("width"),height:this.#N.get("height"),devicePixelRatio:this.#N.get("devicePixelRatio"),contextWidth:this.#N.get("contextWidth"),contextHeight:this.#N.get("contextHeight")}}getActiveOverrideMaterialMap(){return this.#N.get("overrideMaterialMap")}setActiveOverrideMaterialMap(e){this.#N.set("overrideMaterialMap",e)}},{requestAnimationFrame:Ft}=window,Xt=class extends L{#t;#$=[];#H="FREE";constructor(e){super(),this.#t=e,this.#S()}#S(){const{renderer:e}=this.#t;e.on("load",()=>{this.drawFrame()})}#W(){if("DRAWING"===this.#H||0===this.#$.length)return;this.#H="DRAWING";const e=this.#$.shift(),{renderer:t,boardContent:i,beforeDrawFrame:o,afterDrawFrame:r}=this.#t;if(e){const{scale:a,offsetTop:n,offsetBottom:s,offsetLeft:l,offsetRight:h,width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g}=e.activeStore,m={scale:a,offsetTop:n,offsetBottom:s,offsetLeft:l,offsetRight:h},p={width:c,height:d,contextHeight:u,contextWidth:f,devicePixelRatio:g};e?.activeStore.data&&t.drawData(e.activeStore.data,{viewScaleInfo:m,viewSizeInfo:p}),o({snapshot:e}),i.drawView(),r({snapshot:e})}0!==this.#$.length?"DRAWING"===this.#H&&Ft(()=>{this.#W()}):this.#H="COMPLETE"}resetVirtualItemMap(e,t){e&&this.#t.calculator.resetVirtualItemMap(e,t)}drawFrame(){const{sharer:e}=this.#t,t=e.getActiveStoreSnapshot(),i=e.getSharedStoreSnapshot();this.#$.push({activeStore:t,sharedStore:i}),this.#W()}scale(e){const{scale:t,point:i,ignoreUpdateVisibleStatus:o}=e,{sharer:r}=this.#t,{moveX:a,moveY:n}=function(e){const{scale:t,point:i,viewScaleInfo:o}=e,{offsetLeft:r,offsetTop:a}=o,n=t/o.scale,s=i.x,l=i.y;return{moveX:s-s*n+(r*n-r),moveY:l-l*n+(a*n-a)}}({scale:t,point:i,viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()});return r.setActiveStorage("scale",t),o||this.#t.calculator.updateVisiableStatus({viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()}),{moveX:a,moveY:n}}scroll(e){const{sharer:t}=this.#t,i=t.getActiveViewScaleInfo(),{moveX:o,moveY:r,ignoreUpdateVisibleStatus:a}=e,n=function(e){const{moveX:t=0,moveY:i=0,viewScaleInfo:o,viewSizeInfo:r}=e,{scale:a}=o,{width:n,height:s,contextWidth:l,contextHeight:h}=r;let c=o.offsetLeft,d=o.offsetRight,u=o.offsetTop,f=o.offsetBottom;return c+=t,u+=i,d=n-(l*a+c),f=s-(h*a+u),{scale:a,offsetTop:u,offsetLeft:c,offsetRight:d,offsetBottom:f}}({moveX:o,moveY:r,viewScaleInfo:i,viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(n),a||this.#t.calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),n}updateViewScaleInfo(e){const{sharer:t}=this.#t,i=function(e,t){const{scale:i,offsetX:o,offsetY:r}=e,{viewSizeInfo:a}=t,{width:n,height:s,contextWidth:l,contextHeight:h}=a,c=0-o*i,d=0-r*i;return{scale:i,offsetLeft:c,offsetTop:d,offsetRight:n-(l*i+c/i),offsetBottom:s-(h*i+d/i)}}(e,{viewSizeInfo:t.getActiveViewSizeInfo()});return t.setActiveViewScaleInfo(i),this.#t.calculator.updateVisiableStatus({viewScaleInfo:t.getActiveViewScaleInfo(),viewSizeInfo:t.getActiveViewSizeInfo()}),i}resize(e={},t){const{sharer:i}=this.#t,o={...i.getActiveViewSizeInfo(),...e},{width:r,height:a,devicePixelRatio:n}=o,{underlayContext:s,boardContext:l,overlayContext:h,viewContext:c}=this.#t.boardContent;return l.canvas.width=r*n,l.canvas.height=a*n,l.canvas.style.width=`${r}px`,l.canvas.style.height=`${a}px`,s.canvas.width=r*n,s.canvas.height=a*n,h.canvas.width=r*n,h.canvas.height=a*n,c.canvas.width=r*n,c.canvas.height=a*n,i.setActiveViewSizeInfo(o),t?.ignoreUpdateVisibleStatus||this.#t.calculator.updateVisiableStatus({viewScaleInfo:i.getActiveViewScaleInfo(),viewSizeInfo:i.getActiveViewSizeInfo()}),o}},Qt=class{#t;#O=new Map;#Y=[];#V;#j;#G;#F;#w;#X=new L;#c=!1;constructor(e){const{boardContent:t,container:i}=e,o=new Gt,r=new Vt({boardContent:t,sharer:o,disabled:e?.disableWatcher,container:i}),a=new Ot({viewContext:t.viewContext,tempContext:t.tempContext,sharer:o}),n=a.getCalculator();this.#t=e,this.#G=o,this.#V=r,this.#j=a,this.#w=n,this.#F=new Xt({boardContent:e.boardContent,sharer:o,renderer:a,calculator:this.#w,beforeDrawFrame:e=>{this.#Q(e)},afterDrawFrame:e=>{this.#U(e)}}),this.#S(),this.#Z()}isDestroyed(){return this.#c}destroy(){this.#V.destroy(),this.#j.destroy(),this.#w.destroy(),this.#X.destroy(),this.#c=!0}#S(){!0!==this.#t.disableWatcher&&(this.#V.on("pointStart",this.#J.bind(this)),this.#V.on("pointEnd",this.#K.bind(this)),this.#V.on("pointMove",this.#q.bind(this)),this.#V.on("pointLeave",this.#_.bind(this)),this.#V.on("hover",this.#ee.bind(this)),this.#V.on("wheel",this.#te.bind(this)),this.#V.on("wheelScale",this.#ie.bind(this)),this.#V.on("scrollX",this.#oe.bind(this)),this.#V.on("scrollY",this.#re.bind(this)),this.#V.on("resize",this.#ae.bind(this)),this.#V.on("click",this.#ne.bind(this)),this.#V.on("doubleClick",this.#se.bind(this)),this.#V.on("contextMenu",this.#le.bind(this))),this.#j.on("load",()=>{this.#X.trigger("loadResource")})}#J(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.pointStart?.(e))return}#K(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.pointEnd?.(e))return}#q(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.pointMove?.(e))return}#_(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.pointLeave?.(e))return}#ee(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.hover?.(e))return}#ne(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.click?.(e))return}#se(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.doubleClick?.(e))return}#le(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.contextMenu?.(e))return}#te(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.wheel?.(e))return}#ie(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.wheelScale?.(e))return}#oe(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.scrollX?.(e))return}#re(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.scrollY?.(e))return}#ae(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.resize?.(e))return}#he(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.clear?.(e))return}#Q(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.beforeDrawFrame?.(e))return}#U(e){for(let t=0;t<this.#Y.length;t++)if(!1===this.#Y[t]?.afterDrawFrame?.(e))return}#Z(){const e=[];for(const[t,i]of this.#O)"enable"===i?.status&&i?.middlewareObject&&e.push(i.middlewareObject);this.#Y=e}getSharer(){return this.#G}getViewer(){return this.#F}getRenderer(){return this.#j}setData(e){const t=this.#G;this.#G.setActiveStorage("data",e);const i=t.getActiveViewSizeInfo(),o=t.getActiveViewScaleInfo(),r=U(e.materials,{viewWidth:i.width,viewHeight:i.height,extend:!0});this.#F.resetVirtualItemMap(e,{viewSizeInfo:i,viewScaleInfo:o}),this.#F.drawFrame();const a={...i,...r};return this.#G.setActiveViewSizeInfo(a),{viewSizeInfo:a}}getData(){const{data:e}=this.#G.getActiveStoreSnapshot();return e}use(e,t){if(this.#O.has(e)){const t=this.#O.get(e);return void(t&&"enable"!==t.status&&(t.status="enable",t.middlewareObject.use?.(),this.#Z()))}const{boardContent:i,container:o}=this.#t,r=e({boardContent:i,sharer:this.#G,viewer:this.#F,calculator:this.#w,eventHub:this.#X,container:o},t);r.use?.(),this.#O.set(e,{status:"enable",middlewareObject:r,config:t}),this.#Z()}disuse(e){if(this.#O.has(e)){const t=this.#O.get(e);t&&(t.middlewareObject.disuse?.(),t.status="disable"),this.#O.delete(e),this.#Z()}}resetMiddlewareConfig(e,t){if(this.#O.has(e)){const i=this.#O.get(e);i&&i.middlewareObject.resetConfig?.(t)}}scale(e){const t=this.#F,{ignoreUpdateVisibleStatus:i}=e,{moveX:o,moveY:r}=t.scale({...e,ignoreUpdateVisibleStatus:!0});t.scroll({moveX:o,moveY:r,ignoreUpdateVisibleStatus:i})}scroll(e){return this.#F.scroll(e)}updateViewScaleInfo(e){return this.#F.updateViewScaleInfo(e)}resize(e,t){const i=this.#F.resize(e,t),{width:o,height:r,devicePixelRatio:a}=e,{boardContent:n}=this.#t;n.viewContext.$resize({width:o,height:r,devicePixelRatio:a}),n.overlayContext.$resize({width:o,height:r,devicePixelRatio:a}),n.boardContext.$resize({width:o,height:r,devicePixelRatio:a}),n.underlayContext.$resize({width:o,height:r,devicePixelRatio:a}),this.#F.drawFrame(),this.#V.trigger("resize",i),this.#G.setActiveViewSizeInfo(e)}clear(){const{boardContent:e}=this.#t,{underlayContext:t,overlayContext:i,viewContext:o,boardContext:r}=e;t.clearRect(0,0,t.canvas.width,t.canvas.height),i.clearRect(0,0,i.canvas.width,i.canvas.height),o.clearRect(0,0,o.canvas.width,o.canvas.height),r.clearRect(0,0,r.canvas.width,r.canvas.height),this.#he()}getEventHub(){return this.#X}onWatcherEvents(){!0!==this.#t.disableWatcher&&this.#V.onEvents()}offWatcherEvents(){!0!==this.#t.disableWatcher&&this.#V.offEvents()}},Ut="CREATOR",Zt=Symbol(`${Ut}_startPoint`),Jt=Symbol(`${Ut}_endPoint`),Kt=Symbol(`${Ut}_activeMaterialType`),qt="idraw-middleware-creator",_t={zIndex:2,creationAreaBorderColor:"#1973ba"},ei={selectAfterCreated:!0},ti={creationAreaBox:`${qt}-creationAreaBox`,creative:`${qt}-creative`};function ii(e){return N(e,["zIndex","creationAreaBorderColor"])}function oi(e){!function(e,t){if(!e)return;const{className:i}=t;Array.from(e.getElementsByClassName(i)).forEach(e=>{e.remove()})}(e,{className:ti.creationAreaBox})}function ri(e,t){if(!e)return;const{start:i,end:o}=t;i&&o?it(function(e){const t=e.getElementsByClassName(ti.creationAreaBox);if(t[0])return t[0];const i=rt("div",{[yt]:"true",className:ti.creationAreaBox});return ot(e,{},[i]),i}(e),{left:Math.min(i.x,o.x),top:Math.min(i.y,o.y),width:Math.abs(o.x-i.x),height:Math.abs(o.y-i.y)}):oi(e)}function ai(e){const{start:t,end:i,viewScaleInfo:o,calculator:r}=e,a=ne(t,{viewScaleInfo:o}),n=ne(i,{viewScaleInfo:o});return{x:r.toGridNum(Math.min(a.x,n.x)),y:r.toGridNum(Math.min(a.y,n.y)),width:r.toGridNum(Math.abs(n.x-a.x)),height:r.toGridNum(Math.abs(n.y-a.y))}}function ni(e,t,i){"continuous"===i?e.trigger(o.CHANGING,t):"all"===i?(e.trigger(o.CHANGING,t),e.trigger(o.CHANGE,t)):e.trigger(o.CHANGE,t)}var si="SELECTOR",li="idraw-middleware-selector",hi="data-idraw-box-type",ci="data-idraw-material-id",di="data-idraw-handler-type",ui="box-group",fi="box-material",gi={materialBox:`${li}-materialBox`,groupBox:`${li}-groupBox`,nestedBox:`${li}-nestedBox`,nestedTargetBox:`${li}-nestedTargetBox`,hoverBox:`${li}-hoverBox`,hoverTargetBox:`${li}-hoverTargetBox`,lockedBox:`${li}-lockedBox`,lockedTargetBox:`${li}-lockedTargetBox`,selectedBox:`${li}-selectedBox`,selectedTargetBox:`${li}-selectedTargetBox`,hideHandler:`${li}-hideHandler`,edgeHandler:`${li}-edgeHandler`,edgeTopHandler:`${li}-edgeTopHandler`,edgeRightHandler:`${li}-edgeRightandler`,edgeBottomHandler:`${li}-edgeBottomHandler`,edgeLeftHandler:`${li}-edgeLeftHandler`,cornerHandler:`${li}-cornerHandler`,cornerTopLeftHandler:`${li}-cornerTopLeftHandler`,cornerTopRightHandler:`${li}-cornerTopRightHandler`,cornerBottomLeftHandler:`${li}-cornerBottomLeftHandler`,cornerBottomRightHandler:`${li}-cornerBottomRightHandler`,rotateHandler:`${li}-rotateHandler`,selectionAreaBox:`${li}-selectionAreaBox`},mi=Symbol(`${si}_prevPoint`),pi=Symbol(`${si}_pointStartMaterialSizeList`),yi=Symbol(`${si}_moveOriginalStartPoint`),xi=Symbol(`${si}_moveOriginalStartMaterialSize`),vi=Symbol(`${si}_inBusyMode`),wi=Symbol(`${si}_hasChangedData`),Si=Symbol(`${si}_startResizeGroupRecord`),bi=Symbol(`${si}_endResizeGroupRecord`),Ai=Symbol(`${si}_actionType`),Mi=Symbol(`${si}_resizeType`),Ii=Symbol(`${si}_areaStart`),Ci=Symbol(`${si}_areaEnd`),Ri=Symbol(`${si}_hoverMaterial`),zi=Symbol(`${si}_selectedMaterialList`),Ei=Symbol(`${si}_selectedMaterialListVertexes`),Li=Symbol(`${si}_selectedMaterialPosition`),Bi=Symbol(`${si}_groupQueue`),ki=Symbol(`${si}_isMoving`),Pi=Symbol(`${si}_enableSelectInGroup`),Ti=Symbol(`${si}_enableSnapToGrid`),Ni={zIndex:1,activeColor:"#1973ba",handlerBorderColor:"#1973ba",handlerBackground:"#ffffff",handlerHoverBackground:"#aad4f6",handlerActiveBackground:"#63b8f8",selectionAreaBorderColor:"#1973ba",selectionAreaBackground:"#1973ba3f",lockedColor:"#5b5959b5",referenceColor:"#f7276e"};function Di(e){return e*Math.PI/180}function $i(e,t){return Math.sqrt(e*e+t*t)}function Hi(e,t){return t>0?Math.abs(e):0-Math.abs(e)}function Wi(e,t){const{ctx:i,viewScaleInfo:o,vertexes:r}=t,a=ae(r[0],{viewScaleInfo:o}),n=ae(r[1],{viewScaleInfo:o}),s=ae(r[2],{viewScaleInfo:o}),l=ae(r[3],{viewScaleInfo:o});return i.beginPath(),i.moveTo(a.x,a.y),i.lineTo(n.x,n.y),i.lineTo(s.x,s.y),i.lineTo(l.x,l.y),i.lineTo(a.x,a.y),i.closePath(),!!i.isPointInPath(e.x,e.y)}function Oi(e,t){const i={type:null,materials:[],materialVertexesList:[],groupQueue:[]},{ctx:o,data:r,calculator:a,selectedMaterials:n,viewScaleInfo:s,viewSizeInfo:l,areaSize:h,groupQueue:c,nativeEvent:d}=t,u=d.target;if(n&&1===n?.length&&u){const e=u;if(e?.hasAttribute("data-idraw-handler-type")){const t=e.getAttribute(di);if("string"==typeof t)return i.type=`resize-${t}`,i.groupQueue=c||[],i.materials=[n[0]],i}}if(c&&Array.isArray(c)&&c.length>0){const t=c[c.length-1];if(t?.children&&Array.isArray(t?.children))for(let r=t.children.length-1;r>=0;r--){const a=t.children[r],n=oe(a,{groupQueue:c});if(n&&Wi(e,{ctx:o,vertexes:n,viewScaleInfo:s,viewSizeInfo:l}))return i.type||(i.type="over-material"),i.groupQueue=c,i.materials=[a],i}return i}if(null!==i.type)return i;if(h&&Array.isArray(n)&&n?.length>1){const{x:t,y:o,width:r,height:a}=h;if(e.x>=t&&e.x<=t+r&&e.y>=o&&e.y<=o+a)return i.type="list-area",i.materials=n,i}if(r){const{index:t,material:o}=a.getPointMaterial(e,{data:r,viewScaleInfo:s,viewSizeInfo:l});if(t>=0&&o&&!0!==o?.operations?.invisible)return i.materials=[o],i.type="over-material",i}return i}function Yi(e,t){const{x:i,y:o,width:r,height:a,angle:n=0}=e,{center:s,start:l,end:h,viewScaleInfo:c,calculator:d}=t,u=ae(s,{viewScaleInfo:c}),f=X(X(n)+(g=function(e,t,i){const o=O(e,t),r=O(e,i);return null!==r&&null!==o?r-o:0}(u,l,h),g/Math.PI*180));var g;return{x:d.toGridNum(i),y:d.toGridNum(o),width:d.toGridNum(r),height:d.toGridNum(a),angle:d.toGridNum(f)}}function Vi(e,t){if(!Array.isArray(e))return null;const i={x:0,y:0,width:0,height:0},{viewScaleInfo:o}=t;let r=null;for(let t=0;t<e.length;t++){const a=e[t];if(a?.operations?.invisible)continue;const n=re(a,{viewScaleInfo:o});if(n.angle&&(n.angle>0||n.angle<0)){const e=G(n);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];n.x=Math.min(...t),n.y=Math.min(...i),n.width=Math.abs(Math.max(...t)-Math.min(...t)),n.height=Math.abs(Math.max(...i)-Math.min(...i))}}if(r){const e=Math.min(n.x,i.x),t=Math.min(n.y,i.y),o=Math.max(n.x+n.width,i.x+i.width),r=Math.max(n.y+n.height,i.y+i.height);i.x=e,i.y=t,i.width=Math.abs(o-e),i.height=Math.abs(r-t)}else i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height;r=n}return i}function ji(e){return{minX:e.topLeft.x,minY:e.topLeft.y,maxX:e.bottomRight.x,maxY:e.bottomRight.y,midX:e.center.x,midY:e.center.y}}var Gi=(e,t)=>{if(0===e.length)throw null;if(1===e.length)return e[0];let i=0,o=e.length-1;for(;i<=o;){const r=Math.floor((i+o)/2);if(e[r]===t)return e[r];e[r]<t?i=r+1:o=r-1}return i>=e.length?e[o]:o<0?e[i]:Math.abs(e[o]-t)<=Math.abs(e[i]-t)?e[o]:e[i]},Fi=(e,t)=>Math.abs(e-t)<1e-5;function Xi(e,t){const{data:i,groupQueue:o,calculator:r,viewScaleInfo:a,viewSizeInfo:n}=t;let s=i.materials||[];o?.length>0&&(s=o[o.length-1]?.children||[]);const l=[];s.forEach(t=>{if(t.id!==e){const e=r.calcViewBoundingInfoFromRange(t.id,{checkVisible:!0,viewScaleInfo:a,viewSizeInfo:n});e&&l.push(e)}});const h=r.calcViewBoundingInfoFromRange(e,{viewScaleInfo:a,viewSizeInfo:n});if(!h)return null;const c={},d={},u={},f={},g=[],m=[];let p=[],y=[];const x=ji(h);c[x.minX]=[x.minY,x.midY,x.maxY],c[x.midX]=[x.minY,x.midY,x.maxY],c[x.maxX]=[x.minY,x.midY,x.maxY],d[x.minY]=[x.minX,x.midX,x.maxX],d[x.midY]=[x.minX,x.midX,x.maxX],d[x.maxY]=[x.minX,x.midX,x.maxX],l.forEach(e=>{const t=ji(e);u[t.minX]||(u[t.minX]=[]),u[t.midX]||(u[t.midX]=[]),u[t.maxX]||(u[t.maxX]=[]),f[t.minY]||(f[t.minY]=[]),f[t.midY]||(f[t.midY]=[]),f[t.maxY]||(f[t.maxY]=[]),u[t.minX]=[t.minY,t.midY,t.maxY],u[t.midX]=[t.minY,t.midY,t.maxY],u[t.maxX]=[t.minY,t.midY,t.maxY],p.push(t.minX),p.push(t.midX),p.push(t.maxX),f[t.minY]=[t.minX,t.midX,t.maxX],f[t.midY]=[t.minX,t.midX,t.maxX],f[t.maxY]=[t.minX,t.midX,t.maxX],y.push(t.minY),y.push(t.midY),y.push(t.maxY)}),p=p.sort((e,t)=>e-t),y=y.sort((e,t)=>e-t);let v=null,w=null,S=null,b=null,A=null,M=null,I=null,R=null;if(p.length>0){S=Gi(p,x.minX),b=Gi(p,x.midX),A=Gi(p,x.maxX);const e=Math.abs(S-x.minX),t=Math.abs(b-x.midX),i=Math.abs(A-x.maxX),o=Math.min(e,t,i);o<=2/a.scale&&(Fi(o,e)?v=S-x.minX:Fi(o,t)?v=b-x.midX:Fi(o,i)&&(v=A-x.maxX))}if(y.length>0){M=Gi(y,x.minY),I=Gi(y,x.midY),R=Gi(y,x.maxY);const e=Math.abs(M-x.minY),t=Math.abs(I-x.midY),i=Math.abs(R-x.maxY),o=Math.min(e,t,i);o<=2/a.scale&&(Fi(o,e)?w=M-x.minY:Fi(o,t)?w=I-x.midY:Fi(o,i)&&(w=R-x.maxY))}const z={...x};if(null!==v&&(z.minX+=v,z.midX+=v,z.maxX+=v),null!==w&&(z.minY+=w,z.midY+=w,z.maxY+=w),C.x(v)&&null!==v&&null!==S&&null!==b&&null!==A){if(Fi(v,S-x.minX)){const e={x:S,yList:[]};e.yList.push(z.minY),e.yList.push(z.maxY),e.yList.push(...f?.[S]||[]),g.push(e)}if(Fi(v,b-x.minX)){const e={x:b,yList:[]};e.yList.push(z.minY),e.yList.push(z.maxY),e.yList.push(...f?.[b]||[]),g.push(e)}if(Fi(v,A-x.minX)){const e={x:A,yList:[]};e.yList.push(z.minY),e.yList.push(z.maxY),e.yList.push(...f?.[A]||[]),g.push(e)}}if(C.y(w)&&null!==w&&null!==M&&null!==I&&null!==R){if(Fi(w,M-x.minY)){const e={y:M,xList:[]};e.xList.push(z.minX),e.xList.push(z.maxX),e.xList.push(...u?.[M]||[]),m.push(e)}if(Fi(w,I-x.midY)){const e={y:I,xList:[]};e.xList.push(z.minX),e.xList.push(z.maxX),e.xList.push(...u?.[M]||[]),m.push(e)}if(Fi(w,R-x.maxY)){const e={y:R,xList:[]};e.xList.push(z.minX),e.xList.push(z.maxX),e.xList.push(...u?.[R]||[]),m.push(e)}}const E=[];g?.length>0&&g.forEach((e,t)=>{E.push([]),e.yList.forEach(i=>{E[t].push({x:e.x,y:i})})});const L=[];return m?.length>0&&m.forEach((e,t)=>{L.push([]),e.xList.forEach(i=>{L[t].push({x:i,y:e.y})})}),{offsetX:v,offsetY:w,yLines:E,xLines:L}}var Qi="LAYOUT_SELECTOR",Ui=Symbol(`${Qi}_layoutActionType`),Zi=Symbol(`${Qi}_layoutControlType`);Symbol(`${Qi}_layoutController`);var Ji=Symbol(`${Qi}_layoutIsHoverContent`),Ki=Symbol(`${Qi}_layoutIsHoverController`),qi=Symbol(`${Qi}_layoutIsSelected`),_i=Symbol(`${Qi}_layoutIsSelected`),eo="idraw-middleware-layout-selector",to="data-idraw-handler-type",io=1.5,oo={zIndex:2,activeColor:"#b331c9",handlerBorderColor:"#b331c9",handlerBackground:"#ffffff",handlerHoverBackground:"#bb8fc3",handlerActiveBackground:"#b467c2"},ro={hover:`${eo}-hover`,edgeHandler:`${eo}-edgeHandler`,edgeTopHandler:`${eo}-edgeTopHandler`,edgeRightHandler:`${eo}-edgeRightandler`,edgeBottomHandler:`${eo}-edgeBottomHandler`,edgeLeftHandler:`${eo}-edgeLeftHandler`,cornerHandler:`${eo}-cornerHandler`,cornerTopLeftHandler:`${eo}-cornerTopLeftHandler`,cornerTopRightHandler:`${eo}-cornerTopRightHandler`,cornerBottomLeftHandler:`${eo}-cornerBottomLeftHandler`,cornerBottomRightHandler:`${eo}-cornerBottomRightHandler`};function ao(e,t){const{rootClassName:i}=t,o=e.getElementsByClassName(i);Array.from(o).forEach(e=>{e.remove()})}function no(e,t){const{layout:i}=t;i?function(e,t){const i=e.querySelectorAll(`[${to}]`),{rootClassName:o,layout:r,viewScaleInfo:a,hover:n}=t;if(!r)return;const{x:s,y:l,height:h,width:c}=re(r,{viewScaleInfo:a}),d={left:s,top:l,height:h},u={left:s,top:l,width:c},f={left:s+c,top:l,height:h},g={left:s,top:l+h,width:c},m={left:s,top:l},p={left:s+c,top:l},y={left:s,top:l+h},x={left:s+c,top:l+h};if(i.length>0){const t=e.getElementsByClassName(ro.edgeLeftHandler)[0],i=e.getElementsByClassName(ro.edgeRightHandler)[0],o=e.getElementsByClassName(ro.edgeTopHandler)[0],r=e.getElementsByClassName(ro.edgeBottomHandler)[0],a=e.getElementsByClassName(ro.cornerTopLeftHandler)[0],n=e.getElementsByClassName(ro.cornerTopRightHandler)[0],s=e.getElementsByClassName(ro.cornerBottomLeftHandler)[0],l=e.getElementsByClassName(ro.cornerBottomRightHandler)[0];it(t,d),it(i,f),it(o,u),it(r,g),it(a,m),it(n,p),it(s,y),it(l,x)}else{const t=rt,i={[yt]:"true"};ot(e,{},[t("div",{[to]:"left",...i,className:`${o} ${ro.edgeHandler} ${ro.edgeLeftHandler}`,style:d}),t("div",{[to]:"top",...i,className:`${o} ${ro.edgeHandler} ${ro.edgeTopHandler}`,style:u}),t("div",{[to]:"right",...i,className:`${o} ${ro.edgeHandler} ${ro.edgeRightHandler}`,style:f}),t("div",{[to]:"bottom",...i,className:`${o} ${ro.edgeHandler} ${ro.edgeBottomHandler}`,style:g}),t("div",{[to]:"top-left",...i,className:`${o} ${ro.cornerHandler} ${ro.cornerTopLeftHandler}`,style:m}),t("div",{[to]:"top-right",...i,className:`${o} ${ro.cornerHandler} ${ro.cornerTopRightHandler}`,style:p}),t("div",{[to]:"bottom-left",...i,className:`${o} ${ro.cornerHandler} ${ro.cornerBottomLeftHandler}`,style:y}),t("div",{[to]:"bottom-right",...i,className:`${o} ${ro.cornerHandler} ${ro.cornerBottomRightHandler}`,style:x})])}const v=Array.from(e.querySelectorAll(`[${to}]`));n?v.forEach(e=>{et(e,[ro.hover])}):v.forEach(e=>{tt(e,[ro.hover])})}(e,t):ao(e,t)}var so="monospace";var lo="@middleware/internal-event/show-info-angle",ho={textBackground:"#1973bac6",textColor:"#ffffff"};function co(e){return N(e,["textBackground","textColor"])}var uo=10;function fo(e){const{material:t,groupQueue:i,viewScaleInfo:o}=e;let r=t?K(t):null;const a=i.map(e=>K(e));if(Array.isArray(a)&&a.length>0){r=r?re(r,{viewScaleInfo:{scale:o.scale}}):null,a[0]=re(a[0],{viewScaleInfo:o});for(let e=1;e<a.length;e++)a[e]=re(a[e],{viewScaleInfo:{scale:o.scale}})}else r=r?re(r,{viewScaleInfo:o}):null;return{viewMaterialSize:r,viewGroupSizeQueue:a}}function go(e,t){if(!e)return null;const{className:i,targetClassName:o,viewMaterialSize:r,viewGroupSizeQueue:a}=t,n=function(e){const{viewMaterialSize:t,viewGroupSizeQueue:i,className:o,targetClassName:r}=e;let a=null;t&&(a=rt("div",{[hi]:fi,[yt]:"true",[ci]:t.id,className:gi.materialBox,style:{display:"block",position:"absolute",top:t.y,left:t.x,width:t.width,height:t.height,transform:`rotate(${t.angle||0}deg)`}}),et(a,[r]));let n=a;for(let e=i.length-1;e>=0;e--){const t=i[e],o=[];n&&o.push(n),n=rt("div",{[hi]:ui,[yt]:"true",[ci]:t.id,className:`${gi.materialBox} ${gi.groupBox}`,style:{position:"absolute",top:t.y,left:t.x,width:t.width,height:t.height,transform:`rotate(${t.angle||0}deg)`}},o)}return n&&et(n,[o]),n}({viewMaterialSize:r,viewGroupSizeQueue:a,className:i,targetClassName:o});return n&&ot(e,{},[n]),n}function mo(e,t){if(!e)return null;const{className:i,targetClassName:o,renderTargetInner:r,destoryTargetInner:a,afterRender:n}=t,s=e.getElementsByClassName(i),{viewMaterialSize:l,viewGroupSizeQueue:h}=fo(t),c=()=>{Array.from(s).forEach(e=>{e.remove()})};if(l||h.length||c(),1===s.length){const e=s[0];if(et(e,[i]),h.length>0){let e=0,t=s[0],i=t.parentElement;for(;e<h.length;){const r=h[e];if(t?(tt(t,[o]),ot(t,{[hi]:ui,[yt]:"true",[ci]:r.id,style:{position:"absolute",top:r.y,left:r.x,width:r.width,height:r.height,transform:`rotate(${r.angle||0}deg)`}})):(t=rt("div",{[hi]:ui,[yt]:"true",[ci]:r.id,className:`${gi.materialBox} ${gi.groupBox}`,style:{position:"absolute",top:r.y,left:r.x,width:r.width,height:r.height,transform:`rotate(${r.angle||0}deg)`}}),i?.appendChild(t)),i=t,e+1===h.length)break;t=t?.children?.[0],e++}if(l){let e=t?.children?.[0];e||(e=rt("div"),i?.appendChild(e)),ot(e,{[hi]:fi,[yt]:"true",[ci]:l.id,style:{display:"block",position:"absolute",top:l.y,left:l.x,width:l.width,height:l.height,transform:`rotate(${l.angle||0}deg)`}}),r?.(e)}else a?.(t)}else l?(a?.(e),ot(e,{[hi]:fi,[yt]:"true",[ci]:l.id,style:{display:"block",position:"absolute",top:l.y,left:l.x,width:l.width,height:l.height,transform:`rotate(${l.angle||0}deg)`}}),et(e,[o]),r?.(e)):c();return n?.({$rootBox:e,viewGroupSizeQueue:h,viewMaterialSize:l}),e}{c();const t=go(e,{viewMaterialSize:l,viewGroupSizeQueue:h,className:i,targetClassName:o});et(t,[o]),r?.(t),n?.({$rootBox:t,viewGroupSizeQueue:h,viewMaterialSize:l})}}function po(e,t){if(!e)return;const{className:i}=t;Array.from(e.getElementsByClassName(i)).forEach(e=>{e.remove()})}function yo(e,t){const{groupQueue:i}=t;Array.isArray(i)&&i.length?mo(e,{...t,className:gi.nestedBox,targetClassName:gi.nestedTargetBox}):function(e){po(e,{className:gi.nestedBox})}(e)}function xo(e){return po(e,{className:gi.hoverBox})}function vo(e){return po(e,{className:gi.lockedBox})}function wo(e,t){vo(e),function(e,t){if(!e)return null;const{className:i,targetClassName:o}=t,{viewMaterialSize:r,viewGroupSizeQueue:a}=fo(t);go(e,{viewMaterialSize:r,viewGroupSizeQueue:a,className:i,targetClassName:o})}(e,{...t,className:gi.lockedBox,targetClassName:gi.lockedTargetBox})}function So(e){if(e.querySelectorAll("[data-idraw-handler-type]").length>0)return;const t=rt,i={[yt]:"true"};ot(e,{},[t("div",{[di]:"left",...i,className:`${gi.edgeHandler} ${gi.edgeLeftHandler}`}),t("div",{[di]:"top",...i,className:`${gi.edgeHandler} ${gi.edgeTopHandler}`}),t("div",{[di]:"right",...i,className:`${gi.edgeHandler} ${gi.edgeRightHandler}`}),t("div",{[di]:"bottom",...i,className:`${gi.edgeHandler} ${gi.edgeBottomHandler}`}),t("div",{[di]:"top-left",...i,className:`${gi.cornerHandler} ${gi.cornerTopLeftHandler}`}),t("div",{[di]:"top-right",...i,className:`${gi.cornerHandler} ${gi.cornerTopRightHandler}`}),t("div",{[di]:"bottom-left",...i,className:`${gi.cornerHandler} ${gi.cornerBottomLeftHandler}`}),t("div",{[di]:"bottom-right",...i,className:`${gi.cornerHandler} ${gi.cornerBottomRightHandler}`}),t("div",{[di]:"rotate",...i,className:gi.rotateHandler})])}function bo(e,t){const{material:i}=t;i?mo(e,{...t,className:gi.selectedBox,targetClassName:gi.selectedTargetBox,renderTargetInner:So,destoryTargetInner:e=>e.innerHTML="",afterRender:({$rootBox:e,viewMaterialSize:t})=>{if(t&&e){const{width:i,height:o}=t;Math.min(i,o)>40?tt(e,[gi.hideHandler]):et(e,[gi.hideHandler])}}}):function(e){po(e,{className:gi.selectedBox})}(e)}function Ao(e,t){if(!e)return;const{areaStart:i,areaEnd:o,selectedMaterials:r,viewScaleInfo:a}=t;let n=null,s=null,l=!1;if(r.length>1||1===r.length&&i&&o){const{x:e,y:t,width:i,height:o}=function(e){const t={x:0,y:0,width:0,height:0};let i=null;for(let o=0;o<e.length;o++){const r=e[o];if(r?.operations?.invisible)continue;const a={x:r.x,y:r.y,width:r.width,height:r.height,angle:r.angle||0};if(a.angle&&(a.angle>0||a.angle<0)){const e=G(a);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];a.x=Math.min(...t),a.y=Math.min(...i),a.width=Math.abs(Math.max(...t)-Math.min(...t)),a.height=Math.abs(Math.max(...i)-Math.min(...i))}}if(i){const e=Math.min(a.x,t.x),i=Math.min(a.y,t.y),o=Math.max(a.x+a.width,t.x+t.width),r=Math.max(a.y+a.height,t.y+t.height);t.x=e,t.y=i,t.width=Math.abs(o-e),t.height=Math.abs(r-i)}else t.x=a.x,t.y=a.y,t.width=a.width,t.height=a.height;i=a}return{x:Math.floor(t.x),y:Math.floor(t.y),width:Math.ceil(t.width),height:Math.ceil(t.height)}}(r);n={x:e,y:t},s={x:e+i,y:t+o},l=!0}else i&&o&&(n={...i},s={...o});if(n&&s){const t=function(e){const t=e.getElementsByClassName(gi.selectionAreaBox);if(t[0])return t[0];const i=rt("div",{[yt]:"true",className:gi.selectionAreaBox});return ot(e,{},[i]),i}(e);l&&(n=ae(n,{viewScaleInfo:a}),s=ae(s,{viewScaleInfo:a})),it(t,{left:Math.min(n.x,s.x),top:Math.min(n.y,s.y),width:Math.abs(s.x-n.x),height:Math.abs(s.y-n.y)})}else!function(e){po(e,{className:gi.selectionAreaBox})}(e)}function Mo(e,t){const{groupQueue:i,$root:o}=t;if(!(i&&i?.length>0&&o))return!1;const r=i[i.length-1].id,a=e.target;if("string"==typeof r&&r){if("box-group"===a?.getAttribute("data-idraw-box-type")&&a?.getAttribute("data-idraw-material-id")===r)return!0;const e=st(a,o,{[hi]:ui});if("box-group"===e?.getAttribute("data-idraw-box-type")&&e?.getAttribute("data-idraw-material-id")===r)return!0}return!1}function Io(e){return N(e,["zIndex","activeColor","handlerBorderColor","handlerBackground","handlerHoverBackground","handlerActiveBackground","selectionAreaBackground","selectionAreaBorderColor","lockedColor","referenceColor"])}var Co=(e,t)=>{const{x:i,y:o,width:r,height:a}=t,n=e.width,s=e.height;if(e.x=i,e.y=o,e.width=r,e.height=a,"circle"===e.type)e.cx=i+r/2,e.cy=o+a/2,e.r=Math.min(r,a)/2;else if("ellipse"===e.type)e.cx=i+r/2,e.cy=o+a/2,e.rx=r/2,e.ry=a/2;else if("path"===e.type){const t=r/n,i=a/s,o=e;o.commands=Ue(o.commands,t,i)}};function Ro(e,t,i,o){const{stroke:r,strokeWidth:a,lineDash:n}=o;e.setLineDash([]),e.lineWidth=a,e.strokeStyle=r,e.setLineDash(n),e.beginPath(),e.moveTo(t.x,t.y),e.lineTo(i.x,i.y),e.closePath(),e.stroke()}function zo(e,t,i){const{size:o,stroke:r,strokeWidth:a,lineDash:n}=i,s=t.x-o/2,l=t.x+o/2,h=t.y-o/2,c=t.y+o/2;!function(e,t,i){const{stroke:o,strokeWidth:r,lineDash:a}=i;e.setLineDash([]),e.lineWidth=r,e.strokeStyle=o,e.setLineDash(a),e.beginPath(),e.moveTo(t[0].x,t[0].y),e.lineTo(t[2].x,t[2].y),e.closePath(),e.stroke(),e.beginPath(),e.moveTo(t[1].x,t[1].y),e.lineTo(t[3].x,t[3].y),e.closePath(),e.stroke()}(e,[{x:s,y:h},{x:l,y:h},{x:l,y:c},{x:s,y:c}],{stroke:r,strokeWidth:a,lineDash:n})}function Eo(e,t){const{xLines:i,yLines:o,styles:r}=t,{referenceColor:a}=r,n={stroke:a,strokeWidth:1,lineDash:[]},s={...n,size:6};i&&i.forEach(t=>{t.forEach((i,o)=>{zo(e,i,s),t[o+1]&&Ro(e,t[o],t[o+1],n)})}),o&&o.forEach(t=>{t.forEach((i,o)=>{zo(e,i,s),t[o+1]&&Ro(e,t[o],t[o+1],n)})})}function Lo({$root:e,styles:t,snapshot:i,sharer:o,calculator:r,boardContent:a}){const{activeStore:n,sharedStore:s}=i,{overlayContext:l}=a,{scale:h,offsetLeft:c,offsetTop:d,offsetRight:u,offsetBottom:f,width:g,height:m,contextHeight:p,contextWidth:y,devicePixelRatio:x}=n,v={scale:h,offsetLeft:c,offsetTop:d,offsetRight:u,offsetBottom:f},w={width:g,height:m,contextHeight:p,contextWidth:y,devicePixelRatio:x},S=s[zi],b=S[0],A=s[Ri],M=s[Ai],I=s[Ii],C=s[Ci],R=s[Bi],z=s[Ti],E=!!A?.operations?.locked,L={material:null,groupQueue:R||[],viewScaleInfo:v,viewSizeInfo:w,calculator:r};if(yo(e,L),xo(e),vo(e),A&&A?.id!==S[0]?.id&&(L.material=A,E?wo(e,L):function(e,t){xo(e),mo(e,{...t,className:gi.hoverBox,targetClassName:gi.hoverTargetBox})}(e,L)),bo(e,{...L,material:1===S.length?S[0]:null}),Ao(e,{...L,areaStart:I,areaEnd:C,selectedMaterials:S}),R?.length>0){if(b&&["select","drag","resize"].includes(M)&&"drag"===M&&!0===z){const e=Xi(b.id,{calculator:r,data:n.data,groupQueue:R,viewScaleInfo:v,viewSizeInfo:w});if(e){const{offsetX:i,offsetY:o,xLines:r,yLines:a}=e;0!==i&&0!==o||Eo(l,{xLines:r,yLines:a,styles:t})}}}else if(b&&["select","drag","resize"].includes(M)){if("drag"===M&&!0===z){const e=Xi(b.id,{calculator:r,data:n.data,groupQueue:R,viewScaleInfo:v,viewSizeInfo:w});if(e){const{offsetX:i,offsetY:o,xLines:r,yLines:a}=e;0!==i&&0!==o||Eo(l,{xLines:r,yLines:a,styles:t})}}}else"area"===M&&I&&C||["drag-list","drag-list-end"].includes(M)&&Vi(o.getSharedStorage(zi),{viewScaleInfo:o.getActiveViewScaleInfo(),viewSizeInfo:o.getActiveViewSizeInfo(),calculator:r})}var Bo="SCROLL",ko=Symbol(`${Bo}_xThumbStyle`),Po=Symbol(`${Bo}_yThumbStyle`),To=Symbol(`${Bo}_prevPoint`),No=Symbol(`${Bo}_activePoint`),Do=Symbol(`${Bo}_activeThumbType`),$o="idraw-middleware-scroller",Ho="data-idraw-thumb-type",Wo={zIndex:2,thumbBackground:"#0000003A",thumbBorderColor:"#0000008A",hoverThumbBackground:"#0000005F",hoverThumbBorderColor:"#000000EE",activeThumbBackground:"#0000005E",activeThumbBorderColor:"#000000F0"},Oo={horizontal:`${$o}-horizontal`,vertical:`${$o}-vertical`,thumb:`${$o}-thumb`};function Yo(e){return N(e,["zIndex","thumbBackground","thumbBorderColor","hoverThumbBackground","hoverThumbBorderColor","activeThumbBackground","activeThumbBorderColor"])}function Vo(e){const t=e.target;return!!(t?.classList?.contains(Oo.thumb)||t?.classList?.contains(Oo.horizontal)||t?.classList?.contains(Oo.vertical))}function jo(e){const{xThumbStyle:t,yThumbStyle:i,$horizontal:o,$vertical:r}=e;if(o&&t){const e=o.getElementsByClassName(Oo.thumb)[0];e&&it(e,t)}if(r&&i){const e=r.getElementsByClassName(Oo.thumb)[0];e&&it(e,i)}}function Go(e){const t=e?.target;return t?.classList?.contains(Oo.thumb)&&t.hasAttribute("data-idraw-thumb-type")?t.getAttribute(Ho):null}var Fo="monospace",Xo={background:"#FFFFFFA8",stroke:"#00000080",scaleColor:"#000000",textColor:"#00000080",gridColor:"#AAAAAA20",gridPrimaryColor:"#AAAAAA40",selectedAreaColor:"#19609780"};function Qo(e){return N(e,["background","stroke","scaleColor","textColor","gridColor","gridPrimaryColor","selectedAreaColor"])}var Uo=[1,2,5,10,20,50,100,200,500];function Zo(e){const{scale:t,viewLength:i,viewOffset:o}=e,r=[];let a=10;a=ue(a/t,{decimalPlaces:0}),a=function(e){e=Math.max(Uo[0],Math.min(e,Uo[Uo.length-1]));for(let t=0;t<Uo.length-1;t++){const i=Uo[t],o=Uo[t+1];if(!(e>o))return e===i||e===o?e:e<=(i+o)/2?i:o}return e}(a);const n=10*a,s=5*a;let l=0;const h=a*t,c=0-o,d=c%h,u=(c-d+h)/t,f=h-d+0;for(;f+l*h<i;){const e=ue(u+l*a,{decimalPlaces:0}),t={num:e,position:ue(f+l*h,{decimalPlaces:0}),showNum:e%n===0,isKeyNum:e%n===0,isSubKeyNum:e%s===0};r.push(t),l++}return{list:r,rulerUnit:a}}var Jo="idraw-middleware-text-editor",Ko={zIndex:1,boxBorderColor:"#0c8ce9"},qo={textarea:`${Jo}-textarea`,hide:`${Jo}-hide`,canvasWrapper:`${Jo}-canvas-wrapper`};function _o(e){return N(e,["zIndex","boxBorderColor"])}var er=pe();var tr=e=>{const{size:t,parent:i}=e,o=document.createElement("div"),{x:r,y:a,width:n,height:s}=t;return it(o,{position:"absolute",left:`${r}px`,top:`${a}px`,width:`${n}px`,height:`${s}px`,transform:`rotate(${X(t.angle||0)}deg)`}),i.appendChild(o),o},ir=Symbol("DRAG_prevPoint"),or="idraw-middleware-path-creator",rr={hide:`${or}-hide`,anchor:`${or}-anchor`,director:`${or}-director`,directorLines:`${or}-director-lines`,pathLine:`${or}-path-line`,selected:`${or}-selected`},ar="data-uuid",nr="data-x",sr="data-y",lr="data-w",hr="data-h",cr="data-angle",dr="data-type",ur="data-helper-type",fr="data-anchor-cmd-type",gr="data-anchor-index",mr="data-anchor-id",pr="data-director-from-anchor-id",yr="data-director-control-type",xr="data-director-opened-by-anchor-id",vr="material",wr="anchor",Sr="director",br="director-line",Ar="path-preview",Mr="path-definition",Ir={zIndex:2,anchorSize:8,anchorSelectedSize:12,anchorBorderWidth:2,anchorBorderColor:"#0c8ce9",anchorBackground:"#ffffff",anchorHoverBorderColor:"#1671b8",anchorHoverBackground:"#cfe4f4",anchorActiveBorderColor:"#0d548c",anchorActiveBackground:"#88c0ec",directorSize:10,directorBorderWidth:2,directorBorderColor:"#7315d1ff",directorBackground:"#ffffff",directorHoverBorderColor:"#4716b8ff",directorHoverBackground:"#ebcff4ff",directorActiveBorderColor:"#510d8cff",directorActiveBackground:"#c988ecff",directorLineColor:"#7315d1ff",helperStrokeColor:"#0c8ce9",helperStrokeWidth:1};function Cr(e){return N(e,["zIndex","anchorSize","anchorSelectedSize","anchorBorderWidth","anchorBorderColor","anchorBackground","anchorHoverBorderColor","anchorHoverBackground","anchorActiveBorderColor","anchorActiveBackground","directorSize","directorBorderWidth","directorBorderColor","directorBackground","directorHoverBorderColor","directorHoverBackground","directorActiveBorderColor","directorActiveBackground","directorLineColor","helperStrokeColor","helperStrokeWidth"])}var Rr=(e,t)=>{const{size:i,parent:o}=e,{x:r,y:a,width:n,height:s}=i,l=X(i.angle||0),h=rt("div",{[yt]:"true",style:{position:"absolute",left:r,top:a,width:n,height:s,transform:`rotate(${l}deg)`},...t});return o.appendChild(h),h},zr=e=>({id:e.getAttribute(ar)||"",type:e.getAttribute(dr)||"",x:parseFloat(e.getAttribute(nr)||"0"),y:parseFloat(e.getAttribute(sr)||"0"),w:parseFloat(e.getAttribute(lr)||"0"),h:parseFloat(e.getAttribute(hr)||"0"),angle:parseFloat(e.getAttribute(cr)||"0")}),Er=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}},Lr=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}},Br=e=>({type:e.getAttribute(yr),fromAnchorId:e.getAttribute(pr)||"",openedAnchorId:e.getAttribute(xr)||""}),kr=e=>{const t=e.querySelectorAll(`[${ur}="${br}"]`);Array.from(t).forEach(e=>{e?.remove()})},Pr=(e,t)=>{const i=e.querySelector(`[${ur}="${vr}"]`),o=e.querySelector(`[${ur}="${Ar}"]`);if(!i||!o)return;kr(e);const{currentDirector:r,prevDirector:a,styles:n}=t;if(a||r){const e=((e,t)=>{const{styles:i}=t,o=`\n <svg\n width="100%"\n height="100%"\n overflow="visible"\n xmlns="http://www.w3.org/2000/svg" \n ${yt}="true"\n >\n ${e.map(e=>{if(!e)return"";const{anchorPoint:t,directPoint:o}=e,r=t.x,a=t.y;return`<line \n x1="${r}" \n x2="${o.x}" \n y1="${a}" \n y2="${o.y}" \n stroke="${i.directorLineColor}" \n stroke-width="2" \n ${yt}="true"\n />`}).join("")}\n </svg>\n `;return rt("div",{width:"100%",height:"100%",className:rr.directorLines,[ur]:br,[yt]:"true"},[at(o)])})([a,r],{styles:n});i.firstElementChild&&i.insertBefore(e,o)}},Tr=e=>{if(!e)return;const t=e.querySelectorAll(`[${ur}="${Sr}"]`);Array.from(t).forEach(e=>{e?.remove()}),kr(e)},Nr=(e,t)=>{const{selectedAnchorId:i,prevDirector:o,currentDirector:r,styles:a}=t,n=[];o&&n.push(o),r&&n.push(r);const s=Array.from(e.querySelectorAll(`[${ur}="${Sr}"]`));let l=!1;if(n.length===s.length)for(let e=0;e<s.length;e++){const t=s[e],o=n[e],r=Br(s[e]);if(r.openedAnchorId!==i||r.fromAnchorId!==o.anchorId){l=!0;break}it(t,Lr({x:o.directPoint.x,y:o.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth}))}else l=!0;l&&Dr(e,{prevDirector:o,currentDirector:r,styles:a})},Dr=(e,t)=>{if(!e)return;const i=e.querySelector(`[${ur}="${vr}"]`);if(!i)return;Tr(e),Pr(e,t);const{currentDirector:o,prevDirector:r,styles:a}=t;if(r){const e=rt("div",{[ur]:Sr,[yr]:"curve-ctrl2",[pr]:r.anchorId,[xr]:r.openedByAnchorId,[yt]:"true",className:rr.director,style:{...Lr({x:r.directPoint.x,y:r.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth})}});i.appendChild(e)}if(o){const e=rt("div",{[ur]:Sr,[yr]:"curve-ctrl1",[pr]:o.anchorId,[xr]:o.openedByAnchorId,[yt]:"true",className:rr.director,style:{...Lr({x:o.directPoint.x,y:o.directPoint.y,size:a.directorSize,borderWidth:a.directorBorderWidth})}});i.appendChild(e)}},$r=(e,t)=>{if(!e)return;const i=e.querySelector(`[${ur}="${vr}"]`);if(!i)return;const o=rt("div",{className:rr.pathLine,[ur]:Ar,[yt]:"true"});i.firstElementChild&&i.insertBefore(o,i.firstElementChild),Wr(e,t)},Hr=(e,t)=>{const i=e.querySelector(`[${ur}="${Ar}"]`);if(!i)return;const o=i.querySelector(`[${ur}="${Mr}"]`);if(o){const{anchorCommands:e}=t;ot(o,{d:de(e)})}else Wr(e,t)},Wr=(e,t)=>{const i=e.querySelector(`[${ur}="${Ar}"]`);if(!i)return;i?.children&&Array.from(i.children).forEach(e=>{e.remove()});const{anchorCommands:o,styles:r}=t;ot(i,{},[at(`\n <svg \n width="100%" \n height="100%" \n overflow="visible" \n fill="transparent"\n ${yt}="true"\n >\n <path \n ${ur}="${Mr}" \n d="${de(o)}" \n stroke="${r.helperStrokeColor}"\n stroke-width="${r.helperStrokeWidth}"\n ${yt}="true"\n />\n </svg>\n `)])};function Or(e,t){const{pageX:i,pageY:o}=e,r=t.getBoundingClientRect(),a=window.scrollX||document.documentElement.scrollLeft,n=window.scrollY||document.documentElement.scrollTop;return{x:i-(r.left+a),y:o-(r.top+n)}}function Yr(e,t){const{calculator:i}=t,{id:o}=e;return[...i.getVirtualItem(o).anchorCommands||[]]}var Vr="idraw-middleware-path-creator",jr={hide:`${Vr}-hide`,anchor:`${Vr}-anchor`,director:`${Vr}-director`,directorLines:`${Vr}-director-lines`,pathLine:`${Vr}-path-line`,selected:`${Vr}-selected`},Gr="data-x",Fr="data-y",Xr="data-helper-type",Qr="data-anchor-cmd-type",Ur="data-anchor-index",Zr="data-anchor-id",Jr="anchor",Kr={anchorSize:8,anchorBorderWidth:2,anchorBorderColor:"#157ed1",anchorBackground:"#ffffff",anchorHoverBorderColor:"#1671b8",anchorHoverBackground:"#cfe4f4",anchorActiveBorderColor:"#0d548c",anchorActiveBackground:"#88c0ec",defaultStroke:"#a0a0a0",defaultStrokeWidth:2};function qr(e){return N(e,["anchorSize","anchorBorderWidth","anchorBorderColor","anchorBackground","anchorHoverBorderColor","anchorHoverBackground","anchorActiveBorderColor","anchorActiveBackground","defaultStroke","defaultStrokeWidth"])}var _r=e=>{const{x:t,y:i,size:o,borderWidth:r}=e;return{left:t-o/2-r,top:i-o/2-r}};function ea(e,t){const{point:i,viewScaleInfo:o,styles:r}=t,a=Array.from(e.querySelectorAll(`[${Xr}="${Jr}"]`)),n=a.length,s=Xe(),l=function(e){const{id:t,index:i,point:o,commandType:r,viewScaleInfo:a,styles:n}=e,s=ae(o,{viewScaleInfo:a});return rt("div",{[Xr]:Jr,[Qr]:r,[Ur]:i,[Zr]:t,[yt]:"true",[Gr]:o.x,[Fr]:o.y,className:jr.anchor,style:{..._r({x:s.x,y:s.y,size:n.anchorSize,borderWidth:n.anchorBorderWidth}),display:"block"}})}({index:n,id:s,point:i,styles:r,viewScaleInfo:o,commandType:0===n?"M":"C"});return 0===n?e.appendChild(l):a[a.length-1].after(l),{id:s}}function ta(e,t){const{viewScaleInfo:i,styles:o}=t;Array.from(e.querySelectorAll(`[${Xr}="${Jr}"]`)).forEach(e=>{const t={id:(r=e).getAttribute(Zr)||"",type:r.getAttribute(Xr)||"",x:parseFloat(r.getAttribute(Gr)||"0"),y:parseFloat(r.getAttribute(Fr)||"0")};var r;it(e,_r({...ae({x:t.x,y:t.y},{viewScaleInfo:i}),size:o.anchorSize,borderWidth:o.anchorBorderWidth}))})}var ia="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAApCAYAAABHomvIAAAACXBIWXMAAAsTAAALEwEAmpwYAAAF92lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNi4wLWMwMDYgNzkuMTY0NzUzLCAyMDIxLzAyLzE1LTExOjUyOjEzICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbn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YsgNgcGRl5CCY+wfu3oVzrY2EXDivMc4NaPAMQrSxIhwQif4oK9z+en5F3CriecA7U/E2rB4AcxQcKBI/udwR5SStFKKuuayagLFqPyOeVnGmOkCOVY6crx5KMNSX0L5QSqWyOutbVvRQXk/wiE0qeA2qKq4lnbJY2AAAAAElFTkSuQmCC"};#ge={};constructor(e,t){this.#ce=e,this.#X=t.eventHub,this.#S(),this.#me(),Object.keys(this.#fe).forEach(e=>{const t=`${oa}-${e}`;this.#ge[e]=t;const i=this.#fe[e];this.#pe(e,t,i)})}#pe(e,t,i){const{offsetX:o,offsetY:r}=this.#ye(e);mt({rootClassName:t,type:"element",styles:{cursor:`image-set(url(${i})2x) ${o} ${r}, auto`}})}#S(){const e=this.#X;this.#xe("default"),e.on(o.CURSOR,e=>{"over-material"!==e.type&&e.type?"resize-rotate"===e.type?this.#xe("rotate"):"string"==typeof e.type&&e.type?.startsWith("resize-")?this.#ve(e):"drag-default"===e.type?this.#xe("drag-default"):"drag-active"===e.type?this.#xe("drag-active"):"pen"===e.type?this.#xe("pen"):"plus"===e.type?this.#xe("plus"):this.#xe("auto"):this.#xe("auto")})}#me(){g(ia).then(e=>{this.#ue=e}).catch(e=>{console.error(e)})}#ye(e){let t=0,i=0;return e.startsWith("rotate-")&&this.#fe[e]||"rotate"===e?(t=10,i=10):"plus"===e&&(t=5,i=3),{offsetX:t,offsetY:i}}#xe(e){if(this.#de===e)return;this.#de=e;const t=this.#ce,i=this.#ge[e]||this.#ge.auto;tt(t,Object.keys(this.#ge).map(e=>this.#ge[e])),et(t,[i])}#ve(e){let t=0;"resize-top"===e.type?t+=0:"resize-top-right"===e.type?t+=45:"resize-right"===e.type?t+=90:"resize-bottom-right"===e.type?t+=135:"resize-bottom"===e.type?t+=180:"resize-bottom-left"===e.type?t+=225:"resize-left"===e.type?t+=270:"resize-top-left"===e.type&&(t+=315),t+=X(e?.material?.angle||0),Array.isArray(e.groupQueue)&&e.groupQueue.length>0&&e.groupQueue.forEach(e=>{t+=X(e.angle||0)}),t=X(t);const i=this.#we(t);this.#xe(i)}#we(e){const t=`rotate-${e}`;if(!this.#fe[t]){const i=this.#ue;if(i){const o=document.createElement("canvas"),r=i.width,a=i.height,n={x:r/2,y:a/2};o.width=r,o.height=a;const s=o.getContext("2d"),l=D(e);s.translate(n.x,n.y),s.rotate(l),s.translate(-n.x,-n.y),s.drawImage(i,0,0,r,a),s.translate(n.x,n.y),s.rotate(-l),s.translate(-n.x,-n.y);const h=o.toDataURL("image/png");this.#fe[t]=h;const c=`${oa}-${t}`;this.#ge[t]=c,this.#pe(t,c,h)}}return t}};function aa(e){const{modifiedMaterial:t,beforeMaterial:i}=e,{id:o,...r}=t,a=ve(r);let n={};return Object.keys(a).forEach(e=>{let t=Ae(i,e);void 0===t&&/(cornerRadius|strokeWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=Ae(i,e)),n[e]=t}),n=ve(n),{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:o,before:n,after:a}}}return e.Board=Qt,e.Calculator=Wt,e.Core=class{#Se;#be;#ce;constructor(e,t){const{devicePixelRatio:i=1,width:o,height:r,disableWatcher:a=!1}=t;it(e,{width:o,height:r}),this.#ce=e;const n=document.createElement("canvas");n.setAttribute("tabindex","0"),it(n,{margin:0,padding:0}),this.#be=n,this.#Ae(),e.appendChild(n);const s=new Qt({boardContent:E(n,{width:o,height:r,devicePixelRatio:i}),container:e,disableWatcher:a}),l=s.getSharer();l.setActiveViewSizeInfo({width:o,height:r,devicePixelRatio:i,contextWidth:o,contextHeight:r}),this.#Se=s,this.resize(l.getActiveViewSizeInfo()),new ra(e,{eventHub:s.getEventHub()})}isDestroyed(){return this.#Se.isDestroyed()}destroy(){this.#Se.destroy(),this.#be.remove()}#Ae(){it(this.#ce,{position:"relative",margin:"0px",padding:"0px",overflow:"hidden"})}use(e,t){this.#Se.use(e,t)}disuse(e){this.#Se.disuse(e)}resetMiddlewareConfig(e,t){this.#Se.resetMiddlewareConfig(e,t)}#Me(e){Q(e?.materials||[]),this.#Se.setData(e)}setData(e){this.#Se.getRenderer().getLoader().reset(),this.#Me(e)}getData(){return this.#Se.getData()}scale(e){this.#Se.scale(e),this.#Se.getViewer().drawFrame()}resize(e){const t=this.#Se,i=this.#ce,o={...t.getSharer().getActiveViewSizeInfo(),...e},{width:r,height:a}=o;it(i,{width:r,height:a}),t.resize(o)}clear(){this.#Se.clear()}on(e,t){this.#Se.getEventHub().on(e,t)}off(e,t){this.#Se.getEventHub().off(e,t)}trigger(e,t){this.#Se.getEventHub().trigger(e,t)}getViewInfo(){const e=this.#Se.getSharer();return{viewSizeInfo:e.getActiveViewSizeInfo(),viewScaleInfo:e.getActiveViewScaleInfo()}}refresh(){this.#Se.getViewer().drawFrame()}forceRender(){const e=this.#Se.getRenderer(),t=e.getCalculator(),i=e.getLoader(),o=this.getData();if(o){const{viewScaleInfo:e,viewSizeInfo:i}=this.getViewInfo();t.resetVirtualItemMap(o,{viewScaleInfo:e,viewSizeInfo:i})}i.reset(),this.refresh()}setViewScale(e){this.#Se.updateViewScaleInfo(e)}getLoadItemMap(){return this.#Se.getRenderer().getLoadItemMap()}onBoardWatcherEvents(){this.#Se.onWatcherEvents()}offBoardWatcherEvents(){this.#Se.offWatcherEvents()}createMaterial(e,t,i){const{viewScaleInfo:o,viewSizeInfo:r}=this.getViewInfo();return Le(e,t||{},!0===i?.viewCenter?{viewScaleInfo:o,viewSizeInfo:r}:void 0)}updateMaterial(e){const t=this.getData()||{materials:[]},i=e.id,o=_(i,t.materials),r=q(o,t.materials);if(!r)return null;const a=ve(r),n=ve(Ne(o,e,t.materials,{onlyUpdateContent:!0}));return this.#Se.getRenderer().getLoader().resetMaterialAsset(e),this.#Me(t),this.refresh(),{type:"updateMaterial",time:Date.now(),content:{method:"updateMaterial",id:i,before:a,after:n}}}modifyMaterial(e){const{id:t,...i}=e,o=this.getData()||{materials:[]},r=_(t,o.materials),a=q(r,o.materials);if(!a)return null;const n=aa({modifiedMaterial:e,beforeMaterial:a});return Ne(r,i,o.materials),this.#Se.getRenderer().getLoader().resetMaterialAsset({...e,type:a.type}),this.#Me(o),this.refresh(),n}modifyMaterials(e){const t=this.getData()||{materials:[]};let i=null;const o=[],r=[];return e.forEach(e=>{const{id:i,...a}=e,n=_(i,t.materials),s=q(n,t.materials);if(!s)return null;const l=aa({modifiedMaterial:e,beforeMaterial:s});l.content&&(o.push({...l.content.before,id:i}),r.push({...l.content.after,id:i})),Ne(n,a,t.materials)}),i={type:"modifyMaterials",time:Date.now(),content:{method:"modifyMaterials",before:o,after:r}},this.#Me(t),this.refresh(),i}addMaterial(e,t){const i=this.getData()||{materials:[]};t&&t?.position?.length?t?.position&&Be(e,[...t?.position||[]],i.materials):i.materials.push(e);const o=_(e.id,i.materials),r={type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:e.id,position:o,material:c(e)}};return this.#Me(i),this.refresh(),r}deleteMaterial(e){const t=this.getData()||{materials:[]},i=_(e,t.materials),o=q(i,t.materials),r={type:"deleteMaterial",time:Date.now(),content:{method:"deleteMaterial",id:e,position:i,material:o?c(o):null}};return o&&this.#Se.getRenderer().getLoader().resetMaterialAsset(o),function(e,t){ke(_(e,t),t)}(e,t.materials),this.#Me(t),this.refresh(),r}moveMaterial(e,t){const i=this.getData()||{materials:[]},o=_(e,i.materials),r={type:"moveMaterial",time:Date.now(),content:{method:"moveMaterial",id:e,from:[...o],to:[...t]}},{materials:a}=function(e,t){const i=[...t.from],o=[...t.to];if(0===i.length||0===o.length)return{materials:e,from:i,to:o};if(i.length<=o.length)for(let t=0;t<i.length;t++)if(o[t]===i[t]){if(t===i.length-1)return{materials:e,from:i,to:o};continue}const r=q(i,e);if(r){if(!Be(r,o,e))return{materials:e,from:i,to:o};let t=-1;const a="down";let n=!1;if(i.length>=1&&o.length>=1){if(i.length<=o.length)if(1===i.length)i[0]<o[0]&&(n=!0);else for(let e=0;e<i.length&&i[e]===o[e];e++)if(i.length===i.length-1){n=!0;break}if(i.length>=o.length)if(1===o.length)o[0]<i[0]&&(n=!0);else for(let e=0;e<o.length&&(e===o.length-1&&o[e]<i[e]&&(n=!0),i[e]===o[e]);e++);}if(!0===n)for(let e=0;e<i.length&&o[e]>=0;e++)o[e]!==i[e]&&o[e]<i[e]&&e==o.length-1&&(t=e);t>=0&&"down"===a&&(i[t]=i[t]+1),ke(i,e)}return{materials:e,from:i,to:o}}(i.materials,{from:o,to:t});return i.materials=a,this.#Me(i),this.refresh(),r}modifyLayout(e){const t=this.getData()||{materials:[]},i={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:null,after:null}};if(null===e)return t.layout?(i.content.before=we(t.layout),delete t.layout,this.#Me(t),this.refresh(),i):i;const o=t.layout;let r={};const a=we(e);return t.layout?(Object.keys(a).forEach(e=>{let t=Ae(o,e);void 0===t&&/(cornerRadius|strokeWidth)\[[0-9]{1,}\]$/.test(e)&&(e=e.replace(/\[[0-9]{1,}\]$/,""),t=Ae(o,e)),r[e]=t}),r=we(r),i.content.before=r):t.layout={},i.content.after=a,function(e,t,i){const o=we(t),r=[],a=Object.keys(o);if(a.forEach(t=>{if(!r.includes(t)){const i=o[t];Ie(e,t),void 0!==i&&Me(e,t,i)}}),!0===i?.strict){const t=we(e);Object.keys(t).forEach(t=>{r.includes(t)||a.includes(t)||Ie(e,t)})}}(t.layout,e),this.#Me(t),this.refresh(),i}modifyGlobal(e){const t=this.getData()||{materials:[]},i={type:"modifyGlobal",time:Date.now(),content:{method:"modifyGlobal",before:null,after:null}};if(null===e)return t.global?(i.content.before=Se(t.global),delete t.global,this.#Me(t),this.refresh(),i):i;const o=t.global;let r={};const a=Se(e);return t.global?(Object.keys(a).forEach(e=>{r[e]=Ae(o,e)}),r=Se(r),i.content.before=r):t.global={},i.content.after=a,function(e,t,i){const o=Se(t),r=[],a=Object.keys(o);if(a.forEach(t=>{if(!r.includes(t)){const i=o[t];Ie(e,t),void 0!==i&&Me(e,t,i)}}),!0===i?.strict){const t=Se(e);Object.keys(t).forEach(t=>{r.includes(t)||a.includes(t)||Ie(e,t)})}}(t.global,e),this.#Me(t),this.refresh(),i}},e.MiddlewareCreator=(e,t)=>{const{sharer:i,viewer:r,calculator:a,eventHub:n}=e;let s={..._t,...ei,...t};const l=ii(s),h=`${qt}-${Xe()}`;let d=null,u=null;const f=()=>{i.setSharedStorage(Zt,null),i.setSharedStorage(Jt,null),u=null};f();let g=!1;const m=({type:e})=>{g=!0,d&&(n.trigger(o.CURSOR,{type:"plus"}),i.setSharedStorage(Kt,e),et(d,[ti.creative]),n.trigger(o.CLEAR_SELECT))},p=()=>{n.trigger(o.CURSOR,{type:"auto"}),g=!1,d&&tt(d,[ti.creative])};return{name:"@middleware/creator",use(){!function(e,t){const i=e=>`.${e}`;mt({styles:{display:"none",zIndex:t.zIndex,position:"absolute",background:"transparent",top:0,bottom:0,left:0,right:0,overflow:"hidden",[`&${i(ti.creative)}`]:{display:"block"},[i(ti.creationAreaBox)]:{position:"absolute",outline:`1.5px solid ${t.creationAreaBorderColor}`,background:"#0000ff1f"}},rootClassName:e,type:"element"})}(h,l),d=function(e){const{rootClassName:t,$container:i}=e,o=rt("div",{className:t,[yt]:"true"},[]);return i.appendChild(o),o}({rootClassName:h,$container:e.container}),n.on(o.CREATE,m),n.on(o.CLEAR_CREATE,p)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),d?.remove(),d=null,n.trigger(o.CURSOR,{type:"auto"}),n.off(o.CREATE,m),n.off(o.CLEAR_CREATE,p)},resetConfig(e){s={...s,...e}},pointStart:e=>{f(),g&&i.setSharedStorage(Zt,e.point)},pointMove:e=>{if(!g)return;i.setSharedStorage(Jt,e.point);const t=i.getSharedStorage(Kt),o=i.getSharedStorage(Zt),n=i.getSharedStorage(Jt),s=i.getActiveViewScaleInfo(),l=i.getActiveViewSizeInfo(),h=i.getActiveStorage("data");u&&o&&n?(u=function(e,t){const i=ai(t),{type:o}=e,r={...e,...i};return"circle"===o?r.r=Math.min(i.width,i.height)/2:"ellipse"===o?(r.rx=i.width/2,r.ry=i.height/2):"text"===o&&(r.fontSize=Math.min(i.width,i.height)),r}(u,{start:o,end:n,viewScaleInfo:s,calculator:a}),Te(u.id,u,h.materials),a.modifyVirtualAttributes(u,{viewScaleInfo:s,viewSizeInfo:l,groupQueue:[]})):t&&o&&n&&(u=function(e,t){const{fill:i,text:o,href:r}=pe(),a={fill:i};return"circle"===e?a.r=1:"ellipse"===e?(a.rx=1,a.ry=1):"text"===e?(a.text=o,a.fontSize=1):"image"===e?a.href=r:"group"===e&&(a.children=[]),{id:Xe(),type:e,...a,...ai(t)}}(t,{start:o,end:n,viewScaleInfo:s,calculator:a}),h.materials.push(u),a.resetVirtualItemMap(h,{viewScaleInfo:s,viewSizeInfo:l})),r.drawFrame()},pointEnd:()=>{if(g){if(u){const e=i.getActiveStorage("data");ni(n,{data:e,type:"addMaterial",modifyRecord:{type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:u.id,position:[e.materials?.length],material:c(u)}}},"all")}if(!0===s.selectAfterCreated&&u?.id){const e=u.id;n.trigger(o.SELECT,{ids:[e],type:"selectMaterial"})}s.afterCreated?.(),oi(d),p(),f()}},beforeDrawFrame(){const e=i.getSharedStorage(Zt),t=i.getSharedStorage(Jt);e&&t?ri(d,{start:e,end:t}):oi(d)}}},e.MiddlewareDragger=e=>{const{eventHub:t,sharer:i,viewer:r}=e;let a=!1;return{name:"@middleware/dragger",hover(){!0!==a&&t.trigger(o.CURSOR,{type:"drag-default"})},pointStart(e){const{point:r}=e;i.setSharedStorage(ir,r),a=!0,t.trigger(o.CURSOR,{type:"drag-active"})},pointMove(e){const{point:t}=e,o=i.getSharedStorage(ir);if(t&&o){const e=t.x-o.x,i=t.y-o.y;r.scroll({moveX:e,moveY:i}),r.drawFrame()}i.setSharedStorage(ir,t)},pointEnd(){a=!1,i.setSharedStorage(ir,null),t.trigger(o.CURSOR,{type:"drag-default"})}}},e.MiddlewareInfo=(e,t)=>{const{boardContent:i,calculator:o,eventHub:r}=e,{overlayContext:a}=i;let s={...ho,...t};const l=co(s);let h=!0;const c=({show:e})=>{h=e};return{name:"@middleware/info",use(){r.on(lo,c)},disuse(){r.off(lo,c)},resetConfig(e){s={...s,...e}},beforeDrawFrame({snapshot:e}){const{sharedStore:t}=e,i=t[zi],r=t[Ai],s=t[Bi]||[];if(1===i?.length){const t=i[0];if(t&&["select","drag","resize"].includes(r)){const i=P(e),r=T(e),{x:c,y:d,width:u,height:f,angle:g}=t,m=[...s,{id:n(),x:c,y:d,width:u,height:f,angle:g,type:"group",children:[]}],p={viewScaleInfo:i,viewSizeInfo:r},y=o.calcViewBoundingInfoFromOrigin(t.id,p);let x=0;m.forEach(e=>{x+=e.angle||0});const v=D(X(0-x));if(y){const e=y?.center,i={topLeft:Y(e,y.topLeft,v),topRight:Y(e,y.topRight,v),bottomRight:Y(e,y.bottomRight,v),bottomLeft:Y(e,y.bottomLeft,v),center:Y(e,y.center,v),top:Y(e,y.top,v),right:Y(e,y.right,v),bottom:Y(e,y.bottom,v),left:Y(e,y.left,v)},o=ue(t.x,{decimalPlaces:2}),r=ue(t.y,{decimalPlaces:2}),n=ue(t.width,{decimalPlaces:2}),s=ue(t.height,{decimalPlaces:2}),c=`${ue(o,{decimalPlaces:0})},${ue(r,{decimalPlaces:0})}`,d=`${ue(n,{decimalPlaces:0})}x${ue(s,{decimalPlaces:0})}`,u=`${ue(X(t.angle||0),{decimalPlaces:0})}°`;!function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textColor:h,textBackground:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:so});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x-o/2-t,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x-o/2,y:i.y};e.setLineDash([]),e.fillStyle=c,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=h,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.bottom.x,y:i.bottom.y+uo},rotateCenter:i.center,angle:x,text:d,fontSize:uo,lineHeight:16,styles:l}),function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textBackground:h,textColor:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:so});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.topLeft.x,y:i.topLeft.y-20},rotateCenter:i.center,angle:x,text:c,fontSize:uo,lineHeight:16,styles:l}),h&&!1!==t.operations?.rotatable&&function(e,t){const{point:i,rotateCenter:o,angle:r,text:a,styles:n,fontSize:s,lineHeight:l}=t,{textBackground:h,textColor:c}=n;$(e,r,o,()=>{e.$setFont({fontWeight:"300",fontSize:s,fontFamily:so});const t=(l-s)/2,o=e.$undoPixelRatio(e.measureText(a).width),r={x:i.x,y:i.y},n={x:r.x+o+2*t,y:r.y+s+t},d={x:i.x+t,y:i.y};e.setLineDash([]),e.fillStyle=h,e.beginPath(),e.moveTo(r.x,r.y),e.lineTo(n.x,r.y),e.lineTo(n.x,n.y),e.lineTo(r.x,n.y),e.closePath(),e.fill("nonzero"),e.fillStyle=c,e.textBaseline="top",e.fillText(a,d.x,d.y+t)})}(a,{point:{x:i.top.x+uo+4,y:i.top.y-20-18},rotateCenter:i.center,angle:x,text:u,fontSize:uo,lineHeight:16,styles:l})}}}}}},e.MiddlewareLayoutSelector=(e,t)=>{const{sharer:i,calculator:r,viewer:a,eventHub:n}=e;let s={...oo,...t};const l=function(e){return N(e,["zIndex","activeColor","handlerBorderColor","handlerBackground","handlerHoverBackground","handlerActiveBackground"])}(s),h=`${eo}-${Xe()}`;let c=null,d=null,u=null,f=null;const g=()=>{c=null,i.setSharedStorage(Ui,null),i.setSharedStorage(Zi,null),i.setSharedStorage(Ji,null),i.setSharedStorage(Ki,null),i.setSharedStorage(qi,null),i.setSharedStorage(_i,null),d=null,u=null},m=()=>{const e=i.getSharedStorage(Ai);return!(!e||"area"===e)&&(g(),!0)},p=()=>{const e=i.getActiveStorage("data");if(e?.layout){const{x:t,y:i,width:o,height:r}=e.layout;return{x:t,y:i,width:o,height:r}}return null},y=e=>{const t=p();if(t){const{x:o,y:r,width:a,height:n}=t;return le(e,re({x:o-5,y:r-5,width:a+10,height:n+10},{viewScaleInfo:i.getActiveViewScaleInfo()}))}return!1},x=e=>{const t=i.getActiveStorage("data"),r=e.nativeEvent.target;let a=null;if(r?.hasAttribute("data-idraw-handler-type")&&t?.layout&&e?.point){i.setSharedStorage(Zi,null);const e=r.getAttribute(to);e&&(i.setSharedStorage(Zi,e),n.trigger(o.CLEAR_SELECT),a=e)}return a?i.setSharedStorage(Ki,!0):i.setSharedStorage(Ki,!1),a},v=e=>{!0!==i.getSharedStorage(_i)&&n.trigger(o.CURSOR,{type:e?`resize-${e}`:e,groupQueue:[],material:p()})};return{name:"@middleware/layout-selector",use:()=>{g(),function(e,t){const i=e=>`.${e}`;mt({styles:{zIndex:t.zIndex,position:"absolute",background:"transparent",[`&${i(ro.hover)}`]:{[`&${i(ro.cornerHandler)}`]:{display:"none"},[`&${i(ro.edgeHandler)}`]:{width:"1px",height:"1px",[`&${i(ro.edgeLeftHandler)}`]:{width:"1px"},[`&${i(ro.edgeRightHandler)}`]:{width:"1px"},[`&${i(ro.edgeTopHandler)}`]:{height:"1px"},[`&${i(ro.edgeBottomHandler)}`]:{height:"1px"}}},[`&${i(ro.cornerHandler)}`]:{outline:`1.5px solid ${t.handlerBorderColor}`,background:t.handlerBackground,width:"10px",height:"10px",top:"unset",bottom:"unset",left:"unset",right:"unset","&:hover":{background:t.handlerHoverBackground},"&:active":{background:t.handlerActiveBackground},[`&${i(ro.cornerTopLeftHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(ro.cornerTopRightHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(ro.cornerBottomLeftHandler)}`]:{transform:"translate(-50%, -50%)"},[`&${i(ro.cornerBottomRightHandler)}`]:{transform:"translate(-50%, -50%)"}},[`&${i(ro.edgeHandler)}`]:{width:"10px",height:"10px","&:after":{position:"absolute",content:"\"\"",background:t.handlerBorderColor},[`&${i(ro.edgeLeftHandler)}`]:{width:"10px",transform:"translateX(-50%)","&:after":{top:0,bottom:0,left:"50%",right:"unset",width:io}},[`&${i(ro.edgeRightHandler)}`]:{width:"10px",transform:"translateX(-50%)","&:after":{top:0,bottom:0,left:"50%",right:"unset",width:io}},[`&${i(ro.edgeTopHandler)}`]:{height:"10px",transform:"translateY(-50%)","&:after":{left:0,right:0,top:"50%",bottom:"unset",height:io}},[`&${i(ro.edgeBottomHandler)}`]:{height:"10px",transform:"translateY(-50%)","&:after":{left:0,right:0,top:"50%",bottom:"unset",height:io}}}},rootClassName:e,type:"element"})}(h,l)},disuse:()=>{g(),function(e){pt({rootClassName:e,type:"element"})}(h)},resetConfig(e){s={...s,...e}},hover:e=>{if(!0===i.getSharedStorage(_i))return;y(e.point)?i.setSharedStorage(Ji,!0):(i.setSharedStorage(Ji,!1),!0===d&&(a.drawFrame(),d=!1));const t=i.getSharedStorage(Ui);if(i.getActiveStorage("data")?.layout)if("resize"!==t){const t=x(e);t?v(t):(v(),i.setSharedStorage(Ui,null))}else v(x(e))},pointStart:t=>{y(t.point)?i.setSharedStorage(qi,!0):(!0===u&&(e.container&&ao(e.container,{rootClassName:h}),g(),a.drawFrame()),i.setSharedStorage(qi,!1));const r=i.getActiveStorage("data");f=r?.layout?K(r.layout):null;const s=x(t);if(c=t.point,s&&i.setSharedStorage(Ui,"resize"),!0!==i.getSharedStorage(qi)||u||(a.drawFrame(),n.trigger(o.SELECT_LAYOUT)),u=i.getSharedStorage(qi),!0===i.getSharedStorage(Ki))return!1},pointMove:e=>{if(!i.getSharedStorage(qi)&&m())return;const t=i.getSharedStorage(Ui),o=i.getSharedStorage(Zi),n=i.getActiveStorage("data");if("resize"===t&&o&&n?.layout){if(c){i.setSharedStorage(_i,!0);const t=i.getActiveStorage("scale"),s=e.point.x-c.x,l=e.point.y-c.y,h=s/t,d=l/t,{x:u,y:f,width:g,height:m,operations:p={}}=n.layout,{position:y="absolute"}=p;"top"===o?"relative"===y?(n.layout.height=r.toGridNum(m-d),a.scroll({moveY:l})):(n.layout.y=r.toGridNum(f+d),n.layout.height=r.toGridNum(m-d)):"right"===o?n.layout.width=r.toGridNum(g+h):"bottom"===o?n.layout.height=r.toGridNum(m+d):"left"===o?"relative"===y?(n.layout.width=r.toGridNum(g-h),a.scroll({moveX:s})):(n.layout.x=r.toGridNum(u+h),n.layout.width=r.toGridNum(g-h)):"top-left"===o?"relative"===y?(n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m-d),a.scroll({moveX:s,moveY:l})):(n.layout.x=r.toGridNum(u+h),n.layout.y=r.toGridNum(f+d),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m-d)):"top-right"===o?"relative"===y?(a.scroll({moveY:l}),n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m-d)):(n.layout.y=r.toGridNum(f+d),n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m-d)):"bottom-right"===o?(n.layout.width=r.toGridNum(g+h),n.layout.height=r.toGridNum(m+d)):"bottom-left"===o&&("relative"===y?(a.scroll({moveX:s}),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m+d)):(n.layout.x=r.toGridNum(u+h),n.layout.width=r.toGridNum(g-h),n.layout.height=r.toGridNum(m+d)))}return c=e.point,a.drawFrame(),!1}return!["resize"].includes(t)&&void 0},pointEnd:()=>{i.setSharedStorage(_i,!1);const e=i.getSharedStorage(Ui),t=i.getSharedStorage(Zi),o=i.getActiveStorage("data");if(o&&"resize"===e&&t){let e;f&&(e={type:"modifyLayout",time:Date.now(),content:{method:"modifyLayout",before:we(f),after:we(K(o.layout))}}),ni(n,{type:"resizeLayout",data:o,modifyRecord:e})}if(f=null,i.setSharedStorage(Ui,null),i.setSharedStorage(Zi,null),!0===i.getSharedStorage(Ki))return!1},beforeDrawFrame:({snapshot:t})=>{if(m())return;const{activeStore:o}=t,r=i.getActiveViewScaleInfo();e.container&&o.data?.layout&&no(e.container,{rootClassName:h,viewScaleInfo:r,layout:o.data?.layout,hover:!1})}}},e.MiddlewarePathCreator=(e,t)=>{const i={...Kr,...t},{defaultStrokeWidth:r,defaultStroke:a}=i,s=qr(i),l=`${Vr}-${Xe()}`,{viewer:h,eventHub:d,sharer:u,calculator:f}=e,g=e.container,m=l;let p=null,y=-1,x=null,v=null;const w=()=>{!function(e){e&&Array.from(e.children).forEach(e=>{e.remove()})}(p),v=null,x=null,y=-1},S=()=>{if(!x)return;x=Ke(x);const e=u.getActiveStorage("data");Te(x.id,{x:x.x,y:x.y,width:x.width,height:x.height,commands:x.commands},e.materials),f.modifyVirtualAttributes(x,{viewScaleInfo:u.getActiveViewScaleInfo(),viewSizeInfo:u.getActiveViewSizeInfo(),groupQueue:[]}),f.forceVisiable(x.id),h.drawFrame()},b=e=>{const t=e.target;if(t.getAttribute(Xr)===Jr)return void(0===function(e){const t=e.getAttribute(Ur);return"string"==typeof t?parseInt(t):t}(t)&&y>1&&x&&(x.commands.push({id:Xe(),type:"Z",params:[]}),S(),w()));const i=nt(p),o={x:e.pageX-i.pageX,y:e.pageY-i.pageY},l=u.getActiveViewScaleInfo(),g=u.getActiveViewSizeInfo(),m=ne(o,{viewScaleInfo:l}),{id:b}=ea(p,{point:m,viewScaleInfo:l,styles:s});y<0||!x?(y=0,x={id:n(),type:"path",x:0,y:0,width:g.width,height:g.height,strokeWidth:r,stroke:a,commands:[{id:b,type:"M",params:[m.x,m.y]}]}):(y++,x.commands.push({...Je(v,m),id:b})),v=m,(()=>{if(!x)return;const e=u.getActiveStorage("data");y>0?Te(x.id,{x:x.x,y:x.y,width:x.width,height:x.height,commands:x.commands},e.materials):(e.materials.push(x),ni(d,{data:e,type:"addMaterial",modifyRecord:{type:"addMaterial",time:Date.now(),content:{method:"addMaterial",id:x.id,position:[e.materials?.length],material:c(x)}}})),f.modifyVirtualAttributes(x,{viewScaleInfo:u.getActiveViewScaleInfo(),viewSizeInfo:u.getActiveViewSizeInfo(),groupQueue:[]}),f.forceVisiable(x.id),h.drawFrame()})()},A=()=>{},M=()=>{window.removeEventListener("mousemove",A)},I=()=>{window.removeEventListener("mousemove",A)},C=()=>{p?.removeEventListener("mousedown",b),window.removeEventListener("mouseup",M),window.removeEventListener("mouseleave",I)},R=()=>{g&&(p=function(e,t){const{id:i,rootClassName:o}=t;if(!e)return;const r=rt("div",{id:i,className:[jr.hide,o].join(" "),[yt]:"true"});return e.contains(r)||e.appendChild(r),r}(g,{id:m,rootClassName:l}),g.contains(p)||g.appendChild(p))},z=()=>{p?.addEventListener("mousedown",b),window.addEventListener("mouseup",M),window.addEventListener("mouseleave",I),h.drawFrame()},E=()=>{S(),C(),w()};return{name:"@middleware/pen-create",use(){!function(e,t){mt({styles:{display:"flex",position:"absolute",top:0,left:0,right:0,bottom:0,overflow:"hidden",justifyContent:"center",alignItems:"center",[`.${jr.anchor}`]:{position:"absolute",width:t.anchorSize,height:t.anchorSize,background:t.anchorBackground,border:`${t.anchorBorderWidth}px solid ${t.anchorBorderColor}`,borderRadius:"50%",overflow:"hidden","&:hover":{borderColor:t.anchorHoverBorderColor,background:t.anchorHoverBackground},"&:active":{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground},[`&.${jr.selected}`]:{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground}}},rootClassName:e,type:"element"})}(l,s),d.on(o.PATH_CREATE,z),d.on(o.CLEAR_PATH_CREATE,E),R()},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(l),d.off(o.PATH_CREATE,z),d.off(o.CLEAR_PATH_CREATE,E),w(),h.drawFrame(),C(),p?.remove(),p=null},beforeDrawFrame(){ta(p,{viewScaleInfo:u.getActiveViewScaleInfo(),styles:s})},hover:()=>(d.trigger(o.CURSOR,{type:"pen"}),!1)}},e.MiddlewarePathEditor=(e,t)=>{const{viewer:i,eventHub:r,sharer:a,calculator:n}=e,s={...Ir,...t},{afterClickAway:l}=s,h=`${or}-${Xe()}`,c=Cr(s),d=e.container,u=`idraw-middleware-path-editor-${Xe()}`;let f=null,g=!1,m=!1,p=null,y=null,x=null,v=null,w=null,S=null,b=null,A=null,M=null,I=null;const C=()=>{R(),S=null,b=null,A=null},R=()=>{M=null,I=null},z=()=>{f&&Array.from(f.getElementsByClassName(rr.selected)).forEach(e=>{tt(e,[rr.selected])})},E=()=>{p=null,v=null,w=null},L=e=>{const t=e.target,o=t?.getAttribute(ur);"anchor"===o&&y?(e.stopPropagation(),e.preventDefault(),C(),w=K(y),v=Or(e,f),p="dragging-anchor",S=t,b=(e=>{const t=e.getAttribute(mr)||"";return{index:parseFloat(e.getAttribute(gr)||"0"),id:t}})(t),A=Yr(y,{calculator:n}),window.addEventListener("mousemove",B),et(S,[rr.selected]),i.drawFrame()):"director"===o&&y?(e.stopPropagation(),e.preventDefault(),R(),w=K(y),v=Or(e,f),p="dragging-director",M=t,I=Br(t),A=Yr(y,{calculator:n}),window.addEventListener("mousemove",B),et(M,[rr.selected]),i.drawFrame()):(W(),l?.())},B=e=>{if(v&&y&&w&&A){const t=Or(e,f),o=[...x||[],{...w,type:"group",id:y.id,angle:y.angle,children:[]}],{moveX:r,moveY:s}=He(v,t,o),l=a.getActiveStorage("scale")||1,h=n.toGridNum(r/l),c=n.toGridNum(s/l),d=[...A];if(S&&b&&"dragging-anchor"===p){const e=function(e,t){const i=[],{index:o,moveX:r,moveY:a}=t;e.forEach(e=>{const{id:t,type:o,params:r}=e,a={id:t,type:o,params:[...r]};i.push(a)});const n=i[o],s=i[o-1];if("start"===t.type){if(!s||!n)return Ze(i);switch("M"===n.type&&(n.params[0]+=r,n.params[1]+=a),"C"===n.type&&(n.params[0]+=r,n.params[1]+=a),s.type){case"M":case"L":case"Z":s.params[0]+=r,s.params[1]+=a;break;case"A":s.params[5]+=r,s.params[6]+=a;break;case"C":s.params[2]+=r,s.params[3]+=a,s.params[4]+=r,s.params[5]+=a}}return Ze(i)}(d,{type:"start",index:b.index,moveX:h,moveY:c}),t=a.getActiveStorage("data"),o=e.map(({id:e,type:t,params:i})=>({id:e,type:t,params:i}));Te(y.id,{commands:o},t.materials),y.commands=o,n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()}else if(M&&I&&"dragging-director"===p){const{type:e,fromAnchorId:t}=I,o=function(e,t){const i=[],{index:o,type:r,moveX:a,moveY:n}=t;e.forEach(e=>{const{id:t,type:o,params:r}=e,a={id:t,type:o,params:[...r]};i.push(a)});const s=i[o];return"C"===s.type&&("curve-ctrl1"===r?(s.params[0]+=a,s.params[1]+=n):"curve-ctrl2"===r&&(s.params[2]+=a,s.params[3]+=n)),Ze(i)}(d,{type:e,index:d.findIndex(e=>e.id===t),moveX:h,moveY:c}),r=a.getActiveStorage("data")||{materials:[]},s=o.map(({id:e,type:t,params:i})=>({id:e,type:t,params:i}));Te(y.id,{commands:s},r.materials),y.commands=s,n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()}}},k=()=>{!function(e){if(!e);}(f)},P=()=>{if(!y)return;y=Ke(y);const e=a.getActiveStorage("data")||{materials:[]};Te(y.id,{x:y.x,y:y.y,width:y.width,height:y.height,commands:y.commands},e.materials),n.modifyVirtualAttributes(y,{viewScaleInfo:a.getActiveViewScaleInfo(),viewSizeInfo:a.getActiveViewSizeInfo(),groupQueue:x||[]}),i.drawFrame()},T=()=>{window.removeEventListener("mousemove",B),P(),z(),E(),k()},N=()=>{window.removeEventListener("mousemove",B),P(),z(),E(),k()},D=()=>{d&&(f=function(e,t){const{id:i,rootClassName:o}=t;if(!e)return;const r=rt("div",{id:i,className:[rr.hide,o].join(" "),[yt]:"true"});return e.contains(r)||e.appendChild(r),r}(d,{id:u,rootClassName:h}),d.contains(f)||d.appendChild(f),g=!0)},$=()=>{f?.removeEventListener("mousedown",L),window.removeEventListener("mouseup",T),window.removeEventListener("mouseleave",N),m=!1,f?.remove(),f=null,g=!1},H=e=>{D();const{id:t}=e;if("string"==typeof t&&t){const{groupQueue:e,material:o}=Z(t,a.getActiveStorage("data").materials);if("path"===o?.type){y=o,x=[...e],((e,t)=>{const{material:i,calculator:o,viewScaleInfo:r,groupQueue:a,styles:n}=t;if(!e||!i)return;const{scale:s,offsetTop:l,offsetLeft:h}=r;e?.children&&Array.from(e.children).forEach(e=>{e.remove()}),tt(e,[rr.hide]);let c=e;for(let e=0;e<a.length;e++){const t=a[e],{x:i,y:o,width:r,height:n}=t,d={x:i*s,y:o*s,width:r*s,height:n*s,angle:X(t.angle||0)};0===e&&(d.x+=h,d.y+=l),c=Rr({size:d,parent:c},{[ar]:t.id,[nr]:t.x,[sr]:t.y,[lr]:t.width,[hr]:t.height,[cr]:t.angle,[dr]:t.type,[ur]:"group"})}let d=i.x*s+h,u=i.y*s+l,f=i.width*s,g=i.height*s;a.length>0&&(d=i.x*s,u=i.y*s,f=i.width*s,g=i.height*s);const m=rt("div",{[ar]:i.id,[nr]:i.x,[sr]:i.y,[lr]:i.width,[hr]:i.height,[cr]:i.angle,[dr]:i.type,[ur]:vr,[yt]:"true",style:{display:"inline-flex",flexDirection:"column",position:"absolute",left:d,top:u,width:f,height:g,transform:`rotate(${X(i.angle||0)}deg)`,boxSizing:"border-box",overflow:"visible",padding:"0",margin:"0",outline:"none"}}),p=Ue(o.getVirtualItem(i.id).anchorCommands||[],s,s);p.forEach((e,t)=>{const i=rt("div",{[ur]:wr,[fr]:e.type,[gr]:t,[mr]:e.id,[yt]:"true",className:rr.anchor,style:{...Er({x:e.start.x,y:e.start.y,size:n.anchorSize,borderWidth:n.anchorBorderWidth}),display:"M"===e.type?"none":"block"}});m.appendChild(i)}),c.appendChild(m),$r(e,{anchorCommands:p,material:i,viewScaleInfo:r,styles:n})})(f,{material:o,groupQueue:e,calculator:n,viewScaleInfo:a.getActiveViewScaleInfo(),styles:c}),m||(f?.addEventListener("mousedown",L),window.addEventListener("mouseup",T),window.addEventListener("mouseleave",N),m=!0);const t=a.getActiveOverrideMaterialMap()||{};t[o.id]={operations:{renderPathTrace:!0}},a.setActiveOverrideMaterialMap(t),i.drawFrame()}}},W=()=>{const e=a.getActiveOverrideMaterialMap()||{};delete e[y?.id],a.setActiveOverrideMaterialMap(e),y=null,E(),C(),$(),i.drawFrame()};return{name:"@middleware/pen-edit",use(){!function(e,t){mt({styles:{display:"flex",position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0,bottom:0,overflow:"hidden",justifyContent:"center",alignItems:"center",[`&.${rr.hide}`]:{display:"none"},[`.${rr.anchor}`]:{position:"absolute",width:t.anchorSize,height:t.anchorSize,background:t.anchorBackground,border:`${t.anchorBorderWidth}px solid ${t.anchorBorderColor}`,borderRadius:"50%",overflow:"hidden","&:hover":{borderColor:t.anchorHoverBorderColor,background:t.anchorHoverBackground},"&:active":{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground},[`&.${rr.selected}`]:{borderColor:t.anchorActiveBorderColor,background:t.anchorActiveBackground}},[`.${rr.director}`]:{position:"absolute",width:t.directorSize,height:t.directorSize,background:t.directorBackground,border:`${t.directorBorderWidth}px solid ${t.directorBorderColor}`,overflow:"hidden","&:hover":{borderColor:t.directorHoverBorderColor,background:t.directorHoverBackground},"&:active":{borderColor:t.directorActiveBorderColor,background:t.directorActiveBackground},[`&.${rr.selected}`]:{borderColor:t.directorActiveBorderColor,background:t.directorActiveBackground}},[`.${rr.directorLines}`]:{position:"absolute",left:0,right:0,top:0,bottom:0}},rootClassName:e,type:"element"})}(h,c),r.on(o.PATH_EDIT,H),r.on(o.CLEAR_PATH_EDIT,W)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),r.off(o.PATH_EDIT,H),r.off(o.CLEAR_PATH_EDIT,W)},beforeDrawFrame(){((e,t)=>{if(!e)return;const{material:i,viewScaleInfo:o,calculator:r,selectedAnchorId:a,styles:n}=t;if(!i)return;const{scale:s,offsetTop:l,offsetLeft:h}=o;let c=e.children[0],d=0;for(;["group","material"].includes(c?.getAttribute(ur));){"material"===c?.getAttribute(ur)&&(it(c,{width:i.width,height:i.height,left:i.x,top:i.y}),ot(c,{[lr]:i.width,[hr]:i.height,[nr]:i.x,[sr]:i.y}));const{x:e,y:t,w:o,h:r,angle:a}=zr(c),n={x:e*s,y:t*s,w:o*s,h:r*s,angle:a};if(0===d&&(n.x+=h,n.y+=l),it(c,{left:n.x,top:n.y,width:n.w,height:n.h,transform:`rotate(${n.angle}deg)`}),"material"!==c?.children?.[0]?.getAttribute(ur))break;c=c?.children?.[0],d++}const{id:u}=i,f=Ue(r.getVirtualItem(u).anchorCommands||[],s,s);if(Array.from(c.querySelectorAll(`[${ur}="${wr}"]`)).forEach((e,t)=>{const i=f[t],o=e.getAttribute(mr)===a?n.anchorSelectedSize:n.anchorSize;it(e,{width:o,height:o,left:i.start.x-o/2-n.anchorBorderWidth,top:i.start.y-o/2-n.anchorBorderWidth})}),"string"==typeof a&&a){const t=f.findIndex(e=>e.id===a),i=f[t],o=f[t-1];let r=null,s=null;"C"===i.type&&(r={openedByAnchorId:a,anchorId:i.id,anchorPoint:{x:i.start.x,y:i.start.y},directPoint:{x:i.params[0],y:i.params[1]}}),"C"===o.type&&(s={openedByAnchorId:a,anchorId:o.id,anchorPoint:{x:o.end.x,y:o.end.y},directPoint:{x:o.params[2],y:o.params[3]}}),r||s?(Nr(e,{selectedAnchorId:a,currentDirector:r,prevDirector:s,styles:n}),Pr(e,{currentDirector:r,prevDirector:s,styles:n})):Tr(e)}Hr(e,{anchorCommands:f,viewScaleInfo:o,styles:n})})(f,{selectedAnchorId:b?.id,material:y,viewScaleInfo:a.getActiveViewScaleInfo(),calculator:n,styles:c})},hover:()=>!g,pointStart:()=>!g,pointMove:()=>!g,pointEnd:()=>!g,pointLeave:()=>!g,doubleClick:()=>!g,contextMenu:()=>!g,wheel:()=>!g,wheelScale:()=>!g,scrollX:()=>!g,scrollY:()=>!g,resize:()=>!g}},e.MiddlewarePointer=e=>{const{boardContent:t,eventHub:i,sharer:r}=e,a=t.boardContext.canvas,n=e.container||document.body,s=`idraw-middleware-pointer-${Math.random().toString(26).substring(2)}`;let l=document.createElement("div");return{name:"@middleware/pointer",use(){l.setAttribute("id",s),l.style.position="fixed",l.style.top="0",l.style.bottom="unset",l.style.left="0",l.style.right="unset",n.appendChild(l)},disuse(){n.removeChild(l),l.remove(),l=null},contextMenu(e){const{point:t}=e,{left:n,top:s}=(()=>{const{left:e,top:t,width:i,height:o}=a.getBoundingClientRect();return{left:e,top:t,width:i,height:o}})();l.style.left=`${n+t.x}px`,l.style.top=`${s+t.y}px`;const h=r.getSharedStorage(zi);i.trigger(o.CONTEXT_MENU,{pointerContainer:l,selectedMaterials:h||[]})}}},e.MiddlewareRuler=(e,t)=>{const{boardContent:i,viewer:r,eventHub:a,calculator:n}=e,{overlayContext:s,underlayContext:l}=i;let h={...Xo,...t},c=Qo(h),d=!0,u=!0;const f=e=>{"boolean"==typeof e?.show&&(d=e.show),"boolean"==typeof e?.showGrid&&(u=e.showGrid),"boolean"!=typeof e?.show&&"boolean"!=typeof e?.showGrid||r.drawFrame()};return{name:"@middleware/ruler",use(){a.on(o.RULER,f)},disuse(){a.off(o.RULER,f)},resetConfig(e){h={...h,...e},c=Qo(h)},beforeDrawFrame:({snapshot:e})=>{if(!0===d){const t=P(e),i=T(e);!function(e,t){const{viewSizeInfo:i,styles:o}=t,{width:r,height:a}=i,{background:n,stroke:s}=o;e.beginPath();const l=-1;e.moveTo(l,l),e.lineTo(r+1,l),e.lineTo(r+1,16),e.lineTo(16,16),e.lineTo(16,a+1),e.lineTo(l,a+1),e.lineTo(l,l),e.closePath(),e.fillStyle=n,e.fill("nonzero"),e.lineWidth=1,e.setLineDash([]),e.strokeStyle=s,e.stroke()}(s,{viewScaleInfo:t,viewSizeInfo:i,styles:c}),function(e,t){const{snapshot:i,calculator:o,styles:r}=t,{sharedStore:a}=i,{selectedAreaColor:n}=r,s=a[zi],l=a[Ai];if(["select","drag","drag-list","drag-list-end"].includes(l)&&s.length>0){const t=P(i),r=T(i),a=[],l=[],h=[],c=[],d=[];if(s.forEach(e=>{const i=o.calcViewBoundingInfoFromRange(e.id,{viewScaleInfo:t,viewSizeInfo:r});i&&(a.push(i),l.push(i.left.x),h.push(i.right.x),c.push(i.top.y),d.push(i.bottom.y))}),!(a.length>0))return;const u=Math.min(...l),f=Math.max(...h),g=Math.min(...c),m=Math.max(...d);e.globalAlpha=1,e.beginPath(),e.moveTo(u,0),e.lineTo(f,0),e.lineTo(f,16),e.lineTo(u,16),e.fillStyle=n,e.closePath(),e.fill("nonzero"),e.beginPath(),e.moveTo(0,g),e.lineTo(16,g),e.lineTo(16,m),e.lineTo(0,m),e.fillStyle=n,e.closePath(),e.fill("nonzero")}}(s,{snapshot:e,calculator:n,styles:c});const{list:o,rulerUnit:r}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetLeft:r}=t,{width:a}=i;return Zo({axis:"X",scale:o,viewLength:a,viewOffset:r})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,styles:o}=t,{scaleColor:r,textColor:a}=o;for(let t=0;t<i.length;t++){const o=i[t];o.position<16||(e.beginPath(),e.moveTo(o.position,16),e.lineTo(o.position,o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8),e.closePath(),e.lineWidth=1,e.setLineDash([]),e.fillStyle=r,e.stroke(),o.isKeyNum&&(e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Fo}),e.fillText(`${o.num}`,o.position+3.2,3.2)))}}(s,{scaleList:o,styles:c});const{list:a}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{scale:o,offsetTop:r}=t,{height:a}=i;return Zo({axis:"Y",scale:o,viewLength:a,viewOffset:r})}({viewScaleInfo:t,viewSizeInfo:i});!function(e,t){const{scaleList:i,styles:o}=t,{scaleColor:r,textColor:a}=o,n=3.2;for(let t=0;t<i.length;t++){const o=i[t];if(!(o.position<16)&&(e.beginPath(),e.moveTo(16,o.position),e.lineTo(o.isKeyNum?3.2:o.isSubKeyNum?6.4:12.8,o.position),e.closePath(),e.fillStyle=r,e.lineWidth=1,e.setLineDash([]),e.stroke(),!0===o.showNum)){const t=n,i=o.position+n,r=`${o.num}`;$(e,-90,{x:t,y:i},()=>{e.fillStyle=a,e.textBaseline="top",e.$setFont({fontWeight:100,fontSize:10,fontFamily:Fo}),e.fillText(r,13.2,o.position+n)})}}}(s,{scaleList:a,styles:c}),!0===u&&function(e,t){const{xList:i,yList:o,viewSizeInfo:r,styles:a}=t,{width:n,height:s}=r,{gridColor:l,gridPrimaryColor:h}=a;for(let t=0;t<i.length;t++){const o=i[t];e.beginPath(),e.moveTo(o.position,0),e.lineTo(o.position,s),!0===o.isKeyNum||!0===o.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=l,e.closePath(),e.lineWidth=1,e.setLineDash([]),e.stroke()}for(let t=0;t<o.length;t++){const i=o[t];e.beginPath(),e.moveTo(0,i.position),e.lineTo(n,i.position),!0===i.isKeyNum||!0===i.isSubKeyNum?e.strokeStyle=h:e.strokeStyle=l,e.lineWidth=1,e.closePath(),e.stroke()}}(1===r?s:l,{xList:o,yList:a,viewScaleInfo:t,viewSizeInfo:i,styles:c})}}}},e.MiddlewareScaler=e=>{const{viewer:t,sharer:i,eventHub:r}=e;return{name:"@middleware/scaler",wheelScale(e){const{deltaY:a,point:n}=e,{scale:s}=i.getActiveViewScaleInfo();let l=s;if(a<0?l=1.1*s:a>0&&(l=.9*s),l<.05||l>50)return;const{moveX:h,moveY:c}=t.scale({scale:l,point:n});t.scroll({moveX:h,moveY:c}),t.drawFrame();const d=ue(s);r.trigger(o.SCALE,{scale:d})}}},e.MiddlewareScroller=(e,t)=>{const{viewer:i,sharer:r,eventHub:a}=e;let n=!1,s={...Wo,...t};const l=Yo(s),h=`${$o}-${Xe()}`;let c=null,d=null;const u=()=>{r.setSharedStorage(To,null),r.setSharedStorage(No,null),r.setSharedStorage(Do,null),n=!1};u();const f=()=>{const{xThumbStyle:e,yThumbStyle:t}=function(e){const{viewScaleInfo:t,viewSizeInfo:i}=e,{width:o,height:r}=i,{offsetTop:a,offsetBottom:n,offsetLeft:s,offsetRight:l}=t,h=16;let c=0,d=0;c=Math.max(40,o-32-(Math.abs(s)+Math.abs(l))),c>=o&&(c=o),d=Math.max(40,r-32-(Math.abs(a)+Math.abs(n))),d>=r&&(d=r);let u=16;s>0?u=16:l>0?u=o-c-h:s<=0&&c>0&&(0!==s||0!==l)&&(u=16+(o-c)*Math.abs(s)/(Math.abs(s)+Math.abs(l)),u=Math.min(Math.max(0,u-16),o-c));let f=16;return a>0?f=16:n>0?f=r-d-h:a<=0&&d>0&&(0!==a||0!==n)&&(f=16+(r-d)*Math.abs(a)/(Math.abs(a)+Math.abs(n)),f=Math.min(Math.max(0,f-16),r-d)),{xThumbStyle:{left:u,width:c},yThumbStyle:{top:f,height:d}}}({viewScaleInfo:r.getActiveViewScaleInfo(),viewSizeInfo:r.getActiveViewSizeInfo()});r.setSharedStorage(ko,e),r.setSharedStorage(Po,t)},g=e=>{const{thumbMoveX:t,thumbMoveY:i}=e,o=r.getSharedStorage(ko),a=r.getSharedStorage(Po),n=r.getActiveViewSizeInfo();if(o&&(t>0||t<0)){const e=n.width-32,i=16;let a=o.left-t;a=Math.min(n.width-16-40,Math.max(16,a));let s=o.width;(a+s>=e||a<=i)&&(t<0?s+=t:s-=t),s=Math.min(e,Math.max(40,s)),o.left=a,o.width=s,r.setSharedStorage(ko,o)}if(a&&(i>0||i<0)){const e=n.height-32,t=16;let o=a.top-i;o=Math.min(n.height-16-40,Math.max(16,o));let s=a.height;(o+s>=e||o<=t)&&(i<0?s+=i:s-=i),s=Math.min(e,Math.max(40,s)),a.top=o,a.height=s,r.setSharedStorage(Po,a)}};return{name:"@middleware/scroller",use(){!function(e,t){const i=e=>`.${e}`;mt({styles:{zIndex:t.zIndex,position:"absolute",background:"transparent",[i(Oo.thumb)]:{position:"absolute",background:t.thumbBackground,border:`1px solid ${t.thumbBorderColor}`,borderRadius:"4px",boxSizing:"border-box","&:hover":{background:t.hoverThumbBackground,border:`1px solid ${t.hoverThumbBorderColor}`},"&:active":{background:t.activeThumbBackground,border:`1px solid ${t.activeThumbBorderColor}`}},[`&${i(Oo.vertical)}`]:{top:0,bottom:0,right:0,left:"unset",width:16,overflow:"hidden",[i(Oo.thumb)]:{top:16,bottom:"unset",left:4,right:"unset",height:40,width:8}},[`&${i(Oo.horizontal)}`]:{left:0,right:0,top:"unset",bottom:0,height:16,overflow:"hidden",[i(Oo.thumb)]:{top:4,bottom:"unset",left:16,right:"unset",height:8,width:40}}},rootClassName:e,type:"element"})}(h,l);const t=function(e){const{rootClassName:t,$container:i}=e,o=rt,r=o("div",{className:`${t} ${Oo.horizontal}`,[yt]:"true"},[o("div",{className:Oo.thumb,[yt]:"true",[Ho]:"X"})]),a=o("div",{className:`${t} ${Oo.vertical}`,[yt]:"true"},[o("div",{className:Oo.thumb,[yt]:"true",[Ho]:"Y"})]);return i.appendChild(r),i.appendChild(a),{$horizontal:r,$vertical:a}}({rootClassName:h,$container:e.container});c=t.$horizontal,d=t.$vertical,f(),jo({xThumbStyle:r.getSharedStorage(ko),yThumbStyle:r.getSharedStorage(Po),$horizontal:c,$vertical:d})},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(h),c?.remove(),c=null,d?.remove(),d=null},resetConfig(e){s={...s,...e}},wheel:e=>{i.scroll({moveX:0-e.deltaX,moveY:0-e.deltaY}),f(),i.drawFrame()},hover:e=>{if(!0===n)return!1;const{nativeEvent:t}=e,i=Go(t);return"X"===i||"Y"===i?(a.trigger(o.CURSOR,{type:"default"}),!1):!Vo(t)&&void 0},pointStart:e=>{const{point:t,nativeEvent:i}=e,o=Go(i);return"X"===o||"Y"===o?(n=!0,r.setSharedStorage(Do,o),r.setSharedStorage(To,t),!1):!Vo(i)&&void 0},pointMove:e=>{const{point:t,nativeEvent:o}=e,a=r.getSharedStorage(Do);return"X"===a||"Y"===a?(r.setSharedStorage(No,t),"X"===a?(e=>{const t=r.getSharedStorage(To);if(t){const{offsetLeft:o,offsetRight:a}=r.getActiveViewScaleInfo(),{width:n}=r.getActiveViewSizeInfo(),s=-(e.x-t.x),l=s*(n+Math.abs(o)+Math.abs(a))/n;i.scroll({moveX:l}),g({thumbMoveX:s,thumbMoveY:0}),i.drawFrame()}})(t):"Y"===a&&(e=>{const t=r.getSharedStorage(To);if(t){const{offsetTop:o,offsetBottom:a}=r.getActiveViewScaleInfo(),{height:n}=r.getActiveViewSizeInfo(),s=-(e.y-t.y),l=s*(n+Math.abs(o)+Math.abs(a))/n;i.scroll({moveY:l}),g({thumbMoveX:0,thumbMoveY:s}),i.drawFrame()}})(t),r.setSharedStorage(To,t),!1):!Vo(o)&&void 0},pointEnd:()=>{n=!1;const e=r.getSharedStorage(Do);if(u(),"X"===e||"Y"===e)return i.scroll({moveX:0,moveY:0}),f(),i.drawFrame(),!1},beforeDrawFrame(){jo({$horizontal:c,$vertical:d,xThumbStyle:r.getSharedStorage(ko),yThumbStyle:r.getSharedStorage(Po)})}}},e.MiddlewareSelector=(e,t)=>{let i={...Ni,...t};const r=Io(i),a=`${li}-${Xe()}`;let n=null;const{viewer:s,sharer:l,boardContent:h,calculator:c,eventHub:d}=e,{overlayContext:u}=h;l.setSharedStorage(Ai,null),l.setSharedStorage(Ti,!0);const f=e=>{let t=l.getSharedStorage(Bi);return Array.isArray(t)||(t=[]),t.length>0?!function(e,t){if("group"===t?.type&&Array.isArray(t?.children))for(let i=0;i<t.children.length;i++){const o=t.children[i];if(e.id===o.id)return!0}return!1}(e,t[t.length-1])?t=[]:t.push(e):0===t.length&&t.push(e),l.setSharedStorage(Bi,t),t.length>0},g=(e,t)=>{if(l.setSharedStorage(zi,e),1===e.length?l.setSharedStorage(Li,_(e[0].id,l.getActiveStorage("data")?.materials||[])):l.setSharedStorage(Li,[]),!0===t?.triggerEvent){const t=e.map(e=>e.id),i=function(e,t){const i=[],o={};let r=!1;const a=t=>{for(let n=0;n<t.length&&!0!==r;n++){i.push(n);const s=t[n];if(e.includes(s.id)){if(o[s.id]=[...i],Object.keys(o).length===e.length){r=!0;break}}else"group"===s.type&&a(s?.children||[]);if(r)break;i.pop()}};return a(t),o}(t,l.getActiveStorage("data")?.materials||[]);d.trigger(o.SELECT,{type:"clickCanvas",ids:t,positions:e.map(e=>[...i[e.id]])})}},m=e=>({ctx:u,calculator:c,data:l.getActiveStorage("data"),selectedMaterials:l.getSharedStorage(zi),viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo(),groupQueue:l.getSharedStorage(Bi),areaSize:null,selectedMaterialPosition:l.getSharedStorage(Li),nativeEvent:e.nativeEvent}),p=()=>(e=>{e.setSharedStorage(Si,null),e.setSharedStorage(bi,null),e.setSharedStorage(Ai,null),e.setSharedStorage(Mi,null),e.setSharedStorage(Ii,null),e.setSharedStorage(Ci,null),e.setSharedStorage(Bi,[]),e.setSharedStorage(Ri,null),e.setSharedStorage(zi,[]),e.setSharedStorage(Ei,null),e.setSharedStorage(Li,[]),e.setSharedStorage(ki,null)})(l);p();const y=({ids:e=[],positions:t})=>{let i=[];const o=l.getSharedStorage(Ai),r=l.getActiveStorage("data");i=t&&Array.isArray(t)?function(e,t){const i=[];return e.forEach(e=>{const o=q(e,t);o&&i.push(o)}),i}(t,r?.materials||[]):function(e,t){const i=[];return function t(o){for(let r=0;r<o.length;r++){const a=o[r];e.includes(a.id)?i.push(a):"group"===a.type&&t(a?.children||[])}}(t),i}(e,r?.materials||[]);let a=!1;if(o||1!==i.length?"select"===o&&1===i.length&&(a=!0):(l.setSharedStorage(Ai,"select"),a=!0),a){const e=function(e,t){const{groupQueue:i}=Z(e,t);return i}(i[0].id,r?.materials||[]);l.setSharedStorage(Bi,e),g(i),l.setSharedStorage(pi,[{...K(i[0]),id:i[0].id}]),s.drawFrame()}},x=()=>{p(),s.drawFrame()},v=e=>{l.setSharedStorage(Ti,!!e.enable)},w=e=>{l.setSharedStorage(Pi,!!e.enable)};return{name:"@middleware/selector",use(){!function(e,t){const i=e=>`.${e}`;var o;mt({styles:{display:"flex",position:"absolute",zIndex:t.zIndex,top:0,left:0,right:0,bottom:0,overflow:"hidden",[i(gi.hoverTargetBox)]:{position:"absolute",outline:`1px solid ${t.activeColor}`},[i(gi.nestedBox)]:{position:"absolute",[`&${i(gi.groupBox)}`]:{outline:`2px dashed ${t.activeColor}`},[i(gi.groupBox)]:{outline:`2px dashed ${t.activeColor}`}},[i(gi.lockedTargetBox)]:{position:"absolute",outline:`2px solid ${t.lockedColor}`},[i(gi.selectedBox)]:{position:"absolute",[`&${i(gi.hideHandler)}`]:{[i(gi.cornerHandler)]:{display:"none"},[i(gi.edgeHandler)]:{display:"none"},[i(gi.rotateHandler)]:{display:"none"}}},[i(gi.selectedTargetBox)]:{position:"absolute",outline:`1.5px solid ${t.handlerBorderColor}`,[i(gi.cornerHandler)]:{position:"absolute",outline:`1.5px solid ${t.handlerBorderColor}`,background:t.handlerBackground,width:"10px",height:"10px","&:hover":{background:t.handlerHoverBackground},"&:active":{background:t.handlerActiveBackground},[`&${i(gi.cornerTopLeftHandler)}`]:{top:"-5px",left:"-5px"},[`&${i(gi.cornerTopRightHandler)}`]:{top:"-5px",right:"-5px"},[`&${i(gi.cornerBottomLeftHandler)}`]:{bottom:"-5px",left:"-5px"},[`&${i(gi.cornerBottomRightHandler)}`]:{bottom:"-5px",right:"-5px"}},[i(gi.rotateHandler)]:{position:"absolute",top:-40,left:"50%",transform:"translateX(-50%)",width:20,height:20,background:"#FFFFFF",borderRadius:"10px","&::after":{display:"inline-block",content:"\"\"",position:"absolute",top:0,bottom:0,left:0,right:0,backgroundImage:`url(data:image/svg+xml,${encodeURIComponent((o=t.activeColor,`<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200" fill="${o}" >\n <path d="M512 0c282.8 0 512 229.2 512 512s-229.2 512 -512 512S0 794.8 0 512 229.2 0 512 0zm309.8 253.8c0 -10.5 -6.5 -19.8 -15.7 -23.8 -9.7 -4 -21 -2 -28.2 5.6l-52.5 52c-56.9 -53.7 -133.9 -85.5 -213.4 -85.5 -170.7 0 -309.8 139.2 -309.8 309.8 0 170.6 139.2 309.8 309.8 309.8 92.4 0 179.5 -40.8 238.4 -111.8 4 -5.2 4 -12.9 -0.8 -17.3L694.3 637c-2.8 -2.4 -6.5 -3.6 -10.1 -3.6 -3.6 0.4 -7.3 2 -9.3 4.8 -39.5 51.2 -98.8 80.3 -163 80.3 -113.8 0 -206.5 -92.8 -206.5 -206.5 0 -113.8 92.8 -206.5 206.5 -206.5 52.8 0 102.9 20.2 140.8 55.3L597 416.5c-7.7 7.3 -9.7 18.6 -5.6 27.9 4 9.7 13.3 16.1 23.8 16.1H796c14.1 0 25.8 -11.7 25.8 -25.8V253.8z" />\n</svg>`))})`,backgroundPosition:"center",backgroundSize:"20px"}},[i(gi.edgeHandler)]:{position:"absolute",background:"transparent",[`&${i(gi.edgeLeftHandler)}`]:{width:"10px",top:"5px",left:"-5px",bottom:"5px"},[`&${i(gi.edgeRightHandler)}`]:{width:"10px",top:"5px",right:"-5px",bottom:"5px"},[`&${i(gi.edgeTopHandler)}`]:{height:"10px",top:"-5px",left:"5px",right:"5px"},[`&${i(gi.edgeBottomHandler)}`]:{height:"10px",bottom:"-5px",left:"5px",right:"5px"}}},[i(gi.selectionAreaBox)]:{position:"absolute",outline:`1px solid ${t.selectionAreaBorderColor}`,background:t.selectionAreaBackground}},rootClassName:e,type:"element"})}(a,r),n=function(e){const{rootClassName:t,$container:i}=e,o=rt("div",{className:t,[yt]:"true"});return i.appendChild(o),o}({rootClassName:a,$container:e.container}),d.on(o.SELECT,y),d.on(o.CLEAR_SELECT,x),d.on(o.SELECT_IN_GROUP,w),d.on(o.SNAP_TO_GRID,v)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(a),d.off(o.SELECT,y),d.off(o.CLEAR_SELECT,x),d.off(o.SELECT_IN_GROUP,w),d.off(o.SNAP_TO_GRID,v),n?.remove(),p(),i=null,n=null},resetConfig(e){i={...i,...e}},hover:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return void(l.getSharedStorage(Ri)&&(l.setSharedStorage(Ri,null),s.drawFrame()));const t=l.getSharedStorage(qi);if(!0===l.getSharedStorage(_i))return;const i=l.getSharedStorage(Mi),r=l.getSharedStorage(Ai),h=l.getSharedStorage(Bi),u=e=>{if(!0===t)return;const i=e.type;null===l.getSharedStorage(vi)&&d.trigger(o.CURSOR,{type:i,groupQueue:e.groupQueue,material:e.materials[0]})};if(h?.length>0){if(!Mo(e.nativeEvent,{$root:n,groupQueue:l.getSharedStorage(Bi)}))return l.setSharedStorage(Ri,null),void s.drawFrame();const t=Oi(e.point,m(e));return u(t),i||["area","drag","drag-list"].includes(r)?(l.setSharedStorage(Ri,null),void s.drawFrame()):1===t?.materials?.length?(l.setSharedStorage(Ri,t.materials[0]),void s.drawFrame()):(l.setSharedStorage(Ri,null),void s.drawFrame())}if(i||["area","drag","drag-list"].includes(r))return void l.setSharedStorage(Ri,null);if("drag"===r)return void l.setSharedStorage(Ri,null);const f=l.getSharedStorage(zi),g=l.getActiveViewScaleInfo(),p=l.getActiveViewSizeInfo(),y=Oi(e.point,{...m(e),areaSize:Vi(f,{viewScaleInfo:g,viewSizeInfo:p,calculator:c})});if(u(y),null!==y.type){if(!("over-material"===y.type&&"select"===l.getSharedStorage(Ai)&&1===y.materials.length&&y.materials[0].id===l.getSharedStorage(zi)?.[0]?.id||"over-material"===y.type&&null===l.getSharedStorage(Ai)&&1===y.materials.length&&y.materials[0].id===l.getSharedStorage(Ri)?.id))return"over-material"===y.type&&1===y?.materials?.length?(l.setSharedStorage(Ri,y.materials[0]),void s.drawFrame()):l.getSharedStorage(Ri)?(l.setSharedStorage(Ri,null),void s.drawFrame()):void 0}else l.getSharedStorage(Ri)&&(l.setSharedStorage(Ri,null),s.drawFrame())},pointStart:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(mi,e.point),l.setSharedStorage(yi,e.point),l.setSharedStorage(Si,null),l.setSharedStorage(bi,null),l.setSharedStorage(Ai,null),l.setSharedStorage(Mi,null),l.setSharedStorage(Ii,null),l.setSharedStorage(Ci,null),l.setSharedStorage(Ri,null);const t=l.getSharedStorage(Bi);if(t?.length>0){if(Mo(e.nativeEvent,{$root:n,groupQueue:t})){const t=Oi(e.point,m(e)),i=1===t?.materials?.length&&!0===t.materials[0]?.operations?.locked;l.setSharedStorage(Ri,null),1===t?.materials?.length&&l.setSharedStorage(xi,K(t?.materials[0])),!0===i?p():"over-material"===t.type&&1===t?.materials?.length?(g([t.materials[0]],{triggerEvent:!0}),l.setSharedStorage(Ai,"drag"),l.setSharedStorage(pi,[{...K(t?.materials[0]),id:t?.materials[0].id}])):t.type?.startsWith("resize-")?(l.setSharedStorage(Mi,t.type),l.setSharedStorage(Ai,"resize")):g([],{triggerEvent:!0})}else p();return void s.drawFrame()}const i=Vi(l.getSharedStorage(zi),{viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo(),calculator:c}),o=Oi(e.point,{...m(e),areaSize:i,groupQueue:[]}),r=1===o?.materials?.length&&!0===o.materials[0]?.operations?.locked;l.setSharedStorage(Ri,null),1===o?.materials?.length&&l.setSharedStorage(xi,K(o?.materials[0])),!0===r?(p(),l.setSharedStorage(Ri,o?.materials[0]),l.setSharedStorage(Ai,"area"),l.setSharedStorage(Ii,e.point),g([],{triggerEvent:!0})):"list-area"===o.type?l.setSharedStorage(Ai,"drag-list"):"over-material"===o.type&&1===o?.materials?.length?(g([o.materials[0]],{triggerEvent:!0}),l.setSharedStorage(Ai,"drag"),l.setSharedStorage(pi,[{...K(o?.materials[0]),id:o?.materials[0].id}])):o.type?.startsWith("resize-")?(l.setSharedStorage(Mi,o.type),l.setSharedStorage(Ai,"resize")):(p(),l.setSharedStorage(Ai,"area"),l.setSharedStorage(Ii,e.point),g([],{triggerEvent:!0})),s.drawFrame()},pointMove:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(ki,!0);const t=l.getActiveStorage("data"),i=l.getSharedStorage(zi),o=l.getActiveStorage("scale")||1,r=l.getActiveViewScaleInfo(),h=l.getActiveViewSizeInfo(),u=l.getSharedStorage(mi),f=l.getSharedStorage(yi),m=e.point,p=l.getSharedStorage(Mi),y=l.getSharedStorage(Ai),x=l.getSharedStorage(Bi),v=l.getSharedStorage(Ti);let w="unknown";if("drag"===y){if(l.setSharedStorage(wi,!0),l.setSharedStorage(vi,"drag"),d.trigger(lo,{show:!1}),t&&1===i?.length&&l.getSharedStorage(xi)&&f&&m&&!0!==i[0]?.operations?.locked){const{moveX:e,moveY:a}=He(f,m,x);let n=c.toGridNum(e/o),s=c.toGridNum(a/o);if(!0===v){const e=Xi(i[0].id,{calculator:c,data:t,groupQueue:x,viewScaleInfo:r,viewSizeInfo:h});try{e&&(C.x(e.offsetX)&&null!==e.offsetX&&(n=c.toGridNum(n+e.offsetX)),C.y(e.offsetY)&&null!==e.offsetY&&(s=c.toGridNum(s+e.offsetY)))}catch(e){console.error(e)}}const d=l.getSharedStorage(xi),u=c.toGridNum(d.x+n),p=c.toGridNum(d.y+s);Co(i[0],{x:u,y:p,width:i[0].width,height:i[0].height}),g([i[0]]),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i[0],position:l.getSharedStorage(Li)||[]}},viewSizeInfo:h,viewScaleInfo:r})}s.drawFrame()}else if("drag-list"===y){if(l.setSharedStorage(wi,!0),l.setSharedStorage(vi,"drag-list"),t&&f&&u&&m&&i?.length>1){const e=(m.x-u.x)/o,a=(m.y-u.y)/o;i.forEach(i=>{i&&!0!==i?.operations?.locked&&(i.x=c.toGridNum(i.x+e),i.y=c.toGridNum(i.y+a),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i,position:_(i.id,t.materials)||[]}},viewSizeInfo:h,viewScaleInfo:r}))}),l.setActiveStorage("data",t)}s.drawFrame()}else if("resize"===y){if(t&&1===i?.length&&f&&l.getSharedStorage(xi)&&p?.startsWith("resize-")){l.setSharedStorage(wi,!0),l.setSharedStorage(vi,"resize");const e=[];x.forEach(t=>{const{x:i,y:o,width:r,height:a,angle:n=0}=t;e.push({x:i,y:o,width:r,height:a,angle:0-n})});let a=f,n=m;if(x.length>0&&(a=V(f,e),n=V(m,e)),"resize-rotate"===p){const e=l.getSharedStorage(xi),t=c.getVirtualItem(i?.[0]?.id)?.worldCenter,o=Yi(e,{center:t,viewScaleInfo:r,viewSizeInfo:h,start:f,end:m,resizeType:p,sharer:l,calculator:c});i[0].angle=c.toGridNum(o.angle||0)}else{const e=l.getSharedStorage(xi),t=function(e,t){let{x:i,y:o,width:r,height:a,angle:n=0}=e;const s=H({x:i,y:o,width:r,height:a,angle:n});n=X(n);const l=D(n),h=!!e?.operations?.limitRatio,{start:c,end:d,resizeType:u,scale:f,calculator:g}=t;let m={...c},p={...d},y={x:m.x,y:s.y},x={x:p.x,y:s.y},v={...y},w={...x},S={x:s.x,y:m.y},b={x:s.x,y:p.y},A={...S},M={...b},I=(w.x-v.x)/f,C=(w.y-v.y)/f,R=$i(I,C),z=(M.x-A.x)/f,E=(M.y-A.y)/f,L=$i(z,E);(n>0||n<0)&&(m=Y(s,c,0-l),p=Y(s,d,0-l),y={x:m.x,y:s.y},x={x:p.x,y:s.y},v=Y(s,y,l),w=Y(s,x,l),S={x:s.x,y:m.y},b={x:s.x,y:p.y},A=Y(s,S,l),M=Y(s,b,l),I=(w.x-v.x)/f,C=(w.y-v.y)/f,R=$i(I,C),R=Hi(R,C),z=(M.x-A.x)/f,E=(M.y-A.y)/f,L=$i(z,E),L=Hi(L,E));let B=(d.x-c.x)/f,k=(d.y-c.y)/f;if(!0===h)if(["resize-top","resize-bottom","resize-left","resize-right"].includes(u)){const t=Math.max(Math.abs(B),Math.abs(k));B=(B>=0?1:-1)*t,k=(k>=0?1:-1)*t/e.width*e.height;const i=Math.max(Math.abs(z),Math.abs(E));z=(z>=0?1:-1)*i,E=(E>=0?1:-1)*i/e.width*e.height;const o=Math.max(Math.abs(I),Math.abs(C));I=(I>=0?1:-1)*o,C=(C>=0?1:-1)*o/e.width*e.height}else if(["resize-top-left","resize-top-right","resize-bottom-left","resize-bottom-right"].includes(u)){{const t=Math.abs(B);B=(B>=0?1:-1)*t;const i=t/e.width*e.height;"resize-top-left"===u||"resize-bottom-right"===u?k=B>0?i:-i:"resize-top-right"!==u&&"resize-bottom-left"!==u||(k=B>0?-i:i)}R=Math.abs(R),L=R/e.width*e.height}switch(u){case"resize-top":if(0===n)a-k>0&&(o+=k,a-=k,!0===e.operations?.limitRatio&&(i+=k/e.height*e.width/2,r-=k/e.height*e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){L=0-Hi(L,E);const e=Di(n),i=L/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<180){L=Hi(L,z);const e=Di(n-90),i=L/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<270){L=Hi(L,E);const e=Di(n-180),i=L/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<360){L=0-Hi(L,z);const e=Di(n-270),i=L/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}a+L>0&&(!0===e.operations?.limitRatio&&(r+=L/e.height*e.width),a+=L,i=t-r/2,o=l-a/2)}break;case"resize-bottom":if(0===n)e.height+k>0&&(a+=k,!0===e.operations?.limitRatio&&(i-=k/e.height*e.width/2,r+=k/e.height*e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){L=Hi(L,E);const e=Di(n),i=L/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<180){L=0-Hi(L,z);const e=Di(n-90),i=L/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}else if(n<270){L=Hi(L,z);const e=Di(n-180),i=L/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<360){L=Hi(L,z);const e=Di(n-270),i=L/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}a+L>0&&(!0===e.operations?.limitRatio&&(r+=L/e.height*e.width),a+=L,i=t-r/2,o=l-a/2)}break;case"resize-left":if(0===n)e.width-B>0&&(i+=B,r-=B,!0===e.operations?.limitRatio&&(a-=B/e.width*e.height,o+=B/e.width*e.height/2));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){R=0-Hi(R,I);const e=Di(n),i=R/2;t-=i*Math.cos(e),l-=i*Math.sin(e)}else if(n<180){R=Hi(R,I);const e=Di(n-90),i=R/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}else if(n<270){R=Hi(R,C);const e=Di(n-180),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<360){R=Hi(R,C);const e=Di(n-270),i=R/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}r+R>0&&(!0===e.operations?.limitRatio&&(a+=R/e.width*e.height),r+=R,i=t-r/2,o=l-a/2)}break;case"resize-right":if(0===n)e.width+B>0&&(r+=B,!0===e.operations?.limitRatio&&(o-=B*e.height/e.width/2,a+=B*e.height/e.width));else if(n>0||n<0){let t=s.x,l=s.y;if(n<90){R=Hi(R,C);const e=Di(n),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e)}else if(n<180){R=Hi(R,k);const e=Di(n-90),i=R/2;t-=i*Math.sin(e),l+=i*Math.cos(e)}else if(n<270){R=Hi(R,k);const e=Di(n-180),i=R/2;t+=i*Math.cos(e),l+=i*Math.sin(e),R=0-R}else if(n<360){R=Hi(R,B);const e=Di(n-270),i=R/2;t+=i*Math.sin(e),l-=i*Math.cos(e)}r+R>0&&(!0===e.operations?.limitRatio&&(a+=R/e.width*e.height),r+=R,i=t-r/2,o=l-a/2)}break;case"resize-top-left":if(0===n)r-B>0&&(i+=B,r-=B),a-k>0&&(o+=k,a-=k);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=0-Hi(L,E),R=0-Hi(R,h?0-L:I);const i=L/2;e+=i*Math.sin(l),t-=i*Math.cos(l);const o=R/2;e-=o*Math.cos(l),t-=o*Math.sin(l)}else if(n<180){L=Hi(L,z),R=Hi(R,h?L:I);const i=Di(n-90),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}else if(n<270){L=Hi(L,E),R=Hi(R,h?L:C);const i=Di(n-180),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<360){L=0-Hi(L,z),R=Hi(R,h?L:C);const i=Di(n-270),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-top-right":if(0===n)r+B>0&&(r+=B),a-k>0&&(o+=k,a-=k);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=0-Hi(L,E),R=Hi(R,h?L:C);const i=Di(n),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<180){L=Hi(L,z),R=Hi(R,h?L:C);const i=Di(n-90),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}else if(n<270){const i=Di(n-180);L=Hi(L,E),R=Hi(R,h?L:0-I);const o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<360){L=0-Hi(L,z),R=Hi(R,h?L:I);const i=Di(n-270),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-bottom-left":if(0===n)e.height+k>0&&(a+=k),e.width-B>0&&(i+=B,r-=B);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=Hi(L,E),R=0-Hi(R,h?0-L:I);const i=Di(n),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<180){L=0-Hi(L,z),R=Hi(R,h?L:I);const i=Di(n-90),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}else if(n<270){L=Hi(L,z),R=Hi(R,h?L:C);const i=Di(n-180),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<360){L=Hi(L,z),R=Hi(R,h?L:C);const i=Di(n-270),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}break;case"resize-bottom-right":if(0===n)e.height+k>0&&(a+=k),e.width+B>0&&(r+=B);else if(n>0||n<0){let e=s.x,t=s.y;if(n<90){L=Hi(L,E),R=Hi(R,h?L:C);const i=Di(n),o=L/2;e-=o*Math.sin(i),t+=o*Math.cos(i);const r=R/2;e+=r*Math.cos(i),t+=r*Math.sin(i)}else if(n<180){L=0-Hi(L,z),R=Hi(R,h?L:k);const i=Di(n-90),o=L/2;e-=o*Math.cos(i),t-=o*Math.sin(i);const r=R/2;e-=r*Math.sin(i),t+=r*Math.cos(i)}else if(n<270){L=Hi(L,z),R=Hi(R,h?L:0-C);const i=Di(n-180),o=L/2;e+=o*Math.sin(i),t-=o*Math.cos(i);const r=R/2;e-=r*Math.cos(i),t-=r*Math.sin(i)}else if(n<360){L=Hi(L,z),R=Hi(R,h?L:I);const i=Di(n-270),o=L/2;e+=o*Math.cos(i),t+=o*Math.sin(i);const r=R/2;e+=r*Math.sin(i),t-=r*Math.cos(i)}a+L>0&&(a+=L),r+R>0&&(r+=R),i=e-r/2,o=t-a/2}}return{x:g.toGridNum(i),y:g.toGridNum(o),width:g.toGridNum(r),height:g.toGridNum(a),angle:g.toGridNum(e.angle||0)}}({...e,operations:i[0].operations},{scale:o,start:a,end:n,resizeType:p,sharer:l,calculator:c}),r={ignore:!!e.angle},s=c.toGridNum(t.x,r),h=c.toGridNum(t.y,r),d=c.toGridNum(t.width,r),u=c.toGridNum(t.height,r);"group"===i[0].type?(l.setSharedStorage(bi,Ee(i[0],{x:s,y:h,width:d,height:u},{resizeEffect:i[0].operations?.resizeEffect})),l.getSharedStorage(Si)||l.setSharedStorage(Si,l.getSharedStorage(bi)),i[0].x=s,i[0].y=h):Co(i[0],{x:s,y:h,width:d,height:u})}g([i[0]]),w="updateMaterial",c.modifyVirtualItemMap(t,{modifyInfo:{type:w,content:{material:i[0],position:l.getSharedStorage(Li)||[]}},viewSizeInfo:h,viewScaleInfo:r}),s.drawFrame()}}else"area"===y&&(l.setSharedStorage(vi,"area"),l.setSharedStorage(Ci,e.point),s.drawFrame());ni(d,{data:t,type:"updatingMaterial",selectedMaterials:l.getSharedStorage(zi),hoverMaterial:null,modifyRecord:null},"continuous"),l.setSharedStorage(mi,e.point)},pointEnd(e){if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;l.setSharedStorage(vi,null),l.setSharedStorage(ki,!1);const t=l.getActiveStorage("data"),i=l.getSharedStorage(zi),o=l.getSharedStorage(Ri),r=l.getSharedStorage(Mi),h=l.getSharedStorage(Ai),u=l.getActiveViewSizeInfo();let f=!1;if(l.setSharedStorage(mi,null),l.setSharedStorage(yi,null),l.setSharedStorage(xi,null),"drag"===h&&d.trigger(lo,{show:!0}),"resize"===h&&r)l.setSharedStorage(Mi,null),f=!0;else if("area"===h){if(o?.operations?.locked?l.setSharedStorage(Ai,"hover"):l.setSharedStorage(Ai,null),t){const e=l.getSharedStorage(Ii),i=l.getSharedStorage(Ci);if(e&&i){const{materials:o}=function(e,t){const i=[],o=[],r=[],{viewScaleInfo:a,start:n,end:s}=t;if(!(Array.isArray(e.materials)&&n&&s))return{indexes:i,ids:o,materials:r};const l=Math.min(n.x,s.x),h=Math.max(n.x,s.x),c=Math.min(n.y,s.y),d=Math.max(n.y,s.y);for(let t=0;t<e.materials.length;t++){const n=e.materials[t];if(!0===n?.operations?.locked)continue;const s=re(n,{viewScaleInfo:a}),u=H(s);if(u.x>=l&&u.x<=h&&u.y>=c&&u.y<=d&&(i.push(t),o.push(n.id),r.push(n),s.angle&&(s.angle>0||s.angle<0))){const e=G(s);if(4===e.length){const t=[e[0].x,e[1].x,e[2].x,e[3].x],i=[e[0].y,e[1].y,e[2].y,e[3].y];s.x=Math.min(...t),s.y=Math.min(...i),s.width=Math.abs(Math.max(...t)-Math.min(...t)),s.height=Math.abs(Math.max(...i)-Math.min(...i))}}}return{indexes:i,ids:o,materials:r}}(t,{start:e,end:i,calculator:c,viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()});o.length>0&&(l.setSharedStorage(Ai,"drag-list"),g(o,{triggerEvent:!0}),f=!0)}}}else"drag-list"===h?(l.setSharedStorage(Ai,"drag-list-end"),f=!0):t&&(c.getPointMaterial(e.point,{data:t,viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo()}).material?(l.setSharedStorage(Ai,"select"),f=!0):l.setSharedStorage(Ai,null));null===l.getSharedStorage(Ai)&&(p(),f=!0);(()=>{if(f){if(t&&Array.isArray(t?.materials)&&["drag","drag-list"].includes(h)){const e=function(e,t,i){const o=U(e,{viewWidth:t.width,viewHeight:t.height,extend:i?.extend});return!0===i?.extend&&(o.contextWidth=Math.max(o.contextWidth,t.contextWidth),o.contextHeight=Math.max(o.contextHeight,t.contextHeight)),{contextSize:o}}(t.materials,u,{extend:!0});l.setActiveStorage("contextHeight",e.contextSize.contextHeight),l.setActiveStorage("contextWidth",e.contextSize.contextWidth)}if(t&&["drag","drag-list","drag-list-end","resize"].includes(h)){let e="resizeMaterial";if("resize"===e&&(e="resizeMaterial"),l.getSharedStorage(wi)){let r=null;const a=l.getSharedStorage(pi);if(Array.isArray(a)&&a.length){const e=a[0];if(1===i.length){r={type:"resizeMaterial",time:0,content:{method:"modifyMaterial",id:e.id,before:ve(e),after:ve(K(i[0]))}};const t=l.getSharedStorage(Si),o=l.getSharedStorage(bi);"group"===i[0].type&&t&&o&&(r={...o,content:{...o.content,before:t.content.before}})}else i.length>1&&(r={type:"resizeMaterials",time:0,content:{method:"modifyMaterials",before:a.map(e=>({...ve(e),id:e.id})),after:i.map(e=>({...ve(K(e)),id:e.id}))}})}ni(d,{data:t,type:e,selectedMaterials:i,hoverMaterial:o,modifyRecord:r}),l.setSharedStorage(wi,!1)}}s.drawFrame()}})()},pointLeave(){l.setSharedStorage(vi,null),l.setSharedStorage(Mi,null),d.trigger(o.CURSOR,{type:"default"})},doubleClick(e){if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;if(!1===l.getSharedStorage(Pi))return;const t=Oi(e.point,m(e));if(l.setSharedStorage(zi,[]),1!==t.materials.length||!0===t.materials[0]?.operations?.locked||!0===t.materials[0]?.operations?.invisible)return;const r=t.materials[0];if(i?.afterDoubleClickMaterial?.({material:r}),"group"===r?.type){if(!0===f(r))return l.setSharedStorage(Ai,null),void s.drawFrame()}else"text"===r?.type&&d.trigger(o.TEXT_EDIT,{id:r.id});l.setSharedStorage(Ai,null)},contextMenu:e=>{if(!lt(e.nativeEvent,{$root:n,rootClassName:a}))return;const t=l.getSharedStorage(Bi);if(t?.length>0){if(Mo(e.nativeEvent,{$root:n,groupQueue:t})){const t=Oi(e.point,m(e));1===t?.materials?.length&&!0!==t.materials[0]?.operations?.locked?(p(),g([t.materials[0]],{triggerEvent:!0}),s.drawFrame()):t?.materials?.length||p()}return}const i=Vi(l.getSharedStorage(zi),{viewScaleInfo:l.getActiveViewScaleInfo(),viewSizeInfo:l.getActiveViewSizeInfo(),calculator:c}),o=Oi(e.point,{...m(e),areaSize:i,groupQueue:[]});if(1===o?.materials?.length&&!0!==o.materials[0]?.operations?.locked)return p(),g([o.materials[0]],{triggerEvent:!0}),void s.drawFrame();o?.materials?.length||p()},beforeDrawFrame({snapshot:t}){Lo({$root:n,styles:r,boardContent:h,snapshot:t,calculator:c,sharer:e.sharer})}}},e.MiddlewareTextEditor=(e,t)=>{const{eventHub:i,boardContent:r,viewer:a,sharer:n,calculator:s}=e,l=r.boardContext.canvas,h=e.container||document.body,c=_o({...Ko,...t});let d=null,u=[],f="",g=!1;const m=`idraw-middleware-text-editor-${Math.random().toString(26).substring(2)}`,p=`${Jo}-${Xe()}`;let y=null,x=null,v=null;const w=()=>{!0!==g&&(y=rt("div",{className:qo.textarea,contenteditable:"true"}),x=rt("div",{className:qo.canvasWrapper},[y]),v=rt("div",{id:m,className:p},[x]),h.appendChild(v))},S=()=>{v?.remove()},b=e=>{v&&y&&(M(),((e,t,i)=>{if(!e||!t)return;const{viewScaleInfo:o,material:r,groupQueue:a}=i,{scale:n,offsetTop:s,offsetLeft:l}=o;t?.children&&Array.from(t.children).forEach(e=>{e.remove()});let h=t;for(let e=0;e<a.length;e++){const t=a[e],{x:i,y:o,width:r,height:c}=t,d={x:i*n,y:o*n,width:r*n,height:c*n,angle:X(t.angle||0)};0===e&&(d.x+=l,d.y+=s),h=tr({size:d,parent:h})}const c={...er,...r};let d=r.x*n+l,u=r.y*n+s,f=r.width*n,g=r.height*n;a.length>0&&(d=r.x*n,u=r.y*n,f=r.width*n,g=r.height*n);let m="center",p="center";"left"===c.textAlign?m="start":"right"===c.textAlign&&(m="end"),"top"===c.verticalAlign?p="start":"bottom"===c.verticalAlign&&(p="end"),it(e,{justifyContent:m,alignItems:p,transform:`rotate(${X(r.angle||0)}deg)`,left:d-1+"px",top:u-1+"px",width:`${f+2}px`,height:`${g+2}px`,cornerRadius:("number"==typeof c.cornerRadius?c.cornerRadius:0)*n+"px",color:`${c.fill||"#000000"}`,textStroke:"number"==typeof c.strokeWidth&&c.strokeWidth>0?`${c.strokeWidth}px ${c.stroke}`:"","-webkit-text-stroke":"number"==typeof c.strokeWidth&&c.strokeWidth>0?`${c.strokeWidth}px ${c.stroke}`:"",fontSize:c.fontSize*n+"px",lineHeight:(c.lineHeight||c.fontSize)*n+"px",fontFamily:$e(c.fontFamily),fontWeight:`${c.fontWeight}`,opacity:c.opacity||1}),e.innerText=c.text||"",h.appendChild(e)})(y,x,e),tt(v,[qo.hide]),f="",g=!0,y.focus(),d?.id&&(n.setActiveOverrideMaterialMap({[d.id]:{operations:{invisible:!0}}}),f=d.text||"",a.drawFrame()))},A=()=>{if(d?.id){const e=n.getActiveOverrideMaterialMap();e&&delete e[d.id],n.setActiveOverrideMaterialMap(e),a.drawFrame()}v&&et(v,[qo.hide]),d=null,u=[],g=!1,S()},M=()=>{if(!x)return;const{left:e,top:t,width:i,height:o}=(()=>{const{left:e,top:t,width:i,height:o}=l.getBoundingClientRect();return{left:e,top:t,width:i,height:o}})();it(x,{position:"absolute",overflow:"hidden",top:`${t}px`,left:`${e}px`,width:`${i}px`,height:`${o}px`})},I=()=>{A()},C=e=>{e.stopPropagation(),e.preventDefault(),window?.getSelection()?.removeAllRanges()},R=e=>{2===e.attributes&&e.preventDefault()},z=()=>{if(y&&d&&u){d.text=y.innerText||"",i.trigger(o.TEXT_CHANGE,{material:{id:d.id,attributes:{text:d.text}},position:[...u||[]]});const e=s.getVirtualItem(d.id),t=n.getActiveStorage("data")||{materials:[]};s.modifyVirtualAttributes(d,{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:J(t.materials,e?.position||[])||[]}),a.drawFrame()}},E=()=>{if(d&&u){d.text=y?.innerText||"",i.trigger(o.TEXT_CHANGE,{material:{id:d.id,attributes:{text:d.text}},position:[...u]});const e=n.getActiveStorage("data")||{materials:[]},t={text:d.text};Te(d.id,t,e.materials),ni(i,{selectedMaterials:[{...d,...d,...t}],data:e,type:"modifyMaterial",modifyRecord:{type:"modifyMaterial",time:Date.now(),content:{method:"modifyMaterial",id:d.id,before:{"attributes.text":f},after:{"attributes.text":d.text}}}});const r=s.getVirtualItem(d.id);s.modifyVirtualAttributes(d,{viewScaleInfo:n.getActiveViewScaleInfo(),viewSizeInfo:n.getActiveViewSizeInfo(),groupQueue:J(e.materials,r?.position||[])||[]}),a.drawFrame()}A()},L=e=>{e.stopPropagation()},B=e=>{e.stopPropagation(),e.preventDefault()},k=e=>{const{id:t}=e;if("string"!=typeof t||!t)return;w(),v?.addEventListener("click",I),y?.addEventListener("mousedown",L),y?.addEventListener("mouseover",L),y?.addEventListener("mouseenter",L),y?.addEventListener("mouseleave",L),y?.addEventListener("dblclick",C),y?.addEventListener("selectstart",R),y?.addEventListener("click",L),y?.addEventListener("input",z),y?.addEventListener("blur",E),y?.addEventListener("keydown",L),y?.addEventListener("keypress",L),y?.addEventListener("keyup",L),y?.addEventListener("wheel",B);const{material:i,groupQueue:o,position:r}=Z(t,n.getActiveStorage("data").materials);"text"===i?.type&&(d=i,u=r,b({material:d,groupQueue:o,viewScaleInfo:n.getActiveViewScaleInfo(),styles:c}))},P=()=>{if(!0===g)return!1};return{name:"@middleware/text-editor",use(){!function(e,t){mt({type:"element",rootClassName:e,styles:{position:"fixed",top:"0",bottom:"0",left:"0",right:"0",display:"block",zIndex:t.zIndex,[`&.${qo.hide}`]:{display:"none"},[`.${qo.textarea}`]:{display:"inline-flex",flexDirection:"column",position:"absolute",boxSizing:"border-box",overflow:"hidden",wordBreak:"break-all",padding:"0",margin:"0",outline:"none",border:`1px solid ${t.boxBorderColor}`,background:"transparent"},[`.${qo.canvasWrapper}`]:{position:"absolute"}}})}(p,c),i.on(o.TEXT_EDIT,k)},disuse(){!function(e){pt({rootClassName:e,type:"element"})}(p),i.off(o.TEXT_EDIT,k),v?.removeEventListener("click",I),y?.removeEventListener("mousedown",L),y?.removeEventListener("mouseover",L),y?.removeEventListener("mouseenter",L),y?.removeEventListener("mouseleave",L),y?.removeEventListener("dblclick",C),y?.removeEventListener("selectstart",R),y?.removeEventListener("click",L),y?.removeEventListener("input",z),y?.removeEventListener("blur",E),y?.removeEventListener("keydown",L),y?.removeEventListener("keypress",L),y?.removeEventListener("keyup",L),y?.removeEventListener("wheel",B),S(),y=null,x=null,v=null,d=null,u=null,f=null},hover:P,pointStart:P,pointMove:P,pointEnd:P,pointLeave:P,doubleClick:P,contextMenu:P,wheel:P,wheelScale:P,scrollX:P,scrollY:P,resize:P}},e.Sharer=Gt,e.coreEventKeys=o,e.getMiddlewareCreatorStyles=ii,e.getMiddlewareInfoStyles=co,e.getMiddlewarePathCreatorStyles=qr,e.getMiddlewarePathEditorStyles=Cr,e.getMiddlewareRulerStyles=Qo,e.getMiddlewareScrollerStyles=Yo,e.getMiddlewareSelectorStyles=Io,e.getMiddlewareTextEditorStyles=_o,e}({});