@leafer-ui/worker 1.0.0-rc.8 → 1.0.0-rc.9

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.
@@ -916,6 +916,7 @@ else if (userAgent.indexOf('Linux') > -1) {
916
916
  Platform.os = 'Linux';
917
917
  }
918
918
 
919
+ let origin = {};
919
920
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
920
921
  function fillOrFitMode(data, mode, box, width, height, rotation) {
921
922
  const transform = get$4();
@@ -932,13 +933,13 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
932
933
  data.scaleX = data.scaleY = scale;
933
934
  data.transform = transform;
934
935
  }
935
- function clipMode(data, box, offset, scale, rotation) {
936
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
936
937
  const transform = get$4();
937
938
  translate$1(transform, box.x, box.y);
938
- if (offset)
939
- translate$1(transform, offset.x, offset.y);
940
- if (scale) {
941
- typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
939
+ if (x || y)
940
+ translate$1(transform, x, y);
941
+ if (scaleX) {
942
+ scaleHelper(transform, scaleX, scaleY);
942
943
  data.scaleX = transform.a;
943
944
  data.scaleY = transform.d;
944
945
  }
@@ -946,7 +947,7 @@ function clipMode(data, box, offset, scale, rotation) {
946
947
  rotate(transform, rotation);
947
948
  data.transform = transform;
948
949
  }
949
- function repeatMode(data, box, width, height, scale, rotation) {
950
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
950
951
  const transform = get$4();
951
952
  if (rotation) {
952
953
  rotate(transform, rotation);
@@ -962,10 +963,15 @@ function repeatMode(data, box, width, height, scale, rotation) {
962
963
  break;
963
964
  }
964
965
  }
965
- translate$1(transform, box.x, box.y);
966
- if (scale) {
967
- scaleOfOuter$2(transform, box, scale);
968
- data.scaleX = data.scaleY = scale;
966
+ origin.x = box.x;
967
+ origin.y = box.y;
968
+ if (x || y)
969
+ origin.x += x, origin.y += y;
970
+ translate$1(transform, origin.x, origin.y);
971
+ if (scaleX) {
972
+ scaleOfOuter$2(transform, origin, scaleX, scaleY);
973
+ data.scaleX = scaleX;
974
+ data.scaleY = scaleY;
969
975
  }
970
976
  data.transform = transform;
971
977
  }
@@ -973,11 +979,22 @@ function repeatMode(data, box, width, height, scale, rotation) {
973
979
  const { get: get$3, translate } = MatrixHelper;
974
980
  function createData(leafPaint, image, paint, box) {
975
981
  let { width, height } = image;
976
- const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
982
+ const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
977
983
  const sameBox = box.width === width && box.height === height;
978
984
  if (blendMode)
979
985
  leafPaint.blendMode = blendMode;
980
986
  const data = leafPaint.data = { mode };
987
+ let x, y, scaleX, scaleY;
988
+ if (offset)
989
+ x = offset.x, y = offset.y;
990
+ if (size) {
991
+ scaleX = (typeof size === 'number' ? size : size.width) / width;
992
+ scaleY = (typeof size === 'number' ? size : size.height) / height;
993
+ }
994
+ else if (scale) {
995
+ scaleX = typeof scale === 'number' ? scale : scale.x;
996
+ scaleY = typeof scale === 'number' ? scale : scale.y;
997
+ }
981
998
  switch (mode) {
982
999
  case 'strench':
983
1000
  if (!sameBox)
@@ -988,12 +1005,12 @@ function createData(leafPaint, image, paint, box) {
988
1005
  }
989
1006
  break;
990
1007
  case 'clip':
991
- if (offset || scale || rotation)
992
- clipMode(data, box, offset, scale, rotation);
1008
+ if (offset || scaleX || rotation)
1009
+ clipMode(data, box, x, y, scaleX, scaleY, rotation);
993
1010
  break;
994
1011
  case 'repeat':
995
- if (!sameBox || scale || rotation)
996
- repeatMode(data, box, width, height, scale, rotation);
1012
+ if (!sameBox || scaleX || rotation)
1013
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
997
1014
  if (!repeat)
998
1015
  data.repeat = 'repeat';
999
1016
  break;
@@ -1 +1 @@
1
- import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as a,LeafHelper as r,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,Debug as l,LeafLevelList as c,LayoutEvent as u,Run as f,ImageManager as _,Platform as g,AnimateEvent as p,ResizeEvent as w,BoundsHelper as y,Creator as m,LeaferCanvasBase as x,canvasPatch as v,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as E,ImageEvent as k,PointHelper as L,Direction4 as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as M,ImageManager as C,Paint as O,Effect as T,TextConvert as I,Export as W}from"@leafer-ui/core";export*from"@leafer-ui/core";class D{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(i.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(a.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:P,updateBounds:F,updateAllWorldOpacity:Y}=r,{pushAllChildBranch:N,pushAllParent:U}=o;const{worldBounds:H}=h,V={x:0,y:0,width:1e5,height:1e5};class X{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,H)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(V):this.afterBounds.setListWithFn(t,H),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:q,updateAllChange:j}=r,G=l.get("Layouter");class z{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new c,this.target=t,i&&(this.config=e.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(u.START),this.layoutOnce(),t.emitEvent(new u(u.END,this.layoutedBlocks,this.times))}catch(t){G.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?G.warn("layouting"):this.times>3?G.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=f.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=u,o=this.getBlocks(s);o.forEach((t=>t.setBefore())),i.emitEvent(new u(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(P(t,!0),e.add(t),t.isBranch&&N(t,e),U(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),U(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||F(s[t])}F(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Y(t),t.__updateChange()}))}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new u(a,o,this.times)),i.emitEvent(new u(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:a}=u,r=this.getBlocks(new t(i));i.emitEvent(new u(s,r,this.times)),z.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new u(n,r,this.times)),i.emitEvent(new u(a,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){q(t,!0),t.isBranch?o.updateBounds(t):r.updateBounds(t),j(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new X([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new X(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.layout,this),t.on_(u.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Q=l.get("Renderer");class Z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(u.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Q.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Q.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new d(s);i.save(),n&&!l.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),f.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),l.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),l.showHitView&&this.renderHitView(s),l.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();g.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(p.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new d(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Q.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(u.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(w.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}var K;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(K||(K={}));const{hitRadiusPoint:$}=y;class J{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const a=this.findList,r=this.getBestMatchLeaf(),o=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:o,leaf:r,throughPath:a.length?this.getThroughPath(a):o}:{path:o,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.add(e),e=e.parent;return i.add(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.addAt(s,0),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,a,r;for(let t=0,e=s.length;t<e;t++){n=s[t],a=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!a||!a.has(r));t++)i.add(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||$(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:tt,NoAndSkip:et,YesAndSkip:it}=K;class st{constructor(t,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,i&&(this.config=e.default(i,this.config)),this.pather=new J(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,e,i){return"node"===g.name&&this.target.emit(u.CHECK_UPDATE),this.pather.getByPoint(t,e,i)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&r.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,a;for(let r=0,o=t.length;r<o;r++){if(n=t[r],a=e(n,s),a===tt||a===it){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<et&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this),this.target.on_(a.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.pather.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(m,{watcher:(t,e)=>new D(t,e),layouter:(t,e)=>new z(t,e),renderer:(t,e,i)=>new Z(t,e,i),selector:(t,e)=>new st(t,e)}),g.layout=z.fullLayout;class nt extends x{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=g.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i,this.clientBounds=this.bounds}}v(OffscreenCanvasRenderingContext2D.prototype),v(Path2D.prototype);const{mineType:at}=R;function rt(t,e){g.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:at(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:at(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,i)=>{!t.startsWith("data:")&&g.image.suffix&&(t+=(t.includes("?")?"&":"?")+g.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{e(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},g.canvas=m.canvas(),g.conicGradientSupport=!!g.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new nt(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new nt(t,e),interaction:(t,e,i,s)=>new B(t,e,i,s)}),g.name="web",g.isWorker=!0,g.requestRender=function(t){requestAnimationFrame(t)},g.devicePixelRatio=1;const{userAgent:ot}=navigator;ot.indexOf("Firefox")>-1?(g.conicGradientRotate90=!0,g.intWheelDeltaY=!0):ot.indexOf("Safari")>-1&&-1===ot.indexOf("Chrome")&&(g.fullImageShadow=!0),ot.indexOf("Windows")>-1?(g.os="Windows",g.intWheelDeltaY=!0):ot.indexOf("Mac")>-1?g.os="Mac":ot.indexOf("Linux")>-1&&(g.os="Linux");const{get:dt,rotateOfOuter:ht,translate:lt,scaleOfOuter:ct,scale:ut,rotate:ft}=E;const{get:_t,translate:gt}=E;function pt(t,e,i,s){let{width:n,height:a}=e;const{opacity:r,mode:o,offset:d,scale:h,rotation:l,blendMode:c,repeat:u}=i,f=s.width===n&&s.height===a;c&&(t.blendMode=c);const _=t.data={mode:o};switch(o){case"strench":f||(n=s.width,a=s.height),(s.x||s.y)&&(_.transform=_t(),gt(_.transform,s.x,s.y));break;case"clip":(d||h||l)&&function(t,e,i,s,n){const a=dt();lt(a,e.x,e.y),i&&lt(a,i.x,i.y),s&&("number"==typeof s?ut(a,s):ut(a,s.x,s.y),t.scaleX=a.a,t.scaleY=a.d),n&&ft(a,n),t.transform=a}(_,s,d,h,l);break;case"repeat":(!f||h||l)&&function(t,e,i,s,n,a){const r=dt();if(a)switch(ft(r,a),a){case 90:lt(r,s,0);break;case 180:lt(r,i,s);break;case 270:lt(r,0,i)}lt(r,e.x,e.y),n&&(ct(r,e,n),t.scaleX=t.scaleY=n),t.transform=r}(_,s,n,a,h,l),u||(_.repeat="repeat");break;default:f&&!l||function(t,e,i,s,n,a){const r=dt(),o=a&&180!==a,d=i.width/(o?n:s),h=i.height/(o?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;lt(r,c,u),ut(r,l),a&&ht(r,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=r}(_,o,s,n,a,l)}_.width=n,_.height=a,r&&(_.opacity=r),u&&(_.repeat="string"==typeof u?"x"===u?"repeat-x":"repeat-y":"repeat")}function wt(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",t.__.width),t.setProxyAttr("height",t.__.height)),!1}return!0}function yt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new k(t,e))}function mt(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{d(s.next(t))}catch(t){a(t)}}function o(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const xt={},{get:vt,scale:bt,copy:Bt}=E;function Rt(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const a=s+"-"+n;if(e.patternId===a||t.destroyed)return!1;{s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e;let o,d,{width:h,height:l,scaleX:c,scaleY:u,opacity:f,transform:_,repeat:p}=r;c&&(d=vt(),Bt(d,_),bt(d,1/c,1/u),s*=c,n*=u),s*=i,n*=i,h*=s,l*=n;const w=h*l;if(!p&&w>g.image.maxCacheSize)return!1;let y=g.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;y>e&&(y=e)}w>y&&(o=Math.sqrt(w/y)),o&&(s/=o,n/=o,h/=o,l/=o),c&&(s/=c,n/=u),(_||1!==s||1!==n)&&(d||(d=vt(),_&&Bt(d,_)),bt(d,1/s,1/n));const m=g.canvas.createPattern(t.getCanvas(h<1?1:h,l<1?1:l,f),p||g.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),d&&(m.setTransform?m.setTransform(d):e.transform=d)}catch(t){e.transform=d}return e.style=m,e.patternId=a,!0}}const{abs:Et}=Math;function kt(t,e,i,s){const{scaleX:n,scaleY:a}=t.__world;if(i.data&&i.patternId!==n+"-"+a){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=Et(n)*e.pixelRatio,i*=Et(a)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>g.image.maxCacheSize}return s?(e.save(),e.clip(),i.blendMode&&(e.blendMode=i.blendMode),r.opacity&&(e.opacity*=r.opacity),r.transform&&e.transform(r.transform),e.drawImage(i.image.view,0,0,r.width,r.height),e.restore(),!0):(!i.style||xt.running?Rt(t,i,e.pixelRatio):i.patternTask||(i.patternTask=_.patternTasker.add((()=>mt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Rt(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1}function Lt(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,r;for(let o=0,d=i.length;o<d;o++)s=i[o].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[o].loadId,!a.some((t=>t.url===r)))));return n}return null}function St(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,a)}function At(t,e,i,s){const{strokeAlign:n}=e.__,a="string"!=typeof t;switch(n){case"center":i.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?Ot(t,!0,e,i):Ct(e,i);break;case"inside":Mt("inside",t,a,e,i,s);break;case"outside":Mt("outside",t,a,e,i,s)}}function Mt(t,e,i,s,n,a){const{strokeWidth:r,__font:o}=s.__,d=n.getSameCanvas(!0);d.setStroke(i?void 0:e,2*r,s.__),d.font=o,i?Ot(e,!0,s,d):Ct(s,d),d.blendMode="outside"===t?"destination-out":"destination-in",St(s,d),d.blendMode="normal",s.__worldFlipped||a.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,s.__world,s.__layout.renderBounds),d.recycle()}function Ct(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,a)}function Ot(t,e,i,s){let n;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&kt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Ct(i,s):s.stroke(),s.restoreBlendMode()):e?Ct(i,s):s.stroke())}const{getSpread:Tt,getOuterOf:It,getByMove:Wt,getIntersectData:Dt}=y;const Pt={x:.5,y:0},Ft={x:.5,y:1};function Yt(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,M.string(s.color,i))}const{set:Nt,getAngle:Ut,getDistance:Ht}=L,{get:Vt,rotateOfOuter:Xt,scaleOfOuter:qt}=E,jt={x:.5,y:.5},Gt={x:.5,y:1},zt={},Qt={};const{set:Zt,getAngle:Kt,getDistance:$t}=L,{get:Jt,rotateOfOuter:te,scaleOfOuter:ee}=E,ie={x:.5,y:.5},se={x:.5,y:1},ne={},ae={};let re;function oe(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:a,color:r,opacity:o}=e;return{type:n,blendMode:a,style:M.string(r,o)};case"image":return function(t,e,i,s,n){const a={type:i.type},r=a.image=_.get(i),o=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(wt(t,e,r)&&pt(a,r,i,s),n&&(yt(k.LOAD,o),yt(k.LOADED,o))):r.error?n&&(t.forceUpdate("surface"),o.error=r.error,yt(k.ERROR,o)):(n&&yt(k.LOAD,o),a.loadId=r.load((()=>{t.destroyed||(wt(t,e,r)&&(pt(a,r,i,s),t.forceUpdate("surface")),yt(k.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,yt(k.ERROR,o)}))),a}(i,t,e,s,!re||!re[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:a,opacity:r}=t;i||(i=Pt),s||(s=Ft);const o=g.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);Yt(o,t.stops,r);const d={type:n,style:o};return a&&(d.blendMode=a),d}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=jt),s||(s=Gt);const{x:d,y:h,width:l,height:c}=e;let u;Nt(zt,d+i.x*l,h+i.y*c),Nt(Qt,d+s.x*l,h+s.y*c),(l!==c||o)&&(u=Vt(),qt(u,zt,l/c*(o||1),1),Xt(u,zt,Ut(zt,Qt)+90));const f=g.canvas.createRadialGradient(zt.x,zt.y,0,zt.x,zt.y,Ht(zt,Qt));Yt(f,t.stops,a);const _={type:n,style:f,transform:u};return r&&(_.blendMode=r),_}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=ie),s||(s=se);const{x:d,y:h,width:l,height:c}=e;Zt(ne,d+i.x*l,h+i.y*c),Zt(ae,d+s.x*l,h+s.y*c);const u=Jt(),f=Kt(ne,ae);g.conicGradientRotate90?(ee(u,ne,l/c*(o||1),1),te(u,ne,f+90)):(ee(u,ne,1,l/c*(o||1)),te(u,ne,f));const _=g.conicGradientSupport?g.canvas.createConicGradient(0,ne.x,ne.y):g.canvas.createRadialGradient(ne.x,ne.y,0,ne.x,ne.y,$t(ne,ae));Yt(_,t.stops,a);const p={type:n,style:_,transform:u};return r&&(p.blendMode=r),p}(e,s);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}var de=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,a,r=s.__input[t];r instanceof Array||(r=[r]),re=Lt(t,s);for(let s=0,a=r.length;s<a;s++)n=oe(t,r[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===r.length){const t=r[0];"image"===t.type&&(a=C.isPixel(t))}"fill"===t?s.__pixelFill=a:s.__pixelStroke=a},drawTextStroke:Ct,fill:function(t,e,i){i.fillStyle=t,e.__.__font?St(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:St,fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let r=0,o=t.length;r<o;r++)s=t[r],s.image&&kt(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?St(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?St(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?St(e,i):n?i.fill(n):i.fill())},recycleImage:Lt,shape:function(t,e,i){const s=e.getSameCanvas();let n,a,r,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,i.matrix))i.matrix?(h*=i.matrix.a,l*=i.matrix.d,n=r=It(d,i.matrix)):n=r=d,o=s;else{const{renderShapeSpread:s}=t.__layout,c=Dt(s?Tt(e.bounds,s*h,s*l):e.bounds,d,i.matrix);a=e.bounds.getFitMatrix(c),a.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,i),h*=a.a,l*=a.d),r=It(d,a),n=Wt(r,-a.e,-a.f),i.matrix&&a.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:a})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:n,worldCanvas:o,shapeBounds:r,scaleX:h,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)At(t,e,i,s);else switch(r){case"center":i.setStroke(t,a,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*a,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const r=i.getSameCanvas(!0);r.setStroke(t,2*a,e.__),e.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(e.__layout.renderBounds),e.__worldFlipped||s.matrix?i.copyWorldByReset(r):i.copyWorldToInner(r,e.__world,e.__layout.renderBounds),r.recycle()}},strokeText:At,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)At(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,a,n),Ot(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*a,n),n.windingRule?i.clip(n.windingRule):i.clip(),Ot(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,e.__),Ot(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(r),e.__worldFlipped||s.matrix?i.copyWorldByReset(o):i.copyWorldToInner(o,e.__world,r),o.recycle()}}});const{copy:he,toOffsetOutBounds:le}=y,ce={},ue={};function fe(t,e,i,s){const{bounds:n,shapeBounds:a}=s;if(g.fullImageShadow){if(he(ce,t.bounds),ce.x+=e.x-a.x,ce.y+=e.y-a.y,i){const{matrix:t}=s;ce.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ce.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ce.width*=i,ce.height*=i}t.copyWorld(s.canvas,t.bounds,ce)}else i&&(he(ce,e),ce.x-=e.width/2*(i-1),ce.y-=e.height/2*(i-1),ce.width*=i,ce.height*=i),t.copyWorld(s.canvas,a,i?ce:e)}const{toOffsetOutBounds:_e}=y,ge={};var pe=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,a;const{__world:r,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;_e(l,ge),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(ge.offsetX+d.x*u,ge.offsetY+d.y*f,d.blur*u),a=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,fe(_,ge,a,i),_.restore(),h?(_.copyWorld(_,l,r,"copy"),_.copyWorld(h,r,r,"source-out"),n=r):(_.copyWorld(i.canvas,c,l,"source-out"),n=l),_.fillWorld(n,d.color,"source-in"),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,i,s){let n,a;const{__world:r,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;le(l,ue),d.forEach(((d,p)=>{_.setWorldShadow(ue.offsetX+d.x*u,ue.offsetY+d.y*f,d.blur*u,d.color),a=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,fe(_,ue,a,i),n=l,d.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,r,"copy"),n=r),h?_.copyWorld(h,r,r,"destination-out"):_.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ye=we+"_#~&*+\\=|≮≯≈≠=…",me=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function xe(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const ve=xe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),be=xe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Be=xe(we),Re=xe(ye),Ee=xe("- —/~|┆·");var ke;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(ke||(ke={}));const{Letter:Le,Single:Se,Before:Ae,After:Me,Symbol:Ce,Break:Oe}=ke;function Te(t){return ve[t]?Le:Ee[t]?Oe:be[t]?Ae:Be[t]?Me:Re[t]?Ce:me.test(t)?Se:Le}const Ie={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function We(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:De}=Ie,{Letter:Pe,Single:Fe,Before:Ye,After:Ne,Symbol:Ue,Break:He}=ke;let Ve,Xe,qe,je,Ge,ze,Qe,Ze,Ke,$e,Je,ti,ei,ii,si,ni,ai=[];function ri(t,e){Ke&&!Ze&&(Ze=Ke),Ve.data.push({char:t,width:e}),qe+=e}function oi(){je+=qe,Ve.width=qe,Xe.words.push(Ve),Ve={data:[]},qe=0}function di(){ii&&(si.paraNumber++,Xe.paraStart=!0,ii=!1),Ke&&(Xe.startCharSize=Ze,Xe.endCharSize=Ke,Ze=0),Xe.width=je,ni.width&&De(Xe),ai.push(Xe),Xe={words:[]},je=0}const{top:hi,right:li,bottom:ci,left:ui}=S,fi={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:o,__padding:d}=e;d&&(n&&(i=d[ui],n-=d[li]+d[ui]),a&&(s=d[hi],a-=d[hi]+d[ci]));const h={bounds:{x:i,y:s,width:n,height:a},rows:[],paraNumber:0,font:g.canvas.font=o};return function(t,e,i){si=t,ai=t.rows,ni=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:a}=i,{canvas:r}=g,{width:o,height:d}=ni;if(o||d||s||"none"!==a){const t="none"!==i.textWrap,d="break"===i.textWrap;ii=!0,Je=null,Ze=Qe=Ke=qe=je=0,Ve={data:[]},Xe={words:[]};for(let i=0,h=e.length;i<h;i++)ze=e[i],"\n"===ze?(qe&&oi(),Xe.paraEnd=!0,di(),ii=!0):($e=Te(ze),$e===Pe&&"none"!==a&&(ze=We(ze,a,!qe)),Qe=r.measureText(ze).width,s&&(s<0&&(Ke=Qe),Qe+=s),ti=$e===Fe&&(Je===Fe||Je===Pe)||Je===Fe&&$e!==Ne,ei=!($e!==Ye&&$e!==Fe||Je!==Ue&&Je!==Ne),Ge=ii&&n?o-n:o,t&&o&&je+qe+Qe>Ge&&(d?(qe&&oi(),di()):(ei||(ei=$e===Pe&&Je==Ne),ti||ei||$e===He||$e===Ye||$e===Fe||qe+Qe>Ge?(qe&&oi(),di()):di()))," "===ze&&!0!==ii&&je+qe===0||($e===He?(" "===ze&&qe&&oi(),ri(ze,Qe),oi()):ti||ei?(qe&&oi(),ri(ze,Qe)):ri(ze,Qe)),Je=$e);qe&&oi(),je&&di(),ai.length>0&&(ai[ai.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{si.paraNumber++,ai.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,t,e),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":_i(e,"x",t[ui]);break;case"right":_i(e,"x",-t[li])}if(!n)switch(i.verticalAlign){case"top":_i(e,"y",t[hi]);break;case"bottom":_i(e,"y",-t[ci])}}(d,h,e,n,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:w}=s,y=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(o&&y>w)y=Math.max(w,n),t.overflow=i.length;else switch(h){case"middle":g+=(w-y)/2;break;case"bottom":g+=w-y}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=n,t.overflow>a&&m>y&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<s.x&&(s.x=u),f>s.width&&(s.width=f),o&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=y}(h,e),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(h,e,n),h.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,a;"ellipsis"===n&&(n="...");const r=g.canvas.measureText(n).width,o=e.x+e.width-r;("none"===e.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<o));s--){if(a<o&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:n,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,e),h}};function _i(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const gi={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},pi={export(t,e,i){return pi.running=!0,function(t){wi||(wi=new A);return new Promise((e=>{wi.add((()=>mt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:a}=t;a?a.waitViewCompleted((()=>mt(this,void 0,void 0,(function*(){let t,r,o,{canvas:d}=a,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=a.config.fill,a.__render(d,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}o=e.includes(".")?yield d.saveAs(e,t):r?yield d.toBlob(e,t):yield d.toDataURL(e,t),s({data:o}),n(),pi.running=!1,h&&d.recycle()})))):(s({data:!1}),n(),pi.running=!1)}))))}};let wi;Object.assign(O,de),Object.assign(T,pe),Object.assign(I,fi),Object.assign(M,gi),Object.assign(W,pi),rt();export{z as Layouter,nt as LeaferCanvas,Z as Renderer,st as Selector,D as Watcher,rt as useCanvas};
1
+ import{LeafList as t,DataHelper as e,RenderEvent as i,ChildEvent as s,WatchEvent as n,PropertyEvent as a,LeafHelper as r,BranchHelper as o,Bounds as d,LeafBoundsHelper as h,Debug as l,LeafLevelList as c,LayoutEvent as u,Run as f,ImageManager as _,Platform as g,AnimateEvent as p,ResizeEvent as y,BoundsHelper as w,Creator as m,LeaferCanvasBase as x,canvasPatch as v,LeaferImage as b,InteractionBase as B,FileHelper as R,MatrixHelper as E,ImageEvent as k,PointHelper as L,Direction4 as S,TaskProcessor as A}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{ColorConvert as M,ImageManager as C,Paint as O,Effect as T,TextConvert as I,Export as W}from"@leafer-ui/core";export*from"@leafer-ui/core";class D{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const e=new t;return this.__updatedList.list.forEach((t=>{t.leafer&&e.add(t)})),e}return this.__updatedList}constructor(i,s){this.totalTimes=0,this.config={},this.__updatedList=new t,this.target=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(i.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===s.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new n(n.DATA,{updatedList:this.updatedList})),this.__updatedList=new t,this.totalTimes++,this.changed=!1,this.hasVisible=!1,this.hasRemove=!1,this.hasAdd=!1}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(a.CHANGE,this.__onAttrChange,this),t.on_([s.ADD,s.REMOVE],this.__onChildEvent,this),t.on_(n.REQUEST,this.__onRquestData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.__updatedList=null)}}const{updateAllMatrix:P,updateBounds:F,updateAllWorldOpacity:Y}=r,{pushAllChildBranch:N,pushAllParent:U}=o;const{worldBounds:H}=h,V={x:0,y:0,width:1e5,height:1e5};class X{constructor(e){this.updatedBounds=new d,this.beforeBounds=new d,this.afterBounds=new d,e instanceof Array&&(e=new t(e)),this.updatedList=e}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,H)}setAfter(){const{list:t}=this.updatedList;t.some((t=>t.noBounds))?this.afterBounds.set(V):this.afterBounds.setListWithFn(t,H),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:q,updateAllChange:j}=r,z=l.get("Layouter");class G{constructor(t,i){this.totalTimes=0,this.config={},this.__levelList=new c,this.target=t,i&&(this.config=e.default(i,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(!this.running)return;const{target:t}=this;this.times=0;try{t.emit(u.START),this.layoutOnce(),t.emitEvent(new u(u.END,this.layoutedBlocks,this.times))}catch(t){z.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?z.warn("layouting"):this.times>3?z.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(n.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=f.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:r}=u,o=this.getBlocks(s);o.forEach((t=>t.setBefore())),i.emitEvent(new u(n,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach((t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(P(t,!0),e.add(t),t.isBranch&&N(t,e),U(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),U(t,e)))}))}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach((n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||F(s[t])}F(i)}}))}(this.__levelList),function(t){t.list.forEach((t=>{t.__layout.opacityChanged&&Y(t),t.__updateChange()}))}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach((t=>t.setAfter())),i.emitEvent(new u(a,o,this.times)),i.emitEvent(new u(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,f.end(e)}fullLayout(){const e=f.start("FullLayout"),{target:i}=this,{BEFORE:s,LAYOUT:n,AFTER:a}=u,r=this.getBlocks(new t(i));i.emitEvent(new u(s,r,this.times)),G.fullLayout(i),r.forEach((t=>{t.setAfter()})),i.emitEvent(new u(n,r,this.times)),i.emitEvent(new u(a,r,this.times)),this.addBlocks(r),f.end(e)}static fullLayout(t){q(t,!0),t.isBranch?o.updateBounds(t):r.updateBounds(t),j(t)}addExtra(t){const e=this.extraBlock||(this.extraBlock=new X([]));e.updatedList.add(t),e.beforeBounds.add(t.__world)}createBlock(t){return new X(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(u.REQUEST,this.layout,this),t.on_(u.AGAIN,this.layoutAgain,this),t.on_(n.DATA,this.__onReceiveWatchData,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Q=l.get("Renderer");class Z{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,i,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:60},this.target=t,this.canvas=i,s&&(this.config=e.default(s,this.config)),this.__listenEvents(),this.__requestRender()}start(){this.running=!0}stop(){this.running=!1}update(){this.changed=!0}requestLayout(){this.target.emit(u.REQUEST)}render(t){if(!this.running||!this.canvas.view)return void(this.changed=!0);const{target:e}=this;this.times=0,this.totalBounds=new d,Q.log(e.innerName,"---\x3e");try{this.emitRender(i.START),this.renderOnce(t),this.emitRender(i.END,this.totalBounds),_.clearRecycled()}catch(t){this.rendering=!1,Q.error(t)}Q.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){return this.rendering?Q.warn("rendering"):this.times>3?Q.warn("render max times"):(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new d,this.renderOptions={},t?(this.emitRender(i.BEFORE),t()):(this.requestLayout(),this.emitRender(i.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()),this.emitRender(i.RENDER,this.renderBounds,this.renderOptions),this.emitRender(i.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,void(this.waitAgain&&(this.waitAgain=!1,this.renderOnce())))}partRender(){const{canvas:t,updateBlocks:e}=this;if(!e)return Q.warn("PartRender: need update attr");this.mergeBlocks(),e.forEach((e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=f.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=t.includes(this.target.__world),a=new d(s);i.save(),n&&!l.showRepaint?i.clear():(s.spread(1+1/this.canvas.pixelRatio).ceil(),i.clearWorld(s,!0),i.clipWorld(s,!0)),this.__render(s,n,a),i.restore(),f.end(e)}fullRender(){const t=f.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds,!0),e.restore(),f.end(t)}__render(t,e,i){const s=t.includes(this.target.__world)?{includes:e}:{bounds:t,includes:e};this.needFill&&this.canvas.fillWorld(t,this.config.fill),l.showRepaint&&this.canvas.strokeWorld(t,"red"),this.target.__render(this.canvas,s),this.renderBounds=i||t,this.renderOptions=s,this.totalBounds.isEmpty()?this.totalBounds=this.renderBounds:this.totalBounds.add(this.renderBounds),l.showHitView&&this.renderHitView(s),l.showBoundsView&&this.renderBoundsView(s),this.canvas.updateRender()}renderHitView(t){}renderBoundsView(t){}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new d;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=Date.now();g.requestRender((()=>{this.FPS=Math.min(60,Math.ceil(1e3/(Date.now()-t))),this.changed&&this.running&&this.canvas.view&&this.render(),this.running&&this.target.emit(p.FRAME),this.target&&this.__requestRender()}))}__onResize(t){if(!this.canvas.unreal&&(t.bigger||!t.samePixelRatio)){const{width:e,height:i}=t.old;new d(0,0,e,i).includes(this.target.__world)&&!this.needFill&&t.samePixelRatio||(this.addBlock(this.canvas.bounds),this.target.forceUpdate("blendMode"))}}__onLayoutEnd(t){t.data&&t.data.map((t=>{let e;t.updatedList&&t.updatedList.list.some((t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||Q.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e))),this.addBlock(e?this.canvas.bounds:t.updatedBounds)}))}emitRender(t,e,s){this.target.emitEvent(new i(t,this.times,e,s))}__listenEvents(){const{target:t}=this;this.__eventIds=[t.on_(i.REQUEST,this.update,this),t.on_(u.END,this.__onLayoutEnd,this),t.on_(i.AGAIN,this.renderAgain,this),t.on_(y.RESIZE,this.__onResize,this)]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=null,this.canvas=null,this.config=null)}}var K;!function(t){t[t.No=0]="No",t[t.Yes=1]="Yes",t[t.NoAndSkip=2]="NoAndSkip",t[t.YesAndSkip=3]="YesAndSkip"}(K||(K={}));const{hitRadiusPoint:$}=w;class J{constructor(t,e){this.target=t,this.selector=e}getByPoint(t,e,i){e||(e=0),i||(i={});const s=i.through||!1,n=i.ignoreHittable||!1;this.exclude=i.exclude||null,this.point={x:t.x,y:t.y,radiusX:e,radiusY:e},this.findList=[],this.eachFind(this.target.children,this.target.__onlyHitMask);const a=this.findList,r=this.getBestMatchLeaf(),o=n?this.getPath(r):this.getHitablePath(r);return this.clear(),s?{path:o,leaf:r,throughPath:a.length?this.getThroughPath(a):o}:{path:o,leaf:r}}getBestMatchLeaf(){const{findList:t}=this;if(t.length>1){let e;this.findList=[];const{x:i,y:s}=this.point,n={x:i,y:s,radiusX:0,radiusY:0};for(let i=0,s=t.length;i<s;i++)if(e=t[i],r.worldHittable(e)&&(this.hitChild(e,n),this.findList.length))return this.findList[0]}return t[0]}getPath(e){const i=new t;for(;e;)i.add(e),e=e.parent;return i.add(this.target),i}getHitablePath(e){const i=this.getPath(e);let s,n=new t;for(let t=i.list.length-1;t>-1&&(s=i.list[t],s.__.hittable)&&(n.addAt(s,0),s.__.hitChildren);t--);return n}getThroughPath(e){const i=new t,s=[];for(let t=e.length-1;t>-1;t--)s.push(this.getPath(e[t]));let n,a,r;for(let t=0,e=s.length;t<e;t++){n=s[t],a=s[t+1];for(let t=0,e=n.length;t<e&&(r=n.list[t],!a||!a.has(r));t++)i.add(r)}return i}eachFind(t,e){let i,s;const{point:n}=this;for(let a=t.length-1;a>-1;a--)i=t[a],!i.__.visible||e&&!i.__.isMask||(s=!!i.__.hitRadius||$(i.__world,n),i.isBranch?(s||i.__ignoreHitWorld)&&(this.eachFind(i.children,i.__onlyHitMask),i.isBranchLeaf&&!this.findList.length&&this.hitChild(i,n)):s&&this.hitChild(i,n))}hitChild(t,e){this.exclude&&this.exclude.has(t)||t.__hitWorld(e)&&this.findList.push(t)}clear(){this.point=null,this.findList=null,this.exclude=null}destroy(){this.clear()}}const{Yes:tt,NoAndSkip:et,YesAndSkip:it}=K;class st{constructor(t,i){this.config={},this.innerIdMap={},this.idMap={},this.methods={id:(t,e)=>t.id===e?(this.idMap[e]=t,1):0,innerId:(t,e)=>t.innerId===e?(this.innerIdMap[e]=t,1):0,className:(t,e)=>t.className===e?1:0,tag:(t,e)=>t.__tag===e?1:0},this.target=t,i&&(this.config=e.default(i,this.config)),this.pather=new J(t,this),this.__listenEvents()}getBy(t,e,i,s){switch(typeof t){case"number":const n=this.getByInnerId(t,e);return i?n:n?[n]:[];case"string":switch(t[0]){case"#":const s=this.getById(t.substring(1),e);return i?s:s?[s]:[];case".":return this.getByMethod(this.methods.className,e,i,t.substring(1));default:return this.getByMethod(this.methods.tag,e,i,t)}case"function":return this.getByMethod(t,e,i,s)}}getByPoint(t,e,i){return"node"===g.name&&this.target.emit(u.CHECK_UPDATE),this.pather.getByPoint(t,e,i)}getByInnerId(t,e){const i=this.innerIdMap[t];return i||(this.eachFind(this.toChildren(e),this.methods.innerId,null,t),this.findLeaf)}getById(t,e){const i=this.idMap[t];return i&&r.hasParent(i,e||this.target)?i:(this.eachFind(this.toChildren(e),this.methods.id,null,t),this.findLeaf)}getByClassName(t,e){return this.getByMethod(this.methods.className,e,!1,t)}getByTag(t,e){return this.getByMethod(this.methods.tag,e,!1,t)}getByMethod(t,e,i,s){const n=i?null:[];return this.eachFind(this.toChildren(e),t,n,s),n||this.findLeaf}eachFind(t,e,i,s){let n,a;for(let r=0,o=t.length;r<o;r++){if(n=t[r],a=e(n,s),a===tt||a===it){if(!i)return void(this.findLeaf=n);i.push(n)}n.isBranch&&a<et&&this.eachFind(n.children,e,i,s)}}toChildren(t){return this.findLeaf=null,[t||this.target]}__onRemoveChild(t){const{id:e,innerId:i}=t.child;this.idMap[e]&&delete this.idMap[e],this.innerIdMap[i]&&delete this.innerIdMap[i]}__checkIdChange(t){if("id"===t.attrName){const e=t.oldValue;this.idMap[e]&&delete this.idMap[e]}}__listenEvents(){this.__eventIds=[this.target.on_(s.REMOVE,this.__onRemoveChild,this),this.target.on_(a.CHANGE,this.__checkIdChange,this)]}__removeListenEvents(){this.target.off_(this.__eventIds),this.__eventIds.length=0}destroy(){this.__eventIds.length&&(this.__removeListenEvents(),this.pather.destroy(),this.findLeaf=null,this.innerIdMap={},this.idMap={})}}Object.assign(m,{watcher:(t,e)=>new D(t,e),layouter:(t,e)=>new G(t,e),renderer:(t,e,i)=>new Z(t,e,i),selector:(t,e)=>new st(t,e)}),g.layout=G.fullLayout;class nt extends x{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config)}__createView(){this.view=g.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=t*i,this.view.height=e*i,this.clientBounds=this.bounds}}v(OffscreenCanvasRenderingContext2D.prototype),v(Path2D.prototype);const{mineType:at}=R;function rt(t,e){g.origin={createCanvas:(t,e)=>new OffscreenCanvas(t,e),canvasToDataURL:(t,e,i)=>new Promise(((s,n)=>{t.convertToBlob({type:at(e),quality:i}).then((t=>{var e=new FileReader;e.onload=t=>s(t.target.result),e.onerror=t=>n(t),e.readAsDataURL(t)})).catch((t=>{n(t)}))})),canvasToBolb:(t,e,i)=>t.convertToBlob({type:at(e),quality:i}),canvasSaveAs:(t,e,i)=>new Promise((t=>t())),loadImage:t=>new Promise(((e,i)=>{!t.startsWith("data:")&&g.image.suffix&&(t+=(t.includes("?")?"&":"?")+g.image.suffix);let s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.onload=()=>{createImageBitmap(s.response).then((t=>{e(t)})).catch((t=>{i(t)}))},s.onerror=t=>i(t),s.send()}))},g.canvas=m.canvas(),g.conicGradientSupport=!!g.canvas.context.createConicGradient}Object.assign(m,{canvas:(t,e)=>new nt(t,e),image:t=>new b(t),hitCanvas:(t,e)=>new nt(t,e),interaction:(t,e,i,s)=>new B(t,e,i,s)}),g.name="web",g.isWorker=!0,g.requestRender=function(t){requestAnimationFrame(t)},g.devicePixelRatio=1;const{userAgent:ot}=navigator;ot.indexOf("Firefox")>-1?(g.conicGradientRotate90=!0,g.intWheelDeltaY=!0):ot.indexOf("Safari")>-1&&-1===ot.indexOf("Chrome")&&(g.fullImageShadow=!0),ot.indexOf("Windows")>-1?(g.os="Windows",g.intWheelDeltaY=!0):ot.indexOf("Mac")>-1?g.os="Mac":ot.indexOf("Linux")>-1&&(g.os="Linux");let dt={};const{get:ht,rotateOfOuter:lt,translate:ct,scaleOfOuter:ut,scale:ft,rotate:_t}=E;const{get:gt,translate:pt}=E;function yt(t,e,i,s){let{width:n,height:a}=e;const{opacity:r,mode:o,offset:d,scale:h,size:l,rotation:c,blendMode:u,repeat:f}=i,_=s.width===n&&s.height===a;u&&(t.blendMode=u);const g=t.data={mode:o};let p,y,w,m;switch(d&&(p=d.x,y=d.y),l?(w=("number"==typeof l?l:l.width)/n,m=("number"==typeof l?l:l.height)/a):h&&(w="number"==typeof h?h:h.x,m="number"==typeof h?h:h.y),o){case"strench":_||(n=s.width,a=s.height),(s.x||s.y)&&(g.transform=gt(),pt(g.transform,s.x,s.y));break;case"clip":(d||w||c)&&function(t,e,i,s,n,a,r){const o=ht();ct(o,e.x,e.y),(i||s)&&ct(o,i,s),n&&(ft(o,n,a),t.scaleX=o.a,t.scaleY=o.d),r&&_t(o,r),t.transform=o}(g,s,p,y,w,m,c);break;case"repeat":(!_||w||c)&&function(t,e,i,s,n,a,r,o,d){const h=ht();if(d)switch(_t(h,d),d){case 90:ct(h,s,0);break;case 180:ct(h,i,s);break;case 270:ct(h,0,i)}dt.x=e.x,dt.y=e.y,(n||a)&&(dt.x+=n,dt.y+=a),ct(h,dt.x,dt.y),r&&(ut(h,dt,r,o),t.scaleX=r,t.scaleY=o),t.transform=h}(g,s,n,a,p,y,w,m,c),f||(g.repeat="repeat");break;default:_&&!c||function(t,e,i,s,n,a){const r=ht(),o=a&&180!==a,d=i.width/(o?n:s),h=i.height/(o?s:n),l="fit"===e?Math.min(d,h):Math.max(d,h),c=i.x+(i.width-s*l)/2,u=i.y+(i.height-n*l)/2;ct(r,c,u),ft(r,l),a&&lt(r,{x:i.x+i.width/2,y:i.y+i.height/2},a),t.scaleX=t.scaleY=l,t.transform=r}(g,o,s,n,a,c)}g.width=n,g.height=a,r&&(g.opacity=r),f&&(g.repeat="string"==typeof f?"x"===f?"repeat-x":"repeat-y":"repeat")}function wt(t,e,i){if("fill"===e&&!t.__.__naturalWidth){const{__:e}=t;if(e.__naturalWidth=i.width,e.__naturalHeight=i.height,!e.__getInput("width")||!e.__getInput("height"))return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",t.__.width),t.setProxyAttr("height",t.__.height)),!1}return!0}function mt(t,e){e.target.hasEvent(t)&&e.target.emitEvent(new k(t,e))}function xt(t,e,i,s){return new(i||(i=Promise))((function(n,a){function r(t){try{d(s.next(t))}catch(t){a(t)}}function o(t){try{d(s.throw(t))}catch(t){a(t)}}function d(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,o)}d((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const vt={},{get:bt,scale:Bt,copy:Rt}=E;function Et(t,e,i){let{scaleX:s,scaleY:n}=t.__world;const a=s+"-"+n;if(e.patternId===a||t.destroyed)return!1;{s=Math.abs(s),n=Math.abs(n);const{image:t,data:r}=e;let o,d,{width:h,height:l,scaleX:c,scaleY:u,opacity:f,transform:_,repeat:p}=r;c&&(d=bt(),Rt(d,_),Bt(d,1/c,1/u),s*=c,n*=u),s*=i,n*=i,h*=s,l*=n;const y=h*l;if(!p&&y>g.image.maxCacheSize)return!1;let w=g.image.maxPatternSize;if(!t.isSVG){const e=t.width*t.height;w>e&&(w=e)}y>w&&(o=Math.sqrt(y/w)),o&&(s/=o,n/=o,h/=o,l/=o),c&&(s/=c,n/=u),(_||1!==s||1!==n)&&(d||(d=bt(),_&&Rt(d,_)),Bt(d,1/s,1/n));const m=g.canvas.createPattern(t.getCanvas(h<1?1:h,l<1?1:l,f),p||g.origin.noRepeat||"no-repeat");try{e.transform&&(e.transform=null),d&&(m.setTransform?m.setTransform(d):e.transform=d)}catch(t){e.transform=d}return e.style=m,e.patternId=a,!0}}const{abs:kt}=Math;function Lt(t,e,i,s){const{scaleX:n,scaleY:a}=t.__world;if(i.data&&i.patternId!==n+"-"+a){const{data:r}=i;if(s)if(r.repeat)s=!1;else{let{width:t,height:i}=r;t*=kt(n)*e.pixelRatio,i*=kt(a)*e.pixelRatio,r.scaleX&&(t*=r.scaleX,i*=r.scaleY),s=t*i>g.image.maxCacheSize}return s?(e.save(),e.clip(),i.blendMode&&(e.blendMode=i.blendMode),r.opacity&&(e.opacity*=r.opacity),r.transform&&e.transform(r.transform),e.drawImage(i.image.view,0,0,r.width,r.height),e.restore(),!0):(!i.style||vt.running?Et(t,i,e.pixelRatio):i.patternTask||(i.patternTask=_.patternTasker.add((()=>xt(this,void 0,void 0,(function*(){i.patternTask=null,e.bounds.hit(t.__world)&&Et(t,i,e.pixelRatio),t.forceUpdate("surface")}))),300)),!1)}return!1}function St(t,e){const i=e["_"+t];if(i instanceof Array){let s,n,a,r;for(let o=0,d=i.length;o<d;o++)s=i[o].image,r=s&&s.url,r&&(n||(n={}),n[r]=!0,_.recycle(s),s.loading&&(a||(a=e.__input&&e.__input[t]||[],a instanceof Array||(a=[a])),s.unload(i[o].loadId,!a.some((t=>t.url===r)))));return n}return null}function At(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.fillText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.fillText(t.char,t.x,i.y)})),n&&e.fillRect(i.x,i.y+n,i.width,a)}function Mt(t,e,i,s){const{strokeAlign:n}=e.__,a="string"!=typeof t;switch(n){case"center":i.setStroke(a?void 0:t,e.__.strokeWidth,e.__),a?Tt(t,!0,e,i):Ot(e,i);break;case"inside":Ct("inside",t,a,e,i,s);break;case"outside":Ct("outside",t,a,e,i,s)}}function Ct(t,e,i,s,n,a){const{strokeWidth:r,__font:o}=s.__,d=n.getSameCanvas(!0);d.setStroke(i?void 0:e,2*r,s.__),d.font=o,i?Tt(e,!0,s,d):Ot(s,d),d.blendMode="outside"===t?"destination-out":"destination-in",At(s,d),d.blendMode="normal",s.__worldFlipped||a.matrix?n.copyWorldByReset(d):n.copyWorldToInner(d,s.__world,s.__layout.renderBounds),d.recycle()}function Ot(t,e){let i;const{rows:s,decorationY:n,decorationHeight:a}=t.__.__textDrawData;for(let t=0,r=s.length;t<r;t++)i=s[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach((t=>{e.strokeText(t.char,t.x,i.y)})),n&&e.strokeRect(i.x,i.y+n,i.width,a)}function Tt(t,e,i,s){let n;for(let a=0,r=t.length;a<r;a++)n=t[a],n.image&&Lt(i,s,n,!1)||n.style&&(s.strokeStyle=n.style,n.blendMode?(s.saveBlendMode(n.blendMode),e?Ot(i,s):s.stroke(),s.restoreBlendMode()):e?Ot(i,s):s.stroke())}const{getSpread:It,getOuterOf:Wt,getByMove:Dt,getIntersectData:Pt}=w;const Ft={x:.5,y:0},Yt={x:.5,y:1};function Nt(t,e,i){let s;for(let n=0,a=e.length;n<a;n++)s=e[n],t.addColorStop(s.offset,M.string(s.color,i))}const{set:Ut,getAngle:Ht,getDistance:Vt}=L,{get:Xt,rotateOfOuter:qt,scaleOfOuter:jt}=E,zt={x:.5,y:.5},Gt={x:.5,y:1},Qt={},Zt={};const{set:Kt,getAngle:$t,getDistance:Jt}=L,{get:te,rotateOfOuter:ee,scaleOfOuter:ie}=E,se={x:.5,y:.5},ne={x:.5,y:1},ae={},re={};let oe;function de(t,e,i){if("object"!=typeof e||!1===e.visible||0===e.opacity)return;const{boxBounds:s}=i.__layout;switch(e.type){case"solid":let{type:n,blendMode:a,color:r,opacity:o}=e;return{type:n,blendMode:a,style:M.string(r,o)};case"image":return function(t,e,i,s,n){const a={type:i.type},r=a.image=_.get(i),o=(n||r.loading)&&{target:t,image:r,attrName:e,attrValue:i};return r.ready?(wt(t,e,r)&&yt(a,r,i,s),n&&(mt(k.LOAD,o),mt(k.LOADED,o))):r.error?n&&(t.forceUpdate("surface"),o.error=r.error,mt(k.ERROR,o)):(n&&mt(k.LOAD,o),a.loadId=r.load((()=>{t.destroyed||(wt(t,e,r)&&(yt(a,r,i,s),t.forceUpdate("surface")),mt(k.LOADED,o))}),(e=>{t.forceUpdate("surface"),o.error=e,mt(k.ERROR,o)}))),a}(i,t,e,s,!oe||!oe[e.url]);case"linear":return function(t,e){let{from:i,to:s,type:n,blendMode:a,opacity:r}=t;i||(i=Ft),s||(s=Yt);const o=g.canvas.createLinearGradient(e.x+i.x*e.width,e.y+i.y*e.height,e.x+s.x*e.width,e.y+s.y*e.height);Nt(o,t.stops,r);const d={type:n,style:o};return a&&(d.blendMode=a),d}(e,s);case"radial":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=zt),s||(s=Gt);const{x:d,y:h,width:l,height:c}=e;let u;Ut(Qt,d+i.x*l,h+i.y*c),Ut(Zt,d+s.x*l,h+s.y*c),(l!==c||o)&&(u=Xt(),jt(u,Qt,l/c*(o||1),1),qt(u,Qt,Ht(Qt,Zt)+90));const f=g.canvas.createRadialGradient(Qt.x,Qt.y,0,Qt.x,Qt.y,Vt(Qt,Zt));Nt(f,t.stops,a);const _={type:n,style:f,transform:u};return r&&(_.blendMode=r),_}(e,s);case"angular":return function(t,e){let{from:i,to:s,type:n,opacity:a,blendMode:r,stretch:o}=t;i||(i=se),s||(s=ne);const{x:d,y:h,width:l,height:c}=e;Kt(ae,d+i.x*l,h+i.y*c),Kt(re,d+s.x*l,h+s.y*c);const u=te(),f=$t(ae,re);g.conicGradientRotate90?(ie(u,ae,l/c*(o||1),1),ee(u,ae,f+90)):(ie(u,ae,1,l/c*(o||1)),ee(u,ae,f));const _=g.conicGradientSupport?g.canvas.createConicGradient(0,ae.x,ae.y):g.canvas.createRadialGradient(ae.x,ae.y,0,ae.x,ae.y,Jt(ae,re));Nt(_,t.stops,a);const p={type:n,style:_,transform:u};return r&&(p.blendMode=r),p}(e,s);default:return e.r?{type:"solid",style:M.string(e)}:void 0}}var he=Object.freeze({__proto__:null,compute:function(t,e){const i=[],s=e.__;let n,a,r=s.__input[t];r instanceof Array||(r=[r]),oe=St(t,s);for(let s=0,a=r.length;s<a;s++)n=de(t,r[s],e),n&&i.push(n);if(s["_"+t]=i.length?i:void 0,1===r.length){const t=r[0];"image"===t.type&&(a=C.isPixel(t))}"fill"===t?s.__pixelFill=a:s.__pixelStroke=a},drawTextStroke:Ot,fill:function(t,e,i){i.fillStyle=t,e.__.__font?At(e,i):e.__.windingRule?i.fill(e.__.windingRule):i.fill()},fillText:At,fills:function(t,e,i){let s;const{windingRule:n,__font:a}=e.__;for(let r=0,o=t.length;r<o;r++)s=t[r],s.image&&Lt(e,i,s,!a)||s.style&&(i.fillStyle=s.style,s.transform?(i.save(),i.transform(s.transform),s.blendMode&&(i.blendMode=s.blendMode),a?At(e,i):n?i.fill(n):i.fill(),i.restore()):s.blendMode?(i.saveBlendMode(s.blendMode),a?At(e,i):n?i.fill(n):i.fill(),i.restoreBlendMode()):a?At(e,i):n?i.fill(n):i.fill())},recycleImage:St,shape:function(t,e,i){const s=e.getSameCanvas();let n,a,r,o;const{__world:d}=t;let{scaleX:h,scaleY:l}=d;if(h<0&&(h=-h),l<0&&(l=-l),e.bounds.includes(d,i.matrix))i.matrix?(h*=i.matrix.a,l*=i.matrix.d,n=r=Wt(d,i.matrix)):n=r=d,o=s;else{const{renderShapeSpread:s}=t.__layout,c=Pt(s?It(e.bounds,s*h,s*l):e.bounds,d,i.matrix);a=e.bounds.getFitMatrix(c),a.a<1&&(o=e.getSameCanvas(),t.__renderShape(o,i),h*=a.a,l*=a.d),r=Wt(d,a),n=Dt(r,-a.e,-a.f),i.matrix&&a.multiply(i.matrix),i=Object.assign(Object.assign({},i),{matrix:a})}return t.__renderShape(s,i),{canvas:s,matrix:a,bounds:n,worldCanvas:o,shapeBounds:r,scaleX:h,scaleY:l}},stroke:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)Mt(t,e,i,s);else switch(r){case"center":i.setStroke(t,a,n),i.stroke();break;case"inside":i.save(),i.setStroke(t,2*a,n),n.windingRule?i.clip(n.windingRule):i.clip(),i.stroke(),i.restore();break;case"outside":const r=i.getSameCanvas(!0);r.setStroke(t,2*a,e.__),e.__drawRenderPath(r),r.stroke(),n.windingRule?r.clip(n.windingRule):r.clip(),r.clearWorld(e.__layout.renderBounds),e.__worldFlipped||s.matrix?i.copyWorldByReset(r):i.copyWorldToInner(r,e.__world,e.__layout.renderBounds),r.recycle()}},strokeText:Mt,strokes:function(t,e,i,s){const n=e.__,{strokeWidth:a,strokeAlign:r,__font:o}=n;if(a)if(o)Mt(t,e,i,s);else switch(r){case"center":i.setStroke(void 0,a,n),Tt(t,!1,e,i);break;case"inside":i.save(),i.setStroke(void 0,2*a,n),n.windingRule?i.clip(n.windingRule):i.clip(),Tt(t,!1,e,i),i.restore();break;case"outside":const{renderBounds:r}=e.__layout,o=i.getSameCanvas(!0);e.__drawRenderPath(o),o.setStroke(void 0,2*a,e.__),Tt(t,!1,e,o),n.windingRule?o.clip(n.windingRule):o.clip(),o.clearWorld(r),e.__worldFlipped||s.matrix?i.copyWorldByReset(o):i.copyWorldToInner(o,e.__world,r),o.recycle()}}});const{copy:le,toOffsetOutBounds:ce}=w,ue={},fe={};function _e(t,e,i,s){const{bounds:n,shapeBounds:a}=s;if(g.fullImageShadow){if(le(ue,t.bounds),ue.x+=e.x-a.x,ue.y+=e.y-a.y,i){const{matrix:t}=s;ue.x-=(n.x+(t?t.e:0)+n.width/2)*(i-1),ue.y-=(n.y+(t?t.f:0)+n.height/2)*(i-1),ue.width*=i,ue.height*=i}t.copyWorld(s.canvas,t.bounds,ue)}else i&&(le(ue,e),ue.x-=e.width/2*(i-1),ue.y-=e.height/2*(i-1),ue.width*=i,ue.height*=i),t.copyWorld(s.canvas,a,i?ue:e)}const{toOffsetOutBounds:ge}=w,pe={};var ye=Object.freeze({__proto__:null,blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__world.a),i.copyWorldToInner(e,t.__world,t.__layout.renderBounds),i.filter="none"},innerShadow:function(t,e,i,s){let n,a;const{__world:r,__layout:o}=t,{innerShadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;ge(l,pe),d.forEach(((d,p)=>{_.save(),_.setWorldShadow(pe.offsetX+d.x*u,pe.offsetY+d.y*f,d.blur*u),a=d.spread?1-2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,_e(_,pe,a,i),_.restore(),h?(_.copyWorld(_,l,r,"copy"),_.copyWorld(h,r,r,"source-out"),n=r):(_.copyWorld(i.canvas,c,l,"source-out"),n=l),_.fillWorld(n,d.color,"source-in"),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()},shadow:function(t,e,i,s){let n,a;const{__world:r,__layout:o}=t,{shadow:d}=t.__,{worldCanvas:h,bounds:l,shapeBounds:c,scaleX:u,scaleY:f}=i,_=e.getSameCanvas(),g=d.length-1;ce(l,fe),d.forEach(((d,p)=>{_.setWorldShadow(fe.offsetX+d.x*u,fe.offsetY+d.y*f,d.blur*u,d.color),a=d.spread?1+2*d.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0)):0,_e(_,fe,a,i),n=l,d.box&&(_.restore(),_.save(),h&&(_.copyWorld(_,l,r,"copy"),n=r),h?_.copyWorld(h,r,r,"destination-out"):_.copyWorld(i.canvas,c,l,"destination-out")),t.__worldFlipped||s.matrix?e.copyWorldByReset(_,n,r,d.blendMode):e.copyWorldToInner(_,n,o.renderBounds,d.blendMode),g&&p<g&&_.clear()})),_.recycle()}});const we=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",me=we+"_#~&*+\\=|≮≯≈≠=…",xe=new RegExp([[19968,40959],[13312,19903],[131072,173791],[173824,177983],[177984,178207],[178208,183983],[183984,191471],[196608,201551],[201552,205743],[11904,12031],[12032,12255],[12272,12287],[12288,12351],[12736,12783],[12800,13055],[13056,13311],[63744,64255],[65072,65103],[127488,127743],[194560,195103]].map((([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`)).join("|"));function ve(t){const e={};return t.split("").forEach((t=>e[t]=!0)),e}const be=ve("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Be=ve("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Re=ve(we),Ee=ve(me),ke=ve("- —/~|┆·");var Le;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(Le||(Le={}));const{Letter:Se,Single:Ae,Before:Me,After:Ce,Symbol:Oe,Break:Te}=Le;function Ie(t){return be[t]?Se:ke[t]?Te:Be[t]?Me:Re[t]?Ce:Ee[t]?Oe:xe.test(t)?Ae:Se}const We={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function De(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Pe}=We,{Letter:Fe,Single:Ye,Before:Ne,After:Ue,Symbol:He,Break:Ve}=Le;let Xe,qe,je,ze,Ge,Qe,Ze,Ke,$e,Je,ti,ei,ii,si,ni,ai,ri=[];function oi(t,e){$e&&!Ke&&(Ke=$e),Xe.data.push({char:t,width:e}),je+=e}function di(){ze+=je,Xe.width=je,qe.words.push(Xe),Xe={data:[]},je=0}function hi(){si&&(ni.paraNumber++,qe.paraStart=!0,si=!1),$e&&(qe.startCharSize=Ke,qe.endCharSize=$e,Ke=0),qe.width=ze,ai.width&&Pe(qe),ri.push(qe),qe={words:[]},ze=0}const{top:li,right:ci,bottom:ui,left:fi}=S,_i={getDrawData(t,e){"string"!=typeof t&&(t=String(t));let i=0,s=0,n=e.__getInput("width")||0,a=e.__getInput("height")||0;const{textDecoration:r,__font:o,__padding:d}=e;d&&(n&&(i=d[fi],n-=d[ci]+d[fi]),a&&(s=d[li],a-=d[li]+d[ui]));const h={bounds:{x:i,y:s,width:n,height:a},rows:[],paraNumber:0,font:g.canvas.font=o};return function(t,e,i){ni=t,ri=t.rows,ai=t.bounds;const{__letterSpacing:s,paraIndent:n,textCase:a}=i,{canvas:r}=g,{width:o,height:d}=ai;if(o||d||s||"none"!==a){const t="none"!==i.textWrap,d="break"===i.textWrap;si=!0,ti=null,Ke=Ze=$e=je=ze=0,Xe={data:[]},qe={words:[]};for(let i=0,h=e.length;i<h;i++)Qe=e[i],"\n"===Qe?(je&&di(),qe.paraEnd=!0,hi(),si=!0):(Je=Ie(Qe),Je===Fe&&"none"!==a&&(Qe=De(Qe,a,!je)),Ze=r.measureText(Qe).width,s&&(s<0&&($e=Ze),Ze+=s),ei=Je===Ye&&(ti===Ye||ti===Fe)||ti===Ye&&Je!==Ue,ii=!(Je!==Ne&&Je!==Ye||ti!==He&&ti!==Ue),Ge=si&&n?o-n:o,t&&o&&ze+je+Ze>Ge&&(d?(je&&di(),hi()):(ii||(ii=Je===Fe&&ti==Ue),ei||ii||Je===Ve||Je===Ne||Je===Ye||je+Ze>Ge?(je&&di(),hi()):hi()))," "===Qe&&!0!==si&&ze+je===0||(Je===Ve?(" "===Qe&&je&&di(),oi(Qe,Ze),di()):ei||ii?(je&&di(),oi(Qe,Ze)):oi(Qe,Ze)),ti=Je);je&&di(),ze&&hi(),ri.length>0&&(ri[ri.length-1].paraEnd=!0)}else e.split("\n").forEach((t=>{ni.paraNumber++,ri.push({x:n||0,text:t,width:r.measureText(t).width,paraStart:!0})}))}(h,t,e),d&&function(t,e,i,s,n){if(!s)switch(i.textAlign){case"left":gi(e,"x",t[fi]);break;case"right":gi(e,"x",-t[ci])}if(!n)switch(i.verticalAlign){case"top":gi(e,"y",t[li]);break;case"bottom":gi(e,"y",-t[ui])}}(d,h,e,n,a),function(t,e){const{rows:i,bounds:s}=t,{__lineHeight:n,__baseLine:a,__letterSpacing:r,__clipText:o,textAlign:d,verticalAlign:h,paraSpacing:l}=e;let c,u,f,{x:_,y:g,width:p,height:y}=s,w=n*i.length+(l?l*(t.paraNumber-1):0),m=a;if(o&&w>y)w=Math.max(y,n),t.overflow=i.length;else switch(h){case"middle":g+=(y-w)/2;break;case"bottom":g+=y-w}m+=g;for(let a=0,h=i.length;a<h;a++){switch(c=i[a],c.x=_,d){case"center":c.x+=(p-c.width)/2;break;case"right":c.x+=p-c.width}c.paraStart&&l&&a>0&&(m+=l),c.y=m,m+=n,t.overflow>a&&m>w&&(c.isOverflow=!0,t.overflow=a+1),u=c.x,f=c.width,r<0&&(c.width<0?(f=-c.width+e.fontSize+r,u-=f,f+=e.fontSize):f-=r),u<s.x&&(s.x=u),f>s.width&&(s.width=f),o&&p&&p<f&&(c.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=g,s.height=w}(h,e),function(t,e,i,s){const{rows:n}=t,{textAlign:a,paraIndent:r,letterSpacing:o}=e;let d,h,l,c,u;n.forEach((t=>{t.words&&(l=r&&t.paraStart?r:0,h=i&&"justify"===a&&t.words.length>1?(i-t.width-l)/(t.words.length-1):0,c=o||t.isOverflow?0:h>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=l,function(t){t.text="",t.words.forEach((e=>{e.data.forEach((e=>{t.text+=e.char}))}))}(t)):(t.x+=l,d=t.x,t.data=[],t.words.forEach((e=>{1===c?(u={char:"",x:d},d=function(t,e,i){return t.forEach((t=>{i.char+=t.char,e+=t.width})),e}(e.data,d,u)," "!==u.char&&t.data.push(u)):d=function(t,e,i){return t.forEach((t=>{" "!==t.char&&(t.x=e,i.push(t)),e+=t.width})),e}(e.data,d,t.data),!t.paraEnd&&h&&(d+=h,t.width+=h)}))),t.words=null)}))}(h,e,n),h.overflow&&function(t,e){const{rows:i,overflow:s}=t;let{textOverflow:n}=e;if(i.splice(s),"hide"!==n){let t,a;"ellipsis"===n&&(n="...");const r=g.canvas.measureText(n).width,o=e.x+e.width-r;("none"===e.textWrap?i:[i[s-1]]).forEach((e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],a=t.x+t.width,!(s===i&&a<o));s--){if(a<o&&" "!==t.char){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=r,e.data.push({char:n,x:a}),e.textMode&&function(t){t.text="",t.data.forEach((e=>{t.text+=e.char})),t.data=null}(e)}}))}}(h,e),"none"!==r&&function(t,e){const{fontSize:i}=e;switch(t.decorationHeight=i/11,e.textDecoration){case"under":t.decorationY=.15*i;break;case"delete":t.decorationY=.35*-i}}(h,e),h}};function gi(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const pi={string(t,e){if("string"==typeof t)return t;let i=void 0===t.a?1:t.a;e&&(i*=e);const s=t.r+","+t.g+","+t.b;return 1===i?"rgb("+s+")":"rgba("+s+","+i+")"}},yi={export(t,e,i){return yi.running=!0,function(t){wi||(wi=new A);return new Promise((e=>{wi.add((()=>xt(this,void 0,void 0,(function*(){return yield t(e)}))),{parallel:!1})}))}((s=>new Promise((n=>{const{leafer:a}=t;a?a.waitViewCompleted((()=>xt(this,void 0,void 0,(function*(){let t,r,o,{canvas:d}=a,{unreal:h}=d;switch(h&&(d=d.getSameCanvas(),d.backgroundColor=a.config.fill,a.__render(d,{})),typeof i){case"object":i.quality&&(t=i.quality),i.blob&&(r=!0);break;case"number":t=i;break;case"boolean":r=i}o=e.includes(".")?yield d.saveAs(e,t):r?yield d.toBlob(e,t):yield d.toDataURL(e,t),s({data:o}),n(),yi.running=!1,h&&d.recycle()})))):(s({data:!1}),n(),yi.running=!1)}))))}};let wi;Object.assign(O,he),Object.assign(T,ye),Object.assign(I,_i),Object.assign(M,pi),Object.assign(W,yi),rt();export{G as Layouter,nt as LeaferCanvas,Z as Renderer,st as Selector,D as Watcher,rt as useCanvas};
package/dist/worker.js CHANGED
@@ -5938,7 +5938,7 @@ var LeaferUI = (function (exports) {
5938
5938
  canvas.setWorld(this.__world, options.matrix);
5939
5939
  canvas.opacity = this.__worldOpacity;
5940
5940
  if (this.__.__single) {
5941
- const tempCanvas = canvas.getSameCanvas(true);
5941
+ const tempCanvas = canvas.getSameCanvas(true, true);
5942
5942
  this.__draw(tempCanvas, options);
5943
5943
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5944
5944
  if (this.__worldFlipped || options.matrix) {
@@ -6015,7 +6015,7 @@ var LeaferUI = (function (exports) {
6015
6015
  if (this.__worldOpacity) {
6016
6016
  if (this.__.__single) {
6017
6017
  canvas.resetTransform();
6018
- const tempCanvas = canvas.getSameCanvas();
6018
+ const tempCanvas = canvas.getSameCanvas(false, true);
6019
6019
  this.__renderBranch(tempCanvas, options);
6020
6020
  canvas.opacity = this.__worldOpacity;
6021
6021
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
@@ -7618,6 +7618,9 @@ var LeaferUI = (function (exports) {
7618
7618
  class LineData extends UIData {
7619
7619
  }
7620
7620
 
7621
+ class ArrowData extends LineData {
7622
+ }
7623
+
7621
7624
  class RectData extends UIData {
7622
7625
  get __boxStroke() { return true; }
7623
7626
  }
@@ -7676,6 +7679,25 @@ var LeaferUI = (function (exports) {
7676
7679
  }
7677
7680
 
7678
7681
  class ImageData extends RectData {
7682
+ setUrl(value) {
7683
+ this.__setImageFill(value);
7684
+ this._url = value;
7685
+ }
7686
+ __setImageFill(value) {
7687
+ if (this.__leaf.image)
7688
+ this.__leaf.image = null;
7689
+ this.fill = value ? { type: 'image', mode: 'strench', url: value } : undefined;
7690
+ }
7691
+ __getData() {
7692
+ const data = super.__getData();
7693
+ delete data.fill;
7694
+ return data;
7695
+ }
7696
+ __getInputData() {
7697
+ const data = super.__getInputData();
7698
+ delete data.fill;
7699
+ return data;
7700
+ }
7679
7701
  }
7680
7702
 
7681
7703
  class CanvasData extends RectData {
@@ -7922,14 +7944,15 @@ var LeaferUI = (function (exports) {
7922
7944
  findOne(condition, options) {
7923
7945
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
7924
7946
  }
7925
- getPath(curve) {
7926
- const { path } = this.__;
7947
+ getPath(curve, pathForRender) {
7948
+ this.__layout.update();
7949
+ let path = pathForRender ? this.__.__pathForRender : this.__.path;
7927
7950
  if (!path)
7928
- return [];
7951
+ this.__drawPathByBox(new PathCreator(path = []));
7929
7952
  return curve ? PathConvert.toCanvasData(path, true) : path;
7930
7953
  }
7931
- getPathString(curve) {
7932
- return PathConvert.stringify(this.getPath(curve));
7954
+ getPathString(curve, pathForRender) {
7955
+ return PathConvert.stringify(this.getPath(curve, pathForRender));
7933
7956
  }
7934
7957
  __onUpdateSize() {
7935
7958
  if (this.__.__input) {
@@ -8101,6 +8124,12 @@ var LeaferUI = (function (exports) {
8101
8124
  __decorate([
8102
8125
  strokeType(10)
8103
8126
  ], exports.UI.prototype, "miterLimit", void 0);
8127
+ __decorate([
8128
+ strokeType('none')
8129
+ ], exports.UI.prototype, "startArrow", void 0);
8130
+ __decorate([
8131
+ strokeType('none')
8132
+ ], exports.UI.prototype, "endArrow", void 0);
8104
8133
  __decorate([
8105
8134
  pathType(0)
8106
8135
  ], exports.UI.prototype, "cornerRadius", void 0);
@@ -8597,26 +8626,10 @@ var LeaferUI = (function (exports) {
8597
8626
  get ready() { return this.image ? this.image.ready : false; }
8598
8627
  constructor(data) {
8599
8628
  super(data);
8600
- }
8601
- __updateBoxBounds() {
8602
- let update;
8603
- const { url } = this;
8604
- const fill = this.fill;
8605
- if (fill) {
8606
- if (fill.url !== url)
8607
- update = true;
8608
- }
8609
- else {
8610
- if (url)
8611
- update = true;
8612
- }
8613
- if (update) {
8614
- if (this.image)
8615
- this.image = null;
8616
- this.fill = url ? { type: 'image', mode: 'strench', url } : undefined;
8617
- this.once(ImageEvent.LOADED, (e) => this.image = e.image);
8618
- }
8619
- super.__updateBoxBounds();
8629
+ this.on(ImageEvent.LOADED, (e) => {
8630
+ if (e.attrName === 'fill' && e.attrValue.url === this.url)
8631
+ this.image = e.image;
8632
+ });
8620
8633
  }
8621
8634
  destroy() {
8622
8635
  this.image = null;
@@ -9376,6 +9389,7 @@ var LeaferUI = (function (exports) {
9376
9389
  registerUI()
9377
9390
  ], exports.App);
9378
9391
 
9392
+ let origin = {};
9379
9393
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
9380
9394
  function fillOrFitMode(data, mode, box, width, height, rotation) {
9381
9395
  const transform = get$4();
@@ -9392,13 +9406,13 @@ var LeaferUI = (function (exports) {
9392
9406
  data.scaleX = data.scaleY = scale;
9393
9407
  data.transform = transform;
9394
9408
  }
9395
- function clipMode(data, box, offset, scale, rotation) {
9409
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
9396
9410
  const transform = get$4();
9397
9411
  translate$1(transform, box.x, box.y);
9398
- if (offset)
9399
- translate$1(transform, offset.x, offset.y);
9400
- if (scale) {
9401
- typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
9412
+ if (x || y)
9413
+ translate$1(transform, x, y);
9414
+ if (scaleX) {
9415
+ scaleHelper(transform, scaleX, scaleY);
9402
9416
  data.scaleX = transform.a;
9403
9417
  data.scaleY = transform.d;
9404
9418
  }
@@ -9406,7 +9420,7 @@ var LeaferUI = (function (exports) {
9406
9420
  rotate(transform, rotation);
9407
9421
  data.transform = transform;
9408
9422
  }
9409
- function repeatMode(data, box, width, height, scale, rotation) {
9423
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
9410
9424
  const transform = get$4();
9411
9425
  if (rotation) {
9412
9426
  rotate(transform, rotation);
@@ -9422,10 +9436,15 @@ var LeaferUI = (function (exports) {
9422
9436
  break;
9423
9437
  }
9424
9438
  }
9425
- translate$1(transform, box.x, box.y);
9426
- if (scale) {
9427
- scaleOfOuter$2(transform, box, scale);
9428
- data.scaleX = data.scaleY = scale;
9439
+ origin.x = box.x;
9440
+ origin.y = box.y;
9441
+ if (x || y)
9442
+ origin.x += x, origin.y += y;
9443
+ translate$1(transform, origin.x, origin.y);
9444
+ if (scaleX) {
9445
+ scaleOfOuter$2(transform, origin, scaleX, scaleY);
9446
+ data.scaleX = scaleX;
9447
+ data.scaleY = scaleY;
9429
9448
  }
9430
9449
  data.transform = transform;
9431
9450
  }
@@ -9433,11 +9452,22 @@ var LeaferUI = (function (exports) {
9433
9452
  const { get: get$3, translate } = MatrixHelper;
9434
9453
  function createData(leafPaint, image, paint, box) {
9435
9454
  let { width, height } = image;
9436
- const { opacity, mode, offset, scale, rotation, blendMode, repeat } = paint;
9455
+ const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
9437
9456
  const sameBox = box.width === width && box.height === height;
9438
9457
  if (blendMode)
9439
9458
  leafPaint.blendMode = blendMode;
9440
9459
  const data = leafPaint.data = { mode };
9460
+ let x, y, scaleX, scaleY;
9461
+ if (offset)
9462
+ x = offset.x, y = offset.y;
9463
+ if (size) {
9464
+ scaleX = (typeof size === 'number' ? size : size.width) / width;
9465
+ scaleY = (typeof size === 'number' ? size : size.height) / height;
9466
+ }
9467
+ else if (scale) {
9468
+ scaleX = typeof scale === 'number' ? scale : scale.x;
9469
+ scaleY = typeof scale === 'number' ? scale : scale.y;
9470
+ }
9441
9471
  switch (mode) {
9442
9472
  case 'strench':
9443
9473
  if (!sameBox)
@@ -9448,12 +9478,12 @@ var LeaferUI = (function (exports) {
9448
9478
  }
9449
9479
  break;
9450
9480
  case 'clip':
9451
- if (offset || scale || rotation)
9452
- clipMode(data, box, offset, scale, rotation);
9481
+ if (offset || scaleX || rotation)
9482
+ clipMode(data, box, x, y, scaleX, scaleY, rotation);
9453
9483
  break;
9454
9484
  case 'repeat':
9455
- if (!sameBox || scale || rotation)
9456
- repeatMode(data, box, width, height, scale, rotation);
9485
+ if (!sameBox || scaleX || rotation)
9486
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
9457
9487
  if (!repeat)
9458
9488
  data.repeat = 'repeat';
9459
9489
  break;
@@ -10758,6 +10788,7 @@ var LeaferUI = (function (exports) {
10758
10788
  exports.Animate = Animate;
10759
10789
  exports.AnimateEvent = AnimateEvent;
10760
10790
  exports.AroundHelper = AroundHelper;
10791
+ exports.ArrowData = ArrowData;
10761
10792
  exports.AutoBounds = AutoBounds;
10762
10793
  exports.BezierHelper = BezierHelper;
10763
10794
  exports.Bounds = Bounds;