@idraw/renderer 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.
- package/dist/index.global.js +3116 -2968
- package/dist/index.global.min.js +1 -1
- package/package.json +3 -3
package/dist/index.global.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var iDrawRenderer=function(t){"use strict";function e(t,e){if(1===e)return t;let i=1;const n=/^#[0-9a-f]{6,6}$/i;let o=t;if(n.test(t)?i=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(i=parseInt(t.substring(7,9).replace(/^#/,"0x")),o=t.substring(0,7)),i*=e,n.test(o)&&i>0&&i<1){const t=Math.max(0,Math.min(255,Math.ceil(256*i)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o}function i(t){return(65536*(1+Math.random())|0).toString(16).substring(1)}function n(){return`${i()}${i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`}function o(t,e){let i=0;for(let e=0;e<t.length;e++)i+=t.charCodeAt(e);return(i+e).toString(16).substring(0,4)}function r(t,e){const i=t.length,n=function(t){let e=0;for(let i=0;i<t.length;i++)e+=t.charCodeAt(i);return e}(e),r=Math.floor(i/2),a=t.substring(0,4).padStart(4,"0"),s=t.substring(0,4).padStart(4,"0");return`@assets/${o(i.toString(16).padStart(4,a),n).padStart(4,"0")}${o(t.substring(r-4,r).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-8,r-4).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-12,r-8).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-16,r-12).padStart(4,s),n).padStart(4,"0")}-${o(t.substring(r,r+4).padStart(4,s),n).padStart(4,"0")}${o(t.substring(r+4,r+8).padStart(4,s),n).padStart(4,"0")}${o(s.padStart(4,a).padStart(4,s),n)}`}function a(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function s(t){return function t(e){const i=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return e;if("Array"===i){const i=[];return e.forEach(e=>{i.push(t(e))}),i}if("Object"===i){const i={};Object.keys(e).forEach(n=>{i[n]=t(e[n])});return Object.getOwnPropertySymbols(e).forEach(n=>{i[n]=t(e[n])}),i}}(t)}const{Image:l}=window;function c(t){return new Promise((e,i)=>{const n=new l;n.crossOrigin="anonymous",n.onload=function(){e(n)},n.onabort=i,n.onerror=i,n.src=t})}async function h(t){const e=await(i=t,new Promise((t,e)=>{const n=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(n),o.onload=function(e){const i=e?.target?.result;t(i)},o.onerror=function(t){e(t)}}));var i;return await c(e)}async function u(t,e){t=t.replace(/&/gi,"&");const i=await function(t,e){const{width:i,height:n}=e;return new Promise((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${n||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){const i=t?.target?.result;e(i)},a.onerror=function(t){o(t)}})}(t,e);return await c(i)}function f(t){return"number"==typeof t&&t>=0}function p(t){return"number"==typeof t&&(t>0||t<=0)}function d(t){return p(t)}function y(t){return p(t)}function g(t){return f(t)}function m(t){return f(t)}function x(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function w(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function b(t){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(t)}const I={positiveNum:f,data:function(t){return!!(Array(t?.materials)&&t?.materials.length>=0)},material:function(t){return!!t&&(b(t?.type)&&d(t?.x)&&y(t?.y)&&g(t?.w)&&m(t?.h))},layout:function(t){return!!t&&(d(t?.x)&&y(t?.y)&&g(t?.w)&&m(t?.h))},type:b,x:d,y:y,width:g,height:m,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:p,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},strokeWidth:function(t){return f(t)||Array.isArray(t)&&f(t[0])&&f(t[1])&&f(t[2])&&f(t[3])},cornerRadius:function(t){return f(t)||Array.isArray(t)&&f(t[0])&&f(t[1])&&f(t[2])&&f(t[3])},color:function(t){return"string"==typeof(e=t)&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e)||/^[a-z]{1,}$/i.test(e));var e},imageSrc:function(t){return w(t)||x(t)},imageURL:x,imageBase64:w,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let i=document.createElement("div");i.innerHTML=t,i.children.length>0&&(e=!0),i=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return p(t)&&t>0},lineHeight:function(t){return p(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)}};class v{#t;constructor(){this.#t=new Map}on(t,e){if(this.#t.has(t)){const i=this.#t.get(t)||[];i?.push(e),this.#t.set(t,i)}else this.#t.set(t,[e])}off(t,e){if(this.#t.has(t)){const i=this.#t.get(t);if(Array.isArray(i))for(let t=0;t<i?.length;t++)if(i[t]===e){i.splice(t,1);break}this.#t.set(t,i||[])}}trigger(t,e){const i=this.#t.get(t);return!!Array.isArray(i)&&(i.forEach(t=>{t(e)}),!0)}has(t){if(this.#t.has(t)){const e=this.#t.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#t.clear()}}function M(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}class S{#e;#i;#n;constructor(t){this.#i=s(t.defaultStorage),this.#e=this.#o(),this.#n=t.defaultStatic||{}}set(t,e){this.#e[t]=e}get(t){return this.#e[t]}setStatic(t,e){this.#n[t]=e}getStatic(t){return this.#n[t]}getSnapshot(t){return!0===t?.deepClone?s(this.#e):{...this.#e}}clear(){this.#e=this.#o()}destroy(){this.#e=null,this.#n=null}#o(){return s(this.#i)}}function L(t){return t/180*Math.PI}function C(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function k(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),i=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return C({x:e,y:i,width:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,height:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-i})}function A(t,e,i){const n=function(t,e){const i=e.x-t.x,n=e.y-t.y;if(0===i){if(n<0)return 0;if(n>0)return Math.PI}else if(0===n){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&n<0?Math.atan(Math.abs(i)/Math.abs(n)):i>0&&n>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):0}(t,e);let o=n+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(t,e){const i=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===i?i:Math.sqrt(i)}(t,e);let a=0,s=0;return 0===o?(a=0,s=0-r):o>0&&o<Math.PI/2?(a=Math.sin(o)*r,s=0-Math.cos(o)*r):o===Math.PI/2?(a=r,s=0):o>Math.PI/2&&o<Math.PI?(a=Math.sin(Math.PI-o)*r,s=Math.cos(Math.PI-o)*r):o===Math.PI?(a=0,s=r):o>Math.PI&&o<1.5*Math.PI?(a=0-Math.sin(o-Math.PI)*r,s=Math.cos(o-Math.PI)*r):o===1.5*Math.PI?(a=0-r,s=0):o>1.5*Math.PI&&o<2*Math.PI?(a=0-Math.sin(2*Math.PI-o)*r,s=0-Math.cos(2*Math.PI-o)*r):o===2*Math.PI&&(a=0,s=0-r),a+=t.x,s+=t.y,{x:a,y:s}}function R(t,e,i){const{x:n,y:o,width:r,height:a}=t;let s={x:n,y:o},l={x:n+r,y:o},c={x:n+r,y:o+a},h={x:n,y:o+a};if(i&&(i>0||i<0)){const t=L(T(i));s=A(e,s,t),l=A(e,l,t),c=A(e,c,t),h=A(e,h,t)}return[s,l,c,h]}function P(t,e,i){return[A(t,{x:e[0].x,y:e[0].y},i),A(t,{x:e[1].x,y:e[1].y},i),A(t,{x:e[2].x,y:e[2].y},i),A(t,{x:e[3].x,y:e[3].y},i)]}function T(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function $(t,e){const i=[];let n=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const o=n[e[t]];if("group"!==o?.type||!Array.isArray(o?.children))return null;i.push(o),n=o.children}return i}function D(t){const{x:e,y:i,height:n,width:o}=t;return[{x:e,y:i},{x:e+o,y:i},{x:e+o,y:i+n},{x:e,y:i+n}]}function z(t){const{x:e,y:i,width:n,height:o,angle:r=0}=t;return 0===r?D(t):R(t,C({x:e,y:i,width:n,height:o}),r)}function O(t,e){const{groupQueue:i}=e;if(!(i.length>0))return[z(t)];const n=function(t){const e=[];let i=0,n=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:s,width:l,height:c,angle:h=0}=r[t];let u;if(i+=a,n+=s,0===t){const t={x:i,y:n,width:l,height:c};u=z({x:a,y:s,width:l,height:c,angle:h}),o.push({center:C(t),angle:h,radian:L(h)})}else{u=D({x:i,y:n,width:l,height:c});for(let t=0;t<o.length;t++){const{center:e,radian:i}=o[t];u=P(e,u,i)}const t=k(u);(h>0||h<0)&&(u=P(t,u,L(h))),o.push({center:t,angle:h,radian:L(h)})}e.push(u)}return e}([...i,t]);return n}function V(t,e){const{viewScaleInfo:i}=e,{id:n,x:o,y:r,width:a,height:s,angle:l}=t,{scale:c=1,offsetTop:h=0,offsetLeft:u=0}=i;return{id:n,x:o*c+u,y:r*c+h,width:a*c,height:s*c,angle:l}}function E(t,e){const{viewScaleInfo:i}=e,{x:n,y:o}=t,{scale:r,offsetTop:a,offsetLeft:s}=i;return{x:n*r+s,y:o*r+a}}function j(t,e){const{context2d:i,material:n,viewScaleInfo:o}=e,{angle:r=0}=n,{x:a,y:s,width:l,height:c}=V(n,{viewScaleInfo:o}),h=function(t){const{angle:e=0}=t;return R(t,C(t),e)}({x:a,y:s,width:l,height:c,angle:r});if(h.length>=2){i.beginPath(),i.moveTo(h[0].x,h[0].y);for(let t=1;t<h.length;t++)i.lineTo(h[t].x,h[t].y);i.closePath()}return!!i.isPointInPath(t.x,t.y)}function F(t,e){const{groupQueue:i}=e,n=function(t,e){return O(t,e).pop()||null}(t,{groupQueue:i}),o=M(n[0],n[1]),r=M(n[1],n[2]),a=M(n[2],n[3]),s=M(n[3],n[0]),l=n[0],c=n[1],h=n[2],u=n[3],f=Math.max(l.x,c.x,h.x,u.x),p=Math.max(l.y,c.y,h.y,u.y);return{center:{x:(f+Math.min(l.x,c.x,h.x,u.x))/2,y:(p+Math.min(l.y,c.y,h.y,u.y))/2},topLeft:l,topRight:c,bottomLeft:u,bottomRight:h,top:o,right:r,left:s,bottom:a}}function B(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),i=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),n=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},a={x:n,y:o},s={x:e,y:o},l={x:e,y:i},c={x:n,y:i},h=M(a,s),u=M(c,l),f=M(a,c);return{center:r,topLeft:a,topRight:s,bottomLeft:c,bottomRight:l,top:h,right:M(s,l),left:f,bottom:u}}function W(t){let e="";return t.forEach(t=>{e+=t.type+t.params?.join?.(" ")}),e}const Q="#787878",U=`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="${Q}"><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 H(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:Q,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:"Text",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:U}}const G=["-apple-system",'"system-ui"',' "Segoe UI"'," Roboto",'"Helvetica Neue"',"Arial",'"Noto Sans"'," sans-serif"];function N(t){return[t,...G].join(", ")}const Z=()=>Math.random().toString(36).substring(2);function J(){return`${Z()}${Z()}`.substring(0,16)}function X(t,e,i){const n=[];return t.forEach(t=>{const o=function(t,e,i){const{type:n}=t,o=[...t.params],r=t.id;let a={id:r};if(t.start&&t.end){const n={...t.start},o={...t.end};n.x+=e,n.y+=i,o.x+=e,o.y+=i,a={id:r,start:n,end:o}}switch(n){case"M":case"L":case"T":return o[0]+=e,o[1]+=i,{type:n,params:o,...a};case"H":return o[0]+=e,{type:n,params:o,...a};case"V":return o[0]+=i,{type:n,params:o,...a};case"C":return o[0]+=e,o[1]+=i,o[2]+=e,o[3]+=i,o[4]+=e,o[5]+=i,{type:n,params:o,...a};case"S":case"Q":return o[0]+=e,o[1]+=i,o[2]+=e,o[3]+=i,{type:n,params:o,...a};case"A":return o[5]+=e,o[6]+=i,{type:n,params:o,...a};default:return{type:n,params:o,...a}}}(t,e,i);n.push(o)}),n}function Y(t,e,i){return t.map(t=>{const{id:n,type:o,params:r}=t,a=[];let s={id:n};if(t.start&&t.end){const o={...t.start},r={...t.end};o.x*=e,o.y*=i,r.x*=e,r.y*=i,s={id:n,start:o,end:r}}switch(o.toUpperCase()){case"M":case"L":case"T":for(let t=0;t<r.length;t+=2)a.push(r[t]*e,r[t+1]*i);break;case"C":for(let t=0;t<r.length;t+=6)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i,r[t+4]*e,r[t+5]*i);break;case"S":for(let t=0;t<r.length;t+=4)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i);break;case"Q":for(let t=0;t<r.length;t+=4)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i);break;case"H":r.forEach(t=>a.push(t*e));break;case"V":r.forEach(t=>a.push(t*i));break;case"A":for(let t=0;t<r.length;t+=7)a.push(r[t]*e,r[t+1]*i,r[t+2],r[t+3],r[t+4],r[t+5]*e,r[t+6]*i);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let t=0;t<r.length;t++){const n="a"===o&&(t%7==0||t%7==5)||"h"===o||"v"!==o&&t%2==0;a.push(r[t]*(n?e:i))}break;default:return{type:o,params:[...r],...s}}return{type:o,params:a,...s}})}function q(t,i,n){if("string"==typeof i)return i;const{viewMaterialSize:o,viewScaleInfo:r,opacity:a=1}=n,{x:s,y:l}=o,{scale:c}=r;if("linear-gradient"===i?.type){const{start:n,end:o,stops:r}=i,h={x:s+n.x*c,y:l+n.y*c},u={x:s+o.x*c,y:l+o.y*c},f=t.createLinearGradient(h.x,h.y,u.x,u.y);return r.forEach(t=>{t.offset>=0&&t.color&&f.addColorStop(t.offset,e(t.color,a))}),f}if("radial-gradient"===i?.type){const{inner:n,outer:o,stops:r}=i,h={x:s+n.x*c,y:l+n.y*c,radius:n.radius*c},u={x:s+o.x*c,y:l+o.y*c,radius:o.radius*c},f=t.createRadialGradient(h.x,h.y,h.radius,u.x,u.y,u.radius);return r.forEach(t=>{f.addColorStop(t.offset,e(t.color,a))}),f}return"#000000"}let K=H();function _(t,e,i){const{viewScaleInfo:n,viewSizeInfo:o,calculator:r}=i,{opacity:a,fill:s,fillOpacity:l,fillRule:c,stroke:h,strokeWidth:u,strokeOpacity:f,strokeLinecap:p,strokeLinejoin:d,strokeDasharray:y,strokeDashoffset:g,strokeMiterlimit:m}={...K,...e},{scale:x,offsetLeft:w,offsetTop:b}=n,{devicePixelRatio:v}=o,M=r.getVirtualItem(e.id),{commands:S,worldCenter:L}=M,{width:C,height:k}=e;let A=S;A=Y(A,x,x),A=X(A,(w+(L.x-C/2)*x)*v,(b+(L.y-k/2)*x)*v);const R=t.globalAlpha,P=W(A),T=new Path2D(P);!function(t,e,i){const{...n}=e,{viewScaleInfo:o,viewSizeInfo:r,tempContext:a,path2d:s}=i,{width:l,height:c}=r,{shadowColor:h,shadowOffsetX:u,shadowOffsetY:f,shadowBlur:p}=n;I.number(p)&&h&&(a.clearRect(0,0,a.canvas.width,a.canvas.height),a.save(),a.shadowColor=h,a.shadowOffsetX=(u||0)*o.scale,a.shadowOffsetY=(f||0)*o.scale,a.shadowBlur=(p||0)*o.scale,a.fillStyle="#ffffff",a.fill(s),a.restore(),a.save(),a.globalCompositeOperation="destination-out",a.fillStyle="#ffffff",a.fill(s),a.restore(),t.drawImage(a.canvas,0,0,l,c),a.clearRect(0,0,a.canvas.width,a.canvas.height))}(t,e,{...i,path2d:T}),tt(t,e,{path2d:T,viewScaleInfo:n,viewSizeInfo:o,calculator:r,renderContent:()=>{if(s){const i=V(e,{viewScaleInfo:n});"number"==typeof l&&l>0&&(t.globalAlpha=R*l*a),t.fillStyle=q(t,s,{viewMaterialSize:i,viewScaleInfo:n,opacity:e.opacity||1}),t.fill(T,c),t.globalAlpha=R}if("number"==typeof u&&u>0){if("number"==typeof f&&f>0&&(t.globalAlpha=R*f*a),t.lineCap=p,t.lineJoin=d,t.lineDashOffset=g,t.miterLimit=m,Array.isArray(y)){const e=y.map(t=>x*t);t.setLineDash(e)}t.lineWidth=u*x,t.strokeStyle=h,t.stroke(T),t.setLineDash([]),t.lineCap=K.strokeLinecap,t.lineJoin=K.strokeLinejoin,t.lineDashOffset=K.strokeDashoffset,t.miterLimit=K.strokeMiterlimit,t.globalAlpha=R}}})}function tt(t,e,i){const{renderContent:n,calculator:o,viewScaleInfo:r,viewSizeInfo:a}=i;if("hidden"===e.overflow){let s=i.path2d;if(!s){const{scale:t,offsetLeft:i,offsetTop:n}=r,{devicePixelRatio:l}=a,c=o.getVirtualItem(e.id),{commands:h,worldCenter:u}=c,{width:f,height:p}=e;let d=h;d=Y(d,t,t),d=X(d,(i+(u.x-f/2)*t)*l,(n+(u.y-p/2)*t)*l);const y=W(d);s=new Path2D(y)}t.save(),t.clip(s,"nonzero"),n?.(),t.restore()}else n?.()}function et(t,e,i,n){const{viewScaleInfo:o,calculator:r}=i,a=r?.getVirtualItem(e.id);if(a){const{worldAngle:i,worldCenter:r}=a,s=E(r,{viewScaleInfo:o}),{scale:l}=o;!function(t,e,i,n){const o=L(e||0);i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(o),t.translate(-i.x,-i.y)),n(t),i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(-o),t.translate(-i.x,-i.y))}(t,i,s,()=>{const t=e.width*l,i=e.height*l,o={x:s.x-t/2,y:s.y-i/2,width:t,height:i};n({viewWorldCenter:s,viewWorldSize:o})})}}function it(t,e,i){et(t,e,i,()=>{_(t,e,i)})}function nt(t,e,i){et(t,e,i,()=>{_(t,e,i)})}function ot(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o,parentOpacity:r}=i,{x:a,y:s,width:l,height:c,angle:h}=V(e,{viewScaleInfo:o})||e,u={...e,x:a,y:s,width:l,height:c,angle:h};et(t,e,i,()=>{if(n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"image"===e.type&&n){t.globalAlpha=function(t){let e=1;return void 0!==t?.opacity&&t?.opacity>=0&&t?.opacity<=1&&(e=t?.opacity),e}(e)*r;const{x:i,y:o,width:a,height:s}=u,l=[0,0,0,0],c=e,{scaleMode:h,originW:f=0,originH:p=0}=c,d=t.$undoPixelRatio(f),y=t.$undoPixelRatio(p);if(t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(i+l[0],o),t.arcTo(i+a,o,i+a,o+s,l[1]),t.arcTo(i+a,o+s,i,o+s,l[2]),t.arcTo(i,o+s,i,o,l[3]),t.arcTo(i,o,i+a,o,l[0]),t.closePath(),t.fill("nonzero"),t.clip("nonzero"),h&&p&&f){let r=0,l=0,c=d,u=y;const f=i,p=o,g=a,m=s;if(d>e.width||y>e.height)if("fill"===h){const t=Math.max(e.width/d,e.height/y),i=y*t;r=(d*t-e.width)/2/t,l=(i-e.height)/2/t,c=e.width/t,u=e.height/t}else if("tile"===h)r=0,l=0,c=e.width,u=e.height;else if("fit"===h){const t=Math.min(e.width/d,e.height/y);r=(d-e.width/t)/2,l=(y-e.height/t)/2,c=e.width/t,u=e.height/t}t.drawImage(n,r,l,c,u,f,p,g,m)}else t.drawImage(n,i,o,a,s);t.globalAlpha=r,t.restore()}})}function rt(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o}=i,{x:r,y:a,width:s,height:l}=V(e,{viewScaleInfo:o})||e;et(t,e,i,()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"svgCode"===e.type&&n&&t.drawImage(n,r,a,s,l)})}function at(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o}=i,{x:r,y:a,width:s,height:l}=V(e,{viewScaleInfo:o})||e;et(t,e,i,()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"foreignObject"===e.type&&n&&t.drawImage(n,r,a,s,l)})}K=function(t,e){const i={...t};for(const t of e)delete i[t];return i}(K,["fill"]);const st=H();function lt(t,e,i){const{viewScaleInfo:n,viewSizeInfo:o,calculator:r}=i,a=V(e,{viewScaleInfo:n})||e,{scale:s}=n;et(t,e,i,({viewWorldSize:i})=>{{const l={...st,...e},{x:c,y:h}=i,u=(l.fontSize||st.fontSize)*n.scale,{opacity:f,fill:p,fillOpacity:d,stroke:y,strokeWidth:g,strokeOpacity:m,strokeLinecap:x,strokeLinejoin:w,strokeDasharray:b,strokeDashoffset:I,strokeMiterlimit:v}=l;if(u<2)return;const M=t.globalAlpha,S=r.getVirtualItem(e.id);t.textBaseline="top",t.$setFont({fontWeight:l.fontWeight,fontSize:u,fontFamily:N(l.fontFamily)}),tt(t,e,{viewScaleInfo:n,viewSizeInfo:o,calculator:r,renderContent:()=>{if(p&&("number"==typeof d&&d>0&&(t.globalAlpha=M*d*f),t.fillStyle=q(t,p,{viewMaterialSize:a,viewScaleInfo:n,opacity:e.opacity||1}),Array.isArray(S?.textLines)&&S?.textLines?.length>0&&S?.textLines?.forEach(e=>{t.fillText(e.text,c+e.x*n.scale,h+e.y*n.scale)}),t.globalAlpha=M),"number"==typeof g&&g>0){if("number"==typeof m&&m>0&&(t.globalAlpha=M*m*f),t.lineCap=x,t.lineJoin=w,t.lineDashOffset=I,t.miterLimit=v,Array.isArray(b)){const e=b.map(t=>s*t);t.setLineDash(e)}t.lineWidth=g*s,t.strokeStyle=y,S?.textLines?.forEach(e=>{t.strokeText(e.text,c+e.x*n.scale,h+e.y*n.scale)}),t.setLineDash([]),t.lineCap=st.strokeLinecap,t.lineJoin=st.strokeLinejoin,t.lineDashOffset=st.strokeDashoffset,t.miterLimit=st.strokeMiterlimit,t.globalAlpha=M}}})}})}function ct(t,e,i){if(!0===e?.operations?.invisible)return;const{width:n,height:o}=e,{scale:r}=i.viewScaleInfo;if(r<1&&(n*r<.4||o*r<.4)||0===i.parentOpacity)return;const{overrideMaterialMap:a}=i;if(!a?.[e.id]?.operations?.invisible)try{switch(e.type){case"rect":it(t,e,i);break;case"circle":nt(t,e,i);break;case"ellipse":case"path":!function(t,e,i){et(t,e,i,()=>{_(t,e,i)})}(t,e,i);break;case"text":lt(t,e,i);break;case"image":ot(t,e,i);break;case"svgCode":rt(t,e,i);break;case"foreignObject":at(t,e,i);break;case"group":{const n={...i.materialAssets||{},...e.assets||{}};ht(t,e,{...i,materialAssets:n});break}}}catch(t){console.error(t)}}function ht(t,e,i){if(et(t,e,i,()=>{_(t,e,i)}),Array.isArray(e.children)){const{parentMaterialSize:n}=i,o={x:n.x+e.x,y:n.y+e.y,width:e.width||n.width,height:e.height||n.height,angle:e.angle},{calculator:r}=i;for(let n=0;n<e.children.length;n++){let a=e.children[n];if(a={...a,x:o.x+a.x,y:o.y+a.y},!0===i.forceDrawAll||r?.needRender(a))try{ct(t,a,i)}catch(t){console.error(t)}}}}const ut=H();function ft(t,e,i){const{materials:n=[]}=e,{parentOpacity:o}=i;for(let e=0;e<n.length;e++){const r=n[e],a={...r,attributes:{...ut,...r}};if(!0===i.forceDrawAll||i.calculator?.needRender(a))try{ct(t,a,{...i,parentOpacity:o})}catch(t){console.error(t)}}}function pt(t,e,i,n){const{parentOpacity:o}=i;t.globalAlpha=1;const{viewScaleInfo:r}=i,a={id:"layout",type:"group",...e},s=V(a,{viewScaleInfo:r})||a,l={...a,...s},{x:c,y:h,width:u,height:f,fill:p}=l,d=[0,0,0,0];t.save(),t.fillStyle=q(t,p,{viewMaterialSize:s,viewScaleInfo:r,opacity:a.opacity||1}),t.beginPath(),t.moveTo(c+d[0],h),t.arcTo(c+u,h,c+u,h+f,d[1]),t.arcTo(c+u,h+f,c,h+f,d[2]),t.arcTo(c,h+f,c,h,d[3]),t.arcTo(c,h,c+u,h,d[0]),t.closePath(),t.fill("nonzero"),"hidden"===e.overflow&&t.clip("nonzero"),n(t),"hidden"===e.overflow&&t.restore(),t.globalAlpha=o}function dt(t,e,i){if("string"==typeof e?.fill){const{viewSizeInfo:n}=i,{width:o,height:r}=n;t.globalAlpha=1,t.fillStyle=e.fill,t.fillRect(0,0,o,r)}}const yt=["image","svgCode","foreignObject"],gt=t=>{let e=null;return"image"===t.type?e=t?.href||null:"svgCode"===t.type?e=t?.code||null:"foreignObject"===t.type&&(e=t?.content||null),"string"==typeof e&&e?a(e)?e:r(e,t.id):r(`${n()}-${t.id}-${n()}-${n()}`,t.id)};class mt extends v{#r={};#a={};#s={};#l=!1;constructor(){super(),this.#c("image",async(t,e)=>{const i=e[t.href]?.value||t.href,n=await c(i);return{id:t.id,lastModified:Date.now(),content:n}}),this.#c("foreignObject",async(t,e)=>{const i=e[t.content]?.value||t.content,n=await u(i,{width:t.originW||t.width,height:t.originH||t.height});return{id:t.id,lastModified:Date.now(),content:n}}),this.#c("svgCode",async(t,e)=>{const i=e[t.code]?.value||t.code,n=await h(i);return{id:t.id,lastModified:Date.now(),content:n}})}isDestroyed(){return this.#l}reset(){!0!==this.#l&&(this.#a={},this.#s={})}resetMaterialAsset(t){if(yt.includes(t.type)){let e=null,i=null;"image"===t.type&&"string"==typeof t?.href?i=t.href:"svgCode"===t.type&&"string"==typeof t?.code?i=t.code:"foreignObject"===t.type&&"string"==typeof t?.content&&(i=t.content),"string"==typeof i&&(this.load(t,{}),a(i)?e=i:t.id&&(e=r(i,t.id))),e&&a(e)&&(delete this.#s[e],delete this.#a[e])}}destroy(){this.#l=!0,this.clear(),this.#r=null,this.#a=null,this.#s=null}#c(t,e){this.#r[t]=e}#h(t){let e=null;return"image"===t.type?e=t?.href||null:"svgCode"===t.type?e=t?.code||null:"foreignObject"===t.type&&(e=t?.content||null),e}#u(t){return{material:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this.#h(t)}}#f(t){const e=gt(t.material),i=this.#s[e];this.#l||(i?i.startTime<t.startTime&&(this.#s[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})):(this.#s[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})))}#p(t){const e=gt(t.material),i=this.#s?.[e];this.#l||(i?i.startTime<t.startTime&&(this.#s[e]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})):(this.#s[e]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})))}#d(t,e){const i=this.#u(t),n=gt(t);if(this.#a[n])return;this.#a[n]=i;const o=this.#r[t.type];"function"!=typeof o||this.#l||(i.startTime=Date.now(),o(t,e).then(t=>{this.#l||(i.content=t.content,i.endTime=Date.now(),i.status="load",this.#f(i))}).catch(e=>{console.warn(`Load material source "${i.source}" fail`,e,t),i.endTime=Date.now(),i.status="error",i.error=e,this.#p(i)}))}#y(t){const e=gt(t),i=this.#a?.[e];return!(!i||"error"!==i.status||!i.source||i.source!==this.#h(t))}load(t,e){!0!==this.#l&&(this.#y(t)||yt.includes(t.type)&&this.#d(t,e))}getContent(t){const e=gt(t);return this.#s?.[e]?.content||null}getLoadItemMap(){return this.#s}setLoadItemMap(t){this.#s=t}}function xt(t,e){const i=e.width/2,n=e.height/2,o=t.x-i,r=t.y-n;let a=o,s=r;if("number"==typeof e.angle&&0!==e.angle){const t=e.angle*Math.PI/180,i=Math.cos(t),n=Math.sin(t);a=o*i-r*n,s=o*n+r*i}const l=s+n;return{x:a+i+e.x,y:l+e.y}}function wt(t,e){const{groupQueue:i=[]}=e;let n=t.angle||0;i.forEach(t=>{n+=t.angle||0});return{worldCenter:function(t,e){if(!(e=[...e].reverse())||0===e.length)return{x:t.x+t.width/2,y:t.y+t.height/2};let i=t.x+t.width/2,n=t.y+t.height/2;for(let t=0;t<e.length;t++){const o=xt({x:i,y:n},e[t]);i=o.x,n=o.y}return{x:i,y:n}}(t,i),worldAngle:T(n)}}function bt(t,e){const{dpr:i}=e;let{width:n,height:o,rx:r=0,ry:a=0}=t;const{cornerRadius:s}=t;o*=i,n*=i;const l=[];let c=0,h=0,u=0,f=0,p=0,d=0,y=0,g=0;if("number"==typeof r&&"number"==typeof a)r*=i,a*=i,c=r,h=r,u=r,f=r,p=a,d=a,y=a,g=a;else if(Array.isArray(s)&&4===s.length){const t=s.map(t=>t*i);c=t[0]||0,h=t[1]||0,u=t[2]||0,f=t[3]||0,p=t[0]||0,d=t[1]||0,y=t[2]||0,g=t[3]||0}else if("number"==typeof s){const t=s*i;c=t,h=t,u=t,f=t,p=t,d=t,y=t,g=t}const m=0+n,x=0+o;l.push({id:J(),type:"M",params:[0+c,0]}),h>0||d>0?(l.push({id:J(),type:"L",params:[m-h,0]}),l.push({id:J(),type:"A",params:[h,d,0,0,1,m,0+d]})):l.push({id:J(),type:"L",params:[m,0]}),u>0||y>0?(l.push({id:J(),type:"L",params:[m,x-y]}),l.push({id:J(),type:"A",params:[u,y,0,0,1,m-u,x]})):l.push({id:J(),type:"L",params:[m,x]}),f>0||g>0?(l.push({id:J(),type:"L",params:[0+f,x]}),l.push({id:J(),type:"A",params:[f,g,0,0,1,0,x-g]})):l.push({id:J(),type:"L",params:[0,x]}),c>0||p>0?(l.push({id:J(),type:"L",params:[0,0+p]}),l.push({id:J(),type:"A",params:[c,p,0,0,1,0+c,0]})):l.push({id:J(),type:"L",params:[0,0]}),l.push({id:J(),type:"Z",params:[]});return{...wt(t,e),commands:l}}const It=H();function vt(t,e,i){return t>=e}function Mt(t,e){const{dpr:i}=e,n={...wt(t,e),anchorCommands:[]},o=function(t){const e=[];let i={x:0,y:0},n={x:0,y:0},o=null;for(const r of t){const t=r.type,a=r.params,s=t===t.toLowerCase(),l=t.toUpperCase(),c=r.id;switch(l){case"M":{const[t,r]=a,l=s?{x:i.x+t,y:i.y+r}:{x:t,y:r};e.push({id:c,type:"M",params:[l.x,l.y],start:{x:t,y:r},end:{x:t,y:r}}),i=l,n=l,o=null;break}case"L":{const[t,n]=a,r=s?{x:i.x+t,y:i.y+n}:{x:t,y:n};e.push({id:c,type:"L",params:[r.x,r.y],start:{...i},end:{...r}}),i=r,o=null;break}case"H":{const[t]=a,n=s?{x:i.x+t,y:i.y}:{x:t,y:i.y};e.push({id:c,type:"L",params:[n.x,n.y],start:{...i},end:{...n}}),i=n,o=null;break}case"V":{const[t]=a,n=s?{x:i.x,y:i.y+t}:{x:i.x,y:t};e.push({id:c,type:"L",params:[n.x,n.y],start:{...i},end:{...n}}),i=n,o=null;break}case"C":{const[t,n,r,l,h,u]=a,f=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},p=s?{x:i.x+r,y:i.y+l}:{x:r,y:l},d=s?{x:i.x+h,y:i.y+u}:{x:h,y:u};e.push({id:c,type:"C",params:[f.x,f.y,p.x,p.y,d.x,d.y],start:{...i},end:{...d}}),i=d,o=p;break}case"S":{const[t,n,r,l]=a,h=o?{x:2*i.x-o.x,y:2*i.y-o.y}:i,u=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},f=s?{x:i.x+r,y:i.y+l}:{x:r,y:l};e.push({id:c,type:"C",params:[h.x,h.y,u.x,u.y,f.x,f.y],start:{...i},end:{...f}}),i=f,o=u;break}case"Q":{const[t,n,r,l]=a,h=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},u=s?{x:i.x+r,y:i.y+l}:{x:r,y:l};e.push({id:c,type:"C",params:[i.x+2/3*(h.x-i.x),i.y+2/3*(h.y-i.y),u.x+2/3*(h.x-u.x),u.y+2/3*(h.y-u.y),u.x,u.y],start:{...i},end:{...u}}),i=u,o=h;break}case"T":{const[t,n]=a,r=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},l=o?{x:2*i.x-o.x,y:2*i.y-o.y}:i;e.push({id:c,type:"C",params:[i.x+2/3*(l.x-i.x),i.y+2/3*(l.y-i.y),r.x+2/3*(l.x-r.x),r.y+2/3*(l.y-r.y),r.x,r.y],start:{...i},end:{...r}}),i=r,o=l;break}case"A":{const[t,n,r,l,h,u,f]=a,p=s?{x:i.x+u,y:i.y+f}:{x:u,y:f};e.push({id:c,type:"A",params:[t,n,r,l,h,p.x,p.y],start:{...i},end:{...p}}),i=p,o=null;break}case"Z":e.push({id:c,type:"Z",params:[],start:{...i},end:{...n}}),i=n,o=null;break;default:throw new Error(`Unsupported command: ${t}`)}}return e}(t.commands||[]);return n.anchorCommands=o,n.commands=Y(t.commands,i,i),n}function St(t,e){let i=null;switch(t.type){case"rect":case"group":i=bt(t,e);break;case"circle":i=function(t,e){const{dpr:i}=e,{width:n,height:o}=t;let{r:r}=t;const a=n/2*i,s=o/2*i;r*=i;const l=.55228475*r,c=[{type:"M",params:[a+r,s]},{type:"C",params:[a+r,s-l,a+l,s-r,a,s-r]},{type:"C",params:[a-l,s-r,a-r,s-l,a-r,s]},{type:"C",params:[a-r,s+l,a-l,s+r,a,s+r]},{type:"C",params:[a+l,s+r,a+r,s+l,a+r,s]},{type:"Z",params:[]}];return{...wt(t,e),commands:c}}(t,e);break;case"ellipse":i=function(t,e){const{dpr:i}=e,{width:n,height:o}=t;let{rx:r,ry:a}=t;const s=n/2*i,l=o/2*i;r*=i,a*=i;const c=.55228475*r,h=.55228475*a,u=[{type:"M",params:[s+r,l]},{type:"C",params:[s+r,l-h,s+c,l-a,s,l-a]},{type:"C",params:[s-c,l-a,s-r,l-h,s-r,l]},{type:"C",params:[s-r,l+h,s-c,l+a,s,l+a]},{type:"C",params:[s+c,l+a,s+r,l+h,s+r,l]},{type:"Z",params:[]}];return{...wt(t,e),commands:u}}(t,e);break;case"text":i=function(t,e){const{width:i,height:n}=t,o=e.tempContext,r=[],a={...It,...t},s=a.fontSize||It.fontSize,l=s,c=bt(t,e);if(l<2)return{...c,textLines:[]};const h=a.lineHeight||s;o.textBaseline="top",o.$setFont({fontWeight:a.fontWeight,fontSize:l,fontFamily:N(a.fontFamily)});let u=a.text.replace(/\r\n/gi,"\n");"lowercase"===a.textTransform?u=u.toLowerCase():"uppercase"===a.textTransform&&(u=u.toUpperCase());const f=h,p=u.split("\n");let d=0;p.forEach((t,e)=>{if("maxContent"===a.minInlineSize){const e=o.measureText(t);r.push({x:0,y:0,text:t,width:o.$undoPixelRatio(e.width)})}else{let s="",l="",c=t.split(l);if("normal"===a.wordBreak){l=" ";const e=t.split(l);c=[],e.forEach((t,i)=>{c.push(t),i<e.length-1&&c.push(l)})}if(1===c.length&&"hidden"!==a.overflow)r.push({x:0,y:0,text:c[0],width:o.$undoPixelRatio(o.measureText(c[0]).width)});else if(c.length>0){for(let t=0;t<c.length;t++){if(vt(o.$doPixelRatio(i),o.measureText(s+c[t]).width)?s+=c[t]||"":(r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s=c[t]||"",d++),d*f>=n&&"hidden"===a.overflow){s="";break}if(c.length-1===t&&(d+1)*f<=n){r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s="",e<p.length-1&&d++;break}}s&&(r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s="")}else r.push({x:0,y:0,text:"",width:0})}});let y=0,g=0;f>l&&(g=(f-l)/2),r.length*f<n&&("top"===a.verticalAlign?y=0:"bottom"===a.verticalAlign?y+=n-r.length*f:y+=(n-r.length*f)/2);{const t=0+y;r.forEach((e,n)=>{let o=0;"center"===a.textAlign?o=0+(i-e.width)/2:"right"===a.textAlign&&(o=i-e.width+0),r[n].x=o,r[n].y=t+f*n+g})}return{...c,textLines:r}}(t,e);break;case"path":i=Mt(t,e);break;default:i=wt(t,e)}return i}function Lt(t,e){const{viewScaleInfo:i,viewSizeInfo:n,tempContext:o}=e,r=function(t,e){const i={},n=[],o=r=>{const a={type:r.type,isVisibleInView:!0,position:[...n]};let s=null;const l=$(t,n);s=F(r,{groupQueue:l||[]});const c={...a,boundingInfo:s,rangeBoundingInfo:I.angle(r.angle)?B(s):s,...St(r,{...e,groupQueue:l||[]})};i[r.id]=c,"group"===r.type&&r.children.forEach((t,e)=>{n.push(e),o(t),n.pop()})};return t.forEach((t,e)=>{n.push(e),o(t),n.pop()}),i}(t,{tempContext:o,dpr:n.devicePixelRatio});return Ct(r,{viewScaleInfo:i,viewSizeInfo:n})}function Ct(t,e){const i=function(t){const{viewScaleInfo:e,viewSizeInfo:i}=t,{scale:n,offsetTop:o,offsetLeft:r}=e,{width:a,height:s}=i,l=0-r/n,c=0-o/n,h=a/n,u=s/n,f=C({x:l,y:c,width:a,height:s}),p={x:l,y:c},d={x:l+h,y:c},y={x:l,y:c+u},g={x:l+h,y:c+u},m={x:l,y:f.y},x={x:f.x,y:c},w={x:l+h,y:f.y},b={x:f.x,y:c+u};return{center:f,topLeft:p,topRight:d,bottomLeft:y,bottomRight:g,left:m,top:x,right:w,bottom:b}}(e);let n=0,o=0;return Object.keys(t).forEach(e=>{const r=t[e];r.isVisibleInView=function(t,e){const i=t.center.x,n=t.center.y,o=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),r=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),a=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),s=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),l=Math.abs(r-o),c=Math.abs(s-a),h=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x)-l,u=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x)+l,f=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y)-c,p=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y)+c;return i>=h&&i<=u&&n>=f&&n<=p}(r.rangeBoundingInfo,i),r.isVisibleInView?n++:o++}),{virtualItemMap:t,visibleCount:n,invisibleCount:o}}class kt{#g;#m;constructor(t){this.#g=t,this.#m=new S({defaultStorage:{virtualItemMap:{},visibleCount:0,invisibleCount:0}})}toGridNum(t,e){return!0===e?.ignore?t:Math.round(t)}destroy(){this.#g=null}needRender(t){const e=this.#m.get("virtualItemMap")[t.id];return!e||e.isVisibleInView}forceVisiable(t){const e=this.#m.get("virtualItemMap")[t];e&&(e.isVisibleInView=!0)}getPointMaterial(t,e){return function(t,e){const{context2d:i,data:n,viewScaleInfo:o,groupQueue:r}=e,a={index:-1,material:null,groupQueueIndex:-1};if(r&&Array.isArray(r)&&r?.length>0)for(let e=r.length-1;e>=0;e--){let n=0,s=0,l=0;for(let t=0;t<=e;t++)n+=r[t].x,s+=r[t].y,l+=r[t].angle||0;const c=r[e];if(c&&"group"===c.type&&Array.isArray(c?.children))for(let h=0;h<c.children.length;h++){const u=c.children[h];if(!0!==u?.operations?.invisible){if(!u)break;if(j(t,{context2d:i,material:{x:n+u.x,y:s+u.y,width:u.width,height:u.height,angle:l+(u.angle||0)},viewScaleInfo:o})){a.material=u,(e<r.length-1||"group"!==u.type)&&(a.groupQueueIndex=e);break}}}if(a.material)break}if(a.material)return a;for(let e=n.materials.length-1;e>=0;e--){const r=n.materials[e];if(!0!==r?.operations?.invisible&&j(t,{context2d:i,material:r,viewScaleInfo:o})){a.index=e,a.material=r;break}}return a}(t,{...e,context2d:this.#g.tempContext})}resetVirtualItemMap(t,e){if(t){const{virtualItemMap:i,invisibleCount:n,visibleCount:o}=Lt(t.materials,{...e,tempContext:this.#g.tempContext});this.#m.set("virtualItemMap",i),this.#m.set("invisibleCount",n),this.#m.set("visibleCount",o)}}updateVisiableStatus(t){const{virtualItemMap:e,invisibleCount:i,visibleCount:n}=Ct(this.#m.get("virtualItemMap"),t);this.#m.set("virtualItemMap",e),this.#m.set("invisibleCount",i),this.#m.set("visibleCount",n)}calcViewBoundingInfoFromOrigin(t,e){const i=this.#m.get("virtualItemMap")[t];if(!i?.boundingInfo)return null;const{checkVisible:n,viewScaleInfo:o,viewSizeInfo:r}=e,{center:a,left:s,right:l,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:p,bottomRight:d}=i.boundingInfo;if(!0===n&&!1===i.isVisibleInView)return null;const y={viewScaleInfo:o};return{center:E(a,y),left:E(s,y),right:E(l,y),bottom:E(c,y),top:E(h,y),topLeft:E(u,y),topRight:E(f,y),bottomLeft:E(p,y),bottomRight:E(d,y)}}calcViewBoundingInfoFromRange(t,e){const i=this.#m.get("virtualItemMap")[t];if(!i?.boundingInfo)return null;const{checkVisible:n,viewScaleInfo:o,viewSizeInfo:r}=e,{center:a,left:s,right:l,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:p,bottomRight:d}=i.rangeBoundingInfo;if(!0===n&&!1===i.isVisibleInView)return null;const y={viewScaleInfo:o};return{center:E(a,y),left:E(s,y),right:E(l,y),bottom:E(c,y),top:E(h,y),topLeft:E(u,y),topRight:E(f,y),bottomLeft:E(p,y),bottomRight:E(d,y)}}modifyVirtualAttributes(t,e){const{viewSizeInfo:i,groupQueue:n}=e,o=this.#m.get("virtualItemMap"),r=o[t.id],a=St(t,{tempContext:this.#g.tempContext,dpr:i.devicePixelRatio,groupQueue:n});if(a){const e=F(t,{groupQueue:n}),i={...r,...a,boundingInfo:e,rangeBoundingInfo:I.angle(t.angle)?B(e):e};o[t.id]=i,this.#m.set("virtualItemMap",o)}}modifyVirtualItemMap(t,e){const{modifyInfo:i,viewScaleInfo:n,viewSizeInfo:o}=e,{type:r,content:a}=i,s=t.materials,l=this.#m.get("virtualItemMap");if("deleteMaterial"===r){const{material:t}=a,e=[],i=t=>{e.push(t.id),"group"===t.type&&Array.isArray(t.children)&&t.children.forEach(t=>{i(t)})};i(t),e.forEach(t=>{delete l[t]}),this.#m.set("virtualItemMap",l)}else if("addMaterial"===r||"updateMaterial"===r){const{position:e}=a,i=function(t,e){let i=null,n=e;for(let e=0;e<t.length;e++){const o=n[t[e]];if(e<t.length-1&&"group"===o?.type)n=o.children;else{if(e!==t.length-1)break;i=o}}return i}(e,t.materials),c=$(s,e);if(i)if("updateMaterial"===r&&"group"===i.type)this.resetVirtualItemMap(t,{viewScaleInfo:n,viewSizeInfo:o});else{const t=F(i,{groupQueue:c||[]}),a={type:i.type,boundingInfo:t,rangeBoundingInfo:I.angle(i.angle)?B(t):t,isVisibleInView:!0,position:[...e],...St(i,{tempContext:this.#g.tempContext,dpr:o.devicePixelRatio,groupQueue:c||[]})};l[i.id]=a,this.#m.set("virtualItemMap",l),"updateMaterial"===r&&this.updateVisiableStatus({viewScaleInfo:n,viewSizeInfo:o})}}else"moveMaterial"===r&&this.resetVirtualItemMap(t,{viewScaleInfo:n,viewSizeInfo:o})}getVirtualItem(t){return this.#m.get("virtualItemMap")[t]||null}}return t.Calculator=kt,t.Renderer=class extends v{#g;#x=new mt;#w;#l=!1;constructor(t){super(),this.#g=t,this.#w=new kt({tempContext:t.tempContext}),this.#b()}isDestroyed(){return this.#l}destroy(){this.clear(),this.#g=null,this.#x.destroy(),this.#x=null,this.#l=!0}#b(){const t=this.#x;t.on("load",t=>{this.trigger("load",t)}),t.on("error",t=>{console.error(t)})}updateOptions(t){this.#g=t}drawData(t,e){const i=this.#x,n=this.#w,{sharer:o}=this.#g,r=this.#g.viewContext;r.clearRect(0,0,r.canvas.width,r.canvas.height);const a={x:0,y:0,width:e.viewSizeInfo.width,height:e.viewSizeInfo.height};!0===e.forceDrawAll&&this.#w.resetVirtualItemMap(t,{viewScaleInfo:e.viewScaleInfo,viewSizeInfo:e.viewSizeInfo});const s={loader:i,calculator:n,parentMaterialSize:a,materialAssets:t.assets,parentOpacity:1,overrideMaterialMap:o?.getActiveOverrideMaterialMap(),tempContext:this.#g.tempContext,...e};dt(r,t.global,s),t.layout?pt(r,t.layout,s,()=>{ft(r,t,s)}):ft(r,t,s)}scale(t){const{sharer:e}=this.#g;if(!e)return;const{data:i,offsetTop:n,offsetBottom:o,offsetLeft:r,offsetRight:a,width:s,height:l,contextHeight:c,contextWidth:h,devicePixelRatio:u}=e.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:t,offsetTop:n,offsetBottom:o,offsetLeft:r,offsetRight:a},viewSizeInfo:{width:s,height:l,contextHeight:c,contextWidth:h,devicePixelRatio:u}})}setLoadItemMap(t){this.#x.setLoadItemMap(t)}getLoadItemMap(){return this.#x.getLoadItemMap()}getLoader(){return this.#x}getCalculator(){return this.#w}},t.drawCircle=nt,t.drawForeignObject=at,t.drawGlobalBackground=dt,t.drawGroup=ht,t.drawImage=ot,t.drawLayout=pt,t.drawMaterial=ct,t.drawMaterialList=ft,t.drawRect=it,t.drawSVGCode=rt,t.drawText=lt,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
|
|
1
|
+
var iDrawRenderer=function(t){function e(t,e){if(1===e)return t;let i=1;const n=/^#[0-9a-f]{6,6}$/i;let o=t;if(n.test(t)?i=parseInt(t.substring(5,7).replace(/^#/,"0x")):/^#[0-9a-f]{8,8}$/i.test(t)&&(i=parseInt(t.substring(7,9).replace(/^#/,"0x")),o=t.substring(0,7)),i*=e,n.test(o)&&i>0&&i<1){const t=Math.max(0,Math.min(255,Math.ceil(256*i)));o=`${o.toUpperCase()}${t.toString(16).toUpperCase()}`}return o}function i(t){return(65536*(1+Math.random())|0).toString(t||16).substring(1)}function n(){return`${i()}${i()}-${i()}-${i()}-${i()}-${i()}${i()}${i()}`}function o(t,e){let i=0;for(let e=0;e<t.length;e++)i+=t.charCodeAt(e);return(i+e).toString(16).substring(0,4)}function r(t,e){const i=t.length,n=function(t){let e=0;for(let i=0;i<t.length;i++)e+=t.charCodeAt(i);return e}(e),r=Math.floor(i/2),a=t.substring(0,4).padStart(4,"0"),s=t.substring(0,4).padStart(4,"0");return`@assets/${o(i.toString(16).padStart(4,a),n).padStart(4,"0")}${o(t.substring(r-4,r).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-8,r-4).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-12,r-8).padStart(4,a),n).padStart(4,"0")}-${o(t.substring(r-16,r-12).padStart(4,s),n).padStart(4,"0")}-${o(t.substring(r,r+4).padStart(4,s),n).padStart(4,"0")}${o(t.substring(r+4,r+8).padStart(4,s),n).padStart(4,"0")}${o(s.padStart(4,a).padStart(4,s),n)}`}function a(t){return/^@assets\/[0-9a-z-]{0,}$/.test(`${t}`)}function s(t){return function t(e){const i=function(t){return Object.prototype.toString.call(t).replace(/[\]|\[]{1,1}/gi,"").split(" ")[1]}(e);if(["Null","Number","String","Boolean","Undefined"].indexOf(i)>=0)return e;if("Array"===i){const i=[];return e.forEach(e=>{i.push(t(e))}),i}if("Object"===i){const i={};return Object.keys(e).forEach(n=>{i[n]=t(e[n])}),Object.getOwnPropertySymbols(e).forEach(n=>{i[n]=t(e[n])}),i}}(t)}Object.defineProperty(t,Symbol.toStringTag,{value:"Module"});var{Image:l}=window;function c(t){return new Promise((e,i)=>{const n=new l;n.crossOrigin="anonymous",n.onload=function(){e(n)},n.onabort=i,n.onerror=i,n.src=t})}async function h(t){return await c(await function(t){return new Promise((e,i)=>{const n=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),o=new FileReader;o.readAsDataURL(n),o.onload=function(t){const i=t?.target?.result;e(i)},o.onerror=function(t){i(t)}})}(t))}async function u(t,e){return t=t.replace(/&/gi,"&"),await c(await function(t,e){const{width:i,height:n}=e;return new Promise((e,o)=>{const r=new Blob([`\n <svg \n xmlns="http://www.w3.org/2000/svg" \n width="${i||""}" \n height = "${n||""}">\n <foreignObject width="100%" height="100%">\n <div xmlns = "http://www.w3.org/1999/xhtml">\n ${t}\n </div>\n </foreignObject>\n </svg>\n `],{type:"image/svg+xml;charset=utf-8"}),a=new FileReader;a.readAsDataURL(r),a.onload=function(t){const i=t?.target?.result;e(i)},a.onerror=function(t){o(t)}})}(t,e))}function f(t){return"number"==typeof t&&t>=0}function p(t){return"number"==typeof t&&(t>0||t<=0)}function d(t){return p(t)}function y(t){return p(t)}function g(t){return f(t)}function m(t){return f(t)}function x(t){return"string"==typeof t&&/^(http:\/\/|https:\/\/|\.\/|\/)/.test(`${t}`)}function w(t){return"string"==typeof t&&/^(data:image\/)/.test(`${t}`)}function b(t){return["rect","circle","text","image","svgCode","foreignObject","group"].includes(t)}var v={positiveNum:f,data:function(t){return!!(Array(t?.materials)&&t?.materials.length>=0)},material:function(t){return!!t&&(b(t?.type)&&d(t?.x)&&y(t?.y)&&g(t?.w)&&m(t?.h))},layout:function(t){return!!t&&(d(t?.x)&&y(t?.y)&&g(t?.w)&&m(t?.h))},type:b,x:d,y:y,width:g,height:m,angle:function(t){return"number"==typeof t&&t>=-360&&t<=360},number:p,numberStr:function(t){return/^(-?\d+(?:\.\d+)?)$/.test(`${t}`)},strokeWidth:function(t){return f(t)||Array.isArray(t)&&f(t[0])&&f(t[1])&&f(t[2])&&f(t[3])},cornerRadius:function(t){return f(t)||Array.isArray(t)&&f(t[0])&&f(t[1])&&f(t[2])&&f(t[3])},color:function(t){return function(t){return"string"==typeof t&&(/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)||/^[a-z]{1,}$/i.test(t))}(t)},imageSrc:function(t){return w(t)||x(t)},imageURL:x,imageBase64:w,svg:function(t){return"string"==typeof t&&/^(<svg[\s]{1,}|<svg>)/i.test(`${t}`.trim())&&/<\/[\s]{0,}svg>$/i.test(`${t}`.trim())},html:function(t){let e=!1;if("string"==typeof t){let i=document.createElement("div");i.innerHTML=t,i.children.length>0&&(e=!0),i=null}return e},text:function(t){return"string"==typeof t},fontSize:function(t){return p(t)&&t>0},lineHeight:function(t){return p(t)&&t>0},textAlign:function(t){return["center","left","right"].includes(t)},fontFamily:function(t){return"string"==typeof t&&t.length>0},fontWeight:function(t){return["bold"].includes(t)}},I=class{#t;constructor(){this.#t=new Map}on(t,e){if(this.#t.has(t)){const i=this.#t.get(t)||[];i?.push(e),this.#t.set(t,i)}else this.#t.set(t,[e])}off(t,e){if(this.#t.has(t)){const i=this.#t.get(t);if(Array.isArray(i))for(let t=0;t<i?.length;t++)if(i[t]===e){i.splice(t,1);break}this.#t.set(t,i||[])}}trigger(t,e){const i=this.#t.get(t);return!!Array.isArray(i)&&(i.forEach(t=>{t(e)}),!0)}has(t){if(this.#t.has(t)){const e=this.#t.get(t);if(Array.isArray(e)&&e.length>0)return!0}return!1}destroy(){this.clear()}clear(){this.#t.clear()}};function M(t,e){return{x:t.x+(e.x-t.x)/2,y:t.y+(e.y-t.y)/2}}var S=class{#e;#i;#n;constructor(t){this.#i=s(t.defaultStorage),this.#e=this.#o(),this.#n=t.defaultStatic||{}}set(t,e){this.#e[t]=e}get(t){return this.#e[t]}setStatic(t,e){this.#n[t]=e}getStatic(t){return this.#n[t]}getSnapshot(t){return!0===t?.deepClone?s(this.#e):{...this.#e}}clear(){this.#e=this.#o()}destroy(){this.#e=null,this.#n=null}#o(){return s(this.#i)}};function L(t){return t/180*Math.PI}function C(t){return{x:t.x+t.width/2,y:t.y+t.height/2}}function k(t){const e=Math.min(t[0].x,t[1].x,t[2].x,t[3].x),i=Math.min(t[0].y,t[1].y,t[2].y,t[3].y);return C({x:e,y:i,width:Math.max(t[0].x,t[1].x,t[2].x,t[3].x)-e,height:Math.max(t[0].y,t[1].y,t[2].y,t[3].y)-i})}function A(t,e,i){let n=function(t,e){const i=e.x-t.x,n=e.y-t.y;if(0===i){if(n<0)return 0;if(n>0)return Math.PI}else if(0===n){if(i<0)return 3*Math.PI/2;if(i>0)return Math.PI/2}return i>0&&n<0?Math.atan(Math.abs(i)/Math.abs(n)):i>0&&n>0?Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n>0?Math.PI+Math.atan(Math.abs(i)/Math.abs(n)):i<0&&n<0?2*Math.PI-Math.atan(Math.abs(i)/Math.abs(n)):0}(t,e)+i;n>2*Math.PI?n-=2*Math.PI:n<0-2*Math.PI&&(n+=2*Math.PI),n<0&&(n+=2*Math.PI);const o=function(t,e){const i=(t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y);return 0===i?i:Math.sqrt(i)}(t,e);let r=0,a=0;return 0===n?(r=0,a=0-o):n>0&&n<Math.PI/2?(r=Math.sin(n)*o,a=0-Math.cos(n)*o):n===Math.PI/2?(r=o,a=0):n>Math.PI/2&&n<Math.PI?(r=Math.sin(Math.PI-n)*o,a=Math.cos(Math.PI-n)*o):n===Math.PI?(r=0,a=o):n>Math.PI&&n<1.5*Math.PI?(r=0-Math.sin(n-Math.PI)*o,a=Math.cos(n-Math.PI)*o):n===1.5*Math.PI?(r=0-o,a=0):n>1.5*Math.PI&&n<2*Math.PI?(r=0-Math.sin(2*Math.PI-n)*o,a=0-Math.cos(2*Math.PI-n)*o):n===2*Math.PI&&(r=0,a=0-o),r+=t.x,a+=t.y,{x:r,y:a}}function R(t,e,i){const{x:n,y:o,width:r,height:a}=t;let s={x:n,y:o},l={x:n+r,y:o},c={x:n+r,y:o+a},h={x:n,y:o+a};if(i&&(i>0||i<0)){const t=L(T(i));s=A(e,s,t),l=A(e,l,t),c=A(e,c,t),h=A(e,h,t)}return[s,l,c,h]}function P(t,e,i){return[A(t,{x:e[0].x,y:e[0].y},i),A(t,{x:e[1].x,y:e[1].y},i),A(t,{x:e[2].x,y:e[2].y},i),A(t,{x:e[3].x,y:e[3].y},i)]}function T(t){if(!(t>0||t<0)||0===t||360===t)return 0;let e=t%360;return e<0?e+=360:360===t&&(e=0),e}function z(t,e){const i=[];let n=t;if(e.length>1)for(let t=0;t<e.length-1;t++){const o=n[e[t]];if("group"!==o?.type||!Array.isArray(o?.children))return null;i.push(o),n=o.children}return i}function $(t){const{x:e,y:i,height:n,width:o}=t;return[{x:e,y:i},{x:e+o,y:i},{x:e+o,y:i+n},{x:e,y:i+n}]}function D(t){const{x:e,y:i,width:n,height:o,angle:r=0}=t;return 0===r?$(t):R(t,C({x:e,y:i,width:n,height:o,angle:r}),r)}function O(t,e){const{groupQueue:i}=e;return i.length>0?function(t){const e=[];let i=0,n=0;const o=[],r=[...t];for(let t=0;t<r.length;t++){const{x:a,y:s,width:l,height:c,angle:h=0}=r[t];let u;if(i+=a,n+=s,0===t){const t={x:i,y:n,width:l,height:c,angle:h};u=D({x:a,y:s,width:l,height:c,angle:h}),o.push({center:C(t),angle:h,radian:L(h)})}else{u=$({x:i,y:n,width:l,height:c,angle:h});for(let t=0;t<o.length;t++){const{center:e,radian:i}=o[t];u=P(e,u,i)}const t=k(u);(h>0||h<0)&&(u=P(t,u,L(h))),o.push({center:t,angle:h,radian:L(h)})}e.push(u)}return e}([...i,t]):[D(t)]}function V(t,e){const{viewScaleInfo:i}=e,{id:n,x:o,y:r,width:a,height:s,angle:l}=t,{scale:c=1,offsetTop:h=0,offsetLeft:u=0}=i;return{id:n,x:o*c+u,y:r*c+h,width:a*c,height:s*c,angle:l}}function E(t,e){const{viewScaleInfo:i}=e,{x:n,y:o}=t,{scale:r,offsetTop:a,offsetLeft:s}=i;return{x:n*r+s,y:o*r+a}}function j(t,e){const{context2d:i,material:n,viewScaleInfo:o}=e,{angle:r=0}=n,{x:a,y:s,width:l,height:c}=V(n,{viewScaleInfo:o}),h=function(t){const{angle:e=0}=t;return R(t,C(t),e)}({x:a,y:s,width:l,height:c,angle:r});if(h.length>=2){i.beginPath(),i.moveTo(h[0].x,h[0].y);for(let t=1;t<h.length;t++)i.lineTo(h[t].x,h[t].y);i.closePath()}return!!i.isPointInPath(t.x,t.y)}function F(t,e){const{groupQueue:i}=e,n=function(t,e){return O(t,e).pop()||null}(t,{groupQueue:i}),o=M(n[0],n[1]),r=M(n[1],n[2]),a=M(n[2],n[3]),s=M(n[3],n[0]),l=n[0],c=n[1],h=n[2],u=n[3],f=Math.max(l.x,c.x,h.x,u.x),p=Math.max(l.y,c.y,h.y,u.y);return{center:{x:(f+Math.min(l.x,c.x,h.x,u.x))/2,y:(p+Math.min(l.y,c.y,h.y,u.y))/2},topLeft:l,topRight:c,bottomLeft:u,bottomRight:h,top:o,right:r,left:s,bottom:a}}function B(t){const e=Math.max(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),i=Math.max(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),n=Math.min(t.topLeft.x,t.topRight.x,t.bottomRight.x,t.bottomLeft.x),o=Math.min(t.topLeft.y,t.topRight.y,t.bottomRight.y,t.bottomLeft.y),r={x:t.center.x,y:t.center.y},a={x:n,y:o},s={x:e,y:o},l={x:e,y:i},c={x:n,y:i},h=M(a,s),u=M(c,l),f=M(a,c);return{center:r,topLeft:a,topRight:s,bottomLeft:c,bottomRight:l,top:h,right:M(s,l),left:f,bottom:u}}function W(t){let e="";return t.forEach(t=>{e+=t.type+t.params?.join?.(" ")}),e}var Q="#787878",U=`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="${Q}"><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 H(){return{opacity:1,display:"inline",visibility:"visible",overflow:"visible",fill:Q,fillOpacity:1,fillRule:"nonzero",stroke:"#525252",strokeWidth:0,strokeOpacity:1,strokeLinecap:"butt",strokeLinejoin:"miter",strokeDasharray:[],strokeDashoffset:0,strokeMiterlimit:0,text:"Text",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:U}}var G=["-apple-system","\"system-ui\""," \"Segoe UI\""," Roboto","\"Helvetica Neue\"","Arial","\"Noto Sans\""," sans-serif"];function N(t){return[t,...G].join(", ")}var Z=()=>Math.random().toString(36).substring(2);function J(){return`${Z()}${Z()}`.substring(0,16)}function X(t,e,i){const n=[];return t.forEach(t=>{const o=function(t,e,i){const{type:n}=t,o=[...t.params],r=t.id;let a={id:r};if(t.start&&t.end){const n={...t.start},o={...t.end};n.x+=e,n.y+=i,o.x+=e,o.y+=i,a={id:r,start:n,end:o}}switch(n){case"M":case"L":case"T":return o[0]+=e,o[1]+=i,{type:n,params:o,...a};case"H":return o[0]+=e,{type:n,params:o,...a};case"V":return o[0]+=i,{type:n,params:o,...a};case"C":return o[0]+=e,o[1]+=i,o[2]+=e,o[3]+=i,o[4]+=e,o[5]+=i,{type:n,params:o,...a};case"S":case"Q":return o[0]+=e,o[1]+=i,o[2]+=e,o[3]+=i,{type:n,params:o,...a};case"A":return o[5]+=e,o[6]+=i,{type:n,params:o,...a};default:return{type:n,params:o,...a}}}(t,e,i);n.push(o)}),n}function Y(t,e,i){return t.map(t=>{const{id:n,type:o,params:r}=t,a=[];let s={id:n};if(t.start&&t.end){const o={...t.start},r={...t.end};o.x*=e,o.y*=i,r.x*=e,r.y*=i,s={id:n,start:o,end:r}}switch(o.toUpperCase()){case"M":case"L":case"T":for(let t=0;t<r.length;t+=2)a.push(r[t]*e,r[t+1]*i);break;case"C":for(let t=0;t<r.length;t+=6)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i,r[t+4]*e,r[t+5]*i);break;case"S":for(let t=0;t<r.length;t+=4)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i);break;case"Q":for(let t=0;t<r.length;t+=4)a.push(r[t]*e,r[t+1]*i,r[t+2]*e,r[t+3]*i);break;case"H":r.forEach(t=>a.push(t*e));break;case"V":r.forEach(t=>a.push(t*i));break;case"A":for(let t=0;t<r.length;t+=7)a.push(r[t]*e,r[t+1]*i,r[t+2],r[t+3],r[t+4],r[t+5]*e,r[t+6]*i);break;case"M":case"L":case"C":case"S":case"Q":case"T":case"A":case"H":case"V":for(let t=0;t<r.length;t++){const n="a"===o&&(t%7==0||t%7==5)||"h"===o||"v"!==o&&t%2==0;a.push(r[t]*(n?e:i))}break;default:return{type:o,params:[...r],...s}}return{type:o,params:a,...s}})}function q(t,i,n){if("string"==typeof i)return i;const{viewMaterialSize:o,viewScaleInfo:r,opacity:a=1}=n,{x:s,y:l}=o,{scale:c}=r;if("linear-gradient"===i?.type){const{start:n,end:o,stops:r}=i,h={x:s+n.x*c,y:l+n.y*c},u={x:s+o.x*c,y:l+o.y*c},f=t.createLinearGradient(h.x,h.y,u.x,u.y);return r.forEach(t=>{t.offset>=0&&t.color&&f.addColorStop(t.offset,e(t.color,a))}),f}if("radial-gradient"===i?.type){const{inner:n,outer:o,stops:r}=i,h={x:s+n.x*c,y:l+n.y*c,radius:n.radius*c},u={x:s+o.x*c,y:l+o.y*c,radius:o.radius*c},f=t.createRadialGradient(h.x,h.y,h.radius,u.x,u.y,u.radius);return r.forEach(t=>{f.addColorStop(t.offset,e(t.color,a))}),f}return"#000000"}var K=H();function _(t,e,i){const{viewScaleInfo:n,viewSizeInfo:o,calculator:r}=i,{opacity:a,fill:s,fillOpacity:l,fillRule:c,stroke:h,strokeWidth:u,strokeOpacity:f,strokeLinecap:p,strokeLinejoin:d,strokeDasharray:y,strokeDashoffset:g,strokeMiterlimit:m}={...K,...e},{scale:x,offsetLeft:w,offsetTop:b}=n,{devicePixelRatio:I}=o,{commands:M,worldCenter:S}=r.getVirtualItem(e.id),{width:L,height:C}=e;let k=M;k=Y(k,x,x),k=X(k,(w+(S.x-L/2)*x)*I,(b+(S.y-C/2)*x)*I);const A=t.globalAlpha,R=W(k),P=new Path2D(R);!function(t,e,i){const{...n}=e,{viewScaleInfo:o,viewSizeInfo:r,tempContext:a,path2d:s}=i,{width:l,height:c}=r,{shadowColor:h,shadowOffsetX:u,shadowOffsetY:f,shadowBlur:p}=n;v.number(p)&&h&&(a.clearRect(0,0,a.canvas.width,a.canvas.height),a.save(),a.shadowColor=h,a.shadowOffsetX=(u||0)*o.scale,a.shadowOffsetY=(f||0)*o.scale,a.shadowBlur=(p||0)*o.scale,a.fillStyle="#ffffff",a.fill(s),a.restore(),a.save(),a.globalCompositeOperation="destination-out",a.fillStyle="#ffffff",a.fill(s),a.restore(),t.drawImage(a.canvas,0,0,l,c),a.clearRect(0,0,a.canvas.width,a.canvas.height))}(t,e,{...i,path2d:P}),tt(t,e,{path2d:P,viewScaleInfo:n,viewSizeInfo:o,calculator:r,renderContent:()=>{if(s){const i=V(e,{viewScaleInfo:n});"number"==typeof l&&l>0&&(t.globalAlpha=A*l*a),t.fillStyle=q(t,s,{viewMaterialSize:i,viewScaleInfo:n,opacity:e.opacity||1}),t.fill(P,c),t.globalAlpha=A}if("number"==typeof u&&u>0){if("number"==typeof f&&f>0&&(t.globalAlpha=A*f*a),t.lineCap=p,t.lineJoin=d,t.lineDashOffset=g,t.miterLimit=m,Array.isArray(y)){const e=y.map(t=>x*t);t.setLineDash(e)}t.lineWidth=u*x,t.strokeStyle=h,t.stroke(P),t.setLineDash([]),t.lineCap=K.strokeLinecap,t.lineJoin=K.strokeLinejoin,t.lineDashOffset=K.strokeDashoffset,t.miterLimit=K.strokeMiterlimit,t.globalAlpha=A}}})}function tt(t,e,i){const{renderContent:n,calculator:o,viewScaleInfo:r,viewSizeInfo:a}=i;if("hidden"===e.overflow){let s=i.path2d;if(!s){const{scale:t,offsetLeft:i,offsetTop:n}=r,{devicePixelRatio:l}=a,{commands:c,worldCenter:h}=o.getVirtualItem(e.id),{width:u,height:f}=e;let p=c;p=Y(p,t,t),p=X(p,(i+(h.x-u/2)*t)*l,(n+(h.y-f/2)*t)*l);const d=W(p);s=new Path2D(d)}t.save(),t.clip(s,"nonzero"),n?.(),t.restore()}else n?.()}function et(t,e,i,n){const{viewScaleInfo:o,calculator:r}=i,a=r?.getVirtualItem(e.id);if(a){const{worldAngle:i,worldCenter:r}=a,s=E(r,{viewScaleInfo:o}),{scale:l}=o;!function(t,e,i,n){const o=L(e||0);i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(o),t.translate(-i.x,-i.y)),n(t),i&&(o>0||o<0)&&(t.translate(i.x,i.y),t.rotate(-o),t.translate(-i.x,-i.y))}(t,i,s,()=>{const t=e.width*l,i=e.height*l;n({viewWorldCenter:s,viewWorldSize:{x:s.x-t/2,y:s.y-i/2,width:t,height:i}})})}}function it(t,e,i){et(t,e,i,()=>{_(t,e,i)})}function nt(t,e,i){et(t,e,i,()=>{_(t,e,i)})}function ot(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o,parentOpacity:r}=i,{x:a,y:s,width:l,height:c,angle:h}=V(e,{viewScaleInfo:o})||e,u={...e,x:a,y:s,width:l,height:c,angle:h};et(t,e,i,()=>{if(n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"image"===e.type&&n){t.globalAlpha=function(t){let e=1;return void 0!==t?.opacity&&t?.opacity>=0&&t?.opacity<=1&&(e=t?.opacity),e}(e)*r;const{x:i,y:o,width:a,height:s}=u,l=[0,0,0,0],{scaleMode:c,originW:h=0,originH:f=0}=e,p=t.$undoPixelRatio(h),d=t.$undoPixelRatio(f);if(t.save(),t.fillStyle="transparent",t.beginPath(),t.moveTo(i+l[0],o),t.arcTo(i+a,o,i+a,o+s,l[1]),t.arcTo(i+a,o+s,i,o+s,l[2]),t.arcTo(i,o+s,i,o,l[3]),t.arcTo(i,o,i+a,o,l[0]),t.closePath(),t.fill("nonzero"),t.clip("nonzero"),c&&f&&h){let r=0,l=0,h=p,u=d;const f=i,y=o,g=a,m=s;if(p>e.width||d>e.height)if("fill"===c){const t=Math.max(e.width/p,e.height/d),i=d*t;r=(p*t-e.width)/2/t,l=(i-e.height)/2/t,h=e.width/t,u=e.height/t}else if("tile"===c)r=0,l=0,h=e.width,u=e.height;else if("fit"===c){const t=Math.min(e.width/p,e.height/d);r=(p-e.width/t)/2,l=(d-e.height/t)/2,h=e.width/t,u=e.height/t}t.drawImage(n,r,l,h,u,f,y,g,m)}else t.drawImage(n,i,o,a,s);t.globalAlpha=r,t.restore()}})}function rt(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o}=i,{x:r,y:a,width:s,height:l}=V(e,{viewScaleInfo:o})||e;et(t,e,i,()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"svgCode"===e.type&&n&&t.drawImage(n,r,a,s,l)})}function at(t,e,i){const n=i.loader.getContent(e),{viewScaleInfo:o}=i,{x:r,y:a,width:s,height:l}=V(e,{viewScaleInfo:o})||e;et(t,e,i,()=>{n||i.loader.isDestroyed()||i.loader.load(e,i.materialAssets||{}),"foreignObject"===e.type&&n&&t.drawImage(n,r,a,s,l)})}K=function(t,e){const i={...t};for(const t of e)delete i[t];return i}(K,["fill"]);var st=H();function lt(t,e,i){const{viewScaleInfo:n,viewSizeInfo:o,calculator:r}=i,a=V(e,{viewScaleInfo:n})||e,{scale:s}=n;et(t,e,i,({viewWorldSize:i})=>{{const l={...st,...e},{x:c,y:h}=i,u=(l.fontSize||st.fontSize)*n.scale,{opacity:f,fill:p,fillOpacity:d,stroke:y,strokeWidth:g,strokeOpacity:m,strokeLinecap:x,strokeLinejoin:w,strokeDasharray:b,strokeDashoffset:v,strokeMiterlimit:I}=l;if(u<2)return;const M=t.globalAlpha,S=r.getVirtualItem(e.id);t.textBaseline="top",t.$setFont({fontWeight:l.fontWeight,fontSize:u,fontFamily:N(l.fontFamily)}),tt(t,e,{viewScaleInfo:n,viewSizeInfo:o,calculator:r,renderContent:()=>{if(p&&("number"==typeof d&&d>0&&(t.globalAlpha=M*d*f),t.fillStyle=q(t,p,{viewMaterialSize:a,viewScaleInfo:n,opacity:e.opacity||1}),Array.isArray(S?.textLines)&&S?.textLines?.length>0&&S?.textLines?.forEach(e=>{t.fillText(e.text,c+e.x*n.scale,h+e.y*n.scale)}),t.globalAlpha=M),"number"==typeof g&&g>0){if("number"==typeof m&&m>0&&(t.globalAlpha=M*m*f),t.lineCap=x,t.lineJoin=w,t.lineDashOffset=v,t.miterLimit=I,Array.isArray(b)){const e=b.map(t=>s*t);t.setLineDash(e)}t.lineWidth=g*s,t.strokeStyle=y,S?.textLines?.forEach(e=>{t.strokeText(e.text,c+e.x*n.scale,h+e.y*n.scale)}),t.setLineDash([]),t.lineCap=st.strokeLinecap,t.lineJoin=st.strokeLinejoin,t.lineDashOffset=st.strokeDashoffset,t.miterLimit=st.strokeMiterlimit,t.globalAlpha=M}}})}})}function ct(t,e,i){if(!0===e?.operations?.invisible)return;const{width:n,height:o}=e,{scale:r}=i.viewScaleInfo;if(r<1&&(n*r<.4||o*r<.4)||0===i.parentOpacity)return;const{overrideMaterialMap:a}=i;if(!a?.[e.id]?.operations?.invisible)try{switch(e.type){case"rect":it(t,e,i);break;case"circle":nt(t,e,i);break;case"ellipse":case"path":!function(t,e,i){et(t,e,i,()=>{_(t,e,i)})}(t,e,i);break;case"text":lt(t,e,i);break;case"image":ot(t,e,i);break;case"svgCode":rt(t,e,i);break;case"foreignObject":at(t,e,i);break;case"group":{const n={...i.materialAssets||{},...e.assets||{}};ht(t,e,{...i,materialAssets:n});break}}}catch(t){console.error(t)}}function ht(t,e,i){if(et(t,e,i,()=>{_(t,e,i)}),Array.isArray(e.children)){const{parentMaterialSize:n}=i,o={x:n.x+e.x,y:n.y+e.y,width:e.width||n.width,height:e.height||n.height,angle:e.angle},{calculator:r}=i;for(let n=0;n<e.children.length;n++){let a=e.children[n];if(a={...a,x:o.x+a.x,y:o.y+a.y},!0===i.forceDrawAll||r?.needRender(a))try{ct(t,a,i)}catch(t){console.error(t)}}}}var ut=H();function ft(t,e,i){const{materials:n=[]}=e,{parentOpacity:o}=i;for(let e=0;e<n.length;e++){const r=n[e],a={...r,attributes:{...ut,...r}};if(!0===i.forceDrawAll||i.calculator?.needRender(a))try{ct(t,a,{...i,parentOpacity:o})}catch(t){console.error(t)}}}function pt(t,e,i,n){const{parentOpacity:o}=i;t.globalAlpha=1;const{viewScaleInfo:r}=i,a={id:"layout",type:"group",...e},s=V(a,{viewScaleInfo:r})||a,{x:l,y:c,width:h,height:u,fill:f}={...a,...s},p=[0,0,0,0];t.save(),t.fillStyle=q(t,f,{viewMaterialSize:s,viewScaleInfo:r,opacity:a.opacity||1}),t.beginPath(),t.moveTo(l+p[0],c),t.arcTo(l+h,c,l+h,c+u,p[1]),t.arcTo(l+h,c+u,l,c+u,p[2]),t.arcTo(l,c+u,l,c,p[3]),t.arcTo(l,c,l+h,c,p[0]),t.closePath(),t.fill("nonzero"),"hidden"===e.overflow&&t.clip("nonzero"),n(t),"hidden"===e.overflow&&t.restore(),t.globalAlpha=o}function dt(t,e,i){if("string"==typeof e?.fill){const{viewSizeInfo:n}=i,{width:o,height:r}=n;t.globalAlpha=1,t.fillStyle=e.fill,t.fillRect(0,0,o,r)}}var yt=["image","svgCode","foreignObject"],gt=t=>{let e=null;return"image"===t.type?e=t?.href||null:"svgCode"===t.type?e=t?.code||null:"foreignObject"===t.type&&(e=t?.content||null),"string"==typeof e&&e?a(e)?e:r(e,t.id):r(`${n()}-${t.id}-${n()}-${n()}`,t.id)},mt=class extends I{#r={};#a={};#s={};#l=!1;constructor(){super(),this.#c("image",async(t,e)=>{const i=await c(e[t.href]?.value||t.href);return{id:t.id,lastModified:Date.now(),content:i}}),this.#c("foreignObject",async(t,e)=>{const i=await u(e[t.content]?.value||t.content,{width:t.originW||t.width,height:t.originH||t.height});return{id:t.id,lastModified:Date.now(),content:i}}),this.#c("svgCode",async(t,e)=>{const i=await h(e[t.code]?.value||t.code);return{id:t.id,lastModified:Date.now(),content:i}})}isDestroyed(){return this.#l}reset(){!0!==this.#l&&(this.#a={},this.#s={})}resetMaterialAsset(t){if(yt.includes(t.type)){let e=null,i=null;"image"===t.type&&"string"==typeof t?.href?i=t.href:"svgCode"===t.type&&"string"==typeof t?.code?i=t.code:"foreignObject"===t.type&&"string"==typeof t?.content&&(i=t.content),"string"==typeof i&&(this.load(t,{}),a(i)?e=i:t.id&&(e=r(i,t.id))),e&&a(e)&&(delete this.#s[e],delete this.#a[e])}}destroy(){this.#l=!0,this.clear(),this.#r=null,this.#a=null,this.#s=null}#c(t,e){this.#r[t]=e}#h(t){let e=null;return"image"===t.type?e=t?.href||null:"svgCode"===t.type?e=t?.code||null:"foreignObject"===t.type&&(e=t?.content||null),e}#u(t){return{material:t,status:"null",content:null,error:null,startTime:-1,endTime:-1,source:this.#h(t)}}#f(t){const e=gt(t.material),i=this.#s[e];this.#l||(i?i.startTime<t.startTime&&(this.#s[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})):(this.#s[e]=t,this.trigger("load",{...t,countTime:t.endTime-t.startTime})))}#p(t){const e=gt(t.material),i=this.#s?.[e];this.#l||(i?i.startTime<t.startTime&&(this.#s[e]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})):(this.#s[e]=t,this.trigger("error",{...t,countTime:t.endTime-t.startTime})))}#d(t,e){const i=this.#u(t),n=gt(t);if(this.#a[n])return;this.#a[n]=i;const o=this.#r[t.type];"function"!=typeof o||this.#l||(i.startTime=Date.now(),o(t,e).then(t=>{this.#l||(i.content=t.content,i.endTime=Date.now(),i.status="load",this.#f(i))}).catch(e=>{console.warn(`Load material source "${i.source}" fail`,e,t),i.endTime=Date.now(),i.status="error",i.error=e,this.#p(i)}))}#y(t){const e=gt(t),i=this.#a?.[e];return!(!i||"error"!==i.status||!i.source||i.source!==this.#h(t))}load(t,e){!0!==this.#l&&(this.#y(t)||yt.includes(t.type)&&this.#d(t,e))}getContent(t){const e=gt(t);return this.#s?.[e]?.content||null}getLoadItemMap(){return this.#s}setLoadItemMap(t){this.#s=t}};function xt(t,e){if(!(e=[...e].reverse())||0===e.length)return{x:t.x+t.width/2,y:t.y+t.height/2};let i=t.x+t.width/2,n=t.y+t.height/2;for(let t=0;t<e.length;t++){const o=wt({x:i,y:n},e[t]);i=o.x,n=o.y}return{x:i,y:n}}function wt(t,e){const i=e.width/2,n=e.height/2,o=t.x-i,r=t.y-n;let a=o,s=r;if("number"==typeof e.angle&&0!==e.angle){const t=e.angle*Math.PI/180,i=Math.cos(t),n=Math.sin(t);a=o*i-r*n,s=o*n+r*i}const l=s+n;return{x:a+i+e.x,y:l+e.y}}function bt(t,e){const{groupQueue:i=[]}=e;let n=t.angle||0;return i.forEach(t=>{n+=t.angle||0}),{worldCenter:xt(t,i),worldAngle:T(n)}}function vt(t,e){const{dpr:i}=e;let{width:n,height:o,rx:r=0,ry:a=0}=t;const{cornerRadius:s}=t;o*=i,n*=i;const l=[];let c=0,h=0,u=0,f=0,p=0,d=0,y=0,g=0;if("number"==typeof r&&"number"==typeof a)r*=i,a*=i,c=r,h=r,u=r,f=r,p=a,d=a,y=a,g=a;else if(Array.isArray(s)&&4===s.length){const t=s.map(t=>t*i);c=t[0]||0,h=t[1]||0,u=t[2]||0,f=t[3]||0,p=t[0]||0,d=t[1]||0,y=t[2]||0,g=t[3]||0}else if("number"==typeof s){const t=s*i;c=t,h=t,u=t,f=t,p=t,d=t,y=t,g=t}const m=0+n,x=0+o;return l.push({id:J(),type:"M",params:[0+c,0]}),h>0||d>0?(l.push({id:J(),type:"L",params:[m-h,0]}),l.push({id:J(),type:"A",params:[h,d,0,0,1,m,0+d]})):l.push({id:J(),type:"L",params:[m,0]}),u>0||y>0?(l.push({id:J(),type:"L",params:[m,x-y]}),l.push({id:J(),type:"A",params:[u,y,0,0,1,m-u,x]})):l.push({id:J(),type:"L",params:[m,x]}),f>0||g>0?(l.push({id:J(),type:"L",params:[0+f,x]}),l.push({id:J(),type:"A",params:[f,g,0,0,1,0,x-g]})):l.push({id:J(),type:"L",params:[0,x]}),c>0||p>0?(l.push({id:J(),type:"L",params:[0,0+p]}),l.push({id:J(),type:"A",params:[c,p,0,0,1,0+c,0]})):l.push({id:J(),type:"L",params:[0,0]}),l.push({id:J(),type:"Z",params:[]}),{...bt(t,e),commands:l}}var It=H();function Mt(t,e,i){return i<.5&&t<e&&(t-e)/t>-.15||t>=e}function St(t,e){const{dpr:i}=e,n={...bt(t,e),anchorCommands:[]};return n.anchorCommands=function(t){const e=[];let i={x:0,y:0},n={x:0,y:0},o=null;for(const r of t){const t=r.type,a=r.params,s=t===t.toLowerCase(),l=t.toUpperCase(),c=r.id;switch(l){case"M":{const[t,r]=a,l=s?{x:i.x+t,y:i.y+r}:{x:t,y:r};e.push({id:c,type:"M",params:[l.x,l.y],start:{x:t,y:r},end:{x:t,y:r}}),i=l,n=l,o=null;break}case"L":{const[t,n]=a,r=s?{x:i.x+t,y:i.y+n}:{x:t,y:n};e.push({id:c,type:"L",params:[r.x,r.y],start:{...i},end:{...r}}),i=r,o=null;break}case"H":{const[t]=a,n=s?{x:i.x+t,y:i.y}:{x:t,y:i.y};e.push({id:c,type:"L",params:[n.x,n.y],start:{...i},end:{...n}}),i=n,o=null;break}case"V":{const[t]=a,n=s?{x:i.x,y:i.y+t}:{x:i.x,y:t};e.push({id:c,type:"L",params:[n.x,n.y],start:{...i},end:{...n}}),i=n,o=null;break}case"C":{const[t,n,r,l,h,u]=a,f=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},p=s?{x:i.x+r,y:i.y+l}:{x:r,y:l},d=s?{x:i.x+h,y:i.y+u}:{x:h,y:u};e.push({id:c,type:"C",params:[f.x,f.y,p.x,p.y,d.x,d.y],start:{...i},end:{...d}}),i=d,o=p;break}case"S":{const[t,n,r,l]=a,h=o?{x:2*i.x-o.x,y:2*i.y-o.y}:i,u=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},f=s?{x:i.x+r,y:i.y+l}:{x:r,y:l};e.push({id:c,type:"C",params:[h.x,h.y,u.x,u.y,f.x,f.y],start:{...i},end:{...f}}),i=f,o=u;break}case"Q":{const[t,n,r,l]=a,h=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},u=s?{x:i.x+r,y:i.y+l}:{x:r,y:l};e.push({id:c,type:"C",params:[i.x+2/3*(h.x-i.x),i.y+2/3*(h.y-i.y),u.x+2/3*(h.x-u.x),u.y+2/3*(h.y-u.y),u.x,u.y],start:{...i},end:{...u}}),i=u,o=h;break}case"T":{const[t,n]=a,r=s?{x:i.x+t,y:i.y+n}:{x:t,y:n},l=o?{x:2*i.x-o.x,y:2*i.y-o.y}:i;e.push({id:c,type:"C",params:[i.x+2/3*(l.x-i.x),i.y+2/3*(l.y-i.y),r.x+2/3*(l.x-r.x),r.y+2/3*(l.y-r.y),r.x,r.y],start:{...i},end:{...r}}),i=r,o=l;break}case"A":{const[t,n,r,l,h,u,f]=a,p=s?{x:i.x+u,y:i.y+f}:{x:u,y:f};e.push({id:c,type:"A",params:[t,n,r,l,h,p.x,p.y],start:{...i},end:{...p}}),i=p,o=null;break}case"Z":e.push({id:c,type:"Z",params:[],start:{...i},end:{...n}}),i=n,o=null;break;default:throw new Error(`Unsupported command: ${t}`)}}return e}(t.commands||[]),n.commands=Y(t.commands,i,i),n}function Lt(t,e){let i=null;switch(t.type){case"rect":case"group":i=vt(t,e);break;case"circle":i=function(t,e){const{dpr:i}=e,{width:n,height:o}=t;let{r:r}=t;const a=n/2*i,s=o/2*i;r*=i;const l=.55228475*r,c=[{type:"M",params:[a+r,s]},{type:"C",params:[a+r,s-l,a+l,s-r,a,s-r]},{type:"C",params:[a-l,s-r,a-r,s-l,a-r,s]},{type:"C",params:[a-r,s+l,a-l,s+r,a,s+r]},{type:"C",params:[a+l,s+r,a+r,s+l,a+r,s]},{type:"Z",params:[]}];return{...bt(t,e),commands:c}}(t,e);break;case"ellipse":i=function(t,e){const{dpr:i}=e,{width:n,height:o}=t;let{rx:r,ry:a}=t;const s=n/2*i,l=o/2*i;r*=i,a*=i;const c=.55228475*r,h=.55228475*a,u=[{type:"M",params:[s+r,l]},{type:"C",params:[s+r,l-h,s+c,l-a,s,l-a]},{type:"C",params:[s-c,l-a,s-r,l-h,s-r,l]},{type:"C",params:[s-r,l+h,s-c,l+a,s,l+a]},{type:"C",params:[s+c,l+a,s+r,l+h,s+r,l]},{type:"Z",params:[]}];return{...bt(t,e),commands:u}}(t,e);break;case"text":i=function(t,e){const{width:i,height:n}=t,o=e.tempContext,r=[],a={...It,...t},s=a.fontSize||It.fontSize,l=s,c=vt(t,e);if(l<2)return{...c,textLines:[]};const h=a.lineHeight||s;o.textBaseline="top",o.$setFont({fontWeight:a.fontWeight,fontSize:l,fontFamily:N(a.fontFamily)});let u=a.text.replace(/\r\n/gi,"\n");"lowercase"===a.textTransform?u=u.toLowerCase():"uppercase"===a.textTransform&&(u=u.toUpperCase());const f=h,p=u.split("\n");let d=0;p.forEach((t,e)=>{if("maxContent"===a.minInlineSize){const e=o.measureText(t);r.push({x:0,y:0,text:t,width:o.$undoPixelRatio(e.width)})}else{let s="",l="",c=t.split(l);if("normal"===a.wordBreak){l=" ";const e=t.split(l);c=[],e.forEach((t,i)=>{c.push(t),i<e.length-1&&c.push(l)})}if(1===c.length&&"hidden"!==a.overflow)r.push({x:0,y:0,text:c[0],width:o.$undoPixelRatio(o.measureText(c[0]).width)});else if(c.length>0){for(let t=0;t<c.length;t++){if(Mt(o.$doPixelRatio(i),o.measureText(s+c[t]).width,1)?s+=c[t]||"":(r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s=c[t]||"",d++),d*f>=n&&"hidden"===a.overflow){s="";break}if(c.length-1===t&&(d+1)*f<=n){r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s="",e<p.length-1&&d++;break}}s&&(r.push({x:0,y:0,text:s,width:o.$undoPixelRatio(o.measureText(s).width)}),s="")}else r.push({x:0,y:0,text:"",width:0})}});let y=0,g=0;f>l&&(g=(f-l)/2),r.length*f<n&&("top"===a.verticalAlign?y=0:"bottom"===a.verticalAlign?y+=n-r.length*f:y+=(n-r.length*f)/2);{const t=0+y;r.forEach((e,n)=>{let o=0;"center"===a.textAlign?o=0+(i-e.width)/2:"right"===a.textAlign&&(o=i-e.width+0),r[n].x=o,r[n].y=t+f*n+g})}return{...c,textLines:r}}(t,e);break;case"path":i=St(t,e);break;default:i=bt(t,e)}return i}function Ct(t,e){const{viewScaleInfo:i,viewSizeInfo:n,tempContext:o}=e;return kt(function(t,e){const i={},n=[],o=r=>{const a={type:r.type,isVisibleInView:!0,position:[...n]};let s=null;const l=z(t,n);s=F(r,{groupQueue:l||[]});const c={...a,boundingInfo:s,rangeBoundingInfo:v.angle(r.angle)?B(s):s,...Lt(r,{...e,groupQueue:l||[]})};i[r.id]=c,"group"===r.type&&r.children.forEach((t,e)=>{n.push(e),o(t),n.pop()})};return t.forEach((t,e)=>{n.push(e),o(t),n.pop()}),i}(t,{tempContext:o,dpr:n.devicePixelRatio}),{viewScaleInfo:i,viewSizeInfo:n})}function kt(t,e){const i=function(t){const{viewScaleInfo:e,viewSizeInfo:i}=t,{scale:n,offsetTop:o,offsetLeft:r}=e,{width:a,height:s}=i,l=0-r/n,c=0-o/n,h=a/n,u=s/n,f=C({x:l,y:c,width:a,height:s});return{center:f,topLeft:{x:l,y:c},topRight:{x:l+h,y:c},bottomLeft:{x:l,y:c+u},bottomRight:{x:l+h,y:c+u},left:{x:l,y:f.y},top:{x:f.x,y:c},right:{x:l+h,y:f.y},bottom:{x:f.x,y:c+u}}}(e);let n=0,o=0;return Object.keys(t).forEach(e=>{const r=t[e];r.isVisibleInView=function(t,e){const i=t.center.x,n=t.center.y,o=Math.min(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),r=Math.max(t.topLeft.x,t.topRight.x,t.bottomLeft.x,t.bottomRight.x),a=Math.min(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),s=Math.max(t.topLeft.y,t.topRight.y,t.bottomLeft.y,t.bottomRight.y),l=Math.abs(r-o),c=Math.abs(s-a),h=Math.min(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x)-l,u=Math.max(e.topLeft.x,e.topRight.x,e.bottomLeft.x,e.bottomRight.x)+l,f=Math.min(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y)-c,p=Math.max(e.topLeft.y,e.topRight.y,e.bottomLeft.y,e.bottomRight.y)+c;return i>=h&&i<=u&&n>=f&&n<=p}(r.rangeBoundingInfo,i),r.isVisibleInView?n++:o++}),{virtualItemMap:t,visibleCount:n,invisibleCount:o}}var At=class{#g;#m;constructor(t){this.#g=t,this.#m=new S({defaultStorage:{virtualItemMap:{},visibleCount:0,invisibleCount:0}})}toGridNum(t,e){return!0===e?.ignore?t:Math.round(t)}destroy(){this.#g=null}needRender(t){const e=this.#m.get("virtualItemMap")[t.id];return!e||e.isVisibleInView}forceVisiable(t){const e=this.#m.get("virtualItemMap")[t];e&&(e.isVisibleInView=!0)}getPointMaterial(t,e){return function(t,e){const{context2d:i,data:n,viewScaleInfo:o,viewSizeInfo:r,groupQueue:a}=e,s={index:-1,material:null,groupQueueIndex:-1};if(a&&Array.isArray(a)&&a?.length>0)for(let e=a.length-1;e>=0;e--){let n=0,l=0,c=0;for(let t=0;t<=e;t++)n+=a[t].x,l+=a[t].y,c+=a[t].angle||0;const h=a[e];if(h&&"group"===h.type&&Array.isArray(h?.children))for(let u=0;u<h.children.length;u++){const f=h.children[u];if(!0!==f?.operations?.invisible){if(!f)break;if(j(t,{context2d:i,material:{x:n+f.x,y:l+f.y,width:f.width,height:f.height,angle:c+(f.angle||0)},viewScaleInfo:o,viewSizeInfo:r})){s.material=f,(e<a.length-1||"group"!==f.type)&&(s.groupQueueIndex=e);break}}}if(s.material)break}if(s.material)return s;for(let e=n.materials.length-1;e>=0;e--){const a=n.materials[e];if(!0!==a?.operations?.invisible&&j(t,{context2d:i,material:a,viewScaleInfo:o,viewSizeInfo:r})){s.index=e,s.material=a;break}}return s}(t,{...e,context2d:this.#g.tempContext})}resetVirtualItemMap(t,e){if(t){const{virtualItemMap:i,invisibleCount:n,visibleCount:o}=Ct(t.materials,{...e,tempContext:this.#g.tempContext});this.#m.set("virtualItemMap",i),this.#m.set("invisibleCount",n),this.#m.set("visibleCount",o)}}updateVisiableStatus(t){const{virtualItemMap:e,invisibleCount:i,visibleCount:n}=kt(this.#m.get("virtualItemMap"),t);this.#m.set("virtualItemMap",e),this.#m.set("invisibleCount",i),this.#m.set("visibleCount",n)}calcViewBoundingInfoFromOrigin(t,e){const i=this.#m.get("virtualItemMap")[t];if(!i?.boundingInfo)return null;const{checkVisible:n,viewScaleInfo:o,viewSizeInfo:r}=e,{center:a,left:s,right:l,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:p,bottomRight:d}=i.boundingInfo;if(!0===n&&!1===i.isVisibleInView)return null;const y={viewScaleInfo:o,viewSizeInfo:r};return{center:E(a,y),left:E(s,y),right:E(l,y),bottom:E(c,y),top:E(h,y),topLeft:E(u,y),topRight:E(f,y),bottomLeft:E(p,y),bottomRight:E(d,y)}}calcViewBoundingInfoFromRange(t,e){const i=this.#m.get("virtualItemMap")[t];if(!i?.boundingInfo)return null;const{checkVisible:n,viewScaleInfo:o,viewSizeInfo:r}=e,{center:a,left:s,right:l,bottom:c,top:h,topLeft:u,topRight:f,bottomLeft:p,bottomRight:d}=i.rangeBoundingInfo;if(!0===n&&!1===i.isVisibleInView)return null;const y={viewScaleInfo:o,viewSizeInfo:r};return{center:E(a,y),left:E(s,y),right:E(l,y),bottom:E(c,y),top:E(h,y),topLeft:E(u,y),topRight:E(f,y),bottomLeft:E(p,y),bottomRight:E(d,y)}}modifyVirtualAttributes(t,e){const{viewSizeInfo:i,groupQueue:n}=e,o=this.#m.get("virtualItemMap"),r=o[t.id],a=Lt(t,{tempContext:this.#g.tempContext,dpr:i.devicePixelRatio,groupQueue:n});if(a){const e=F(t,{groupQueue:n}),i={...r,...a,boundingInfo:e,rangeBoundingInfo:v.angle(t.angle)?B(e):e};o[t.id]=i,this.#m.set("virtualItemMap",o)}}modifyVirtualItemMap(t,e){const{modifyInfo:i,viewScaleInfo:n,viewSizeInfo:o}=e,{type:r,content:a}=i,s=t.materials,l=this.#m.get("virtualItemMap");if("deleteMaterial"===r){const{material:t}=a,e=[],i=t=>{e.push(t.id),"group"===t.type&&Array.isArray(t.children)&&t.children.forEach(t=>{i(t)})};i(t),e.forEach(t=>{delete l[t]}),this.#m.set("virtualItemMap",l)}else if("addMaterial"===r||"updateMaterial"===r){const{position:e}=a,i=function(t,e){let i=null,n=e;for(let e=0;e<t.length;e++){const o=n[t[e]];if(e<t.length-1&&"group"===o?.type)n=o.children;else{if(e!==t.length-1)break;i=o}}return i}(e,t.materials),c=z(s,e);if(i)if("updateMaterial"===r&&"group"===i.type)this.resetVirtualItemMap(t,{viewScaleInfo:n,viewSizeInfo:o});else{const t=F(i,{groupQueue:c||[]}),a={type:i.type,boundingInfo:t,rangeBoundingInfo:v.angle(i.angle)?B(t):t,isVisibleInView:!0,position:[...e],...Lt(i,{tempContext:this.#g.tempContext,dpr:o.devicePixelRatio,groupQueue:c||[]})};l[i.id]=a,this.#m.set("virtualItemMap",l),"updateMaterial"===r&&this.updateVisiableStatus({viewScaleInfo:n,viewSizeInfo:o})}}else"moveMaterial"===r&&this.resetVirtualItemMap(t,{viewScaleInfo:n,viewSizeInfo:o})}getVirtualItem(t){return this.#m.get("virtualItemMap")[t]||null}};return t.Calculator=At,t.Renderer=class extends I{#g;#x=new mt;#w;#l=!1;constructor(t){super(),this.#g=t,this.#w=new At({tempContext:t.tempContext}),this.#b()}isDestroyed(){return this.#l}destroy(){this.clear(),this.#g=null,this.#x.destroy(),this.#x=null,this.#l=!0}#b(){const t=this.#x;t.on("load",t=>{this.trigger("load",t)}),t.on("error",t=>{console.error(t)})}updateOptions(t){this.#g=t}drawData(t,e){const i=this.#x,n=this.#w,{sharer:o}=this.#g,r=this.#g.viewContext;r.clearRect(0,0,r.canvas.width,r.canvas.height);const a={x:0,y:0,width:e.viewSizeInfo.width,height:e.viewSizeInfo.height};!0===e.forceDrawAll&&this.#w.resetVirtualItemMap(t,{viewScaleInfo:e.viewScaleInfo,viewSizeInfo:e.viewSizeInfo});const s={loader:i,calculator:n,parentMaterialSize:a,materialAssets:t.assets,parentOpacity:1,overrideMaterialMap:o?.getActiveOverrideMaterialMap(),tempContext:this.#g.tempContext,...e};dt(r,t.global,s),t.layout?pt(r,t.layout,s,()=>{ft(r,t,s)}):ft(r,t,s)}scale(t){const{sharer:e}=this.#g;if(!e)return;const{data:i,offsetTop:n,offsetBottom:o,offsetLeft:r,offsetRight:a,width:s,height:l,contextHeight:c,contextWidth:h,devicePixelRatio:u}=e.getActiveStoreSnapshot();i&&this.drawData(i,{viewScaleInfo:{scale:t,offsetTop:n,offsetBottom:o,offsetLeft:r,offsetRight:a},viewSizeInfo:{width:s,height:l,contextHeight:c,contextWidth:h,devicePixelRatio:u}})}setLoadItemMap(t){this.#x.setLoadItemMap(t)}getLoadItemMap(){return this.#x.getLoadItemMap()}getLoader(){return this.#x}getCalculator(){return this.#w}},t.drawCircle=nt,t.drawForeignObject=at,t.drawGlobalBackground=dt,t.drawGroup=ht,t.drawImage=ot,t.drawLayout=pt,t.drawMaterial=ct,t.drawMaterialList=ft,t.drawRect=it,t.drawSVGCode=rt,t.drawText=lt,t}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idraw/renderer",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"author": "idrawjs",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@idraw/types": "^1.0.0-alpha.
|
|
24
|
+
"@idraw/types": "^1.0.0-alpha.3"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@idraw/util": "^1.0.0-alpha.
|
|
28
|
+
"@idraw/util": "^1.0.0-alpha.3"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public",
|