@leafer-ui/draw 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{decorateLeafAttr as t,attr as e,defineKey as i,Plugin as s,Debug as o,LeafData as r,PathConvert as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as A,useModule as P,rewriteAble as F,MathHelper as D,pen as I,PathCorner as E,PathDrawer as W,UICreator as L,registerUI as z,Branch as T,LeafList as M,ImageManager as O,DataHelper as N,Creator as V,CanvasManager as j,WaitHelper as H,LeaferEvent as Y,Bounds as X,ResizeEvent as U,AutoBounds as q,Run as G,LayoutEvent as J,RenderEvent as $,WatchEvent as K,affectRenderBoundsType as Q,BoundsHelper as Z,Platform as tt,PathCommandDataHelper as et,affectStrokeBoundsType as it,getPointData as st,PointHelper as ot,PathBounds as rt,ImageEvent as at,LeaferImage as nt,Matrix as _t,PathCreator as ht}from"@leafer/core";export*from"@leafer/core";function dt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function pt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function lt(i){return t(i,(t=>e({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function ut(){return(t,e)=>{const s="_"+e;i(t,e,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const ct={},yt={},gt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},vt={},ft={},wt={},xt={},mt={},Rt={},St={setStyleName:(t,e,i)=>s.need("state"),set:(t,e)=>s.need("state")},kt={list:{},register(t,e){kt.list[t]=e},get:t=>kt.list[t]},{parse:Bt,objectToCanvasData:bt}=a,Ct={},At=o.get("UIData");class Pt extends r{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,At.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,At.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Ct)):(this.__isFills&&(this.__removeInput("fill"),wt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Ct)):(this.__isStrokes&&(this.__removeInput("stroke"),wt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Bt(t):bt(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){this.__setInput("shadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._shadow=t.length?t:null):this._shadow=t&&!1!==t.visible?[t]:null}setInnerShadow(t){this.__setInput("innerShadow",t),t instanceof Array?(t.some((t=>!1===t.visible))&&(t=t.filter((t=>!1!==t.visible))),this._innerShadow=t.length?t:null):this._innerShadow=t&&!1!==t.visible?[t]:null}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&ft.compute("fill",this.__leaf),e&&ft.compute("stroke",this.__leaf),this.__needComputePaint=!1}}class Ft extends Pt{}class Dt extends Ft{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class It extends Ft{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class Et extends Dt{}class Wt extends Pt{}class Lt extends Pt{get __boxStroke(){return!this.__pathInputed}}class zt extends Pt{get __boxStroke(){return!this.__pathInputed}}class Tt extends Pt{}class Mt extends Pt{}class Ot extends Pt{get __pathInputed(){return 2}}class Nt extends Ft{}const Vt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class jt extends Pt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Vt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ht extends Lt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class Yt extends Lt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Xt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s));let r=t=Math.ceil(t);return i&&i.forEach((t=>r=Math.max(r,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(r=Math.max(r,o)),this.__layout.renderShapeSpread=r,t+(this.__layout.strokeSpread||0)}},Ut={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o}=this.__;t.__useEffect=!!(e||i||s||o)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){qt(this,t,e)},__draw(t,e){const i=this.__;if(i.__complex){i.__needComputePaint&&i.__computePaint();const{fill:s,stroke:o,__drawAfterFill:r}=i;if(this.__drawRenderPath(t),i.__useEffect){const a=ft.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:n,innerShadow:_}=i;n&&mt.shadow(this,t,a),s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),_&&mt.innerShadow(this,t,a),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t)),a.worldCanvas&&a.worldCanvas.recycle(),a.canvas.recycle()}else s&&(i.__isFills?ft.fills(s,this,t):ft.fill(s,this,t)),r&&this.__drawAfterFill(t,e),o&&(i.__isStrokes?ft.strokes(o,this,t):ft.stroke(o,this,t))}else i.__pathInputed?qt(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?ft.fills(o,this,t):ft.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?ft.strokes(r,this,t):ft.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function qt(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&ft.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&ft.stroke(o,t,e)}const Gt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var Jt;let $t=Jt=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return I.set(this.path=t||[]),t||this.__drawPathByBox(I),I}get editConfig(){}get editOuter(){return""}get editInner(){return""}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return s.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return s.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(I.set(i=[]),this.__drawPathByBox(I)),t?a.toCanvasData(i,!0):i}getPathString(t,e,i){return a.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||Rt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&vt.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?W.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s.need("animate")}killAnimate(t,e){}export(t,e){return s.need("export")}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),Jt.one(e)}static one(t,e,i,s,o){return L.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){z()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};dt([_(Pt)],$t.prototype,"__",void 0),dt([ut()],$t.prototype,"zoomLayer",void 0),dt([h("")],$t.prototype,"id",void 0),dt([h("")],$t.prototype,"name",void 0),dt([h("")],$t.prototype,"className",void 0),dt([d("pass-through")],$t.prototype,"blendMode",void 0),dt([p(1)],$t.prototype,"opacity",void 0),dt([l(!0)],$t.prototype,"visible",void 0),dt([d(!1)],$t.prototype,"locked",void 0),dt([u(0)],$t.prototype,"zIndex",void 0),dt([c(!1)],$t.prototype,"mask",void 0),dt([y(!1)],$t.prototype,"eraser",void 0),dt([g(0,!0)],$t.prototype,"x",void 0),dt([g(0,!0)],$t.prototype,"y",void 0),dt([v(100,!0)],$t.prototype,"width",void 0),dt([v(100,!0)],$t.prototype,"height",void 0),dt([f(1,!0)],$t.prototype,"scaleX",void 0),dt([f(1,!0)],$t.prototype,"scaleY",void 0),dt([w(0,!0)],$t.prototype,"rotation",void 0),dt([w(0,!0)],$t.prototype,"skewX",void 0),dt([w(0,!0)],$t.prototype,"skewY",void 0),dt([g(0,!0)],$t.prototype,"offsetX",void 0),dt([g(0,!0)],$t.prototype,"offsetY",void 0),dt([g(0,!0)],$t.prototype,"scrollX",void 0),dt([g(0,!0)],$t.prototype,"scrollY",void 0),dt([x()],$t.prototype,"origin",void 0),dt([x()],$t.prototype,"around",void 0),dt([h(!1)],$t.prototype,"lazy",void 0),dt([m(1)],$t.prototype,"pixelRatio",void 0),dt([R()],$t.prototype,"path",void 0),dt([S()],$t.prototype,"windingRule",void 0),dt([S(!0)],$t.prototype,"closed",void 0),dt([v(0)],$t.prototype,"padding",void 0),dt([v(!1)],$t.prototype,"lockRatio",void 0),dt([v()],$t.prototype,"widthRange",void 0),dt([v()],$t.prototype,"heightRange",void 0),dt([h(!1)],$t.prototype,"draggable",void 0),dt([h()],$t.prototype,"dragBounds",void 0),dt([h(!1)],$t.prototype,"editable",void 0),dt([k(!0)],$t.prototype,"hittable",void 0),dt([k("path")],$t.prototype,"hitFill",void 0),dt([B("path")],$t.prototype,"hitStroke",void 0),dt([k(!1)],$t.prototype,"hitBox",void 0),dt([k(!0)],$t.prototype,"hitChildren",void 0),dt([k(!0)],$t.prototype,"hitSelf",void 0),dt([k()],$t.prototype,"hitRadius",void 0),dt([b("")],$t.prototype,"cursor",void 0),dt([d()],$t.prototype,"fill",void 0),dt([B()],$t.prototype,"stroke",void 0),dt([B("inside")],$t.prototype,"strokeAlign",void 0),dt([B(1)],$t.prototype,"strokeWidth",void 0),dt([B(!1)],$t.prototype,"strokeWidthFixed",void 0),dt([B("none")],$t.prototype,"strokeCap",void 0),dt([B("miter")],$t.prototype,"strokeJoin",void 0),dt([B()],$t.prototype,"dashPattern",void 0),dt([B()],$t.prototype,"dashOffset",void 0),dt([B(10)],$t.prototype,"miterLimit",void 0),dt([S(0)],$t.prototype,"cornerRadius",void 0),dt([S()],$t.prototype,"cornerSmoothing",void 0),dt([pt()],$t.prototype,"shadow",void 0),dt([pt()],$t.prototype,"innerShadow",void 0),dt([pt()],$t.prototype,"blur",void 0),dt([pt()],$t.prototype,"backgroundBlur",void 0),dt([pt()],$t.prototype,"grayscale",void 0),dt([h({})],$t.prototype,"data",void 0),dt([C(A.prototype.reset)],$t.prototype,"reset",null),$t=Jt=dt([P(Xt),P(Ut),F()],$t);let Kt=class extends $t{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var Qt;dt([_(Ft)],Kt.prototype,"__",void 0),Kt=dt([P(T),z()],Kt);const Zt=o.get("Leafer");let te=Qt=class extends Kt{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&O.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),Qt.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,N.assign(s,t));const o=this.canvas=V.canvas(s);this.__controllers.push(this.renderer=V.renderer(this,o,s),this.watcher=V.watcher(this,s),this.layouter=V.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=V.selector(this),this.interaction=V.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=V.hitCanvasManager()),this.canvasManager=new j,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(Y.RESTART):this.emitLeafer(Y.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Y.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=N.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=N.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new U(t,i))}__onResize(t){this.emitEvent(t),N.copyAttrs(this.__,t,n),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new q(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=N.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(Y.BEFORE_READY),this.emitLeafer(Y.READY),this.emitLeafer(Y.AFTER_READY),H.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Y.VIEW_READY),H.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,growWidth:e,growHeight:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;!1!==e&&(s=Math.max(1,a.x+a.width)),!1!==i&&(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Y.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i){return s.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new Y(t,this))}__listenEvents(){const t=G.start("FirstCreate "+this.innerName);this.once(Y.START,(()=>G.end(t))),this.once(J.START,(()=>this.updateLazyBounds())),this.once($.START,(()=>this.__onCreated())),this.once($.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(K.DATA,this.__onWatchData,this),this.on_(J.END,this.__onLayoutEnd,this),this.on_($.NEXT,this.__onNextRender,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){Qt.list.remove(this);try{this.stop(),this.emitEvent(new Y(Y.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{O.clearRecycled()}),100)}catch(t){Zt.error(t)}}};t?e():setTimeout(e)}};te.list=new M,dt([_(It)],te.prototype,"__",void 0),dt([v()],te.prototype,"pixelRatio",void 0),te=Qt=dt([z()],te);let ee=class extends $t{get __tag(){return"Rect"}constructor(t){super(t)}};dt([_(Lt)],ee.prototype,"__",void 0),ee=dt([P(Gt),F(),z()],ee);const{copy:ie,add:se,includes:oe}=Z,re=ee.prototype,ae=Kt.prototype,ne={};let _e=class extends Kt{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),ie(ne,e),this.__updateRectRenderBounds(),t=!oe(e,ne),t&&"hide"!==this.__.overflow&&se(e,ne)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};dt([_(Dt)],_e.prototype,"__",void 0),dt([h(!1)],_e.prototype,"resizeChildren",void 0),dt([Q("show")],_e.prototype,"overflow",void 0),dt([C(re.__updateStrokeSpread)],_e.prototype,"__updateStrokeSpread",null),dt([C(re.__updateRenderSpread)],_e.prototype,"__updateRectRenderSpread",null),dt([C(re.__updateBoxBounds)],_e.prototype,"__updateRectBoxBounds",null),dt([C(re.__updateStrokeBounds)],_e.prototype,"__updateStrokeBounds",null),dt([C(re.__updateRenderBounds)],_e.prototype,"__updateRectRenderBounds",null),dt([C(re.__updateChange)],_e.prototype,"__updateRectChange",null),dt([C(re.__render)],_e.prototype,"__renderRect",null),dt([C(ae.__render)],_e.prototype,"__renderGroup",null),_e=dt([F(),z()],_e);let he=class extends _e{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};dt([_(Et)],he.prototype,"__",void 0),dt([d("#FFFFFF")],he.prototype,"fill",void 0),dt([Q("hide")],he.prototype,"overflow",void 0),he=dt([z()],he);const{moveTo:de,closePath:pe,ellipse:le}=et;let ue=class extends $t{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&le(n,r,a,r*i,a*i,0,s,o,!1),le(n,r,a,r,a,0,o,s,!0),i<1&&pe(n)):(i<1&&(le(n,r,a,r*i,a*i),de(n,t,a)),le(n,r,a,r,a,0,360,0,!0)),tt.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(de(n,r,a),le(n,r,a,r,a,0,s,o,!1),pe(n)):le(n,r,a,r,a)}};dt([_(zt)],ue.prototype,"__",void 0),dt([S(0)],ue.prototype,"innerRadius",void 0),dt([S(0)],ue.prototype,"startAngle",void 0),dt([S(0)],ue.prototype,"endAngle",void 0),ue=dt([z()],ue);const{moveTo:ce,lineTo:ye,drawPoints:ge}=et,{rotate:ve,getAngle:fe,getDistance:we,defaultPoint:xe}=ot,{toBounds:me}=rt;let Re=class extends $t{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=st();return t&&(i.x=t),e&&ve(i,e),i}set toPoint(t){this.width=we(xe,t),this.rotation=fe(xe,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?ge(e,t.points,!1,t.closed):(ce(e,0,0),ye(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(ge(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&vt.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?me(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};dt([_(Wt)],Re.prototype,"__",void 0),dt([it("center")],Re.prototype,"strokeAlign",void 0),dt([v(0)],Re.prototype,"height",void 0),dt([S()],Re.prototype,"points",void 0),dt([S(0)],Re.prototype,"curve",void 0),dt([S(!1)],Re.prototype,"closed",void 0),Re=dt([z()],Re);const{sin:Se,cos:ke,PI:Be}=Math,{moveTo:be,lineTo:Ce,closePath:Ae,drawPoints:Pe}=et,Fe=Re.prototype;let De=class extends $t{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Pe(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;be(t,o,0);for(let e=1;e<s;e++)Ce(t,o+o*Se(2*e*Be/s),r-r*ke(2*e*Be/s))}Ae(t)}__updateRenderPath(){}__updateBoxBounds(){}};dt([_(Tt)],De.prototype,"__",void 0),dt([S(3)],De.prototype,"sides",void 0),dt([S()],De.prototype,"points",void 0),dt([S(0)],De.prototype,"curve",void 0),dt([C(Fe.__updateRenderPath)],De.prototype,"__updateRenderPath",null),dt([C(Fe.__updateBoxBounds)],De.prototype,"__updateBoxBounds",null),De=dt([F(),z()],De);const{sin:Ie,cos:Ee,PI:We}=Math,{moveTo:Le,lineTo:ze,closePath:Te}=et;let Me=class extends $t{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Le(a,o,0);for(let t=1;t<2*i;t++)ze(a,o+(t%2==0?o:o*s)*Ie(t*We/i),r-(t%2==0?r:r*s)*Ee(t*We/i));Te(a)}};dt([_(Mt)],Me.prototype,"__",void 0),dt([S(5)],Me.prototype,"corners",void 0),dt([S(.382)],Me.prototype,"innerRadius",void 0),Me=dt([z()],Me);let Oe=class extends ee{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(at.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};dt([_(Ht)],Oe.prototype,"__",void 0),dt([v("")],Oe.prototype,"url",void 0),Oe=dt([z()],Oe);const Ne=Oe;let Ve=class extends ee{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new nt({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new at(at.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new _t(t.worldTransform).invert(),r=new _t;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};dt([_(Yt)],Ve.prototype,"__",void 0),dt([lt(100)],Ve.prototype,"width",void 0),dt([lt(100)],Ve.prototype,"height",void 0),dt([lt(1)],Ve.prototype,"pixelRatio",void 0),dt([lt(!0)],Ve.prototype,"smooth",void 0),dt([h(!1)],Ve.prototype,"safeResize",void 0),dt([lt()],Ve.prototype,"contextSettings",void 0),Ve=dt([z()],Ve);const{copyAndSpread:je,includes:He,isSame:Ye,spread:Xe,setList:Ue}=Z;let qe=class extends $t{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=gt.number(e,o),t.__letterSpacing=gt.number(i,o),t.__padding=h?D.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=ct.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,_=e.boxBounds;if(t.__lineHeight<i&&Xe(n,i/2),r||a){if(_.x=r?n.x:0,_.y=a?n.y:0,_.width=r?n.width:t.width,_.height=a?n.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(_.x-=o,_.width+=i+o),a&&(_.y-=e,_.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(_.width+=.16*i);const h=He(_,n)?_:n;Ye(h,e.contentBounds)?t.__textBoxBounds=h:(e.contentBounds=h,e.renderChanged=!0,Ue(t.__textBoxBounds={},[_,n]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){je(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};dt([_(jt)],qe.prototype,"__",void 0),dt([v(0)],qe.prototype,"width",void 0),dt([v(0)],qe.prototype,"height",void 0),dt([h(!1)],qe.prototype,"resizeFontSize",void 0),dt([d("#000000")],qe.prototype,"fill",void 0),dt([it("outside")],qe.prototype,"strokeAlign",void 0),dt([k("all")],qe.prototype,"hitFill",void 0),dt([v("")],qe.prototype,"text",void 0),dt([v("caption")],qe.prototype,"fontFamily",void 0),dt([v(12)],qe.prototype,"fontSize",void 0),dt([v("normal")],qe.prototype,"fontWeight",void 0),dt([v(!1)],qe.prototype,"italic",void 0),dt([v("none")],qe.prototype,"textCase",void 0),dt([v("none")],qe.prototype,"textDecoration",void 0),dt([v(0)],qe.prototype,"letterSpacing",void 0),dt([v({type:"percent",value:1.5})],qe.prototype,"lineHeight",void 0),dt([v(0)],qe.prototype,"paraIndent",void 0),dt([v(0)],qe.prototype,"paraSpacing",void 0),dt([v("x")],qe.prototype,"writingMode",void 0),dt([v("left")],qe.prototype,"textAlign",void 0),dt([v("top")],qe.prototype,"verticalAlign",void 0),dt([v(!0)],qe.prototype,"autoSizeAlign",void 0),dt([v("normal")],qe.prototype,"textWrap",void 0),dt([v("show")],qe.prototype,"textOverflow",void 0),qe=dt([z()],qe);let Ge=class extends $t{get __tag(){return"Path"}constructor(t){super(t)}};dt([_(Ot)],Ge.prototype,"__",void 0),dt([it("center")],Ge.prototype,"strokeAlign",void 0),Ge=dt([z()],Ge);let Je=class extends Kt{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ge(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};dt([_(Nt)],Je.prototype,"__",void 0),dt([(t,e)=>{i(t,e,{get(){return this.__path}})}],Je.prototype,"path",void 0),Je=dt([P(ht,["set","path","paint"]),z()],Je);export{_e as Box,Dt as BoxData,Ve as Canvas,Yt as CanvasData,yt as ColorConvert,mt as Effect,ue as Ellipse,zt as EllipseData,Rt as Export,he as Frame,Et as FrameData,Kt as Group,Ft as GroupData,Oe as Image,Ht as ImageData,te as Leafer,It as LeaferData,Re as Line,Wt as LineData,Ne as MyImage,ft as Paint,xt as PaintGradient,wt as PaintImage,Ge as Path,vt as PathArrow,Ot as PathData,Je as Pen,Nt as PenData,De as Polygon,Tt as PolygonData,ee as Rect,Lt as RectData,Gt as RectRender,Me as Star,Mt as StarData,St as State,qe as Text,ct as TextConvert,jt as TextData,kt as Transition,$t as UI,Xt as UIBounds,Pt as UIData,Ut as UIRender,gt as UnitConvert,pt as effectType,lt as resizeType,ut as zoomLayerType};
1
+ import{defineKey as t,decorateLeafAttr as e,attr as i,Plugin as s,PathConvert as o,Debug as r,LeafData as a,canvasSizeAttrs as n,dataProcessor as _,dataType as h,surfaceType as d,opacityType as p,visibleType as l,sortType as u,maskType as c,eraserType as y,positionType as g,boundsType as v,scaleType as f,rotationType as w,autoLayoutType as x,naturalBoundsType as m,pathInputType as R,pathType as S,hitType as k,strokeType as B,cursorType as b,rewrite as C,Leaf as A,useModule as P,rewriteAble as F,MathHelper as D,pen as I,PathCorner as E,PathDrawer as W,UICreator as L,registerUI as z,Branch as T,LeafList as M,Resource as O,DataHelper as N,Creator as V,CanvasManager as j,WaitHelper as H,LeaferEvent as Y,Bounds as X,ResizeEvent as U,AutoBounds as q,Run as G,LayoutEvent as J,RenderEvent as $,WatchEvent as K,ImageManager as Q,BoundsHelper as Z,affectRenderBoundsType as tt,PathCommandDataHelper as et,Platform as it,PointHelper as st,PathBounds as ot,affectStrokeBoundsType as rt,getPointData as at,ImageEvent as nt,LeaferImage as _t,Matrix as ht,PathCreator as dt}from"@leafer/core";export*from"@leafer/core";function pt(t,e,i,s){var o,r=arguments.length,a=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,i,s);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(a=(r<3?o(a):r>3?o(e,i,a):o(e,i))||a);return r>3&&a&&Object.defineProperty(e,i,a),a}function lt(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),e&&(this.__.__useEffect=!0),this.__layout.renderChanged||this.__layout.renderChange()}})))}function ut(t){return e(t,(t=>i({set(e){this.__setAttr(t,e),this.__layout.boxChanged||this.__layout.boxChange(),this.__updateSize()}})))}function ct(){return(e,i)=>{const s="_"+i;t(e,i,{set(t){this.isLeafer&&(this[s]=t)},get(){return this.isApp?this.tree.zoomLayer:this.isLeafer?this[s]||this:this.leafer&&this.leafer.zoomLayer}})}}"function"==typeof SuppressedError&&SuppressedError;const yt={},gt={},vt={number:(t,e)=>"object"==typeof t?"percent"===t.type?t.value*e:t.value:t},ft={},wt={},xt={},mt={},Rt={},St={apply(){s.need("filter")}},kt={},Bt={setStyleName:()=>s.need("state"),set:()=>s.need("state")},bt={},{parse:Ct,objectToCanvasData:At}=o,Pt={},Ft=r.get("UIData");class Dt extends a{get scale(){const{scaleX:t,scaleY:e}=this;return t!==e?{x:t,y:e}:t}get __strokeWidth(){const{strokeWidth:t,strokeWidthFixed:e}=this;if(e){const e=this.__leaf;let{scaleX:i}=e.__nowWorld||e.__world;return i<0&&(i=-i),i>1?t/i:t}return t}get __hasStroke(){return this.stroke&&this.strokeWidth}get __hasMultiPaint(){const t=this;return!!(t.__isFills&&t.fill.length>1||t.__isStrokes&&t.stroke.length>1||t.__useEffect)||t.fill&&this.__hasStroke}get __clipAfterFill(){const t=this;return t.cornerRadius||t.innerShadow||t.__pathInputed}get __hasSurface(){return this.fill||this.stroke}get __autoWidth(){return!this._width}get __autoHeight(){return!this._height}get __autoSide(){return!this._width||!this._height}get __autoSize(){return!this._width&&!this._height}setVisible(t){this._visible=t;const{leafer:e}=this.__leaf;e&&(e.watcher.hasVisible=!0)}setWidth(t){t<0?(this._width=-t,this.__leaf.scaleX*=-1,Ft.warn("width < 0, instead -scaleX ",this)):this._width=t}setHeight(t){t<0?(this._height=-t,this.__leaf.scaleY*=-1,Ft.warn("height < 0, instead -scaleY",this)):this._height=t}setFill(t){this.__naturalWidth&&this.__removeNaturalSize(),"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("fill",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isFills=!0,this._fill||(this._fill=Pt)):(this.__isFills&&(this.__removeInput("fill"),xt.recycleImage("fill",this),this.__isFills=!1,this.__pixelFill&&(this.__pixelFill=!1)),this._fill=t)}setStroke(t){"string"!=typeof t&&t?"object"==typeof t&&(this.__setInput("stroke",t),this.__leaf.__layout.boxChanged||this.__leaf.__layout.boxChange(),this.__isStrokes=!0,this._stroke||(this._stroke=Pt)):(this.__isStrokes&&(this.__removeInput("stroke"),xt.recycleImage("stroke",this),this.__isStrokes=!1,this.__pixelStroke&&(this.__pixelStroke=!1)),this._stroke=t)}setPath(t){const e="string"==typeof t;e||t&&"object"==typeof t[0]?(this.__setInput("path",t),this._path=e?Ct(t):At(t)):(this.__input&&this.__removeInput("path"),this._path=t)}setShadow(t){It(this,"shadow",t)}setInnerShadow(t){It(this,"innerShadow",t)}setFilter(t){It(this,"filter",t)}__computePaint(){const{fill:t,stroke:e}=this.__input;t&&wt.compute("fill",this.__leaf),e&&wt.compute("stroke",this.__leaf),this.__needComputePaint=!1}}function It(t,e,i){t.__setInput(e,i),i instanceof Array?(i.some((t=>!1===t.visible))&&(i=i.filter((t=>!1!==t.visible))),i.length||(i=null)):i=i&&!1!==i.visible?[i]:null,t["_"+e]=i}class Et extends Dt{}class Wt extends Et{get __boxStroke(){return!this.__pathInputed}get __drawAfterFill(){const t=this;return"hide"===t.overflow&&(t.__clipAfterFill||t.innerShadow)&&t.__leaf.children.length}get __clipAfterFill(){return this.__leaf.isOverflow||super.__clipAfterFill}}class Lt extends Et{__getInputData(t,e){const i=super.__getInputData(t,e);return n.forEach((t=>delete i[t])),i}}class zt extends Wt{}class Tt extends Dt{}class Mt extends Dt{get __boxStroke(){return!this.__pathInputed}}class Ot extends Dt{get __boxStroke(){return!this.__pathInputed}}class Nt extends Dt{}class Vt extends Dt{}class jt extends Dt{get __pathInputed(){return 2}}class Ht extends Et{}const Yt={thin:100,"extra-light":200,light:300,normal:400,medium:500,"semi-bold":600,bold:700,"extra-bold":800,black:900};class Xt extends Dt{get __useNaturalRatio(){return!1}setFontWeight(t){"string"==typeof t?(this.__setInput("fontWeight",t),this._fontWeight=Yt[t]||400):(this.__input&&this.__removeInput("fontWeight"),this._fontWeight=t)}}class Ut extends Mt{setUrl(t){this.__setImageFill(t),this._url=t}__setImageFill(t){this.__leaf.image&&(this.__leaf.image=null),this.fill=t?{type:"image",mode:"stretch",url:t}:void 0}__getData(){const t=super.__getData();return delete t.fill,t}__getInputData(t,e){const i=super.__getInputData(t,e);return delete i.fill,i}}class qt extends Mt{get __isCanvas(){return!0}get __drawAfterFill(){return!0}__getInputData(t,e){const i=super.__getInputData(t,e);return i.url=this.__leaf.canvas.toDataURL("image/png"),i}}const Gt={__updateStrokeSpread(){let t=0,e=0;const i=this.__,{strokeAlign:s,strokeWidth:o}=i;if((i.stroke||"all"===i.hitStroke)&&o&&"inside"!==s&&(e=t="center"===s?o/2:o,!i.__boxStroke)){const e=i.__isLinePath?0:10*t,s="none"===i.strokeCap?0:o;t+=Math.max(e,s)}return i.__useArrow&&(t+=5*o),this.__layout.strokeBoxSpread=e,t},__updateRenderSpread(){let t=0;const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;e&&e.forEach((e=>t=Math.max(t,Math.max(Math.abs(e.y),Math.abs(e.x))+(e.spread>0?e.spread:0)+1.5*e.blur))),s&&(t=Math.max(t,s)),r&&(t+=St.getSpread(r));let a=t=Math.ceil(t);return i&&i.forEach((t=>a=Math.max(a,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread<0?-t.spread:0)+1.5*t.blur))),o&&(a=Math.max(a,o)),this.__layout.renderShapeSpread=a,t+(this.__layout.strokeSpread||0)}},Jt={__updateChange(){const t=this.__;if(t.__useEffect){const{shadow:e,innerShadow:i,blur:s,backgroundBlur:o,filter:r}=this.__;t.__useEffect=!!(e||i||s||o||r)}t.__checkSingle();t.__isFills||t.__isStrokes||t.cornerRadius||t.__useEffect?t.__complex=!0:t.__complex&&(t.__complex=!1)},__drawFast(t,e){$t(this,t,e)},__draw(t,e,i){const s=this.__;if(s.__complex){s.__needComputePaint&&s.__computePaint();const{fill:o,stroke:r,__drawAfterFill:a}=s;if(this.__drawRenderPath(t),s.__useEffect){const n=wt.shape(this,t,e);this.__nowWorld=this.__getNowWorld(e);const{shadow:_,innerShadow:h,filter:d}=s;_&&Rt.shadow(this,t,n),o&&(s.__isFills?wt.fills(o,this,t):wt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),h&&Rt.innerShadow(this,t,n),r&&(s.__isStrokes?wt.strokes(r,this,t):wt.stroke(r,this,t)),d&&St.apply(d,this,this.__nowWorld,t,i,n),n.worldCanvas&&n.worldCanvas.recycle(),n.canvas.recycle()}else o&&(s.__isFills?wt.fills(o,this,t):wt.fill(o,this,t)),a&&this.__drawAfterFill(t,e),r&&(s.__isStrokes?wt.strokes(r,this,t):wt.stroke(r,this,t))}else s.__pathInputed?$t(this,t,e):this.__drawFast(t,e)},__renderShape(t,e,i,s){if(this.__worldOpacity){t.setWorld(this.__nowWorld=this.__getNowWorld(e));const{fill:o,stroke:r}=this.__;this.__drawRenderPath(t),o&&!i&&(this.__.__pixelFill?wt.fills(o,this,t):wt.fill("#000000",this,t)),this.__.__isCanvas&&this.__drawAfterFill(t,e),r&&!s&&(this.__.__pixelStroke?wt.strokes(r,this,t):wt.stroke("#000000",this,t))}},__drawAfterFill(t,e){this.__.__clipAfterFill?(t.save(),this.windingRule?t.clip(this.windingRule):t.clip(),this.__drawContent(t,e),t.restore()):this.__drawContent(t,e)}};function $t(t,e,i){const{fill:s,stroke:o,__drawAfterFill:r}=t.__;t.__drawRenderPath(e),s&&wt.fill(s,t,e),r&&t.__drawAfterFill(e,i),o&&wt.stroke(o,t,e)}const Kt={__drawFast(t,e){let{width:i,height:s,fill:o,stroke:r,__drawAfterFill:a}=this.__;if(o&&(t.fillStyle=o,t.fillRect(0,0,i,s)),a&&this.__drawAfterFill(t,e),r){const{strokeAlign:o,__strokeWidth:a}=this.__;if(!a)return;t.setStroke(r,a,this.__);const n=a/2;switch(o){case"center":t.strokeRect(0,0,i,s);break;case"inside":i-=a,s-=a,i<0||s<0?(t.save(),this.__clip(t,e),t.strokeRect(n,n,i,s),t.restore()):t.strokeRect(n,n,i,s);break;case"outside":t.strokeRect(-n,-n,i+a,s+a)}}}};var Qt;let Zt=Qt=class extends A{get app(){return this.leafer&&this.leafer.app}get isFrame(){return!1}set scale(t){D.assignScale(this,t)}get scale(){return this.__.scale}get pen(){const{path:t}=this.__;return I.set(this.path=t||[]),t||this.__drawPathByBox(I),I}get editConfig(){}get editOuter(){return""}get editInner(){return""}constructor(t){super(t)}reset(t){}set(t,e){t&&(e?"temp"===e?(this.lockNormalStyle=!0,Object.assign(this,t),this.lockNormalStyle=!1):this.animate(t,e):Object.assign(this,t))}get(t){return"string"==typeof t?this.__.__getInput(t):this.__.__getInputData(t)}createProxyData(){}find(t,e){return s.need("find")}findTag(t){return this.find({tag:t})}findOne(t,e){return s.need("find")}findId(t){return this.findOne({id:t})}getPath(t,e){this.__layout.update();let i=e?this.__.__pathForRender:this.__.path;return i||(I.set(i=[]),this.__drawPathByBox(I)),t?o.toCanvasData(i,!0):i}getPathString(t,e,i){return o.stringify(this.getPath(t,e),i)}load(){this.__.__computePaint()}__onUpdateSize(){if(this.__.__input){const t=this.__;!t.lazy||this.__inLazyBounds||kt.running?t.__computePaint():t.__needComputePaint=!0}}__updateRenderPath(){if(this.__.path){const t=this.__;t.__pathForRender=t.cornerRadius?E.smooth(t.path,t.cornerRadius,t.cornerSmoothing):t.path,t.__useArrow&&ft.addArrows(this,!t.cornerRadius)}}__drawRenderPath(t){t.beginPath(),this.__drawPathByData(t,this.__.__pathForRender)}__drawPath(t){t.beginPath(),this.__drawPathByData(t,this.__.path)}__drawPathByData(t,e){e?W.drawPathByData(t,e):this.__drawPathByBox(t)}__drawPathByBox(t){const{x:e,y:i,width:s,height:o}=this.__layout.boxBounds;if(this.__.cornerRadius){const{cornerRadius:r}=this.__;t.roundRect(e,i,s,o,"number"==typeof r?[r]:r)}else t.rect(e,i,s,o)}animate(t,e,i,o){return s.need("animate")}killAnimate(t,e){}export(t,e){return s.need("export")}clone(t){const e=this.toJSON();return t&&Object.assign(e,t),Qt.one(e)}static one(t,e,i,s,o){return L.get(t.tag||this.prototype.__tag,t,e,i,s,o)}static registerUI(){z()(this)}static registerData(t){_(t)(this.prototype)}static setEditConfig(t){}static setEditOuter(t){}static setEditInner(t){}destroy(){this.fill=this.stroke=null,this.__animate&&this.killAnimate(),super.destroy()}};pt([_(Dt)],Zt.prototype,"__",void 0),pt([ct()],Zt.prototype,"zoomLayer",void 0),pt([h("")],Zt.prototype,"id",void 0),pt([h("")],Zt.prototype,"name",void 0),pt([h("")],Zt.prototype,"className",void 0),pt([d("pass-through")],Zt.prototype,"blendMode",void 0),pt([p(1)],Zt.prototype,"opacity",void 0),pt([l(!0)],Zt.prototype,"visible",void 0),pt([d(!1)],Zt.prototype,"locked",void 0),pt([u(0)],Zt.prototype,"zIndex",void 0),pt([c(!1)],Zt.prototype,"mask",void 0),pt([y(!1)],Zt.prototype,"eraser",void 0),pt([g(0,!0)],Zt.prototype,"x",void 0),pt([g(0,!0)],Zt.prototype,"y",void 0),pt([v(100,!0)],Zt.prototype,"width",void 0),pt([v(100,!0)],Zt.prototype,"height",void 0),pt([f(1,!0)],Zt.prototype,"scaleX",void 0),pt([f(1,!0)],Zt.prototype,"scaleY",void 0),pt([w(0,!0)],Zt.prototype,"rotation",void 0),pt([w(0,!0)],Zt.prototype,"skewX",void 0),pt([w(0,!0)],Zt.prototype,"skewY",void 0),pt([g(0,!0)],Zt.prototype,"offsetX",void 0),pt([g(0,!0)],Zt.prototype,"offsetY",void 0),pt([g(0,!0)],Zt.prototype,"scrollX",void 0),pt([g(0,!0)],Zt.prototype,"scrollY",void 0),pt([x()],Zt.prototype,"origin",void 0),pt([x()],Zt.prototype,"around",void 0),pt([h(!1)],Zt.prototype,"lazy",void 0),pt([m(1)],Zt.prototype,"pixelRatio",void 0),pt([R()],Zt.prototype,"path",void 0),pt([S()],Zt.prototype,"windingRule",void 0),pt([S(!0)],Zt.prototype,"closed",void 0),pt([v(0)],Zt.prototype,"padding",void 0),pt([v(!1)],Zt.prototype,"lockRatio",void 0),pt([v()],Zt.prototype,"widthRange",void 0),pt([v()],Zt.prototype,"heightRange",void 0),pt([h(!1)],Zt.prototype,"draggable",void 0),pt([h()],Zt.prototype,"dragBounds",void 0),pt([h(!1)],Zt.prototype,"editable",void 0),pt([k(!0)],Zt.prototype,"hittable",void 0),pt([k("path")],Zt.prototype,"hitFill",void 0),pt([B("path")],Zt.prototype,"hitStroke",void 0),pt([k(!1)],Zt.prototype,"hitBox",void 0),pt([k(!0)],Zt.prototype,"hitChildren",void 0),pt([k(!0)],Zt.prototype,"hitSelf",void 0),pt([k()],Zt.prototype,"hitRadius",void 0),pt([b("")],Zt.prototype,"cursor",void 0),pt([d()],Zt.prototype,"fill",void 0),pt([B()],Zt.prototype,"stroke",void 0),pt([B("inside")],Zt.prototype,"strokeAlign",void 0),pt([B(1)],Zt.prototype,"strokeWidth",void 0),pt([B(!1)],Zt.prototype,"strokeWidthFixed",void 0),pt([B("none")],Zt.prototype,"strokeCap",void 0),pt([B("miter")],Zt.prototype,"strokeJoin",void 0),pt([B()],Zt.prototype,"dashPattern",void 0),pt([B()],Zt.prototype,"dashOffset",void 0),pt([B(10)],Zt.prototype,"miterLimit",void 0),pt([S(0)],Zt.prototype,"cornerRadius",void 0),pt([S()],Zt.prototype,"cornerSmoothing",void 0),pt([lt()],Zt.prototype,"shadow",void 0),pt([lt()],Zt.prototype,"innerShadow",void 0),pt([lt()],Zt.prototype,"blur",void 0),pt([lt()],Zt.prototype,"backgroundBlur",void 0),pt([lt()],Zt.prototype,"grayscale",void 0),pt([lt()],Zt.prototype,"filter",void 0),pt([h({})],Zt.prototype,"data",void 0),pt([C(A.prototype.reset)],Zt.prototype,"reset",null),Zt=Qt=pt([P(Gt),P(Jt),F()],Zt);let te=class extends Zt{get __tag(){return"Group"}get isBranch(){return!0}constructor(t){super(t)}reset(t){this.__setBranch(),super.reset(t)}__setBranch(){this.children||(this.children=[])}set(t,e){if(t)if(t.children){const{children:i}=t;delete t.children,this.children?this.clear():this.__setBranch(),super.set(t,e),i.forEach((t=>this.add(t))),t.children=i}else super.set(t,e)}toJSON(t){const e=super.toJSON(t);return e.children=this.children.map((e=>e.toJSON(t))),e}pick(t,e){}addAt(t,e){this.add(t,e)}addAfter(t,e){this.add(t,this.children.indexOf(e)+1)}addBefore(t,e){this.add(t,this.children.indexOf(e))}add(t,e){}addMany(...t){}remove(t,e){}removeAll(t){}clear(){}};var ee;pt([_(Et)],te.prototype,"__",void 0),te=pt([P(T),z()],te);const ie=r.get("Leafer");let se=ee=class extends te{get __tag(){return"Leafer"}get isApp(){return!1}get app(){return this.parent||this}get isLeafer(){return!0}get imageReady(){return this.viewReady&&O.isComplete}get layoutLocked(){return!this.layouter.running}get FPS(){return this.renderer?this.renderer.FPS:60}get cursorPoint(){return this.interaction&&this.interaction.hoverData||{x:this.width/2,y:this.height/2}}get clientBounds(){return this.canvas&&this.canvas.getClientBounds()}constructor(t,e){super(e),this.config={start:!0,hittable:!0,smooth:!0,lazySpeard:100},this.leafs=0,this.__eventIds=[],this.__controllers=[],this.__readyWait=[],this.__viewReadyWait=[],this.__viewCompletedWait=[],this.__nextRenderWait=[],this.userConfig=t,t&&(t.view||t.width)&&this.init(t),ee.list.add(this)}init(t,e){if(this.canvas)return;let i;const{config:s}=this;this.__setLeafer(this),e&&(this.parentApp=e,this.__bindApp(e),i=e.running),t&&(this.parent=e,this.initType(t.type),this.parent=void 0,N.assign(s,t));const o=this.canvas=V.canvas(s);this.__controllers.push(this.renderer=V.renderer(this,o,s),this.watcher=V.watcher(this,s),this.layouter=V.layouter(this,s)),this.isApp&&this.__setApp(),this.__checkAutoLayout(s,e),this.view=o.view,e||(this.selector=V.selector(this),this.interaction=V.interaction(this,o,this.selector,s),this.interaction&&(this.__controllers.unshift(this.interaction),this.hitCanvasManager=V.hitCanvasManager()),this.canvasManager=new j,i=s.start),this.hittable=s.hittable,this.fill=s.fill,this.canvasManager.add(o),this.__listenEvents(),i&&(this.__startTimer=setTimeout(this.start.bind(this))),H.run(this.__initWait),this.onInit()}onInit(){}initType(t){}set(t,e){this.waitInit((()=>{super.set(t,e)}))}start(){clearTimeout(this.__startTimer),!this.running&&this.canvas&&(this.running=!0,this.ready?this.emitLeafer(Y.RESTART):this.emitLeafer(Y.START),this.__controllers.forEach((t=>t.start())),this.isApp||this.renderer.render())}stop(){clearTimeout(this.__startTimer),this.running&&this.canvas&&(this.__controllers.forEach((t=>t.stop())),this.running=!1,this.emitLeafer(Y.STOP))}unlockLayout(){this.layouter.start(),this.updateLayout()}lockLayout(){this.updateLayout(),this.layouter.stop()}resize(t){const e=N.copyAttrs({},t,n);Object.keys(e).forEach((t=>this[t]=e[t]))}forceRender(t,e){const{renderer:i}=this;i&&(i.addBlock(t?new X(t):this.canvas.bounds),this.viewReady&&(e?i.render():i.update()))}requestRender(t=!1){this.renderer&&this.renderer.update(t)}updateCursor(t){const e=this.interaction;e&&(t?e.setCursor(t):e.updateCursor())}updateLazyBounds(){this.lazyBounds=this.canvas.bounds.clone().spread(this.config.lazySpeard)}__doResize(t){const{canvas:e}=this;if(!e||e.isSameSize(t))return;const i=N.copyAttrs({},this.canvas,n);e.resize(t),this.updateLazyBounds(),this.__onResize(new U(t,i))}__onResize(t){this.emitEvent(t),N.copyAttrs(this.__,t,n),setTimeout((()=>{this.canvasManager&&this.canvasManager.clearRecycled()}),0)}__setApp(){}__bindApp(t){this.selector=t.selector,this.interaction=t.interaction,this.canvasManager=t.canvasManager,this.hitCanvasManager=t.hitCanvasManager}__setLeafer(t){this.leafer=t,this.__level=1}__checkAutoLayout(t,e){e||(t.width&&t.height||(this.autoLayout=new q(t)),this.canvas.startAutoLayout(this.autoLayout,this.__onResize.bind(this)))}__setAttr(t,e){return this.canvas&&(n.includes(t)?this.__changeCanvasSize(t,e):"fill"===t?this.__changeFill(e):"hittable"===t?this.parent||(this.canvas.hittable=e):"zIndex"===t&&(this.canvas.zIndex=e,setTimeout((()=>this.parent&&this.parent.__updateSortChildren())))),super.__setAttr(t,e)}__getAttr(t){return this.canvas&&n.includes(t)?this.canvas[t]:super.__getAttr(t)}__changeCanvasSize(t,e){const i=N.copyAttrs({},this.canvas,n);i[t]=this.config[t]=e,e&&this.canvas.stopAutoLayout(),this.__doResize(i)}__changeFill(t){this.config.fill=t,this.canvas.allowBackgroundColor?this.canvas.backgroundColor=t:this.forceRender()}__onCreated(){this.created=!0}__onReady(){this.ready=!0,this.emitLeafer(Y.BEFORE_READY),this.emitLeafer(Y.READY),this.emitLeafer(Y.AFTER_READY),H.run(this.__readyWait)}__onViewReady(){this.viewReady||(this.viewReady=!0,this.emitLeafer(Y.VIEW_READY),H.run(this.__viewReadyWait))}__onLayoutEnd(){const{grow:t,width:e,height:i}=this.config;if(t){let{width:s,height:o,pixelRatio:r}=this;const a="box"===t?this.worldBoxBounds:this.__world;e||(s=Math.max(1,a.x+a.width)),i||(o=Math.max(1,a.y+a.height)),this.__doResize({width:s,height:o,pixelRatio:r})}this.ready||this.__onReady()}__onNextRender(){if(this.viewReady){H.run(this.__nextRenderWait);const{imageReady:t}=this;t&&!this.viewCompleted&&this.__checkViewCompleted(),t||(this.viewCompleted=!1,this.requestRender())}else this.requestRender()}__checkViewCompleted(t=!0){this.nextRender((()=>{this.imageReady&&(t&&this.emitLeafer(Y.VIEW_COMPLETED),H.run(this.__viewCompletedWait),this.viewCompleted=!0)}))}__onWatchData(){this.watcher.childrenChanged&&this.interaction&&this.nextRender((()=>this.interaction.updateCursor()))}waitInit(t,e){e&&(t=t.bind(e)),this.__initWait||(this.__initWait=[]),this.canvas?t():this.__initWait.push(t)}waitReady(t,e){e&&(t=t.bind(e)),this.ready?t():this.__readyWait.push(t)}waitViewReady(t,e){e&&(t=t.bind(e)),this.viewReady?t():this.__viewReadyWait.push(t)}waitViewCompleted(t,e){e&&(t=t.bind(e)),this.__viewCompletedWait.push(t),this.viewCompleted?this.__checkViewCompleted(!1):this.running||this.start()}nextRender(t,e,i){e&&(t=t.bind(e));const s=this.__nextRenderWait;if(i){for(let e=0;e<s.length;e++)if(s[e]===t){s.splice(e,1);break}}else s.push(t);this.requestRender()}zoom(t,e,i,o){return s.need("view")}getValidMove(t,e){return{x:t,y:e}}getValidScale(t){return t}getWorldPointByClient(t,e){return this.interaction&&this.interaction.getLocal(t,e)}getPagePointByClient(t,e){return this.getPagePoint(this.getWorldPointByClient(t,e))}updateClientBounds(){this.canvas&&this.canvas.updateClientBounds()}receiveEvent(t){}emitLeafer(t){this.emitEvent(new Y(t,this))}__listenEvents(){const t=G.start("FirstCreate "+this.innerName);this.once(Y.START,(()=>G.end(t))),this.once(J.START,(()=>this.updateLazyBounds())),this.once($.START,(()=>this.__onCreated())),this.once($.END,(()=>this.__onViewReady())),this.__eventIds.push(this.on_(K.DATA,this.__onWatchData,this),this.on_(J.END,this.__onLayoutEnd,this),this.on_($.NEXT,this.__onNextRender,this))}__removeListenEvents(){this.off_(this.__eventIds),this.__eventIds.length=0}destroy(t){const e=()=>{if(!this.destroyed){ee.list.remove(this);try{this.stop(),this.emitEvent(new Y(Y.END,this)),this.__removeListenEvents(),this.__controllers.forEach((t=>!(this.parent&&t===this.interaction)&&t.destroy())),this.__controllers.length=0,this.parent||(this.selector&&this.selector.destroy(),this.hitCanvasManager&&this.hitCanvasManager.destroy(),this.canvasManager.destroy()),this.canvas.destroy(),this.config.view=this.view=this.parentApp=null,this.userConfig&&(this.userConfig.view=null),super.destroy(),setTimeout((()=>{Q.clearRecycled()}),100)}catch(t){ie.error(t)}}};t?e():setTimeout(e)}};se.list=new M,pt([_(Lt)],se.prototype,"__",void 0),pt([v()],se.prototype,"pixelRatio",void 0),se=ee=pt([z()],se);let oe=class extends Zt{get __tag(){return"Rect"}constructor(t){super(t)}};pt([_(Mt)],oe.prototype,"__",void 0),oe=pt([P(Kt),F(),z()],oe);const{copy:re,add:ae,includes:ne}=Z,_e=oe.prototype,he=te.prototype,de={};let pe=class extends te{get __tag(){return"Box"}get isBranchLeaf(){return!0}constructor(t){super(t),this.__layout.renderChanged||this.__layout.renderChange()}__updateStrokeSpread(){return 0}__updateRectRenderSpread(){return 0}__updateRenderSpread(){return this.__updateRectRenderSpread()||-1}__updateRectBoxBounds(){}__updateBoxBounds(t){const e=this.__;if(this.children.length)if(e.__autoSide){e.__hasSurface&&this.__extraUpdate(),super.__updateBoxBounds();const{boxBounds:t}=this.__layout;e.__autoSize||(e.__autoWidth?(t.width+=t.x,t.x=0,t.height=e.height,t.y=0):(t.height+=t.y,t.y=0,t.width=e.width,t.x=0)),this.__updateNaturalSize()}else this.__updateRectBoxBounds();else this.__updateRectBoxBounds()}__updateStrokeBounds(){}__updateRenderBounds(){let t;const{renderBounds:e}=this.__layout;this.children.length?(super.__updateRenderBounds(),re(de,e),this.__updateRectRenderBounds(),t=!ne(e,de),t&&"hide"!==this.__.overflow&&ae(e,de)):this.__updateRectRenderBounds(),!this.isOverflow!=!t&&(this.isOverflow=t)}__updateRectRenderBounds(){}__updateRectChange(){}__updateChange(){super.__updateChange(),this.__updateRectChange()}__renderRect(t,e){}__renderGroup(t,e){}__render(t,e){this.__.__drawAfterFill?this.__renderRect(t,e):(this.__renderRect(t,e),this.children.length&&this.__renderGroup(t,e))}__drawContent(t,e){this.__renderGroup(t,e),this.__.__hasStroke&&(t.setWorld(this.__nowWorld),this.__drawRenderPath(t))}};pt([_(Wt)],pe.prototype,"__",void 0),pt([h(!1)],pe.prototype,"resizeChildren",void 0),pt([tt("show")],pe.prototype,"overflow",void 0),pt([C(_e.__updateStrokeSpread)],pe.prototype,"__updateStrokeSpread",null),pt([C(_e.__updateRenderSpread)],pe.prototype,"__updateRectRenderSpread",null),pt([C(_e.__updateBoxBounds)],pe.prototype,"__updateRectBoxBounds",null),pt([C(_e.__updateStrokeBounds)],pe.prototype,"__updateStrokeBounds",null),pt([C(_e.__updateRenderBounds)],pe.prototype,"__updateRectRenderBounds",null),pt([C(_e.__updateChange)],pe.prototype,"__updateRectChange",null),pt([C(_e.__render)],pe.prototype,"__renderRect",null),pt([C(he.__render)],pe.prototype,"__renderGroup",null),pe=pt([F(),z()],pe);let le=class extends pe{get __tag(){return"Frame"}get isFrame(){return!0}constructor(t){super(t)}};pt([_(zt)],le.prototype,"__",void 0),pt([d("#FFFFFF")],le.prototype,"fill",void 0),pt([tt("hide")],le.prototype,"overflow",void 0),le=pt([z()],le);const{moveTo:ue,closePath:ce,ellipse:ye}=et;let ge=class extends Zt{get __tag(){return"Ellipse"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,innerRadius:i,startAngle:s,endAngle:o}=this.__,r=t/2,a=e/2,n=this.__.path=[];i?(s||o?(i<1&&ye(n,r,a,r*i,a*i,0,s,o,!1),ye(n,r,a,r,a,0,o,s,!0),i<1&&ce(n)):(i<1&&(ye(n,r,a,r*i,a*i),ue(n,t,a)),ye(n,r,a,r,a,0,360,0,!0)),it.ellipseToCurve&&(this.__.path=this.getPath(!0))):s||o?(ue(n,r,a),ye(n,r,a,r,a,0,s,o,!1),ce(n)):ye(n,r,a,r,a)}};pt([_(Ot)],ge.prototype,"__",void 0),pt([S(0)],ge.prototype,"innerRadius",void 0),pt([S(0)],ge.prototype,"startAngle",void 0),pt([S(0)],ge.prototype,"endAngle",void 0),ge=pt([z()],ge);const{moveTo:ve,lineTo:fe,drawPoints:we}=et,{rotate:xe,getAngle:me,getDistance:Re,defaultPoint:Se}=st,{toBounds:ke}=ot;let Be=class extends Zt{get __tag(){return"Line"}get toPoint(){const{width:t,rotation:e}=this.__,i=at();return t&&(i.x=t),e&&xe(i,e),i}set toPoint(t){this.width=Re(Se,t),this.rotation=me(Se,t),this.height&&(this.height=0)}constructor(t){super(t)}__updatePath(){const t=this.__,e=t.path=[];t.points?we(e,t.points,!1,t.closed):(ve(e,0,0),fe(e,this.width,0))}__updateRenderPath(){const t=this.__;!this.pathInputed&&t.points&&t.curve?(we(t.__pathForRender=[],t.points,t.curve,t.closed),t.__useArrow&&ft.addArrows(this,!1)):super.__updateRenderPath()}__updateBoxBounds(){this.points?ke(this.__.__pathForRender,this.__layout.boxBounds):super.__updateBoxBounds()}};pt([_(Tt)],Be.prototype,"__",void 0),pt([rt("center")],Be.prototype,"strokeAlign",void 0),pt([v(0)],Be.prototype,"height",void 0),pt([S()],Be.prototype,"points",void 0),pt([S(0)],Be.prototype,"curve",void 0),pt([S(!1)],Be.prototype,"closed",void 0),Be=pt([z()],Be);const{sin:be,cos:Ce,PI:Ae}=Math,{moveTo:Pe,lineTo:Fe,closePath:De,drawPoints:Ie}=et,Ee=Be.prototype;let We=class extends Zt{get __tag(){return"Polygon"}constructor(t){super(t)}__updatePath(){const t=this.__.path=[];if(this.__.points)Ie(t,this.__.points,!1,!0);else{const{width:e,height:i,sides:s}=this.__,o=e/2,r=i/2;Pe(t,o,0);for(let e=1;e<s;e++)Fe(t,o+o*be(2*e*Ae/s),r-r*Ce(2*e*Ae/s))}De(t)}__updateRenderPath(){}__updateBoxBounds(){}};pt([_(Nt)],We.prototype,"__",void 0),pt([S(3)],We.prototype,"sides",void 0),pt([S()],We.prototype,"points",void 0),pt([S(0)],We.prototype,"curve",void 0),pt([C(Ee.__updateRenderPath)],We.prototype,"__updateRenderPath",null),pt([C(Ee.__updateBoxBounds)],We.prototype,"__updateBoxBounds",null),We=pt([F(),z()],We);const{sin:Le,cos:ze,PI:Te}=Math,{moveTo:Me,lineTo:Oe,closePath:Ne}=et;let Ve=class extends Zt{get __tag(){return"Star"}constructor(t){super(t)}__updatePath(){const{width:t,height:e,corners:i,innerRadius:s}=this.__,o=t/2,r=e/2,a=this.__.path=[];Me(a,o,0);for(let t=1;t<2*i;t++)Oe(a,o+(t%2==0?o:o*s)*Le(t*Te/i),r-(t%2==0?r:r*s)*ze(t*Te/i));Ne(a)}};pt([_(Vt)],Ve.prototype,"__",void 0),pt([S(5)],Ve.prototype,"corners",void 0),pt([S(.382)],Ve.prototype,"innerRadius",void 0),Ve=pt([z()],Ve);let je=class extends oe{get __tag(){return"Image"}get ready(){return!!this.image&&this.image.ready}constructor(t){super(t),this.on(nt.LOADED,(t=>{"fill"===t.attrName&&t.attrValue.url===this.url&&(this.image=t.image)}))}destroy(){this.image=null,super.destroy()}};pt([_(Ut)],je.prototype,"__",void 0),pt([v("")],je.prototype,"url",void 0),je=pt([z()],je);const He=je;let Ye=class extends oe{get __tag(){return"Canvas"}get ready(){return!this.url}constructor(t){super(t),this.canvas=V.canvas(this.__),this.context=this.canvas.context,t&&t.url&&this.drawImage(t.url)}drawImage(t){new _t({url:t}).load((t=>{this.context.drawImage(t.view,0,0),this.url=void 0,this.paint(),this.emitEvent(new nt(nt.LOADED,{image:t}))}))}draw(t,e,i,s){const o=new ht(t.worldTransform).invert(),r=new ht;e&&r.translate(e.x,e.y),i&&("number"==typeof i?r.scale(i):r.scale(i.x,i.y)),s&&r.rotate(s),o.multiplyParent(r),t.__render(this.canvas,{matrix:o.withScale()}),this.paint()}paint(){this.forceRender()}__drawContent(t,e){const{width:i,height:s}=this.__,{view:o}=this.canvas;t.drawImage(o,0,0,o.width,o.height,0,0,i,s)}__updateSize(){const{canvas:t}=this;if(t){const{smooth:e,safeResize:i}=this.__;t.resize(this.__,i),t.smooth!==e&&(t.smooth=e)}}destroy(){this.canvas&&(this.canvas.destroy(),this.canvas=this.context=null),super.destroy()}};pt([_(qt)],Ye.prototype,"__",void 0),pt([ut(100)],Ye.prototype,"width",void 0),pt([ut(100)],Ye.prototype,"height",void 0),pt([ut(1)],Ye.prototype,"pixelRatio",void 0),pt([ut(!0)],Ye.prototype,"smooth",void 0),pt([h(!1)],Ye.prototype,"safeResize",void 0),pt([ut()],Ye.prototype,"contextSettings",void 0),Ye=pt([z()],Ye);const{copyAndSpread:Xe,includes:Ue,isSame:qe,spread:Ge,setList:Je}=Z;let $e=class extends Zt{get __tag(){return"Text"}get textDrawData(){return this.__layout.update(),this.__.__textDrawData}constructor(t){super(t)}__drawHitPath(t){const{__lineHeight:e,fontSize:i,__baseLine:s,__textDrawData:o}=this.__;t.beginPath(),this.__.__letterSpacing<0?this.__drawPathByData(t):o.rows.forEach((o=>t.rect(o.x,o.y-s,o.width,e<i?i:e)))}__drawPathByData(t,e){const{x:i,y:s,width:o,height:r}=this.__layout.boxBounds;t.rect(i,s,o,r)}__drawRenderPath(t){t.font=this.__.__font}__updateTextDrawData(){const t=this.__,{lineHeight:e,letterSpacing:i,fontFamily:s,fontSize:o,fontWeight:r,italic:a,textCase:n,textOverflow:_,padding:h}=t;t.__lineHeight=vt.number(e,o),t.__letterSpacing=vt.number(i,o),t.__padding=h?D.fourNumber(h):void 0,t.__baseLine=t.__lineHeight-(t.__lineHeight-.7*o)/2,t.__font=`${a?"italic ":""}${"small-caps"===n?"small-caps ":""}${"normal"!==r?r+" ":""}${o}px ${s}`,t.__clipText="show"!==_&&!t.__autoSize,t.__textDrawData=yt.getDrawData(t.text,this.__)}__updateBoxBounds(){const t=this.__,e=this.__layout,{fontSize:i,italic:s,padding:o,__autoWidth:r,__autoHeight:a}=t;this.__updateTextDrawData();const{bounds:n}=t.__textDrawData,_=e.boxBounds;if(t.__lineHeight<i&&Ge(n,i/2),r||a){if(_.x=r?n.x:0,_.y=a?n.y:0,_.width=r?n.width:t.width,_.height=a?n.height:t.height,o){const[e,i,s,o]=t.__padding;r&&(_.x-=o,_.width+=i+o),a&&(_.y-=e,_.height+=s+e)}this.__updateNaturalSize()}else super.__updateBoxBounds();s&&(_.width+=.16*i);const h=Ue(_,n)?_:n;qe(h,e.contentBounds)?t.__textBoxBounds=h:(e.contentBounds=h,e.renderChanged=!0,Je(t.__textBoxBounds={},[_,n]))}__updateRenderSpread(){let t=super.__updateRenderSpread();return t||(t=this.__layout.boxBounds===this.__layout.contentBounds?0:1),t}__updateRenderBounds(){Xe(this.__layout.renderBounds,this.__.__textBoxBounds,this.__layout.renderSpread)}};pt([_(Xt)],$e.prototype,"__",void 0),pt([v(0)],$e.prototype,"width",void 0),pt([v(0)],$e.prototype,"height",void 0),pt([h(!1)],$e.prototype,"resizeFontSize",void 0),pt([d("#000000")],$e.prototype,"fill",void 0),pt([rt("outside")],$e.prototype,"strokeAlign",void 0),pt([k("all")],$e.prototype,"hitFill",void 0),pt([v("")],$e.prototype,"text",void 0),pt([v("caption")],$e.prototype,"fontFamily",void 0),pt([v(12)],$e.prototype,"fontSize",void 0),pt([v("normal")],$e.prototype,"fontWeight",void 0),pt([v(!1)],$e.prototype,"italic",void 0),pt([v("none")],$e.prototype,"textCase",void 0),pt([v("none")],$e.prototype,"textDecoration",void 0),pt([v(0)],$e.prototype,"letterSpacing",void 0),pt([v({type:"percent",value:1.5})],$e.prototype,"lineHeight",void 0),pt([v(0)],$e.prototype,"paraIndent",void 0),pt([v(0)],$e.prototype,"paraSpacing",void 0),pt([v("x")],$e.prototype,"writingMode",void 0),pt([v("left")],$e.prototype,"textAlign",void 0),pt([v("top")],$e.prototype,"verticalAlign",void 0),pt([v(!0)],$e.prototype,"autoSizeAlign",void 0),pt([v("normal")],$e.prototype,"textWrap",void 0),pt([v("show")],$e.prototype,"textOverflow",void 0),$e=pt([z()],$e);let Ke=class extends Zt{get __tag(){return"Path"}constructor(t){super(t)}};pt([_(jt)],Ke.prototype,"__",void 0),pt([rt("center")],Ke.prototype,"strokeAlign",void 0),Ke=pt([z()],Ke);let Qe=class extends te{get __tag(){return"Pen"}constructor(t){super(t)}setStyle(t){const e=this.pathElement=new Ke(t);return this.pathStyle=t,this.__path=e.path||(e.path=[]),this.add(e),this}beginPath(){return this}moveTo(t,e){return this}lineTo(t,e){return this}bezierCurveTo(t,e,i,s,o,r){return this}quadraticCurveTo(t,e,i,s){return this}closePath(){return this}rect(t,e,i,s){return this}roundRect(t,e,i,s,o){return this}ellipse(t,e,i,s,o,r,a,n){return this}arc(t,e,i,s,o,r){return this}arcTo(t,e,i,s,o){return this}drawEllipse(t,e,i,s,o,r,a,n){return this}drawArc(t,e,i,s,o,r){return this}drawPoints(t,e,i){return this}clearPath(){return this}paint(){this.pathElement.__layout.boxChanged||this.pathElement.forceUpdate("path")}};pt([_(Ht)],Qe.prototype,"__",void 0),pt([(e,i)=>{t(e,i,{get(){return this.__path}})}],Qe.prototype,"path",void 0),Qe=pt([P(dt,["set","path","paint"]),z()],Qe);export{pe as Box,Wt as BoxData,Ye as Canvas,qt as CanvasData,gt as ColorConvert,Rt as Effect,ge as Ellipse,Ot as EllipseData,kt as Export,St as Filter,le as Frame,zt as FrameData,te as Group,Et as GroupData,je as Image,Ut as ImageData,se as Leafer,Lt as LeaferData,Be as Line,Tt as LineData,He as MyImage,wt as Paint,mt as PaintGradient,xt as PaintImage,Ke as Path,ft as PathArrow,jt as PathData,Qe as Pen,Ht as PenData,We as Polygon,Nt as PolygonData,oe as Rect,Mt as RectData,Kt as RectRender,Ve as Star,Vt as StarData,Bt as State,$e as Text,yt as TextConvert,Xt as TextData,bt as Transition,Zt as UI,Gt as UIBounds,Dt as UIData,Jt as UIRender,vt as UnitConvert,lt as effectType,ut as resizeType,ct as zoomLayerType};
2
2
  //# sourceMappingURL=draw.esm.min.js.map