ice-entity-designer 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/dist/types/flow/FlowDesigner.d.mts +19 -1
- package/dist/types/flow/FlowDesigner.d.ts +19 -1
- package/dist/types/index.d.mts +8 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/utils/register-types.d.mts +23 -0
- package/dist/types/utils/register-types.d.ts +23 -0
- package/package.json +3 -3
package/dist/react.mjs
CHANGED
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import{createContext as e,createElement as t,useContext as i,forwardRef as n,useRef as r,useState as o,useEffect as s,useImperativeHandle as a,Fragment as l}from"react";import{ICEGroup as u,ICEText as c,ICERect as h,ICEPolyLine as d,ICEVisioLink as p,toIsoTime as f,ICEPath as y,DEFAULT_THEME as m,ICE_EVENT_NAME_CONSTS as g,Serializer as _,Deserializer as b,exportSvg as v,ICE as k}from"ice-render";const w=e(null);function EntityDesignerProvider(e){return t(w.Provider,{value:e.designer},e.children)}function useEntityDesigner(){return i(w)}const S=e(null);function FlowDesignerProvider(e){return t(S.Provider,{value:e.designer},e.children)}function useFlowDesigner(){return i(S)}var C,T,x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var q,I,j,E,$,P,M,O,D,A,N,B,F,z,L,R,H,W,V,U,G,K,X,Y,J,Q,Z,ee,te,ie,ne,re,oe,se,ae,le,ue,ce,he,de,pe,fe,ye,me,ge,_e,be,ve,ke,we,Se,Ce,Te,xe,qe,Ie,je,Ee,$e,Pe,Me,Oe,De,Ae,Ne,Be,Fe,ze,Le,Re,He,We,Ve,Ue,Ge,Ke,Xe,Ye,Je,Qe,Ze,et,tt,it,nt,rt,ot,st,at,lt,ut,ct,ht,dt,pt,ft,yt,mt,gt=getDefaultExportFromCjs(function requireIsNil(){return T?C:(T=1,C=function isNil(e){return null==e})}());function requireEq(){if(E)return j;return E=1,j=function eq(e,t){return e===t||e!=e&&t!=t}}function require_assocIndexOf(){if(P)return $;P=1;var e=requireEq();return $=function assocIndexOf(t,i){for(var n=t.length;n--;)if(e(t[n][0],i))return n;return-1}}function require_ListCache(){if(R)return L;R=1;var e=function require_listCacheClear(){return I?q:(I=1,q=function listCacheClear(){this.__data__=[],this.size=0})}(),t=function require_listCacheDelete(){if(O)return M;O=1;var e=require_assocIndexOf(),t=Array.prototype.splice;return M=function listCacheDelete(i){var n=this.__data__,r=e(n,i);return!(r<0||(r==n.length-1?n.pop():t.call(n,r,1),--this.size,0))}}(),i=function require_listCacheGet(){if(A)return D;A=1;var e=require_assocIndexOf();return D=function listCacheGet(t){var i=this.__data__,n=e(i,t);return n<0?void 0:i[n][1]}}(),n=function require_listCacheHas(){if(B)return N;B=1;var e=require_assocIndexOf();return N=function listCacheHas(t){return e(this.__data__,t)>-1}}(),r=function require_listCacheSet(){if(z)return F;z=1;var e=require_assocIndexOf();return F=function listCacheSet(t,i){var n=this.__data__,r=e(n,t);return r<0?(++this.size,n.push([t,i])):n[r][1]=i,this}}();function ListCache(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}return ListCache.prototype.clear=e,ListCache.prototype.delete=t,ListCache.prototype.get=i,ListCache.prototype.has=n,ListCache.prototype.set=r,L=ListCache}function require_freeGlobal(){if(Q)return J;Q=1;var e="object"==typeof x&&x&&x.Object===Object&&x;return J=e}function require_root(){if(ee)return Z;ee=1;var e=require_freeGlobal(),t="object"==typeof self&&self&&self.Object===Object&&self,i=e||t||Function("return this")();return Z=i}function require_Symbol(){if(ie)return te;ie=1;var e=require_root().Symbol;return te=e}function require_baseGetTag(){if(le)return ae;le=1;var e=require_Symbol(),t=function require_getRawTag(){if(re)return ne;re=1;var e=require_Symbol(),t=Object.prototype,i=t.hasOwnProperty,n=t.toString,r=e?e.toStringTag:void 0;return ne=function getRawTag(e){var t=i.call(e,r),o=e[r];try{e[r]=void 0;var s=!0}catch(e){}var a=n.call(e);return s&&(t?e[r]=o:delete e[r]),a}}(),i=function require_objectToString(){if(se)return oe;se=1;var e=Object.prototype.toString;return oe=function objectToString(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return ae=function baseGetTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):i(e)}}function requireIsObject(){if(ce)return ue;return ce=1,ue=function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function requireIsFunction(){if(de)return he;de=1;var e=require_baseGetTag(),t=requireIsObject();return he=function isFunction(i){if(!t(i))return!1;var n=e(i);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function require_isMasked(){if(me)return ye;me=1;var e,t=function require_coreJsData(){if(fe)return pe;fe=1;var e=require_root()["__core-js_shared__"];return pe=e}(),i=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return ye=function isMasked(e){return!!i&&i in e}}function require_baseIsNative(){if(ve)return be;ve=1;var e=requireIsFunction(),t=require_isMasked(),i=requireIsObject(),n=function require_toSource(){if(_e)return ge;_e=1;var e=Function.prototype.toString;return ge=function toSource(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),r=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,a=o.toString,l=s.hasOwnProperty,u=RegExp("^"+a.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return be=function baseIsNative(o){return!(!i(o)||t(o))&&(e(o)?u:r).test(n(o))}}function require_getNative(){if(Ce)return Se;Ce=1;var e=require_baseIsNative(),t=function require_getValue(){return we?ke:(we=1,ke=function getValue(e,t){return null==e?void 0:e[t]})}();return Se=function getNative(i,n){var r=t(i,n);return e(r)?r:void 0}}function require_Map(){if(xe)return Te;xe=1;var e=require_getNative()(require_root(),"Map");return Te=e}function require_nativeCreate(){if(Ie)return qe;Ie=1;var e=require_getNative()(Object,"create");return qe=e}function require_Hash(){if(ze)return Fe;ze=1;var e=function require_hashClear(){if(Ee)return je;Ee=1;var e=require_nativeCreate();return je=function hashClear(){this.__data__=e?e(null):{},this.size=0}}(),t=function require_hashDelete(){return Pe?$e:(Pe=1,$e=function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t})}(),i=function require_hashGet(){if(Oe)return Me;Oe=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return Me=function hashGet(i){var n=this.__data__;if(e){var r=n[i];return"__lodash_hash_undefined__"===r?void 0:r}return t.call(n,i)?n[i]:void 0}}(),n=function require_hashHas(){if(Ae)return De;Ae=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return De=function hashHas(i){var n=this.__data__;return e?void 0!==n[i]:t.call(n,i)}}(),r=function require_hashSet(){if(Be)return Ne;Be=1;var e=require_nativeCreate();return Ne=function hashSet(t,i){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===i?"__lodash_hash_undefined__":i,this}}();function Hash(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}return Hash.prototype.clear=e,Hash.prototype.delete=t,Hash.prototype.get=i,Hash.prototype.has=n,Hash.prototype.set=r,Fe=Hash}function require_getMapData(){if(Ue)return Ve;Ue=1;var e=function require_isKeyable(){return We?He:(We=1,He=function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e})}();return Ve=function getMapData(t,i){var n=t.__data__;return e(i)?n["string"==typeof i?"string":"hash"]:n.map}}function require_MapCache(){if(it)return tt;it=1;var e=function require_mapCacheClear(){if(Re)return Le;Re=1;var e=require_Hash(),t=require_ListCache(),i=require_Map();return Le=function mapCacheClear(){this.size=0,this.__data__={hash:new e,map:new(i||t),string:new e}}}(),t=function require_mapCacheDelete(){if(Ke)return Ge;Ke=1;var e=require_getMapData();return Ge=function mapCacheDelete(t){var i=e(this,t).delete(t);return this.size-=i?1:0,i}}(),i=function require_mapCacheGet(){if(Ye)return Xe;Ye=1;var e=require_getMapData();return Xe=function mapCacheGet(t){return e(this,t).get(t)}}(),n=function require_mapCacheHas(){if(Qe)return Je;Qe=1;var e=require_getMapData();return Je=function mapCacheHas(t){return e(this,t).has(t)}}(),r=function require_mapCacheSet(){if(et)return Ze;et=1;var e=require_getMapData();return Ze=function mapCacheSet(t,i){var n=e(this,t),r=n.size;return n.set(t,i),this.size+=n.size==r?0:1,this}}();function MapCache(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}return MapCache.prototype.clear=e,MapCache.prototype.delete=t,MapCache.prototype.get=i,MapCache.prototype.has=n,MapCache.prototype.set=r,tt=MapCache}function require_Stack(){if(st)return ot;st=1;var e=require_ListCache(),t=function require_stackClear(){if(W)return H;W=1;var e=require_ListCache();return H=function stackClear(){this.__data__=new e,this.size=0}}(),i=function require_stackDelete(){return U?V:(U=1,V=function stackDelete(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i})}(),n=function require_stackGet(){return K?G:(K=1,G=function stackGet(e){return this.__data__.get(e)})}(),r=function require_stackHas(){return Y?X:(Y=1,X=function stackHas(e){return this.__data__.has(e)})}(),o=function require_stackSet(){if(rt)return nt;rt=1;var e=require_ListCache(),t=require_Map(),i=require_MapCache();return nt=function stackSet(n,r){var o=this.__data__;if(o instanceof e){var s=o.__data__;if(!t||s.length<199)return s.push([n,r]),this.size=++o.size,this;o=this.__data__=new i(s)}return o.set(n,r),this.size=o.size,this}}();function Stack(t){var i=this.__data__=new e(t);this.size=i.size}return Stack.prototype.clear=t,Stack.prototype.delete=i,Stack.prototype.get=n,Stack.prototype.has=r,Stack.prototype.set=o,ot=Stack}function require_defineProperty(){if(lt)return at;lt=1;var e=require_getNative(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return at=t}function require_baseAssignValue(){if(ct)return ut;ct=1;var e=require_defineProperty();return ut=function baseAssignValue(t,i,n){"__proto__"==i&&e?e(t,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[i]=n}}function require_assignMergeValue(){if(dt)return ht;dt=1;var e=require_baseAssignValue(),t=requireEq();return ht=function assignMergeValue(i,n,r){(void 0!==r&&!t(i[n],r)||void 0===r&&!(n in i))&&e(i,n,r)}}function require_baseFor(){if(mt)return yt;mt=1;var e=function require_createBaseFor(){return ft?pt:(ft=1,pt=function createBaseFor(e){return function(t,i,n){for(var r=-1,o=Object(t),s=n(t),a=s.length;a--;){var l=s[e?a:++r];if(!1===i(o[l],l,o))break}return t}})}()();return yt=e}var _t,bt,vt,kt,wt,St,Ct,Tt,xt,qt,It,jt,Et,$t,Pt,Mt,Ot,Dt,At,Nt,Bt,Ft,zt,Lt,Rt,Ht,Wt,Vt,Ut,Gt,Kt,Xt,Yt,Jt={exports:{}};function require_cloneArrayBuffer(){if(wt)return kt;wt=1;var e=function require_Uint8Array(){if(vt)return bt;vt=1;var e=require_root().Uint8Array;return bt=e}();return kt=function cloneArrayBuffer(t){var i=new t.constructor(t.byteLength);return new e(i).set(new e(t)),i}}function require_getPrototype(){if(Pt)return $t;Pt=1;var e=function require_overArg(){return Et?jt:(Et=1,jt=function overArg(e,t){return function(i){return e(t(i))}})}()(Object.getPrototypeOf,Object);return $t=e}function require_isPrototype(){if(Ot)return Mt;Ot=1;var e=Object.prototype;return Mt=function isPrototype(t){var i=t&&t.constructor;return t===("function"==typeof i&&i.prototype||e)}}function require_initCloneObject(){if(At)return Dt;At=1;var e=function require_baseCreate(){if(It)return qt;It=1;var e=requireIsObject(),t=Object.create,i=function(){function object(){}return function(i){if(!e(i))return{};if(t)return t(i);object.prototype=i;var n=new object;return object.prototype=void 0,n}}();return qt=i}(),t=require_getPrototype(),i=require_isPrototype();return Dt=function initCloneObject(n){return"function"!=typeof n.constructor||i(n)?{}:e(t(n))}}function requireIsObjectLike(){if(Bt)return Nt;return Bt=1,Nt=function isObjectLike(e){return null!=e&&"object"==typeof e}}function requireIsArguments(){if(Rt)return Lt;Rt=1;var e=function require_baseIsArguments(){if(zt)return Ft;zt=1;var e=require_baseGetTag(),t=requireIsObjectLike();return Ft=function baseIsArguments(i){return t(i)&&"[object Arguments]"==e(i)}}(),t=requireIsObjectLike(),i=Object.prototype,n=i.hasOwnProperty,r=i.propertyIsEnumerable,o=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!r.call(e,"callee")};return Lt=o}function requireIsArray(){if(Wt)return Ht;Wt=1;var e=Array.isArray;return Ht=e}function requireIsLength(){if(Ut)return Vt;Ut=1;return Vt=function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function requireIsArrayLike(){if(Kt)return Gt;Kt=1;var e=requireIsFunction(),t=requireIsLength();return Gt=function isArrayLike(i){return null!=i&&t(i.length)&&!e(i)}}var Qt,Zt,ei,ti,ii,ni,ri,oi,si,ai={exports:{}};function requireIsBuffer(){return ei||(ei=1,function(e,t){var i=require_root(),n=function requireStubFalse(){return Zt?Qt:(Zt=1,Qt=function stubFalse(){return!1})}(),r=t&&!t.nodeType&&t,o=r&&e&&!e.nodeType&&e,s=o&&o.exports===r?i.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;e.exports=a}(ai,ai.exports)),ai.exports}var li,ui,ci,hi,di,pi,fi,yi,mi,gi,_i,bi,vi,ki,wi,Si,Ci,Ti,xi,qi,Ii,ji,Ei,$i,Pi,Mi,Oi,Di,Ai,Ni,Bi,Fi,zi,Li,Ri,Hi,Wi,Vi,Ui,Gi,Ki,Xi,Yi,Ji,Qi,Zi,en,tn,nn,rn={exports:{}};function requireIsTypedArray(){if(ci)return ui;ci=1;var e=function require_baseIsTypedArray(){if(ri)return ni;ri=1;var e=require_baseGetTag(),t=requireIsLength(),i=requireIsObjectLike(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,ni=function baseIsTypedArray(r){return i(r)&&t(r.length)&&!!n[e(r)]}}(),t=function require_baseUnary(){return si?oi:(si=1,oi=function baseUnary(e){return function(t){return e(t)}})}(),i=function require_nodeUtil(){return li||(li=1,e=rn,t=rn.exports,i=require_freeGlobal(),n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,o=r&&r.exports===n&&i.process,s=function(){try{return r&&r.require&&r.require("util").types||o&&o.binding&&o.binding("util")}catch(e){}}(),e.exports=s),rn.exports;var e,t,i,n,r,o,s}(),n=i&&i.isTypedArray,r=n?t(n):e;return ui=r}function require_safeGet(){if(di)return hi;return di=1,hi=function safeGet(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function require_copyObject(){if(mi)return yi;mi=1;var e=function require_assignValue(){if(fi)return pi;fi=1;var e=require_baseAssignValue(),t=requireEq(),i=Object.prototype.hasOwnProperty;return pi=function assignValue(n,r,o){var s=n[r];i.call(n,r)&&t(s,o)&&(void 0!==o||r in n)||e(n,r,o)}}(),t=require_baseAssignValue();return yi=function copyObject(i,n,r,o){var s=!r;r||(r={});for(var a=-1,l=n.length;++a<l;){var u=n[a],c=o?o(r[u],i[u],u,r,i):void 0;void 0===c&&(c=i[u]),s?t(r,u,c):e(r,u,c)}return r}}function require_isIndex(){if(vi)return bi;vi=1;var e=/^(?:0|[1-9]\d*)$/;return bi=function isIndex(t,i){var n=typeof t;return!!(i=null==i?9007199254740991:i)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<i}}function require_arrayLikeKeys(){if(wi)return ki;wi=1;var e=function require_baseTimes(){return _i?gi:(_i=1,gi=function baseTimes(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n})}(),t=requireIsArguments(),i=requireIsArray(),n=requireIsBuffer(),r=require_isIndex(),o=requireIsTypedArray(),s=Object.prototype.hasOwnProperty;return ki=function arrayLikeKeys(a,l){var u=i(a),c=!u&&t(a),h=!u&&!c&&n(a),d=!u&&!c&&!h&&o(a),p=u||c||h||d,f=p?e(a.length,String):[],y=f.length;for(var m in a)!l&&!s.call(a,m)||p&&("length"==m||h&&("offset"==m||"parent"==m)||d&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||r(m,y))||f.push(m);return f}}function require_baseKeysIn(){if(xi)return Ti;xi=1;var e=requireIsObject(),t=require_isPrototype(),i=function require_nativeKeysIn(){return Ci?Si:(Ci=1,Si=function nativeKeysIn(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t})}(),n=Object.prototype.hasOwnProperty;return Ti=function baseKeysIn(r){if(!e(r))return i(r);var o=t(r),s=[];for(var a in r)("constructor"!=a||!o&&n.call(r,a))&&s.push(a);return s}}function requireKeysIn(){if(Ii)return qi;Ii=1;var e=require_arrayLikeKeys(),t=require_baseKeysIn(),i=requireIsArrayLike();return qi=function keysIn(n){return i(n)?e(n,!0):t(n)}}function require_baseMergeDeep(){if(Pi)return $i;Pi=1;var e=require_assignMergeValue(),t=function require_cloneBuffer(){return _t||(_t=1,e=Jt,t=Jt.exports,i=require_root(),n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,o=r&&r.exports===n?i.Buffer:void 0,s=o?o.allocUnsafe:void 0,e.exports=function cloneBuffer(e,t){if(t)return e.slice();var i=e.length,n=s?s(i):new e.constructor(i);return e.copy(n),n}),Jt.exports;var e,t,i,n,r,o,s}(),i=function require_cloneTypedArray(){if(Ct)return St;Ct=1;var e=require_cloneArrayBuffer();return St=function cloneTypedArray(t,i){var n=i?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}(),n=function require_copyArray(){return xt?Tt:(xt=1,Tt=function copyArray(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i<n;)t[i]=e[i];return t})}(),r=require_initCloneObject(),o=requireIsArguments(),s=requireIsArray(),a=function requireIsArrayLikeObject(){if(Yt)return Xt;Yt=1;var e=requireIsArrayLike(),t=requireIsObjectLike();return Xt=function isArrayLikeObject(i){return t(i)&&e(i)}}(),l=requireIsBuffer(),u=requireIsFunction(),c=requireIsObject(),h=function requireIsPlainObject(){if(ii)return ti;ii=1;var e=require_baseGetTag(),t=require_getPrototype(),i=requireIsObjectLike(),n=Function.prototype,r=Object.prototype,o=n.toString,s=r.hasOwnProperty,a=o.call(Object);return ti=function isPlainObject(n){if(!i(n)||"[object Object]"!=e(n))return!1;var r=t(n);if(null===r)return!0;var l=s.call(r,"constructor")&&r.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==a}}(),d=requireIsTypedArray(),p=require_safeGet(),f=function requireToPlainObject(){if(Ei)return ji;Ei=1;var e=require_copyObject(),t=requireKeysIn();return ji=function toPlainObject(i){return e(i,t(i))}}();return $i=function baseMergeDeep(y,m,g,_,b,v,k){var w=p(y,g),S=p(m,g),C=k.get(S);if(C)e(y,g,C);else{var T=v?v(w,S,g+"",y,m,k):void 0,x=void 0===T;if(x){var q=s(S),I=!q&&l(S),j=!q&&!I&&d(S);T=S,q||I||j?s(w)?T=w:a(w)?T=n(w):I?(x=!1,T=t(S,!0)):j?(x=!1,T=i(S,!0)):T=[]:h(S)||o(S)?(T=w,o(w)?T=f(w):c(w)&&!u(w)||(T=r(S))):x=!1}x&&(k.set(S,T),b(T,S,_,v,k),k.delete(S)),e(y,g,T)}}}function requireIdentity(){if(Ai)return Di;return Ai=1,Di=function identity(e){return e}}function require_overRest(){if(zi)return Fi;zi=1;var e=function require_apply(){return Bi?Ni:(Bi=1,Ni=function apply(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)})}(),t=Math.max;return Fi=function overRest(i,n,r){return n=t(void 0===n?i.length-1:n,0),function(){for(var o=arguments,s=-1,a=t(o.length-n,0),l=Array(a);++s<a;)l[s]=o[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=o[s];return u[n]=r(l),e(i,this,u)}},Fi}function require_baseSetToString(){if(Wi)return Hi;Wi=1;var e=function requireConstant(){return Ri?Li:(Ri=1,Li=function constant(e){return function(){return e}})}(),t=require_defineProperty(),i=requireIdentity();return Hi=t?function(i,n){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:i}function require_setToString(){if(Ki)return Gi;Ki=1;var e=require_baseSetToString(),t=function require_shortOut(){if(Ui)return Vi;Ui=1;var e=Date.now;return Vi=function shortOut(t){var i=0,n=0;return function(){var r=e(),o=16-(r-n);if(n=r,o>0){if(++i>=800)return arguments[0]}else i=0;return t.apply(void 0,arguments)}},Vi}(),i=t(e);return Gi=i}function require_createAssigner(){if(en)return Zi;en=1;var e=function require_baseRest(){if(Yi)return Xi;Yi=1;var e=requireIdentity(),t=require_overRest(),i=require_setToString();return Xi=function baseRest(n,r){return i(t(n,r,e),n+"")}}(),t=function require_isIterateeCall(){if(Qi)return Ji;Qi=1;var e=requireEq(),t=requireIsArrayLike(),i=require_isIndex(),n=requireIsObject();return Ji=function isIterateeCall(r,o,s){if(!n(s))return!1;var a=typeof o;return!!("number"==a?t(s)&&i(o,s.length):"string"==a&&o in s)&&e(s[o],r)}}();return Zi=function createAssigner(i){return e(function(e,n){var r=-1,o=n.length,s=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(s=i.length>3&&"function"==typeof s?(o--,s):void 0,a&&t(n[0],n[1],a)&&(s=o<3?void 0:s,o=1),e=Object(e);++r<o;){var l=n[r];l&&i(e,l,r,s)}return e})}}var on=function requireMerge(){if(nn)return tn;nn=1;var e=function require_baseMerge(){if(Oi)return Mi;Oi=1;var e=require_Stack(),t=require_assignMergeValue(),i=require_baseFor(),n=require_baseMergeDeep(),r=requireIsObject(),o=requireKeysIn(),s=require_safeGet();return Mi=function baseMerge(a,l,u,c,h){a!==l&&i(l,function(i,o){if(h||(h=new e),r(i))n(a,l,o,u,baseMerge,c,h);else{var d=c?c(s(a,o),i,o+"",a,l,h):void 0;void 0===d&&(d=i),t(a,o,d)}},o)},Mi}(),t=require_createAssigner()(function(t,i,n){e(t,i,n)});return tn=t}(),sn=getDefaultExportFromCjs(on);class Entity extends u{static typeId="ice-entity-designer:Entity";hasDerivedChildren(){return!0}entityFieldsComponent=[];constructor(e){super(Entity.arrangeParam(e)),this.syncEntityNameAndFields()}static arrangeParam(e){const t=sn({entityName:"Entity Name",fields:[],style:{strokeStyle:"#334155",fillStyle:"#ffffff",radius:8,lineWidth:1.5},headerStyle:{textColor:"#0f172a",backgroundColor:"#f1f5f9",fontSize:18,fontWeight:"bold",paddingTop:12,paddingLeft:14,paddingRight:14,paddingBottom:12},fieldStyle:{textColor:"#334155",fontSize:16,fontWeight:"normal",paddingTop:9,paddingLeft:14,paddingRight:14},dividerStyle:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}},e,{transformable:!1});return gt(t.entityName)&&(t.entityName="Entity Name"),gt(t.fields)&&(t.fields=[]),t}syncEntityNameAndFields(){if(this.entityNameComponent&&(this.removeChild(this.entityNameComponent),this.entityNameComponent=null),this.headerBackgroundComponent&&(this.removeChild(this.headerBackgroundComponent),this.headerBackgroundComponent=null),this.deviderLine&&(this.removeChild(this.deviderLine),this.deviderLine=null),this.entityFieldsComponent.length&&(this.removeChildren(this.entityFieldsComponent),this.entityFieldsComponent.length=0),this.state.entityName){if(this.entityNameComponent=new c({left:0,top:0,text:this.state.entityName,style:{strokeStyle:this.state.headerStyle.textColor,fillStyle:this.state.headerStyle.textColor,fontSize:this.state.headerStyle.fontSize,fontWeight:this.state.headerStyle.fontWeight,paddingTop:this.state.headerStyle.paddingTop,paddingLeft:this.state.headerStyle.paddingLeft,paddingRight:this.state.headerStyle.paddingRight,paddingBottom:this.state.headerStyle.paddingBottom},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.state.headerStyle.backgroundColor&&"none"!==this.state.headerStyle.backgroundColor){const e=this.state.style.lineWidth||1.5,t=e/2;this.headerBackgroundComponent=new h({left:t,top:t,width:Math.max(this.state.width-e,0),height:Math.max(this.entityNameComponent.state.height-t,0),zIndex:(Number(this.entityNameComponent.state.zIndex)||0)-1,origin:"top-left",style:{fillStyle:this.state.headerStyle.backgroundColor,radius:Math.max((this.state.style.radius||0)-t,0),lineWidth:0},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.addChild(this.headerBackgroundComponent)}this.addChild(this.entityNameComponent),this.deviderLine=new d({left:0,top:0,points:[[0,0],[this.state.width,0]],style:{strokeStyle:this.state.dividerStyle.strokeStyle,fillStyle:this.state.dividerStyle.fillStyle,lineWidth:this.state.dividerStyle.lineWidth},interactive:!1,linkable:!1}),this.addChild(this.deviderLine)}if(!gt(this.state.fields)){const e=this.state.fields.length;for(let t=0;t<e;t++){const i=this.state.fields[t],n=this.fieldDisplay(i),r=new c({left:0,top:0,text:n.text,style:{strokeStyle:this.state.fieldStyle.textColor,fillStyle:this.state.fieldStyle.textColor,fontSize:this.state.fieldStyle.fontSize,fontWeight:this.state.fieldStyle.fontWeight,paddingTop:this.state.fieldStyle.paddingTop,paddingLeft:this.state.fieldStyle.paddingLeft,paddingRight:this.state.fieldStyle.paddingRight,paddingBottom:t===e-1?12:0},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1});this.entityFieldsComponent.push(r)}this.addChildren(this.entityFieldsComponent)}}fieldDisplay(e){const t=[];e.primary&&t.push("PK"),e.foreignKey&&t.push("FK");const i=[];e.unique&&i.push("UQ"),e.autoIncrement&&i.push("AI"),!1===e.nullable&&i.push("NN");const n=t.length?`${t.join(" ")} `:"",r=e.type?`${e.type}${e.length?`(${e.length})`:""}`:"",o=i.length?` ${i.join(" ")}`:"",s=void 0!==e.default?` = ${e.default}`:"",a=e.comment?` // ${e.comment}`:"";return{text:`${n}${e.name}${r?` ${r}`:""}${o}${s}${a}`}}calcComponentParams(){let e=this.state.width,t=0,i=0,n=0;this.entityNameComponent&&(n=this.entityNameComponent.state.height,t=n,e=Math.max(e,this.entityNameComponent.state.width),t+=this.deviderLine.state.height,i=t);for(let i=0;i<this.entityFieldsComponent.length;i++){const n=this.entityFieldsComponent[i];n.state.left=0,n.state.top=t,t+=n.state.height,e=Math.max(e,n.state.width)}if(this.deviderLine&&(this.deviderLine.state.points=[[0,i],[e,i]]),this.headerBackgroundComponent){const t=this.state.style.lineWidth||1.5,i=t/2;this.headerBackgroundComponent.state.left=i,this.headerBackgroundComponent.state.top=i,this.headerBackgroundComponent.state.width=Math.max(e-t,0),this.headerBackgroundComponent.state.height=Math.max(n-i,0)}const r=e,o=Math.max(t,this.state.height);return this.state.width=r,this.state.height=o,{width:r,height:o}}toEntityObject(){const e={name:this.state.entityName,columns:{}};return this.state.fields.forEach(t=>{const i={};void 0!==t.type&&(i.type=t.type),void 0!==t.length&&(i.length=t.length),t.primary&&(i.primary=!0),t.generated&&(i.generated=!0),t.autoIncrement&&(i.generated=!0,i.strategy="increment"),!1===t.nullable&&(i.nullable=!1),t.unique&&(i.unique=!0),void 0!==t.default&&(i.default=t.default),void 0!==t.comment&&(i.comment=t.comment),t.index&&(i.index=!0),e.columns[t.name]=i}),e}setState(e){const t=!gt(e.fields)||!gt(e.entityName);super.setState(e),t&&this.syncEntityNameAndFields()}addField(e){const t=[...this.state.fields||[],e];return this.setFields(t),this}removeField(e){const t=(this.state.fields||[]).filter(t=>t.name!==e);return this.setFields(t),this}setFields(e){return this.setState({fields:e}),this}}class Relation extends p{static typeId="ice-entity-designer:Relation";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Relation.normalizeLinks(e||{}),i=t.relationType||"one-to-one",n=Relation.composeLabel(t,i);super({title:"Relation",transformable:!1,relationType:i,referencedColumnName:"id",sourceField:"id",targetField:"id",arrow:t.arrow||Relation.defaultArrow(i),...t,label:n,style:{...t.style||{},label:{fontSize:14,fillStyle:"#334155",backgroundColor:"#ffffff",...t.labelStyle||{},...(t.style||{}).label||{}}}})}static defaultArrow(e){switch(e){case"one-to-many":return"end";case"many-to-one":return"start";default:return"none"}}static normalizeLinks(e){if(!e||!e.links)return e||{};const t={top:"T",right:"R",bottom:"B",left:"L",center:"C"},i={...e.links};return i.start&&t[i.start.position]&&(i.start={...i.start,position:t[i.start.position]}),i.end&&t[i.end.position]&&(i.end={...i.end,position:t[i.end.position]}),{...e,links:i}}static cardinalityLabel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={"one-to-many":["1","N"],"many-to-one":["N","1"],"many-to-many":["N","N"],"one-to-one":["1","1"]},[n,r]=i[e]||i["one-to-one"];return`${t.sourceCardinality||n} : ${t.targetCardinality||r}`}static composeLabel(e,t){return e.label?e.label:Relation.buildLabel(e,t)}static buildLabel(e,t){const i=[];e.onDelete&&i.push(`ON DELETE ${e.onDelete}`),e.onUpdate&&i.push(`ON UPDATE ${e.onUpdate}`);const n=Relation.cardinalityLabel(t,e);return i.length?`${n} (${i.join(", ")})`:n}toEntityObject(){const{title:e,relationType:t,referencedColumnName:i,sourceField:n,targetField:r,nullable:o,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}=this.state;let h,d,p,f,y,m;this.state.links&&this.state.links.start&&this.state.links.start.id&&(p=this.state.links.start.id,h=this.ice.findComponent(p),f=h.state.entityName),this.state.links&&this.state.links.end&&this.state.links.end.id&&(y=this.state.links.end.id,d=this.ice.findComponent(y),m=d.state.entityName);return{title:e,fromId:p,fromName:f,toId:y,toName:m,relationType:t,referencedColumnName:i,sourceField:n,targetField:r,nullable:!1!==o&&void 0,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}}}function designerChromeFromTheme(e){const t=e&&e.semantic||{},i=t.primary||"#0D6EFD",n=t.success||"#198754",r=t.warning||"#FFC107";return{selection:{stroke:i,fill:withAlpha(i,.12),lineWidth:1,lineDash:[]},handle:{fill:i,stroke:"#ffffff",activeFill:r,lineWidth:1},linkHook:{fill:n,stroke:"#ffffff",lineWidth:1},slot:{fill:n,stroke:"#ffffff",hoverFill:r,lineWidth:1},guide:{color:i,lineWidth:1},textSelection:{color:withAlpha(i,.28)}}}function applyDesignerChrome(e){if(!e)return e;if("function"!=typeof e.setThemePatch&&"function"!=typeof e.setChrome)return e;const t=designerChromeFromTheme("function"==typeof e.getTheme?e.getTheme():null);return"function"==typeof e.setThemePatch?(e.setThemePatch("ice-designer",{semantic:{chrome:t}}),function subscribeDesignerChrome(e){if(e.__designerChromeSubscribed||"function"!=typeof e.onThemeChange)return;e.__designerChromeSubscribed=!0,e.onThemeChange(t=>{if(t&&"theme"!==t.kind)return;const i="function"==typeof e.getTheme?e.getTheme():null;e.setThemePatch("ice-designer",{semantic:{chrome:designerChromeFromTheme(i)}})})}(e)):e.setChrome(t),e}function withAlpha(e,t){if("string"!=typeof e)return e;const i=e.trim();if("#"===i.charAt(0)){let e=i.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6!==e.length)return i;return`rgba(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)},${t})`}return 0===i.indexOf("rgb(")?i.replace("rgb(","rgba(").replace(")",`,${t})`):i}const an=["T","R","B","L"],ln={T:[0,-1],R:[1,0],B:[0,1],L:[-1,0]};function boxOf(e){if(!e||"function"!=typeof e.getMaxBoundingBox)return null;const t=e.getMaxBoundingBox(!0).getMinAndMaxPoint();return{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}}function centerOf(e){return[(e.minX+e.maxX)/2,(e.minY+e.maxY)/2]}function portPoint(e,t){const[i,n]=centerOf(e);return"T"===t?[i,e.minY]:"B"===t?[i,e.maxY]:"L"===t?[e.minX,n]:[e.maxX,n]}function autoPorts(e,t,i){const n=boxOf(e),r=boxOf(t);if(!n||!r)return{...i};const o=centerOf(n),s=centerOf(r);let a={...i},l=1/0;for(const e of an){const t=portPoint(n,e),i=ln[e],u=(s[0]-t[0])*i[0]+(s[1]-t[1])*i[1]>=0;for(const n of an){const s=portPoint(r,n),c=ln[n],h=(u?0:1e6)+((o[0]-s[0])*c[0]+(o[1]-s[1])*c[1]>=0?0:1e6)+((s[0]-t[0])*i[0]+(s[1]-t[1])*i[1]>=0&&(t[0]-s[0])*c[0]+(t[1]-s[1])*c[1]>=0?0:1e6)+Math.hypot(t[0]-s[0],t[1]-s[1]);h<l&&(l=h,a={sourcePort:e,targetPort:n})}}return a}function enableDesignerAlignmentGuides(e){return e&&e.alignmentGuide&&"function"==typeof e.alignmentGuide.enable?(e.alignmentGuide.enable({threshold:2}),e):e}function typeIdOf(e){const t=e&&e.constructor;return t&&"string"==typeof t.typeId?t.typeId:void 0}function isEntity(e){return typeIdOf(e)===Entity.typeId}function isRelation(e){return typeIdOf(e)===Relation.typeId}const un="data",cn=[{key:"display",type:"boolean"},{key:"zIndex",type:"any"},{key:"opacity",type:"number",doc:"子树不透明度(引擎 1.3 起)"},{key:"transform",type:"object"},{key:"origin",type:"string"},{key:"originX",type:"number"},{key:"originY",type:"number"},{key:"lineDash",type:"array"},{key:"lineDashOffset",type:"number"},{key:"lineDashFlow",type:"boolean"},{key:"lineDashFlowSpeed",type:"number"},{key:"lineBorder",type:"boolean"},{key:"lineBorderWidth",type:"number"},{key:"lineBorderColor",type:"string"},{key:"fill",type:"boolean"},{key:"stroke",type:"boolean"},{key:"linkable",type:"boolean"},{key:"linkEditable",type:"boolean"},{key:"transformable",type:"boolean"},{key:"animations",type:"object"}],hn=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"relationType",type:"string"},{key:"referencedColumnName",type:"string"},{key:"sourceField",type:"string"},{key:"targetField",type:"string"},{key:"nullable",type:"boolean"},{key:"onDelete",type:"string"},{key:"onUpdate",type:"string"},{key:"joinTableName",type:"string"},{key:"fromKey",type:"string"},{key:"toKey",type:"string"},{key:"sourceCardinality",type:"string"},{key:"targetCardinality",type:"string"},{key:"label",type:"string"},{key:"style.label",type:"object",doc:"标签外观(引擎 2.4 起归到 style.label)"},{key:"style",type:"object"},{key:"arrow",type:"string"},{key:"lineType",type:"string"},{key:"escapeDistance",type:"number"},{key:"routeType",type:"string"},{key:"routeOffset",type:"number"},{key:"curveType",type:"string"},{key:"linkShape",type:"string",doc:"连线形态(visio/bezier)"},{key:"lineDash",type:"array"},{key:"lineWidth",type:"number"},{key:"arrowLength",type:"number"},{key:"arrowAngel",type:"number"},{key:"arrowStyle",type:"string"},{key:"startPoint",type:"array"},{key:"endPoint",type:"array"},{key:"links",type:"object",validate:function validateLinks(e,t,i){["start","end"].forEach(n=>{const r=e[n];void 0!==r&&(r&&"object"==typeof r&&!Array.isArray(r)?(void 0!==r.id&&"string"!=typeof r.id&&i.push(`${t}.${n}.id must be a string when present`),void 0!==r.position&&"string"!=typeof r.position&&i.push(`${t}.${n}.position must be a string when present`)):i.push(`${t}.${n} must be an object when present`))})}},{key:"sourceId",type:"string",doc:"连线起点宿主 id(与 links.start.id 同步)"},{key:"targetId",type:"string",doc:"连线终点宿主 id(与 links.end.id 同步)"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],dn=[...[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"entityName",type:"string",required:!0},{key:"fields",type:"array",validate:function validateFields(e,t,i){e.forEach((e,n)=>{e&&"object"==typeof e&&!Array.isArray(e)?void 0!==e.name&&"string"!=typeof e.name&&i.push(`${t}[${n}].name must be a string when present`):i.push(`${t}[${n}] must be an object`)})}},{key:"style",type:"object"},{key:"headerStyle",type:"object"},{key:"fieldStyle",type:"object"},{key:"dividerStyle",type:"object"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],...cn],pn=[...hn,...cn];function pickDocumentNode(e,t){const i={};t.forEach(t=>{const n=e?e[t.key]:void 0;void 0!==n&&(i[t.key]=n)});const n=e?e[un]:void 0;return void 0!==n&&(i[un]=n),i}function validateDocumentNode(e,t,i,n){e&&"object"==typeof e&&!Array.isArray(e)?i.forEach(i=>{const r=e[i.key];void 0!==r?!function typeMatches(e,t){switch(t){case void 0:case"any":return!0;case"array":return Array.isArray(e);case"object":return!!e&&"object"==typeof e&&!Array.isArray(e);case"number":return"number"==typeof e;case"boolean":return"boolean"==typeof e;default:return"string"==typeof e}}(r,i.type)?n.push(`${t}.${i.key} must be a ${i.type} when present`):i.validate&&i.validate(r,`${t}.${i.key}`,n):i.required&&n.push(`${t}.${i.key} is required`)}):n.push(`${t} must be an object`)}const fn=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"}];function validateNode(e,t,i,n){if(!e||"object"!=typeof e||Array.isArray(e))return void n.push(`${t} must be an object`);const r=void 0===e.typeId?i:e.typeId;!function isEntityTypeId(e){return e===Entity.typeId}(r)?!function isRelationTypeId(e){return e===Relation.typeId}(r)?validateDocumentNode(e,t,fn,n):validateDocumentNode(e,t,pn,n):validateDocumentNode(e,t,dn,n)}function validateSchema(e){const t=[],i=e.filter(isEntity),n=e.filter(isRelation),r=new Map;return i.forEach(e=>{const i=(e.state.entityName||"").trim();if(!i)return void t.push({level:"error",message:"存在未命名的 Entity",componentId:e.state.id});r.has(i)||r.set(i,[]),r.get(i).push(e);const n=e.state.fields||[];0===n.length&&t.push({level:"warning",message:`Entity "${i}" 没有任何字段`,componentId:e.state.id});const o=new Set;n.forEach(n=>{const r=(n.name||"").trim();r?o.has(r)?t.push({level:"error",message:`Entity "${i}" 存在重复字段 "${r}"`,componentId:e.state.id}):o.add(r):t.push({level:"error",message:`Entity "${i}" 存在未命名字段`,componentId:e.state.id}),n.type||t.push({level:"warning",message:`Entity "${i}" 的字段 "${r||"(未命名)"}" 未设置类型`,componentId:e.state.id})})}),r.forEach((e,i)=>{e.length>1&&t.push({level:"error",message:`存在重复的 Entity 名称 "${i}"`})}),n.forEach(e=>{const n=e.state.links||{},r=n.start&&n.start.id,o=n.end&&n.end.id,s=e.state.relationType;if(!r||!o)return void t.push({level:"error",message:"存在没有完整起点/终点的 Relation",componentId:e.state.id});const a=i.some(e=>e.state.id===r),l=i.some(e=>e.state.id===o);a&&l||t.push({level:"error",message:"Relation 连接到了不存在的 Entity",componentId:e.state.id}),s?"many-to-many"!==s||e.state.joinTableName||t.push({level:"warning",message:"many-to-many 关系建议设置 joinTableName",componentId:e.state.id}):t.push({level:"error",message:"Relation 未设置关系类型",componentId:e.state.id})}),t}function toWords(e){return function convertToString(e){const t=e||"";return"string"==typeof t?t:String(t)}(e).match(/[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g)||[]}function camelCase(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function toCamelCase(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i="";for(let n=0,r=e.length;n<r;n++){let r=e[n].toLowerCase();(t||0!==n)&&(r=r.substr(0,1).toUpperCase()+r.substr(1)),i+=r}return i}(toWords(e),t)}var yn=[],mn=[],gn={},_n={},bn={};function sanitizeRule(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function restoreCase(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function replace(e,t){return e.replace(t[0],function(i,n){var r=function interpolate(e,t){return e.replace(/\$(\d{1,2})/g,function(e,i){return t[i]||""})}(t[1],arguments);return restoreCase(""===i?e[n-1]:i,r)})}function sanitizeWord(e,t,i){if(!e.length||gn.hasOwnProperty(e))return t;for(var n=i.length;n--;){var r=i[n];if(r[0].test(t))return replace(t,r)}return t}function replaceWord(e,t,i){return function(n){var r=n.toLowerCase();return t.hasOwnProperty(r)?restoreCase(n,r):e.hasOwnProperty(r)?restoreCase(n,e[r]):sanitizeWord(r,n,i)}}function checkWord(e,t,i){return function(n){var r=n.toLowerCase();return!!t.hasOwnProperty(r)||!e.hasOwnProperty(r)&&sanitizeWord(r,r,i)===r}}function pluralize(e,t,i){return(i?t+" ":"")+(1===t?pluralize.singular(e):pluralize.plural(e))}pluralize.plural=replaceWord(bn,_n,yn),pluralize.isPlural=checkWord(bn,_n,yn),pluralize.singular=replaceWord(_n,bn,mn),pluralize.isSingular=checkWord(_n,bn,mn),pluralize.addPluralRule=function(e,t){yn.push([sanitizeRule(e),t])},pluralize.addSingularRule=function(e,t){mn.push([sanitizeRule(e),t])},pluralize.addUncountableRule=function(e){"string"!=typeof e?(pluralize.addPluralRule(e,"$0"),pluralize.addSingularRule(e,"$0")):gn[e.toLowerCase()]=!0},pluralize.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),bn[e]=t,_n[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(e){return pluralize.addIrregularRule(e[0],e[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(e){return pluralize.addPluralRule(e[0],e[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(e){return pluralize.addSingularRule(e[0],e[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(pluralize.addUncountableRule);const vn={number:"int",int:"int",integer:"int",smallint:"smallint",bigint:"bigint",float:"float",double:"double",real:"real",decimal:"decimal",numeric:"numeric",string:"varchar",varchar:"varchar",char:"char",text:"text",boolean:"boolean",bool:"boolean",date:"date",datetime:"datetime",timestamp:"timestamp",time:"time",json:"json",jsonb:"jsonb",uuid:"uuid",enum:"enum",blob:"blob",binary:"blob","simple-array":"simple-array","simple-json":"simple-json"},kn=["varchar","char","nvarchar","nchar","text","uuid"];function normalizeColumn(e){const t={},i=function mapColumnType(e){if(null==e||""===e)return;const t=String(e).toLowerCase();return vn[t]||String(e)}(e.type);if(void 0!==i&&(t.type=i),void 0!==e.length&&null!==e.length&&""!==e.length){const n=String(e.length).trim();if("decimal"===i||"numeric"===i){const[e,i]=n.split(",").map(e=>e.trim());e&&(t.precision=Number(e)),i&&(t.scale=Number(i))}else i&&kn.indexOf(i)>=0&&(t.length=e.length)}return e.primary&&(t.primary=!0),e.generated&&(t.generated=!0),e.autoIncrement&&(t.generated=!0,t.strategy="increment"),void 0!==e.strategy&&(t.strategy=e.strategy),!1===e.nullable&&(t.nullable=!1),e.unique&&(t.unique=!0),void 0!==e.default&&(t.default=e.default),void 0!==e.comment&&(t.comment=e.comment),e.index&&(t.index=!0),t}function normalizeColumns(e){const t={};return Object.keys(e||{}).forEach(i=>{t[i]=normalizeColumn(e[i])}),t}function buildJoinColumn(e,t){return{name:e||t||"id",referencedColumnName:t||"id"}}function toSchemaObject(e){const t=[...e],i=[],n={};for(let e=0;e<t.length;e++){const r=t[e];if(isRelation(r))i.push(r);else if(isEntity(r)){const e=r.toEntityObject();e.columns=normalizeColumns(e.columns),n[r.state.id]=e}}for(let e=0;e<i.length;e++){const t=i[e],{fromId:r,fromName:o,toId:s,toName:a,relationType:l,referencedColumnName:u,sourceField:c,targetField:h,nullable:d,onDelete:p,onUpdate:f,joinTableName:y,fromKey:m,toKey:g}=t.toEntityObject(),_=n[r],b=n[s];if(!_||!b)continue;_.relations||(_.relations={}),b.relations||(b.relations={});const v=m||camelCase(a),k=g||camelCase(o),w={};!1===d&&(w.nullable=!1),p&&(w.onDelete=p),f&&(w.onUpdate=f),"one-to-one"===l?(b.relations[k]={type:l,target:o,joinColumn:buildJoinColumn(h||u,c||u),...w},_.relations[v]={type:l,target:a,inverseSide:k}):"one-to-many"===l?(_.relations[v]={type:l,target:a,inverseSide:k},b.relations[k]={type:"many-to-one",target:o,joinColumn:buildJoinColumn(h||u,c||u),...w}):"many-to-one"===l?(_.relations[v]={type:l,target:a,joinColumn:buildJoinColumn(c||u,h||u),...w},b.relations[k]={type:"one-to-many",target:o,inverseSide:v}):"many-to-many"===l&&(_.relations[`${pluralize(v)}`]={type:l,target:a,joinTable:!y||{name:y}},b.relations[`${pluralize(k)}`]={type:l,target:o,inverseSide:`${pluralize(v)}`})}const r=[];for(const e in n)r.push(n[e]);return r}function toSchemaString(e){return JSON.stringify(toSchemaObject(e))}function registerIEDType(e,t){e.registerType(t.typeId,t)}class EntityDesigner{selectedId=null;__changeListeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;constructor(e){this.ice=e,applyDesignerChrome(this.ice),enableDesignerAlignmentGuides(this.ice),registerIEDType(this.ice,Entity),registerIEDType(this.ice,Relation),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this)}get entities(){return this.ice.childNodes.filter(e=>isEntity(e))}get relations(){return this.ice.childNodes.filter(e=>isRelation(e))}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}select(e){return this.selectedId=e,this}createEntity(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=this.entities.length,i=new Entity({left:120+t%4*220,top:120+260*Math.floor(t/4),entityName:"NewEntity",fields:[],...e});return this.ice.addChild(i),this.select(i.state.id),this.__emitChange(),i}createRelation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=e.sourceId||e.fromId||e.links&&e.links.start&&e.links.start.id,i=e.targetId||e.toId||e.links&&e.links.end&&e.links.end.id,n=t?this.ice.findComponent(t):null,r=i?this.ice.findComponent(i):null,o=autoPorts(n,r,{sourcePort:"R",targetPort:"L"}),s=e.links&&e.links.start&&e.links.start.position||e.startPosition||o.sourcePort,a=e.links&&e.links.end&&e.links.end.position||e.endPosition||o.targetPort,l=e.links||{start:{id:t,position:s},end:{id:i,position:a}},u=n?this.__slotPoint(n,s):null,c=r?this.__slotPoint(r,a):null,h=new Relation({relationType:e.relationType||"one-to-many",sourceField:e.sourceField||"id",targetField:e.targetField||"id",links:l,startPoint:u||[0,0],endPoint:c||[10,10],...e});return this.ice.addChild(h),this.select(h.state.id),this.__emitChange(),h}updateEntity(e,t){const i=this.ice.findComponent(e);return isEntity(i)&&(this.captureHistory(),i.setState(t),this.__emitChange()),i}updateRelation(e,t){const i=this.ice.findComponent(e);if(isRelation(i)){this.captureHistory();const e={...i.state,...t},n=Relation.buildLabel(e,e.relationType||"one-to-one");i.setState({...t,label:n}),this.__emitChange()}return i}removeComponent(e){const t=this.ice.findComponent(e);if(t){if(this.captureHistory(),isEntity(t)){this.relations.filter(t=>{const i=t.state.links||{};return i.start&&i.start.id===e||i.end&&i.end.id===e}).forEach(e=>this.ice.removeChild(e))}this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange()}}bringToFront(e){return this.__reorder(e,"front")}sendToBack(e){return this.__reorder(e,"back")}moveUp(e){return this.__reorder(e,"up")}moveDown(e){return this.__reorder(e,"down")}__reorder(e,t){const i=e?this.ice.findComponent(e):this.selected;if(!i||"function"!=typeof i.bringToFront)return!1;const n=i.parentNode&&Array.isArray(i.parentNode.childNodes)?i.parentNode.childNodes:this.ice.childNodes;if(!Array.isArray(n)||n.length<2)return!1;const r=this.serializeProject(),o=n.map(e=>e.state.zIndex);"front"===t?i.bringToFront():"back"===t?i.sendToBack():"up"===t?i.moveUp():i.moveDown();const s=n.map(e=>e.state.zIndex);return!(o.length===s.length&&!o.some((e,t)=>e!==s[t]))&&(this.__pushHistory(r),this.__emitChange(),!0)}toSchemaObject(){return toSchemaObject(this.ice.childNodes)}toSchemaString(){return toSchemaString(this.ice.childNodes)}validate(){return validateSchema(this.ice.childNodes)}serializeProject(){const e={version:1,schemaVersion:1,createTime:f(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime)||this.__rememberCreateTime(void 0),entities:this.entities.map(e=>this.__entitySnapshot(e)),relations:this.relations.map(e=>this.__relationSnapshot(e))};return JSON.stringify(e)}__rememberCreateTime(e){const t=this.ice;t&&"object"==typeof t&&(t.documentMeta&&"object"==typeof t.documentMeta||(t.documentMeta={}));const i=f(e);if(i)return t&&t.documentMeta&&(t.documentMeta.createTime=i),i;const n=(new Date).toISOString();return t&&t.documentMeta&&(t.documentMeta.createTime=n),n}loadProject(e){if(!e)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};const t=this.__parseProject(e);if(!t)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};this.captureHistory();const i=this.__applySnapshot(t);return this.__emitChange(),i}__entitySnapshot(e){return pickDocumentNode({...e.state||{},typeId:Entity.typeId},dn)}__slotPoint(e,t){const i=e.getMinBoundingBox(!0),n=i.center[0],r=i.center[1];switch(t){case"T":return[n,i.tl[1]];case"B":return[n,i.br[1]];case"L":return[i.tl[0],r];case"R":return[i.tr[0],r];default:return[n,r]}}__relationSnapshot(e){return pickDocumentNode({...e.state||{},typeId:Relation.typeId},pn)}__parseProject(e){const t=JSON.parse(e);if(!t||!Array.isArray(t.entities))return null;if(void 0!==t.schemaVersion&&1!==t.schemaVersion)throw new Error(`Unsupported project schemaVersion: ${t.schemaVersion}`);const i=function validateProjectSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:(void 0!==e.schemaVersion&&"number"!=typeof e.schemaVersion&&t.push("schemaVersion must be a number when present"),void 0!==e.createTime&&"string"!=typeof e.createTime&&t.push("createTime must be a string when present"),Array.isArray(e.entities)?e.entities.forEach((e,i)=>{validateNode(e,`entities[${i}]`,Entity.typeId,t)}):t.push("entities must be an array"),void 0===e.relations||Array.isArray(e.relations)?Array.isArray(e.relations)&&e.relations.forEach((e,i)=>{validateNode(e,`relations[${i}]`,Relation.typeId,t)}):t.push("relations must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!i.valid)throw new Error(`Invalid project snapshot:\n${i.errors.join("\n")}`);return t}__applyProject(e){const t=this.__parseProject(e);t&&this.__applySnapshot(t)}__resolveTypeId(e,t){return e&&"string"==typeof e.typeId&&e.typeId?e.typeId:"entities"===t?Entity.typeId:Relation.typeId}__resolveComponentClass(e){const t=this.ice;if("function"==typeof t.getType){const i=t.getType(e);if("function"==typeof i)return i}else if(t.typeMapping&&"function"==typeof t.typeMapping[e])return t.typeMapping[e];return e===Entity.typeId?Entity:e===Relation.typeId?Relation:null}__recordUnknownType(e,t,i,n,r){-1===e.unknownTypes.indexOf(n)&&e.unknownTypes.push(n);const o=r&&"string"==typeof r.id?r.id:void 0;e.skipped.push(void 0===o?{bucket:t,index:i,typeId:n}:{bucket:t,index:i,typeId:n,id:o})}__applySnapshot(e){const t=this.ice.renderer;t&&t.stop();const i={loaded:!0,entities:0,relations:0,unknownTypes:[],skipped:[]};try{this.ice.clearAll(),this.__rememberCreateTime(e&&e.createTime),this.ice.ctx&&"function"==typeof this.ice.ctx.clearRect&&(this.ice.ctx.setTransform(1,0,0,1,0,0),this.ice.ctx.clearRect(0,0,this.ice.canvasWidth||0,this.ice.canvasHeight||0));const createNode=(e,t,n)=>{const r=this.__resolveTypeId(e,t),o=this.__resolveComponentClass(r);if("function"!=typeof o)return this.__recordUnknownType(i,t,n,r,e),null;const s=new o(e);return delete s.state.typeId,delete s.props.typeId,this.ice.addChild(s),s},collect=(e,t,n)=>{const r=createNode(e,t,n);isEntity(r)?i.entities+=1:isRelation(r)&&(i.relations+=1)};e.entities.forEach((e,t)=>collect(e,"entities",t)),(e.relations||[]).forEach((e,t)=>collect(e,"relations",t)),this.selectedId=null}finally{if(t){const e=t.getRenderMode();t.setRenderMode("full"),t.start(),this.ice.dirty=!0,setTimeout(()=>{t.setRenderMode(e)},50)}}return i}__applyHistorySnapshot(e){this.__historyEnabled=!1;try{this.__applyProject(e),this.selectedId=null}finally{this.__historyEnabled=!0}}canUndo(){return this.__undoStack.length>0}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__historyEnabled&&this.__pushHistory(this.serializeProject())}__pushHistory(e){this.__historyEnabled&&(this.__undoStack.push(e),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}undo(){if(!this.canUndo())return;const e=this.serializeProject(),t=this.__undoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__undoStack.push(t),e}this.__redoStack.push(e),this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serializeProject(),t=this.__redoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__redoStack.push(t),e}this.__undoStack.push(e),this.__emitChange()}subscribe(e){return"function"!=typeof e?()=>{}:(this.__changeListeners.push(e),()=>{const t=this.__changeListeners.indexOf(e);-1!==t&&this.__changeListeners.splice(t,1)})}__emitChange(){if(!this.__changeListeners.length)return;const e=this.serializeProject();this.__changeListeners.slice().forEach(t=>t(e))}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this)}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let i=t;for(;i.parentNode;)i=i.parentNode;(isEntity(i)||isRelation(i))&&this.select(i.state.id)}}function createEmptyPath$1(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function createEmptyPath(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function localBox(e){return{w:e.state.width,h:e.state.height,x:0-e.state.localOrigin[0],y:0-e.state.localOrigin[1]}}class BpmnTaskIcon extends y{static typeId="ice-entity-designer:BpmnTaskIcon";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=i+e/2,s=n+t/2,a=Math.min(e,t)/2,l=this.state.taskType||"none";if("user"===l)r.moveTo(o,s-a),r.arc(o,s-.35*a,.34*a,0,2*Math.PI),r.moveTo(o-.62*a,s+.72*a),r.arc(o,s+.72*a,.62*a,Math.PI,0);else if("service"===l){const e=8;for(let t=0;t<e;t++){const i=t*Math.PI*2/e,n=o+Math.cos(i)*a*.55,l=s+Math.sin(i)*a*.55,u=o+Math.cos(i)*a,c=s+Math.sin(i)*a;r.moveTo(n,l),r.lineTo(u,c)}r.moveTo(o+.34*a,s),r.arc(o,s,.34*a,0,2*Math.PI)}else"script"===l?(r.moveTo(o-.7*a,s-.85*a),r.lineTo(o+.7*a,s-.85*a),r.lineTo(o+.7*a,s+.5*a),r.moveTo(o-.7*a,s-.85*a),r.lineTo(o-.7*a,s+.5*a),r.moveTo(o-.7*a,s+.6*a),r.lineTo(o-.25*a,s+.85*a),r.lineTo(o+.25*a,s+.6*a),r.lineTo(o+.7*a,s+.85*a)):"send"===l?(r.moveTo(o-.85*a,s-.55*a),r.lineTo(o+.85*a,s-.55*a),r.lineTo(o+.85*a,s+.55*a),r.lineTo(o-.85*a,s+.55*a),r.closePath(),r.moveTo(o-.85*a,s-.55*a),r.lineTo(o,s+.12*a),r.lineTo(o+.85*a,s-.55*a)):"receive"===l?(r.moveTo(o-.85*a,s-.55*a),r.lineTo(o+.85*a,s-.55*a),r.lineTo(o+.85*a,s+.55*a),r.lineTo(o-.85*a,s+.55*a),r.closePath()):"manual"===l&&(r.moveTo(o-.7*a,s+.6*a),r.lineTo(o-.45*a,s-.5*a),r.lineTo(o+.45*a,s-.5*a),r.lineTo(o+.7*a,s+.6*a),r.closePath());return this.path2D=r,this.path2D}}class BpmnSubprocessMarker extends y{static typeId="ice-entity-designer:BpmnSubprocessMarker";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);return r?(r.moveTo(i,n),r.lineTo(i+e,n),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),r.moveTo(i+e/2,n+.22*t),r.lineTo(i+e/2,n+.78*t),r.moveTo(i+.22*e,n+t/2),r.lineTo(i+.78*e,n+t/2),this.path2D=r,this.path2D):this.path2D}}const wn={terminator:{label:"开始 / 结束",width:180,height:60,fill:"#dcfce7",stroke:"#16a34a",radius:30,shape:"rect"},process:{label:"处理",width:220,height:80,fill:"#e0e7ff",stroke:"#4f46e5",radius:10,shape:"rect"},decision:{label:"判定",width:200,height:120,fill:"#fef3c7",stroke:"#d97706",shape:"diamond"},io:{label:"输入 / 输出",width:220,height:80,fill:"#e0f2fe",stroke:"#0284c7",shape:"parallelogram"},bpmnEvent:{label:"事件",width:56,height:56,fill:"#ffffff",stroke:"#475569",shape:"event",lineWidth:1.4,eventKind:"start",trigger:"none",labelPlacement:"top-left"},bpmnTask:{label:"任务",width:180,height:90,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",taskType:"none",labelPlacement:"center"},bpmnGateway:{label:"网关",width:70,height:70,fill:"#ffffff",stroke:"#64748b",shape:"gateway",gatewayType:"exclusive",labelPlacement:"top-left"},bpmnSubprocess:{label:"子流程",width:200,height:110,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",labelPlacement:"center"},bpmnDataObject:{label:"数据对象",width:130,height:80,fill:"#ffffff",stroke:"#64748b",shape:"dataObject",labelPlacement:"center"},bpmnAnnotation:{label:"注释",width:200,height:80,fill:"#ffffff",stroke:"#64748b",shape:"annotation",lineDash:[],labelPlacement:"center"},bpmnPool:{label:"池",width:900,height:260,fill:"#f8fafc",stroke:"#94a3b8",shape:"lane",band:"top",bandSize:32,labelPlacement:"top-left"},bpmnLane:{label:"泳道",width:900,height:130,fill:"#ffffff",stroke:"#cbd5e1",shape:"lane",band:"left",bandSize:32,labelPlacement:"top-left",transparent:!0}},Sn=["bpmnPool","bpmnLane","bpmnAnnotation","bpmnDataObject"],Cn={rect:h,diamond:class FlowDiamond extends y{static typeId="ice-entity-designer:FlowDiamond";createPathObject(){const e=this.state.width,t=this.state.height,i=0-this.state.localOrigin[0],n=0-this.state.localOrigin[1],r=createEmptyPath$1(this);return r?(r.moveTo(i+e/2,n),r.lineTo(i+e,n+t/2),r.lineTo(i+e/2,n+t),r.lineTo(i,n+t/2),r.closePath(),this.path2D=r,this.path2D):this.path2D}},parallelogram:class FlowParallelogram extends y{static typeId="ice-entity-designer:FlowParallelogram";createPathObject(){const e=this.state.width,t=this.state.height,i=Math.min(28,.18*e),n=0-this.state.localOrigin[0],r=0-this.state.localOrigin[1],o=createEmptyPath$1(this);return o?(o.moveTo(n+i,r),o.lineTo(n+e,r),o.lineTo(n+e-i,r+t),o.lineTo(n,r+t),o.closePath(),this.path2D=o,this.path2D):this.path2D}},event:class BpmnEventShape extends y{static typeId="ice-entity-designer:BpmnEventShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=i+e/2,s=n+t/2,a=Math.min(e,t)/2,l=this.state.eventKind||"start";r.arc(o,s,a,0,2*Math.PI),"intermediate"!==l&&"end"!==l||(r.moveTo(o+.84*a,s),r.arc(o,s,.84*a,0,2*Math.PI));const u=this.state.trigger||"none";if("message"===u){const e=1.1*a,t=.78*a;r.moveTo(o-e/2,s-t/2),r.lineTo(o+e/2,s-t/2),r.lineTo(o+e/2,s+t/2),r.lineTo(o-e/2,s+t/2),r.closePath(),r.moveTo(o-e/2,s-t/2),r.lineTo(o,s+.08*t),r.lineTo(o+e/2,s-t/2)}else if("timer"===u){const e=.52*a;r.moveTo(o+e,s),r.arc(o,s,e,0,2*Math.PI),r.moveTo(o,s),r.lineTo(o,s-.62*e),r.moveTo(o,s),r.lineTo(o+.5*e,s)}else"error"===u?(r.moveTo(o+.34*a,s-.62*a),r.lineTo(o-.42*a,s+.06*a),r.lineTo(o-.02*a,s+.06*a),r.lineTo(o-.3*a,s+.66*a),r.lineTo(o+.44*a,s-.02*a),r.lineTo(o+.04*a,s-.02*a),r.closePath()):"terminate"===u&&(r.moveTo(o+.5*a,s),r.arc(o,s,.5*a,0,2*Math.PI));return this.path2D=r,this.path2D}},gateway:class BpmnGatewayShape extends y{static typeId="ice-entity-designer:BpmnGatewayShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=i+e/2,s=n+t/2,a=e/2,l=t/2;r.moveTo(o,s-l),r.lineTo(o+a,s),r.lineTo(o,s+l),r.lineTo(o-a,s),r.closePath();const u=this.state.gatewayType||"exclusive",c=.42*Math.min(a,l);if("exclusive"===u)r.moveTo(o-c,s-c),r.lineTo(o+c,s+c),r.moveTo(o+c,s-c),r.lineTo(o-c,s+c);else if("parallel"===u)r.moveTo(o-c,s),r.lineTo(o+c,s),r.moveTo(o,s-c),r.lineTo(o,s+c);else if("inclusive"===u)r.moveTo(o+c,s),r.arc(o,s,c,0,2*Math.PI);else if("event"===u){const e=1.15*c;for(let t=0;t<5;t++){const i=-Math.PI/2+t*Math.PI*2/5,n=o+Math.cos(i)*e,a=s+Math.sin(i)*e;0===t?r.moveTo(n,a):r.lineTo(n,a)}r.closePath()}return this.path2D=r,this.path2D}},dataObject:class BpmnDataObjectShape extends y{static typeId="ice-entity-designer:BpmnDataObjectShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=Math.min(14,.22*e,.32*t);return r.moveTo(i,n),r.lineTo(i+e-o,n),r.lineTo(i+e,n+o),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),r.moveTo(i+e-o,n),r.lineTo(i+e-o,n+o),r.lineTo(i+e,n+o),this.path2D=r,this.path2D}},annotation:class BpmnAnnotationShape extends y{static typeId="ice-entity-designer:BpmnAnnotationShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=Math.min(16,.3*e);return r.moveTo(i,n),r.lineTo(i+e,n),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),r.moveTo(i+o,n),r.lineTo(i,n),r.lineTo(i,n+t),r.lineTo(i+o,n+t),this.path2D=r,this.path2D}},lane:class BpmnLaneShape extends y{static typeId="ice-entity-designer:BpmnLaneShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=Math.min(this.state.bandSize||30,.4*e,.4*t);return r.moveTo(i,n),r.lineTo(i+e,n),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),"top"===(this.state.band||"left")?(r.moveTo(i,n+o),r.lineTo(i+e,n+o)):(r.moveTo(i+o,n),r.lineTo(i+o,n+t)),this.path2D=r,this.path2D}}},Tn="#0f172a";class FlowNode extends u{static typeId="ice-entity-designer:FlowNode";shapeComponent=null;labelComponent=null;decorationComponents=[];hasDerivedChildren(){return!0}getSerializableChildren(){const e=[this.shapeComponent,this.labelComponent,...this.decorationComponents||[]];return this.childNodes.filter(t=>-1===e.indexOf(t))}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=wn[e.kind]?e.kind:"process",i=wn[t];super({kind:t,title:i.label,fillColor:i.fill,strokeColor:i.stroke,textColor:Tn,fontSize:14,width:i.width,height:i.height,fill:!1,stroke:!1,draggable:!0,interactive:!0,transformable:!1,linkable:-1===Sn.indexOf(t),...e}),this.__buildShape()}__buildShape(){this.shapeComponent&&this.removeChild(this.shapeComponent),this.labelComponent&&this.removeChild(this.labelComponent),this.decorationComponents&&this.decorationComponents.length&&(this.removeChildren(this.decorationComponents),this.decorationComponents.length=0);const e=wn[this.state.kind]||wn.process,t=Cn[e.shape]||h;this.shapeComponent=new t({left:0,top:0,width:this.state.width,height:this.state.height,radius:e.radius||0,lineWidth:e.lineWidth||1.5,lineDash:this.state.lineDash||e.lineDash||[],eventKind:this.state.eventKind||e.eventKind,trigger:this.state.trigger||e.trigger,gatewayType:this.state.gatewayType||e.gatewayType,taskType:this.state.taskType||e.taskType,band:e.band,bandSize:e.bandSize,fill:!e.transparent,interactive:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fillStyle:this.state.fillColor||e.fill,strokeStyle:this.state.strokeColor||e.stroke,lineWidth:e.lineWidth||1.5}}),this.__buildDecorations(e);const i="top-left"===e.labelPlacement,n="lane"===e.shape&&"left"===e.band,r=n?Math.min(Number(e.bandSize)||30,.4*this.state.width,.4*this.state.height):0,o=n?Math.max(this.state.height-8,r):0;this.labelComponent=new c(n?{left:r/2-o/2,top:this.state.height/2-r/2,width:o,height:r,text:String(this.state.title||""),wrap:!0,maxLines:1,ellipsis:"…",transform:{rotate:-90},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fontSize:this.state.fontSize||13,fillStyle:this.state.textColor||Tn,textAlign:"center",textBaseline:"middle",fontWeight:"bold"}}:{left:i?10:0,top:i?"top"===e.band?18:16:0,width:i?Math.max(this.state.width-20,20):this.state.width,height:i?18:this.state.height,text:String(this.state.title||""),wrap:!i,maxLines:2,interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fontSize:this.state.fontSize||(i?13:14),fillStyle:this.state.textColor||Tn,textAlign:i?"left":"center",textBaseline:"middle",fontWeight:i?"bold":"normal",paddingLeft:i?0:12,paddingRight:i?0:12}}),this.addChild(this.shapeComponent),this.addChild(this.labelComponent)}__buildDecorations(e){const t=this.state.kind,i=[],n=this.state.strokeColor||e.stroke;if("bpmnTask"===t||"bpmnSubprocess"===t){const t=this.state.taskType||e.taskType||"none";"none"!==t&&i.push(new BpmnTaskIcon({left:8,top:8,width:14,height:14,stroke:!0,fill:!1,interactive:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,taskType:t,style:{strokeStyle:n,lineWidth:1.4}}))}"bpmnSubprocess"===t&&i.push(new BpmnSubprocessMarker({left:(this.state.width-14)/2,top:this.state.height-20,width:14,height:14,stroke:!0,fill:!1,interactive:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{strokeStyle:n,lineWidth:1.4}})),i.length&&(i.forEach(e=>this.addChild(e)),this.decorationComponents=i)}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=void 0!==e.kind||void 0!==e.fillColor||void 0!==e.strokeColor||void 0!==e.textColor||void 0!==e.fontSize||void 0!==e.eventKind||void 0!==e.trigger||void 0!==e.gatewayType||void 0!==e.taskType||void 0!==e.width||void 0!==e.height;return this.setState(e),t?this.__buildShape():this.labelComponent&&this.labelComponent.setState({text:String(this.state.title||"")}),this.dirty=!0,this}}class FlowEdge extends p{static typeId="ice-entity-designer:FlowEdge";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({title:"Edge",arrow:"end",linkShape:"visio",lineType:"solid",linkable:!1,draggable:!1,interactive:!0,transformable:!1,startPoint:[0,0],endPoint:[10,10],label:"",...e,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4,...e.style||{},label:{fontSize:12,fillStyle:"#334155",backgroundColor:"#ffffff",paddingLeft:4,paddingRight:4,...e.labelStyle||{},...(e.style||{}).label||{}}}}),this.applyPatch({flowType:this.state.flowType,condition:this.state.condition,isDefault:this.state.isDefault})}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e&&e.labelStyle&&(e={...e,style:{...this.state.style||{},...e.style||{},label:{...e.labelStyle||{},...(e.style||{}).label||{}}}},delete e.labelStyle);const t={...this.state,...e},i=t.flowType||"sequence",n="message"===i?{lineDash:[7,4],arrowStyle:"hollow",lineWidth:t.lineWidth||1.4}:"association"===i?{lineDash:[2,3],arrow:"none",arrowStyle:"hollow",lineWidth:t.lineWidth||1.2}:{arrow:t.arrow||"end",arrowStyle:"filled",lineDash:[],lineWidth:t.lineWidth||1.4};return this.setState({...e,...n}),this.dirty=!0,this}}class DesignerHighlightLayer{boxes=(()=>new Map)();options={color:"",lineWidth:3,padding:4,radius:6,fill:!1};constructor(e){this.ice=e}get ids(){return Array.from(this.boxes.keys())}set(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options={...this.options,...t};const i=new Set(e.map(e=>e.id));Array.from(this.boxes.keys()).forEach(e=>{i.has(e)||this.__remove(e)}),e.forEach(e=>this.__place(e)),this.boxes.size||this.__destroy(),this.ice&&"function"==typeof this.ice.requestRepaint&&this.ice.requestRepaint()}clear(){this.boxes.forEach(e=>{this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(e)}),this.boxes.clear(),this.ice&&"function"==typeof this.ice.requestRepaint&&this.ice.requestRepaint()}__place(e){const t=Number(this.options.padding)||0,i=e.minX-t,n=e.minY-t,r=Math.max(1,e.maxX-e.minX+2*t),o=Math.max(1,e.maxY-e.minY+2*t);let s=this.boxes.get(e.id);if(!s)return s=new h({left:i,top:n,width:r,height:o,radius:this.options.radius,fill:!!this.options.fill,stroke:!0,interactive:!1,draggable:!1,transformable:!1,linkable:!1,style:{fillStyle:this.options.fill||"transparent",strokeStyle:this.__color(),lineWidth:this.options.lineWidth}}),s.__iceDesignerHighlight=!0,this.boxes.set(e.id,s),void this.ice.addTool(s);s.setState({left:i,top:n,width:r,height:o,radius:this.options.radius,fill:!!this.options.fill,style:{fillStyle:this.options.fill||"transparent",strokeStyle:this.__color(),lineWidth:this.options.lineWidth}})}__remove(e){const t=this.boxes.get(e);t&&(this.boxes.delete(e),this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(t))}__destroy(){this.boxes.forEach(e=>{this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(e)}),this.boxes.clear()}__color(){if(this.options.color)return this.options.color;try{const e=this.ice&&"function"==typeof this.ice.getTheme?this.ice.getTheme():null;return e&&e.semantic&&e.semantic.primary||m.semantic.primary}catch{return m.semantic.primary}}}class FlowDesigner{selectedId=null;__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;__listeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__moveSession=!1;__moveEmitQueued=!1;__highlightOptions={};__beforeMoveHandler=()=>this.__onBeforeMove();__afterMoveHandler=()=>this.__onAfterMove();__mouseupHandler=()=>this.__endMoveSession();constructor(e){applyDesignerChrome(e),enableDesignerAlignmentGuides(e),this.ice=e,this.__highlight=new DesignerHighlightLayer(this.ice),registerIEDType(this.ice,FlowNode),registerIEDType(this.ice,FlowEdge),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this),this.ice.evtBus.on("mouseup",this.__mouseupHandler,this)}get nodes(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowNode.typeId)}get edges(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowEdge.typeId)}__flatten(){const e=[],walk=t=>{t.forEach(t=>{e.push(t),t.childNodes&&t.childNodes.length&&walk(t.childNodes)})};return walk(this.ice.childNodes||[]),e}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}setHighlights(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object.keys(t).length&&(this.__highlightOptions={...this.__highlightOptions,...t});const i=(null==e?[]:Array.isArray(e)?e:[e]).map(e=>this.__highlightEntry(e)).filter(e=>!!e);return this.__highlight.set(i,this.__highlightOptions),i.length}highlight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=null==e?null:this.__highlightEntry(e);return!(null!=e&&!i)&&(this.setHighlights(i?[i.id]:null,t),!!i)}clearHighlights(){this.setHighlights(null)}getHighlightedIds(){return this.__highlight.ids}__highlightEntry(e){const t=String(e),i=this.nodes.find(e=>String(e.state?.id)===t)||this.nodes.find(e=>String(e.state?.tag)===t);if(!i)return null;const n=i.getMinBoundingBox(!0).getMinAndMaxPoint();return{id:String(i.state.id),minX:n.minX,minY:n.minY,maxX:n.maxX,maxY:n.maxY}}__syncHighlights(){const e=this.__highlight.ids;e.length&&this.setHighlights(e)}subscribe(e){return"function"!=typeof e?()=>{}:(this.__listeners.push(e),()=>{const t=this.__listeners.indexOf(e);-1!==t&&this.__listeners.splice(t,1)})}__emitChange(){if(this.__syncHighlights(),!this.__listeners.length)return;const e=this.serialize();this.__listeners.slice().forEach(t=>t(e,this))}__attachNodeListeners(e){e&&"function"==typeof e.on&&(e.on(g.BEFORE_MOVE,this.__beforeMoveHandler,this),e.on(g.AFTER_MOVE,this.__afterMoveHandler,this))}__detachNodeListeners(e){e&&"function"==typeof e.off&&(e.off(g.BEFORE_MOVE,this.__beforeMoveHandler,this),e.off(g.AFTER_MOVE,this.__afterMoveHandler,this))}__onBeforeMove(){this.__moveSession||(this.__moveSession=!0,this.__captureHistory())}__onAfterMove(){if(this.__moveEmitQueued)return;this.__moveEmitQueued=!0;const flush=()=>{this.__moveEmitQueued=!1,this.__emitChange()};"function"==typeof requestAnimationFrame?requestAnimationFrame(flush):setTimeout(flush,16)}__endMoveSession(){this.__moveSession=!1}select(e){return this.selectedId=e,this.__emitChange(),this}__defaultPlacement(e,t){const i=this.nodes;if(!i.length)return{left:120,top:120};let n=1/0,r=-1/0;i.forEach(e=>{const t=e.getMinBoundingBox(!0);n=Math.min(n,t.tl[0]),r=Math.max(r,t.br[1])});const o=i.length;return{left:n+o%4*280,top:r+80+Math.floor(o/4)*(t+90)}}createNode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new FlowNode({kind:e,...t});if(void 0===t.left||void 0===t.top){const e=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===t.left?e.left:t.left,top:void 0===t.top?e.top:t.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}__slotPoint(e,t){const i=e.getMinBoundingBox(!0);switch(t){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}createEdge(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.sourceId?this.ice.findComponent(e.sourceId):null,i=e.targetId?this.ice.findComponent(e.targetId):null;if(!t||!i)throw new Error("连接两端必须是已存在的节点");this.__captureHistory();const n=autoPorts(t,i,{sourcePort:"B",targetPort:"T"}),r=e.sourcePort||n.sourcePort,o=e.targetPort||n.targetPort,s=new FlowEdge({id:e.id,links:{start:{id:e.sourceId,position:r},end:{id:e.targetId,position:o}},startPoint:this.__slotPoint(t,r),endPoint:this.__slotPoint(i,o),label:e.label||"",linkShape:e.linkShape||"visio",flowType:e.flowType||"sequence",condition:e.condition||"",isDefault:!!e.isDefault,style:{...e.style||{},...e.labelStyle?{label:e.labelStyle}:{}}});return this.ice.addChild(s),this.selectedId=s.state.id,this.__emitChange(),s}updateNode(e,t){const i=this.ice.findComponent(e);return i&&i.constructor.typeId===FlowNode.typeId&&(this.__captureHistory(),i.applyPatch(t),this.__emitChange()),i}updateEdge(e,t){const i=this.ice.findComponent(e);return i&&i.constructor.typeId===FlowEdge.typeId&&(this.__captureHistory(),"function"==typeof i.applyPatch?i.applyPatch(t):(i.setState(t),i.dirty=!0),this.__emitChange()),i}remove(e){const t=this.ice.findComponent(e);t&&(this.__captureHistory(),-1!==this.nodes.indexOf(t)&&(this.__detachNodeListeners(t),this.edges.filter(t=>{const i=t.state.links||{};return i.start&&i.start.id===e||i.end&&i.end.id===e}).forEach(e=>this.ice.removeChild(e))),t.parentNode&&"function"==typeof t.parentNode.removeChild?t.parentNode.removeChild(t):this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange())}clear(){this.__captureHistory(),this.ice.clearAll(),this.selectedId=null,this.__emitChange()}serialize(){return JSON.stringify(this.toSnapshot())}toSnapshot(){const e=this.__serializer().toJSONObject();return{version:2,kind:"flowchart",createTime:e.createTime,scene:{version:e.version,childNodes:e.childNodes}}}__serializer(){const e=this.ice;return e.serializer||new _(e)}__deserializer(){const e=this.ice;return e.deserializer||new b(e)}load(e){if(!e)return{loaded:!1,nodes:0,edges:0,skipped:[]};let t;try{t=JSON.parse(e)}catch(e){throw new Error(`Invalid flow snapshot: 不是合法 JSON(${e instanceof Error?e.message:String(e)})`)}if(!t||"object"!=typeof t)return{loaded:!1,nodes:0,edges:0,skipped:[]};const i=!!t.scene;if(!i&&!Array.isArray(t.nodes))return{loaded:!1,nodes:0,edges:0,skipped:[]};const n=function validateFlowSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:void 0!==e.scene?(!e.scene||"object"!=typeof e.scene||Array.isArray(e.scene)?t.push("scene must be an object when present"):Array.isArray(e.scene.childNodes)||t.push("scene.childNodes must be an array"),{valid:0===t.length,errors:t}):(Array.isArray(e.nodes)?e.nodes.forEach((e,i)=>{const n=`nodes[${i}]`;e&&"object"==typeof e&&!Array.isArray(e)?("string"!=typeof e.id&&t.push(`${n}.id must be a string`),void 0!==e.kind&&"string"!=typeof e.kind&&t.push(`${n}.kind must be a string when present`),void 0!==e.left&&"number"!=typeof e.left&&t.push(`${n}.left must be a number when present`),void 0!==e.top&&"number"!=typeof e.top&&t.push(`${n}.top must be a number when present`)):t.push(`${n} must be an object`)}):t.push("nodes must be an array"),void 0===e.edges||Array.isArray(e.edges)?Array.isArray(e.edges)&&e.edges.forEach((e,i)=>{const n=`edges[${i}]`;e&&"object"==typeof e&&!Array.isArray(e)?(["sourceId","targetId"].forEach(i=>{void 0!==e[i]&&null!==e[i]&&"string"!=typeof e[i]&&t.push(`${n}.${i} must be a string or null when present`)}),void 0!==e.label&&"string"!=typeof e.label&&t.push(`${n}.label must be a string when present`),void 0!==e.linkShape&&"visio"!==e.linkShape&&"bezier"!==e.linkShape&&t.push(`${n}.linkShape must be "visio" or "bezier" when present`)):t.push(`${n} must be an object`)}):t.push("edges must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!n.valid)throw new Error(`Invalid flow snapshot:\n${n.errors.join("\n")}`);this.__captureHistory();const r=i?this.__applyEngineScene(t.scene,t.createTime):this.__clearAndBuild(t);return this.__emitChange(),r}__applyEngineScene(e,t){this.ice.clearAll(),this.selectedId=null;const i=this.__deserializer();i.fromJSONObject({version:e.version,createTime:t,childNodes:e.childNodes});const n={loaded:!0,nodes:this.nodes.length,edges:this.edges.length,skipped:[...i.unknownTypes||[]]};return this.nodes.forEach(e=>this.__attachNodeListeners(e)),n}__clearAndBuild(e){this.ice.clearAll(),this.selectedId=null;const t={loaded:!0,nodes:0,edges:0,skipped:[]};return(e.nodes||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowNode)return void t.skipped.push(String(e.typeId));const i=new FlowNode(e);delete i.state.typeId,this.ice.addChild(i),this.__attachNodeListeners(i),t.nodes+=1}),(e.edges||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowEdge)return void t.skipped.push(String(e.typeId));const i=e.sourceId||e.links&&e.links.start&&e.links.start.id||null,n=e.targetId||e.links&&e.links.end&&e.links.end.id||null,r=e.sourcePort||e.links&&e.links.start&&e.links.start.position||"B",o=e.targetPort||e.links&&e.links.end&&e.links.end.position||"T",s=i&&n?{start:{id:i,position:r},end:{id:n,position:o}}:e.links,a=new FlowEdge({...e,links:s,startPoint:e.startPoint||[0,0],endPoint:e.endPoint||[10,10]});delete a.state.typeId,this.ice.addChild(a),t.edges+=1}),t}contentComponents(){return this.nodes}fitViewportAlign="center";fitViewport(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:80;const t=this.contentComponents(),{width:i,height:n}=this.__viewportSize();if(!t.length||!i||!n)return;let r=1/0,o=1/0,s=-1/0,a=-1/0;t.forEach(e=>{const t=e.getMinBoundingBox(!0);r=Math.min(r,t.tl[0]),o=Math.min(o,t.tl[1]),s=Math.max(s,t.br[0]),a=Math.max(a,t.br[1])});const l=Math.max(s-r,1),u=Math.max(a-o,1),c=Math.min((i-2*e)/l,(n-2*e)/u,1.25),h=(i-l*c)/2-r*c,d="start"===this.fitViewportAlign?e-o*c:(n-u*c)/2-o*c;this.ice.setViewport(c,h,d)}__viewportSize(){const e=this.ice,t=e&&e.dpr?e.dpr:1,i=e&&"function"==typeof e.getInputRect?e.getInputRect():null;return{width:i&&i.width>0?i.width:(e?.canvasWidth||0)/t,height:i&&i.height>0?i.height:(e?.canvasHeight||0)/t}}canUndo(){return this.__undoStack.length>0}toSvg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v(this.ice,e)}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__captureHistory()}resetHistory(){this.__undoStack.length=0,this.__redoStack.length=0}__captureHistory(){this.__historyEnabled&&(this.__undoStack.push(this.serialize()),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}__applySnapshot(e){const t=JSON.parse(e);t&&t.scene?this.__applyEngineScene(t.scene):this.__clearAndBuild(t)}undo(){if(!this.canUndo())return;const e=this.serialize(),t=this.__undoStack.pop();this.__redoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__redoStack.pop(),this.__undoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serialize(),t=this.__redoStack.pop();this.__undoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__undoStack.pop(),this.__redoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let i=t;for(;i;){const e=i.constructor&&i.constructor.typeId;if(e===FlowNode.typeId||e===FlowEdge.typeId)return void this.select(i.state.id);i=i.parentNode}}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this),this.ice.evtBus.off("mouseup",this.__mouseupHandler,this),this.nodes.forEach(e=>this.__detachNodeListeners(e))}}function createDesignerSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new k;i.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const n=new EntityDesigner(i),r=t.onChange?n.subscribe(t.onChange):null;t.initialProject&&n.loadProject(t.initialProject);let o=!1;return{ice:i,designer:n,destroy(){o||(o=!0,r&&r(),n.dispose(),i.destroy())}}}function shouldApplyControlledValue(e,t){return void 0!==e&&e!==t}function createFlowSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new k;i.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const n=new FlowDesigner(i),r=t.onChange,o=r?n.subscribe(e=>r(e)):null;t.initialFlow&&n.load(t.initialFlow);let s=!1;return{ice:i,designer:n,destroy(){s||(s=!0,o&&o(),n.dispose(),i.destroy())}}}function reportLoadError(e,t,i,n){const r=n instanceof Error?n:new Error(String(n));e&&e({phase:t,snapshot:i,error:r})}function createHandle$1(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addEntity:e=>t?t.createEntity(e):null,connect:e=>t?t.createRelation(e):null,updateEntity:(e,i)=>t?t.updateEntity(e,i):null,updateRelation:(e,i)=>t?t.updateRelation(e,i):null,remove:e=>{t&&t.removeComponent(e)},loadProject:e=>t?t.loadProject(e):{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},toSchemaObject:()=>t?t.toSchemaObject():[],toSchemaString:()=>t?t.toSchemaString():"[]",validate:()=>t?t.validate():[],serializeProject:()=>t?t.serializeProject():""}}const xn=n(function EntityDesignerCanvas(e,i){const n=r(null),u=r(null),[c,h]=o(null),d=r(e.onChange);d.current=e.onChange;const p=r(e.onReady);p.current=e.onReady;const f=r(e.onError);f.current=e.onError;const y=r(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=n.current;if(!t)return;const i=createDesignerSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,i=u.current;t&&i&&t({snapshot:e,schema:i.designer.toSchemaObject()})}});if(u.current=i,void 0!==_){y.current=_;try{i.designer.loadProject(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(i.designer),p.current&&p.current(createHandle$1(i)),()=>{i.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.loadProject(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(i,()=>createHandle$1(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:n,width:m,height:g,style:{display:"block"}})),t(EntityDesignerProvider,{designer:c,children:e.children}))}),qn='{"version":1,"kind":"flowchart","nodes":[],"edges":[]}';function createHandle(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addNode:(e,i)=>t?t.createNode(e,i):null,connect:e=>t?t.createEdge(e):null,updateNode:(e,i)=>t?t.updateNode(e,i):null,updateEdge:(e,i)=>t?t.updateEdge(e,i):null,remove:e=>{t&&t.remove(e)},load:e=>t?t.load(e):{loaded:!1,nodes:0,edges:0,skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},serialize:()=>t?t.serialize():qn,toSnapshot:()=>t?t.toSnapshot():JSON.parse(qn),fitViewport:e=>{t&&t.fitViewport(e)}}}const In=n(function FlowDesignerCanvas(e,i){const n=r(null),u=r(null),[c,h]=o(null),d=r(e.onChange);d.current=e.onChange;const p=r(e.onReady);p.current=e.onReady;const f=r(e.onError);f.current=e.onError;const y=r(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=n.current;if(!t)return;const i=createFlowSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,i=u.current;t&&i&&t({snapshot:e,counts:{nodes:i.designer.nodes.length,edges:i.designer.edges.length}})}});if(u.current=i,void 0!==_){y.current=_;try{i.designer.load(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(i.designer),p.current&&p.current(createHandle(i)),()=>{i.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.load(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(i,()=>createHandle(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:n,width:m,height:g,style:{display:"block"}})),t(FlowDesignerProvider,{designer:c,children:e.children}))});export{Entity,xn as EntityDesignerCanvas,w as EntityDesignerContext,EntityDesignerProvider,wn as FLOW_NODE_KINDS,FlowDesigner,In as FlowDesignerCanvas,S as FlowDesignerContext,FlowDesignerProvider,FlowEdge,FlowNode,Relation,createDesignerSession,createFlowSession,shouldApplyControlledValue,toSchemaObject,toSchemaString,useEntityDesigner,useFlowDesigner,validateSchema};
|
|
25
|
+
import{createContext as e,createElement as t,useContext as i,forwardRef as n,useRef as r,useState as o,useEffect as s,useImperativeHandle as a,Fragment as l}from"react";import{ICEGroup as u,ICEText as c,ICERect as h,ICEPolyLine as d,ICEVisioLink as p,toIsoTime as f,ICEPath as y,ICE_EVENT_NAME_CONSTS as m,DEFAULT_THEME as g,Serializer as _,Deserializer as b,exportSvg as v,ICE as k}from"ice-render";const w=e(null);function EntityDesignerProvider(e){return t(w.Provider,{value:e.designer},e.children)}function useEntityDesigner(){return i(w)}const S=e(null);function FlowDesignerProvider(e){return t(S.Provider,{value:e.designer},e.children)}function useFlowDesigner(){return i(S)}var C,T,x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var I,q,j,E,P,$,O,M,D,A,N,B,F,z,L,R,H,W,V,U,G,K,X,Y,J,Q,Z,ee,te,ie,ne,re,oe,se,ae,le,ue,ce,he,de,pe,fe,ye,me,ge,_e,be,ve,ke,we,Se,Ce,Te,xe,Ie,qe,je,Ee,Pe,$e,Oe,Me,De,Ae,Ne,Be,Fe,ze,Le,Re,He,We,Ve,Ue,Ge,Ke,Xe,Ye,Je,Qe,Ze,et,tt,it,nt,rt,ot,st,at,lt,ut,ct,ht,dt,pt,ft,yt,mt,gt=getDefaultExportFromCjs(function requireIsNil(){return T?C:(T=1,C=function isNil(e){return null==e})}());function requireEq(){if(E)return j;return E=1,j=function eq(e,t){return e===t||e!=e&&t!=t}}function require_assocIndexOf(){if($)return P;$=1;var e=requireEq();return P=function assocIndexOf(t,i){for(var n=t.length;n--;)if(e(t[n][0],i))return n;return-1}}function require_ListCache(){if(R)return L;R=1;var e=function require_listCacheClear(){return q?I:(q=1,I=function listCacheClear(){this.__data__=[],this.size=0})}(),t=function require_listCacheDelete(){if(M)return O;M=1;var e=require_assocIndexOf(),t=Array.prototype.splice;return O=function listCacheDelete(i){var n=this.__data__,r=e(n,i);return!(r<0||(r==n.length-1?n.pop():t.call(n,r,1),--this.size,0))}}(),i=function require_listCacheGet(){if(A)return D;A=1;var e=require_assocIndexOf();return D=function listCacheGet(t){var i=this.__data__,n=e(i,t);return n<0?void 0:i[n][1]}}(),n=function require_listCacheHas(){if(B)return N;B=1;var e=require_assocIndexOf();return N=function listCacheHas(t){return e(this.__data__,t)>-1}}(),r=function require_listCacheSet(){if(z)return F;z=1;var e=require_assocIndexOf();return F=function listCacheSet(t,i){var n=this.__data__,r=e(n,t);return r<0?(++this.size,n.push([t,i])):n[r][1]=i,this}}();function ListCache(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}return ListCache.prototype.clear=e,ListCache.prototype.delete=t,ListCache.prototype.get=i,ListCache.prototype.has=n,ListCache.prototype.set=r,L=ListCache}function require_freeGlobal(){if(Q)return J;Q=1;var e="object"==typeof x&&x&&x.Object===Object&&x;return J=e}function require_root(){if(ee)return Z;ee=1;var e=require_freeGlobal(),t="object"==typeof self&&self&&self.Object===Object&&self,i=e||t||Function("return this")();return Z=i}function require_Symbol(){if(ie)return te;ie=1;var e=require_root().Symbol;return te=e}function require_baseGetTag(){if(le)return ae;le=1;var e=require_Symbol(),t=function require_getRawTag(){if(re)return ne;re=1;var e=require_Symbol(),t=Object.prototype,i=t.hasOwnProperty,n=t.toString,r=e?e.toStringTag:void 0;return ne=function getRawTag(e){var t=i.call(e,r),o=e[r];try{e[r]=void 0;var s=!0}catch(e){}var a=n.call(e);return s&&(t?e[r]=o:delete e[r]),a}}(),i=function require_objectToString(){if(se)return oe;se=1;var e=Object.prototype.toString;return oe=function objectToString(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return ae=function baseGetTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):i(e)}}function requireIsObject(){if(ce)return ue;return ce=1,ue=function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function requireIsFunction(){if(de)return he;de=1;var e=require_baseGetTag(),t=requireIsObject();return he=function isFunction(i){if(!t(i))return!1;var n=e(i);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function require_isMasked(){if(me)return ye;me=1;var e,t=function require_coreJsData(){if(fe)return pe;fe=1;var e=require_root()["__core-js_shared__"];return pe=e}(),i=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return ye=function isMasked(e){return!!i&&i in e}}function require_baseIsNative(){if(ve)return be;ve=1;var e=requireIsFunction(),t=require_isMasked(),i=requireIsObject(),n=function require_toSource(){if(_e)return ge;_e=1;var e=Function.prototype.toString;return ge=function toSource(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),r=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,a=o.toString,l=s.hasOwnProperty,u=RegExp("^"+a.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return be=function baseIsNative(o){return!(!i(o)||t(o))&&(e(o)?u:r).test(n(o))}}function require_getNative(){if(Ce)return Se;Ce=1;var e=require_baseIsNative(),t=function require_getValue(){return we?ke:(we=1,ke=function getValue(e,t){return null==e?void 0:e[t]})}();return Se=function getNative(i,n){var r=t(i,n);return e(r)?r:void 0}}function require_Map(){if(xe)return Te;xe=1;var e=require_getNative()(require_root(),"Map");return Te=e}function require_nativeCreate(){if(qe)return Ie;qe=1;var e=require_getNative()(Object,"create");return Ie=e}function require_Hash(){if(ze)return Fe;ze=1;var e=function require_hashClear(){if(Ee)return je;Ee=1;var e=require_nativeCreate();return je=function hashClear(){this.__data__=e?e(null):{},this.size=0}}(),t=function require_hashDelete(){return $e?Pe:($e=1,Pe=function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t})}(),i=function require_hashGet(){if(Me)return Oe;Me=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return Oe=function hashGet(i){var n=this.__data__;if(e){var r=n[i];return"__lodash_hash_undefined__"===r?void 0:r}return t.call(n,i)?n[i]:void 0}}(),n=function require_hashHas(){if(Ae)return De;Ae=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return De=function hashHas(i){var n=this.__data__;return e?void 0!==n[i]:t.call(n,i)}}(),r=function require_hashSet(){if(Be)return Ne;Be=1;var e=require_nativeCreate();return Ne=function hashSet(t,i){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===i?"__lodash_hash_undefined__":i,this}}();function Hash(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}return Hash.prototype.clear=e,Hash.prototype.delete=t,Hash.prototype.get=i,Hash.prototype.has=n,Hash.prototype.set=r,Fe=Hash}function require_getMapData(){if(Ue)return Ve;Ue=1;var e=function require_isKeyable(){return We?He:(We=1,He=function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e})}();return Ve=function getMapData(t,i){var n=t.__data__;return e(i)?n["string"==typeof i?"string":"hash"]:n.map}}function require_MapCache(){if(it)return tt;it=1;var e=function require_mapCacheClear(){if(Re)return Le;Re=1;var e=require_Hash(),t=require_ListCache(),i=require_Map();return Le=function mapCacheClear(){this.size=0,this.__data__={hash:new e,map:new(i||t),string:new e}}}(),t=function require_mapCacheDelete(){if(Ke)return Ge;Ke=1;var e=require_getMapData();return Ge=function mapCacheDelete(t){var i=e(this,t).delete(t);return this.size-=i?1:0,i}}(),i=function require_mapCacheGet(){if(Ye)return Xe;Ye=1;var e=require_getMapData();return Xe=function mapCacheGet(t){return e(this,t).get(t)}}(),n=function require_mapCacheHas(){if(Qe)return Je;Qe=1;var e=require_getMapData();return Je=function mapCacheHas(t){return e(this,t).has(t)}}(),r=function require_mapCacheSet(){if(et)return Ze;et=1;var e=require_getMapData();return Ze=function mapCacheSet(t,i){var n=e(this,t),r=n.size;return n.set(t,i),this.size+=n.size==r?0:1,this}}();function MapCache(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var n=e[t];this.set(n[0],n[1])}}return MapCache.prototype.clear=e,MapCache.prototype.delete=t,MapCache.prototype.get=i,MapCache.prototype.has=n,MapCache.prototype.set=r,tt=MapCache}function require_Stack(){if(st)return ot;st=1;var e=require_ListCache(),t=function require_stackClear(){if(W)return H;W=1;var e=require_ListCache();return H=function stackClear(){this.__data__=new e,this.size=0}}(),i=function require_stackDelete(){return U?V:(U=1,V=function stackDelete(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i})}(),n=function require_stackGet(){return K?G:(K=1,G=function stackGet(e){return this.__data__.get(e)})}(),r=function require_stackHas(){return Y?X:(Y=1,X=function stackHas(e){return this.__data__.has(e)})}(),o=function require_stackSet(){if(rt)return nt;rt=1;var e=require_ListCache(),t=require_Map(),i=require_MapCache();return nt=function stackSet(n,r){var o=this.__data__;if(o instanceof e){var s=o.__data__;if(!t||s.length<199)return s.push([n,r]),this.size=++o.size,this;o=this.__data__=new i(s)}return o.set(n,r),this.size=o.size,this}}();function Stack(t){var i=this.__data__=new e(t);this.size=i.size}return Stack.prototype.clear=t,Stack.prototype.delete=i,Stack.prototype.get=n,Stack.prototype.has=r,Stack.prototype.set=o,ot=Stack}function require_defineProperty(){if(lt)return at;lt=1;var e=require_getNative(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return at=t}function require_baseAssignValue(){if(ct)return ut;ct=1;var e=require_defineProperty();return ut=function baseAssignValue(t,i,n){"__proto__"==i&&e?e(t,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[i]=n}}function require_assignMergeValue(){if(dt)return ht;dt=1;var e=require_baseAssignValue(),t=requireEq();return ht=function assignMergeValue(i,n,r){(void 0!==r&&!t(i[n],r)||void 0===r&&!(n in i))&&e(i,n,r)}}function require_baseFor(){if(mt)return yt;mt=1;var e=function require_createBaseFor(){return ft?pt:(ft=1,pt=function createBaseFor(e){return function(t,i,n){for(var r=-1,o=Object(t),s=n(t),a=s.length;a--;){var l=s[e?a:++r];if(!1===i(o[l],l,o))break}return t}})}()();return yt=e}var _t,bt,vt,kt,wt,St,Ct,Tt,xt,It,qt,jt,Et,Pt,$t,Ot,Mt,Dt,At,Nt,Bt,Ft,zt,Lt,Rt,Ht,Wt,Vt,Ut,Gt,Kt,Xt,Yt,Jt={exports:{}};function require_cloneArrayBuffer(){if(wt)return kt;wt=1;var e=function require_Uint8Array(){if(vt)return bt;vt=1;var e=require_root().Uint8Array;return bt=e}();return kt=function cloneArrayBuffer(t){var i=new t.constructor(t.byteLength);return new e(i).set(new e(t)),i}}function require_getPrototype(){if($t)return Pt;$t=1;var e=function require_overArg(){return Et?jt:(Et=1,jt=function overArg(e,t){return function(i){return e(t(i))}})}()(Object.getPrototypeOf,Object);return Pt=e}function require_isPrototype(){if(Mt)return Ot;Mt=1;var e=Object.prototype;return Ot=function isPrototype(t){var i=t&&t.constructor;return t===("function"==typeof i&&i.prototype||e)}}function require_initCloneObject(){if(At)return Dt;At=1;var e=function require_baseCreate(){if(qt)return It;qt=1;var e=requireIsObject(),t=Object.create,i=function(){function object(){}return function(i){if(!e(i))return{};if(t)return t(i);object.prototype=i;var n=new object;return object.prototype=void 0,n}}();return It=i}(),t=require_getPrototype(),i=require_isPrototype();return Dt=function initCloneObject(n){return"function"!=typeof n.constructor||i(n)?{}:e(t(n))}}function requireIsObjectLike(){if(Bt)return Nt;return Bt=1,Nt=function isObjectLike(e){return null!=e&&"object"==typeof e}}function requireIsArguments(){if(Rt)return Lt;Rt=1;var e=function require_baseIsArguments(){if(zt)return Ft;zt=1;var e=require_baseGetTag(),t=requireIsObjectLike();return Ft=function baseIsArguments(i){return t(i)&&"[object Arguments]"==e(i)}}(),t=requireIsObjectLike(),i=Object.prototype,n=i.hasOwnProperty,r=i.propertyIsEnumerable,o=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!r.call(e,"callee")};return Lt=o}function requireIsArray(){if(Wt)return Ht;Wt=1;var e=Array.isArray;return Ht=e}function requireIsLength(){if(Ut)return Vt;Ut=1;return Vt=function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function requireIsArrayLike(){if(Kt)return Gt;Kt=1;var e=requireIsFunction(),t=requireIsLength();return Gt=function isArrayLike(i){return null!=i&&t(i.length)&&!e(i)}}var Qt,Zt,ei,ti,ii,ni,ri,oi,si,ai={exports:{}};function requireIsBuffer(){return ei||(ei=1,function(e,t){var i=require_root(),n=function requireStubFalse(){return Zt?Qt:(Zt=1,Qt=function stubFalse(){return!1})}(),r=t&&!t.nodeType&&t,o=r&&e&&!e.nodeType&&e,s=o&&o.exports===r?i.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;e.exports=a}(ai,ai.exports)),ai.exports}var li,ui,ci,hi,di,pi,fi,yi,mi,gi,_i,bi,vi,ki,wi,Si,Ci,Ti,xi,Ii,qi,ji,Ei,Pi,$i,Oi,Mi,Di,Ai,Ni,Bi,Fi,zi,Li,Ri,Hi,Wi,Vi,Ui,Gi,Ki,Xi,Yi,Ji,Qi,Zi,en,tn,nn,rn={exports:{}};function requireIsTypedArray(){if(ci)return ui;ci=1;var e=function require_baseIsTypedArray(){if(ri)return ni;ri=1;var e=require_baseGetTag(),t=requireIsLength(),i=requireIsObjectLike(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,ni=function baseIsTypedArray(r){return i(r)&&t(r.length)&&!!n[e(r)]}}(),t=function require_baseUnary(){return si?oi:(si=1,oi=function baseUnary(e){return function(t){return e(t)}})}(),i=function require_nodeUtil(){return li||(li=1,e=rn,t=rn.exports,i=require_freeGlobal(),n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,o=r&&r.exports===n&&i.process,s=function(){try{return r&&r.require&&r.require("util").types||o&&o.binding&&o.binding("util")}catch(e){}}(),e.exports=s),rn.exports;var e,t,i,n,r,o,s}(),n=i&&i.isTypedArray,r=n?t(n):e;return ui=r}function require_safeGet(){if(di)return hi;return di=1,hi=function safeGet(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function require_copyObject(){if(mi)return yi;mi=1;var e=function require_assignValue(){if(fi)return pi;fi=1;var e=require_baseAssignValue(),t=requireEq(),i=Object.prototype.hasOwnProperty;return pi=function assignValue(n,r,o){var s=n[r];i.call(n,r)&&t(s,o)&&(void 0!==o||r in n)||e(n,r,o)}}(),t=require_baseAssignValue();return yi=function copyObject(i,n,r,o){var s=!r;r||(r={});for(var a=-1,l=n.length;++a<l;){var u=n[a],c=o?o(r[u],i[u],u,r,i):void 0;void 0===c&&(c=i[u]),s?t(r,u,c):e(r,u,c)}return r}}function require_isIndex(){if(vi)return bi;vi=1;var e=/^(?:0|[1-9]\d*)$/;return bi=function isIndex(t,i){var n=typeof t;return!!(i=null==i?9007199254740991:i)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<i}}function require_arrayLikeKeys(){if(wi)return ki;wi=1;var e=function require_baseTimes(){return _i?gi:(_i=1,gi=function baseTimes(e,t){for(var i=-1,n=Array(e);++i<e;)n[i]=t(i);return n})}(),t=requireIsArguments(),i=requireIsArray(),n=requireIsBuffer(),r=require_isIndex(),o=requireIsTypedArray(),s=Object.prototype.hasOwnProperty;return ki=function arrayLikeKeys(a,l){var u=i(a),c=!u&&t(a),h=!u&&!c&&n(a),d=!u&&!c&&!h&&o(a),p=u||c||h||d,f=p?e(a.length,String):[],y=f.length;for(var m in a)!l&&!s.call(a,m)||p&&("length"==m||h&&("offset"==m||"parent"==m)||d&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||r(m,y))||f.push(m);return f}}function require_baseKeysIn(){if(xi)return Ti;xi=1;var e=requireIsObject(),t=require_isPrototype(),i=function require_nativeKeysIn(){return Ci?Si:(Ci=1,Si=function nativeKeysIn(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t})}(),n=Object.prototype.hasOwnProperty;return Ti=function baseKeysIn(r){if(!e(r))return i(r);var o=t(r),s=[];for(var a in r)("constructor"!=a||!o&&n.call(r,a))&&s.push(a);return s}}function requireKeysIn(){if(qi)return Ii;qi=1;var e=require_arrayLikeKeys(),t=require_baseKeysIn(),i=requireIsArrayLike();return Ii=function keysIn(n){return i(n)?e(n,!0):t(n)}}function require_baseMergeDeep(){if($i)return Pi;$i=1;var e=require_assignMergeValue(),t=function require_cloneBuffer(){return _t||(_t=1,e=Jt,t=Jt.exports,i=require_root(),n=t&&!t.nodeType&&t,r=n&&e&&!e.nodeType&&e,o=r&&r.exports===n?i.Buffer:void 0,s=o?o.allocUnsafe:void 0,e.exports=function cloneBuffer(e,t){if(t)return e.slice();var i=e.length,n=s?s(i):new e.constructor(i);return e.copy(n),n}),Jt.exports;var e,t,i,n,r,o,s}(),i=function require_cloneTypedArray(){if(Ct)return St;Ct=1;var e=require_cloneArrayBuffer();return St=function cloneTypedArray(t,i){var n=i?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}(),n=function require_copyArray(){return xt?Tt:(xt=1,Tt=function copyArray(e,t){var i=-1,n=e.length;for(t||(t=Array(n));++i<n;)t[i]=e[i];return t})}(),r=require_initCloneObject(),o=requireIsArguments(),s=requireIsArray(),a=function requireIsArrayLikeObject(){if(Yt)return Xt;Yt=1;var e=requireIsArrayLike(),t=requireIsObjectLike();return Xt=function isArrayLikeObject(i){return t(i)&&e(i)}}(),l=requireIsBuffer(),u=requireIsFunction(),c=requireIsObject(),h=function requireIsPlainObject(){if(ii)return ti;ii=1;var e=require_baseGetTag(),t=require_getPrototype(),i=requireIsObjectLike(),n=Function.prototype,r=Object.prototype,o=n.toString,s=r.hasOwnProperty,a=o.call(Object);return ti=function isPlainObject(n){if(!i(n)||"[object Object]"!=e(n))return!1;var r=t(n);if(null===r)return!0;var l=s.call(r,"constructor")&&r.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==a}}(),d=requireIsTypedArray(),p=require_safeGet(),f=function requireToPlainObject(){if(Ei)return ji;Ei=1;var e=require_copyObject(),t=requireKeysIn();return ji=function toPlainObject(i){return e(i,t(i))}}();return Pi=function baseMergeDeep(y,m,g,_,b,v,k){var w=p(y,g),S=p(m,g),C=k.get(S);if(C)e(y,g,C);else{var T=v?v(w,S,g+"",y,m,k):void 0,x=void 0===T;if(x){var I=s(S),q=!I&&l(S),j=!I&&!q&&d(S);T=S,I||q||j?s(w)?T=w:a(w)?T=n(w):q?(x=!1,T=t(S,!0)):j?(x=!1,T=i(S,!0)):T=[]:h(S)||o(S)?(T=w,o(w)?T=f(w):c(w)&&!u(w)||(T=r(S))):x=!1}x&&(k.set(S,T),b(T,S,_,v,k),k.delete(S)),e(y,g,T)}}}function requireIdentity(){if(Ai)return Di;return Ai=1,Di=function identity(e){return e}}function require_overRest(){if(zi)return Fi;zi=1;var e=function require_apply(){return Bi?Ni:(Bi=1,Ni=function apply(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)})}(),t=Math.max;return Fi=function overRest(i,n,r){return n=t(void 0===n?i.length-1:n,0),function(){for(var o=arguments,s=-1,a=t(o.length-n,0),l=Array(a);++s<a;)l[s]=o[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=o[s];return u[n]=r(l),e(i,this,u)}},Fi}function require_baseSetToString(){if(Wi)return Hi;Wi=1;var e=function requireConstant(){return Ri?Li:(Ri=1,Li=function constant(e){return function(){return e}})}(),t=require_defineProperty(),i=requireIdentity();return Hi=t?function(i,n){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:i}function require_setToString(){if(Ki)return Gi;Ki=1;var e=require_baseSetToString(),t=function require_shortOut(){if(Ui)return Vi;Ui=1;var e=Date.now;return Vi=function shortOut(t){var i=0,n=0;return function(){var r=e(),o=16-(r-n);if(n=r,o>0){if(++i>=800)return arguments[0]}else i=0;return t.apply(void 0,arguments)}},Vi}(),i=t(e);return Gi=i}function require_createAssigner(){if(en)return Zi;en=1;var e=function require_baseRest(){if(Yi)return Xi;Yi=1;var e=requireIdentity(),t=require_overRest(),i=require_setToString();return Xi=function baseRest(n,r){return i(t(n,r,e),n+"")}}(),t=function require_isIterateeCall(){if(Qi)return Ji;Qi=1;var e=requireEq(),t=requireIsArrayLike(),i=require_isIndex(),n=requireIsObject();return Ji=function isIterateeCall(r,o,s){if(!n(s))return!1;var a=typeof o;return!!("number"==a?t(s)&&i(o,s.length):"string"==a&&o in s)&&e(s[o],r)}}();return Zi=function createAssigner(i){return e(function(e,n){var r=-1,o=n.length,s=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(s=i.length>3&&"function"==typeof s?(o--,s):void 0,a&&t(n[0],n[1],a)&&(s=o<3?void 0:s,o=1),e=Object(e);++r<o;){var l=n[r];l&&i(e,l,r,s)}return e})}}var on=function requireMerge(){if(nn)return tn;nn=1;var e=function require_baseMerge(){if(Mi)return Oi;Mi=1;var e=require_Stack(),t=require_assignMergeValue(),i=require_baseFor(),n=require_baseMergeDeep(),r=requireIsObject(),o=requireKeysIn(),s=require_safeGet();return Oi=function baseMerge(a,l,u,c,h){a!==l&&i(l,function(i,o){if(h||(h=new e),r(i))n(a,l,o,u,baseMerge,c,h);else{var d=c?c(s(a,o),i,o+"",a,l,h):void 0;void 0===d&&(d=i),t(a,o,d)}},o)},Oi}(),t=require_createAssigner()(function(t,i,n){e(t,i,n)});return tn=t}(),sn=getDefaultExportFromCjs(on);class Entity extends u{static typeId="ice-entity-designer:Entity";hasDerivedChildren(){return!0}entityFieldsComponent=[];constructor(e){super(Entity.arrangeParam(e)),this.syncEntityNameAndFields()}static arrangeParam(e){const t=sn({entityName:"Entity Name",fields:[],style:{strokeStyle:"#334155",fillStyle:"#ffffff",radius:8,lineWidth:1.5},headerStyle:{textColor:"#0f172a",backgroundColor:"#f1f5f9",fontSize:18,fontWeight:"bold",paddingTop:12,paddingLeft:14,paddingRight:14,paddingBottom:12},fieldStyle:{textColor:"#334155",fontSize:16,fontWeight:"normal",paddingTop:9,paddingLeft:14,paddingRight:14},dividerStyle:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}},e,{transformable:!1});return gt(t.entityName)&&(t.entityName="Entity Name"),gt(t.fields)&&(t.fields=[]),t}syncEntityNameAndFields(){if(this.entityNameComponent&&(this.removeChild(this.entityNameComponent),this.entityNameComponent=null),this.headerBackgroundComponent&&(this.removeChild(this.headerBackgroundComponent),this.headerBackgroundComponent=null),this.deviderLine&&(this.removeChild(this.deviderLine),this.deviderLine=null),this.entityFieldsComponent.length&&(this.removeChildren(this.entityFieldsComponent),this.entityFieldsComponent.length=0),this.state.entityName){if(this.entityNameComponent=new c({left:0,top:0,text:this.state.entityName,style:{strokeStyle:this.state.headerStyle.textColor,fillStyle:this.state.headerStyle.textColor,fontSize:this.state.headerStyle.fontSize,fontWeight:this.state.headerStyle.fontWeight,paddingTop:this.state.headerStyle.paddingTop,paddingLeft:this.state.headerStyle.paddingLeft,paddingRight:this.state.headerStyle.paddingRight,paddingBottom:this.state.headerStyle.paddingBottom},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.state.headerStyle.backgroundColor&&"none"!==this.state.headerStyle.backgroundColor){const e=this.state.style.lineWidth||1.5,t=e/2;this.headerBackgroundComponent=new h({left:t,top:t,width:Math.max(this.state.width-e,0),height:Math.max(this.entityNameComponent.state.height-t,0),zIndex:(Number(this.entityNameComponent.state.zIndex)||0)-1,origin:"top-left",style:{fillStyle:this.state.headerStyle.backgroundColor,radius:Math.max((this.state.style.radius||0)-t,0),lineWidth:0},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.addChild(this.headerBackgroundComponent)}this.addChild(this.entityNameComponent),this.deviderLine=new d({left:0,top:0,points:[[0,0],[this.state.width,0]],style:{strokeStyle:this.state.dividerStyle.strokeStyle,fillStyle:this.state.dividerStyle.fillStyle,lineWidth:this.state.dividerStyle.lineWidth},interactive:!1,linkable:!1}),this.addChild(this.deviderLine)}if(!gt(this.state.fields)){const e=this.state.fields.length;for(let t=0;t<e;t++){const i=this.state.fields[t],n=this.fieldDisplay(i),r=new c({left:0,top:0,text:n.text,style:{strokeStyle:this.state.fieldStyle.textColor,fillStyle:this.state.fieldStyle.textColor,fontSize:this.state.fieldStyle.fontSize,fontWeight:this.state.fieldStyle.fontWeight,paddingTop:this.state.fieldStyle.paddingTop,paddingLeft:this.state.fieldStyle.paddingLeft,paddingRight:this.state.fieldStyle.paddingRight,paddingBottom:t===e-1?12:0},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1});this.entityFieldsComponent.push(r)}this.addChildren(this.entityFieldsComponent)}}fieldDisplay(e){const t=[];e.primary&&t.push("PK"),e.foreignKey&&t.push("FK");const i=[];e.unique&&i.push("UQ"),e.autoIncrement&&i.push("AI"),!1===e.nullable&&i.push("NN");const n=t.length?`${t.join(" ")} `:"",r=e.type?`${e.type}${e.length?`(${e.length})`:""}`:"",o=i.length?` ${i.join(" ")}`:"",s=void 0!==e.default?` = ${e.default}`:"",a=e.comment?` // ${e.comment}`:"";return{text:`${n}${e.name}${r?` ${r}`:""}${o}${s}${a}`}}calcComponentParams(){let e=this.state.width,t=0,i=0,n=0;this.entityNameComponent&&(n=this.entityNameComponent.state.height,t=n,e=Math.max(e,this.entityNameComponent.state.width),t+=this.deviderLine.state.height,i=t);for(let i=0;i<this.entityFieldsComponent.length;i++){const n=this.entityFieldsComponent[i];n.state.left=0,n.state.top=t,t+=n.state.height,e=Math.max(e,n.state.width)}if(this.deviderLine&&(this.deviderLine.state.points=[[0,i],[e,i]]),this.headerBackgroundComponent){const t=this.state.style.lineWidth||1.5,i=t/2;this.headerBackgroundComponent.state.left=i,this.headerBackgroundComponent.state.top=i,this.headerBackgroundComponent.state.width=Math.max(e-t,0),this.headerBackgroundComponent.state.height=Math.max(n-i,0)}const r=e,o=Math.max(t,this.state.height);return this.state.width=r,this.state.height=o,{width:r,height:o}}toEntityObject(){const e={name:this.state.entityName,columns:{}};return this.state.fields.forEach(t=>{const i={};void 0!==t.type&&(i.type=t.type),void 0!==t.length&&(i.length=t.length),t.primary&&(i.primary=!0),t.generated&&(i.generated=!0),t.autoIncrement&&(i.generated=!0,i.strategy="increment"),!1===t.nullable&&(i.nullable=!1),t.unique&&(i.unique=!0),void 0!==t.default&&(i.default=t.default),void 0!==t.comment&&(i.comment=t.comment),t.index&&(i.index=!0),e.columns[t.name]=i}),e}setState(e){const t=!gt(e.fields)||!gt(e.entityName);super.setState(e),t&&this.syncEntityNameAndFields()}addField(e){const t=[...this.state.fields||[],e];return this.setFields(t),this}removeField(e){const t=(this.state.fields||[]).filter(t=>t.name!==e);return this.setFields(t),this}setFields(e){return this.setState({fields:e}),this}}class Relation extends p{static typeId="ice-entity-designer:Relation";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Relation.normalizeLinks(e||{}),i=t.relationType||"one-to-one",n=Relation.composeLabel(t,i);super({title:"Relation",transformable:!1,relationType:i,referencedColumnName:"id",sourceField:"id",targetField:"id",arrow:t.arrow||Relation.defaultArrow(i),...t,label:n,style:{...t.style||{},label:{fontSize:14,fillStyle:"#334155",backgroundColor:"#ffffff",...t.labelStyle||{},...(t.style||{}).label||{}}}})}static defaultArrow(e){switch(e){case"one-to-many":return"end";case"many-to-one":return"start";default:return"none"}}static normalizeLinks(e){if(!e||!e.links)return e||{};const t={top:"T",right:"R",bottom:"B",left:"L",center:"C"},i={...e.links};return i.start&&t[i.start.position]&&(i.start={...i.start,position:t[i.start.position]}),i.end&&t[i.end.position]&&(i.end={...i.end,position:t[i.end.position]}),{...e,links:i}}static cardinalityLabel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={"one-to-many":["1","N"],"many-to-one":["N","1"],"many-to-many":["N","N"],"one-to-one":["1","1"]},[n,r]=i[e]||i["one-to-one"];return`${t.sourceCardinality||n} : ${t.targetCardinality||r}`}static composeLabel(e,t){return e.label?e.label:Relation.buildLabel(e,t)}static buildLabel(e,t){const i=[];e.onDelete&&i.push(`ON DELETE ${e.onDelete}`),e.onUpdate&&i.push(`ON UPDATE ${e.onUpdate}`);const n=Relation.cardinalityLabel(t,e);return i.length?`${n} (${i.join(", ")})`:n}toEntityObject(){const{title:e,relationType:t,referencedColumnName:i,sourceField:n,targetField:r,nullable:o,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}=this.state;let h,d,p,f,y,m;this.state.links&&this.state.links.start&&this.state.links.start.id&&(p=this.state.links.start.id,h=this.ice.findComponent(p),f=h.state.entityName),this.state.links&&this.state.links.end&&this.state.links.end.id&&(y=this.state.links.end.id,d=this.ice.findComponent(y),m=d.state.entityName);return{title:e,fromId:p,fromName:f,toId:y,toName:m,relationType:t,referencedColumnName:i,sourceField:n,targetField:r,nullable:!1!==o&&void 0,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}}}function designerChromeFromTheme(e){const t=e&&e.semantic||{},i=t.primary||"#0D6EFD",n=t.success||"#198754",r=t.warning||"#FFC107";return{selection:{stroke:i,fill:withAlpha(i,.12),lineWidth:1,lineDash:[]},handle:{fill:i,stroke:"#ffffff",activeFill:r,lineWidth:1},linkHook:{fill:n,stroke:"#ffffff",lineWidth:1},slot:{fill:n,stroke:"#ffffff",hoverFill:r,lineWidth:1},guide:{color:i,lineWidth:1},textSelection:{color:withAlpha(i,.28)}}}function applyDesignerChrome(e){if(!e)return e;if("function"!=typeof e.setThemePatch&&"function"!=typeof e.setChrome)return e;const t=designerChromeFromTheme("function"==typeof e.getTheme?e.getTheme():null);return"function"==typeof e.setThemePatch?(e.setThemePatch("ice-designer",{semantic:{chrome:t}}),function subscribeDesignerChrome(e){if(e.__designerChromeSubscribed||"function"!=typeof e.onThemeChange)return;e.__designerChromeSubscribed=!0,e.onThemeChange(t=>{if(t&&"theme"!==t.kind)return;const i="function"==typeof e.getTheme?e.getTheme():null;e.setThemePatch("ice-designer",{semantic:{chrome:designerChromeFromTheme(i)}})})}(e)):e.setChrome(t),e}function withAlpha(e,t){if("string"!=typeof e)return e;const i=e.trim();if("#"===i.charAt(0)){let e=i.slice(1);if(3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),6!==e.length)return i;return`rgba(${parseInt(e.slice(0,2),16)},${parseInt(e.slice(2,4),16)},${parseInt(e.slice(4,6),16)},${t})`}return 0===i.indexOf("rgb(")?i.replace("rgb(","rgba(").replace(")",`,${t})`):i}const an=["T","R","B","L"],ln={T:[0,-1],R:[1,0],B:[0,1],L:[-1,0]};function boxOf(e){if(!e||"function"!=typeof e.getMaxBoundingBox)return null;const t=e.getMaxBoundingBox(!0).getMinAndMaxPoint();return{minX:t.minX,minY:t.minY,maxX:t.maxX,maxY:t.maxY}}function centerOf(e){return[(e.minX+e.maxX)/2,(e.minY+e.maxY)/2]}function portPoint(e,t){const[i,n]=centerOf(e);return"T"===t?[i,e.minY]:"B"===t?[i,e.maxY]:"L"===t?[e.minX,n]:[e.maxX,n]}function autoPorts(e,t,i){const n=boxOf(e),r=boxOf(t);if(!n||!r)return{...i};const o=centerOf(n),s=centerOf(r);let a={...i},l=1/0;for(const e of an){const t=portPoint(n,e),i=ln[e],u=(s[0]-t[0])*i[0]+(s[1]-t[1])*i[1]>=0;for(const n of an){const s=portPoint(r,n),c=ln[n],h=(u?0:1e6)+((o[0]-s[0])*c[0]+(o[1]-s[1])*c[1]>=0?0:1e6)+((s[0]-t[0])*i[0]+(s[1]-t[1])*i[1]>=0&&(t[0]-s[0])*c[0]+(t[1]-s[1])*c[1]>=0?0:1e6)+Math.hypot(t[0]-s[0],t[1]-s[1]);h<l&&(l=h,a={sourcePort:e,targetPort:n})}}return a}function enableDesignerAlignmentGuides(e){return e&&e.alignmentGuide&&"function"==typeof e.alignmentGuide.enable?(e.alignmentGuide.enable({threshold:2}),e):e}function typeIdOf(e){const t=e&&e.constructor;return t&&"string"==typeof t.typeId?t.typeId:void 0}function isEntity(e){return typeIdOf(e)===Entity.typeId}function isRelation(e){return typeIdOf(e)===Relation.typeId}const un="data",cn=[{key:"display",type:"boolean"},{key:"zIndex",type:"any"},{key:"opacity",type:"number",doc:"子树不透明度(引擎 1.3 起)"},{key:"transform",type:"object"},{key:"origin",type:"string"},{key:"originX",type:"number"},{key:"originY",type:"number"},{key:"lineDash",type:"array"},{key:"lineDashOffset",type:"number"},{key:"lineDashFlow",type:"boolean"},{key:"lineDashFlowSpeed",type:"number"},{key:"lineBorder",type:"boolean"},{key:"lineBorderWidth",type:"number"},{key:"lineBorderColor",type:"string"},{key:"fill",type:"boolean"},{key:"stroke",type:"boolean"},{key:"linkable",type:"boolean"},{key:"linkEditable",type:"boolean"},{key:"transformable",type:"boolean"},{key:"animations",type:"object"}],hn=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"relationType",type:"string"},{key:"referencedColumnName",type:"string"},{key:"sourceField",type:"string"},{key:"targetField",type:"string"},{key:"nullable",type:"boolean"},{key:"onDelete",type:"string"},{key:"onUpdate",type:"string"},{key:"joinTableName",type:"string"},{key:"fromKey",type:"string"},{key:"toKey",type:"string"},{key:"sourceCardinality",type:"string"},{key:"targetCardinality",type:"string"},{key:"label",type:"string"},{key:"style.label",type:"object",doc:"标签外观(引擎 2.4 起归到 style.label)"},{key:"style",type:"object"},{key:"arrow",type:"string"},{key:"lineType",type:"string"},{key:"escapeDistance",type:"number"},{key:"routeType",type:"string"},{key:"routeOffset",type:"number"},{key:"curveType",type:"string"},{key:"linkShape",type:"string",doc:"连线形态(visio/bezier)"},{key:"lineDash",type:"array"},{key:"lineWidth",type:"number"},{key:"arrowLength",type:"number"},{key:"arrowAngel",type:"number"},{key:"arrowStyle",type:"string"},{key:"startPoint",type:"array"},{key:"endPoint",type:"array"},{key:"links",type:"object",validate:function validateLinks(e,t,i){["start","end"].forEach(n=>{const r=e[n];void 0!==r&&(r&&"object"==typeof r&&!Array.isArray(r)?(void 0!==r.id&&"string"!=typeof r.id&&i.push(`${t}.${n}.id must be a string when present`),void 0!==r.position&&"string"!=typeof r.position&&i.push(`${t}.${n}.position must be a string when present`)):i.push(`${t}.${n} must be an object when present`))})}},{key:"sourceId",type:"string",doc:"连线起点宿主 id(与 links.start.id 同步)"},{key:"targetId",type:"string",doc:"连线终点宿主 id(与 links.end.id 同步)"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],dn=[...[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"entityName",type:"string",required:!0},{key:"fields",type:"array",validate:function validateFields(e,t,i){e.forEach((e,n)=>{e&&"object"==typeof e&&!Array.isArray(e)?void 0!==e.name&&"string"!=typeof e.name&&i.push(`${t}[${n}].name must be a string when present`):i.push(`${t}[${n}] must be an object`)})}},{key:"style",type:"object"},{key:"headerStyle",type:"object"},{key:"fieldStyle",type:"object"},{key:"dividerStyle",type:"object"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],...cn],pn=[...hn,...cn];function pickDocumentNode(e,t){const i={};t.forEach(t=>{const n=e?e[t.key]:void 0;void 0!==n&&(i[t.key]=n)});const n=e?e[un]:void 0;return void 0!==n&&(i[un]=n),i}function validateDocumentNode(e,t,i,n){e&&"object"==typeof e&&!Array.isArray(e)?i.forEach(i=>{const r=e[i.key];void 0!==r?!function typeMatches(e,t){switch(t){case void 0:case"any":return!0;case"array":return Array.isArray(e);case"object":return!!e&&"object"==typeof e&&!Array.isArray(e);case"number":return"number"==typeof e;case"boolean":return"boolean"==typeof e;default:return"string"==typeof e}}(r,i.type)?n.push(`${t}.${i.key} must be a ${i.type} when present`):i.validate&&i.validate(r,`${t}.${i.key}`,n):i.required&&n.push(`${t}.${i.key} is required`)}):n.push(`${t} must be an object`)}const fn=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"}];function validateNode(e,t,i,n){if(!e||"object"!=typeof e||Array.isArray(e))return void n.push(`${t} must be an object`);const r=void 0===e.typeId?i:e.typeId;!function isEntityTypeId(e){return e===Entity.typeId}(r)?!function isRelationTypeId(e){return e===Relation.typeId}(r)?validateDocumentNode(e,t,fn,n):validateDocumentNode(e,t,pn,n):validateDocumentNode(e,t,dn,n)}function validateSchema(e){const t=[],i=e.filter(isEntity),n=e.filter(isRelation),r=new Map;return i.forEach(e=>{const i=(e.state.entityName||"").trim();if(!i)return void t.push({level:"error",message:"存在未命名的 Entity",componentId:e.state.id});r.has(i)||r.set(i,[]),r.get(i).push(e);const n=e.state.fields||[];0===n.length&&t.push({level:"warning",message:`Entity "${i}" 没有任何字段`,componentId:e.state.id});const o=new Set;n.forEach(n=>{const r=(n.name||"").trim();r?o.has(r)?t.push({level:"error",message:`Entity "${i}" 存在重复字段 "${r}"`,componentId:e.state.id}):o.add(r):t.push({level:"error",message:`Entity "${i}" 存在未命名字段`,componentId:e.state.id}),n.type||t.push({level:"warning",message:`Entity "${i}" 的字段 "${r||"(未命名)"}" 未设置类型`,componentId:e.state.id})})}),r.forEach((e,i)=>{e.length>1&&t.push({level:"error",message:`存在重复的 Entity 名称 "${i}"`})}),n.forEach(e=>{const n=e.state.links||{},r=n.start&&n.start.id,o=n.end&&n.end.id,s=e.state.relationType;if(!r||!o)return void t.push({level:"error",message:"存在没有完整起点/终点的 Relation",componentId:e.state.id});const a=i.some(e=>e.state.id===r),l=i.some(e=>e.state.id===o);a&&l||t.push({level:"error",message:"Relation 连接到了不存在的 Entity",componentId:e.state.id}),s?"many-to-many"!==s||e.state.joinTableName||t.push({level:"warning",message:"many-to-many 关系建议设置 joinTableName",componentId:e.state.id}):t.push({level:"error",message:"Relation 未设置关系类型",componentId:e.state.id})}),t}function toWords(e){return function convertToString(e){const t=e||"";return"string"==typeof t?t:String(t)}(e).match(/[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g)||[]}function camelCase(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function toCamelCase(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i="";for(let n=0,r=e.length;n<r;n++){let r=e[n].toLowerCase();(t||0!==n)&&(r=r.substr(0,1).toUpperCase()+r.substr(1)),i+=r}return i}(toWords(e),t)}var yn=[],mn=[],gn={},_n={},bn={};function sanitizeRule(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function restoreCase(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function replace(e,t){return e.replace(t[0],function(i,n){var r=function interpolate(e,t){return e.replace(/\$(\d{1,2})/g,function(e,i){return t[i]||""})}(t[1],arguments);return restoreCase(""===i?e[n-1]:i,r)})}function sanitizeWord(e,t,i){if(!e.length||gn.hasOwnProperty(e))return t;for(var n=i.length;n--;){var r=i[n];if(r[0].test(t))return replace(t,r)}return t}function replaceWord(e,t,i){return function(n){var r=n.toLowerCase();return t.hasOwnProperty(r)?restoreCase(n,r):e.hasOwnProperty(r)?restoreCase(n,e[r]):sanitizeWord(r,n,i)}}function checkWord(e,t,i){return function(n){var r=n.toLowerCase();return!!t.hasOwnProperty(r)||!e.hasOwnProperty(r)&&sanitizeWord(r,r,i)===r}}function pluralize(e,t,i){return(i?t+" ":"")+(1===t?pluralize.singular(e):pluralize.plural(e))}pluralize.plural=replaceWord(bn,_n,yn),pluralize.isPlural=checkWord(bn,_n,yn),pluralize.singular=replaceWord(_n,bn,mn),pluralize.isSingular=checkWord(_n,bn,mn),pluralize.addPluralRule=function(e,t){yn.push([sanitizeRule(e),t])},pluralize.addSingularRule=function(e,t){mn.push([sanitizeRule(e),t])},pluralize.addUncountableRule=function(e){"string"!=typeof e?(pluralize.addPluralRule(e,"$0"),pluralize.addSingularRule(e,"$0")):gn[e.toLowerCase()]=!0},pluralize.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),bn[e]=t,_n[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(e){return pluralize.addIrregularRule(e[0],e[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(e){return pluralize.addPluralRule(e[0],e[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(e){return pluralize.addSingularRule(e[0],e[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(pluralize.addUncountableRule);const vn={number:"int",int:"int",integer:"int",smallint:"smallint",bigint:"bigint",float:"float",double:"double",real:"real",decimal:"decimal",numeric:"numeric",string:"varchar",varchar:"varchar",char:"char",text:"text",boolean:"boolean",bool:"boolean",date:"date",datetime:"datetime",timestamp:"timestamp",time:"time",json:"json",jsonb:"jsonb",uuid:"uuid",enum:"enum",blob:"blob",binary:"blob","simple-array":"simple-array","simple-json":"simple-json"},kn=["varchar","char","nvarchar","nchar","text","uuid"];function normalizeColumn(e){const t={},i=function mapColumnType(e){if(null==e||""===e)return;const t=String(e).toLowerCase();return vn[t]||String(e)}(e.type);if(void 0!==i&&(t.type=i),void 0!==e.length&&null!==e.length&&""!==e.length){const n=String(e.length).trim();if("decimal"===i||"numeric"===i){const[e,i]=n.split(",").map(e=>e.trim());e&&(t.precision=Number(e)),i&&(t.scale=Number(i))}else i&&kn.indexOf(i)>=0&&(t.length=e.length)}return e.primary&&(t.primary=!0),e.generated&&(t.generated=!0),e.autoIncrement&&(t.generated=!0,t.strategy="increment"),void 0!==e.strategy&&(t.strategy=e.strategy),!1===e.nullable&&(t.nullable=!1),e.unique&&(t.unique=!0),void 0!==e.default&&(t.default=e.default),void 0!==e.comment&&(t.comment=e.comment),e.index&&(t.index=!0),t}function normalizeColumns(e){const t={};return Object.keys(e||{}).forEach(i=>{t[i]=normalizeColumn(e[i])}),t}function buildJoinColumn(e,t){return{name:e||t||"id",referencedColumnName:t||"id"}}function toSchemaObject(e){const t=[...e],i=[],n={};for(let e=0;e<t.length;e++){const r=t[e];if(isRelation(r))i.push(r);else if(isEntity(r)){const e=r.toEntityObject();e.columns=normalizeColumns(e.columns),n[r.state.id]=e}}for(let e=0;e<i.length;e++){const t=i[e],{fromId:r,fromName:o,toId:s,toName:a,relationType:l,referencedColumnName:u,sourceField:c,targetField:h,nullable:d,onDelete:p,onUpdate:f,joinTableName:y,fromKey:m,toKey:g}=t.toEntityObject(),_=n[r],b=n[s];if(!_||!b)continue;_.relations||(_.relations={}),b.relations||(b.relations={});const v=m||camelCase(a),k=g||camelCase(o),w={};!1===d&&(w.nullable=!1),p&&(w.onDelete=p),f&&(w.onUpdate=f),"one-to-one"===l?(b.relations[k]={type:l,target:o,joinColumn:buildJoinColumn(h||u,c||u),...w},_.relations[v]={type:l,target:a,inverseSide:k}):"one-to-many"===l?(_.relations[v]={type:l,target:a,inverseSide:k},b.relations[k]={type:"many-to-one",target:o,joinColumn:buildJoinColumn(h||u,c||u),...w}):"many-to-one"===l?(_.relations[v]={type:l,target:a,joinColumn:buildJoinColumn(c||u,h||u),...w},b.relations[k]={type:"one-to-many",target:o,inverseSide:v}):"many-to-many"===l&&(_.relations[`${pluralize(v)}`]={type:l,target:a,joinTable:!y||{name:y}},b.relations[`${pluralize(k)}`]={type:l,target:o,inverseSide:`${pluralize(v)}`})}const r=[];for(const e in n)r.push(n[e]);return r}function toSchemaString(e){return JSON.stringify(toSchemaObject(e))}function registerIEDType(e,t){e.registerType(t.typeId,t)}class EntityDesigner{selectedId=null;__changeListeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;constructor(e){this.ice=e,applyDesignerChrome(this.ice),enableDesignerAlignmentGuides(this.ice),registerIEDType(this.ice,Entity),registerIEDType(this.ice,Relation),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this)}get entities(){return this.ice.childNodes.filter(e=>isEntity(e))}get relations(){return this.ice.childNodes.filter(e=>isRelation(e))}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}select(e){return this.selectedId=e,this}createEntity(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=this.entities.length,i=new Entity({left:120+t%4*220,top:120+260*Math.floor(t/4),entityName:"NewEntity",fields:[],...e});return this.ice.addChild(i),this.select(i.state.id),this.__emitChange(),i}createRelation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=e.sourceId||e.fromId||e.links&&e.links.start&&e.links.start.id,i=e.targetId||e.toId||e.links&&e.links.end&&e.links.end.id,n=t?this.ice.findComponent(t):null,r=i?this.ice.findComponent(i):null,o=autoPorts(n,r,{sourcePort:"R",targetPort:"L"}),s=e.links&&e.links.start&&e.links.start.position||e.startPosition||o.sourcePort,a=e.links&&e.links.end&&e.links.end.position||e.endPosition||o.targetPort,l=e.links||{start:{id:t,position:s},end:{id:i,position:a}},u=n?this.__slotPoint(n,s):null,c=r?this.__slotPoint(r,a):null,h=new Relation({relationType:e.relationType||"one-to-many",sourceField:e.sourceField||"id",targetField:e.targetField||"id",links:l,startPoint:u||[0,0],endPoint:c||[10,10],...e});return this.ice.addChild(h),this.select(h.state.id),this.__emitChange(),h}updateEntity(e,t){const i=this.ice.findComponent(e);return isEntity(i)&&(this.captureHistory(),i.setState(t),this.__emitChange()),i}updateRelation(e,t){const i=this.ice.findComponent(e);if(isRelation(i)){this.captureHistory();const e={...i.state,...t},n=Relation.buildLabel(e,e.relationType||"one-to-one");i.setState({...t,label:n}),this.__emitChange()}return i}removeComponent(e){const t=this.ice.findComponent(e);if(t){if(this.captureHistory(),isEntity(t)){this.relations.filter(t=>{const i=t.state.links||{};return i.start&&i.start.id===e||i.end&&i.end.id===e}).forEach(e=>this.ice.removeChild(e))}this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange()}}bringToFront(e){return this.__reorder(e,"front")}sendToBack(e){return this.__reorder(e,"back")}moveUp(e){return this.__reorder(e,"up")}moveDown(e){return this.__reorder(e,"down")}__reorder(e,t){const i=e?this.ice.findComponent(e):this.selected;if(!i||"function"!=typeof i.bringToFront)return!1;const n=i.parentNode&&Array.isArray(i.parentNode.childNodes)?i.parentNode.childNodes:this.ice.childNodes;if(!Array.isArray(n)||n.length<2)return!1;const r=this.serializeProject(),o=n.map(e=>e.state.zIndex);"front"===t?i.bringToFront():"back"===t?i.sendToBack():"up"===t?i.moveUp():i.moveDown();const s=n.map(e=>e.state.zIndex);return!(o.length===s.length&&!o.some((e,t)=>e!==s[t]))&&(this.__pushHistory(r),this.__emitChange(),!0)}toSchemaObject(){return toSchemaObject(this.ice.childNodes)}toSchemaString(){return toSchemaString(this.ice.childNodes)}validate(){return validateSchema(this.ice.childNodes)}serializeProject(){const e={version:1,schemaVersion:1,createTime:f(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime)||this.__rememberCreateTime(void 0),entities:this.entities.map(e=>this.__entitySnapshot(e)),relations:this.relations.map(e=>this.__relationSnapshot(e))};return JSON.stringify(e)}__rememberCreateTime(e){const t=this.ice;t&&"object"==typeof t&&(t.documentMeta&&"object"==typeof t.documentMeta||(t.documentMeta={}));const i=f(e);if(i)return t&&t.documentMeta&&(t.documentMeta.createTime=i),i;const n=(new Date).toISOString();return t&&t.documentMeta&&(t.documentMeta.createTime=n),n}loadProject(e){if(!e)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};const t=this.__parseProject(e);if(!t)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};this.captureHistory();const i=this.__applySnapshot(t);return this.__emitChange(),i}__entitySnapshot(e){return pickDocumentNode({...e.state||{},typeId:Entity.typeId},dn)}__slotPoint(e,t){const i=e.getMinBoundingBox(!0),n=i.center[0],r=i.center[1];switch(t){case"T":return[n,i.tl[1]];case"B":return[n,i.br[1]];case"L":return[i.tl[0],r];case"R":return[i.tr[0],r];default:return[n,r]}}__relationSnapshot(e){return pickDocumentNode({...e.state||{},typeId:Relation.typeId},pn)}__parseProject(e){const t=JSON.parse(e);if(!t||!Array.isArray(t.entities))return null;if(void 0!==t.schemaVersion&&1!==t.schemaVersion)throw new Error(`Unsupported project schemaVersion: ${t.schemaVersion}`);const i=function validateProjectSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:(void 0!==e.schemaVersion&&"number"!=typeof e.schemaVersion&&t.push("schemaVersion must be a number when present"),void 0!==e.createTime&&"string"!=typeof e.createTime&&t.push("createTime must be a string when present"),Array.isArray(e.entities)?e.entities.forEach((e,i)=>{validateNode(e,`entities[${i}]`,Entity.typeId,t)}):t.push("entities must be an array"),void 0===e.relations||Array.isArray(e.relations)?Array.isArray(e.relations)&&e.relations.forEach((e,i)=>{validateNode(e,`relations[${i}]`,Relation.typeId,t)}):t.push("relations must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!i.valid)throw new Error(`Invalid project snapshot:\n${i.errors.join("\n")}`);return t}__applyProject(e){const t=this.__parseProject(e);t&&this.__applySnapshot(t)}__resolveTypeId(e,t){return e&&"string"==typeof e.typeId&&e.typeId?e.typeId:"entities"===t?Entity.typeId:Relation.typeId}__resolveComponentClass(e){const t=this.ice;if("function"==typeof t.getType){const i=t.getType(e);if("function"==typeof i)return i}else if(t.typeMapping&&"function"==typeof t.typeMapping[e])return t.typeMapping[e];return e===Entity.typeId?Entity:e===Relation.typeId?Relation:null}__recordUnknownType(e,t,i,n,r){-1===e.unknownTypes.indexOf(n)&&e.unknownTypes.push(n);const o=r&&"string"==typeof r.id?r.id:void 0;e.skipped.push(void 0===o?{bucket:t,index:i,typeId:n}:{bucket:t,index:i,typeId:n,id:o})}__applySnapshot(e){const t=this.ice.renderer;t&&t.stop();const i={loaded:!0,entities:0,relations:0,unknownTypes:[],skipped:[]};try{this.ice.clearAll(),this.__rememberCreateTime(e&&e.createTime),this.ice.ctx&&"function"==typeof this.ice.ctx.clearRect&&(this.ice.ctx.setTransform(1,0,0,1,0,0),this.ice.ctx.clearRect(0,0,this.ice.canvasWidth||0,this.ice.canvasHeight||0));const createNode=(e,t,n)=>{const r=this.__resolveTypeId(e,t),o=this.__resolveComponentClass(r);if("function"!=typeof o)return this.__recordUnknownType(i,t,n,r,e),null;const s=new o(e);return delete s.state.typeId,delete s.props.typeId,this.ice.addChild(s),s},collect=(e,t,n)=>{const r=createNode(e,t,n);isEntity(r)?i.entities+=1:isRelation(r)&&(i.relations+=1)};e.entities.forEach((e,t)=>collect(e,"entities",t)),(e.relations||[]).forEach((e,t)=>collect(e,"relations",t)),this.selectedId=null}finally{if(t){const e=t.getRenderMode();t.setRenderMode("full"),t.start(),this.ice.dirty=!0,setTimeout(()=>{t.setRenderMode(e)},50)}}return i}__applyHistorySnapshot(e){this.__historyEnabled=!1;try{this.__applyProject(e),this.selectedId=null}finally{this.__historyEnabled=!0}}canUndo(){return this.__undoStack.length>0}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__historyEnabled&&this.__pushHistory(this.serializeProject())}__pushHistory(e){this.__historyEnabled&&(this.__undoStack.push(e),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}undo(){if(!this.canUndo())return;const e=this.serializeProject(),t=this.__undoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__undoStack.push(t),e}this.__redoStack.push(e),this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serializeProject(),t=this.__redoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__redoStack.push(t),e}this.__undoStack.push(e),this.__emitChange()}subscribe(e){return"function"!=typeof e?()=>{}:(this.__changeListeners.push(e),()=>{const t=this.__changeListeners.indexOf(e);-1!==t&&this.__changeListeners.splice(t,1)})}__emitChange(){if(!this.__changeListeners.length)return;const e=this.serializeProject();this.__changeListeners.slice().forEach(t=>t(e))}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this)}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let i=t;for(;i.parentNode;)i=i.parentNode;(isEntity(i)||isRelation(i))&&this.select(i.state.id)}}function createEmptyPath$1(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function createEmptyPath(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function localBox(e){return{w:e.state.width,h:e.state.height,x:0-e.state.localOrigin[0],y:0-e.state.localOrigin[1]}}class BpmnTaskIcon extends y{static typeId="ice-entity-designer:BpmnTaskIcon";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=i+e/2,s=n+t/2,a=Math.min(e,t)/2,l=this.state.taskType||"none";if("user"===l)r.moveTo(o,s-a),r.arc(o,s-.35*a,.34*a,0,2*Math.PI),r.moveTo(o-.62*a,s+.72*a),r.arc(o,s+.72*a,.62*a,Math.PI,0);else if("service"===l){const e=8;for(let t=0;t<e;t++){const i=t*Math.PI*2/e,n=o+Math.cos(i)*a*.55,l=s+Math.sin(i)*a*.55,u=o+Math.cos(i)*a,c=s+Math.sin(i)*a;r.moveTo(n,l),r.lineTo(u,c)}r.moveTo(o+.34*a,s),r.arc(o,s,.34*a,0,2*Math.PI)}else"script"===l?(r.moveTo(o-.7*a,s-.85*a),r.lineTo(o+.7*a,s-.85*a),r.lineTo(o+.7*a,s+.5*a),r.moveTo(o-.7*a,s-.85*a),r.lineTo(o-.7*a,s+.5*a),r.moveTo(o-.7*a,s+.6*a),r.lineTo(o-.25*a,s+.85*a),r.lineTo(o+.25*a,s+.6*a),r.lineTo(o+.7*a,s+.85*a)):"send"===l?(r.moveTo(o-.85*a,s-.55*a),r.lineTo(o+.85*a,s-.55*a),r.lineTo(o+.85*a,s+.55*a),r.lineTo(o-.85*a,s+.55*a),r.closePath(),r.moveTo(o-.85*a,s-.55*a),r.lineTo(o,s+.12*a),r.lineTo(o+.85*a,s-.55*a)):"receive"===l?(r.moveTo(o-.85*a,s-.55*a),r.lineTo(o+.85*a,s-.55*a),r.lineTo(o+.85*a,s+.55*a),r.lineTo(o-.85*a,s+.55*a),r.closePath()):"manual"===l&&(r.moveTo(o-.7*a,s+.6*a),r.lineTo(o-.45*a,s-.5*a),r.lineTo(o+.45*a,s-.5*a),r.lineTo(o+.7*a,s+.6*a),r.closePath());return this.path2D=r,this.path2D}}class BpmnSubprocessMarker extends y{static typeId="ice-entity-designer:BpmnSubprocessMarker";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);return r?(r.moveTo(i,n),r.lineTo(i+e,n),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),r.moveTo(i+e/2,n+.22*t),r.lineTo(i+e/2,n+.78*t),r.moveTo(i+.22*e,n+t/2),r.lineTo(i+.78*e,n+t/2),this.path2D=r,this.path2D):this.path2D}}const wn={terminator:{label:"开始 / 结束",width:180,height:60,fill:"#dcfce7",stroke:"#16a34a",radius:30,shape:"rect"},process:{label:"处理",width:220,height:80,fill:"#e0e7ff",stroke:"#4f46e5",radius:10,shape:"rect"},decision:{label:"判定",width:200,height:120,fill:"#fef3c7",stroke:"#d97706",shape:"diamond"},io:{label:"输入 / 输出",width:220,height:80,fill:"#e0f2fe",stroke:"#0284c7",shape:"parallelogram"},bpmnEvent:{label:"事件",width:56,height:56,fill:"#ffffff",stroke:"#475569",shape:"event",lineWidth:1.4,eventKind:"start",trigger:"none",labelPlacement:"top-left"},bpmnTask:{label:"任务",width:180,height:90,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",taskType:"none",labelPlacement:"center"},bpmnGateway:{label:"网关",width:70,height:70,fill:"#ffffff",stroke:"#64748b",shape:"gateway",gatewayType:"exclusive",labelPlacement:"top-left"},bpmnSubprocess:{label:"子流程",width:200,height:110,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",labelPlacement:"center"},bpmnDataObject:{label:"数据对象",width:130,height:80,fill:"#ffffff",stroke:"#64748b",shape:"dataObject",labelPlacement:"center"},bpmnAnnotation:{label:"注释",width:200,height:80,fill:"#ffffff",stroke:"#64748b",shape:"annotation",lineDash:[],labelPlacement:"center"},bpmnPool:{label:"池",width:900,height:260,fill:"#f8fafc",stroke:"#94a3b8",shape:"lane",band:"top",bandSize:32,labelPlacement:"top-left"},bpmnLane:{label:"泳道",width:900,height:130,fill:"#ffffff",stroke:"#cbd5e1",shape:"lane",band:"left",bandSize:32,labelPlacement:"top-left",transparent:!0}},Sn=["bpmnPool","bpmnLane","bpmnAnnotation","bpmnDataObject"],Cn={rect:h,diamond:class FlowDiamond extends y{static typeId="ice-entity-designer:FlowDiamond";createPathObject(){const e=this.state.width,t=this.state.height,i=0-this.state.localOrigin[0],n=0-this.state.localOrigin[1],r=createEmptyPath$1(this);return r?(r.moveTo(i+e/2,n),r.lineTo(i+e,n+t/2),r.lineTo(i+e/2,n+t),r.lineTo(i,n+t/2),r.closePath(),this.path2D=r,this.path2D):this.path2D}},parallelogram:class FlowParallelogram extends y{static typeId="ice-entity-designer:FlowParallelogram";createPathObject(){const e=this.state.width,t=this.state.height,i=Math.min(28,.18*e),n=0-this.state.localOrigin[0],r=0-this.state.localOrigin[1],o=createEmptyPath$1(this);return o?(o.moveTo(n+i,r),o.lineTo(n+e,r),o.lineTo(n+e-i,r+t),o.lineTo(n,r+t),o.closePath(),this.path2D=o,this.path2D):this.path2D}},event:class BpmnEventShape extends y{static typeId="ice-entity-designer:BpmnEventShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=i+e/2,s=n+t/2,a=Math.min(e,t)/2,l=this.state.eventKind||"start";r.arc(o,s,a,0,2*Math.PI),"intermediate"!==l&&"end"!==l||(r.moveTo(o+.84*a,s),r.arc(o,s,.84*a,0,2*Math.PI));const u=this.state.trigger||"none";if("message"===u){const e=1.1*a,t=.78*a;r.moveTo(o-e/2,s-t/2),r.lineTo(o+e/2,s-t/2),r.lineTo(o+e/2,s+t/2),r.lineTo(o-e/2,s+t/2),r.closePath(),r.moveTo(o-e/2,s-t/2),r.lineTo(o,s+.08*t),r.lineTo(o+e/2,s-t/2)}else if("timer"===u){const e=.52*a;r.moveTo(o+e,s),r.arc(o,s,e,0,2*Math.PI),r.moveTo(o,s),r.lineTo(o,s-.62*e),r.moveTo(o,s),r.lineTo(o+.5*e,s)}else"error"===u?(r.moveTo(o+.34*a,s-.62*a),r.lineTo(o-.42*a,s+.06*a),r.lineTo(o-.02*a,s+.06*a),r.lineTo(o-.3*a,s+.66*a),r.lineTo(o+.44*a,s-.02*a),r.lineTo(o+.04*a,s-.02*a),r.closePath()):"terminate"===u&&(r.moveTo(o+.5*a,s),r.arc(o,s,.5*a,0,2*Math.PI));return this.path2D=r,this.path2D}},gateway:class BpmnGatewayShape extends y{static typeId="ice-entity-designer:BpmnGatewayShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=i+e/2,s=n+t/2,a=e/2,l=t/2;r.moveTo(o,s-l),r.lineTo(o+a,s),r.lineTo(o,s+l),r.lineTo(o-a,s),r.closePath();const u=this.state.gatewayType||"exclusive",c=.42*Math.min(a,l);if("exclusive"===u)r.moveTo(o-c,s-c),r.lineTo(o+c,s+c),r.moveTo(o+c,s-c),r.lineTo(o-c,s+c);else if("parallel"===u)r.moveTo(o-c,s),r.lineTo(o+c,s),r.moveTo(o,s-c),r.lineTo(o,s+c);else if("inclusive"===u)r.moveTo(o+c,s),r.arc(o,s,c,0,2*Math.PI);else if("event"===u){const e=1.15*c;for(let t=0;t<5;t++){const i=-Math.PI/2+t*Math.PI*2/5,n=o+Math.cos(i)*e,a=s+Math.sin(i)*e;0===t?r.moveTo(n,a):r.lineTo(n,a)}r.closePath()}return this.path2D=r,this.path2D}},dataObject:class BpmnDataObjectShape extends y{static typeId="ice-entity-designer:BpmnDataObjectShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=Math.min(14,.22*e,.32*t);return r.moveTo(i,n),r.lineTo(i+e-o,n),r.lineTo(i+e,n+o),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),r.moveTo(i+e-o,n),r.lineTo(i+e-o,n+o),r.lineTo(i+e,n+o),this.path2D=r,this.path2D}},annotation:class BpmnAnnotationShape extends y{static typeId="ice-entity-designer:BpmnAnnotationShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=Math.min(16,.3*e);return r.moveTo(i,n),r.lineTo(i+e,n),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),r.moveTo(i+o,n),r.lineTo(i,n),r.lineTo(i,n+t),r.lineTo(i+o,n+t),this.path2D=r,this.path2D}},lane:class BpmnLaneShape extends y{static typeId="ice-entity-designer:BpmnLaneShape";createPathObject(){const{w:e,h:t,x:i,y:n}=localBox(this),r=createEmptyPath(this);if(!r)return this.path2D;const o=Math.min(this.state.bandSize||30,.4*e,.4*t);return r.moveTo(i,n),r.lineTo(i+e,n),r.lineTo(i+e,n+t),r.lineTo(i,n+t),r.closePath(),"top"===(this.state.band||"left")?(r.moveTo(i,n+o),r.lineTo(i+e,n+o)):(r.moveTo(i+o,n),r.lineTo(i+o,n+t)),this.path2D=r,this.path2D}}},Tn="#0f172a";class FlowNode extends u{static typeId="ice-entity-designer:FlowNode";shapeComponent=null;labelComponent=null;decorationComponents=[];hasDerivedChildren(){return!0}getSerializableChildren(){const e=[this.shapeComponent,this.labelComponent,...this.decorationComponents||[]];return this.childNodes.filter(t=>-1===e.indexOf(t))}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=wn[e.kind]?e.kind:"process",i=wn[t];super({kind:t,title:i.label,fillColor:i.fill,strokeColor:i.stroke,textColor:Tn,fontSize:14,width:i.width,height:i.height,fill:!1,stroke:!1,draggable:!0,interactive:!0,transformable:!1,linkable:-1===Sn.indexOf(t),...e}),this.__buildShape()}__buildShape(){this.shapeComponent&&this.removeChild(this.shapeComponent),this.labelComponent&&this.removeChild(this.labelComponent),this.decorationComponents&&this.decorationComponents.length&&(this.removeChildren(this.decorationComponents),this.decorationComponents.length=0);const e=wn[this.state.kind]||wn.process,t=Cn[e.shape]||h;this.shapeComponent=new t({left:0,top:0,width:this.state.width,height:this.state.height,radius:e.radius||0,lineWidth:e.lineWidth||1.5,lineDash:this.state.lineDash||e.lineDash||[],eventKind:this.state.eventKind||e.eventKind,trigger:this.state.trigger||e.trigger,gatewayType:this.state.gatewayType||e.gatewayType,taskType:this.state.taskType||e.taskType,band:e.band,bandSize:e.bandSize,fill:!e.transparent,interactive:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fillStyle:this.state.fillColor||e.fill,strokeStyle:this.state.strokeColor||e.stroke,lineWidth:e.lineWidth||1.5}}),this.__buildDecorations(e);const i="top-left"===e.labelPlacement,n="lane"===e.shape&&"left"===e.band,r=n?Math.min(Number(e.bandSize)||30,.4*this.state.width,.4*this.state.height):0,o=n?Math.max(this.state.height-8,r):0;this.labelComponent=new c(n?{left:r/2-o/2,top:this.state.height/2-r/2,width:o,height:r,text:String(this.state.title||""),wrap:!0,maxLines:1,ellipsis:"…",transform:{rotate:-90},interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fontSize:this.state.fontSize||13,fillStyle:this.state.textColor||Tn,textAlign:"center",textBaseline:"middle",fontWeight:"bold"}}:{left:i?10:0,top:i?"top"===e.band?18:16:0,width:i?Math.max(this.state.width-20,20):this.state.width,height:i?18:this.state.height,text:String(this.state.title||""),wrap:!i,maxLines:2,interactive:!1,linkable:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fontSize:this.state.fontSize||(i?13:14),fillStyle:this.state.textColor||Tn,textAlign:i?"left":"center",textBaseline:"middle",fontWeight:i?"bold":"normal",paddingLeft:i?0:12,paddingRight:i?0:12}}),this.addChild(this.shapeComponent),this.addChild(this.labelComponent)}__buildDecorations(e){const t=this.state.kind,i=[],n=this.state.strokeColor||e.stroke;if("bpmnTask"===t||"bpmnSubprocess"===t){const t=this.state.taskType||e.taskType||"none";"none"!==t&&i.push(new BpmnTaskIcon({left:8,top:8,width:14,height:14,stroke:!0,fill:!1,interactive:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,taskType:t,style:{strokeStyle:n,lineWidth:1.4}}))}"bpmnSubprocess"===t&&i.push(new BpmnSubprocessMarker({left:(this.state.width-14)/2,top:this.state.height-20,width:14,height:14,stroke:!0,fill:!1,interactive:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{strokeStyle:n,lineWidth:1.4}})),i.length&&(i.forEach(e=>this.addChild(e)),this.decorationComponents=i)}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=void 0!==e.kind||void 0!==e.fillColor||void 0!==e.strokeColor||void 0!==e.textColor||void 0!==e.fontSize||void 0!==e.eventKind||void 0!==e.trigger||void 0!==e.gatewayType||void 0!==e.taskType||void 0!==e.width||void 0!==e.height,i=void 0!==e.left||void 0!==e.top,n=void 0!==e.width||void 0!==e.height;if(n&&this.trigger(m.BEFORE_RESIZE),i){const t=void 0!==e.left?e.left:this.state.left,i=void 0!==e.top?e.top:this.state.top,n={...e};delete n.left,delete n.top,Object.keys(n).length&&this.setState(n),this.setPosition(t,i)}else this.setState(e);return t?this.__buildShape():this.labelComponent&&this.labelComponent.setState({text:String(this.state.title||"")}),(n||t)&&this.trigger(m.AFTER_RESIZE),this.dirty=!0,this}}class FlowEdge extends p{static typeId="ice-entity-designer:FlowEdge";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({title:"Edge",arrow:"end",linkShape:"visio",lineType:"solid",linkable:!1,draggable:!1,interactive:!0,transformable:!1,startPoint:[0,0],endPoint:[10,10],label:"",...e,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4,...e.style||{},label:{fontSize:12,fillStyle:"#334155",backgroundColor:"#ffffff",paddingLeft:4,paddingRight:4,...e.labelStyle||{},...(e.style||{}).label||{}}}}),this.applyPatch({flowType:this.state.flowType,condition:this.state.condition,isDefault:this.state.isDefault})}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e&&e.labelStyle&&(e={...e,style:{...this.state.style||{},...e.style||{},label:{...e.labelStyle||{},...(e.style||{}).label||{}}}},delete e.labelStyle);const t={...this.state,...e},i=t.flowType||"sequence",n="message"===i?{lineDash:[7,4],arrowStyle:"hollow",lineWidth:t.lineWidth||1.4}:"association"===i?{lineDash:[2,3],arrow:"none",arrowStyle:"hollow",lineWidth:t.lineWidth||1.2}:{arrow:t.arrow||"end",arrowStyle:"filled",lineDash:[],lineWidth:t.lineWidth||1.4};return this.setState({...e,...n}),this.dirty=!0,this}}class DesignerHighlightLayer{boxes=(()=>new Map)();options={color:"",lineWidth:3,padding:4,radius:6,fill:!1};constructor(e){this.ice=e}get ids(){return Array.from(this.boxes.keys())}set(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options={...this.options,...t};const i=new Set(e.map(e=>e.id));Array.from(this.boxes.keys()).forEach(e=>{i.has(e)||this.__remove(e)}),e.forEach(e=>this.__place(e)),this.boxes.size||this.__destroy(),this.ice&&"function"==typeof this.ice.requestRepaint&&this.ice.requestRepaint()}clear(){this.boxes.forEach(e=>{this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(e)}),this.boxes.clear(),this.ice&&"function"==typeof this.ice.requestRepaint&&this.ice.requestRepaint()}__place(e){const t=Number(this.options.padding)||0,i=e.minX-t,n=e.minY-t,r=Math.max(1,e.maxX-e.minX+2*t),o=Math.max(1,e.maxY-e.minY+2*t);let s=this.boxes.get(e.id);if(!s)return s=new h({left:i,top:n,width:r,height:o,radius:this.options.radius,fill:!!this.options.fill,stroke:!0,interactive:!1,draggable:!1,transformable:!1,linkable:!1,style:{fillStyle:this.options.fill||"transparent",strokeStyle:this.__color(),lineWidth:this.options.lineWidth}}),s.__iceDesignerHighlight=!0,this.boxes.set(e.id,s),void this.ice.addTool(s);s.setState({left:i,top:n,width:r,height:o,radius:this.options.radius,fill:!!this.options.fill,style:{fillStyle:this.options.fill||"transparent",strokeStyle:this.__color(),lineWidth:this.options.lineWidth}})}__remove(e){const t=this.boxes.get(e);t&&(this.boxes.delete(e),this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(t))}__destroy(){this.boxes.forEach(e=>{this.ice&&"function"==typeof this.ice.removeTool&&this.ice.removeTool(e)}),this.boxes.clear()}__color(){if(this.options.color)return this.options.color;try{const e=this.ice&&"function"==typeof this.ice.getTheme?this.ice.getTheme():null;return e&&e.semantic&&e.semantic.primary||g.semantic.primary}catch{return g.semantic.primary}}}class FlowDesigner{selectedId=null;__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;__listeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__moveSession=!1;__moveEmitQueued=!1;__patchDepth=0;__highlightOptions={};__beforeMoveHandler=()=>this.__onBeforeMove();__afterMoveHandler=()=>this.__onAfterMove();__mouseupHandler=()=>this.__endMoveSession();constructor(e){applyDesignerChrome(e),enableDesignerAlignmentGuides(e),this.ice=e,this.__highlight=new DesignerHighlightLayer(this.ice),registerIEDType(this.ice,FlowNode),registerIEDType(this.ice,FlowEdge),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this),this.ice.evtBus.on("mouseup",this.__mouseupHandler,this)}get nodes(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowNode.typeId)}get edges(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowEdge.typeId)}__flatten(){const e=[],walk=t=>{t.forEach(t=>{e.push(t),t.childNodes&&t.childNodes.length&&walk(t.childNodes)})};return walk(this.ice.childNodes||[]),e}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}setHighlights(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Object.keys(t).length&&(this.__highlightOptions={...this.__highlightOptions,...t});const i=(null==e?[]:Array.isArray(e)?e:[e]).map(e=>this.__highlightEntry(e)).filter(e=>!!e);return this.__highlight.set(i,this.__highlightOptions),i.length}highlight(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=null==e?null:this.__highlightEntry(e);return!(null!=e&&!i)&&(this.setHighlights(i?[i.id]:null,t),!!i)}clearHighlights(){this.setHighlights(null)}getHighlightedIds(){return this.__highlight.ids}__highlightEntry(e){const t=String(e),i=this.nodes.find(e=>String(e.state?.id)===t)||this.nodes.find(e=>String(e.state?.tag)===t);if(!i)return null;const n=i.getMinBoundingBox(!0).getMinAndMaxPoint();return{id:String(i.state.id),minX:n.minX,minY:n.minY,maxX:n.maxX,maxY:n.maxY}}__syncHighlights(){const e=this.__highlight.ids;e.length&&this.setHighlights(e)}subscribe(e){return"function"!=typeof e?()=>{}:(this.__listeners.push(e),()=>{const t=this.__listeners.indexOf(e);-1!==t&&this.__listeners.splice(t,1)})}__emitChange(){if(this.__syncHighlights(),!this.__listeners.length)return;const e=this.serialize();this.__listeners.slice().forEach(t=>t(e,this))}__attachNodeListeners(e){e&&"function"==typeof e.on&&(e.on(m.BEFORE_MOVE,this.__beforeMoveHandler,this),e.on(m.AFTER_MOVE,this.__afterMoveHandler,this))}__detachNodeListeners(e){e&&"function"==typeof e.off&&(e.off(m.BEFORE_MOVE,this.__beforeMoveHandler,this),e.off(m.AFTER_MOVE,this.__afterMoveHandler,this))}__onBeforeMove(){this.__patchDepth>0||this.__moveSession||(this.__moveSession=!0,this.__captureHistory())}__onAfterMove(){if(this.__patchDepth>0)return;if(this.__moveEmitQueued)return;this.__moveEmitQueued=!0;const flush=()=>{this.__moveEmitQueued=!1,this.__emitChange()};"function"==typeof requestAnimationFrame?requestAnimationFrame(flush):setTimeout(flush,16)}__endMoveSession(){this.__moveSession=!1}select(e){return this.selectedId=e,this.__emitChange(),this}__defaultPlacement(e,t){const i=this.nodes;if(!i.length)return{left:120,top:120};let n=1/0,r=-1/0;i.forEach(e=>{const t=e.getMinBoundingBox(!0);n=Math.min(n,t.tl[0]),r=Math.max(r,t.br[1])});const o=i.length;return{left:n+o%4*280,top:r+80+Math.floor(o/4)*(t+90)}}createNode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new FlowNode({kind:e,...t});if(void 0===t.left||void 0===t.top){const e=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===t.left?e.left:t.left,top:void 0===t.top?e.top:t.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}__slotPoint(e,t){const i=e.getMinBoundingBox(!0);switch(t){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}createEdge(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.sourceId?this.ice.findComponent(e.sourceId):null,i=e.targetId?this.ice.findComponent(e.targetId):null;if(!t||!i)throw new Error("连接两端必须是已存在的节点");this.__captureHistory();const n=autoPorts(t,i,{sourcePort:"B",targetPort:"T"}),r=e.sourcePort||n.sourcePort,o=e.targetPort||n.targetPort,s=new FlowEdge({id:e.id,links:{start:{id:e.sourceId,position:r},end:{id:e.targetId,position:o}},startPoint:this.__slotPoint(t,r),endPoint:this.__slotPoint(i,o),label:e.label||"",linkShape:e.linkShape||"visio",flowType:e.flowType||"sequence",condition:e.condition||"",isDefault:!!e.isDefault,style:{...e.style||{},...e.labelStyle?{label:e.labelStyle}:{}}});return this.ice.addChild(s),this.selectedId=s.state.id,this.__emitChange(),s}updateNode(e,t){const i=this.ice.findComponent(e);return i&&i.constructor.typeId===FlowNode.typeId&&(this.__captureHistory(),this.__applyPatch(i,t),this.__emitChange()),i}updateEdge(e,t){const i=this.ice.findComponent(e);return i&&i.constructor.typeId===FlowEdge.typeId&&(this.__captureHistory(),this.__applyPatch(i,t),this.__emitChange()),i}__applyPatch(e,t){this.__patchDepth++;try{e&&"function"==typeof e.applyPatch?e.applyPatch(t):(e.setState(t),e.dirty=!0)}finally{this.__patchDepth--}}remove(e){const t=this.ice.findComponent(e);t&&(this.__captureHistory(),-1!==this.nodes.indexOf(t)&&(this.__detachNodeListeners(t),this.edges.filter(t=>{const i=t.state.links||{};return i.start&&i.start.id===e||i.end&&i.end.id===e}).forEach(e=>this.ice.removeChild(e))),t.parentNode&&"function"==typeof t.parentNode.removeChild?t.parentNode.removeChild(t):this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange())}clear(){this.__captureHistory(),this.ice.clearAll(),this.selectedId=null,this.__emitChange()}serialize(){return JSON.stringify(this.toSnapshot())}toSnapshot(){const e=this.__serializer().toJSONObject();return{version:2,kind:"flowchart",createTime:e.createTime,scene:{version:e.version,childNodes:e.childNodes}}}__serializer(){const e=this.ice;return e.serializer||new _(e)}__deserializer(){const e=this.ice;return e.deserializer||new b(e)}load(e){if(!e)return{loaded:!1,nodes:0,edges:0,skipped:[]};let t;try{t=JSON.parse(e)}catch(e){throw new Error(`Invalid flow snapshot: 不是合法 JSON(${e instanceof Error?e.message:String(e)})`)}if(!t||"object"!=typeof t)return{loaded:!1,nodes:0,edges:0,skipped:[]};const i=!!t.scene;if(!i&&!Array.isArray(t.nodes))return{loaded:!1,nodes:0,edges:0,skipped:[]};const n=function validateFlowSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:void 0!==e.scene?(!e.scene||"object"!=typeof e.scene||Array.isArray(e.scene)?t.push("scene must be an object when present"):Array.isArray(e.scene.childNodes)||t.push("scene.childNodes must be an array"),{valid:0===t.length,errors:t}):(Array.isArray(e.nodes)?e.nodes.forEach((e,i)=>{const n=`nodes[${i}]`;e&&"object"==typeof e&&!Array.isArray(e)?("string"!=typeof e.id&&t.push(`${n}.id must be a string`),void 0!==e.kind&&"string"!=typeof e.kind&&t.push(`${n}.kind must be a string when present`),void 0!==e.left&&"number"!=typeof e.left&&t.push(`${n}.left must be a number when present`),void 0!==e.top&&"number"!=typeof e.top&&t.push(`${n}.top must be a number when present`)):t.push(`${n} must be an object`)}):t.push("nodes must be an array"),void 0===e.edges||Array.isArray(e.edges)?Array.isArray(e.edges)&&e.edges.forEach((e,i)=>{const n=`edges[${i}]`;e&&"object"==typeof e&&!Array.isArray(e)?(["sourceId","targetId"].forEach(i=>{void 0!==e[i]&&null!==e[i]&&"string"!=typeof e[i]&&t.push(`${n}.${i} must be a string or null when present`)}),void 0!==e.label&&"string"!=typeof e.label&&t.push(`${n}.label must be a string when present`),void 0!==e.linkShape&&"visio"!==e.linkShape&&"bezier"!==e.linkShape&&t.push(`${n}.linkShape must be "visio" or "bezier" when present`)):t.push(`${n} must be an object`)}):t.push("edges must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!n.valid)throw new Error(`Invalid flow snapshot:\n${n.errors.join("\n")}`);this.__captureHistory();const r=i?this.__applyEngineScene(t.scene,t.createTime):this.__clearAndBuild(t);return this.__emitChange(),r}__applyEngineScene(e,t){this.ice.clearAll(),this.selectedId=null;const i=this.__deserializer();i.fromJSONObject({version:e.version,createTime:t,childNodes:e.childNodes});const n={loaded:!0,nodes:this.nodes.length,edges:this.edges.length,skipped:[...i.unknownTypes||[]]};return this.nodes.forEach(e=>this.__attachNodeListeners(e)),n}__clearAndBuild(e){this.ice.clearAll(),this.selectedId=null;const t={loaded:!0,nodes:0,edges:0,skipped:[]};return(e.nodes||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowNode)return void t.skipped.push(String(e.typeId));const i=new FlowNode(e);delete i.state.typeId,this.ice.addChild(i),this.__attachNodeListeners(i),t.nodes+=1}),(e.edges||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowEdge)return void t.skipped.push(String(e.typeId));const i=e.sourceId||e.links&&e.links.start&&e.links.start.id||null,n=e.targetId||e.links&&e.links.end&&e.links.end.id||null,r=e.sourcePort||e.links&&e.links.start&&e.links.start.position||"B",o=e.targetPort||e.links&&e.links.end&&e.links.end.position||"T",s=i&&n?{start:{id:i,position:r},end:{id:n,position:o}}:e.links,a=new FlowEdge({...e,links:s,startPoint:e.startPoint||[0,0],endPoint:e.endPoint||[10,10]});delete a.state.typeId,this.ice.addChild(a),t.edges+=1}),t}contentComponents(){return this.nodes}fitViewportAlign="center";fitViewport(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:80;const t=this.contentComponents(),{width:i,height:n}=this.__viewportSize();if(!t.length||!i||!n)return;let r=1/0,o=1/0,s=-1/0,a=-1/0;t.forEach(e=>{const t=e.getMinBoundingBox(!0);r=Math.min(r,t.tl[0]),o=Math.min(o,t.tl[1]),s=Math.max(s,t.br[0]),a=Math.max(a,t.br[1])});const l=Math.max(s-r,1),u=Math.max(a-o,1),c=Math.min((i-2*e)/l,(n-2*e)/u,1.25),h=(i-l*c)/2-r*c,d="start"===this.fitViewportAlign?e-o*c:(n-u*c)/2-o*c;this.ice.setViewport(c,h,d)}__viewportSize(){const e=this.ice,t=e&&e.dpr?e.dpr:1,i=e&&"function"==typeof e.getInputRect?e.getInputRect():null;return{width:i&&i.width>0?i.width:(e?.canvasWidth||0)/t,height:i&&i.height>0?i.height:(e?.canvasHeight||0)/t}}canUndo(){return this.__undoStack.length>0}toSvg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return v(this.ice,e)}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__captureHistory()}resetHistory(){this.__undoStack.length=0,this.__redoStack.length=0}__captureHistory(){this.__historyEnabled&&(this.__undoStack.push(this.serialize()),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}__applySnapshot(e){const t=JSON.parse(e);t&&t.scene?this.__applyEngineScene(t.scene):this.__clearAndBuild(t)}undo(){if(!this.canUndo())return;const e=this.serialize(),t=this.__undoStack.pop();this.__redoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__redoStack.pop(),this.__undoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serialize(),t=this.__redoStack.pop();this.__undoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__undoStack.pop(),this.__redoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let i=t;for(;i;){const e=i.constructor&&i.constructor.typeId;if(e===FlowNode.typeId||e===FlowEdge.typeId)return void this.select(i.state.id);i=i.parentNode}}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this),this.ice.evtBus.off("mouseup",this.__mouseupHandler,this),this.nodes.forEach(e=>this.__detachNodeListeners(e))}}function createDesignerSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new k;i.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const n=new EntityDesigner(i),r=t.onChange?n.subscribe(t.onChange):null;t.initialProject&&n.loadProject(t.initialProject);let o=!1;return{ice:i,designer:n,destroy(){o||(o=!0,r&&r(),n.dispose(),i.destroy())}}}function shouldApplyControlledValue(e,t){return void 0!==e&&e!==t}function createFlowSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new k;i.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const n=new FlowDesigner(i),r=t.onChange,o=r?n.subscribe(e=>r(e)):null;t.initialFlow&&n.load(t.initialFlow);let s=!1;return{ice:i,designer:n,destroy(){s||(s=!0,o&&o(),n.dispose(),i.destroy())}}}function reportLoadError(e,t,i,n){const r=n instanceof Error?n:new Error(String(n));e&&e({phase:t,snapshot:i,error:r})}function createHandle$1(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addEntity:e=>t?t.createEntity(e):null,connect:e=>t?t.createRelation(e):null,updateEntity:(e,i)=>t?t.updateEntity(e,i):null,updateRelation:(e,i)=>t?t.updateRelation(e,i):null,remove:e=>{t&&t.removeComponent(e)},loadProject:e=>t?t.loadProject(e):{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},toSchemaObject:()=>t?t.toSchemaObject():[],toSchemaString:()=>t?t.toSchemaString():"[]",validate:()=>t?t.validate():[],serializeProject:()=>t?t.serializeProject():""}}const xn=n(function EntityDesignerCanvas(e,i){const n=r(null),u=r(null),[c,h]=o(null),d=r(e.onChange);d.current=e.onChange;const p=r(e.onReady);p.current=e.onReady;const f=r(e.onError);f.current=e.onError;const y=r(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=n.current;if(!t)return;const i=createDesignerSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,i=u.current;t&&i&&t({snapshot:e,schema:i.designer.toSchemaObject()})}});if(u.current=i,void 0!==_){y.current=_;try{i.designer.loadProject(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(i.designer),p.current&&p.current(createHandle$1(i)),()=>{i.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.loadProject(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(i,()=>createHandle$1(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:n,width:m,height:g,style:{display:"block"}})),t(EntityDesignerProvider,{designer:c,children:e.children}))}),In='{"version":1,"kind":"flowchart","nodes":[],"edges":[]}';function createHandle(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addNode:(e,i)=>t?t.createNode(e,i):null,connect:e=>t?t.createEdge(e):null,updateNode:(e,i)=>t?t.updateNode(e,i):null,updateEdge:(e,i)=>t?t.updateEdge(e,i):null,remove:e=>{t&&t.remove(e)},load:e=>t?t.load(e):{loaded:!1,nodes:0,edges:0,skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},serialize:()=>t?t.serialize():In,toSnapshot:()=>t?t.toSnapshot():JSON.parse(In),fitViewport:e=>{t&&t.fitViewport(e)}}}const qn=n(function FlowDesignerCanvas(e,i){const n=r(null),u=r(null),[c,h]=o(null),d=r(e.onChange);d.current=e.onChange;const p=r(e.onReady);p.current=e.onReady;const f=r(e.onError);f.current=e.onError;const y=r(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=n.current;if(!t)return;const i=createFlowSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,i=u.current;t&&i&&t({snapshot:e,counts:{nodes:i.designer.nodes.length,edges:i.designer.edges.length}})}});if(u.current=i,void 0!==_){y.current=_;try{i.designer.load(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(i.designer),p.current&&p.current(createHandle(i)),()=>{i.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.load(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(i,()=>createHandle(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:n,width:m,height:g,style:{display:"block"}})),t(FlowDesignerProvider,{designer:c,children:e.children}))});export{Entity,xn as EntityDesignerCanvas,w as EntityDesignerContext,EntityDesignerProvider,wn as FLOW_NODE_KINDS,FlowDesigner,qn as FlowDesignerCanvas,S as FlowDesignerContext,FlowDesignerProvider,FlowEdge,FlowNode,Relation,createDesignerSession,createFlowSession,shouldApplyControlledValue,toSchemaObject,toSchemaString,useEntityDesigner,useFlowDesigner,validateSchema};
|
|
@@ -59,6 +59,16 @@ export default class FlowDesigner {
|
|
|
59
59
|
/** 画布拖拽节点时会话:BEFORE_MOVE 记一次历史,mouseup 结束会话 */
|
|
60
60
|
private __moveSession;
|
|
61
61
|
private __moveEmitQueued;
|
|
62
|
+
/**
|
|
63
|
+
* 正在执行**程序化补丁**(`updateNode` / `updateEdge`)的嵌套层数。
|
|
64
|
+
*
|
|
65
|
+
* 为什么需要:位置补丁现在走引擎的 `setPosition()`(否则连线不跟随,见 `FlowNode.applyPatch`),
|
|
66
|
+
* 而那会派发 `BEFORE_MOVE`/`AFTER_MOVE` —— 这两个事件在**鼠标拖拽**里的语义是"开一个拖拽会话":
|
|
67
|
+
* 会话里只记一次历史、按帧合并广播。程序化补丁不是拖拽会话:它自己已经 `__captureHistory()` +
|
|
68
|
+
* `__emitChange()`,若再被当成开会话,就会出现**重复历史条目**,并且那个"会话"永远不会结束
|
|
69
|
+
* (程序化路径不会有 mouseup)——下一次真拖拽的撤销点就丢了。
|
|
70
|
+
*/
|
|
71
|
+
private __patchDepth;
|
|
62
72
|
/**
|
|
63
73
|
* 程序化高亮层(见 `designer/highlight.ts`)。
|
|
64
74
|
*
|
|
@@ -149,6 +159,14 @@ export default class FlowDesigner {
|
|
|
149
159
|
createEdge(props?: any): any;
|
|
150
160
|
updateNode(id: string, patch: Record<string, any>): any;
|
|
151
161
|
updateEdge(id: string, patch: Record<string, any>): any;
|
|
162
|
+
/**
|
|
163
|
+
* **程序化补丁的统一入口**:走组件自己的 `applyPatch`(会重算派生:连线样式 / 重建形状),
|
|
164
|
+
* 并把它标记成"不是拖拽会话"(见 `__patchDepth`)。
|
|
165
|
+
*
|
|
166
|
+
* 例如 `FlowEdge.applyPatch` 会顺带按 BPMN 语义重算虚线 / 箭头;`FlowNode.applyPatch` 会
|
|
167
|
+
* 按新位置 / 新尺寸派发引擎的移动与尺寸事件(连线因此跟随)。
|
|
168
|
+
*/
|
|
169
|
+
private __applyPatch;
|
|
152
170
|
/**
|
|
153
171
|
* 删除节点(连带删除挂在它两端的连线)或删除一条连线。
|
|
154
172
|
*
|
|
@@ -212,7 +230,7 @@ export default class FlowDesigner {
|
|
|
212
230
|
* 两级口径,都对齐"渲染视口 = dpr · viewport"这条约定:
|
|
213
231
|
* ① 首选引擎的输入矩形(`getInputRect()`)—— 它是**内容盒**,与命中测试 / 坐标换算
|
|
214
232
|
* 同一口径,dpr 变化时它的数值不变;
|
|
215
|
-
* ② 没有布局信息的运行时(测试桩 /
|
|
233
|
+
* ② 没有布局信息的运行时(测试桩 / headless)退回 `canvasWidth / dpr`。
|
|
216
234
|
*
|
|
217
235
|
* 千万不要退回 `canvasWidth` 本身 —— 那正是这条 dpr 缺陷的来源。
|
|
218
236
|
*/
|
|
@@ -59,6 +59,16 @@ export default class FlowDesigner {
|
|
|
59
59
|
/** 画布拖拽节点时会话:BEFORE_MOVE 记一次历史,mouseup 结束会话 */
|
|
60
60
|
private __moveSession;
|
|
61
61
|
private __moveEmitQueued;
|
|
62
|
+
/**
|
|
63
|
+
* 正在执行**程序化补丁**(`updateNode` / `updateEdge`)的嵌套层数。
|
|
64
|
+
*
|
|
65
|
+
* 为什么需要:位置补丁现在走引擎的 `setPosition()`(否则连线不跟随,见 `FlowNode.applyPatch`),
|
|
66
|
+
* 而那会派发 `BEFORE_MOVE`/`AFTER_MOVE` —— 这两个事件在**鼠标拖拽**里的语义是"开一个拖拽会话":
|
|
67
|
+
* 会话里只记一次历史、按帧合并广播。程序化补丁不是拖拽会话:它自己已经 `__captureHistory()` +
|
|
68
|
+
* `__emitChange()`,若再被当成开会话,就会出现**重复历史条目**,并且那个"会话"永远不会结束
|
|
69
|
+
* (程序化路径不会有 mouseup)——下一次真拖拽的撤销点就丢了。
|
|
70
|
+
*/
|
|
71
|
+
private __patchDepth;
|
|
62
72
|
/**
|
|
63
73
|
* 程序化高亮层(见 `designer/highlight.ts`)。
|
|
64
74
|
*
|
|
@@ -149,6 +159,14 @@ export default class FlowDesigner {
|
|
|
149
159
|
createEdge(props?: any): any;
|
|
150
160
|
updateNode(id: string, patch: Record<string, any>): any;
|
|
151
161
|
updateEdge(id: string, patch: Record<string, any>): any;
|
|
162
|
+
/**
|
|
163
|
+
* **程序化补丁的统一入口**:走组件自己的 `applyPatch`(会重算派生:连线样式 / 重建形状),
|
|
164
|
+
* 并把它标记成"不是拖拽会话"(见 `__patchDepth`)。
|
|
165
|
+
*
|
|
166
|
+
* 例如 `FlowEdge.applyPatch` 会顺带按 BPMN 语义重算虚线 / 箭头;`FlowNode.applyPatch` 会
|
|
167
|
+
* 按新位置 / 新尺寸派发引擎的移动与尺寸事件(连线因此跟随)。
|
|
168
|
+
*/
|
|
169
|
+
private __applyPatch;
|
|
152
170
|
/**
|
|
153
171
|
* 删除节点(连带删除挂在它两端的连线)或删除一条连线。
|
|
154
172
|
*
|
|
@@ -212,7 +230,7 @@ export default class FlowDesigner {
|
|
|
212
230
|
* 两级口径,都对齐"渲染视口 = dpr · viewport"这条约定:
|
|
213
231
|
* ① 首选引擎的输入矩形(`getInputRect()`)—— 它是**内容盒**,与命中测试 / 坐标换算
|
|
214
232
|
* 同一口径,dpr 变化时它的数值不变;
|
|
215
|
-
* ② 没有布局信息的运行时(测试桩 /
|
|
233
|
+
* ② 没有布局信息的运行时(测试桩 / headless)退回 `canvasWidth / dpr`。
|
|
216
234
|
*
|
|
217
235
|
* 千万不要退回 `canvasWidth` 本身 —— 那正是这条 dpr 缺陷的来源。
|
|
218
236
|
*/
|
package/dist/types/index.d.mts
CHANGED
|
@@ -64,6 +64,14 @@ export type { WaterSymbolKind, WaterMedium, WaterValveState, WaterSymbolPreset }
|
|
|
64
64
|
export { toPlantUml, fromPlantUml, arrowOf, detectUmlDialect } from './uml/uml_text.mjs';
|
|
65
65
|
export type { UmlTextImportResult } from './uml/uml_text.mjs';
|
|
66
66
|
export { DESIGNER_CHROME, DESIGNER_CHROME_ANTD, designerChromeFromTheme, applyDesignerChrome, } from './theme/designerTheme.mjs';
|
|
67
|
+
/**
|
|
68
|
+
* **Worker 镜像渲染**:把本库的全部领域图元类型注册到一个 ICE 实例上。
|
|
69
|
+
*
|
|
70
|
+
* 应用里那台 ICE 由各 Designer 的构造函数顺手注册类型;worker 侧的镜像那台 ICE 没有任何 Designer,
|
|
71
|
+
* 不注册就会在反序列化时**静默跳过**整棵子树(`MirrorTarget.applyScene()` 会把 `unknownTypes`
|
|
72
|
+
* 报回来)。用法见 `examples/worker-mirror.html` 与 `docs/worker-mirror-rendering.md`。
|
|
73
|
+
*/
|
|
74
|
+
export { registerDesignerTypes, designerTypeIds } from './utils/register-types.mjs';
|
|
67
75
|
/**
|
|
68
76
|
* ice-render 是 peer 依赖,不再内联进本包。
|
|
69
77
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -64,6 +64,14 @@ export type { WaterSymbolKind, WaterMedium, WaterValveState, WaterSymbolPreset }
|
|
|
64
64
|
export { toPlantUml, fromPlantUml, arrowOf, detectUmlDialect } from './uml/uml_text';
|
|
65
65
|
export type { UmlTextImportResult } from './uml/uml_text';
|
|
66
66
|
export { DESIGNER_CHROME, DESIGNER_CHROME_ANTD, designerChromeFromTheme, applyDesignerChrome, } from './theme/designerTheme';
|
|
67
|
+
/**
|
|
68
|
+
* **Worker 镜像渲染**:把本库的全部领域图元类型注册到一个 ICE 实例上。
|
|
69
|
+
*
|
|
70
|
+
* 应用里那台 ICE 由各 Designer 的构造函数顺手注册类型;worker 侧的镜像那台 ICE 没有任何 Designer,
|
|
71
|
+
* 不注册就会在反序列化时**静默跳过**整棵子树(`MirrorTarget.applyScene()` 会把 `unknownTypes`
|
|
72
|
+
* 报回来)。用法见 `examples/worker-mirror.html` 与 `docs/worker-mirror-rendering.md`。
|
|
73
|
+
*/
|
|
74
|
+
export { registerDesignerTypes, designerTypeIds } from './utils/register-types';
|
|
67
75
|
/**
|
|
68
76
|
* ice-render 是 peer 依赖,不再内联进本包。
|
|
69
77
|
*
|