@g1cloud/entity-modeler-next 5.0.0-alpha.12 → 5.0.0-alpha.13
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.
|
@@ -54,12 +54,18 @@ export declare function planPropagation(logical: LogicalModel, changedEntityId:
|
|
|
54
54
|
* 관계가 소유한다 — 컬럼을 직접 지우는 게 아니라 관계를 삭제/변경해 제거해야 한다. 이 판별로
|
|
55
55
|
* FK 속성의 직접 삭제를 차단(어포던스+가드)하고 사용자를 관계 삭제 경로로 유도한다.
|
|
56
56
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
57
|
+
* FK 컬럼 불변식(RELATION* + 물리 컬럼 보유, EntityNode.keyMarks와 동형)으로 먼저 게이트해, 관계의
|
|
58
|
+
* 부모측 end가 가리키는 PK(비-RELATION) 오탐을 배제한다. 그다음 두 신호로 소유 관계를 찾는다:
|
|
59
|
+
*
|
|
60
|
+
* 1순위 `derivedFrom.associationRef` — 전파가 심은 권위 신호. v2 네이티브 doc에 보존되고 어댑터
|
|
61
|
+
* hydration이 복원한다. GUI·sync 스킬·에이전트 어느 경로로 만들어졌든 FK 자신에 붙어 있어,
|
|
62
|
+
* 관계 end의 `attributeRef`가 stale해도(자기참조 재생성·sync가 링크를 다르게 심은 경우 등) 정확하다.
|
|
63
|
+
* 2순위 관계 end의 `attributeRef` 역참조 — `derivedFrom`이 없는 경우(레거시 v1 로드 FK 등)의 폴백.
|
|
64
|
+
* 방향 규약은 end2=자식이지만 드문 로드 형태가 end1에 실을 수 있어 양 end를 모두 검사한다.
|
|
65
|
+
*
|
|
66
|
+
* (초기엔 attributeRef만 신뢰했으나, sync 스킬로 만든 자기참조 FK가 `derivedFrom`은 정확한데
|
|
67
|
+
* end2.attributeRef는 옛 FK id를 가리키는 실사례로 derivedFrom을 1순위로 승격.)
|
|
68
|
+
*
|
|
69
|
+
* `derivedFrom`이 이미 삭제된 관계를 가리키거나(고아) 둘 다 매칭 없으면 undefined → 직접 삭제(정리) 허용.
|
|
64
70
|
*/
|
|
65
71
|
export declare function findFkOwningAssociation(logical: LogicalModel, entityId: ModelId, attributeId: ModelId): Association | undefined;
|
package/dist/entity-modeler.js
CHANGED
|
@@ -3106,11 +3106,17 @@ function Hm(e, t, n = vd) {
|
|
|
3106
3106
|
return o;
|
|
3107
3107
|
}
|
|
3108
3108
|
function ia(e, t, n) {
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3109
|
+
var l;
|
|
3110
|
+
const o = e.entities.find((s) => s.modelId === t), i = o == null ? void 0 : o.attributes.find((s) => s.modelId === n);
|
|
3111
|
+
if (!i || !i.attrType.startsWith("RELATION") || i.dbAttrs.length === 0) return;
|
|
3112
|
+
const a = (l = i.derivedFrom) == null ? void 0 : l.associationRef;
|
|
3113
|
+
if (a) {
|
|
3114
|
+
const s = e.associations.find((r) => r.modelId === a);
|
|
3115
|
+
if (s) return s;
|
|
3116
|
+
}
|
|
3117
|
+
return e.associations.find(
|
|
3118
|
+
(s) => s.end1.entityRef === t && s.end1.attributeRef === n || s.end2.entityRef === t && s.end2.attributeRef === n
|
|
3119
|
+
);
|
|
3114
3120
|
}
|
|
3115
3121
|
function Fm(e, t) {
|
|
3116
3122
|
const n = () => e.entities.filter((a) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(Ee,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue"),require("@g1cloud/open-bluesea-core")):typeof define=="function"&&define.amd?define(["exports","vue","@g1cloud/open-bluesea-core"],n):(Ee=typeof globalThis<"u"?globalThis:Ee||self,n(Ee.EntityModeler={},Ee.Vue,Ee.OpenBlueseaCore))})(this,(function(Ee,n,ie){"use strict";var sS=Object.defineProperty;var cS=(Ee,n,ie)=>n in Ee?sS(Ee,n,{enumerable:!0,configurable:!0,writable:!0,value:ie}):Ee[n]=ie;var Ye=(Ee,n,ie)=>cS(Ee,typeof n!="symbol"?n+"":n,ie);const Hu={startX:40,startY:40,columnGap:280,rowGap:220,perRow:4,defaultSize:{width:220,height:140}};function Fu(e,t){const o=e%t.perRow,i=Math.floor(e/t.perRow);return{location:{x:t.startX+o*t.columnGap,y:t.startY+i*t.rowGap},size:{...t.defaultSize}}}function Ul(e,t,o={}){const i={...Hu,...o},a=new Map(e.entities.map(y=>[y.modelId,y])),l=new Map(e.associations.map(y=>[y.modelId,y])),r=new Map(t.entityLayouts.map(y=>[y.entityRef,y])),s=new Map(t.associationLayouts.map(y=>[y.associationRef,y])),c=t.entityLayouts.map(y=>y.entityRef).filter(y=>!a.has(y)),d=t.associationLayouts.map(y=>y.associationRef).filter(y=>!l.has(y)),u=new Map;for(const y of e.groups)for(const N of y.memberEntityRefs)u.set(N,y.modelId);const f=new Map;for(const y of t.groupLayouts)for(const N of y.memberNoteRefs??[])f.set(N,y.groupRef);let p=0;const m=e.entities.map(y=>{const N=u.get(y.modelId),q=r.get(y.modelId);if(q){const X={location:{x:q.geo.location.x,y:q.geo.location.y},size:{width:q.geo.size.width,height:q.geo.size.height}};return{entity:y,geo:X,collapsed:q.collapsed??!1,locked:q.locked??!1,groupRef:N,style:q.style,attributeStyles:q.attributeStyles,operationStyles:q.operationStyles}}const U=Fu(p++,i);return{entity:y,geo:U,collapsed:!1,locked:!1,groupRef:N}}),h=new Map(t.groupLayouts.map(y=>[y.groupRef,y])),_=e.groups.map(y=>{const N=h.get(y.modelId),q=N?{location:{x:N.geo.location.x,y:N.geo.location.y},size:{width:N.geo.size.width,height:N.geo.size.height}}:{location:{x:0,y:0},size:{width:400,height:300}};return{group:y,geo:q,style:N==null?void 0:N.style,locked:(N==null?void 0:N.locked)??!1}}),b=e.associations.map(y=>{const N=s.get(y.modelId);return{association:y,waypoints:(N==null?void 0:N.waypoints)??[],sourceColumnRef:N==null?void 0:N.sourceColumnRef,targetColumnRef:N==null?void 0:N.targetColumnRef}}),g=t.notes.map(y=>({note:{...y,geo:{location:{x:y.geo.location.x,y:y.geo.location.y},size:{width:y.geo.size.width,height:y.geo.size.height}}},groupRef:f.get(y.modelId)})),I=[];for(const y of t.notes)for(const N of y.connections??[])a.has(N.targetRef)&&I.push({noteRef:y.modelId,targetRef:N.targetRef,waypoints:N.waypoints.map(q=>({x:q.x,y:q.y}))});return{entities:m,associations:b,groups:_,notes:g,noteConnections:I,prunedEntityRefs:c,prunedAssociationRefs:d}}function Gn(e){switch(e){case"right":return{x:1,y:0};case"left":return{x:-1,y:0};case"top":return{x:0,y:-1};case"bottom":return{x:0,y:1}}}const _n=.5;function Hl(e,t,o,i,a,l){const r=Gn(t),s=Gn(a),c={x:e.x+r.x*l,y:e.y+r.y*l},d={x:i.x+s.x*l,y:i.y+s.y*l},u=[c,...o,d],f=[];let p=e;const m=(b,g)=>{(Math.abs(b.x-p.x)>=_n||Math.abs(b.y-p.y)>=_n)&&(f.push({a:p,b,seg:g}),p=b)};m(c,0);let h=r.x!==0,_=c;for(let b=1;b<u.length;b++){const g=u[b],I=b<=o.length?b-1:o.length,y=Math.abs(g.x-_.x)<_n,N=Math.abs(g.y-_.y)<_n;y&&N||(y?(m(g,I),h=!1):N?(m(g,I),h=!0):h?(m({x:_.x,y:g.y},I),m(g,I),h=!0):(m({x:g.x,y:_.y},I),m(g,I),h=!1),_=g)}return m(i,o.length),f}function ia(e,t,o,i,a,l=20){const r=Hl(e,t,o,i,a,l);let s=`M ${tt(e.x)},${tt(e.y)}`;for(const c of r)s+=` L ${tt(c.b.x)},${tt(c.b.y)}`;return s}const Gu=14;function aa(e,t,o,i,a,l=20){return Hl(e,t,o,i,a,l).filter(r=>Math.hypot(r.b.x-r.a.x,r.b.y-r.a.y)>=Gu).map(r=>({point:{x:(r.a.x+r.b.x)/2,y:(r.a.y+r.b.y)/2},segIndex:r.seg}))}function tt(e){return Math.round(e*100)/100}const Yu=36;function Fl(e,t,o=Yu){const i=Math.max(e.x,t.x)+o;return`M ${tt(e.x)},${tt(e.y)} L ${tt(i)},${tt(e.y)} L ${tt(i)},${tt(t.y)} L ${tt(t.x)},${tt(t.y)}`}function la(e,t,o){const i=[e,...t,o];let a=`M ${tt(i[0].x)},${tt(i[0].y)}`;for(let l=1;l<i.length;l++)a+=` L ${tt(i[l].x)},${tt(i[l].y)}`;return a}function Wu(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function ra(e,t){const o=Wu(e),i=e.width/2,a=e.height/2,l=t.x-o.x,r=t.y-o.y;if(Math.abs(l)<_n&&Math.abs(r)<_n)return{point:{x:e.x+e.width,y:o.y},side:"right"};const s=l!==0?i/Math.abs(l):1/0,c=r!==0?a/Math.abs(r):1/0,d=Math.min(s,c),u={x:o.x+l*d,y:o.y+r*d},f=s<=c?l>=0?"right":"left":r>=0?"bottom":"top";return{point:u,side:f}}function sa(e,t,o){const i=o>=e.x+e.width/2;return{point:{x:i?e.x+e.width:e.x,y:t},side:i?"right":"left"}}function ca(e,t,o){const i=[e,...t,o],a=[];for(let l=1;l<i.length;l++){const r=i[l-1],s=i[l];a.push({x:(r.x+s.x)/2,y:(r.y+s.y)/2})}return a}const Ku={cellWidth:260,cellHeight:200,pad:24,headerHeight:28,ungroupedCols:4};function Gl(e,t,o={}){const i={...Ku,...o},a=new Map(t.groupLayouts.map(u=>[u.groupRef,u.geo])),l=[];let r=0;for(const u of e.groups){const f=a.get(u.modelId),p=f?f.location:{x:0,y:0},m=f?f.size.width:800;f&&(r=Math.max(r,f.location.y+f.size.height));const h=Math.max(1,Math.floor((m-i.pad*2)/i.cellWidth));u.memberEntityRefs.forEach((_,b)=>{const g=b%h,I=Math.floor(b/h);l.push({id:_,location:{x:p.x+i.pad+g*i.cellWidth,y:p.y+i.pad+i.headerHeight+I*i.cellHeight}})})}const s=new Set(e.groups.flatMap(u=>u.memberEntityRefs)),c=e.entities.filter(u=>!s.has(u.modelId)),d=r>0?r+40:i.pad;return c.forEach((u,f)=>{const p=f%i.ungroupedCols,m=Math.floor(f/i.ungroupedCols);l.push({id:u.modelId,location:{x:i.pad+p*i.cellWidth,y:d+m*i.cellHeight}})}),l}const Yl={cols:5,boxWidth:200,gap:60,baseX:0,baseY:0,headerHeight:48,rowHeight:24,footerHeight:16,minHeight:120};function Wl(e,t={}){const o={...Yl,...t},i=o.headerHeight+Math.max(0,e)*o.rowHeight+o.footerHeight;return Math.max(o.minHeight,i)}function qu(e,t={}){const o={...Yl,...t},i=Math.max(1,o.cols),a=new Array(i).fill(o.baseY);return e.map((l,r)=>{const s=r%i,c=Wl(l.attributeCount,o),d=o.baseX+s*(o.boxWidth+o.gap),u=a[s];return a[s]=u+c+o.gap,{id:l.id,location:{x:d,y:u},size:{width:o.boxWidth,height:c}}})}function Lo(e,t,o,i){switch(e){case"CLASS":return t;case"PHYSICAL":return i||t;case"LOGICAL":return o||"(논리명)";default:return i?`${o||"(논리명)"} · ${i}`:o||"(논리명)"}}function Kl(e){switch(e){case"NO_INSTANCE_OR_ONE_INSTANCE":return"0..1";case"EXACTLY_ONE_INSTANCE":return"1";case"ZERO_OR_MORE_INSTANCES":return"0..*";case"ONE_OR_MORE_INSTANCES":return"1..*"}}function ql(e){var l,r,s;const t=new Map(e.entities.map(c=>[c.modelId,c.name])),o=new Map;for(const c of e.entities)for(const d of c.attributes)o.set(d.modelId,d.name);const i=new Map;for(const c of e.groups)for(const d of c.memberEntityRefs)i.set(d,c.packageName||(((l=c.name)==null?void 0:l.ko)??c.modelId));const a=[];for(const c of e.entities){const d=(r=c.table)!=null&&r.physicalName?` (${c.table.physicalName})`:"",u=i.get(c.modelId);a.push(`## ${c.name}${d} «${c.stereotype}»${u?` [${u}]`:""}`);const f=[...c.attributes].sort((m,h)=>m.order-h.order);for(const m of f){if(m.attrType==="DIVIDER"){a.push(` ${"─".repeat(8)}${m.name?` ${m.name} ${"─".repeat(8)}`:""}`);continue}const h=m.dbAttrs[0],_=h!=null&&h.length?`(${h.length}${h.scale!=null?`,${h.scale}`:""})`:"",b=h?` → ${h.physicalName} ${h.dataType}${_}`:"",g=[m.identifier?"PK":"",m.notNull?"NOT NULL":"",h!=null&&h.unique?"UNIQUE":"",h!=null&&h.autoIncrement?"AUTO_INCREMENT":""].filter(Boolean);a.push(` - ${m.name}: ${m.type}${b}${g.length?` {${g.join(", ")}}`:""}`)}for(const m of c.indexes??[]){const h=m.columns.map(_=>`${o.get(_.columnRef)??_.columnRef}${_.descending?" DESC":""}`).join(", ");a.push(` index ${m.name}${m.unique?" UNIQUE":""}: ${h}`)}const p=[...c.operations??[]].sort((m,h)=>m.order-h.order);for(const m of p){const h=m.visibility?` {${m.visibility}}`:"",_=(s=m.description)!=null&&s.ko?` — ${m.description.ko}`:"";a.push(` method ${m.name}()${h}${_}`)}a.push("")}if(e.associations.length){a.push("# 관계");for(const c of e.associations){const d=t.get(c.end1.entityRef)??c.end1.entityRef,u=t.get(c.end2.entityRef)??c.end2.entityRef,f=c.end2.composition||c.end1.composition?" (composition)":"";a.push(` ${d} ${Kl(c.end1.multiplicity)} —— ${Kl(c.end2.multiplicity)} ${u}${f}`)}}return a.join(`
|
|
2
|
-
`).trim()}const Xu=/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;function rt(e){return e.replace(Xu,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ce(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.?0+$/,"")}function Xl(e){return`<text ${[`x="${Ce(e.x)}"`,`y="${Ce(e.y)}"`,`fill="${rt(e.fill)}"`,`font-size="${Ce(e.fontSize)}"`,e.fontFamily?`font-family="${rt(e.fontFamily)}"`:"",e.fontWeight!=null?`font-weight="${rt(String(e.fontWeight))}"`:"",e.fontStyle&&e.fontStyle!=="normal"?`font-style="${rt(e.fontStyle)}"`:"",e.anchor&&e.anchor!=="start"?`text-anchor="${e.anchor}"`:"",'dominant-baseline="central"'].filter(Boolean).join(" ")}>${rt(e.text)}</text>`}function ju(e){return`<line x1="${Ce(e.x1)}" y1="${Ce(e.y)}" x2="${Ce(e.x2)}" y2="${Ce(e.y)}" stroke="${rt(e.stroke)}" stroke-width="${Ce(e.strokeWidth??1)}" />`}function Zu(e){return e==null?{tl:0,tr:0,br:0,bl:0}:typeof e=="number"?{tl:e,tr:e,br:e,bl:e}:e}function Ju(e,t,o,i,a){return[`M${Ce(e+a.tl)},${Ce(t)}`,`L${Ce(e+o-a.tr)},${Ce(t)}`,a.tr?`Q${Ce(e+o)},${Ce(t)} ${Ce(e+o)},${Ce(t+a.tr)}`:"",`L${Ce(e+o)},${Ce(t+i-a.br)}`,a.br?`Q${Ce(e+o)},${Ce(t+i)} ${Ce(e+o-a.br)},${Ce(t+i)}`:"",`L${Ce(e+a.bl)},${Ce(t+i)}`,a.bl?`Q${Ce(e)},${Ce(t+i)} ${Ce(e)},${Ce(t+i-a.bl)}`:"",`L${Ce(e)},${Ce(t+a.tl)}`,a.tl?`Q${Ce(e)},${Ce(t)} ${Ce(e+a.tl)},${Ce(t)}`:"","Z"].filter(Boolean).join(" ")}function da(e){const t=Zu(e.radius),o=t.tl||t.tr||t.br||t.bl,i=[`fill="${rt(e.fill)}"`,`stroke="${rt(e.stroke)}"`,`stroke-width="${Ce(e.strokeWidth??1)}"`,e.strokeDasharray?`stroke-dasharray="${rt(e.strokeDasharray)}"`:"",e.opacity!=null?`opacity="${Ce(e.opacity)}"`:""].filter(Boolean),l=[o?`<path d="${Ju(e.x,e.y,e.w,e.h,t)}" ${i.join(" ")} />`:`<rect x="${Ce(e.x)}" y="${Ce(e.y)}" width="${Ce(e.w)}" height="${Ce(e.h)}" ${i.join(" ")} />`];for(const r of e.lines??[])l.push(ju(r));for(const r of e.texts)l.push(Xl(r));for(const r of e.icons??[])l.push(r);return`<g>${l.join("")}</g>`}function Qu(e){const o=[`<path ${[`d="${rt(e.d)}"`,'fill="none"',`stroke="${rt(e.stroke)}"`,`stroke-width="${Ce(e.strokeWidth)}"`,e.strokeDasharray?`stroke-dasharray="${rt(e.strokeDasharray)}"`:""].filter(Boolean).join(" ")} />`];for(const i of e.markers??[])o.push(i);for(const i of e.labels)o.push(Xl(i));return`<g>${o.join("")}</g>`}function jl(e){const{x:t,y:o,w:i,h:a}=e.viewBox,l=[];e.background&&l.push(`<rect x="${Ce(t)}" y="${Ce(o)}" width="${Ce(i)}" height="${Ce(a)}" fill="${rt(e.background)}" />`);for(const r of e.groups)l.push(da(r));for(const r of e.edges)l.push(Qu(r));for(const r of e.entities)l.push(da(r));for(const r of e.notes)l.push(da(r));return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${Ce(t)} ${Ce(o)} ${Ce(i)} ${Ce(a)}" width="${Ce(i)}" height="${Ce(a)}">`+l.join("")+"</svg>"}const ef=["BIT","TINYINT","SMALLINT","INTEGER","BIGINT","FLOAT","REAL","DOUBLE","NUMERIC","DECIMAL","CHAR","VARCHAR","LONGVARCHAR","DATE","TIME","TIMESTAMP","BINARY","VARBINARY","LONGVARBINARY","NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","BLOB","CLOB","REF","DATALINK","BOOLEAN","ROWID","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","REF_CURSOR","TIME_WITH_TIMEZONE","TIMESTAMP_WITH_TIMEZONE","SERIAL","BIG_SERIAL","JSONB"],tf=new Set(["NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","REF","DATALINK","ROWID","REF_CURSOR","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","TIME_WITH_TIMEZONE","BIT","TINYINT","FLOAT"]),nf=ef.filter(e=>!tf.has(e)),of={TIMESTAMP_WITH_TIMEZONE:"TIMESTAMP WITH TIME ZONE",BIG_SERIAL:"BIGSERIAL",DOUBLE:"DOUBLE PRECISION"};function ua(e){return of[e]??e}const af=new Set(["CHAR","VARCHAR","NCHAR","NVARCHAR","BINARY","VARBINARY","NUMERIC","DECIMAL"]),Po=new Set(["NUMERIC","DECIMAL"]);function Zl(e,t=nf){const o=[...t];return e&&!o.includes(e)?[e,...o]:o}const Lt="CustomType",Yn="GroupCodeEnum",fa="String",ma=[{value:"String",label:"String"},{value:"Integer",label:"Integer"},{value:"Long",label:"Long"},{value:"Double",label:"Double"},{value:"Boolean",label:"Boolean"},{value:"Date",label:"Date"},{value:"LocalDate",label:"LocalDate"},{value:"LocalDateTime",label:"LocalDateTime"},{value:"Instant",label:"Instant"},{value:"ZonedDateTime",label:"ZonedDateTime"},{value:"OffsetDateTime",label:"OffsetDateTime"},{value:"BigDecimal",label:"BigDecimal"},{value:"BigInteger",label:"BigInteger"},{value:"ByteArray",label:"Byte[]"},{value:"CharacterArray",label:"Character[]"},{value:"Short",label:"Short"},{value:"PrimitiveInt",label:"int",boxed:"Integer"},{value:"PrimitiveLong",label:"long",boxed:"Long"},{value:"PrimitiveDouble",label:"double",boxed:"Double"},{value:"PrimitiveBoolean",label:"boolean",boxed:"Boolean"},{value:"PrimitiveShort",label:"short",boxed:"Short"},{value:"PrimitiveByteArray",label:"byte[]",boxed:"Byte[]"},{value:"PrimitiveCharacterArray",label:"char[]",boxed:"Character[]"},{value:Yn,label:"GroupCodeEnum"},{value:"CustomMoneyType",label:"Money"},{value:Lt,label:"CustomType"}],lf=new Map(ma.map(e=>[e.value,e.label]));function wn(e){return lf.get(e)??e}const rf=new Set([Yn,"CustomMoneyType"]),Jl=ma.filter(e=>!rf.has(e.value)).map(e=>e.value===Lt?{...e,label:"CustomType (사용자정의)"}:e);function Ql(e,t=[]){const o=t.map(a=>{var r,s;const l=((r=a.label)==null?void 0:r.ko)??((s=a.label)==null?void 0:s.en);return{value:a.type,label:l?`${a.type} (${l})`:a.type}}),i=[...Jl,...o];return e&&!i.some(a=>a.value===e)?[{value:e,label:wn(e)},...i]:i}function sf(e){return e.attrType.startsWith("EMBED")&&e.dbAttrs.length>0}function er(e,t){var a;if(!e.embedded||!e.attrType.startsWith("EMBED"))return;const o=t.find(l=>l.modelId===e.embedded.associationRef);if(!o)return;const i=o.end2.entityRef===e.embedded.embeddableRef?o.end2:o.end1;if(i.multiplicity!=="EXACTLY_ONE_INSTANCE")return((a=i.jpa)==null?void 0:a.collectionType)??"LIST"}function pa(e,t,o){var i;return t.attrType==="DIVIDER"||e==="LOGICAL"?"":o&&t.attrType.startsWith("EMBED")?`${o==="SET"?"Set":"List"}<${wn(t.type)}>`:sf(t)?wn(t.type):e==="CLASS"?t.type===Lt&&t.customType||wn(t.type):ua(((i=t.dbAttrs[0])==null?void 0:i.dataType)??"")}function Wn(e){const t=new Map;for(const o of e)t.set(o.modelId,o);return t}function zo(e,t){if(e.sharedColumnRef==null)return null;const o=t.get(e.sharedColumnRef);return o?{physicalName:o.physicalName,insertable:!1,updatable:!1}:null}const ha=63;function Uo(e){if(!e)return null;const t=e.length;return t<=ha?null:`물리명이 ${ha}자를 초과했습니다 (${t}자) — 일부 DB에서 잘릴 수 있습니다`}function tr(e){return e.dataType?e.length==null?e.dataType:e.scale==null?`${e.dataType}(${e.length})`:`${e.dataType}(${e.length},${e.scale})`:"(미지정)"}function dt(e){return!e||e.trim()===""}function Kn(e){return e==="ZERO_OR_MORE_INSTANCES"||e==="ONE_OR_MORE_INSTANCES"}function cf(e){const t=new Map;for(const u of e.associations){if(u.identifying!==!0||u.end1.entityRef===u.end2.entityRef)continue;const f=t.get(u.end1.entityRef)??[];f.push(u.end2.entityRef),t.set(u.end1.entityRef,f)}const o=0,i=1,a=2,l=new Map,r=[],s=[],c=new Set,d=u=>{l.set(u,i),r.push(u);for(const f of t.get(u)??[]){const p=l.get(f)??o;if(p===o)d(f);else if(p===i){const m=r.slice(r.indexOf(f)),h=[...m].sort().join(" ");c.has(h)||(c.add(h),s.push(m))}}r.pop(),l.set(u,a)};for(const u of e.entities)(l.get(u.modelId)??o)===o&&d(u.modelId);return s}function df(e,t,o,i,a){var l,r,s,c,d;if(!dt(t.physicalName))return t.physicalName;if(e.attrType==="EMBED_PREDEF")return((s=(r=(l=a==null?void 0:a.embeddableCatalog)==null?void 0:l.find(u=>u.type===e.type))==null?void 0:r.fields[o])==null?void 0:s.physicalName)??"";if(e.attrType==="EMBED_OWN"){const u=(c=e.embedded)==null?void 0:c.embeddableRef;if(u==null)return"";const f=(d=i.entities.find(p=>p.modelId===u))==null?void 0:d.attributes.flatMap(p=>p.dbAttrs)[o];return(f==null?void 0:f.physicalName)??""}return t.physicalName??""}function ya(e,t){const o=new Map;for(const i of e){const a=t(i);a==null||a===""||o.set(a,(o.get(a)??0)+1)}return e.filter(i=>{const a=t(i);return a!=null&&a!==""&&(o.get(a)??0)>1})}function nr(e,t){var l,r,s;const o=[];for(const c of ya(e.entities,d=>d.name))o.push({ruleId:"CHK-NAME-3",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:`엔티티 이름이 중복됩니다: "${c.name}"`});for(const c of e.entities){const d=c.attributes.filter(h=>h.attrType!=="DIVIDER");if(dt(c.name)&&o.push({ruleId:"CHK-NAME-4",severity:"info",targetKind:"entity",targetRef:c.modelId,message:"엔티티 이름이 비어 있습니다"}),c.stereotype==="JPA_ENTITY"&&!c.abstractClass&&(d.some(h=>h.identifier)||o.push({ruleId:"CHK-JPA-1",severity:"error",targetKind:"entity",targetRef:c.modelId,message:"JPA 엔티티에 식별자(PK) 속성이 없습니다"}),dt((l=c.table)==null?void 0:l.physicalName)&&o.push({ruleId:"CHK-JPA-8",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:"JPA 엔티티에 테이블 물리명이 설정되지 않았습니다"})),c.stereotype==="JPA_EMBEDDABLE")for(const h of d.filter(_=>_.identifier))o.push({ruleId:"CHK-JPA-2",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`임베더블 타입은 식별자 속성을 가질 수 없습니다: "${h.name}"`});for(const h of d.filter(_=>_.identifier&&_.transient))o.push({ruleId:"CHK-JPA-12",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`식별자(@Id) 속성은 transient(@Transient)일 수 없습니다: "${h.name}"`});for(const h of d)if(!h.identifier)for(const _ of h.dbAttrs)!_.autoIncrement&&dt(_.sequenceName)||o.push({ruleId:"CHK-JPA-13",severity:"error",targetKind:"column",targetRef:_.modelId,contextRef:c.modelId,message:`채번(${_.autoIncrement?"auto increment":`시퀀스 "${_.sequenceName}"`})은 식별자(@Id) 속성에만 쓸 수 있습니다 — 비식별 속성 "${h.name}"에 설정되어 있습니다`});for(const h of d.filter(_=>_.naturalId&&_.identifier))o.push({ruleId:"CHK-JPA-15",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`식별자(@Id) 속성은 자연키(@NaturalId)일 수 없습니다 — 자연키는 PK와 별개의 비즈니스 키입니다: "${h.name}"`});for(const h of d.filter(_=>_.naturalId&&_.transient))o.push({ruleId:"CHK-JPA-16",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`자연키(@NaturalId) 속성은 transient(@Transient)일 수 없습니다: "${h.name}"`});for(const h of d.filter(_=>_.naturalId&&!_.notNull&&!_.identifier&&!_.transient))o.push({ruleId:"CHK-JPA-17",severity:"warning",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`자연키(@NaturalId) 속성은 not null이 권장됩니다(비즈니스 키는 non-null이 원칙): "${h.name}"`});!c.abstractClass&&d.length===0&&o.push({ruleId:"CHK-DSN-2",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:"속성이 하나도 없는 엔티티입니다"}),(t==null?void 0:t.largeEntityThreshold)!=null&&d.length>t.largeEntityThreshold&&o.push({ruleId:"CHK-DSN-4",severity:"info",targetKind:"entity",targetRef:c.modelId,message:`속성이 ${d.length}개로 많습니다 (임계치 ${t.largeEntityThreshold} 초과) — 분해를 검토하세요`});for(const h of ya(d,_=>_.name))o.push({ruleId:"CHK-NAME-1",severity:"warning",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`속성 이름이 중복됩니다: "${h.name}"`});for(const h of d)dt(h.name)&&o.push({ruleId:"CHK-NAME-4",severity:"info",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:"속성 이름이 비어 있습니다"});const u=d.flatMap(h=>h.dbAttrs).filter(h=>h.sharedColumnRef==null),f=d.flatMap(h=>h.dbAttrs.map((_,b)=>({col:_,name:df(h,_,b,e,t)})).filter(_=>_.col.sharedColumnRef==null));for(const h of ya(f,_=>_.name))o.push({ruleId:"CHK-NAME-2",severity:"error",targetKind:"column",targetRef:h.col.modelId,contextRef:c.modelId,message:`컬럼 물리명이 중복됩니다: "${h.name}"`});for(const h of u){const _=Uo(h.physicalName);_&&o.push({ruleId:"CHK-NAME-5",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:_}),t!=null&&t.reservedWords&&!dt(h.physicalName)&&t.reservedWords.has(h.physicalName.toUpperCase())&&o.push({ruleId:"CHK-NAME-6",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:`컬럼 물리명이 SQL 예약어입니다: "${h.physicalName}"`}),t!=null&&t.selectableDataTypes&&!dt(h.dataType)&&!t.selectableDataTypes.has(h.dataType)&&o.push({ruleId:"CHK-TYPE-1",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:`타겟 DB가 지원하지 않는 컬럼 타입입니다: "${h.dataType}"`}),!dt(h.dataType)&&af.has(h.dataType)&&!h.length&&o.push({ruleId:"CHK-TYPE-2",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:`${h.dataType} 타입에 length가 지정되지 않았습니다`})}if((r=t==null?void 0:t.embeddableCatalog)!=null&&r.length){const h=Wn(d.flatMap(_=>_.dbAttrs));for(const _ of d){if(_.attrType!=="EMBED_PREDEF")continue;const b=t.embeddableCatalog.find(g=>g.type===_.type);b&&_.dbAttrs.forEach((g,I)=>{if(g.sharedColumnRef==null)return;const y=b.fields[I],N=h.get(g.sharedColumnRef);if(!y||!N)return;(N.dataType!==y.dataType||(N.length??null)!==(y.length??null)||(N.scale??null)!==(y.scale??null))&&o.push({ruleId:"CHK-TYPE-3",severity:"warning",targetKind:"column",targetRef:g.modelId,contextRef:c.modelId,message:`공유 대상 컬럼의 타입(${tr(N)})이 ${y.name??"컬럼"} 정의(${tr(y)})와 다릅니다`})})}}for(const h of d){const _=h.dbAttrs[0];if(!(_!=null&&_.multiValue))continue;h.type===Yn&&_.dataType==="VARCHAR"||o.push({ruleId:"CHK-TYPE-4",severity:"warning",targetKind:"column",targetRef:_.modelId,contextRef:c.modelId,message:`다중값(Multi-Value) 속성은 GroupCodeEnum + VARCHAR 조합에서만 컨버터가 자동 생성됩니다 — 현재(${h.type||"타입 미지정"} / ${_.dataType||"dataType 미지정"})에서는 Set<…> 필드만 생성되어 매핑이 불완전할 수 있습니다`})}const p=(s=c.table)==null?void 0:s.physicalName,m=Uo(p);m&&o.push({ruleId:"CHK-NAME-5",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:m}),t!=null&&t.reservedWords&&!dt(p)&&t.reservedWords.has(p.toUpperCase())&&o.push({ruleId:"CHK-NAME-6",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:`테이블 물리명이 SQL 예약어입니다: "${p}"`});for(const h of c.indexes??[]){const _=Uo(h.name);_&&o.push({ruleId:"CHK-NAME-5",severity:"warning",targetKind:"index",targetRef:h.modelId,contextRef:c.modelId,message:_}),t!=null&&t.reservedWords&&!dt(h.name)&&t.reservedWords.has(h.name.toUpperCase())&&o.push({ruleId:"CHK-NAME-6",severity:"warning",targetKind:"index",targetRef:h.modelId,contextRef:c.modelId,message:`인덱스 이름이 SQL 예약어입니다: "${h.name}"`})}}const i=new Map;for(const c of e.entities)for(const d of c.attributes)d.attrType==="EMBED_OWN"&&d.embedded&&i.set(d.embedded.associationRef,d);for(const c of e.associations){Kn(c.end1.multiplicity)&&Kn(c.end2.multiplicity)&&o.push({ruleId:"CHK-DSN-1",severity:"info",targetKind:"association",targetRef:c.modelId,message:"both-many(M:N) 관계를 조인 엔티티 없이 직접 연결했습니다 — 연관 엔티티 도입을 검토하세요"}),i.has(c.modelId)&&c.identifying&&o.push({ruleId:"CHK-JPA-11",severity:"error",targetKind:"association",targetRef:c.modelId,message:"임베드(@Embedded/@ElementCollection)는 식별 관계로 둘 수 없습니다 — 임베더블은 독립 식별자가 없습니다"});for(const d of["end1","end2"]){const u=c[d].jpa;if(!u)continue;const f=u.cascadeTypes??[],p=f.includes("ALL"),m=f.includes("REMOVE");p&&f.length>1&&o.push({ruleId:"CHK-JPA-5",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: cascade ALL이 개별 cascade와 중복됩니다 (ALL이 모두 포함)`}),u.orphanRemoval&&(m||p)&&o.push({ruleId:"CHK-JPA-6",severity:"info",targetKind:"association",targetRef:c.modelId,message:`${d}: orphanRemoval이 cascade ${p?"ALL":"REMOVE"}와 의미가 겹칩니다`}),Kn(c[d].multiplicity)&&u.fetchType==="EAGER"&&o.push({ruleId:"CHK-JPA-7",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: 컬렉션(to-many) 연관에 EAGER 페치는 성능 위험이 있습니다`}),u.orphanRemoval&&Kn(c[d==="end1"?"end2":"end1"].multiplicity)&&o.push({ruleId:"CHK-JPA-14",severity:"error",targetKind:"association",targetRef:c.modelId,message:`${d}: orphanRemoval은 @ManyToOne/@ManyToMany(반대편이 컬렉션) 연관에는 적용할 수 없습니다 — @OneToOne·@OneToMany에서만 유효합니다`}),!Kn(c[d].multiplicity)&&(u.collectionType||u.collectionTable||u.orderColumn)&&o.push({ruleId:"CHK-JPA-9",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: 단일(to-one) 연관에 컬렉션 메타(collectionType/collectionTable/orderColumn)는 무의미합니다 — @ElementCollection은 컬렉션에서만 적용됩니다`}),u.collectionType==="SET"&&u.orderColumn&&o.push({ruleId:"CHK-JPA-10",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: SET 컬렉션은 순서를 보존하지 않아 orderColumn(@OrderColumn)이 무의미합니다`})}}const a=new Map(e.entities.map(c=>[c.modelId,c.name||c.modelId]));for(const c of cf(e)){const d=[...c,c[0]].map(u=>a.get(u)??u).join(" → ");for(const u of c)o.push({ruleId:"CHK-JPA-4",severity:"warning",targetKind:"entity",targetRef:u,message:`식별 관계 사이클입니다 (PK 무한 의존): ${d}`})}if(t!=null&&t.flagEntitiesWithoutRelations){const c=new Set;for(const u of e.associations)c.add(u.end1.entityRef),c.add(u.end2.entityRef);const d=new Map(e.entities.map(u=>[u.name,u.modelId]));for(const u of e.entities){for(const f of u.attributes)f.embedded&&(c.add(u.modelId),c.add(f.embedded.embeddableRef));if(!dt(u.superClass)){c.add(u.modelId);const f=d.get(u.superClass);f&&c.add(f)}}for(const u of e.entities)c.has(u.modelId)||o.push({ruleId:"CHK-DSN-3",severity:"info",targetKind:"entity",targetRef:u.modelId,message:"모델링된 관계가 없습니다 (연관·상속·임베딩 미참여 — 의도적 생략이면 무시)"})}return o}function Me(){return crypto.randomUUID()}const uf="CustomMoneyType",ff="Money";function mf(e){return!(e.type!==uf||e.attrType!=="NORMAL"||e.identifier||e.dbAttrs.length>1)}function pf(e){const t=e.dbAttrs[0]??{modelId:Me(),physicalName:"",dataType:""},o={modelId:Me(),physicalName:"",dataType:""},{customType:i,...a}=e;return{...a,type:ff,attrType:"EMBED_PREDEF",dbAttrs:[t,o]}}function hf(e){let t=!1;const o=e.entities.map(i=>{let a=!1;const l=i.attributes.map(r=>mf(r)?(a=!0,t=!0,pf(r)):r);return a?{...i,attributes:l}:i});return t?{...e,entities:o}:e}function ga(e){if(!("rev"in e))return e;const{rev:t,...o}=e;return o}function vn(e,t){if(e===t||e==null&&t==null)return!0;if(e==null||t==null)return!1;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((o,i)=>vn(o,t[i]));if(typeof e=="object"&&typeof t=="object"){const o=new Set([...Object.keys(e),...Object.keys(t)]);for(const i of o)if(!vn(e[i],t[i]))return!1;return!0}return!1}function Zt(e,t,o){const i={},a=new Set([...Object.keys(e),...Object.keys(t)]);for(const l of a)o.has(l)||vn(e[l],t[l])||(i[l]=t[l]===void 0?null:t[l]);return Object.keys(i).length?i:null}function Jt(e,t,o){const i=new Map(e.map(d=>[o(d),d])),a=new Map(t.map(d=>[o(d),d])),l=[],r=[],s=[];for(const[d,u]of a){const f=i.get(d);f?s.push({cur:f,tgt:u}):l.push(u)}for(const[d,u]of i)a.has(d)||r.push(u);const c=(d,u)=>o(d)<o(u)?-1:o(d)>o(u)?1:0;return l.sort(c),r.sort(c),s.sort((d,u)=>c(d.tgt,u.tgt)),{added:l,removed:r,common:s}}function yf(e,t){const o=new Set(e),i=new Set(t),a=t.filter(r=>!o.has(r)).sort(),l=e.filter(r=>!i.has(r)).sort();return{added:a,removed:l}}const gf=new Set(["attributes","operations","indexes","rev"]),bf=new Set(["end1","end2","rev"]),_f=new Set(["memberEntityRefs","rev"]),or=new Set(["modelId"]),wf=new Set(["modelId","columns"]),vf=new Set([]);function kf(e,t,o,i){const a=Jt(t.attributes??[],o.attributes??[],s=>s.modelId);for(const s of a.removed)i.push({kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId});for(const s of a.added)i.push({kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of a.common){const d=Zt(s,c,or);d&&i.push({kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId,patch:d})}const l=Jt(t.operations??[],o.operations??[],s=>s.modelId);for(const s of l.removed)i.push({kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId});for(const s of l.added)i.push({kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of l.common){const d=Zt(s,c,or);d&&i.push({kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId,patch:d})}const r=Jt(t.indexes??[],o.indexes??[],s=>s.modelId);for(const s of r.removed)i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId});for(const s of r.added)i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of r.common){if(!vn(s.columns,c.columns)){i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId}),i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:c});continue}const d=Zt(s,c,wf);d&&i.push({kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId,patch:d})}}function Ef(e,t,o){const i=Jt(e.entities??[],t.entities??[],r=>r.modelId);for(const r of i.removed)o.push({kind:"entity.remove",casUnit:"logical",entityRef:r.modelId});for(const r of i.added)o.push({kind:"entity.add",casUnit:"logical",entityRef:r.modelId,value:ga(r)});for(const{cur:r,tgt:s}of i.common){const c=Zt(r,s,gf);c&&o.push({kind:"entity.update",casUnit:"logical",containerRef:r.modelId,entityRef:r.modelId,patch:c}),kf(r.modelId,r,s,o)}const a=Jt(e.associations??[],t.associations??[],r=>r.modelId);for(const r of a.removed)o.push({kind:"association.remove",casUnit:"logical",associationRef:r.modelId});for(const r of a.added)o.push({kind:"association.add",casUnit:"logical",associationRef:r.modelId,value:ga(r)});for(const{cur:r,tgt:s}of a.common){const c=Zt(r,s,bf);c&&o.push({kind:"association.update",casUnit:"logical",containerRef:r.modelId,associationRef:r.modelId,patch:c});for(const d of["end1","end2"]){const u=Zt(r[d]??{},s[d]??{},vf);u&&o.push({kind:"associationEnd.update",casUnit:"logical",containerRef:r.modelId,associationRef:r.modelId,end:d,patch:u})}}const l=Jt(e.groups??[],t.groups??[],r=>r.modelId);for(const r of l.removed)o.push({kind:"group.remove",casUnit:"logical",groupRef:r.modelId});for(const r of l.added)o.push({kind:"group.add",casUnit:"logical",groupRef:r.modelId,value:ga(r)});for(const{cur:r,tgt:s}of l.common){const c=Zt(r,s,_f);c&&o.push({kind:"group.update",casUnit:"logical",containerRef:r.modelId,groupRef:r.modelId,patch:c});const d=yf(r.memberEntityRefs??[],s.memberEntityRefs??[]);for(const u of d.removed)o.push({kind:"group.removeMember",casUnit:"logical",containerRef:r.modelId,groupRef:r.modelId,entityRef:u});for(const u of d.added)o.push({kind:"group.addMember",casUnit:"logical",containerRef:r.modelId,groupRef:r.modelId,entityRef:u})}}function Ho(e,t,o,i,a,l,r){const s=Jt(e,t,o);for(const c of s.removed)r.push({kind:a,casUnit:"layout",[l]:o(c),value:void 0});for(const c of s.added)r.push({kind:i,casUnit:"layout",[l]:o(c),value:c});for(const{cur:c,tgt:d}of s.common)vn(c,d)||(r.push({kind:a,casUnit:"layout",[l]:o(c),value:void 0}),r.push({kind:i,casUnit:"layout",[l]:o(d),value:d}))}function Nf(e,t,o){Ho(e.entityLayouts??[],t.entityLayouts??[],i=>i.entityRef,"entityLayout.add","entityLayout.remove","entityRef",o),Ho(e.associationLayouts??[],t.associationLayouts??[],i=>i.associationRef,"associationLayout.add","associationLayout.remove","associationRef",o),Ho(e.groupLayouts??[],t.groupLayouts??[],i=>i.groupRef,"groupLayout.add","groupLayout.remove","groupRef",o),Ho(e.notes??[],t.notes??[],i=>i.modelId,"note.add","note.remove","noteRef",o)}function $f(e,t){const o=[];return Ef(e.logical,t.logical,o),Nf(e.layout,t.layout,o),o}function xf(e){if(e.groupRef!=null)return"group";if(e.associationRef!=null)return e.end!=null?"associationEnd":"association";if(e.entityRef!=null&&e.attributeRef!=null)return"attribute";if(e.entityRef!=null&&e.operationRef!=null)return"operation";if(e.entityRef!=null&&e.indexRef!=null)return"index";if(e.entityRef!=null)return"entity";throw new Error("projectFieldAudit: 대상 로케이터가 비었습니다(entityRef/associationRef/groupRef 중 하나 필요).")}const If={entity:new Set(["attributes","operations","indexes","rev","modelId"]),association:new Set(["end1","end2","rev","modelId"]),group:new Set(["memberEntityRefs","rev","modelId"]),attribute:new Set(["modelId"]),operation:new Set(["modelId"]),index:new Set(["modelId"]),associationEnd:new Set([])};class Sf{constructor(t){Ye(this,"out",[]);Ye(this,"last",new Map);this.fieldFilter=t}set(t,o,i){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;const a=this.last.get(o);this.out.push({...qn(t),field:o,value:i,...this.last.has(o)?{oldValue:a}:{}}),this.last.set(o,i)}remove(t,o){if(o!=null){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;this.out.push({...qn(t),field:o,value:void 0,removed:!0,...this.last.has(o)?{oldValue:this.last.get(o)}:{}}),this.last.delete(o);return}const i=this.fieldFilter!=null?[this.fieldFilter]:[...this.last.keys()];for(const a of i){if(!this.last.has(a)){this.out.push({...qn(t),field:a,value:void 0,removed:!0});continue}this.out.push({...qn(t),field:a,value:void 0,removed:!0,oldValue:this.last.get(a)}),this.last.delete(a)}}member(t,o,i){const a="memberEntityRefs";this.fieldFilter!=null&&a!==this.fieldFilter||this.out.push({...qn(t),field:a,value:o,...i?{removed:!0}:{}})}result(){return this.out}}function qn(e){const t={seq:e.seq};return e.ts!==void 0&&(t.ts=e.ts),e.origin!==void 0&&(t.origin=e.origin),e.author!==void 0&&(t.author=e.author),e.kind!==void 0&&(t.kind=e.kind),e.restoredFromSeq!==void 0&&(t.restoredFromSeq=e.restoredFromSeq),t}function gt(e,t,o,i){if(o==null||typeof o!="object")return;const a=If[i];for(const[l,r]of Object.entries(o))a.has(l)||e.set(t,l,r)}function Qt(e,t,o){if(!(o==null||typeof o!="object"))for(const[i,a]of Object.entries(o))e.set(t,i,a)}function ba(e,t){if(Array.isArray(e))return e.find(o=>o.modelId===t)}function Pt(e,t){var l,r,s,c,d,u,f,p;const o=xf(t),i=new Sf(t.field),a=[...e].sort((m,h)=>m.seq-h.seq);for(const m of a)for(const h of m.ops)switch(o){case"entity":if(h.entityRef!==t.entityRef)break;h.kind==="entity.add"?gt(i,m,h.value,"entity"):h.kind==="entity.update"?Qt(i,m,h.patch):h.kind==="entity.remove"&&i.remove(m);break;case"attribute":if(h.entityRef!==t.entityRef)break;if(h.kind==="entity.add"){const _=ba((l=h.value)==null?void 0:l.attributes,t.attributeRef);_&>(i,m,_,"attribute")}else h.kind==="attribute.add"&&((r=h.value)==null?void 0:r.modelId)===t.attributeRef?gt(i,m,h.value,"attribute"):h.kind==="attribute.update"&&h.attributeRef===t.attributeRef?Qt(i,m,h.patch):(h.kind==="attribute.remove"&&h.attributeRef===t.attributeRef||h.kind==="entity.remove")&&i.remove(m);break;case"operation":if(h.entityRef!==t.entityRef)break;if(h.kind==="entity.add"){const _=ba((s=h.value)==null?void 0:s.operations,t.operationRef);_&>(i,m,_,"operation")}else h.kind==="operation.add"&&((c=h.value)==null?void 0:c.modelId)===t.operationRef?gt(i,m,h.value,"operation"):h.kind==="operation.update"&&h.operationRef===t.operationRef?Qt(i,m,h.patch):(h.kind==="operation.remove"&&h.operationRef===t.operationRef||h.kind==="entity.remove")&&i.remove(m);break;case"index":if(h.entityRef!==t.entityRef)break;if(h.kind==="entity.add"){const _=ba((d=h.value)==null?void 0:d.indexes,t.indexRef);_&>(i,m,_,"index")}else h.kind==="index.add"&&((u=h.value)==null?void 0:u.modelId)===t.indexRef?gt(i,m,h.value,"index"):h.kind==="index.update"&&h.indexRef===t.indexRef?Qt(i,m,h.patch):(h.kind==="index.remove"&&h.indexRef===t.indexRef||h.kind==="entity.remove")&&i.remove(m);break;case"association":if(h.associationRef!==t.associationRef)break;h.kind==="association.add"?gt(i,m,h.value,"association"):h.kind==="association.update"?Qt(i,m,h.patch):h.kind==="association.remove"&&i.remove(m);break;case"associationEnd":if(h.associationRef!==t.associationRef)break;if(h.kind==="association.add"){const _=(f=h.value)==null?void 0:f[t.end];gt(i,m,_,"associationEnd")}else h.kind==="associationEnd.update"&&h.end===t.end?Qt(i,m,h.patch):h.kind==="association.remove"&&i.remove(m);break;case"group":if(h.groupRef!==t.groupRef)break;if(h.kind==="group.add"){gt(i,m,h.value,"group");const _=(p=h.value)==null?void 0:p.memberEntityRefs;if(Array.isArray(_))for(const b of _)i.member(m,b,!1)}else h.kind==="group.update"?Qt(i,m,h.patch):h.kind==="group.remove"?i.remove(m):h.kind==="group.addMember"&&h.entityRef!=null?i.member(m,h.entityRef,!1):h.kind==="group.removeMember"&&h.entityRef!=null&&i.member(m,h.entityRef,!0);break}return i.result()}function Cf(e,t){const o=e;return o.entityRef===t||o.containerRef===t}function kn(e,t){if(Array.isArray(e))for(const o of e)typeof o.modelId=="string"&&t.add(o.modelId)}function Rf(e,t){const o=new Set,i=new Set,a=new Set;for(const l of e)for(const r of l.ops){const s=r;if(r.kind==="entity.add"&&s.entityRef===t){const c=s.value;kn(c==null?void 0:c.attributes,o),kn(c==null?void 0:c.operations,i),kn(c==null?void 0:c.indexes,a);continue}s.containerRef!==t&&s.entityRef!==t||(r.kind==="attribute.add"?kn([s.value],o):r.kind==="attribute.update"||r.kind==="attribute.remove"?typeof s.attributeRef=="string"&&o.add(s.attributeRef):r.kind==="operation.add"?kn([s.value],i):r.kind==="operation.update"||r.kind==="operation.remove"?typeof s.operationRef=="string"&&i.add(s.operationRef):r.kind==="index.add"?kn([s.value],a):(r.kind==="index.update"||r.kind==="index.remove")&&typeof s.indexRef=="string"&&a.add(s.indexRef))}return{attributes:o,operations:i,indexes:a}}function Fo(e,t){return e.map(o=>({...o,subject:t}))}function ir(e,t){const o=e.filter(s=>s.ops.some(c=>Cf(c,t))),{attributes:i,operations:a,indexes:l}=Rf(o,t),r=[...Fo(Pt(o,{entityRef:t}),{kind:"entity",ref:t})];for(const s of i)r.push(...Fo(Pt(o,{entityRef:t,attributeRef:s}),{kind:"attribute",ref:s}));for(const s of a)r.push(...Fo(Pt(o,{entityRef:t,operationRef:s}),{kind:"operation",ref:s}));for(const s of l)r.push(...Fo(Pt(o,{entityRef:t,indexRef:s}),{kind:"index",ref:s}));return r.map((s,c)=>({e:s,i:c})).sort((s,c)=>s.e.seq-c.e.seq||s.i-c.i).map(({e:s})=>s)}function ar(e){return`${e.kind}:${e.ref}:${e.end??""}`}function Vf(e){var i,a,l;const t=new Set,o=(r,s)=>{typeof s=="string"&&t.add(`${r}:${s}:`)};for(const r of e)for(const s of r.ops){const c=s;switch(s.kind){case"entity.add":{o("entity",c.entityRef);const d=c.value;for(const u of Array.isArray(d==null?void 0:d.attributes)?d.attributes:[])o("attribute",u.modelId);for(const u of Array.isArray(d==null?void 0:d.operations)?d.operations:[])o("operation",u.modelId);for(const u of Array.isArray(d==null?void 0:d.indexes)?d.indexes:[])o("index",u.modelId);break}case"attribute.add":o("attribute",(i=c.value)==null?void 0:i.modelId);break;case"operation.add":o("operation",(a=c.value)==null?void 0:a.modelId);break;case"index.add":o("index",(l=c.value)==null?void 0:l.modelId);break;case"association.add":o("association",c.associationRef);break;case"group.add":o("group",c.groupRef);break}}return t}function Af(e){const t=new Set,o=new Set,i=new Set;for(const a of e)for(const l of a.ops){const r=l,s=l.kind;if(s.startsWith("entity."))typeof r.entityRef=="string"&&t.add(r.entityRef);else if(s.startsWith("attribute.")||s.startsWith("operation.")||s.startsWith("index.")){const c=r.containerRef??r.entityRef;typeof c=="string"&&t.add(c)}else s.startsWith("associationEnd.")||s.startsWith("association.")?typeof r.associationRef=="string"&&o.add(r.associationRef):s.startsWith("group.")&&typeof r.groupRef=="string"&&i.add(r.groupRef)}return{entities:t,associations:o,groups:i}}function Tf(e){const{entities:t,associations:o,groups:i}=Af(e),a=[];for(const l of t)for(const r of ir(e,l))a.push({...r,subject:{...r.subject,entityRef:l}});for(const l of o){for(const r of Pt(e,{associationRef:l}))a.push({...r,subject:{kind:"association",ref:l}});for(const r of["end1","end2"])for(const s of Pt(e,{associationRef:l,end:r}))a.push({...s,subject:{kind:"associationEnd",ref:l,end:r}})}for(const l of i)for(const r of Pt(e,{groupRef:l}))a.push({...r,subject:{kind:"group",ref:l}});return a}function lr(e){const t=Tf(e),o=Vf(e),i=new Map;for(const r of t){const s=ar(r.subject),c=i.get(s);(c===void 0||r.seq<c)&&i.set(s,r.seq)}const a=new Map;for(const r of t){let s=a.get(r.seq);s||(s={meta:r,subjects:new Map},a.set(r.seq,s));const c=ar(r.subject);let d=s.subjects.get(c);if(!d){const u=r.removed?"remove":i.get(c)===r.seq&&o.has(c)?"add":"update";d={subject:r.subject,verb:u,fields:[]},s.subjects.set(c,d)}r.removed?d.verb="remove":d.fields.push({field:r.field,value:r.value,...r.oldValue!==void 0?{oldValue:r.oldValue}:{}})}const l=[];for(const[r,s]of a){const c=s.meta;l.push({seq:r,...c.ts!==void 0?{ts:c.ts}:{},...c.origin!==void 0?{origin:c.origin}:{},...c.author!==void 0?{author:c.author}:{},...c.kind!==void 0?{kind:c.kind}:{},...c.restoredFromSeq!==void 0?{restoredFromSeq:c.restoredFromSeq}:{},actions:[...s.subjects.values()]})}return l.sort((r,s)=>s.seq-r.seq)}class _a{constructor(t){Ye(this,"undoStack",[]);Ye(this,"redoStack",[]);Ye(this,"savePoint",null);Ye(this,"listeners",new Set);Ye(this,"commandListeners",new Set);Ye(this,"coalesceSealed",!1);this.state=t}execute(t){t.apply(this.state);const o=this.undoStack.at(-1),i=!this.coalesceSealed&&t.coalesceKey!=null&&!!o&&o.coalesceKey===t.coalesceKey;this.coalesceSealed=!1,i?(t.invert=o.invert,this.undoStack[this.undoStack.length-1]=t):this.undoStack.push(t),this.redoStack=[],this.emitCommand(t,"do",i),this.emit()}undo(){const t=this.undoStack.pop();t&&(t.invert(this.state),this.redoStack.push(t),this.emitCommand(t,"undo",!1),this.emit())}redo(){const t=this.redoStack.pop();t&&(t.apply(this.state),this.undoStack.push(t),this.emitCommand(t,"redo",!1),this.emit())}sealCoalesce(){this.coalesceSealed=!0}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}markSavePoint(){this.savePoint=this.undoStack.at(-1)??null,this.emit()}get isDirty(){return(this.undoStack.at(-1)??null)!==this.savePoint}onChange(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onCommand(t){return this.commandListeners.add(t),()=>this.commandListeners.delete(t)}emit(){for(const t of this.listeners)t()}emitCommand(t,o,i){for(const a of this.commandListeners)a(t,o,i)}}function rr(e,t){return e.logical.entities.findIndex(o=>o.modelId===t)}function je(e,t){return e.layout.entityLayouts.findIndex(o=>o.entityRef===t)}function ut(e,t){return e.layout.associationLayouts.find(o=>o.associationRef===t)}function ze(e,t){const o=e.logical.entities.find(i=>i.modelId===t);if(!o)throw new Error(`엔티티 없음: ${t}`);return o}function It(e,t,o){var i,a;return(a=(i=e.layout.notes.find(l=>l.modelId===t))==null?void 0:i.connections)==null?void 0:a.find(l=>l.targetRef===o)}function wa(e,t){return{label:`엔티티 추가: ${e.name}`,apply(o){o.logical.entities.push(e),o.layout.entityLayouts.push({entityRef:e.modelId,geo:t})},invert(o){const i=rr(o,e.modelId);i>=0&&o.logical.entities.splice(i,1);const a=je(o,e.modelId);a>=0&&o.layout.entityLayouts.splice(a,1)},emitOps(){const o={kind:"entity.add",casUnit:"logical",entityRef:e.modelId,value:e},i={kind:"entityLayout.add",casUnit:"layout",entityRef:e.modelId,value:{entityRef:e.modelId,geo:t},incidental:!0};return{forward:[o,i],invert:[{kind:"entityLayout.remove",casUnit:"layout",entityRef:e.modelId,incidental:!0},{kind:"entity.remove",casUnit:"logical",entityRef:e.modelId}]}}}}function sr(e){let t=null;const o=i=>i.end1.entityRef===e||i.end2.entityRef===e;return{label:"엔티티 삭제",apply(i){const a=rr(i,e);if(a<0)throw new Error(`엔티티 없음: ${e}`);const l=je(i,e),r=[];i.logical.associations.forEach((u,f)=>{o(u)&&r.push({item:u,index:f})});const s=new Set(r.map(u=>u.item.modelId)),c=[];i.layout.associationLayouts.forEach((u,f)=>{s.has(u.associationRef)&&c.push({item:u,index:f})});const d=[];i.logical.groups.forEach(u=>{const f=u.memberEntityRefs.indexOf(e);f>=0&&d.push({groupId:u.modelId,index:f})}),t={entity:{item:i.logical.entities[a],index:a},entityLayout:l>=0?{item:i.layout.entityLayouts[l],index:l}:void 0,assocs:r,assocLayouts:c,groupMemberships:d},[...c].sort((u,f)=>f.index-u.index).forEach(u=>i.layout.associationLayouts.splice(u.index,1)),[...r].sort((u,f)=>f.index-u.index).forEach(u=>i.logical.associations.splice(u.index,1));for(const u of d){const f=i.logical.groups.find(p=>p.modelId===u.groupId);f==null||f.memberEntityRefs.splice(u.index,1)}l>=0&&i.layout.entityLayouts.splice(l,1),i.logical.entities.splice(a,1)},invert(i){if(t){i.logical.entities.splice(t.entity.index,0,t.entity.item),t.entityLayout&&i.layout.entityLayouts.splice(t.entityLayout.index,0,t.entityLayout.item),[...t.assocs].sort((a,l)=>a.index-l.index).forEach(a=>i.logical.associations.splice(a.index,0,a.item)),[...t.assocLayouts].sort((a,l)=>a.index-l.index).forEach(a=>i.layout.associationLayouts.splice(a.index,0,a.item));for(const a of t.groupMemberships){const l=i.logical.groups.find(r=>r.modelId===a.groupId);l==null||l.memberEntityRefs.splice(a.index,0,e)}}},emitOps(){if(!t)return{forward:[],invert:[]};const i=[],a=[];for(const l of t.assocs)i.push({kind:"association.remove",casUnit:"logical",associationRef:l.item.modelId}),a.push({kind:"association.add",casUnit:"logical",associationRef:l.item.modelId,value:l.item});for(const l of t.assocLayouts)i.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:l.item.associationRef,incidental:!0}),a.push({kind:"associationLayout.add",casUnit:"layout",associationRef:l.item.associationRef,value:l.item,incidental:!0});for(const l of t.groupMemberships)i.push({kind:"group.removeMember",casUnit:"logical",containerRef:l.groupId,groupRef:l.groupId,entityRef:e}),a.push({kind:"group.addMember",casUnit:"logical",containerRef:l.groupId,groupRef:l.groupId,entityRef:e});return t.entityLayout&&(i.push({kind:"entityLayout.remove",casUnit:"layout",entityRef:e,incidental:!0}),a.push({kind:"entityLayout.add",casUnit:"layout",entityRef:e,value:t.entityLayout.item,incidental:!0})),i.push({kind:"entity.remove",casUnit:"logical",entityRef:e}),a.push({kind:"entity.add",casUnit:"logical",entityRef:e,value:t.entity.item}),{forward:i,invert:a.reverse()}}}}function cr(e,t){const o={};return{label:"엔티티 수정",apply(i){const a=ze(i,e);for(const l of Object.keys(t))o[l]=a[l];Object.assign(a,t)},invert(i){Object.assign(ze(i,e),o)},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:t}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{...o}}]}}}}function dr(e,t){let o="";return{label:`엔티티 이름 변경: ${t}`,apply(i){const a=ze(i,e);o=a.name,a.name=t},invert(i){ze(i,e).name=o},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:t}}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:o}}]}}}}function En(e,t){let o=null;return{label:"엔티티 이동",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a].geo;o={...l.location},l.location={...t}},invert(i){const a=je(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.location=o)},emitOps(){const i=a=>({kind:"entityLayout.move",casUnit:"layout",entityRef:e,value:{location:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function ur(e,t){let o=null;return{label:"엔티티 크기 변경",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a].geo;o={...l.size},l.size={...t}},invert(i){const a=je(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.size=o)},emitOps(){const i=a=>({kind:"entityLayout.resize",casUnit:"layout",entityRef:e,value:{size:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function Xn(e,t){const o={...(e==null?void 0:e.properties)??{}};return t?o.swatch=t:delete o.swatch,Object.keys(o).length?{properties:o}:void 0}function fr(e,t){let o;return{label:"엔티티 색상 변경",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a];o=l.style,l.style=Xn(l.style,t)},invert(i){const a=je(i,e);a>=0&&(i.layout.entityLayouts[a].style=o)},emitOps(i){const a=je(i,e),l=a>=0?i.layout.entityLayouts[a].style:void 0,r=s=>({kind:"entityLayout.setStyle",casUnit:"layout",entityRef:e,value:{style:s}});return{forward:[r(l)],invert:[r(o)]}}}}function mr(e,t){let o;return{label:t?"엔티티 접기":"엔티티 펼치기",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a];o=l.collapsed,l.collapsed=t},invert(i){const a=je(i,e);a>=0&&(i.layout.entityLayouts[a].collapsed=o)},emitOps(){const i=a=>({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:e,value:{collapsed:a}});return{forward:[i(t)],invert:[i(o)]}}}}function pr(e,t){let o;return{label:t?"엔티티 잠금":"엔티티 잠금 해제",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a];o=l.locked,l.locked=t},invert(i){const a=je(i,e);a>=0&&(i.layout.entityLayouts[a].locked=o)},emitOps(){const i=a=>({kind:"entityLayout.setLocked",casUnit:"layout",entityRef:e,value:{locked:a}});return{forward:[i(t)],invert:[i(o)]}}}}function va(e){let t=[];return{label:e?"모두 접기":"모두 펼치기",apply(o){t=o.layout.entityLayouts.map(i=>i.collapsed);for(const i of o.layout.entityLayouts)i.collapsed=e},invert(o){o.layout.entityLayouts.forEach((i,a)=>{i.collapsed=t[a]})},emitOps(o){const i=[],a=[];return o.layout.entityLayouts.forEach((l,r)=>{i.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:l.entityRef,value:{collapsed:e}}),a.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:l.entityRef,value:{collapsed:t[r]}})}),{forward:i,invert:a}}}}function Go(e,t,o){let i;return{label:"속성 색상 변경",apply(a){const l=je(a,e);if(l<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=a.layout.entityLayouts[l];i=r.attributeStyles;const s={...r.attributeStyles},c=Xn(s[t],o);c?s[t]=c:delete s[t],r.attributeStyles=Object.keys(s).length?s:void 0},invert(a){const l=je(a,e);l>=0&&(a.layout.entityLayouts[l].attributeStyles=i)},emitOps(a){const l=je(a,e),r=l>=0?a.layout.entityLayouts[l].attributeStyles:void 0,s=c=>({kind:"entityLayout.setAttrStyle",casUnit:"layout",entityRef:e,value:{attributeStyles:c}});return{forward:[s(r)],invert:[s(i)]}}}}function ka(e,t){return{label:"그룹 추가",apply(o){o.logical.groups.push(e),o.layout.groupLayouts.push({groupRef:e.modelId,geo:t})},invert(o){const i=o.logical.groups.findIndex(l=>l.modelId===e.modelId);i>=0&&o.logical.groups.splice(i,1);const a=o.layout.groupLayouts.findIndex(l=>l.groupRef===e.modelId);a>=0&&o.layout.groupLayouts.splice(a,1)},emitOps(){const o={kind:"group.add",casUnit:"logical",groupRef:e.modelId,value:e},i={kind:"groupLayout.add",casUnit:"layout",groupRef:e.modelId,value:{groupRef:e.modelId,geo:t},incidental:!0};return{forward:[o,i],invert:[{kind:"groupLayout.remove",casUnit:"layout",groupRef:e.modelId,incidental:!0},{kind:"group.remove",casUnit:"logical",groupRef:e.modelId}]}}}}function hr(e,t){const o={},i=a=>{const l=a.logical.groups.find(r=>r.modelId===e);if(!l)throw new Error(`그룹 없음: ${e}`);return l};return{label:"그룹 수정",apply(a){const l=i(a);for(const r of Object.keys(t))o[r]=l[r];Object.assign(l,t)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:t}],invert:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:{...o}}]}}}}function yr(e){let t=null;return{label:"그룹 해제",apply(o){const i=o.logical.groups.findIndex(l=>l.modelId===e);if(i<0)throw new Error(`그룹 없음: ${e}`);const a=o.layout.groupLayouts.findIndex(l=>l.groupRef===e);t={group:{item:o.logical.groups[i],index:i},layout:a>=0?{item:o.layout.groupLayouts[a],index:a}:void 0},a>=0&&o.layout.groupLayouts.splice(a,1),o.logical.groups.splice(i,1)},invert(o){t&&(o.logical.groups.splice(t.group.index,0,t.group.item),t.layout&&o.layout.groupLayouts.splice(t.layout.index,0,t.layout.item))},emitOps(){if(!t)return{forward:[],invert:[]};const o=[],i=[];return t.layout&&(o.push({kind:"groupLayout.remove",casUnit:"layout",groupRef:e,incidental:!0}),i.push({kind:"groupLayout.add",casUnit:"layout",groupRef:e,value:t.layout.item,incidental:!0})),o.push({kind:"group.remove",casUnit:"logical",groupRef:e}),i.push({kind:"group.add",casUnit:"logical",groupRef:e,value:t.group.item}),{forward:o,invert:i.reverse()}}}}function gr(e,t){let o=!1;const i=a=>a.logical.groups.find(l=>l.modelId===e);return{label:"그룹에 편입",apply(a){const l=i(a);l&&!l.memberEntityRefs.includes(t)&&(l.memberEntityRefs.push(t),o=!0)},invert(a){if(!o)return;const l=i(a),r=(l==null?void 0:l.memberEntityRefs.indexOf(t))??-1;r>=0&&l.memberEntityRefs.splice(r,1)},emitOps(){return o?{forward:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}],invert:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}]}:{forward:[],invert:[]}}}}function Yo(e,t){let o=-1;const i=a=>a.logical.groups.find(l=>l.modelId===e);return{label:"그룹에서 제외",apply(a){const l=i(a);o=(l==null?void 0:l.memberEntityRefs.indexOf(t))??-1,o>=0&&l.memberEntityRefs.splice(o,1)},invert(a){var l;o<0||(l=i(a))==null||l.memberEntityRefs.splice(o,0,t)},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}],invert:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}]}}}}function br(e,t){let o=null;return{label:"그룹 이동",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.location},a.geo.location={...t}},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"groupLayout.move",casUnit:"layout",groupRef:e,value:{location:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function _r(e,t){let o=null;return{label:"그룹 크기 변경",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.size},a.geo.size={...t}},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"groupLayout.resize",casUnit:"layout",groupRef:e,value:{size:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function wr(e,t){let o;return{label:"그룹 색상 변경",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.style,a.style=Xn(a.style,t)},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&(a.style=o)},emitOps(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e),l=r=>({kind:"groupLayout.setStyle",casUnit:"layout",groupRef:e,value:{style:r}});return{forward:[l(a==null?void 0:a.style)],invert:[l(o)]}}}}function vr(e,t){let o;return{label:t?"그룹 잠금":"그룹 잠금 해제",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.locked,a.locked=t},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&(a.locked=o)},emitOps(){const i=a=>({kind:"groupLayout.setLocked",casUnit:"layout",groupRef:e,value:{locked:a}});return{forward:[i(t)],invert:[i(o)]}}}}function St(e,t){return{label:`속성 추가: ${t.name}`,apply(o){ze(o,e).attributes.push(t)},invert(o){const i=ze(o,e),a=i.attributes.findIndex(l=>l.modelId===t.modelId);a>=0&&i.attributes.splice(a,1)},emitOps(){return{forward:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:t}],invert:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t.modelId}]}}}}function en(e,t,o){const i={},a=l=>{const r=ze(l,e).attributes.find(s=>s.modelId===t);if(!r)throw new Error(`속성 없음: ${t}`);return r};return{label:"속성 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t,patch:o}],invert:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t,patch:{...i}}]}}}}function Nn(e,t){let o=null;return{label:"속성 삭제",apply(i){const a=ze(i,e),l=a.attributes.findIndex(r=>r.modelId===t);if(l<0)throw new Error(`속성 없음: ${t}`);o={item:a.attributes[l],index:l},a.attributes.splice(l,1)},invert(i){o&&ze(i,e).attributes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t}],invert:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function Ea(e,t,o){let i=null;return{label:"속성 재정렬",apply(a){const l=ze(a,e);i=l.attributes.map(f=>({...f}));const r=new Set(t),s=l.attributes.filter(f=>r.has(f.modelId)),c=l.attributes.filter(f=>!r.has(f.modelId)),d=Math.max(0,Math.min(o,c.length)),u=[...c.slice(0,d),...s,...c.slice(d)];l.attributes.splice(0,l.attributes.length,...u),l.attributes.forEach((f,p)=>f.order=p)},invert(a){i&&ze(a,e).attributes.splice(0,1/0,...i)},emitOps(a){const l=ze(a,e).attributes.map(r=>({...r}));return{forward:[{kind:"attribute.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:l}],invert:[{kind:"attribute.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:i??[]}]}}}}function kr(e,t){let o=!1;return{label:`메서드 추가: ${t.name}`,apply(i){const a=ze(i,e);a.operations||(a.operations=[],o=!0),a.operations.push(t)},invert(i){var r;const a=ze(i,e),l=((r=a.operations)==null?void 0:r.findIndex(s=>s.modelId===t.modelId))??-1;l>=0&&a.operations.splice(l,1),o&&a.operations&&a.operations.length===0&&(a.operations=void 0)},emitOps(){return{forward:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:t}],invert:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t.modelId}]}}}}function Er(e,t,o){const i={},a=l=>{var s;const r=(s=ze(l,e).operations)==null?void 0:s.find(c=>c.modelId===t);if(!r)throw new Error(`메서드 없음: ${t}`);return r};return{label:"메서드 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t,patch:o}],invert:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t,patch:{...i}}]}}}}function Nr(e,t){let o=null;return{label:"메서드 삭제",apply(i){var s;const a=ze(i,e),l=((s=a.operations)==null?void 0:s.findIndex(c=>c.modelId===t))??-1;if(l<0)throw new Error(`메서드 없음: ${t}`);const r=a.operations.length===1;o={item:a.operations[l],index:l,wasSole:r},a.operations.splice(l,1),r&&(a.operations=void 0)},invert(i){if(!o)return;const a=ze(i,e);a.operations||(a.operations=[]),a.operations.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t}],invert:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function $r(e,t,o){let i=null;return{label:"메서드 재정렬",apply(a){const l=ze(a,e),r=l.operations??[];i=r.map(p=>({...p}));const s=new Set(t),c=r.filter(p=>s.has(p.modelId)),d=r.filter(p=>!s.has(p.modelId)),u=Math.max(0,Math.min(o,d.length)),f=[...d.slice(0,u),...c,...d.slice(u)];r.splice(0,r.length,...f),r.forEach((p,m)=>p.order=m),l.operations=r},invert(a){if(!i)return;const l=ze(a,e);l.operations&&l.operations.splice(0,1/0,...i)},emitOps(a){const l=(ze(a,e).operations??[]).map(r=>({...r}));return{forward:[{kind:"operation.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:l}],invert:[{kind:"operation.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:i??[]}]}}}}function xr(e,t,o){let i;return{label:"메서드 색상 변경",apply(a){const l=je(a,e);if(l<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=a.layout.entityLayouts[l];i=r.operationStyles;const s={...r.operationStyles},c=Xn(s[t],o);c?s[t]=c:delete s[t],r.operationStyles=Object.keys(s).length?s:void 0},invert(a){const l=je(a,e);l>=0&&(a.layout.entityLayouts[l].operationStyles=i)},emitOps(a){const l=je(a,e),r=l>=0?a.layout.entityLayouts[l].operationStyles:void 0,s=c=>({kind:"entityLayout.setOpStyle",casUnit:"layout",entityRef:e,value:{operationStyles:c}});return{forward:[s(r)],invert:[s(i)]}}}}function Na(e,t){return{label:"관계 추가",apply(o){o.logical.associations.push(e),o.layout.associationLayouts.push(t)},invert(o){const i=o.logical.associations.findIndex(l=>l.modelId===e.modelId);i>=0&&o.logical.associations.splice(i,1);const a=o.layout.associationLayouts.findIndex(l=>l.associationRef===e.modelId);a>=0&&o.layout.associationLayouts.splice(a,1)},emitOps(){const o={kind:"association.add",casUnit:"logical",associationRef:e.modelId,value:e},i={kind:"associationLayout.add",casUnit:"layout",associationRef:e.modelId,value:t,incidental:!0};return{forward:[o,i],invert:[{kind:"associationLayout.remove",casUnit:"layout",associationRef:e.modelId,incidental:!0},{kind:"association.remove",casUnit:"logical",associationRef:e.modelId}]}}}}function Ir(e){let t=null;return{label:"관계 삭제",apply(o){const i=o.logical.associations.findIndex(l=>l.modelId===e);if(i<0)throw new Error(`관계 없음: ${e}`);const a=o.layout.associationLayouts.findIndex(l=>l.associationRef===e);t={assoc:{item:o.logical.associations[i],index:i},layout:a>=0?{item:o.layout.associationLayouts[a],index:a}:void 0},a>=0&&o.layout.associationLayouts.splice(a,1),o.logical.associations.splice(i,1)},invert(o){t&&(o.logical.associations.splice(t.assoc.index,0,t.assoc.item),t.layout&&o.layout.associationLayouts.splice(t.layout.index,0,t.layout.item))},emitOps(){if(!t)return{forward:[],invert:[]};const o=[],i=[];return t.layout&&(o.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:e,incidental:!0}),i.push({kind:"associationLayout.add",casUnit:"layout",associationRef:e,value:t.layout.item,incidental:!0})),o.push({kind:"association.remove",casUnit:"logical",associationRef:e}),i.push({kind:"association.add",casUnit:"logical",associationRef:e,value:t.assoc.item}),{forward:o,invert:i.reverse()}}}}function Wo(e,t){const o={},i=a=>{const l=a.logical.associations.find(r=>r.modelId===e);if(!l)throw new Error(`관계 없음: ${e}`);return l};return{label:"관계 수정",apply(a){const l=i(a);for(const r of Object.keys(t))o[r]=l[r];Object.assign(l,t)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:t}],invert:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:{...o}}]}}}}function $n(e,t,o){const i={},a=l=>{const r=l.logical.associations.find(s=>s.modelId===e);if(!r)throw new Error(`관계 없음: ${e}`);return r[t]};return{label:"관계 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:t,patch:o}],invert:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:t,patch:{...i}}]}}}}function Sr(e,t){return{label:"인덱스 추가",apply(o){const i=ze(o,e);(i.indexes??(i.indexes=[])).push(t)},invert(o){var l;const i=ze(o,e),a=((l=i.indexes)==null?void 0:l.findIndex(r=>r.modelId===t.modelId))??-1;a>=0&&i.indexes.splice(a,1)},emitOps(){return{forward:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:t}],invert:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t.modelId}]}}}}function Cr(e,t,o){const i={},a=l=>{var s;const r=(s=ze(l,e).indexes)==null?void 0:s.find(c=>c.modelId===t);if(!r)throw new Error(`인덱스 없음: ${t}`);return r};return{label:"인덱스 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t,patch:o}],invert:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t,patch:{...i}}]}}}}function Rr(e,t){let o=null;return{label:"인덱스 삭제",apply(i){var r;const a=ze(i,e),l=((r=a.indexes)==null?void 0:r.findIndex(s=>s.modelId===t))??-1;if(l<0)throw new Error(`인덱스 없음: ${t}`);o={item:a.indexes[l],index:l},a.indexes.splice(l,1)},invert(i){o&&ze(i,e).indexes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t}],invert:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}const bt=(e,t)=>({kind:"associationLayout.setWaypoints",casUnit:"layout",associationRef:e,value:{waypoints:t}}),jn=(e,t)=>{var o;return((o=ut(e,t))==null?void 0:o.waypoints.map(i=>({...i})))??[]};function Vr(e,t,o){let i=null;return{label:"waypoint 이동",coalesceKey:`waypoint:${e}`,apply(a){const l=ut(a,e);if(!l||!l.waypoints[t])throw new Error(`waypoint 없음: ${e}[${t}]`);i={...l.waypoints[t]},l.waypoints.splice(t,1,{...o})},invert(a){const l=ut(a,e);l&&i&&l.waypoints.splice(t,1,i)},emitOps(a){const l=jn(a,e),r=l.map((s,c)=>c===t&&i?{...i}:s);return{forward:[bt(e,l)],invert:[bt(e,r)]}}}}function Ar(e,t){let o=null;return{label:"waypoint 제거",apply(i){const a=ut(i,e);if(!a||!a.waypoints[t])throw new Error(`waypoint 없음: ${e}[${t}]`);o={...a.waypoints[t]},a.waypoints.splice(t,1)},invert(i){const a=ut(i,e);a&&o&&a.waypoints.splice(t,0,o)},emitOps(i){const a=jn(i,e),l=a.slice();return o&&l.splice(t,0,{...o}),{forward:[bt(e,a)],invert:[bt(e,l)]}}}}function Tr(e,t,o){let i=null;return{label:"waypoint 평행이동",apply(a){const l=ut(a,e);if(!l)throw new Error(`관계 레이아웃 없음: ${e}`);i=l.waypoints.map(r=>({...r})),l.waypoints=i.map(r=>({x:r.x+t,y:r.y+o}))},invert(a){const l=ut(a,e);l&&i&&(l.waypoints=i)},emitOps(a){return{forward:[bt(e,jn(a,e))],invert:[bt(e,i??[])]}}}}function Mr(e){let t=null;return{label:"꺾은선 풀기",apply(o){const i=ut(o,e);if(!i)throw new Error(`관계 레이아웃 없음: ${e}`);t=i.waypoints.map(a=>({...a})),i.waypoints=[]},invert(o){const i=ut(o,e);i&&t&&(i.waypoints=t)},emitOps(o){return{forward:[bt(e,jn(o,e))],invert:[bt(e,t??[])]}}}}function Br(e,t,o){return{label:"waypoint 추가",apply(i){const a=ut(i,e);if(!a)throw new Error(`관계 레이아웃 없음: ${e}`);a.waypoints.splice(t,0,{...o})},invert(i){const a=ut(i,e);a==null||a.waypoints.splice(t,1)},emitOps(i){const a=jn(i,e),l=a.slice();return l.splice(t,1),{forward:[bt(e,a)],invert:[bt(e,l)]}}}}function Dr(e){return{label:"노트 추가",apply(t){t.layout.notes.push(e)},invert(t){const o=t.layout.notes.findIndex(i=>i.modelId===e.modelId);o>=0&&t.layout.notes.splice(o,1)},emitOps(){return{forward:[{kind:"note.add",casUnit:"layout",noteRef:e.modelId,value:e}],invert:[{kind:"note.remove",casUnit:"layout",noteRef:e.modelId}]}}}}function Or(e){let t=null;return{label:"노트 삭제",apply(o){const i=o.layout.notes.findIndex(a=>a.modelId===e);if(i<0)throw new Error(`노트 없음: ${e}`);t={item:o.layout.notes[i],index:i},o.layout.notes.splice(i,1)},invert(o){t&&o.layout.notes.splice(t.index,0,t.item)},emitOps(){return t?{forward:[{kind:"note.remove",casUnit:"layout",noteRef:e}],invert:[{kind:"note.add",casUnit:"layout",noteRef:e,value:t.item}]}:{forward:[],invert:[]}}}}function Zn(e,t){let o=null;return{label:"노트 이동",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.location},a.geo.location={...t}},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"note.move",casUnit:"layout",noteRef:e,value:{location:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function Lr(e,t){let o=null;return{label:"노트 크기 변경",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.size},a.geo.size={...t}},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"note.resize",casUnit:"layout",noteRef:e,value:{size:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function Pr(e,t){let o="";return{label:"노트 내용 변경",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.memo,a.memo=t},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&(a.memo=o)},emitOps(){const i=a=>({kind:"note.setMemo",casUnit:"layout",noteRef:e,value:{memo:a}});return{forward:[i(t)],invert:[i(o)]}}}}function zr(e,t){let o;return{label:"노트 색상 변경",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.style,a.style=Xn(a.style,t)},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&(a.style=o)},emitOps(i){const a=i.layout.notes.find(r=>r.modelId===e),l=r=>({kind:"note.setStyle",casUnit:"layout",noteRef:e,value:{style:r}});return{forward:[l(a==null?void 0:a.style)],invert:[l(o)]}}}}function Ur(e,t){let o=!1,i=!1;const a=l=>l.layout.groupLayouts.find(r=>r.groupRef===e);return{label:"그룹에 노트 편입",apply(l){const r=a(l);r&&(r.memberNoteRefs||(r.memberNoteRefs=[],i=!0),!r.memberNoteRefs.includes(t)&&(r.memberNoteRefs.push(t),o=!0))},invert(l){if(!o)return;const r=a(l);if(!(r!=null&&r.memberNoteRefs))return;const s=r.memberNoteRefs.indexOf(t);s>=0&&r.memberNoteRefs.splice(s,1),i&&delete r.memberNoteRefs},emitOps(){return o?{forward:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:t}],invert:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:t}]}:{forward:[],invert:[]}}}}function Hr(e,t){let o=-1;const i=a=>a.layout.groupLayouts.find(l=>l.groupRef===e);return{label:"그룹에서 노트 제외",apply(a){var r;const l=i(a);o=((r=l==null?void 0:l.memberNoteRefs)==null?void 0:r.indexOf(t))??-1,o>=0&&l.memberNoteRefs.splice(o,1)},invert(a){if(o<0)return;const l=i(a);l&&(l.memberNoteRefs||(l.memberNoteRefs=[]),l.memberNoteRefs.splice(o,0,t))},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:t}],invert:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:t}]}}}}const zt=(e,t,o)=>({kind:"noteConnection.setWaypoints",casUnit:"layout",noteRef:e,targetRef:t,value:{waypoints:o}}),Ko=(e,t,o)=>{var i;return((i=It(e,t,o))==null?void 0:i.waypoints.map(a=>({...a})))??[]};function Fr(e,t){let o=!1,i=!1;return{label:"노트 연결 추가",apply(a){const l=a.layout.notes.find(r=>r.modelId===e);if(!l)throw new Error(`노트 없음: ${e}`);if(l.connections||(l.connections=[],i=!0),l.connections.some(r=>r.targetRef===t)){o=!1;return}l.connections.push({targetRef:t,waypoints:[]}),o=!0},invert(a){if(!o)return;const l=a.layout.notes.find(s=>s.modelId===e);if(!(l!=null&&l.connections))return;const r=l.connections.findIndex(s=>s.targetRef===t);r>=0&&l.connections.splice(r,1),i&&delete l.connections},emitOps(){return o?{forward:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:t,value:{targetRef:t,waypoints:[]}}],invert:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:t}]}:{forward:[],invert:[]}}}}function Gr(e,t){let o=null;return{label:"노트 연결 삭제",apply(i){var r;const a=i.layout.notes.find(s=>s.modelId===e),l=((r=a==null?void 0:a.connections)==null?void 0:r.findIndex(s=>s.targetRef===t))??-1;if(!(a!=null&&a.connections)||l<0)throw new Error(`노트 연결 없음: ${e}→${t}`);o={item:a.connections[l],index:l},a.connections.splice(l,1)},invert(i){if(!o)return;const a=i.layout.notes.find(l=>l.modelId===e);a!=null&&a.connections&&a.connections.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:t}],invert:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:t,value:o.item}]}:{forward:[],invert:[]}}}}function Yr(e,t,o,i){let a=null;return{label:"waypoint 이동",coalesceKey:`noteConnWaypoint:${e}:${t}`,apply(l){const r=It(l,e,t);if(!r||!r.waypoints[o])throw new Error(`waypoint 없음: ${e}→${t}[${o}]`);a={...r.waypoints[o]},r.waypoints.splice(o,1,{...i})},invert(l){const r=It(l,e,t);r&&a&&r.waypoints.splice(o,1,a)},emitOps(l){const r=Ko(l,e,t),s=r.map((c,d)=>d===o&&a?{...a}:c);return{forward:[zt(e,t,r)],invert:[zt(e,t,s)]}}}}function Wr(e,t,o,i){return{label:"waypoint 추가",apply(a){const l=It(a,e,t);if(!l)throw new Error(`노트 연결 없음: ${e}→${t}`);l.waypoints.splice(o,0,{...i})},invert(a){const l=It(a,e,t);l==null||l.waypoints.splice(o,1)},emitOps(a){const l=Ko(a,e,t),r=l.slice();return r.splice(o,1),{forward:[zt(e,t,l)],invert:[zt(e,t,r)]}}}}function Kr(e,t,o){let i=null;return{label:"waypoint 제거",apply(a){const l=It(a,e,t);if(!l||!l.waypoints[o])throw new Error(`waypoint 없음: ${e}→${t}[${o}]`);i={...l.waypoints[o]},l.waypoints.splice(o,1)},invert(a){const l=It(a,e,t);l&&i&&l.waypoints.splice(o,0,i)},emitOps(a){const l=Ko(a,e,t),r=l.slice();return i&&r.splice(o,0,{...i}),{forward:[zt(e,t,l)],invert:[zt(e,t,r)]}}}}function qr(e,t){let o=null;return{label:"꺾은선 풀기",apply(i){const a=It(i,e,t);if(!a)throw new Error(`노트 연결 없음: ${e}→${t}`);o=a.waypoints.map(l=>({...l})),a.waypoints=[]},invert(i){const a=It(i,e,t);a&&o&&(a.waypoints=o)},emitOps(i){return{forward:[zt(e,t,Ko(i,e,t))],invert:[zt(e,t,o??[])]}}}}function Ue(e,t,o){return{label:e,coalesceKey:o,apply(i){for(const a of t)a.apply(i)},invert(i){for(let a=t.length-1;a>=0;a--)t[a].invert(i)},emitOps(i){const a=t.map(l=>{if(!l.emitOps)throw new Error(`emitOps 미구현 command가 composite에 포함됨: ${l.label}`);return l.emitOps(i)});return{forward:a.flatMap(l=>l.forward),invert:a.slice().reverse().flatMap(l=>l.invert)}}}}const Mf=Object.freeze(Object.defineProperty({__proto__:null,addAssociation:Na,addAttribute:St,addEntity:wa,addEntityToGroup:gr,addGroup:ka,addIndex:Sr,addNote:Dr,addNoteConnection:Fr,addNoteConnectionWaypoint:Wr,addNoteToGroup:Ur,addOperation:kr,addWaypoint:Br,clearNoteConnectionWaypoints:qr,clearWaypoints:Mr,composite:Ue,moveEntity:En,moveGroup:br,moveNote:Zn,moveNoteConnectionWaypoint:Yr,moveWaypoint:Vr,removeAssociation:Ir,removeAttribute:Nn,removeEntity:sr,removeEntityFromGroup:Yo,removeGroup:yr,removeIndex:Rr,removeNote:Or,removeNoteConnection:Gr,removeNoteConnectionWaypoint:Kr,removeNoteFromGroup:Hr,removeOperation:Nr,removeWaypoint:Ar,renameEntity:dr,reorderAttributes:Ea,reorderOperations:$r,resizeEntity:ur,resizeGroup:_r,resizeNote:Lr,setAllEntitiesCollapsed:va,setAttributeSwatch:Go,setEntityCollapsed:mr,setEntityLocked:pr,setEntitySwatch:fr,setGroupLocked:vr,setGroupSwatch:wr,setNoteMemo:Pr,setNoteSwatch:zr,setOperationSwatch:xr,translateWaypoints:Tr,updateAssociation:Wo,updateAssociationEnd:$n,updateAttribute:en,updateEntity:cr,updateGroup:hr,updateIndex:Cr,updateOperation:Er},Symbol.toStringTag,{value:"Module"}));class Xr{constructor(){Ye(this,"revs",new Map);Ye(this,"layoutVersion",0);Ye(this,"logicalVersion",0)}seed(t){this.revs.clear();for(const[o,i]of Object.entries(t.revs??{}))this.revs.set(o,i);this.layoutVersion=t.layoutVersion??0,this.logicalVersion=t.logicalVersion??0}rev(t){return this.revs.get(t)??0}setRev(t,o){this.revs.set(t,o)}deleteRev(t){this.revs.delete(t)}snapshot(){return{revs:Object.fromEntries(this.revs),layoutVersion:this.layoutVersion,logicalVersion:this.logicalVersion}}}class jr{constructor(t){Ye(this,"cache",new Xr);Ye(this,"newClientOpId");Ye(this,"debounceMs");Ye(this,"emissions",new WeakMap);Ye(this,"open",null);Ye(this,"debounceHandle",null);Ye(this,"queue",[]);Ye(this,"sending",!1);Ye(this,"_frozen",!1);Ye(this,"stack",null);Ye(this,"settledWaiters",[]);this.opts=t,this.newClientOpId=t.newClientOpId??Me,this.debounceMs=t.debounceMs??300}seed(t){this.cache.seed(t)}attach(t){this.stack=t;const o=t.onCommand((i,a,l)=>this.handle(i,a,l));return()=>{o(),this.stack===t&&(this.stack=null)}}get frozen(){return this._frozen}get hasPending(){return this.open!==null||this.queue.length>0||this.sending}cacheSnapshot(){return this.cache.snapshot()}flush(){this.flushOpen(!0)}whenSettled(){return this.hasPending?new Promise(t=>this.settledWaiters.push(t)):Promise.resolve()}handle(t,o,i){var r;if(this._frozen)return;let a;if(o==="do"){const s=(r=t.emitOps)==null?void 0:r.call(t,this.opts.state);if(!s)throw new Error(`op-mode에서 emitOps 미구현 command 실행: ${t.label}`);a=s}else{const s=this.emissions.get(t);if(!s)throw new Error(`op-mode ${o} 대상 command의 emission 미기록: ${t.label}`);a=s}const l=o==="undo"?a.invert:a.forward;if(o==="do"&&i&&this.open&&this.open.coalesceKey===t.coalesceKey){this.open.fwd=l,this.emissions.set(t,{forward:l,invert:this.open.inv}),this.resetDebounce();return}if(this.flushOpen(!1),o==="do"&&(this.emissions.set(t,a),t.coalesceKey!=null)){this.open={coalesceKey:t.coalesceKey,fwd:l,inv:a.invert},this.startDebounce();return}l.length&&this.enqueue(this.buildBatch(l))}flushOpen(t){var i;this.cancelDebounce();const o=this.open;this.open=null,o&&o.fwd.length&&this.enqueue(this.buildBatch(o.fwd)),t&&((i=this.stack)==null||i.sealCoalesce())}startDebounce(){this.cancelDebounce(),this.debounceHandle=setTimeout(()=>{this.debounceHandle=null,this.flushOpen(!0)},this.debounceMs)}resetDebounce(){this.startDebounce()}cancelDebounce(){this.debounceHandle!=null&&(clearTimeout(this.debounceHandle),this.debounceHandle=null)}buildBatch(t){const o={},i=new Set;let a=!1,l=!1;for(const r of t)if(r.casUnit==="logical")if(a=!0,r.containerRef)i.add(r.containerRef);else{const s=r.entityRef??r.associationRef??r.groupRef;s&&(r.kind.endsWith(".add")?this.cache.setRev(s,0):r.kind.endsWith(".remove")&&this.cache.deleteRev(s))}else r.incidental||(l=!0);if(i.size){o.revs={};for(const r of i){const s=this.cache.rev(r);o.revs[r]=s,this.cache.setRev(r,s+1)}}return l&&(o.layout=this.cache.layoutVersion,this.cache.layoutVersion=o.layout+1),a&&(this.cache.logicalVersion+=1),{diagramId:this.opts.diagramId,ops:t,cas:o,origin:this.opts.origin??"gui",clientOpId:this.newClientOpId()}}enqueue(t){this.queue.push(t),this.pump()}async pump(){var i,a;if(this.sending||this._frozen)return;const t=this.queue.shift();if(!t){this.notifySettled();return}this.sending=!0;let o=null;try{o=await this.opts.transport(t)}catch(l){this.sending=!1,console.error("[op-sync] op 전송 실패 → 하드 프리즈(kind:missing):",l),(a=(i=this.opts).onError)==null||a.call(i,l),this.freeze({kind:"missing"});return}this.sending=!1,o.ok?(this.reconcile(o),this.pump()):this.freeze(o.conflict)}reconcile(t){if(!(this.queue.length>0)){for(const[o,i]of Object.entries(t.revs))this.cache.setRev(o,i);this.cache.layoutVersion=t.layoutVersion,this.cache.logicalVersion=t.logicalVersion}}freeze(t){var o,i;this._frozen=!0,this.queue.length=0,this.open=null,this.cancelDebounce(),(i=(o=this.opts).onFreeze)==null||i.call(o,t),this.notifySettled()}notifySettled(){if(this.hasPending)return;const t=this.settledWaiters;this.settledWaiters=[];for(const o of t)o()}}const Zr=["entity.add","entity.update","entity.remove","attribute.add","attribute.update","attribute.remove","association.add","association.remove","association.update","associationEnd.update","index.add","index.update","index.remove","operation.add","operation.update","operation.remove","group.add"],Jr=()=>crypto.randomUUID(),Bf=e=>e.add.length===0&&e.update.length===0&&e.remove.length===0,Df=e=>e&&e[0].toLowerCase()+e.slice(1),Of=e=>e&&e[0].toUpperCase()+e.slice(1),Lf=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase();function Pf(e,t){return Df(e)+Of(t)}function zf(e,t){const o=e.entities.find(r=>r.modelId===t.end1.entityRef);if(!o)return[];if(o.stereotype==="JPA_EMBEDDABLE")return[];const a=t.end1.entityRef===t.end2.entityRef?!1:t.identifying===!0;return o.attributes.filter(r=>r.identifier&&(r.attrType==="NORMAL"||r.attrType==="RELATION_OWN")).sort((r,s)=>r.order-s.order).map(r=>{const s=Pf(o.name,r.name);return{associationRef:t.modelId,sourceAttributeRef:r.modelId,name:s,type:r.type,identifier:a,notNull:a,dbAttrs:r.dbAttrs.map(c=>({physicalName:Lf(s),logicalName:c.logicalName,dataType:c.dataType,length:c.length,scale:c.scale}))}})}const qo=(e,t)=>`${e}::${t}`,Xo=e=>e??void 0;function Uf(e,t,o){const i={};return e.type!==t.type&&(i.type=t.type),e.identifier!==t.identifier&&(i.identifier=t.identifier),e.notNull!==t.notNull&&(i.notNull=t.notNull),(e.dbAttrs.length!==t.dbAttrs.length||t.dbAttrs.some((l,r)=>{const s=e.dbAttrs[r];return!s||s.dataType!==l.dataType||Xo(s.length)!==Xo(l.length)||Xo(s.scale)!==Xo(l.scale)}))&&(i.dbAttrs=t.dbAttrs.map((l,r)=>{const s=e.dbAttrs[r];return{modelId:(s==null?void 0:s.modelId)??o(),physicalName:(s==null?void 0:s.physicalName)??l.physicalName,logicalName:(s==null?void 0:s.logicalName)??l.logicalName,dataType:l.dataType,length:l.length,scale:l.scale}})),Object.keys(i).length?i:null}function Hf(e,t,o){return{modelId:o(),name:e.name,type:e.type,attrType:"RELATION_OWN",identifier:e.identifier,notNull:e.notNull,order:t,dbAttrs:e.dbAttrs.map(i=>({...i,modelId:o()})),derivedFrom:{associationRef:e.associationRef,sourceAttributeRef:e.sourceAttributeRef}}}function Jn(e,t,o=Jr){const i={add:[],update:[],remove:[]},a=e.entities.find(f=>f.modelId===t);if(!a)return i;const l=e.associations.filter(f=>f.end2.entityRef===t),r=a.stereotype==="JPA_EMBEDDABLE"?[]:l.flatMap(f=>zf(e,f)),s=new Map(r.map(f=>[qo(f.associationRef,f.sourceAttributeRef),f])),c=a.attributes.filter(f=>f.derivedFrom),d=new Map(c.map(f=>[qo(f.derivedFrom.associationRef,f.derivedFrom.sourceAttributeRef),f]));for(const f of c){const p=qo(f.derivedFrom.associationRef,f.derivedFrom.sourceAttributeRef);s.has(p)||i.remove.push(f.modelId)}let u=a.attributes.reduce((f,p)=>Math.max(f,p.order),-1)+1;for(const f of r){const p=qo(f.associationRef,f.sourceAttributeRef),m=d.get(p);if(!m)i.add.push(Hf(f,u++,o));else{const h=Uf(m,f,o);h&&i.update.push({attributeId:m.modelId,patch:h})}}return i}function Ff(e,t){if(t.remove.length){const o=new Set(t.remove);e.attributes=e.attributes.filter(i=>!o.has(i.modelId))}for(const o of t.update){const i=e.attributes.find(a=>a.modelId===o.attributeId);i&&Object.assign(i,o.patch)}t.add.length&&e.attributes.push(...t.add)}function Gf(e){return{...e,entities:e.entities.map(t=>({...t,attributes:t.attributes.map(o=>({...o}))}))}}function Yf(e,t,o=Jr){const i=new Map,a=Gf(e),l=new Set,r=[t];for(;r.length;){const s=r.shift();if(l.has(s))continue;l.add(s);const c=new Set(a.associations.filter(d=>d.end1.entityRef===s).map(d=>d.end2.entityRef));for(const d of c){const u=Jn(a,d,o);if(Bf(u))continue;i.has(d)||i.set(d,u);const f=a.entities.find(p=>p.modelId===d);f&&Ff(f,u),l.has(d)||r.push(d)}}return i}function jo(e,t,o){const i=e.entities.find(l=>l.modelId===t),a=i==null?void 0:i.attributes.find(l=>l.modelId===o);if(!(!a||!a.attrType.startsWith("RELATION")||a.dbAttrs.length===0))return e.associations.find(l=>l.end1.entityRef===t&&l.end1.attributeRef===o||l.end2.entityRef===t&&l.end2.attributeRef===o)}function Wf(e,t){const o=()=>e.entities.filter(l=>{var r;return((r=l.table)==null?void 0:r.physicalName)===t.ref}),i=()=>e.entities.filter(l=>l.name===t.ref);if(t.by==="physicalName")return o();if(t.by==="name")return i();const a=o();return a.length?a:i()}function Kf(e,t){const o=()=>e.attributes.filter(l=>l.name===t.ref),i=()=>e.attributes.filter(l=>l.dbAttrs.some(r=>r.physicalName===t.ref));if(t.by==="name")return o();if(t.by==="physicalName")return i();const a=o();return a.length?a:i()}function Qr(e,t,o){return e.associations.filter(i=>{const a=[i.end1.entityRef,i.end2.entityRef];return a.includes(t)&&a.includes(o)})}function ot(e,t){const o=Wf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function qf(e,t){const o=Kf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Xf(e,t){const o=()=>e.attributes.flatMap(l=>l.dbAttrs).filter(l=>l.physicalName===t.ref),i=()=>e.attributes.filter(l=>l.name===t.ref).flatMap(l=>l.dbAttrs);if(t.by==="physicalName")return o();if(t.by==="name")return i();const a=o();return a.length?a:i()}function es(e,t){const o=Xf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function jf(e,t){return(e.indexes??[]).filter(o=>o.name===t.ref)}function Zf(e,t){return(e.operations??[]).filter(o=>o.name===t.ref)}function Jf(e,t){const o=jf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Qf(e,t){const o=Zf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function ts(e,t,o){const i=e.physicalName!=null||e.dataType!=null||e.length!=null||e.scale!=null||e.columnLogicalName!=null||e.unique!=null||e.updatable!=null;return{modelId:o(),name:e.name,type:e.type,attrType:"NORMAL",identifier:e.identifier??!1,notNull:e.notNull??!1,order:t,...e.transient?{transient:!0}:{},...e.groupCode?{groupCode:e.groupCode}:{},...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},dbAttrs:i?[{modelId:o(),physicalName:e.physicalName??e.name,dataType:e.dataType??"",...e.length?{length:e.length}:{},...e.scale?{scale:e.scale}:{},...e.columnLogicalName?{logicalName:e.columnLogicalName}:{},...e.unique!=null?{unique:e.unique}:{},...e.updatable!=null?{updatable:e.updatable}:{}}]:[]}}function ns(e,t,o,i,a,l,r,s){const c=s(),d=new Map((e.embeddableOverrides??[]).map(p=>[p.field,p])),u=[];let f=!1;for(const p of t.fields){const m=d.get(p.name);if(m!=null&&m.sharedColumnPhysicalName){const h={ref:m.sharedColumnPhysicalName,by:"physicalName"},_=es(i,h);if(!_.ok){r.push(_.reason==="not-found"?{code:"shared-column-target-not-found",opIndex:a,entity:l,handle:h}:{code:"shared-column-target-ambiguous",opIndex:a,entity:l,handle:h,matches:_.matches}),f=!0;continue}u.push({modelId:s(),physicalName:"",dataType:"",sharedColumnRef:_.value.modelId});continue}u.push({modelId:s(),physicalName:(m==null?void 0:m.physicalName)??"",dataType:"",...m!=null&&m.length?{length:m.length}:{},...m!=null&&m.scale?{scale:m.scale}:{},...(m==null?void 0:m.insertable)!=null?{insertable:m.insertable}:{},...(m==null?void 0:m.updatable)!=null?{updatable:m.updatable}:{}})}return f?null:{modelId:c,name:e.name,type:t.type,attrType:"EMBED_PREDEF",identifier:e.identifier??!1,notNull:e.notNull??!1,order:o,...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},dbAttrs:u}}function os(e,t,o){return{modelId:o(),name:e.name,order:t,...e.visibility?{visibility:e.visibility}:{},...e.sourceCode?{sourceCode:e.sourceCode}:{},...e.description?{description:e.description}:{},...e.personalInfoAttributeType?{personalInfoAttributeType:e.personalInfoAttributeType}:{}}}function is(e,t,o,i,a,l){const r=[];let s=!1;for(const c of t.columns){const d=es(e,c.column);if(!d.ok){a.push(d.reason==="not-found"?{code:"column-not-found",opIndex:o,entity:i,handle:c.column}:{code:"column-ambiguous",opIndex:o,entity:i,handle:c.column,matches:d.matches}),s=!0;continue}r.push({columnRef:d.value.modelId,descending:c.descending??!1})}return s?null:{modelId:l(),name:t.name,unique:t.unique??!1,columns:r,...t.description?{description:t.description}:{},...t.parameters?{parameters:t.parameters}:{}}}function em(e,t,o={}){const i=o.mkId??Me,a=o.embeddableCatalog??[],l=f=>a.find(p=>p.type===f),r=[],s=[],c=new Map,d=new Map,u=new Set;for(const f of t)f.kind==="entity.add"&&(u.add(f.spec.name),f.spec.physicalName&&u.add(f.spec.physicalName));return t.forEach((f,p)=>{var m,h,_;switch(f.kind){case"entity.add":{const b=i(),g={modelId:b,name:f.spec.name,stereotype:f.spec.stereotype??"JPA_ENTITY",attributes:[],...f.spec.useVersion?{jpaAttrs:{useVersion:!0}}:{},...f.spec.physicalName?{table:{physicalName:f.spec.physicalName}}:{}},I={ref:f.spec.name};let y=!1;for(const[U,X]of(f.spec.attributes??[]).entries()){if(X.type==="GroupCodeEnum"&&!X.groupCode){s.push({code:"groupcode-required",opIndex:p,entity:I,handle:{ref:X.name}}),y=!0;continue}const K=l(X.type);if(K){const W=ns(X,K,U,g,p,I,s,i);W?g.attributes.push(W):y=!0}else(m=X.embeddableOverrides)!=null&&m.length?(s.push({code:"embeddable-type-unresolved",opIndex:p,entity:I,handle:{ref:X.name}}),y=!0):g.attributes.push(ts(X,U,i))}const N=(f.spec.operations??[]).map((U,X)=>os(U,X,i));N.length&&(g.operations=N);const q=[];for(const U of f.spec.indexes??[]){const X=is(g,U,p,I,s,i);X?q.push(X):y=!0}if(q.length&&(g.indexes=q),y)break;r.push({kind:"entity.add",casUnit:"logical",entityRef:b,value:g});break}case"entity.update":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}r.push({kind:"entity.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,patch:f.patch});break}case"entity.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}r.push({kind:"entity.remove",casUnit:"logical",entityRef:b.value.modelId});break}case"attribute.add":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}if(f.spec.type==="GroupCodeEnum"&&!f.spec.groupCode){s.push({code:"groupcode-required",opIndex:p,entity:f.entity,handle:{ref:f.spec.name}});break}const g=c.get(b.value.modelId)??b.value.attributes.length;c.set(b.value.modelId,g+1);const I=l(f.spec.type);let y;if(I)y=ns(f.spec,I,g,b.value,p,f.entity,s,i);else if((h=f.spec.embeddableOverrides)!=null&&h.length){s.push({code:"embeddable-type-unresolved",opIndex:p,entity:f.entity,handle:{ref:f.spec.name}});break}else y=ts(f.spec,g,i);if(!y)break;r.push({kind:"attribute.add",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,value:y});break}case"attribute.update":case"attribute.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=qf(b.value,f.attribute);if(!g.ok){s.push(g.reason==="not-found"?{code:"attribute-not-found",opIndex:p,entity:f.entity,handle:f.attribute}:{code:"attribute-ambiguous",opIndex:p,entity:f.entity,handle:f.attribute,matches:g.matches});break}f.kind==="attribute.update"?r.push({kind:"attribute.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,attributeRef:g.value.modelId,patch:f.patch}):r.push({kind:"attribute.remove",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,attributeRef:g.value.modelId});break}case"association.add":{const b=ot(e,f.spec.from),g=ot(e,f.spec.to);if(b.ok||s.push(it(b.reason,p,f.spec.from,b.matches,u)),g.ok||s.push(it(g.reason,p,f.spec.to,g.matches,u)),!b.ok||!g.ok)break;if(f.spec.identifying&&b.value.modelId===g.value.modelId){s.push({code:"self-identifying",opIndex:p,handle:{from:f.spec.from,to:f.spec.to}});break}const I=i(),y={modelId:I,...f.spec.identifying!=null?{identifying:f.spec.identifying}:{},end1:{entityRef:b.value.modelId,multiplicity:f.spec.fromMultiplicity??"EXACTLY_ONE_INSTANCE",navigable:!0,composition:!1},end2:{entityRef:g.value.modelId,multiplicity:f.spec.toMultiplicity??"ZERO_OR_MORE_INSTANCES",navigable:!0,composition:f.spec.composition??!1}},N={...e,associations:[...e.associations,y]},q=Jn(N,g.value.modelId,i);q.add[0]&&(y.end2.attributeRef=q.add[0].modelId),r.push({kind:"association.add",casUnit:"logical",associationRef:I,value:y});for(const U of q.add)r.push({kind:"attribute.add",casUnit:"logical",containerRef:g.value.modelId,entityRef:g.value.modelId,value:U});break}case"association.remove":{const b=ot(e,f.association.from),g=ot(e,f.association.to);if(b.ok||s.push(it(b.reason,p,f.association.from,b.matches,u)),g.ok||s.push(it(g.reason,p,f.association.to,g.matches,u)),!b.ok||!g.ok)break;const I=Qr(e,b.value.modelId,g.value.modelId);if(I.length!==1){s.push(I.length===0?{code:"association-not-found",opIndex:p,handle:f.association}:{code:"association-ambiguous",opIndex:p,handle:f.association,matches:I.map(y=>y.modelId)});break}r.push({kind:"association.remove",casUnit:"logical",associationRef:I[0].modelId});break}case"association.update":{const b=as(e,f.association,p,s,u);if(!b)break;r.push({kind:"association.update",casUnit:"logical",containerRef:b.modelId,associationRef:b.modelId,patch:f.patch});break}case"associationEnd.update":{const b=as(e,f.association,p,s,u);if(!b)break;const g=f.end==="from"?"end1":"end2";r.push({kind:"associationEnd.update",casUnit:"logical",containerRef:b.modelId,associationRef:b.modelId,end:g,patch:f.patch});break}case"index.add":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=is(b.value,f.spec,p,f.entity,s,i);if(!g)break;r.push({kind:"index.add",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,indexRef:g.modelId,value:g});break}case"index.update":case"index.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=Jf(b.value,f.index);if(!g.ok){s.push(g.reason==="not-found"?{code:"index-not-found",opIndex:p,entity:f.entity,handle:f.index}:{code:"index-ambiguous",opIndex:p,entity:f.entity,handle:f.index,matches:g.matches});break}if(f.kind==="index.update"){if("columns"in f.patch){s.push({code:"index-columns-patch-unsupported",opIndex:p,entity:f.entity,handle:f.index});break}r.push({kind:"index.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,indexRef:g.value.modelId,patch:f.patch})}else r.push({kind:"index.remove",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,indexRef:g.value.modelId});break}case"operation.add":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=d.get(b.value.modelId)??((_=b.value.operations)==null?void 0:_.length)??0;d.set(b.value.modelId,g+1);const I=os(f.spec,g,i);r.push({kind:"operation.add",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,operationRef:I.modelId,value:I});break}case"operation.update":case"operation.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=Qf(b.value,f.operation);if(!g.ok){s.push(g.reason==="not-found"?{code:"operation-not-found",opIndex:p,entity:f.entity,handle:f.operation}:{code:"operation-ambiguous",opIndex:p,entity:f.entity,handle:f.operation,matches:g.matches});break}f.kind==="operation.update"?r.push({kind:"operation.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,operationRef:g.value.modelId,patch:f.patch}):r.push({kind:"operation.remove",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,operationRef:g.value.modelId});break}case"group.add":{const b=[];let g=!1;for(const N of f.spec.members){const q=ot(e,N);if(!q.ok){s.push(it(q.reason,p,N,q.matches,u)),g=!0;continue}b.push(q.value.modelId)}if(g)break;const I=i(),y={modelId:I,excludeDDLGeneration:f.spec.excludeDDLGeneration??!1,memberEntityRefs:b,...f.spec.name?{name:f.spec.name}:{},...f.spec.packageName?{packageName:f.spec.packageName}:{},...f.spec.description?{description:f.spec.description}:{}};r.push({kind:"group.add",casUnit:"logical",groupRef:I,value:y});break}}}),s.length?{ok:!1,errors:s}:{ok:!0,ops:r}}function it(e,t,o,i,a){return e==="not-found"&&(a!=null&&a.has(o.ref))?{code:"pending-entity-ref",opIndex:t,handle:o}:e==="not-found"?{code:"entity-not-found",opIndex:t,handle:o}:{code:"entity-ambiguous",opIndex:t,handle:o,matches:i}}function as(e,t,o,i,a){const l=ot(e,t.from),r=ot(e,t.to);if(l.ok||i.push(it(l.reason,o,t.from,l.matches,a)),r.ok||i.push(it(r.reason,o,t.to,r.matches,a)),!l.ok||!r.ok)return null;const s=Qr(e,l.value.modelId,r.value.modelId);return s.length!==1?(i.push(s.length===0?{code:"association-not-found",opIndex:o,handle:t}:{code:"association-ambiguous",opIndex:o,handle:t,matches:s.map(c=>c.modelId)}),null):s[0]}const ls={type:"object",description:"요소 지정 핸들. 엔티티: 물리명(table.physicalName) 우선, 논리명(name) 보조. 속성: 소속 엔티티 내 속성명 또는 컬럼 물리명.",properties:{ref:{type:"string",description:"매칭할 이름/물리명."},by:{type:"string",enum:["physicalName","name"],description:"매칭 키 고정(미지정 시 대상별 기본 순서)."}},required:["ref"],additionalProperties:!1},tm={type:"object",description:"관계는 무명이라 양 끝 엔티티로 주소. from=부모(end1), to=자식(end2). 같은 쌍 복수 관계는 모호 보고.",properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"}},required:["from","to"],additionalProperties:!1},nm={type:"object",description:"신규 엔티티. 자식(속성·인덱스·operation)은 별도 attribute.add 등이 아니라 여기 inline 배열로 담아라 — 같은 배치에서 갓 추가된 엔티티에 닿는 child op은 silent no-op이 된다(서버가 pending-entity-ref로 거부). 관계는 inline 불가 → 엔티티 추가 배치 확정 후 별도 배치로 association.add.",properties:{name:{type:"string"},stereotype:{type:"string",enum:["UNDEFINED","JPA_ENTITY","JPA_EMBEDDABLE","JPA_MULTI_LANGUAGE_ENTITY"],description:"기본 JPA_ENTITY."},physicalName:{type:"string",description:"설정 시 table.physicalName."},useVersion:{type:"boolean",description:'JPA @Version(낙관적 락) → jpaAttrs.useVersion. @Version 필드는 별도 속성이 아니라 이 엔티티 플래그로 흡수 (버전 컬럼은 코드젠 소유). 기존 엔티티는 entity.update patch의 dotted key {"jpaAttrs.useVersion":true} 사용.'},attributes:{type:"array",description:"inline 속성(배열 순서가 order). attribute.add와 동일 규칙 — GroupCodeEnum은 groupCode 동반 필수.",items:{$ref:"#/$defs/attrSpec"}},indexes:{type:"array",description:"inline 인덱스. 컬럼 핸들은 이 엔티티가 inline으로 만드는 dbAttr 내에서 해소된다(attributes 동반 전제).",items:{$ref:"#/$defs/indexSpec"}},operations:{type:"array",description:"inline 도메인 메서드(배열 순서가 order).",items:{$ref:"#/$defs/operationSpec"}}},required:["name"],additionalProperties:!1},Zo={type:"object",properties:{ko:{type:"string"},en:{type:"string"},ja:{type:"string"},zh:{type:"string"}},additionalProperties:!1},om={type:"object",properties:{name:{type:"string"},type:{type:"string",description:"Java 타입(예: Long, String). GroupCodeEnum은 파생 타입이라 groupCode 동반 필수(없으면 거부). 호스트 임베더블 카탈로그에 등록된 predefined 임베더블 타입(예: Money, EmbeddableAddress)이면 EMBED_PREDEF로 다중 컬럼 확장(서브컬럼 조정은 embeddableOverrides)."},identifier:{type:"boolean"},notNull:{type:"boolean"},transient:{type:"boolean",description:"JPA @Transient(비영속) → Attribute.transient. 컬럼을 만들지 않으므로 physicalName/dataType 등 컬럼 필드는 함께 주지 않는다. 기존 속성은 attribute.update patch {transient:true}로도 가능."},physicalName:{type:"string",description:"설정 시 단일 dbAttr 컬럼 생성(미설정이면 name을 물리명으로)."},dataType:{type:"string",description:"dbAttr 물리 타입(예: BIGINT). physicalName/dataType/length/scale 중 하나라도 있으면 컬럼 생성."},length:{type:"integer",description:"dbAttr 컬럼 길이(VARCHAR(n)·DECIMAL precision)."},scale:{type:"integer",description:"dbAttr 소수 자릿수(DECIMAL/NUMERIC scale). length 동반이 일반적."},groupCode:{type:"string",description:"코드성 속성의 group code 바인딩. type=GroupCodeEnum이면 필수."},defaultValue:{type:"string",description:"속성 기본값(문자열 패스스루)."},attributeGroup:{type:"string",description:"속성 분류 그룹(예: 'code'·'amt')."},description:{...Zo,description:"속성 설명(다국어)."},columnLogicalName:{...Zo,description:'dbAttr 컬럼 논리명(다국어, 예: {ko:"체크아웃유형"}). 한글 업무명 보존 위치.'},unique:{type:"boolean",description:"dbAttr UNIQUE 제약."},updatable:{type:"boolean",description:"dbAttr 갱신 가능(JPA @Column(updatable=))."},embeddableOverrides:{type:"array",description:"predefined 임베더블 서브컬럼 오버라이드(type이 카탈로그 엔트리일 때만). field=카탈로그 필드명으로 매칭 (@AttributeOverride 대응). 미설정 서브컬럼은 카탈로그 기본 상속. currency 등 공유 컬럼은 sharedColumnPhysicalName으로 SHARED_REF.",items:{type:"object",properties:{field:{type:"string",description:"대상 카탈로그 필드명(예: amount·currency)."},physicalName:{type:"string",description:"서브컬럼 물리명 오버라이드(@AttributeOverride column name). 미설정 시 카탈로그 기본."},length:{type:"integer",description:"서브컬럼 길이 오버라이드."},scale:{type:"integer",description:"서브컬럼 소수 자릿수 오버라이드."},insertable:{type:"boolean",description:"JPA @Column(insertable=). OWN 컬럼에만 저장."},updatable:{type:"boolean",description:"JPA @Column(updatable=). OWN 컬럼에만 저장."},sharedColumnPhysicalName:{type:"string",description:"SHARED_REF — 같은 엔터티 다른 컬럼(물리명)을 공유해 read-only 투영(대표: currency). 설정 시 자체 컬럼 미보유, 타깃은 해소 시점 존재 필수."}},required:["field"],additionalProperties:!1}}},required:["name","type"],additionalProperties:!1},rs={type:"string",enum:["NO_INSTANCE_OR_ONE_INSTANCE","EXACTLY_ONE_INSTANCE","ZERO_OR_MORE_INSTANCES","ONE_OR_MORE_INSTANCES"]},im={type:"object",properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"},fromMultiplicity:{...rs,description:"end1 다중성(기본 EXACTLY_ONE_INSTANCE)."},toMultiplicity:{...rs,description:"end2 다중성(기본 ZERO_OR_MORE_INSTANCES)."},identifying:{type:"boolean",description:"식별 관계(부모 PK가 자식 PK로 전파). self-association은 식별 불가."},composition:{type:"boolean",description:"end2 composition."}},required:["from","to"],additionalProperties:!1},am={type:"object",properties:{name:{type:"string"},unique:{type:"boolean",description:"UNIQUE 인덱스 여부(기본 false)."},columns:{type:"array",description:"인덱스 컬럼(순서 의미 있음).",items:{type:"object",properties:{column:{...ls,description:"컬럼 핸들 — 컬럼 물리명 우선, 속성명 보조(단일 컬럼 속성만). 엔티티 내에서 dbAttr modelId로 해소."},descending:{type:"boolean",description:"내림차순(기본 false)."}},required:["column"],additionalProperties:!1}},description:{type:"string",description:"인덱스 설명(평문)."},parameters:{type:"string",description:"인덱스 파라미터(패스스루)."}},required:["name","columns"],additionalProperties:!1},lm={type:"object",properties:{name:{type:"string"},visibility:{type:"string",enum:["PUBLIC","PRIVATE","PROTECTED","PACKAGE"],description:"가시성(기본 미설정)."},sourceCode:{type:"string",description:"Java 메서드 본문(멀티라인, 파라미터·반환 시그니처 포함)."},description:{...Zo,description:"메서드 설명(다국어)."},personalInfoAttributeType:{type:"string",description:"개인정보 속성 유형(패스스루)."}},required:["name"],additionalProperties:!1},rm={type:"object",properties:{name:{...Zo,description:'그룹 논리명(다국어, 예: {ko:"주문"}).'},packageName:{type:"string",description:"자바 패키지명 등 그룹 물리 식별(레거시 LogicalGroup.packageName)."},description:{type:"string",description:"그룹 설명(자유 텍스트 — 도메인 경계 메모)."},excludeDDLGeneration:{type:"boolean",description:"DDL 생성 제외(기본 false)."},members:{type:"array",description:"멤버 엔티티 핸들(물리명 우선/논리명 보조). 기존 엔티티여야 함 — 같은 배치 신규 엔티티는 별도 배치 후.",items:{$ref:"#/$defs/handle"}}},required:["members"],additionalProperties:!1},sm={type:"object",description:"부분 patch(임의 키). 값 품질 검증은 별도 엔진."};function et(e,t){return{type:"object",properties:{kind:{const:e},...t.properties},required:["kind",...t.required],additionalProperties:!1}}const cm={"entity.add":et("entity.add",{properties:{spec:{$ref:"#/$defs/entitySpec"}},required:["spec"]}),"entity.update":et("entity.update",{properties:{entity:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","patch"]}),"entity.remove":et("entity.remove",{properties:{entity:{$ref:"#/$defs/handle"}},required:["entity"]}),"attribute.add":et("attribute.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/attrSpec"}},required:["entity","spec"]}),"attribute.update":et("attribute.update",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","attribute","patch"]}),"attribute.remove":et("attribute.remove",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"}},required:["entity","attribute"]}),"association.add":et("association.add",{properties:{spec:{$ref:"#/$defs/assocSpec"}},required:["spec"]}),"association.remove":et("association.remove",{properties:{association:{$ref:"#/$defs/assocHandle"}},required:["association"]}),"association.update":et("association.update",{properties:{association:{$ref:"#/$defs/assocHandle"},patch:{$ref:"#/$defs/patch"}},required:["association","patch"]}),"associationEnd.update":et("associationEnd.update",{properties:{association:{$ref:"#/$defs/assocHandle"},end:{type:"string",enum:["from","to"],description:"from=부모(end1), to=자식(end2)."},patch:{$ref:"#/$defs/patch"}},required:["association","end","patch"]}),"index.add":et("index.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/indexSpec"}},required:["entity","spec"]}),"index.update":et("index.update",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","index","patch"]}),"index.remove":et("index.remove",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/handle"}},required:["entity","index"]}),"operation.add":et("operation.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/operationSpec"}},required:["entity","spec"]}),"operation.update":et("operation.update",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","operation","patch"]}),"operation.remove":et("operation.remove",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/handle"}},required:["entity","operation"]}),"group.add":et("group.add",{properties:{spec:{$ref:"#/$defs/groupSpec"}},required:["spec"]})},ss={anyOf:Zr.map(e=>cm[e])},dm={type:"object",description:"엔티티 모델을 생성·수정·삭제할 때 호출한다. ops는 사람 핸들(엔티티 물리명/논리명, 속성명)로 지정하며 서버가 modelId로 해소한다. 모호하면 에러로 후보를 돌려주니 리소스로 현재 모델을 먼저 읽어 핸들을 확정하라.",properties:{ops:{type:"array",items:{$ref:"#/$defs/symbolicOp"}}},required:["ops"],additionalProperties:!1,$defs:{handle:ls,assocHandle:tm,entitySpec:nm,attrSpec:om,assocSpec:im,indexSpec:am,operationSpec:lm,groupSpec:rm,patch:sm,symbolicOp:ss}};function um(e,t,o,i={}){const a=i.mkClientOpId??Me,l=new Set;for(const s of o)s.casUnit==="logical"&&s.containerRef&&l.add(s.containerRef);const r={};if(l.size){r.revs={};for(const s of l)r.revs[s]=t[s]??0}return{diagramId:e,ops:o,cas:r,origin:i.origin??"agent",clientOpId:a()}}const cs={location:{x:0,y:0},size:{width:220,height:140}};function ds(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}const fm=/^[-=_*~\s]{3,}$/;function mm(e){return e.attrType&&e.attrType!=="NORMAL"||!fm.test(e.name??"")?!1:!(e.dbAttrs??[]).some(t=>t.physicalName||t.dataType)}function pm(e,t){return e.attrType==="DIVIDER"||mm(e)?{modelId:e.modelId,name:e.attrType==="DIVIDER"?e.name:"",type:"",attrType:"DIVIDER",identifier:!1,notNull:!1,order:e.order??t,dbAttrs:[]}:{modelId:e.modelId,name:e.name,type:e.type,customType:e.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order??t,dbAttrs:e.dbAttrs.map(ds)}}function hm(e){const{modelId:t,name:o,visibility:i,sourceCode:a,description:l,order:r,personalInfoAttributeType:s,style:c,...d}=e;return{modelId:t,name:o,visibility:i,sourceCode:a,description:l?{ko:l}:void 0,order:r??0,personalInfoAttributeType:s,legacyRaw:Object.keys(d).length?d:void 0}}function ym(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,columns:e.indexColumns.map(t=>({columnRef:t.targetColumn.refId,descending:t.descending}))}}function gm(e){var t,o;return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.map(pm),operations:(t=e.operations)==null?void 0:t.map(hm),indexes:(o=e.indexes)==null?void 0:o.map(ym),jpaAttrs:e.jpaAttrs,table:e.dbAttrs?{physicalName:e.dbAttrs.physicalName,logicalName:e.dbAttrs.logicalName}:void 0}}function bm(e){const t={};for(const i of e.attributes)i.style&&(t[i.modelId]=i.style);const o={};for(const i of e.operations??[])i.style&&(o[i.modelId]=i.style);return{entityRef:e.modelId,geo:e.geo??{...cs},style:e.style,attributeStyles:Object.keys(t).length?t:void 0,operationStyles:Object.keys(o).length?o:void 0,collapsed:e.collapsed,locked:e.locked}}function us(e){return e.jpaAttribute?{fetchType:e.jpaAttribute.fetchType,cascadeTypes:e.jpaAttribute.cascadeTypes,orphanRemoval:e.jpaAttribute.orphanRemoval,orderBy:e.jpaAttribute.orderBy,collectionType:e.jpaAttribute.collectionType,collectionTable:e.jpaAttribute.collectionTable,orderColumn:e.jpaAttribute.orderColumn}:void 0}function $a(e){var t;return{entityRef:e.endModel.refId,multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,attributeRef:(t=e.attribute)==null?void 0:t.modelId,jpa:us(e)}}function _m(e){var i,a;const t={modelId:e.modelId,description:e.description,end1:$a(e.end1),end2:$a(e.end2)},o={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:(i=e.end1.attribute)==null?void 0:i.modelId,targetColumnRef:(a=e.end2.attribute)==null?void 0:a.modelId,style:e.style};return{assoc:t,layout:o}}function fs(e){var t;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("RELATION")&&(((t=e.dbAttrs)==null?void 0:t.length)??0)>0}function ms(e){var t;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("EMBED")&&(((t=e.dbAttrs)==null?void 0:t.length)??0)>0}function ps(e){var o;const t=e.attribute;return(t==null?void 0:t.attrType)==="EMBED_OWN"&&(((o=t.dbAttrs)==null?void 0:o.length)??0)===0&&(e.multiplicity==="ZERO_OR_MORE_INSTANCES"||e.multiplicity==="ONE_OR_MORE_INSTANCES")}function hs(e,t){return{modelId:e.modelId,name:e.name??"",type:e.type??"",customType:e.customType,attrType:e.attrType??"RELATION_OWN",identifier:e.identifier??!1,notNull:e.notNull??!1,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:t,dbAttrs:(e.dbAttrs??[]).map(ds)}}function wm(e,t,o){var b,g;const i=fs(e.end1.attribute),a=fs(e.end2.attribute);if(i===a)return _m(e);const l=i?e.end1:e.end2,r=i?e.end2:e.end1,s=l.attribute,c=(g=(b=s.dbAttrs)==null?void 0:b[0])==null?void 0:g.targetModelId,d=c?o.get(c):void 0,u=t.get(r.endModel.refId),f=u?u.attributes.reduce((I,y)=>Math.max(I,y.order),-1)+1:s.order??0,p={...hs(s,f),attrType:"RELATION_OWN",derivedFrom:d?{associationRef:e.modelId,sourceAttributeRef:d}:void 0};u&&u.attributes.push(p);const m=(I,y)=>({entityRef:I.endModel.refId,multiplicity:I.multiplicity,navigable:I.navigable,composition:I.composition,attributeRef:y?d:p.modelId,legacyNavRaw:y?void 0:I.attribute,jpa:us(I)}),h={modelId:e.modelId,description:e.description,end1:m(e.end1,i),end2:m(e.end2,a)},_={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:h.end1.attributeRef,targetColumnRef:h.end2.attributeRef,style:e.style};return{assoc:h,layout:_}}function vm(e,t){const o=e.targetModelId?t.get(e.targetModelId):void 0;return{modelId:e.modelId,physicalName:e.physicalName||(o==null?void 0:o.physicalName)||"",logicalName:e.logicalName??(o==null?void 0:o.logicalName),dataType:e.dataType||(o==null?void 0:o.dataType)||"",length:e.length??(o==null?void 0:o.length),scale:e.scale??(o==null?void 0:o.scale),unique:e.unique??(o==null?void 0:o.unique),autoIncrement:e.autoIncrement??(o==null?void 0:o.autoIncrement),updatable:e.updatable??(o==null?void 0:o.updatable),insertable:e.insertable??(o==null?void 0:o.insertable)}}function km(e,t,o){var h;const i=((h=e.end1.attribute)==null?void 0:h.attrType)==="EMBED_OWN",a=i?e.end1:e.end2,l=i?e.end2:e.end1,r=a.attribute,s=t.get(l.endModel.refId),c=s?s.attributes.reduce((_,b)=>Math.max(_,b.order),-1)+1:r.order??0,d={...hs(r,c),attrType:r.attrType??"EMBED_OWN",dbAttrs:(r.dbAttrs??[]).map(_=>vm(_,o)),embedded:{associationRef:e.modelId,embeddableRef:a.endModel.refId}};s&&s.attributes.push(d);const u=_=>({...$a(_),legacyEmbedRaw:_.attribute}),f={modelId:e.modelId,description:e.description,end1:u(e.end1),end2:u(e.end2)},p=!i,m={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:p?d.modelId:void 0,targetColumnRef:p?void 0:d.modelId,style:e.style};return{assoc:f,layout:m}}function Em(e,t){var i,a,l,r;const o=[];for(const s of t){const c=(a=(i=s.end1)==null?void 0:i.endModel)==null?void 0:a.refId,d=(r=(l=s.end2)==null?void 0:l.endModel)==null?void 0:r.refId,u=c===e?d:c;!u||u===e||o.push({targetRef:u,waypoints:s.locations??[]})}return o}function ys(e,t={x:0,y:0}){const{modelId:o,memo:i,geo:a,style:l,connections:r,ownedConnections:s,...c}=e;let d=r;if(!d&&Array.isArray(s)){const u=Em(o,s);u.length&&(d=u)}return{modelId:o,memo:i,geo:{location:{x:a.location.x+t.x,y:a.location.y+t.y},size:a.size},style:l,connections:d,legacyRaw:Object.keys(c).length?c:void 0}}function Nm(e){return(e.schemaVersion??1)>=2&&"logical"in e?$m(e):xm(e)}function $m(e){const t=e.id??e.logical.modelId??"",o={},i=f=>{const{rev:p,...m}=f;return p!=null&&(o[f.modelId]=p),m},a=e.logical.entities.map(i),l=e.logical.associations.map(i),r=e.logical.groups.map(i),{version:s,...c}=e.layout,d={logical:{modelId:e.logical.modelId??t,packageName:e.logical.packageName,entities:a,associations:l,groups:r},layout:{...c,diagramId:c.diagramId??t,logicalModelRef:c.logicalModelRef??t}},u={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion,opWriteEnabled:e.opWriteEnabled,revSeed:{revs:o,layoutVersion:s??0,logicalVersion:e.logical.version??0}};return{state:d,meta:u}}function xm(e){var g,I;const t=e.id??"",o=[],i=[],a=[],l=[],r=[],s=[],c=[],d=(y,N)=>{o.push(gm(y));const q=bm(y);q.geo={location:{x:q.geo.location.x+N.x,y:q.geo.location.y+N.y},size:q.geo.size},i.push(q);for(const U of y.ownedAssociations??[])c.push(U)},u={x:0,y:0};for(const y of e.entities??[])d(y,u);const f=[];for(const y of e.groups??[]){const N=y.entities??[];r.push({modelId:y.modelId,name:y.name,description:y.description,packageName:y.packageName,excludeDDLGeneration:y.excludeDDLGeneration??!1,memberEntityRefs:N.map(U=>U.modelId)});const q=((g=y.geo)==null?void 0:g.location)??u;if(y.geo){const U=(y.notes??[]).map(X=>X.modelId);s.push({groupRef:y.modelId,geo:y.geo,style:y.style,locked:y.locked,memberNoteRefs:U.length?U:void 0})}for(const U of N)d(U,q);for(const U of y.notes??[])f.push(ys(U,q))}const p=new Map(o.map(y=>[y.modelId,y])),m=new Map,h=new Map;for(const y of o)for(const N of y.attributes)for(const q of N.dbAttrs)m.set(q.modelId,N.modelId),h.set(q.modelId,q);for(const y of c)for(const N of[y.end1,y.end2]){const q=N.attribute;if(q&&(((I=q.dbAttrs)==null?void 0:I.length)??0)>0)for(const U of q.dbAttrs)U.modelId&&m.set(U.modelId,q.modelId)}for(const y of c){const N=ms(y.end1.attribute),q=ms(y.end2.attribute),U=ps(y.end1)||ps(y.end2),{assoc:X,layout:K}=N!==q||U?km(y,p,h):wm(y,p,m);a.push(X),l.push(K)}const _={logical:{modelId:t,packageName:e.packageName,entities:o,associations:a,groups:r},layout:{diagramId:t,logicalModelRef:t,canvasSize:e.size,entityLayouts:i,associationLayouts:l,groupLayouts:s,notes:[...(e.notes??[]).map(y=>ys(y)),...f]}},b={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion??1};return{state:_,meta:b}}function gs(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}function Im(e,t){return{modelId:e.modelId,name:e.name,type:e.type,customType:e.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient_:e.transient,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order,dbAttrs:e.dbAttrs.map(gs),style:t}}function Sm(e,t){var o;return{...e.legacyRaw,modelId:e.modelId,name:e.name,visibility:e.visibility,sourceCode:e.sourceCode,description:(o=e.description)==null?void 0:o.ko,order:e.order,personalInfoAttributeType:e.personalInfoAttributeType,style:t}}function Cm(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,indexColumns:e.columns.map(t=>({targetColumn:{refId:t.columnRef},descending:t.descending}))}}function Ut(e,t){return{endModel:{refId:e.entityRef},multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,jpaAttribute:e.jpa,attribute:t??(e.attributeRef?{modelId:e.attributeRef}:void 0)}}function Rm(e,t){const o=t==null?void 0:t.attributes.find(i=>{var a;return i.modelId===((a=e.derivedFrom)==null?void 0:a.sourceAttributeRef)});return{modelId:e.modelId,name:e.name,type:e.type,attrType:"RELATION_REF",identifier:e.identifier,notNull:e.notNull,transient_:e.transient,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,order:e.order,dbAttrs:e.dbAttrs.map((i,a)=>{var l;return{...gs(i),targetModelId:(l=o==null?void 0:o.dbAttrs[a])==null?void 0:l.modelId}})}}function Vm(e){const t=new Set;for(const o of e.logical.associations){const i=o.end1.legacyNavRaw?o.end1:o.end2.legacyNavRaw?o.end2:void 0;i!=null&&i.attributeRef&&t.add(i.attributeRef)}return t}function Am(e){const t=new Set;for(const o of e.logical.entities)for(const i of o.attributes)i.embedded&&t.add(i.modelId);return t}function Tm(e,t){return e===t||JSON.stringify(e??null)===JSON.stringify(t??null)}function Mm(e,t){const o=(i,a)=>i===a?void 0:i;return{modelId:e.modelId,targetModelId:t==null?void 0:t.modelId,physicalName:e.physicalName===((t==null?void 0:t.physicalName)??"")?"":e.physicalName,logicalName:Tm(e.logicalName,t==null?void 0:t.logicalName)?void 0:e.logicalName,dataType:e.dataType===((t==null?void 0:t.dataType)??"")?"":e.dataType,length:o(e.length,t==null?void 0:t.length),scale:o(e.scale,t==null?void 0:t.scale),unique:o(e.unique,t==null?void 0:t.unique),autoIncrement:o(e.autoIncrement,t==null?void 0:t.autoIncrement),updatable:o(e.updatable,t==null?void 0:t.updatable),insertable:o(e.insertable,t==null?void 0:t.insertable)}}function Bm(e,t,o){let i;for(const f of t.logical.entities){const p=f.attributes.find(m=>{var h;return((h=m.embedded)==null?void 0:h.associationRef)===e.modelId});if(p){i=p;break}}if(!i)return;const a=i.embedded.embeddableRef,l=t.logical.entities.find(f=>f.modelId===a);if(!l)return;const r=l.attributes.flatMap(f=>f.dbAttrs),s={modelId:i.modelId,name:i.name,type:i.type,attrType:i.attrType,identifier:i.identifier,notNull:i.notNull,transient_:i.transient,description:i.description,attributeGroup:i.attributeGroup,groupCode:i.groupCode,order:i.order,dbAttrs:i.dbAttrs.map((f,p)=>Mm(f,r[p]))},c=e.end1.entityRef===a,d=c?e.end2:e.end1,u=d.attributeRef?{modelId:d.attributeRef,attrType:"EMBED_REF",dbAttrs:[]}:void 0;return{...o,end1:Ut(e.end1,c?s:u),end2:Ut(e.end2,c?u:s)}}function Dm(e,t,o){const i={modelId:e.modelId,description:e.description,locations:(o==null?void 0:o.waypoints)??[],style:o==null?void 0:o.style};if(e.end1.legacyEmbedRaw||e.end2.legacyEmbedRaw)return{...i,end1:Ut(e.end1,e.end1.legacyEmbedRaw),end2:Ut(e.end2,e.end2.legacyEmbedRaw)};const a=Bm(e,t,i);if(a)return a;const l=!!e.end1.legacyNavRaw,r=!!e.end2.legacyNavRaw;if(l!==r){const s=l?e.end1:e.end2,c=l?e.end2:e.end1,d=t.logical.entities.find(h=>h.modelId===s.entityRef),u=d==null?void 0:d.attributes.find(h=>h.modelId===s.attributeRef),f=t.logical.entities.find(h=>h.modelId===c.entityRef),p=u?Rm(u,f):void 0,m=s.legacyNavRaw;return{...i,end1:Ut(e.end1,l?m:p),end2:Ut(e.end2,r?m:p)}}return{...i,end1:Ut(e.end1),end2:Ut(e.end2)}}function bs(e,t,o,i,a={x:0,y:0}){var u,f;const l=t.layout.entityLayouts.find(p=>p.entityRef===e.modelId),r=t.logical.associations.filter(p=>p.end1.entityRef===e.modelId),s=p=>t.layout.associationLayouts.find(m=>m.associationRef===p),c=(l==null?void 0:l.geo)??{...cs},d={location:{x:c.location.x-a.x,y:c.location.y-a.y},size:c.size};return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.filter(p=>!o.has(p.modelId)&&!i.has(p.modelId)).map(p=>{var m;return Im(p,(m=l==null?void 0:l.attributeStyles)==null?void 0:m[p.modelId])}),operations:(u=e.operations)==null?void 0:u.map(p=>{var m;return Sm(p,(m=l==null?void 0:l.operationStyles)==null?void 0:m[p.modelId])}),ownedAssociations:r.map(p=>Dm(p,t,s(p.modelId))),indexes:(f=e.indexes)==null?void 0:f.map(Cm),jpaAttrs:e.jpaAttrs,dbAttrs:e.table?{physicalName:e.table.physicalName,logicalName:e.table.logicalName}:void 0,geo:d,style:l==null?void 0:l.style,collapsed:l==null?void 0:l.collapsed,locked:l==null?void 0:l.locked}}function Om(e,t,o,i){const a=t.layout.groupLayouts.find(c=>c.groupRef===e.modelId),l=e.memberEntityRefs.map(c=>t.logical.entities.find(d=>d.modelId===c)).filter(c=>!!c),r=(a==null?void 0:a.geo.location)??{x:0,y:0},s=((a==null?void 0:a.memberNoteRefs)??[]).map(c=>t.layout.notes.find(d=>d.modelId===c)).filter(c=>!!c).map(c=>_s(c,r));return{modelId:e.modelId,name:e.name,description:e.description,packageName:e.packageName,excludeDDLGeneration:e.excludeDDLGeneration,entities:l.map(c=>bs(c,t,o,i,r)),notes:s.length?s:void 0,geo:a==null?void 0:a.geo,style:a==null?void 0:a.style,locked:a==null?void 0:a.locked}}function _s(e,t={x:0,y:0}){return{...e.legacyRaw,modelId:e.modelId,memo:e.memo,geo:{location:{x:e.geo.location.x-t.x,y:e.geo.location.y-t.y},size:e.geo.size},style:e.style,connections:e.connections}}function Lm(e,t={}){const o=new Set(e.logical.groups.flatMap(s=>s.memberEntityRefs)),i=e.logical.entities.filter(s=>!o.has(s.modelId)),a=Vm(e),l=Am(e),r=new Set(e.layout.groupLayouts.flatMap(s=>s.memberNoteRefs??[]));return{id:t.id,diagramVersion:t.diagramVersion,version:t.version,size:t.size??e.layout.canvasSize,packageName:t.packageName??e.logical.packageName,entities:i.map(s=>bs(s,e,a,l)),groups:e.logical.groups.map(s=>Om(s,e,a,l)),notes:e.layout.notes.filter(s=>!r.has(s.modelId)).map(s=>_s(s))}}function Pm(e,t={}){var a,l,r;const o=((a=t.revSeed)==null?void 0:a.revs)??{},i=s=>({...s,rev:o[s.modelId]??0});return{id:t.id,schemaVersion:2,opWriteEnabled:t.opWriteEnabled,version:t.version,diagramVersion:t.diagramVersion,packageName:t.packageName,size:t.size,logical:{version:((l=t.revSeed)==null?void 0:l.logicalVersion)??0,modelId:e.logical.modelId,packageName:e.logical.packageName,entities:e.logical.entities.map(i),associations:e.logical.associations.map(i),groups:e.logical.groups.map(i)},layout:{...e.layout,version:((r=t.revSeed)==null?void 0:r.layoutVersion)??0}}}function Qn(e){return n.getCurrentScope()?(n.onScopeDispose(e),!0):!1}function Ct(e){return typeof e=="function"?e():n.unref(e)}const zm=typeof window<"u"&&typeof document<"u",Um=e=>typeof e<"u",Hm=Object.prototype.toString,Fm=e=>Hm.call(e)==="[object Object]",Gm=()=>{};function Ym(e,t){function o(...i){return new Promise((a,l)=>{Promise.resolve(e(()=>t.apply(this,i),{fn:t,thisArg:this,args:i})).then(a).catch(l)})}return o}const ws=e=>e();function Wm(e=ws){const t=n.ref(!0);function o(){t.value=!1}function i(){t.value=!0}const a=(...l)=>{t.value&&e(...l)};return{isActive:n.readonly(t),pause:o,resume:i,eventFilter:a}}function vs(e,t=!1,o="Timeout"){return new Promise((i,a)=>{setTimeout(t?()=>a(o):i,e)})}function Km(e,t,o={}){const{eventFilter:i=ws,...a}=o;return n.watch(e,Ym(i,t),a)}function xn(e,t,o={}){const{eventFilter:i,...a}=o,{eventFilter:l,pause:r,resume:s,isActive:c}=Wm(i);return{stop:Km(e,t,{...a,eventFilter:l}),pause:r,resume:s,isActive:c}}function qm(e,t={}){if(!n.isRef(e))return n.toRefs(e);const o=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(const i in e.value)o[i]=n.customRef(()=>({get(){return e.value[i]},set(a){var l;if((l=Ct(t.replaceRef))!=null?l:!0)if(Array.isArray(e.value)){const s=[...e.value];s[i]=a,e.value=s}else{const s={...e.value,[i]:a};Object.setPrototypeOf(s,Object.getPrototypeOf(e.value)),e.value=s}else e.value[i]=a}}));return o}function xa(e,t=!1){function o(f,{flush:p="sync",deep:m=!1,timeout:h,throwOnTimeout:_}={}){let b=null;const I=[new Promise(y=>{b=n.watch(e,N=>{f(N)!==t&&(b==null||b(),y(N))},{flush:p,deep:m,immediate:!0})})];return h!=null&&I.push(vs(h,_).then(()=>Ct(e)).finally(()=>b==null?void 0:b())),Promise.race(I)}function i(f,p){if(!n.isRef(f))return o(N=>N===f,p);const{flush:m="sync",deep:h=!1,timeout:_,throwOnTimeout:b}=p??{};let g=null;const y=[new Promise(N=>{g=n.watch([e,f],([q,U])=>{t!==(q===U)&&(g==null||g(),N(q))},{flush:m,deep:h,immediate:!0})})];return _!=null&&y.push(vs(_,b).then(()=>Ct(e)).finally(()=>(g==null||g(),Ct(e)))),Promise.race(y)}function a(f){return o(p=>!!p,f)}function l(f){return i(null,f)}function r(f){return i(void 0,f)}function s(f){return o(Number.isNaN,f)}function c(f,p){return o(m=>{const h=Array.from(m);return h.includes(f)||h.includes(Ct(f))},p)}function d(f){return u(1,f)}function u(f=1,p){let m=-1;return o(()=>(m+=1,m>=f),p)}return Array.isArray(Ct(e))?{toMatch:o,toContains:c,changed:d,changedTimes:u,get not(){return xa(e,!t)}}:{toMatch:o,toBe:i,toBeTruthy:a,toBeNull:l,toBeNaN:s,toBeUndefined:r,changed:d,changedTimes:u,get not(){return xa(e,!t)}}}function Ia(e){return xa(e)}function Xm(e){var t;const o=Ct(e);return(t=o==null?void 0:o.$el)!=null?t:o}const ks=zm?window:void 0;function Es(...e){let t,o,i,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([o,i,a]=e,t=ks):[t,o,i,a]=e,!t)return Gm;Array.isArray(o)||(o=[o]),Array.isArray(i)||(i=[i]);const l=[],r=()=>{l.forEach(u=>u()),l.length=0},s=(u,f,p,m)=>(u.addEventListener(f,p,m),()=>u.removeEventListener(f,p,m)),c=n.watch(()=>[Xm(t),Ct(a)],([u,f])=>{if(r(),!u)return;const p=Fm(f)?{...f}:f;l.push(...o.flatMap(m=>i.map(h=>s(u,m,h,p))))},{immediate:!0,flush:"post"}),d=()=>{c(),r()};return Qn(d),d}function jm(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function Ns(...e){let t,o,i={};e.length===3?(t=e[0],o=e[1],i=e[2]):e.length===2?typeof e[1]=="object"?(t=!0,o=e[0],i=e[1]):(t=e[0],o=e[1]):(t=!0,o=e[0]);const{target:a=ks,eventName:l="keydown",passive:r=!1,dedupe:s=!1}=i,c=jm(t);return Es(a,l,u=>{u.repeat&&Ct(s)||c(u)&&o(u)},r)}function Zm(e){return JSON.parse(JSON.stringify(e))}function Sa(e,t,o,i={}){var a,l,r;const{clone:s=!1,passive:c=!1,eventName:d,deep:u=!1,defaultValue:f,shouldEmit:p}=i,m=n.getCurrentInstance(),h=o||(m==null?void 0:m.emit)||((a=m==null?void 0:m.$emit)==null?void 0:a.bind(m))||((r=(l=m==null?void 0:m.proxy)==null?void 0:l.$emit)==null?void 0:r.bind(m==null?void 0:m.proxy));let _=d;t||(t="modelValue"),_=_||`update:${t.toString()}`;const b=y=>s?typeof s=="function"?s(y):Zm(y):y,g=()=>Um(e[t])?b(e[t]):f,I=y=>{p?p(y)&&h(_,y):h(_,y)};if(c){const y=g(),N=n.ref(y);let q=!1;return n.watch(()=>e[t],U=>{q||(q=!0,N.value=b(U),n.nextTick(()=>q=!1))}),n.watch(N,U=>{!q&&(U!==e[t]||u)&&I(U)},{deep:u}),N}else return n.computed({get(){return g()},set(y){I(y)}})}var Jm={value:()=>{}};function Jo(){for(var e=0,t=arguments.length,o={},i;e<t;++e){if(!(i=arguments[e]+"")||i in o||/[\s.]/.test(i))throw new Error("illegal type: "+i);o[i]=[]}return new Qo(o)}function Qo(e){this._=e}function Qm(e,t){return e.trim().split(/^|\s+/).map(function(o){var i="",a=o.indexOf(".");if(a>=0&&(i=o.slice(a+1),o=o.slice(0,a)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:i}})}Qo.prototype=Jo.prototype={constructor:Qo,on:function(e,t){var o=this._,i=Qm(e+"",o),a,l=-1,r=i.length;if(arguments.length<2){for(;++l<r;)if((a=(e=i[l]).type)&&(a=ep(o[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++l<r;)if(a=(e=i[l]).type)o[a]=$s(o[a],e.name,t);else if(t==null)for(a in o)o[a]=$s(o[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new Qo(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var o=new Array(a),i=0,a,l;i<a;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],i=0,a=l.length;i<a;++i)l[i].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],a=0,l=i.length;a<l;++a)i[a].value.apply(t,o)}};function ep(e,t){for(var o=0,i=e.length,a;o<i;++o)if((a=e[o]).name===t)return a.value}function $s(e,t,o){for(var i=0,a=e.length;i<a;++i)if(e[i].name===t){e[i]=Jm,e=e.slice(0,i).concat(e.slice(i+1));break}return o!=null&&e.push({name:t,value:o}),e}var Ca="http://www.w3.org/1999/xhtml";const xs={svg:"http://www.w3.org/2000/svg",xhtml:Ca,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ei(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),xs.hasOwnProperty(t)?{space:xs[t],local:e}:e}function tp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Ca&&t.documentElement.namespaceURI===Ca?t.createElement(e):t.createElementNS(o,e)}}function np(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Is(e){var t=ei(e);return(t.local?np:tp)(t)}function op(){}function Ra(e){return e==null?op:function(){return this.querySelector(e)}}function ip(e){typeof e!="function"&&(e=Ra(e));for(var t=this._groups,o=t.length,i=new Array(o),a=0;a<o;++a)for(var l=t[a],r=l.length,s=i[a]=new Array(r),c,d,u=0;u<r;++u)(c=l[u])&&(d=e.call(c,c.__data__,u,l))&&("__data__"in c&&(d.__data__=c.__data__),s[u]=d);return new st(i,this._parents)}function ap(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function lp(){return[]}function Ss(e){return e==null?lp:function(){return this.querySelectorAll(e)}}function rp(e){return function(){return ap(e.apply(this,arguments))}}function sp(e){typeof e=="function"?e=rp(e):e=Ss(e);for(var t=this._groups,o=t.length,i=[],a=[],l=0;l<o;++l)for(var r=t[l],s=r.length,c,d=0;d<s;++d)(c=r[d])&&(i.push(e.call(c,c.__data__,d,r)),a.push(c));return new st(i,a)}function Cs(e){return function(){return this.matches(e)}}function Rs(e){return function(t){return t.matches(e)}}var cp=Array.prototype.find;function dp(e){return function(){return cp.call(this.children,e)}}function up(){return this.firstElementChild}function fp(e){return this.select(e==null?up:dp(typeof e=="function"?e:Rs(e)))}var mp=Array.prototype.filter;function pp(){return Array.from(this.children)}function hp(e){return function(){return mp.call(this.children,e)}}function yp(e){return this.selectAll(e==null?pp:hp(typeof e=="function"?e:Rs(e)))}function gp(e){typeof e!="function"&&(e=Cs(e));for(var t=this._groups,o=t.length,i=new Array(o),a=0;a<o;++a)for(var l=t[a],r=l.length,s=i[a]=[],c,d=0;d<r;++d)(c=l[d])&&e.call(c,c.__data__,d,l)&&s.push(c);return new st(i,this._parents)}function Vs(e){return new Array(e.length)}function bp(){return new st(this._enter||this._groups.map(Vs),this._parents)}function ti(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ti.prototype={constructor:ti,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function _p(e){return function(){return e}}function wp(e,t,o,i,a,l){for(var r=0,s,c=t.length,d=l.length;r<d;++r)(s=t[r])?(s.__data__=l[r],i[r]=s):o[r]=new ti(e,l[r]);for(;r<c;++r)(s=t[r])&&(a[r]=s)}function vp(e,t,o,i,a,l,r){var s,c,d=new Map,u=t.length,f=l.length,p=new Array(u),m;for(s=0;s<u;++s)(c=t[s])&&(p[s]=m=r.call(c,c.__data__,s,t)+"",d.has(m)?a[s]=c:d.set(m,c));for(s=0;s<f;++s)m=r.call(e,l[s],s,l)+"",(c=d.get(m))?(i[s]=c,c.__data__=l[s],d.delete(m)):o[s]=new ti(e,l[s]);for(s=0;s<u;++s)(c=t[s])&&d.get(p[s])===c&&(a[s]=c)}function kp(e){return e.__data__}function Ep(e,t){if(!arguments.length)return Array.from(this,kp);var o=t?vp:wp,i=this._parents,a=this._groups;typeof e!="function"&&(e=_p(e));for(var l=a.length,r=new Array(l),s=new Array(l),c=new Array(l),d=0;d<l;++d){var u=i[d],f=a[d],p=f.length,m=Np(e.call(u,u&&u.__data__,d,i)),h=m.length,_=s[d]=new Array(h),b=r[d]=new Array(h),g=c[d]=new Array(p);o(u,f,_,b,g,m,t);for(var I=0,y=0,N,q;I<h;++I)if(N=_[I]){for(I>=y&&(y=I+1);!(q=b[y])&&++y<h;);N._next=q||null}}return r=new st(r,i),r._enter=s,r._exit=c,r}function Np(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function $p(){return new st(this._exit||this._groups.map(Vs),this._parents)}function xp(e,t,o){var i=this.enter(),a=this,l=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),o==null?l.remove():o(l),i&&a?i.merge(a).order():a}function Ip(e){for(var t=e.selection?e.selection():e,o=this._groups,i=t._groups,a=o.length,l=i.length,r=Math.min(a,l),s=new Array(a),c=0;c<r;++c)for(var d=o[c],u=i[c],f=d.length,p=s[c]=new Array(f),m,h=0;h<f;++h)(m=d[h]||u[h])&&(p[h]=m);for(;c<a;++c)s[c]=o[c];return new st(s,this._parents)}function Sp(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var i=e[t],a=i.length-1,l=i[a],r;--a>=0;)(r=i[a])&&(l&&r.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(r,l),l=r);return this}function Cp(e){e||(e=Rp);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var o=this._groups,i=o.length,a=new Array(i),l=0;l<i;++l){for(var r=o[l],s=r.length,c=a[l]=new Array(s),d,u=0;u<s;++u)(d=r[u])&&(c[u]=d);c.sort(t)}return new st(a,this._parents).order()}function Rp(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Vp(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ap(){return Array.from(this)}function Tp(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var i=e[t],a=0,l=i.length;a<l;++a){var r=i[a];if(r)return r}return null}function Mp(){let e=0;for(const t of this)++e;return e}function Bp(){return!this.node()}function Dp(e){for(var t=this._groups,o=0,i=t.length;o<i;++o)for(var a=t[o],l=0,r=a.length,s;l<r;++l)(s=a[l])&&e.call(s,s.__data__,l,a);return this}function Op(e){return function(){this.removeAttribute(e)}}function Lp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pp(e,t){return function(){this.setAttribute(e,t)}}function zp(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Up(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Hp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function Fp(e,t){var o=ei(e);if(arguments.length<2){var i=this.node();return o.local?i.getAttributeNS(o.space,o.local):i.getAttribute(o)}return this.each((t==null?o.local?Lp:Op:typeof t=="function"?o.local?Hp:Up:o.local?zp:Pp)(o,t))}function As(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Gp(e){return function(){this.style.removeProperty(e)}}function Yp(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Wp(e,t,o){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,o)}}function Kp(e,t,o){return arguments.length>1?this.each((t==null?Gp:typeof t=="function"?Wp:Yp)(e,t,o??"")):In(this.node(),e)}function In(e,t){return e.style.getPropertyValue(t)||As(e).getComputedStyle(e,null).getPropertyValue(t)}function qp(e){return function(){delete this[e]}}function Xp(e,t){return function(){this[e]=t}}function jp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Zp(e,t){return arguments.length>1?this.each((t==null?qp:typeof t=="function"?jp:Xp)(e,t)):this.node()[e]}function Ts(e){return e.trim().split(/^|\s+/)}function Va(e){return e.classList||new Ms(e)}function Ms(e){this._node=e,this._names=Ts(e.getAttribute("class")||"")}Ms.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Bs(e,t){for(var o=Va(e),i=-1,a=t.length;++i<a;)o.add(t[i])}function Ds(e,t){for(var o=Va(e),i=-1,a=t.length;++i<a;)o.remove(t[i])}function Jp(e){return function(){Bs(this,e)}}function Qp(e){return function(){Ds(this,e)}}function eh(e,t){return function(){(t.apply(this,arguments)?Bs:Ds)(this,e)}}function th(e,t){var o=Ts(e+"");if(arguments.length<2){for(var i=Va(this.node()),a=-1,l=o.length;++a<l;)if(!i.contains(o[a]))return!1;return!0}return this.each((typeof t=="function"?eh:t?Jp:Qp)(o,t))}function nh(){this.textContent=""}function oh(e){return function(){this.textContent=e}}function ih(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ah(e){return arguments.length?this.each(e==null?nh:(typeof e=="function"?ih:oh)(e)):this.node().textContent}function lh(){this.innerHTML=""}function rh(e){return function(){this.innerHTML=e}}function sh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ch(e){return arguments.length?this.each(e==null?lh:(typeof e=="function"?sh:rh)(e)):this.node().innerHTML}function dh(){this.nextSibling&&this.parentNode.appendChild(this)}function uh(){return this.each(dh)}function fh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mh(){return this.each(fh)}function ph(e){var t=typeof e=="function"?e:Is(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function hh(){return null}function yh(e,t){var o=typeof e=="function"?e:Is(e),i=t==null?hh:typeof t=="function"?t:Ra(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),i.apply(this,arguments)||null)})}function gh(){var e=this.parentNode;e&&e.removeChild(this)}function bh(){return this.each(gh)}function _h(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function wh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vh(e){return this.select(e?wh:_h)}function kh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Eh(e){return function(t){e.call(this,t,this.__data__)}}function Nh(e){return e.trim().split(/^|\s+/).map(function(t){var o="",i=t.indexOf(".");return i>=0&&(o=t.slice(i+1),t=t.slice(0,i)),{type:t,name:o}})}function $h(e){return function(){var t=this.__on;if(t){for(var o=0,i=-1,a=t.length,l;o<a;++o)l=t[o],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):t[++i]=l;++i?t.length=i:delete this.__on}}}function xh(e,t,o){return function(){var i=this.__on,a,l=Eh(t);if(i){for(var r=0,s=i.length;r<s;++r)if((a=i[r]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=l,a.options=o),a.value=t;return}}this.addEventListener(e.type,l,o),a={type:e.type,name:e.name,value:t,listener:l,options:o},i?i.push(a):this.__on=[a]}}function Ih(e,t,o){var i=Nh(e+""),a,l=i.length,r;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,d=s.length,u;c<d;++c)for(a=0,u=s[c];a<l;++a)if((r=i[a]).type===u.type&&r.name===u.name)return u.value}return}for(s=t?xh:$h,a=0;a<l;++a)this.each(s(i[a],t,o));return this}function Os(e,t,o){var i=As(e),a=i.CustomEvent;typeof a=="function"?a=new a(t,o):(a=i.document.createEvent("Event"),o?(a.initEvent(t,o.bubbles,o.cancelable),a.detail=o.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function Sh(e,t){return function(){return Os(this,e,t)}}function Ch(e,t){return function(){return Os(this,e,t.apply(this,arguments))}}function Rh(e,t){return this.each((typeof t=="function"?Ch:Sh)(e,t))}function*Vh(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var i=e[t],a=0,l=i.length,r;a<l;++a)(r=i[a])&&(yield r)}var Ls=[null];function st(e,t){this._groups=e,this._parents=t}function eo(){return new st([[document.documentElement]],Ls)}function Ah(){return this}st.prototype=eo.prototype={constructor:st,select:ip,selectAll:sp,selectChild:fp,selectChildren:yp,filter:gp,data:Ep,enter:bp,exit:$p,join:xp,merge:Ip,selection:Ah,order:Sp,sort:Cp,call:Vp,nodes:Ap,node:Tp,size:Mp,empty:Bp,each:Dp,attr:Fp,style:Kp,property:Zp,classed:th,text:ah,html:ch,raise:uh,lower:mh,append:ph,insert:yh,remove:bh,clone:vh,datum:kh,on:Ih,dispatch:Rh,[Symbol.iterator]:Vh};function ft(e){return typeof e=="string"?new st([[document.querySelector(e)]],[document.documentElement]):new st([[e]],Ls)}function Th(e){let t;for(;t=e.sourceEvent;)e=t;return e}function _t(e,t){if(e=Th(e),t===void 0&&(t=e.currentTarget),t){var o=t.ownerSVGElement||t;if(o.createSVGPoint){var i=o.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const Mh={passive:!1},to={capture:!0,passive:!1};function Aa(e){e.stopImmediatePropagation()}function Sn(e){e.preventDefault(),e.stopImmediatePropagation()}function Ps(e){var t=e.document.documentElement,o=ft(e).on("dragstart.drag",Sn,to);"onselectstart"in t?o.on("selectstart.drag",Sn,to):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function zs(e,t){var o=e.document.documentElement,i=ft(e).on("dragstart.drag",null);t&&(i.on("click.drag",Sn,to),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in o?i.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}const ni=e=>()=>e;function Ta(e,{sourceEvent:t,subject:o,target:i,identifier:a,active:l,x:r,y:s,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:r,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}Ta.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Bh(e){return!e.ctrlKey&&!e.button}function Dh(){return this.parentNode}function Oh(e,t){return t??{x:e.x,y:e.y}}function Lh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ph(){var e=Bh,t=Dh,o=Oh,i=Lh,a={},l=Jo("start","drag","end"),r=0,s,c,d,u,f=0;function p(N){N.on("mousedown.drag",m).filter(i).on("touchstart.drag",b).on("touchmove.drag",g,Mh).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(N,q){if(!(u||!e.call(this,N,q))){var U=y(this,t.call(this,N,q),N,q,"mouse");U&&(ft(N.view).on("mousemove.drag",h,to).on("mouseup.drag",_,to),Ps(N.view),Aa(N),d=!1,s=N.clientX,c=N.clientY,U("start",N))}}function h(N){if(Sn(N),!d){var q=N.clientX-s,U=N.clientY-c;d=q*q+U*U>f}a.mouse("drag",N)}function _(N){ft(N.view).on("mousemove.drag mouseup.drag",null),zs(N.view,d),Sn(N),a.mouse("end",N)}function b(N,q){if(e.call(this,N,q)){var U=N.changedTouches,X=t.call(this,N,q),K=U.length,W,ne;for(W=0;W<K;++W)(ne=y(this,X,N,q,U[W].identifier,U[W]))&&(Aa(N),ne("start",N,U[W]))}}function g(N){var q=N.changedTouches,U=q.length,X,K;for(X=0;X<U;++X)(K=a[q[X].identifier])&&(Sn(N),K("drag",N,q[X]))}function I(N){var q=N.changedTouches,U=q.length,X,K;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),X=0;X<U;++X)(K=a[q[X].identifier])&&(Aa(N),K("end",N,q[X]))}function y(N,q,U,X,K,W){var ne=l.copy(),re=_t(W||U,q),L,Q,v;if((v=o.call(N,new Ta("beforestart",{sourceEvent:U,target:p,identifier:K,active:r,x:re[0],y:re[1],dx:0,dy:0,dispatch:ne}),X))!=null)return L=v.x-re[0]||0,Q=v.y-re[1]||0,function T($,P,H){var te=re,M;switch($){case"start":a[K]=T,M=r++;break;case"end":delete a[K],--r;case"drag":re=_t(H||P,q),M=r;break}ne.call($,N,new Ta($,{sourceEvent:P,subject:v,target:p,identifier:K,active:M,x:re[0]+L,y:re[1]+Q,dx:re[0]-te[0],dy:re[1]-te[1],dispatch:ne}),X)}}return p.filter=function(N){return arguments.length?(e=typeof N=="function"?N:ni(!!N),p):e},p.container=function(N){return arguments.length?(t=typeof N=="function"?N:ni(N),p):t},p.subject=function(N){return arguments.length?(o=typeof N=="function"?N:ni(N),p):o},p.touchable=function(N){return arguments.length?(i=typeof N=="function"?N:ni(!!N),p):i},p.on=function(){var N=l.on.apply(l,arguments);return N===l?p:N},p.clickDistance=function(N){return arguments.length?(f=(N=+N)*N,p):Math.sqrt(f)},p}function Ma(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Us(e,t){var o=Object.create(e.prototype);for(var i in t)o[i]=t[i];return o}function no(){}var oo=.7,oi=1/oo,Cn="\\s*([+-]?\\d+)\\s*",io="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",zh=/^#([0-9a-f]{3,8})$/,Uh=new RegExp(`^rgb\\(${Cn},${Cn},${Cn}\\)$`),Hh=new RegExp(`^rgb\\(${wt},${wt},${wt}\\)$`),Fh=new RegExp(`^rgba\\(${Cn},${Cn},${Cn},${io}\\)$`),Gh=new RegExp(`^rgba\\(${wt},${wt},${wt},${io}\\)$`),Yh=new RegExp(`^hsl\\(${io},${wt},${wt}\\)$`),Wh=new RegExp(`^hsla\\(${io},${wt},${wt},${io}\\)$`),Hs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ma(no,tn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Fs,formatHex:Fs,formatHex8:Kh,formatHsl:qh,formatRgb:Gs,toString:Gs});function Fs(){return this.rgb().formatHex()}function Kh(){return this.rgb().formatHex8()}function qh(){return Xs(this).formatHsl()}function Gs(){return this.rgb().formatRgb()}function tn(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=zh.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ys(t):o===3?new at(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ii(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ii(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Uh.exec(e))?new at(t[1],t[2],t[3],1):(t=Hh.exec(e))?new at(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Fh.exec(e))?ii(t[1],t[2],t[3],t[4]):(t=Gh.exec(e))?ii(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Yh.exec(e))?qs(t[1],t[2]/100,t[3]/100,1):(t=Wh.exec(e))?qs(t[1],t[2]/100,t[3]/100,t[4]):Hs.hasOwnProperty(e)?Ys(Hs[e]):e==="transparent"?new at(NaN,NaN,NaN,0):null}function Ys(e){return new at(e>>16&255,e>>8&255,e&255,1)}function ii(e,t,o,i){return i<=0&&(e=t=o=NaN),new at(e,t,o,i)}function Xh(e){return e instanceof no||(e=tn(e)),e?(e=e.rgb(),new at(e.r,e.g,e.b,e.opacity)):new at}function Ba(e,t,o,i){return arguments.length===1?Xh(e):new at(e,t,o,i??1)}function at(e,t,o,i){this.r=+e,this.g=+t,this.b=+o,this.opacity=+i}Ma(at,Ba,Us(no,{brighter(e){return e=e==null?oi:Math.pow(oi,e),new at(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new at(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new at(nn(this.r),nn(this.g),nn(this.b),ai(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ws,formatHex:Ws,formatHex8:jh,formatRgb:Ks,toString:Ks}));function Ws(){return`#${on(this.r)}${on(this.g)}${on(this.b)}`}function jh(){return`#${on(this.r)}${on(this.g)}${on(this.b)}${on((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ks(){const e=ai(this.opacity);return`${e===1?"rgb(":"rgba("}${nn(this.r)}, ${nn(this.g)}, ${nn(this.b)}${e===1?")":`, ${e})`}`}function ai(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function nn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function on(e){return e=nn(e),(e<16?"0":"")+e.toString(16)}function qs(e,t,o,i){return i<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new mt(e,t,o,i)}function Xs(e){if(e instanceof mt)return new mt(e.h,e.s,e.l,e.opacity);if(e instanceof no||(e=tn(e)),!e)return new mt;if(e instanceof mt)return e;e=e.rgb();var t=e.r/255,o=e.g/255,i=e.b/255,a=Math.min(t,o,i),l=Math.max(t,o,i),r=NaN,s=l-a,c=(l+a)/2;return s?(t===l?r=(o-i)/s+(o<i)*6:o===l?r=(i-t)/s+2:r=(t-o)/s+4,s/=c<.5?l+a:2-l-a,r*=60):s=c>0&&c<1?0:r,new mt(r,s,c,e.opacity)}function Zh(e,t,o,i){return arguments.length===1?Xs(e):new mt(e,t,o,i??1)}function mt(e,t,o,i){this.h=+e,this.s=+t,this.l=+o,this.opacity=+i}Ma(mt,Zh,Us(no,{brighter(e){return e=e==null?oi:Math.pow(oi,e),new mt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new mt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,i=o+(o<.5?o:1-o)*t,a=2*o-i;return new at(Da(e>=240?e-240:e+120,a,i),Da(e,a,i),Da(e<120?e+240:e-120,a,i),this.opacity)},clamp(){return new mt(js(this.h),li(this.s),li(this.l),ai(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ai(this.opacity);return`${e===1?"hsl(":"hsla("}${js(this.h)}, ${li(this.s)*100}%, ${li(this.l)*100}%${e===1?")":`, ${e})`}`}}));function js(e){return e=(e||0)%360,e<0?e+360:e}function li(e){return Math.max(0,Math.min(1,e||0))}function Da(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}const Oa=e=>()=>e;function Jh(e,t){return function(o){return e+o*t}}function Qh(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(i){return Math.pow(e+i*t,o)}}function ey(e){return(e=+e)==1?Zs:function(t,o){return o-t?Qh(t,o,e):Oa(isNaN(t)?o:t)}}function Zs(e,t){var o=t-e;return o?Jh(e,o):Oa(isNaN(e)?t:e)}const ri=(function e(t){var o=ey(t);function i(a,l){var r=o((a=Ba(a)).r,(l=Ba(l)).r),s=o(a.g,l.g),c=o(a.b,l.b),d=Zs(a.opacity,l.opacity);return function(u){return a.r=r(u),a.g=s(u),a.b=c(u),a.opacity=d(u),a+""}}return i.gamma=e,i})(1);function ty(e,t){t||(t=[]);var o=e?Math.min(t.length,e.length):0,i=t.slice(),a;return function(l){for(a=0;a<o;++a)i[a]=e[a]*(1-l)+t[a]*l;return i}}function ny(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function oy(e,t){var o=t?t.length:0,i=e?Math.min(o,e.length):0,a=new Array(i),l=new Array(o),r;for(r=0;r<i;++r)a[r]=ao(e[r],t[r]);for(;r<o;++r)l[r]=t[r];return function(s){for(r=0;r<i;++r)l[r]=a[r](s);return l}}function iy(e,t){var o=new Date;return e=+e,t=+t,function(i){return o.setTime(e*(1-i)+t*i),o}}function vt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}function ay(e,t){var o={},i={},a;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(a in t)a in e?o[a]=ao(e[a],t[a]):i[a]=t[a];return function(l){for(a in o)i[a]=o[a](l);return i}}var La=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Pa=new RegExp(La.source,"g");function ly(e){return function(){return e}}function ry(e){return function(t){return e(t)+""}}function Js(e,t){var o=La.lastIndex=Pa.lastIndex=0,i,a,l,r=-1,s=[],c=[];for(e=e+"",t=t+"";(i=La.exec(e))&&(a=Pa.exec(t));)(l=a.index)>o&&(l=t.slice(o,l),s[r]?s[r]+=l:s[++r]=l),(i=i[0])===(a=a[0])?s[r]?s[r]+=a:s[++r]=a:(s[++r]=null,c.push({i:r,x:vt(i,a)})),o=Pa.lastIndex;return o<t.length&&(l=t.slice(o),s[r]?s[r]+=l:s[++r]=l),s.length<2?c[0]?ry(c[0].x):ly(t):(t=c.length,function(d){for(var u=0,f;u<t;++u)s[(f=c[u]).i]=f.x(d);return s.join("")})}function ao(e,t){var o=typeof t,i;return t==null||o==="boolean"?Oa(t):(o==="number"?vt:o==="string"?(i=tn(t))?(t=i,ri):Js:t instanceof tn?ri:t instanceof Date?iy:ny(t)?ty:Array.isArray(t)?oy:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?ay:vt)(e,t)}var Qs=180/Math.PI,za={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ec(e,t,o,i,a,l){var r,s,c;return(r=Math.sqrt(e*e+t*t))&&(e/=r,t/=r),(c=e*o+t*i)&&(o-=e*c,i-=t*c),(s=Math.sqrt(o*o+i*i))&&(o/=s,i/=s,c/=s),e*i<t*o&&(e=-e,t=-t,c=-c,r=-r),{translateX:a,translateY:l,rotate:Math.atan2(t,e)*Qs,skewX:Math.atan(c)*Qs,scaleX:r,scaleY:s}}var si;function sy(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?za:ec(t.a,t.b,t.c,t.d,t.e,t.f)}function cy(e){return e==null||(si||(si=document.createElementNS("http://www.w3.org/2000/svg","g")),si.setAttribute("transform",e),!(e=si.transform.baseVal.consolidate()))?za:(e=e.matrix,ec(e.a,e.b,e.c,e.d,e.e,e.f))}function tc(e,t,o,i){function a(d){return d.length?d.pop()+" ":""}function l(d,u,f,p,m,h){if(d!==f||u!==p){var _=m.push("translate(",null,t,null,o);h.push({i:_-4,x:vt(d,f)},{i:_-2,x:vt(u,p)})}else(f||p)&&m.push("translate("+f+t+p+o)}function r(d,u,f,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:f.push(a(f)+"rotate(",null,i)-2,x:vt(d,u)})):u&&f.push(a(f)+"rotate("+u+i)}function s(d,u,f,p){d!==u?p.push({i:f.push(a(f)+"skewX(",null,i)-2,x:vt(d,u)}):u&&f.push(a(f)+"skewX("+u+i)}function c(d,u,f,p,m,h){if(d!==f||u!==p){var _=m.push(a(m)+"scale(",null,",",null,")");h.push({i:_-4,x:vt(d,f)},{i:_-2,x:vt(u,p)})}else(f!==1||p!==1)&&m.push(a(m)+"scale("+f+","+p+")")}return function(d,u){var f=[],p=[];return d=e(d),u=e(u),l(d.translateX,d.translateY,u.translateX,u.translateY,f,p),r(d.rotate,u.rotate,f,p),s(d.skewX,u.skewX,f,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,f,p),d=u=null,function(m){for(var h=-1,_=p.length,b;++h<_;)f[(b=p[h]).i]=b.x(m);return f.join("")}}}var dy=tc(sy,"px, ","px)","deg)"),uy=tc(cy,", ",")",")"),fy=1e-12;function nc(e){return((e=Math.exp(e))+1/e)/2}function my(e){return((e=Math.exp(e))-1/e)/2}function py(e){return((e=Math.exp(2*e))-1)/(e+1)}const ci=(function e(t,o,i){function a(l,r){var s=l[0],c=l[1],d=l[2],u=r[0],f=r[1],p=r[2],m=u-s,h=f-c,_=m*m+h*h,b,g;if(_<fy)g=Math.log(p/d)/t,b=function(X){return[s+X*m,c+X*h,d*Math.exp(t*X*g)]};else{var I=Math.sqrt(_),y=(p*p-d*d+i*_)/(2*d*o*I),N=(p*p-d*d-i*_)/(2*p*o*I),q=Math.log(Math.sqrt(y*y+1)-y),U=Math.log(Math.sqrt(N*N+1)-N);g=(U-q)/t,b=function(X){var K=X*g,W=nc(q),ne=d/(o*I)*(W*py(t*K+q)-my(q));return[s+ne*m,c+ne*h,d*W/nc(t*K+q)]}}return b.duration=g*1e3*t/Math.SQRT2,b}return a.rho=function(l){var r=Math.max(.001,+l),s=r*r,c=s*s;return e(r,s,c)},a})(Math.SQRT2,2,4);var Rn=0,lo=0,ro=0,oc=1e3,di,so,ui=0,an=0,fi=0,co=typeof performance=="object"&&performance.now?performance:Date,ic=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ua(){return an||(ic(hy),an=co.now()+fi)}function hy(){an=0}function mi(){this._call=this._time=this._next=null}mi.prototype=ac.prototype={constructor:mi,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Ua():+o)+(t==null?0:+t),!this._next&&so!==this&&(so?so._next=this:di=this,so=this),this._call=e,this._time=o,Ha()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ha())}};function ac(e,t,o){var i=new mi;return i.restart(e,t,o),i}function yy(){Ua(),++Rn;for(var e=di,t;e;)(t=an-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rn}function lc(){an=(ui=co.now())+fi,Rn=lo=0;try{yy()}finally{Rn=0,by(),an=0}}function gy(){var e=co.now(),t=e-ui;t>oc&&(fi-=t,ui=e)}function by(){for(var e,t=di,o,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(o=t._next,t._next=null,t=e?e._next=o:di=o);so=e,Ha(i)}function Ha(e){if(!Rn){lo&&(lo=clearTimeout(lo));var t=e-an;t>24?(e<1/0&&(lo=setTimeout(lc,e-co.now()-fi)),ro&&(ro=clearInterval(ro))):(ro||(ui=co.now(),ro=setInterval(gy,oc)),Rn=1,ic(lc))}}function rc(e,t,o){var i=new mi;return t=t==null?0:+t,i.restart(a=>{i.stop(),e(a+t)},t,o),i}var _y=Jo("start","end","cancel","interrupt"),wy=[],sc=0,cc=1,Fa=2,pi=3,dc=4,Ga=5,hi=6;function yi(e,t,o,i,a,l){var r=e.__transition;if(!r)e.__transition={};else if(o in r)return;vy(e,o,{name:t,index:i,group:a,on:_y,tween:wy,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:sc})}function Ya(e,t){var o=pt(e,t);if(o.state>sc)throw new Error("too late; already scheduled");return o}function kt(e,t){var o=pt(e,t);if(o.state>pi)throw new Error("too late; already running");return o}function pt(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function vy(e,t,o){var i=e.__transition,a;i[t]=o,o.timer=ac(l,0,o.time);function l(d){o.state=cc,o.timer.restart(r,o.delay,o.time),o.delay<=d&&r(d-o.delay)}function r(d){var u,f,p,m;if(o.state!==cc)return c();for(u in i)if(m=i[u],m.name===o.name){if(m.state===pi)return rc(r);m.state===dc?(m.state=hi,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete i[u]):+u<t&&(m.state=hi,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete i[u])}if(rc(function(){o.state===pi&&(o.state=dc,o.timer.restart(s,o.delay,o.time),s(d))}),o.state=Fa,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Fa){for(o.state=pi,a=new Array(p=o.tween.length),u=0,f=-1;u<p;++u)(m=o.tween[u].value.call(e,e.__data__,o.index,o.group))&&(a[++f]=m);a.length=f+1}}function s(d){for(var u=d<o.duration?o.ease.call(null,d/o.duration):(o.timer.restart(c),o.state=Ga,1),f=-1,p=a.length;++f<p;)a[f].call(e,u);o.state===Ga&&(o.on.call("end",e,e.__data__,o.index,o.group),c())}function c(){o.state=hi,o.timer.stop(),delete i[t];for(var d in i)return;delete e.__transition}}function gi(e,t){var o=e.__transition,i,a,l=!0,r;if(o){t=t==null?null:t+"";for(r in o){if((i=o[r]).name!==t){l=!1;continue}a=i.state>Fa&&i.state<Ga,i.state=hi,i.timer.stop(),i.on.call(a?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete o[r]}l&&delete e.__transition}}function ky(e){return this.each(function(){gi(this,e)})}function Ey(e,t){var o,i;return function(){var a=kt(this,e),l=a.tween;if(l!==o){i=o=l;for(var r=0,s=i.length;r<s;++r)if(i[r].name===t){i=i.slice(),i.splice(r,1);break}}a.tween=i}}function Ny(e,t,o){var i,a;if(typeof o!="function")throw new Error;return function(){var l=kt(this,e),r=l.tween;if(r!==i){a=(i=r).slice();for(var s={name:t,value:o},c=0,d=a.length;c<d;++c)if(a[c].name===t){a[c]=s;break}c===d&&a.push(s)}l.tween=a}}function $y(e,t){var o=this._id;if(e+="",arguments.length<2){for(var i=pt(this.node(),o).tween,a=0,l=i.length,r;a<l;++a)if((r=i[a]).name===e)return r.value;return null}return this.each((t==null?Ey:Ny)(o,e,t))}function Wa(e,t,o){var i=e._id;return e.each(function(){var a=kt(this,i);(a.value||(a.value={}))[t]=o.apply(this,arguments)}),function(a){return pt(a,i).value[t]}}function uc(e,t){var o;return(typeof t=="number"?vt:t instanceof tn?ri:(o=tn(t))?(t=o,ri):Js)(e,t)}function xy(e){return function(){this.removeAttribute(e)}}function Iy(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Sy(e,t,o){var i,a=o+"",l;return function(){var r=this.getAttribute(e);return r===a?null:r===i?l:l=t(i=r,o)}}function Cy(e,t,o){var i,a=o+"",l;return function(){var r=this.getAttributeNS(e.space,e.local);return r===a?null:r===i?l:l=t(i=r,o)}}function Ry(e,t,o){var i,a,l;return function(){var r,s=o(this),c;return s==null?void this.removeAttribute(e):(r=this.getAttribute(e),c=s+"",r===c?null:r===i&&c===a?l:(a=c,l=t(i=r,s)))}}function Vy(e,t,o){var i,a,l;return function(){var r,s=o(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(r=this.getAttributeNS(e.space,e.local),c=s+"",r===c?null:r===i&&c===a?l:(a=c,l=t(i=r,s)))}}function Ay(e,t){var o=ei(e),i=o==="transform"?uy:uc;return this.attrTween(e,typeof t=="function"?(o.local?Vy:Ry)(o,i,Wa(this,"attr."+e,t)):t==null?(o.local?Iy:xy)(o):(o.local?Cy:Sy)(o,i,t))}function Ty(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function My(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function By(e,t){var o,i;function a(){var l=t.apply(this,arguments);return l!==i&&(o=(i=l)&&My(e,l)),o}return a._value=t,a}function Dy(e,t){var o,i;function a(){var l=t.apply(this,arguments);return l!==i&&(o=(i=l)&&Ty(e,l)),o}return a._value=t,a}function Oy(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var i=ei(e);return this.tween(o,(i.local?By:Dy)(i,t))}function Ly(e,t){return function(){Ya(this,e).delay=+t.apply(this,arguments)}}function Py(e,t){return t=+t,function(){Ya(this,e).delay=t}}function zy(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ly:Py)(t,e)):pt(this.node(),t).delay}function Uy(e,t){return function(){kt(this,e).duration=+t.apply(this,arguments)}}function Hy(e,t){return t=+t,function(){kt(this,e).duration=t}}function Fy(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Uy:Hy)(t,e)):pt(this.node(),t).duration}function Gy(e,t){if(typeof t!="function")throw new Error;return function(){kt(this,e).ease=t}}function Yy(e){var t=this._id;return arguments.length?this.each(Gy(t,e)):pt(this.node(),t).ease}function Wy(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;kt(this,e).ease=o}}function Ky(e){if(typeof e!="function")throw new Error;return this.each(Wy(this._id,e))}function qy(e){typeof e!="function"&&(e=Cs(e));for(var t=this._groups,o=t.length,i=new Array(o),a=0;a<o;++a)for(var l=t[a],r=l.length,s=i[a]=[],c,d=0;d<r;++d)(c=l[d])&&e.call(c,c.__data__,d,l)&&s.push(c);return new Rt(i,this._parents,this._name,this._id)}function Xy(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,i=t.length,a=o.length,l=Math.min(i,a),r=new Array(i),s=0;s<l;++s)for(var c=t[s],d=o[s],u=c.length,f=r[s]=new Array(u),p,m=0;m<u;++m)(p=c[m]||d[m])&&(f[m]=p);for(;s<i;++s)r[s]=t[s];return new Rt(r,this._parents,this._name,this._id)}function jy(e){return(e+"").trim().split(/^|\s+/).every(function(t){var o=t.indexOf(".");return o>=0&&(t=t.slice(0,o)),!t||t==="start"})}function Zy(e,t,o){var i,a,l=jy(t)?Ya:kt;return function(){var r=l(this,e),s=r.on;s!==i&&(a=(i=s).copy()).on(t,o),r.on=a}}function Jy(e,t){var o=this._id;return arguments.length<2?pt(this.node(),o).on.on(e):this.each(Zy(o,e,t))}function Qy(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function eg(){return this.on("end.remove",Qy(this._id))}function tg(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ra(e));for(var i=this._groups,a=i.length,l=new Array(a),r=0;r<a;++r)for(var s=i[r],c=s.length,d=l[r]=new Array(c),u,f,p=0;p<c;++p)(u=s[p])&&(f=e.call(u,u.__data__,p,s))&&("__data__"in u&&(f.__data__=u.__data__),d[p]=f,yi(d[p],t,o,p,d,pt(u,o)));return new Rt(l,this._parents,t,o)}function ng(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ss(e));for(var i=this._groups,a=i.length,l=[],r=[],s=0;s<a;++s)for(var c=i[s],d=c.length,u,f=0;f<d;++f)if(u=c[f]){for(var p=e.call(u,u.__data__,f,c),m,h=pt(u,o),_=0,b=p.length;_<b;++_)(m=p[_])&&yi(m,t,o,_,p,h);l.push(p),r.push(u)}return new Rt(l,r,t,o)}var og=eo.prototype.constructor;function ig(){return new og(this._groups,this._parents)}function ag(e,t){var o,i,a;return function(){var l=In(this,e),r=(this.style.removeProperty(e),In(this,e));return l===r?null:l===o&&r===i?a:a=t(o=l,i=r)}}function fc(e){return function(){this.style.removeProperty(e)}}function lg(e,t,o){var i,a=o+"",l;return function(){var r=In(this,e);return r===a?null:r===i?l:l=t(i=r,o)}}function rg(e,t,o){var i,a,l;return function(){var r=In(this,e),s=o(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(e),In(this,e))),r===c?null:r===i&&c===a?l:(a=c,l=t(i=r,s))}}function sg(e,t){var o,i,a,l="style."+t,r="end."+l,s;return function(){var c=kt(this,e),d=c.on,u=c.value[l]==null?s||(s=fc(t)):void 0;(d!==o||a!==u)&&(i=(o=d).copy()).on(r,a=u),c.on=i}}function cg(e,t,o){var i=(e+="")=="transform"?dy:uc;return t==null?this.styleTween(e,ag(e,i)).on("end.style."+e,fc(e)):typeof t=="function"?this.styleTween(e,rg(e,i,Wa(this,"style."+e,t))).each(sg(this._id,e)):this.styleTween(e,lg(e,i,t),o).on("end.style."+e,null)}function dg(e,t,o){return function(i){this.style.setProperty(e,t.call(this,i),o)}}function ug(e,t,o){var i,a;function l(){var r=t.apply(this,arguments);return r!==a&&(i=(a=r)&&dg(e,r,o)),i}return l._value=t,l}function fg(e,t,o){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,ug(e,t,o??""))}function mg(e){return function(){this.textContent=e}}function pg(e){return function(){var t=e(this);this.textContent=t??""}}function hg(e){return this.tween("text",typeof e=="function"?pg(Wa(this,"text",e)):mg(e==null?"":e+""))}function yg(e){return function(t){this.textContent=e.call(this,t)}}function gg(e){var t,o;function i(){var a=e.apply(this,arguments);return a!==o&&(t=(o=a)&&yg(a)),t}return i._value=e,i}function bg(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,gg(e))}function _g(){for(var e=this._name,t=this._id,o=mc(),i=this._groups,a=i.length,l=0;l<a;++l)for(var r=i[l],s=r.length,c,d=0;d<s;++d)if(c=r[d]){var u=pt(c,t);yi(c,e,o,d,r,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Rt(i,this._parents,e,o)}function wg(){var e,t,o=this,i=o._id,a=o.size();return new Promise(function(l,r){var s={value:r},c={value:function(){--a===0&&l()}};o.each(function(){var d=kt(this,i),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),d.on=t}),a===0&&l()})}var vg=0;function Rt(e,t,o,i){this._groups=e,this._parents=t,this._name=o,this._id=i}function mc(){return++vg}var Vt=eo.prototype;Rt.prototype={constructor:Rt,select:tg,selectAll:ng,selectChild:Vt.selectChild,selectChildren:Vt.selectChildren,filter:qy,merge:Xy,selection:ig,transition:_g,call:Vt.call,nodes:Vt.nodes,node:Vt.node,size:Vt.size,empty:Vt.empty,each:Vt.each,on:Jy,attr:Ay,attrTween:Oy,style:cg,styleTween:fg,text:hg,textTween:bg,remove:eg,tween:$y,delay:zy,duration:Fy,ease:Yy,easeVarying:Ky,end:wg,[Symbol.iterator]:Vt[Symbol.iterator]};function kg(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Eg={time:null,delay:0,duration:250,ease:kg};function Ng(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function $g(e){var t,o;e instanceof Rt?(t=e._id,e=e._name):(t=mc(),(o=Eg).time=Ua(),e=e==null?null:e+"");for(var i=this._groups,a=i.length,l=0;l<a;++l)for(var r=i[l],s=r.length,c,d=0;d<s;++d)(c=r[d])&&yi(c,e,t,d,r,o||Ng(c,t));return new Rt(i,this._parents,e,t)}eo.prototype.interrupt=ky,eo.prototype.transition=$g;const bi=e=>()=>e;function xg(e,{sourceEvent:t,target:o,transform:i,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function At(e,t,o){this.k=e,this.x=t,this.y=o}At.prototype={constructor:At,scale:function(e){return e===1?this:new At(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new At(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vn=new At(1,0,0);At.prototype;function Ka(e){e.stopImmediatePropagation()}function uo(e){e.preventDefault(),e.stopImmediatePropagation()}function Ig(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Sg(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function pc(){return this.__zoom||Vn}function Cg(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Rg(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vg(e,t,o){var i=e.invertX(t[0][0])-o[0][0],a=e.invertX(t[1][0])-o[1][0],l=e.invertY(t[0][1])-o[0][1],r=e.invertY(t[1][1])-o[1][1];return e.translate(a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a),r>l?(l+r)/2:Math.min(0,l)||Math.max(0,r))}function Ag(){var e=Ig,t=Sg,o=Vg,i=Cg,a=Rg,l=[0,1/0],r=[[-1/0,-1/0],[1/0,1/0]],s=250,c=ci,d=Jo("start","zoom","end"),u,f,p,m=500,h=150,_=0,b=10;function g(v){v.property("__zoom",pc).on("wheel.zoom",K,{passive:!1}).on("mousedown.zoom",W).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",re).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",Q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(v,T,$,P){var H=v.selection?v.selection():v;H.property("__zoom",pc),v!==H?q(v,T,$,P):H.interrupt().each(function(){U(this,arguments).event(P).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},g.scaleBy=function(v,T,$,P){g.scaleTo(v,function(){var H=this.__zoom.k,te=typeof T=="function"?T.apply(this,arguments):T;return H*te},$,P)},g.scaleTo=function(v,T,$,P){g.transform(v,function(){var H=t.apply(this,arguments),te=this.__zoom,M=$==null?N(H):typeof $=="function"?$.apply(this,arguments):$,ee=te.invert(M),le=typeof T=="function"?T.apply(this,arguments):T;return o(y(I(te,le),M,ee),H,r)},$,P)},g.translateBy=function(v,T,$,P){g.transform(v,function(){return o(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof $=="function"?$.apply(this,arguments):$),t.apply(this,arguments),r)},null,P)},g.translateTo=function(v,T,$,P,H){g.transform(v,function(){var te=t.apply(this,arguments),M=this.__zoom,ee=P==null?N(te):typeof P=="function"?P.apply(this,arguments):P;return o(Vn.translate(ee[0],ee[1]).scale(M.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof $=="function"?-$.apply(this,arguments):-$),te,r)},P,H)};function I(v,T){return T=Math.max(l[0],Math.min(l[1],T)),T===v.k?v:new At(T,v.x,v.y)}function y(v,T,$){var P=T[0]-$[0]*v.k,H=T[1]-$[1]*v.k;return P===v.x&&H===v.y?v:new At(v.k,P,H)}function N(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function q(v,T,$,P){v.on("start.zoom",function(){U(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){U(this,arguments).event(P).end()}).tween("zoom",function(){var H=this,te=arguments,M=U(H,te).event(P),ee=t.apply(H,te),le=$==null?N(ee):typeof $=="function"?$.apply(H,te):$,me=Math.max(ee[1][0]-ee[0][0],ee[1][1]-ee[0][1]),ye=H.__zoom,ce=typeof T=="function"?T.apply(H,te):T,ue=c(ye.invert(le).concat(me/ye.k),ce.invert(le).concat(me/ce.k));return function(he){if(he===1)he=ce;else{var ve=ue(he),Se=me/ve[2];he=new At(Se,le[0]-ve[0]*Se,le[1]-ve[1]*Se)}M.zoom(null,he)}})}function U(v,T,$){return!$&&v.__zooming||new X(v,T)}function X(v,T){this.that=v,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,T),this.taps=0}X.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,T){return this.mouse&&v!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var T=ft(this.that).datum();d.call(v,this.that,new xg(v,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:d}),T)}};function K(v,...T){if(!e.apply(this,arguments))return;var $=U(this,T).event(v),P=this.__zoom,H=Math.max(l[0],Math.min(l[1],P.k*Math.pow(2,i.apply(this,arguments)))),te=_t(v);if($.wheel)($.mouse[0][0]!==te[0]||$.mouse[0][1]!==te[1])&&($.mouse[1]=P.invert($.mouse[0]=te)),clearTimeout($.wheel);else{if(P.k===H)return;$.mouse=[te,P.invert(te)],gi(this),$.start()}uo(v),$.wheel=setTimeout(M,h),$.zoom("mouse",o(y(I(P,H),$.mouse[0],$.mouse[1]),$.extent,r));function M(){$.wheel=null,$.end()}}function W(v,...T){if(p||!e.apply(this,arguments))return;var $=v.currentTarget,P=U(this,T,!0).event(v),H=ft(v.view).on("mousemove.zoom",le,!0).on("mouseup.zoom",me,!0),te=_t(v,$),M=v.clientX,ee=v.clientY;Ps(v.view),Ka(v),P.mouse=[te,this.__zoom.invert(te)],gi(this),P.start();function le(ye){if(uo(ye),!P.moved){var ce=ye.clientX-M,ue=ye.clientY-ee;P.moved=ce*ce+ue*ue>_}P.event(ye).zoom("mouse",o(y(P.that.__zoom,P.mouse[0]=_t(ye,$),P.mouse[1]),P.extent,r))}function me(ye){H.on("mousemove.zoom mouseup.zoom",null),zs(ye.view,P.moved),uo(ye),P.event(ye).end()}}function ne(v,...T){if(e.apply(this,arguments)){var $=this.__zoom,P=_t(v.changedTouches?v.changedTouches[0]:v,this),H=$.invert(P),te=$.k*(v.shiftKey?.5:2),M=o(y(I($,te),P,H),t.apply(this,T),r);uo(v),s>0?ft(this).transition().duration(s).call(q,M,P,v):ft(this).call(g.transform,M,P,v)}}function re(v,...T){if(e.apply(this,arguments)){var $=v.touches,P=$.length,H=U(this,T,v.changedTouches.length===P).event(v),te,M,ee,le;for(Ka(v),M=0;M<P;++M)ee=$[M],le=_t(ee,this),le=[le,this.__zoom.invert(le),ee.identifier],H.touch0?!H.touch1&&H.touch0[2]!==le[2]&&(H.touch1=le,H.taps=0):(H.touch0=le,te=!0,H.taps=1+!!u);u&&(u=clearTimeout(u)),te&&(H.taps<2&&(f=le[0],u=setTimeout(function(){u=null},m)),gi(this),H.start())}}function L(v,...T){if(this.__zooming){var $=U(this,T).event(v),P=v.changedTouches,H=P.length,te,M,ee,le;for(uo(v),te=0;te<H;++te)M=P[te],ee=_t(M,this),$.touch0&&$.touch0[2]===M.identifier?$.touch0[0]=ee:$.touch1&&$.touch1[2]===M.identifier&&($.touch1[0]=ee);if(M=$.that.__zoom,$.touch1){var me=$.touch0[0],ye=$.touch0[1],ce=$.touch1[0],ue=$.touch1[1],he=(he=ce[0]-me[0])*he+(he=ce[1]-me[1])*he,ve=(ve=ue[0]-ye[0])*ve+(ve=ue[1]-ye[1])*ve;M=I(M,Math.sqrt(he/ve)),ee=[(me[0]+ce[0])/2,(me[1]+ce[1])/2],le=[(ye[0]+ue[0])/2,(ye[1]+ue[1])/2]}else if($.touch0)ee=$.touch0[0],le=$.touch0[1];else return;$.zoom("touch",o(y(M,ee,le),$.extent,r))}}function Q(v,...T){if(this.__zooming){var $=U(this,T).event(v),P=v.changedTouches,H=P.length,te,M;for(Ka(v),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),te=0;te<H;++te)M=P[te],$.touch0&&$.touch0[2]===M.identifier?delete $.touch0:$.touch1&&$.touch1[2]===M.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(M=_t(M,this),Math.hypot(f[0]-M[0],f[1]-M[1])<b)){var ee=ft(this).on("dblclick.zoom");ee&&ee.apply(this,arguments)}}}return g.wheelDelta=function(v){return arguments.length?(i=typeof v=="function"?v:bi(+v),g):i},g.filter=function(v){return arguments.length?(e=typeof v=="function"?v:bi(!!v),g):e},g.touchable=function(v){return arguments.length?(a=typeof v=="function"?v:bi(!!v),g):a},g.extent=function(v){return arguments.length?(t=typeof v=="function"?v:bi([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),g):t},g.scaleExtent=function(v){return arguments.length?(l[0]=+v[0],l[1]=+v[1],g):[l[0],l[1]]},g.translateExtent=function(v){return arguments.length?(r[0][0]=+v[0][0],r[1][0]=+v[1][0],r[0][1]=+v[0][1],r[1][1]=+v[1][1],g):[[r[0][0],r[0][1]],[r[1][0],r[1][1]]]},g.constrain=function(v){return arguments.length?(o=v,g):o},g.duration=function(v){return arguments.length?(s=+v,g):s},g.interpolate=function(v){return arguments.length?(c=v,g):c},g.on=function(){var v=d.on.apply(d,arguments);return v===d?g:v},g.clickDistance=function(v){return arguments.length?(_=(v=+v)*v,g):Math.sqrt(_)},g.tapDistance=function(v){return arguments.length?(b=+v,g):b},g}var $e=(e=>(e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom",e))($e||{}),qa=(e=>(e.Partial="partial",e.Full="full",e))(qa||{}),ln=(e=>(e.Bezier="default",e.SimpleBezier="simple-bezier",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e))(ln||{}),Tt=(e=>(e.Strict="strict",e.Loose="loose",e))(Tt||{}),Xa=(e=>(e.Arrow="arrow",e.ArrowClosed="arrowclosed",e))(Xa||{}),fo=(e=>(e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal",e))(fo||{}),hc=(e=>(e.TopLeft="top-left",e.TopCenter="top-center",e.TopRight="top-right",e.BottomLeft="bottom-left",e.BottomCenter="bottom-center",e.BottomRight="bottom-right",e))(hc||{});const Tg=["INPUT","SELECT","TEXTAREA"],Mg=typeof document<"u"?document:null;function ja(e){var t,o;const i=((o=(t=e.composedPath)==null?void 0:t.call(e))==null?void 0:o[0])||e.target,a=typeof(i==null?void 0:i.hasAttribute)=="function"?i.hasAttribute("contenteditable"):!1,l=typeof(i==null?void 0:i.closest)=="function"?i.closest(".nokey"):null;return Tg.includes(i==null?void 0:i.nodeName)||a||!!l}function Bg(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function yc(e,t,o,i){const a=t.replace("+",`
|
|
2
|
+
`).trim()}const Xu=/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;function rt(e){return e.replace(Xu,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ce(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/\.?0+$/,"")}function Xl(e){return`<text ${[`x="${Ce(e.x)}"`,`y="${Ce(e.y)}"`,`fill="${rt(e.fill)}"`,`font-size="${Ce(e.fontSize)}"`,e.fontFamily?`font-family="${rt(e.fontFamily)}"`:"",e.fontWeight!=null?`font-weight="${rt(String(e.fontWeight))}"`:"",e.fontStyle&&e.fontStyle!=="normal"?`font-style="${rt(e.fontStyle)}"`:"",e.anchor&&e.anchor!=="start"?`text-anchor="${e.anchor}"`:"",'dominant-baseline="central"'].filter(Boolean).join(" ")}>${rt(e.text)}</text>`}function ju(e){return`<line x1="${Ce(e.x1)}" y1="${Ce(e.y)}" x2="${Ce(e.x2)}" y2="${Ce(e.y)}" stroke="${rt(e.stroke)}" stroke-width="${Ce(e.strokeWidth??1)}" />`}function Zu(e){return e==null?{tl:0,tr:0,br:0,bl:0}:typeof e=="number"?{tl:e,tr:e,br:e,bl:e}:e}function Ju(e,t,o,i,a){return[`M${Ce(e+a.tl)},${Ce(t)}`,`L${Ce(e+o-a.tr)},${Ce(t)}`,a.tr?`Q${Ce(e+o)},${Ce(t)} ${Ce(e+o)},${Ce(t+a.tr)}`:"",`L${Ce(e+o)},${Ce(t+i-a.br)}`,a.br?`Q${Ce(e+o)},${Ce(t+i)} ${Ce(e+o-a.br)},${Ce(t+i)}`:"",`L${Ce(e+a.bl)},${Ce(t+i)}`,a.bl?`Q${Ce(e)},${Ce(t+i)} ${Ce(e)},${Ce(t+i-a.bl)}`:"",`L${Ce(e)},${Ce(t+a.tl)}`,a.tl?`Q${Ce(e)},${Ce(t)} ${Ce(e+a.tl)},${Ce(t)}`:"","Z"].filter(Boolean).join(" ")}function da(e){const t=Zu(e.radius),o=t.tl||t.tr||t.br||t.bl,i=[`fill="${rt(e.fill)}"`,`stroke="${rt(e.stroke)}"`,`stroke-width="${Ce(e.strokeWidth??1)}"`,e.strokeDasharray?`stroke-dasharray="${rt(e.strokeDasharray)}"`:"",e.opacity!=null?`opacity="${Ce(e.opacity)}"`:""].filter(Boolean),l=[o?`<path d="${Ju(e.x,e.y,e.w,e.h,t)}" ${i.join(" ")} />`:`<rect x="${Ce(e.x)}" y="${Ce(e.y)}" width="${Ce(e.w)}" height="${Ce(e.h)}" ${i.join(" ")} />`];for(const r of e.lines??[])l.push(ju(r));for(const r of e.texts)l.push(Xl(r));for(const r of e.icons??[])l.push(r);return`<g>${l.join("")}</g>`}function Qu(e){const o=[`<path ${[`d="${rt(e.d)}"`,'fill="none"',`stroke="${rt(e.stroke)}"`,`stroke-width="${Ce(e.strokeWidth)}"`,e.strokeDasharray?`stroke-dasharray="${rt(e.strokeDasharray)}"`:""].filter(Boolean).join(" ")} />`];for(const i of e.markers??[])o.push(i);for(const i of e.labels)o.push(Xl(i));return`<g>${o.join("")}</g>`}function jl(e){const{x:t,y:o,w:i,h:a}=e.viewBox,l=[];e.background&&l.push(`<rect x="${Ce(t)}" y="${Ce(o)}" width="${Ce(i)}" height="${Ce(a)}" fill="${rt(e.background)}" />`);for(const r of e.groups)l.push(da(r));for(const r of e.edges)l.push(Qu(r));for(const r of e.entities)l.push(da(r));for(const r of e.notes)l.push(da(r));return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${Ce(t)} ${Ce(o)} ${Ce(i)} ${Ce(a)}" width="${Ce(i)}" height="${Ce(a)}">`+l.join("")+"</svg>"}const ef=["BIT","TINYINT","SMALLINT","INTEGER","BIGINT","FLOAT","REAL","DOUBLE","NUMERIC","DECIMAL","CHAR","VARCHAR","LONGVARCHAR","DATE","TIME","TIMESTAMP","BINARY","VARBINARY","LONGVARBINARY","NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","BLOB","CLOB","REF","DATALINK","BOOLEAN","ROWID","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","REF_CURSOR","TIME_WITH_TIMEZONE","TIMESTAMP_WITH_TIMEZONE","SERIAL","BIG_SERIAL","JSONB"],tf=new Set(["NULL","OTHER","JAVA_OBJECT","DISTINCT","STRUCT","ARRAY","REF","DATALINK","ROWID","REF_CURSOR","NCHAR","NVARCHAR","LONGNVARCHAR","NCLOB","SQLXML","TIME_WITH_TIMEZONE","BIT","TINYINT","FLOAT"]),nf=ef.filter(e=>!tf.has(e)),of={TIMESTAMP_WITH_TIMEZONE:"TIMESTAMP WITH TIME ZONE",BIG_SERIAL:"BIGSERIAL",DOUBLE:"DOUBLE PRECISION"};function ua(e){return of[e]??e}const af=new Set(["CHAR","VARCHAR","NCHAR","NVARCHAR","BINARY","VARBINARY","NUMERIC","DECIMAL"]),Po=new Set(["NUMERIC","DECIMAL"]);function Zl(e,t=nf){const o=[...t];return e&&!o.includes(e)?[e,...o]:o}const Lt="CustomType",Yn="GroupCodeEnum",fa="String",ma=[{value:"String",label:"String"},{value:"Integer",label:"Integer"},{value:"Long",label:"Long"},{value:"Double",label:"Double"},{value:"Boolean",label:"Boolean"},{value:"Date",label:"Date"},{value:"LocalDate",label:"LocalDate"},{value:"LocalDateTime",label:"LocalDateTime"},{value:"Instant",label:"Instant"},{value:"ZonedDateTime",label:"ZonedDateTime"},{value:"OffsetDateTime",label:"OffsetDateTime"},{value:"BigDecimal",label:"BigDecimal"},{value:"BigInteger",label:"BigInteger"},{value:"ByteArray",label:"Byte[]"},{value:"CharacterArray",label:"Character[]"},{value:"Short",label:"Short"},{value:"PrimitiveInt",label:"int",boxed:"Integer"},{value:"PrimitiveLong",label:"long",boxed:"Long"},{value:"PrimitiveDouble",label:"double",boxed:"Double"},{value:"PrimitiveBoolean",label:"boolean",boxed:"Boolean"},{value:"PrimitiveShort",label:"short",boxed:"Short"},{value:"PrimitiveByteArray",label:"byte[]",boxed:"Byte[]"},{value:"PrimitiveCharacterArray",label:"char[]",boxed:"Character[]"},{value:Yn,label:"GroupCodeEnum"},{value:"CustomMoneyType",label:"Money"},{value:Lt,label:"CustomType"}],lf=new Map(ma.map(e=>[e.value,e.label]));function wn(e){return lf.get(e)??e}const rf=new Set([Yn,"CustomMoneyType"]),Jl=ma.filter(e=>!rf.has(e.value)).map(e=>e.value===Lt?{...e,label:"CustomType (사용자정의)"}:e);function Ql(e,t=[]){const o=t.map(a=>{var r,s;const l=((r=a.label)==null?void 0:r.ko)??((s=a.label)==null?void 0:s.en);return{value:a.type,label:l?`${a.type} (${l})`:a.type}}),i=[...Jl,...o];return e&&!i.some(a=>a.value===e)?[{value:e,label:wn(e)},...i]:i}function sf(e){return e.attrType.startsWith("EMBED")&&e.dbAttrs.length>0}function er(e,t){var a;if(!e.embedded||!e.attrType.startsWith("EMBED"))return;const o=t.find(l=>l.modelId===e.embedded.associationRef);if(!o)return;const i=o.end2.entityRef===e.embedded.embeddableRef?o.end2:o.end1;if(i.multiplicity!=="EXACTLY_ONE_INSTANCE")return((a=i.jpa)==null?void 0:a.collectionType)??"LIST"}function pa(e,t,o){var i;return t.attrType==="DIVIDER"||e==="LOGICAL"?"":o&&t.attrType.startsWith("EMBED")?`${o==="SET"?"Set":"List"}<${wn(t.type)}>`:sf(t)?wn(t.type):e==="CLASS"?t.type===Lt&&t.customType||wn(t.type):ua(((i=t.dbAttrs[0])==null?void 0:i.dataType)??"")}function Wn(e){const t=new Map;for(const o of e)t.set(o.modelId,o);return t}function zo(e,t){if(e.sharedColumnRef==null)return null;const o=t.get(e.sharedColumnRef);return o?{physicalName:o.physicalName,insertable:!1,updatable:!1}:null}const ha=63;function Uo(e){if(!e)return null;const t=e.length;return t<=ha?null:`물리명이 ${ha}자를 초과했습니다 (${t}자) — 일부 DB에서 잘릴 수 있습니다`}function tr(e){return e.dataType?e.length==null?e.dataType:e.scale==null?`${e.dataType}(${e.length})`:`${e.dataType}(${e.length},${e.scale})`:"(미지정)"}function dt(e){return!e||e.trim()===""}function Kn(e){return e==="ZERO_OR_MORE_INSTANCES"||e==="ONE_OR_MORE_INSTANCES"}function cf(e){const t=new Map;for(const u of e.associations){if(u.identifying!==!0||u.end1.entityRef===u.end2.entityRef)continue;const f=t.get(u.end1.entityRef)??[];f.push(u.end2.entityRef),t.set(u.end1.entityRef,f)}const o=0,i=1,a=2,l=new Map,r=[],s=[],c=new Set,d=u=>{l.set(u,i),r.push(u);for(const f of t.get(u)??[]){const p=l.get(f)??o;if(p===o)d(f);else if(p===i){const m=r.slice(r.indexOf(f)),h=[...m].sort().join(" ");c.has(h)||(c.add(h),s.push(m))}}r.pop(),l.set(u,a)};for(const u of e.entities)(l.get(u.modelId)??o)===o&&d(u.modelId);return s}function df(e,t,o,i,a){var l,r,s,c,d;if(!dt(t.physicalName))return t.physicalName;if(e.attrType==="EMBED_PREDEF")return((s=(r=(l=a==null?void 0:a.embeddableCatalog)==null?void 0:l.find(u=>u.type===e.type))==null?void 0:r.fields[o])==null?void 0:s.physicalName)??"";if(e.attrType==="EMBED_OWN"){const u=(c=e.embedded)==null?void 0:c.embeddableRef;if(u==null)return"";const f=(d=i.entities.find(p=>p.modelId===u))==null?void 0:d.attributes.flatMap(p=>p.dbAttrs)[o];return(f==null?void 0:f.physicalName)??""}return t.physicalName??""}function ya(e,t){const o=new Map;for(const i of e){const a=t(i);a==null||a===""||o.set(a,(o.get(a)??0)+1)}return e.filter(i=>{const a=t(i);return a!=null&&a!==""&&(o.get(a)??0)>1})}function nr(e,t){var l,r,s;const o=[];for(const c of ya(e.entities,d=>d.name))o.push({ruleId:"CHK-NAME-3",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:`엔티티 이름이 중복됩니다: "${c.name}"`});for(const c of e.entities){const d=c.attributes.filter(h=>h.attrType!=="DIVIDER");if(dt(c.name)&&o.push({ruleId:"CHK-NAME-4",severity:"info",targetKind:"entity",targetRef:c.modelId,message:"엔티티 이름이 비어 있습니다"}),c.stereotype==="JPA_ENTITY"&&!c.abstractClass&&(d.some(h=>h.identifier)||o.push({ruleId:"CHK-JPA-1",severity:"error",targetKind:"entity",targetRef:c.modelId,message:"JPA 엔티티에 식별자(PK) 속성이 없습니다"}),dt((l=c.table)==null?void 0:l.physicalName)&&o.push({ruleId:"CHK-JPA-8",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:"JPA 엔티티에 테이블 물리명이 설정되지 않았습니다"})),c.stereotype==="JPA_EMBEDDABLE")for(const h of d.filter(_=>_.identifier))o.push({ruleId:"CHK-JPA-2",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`임베더블 타입은 식별자 속성을 가질 수 없습니다: "${h.name}"`});for(const h of d.filter(_=>_.identifier&&_.transient))o.push({ruleId:"CHK-JPA-12",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`식별자(@Id) 속성은 transient(@Transient)일 수 없습니다: "${h.name}"`});for(const h of d)if(!h.identifier)for(const _ of h.dbAttrs)!_.autoIncrement&&dt(_.sequenceName)||o.push({ruleId:"CHK-JPA-13",severity:"error",targetKind:"column",targetRef:_.modelId,contextRef:c.modelId,message:`채번(${_.autoIncrement?"auto increment":`시퀀스 "${_.sequenceName}"`})은 식별자(@Id) 속성에만 쓸 수 있습니다 — 비식별 속성 "${h.name}"에 설정되어 있습니다`});for(const h of d.filter(_=>_.naturalId&&_.identifier))o.push({ruleId:"CHK-JPA-15",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`식별자(@Id) 속성은 자연키(@NaturalId)일 수 없습니다 — 자연키는 PK와 별개의 비즈니스 키입니다: "${h.name}"`});for(const h of d.filter(_=>_.naturalId&&_.transient))o.push({ruleId:"CHK-JPA-16",severity:"error",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`자연키(@NaturalId) 속성은 transient(@Transient)일 수 없습니다: "${h.name}"`});for(const h of d.filter(_=>_.naturalId&&!_.notNull&&!_.identifier&&!_.transient))o.push({ruleId:"CHK-JPA-17",severity:"warning",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`자연키(@NaturalId) 속성은 not null이 권장됩니다(비즈니스 키는 non-null이 원칙): "${h.name}"`});!c.abstractClass&&d.length===0&&o.push({ruleId:"CHK-DSN-2",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:"속성이 하나도 없는 엔티티입니다"}),(t==null?void 0:t.largeEntityThreshold)!=null&&d.length>t.largeEntityThreshold&&o.push({ruleId:"CHK-DSN-4",severity:"info",targetKind:"entity",targetRef:c.modelId,message:`속성이 ${d.length}개로 많습니다 (임계치 ${t.largeEntityThreshold} 초과) — 분해를 검토하세요`});for(const h of ya(d,_=>_.name))o.push({ruleId:"CHK-NAME-1",severity:"warning",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:`속성 이름이 중복됩니다: "${h.name}"`});for(const h of d)dt(h.name)&&o.push({ruleId:"CHK-NAME-4",severity:"info",targetKind:"attribute",targetRef:h.modelId,contextRef:c.modelId,message:"속성 이름이 비어 있습니다"});const u=d.flatMap(h=>h.dbAttrs).filter(h=>h.sharedColumnRef==null),f=d.flatMap(h=>h.dbAttrs.map((_,b)=>({col:_,name:df(h,_,b,e,t)})).filter(_=>_.col.sharedColumnRef==null));for(const h of ya(f,_=>_.name))o.push({ruleId:"CHK-NAME-2",severity:"error",targetKind:"column",targetRef:h.col.modelId,contextRef:c.modelId,message:`컬럼 물리명이 중복됩니다: "${h.name}"`});for(const h of u){const _=Uo(h.physicalName);_&&o.push({ruleId:"CHK-NAME-5",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:_}),t!=null&&t.reservedWords&&!dt(h.physicalName)&&t.reservedWords.has(h.physicalName.toUpperCase())&&o.push({ruleId:"CHK-NAME-6",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:`컬럼 물리명이 SQL 예약어입니다: "${h.physicalName}"`}),t!=null&&t.selectableDataTypes&&!dt(h.dataType)&&!t.selectableDataTypes.has(h.dataType)&&o.push({ruleId:"CHK-TYPE-1",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:`타겟 DB가 지원하지 않는 컬럼 타입입니다: "${h.dataType}"`}),!dt(h.dataType)&&af.has(h.dataType)&&!h.length&&o.push({ruleId:"CHK-TYPE-2",severity:"warning",targetKind:"column",targetRef:h.modelId,contextRef:c.modelId,message:`${h.dataType} 타입에 length가 지정되지 않았습니다`})}if((r=t==null?void 0:t.embeddableCatalog)!=null&&r.length){const h=Wn(d.flatMap(_=>_.dbAttrs));for(const _ of d){if(_.attrType!=="EMBED_PREDEF")continue;const b=t.embeddableCatalog.find(g=>g.type===_.type);b&&_.dbAttrs.forEach((g,I)=>{if(g.sharedColumnRef==null)return;const y=b.fields[I],N=h.get(g.sharedColumnRef);if(!y||!N)return;(N.dataType!==y.dataType||(N.length??null)!==(y.length??null)||(N.scale??null)!==(y.scale??null))&&o.push({ruleId:"CHK-TYPE-3",severity:"warning",targetKind:"column",targetRef:g.modelId,contextRef:c.modelId,message:`공유 대상 컬럼의 타입(${tr(N)})이 ${y.name??"컬럼"} 정의(${tr(y)})와 다릅니다`})})}}for(const h of d){const _=h.dbAttrs[0];if(!(_!=null&&_.multiValue))continue;h.type===Yn&&_.dataType==="VARCHAR"||o.push({ruleId:"CHK-TYPE-4",severity:"warning",targetKind:"column",targetRef:_.modelId,contextRef:c.modelId,message:`다중값(Multi-Value) 속성은 GroupCodeEnum + VARCHAR 조합에서만 컨버터가 자동 생성됩니다 — 현재(${h.type||"타입 미지정"} / ${_.dataType||"dataType 미지정"})에서는 Set<…> 필드만 생성되어 매핑이 불완전할 수 있습니다`})}const p=(s=c.table)==null?void 0:s.physicalName,m=Uo(p);m&&o.push({ruleId:"CHK-NAME-5",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:m}),t!=null&&t.reservedWords&&!dt(p)&&t.reservedWords.has(p.toUpperCase())&&o.push({ruleId:"CHK-NAME-6",severity:"warning",targetKind:"entity",targetRef:c.modelId,message:`테이블 물리명이 SQL 예약어입니다: "${p}"`});for(const h of c.indexes??[]){const _=Uo(h.name);_&&o.push({ruleId:"CHK-NAME-5",severity:"warning",targetKind:"index",targetRef:h.modelId,contextRef:c.modelId,message:_}),t!=null&&t.reservedWords&&!dt(h.name)&&t.reservedWords.has(h.name.toUpperCase())&&o.push({ruleId:"CHK-NAME-6",severity:"warning",targetKind:"index",targetRef:h.modelId,contextRef:c.modelId,message:`인덱스 이름이 SQL 예약어입니다: "${h.name}"`})}}const i=new Map;for(const c of e.entities)for(const d of c.attributes)d.attrType==="EMBED_OWN"&&d.embedded&&i.set(d.embedded.associationRef,d);for(const c of e.associations){Kn(c.end1.multiplicity)&&Kn(c.end2.multiplicity)&&o.push({ruleId:"CHK-DSN-1",severity:"info",targetKind:"association",targetRef:c.modelId,message:"both-many(M:N) 관계를 조인 엔티티 없이 직접 연결했습니다 — 연관 엔티티 도입을 검토하세요"}),i.has(c.modelId)&&c.identifying&&o.push({ruleId:"CHK-JPA-11",severity:"error",targetKind:"association",targetRef:c.modelId,message:"임베드(@Embedded/@ElementCollection)는 식별 관계로 둘 수 없습니다 — 임베더블은 독립 식별자가 없습니다"});for(const d of["end1","end2"]){const u=c[d].jpa;if(!u)continue;const f=u.cascadeTypes??[],p=f.includes("ALL"),m=f.includes("REMOVE");p&&f.length>1&&o.push({ruleId:"CHK-JPA-5",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: cascade ALL이 개별 cascade와 중복됩니다 (ALL이 모두 포함)`}),u.orphanRemoval&&(m||p)&&o.push({ruleId:"CHK-JPA-6",severity:"info",targetKind:"association",targetRef:c.modelId,message:`${d}: orphanRemoval이 cascade ${p?"ALL":"REMOVE"}와 의미가 겹칩니다`}),Kn(c[d].multiplicity)&&u.fetchType==="EAGER"&&o.push({ruleId:"CHK-JPA-7",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: 컬렉션(to-many) 연관에 EAGER 페치는 성능 위험이 있습니다`}),u.orphanRemoval&&Kn(c[d==="end1"?"end2":"end1"].multiplicity)&&o.push({ruleId:"CHK-JPA-14",severity:"error",targetKind:"association",targetRef:c.modelId,message:`${d}: orphanRemoval은 @ManyToOne/@ManyToMany(반대편이 컬렉션) 연관에는 적용할 수 없습니다 — @OneToOne·@OneToMany에서만 유효합니다`}),!Kn(c[d].multiplicity)&&(u.collectionType||u.collectionTable||u.orderColumn)&&o.push({ruleId:"CHK-JPA-9",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: 단일(to-one) 연관에 컬렉션 메타(collectionType/collectionTable/orderColumn)는 무의미합니다 — @ElementCollection은 컬렉션에서만 적용됩니다`}),u.collectionType==="SET"&&u.orderColumn&&o.push({ruleId:"CHK-JPA-10",severity:"warning",targetKind:"association",targetRef:c.modelId,message:`${d}: SET 컬렉션은 순서를 보존하지 않아 orderColumn(@OrderColumn)이 무의미합니다`})}}const a=new Map(e.entities.map(c=>[c.modelId,c.name||c.modelId]));for(const c of cf(e)){const d=[...c,c[0]].map(u=>a.get(u)??u).join(" → ");for(const u of c)o.push({ruleId:"CHK-JPA-4",severity:"warning",targetKind:"entity",targetRef:u,message:`식별 관계 사이클입니다 (PK 무한 의존): ${d}`})}if(t!=null&&t.flagEntitiesWithoutRelations){const c=new Set;for(const u of e.associations)c.add(u.end1.entityRef),c.add(u.end2.entityRef);const d=new Map(e.entities.map(u=>[u.name,u.modelId]));for(const u of e.entities){for(const f of u.attributes)f.embedded&&(c.add(u.modelId),c.add(f.embedded.embeddableRef));if(!dt(u.superClass)){c.add(u.modelId);const f=d.get(u.superClass);f&&c.add(f)}}for(const u of e.entities)c.has(u.modelId)||o.push({ruleId:"CHK-DSN-3",severity:"info",targetKind:"entity",targetRef:u.modelId,message:"모델링된 관계가 없습니다 (연관·상속·임베딩 미참여 — 의도적 생략이면 무시)"})}return o}function Me(){return crypto.randomUUID()}const uf="CustomMoneyType",ff="Money";function mf(e){return!(e.type!==uf||e.attrType!=="NORMAL"||e.identifier||e.dbAttrs.length>1)}function pf(e){const t=e.dbAttrs[0]??{modelId:Me(),physicalName:"",dataType:""},o={modelId:Me(),physicalName:"",dataType:""},{customType:i,...a}=e;return{...a,type:ff,attrType:"EMBED_PREDEF",dbAttrs:[t,o]}}function hf(e){let t=!1;const o=e.entities.map(i=>{let a=!1;const l=i.attributes.map(r=>mf(r)?(a=!0,t=!0,pf(r)):r);return a?{...i,attributes:l}:i});return t?{...e,entities:o}:e}function ga(e){if(!("rev"in e))return e;const{rev:t,...o}=e;return o}function vn(e,t){if(e===t||e==null&&t==null)return!0;if(e==null||t==null)return!1;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length?!1:e.every((o,i)=>vn(o,t[i]));if(typeof e=="object"&&typeof t=="object"){const o=new Set([...Object.keys(e),...Object.keys(t)]);for(const i of o)if(!vn(e[i],t[i]))return!1;return!0}return!1}function Zt(e,t,o){const i={},a=new Set([...Object.keys(e),...Object.keys(t)]);for(const l of a)o.has(l)||vn(e[l],t[l])||(i[l]=t[l]===void 0?null:t[l]);return Object.keys(i).length?i:null}function Jt(e,t,o){const i=new Map(e.map(d=>[o(d),d])),a=new Map(t.map(d=>[o(d),d])),l=[],r=[],s=[];for(const[d,u]of a){const f=i.get(d);f?s.push({cur:f,tgt:u}):l.push(u)}for(const[d,u]of i)a.has(d)||r.push(u);const c=(d,u)=>o(d)<o(u)?-1:o(d)>o(u)?1:0;return l.sort(c),r.sort(c),s.sort((d,u)=>c(d.tgt,u.tgt)),{added:l,removed:r,common:s}}function yf(e,t){const o=new Set(e),i=new Set(t),a=t.filter(r=>!o.has(r)).sort(),l=e.filter(r=>!i.has(r)).sort();return{added:a,removed:l}}const gf=new Set(["attributes","operations","indexes","rev"]),bf=new Set(["end1","end2","rev"]),_f=new Set(["memberEntityRefs","rev"]),or=new Set(["modelId"]),wf=new Set(["modelId","columns"]),vf=new Set([]);function kf(e,t,o,i){const a=Jt(t.attributes??[],o.attributes??[],s=>s.modelId);for(const s of a.removed)i.push({kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId});for(const s of a.added)i.push({kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of a.common){const d=Zt(s,c,or);d&&i.push({kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:s.modelId,patch:d})}const l=Jt(t.operations??[],o.operations??[],s=>s.modelId);for(const s of l.removed)i.push({kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId});for(const s of l.added)i.push({kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of l.common){const d=Zt(s,c,or);d&&i.push({kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:s.modelId,patch:d})}const r=Jt(t.indexes??[],o.indexes??[],s=>s.modelId);for(const s of r.removed)i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId});for(const s of r.added)i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:s});for(const{cur:s,tgt:c}of r.common){if(!vn(s.columns,c.columns)){i.push({kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId}),i.push({kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:c});continue}const d=Zt(s,c,wf);d&&i.push({kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:s.modelId,patch:d})}}function Ef(e,t,o){const i=Jt(e.entities??[],t.entities??[],r=>r.modelId);for(const r of i.removed)o.push({kind:"entity.remove",casUnit:"logical",entityRef:r.modelId});for(const r of i.added)o.push({kind:"entity.add",casUnit:"logical",entityRef:r.modelId,value:ga(r)});for(const{cur:r,tgt:s}of i.common){const c=Zt(r,s,gf);c&&o.push({kind:"entity.update",casUnit:"logical",containerRef:r.modelId,entityRef:r.modelId,patch:c}),kf(r.modelId,r,s,o)}const a=Jt(e.associations??[],t.associations??[],r=>r.modelId);for(const r of a.removed)o.push({kind:"association.remove",casUnit:"logical",associationRef:r.modelId});for(const r of a.added)o.push({kind:"association.add",casUnit:"logical",associationRef:r.modelId,value:ga(r)});for(const{cur:r,tgt:s}of a.common){const c=Zt(r,s,bf);c&&o.push({kind:"association.update",casUnit:"logical",containerRef:r.modelId,associationRef:r.modelId,patch:c});for(const d of["end1","end2"]){const u=Zt(r[d]??{},s[d]??{},vf);u&&o.push({kind:"associationEnd.update",casUnit:"logical",containerRef:r.modelId,associationRef:r.modelId,end:d,patch:u})}}const l=Jt(e.groups??[],t.groups??[],r=>r.modelId);for(const r of l.removed)o.push({kind:"group.remove",casUnit:"logical",groupRef:r.modelId});for(const r of l.added)o.push({kind:"group.add",casUnit:"logical",groupRef:r.modelId,value:ga(r)});for(const{cur:r,tgt:s}of l.common){const c=Zt(r,s,_f);c&&o.push({kind:"group.update",casUnit:"logical",containerRef:r.modelId,groupRef:r.modelId,patch:c});const d=yf(r.memberEntityRefs??[],s.memberEntityRefs??[]);for(const u of d.removed)o.push({kind:"group.removeMember",casUnit:"logical",containerRef:r.modelId,groupRef:r.modelId,entityRef:u});for(const u of d.added)o.push({kind:"group.addMember",casUnit:"logical",containerRef:r.modelId,groupRef:r.modelId,entityRef:u})}}function Ho(e,t,o,i,a,l,r){const s=Jt(e,t,o);for(const c of s.removed)r.push({kind:a,casUnit:"layout",[l]:o(c),value:void 0});for(const c of s.added)r.push({kind:i,casUnit:"layout",[l]:o(c),value:c});for(const{cur:c,tgt:d}of s.common)vn(c,d)||(r.push({kind:a,casUnit:"layout",[l]:o(c),value:void 0}),r.push({kind:i,casUnit:"layout",[l]:o(d),value:d}))}function Nf(e,t,o){Ho(e.entityLayouts??[],t.entityLayouts??[],i=>i.entityRef,"entityLayout.add","entityLayout.remove","entityRef",o),Ho(e.associationLayouts??[],t.associationLayouts??[],i=>i.associationRef,"associationLayout.add","associationLayout.remove","associationRef",o),Ho(e.groupLayouts??[],t.groupLayouts??[],i=>i.groupRef,"groupLayout.add","groupLayout.remove","groupRef",o),Ho(e.notes??[],t.notes??[],i=>i.modelId,"note.add","note.remove","noteRef",o)}function $f(e,t){const o=[];return Ef(e.logical,t.logical,o),Nf(e.layout,t.layout,o),o}function xf(e){if(e.groupRef!=null)return"group";if(e.associationRef!=null)return e.end!=null?"associationEnd":"association";if(e.entityRef!=null&&e.attributeRef!=null)return"attribute";if(e.entityRef!=null&&e.operationRef!=null)return"operation";if(e.entityRef!=null&&e.indexRef!=null)return"index";if(e.entityRef!=null)return"entity";throw new Error("projectFieldAudit: 대상 로케이터가 비었습니다(entityRef/associationRef/groupRef 중 하나 필요).")}const If={entity:new Set(["attributes","operations","indexes","rev","modelId"]),association:new Set(["end1","end2","rev","modelId"]),group:new Set(["memberEntityRefs","rev","modelId"]),attribute:new Set(["modelId"]),operation:new Set(["modelId"]),index:new Set(["modelId"]),associationEnd:new Set([])};class Sf{constructor(t){Ye(this,"out",[]);Ye(this,"last",new Map);this.fieldFilter=t}set(t,o,i){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;const a=this.last.get(o);this.out.push({...qn(t),field:o,value:i,...this.last.has(o)?{oldValue:a}:{}}),this.last.set(o,i)}remove(t,o){if(o!=null){if(this.fieldFilter!=null&&o!==this.fieldFilter)return;this.out.push({...qn(t),field:o,value:void 0,removed:!0,...this.last.has(o)?{oldValue:this.last.get(o)}:{}}),this.last.delete(o);return}const i=this.fieldFilter!=null?[this.fieldFilter]:[...this.last.keys()];for(const a of i){if(!this.last.has(a)){this.out.push({...qn(t),field:a,value:void 0,removed:!0});continue}this.out.push({...qn(t),field:a,value:void 0,removed:!0,oldValue:this.last.get(a)}),this.last.delete(a)}}member(t,o,i){const a="memberEntityRefs";this.fieldFilter!=null&&a!==this.fieldFilter||this.out.push({...qn(t),field:a,value:o,...i?{removed:!0}:{}})}result(){return this.out}}function qn(e){const t={seq:e.seq};return e.ts!==void 0&&(t.ts=e.ts),e.origin!==void 0&&(t.origin=e.origin),e.author!==void 0&&(t.author=e.author),e.kind!==void 0&&(t.kind=e.kind),e.restoredFromSeq!==void 0&&(t.restoredFromSeq=e.restoredFromSeq),t}function gt(e,t,o,i){if(o==null||typeof o!="object")return;const a=If[i];for(const[l,r]of Object.entries(o))a.has(l)||e.set(t,l,r)}function Qt(e,t,o){if(!(o==null||typeof o!="object"))for(const[i,a]of Object.entries(o))e.set(t,i,a)}function ba(e,t){if(Array.isArray(e))return e.find(o=>o.modelId===t)}function Pt(e,t){var l,r,s,c,d,u,f,p;const o=xf(t),i=new Sf(t.field),a=[...e].sort((m,h)=>m.seq-h.seq);for(const m of a)for(const h of m.ops)switch(o){case"entity":if(h.entityRef!==t.entityRef)break;h.kind==="entity.add"?gt(i,m,h.value,"entity"):h.kind==="entity.update"?Qt(i,m,h.patch):h.kind==="entity.remove"&&i.remove(m);break;case"attribute":if(h.entityRef!==t.entityRef)break;if(h.kind==="entity.add"){const _=ba((l=h.value)==null?void 0:l.attributes,t.attributeRef);_&>(i,m,_,"attribute")}else h.kind==="attribute.add"&&((r=h.value)==null?void 0:r.modelId)===t.attributeRef?gt(i,m,h.value,"attribute"):h.kind==="attribute.update"&&h.attributeRef===t.attributeRef?Qt(i,m,h.patch):(h.kind==="attribute.remove"&&h.attributeRef===t.attributeRef||h.kind==="entity.remove")&&i.remove(m);break;case"operation":if(h.entityRef!==t.entityRef)break;if(h.kind==="entity.add"){const _=ba((s=h.value)==null?void 0:s.operations,t.operationRef);_&>(i,m,_,"operation")}else h.kind==="operation.add"&&((c=h.value)==null?void 0:c.modelId)===t.operationRef?gt(i,m,h.value,"operation"):h.kind==="operation.update"&&h.operationRef===t.operationRef?Qt(i,m,h.patch):(h.kind==="operation.remove"&&h.operationRef===t.operationRef||h.kind==="entity.remove")&&i.remove(m);break;case"index":if(h.entityRef!==t.entityRef)break;if(h.kind==="entity.add"){const _=ba((d=h.value)==null?void 0:d.indexes,t.indexRef);_&>(i,m,_,"index")}else h.kind==="index.add"&&((u=h.value)==null?void 0:u.modelId)===t.indexRef?gt(i,m,h.value,"index"):h.kind==="index.update"&&h.indexRef===t.indexRef?Qt(i,m,h.patch):(h.kind==="index.remove"&&h.indexRef===t.indexRef||h.kind==="entity.remove")&&i.remove(m);break;case"association":if(h.associationRef!==t.associationRef)break;h.kind==="association.add"?gt(i,m,h.value,"association"):h.kind==="association.update"?Qt(i,m,h.patch):h.kind==="association.remove"&&i.remove(m);break;case"associationEnd":if(h.associationRef!==t.associationRef)break;if(h.kind==="association.add"){const _=(f=h.value)==null?void 0:f[t.end];gt(i,m,_,"associationEnd")}else h.kind==="associationEnd.update"&&h.end===t.end?Qt(i,m,h.patch):h.kind==="association.remove"&&i.remove(m);break;case"group":if(h.groupRef!==t.groupRef)break;if(h.kind==="group.add"){gt(i,m,h.value,"group");const _=(p=h.value)==null?void 0:p.memberEntityRefs;if(Array.isArray(_))for(const b of _)i.member(m,b,!1)}else h.kind==="group.update"?Qt(i,m,h.patch):h.kind==="group.remove"?i.remove(m):h.kind==="group.addMember"&&h.entityRef!=null?i.member(m,h.entityRef,!1):h.kind==="group.removeMember"&&h.entityRef!=null&&i.member(m,h.entityRef,!0);break}return i.result()}function Cf(e,t){const o=e;return o.entityRef===t||o.containerRef===t}function kn(e,t){if(Array.isArray(e))for(const o of e)typeof o.modelId=="string"&&t.add(o.modelId)}function Rf(e,t){const o=new Set,i=new Set,a=new Set;for(const l of e)for(const r of l.ops){const s=r;if(r.kind==="entity.add"&&s.entityRef===t){const c=s.value;kn(c==null?void 0:c.attributes,o),kn(c==null?void 0:c.operations,i),kn(c==null?void 0:c.indexes,a);continue}s.containerRef!==t&&s.entityRef!==t||(r.kind==="attribute.add"?kn([s.value],o):r.kind==="attribute.update"||r.kind==="attribute.remove"?typeof s.attributeRef=="string"&&o.add(s.attributeRef):r.kind==="operation.add"?kn([s.value],i):r.kind==="operation.update"||r.kind==="operation.remove"?typeof s.operationRef=="string"&&i.add(s.operationRef):r.kind==="index.add"?kn([s.value],a):(r.kind==="index.update"||r.kind==="index.remove")&&typeof s.indexRef=="string"&&a.add(s.indexRef))}return{attributes:o,operations:i,indexes:a}}function Fo(e,t){return e.map(o=>({...o,subject:t}))}function ir(e,t){const o=e.filter(s=>s.ops.some(c=>Cf(c,t))),{attributes:i,operations:a,indexes:l}=Rf(o,t),r=[...Fo(Pt(o,{entityRef:t}),{kind:"entity",ref:t})];for(const s of i)r.push(...Fo(Pt(o,{entityRef:t,attributeRef:s}),{kind:"attribute",ref:s}));for(const s of a)r.push(...Fo(Pt(o,{entityRef:t,operationRef:s}),{kind:"operation",ref:s}));for(const s of l)r.push(...Fo(Pt(o,{entityRef:t,indexRef:s}),{kind:"index",ref:s}));return r.map((s,c)=>({e:s,i:c})).sort((s,c)=>s.e.seq-c.e.seq||s.i-c.i).map(({e:s})=>s)}function ar(e){return`${e.kind}:${e.ref}:${e.end??""}`}function Vf(e){var i,a,l;const t=new Set,o=(r,s)=>{typeof s=="string"&&t.add(`${r}:${s}:`)};for(const r of e)for(const s of r.ops){const c=s;switch(s.kind){case"entity.add":{o("entity",c.entityRef);const d=c.value;for(const u of Array.isArray(d==null?void 0:d.attributes)?d.attributes:[])o("attribute",u.modelId);for(const u of Array.isArray(d==null?void 0:d.operations)?d.operations:[])o("operation",u.modelId);for(const u of Array.isArray(d==null?void 0:d.indexes)?d.indexes:[])o("index",u.modelId);break}case"attribute.add":o("attribute",(i=c.value)==null?void 0:i.modelId);break;case"operation.add":o("operation",(a=c.value)==null?void 0:a.modelId);break;case"index.add":o("index",(l=c.value)==null?void 0:l.modelId);break;case"association.add":o("association",c.associationRef);break;case"group.add":o("group",c.groupRef);break}}return t}function Af(e){const t=new Set,o=new Set,i=new Set;for(const a of e)for(const l of a.ops){const r=l,s=l.kind;if(s.startsWith("entity."))typeof r.entityRef=="string"&&t.add(r.entityRef);else if(s.startsWith("attribute.")||s.startsWith("operation.")||s.startsWith("index.")){const c=r.containerRef??r.entityRef;typeof c=="string"&&t.add(c)}else s.startsWith("associationEnd.")||s.startsWith("association.")?typeof r.associationRef=="string"&&o.add(r.associationRef):s.startsWith("group.")&&typeof r.groupRef=="string"&&i.add(r.groupRef)}return{entities:t,associations:o,groups:i}}function Tf(e){const{entities:t,associations:o,groups:i}=Af(e),a=[];for(const l of t)for(const r of ir(e,l))a.push({...r,subject:{...r.subject,entityRef:l}});for(const l of o){for(const r of Pt(e,{associationRef:l}))a.push({...r,subject:{kind:"association",ref:l}});for(const r of["end1","end2"])for(const s of Pt(e,{associationRef:l,end:r}))a.push({...s,subject:{kind:"associationEnd",ref:l,end:r}})}for(const l of i)for(const r of Pt(e,{groupRef:l}))a.push({...r,subject:{kind:"group",ref:l}});return a}function lr(e){const t=Tf(e),o=Vf(e),i=new Map;for(const r of t){const s=ar(r.subject),c=i.get(s);(c===void 0||r.seq<c)&&i.set(s,r.seq)}const a=new Map;for(const r of t){let s=a.get(r.seq);s||(s={meta:r,subjects:new Map},a.set(r.seq,s));const c=ar(r.subject);let d=s.subjects.get(c);if(!d){const u=r.removed?"remove":i.get(c)===r.seq&&o.has(c)?"add":"update";d={subject:r.subject,verb:u,fields:[]},s.subjects.set(c,d)}r.removed?d.verb="remove":d.fields.push({field:r.field,value:r.value,...r.oldValue!==void 0?{oldValue:r.oldValue}:{}})}const l=[];for(const[r,s]of a){const c=s.meta;l.push({seq:r,...c.ts!==void 0?{ts:c.ts}:{},...c.origin!==void 0?{origin:c.origin}:{},...c.author!==void 0?{author:c.author}:{},...c.kind!==void 0?{kind:c.kind}:{},...c.restoredFromSeq!==void 0?{restoredFromSeq:c.restoredFromSeq}:{},actions:[...s.subjects.values()]})}return l.sort((r,s)=>s.seq-r.seq)}class _a{constructor(t){Ye(this,"undoStack",[]);Ye(this,"redoStack",[]);Ye(this,"savePoint",null);Ye(this,"listeners",new Set);Ye(this,"commandListeners",new Set);Ye(this,"coalesceSealed",!1);this.state=t}execute(t){t.apply(this.state);const o=this.undoStack.at(-1),i=!this.coalesceSealed&&t.coalesceKey!=null&&!!o&&o.coalesceKey===t.coalesceKey;this.coalesceSealed=!1,i?(t.invert=o.invert,this.undoStack[this.undoStack.length-1]=t):this.undoStack.push(t),this.redoStack=[],this.emitCommand(t,"do",i),this.emit()}undo(){const t=this.undoStack.pop();t&&(t.invert(this.state),this.redoStack.push(t),this.emitCommand(t,"undo",!1),this.emit())}redo(){const t=this.redoStack.pop();t&&(t.apply(this.state),this.undoStack.push(t),this.emitCommand(t,"redo",!1),this.emit())}sealCoalesce(){this.coalesceSealed=!0}get canUndo(){return this.undoStack.length>0}get canRedo(){return this.redoStack.length>0}markSavePoint(){this.savePoint=this.undoStack.at(-1)??null,this.emit()}get isDirty(){return(this.undoStack.at(-1)??null)!==this.savePoint}onChange(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onCommand(t){return this.commandListeners.add(t),()=>this.commandListeners.delete(t)}emit(){for(const t of this.listeners)t()}emitCommand(t,o,i){for(const a of this.commandListeners)a(t,o,i)}}function rr(e,t){return e.logical.entities.findIndex(o=>o.modelId===t)}function je(e,t){return e.layout.entityLayouts.findIndex(o=>o.entityRef===t)}function ut(e,t){return e.layout.associationLayouts.find(o=>o.associationRef===t)}function ze(e,t){const o=e.logical.entities.find(i=>i.modelId===t);if(!o)throw new Error(`엔티티 없음: ${t}`);return o}function It(e,t,o){var i,a;return(a=(i=e.layout.notes.find(l=>l.modelId===t))==null?void 0:i.connections)==null?void 0:a.find(l=>l.targetRef===o)}function wa(e,t){return{label:`엔티티 추가: ${e.name}`,apply(o){o.logical.entities.push(e),o.layout.entityLayouts.push({entityRef:e.modelId,geo:t})},invert(o){const i=rr(o,e.modelId);i>=0&&o.logical.entities.splice(i,1);const a=je(o,e.modelId);a>=0&&o.layout.entityLayouts.splice(a,1)},emitOps(){const o={kind:"entity.add",casUnit:"logical",entityRef:e.modelId,value:e},i={kind:"entityLayout.add",casUnit:"layout",entityRef:e.modelId,value:{entityRef:e.modelId,geo:t},incidental:!0};return{forward:[o,i],invert:[{kind:"entityLayout.remove",casUnit:"layout",entityRef:e.modelId,incidental:!0},{kind:"entity.remove",casUnit:"logical",entityRef:e.modelId}]}}}}function sr(e){let t=null;const o=i=>i.end1.entityRef===e||i.end2.entityRef===e;return{label:"엔티티 삭제",apply(i){const a=rr(i,e);if(a<0)throw new Error(`엔티티 없음: ${e}`);const l=je(i,e),r=[];i.logical.associations.forEach((u,f)=>{o(u)&&r.push({item:u,index:f})});const s=new Set(r.map(u=>u.item.modelId)),c=[];i.layout.associationLayouts.forEach((u,f)=>{s.has(u.associationRef)&&c.push({item:u,index:f})});const d=[];i.logical.groups.forEach(u=>{const f=u.memberEntityRefs.indexOf(e);f>=0&&d.push({groupId:u.modelId,index:f})}),t={entity:{item:i.logical.entities[a],index:a},entityLayout:l>=0?{item:i.layout.entityLayouts[l],index:l}:void 0,assocs:r,assocLayouts:c,groupMemberships:d},[...c].sort((u,f)=>f.index-u.index).forEach(u=>i.layout.associationLayouts.splice(u.index,1)),[...r].sort((u,f)=>f.index-u.index).forEach(u=>i.logical.associations.splice(u.index,1));for(const u of d){const f=i.logical.groups.find(p=>p.modelId===u.groupId);f==null||f.memberEntityRefs.splice(u.index,1)}l>=0&&i.layout.entityLayouts.splice(l,1),i.logical.entities.splice(a,1)},invert(i){if(t){i.logical.entities.splice(t.entity.index,0,t.entity.item),t.entityLayout&&i.layout.entityLayouts.splice(t.entityLayout.index,0,t.entityLayout.item),[...t.assocs].sort((a,l)=>a.index-l.index).forEach(a=>i.logical.associations.splice(a.index,0,a.item)),[...t.assocLayouts].sort((a,l)=>a.index-l.index).forEach(a=>i.layout.associationLayouts.splice(a.index,0,a.item));for(const a of t.groupMemberships){const l=i.logical.groups.find(r=>r.modelId===a.groupId);l==null||l.memberEntityRefs.splice(a.index,0,e)}}},emitOps(){if(!t)return{forward:[],invert:[]};const i=[],a=[];for(const l of t.assocs)i.push({kind:"association.remove",casUnit:"logical",associationRef:l.item.modelId}),a.push({kind:"association.add",casUnit:"logical",associationRef:l.item.modelId,value:l.item});for(const l of t.assocLayouts)i.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:l.item.associationRef,incidental:!0}),a.push({kind:"associationLayout.add",casUnit:"layout",associationRef:l.item.associationRef,value:l.item,incidental:!0});for(const l of t.groupMemberships)i.push({kind:"group.removeMember",casUnit:"logical",containerRef:l.groupId,groupRef:l.groupId,entityRef:e}),a.push({kind:"group.addMember",casUnit:"logical",containerRef:l.groupId,groupRef:l.groupId,entityRef:e});return t.entityLayout&&(i.push({kind:"entityLayout.remove",casUnit:"layout",entityRef:e,incidental:!0}),a.push({kind:"entityLayout.add",casUnit:"layout",entityRef:e,value:t.entityLayout.item,incidental:!0})),i.push({kind:"entity.remove",casUnit:"logical",entityRef:e}),a.push({kind:"entity.add",casUnit:"logical",entityRef:e,value:t.entity.item}),{forward:i,invert:a.reverse()}}}}function cr(e,t){const o={};return{label:"엔티티 수정",apply(i){const a=ze(i,e);for(const l of Object.keys(t))o[l]=a[l];Object.assign(a,t)},invert(i){Object.assign(ze(i,e),o)},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:t}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{...o}}]}}}}function dr(e,t){let o="";return{label:`엔티티 이름 변경: ${t}`,apply(i){const a=ze(i,e);o=a.name,a.name=t},invert(i){ze(i,e).name=o},emitOps(){return{forward:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:t}}],invert:[{kind:"entity.update",casUnit:"logical",containerRef:e,entityRef:e,patch:{name:o}}]}}}}function En(e,t){let o=null;return{label:"엔티티 이동",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a].geo;o={...l.location},l.location={...t}},invert(i){const a=je(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.location=o)},emitOps(){const i=a=>({kind:"entityLayout.move",casUnit:"layout",entityRef:e,value:{location:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function ur(e,t){let o=null;return{label:"엔티티 크기 변경",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a].geo;o={...l.size},l.size={...t}},invert(i){const a=je(i,e);a>=0&&o&&(i.layout.entityLayouts[a].geo.size=o)},emitOps(){const i=a=>({kind:"entityLayout.resize",casUnit:"layout",entityRef:e,value:{size:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function Xn(e,t){const o={...(e==null?void 0:e.properties)??{}};return t?o.swatch=t:delete o.swatch,Object.keys(o).length?{properties:o}:void 0}function fr(e,t){let o;return{label:"엔티티 색상 변경",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a];o=l.style,l.style=Xn(l.style,t)},invert(i){const a=je(i,e);a>=0&&(i.layout.entityLayouts[a].style=o)},emitOps(i){const a=je(i,e),l=a>=0?i.layout.entityLayouts[a].style:void 0,r=s=>({kind:"entityLayout.setStyle",casUnit:"layout",entityRef:e,value:{style:s}});return{forward:[r(l)],invert:[r(o)]}}}}function mr(e,t){let o;return{label:t?"엔티티 접기":"엔티티 펼치기",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a];o=l.collapsed,l.collapsed=t},invert(i){const a=je(i,e);a>=0&&(i.layout.entityLayouts[a].collapsed=o)},emitOps(){const i=a=>({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:e,value:{collapsed:a}});return{forward:[i(t)],invert:[i(o)]}}}}function pr(e,t){let o;return{label:t?"엔티티 잠금":"엔티티 잠금 해제",apply(i){const a=je(i,e);if(a<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const l=i.layout.entityLayouts[a];o=l.locked,l.locked=t},invert(i){const a=je(i,e);a>=0&&(i.layout.entityLayouts[a].locked=o)},emitOps(){const i=a=>({kind:"entityLayout.setLocked",casUnit:"layout",entityRef:e,value:{locked:a}});return{forward:[i(t)],invert:[i(o)]}}}}function va(e){let t=[];return{label:e?"모두 접기":"모두 펼치기",apply(o){t=o.layout.entityLayouts.map(i=>i.collapsed);for(const i of o.layout.entityLayouts)i.collapsed=e},invert(o){o.layout.entityLayouts.forEach((i,a)=>{i.collapsed=t[a]})},emitOps(o){const i=[],a=[];return o.layout.entityLayouts.forEach((l,r)=>{i.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:l.entityRef,value:{collapsed:e}}),a.push({kind:"entityLayout.setCollapsed",casUnit:"layout",entityRef:l.entityRef,value:{collapsed:t[r]}})}),{forward:i,invert:a}}}}function Go(e,t,o){let i;return{label:"속성 색상 변경",apply(a){const l=je(a,e);if(l<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=a.layout.entityLayouts[l];i=r.attributeStyles;const s={...r.attributeStyles},c=Xn(s[t],o);c?s[t]=c:delete s[t],r.attributeStyles=Object.keys(s).length?s:void 0},invert(a){const l=je(a,e);l>=0&&(a.layout.entityLayouts[l].attributeStyles=i)},emitOps(a){const l=je(a,e),r=l>=0?a.layout.entityLayouts[l].attributeStyles:void 0,s=c=>({kind:"entityLayout.setAttrStyle",casUnit:"layout",entityRef:e,value:{attributeStyles:c}});return{forward:[s(r)],invert:[s(i)]}}}}function ka(e,t){return{label:"그룹 추가",apply(o){o.logical.groups.push(e),o.layout.groupLayouts.push({groupRef:e.modelId,geo:t})},invert(o){const i=o.logical.groups.findIndex(l=>l.modelId===e.modelId);i>=0&&o.logical.groups.splice(i,1);const a=o.layout.groupLayouts.findIndex(l=>l.groupRef===e.modelId);a>=0&&o.layout.groupLayouts.splice(a,1)},emitOps(){const o={kind:"group.add",casUnit:"logical",groupRef:e.modelId,value:e},i={kind:"groupLayout.add",casUnit:"layout",groupRef:e.modelId,value:{groupRef:e.modelId,geo:t},incidental:!0};return{forward:[o,i],invert:[{kind:"groupLayout.remove",casUnit:"layout",groupRef:e.modelId,incidental:!0},{kind:"group.remove",casUnit:"logical",groupRef:e.modelId}]}}}}function hr(e,t){const o={},i=a=>{const l=a.logical.groups.find(r=>r.modelId===e);if(!l)throw new Error(`그룹 없음: ${e}`);return l};return{label:"그룹 수정",apply(a){const l=i(a);for(const r of Object.keys(t))o[r]=l[r];Object.assign(l,t)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:t}],invert:[{kind:"group.update",casUnit:"logical",containerRef:e,groupRef:e,patch:{...o}}]}}}}function yr(e){let t=null;return{label:"그룹 해제",apply(o){const i=o.logical.groups.findIndex(l=>l.modelId===e);if(i<0)throw new Error(`그룹 없음: ${e}`);const a=o.layout.groupLayouts.findIndex(l=>l.groupRef===e);t={group:{item:o.logical.groups[i],index:i},layout:a>=0?{item:o.layout.groupLayouts[a],index:a}:void 0},a>=0&&o.layout.groupLayouts.splice(a,1),o.logical.groups.splice(i,1)},invert(o){t&&(o.logical.groups.splice(t.group.index,0,t.group.item),t.layout&&o.layout.groupLayouts.splice(t.layout.index,0,t.layout.item))},emitOps(){if(!t)return{forward:[],invert:[]};const o=[],i=[];return t.layout&&(o.push({kind:"groupLayout.remove",casUnit:"layout",groupRef:e,incidental:!0}),i.push({kind:"groupLayout.add",casUnit:"layout",groupRef:e,value:t.layout.item,incidental:!0})),o.push({kind:"group.remove",casUnit:"logical",groupRef:e}),i.push({kind:"group.add",casUnit:"logical",groupRef:e,value:t.group.item}),{forward:o,invert:i.reverse()}}}}function gr(e,t){let o=!1;const i=a=>a.logical.groups.find(l=>l.modelId===e);return{label:"그룹에 편입",apply(a){const l=i(a);l&&!l.memberEntityRefs.includes(t)&&(l.memberEntityRefs.push(t),o=!0)},invert(a){if(!o)return;const l=i(a),r=(l==null?void 0:l.memberEntityRefs.indexOf(t))??-1;r>=0&&l.memberEntityRefs.splice(r,1)},emitOps(){return o?{forward:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}],invert:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}]}:{forward:[],invert:[]}}}}function Yo(e,t){let o=-1;const i=a=>a.logical.groups.find(l=>l.modelId===e);return{label:"그룹에서 제외",apply(a){const l=i(a);o=(l==null?void 0:l.memberEntityRefs.indexOf(t))??-1,o>=0&&l.memberEntityRefs.splice(o,1)},invert(a){var l;o<0||(l=i(a))==null||l.memberEntityRefs.splice(o,0,t)},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"group.removeMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}],invert:[{kind:"group.addMember",casUnit:"logical",containerRef:e,groupRef:e,entityRef:t}]}}}}function br(e,t){let o=null;return{label:"그룹 이동",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.location},a.geo.location={...t}},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"groupLayout.move",casUnit:"layout",groupRef:e,value:{location:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function _r(e,t){let o=null;return{label:"그룹 크기 변경",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o={...a.geo.size},a.geo.size={...t}},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"groupLayout.resize",casUnit:"layout",groupRef:e,value:{size:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function wr(e,t){let o;return{label:"그룹 색상 변경",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.style,a.style=Xn(a.style,t)},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&(a.style=o)},emitOps(i){const a=i.layout.groupLayouts.find(r=>r.groupRef===e),l=r=>({kind:"groupLayout.setStyle",casUnit:"layout",groupRef:e,value:{style:r}});return{forward:[l(a==null?void 0:a.style)],invert:[l(o)]}}}}function vr(e,t){let o;return{label:t?"그룹 잠금":"그룹 잠금 해제",apply(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);if(!a)throw new Error(`그룹 레이아웃 없음: ${e}`);o=a.locked,a.locked=t},invert(i){const a=i.layout.groupLayouts.find(l=>l.groupRef===e);a&&(a.locked=o)},emitOps(){const i=a=>({kind:"groupLayout.setLocked",casUnit:"layout",groupRef:e,value:{locked:a}});return{forward:[i(t)],invert:[i(o)]}}}}function St(e,t){return{label:`속성 추가: ${t.name}`,apply(o){ze(o,e).attributes.push(t)},invert(o){const i=ze(o,e),a=i.attributes.findIndex(l=>l.modelId===t.modelId);a>=0&&i.attributes.splice(a,1)},emitOps(){return{forward:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:t}],invert:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t.modelId}]}}}}function en(e,t,o){const i={},a=l=>{const r=ze(l,e).attributes.find(s=>s.modelId===t);if(!r)throw new Error(`속성 없음: ${t}`);return r};return{label:"속성 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t,patch:o}],invert:[{kind:"attribute.update",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t,patch:{...i}}]}}}}function Nn(e,t){let o=null;return{label:"속성 삭제",apply(i){const a=ze(i,e),l=a.attributes.findIndex(r=>r.modelId===t);if(l<0)throw new Error(`속성 없음: ${t}`);o={item:a.attributes[l],index:l},a.attributes.splice(l,1)},invert(i){o&&ze(i,e).attributes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"attribute.remove",casUnit:"logical",containerRef:e,entityRef:e,attributeRef:t}],invert:[{kind:"attribute.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function Ea(e,t,o){let i=null;return{label:"속성 재정렬",apply(a){const l=ze(a,e);i=l.attributes.map(f=>({...f}));const r=new Set(t),s=l.attributes.filter(f=>r.has(f.modelId)),c=l.attributes.filter(f=>!r.has(f.modelId)),d=Math.max(0,Math.min(o,c.length)),u=[...c.slice(0,d),...s,...c.slice(d)];l.attributes.splice(0,l.attributes.length,...u),l.attributes.forEach((f,p)=>f.order=p)},invert(a){i&&ze(a,e).attributes.splice(0,1/0,...i)},emitOps(a){const l=ze(a,e).attributes.map(r=>({...r}));return{forward:[{kind:"attribute.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:l}],invert:[{kind:"attribute.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:i??[]}]}}}}function kr(e,t){let o=!1;return{label:`메서드 추가: ${t.name}`,apply(i){const a=ze(i,e);a.operations||(a.operations=[],o=!0),a.operations.push(t)},invert(i){var r;const a=ze(i,e),l=((r=a.operations)==null?void 0:r.findIndex(s=>s.modelId===t.modelId))??-1;l>=0&&a.operations.splice(l,1),o&&a.operations&&a.operations.length===0&&(a.operations=void 0)},emitOps(){return{forward:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:t}],invert:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t.modelId}]}}}}function Er(e,t,o){const i={},a=l=>{var s;const r=(s=ze(l,e).operations)==null?void 0:s.find(c=>c.modelId===t);if(!r)throw new Error(`메서드 없음: ${t}`);return r};return{label:"메서드 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t,patch:o}],invert:[{kind:"operation.update",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t,patch:{...i}}]}}}}function Nr(e,t){let o=null;return{label:"메서드 삭제",apply(i){var s;const a=ze(i,e),l=((s=a.operations)==null?void 0:s.findIndex(c=>c.modelId===t))??-1;if(l<0)throw new Error(`메서드 없음: ${t}`);const r=a.operations.length===1;o={item:a.operations[l],index:l,wasSole:r},a.operations.splice(l,1),r&&(a.operations=void 0)},invert(i){if(!o)return;const a=ze(i,e);a.operations||(a.operations=[]),a.operations.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"operation.remove",casUnit:"logical",containerRef:e,entityRef:e,operationRef:t}],invert:[{kind:"operation.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}function $r(e,t,o){let i=null;return{label:"메서드 재정렬",apply(a){const l=ze(a,e),r=l.operations??[];i=r.map(p=>({...p}));const s=new Set(t),c=r.filter(p=>s.has(p.modelId)),d=r.filter(p=>!s.has(p.modelId)),u=Math.max(0,Math.min(o,d.length)),f=[...d.slice(0,u),...c,...d.slice(u)];r.splice(0,r.length,...f),r.forEach((p,m)=>p.order=m),l.operations=r},invert(a){if(!i)return;const l=ze(a,e);l.operations&&l.operations.splice(0,1/0,...i)},emitOps(a){const l=(ze(a,e).operations??[]).map(r=>({...r}));return{forward:[{kind:"operation.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:l}],invert:[{kind:"operation.reorder",casUnit:"logical",containerRef:e,entityRef:e,value:i??[]}]}}}}function xr(e,t,o){let i;return{label:"메서드 색상 변경",apply(a){const l=je(a,e);if(l<0)throw new Error(`엔티티 레이아웃 없음: ${e}`);const r=a.layout.entityLayouts[l];i=r.operationStyles;const s={...r.operationStyles},c=Xn(s[t],o);c?s[t]=c:delete s[t],r.operationStyles=Object.keys(s).length?s:void 0},invert(a){const l=je(a,e);l>=0&&(a.layout.entityLayouts[l].operationStyles=i)},emitOps(a){const l=je(a,e),r=l>=0?a.layout.entityLayouts[l].operationStyles:void 0,s=c=>({kind:"entityLayout.setOpStyle",casUnit:"layout",entityRef:e,value:{operationStyles:c}});return{forward:[s(r)],invert:[s(i)]}}}}function Na(e,t){return{label:"관계 추가",apply(o){o.logical.associations.push(e),o.layout.associationLayouts.push(t)},invert(o){const i=o.logical.associations.findIndex(l=>l.modelId===e.modelId);i>=0&&o.logical.associations.splice(i,1);const a=o.layout.associationLayouts.findIndex(l=>l.associationRef===e.modelId);a>=0&&o.layout.associationLayouts.splice(a,1)},emitOps(){const o={kind:"association.add",casUnit:"logical",associationRef:e.modelId,value:e},i={kind:"associationLayout.add",casUnit:"layout",associationRef:e.modelId,value:t,incidental:!0};return{forward:[o,i],invert:[{kind:"associationLayout.remove",casUnit:"layout",associationRef:e.modelId,incidental:!0},{kind:"association.remove",casUnit:"logical",associationRef:e.modelId}]}}}}function Ir(e){let t=null;return{label:"관계 삭제",apply(o){const i=o.logical.associations.findIndex(l=>l.modelId===e);if(i<0)throw new Error(`관계 없음: ${e}`);const a=o.layout.associationLayouts.findIndex(l=>l.associationRef===e);t={assoc:{item:o.logical.associations[i],index:i},layout:a>=0?{item:o.layout.associationLayouts[a],index:a}:void 0},a>=0&&o.layout.associationLayouts.splice(a,1),o.logical.associations.splice(i,1)},invert(o){t&&(o.logical.associations.splice(t.assoc.index,0,t.assoc.item),t.layout&&o.layout.associationLayouts.splice(t.layout.index,0,t.layout.item))},emitOps(){if(!t)return{forward:[],invert:[]};const o=[],i=[];return t.layout&&(o.push({kind:"associationLayout.remove",casUnit:"layout",associationRef:e,incidental:!0}),i.push({kind:"associationLayout.add",casUnit:"layout",associationRef:e,value:t.layout.item,incidental:!0})),o.push({kind:"association.remove",casUnit:"logical",associationRef:e}),i.push({kind:"association.add",casUnit:"logical",associationRef:e,value:t.assoc.item}),{forward:o,invert:i.reverse()}}}}function Wo(e,t){const o={},i=a=>{const l=a.logical.associations.find(r=>r.modelId===e);if(!l)throw new Error(`관계 없음: ${e}`);return l};return{label:"관계 수정",apply(a){const l=i(a);for(const r of Object.keys(t))o[r]=l[r];Object.assign(l,t)},invert(a){Object.assign(i(a),o)},emitOps(){return{forward:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:t}],invert:[{kind:"association.update",casUnit:"logical",containerRef:e,associationRef:e,patch:{...o}}]}}}}function $n(e,t,o){const i={},a=l=>{const r=l.logical.associations.find(s=>s.modelId===e);if(!r)throw new Error(`관계 없음: ${e}`);return r[t]};return{label:"관계 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:t,patch:o}],invert:[{kind:"associationEnd.update",casUnit:"logical",containerRef:e,associationRef:e,end:t,patch:{...i}}]}}}}function Sr(e,t){return{label:"인덱스 추가",apply(o){const i=ze(o,e);(i.indexes??(i.indexes=[])).push(t)},invert(o){var l;const i=ze(o,e),a=((l=i.indexes)==null?void 0:l.findIndex(r=>r.modelId===t.modelId))??-1;a>=0&&i.indexes.splice(a,1)},emitOps(){return{forward:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:t}],invert:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t.modelId}]}}}}function Cr(e,t,o){const i={},a=l=>{var s;const r=(s=ze(l,e).indexes)==null?void 0:s.find(c=>c.modelId===t);if(!r)throw new Error(`인덱스 없음: ${t}`);return r};return{label:"인덱스 수정",apply(l){const r=a(l);for(const s of Object.keys(o))i[s]=r[s];Object.assign(r,o)},invert(l){Object.assign(a(l),i)},emitOps(){return{forward:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t,patch:o}],invert:[{kind:"index.update",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t,patch:{...i}}]}}}}function Rr(e,t){let o=null;return{label:"인덱스 삭제",apply(i){var r;const a=ze(i,e),l=((r=a.indexes)==null?void 0:r.findIndex(s=>s.modelId===t))??-1;if(l<0)throw new Error(`인덱스 없음: ${t}`);o={item:a.indexes[l],index:l},a.indexes.splice(l,1)},invert(i){o&&ze(i,e).indexes.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"index.remove",casUnit:"logical",containerRef:e,entityRef:e,indexRef:t}],invert:[{kind:"index.add",casUnit:"logical",containerRef:e,entityRef:e,value:o.item}]}:{forward:[],invert:[]}}}}const bt=(e,t)=>({kind:"associationLayout.setWaypoints",casUnit:"layout",associationRef:e,value:{waypoints:t}}),jn=(e,t)=>{var o;return((o=ut(e,t))==null?void 0:o.waypoints.map(i=>({...i})))??[]};function Vr(e,t,o){let i=null;return{label:"waypoint 이동",coalesceKey:`waypoint:${e}`,apply(a){const l=ut(a,e);if(!l||!l.waypoints[t])throw new Error(`waypoint 없음: ${e}[${t}]`);i={...l.waypoints[t]},l.waypoints.splice(t,1,{...o})},invert(a){const l=ut(a,e);l&&i&&l.waypoints.splice(t,1,i)},emitOps(a){const l=jn(a,e),r=l.map((s,c)=>c===t&&i?{...i}:s);return{forward:[bt(e,l)],invert:[bt(e,r)]}}}}function Ar(e,t){let o=null;return{label:"waypoint 제거",apply(i){const a=ut(i,e);if(!a||!a.waypoints[t])throw new Error(`waypoint 없음: ${e}[${t}]`);o={...a.waypoints[t]},a.waypoints.splice(t,1)},invert(i){const a=ut(i,e);a&&o&&a.waypoints.splice(t,0,o)},emitOps(i){const a=jn(i,e),l=a.slice();return o&&l.splice(t,0,{...o}),{forward:[bt(e,a)],invert:[bt(e,l)]}}}}function Tr(e,t,o){let i=null;return{label:"waypoint 평행이동",apply(a){const l=ut(a,e);if(!l)throw new Error(`관계 레이아웃 없음: ${e}`);i=l.waypoints.map(r=>({...r})),l.waypoints=i.map(r=>({x:r.x+t,y:r.y+o}))},invert(a){const l=ut(a,e);l&&i&&(l.waypoints=i)},emitOps(a){return{forward:[bt(e,jn(a,e))],invert:[bt(e,i??[])]}}}}function Mr(e){let t=null;return{label:"꺾은선 풀기",apply(o){const i=ut(o,e);if(!i)throw new Error(`관계 레이아웃 없음: ${e}`);t=i.waypoints.map(a=>({...a})),i.waypoints=[]},invert(o){const i=ut(o,e);i&&t&&(i.waypoints=t)},emitOps(o){return{forward:[bt(e,jn(o,e))],invert:[bt(e,t??[])]}}}}function Br(e,t,o){return{label:"waypoint 추가",apply(i){const a=ut(i,e);if(!a)throw new Error(`관계 레이아웃 없음: ${e}`);a.waypoints.splice(t,0,{...o})},invert(i){const a=ut(i,e);a==null||a.waypoints.splice(t,1)},emitOps(i){const a=jn(i,e),l=a.slice();return l.splice(t,1),{forward:[bt(e,a)],invert:[bt(e,l)]}}}}function Dr(e){return{label:"노트 추가",apply(t){t.layout.notes.push(e)},invert(t){const o=t.layout.notes.findIndex(i=>i.modelId===e.modelId);o>=0&&t.layout.notes.splice(o,1)},emitOps(){return{forward:[{kind:"note.add",casUnit:"layout",noteRef:e.modelId,value:e}],invert:[{kind:"note.remove",casUnit:"layout",noteRef:e.modelId}]}}}}function Or(e){let t=null;return{label:"노트 삭제",apply(o){const i=o.layout.notes.findIndex(a=>a.modelId===e);if(i<0)throw new Error(`노트 없음: ${e}`);t={item:o.layout.notes[i],index:i},o.layout.notes.splice(i,1)},invert(o){t&&o.layout.notes.splice(t.index,0,t.item)},emitOps(){return t?{forward:[{kind:"note.remove",casUnit:"layout",noteRef:e}],invert:[{kind:"note.add",casUnit:"layout",noteRef:e,value:t.item}]}:{forward:[],invert:[]}}}}function Zn(e,t){let o=null;return{label:"노트 이동",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.location},a.geo.location={...t}},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&o&&(a.geo.location=o)},emitOps(){const i=a=>({kind:"note.move",casUnit:"layout",noteRef:e,value:{location:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function Lr(e,t){let o=null;return{label:"노트 크기 변경",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o={...a.geo.size},a.geo.size={...t}},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&o&&(a.geo.size=o)},emitOps(){const i=a=>({kind:"note.resize",casUnit:"layout",noteRef:e,value:{size:{...a}}});return{forward:[i(t)],invert:[i(o)]}}}}function Pr(e,t){let o="";return{label:"노트 내용 변경",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.memo,a.memo=t},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&(a.memo=o)},emitOps(){const i=a=>({kind:"note.setMemo",casUnit:"layout",noteRef:e,value:{memo:a}});return{forward:[i(t)],invert:[i(o)]}}}}function zr(e,t){let o;return{label:"노트 색상 변경",apply(i){const a=i.layout.notes.find(l=>l.modelId===e);if(!a)throw new Error(`노트 없음: ${e}`);o=a.style,a.style=Xn(a.style,t)},invert(i){const a=i.layout.notes.find(l=>l.modelId===e);a&&(a.style=o)},emitOps(i){const a=i.layout.notes.find(r=>r.modelId===e),l=r=>({kind:"note.setStyle",casUnit:"layout",noteRef:e,value:{style:r}});return{forward:[l(a==null?void 0:a.style)],invert:[l(o)]}}}}function Ur(e,t){let o=!1,i=!1;const a=l=>l.layout.groupLayouts.find(r=>r.groupRef===e);return{label:"그룹에 노트 편입",apply(l){const r=a(l);r&&(r.memberNoteRefs||(r.memberNoteRefs=[],i=!0),!r.memberNoteRefs.includes(t)&&(r.memberNoteRefs.push(t),o=!0))},invert(l){if(!o)return;const r=a(l);if(!(r!=null&&r.memberNoteRefs))return;const s=r.memberNoteRefs.indexOf(t);s>=0&&r.memberNoteRefs.splice(s,1),i&&delete r.memberNoteRefs},emitOps(){return o?{forward:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:t}],invert:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:t}]}:{forward:[],invert:[]}}}}function Hr(e,t){let o=-1;const i=a=>a.layout.groupLayouts.find(l=>l.groupRef===e);return{label:"그룹에서 노트 제외",apply(a){var r;const l=i(a);o=((r=l==null?void 0:l.memberNoteRefs)==null?void 0:r.indexOf(t))??-1,o>=0&&l.memberNoteRefs.splice(o,1)},invert(a){if(o<0)return;const l=i(a);l&&(l.memberNoteRefs||(l.memberNoteRefs=[]),l.memberNoteRefs.splice(o,0,t))},emitOps(){return o<0?{forward:[],invert:[]}:{forward:[{kind:"groupLayout.removeNoteMember",casUnit:"layout",groupRef:e,noteRef:t}],invert:[{kind:"groupLayout.addNoteMember",casUnit:"layout",groupRef:e,noteRef:t}]}}}}const zt=(e,t,o)=>({kind:"noteConnection.setWaypoints",casUnit:"layout",noteRef:e,targetRef:t,value:{waypoints:o}}),Ko=(e,t,o)=>{var i;return((i=It(e,t,o))==null?void 0:i.waypoints.map(a=>({...a})))??[]};function Fr(e,t){let o=!1,i=!1;return{label:"노트 연결 추가",apply(a){const l=a.layout.notes.find(r=>r.modelId===e);if(!l)throw new Error(`노트 없음: ${e}`);if(l.connections||(l.connections=[],i=!0),l.connections.some(r=>r.targetRef===t)){o=!1;return}l.connections.push({targetRef:t,waypoints:[]}),o=!0},invert(a){if(!o)return;const l=a.layout.notes.find(s=>s.modelId===e);if(!(l!=null&&l.connections))return;const r=l.connections.findIndex(s=>s.targetRef===t);r>=0&&l.connections.splice(r,1),i&&delete l.connections},emitOps(){return o?{forward:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:t,value:{targetRef:t,waypoints:[]}}],invert:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:t}]}:{forward:[],invert:[]}}}}function Gr(e,t){let o=null;return{label:"노트 연결 삭제",apply(i){var r;const a=i.layout.notes.find(s=>s.modelId===e),l=((r=a==null?void 0:a.connections)==null?void 0:r.findIndex(s=>s.targetRef===t))??-1;if(!(a!=null&&a.connections)||l<0)throw new Error(`노트 연결 없음: ${e}→${t}`);o={item:a.connections[l],index:l},a.connections.splice(l,1)},invert(i){if(!o)return;const a=i.layout.notes.find(l=>l.modelId===e);a!=null&&a.connections&&a.connections.splice(o.index,0,o.item)},emitOps(){return o?{forward:[{kind:"noteConnection.remove",casUnit:"layout",noteRef:e,targetRef:t}],invert:[{kind:"noteConnection.add",casUnit:"layout",noteRef:e,targetRef:t,value:o.item}]}:{forward:[],invert:[]}}}}function Yr(e,t,o,i){let a=null;return{label:"waypoint 이동",coalesceKey:`noteConnWaypoint:${e}:${t}`,apply(l){const r=It(l,e,t);if(!r||!r.waypoints[o])throw new Error(`waypoint 없음: ${e}→${t}[${o}]`);a={...r.waypoints[o]},r.waypoints.splice(o,1,{...i})},invert(l){const r=It(l,e,t);r&&a&&r.waypoints.splice(o,1,a)},emitOps(l){const r=Ko(l,e,t),s=r.map((c,d)=>d===o&&a?{...a}:c);return{forward:[zt(e,t,r)],invert:[zt(e,t,s)]}}}}function Wr(e,t,o,i){return{label:"waypoint 추가",apply(a){const l=It(a,e,t);if(!l)throw new Error(`노트 연결 없음: ${e}→${t}`);l.waypoints.splice(o,0,{...i})},invert(a){const l=It(a,e,t);l==null||l.waypoints.splice(o,1)},emitOps(a){const l=Ko(a,e,t),r=l.slice();return r.splice(o,1),{forward:[zt(e,t,l)],invert:[zt(e,t,r)]}}}}function Kr(e,t,o){let i=null;return{label:"waypoint 제거",apply(a){const l=It(a,e,t);if(!l||!l.waypoints[o])throw new Error(`waypoint 없음: ${e}→${t}[${o}]`);i={...l.waypoints[o]},l.waypoints.splice(o,1)},invert(a){const l=It(a,e,t);l&&i&&l.waypoints.splice(o,0,i)},emitOps(a){const l=Ko(a,e,t),r=l.slice();return i&&r.splice(o,0,{...i}),{forward:[zt(e,t,l)],invert:[zt(e,t,r)]}}}}function qr(e,t){let o=null;return{label:"꺾은선 풀기",apply(i){const a=It(i,e,t);if(!a)throw new Error(`노트 연결 없음: ${e}→${t}`);o=a.waypoints.map(l=>({...l})),a.waypoints=[]},invert(i){const a=It(i,e,t);a&&o&&(a.waypoints=o)},emitOps(i){return{forward:[zt(e,t,Ko(i,e,t))],invert:[zt(e,t,o??[])]}}}}function Ue(e,t,o){return{label:e,coalesceKey:o,apply(i){for(const a of t)a.apply(i)},invert(i){for(let a=t.length-1;a>=0;a--)t[a].invert(i)},emitOps(i){const a=t.map(l=>{if(!l.emitOps)throw new Error(`emitOps 미구현 command가 composite에 포함됨: ${l.label}`);return l.emitOps(i)});return{forward:a.flatMap(l=>l.forward),invert:a.slice().reverse().flatMap(l=>l.invert)}}}}const Mf=Object.freeze(Object.defineProperty({__proto__:null,addAssociation:Na,addAttribute:St,addEntity:wa,addEntityToGroup:gr,addGroup:ka,addIndex:Sr,addNote:Dr,addNoteConnection:Fr,addNoteConnectionWaypoint:Wr,addNoteToGroup:Ur,addOperation:kr,addWaypoint:Br,clearNoteConnectionWaypoints:qr,clearWaypoints:Mr,composite:Ue,moveEntity:En,moveGroup:br,moveNote:Zn,moveNoteConnectionWaypoint:Yr,moveWaypoint:Vr,removeAssociation:Ir,removeAttribute:Nn,removeEntity:sr,removeEntityFromGroup:Yo,removeGroup:yr,removeIndex:Rr,removeNote:Or,removeNoteConnection:Gr,removeNoteConnectionWaypoint:Kr,removeNoteFromGroup:Hr,removeOperation:Nr,removeWaypoint:Ar,renameEntity:dr,reorderAttributes:Ea,reorderOperations:$r,resizeEntity:ur,resizeGroup:_r,resizeNote:Lr,setAllEntitiesCollapsed:va,setAttributeSwatch:Go,setEntityCollapsed:mr,setEntityLocked:pr,setEntitySwatch:fr,setGroupLocked:vr,setGroupSwatch:wr,setNoteMemo:Pr,setNoteSwatch:zr,setOperationSwatch:xr,translateWaypoints:Tr,updateAssociation:Wo,updateAssociationEnd:$n,updateAttribute:en,updateEntity:cr,updateGroup:hr,updateIndex:Cr,updateOperation:Er},Symbol.toStringTag,{value:"Module"}));class Xr{constructor(){Ye(this,"revs",new Map);Ye(this,"layoutVersion",0);Ye(this,"logicalVersion",0)}seed(t){this.revs.clear();for(const[o,i]of Object.entries(t.revs??{}))this.revs.set(o,i);this.layoutVersion=t.layoutVersion??0,this.logicalVersion=t.logicalVersion??0}rev(t){return this.revs.get(t)??0}setRev(t,o){this.revs.set(t,o)}deleteRev(t){this.revs.delete(t)}snapshot(){return{revs:Object.fromEntries(this.revs),layoutVersion:this.layoutVersion,logicalVersion:this.logicalVersion}}}class jr{constructor(t){Ye(this,"cache",new Xr);Ye(this,"newClientOpId");Ye(this,"debounceMs");Ye(this,"emissions",new WeakMap);Ye(this,"open",null);Ye(this,"debounceHandle",null);Ye(this,"queue",[]);Ye(this,"sending",!1);Ye(this,"_frozen",!1);Ye(this,"stack",null);Ye(this,"settledWaiters",[]);this.opts=t,this.newClientOpId=t.newClientOpId??Me,this.debounceMs=t.debounceMs??300}seed(t){this.cache.seed(t)}attach(t){this.stack=t;const o=t.onCommand((i,a,l)=>this.handle(i,a,l));return()=>{o(),this.stack===t&&(this.stack=null)}}get frozen(){return this._frozen}get hasPending(){return this.open!==null||this.queue.length>0||this.sending}cacheSnapshot(){return this.cache.snapshot()}flush(){this.flushOpen(!0)}whenSettled(){return this.hasPending?new Promise(t=>this.settledWaiters.push(t)):Promise.resolve()}handle(t,o,i){var r;if(this._frozen)return;let a;if(o==="do"){const s=(r=t.emitOps)==null?void 0:r.call(t,this.opts.state);if(!s)throw new Error(`op-mode에서 emitOps 미구현 command 실행: ${t.label}`);a=s}else{const s=this.emissions.get(t);if(!s)throw new Error(`op-mode ${o} 대상 command의 emission 미기록: ${t.label}`);a=s}const l=o==="undo"?a.invert:a.forward;if(o==="do"&&i&&this.open&&this.open.coalesceKey===t.coalesceKey){this.open.fwd=l,this.emissions.set(t,{forward:l,invert:this.open.inv}),this.resetDebounce();return}if(this.flushOpen(!1),o==="do"&&(this.emissions.set(t,a),t.coalesceKey!=null)){this.open={coalesceKey:t.coalesceKey,fwd:l,inv:a.invert},this.startDebounce();return}l.length&&this.enqueue(this.buildBatch(l))}flushOpen(t){var i;this.cancelDebounce();const o=this.open;this.open=null,o&&o.fwd.length&&this.enqueue(this.buildBatch(o.fwd)),t&&((i=this.stack)==null||i.sealCoalesce())}startDebounce(){this.cancelDebounce(),this.debounceHandle=setTimeout(()=>{this.debounceHandle=null,this.flushOpen(!0)},this.debounceMs)}resetDebounce(){this.startDebounce()}cancelDebounce(){this.debounceHandle!=null&&(clearTimeout(this.debounceHandle),this.debounceHandle=null)}buildBatch(t){const o={},i=new Set;let a=!1,l=!1;for(const r of t)if(r.casUnit==="logical")if(a=!0,r.containerRef)i.add(r.containerRef);else{const s=r.entityRef??r.associationRef??r.groupRef;s&&(r.kind.endsWith(".add")?this.cache.setRev(s,0):r.kind.endsWith(".remove")&&this.cache.deleteRev(s))}else r.incidental||(l=!0);if(i.size){o.revs={};for(const r of i){const s=this.cache.rev(r);o.revs[r]=s,this.cache.setRev(r,s+1)}}return l&&(o.layout=this.cache.layoutVersion,this.cache.layoutVersion=o.layout+1),a&&(this.cache.logicalVersion+=1),{diagramId:this.opts.diagramId,ops:t,cas:o,origin:this.opts.origin??"gui",clientOpId:this.newClientOpId()}}enqueue(t){this.queue.push(t),this.pump()}async pump(){var i,a;if(this.sending||this._frozen)return;const t=this.queue.shift();if(!t){this.notifySettled();return}this.sending=!0;let o=null;try{o=await this.opts.transport(t)}catch(l){this.sending=!1,console.error("[op-sync] op 전송 실패 → 하드 프리즈(kind:missing):",l),(a=(i=this.opts).onError)==null||a.call(i,l),this.freeze({kind:"missing"});return}this.sending=!1,o.ok?(this.reconcile(o),this.pump()):this.freeze(o.conflict)}reconcile(t){if(!(this.queue.length>0)){for(const[o,i]of Object.entries(t.revs))this.cache.setRev(o,i);this.cache.layoutVersion=t.layoutVersion,this.cache.logicalVersion=t.logicalVersion}}freeze(t){var o,i;this._frozen=!0,this.queue.length=0,this.open=null,this.cancelDebounce(),(i=(o=this.opts).onFreeze)==null||i.call(o,t),this.notifySettled()}notifySettled(){if(this.hasPending)return;const t=this.settledWaiters;this.settledWaiters=[];for(const o of t)o()}}const Zr=["entity.add","entity.update","entity.remove","attribute.add","attribute.update","attribute.remove","association.add","association.remove","association.update","associationEnd.update","index.add","index.update","index.remove","operation.add","operation.update","operation.remove","group.add"],Jr=()=>crypto.randomUUID(),Bf=e=>e.add.length===0&&e.update.length===0&&e.remove.length===0,Df=e=>e&&e[0].toLowerCase()+e.slice(1),Of=e=>e&&e[0].toUpperCase()+e.slice(1),Lf=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase();function Pf(e,t){return Df(e)+Of(t)}function zf(e,t){const o=e.entities.find(r=>r.modelId===t.end1.entityRef);if(!o)return[];if(o.stereotype==="JPA_EMBEDDABLE")return[];const a=t.end1.entityRef===t.end2.entityRef?!1:t.identifying===!0;return o.attributes.filter(r=>r.identifier&&(r.attrType==="NORMAL"||r.attrType==="RELATION_OWN")).sort((r,s)=>r.order-s.order).map(r=>{const s=Pf(o.name,r.name);return{associationRef:t.modelId,sourceAttributeRef:r.modelId,name:s,type:r.type,identifier:a,notNull:a,dbAttrs:r.dbAttrs.map(c=>({physicalName:Lf(s),logicalName:c.logicalName,dataType:c.dataType,length:c.length,scale:c.scale}))}})}const qo=(e,t)=>`${e}::${t}`,Xo=e=>e??void 0;function Uf(e,t,o){const i={};return e.type!==t.type&&(i.type=t.type),e.identifier!==t.identifier&&(i.identifier=t.identifier),e.notNull!==t.notNull&&(i.notNull=t.notNull),(e.dbAttrs.length!==t.dbAttrs.length||t.dbAttrs.some((l,r)=>{const s=e.dbAttrs[r];return!s||s.dataType!==l.dataType||Xo(s.length)!==Xo(l.length)||Xo(s.scale)!==Xo(l.scale)}))&&(i.dbAttrs=t.dbAttrs.map((l,r)=>{const s=e.dbAttrs[r];return{modelId:(s==null?void 0:s.modelId)??o(),physicalName:(s==null?void 0:s.physicalName)??l.physicalName,logicalName:(s==null?void 0:s.logicalName)??l.logicalName,dataType:l.dataType,length:l.length,scale:l.scale}})),Object.keys(i).length?i:null}function Hf(e,t,o){return{modelId:o(),name:e.name,type:e.type,attrType:"RELATION_OWN",identifier:e.identifier,notNull:e.notNull,order:t,dbAttrs:e.dbAttrs.map(i=>({...i,modelId:o()})),derivedFrom:{associationRef:e.associationRef,sourceAttributeRef:e.sourceAttributeRef}}}function Jn(e,t,o=Jr){const i={add:[],update:[],remove:[]},a=e.entities.find(f=>f.modelId===t);if(!a)return i;const l=e.associations.filter(f=>f.end2.entityRef===t),r=a.stereotype==="JPA_EMBEDDABLE"?[]:l.flatMap(f=>zf(e,f)),s=new Map(r.map(f=>[qo(f.associationRef,f.sourceAttributeRef),f])),c=a.attributes.filter(f=>f.derivedFrom),d=new Map(c.map(f=>[qo(f.derivedFrom.associationRef,f.derivedFrom.sourceAttributeRef),f]));for(const f of c){const p=qo(f.derivedFrom.associationRef,f.derivedFrom.sourceAttributeRef);s.has(p)||i.remove.push(f.modelId)}let u=a.attributes.reduce((f,p)=>Math.max(f,p.order),-1)+1;for(const f of r){const p=qo(f.associationRef,f.sourceAttributeRef),m=d.get(p);if(!m)i.add.push(Hf(f,u++,o));else{const h=Uf(m,f,o);h&&i.update.push({attributeId:m.modelId,patch:h})}}return i}function Ff(e,t){if(t.remove.length){const o=new Set(t.remove);e.attributes=e.attributes.filter(i=>!o.has(i.modelId))}for(const o of t.update){const i=e.attributes.find(a=>a.modelId===o.attributeId);i&&Object.assign(i,o.patch)}t.add.length&&e.attributes.push(...t.add)}function Gf(e){return{...e,entities:e.entities.map(t=>({...t,attributes:t.attributes.map(o=>({...o}))}))}}function Yf(e,t,o=Jr){const i=new Map,a=Gf(e),l=new Set,r=[t];for(;r.length;){const s=r.shift();if(l.has(s))continue;l.add(s);const c=new Set(a.associations.filter(d=>d.end1.entityRef===s).map(d=>d.end2.entityRef));for(const d of c){const u=Jn(a,d,o);if(Bf(u))continue;i.has(d)||i.set(d,u);const f=a.entities.find(p=>p.modelId===d);f&&Ff(f,u),l.has(d)||r.push(d)}}return i}function jo(e,t,o){var r;const i=e.entities.find(s=>s.modelId===t),a=i==null?void 0:i.attributes.find(s=>s.modelId===o);if(!a||!a.attrType.startsWith("RELATION")||a.dbAttrs.length===0)return;const l=(r=a.derivedFrom)==null?void 0:r.associationRef;if(l){const s=e.associations.find(c=>c.modelId===l);if(s)return s}return e.associations.find(s=>s.end1.entityRef===t&&s.end1.attributeRef===o||s.end2.entityRef===t&&s.end2.attributeRef===o)}function Wf(e,t){const o=()=>e.entities.filter(l=>{var r;return((r=l.table)==null?void 0:r.physicalName)===t.ref}),i=()=>e.entities.filter(l=>l.name===t.ref);if(t.by==="physicalName")return o();if(t.by==="name")return i();const a=o();return a.length?a:i()}function Kf(e,t){const o=()=>e.attributes.filter(l=>l.name===t.ref),i=()=>e.attributes.filter(l=>l.dbAttrs.some(r=>r.physicalName===t.ref));if(t.by==="name")return o();if(t.by==="physicalName")return i();const a=o();return a.length?a:i()}function Qr(e,t,o){return e.associations.filter(i=>{const a=[i.end1.entityRef,i.end2.entityRef];return a.includes(t)&&a.includes(o)})}function ot(e,t){const o=Wf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function qf(e,t){const o=Kf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Xf(e,t){const o=()=>e.attributes.flatMap(l=>l.dbAttrs).filter(l=>l.physicalName===t.ref),i=()=>e.attributes.filter(l=>l.name===t.ref).flatMap(l=>l.dbAttrs);if(t.by==="physicalName")return o();if(t.by==="name")return i();const a=o();return a.length?a:i()}function es(e,t){const o=Xf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function jf(e,t){return(e.indexes??[]).filter(o=>o.name===t.ref)}function Zf(e,t){return(e.operations??[]).filter(o=>o.name===t.ref)}function Jf(e,t){const o=jf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function Qf(e,t){const o=Zf(e,t);return o.length===1?{ok:!0,value:o[0]}:{ok:!1,reason:o.length===0?"not-found":"ambiguous",matches:o.map(i=>i.modelId)}}function ts(e,t,o){const i=e.physicalName!=null||e.dataType!=null||e.length!=null||e.scale!=null||e.columnLogicalName!=null||e.unique!=null||e.updatable!=null;return{modelId:o(),name:e.name,type:e.type,attrType:"NORMAL",identifier:e.identifier??!1,notNull:e.notNull??!1,order:t,...e.transient?{transient:!0}:{},...e.groupCode?{groupCode:e.groupCode}:{},...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},dbAttrs:i?[{modelId:o(),physicalName:e.physicalName??e.name,dataType:e.dataType??"",...e.length?{length:e.length}:{},...e.scale?{scale:e.scale}:{},...e.columnLogicalName?{logicalName:e.columnLogicalName}:{},...e.unique!=null?{unique:e.unique}:{},...e.updatable!=null?{updatable:e.updatable}:{}}]:[]}}function ns(e,t,o,i,a,l,r,s){const c=s(),d=new Map((e.embeddableOverrides??[]).map(p=>[p.field,p])),u=[];let f=!1;for(const p of t.fields){const m=d.get(p.name);if(m!=null&&m.sharedColumnPhysicalName){const h={ref:m.sharedColumnPhysicalName,by:"physicalName"},_=es(i,h);if(!_.ok){r.push(_.reason==="not-found"?{code:"shared-column-target-not-found",opIndex:a,entity:l,handle:h}:{code:"shared-column-target-ambiguous",opIndex:a,entity:l,handle:h,matches:_.matches}),f=!0;continue}u.push({modelId:s(),physicalName:"",dataType:"",sharedColumnRef:_.value.modelId});continue}u.push({modelId:s(),physicalName:(m==null?void 0:m.physicalName)??"",dataType:"",...m!=null&&m.length?{length:m.length}:{},...m!=null&&m.scale?{scale:m.scale}:{},...(m==null?void 0:m.insertable)!=null?{insertable:m.insertable}:{},...(m==null?void 0:m.updatable)!=null?{updatable:m.updatable}:{}})}return f?null:{modelId:c,name:e.name,type:t.type,attrType:"EMBED_PREDEF",identifier:e.identifier??!1,notNull:e.notNull??!1,order:o,...e.defaultValue!=null?{defaultValue:e.defaultValue}:{},...e.attributeGroup?{attributeGroup:e.attributeGroup}:{},...e.description?{description:e.description}:{},dbAttrs:u}}function os(e,t,o){return{modelId:o(),name:e.name,order:t,...e.visibility?{visibility:e.visibility}:{},...e.sourceCode?{sourceCode:e.sourceCode}:{},...e.description?{description:e.description}:{},...e.personalInfoAttributeType?{personalInfoAttributeType:e.personalInfoAttributeType}:{}}}function is(e,t,o,i,a,l){const r=[];let s=!1;for(const c of t.columns){const d=es(e,c.column);if(!d.ok){a.push(d.reason==="not-found"?{code:"column-not-found",opIndex:o,entity:i,handle:c.column}:{code:"column-ambiguous",opIndex:o,entity:i,handle:c.column,matches:d.matches}),s=!0;continue}r.push({columnRef:d.value.modelId,descending:c.descending??!1})}return s?null:{modelId:l(),name:t.name,unique:t.unique??!1,columns:r,...t.description?{description:t.description}:{},...t.parameters?{parameters:t.parameters}:{}}}function em(e,t,o={}){const i=o.mkId??Me,a=o.embeddableCatalog??[],l=f=>a.find(p=>p.type===f),r=[],s=[],c=new Map,d=new Map,u=new Set;for(const f of t)f.kind==="entity.add"&&(u.add(f.spec.name),f.spec.physicalName&&u.add(f.spec.physicalName));return t.forEach((f,p)=>{var m,h,_;switch(f.kind){case"entity.add":{const b=i(),g={modelId:b,name:f.spec.name,stereotype:f.spec.stereotype??"JPA_ENTITY",attributes:[],...f.spec.useVersion?{jpaAttrs:{useVersion:!0}}:{},...f.spec.physicalName?{table:{physicalName:f.spec.physicalName}}:{}},I={ref:f.spec.name};let y=!1;for(const[U,X]of(f.spec.attributes??[]).entries()){if(X.type==="GroupCodeEnum"&&!X.groupCode){s.push({code:"groupcode-required",opIndex:p,entity:I,handle:{ref:X.name}}),y=!0;continue}const K=l(X.type);if(K){const W=ns(X,K,U,g,p,I,s,i);W?g.attributes.push(W):y=!0}else(m=X.embeddableOverrides)!=null&&m.length?(s.push({code:"embeddable-type-unresolved",opIndex:p,entity:I,handle:{ref:X.name}}),y=!0):g.attributes.push(ts(X,U,i))}const N=(f.spec.operations??[]).map((U,X)=>os(U,X,i));N.length&&(g.operations=N);const q=[];for(const U of f.spec.indexes??[]){const X=is(g,U,p,I,s,i);X?q.push(X):y=!0}if(q.length&&(g.indexes=q),y)break;r.push({kind:"entity.add",casUnit:"logical",entityRef:b,value:g});break}case"entity.update":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}r.push({kind:"entity.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,patch:f.patch});break}case"entity.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}r.push({kind:"entity.remove",casUnit:"logical",entityRef:b.value.modelId});break}case"attribute.add":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}if(f.spec.type==="GroupCodeEnum"&&!f.spec.groupCode){s.push({code:"groupcode-required",opIndex:p,entity:f.entity,handle:{ref:f.spec.name}});break}const g=c.get(b.value.modelId)??b.value.attributes.length;c.set(b.value.modelId,g+1);const I=l(f.spec.type);let y;if(I)y=ns(f.spec,I,g,b.value,p,f.entity,s,i);else if((h=f.spec.embeddableOverrides)!=null&&h.length){s.push({code:"embeddable-type-unresolved",opIndex:p,entity:f.entity,handle:{ref:f.spec.name}});break}else y=ts(f.spec,g,i);if(!y)break;r.push({kind:"attribute.add",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,value:y});break}case"attribute.update":case"attribute.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=qf(b.value,f.attribute);if(!g.ok){s.push(g.reason==="not-found"?{code:"attribute-not-found",opIndex:p,entity:f.entity,handle:f.attribute}:{code:"attribute-ambiguous",opIndex:p,entity:f.entity,handle:f.attribute,matches:g.matches});break}f.kind==="attribute.update"?r.push({kind:"attribute.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,attributeRef:g.value.modelId,patch:f.patch}):r.push({kind:"attribute.remove",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,attributeRef:g.value.modelId});break}case"association.add":{const b=ot(e,f.spec.from),g=ot(e,f.spec.to);if(b.ok||s.push(it(b.reason,p,f.spec.from,b.matches,u)),g.ok||s.push(it(g.reason,p,f.spec.to,g.matches,u)),!b.ok||!g.ok)break;if(f.spec.identifying&&b.value.modelId===g.value.modelId){s.push({code:"self-identifying",opIndex:p,handle:{from:f.spec.from,to:f.spec.to}});break}const I=i(),y={modelId:I,...f.spec.identifying!=null?{identifying:f.spec.identifying}:{},end1:{entityRef:b.value.modelId,multiplicity:f.spec.fromMultiplicity??"EXACTLY_ONE_INSTANCE",navigable:!0,composition:!1},end2:{entityRef:g.value.modelId,multiplicity:f.spec.toMultiplicity??"ZERO_OR_MORE_INSTANCES",navigable:!0,composition:f.spec.composition??!1}},N={...e,associations:[...e.associations,y]},q=Jn(N,g.value.modelId,i);q.add[0]&&(y.end2.attributeRef=q.add[0].modelId),r.push({kind:"association.add",casUnit:"logical",associationRef:I,value:y});for(const U of q.add)r.push({kind:"attribute.add",casUnit:"logical",containerRef:g.value.modelId,entityRef:g.value.modelId,value:U});break}case"association.remove":{const b=ot(e,f.association.from),g=ot(e,f.association.to);if(b.ok||s.push(it(b.reason,p,f.association.from,b.matches,u)),g.ok||s.push(it(g.reason,p,f.association.to,g.matches,u)),!b.ok||!g.ok)break;const I=Qr(e,b.value.modelId,g.value.modelId);if(I.length!==1){s.push(I.length===0?{code:"association-not-found",opIndex:p,handle:f.association}:{code:"association-ambiguous",opIndex:p,handle:f.association,matches:I.map(y=>y.modelId)});break}r.push({kind:"association.remove",casUnit:"logical",associationRef:I[0].modelId});break}case"association.update":{const b=as(e,f.association,p,s,u);if(!b)break;r.push({kind:"association.update",casUnit:"logical",containerRef:b.modelId,associationRef:b.modelId,patch:f.patch});break}case"associationEnd.update":{const b=as(e,f.association,p,s,u);if(!b)break;const g=f.end==="from"?"end1":"end2";r.push({kind:"associationEnd.update",casUnit:"logical",containerRef:b.modelId,associationRef:b.modelId,end:g,patch:f.patch});break}case"index.add":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=is(b.value,f.spec,p,f.entity,s,i);if(!g)break;r.push({kind:"index.add",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,indexRef:g.modelId,value:g});break}case"index.update":case"index.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=Jf(b.value,f.index);if(!g.ok){s.push(g.reason==="not-found"?{code:"index-not-found",opIndex:p,entity:f.entity,handle:f.index}:{code:"index-ambiguous",opIndex:p,entity:f.entity,handle:f.index,matches:g.matches});break}if(f.kind==="index.update"){if("columns"in f.patch){s.push({code:"index-columns-patch-unsupported",opIndex:p,entity:f.entity,handle:f.index});break}r.push({kind:"index.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,indexRef:g.value.modelId,patch:f.patch})}else r.push({kind:"index.remove",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,indexRef:g.value.modelId});break}case"operation.add":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=d.get(b.value.modelId)??((_=b.value.operations)==null?void 0:_.length)??0;d.set(b.value.modelId,g+1);const I=os(f.spec,g,i);r.push({kind:"operation.add",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,operationRef:I.modelId,value:I});break}case"operation.update":case"operation.remove":{const b=ot(e,f.entity);if(!b.ok){s.push(it(b.reason,p,f.entity,b.matches,u));break}const g=Qf(b.value,f.operation);if(!g.ok){s.push(g.reason==="not-found"?{code:"operation-not-found",opIndex:p,entity:f.entity,handle:f.operation}:{code:"operation-ambiguous",opIndex:p,entity:f.entity,handle:f.operation,matches:g.matches});break}f.kind==="operation.update"?r.push({kind:"operation.update",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,operationRef:g.value.modelId,patch:f.patch}):r.push({kind:"operation.remove",casUnit:"logical",containerRef:b.value.modelId,entityRef:b.value.modelId,operationRef:g.value.modelId});break}case"group.add":{const b=[];let g=!1;for(const N of f.spec.members){const q=ot(e,N);if(!q.ok){s.push(it(q.reason,p,N,q.matches,u)),g=!0;continue}b.push(q.value.modelId)}if(g)break;const I=i(),y={modelId:I,excludeDDLGeneration:f.spec.excludeDDLGeneration??!1,memberEntityRefs:b,...f.spec.name?{name:f.spec.name}:{},...f.spec.packageName?{packageName:f.spec.packageName}:{},...f.spec.description?{description:f.spec.description}:{}};r.push({kind:"group.add",casUnit:"logical",groupRef:I,value:y});break}}}),s.length?{ok:!1,errors:s}:{ok:!0,ops:r}}function it(e,t,o,i,a){return e==="not-found"&&(a!=null&&a.has(o.ref))?{code:"pending-entity-ref",opIndex:t,handle:o}:e==="not-found"?{code:"entity-not-found",opIndex:t,handle:o}:{code:"entity-ambiguous",opIndex:t,handle:o,matches:i}}function as(e,t,o,i,a){const l=ot(e,t.from),r=ot(e,t.to);if(l.ok||i.push(it(l.reason,o,t.from,l.matches,a)),r.ok||i.push(it(r.reason,o,t.to,r.matches,a)),!l.ok||!r.ok)return null;const s=Qr(e,l.value.modelId,r.value.modelId);return s.length!==1?(i.push(s.length===0?{code:"association-not-found",opIndex:o,handle:t}:{code:"association-ambiguous",opIndex:o,handle:t,matches:s.map(c=>c.modelId)}),null):s[0]}const ls={type:"object",description:"요소 지정 핸들. 엔티티: 물리명(table.physicalName) 우선, 논리명(name) 보조. 속성: 소속 엔티티 내 속성명 또는 컬럼 물리명.",properties:{ref:{type:"string",description:"매칭할 이름/물리명."},by:{type:"string",enum:["physicalName","name"],description:"매칭 키 고정(미지정 시 대상별 기본 순서)."}},required:["ref"],additionalProperties:!1},tm={type:"object",description:"관계는 무명이라 양 끝 엔티티로 주소. from=부모(end1), to=자식(end2). 같은 쌍 복수 관계는 모호 보고.",properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"}},required:["from","to"],additionalProperties:!1},nm={type:"object",description:"신규 엔티티. 자식(속성·인덱스·operation)은 별도 attribute.add 등이 아니라 여기 inline 배열로 담아라 — 같은 배치에서 갓 추가된 엔티티에 닿는 child op은 silent no-op이 된다(서버가 pending-entity-ref로 거부). 관계는 inline 불가 → 엔티티 추가 배치 확정 후 별도 배치로 association.add.",properties:{name:{type:"string"},stereotype:{type:"string",enum:["UNDEFINED","JPA_ENTITY","JPA_EMBEDDABLE","JPA_MULTI_LANGUAGE_ENTITY"],description:"기본 JPA_ENTITY."},physicalName:{type:"string",description:"설정 시 table.physicalName."},useVersion:{type:"boolean",description:'JPA @Version(낙관적 락) → jpaAttrs.useVersion. @Version 필드는 별도 속성이 아니라 이 엔티티 플래그로 흡수 (버전 컬럼은 코드젠 소유). 기존 엔티티는 entity.update patch의 dotted key {"jpaAttrs.useVersion":true} 사용.'},attributes:{type:"array",description:"inline 속성(배열 순서가 order). attribute.add와 동일 규칙 — GroupCodeEnum은 groupCode 동반 필수.",items:{$ref:"#/$defs/attrSpec"}},indexes:{type:"array",description:"inline 인덱스. 컬럼 핸들은 이 엔티티가 inline으로 만드는 dbAttr 내에서 해소된다(attributes 동반 전제).",items:{$ref:"#/$defs/indexSpec"}},operations:{type:"array",description:"inline 도메인 메서드(배열 순서가 order).",items:{$ref:"#/$defs/operationSpec"}}},required:["name"],additionalProperties:!1},Zo={type:"object",properties:{ko:{type:"string"},en:{type:"string"},ja:{type:"string"},zh:{type:"string"}},additionalProperties:!1},om={type:"object",properties:{name:{type:"string"},type:{type:"string",description:"Java 타입(예: Long, String). GroupCodeEnum은 파생 타입이라 groupCode 동반 필수(없으면 거부). 호스트 임베더블 카탈로그에 등록된 predefined 임베더블 타입(예: Money, EmbeddableAddress)이면 EMBED_PREDEF로 다중 컬럼 확장(서브컬럼 조정은 embeddableOverrides)."},identifier:{type:"boolean"},notNull:{type:"boolean"},transient:{type:"boolean",description:"JPA @Transient(비영속) → Attribute.transient. 컬럼을 만들지 않으므로 physicalName/dataType 등 컬럼 필드는 함께 주지 않는다. 기존 속성은 attribute.update patch {transient:true}로도 가능."},physicalName:{type:"string",description:"설정 시 단일 dbAttr 컬럼 생성(미설정이면 name을 물리명으로)."},dataType:{type:"string",description:"dbAttr 물리 타입(예: BIGINT). physicalName/dataType/length/scale 중 하나라도 있으면 컬럼 생성."},length:{type:"integer",description:"dbAttr 컬럼 길이(VARCHAR(n)·DECIMAL precision)."},scale:{type:"integer",description:"dbAttr 소수 자릿수(DECIMAL/NUMERIC scale). length 동반이 일반적."},groupCode:{type:"string",description:"코드성 속성의 group code 바인딩. type=GroupCodeEnum이면 필수."},defaultValue:{type:"string",description:"속성 기본값(문자열 패스스루)."},attributeGroup:{type:"string",description:"속성 분류 그룹(예: 'code'·'amt')."},description:{...Zo,description:"속성 설명(다국어)."},columnLogicalName:{...Zo,description:'dbAttr 컬럼 논리명(다국어, 예: {ko:"체크아웃유형"}). 한글 업무명 보존 위치.'},unique:{type:"boolean",description:"dbAttr UNIQUE 제약."},updatable:{type:"boolean",description:"dbAttr 갱신 가능(JPA @Column(updatable=))."},embeddableOverrides:{type:"array",description:"predefined 임베더블 서브컬럼 오버라이드(type이 카탈로그 엔트리일 때만). field=카탈로그 필드명으로 매칭 (@AttributeOverride 대응). 미설정 서브컬럼은 카탈로그 기본 상속. currency 등 공유 컬럼은 sharedColumnPhysicalName으로 SHARED_REF.",items:{type:"object",properties:{field:{type:"string",description:"대상 카탈로그 필드명(예: amount·currency)."},physicalName:{type:"string",description:"서브컬럼 물리명 오버라이드(@AttributeOverride column name). 미설정 시 카탈로그 기본."},length:{type:"integer",description:"서브컬럼 길이 오버라이드."},scale:{type:"integer",description:"서브컬럼 소수 자릿수 오버라이드."},insertable:{type:"boolean",description:"JPA @Column(insertable=). OWN 컬럼에만 저장."},updatable:{type:"boolean",description:"JPA @Column(updatable=). OWN 컬럼에만 저장."},sharedColumnPhysicalName:{type:"string",description:"SHARED_REF — 같은 엔터티 다른 컬럼(물리명)을 공유해 read-only 투영(대표: currency). 설정 시 자체 컬럼 미보유, 타깃은 해소 시점 존재 필수."}},required:["field"],additionalProperties:!1}}},required:["name","type"],additionalProperties:!1},rs={type:"string",enum:["NO_INSTANCE_OR_ONE_INSTANCE","EXACTLY_ONE_INSTANCE","ZERO_OR_MORE_INSTANCES","ONE_OR_MORE_INSTANCES"]},im={type:"object",properties:{from:{$ref:"#/$defs/handle"},to:{$ref:"#/$defs/handle"},fromMultiplicity:{...rs,description:"end1 다중성(기본 EXACTLY_ONE_INSTANCE)."},toMultiplicity:{...rs,description:"end2 다중성(기본 ZERO_OR_MORE_INSTANCES)."},identifying:{type:"boolean",description:"식별 관계(부모 PK가 자식 PK로 전파). self-association은 식별 불가."},composition:{type:"boolean",description:"end2 composition."}},required:["from","to"],additionalProperties:!1},am={type:"object",properties:{name:{type:"string"},unique:{type:"boolean",description:"UNIQUE 인덱스 여부(기본 false)."},columns:{type:"array",description:"인덱스 컬럼(순서 의미 있음).",items:{type:"object",properties:{column:{...ls,description:"컬럼 핸들 — 컬럼 물리명 우선, 속성명 보조(단일 컬럼 속성만). 엔티티 내에서 dbAttr modelId로 해소."},descending:{type:"boolean",description:"내림차순(기본 false)."}},required:["column"],additionalProperties:!1}},description:{type:"string",description:"인덱스 설명(평문)."},parameters:{type:"string",description:"인덱스 파라미터(패스스루)."}},required:["name","columns"],additionalProperties:!1},lm={type:"object",properties:{name:{type:"string"},visibility:{type:"string",enum:["PUBLIC","PRIVATE","PROTECTED","PACKAGE"],description:"가시성(기본 미설정)."},sourceCode:{type:"string",description:"Java 메서드 본문(멀티라인, 파라미터·반환 시그니처 포함)."},description:{...Zo,description:"메서드 설명(다국어)."},personalInfoAttributeType:{type:"string",description:"개인정보 속성 유형(패스스루)."}},required:["name"],additionalProperties:!1},rm={type:"object",properties:{name:{...Zo,description:'그룹 논리명(다국어, 예: {ko:"주문"}).'},packageName:{type:"string",description:"자바 패키지명 등 그룹 물리 식별(레거시 LogicalGroup.packageName)."},description:{type:"string",description:"그룹 설명(자유 텍스트 — 도메인 경계 메모)."},excludeDDLGeneration:{type:"boolean",description:"DDL 생성 제외(기본 false)."},members:{type:"array",description:"멤버 엔티티 핸들(물리명 우선/논리명 보조). 기존 엔티티여야 함 — 같은 배치 신규 엔티티는 별도 배치 후.",items:{$ref:"#/$defs/handle"}}},required:["members"],additionalProperties:!1},sm={type:"object",description:"부분 patch(임의 키). 값 품질 검증은 별도 엔진."};function et(e,t){return{type:"object",properties:{kind:{const:e},...t.properties},required:["kind",...t.required],additionalProperties:!1}}const cm={"entity.add":et("entity.add",{properties:{spec:{$ref:"#/$defs/entitySpec"}},required:["spec"]}),"entity.update":et("entity.update",{properties:{entity:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","patch"]}),"entity.remove":et("entity.remove",{properties:{entity:{$ref:"#/$defs/handle"}},required:["entity"]}),"attribute.add":et("attribute.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/attrSpec"}},required:["entity","spec"]}),"attribute.update":et("attribute.update",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","attribute","patch"]}),"attribute.remove":et("attribute.remove",{properties:{entity:{$ref:"#/$defs/handle"},attribute:{$ref:"#/$defs/handle"}},required:["entity","attribute"]}),"association.add":et("association.add",{properties:{spec:{$ref:"#/$defs/assocSpec"}},required:["spec"]}),"association.remove":et("association.remove",{properties:{association:{$ref:"#/$defs/assocHandle"}},required:["association"]}),"association.update":et("association.update",{properties:{association:{$ref:"#/$defs/assocHandle"},patch:{$ref:"#/$defs/patch"}},required:["association","patch"]}),"associationEnd.update":et("associationEnd.update",{properties:{association:{$ref:"#/$defs/assocHandle"},end:{type:"string",enum:["from","to"],description:"from=부모(end1), to=자식(end2)."},patch:{$ref:"#/$defs/patch"}},required:["association","end","patch"]}),"index.add":et("index.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/indexSpec"}},required:["entity","spec"]}),"index.update":et("index.update",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","index","patch"]}),"index.remove":et("index.remove",{properties:{entity:{$ref:"#/$defs/handle"},index:{$ref:"#/$defs/handle"}},required:["entity","index"]}),"operation.add":et("operation.add",{properties:{entity:{$ref:"#/$defs/handle"},spec:{$ref:"#/$defs/operationSpec"}},required:["entity","spec"]}),"operation.update":et("operation.update",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/handle"},patch:{$ref:"#/$defs/patch"}},required:["entity","operation","patch"]}),"operation.remove":et("operation.remove",{properties:{entity:{$ref:"#/$defs/handle"},operation:{$ref:"#/$defs/handle"}},required:["entity","operation"]}),"group.add":et("group.add",{properties:{spec:{$ref:"#/$defs/groupSpec"}},required:["spec"]})},ss={anyOf:Zr.map(e=>cm[e])},dm={type:"object",description:"엔티티 모델을 생성·수정·삭제할 때 호출한다. ops는 사람 핸들(엔티티 물리명/논리명, 속성명)로 지정하며 서버가 modelId로 해소한다. 모호하면 에러로 후보를 돌려주니 리소스로 현재 모델을 먼저 읽어 핸들을 확정하라.",properties:{ops:{type:"array",items:{$ref:"#/$defs/symbolicOp"}}},required:["ops"],additionalProperties:!1,$defs:{handle:ls,assocHandle:tm,entitySpec:nm,attrSpec:om,assocSpec:im,indexSpec:am,operationSpec:lm,groupSpec:rm,patch:sm,symbolicOp:ss}};function um(e,t,o,i={}){const a=i.mkClientOpId??Me,l=new Set;for(const s of o)s.casUnit==="logical"&&s.containerRef&&l.add(s.containerRef);const r={};if(l.size){r.revs={};for(const s of l)r.revs[s]=t[s]??0}return{diagramId:e,ops:o,cas:r,origin:i.origin??"agent",clientOpId:a()}}const cs={location:{x:0,y:0},size:{width:220,height:140}};function ds(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}const fm=/^[-=_*~\s]{3,}$/;function mm(e){return e.attrType&&e.attrType!=="NORMAL"||!fm.test(e.name??"")?!1:!(e.dbAttrs??[]).some(t=>t.physicalName||t.dataType)}function pm(e,t){return e.attrType==="DIVIDER"||mm(e)?{modelId:e.modelId,name:e.attrType==="DIVIDER"?e.name:"",type:"",attrType:"DIVIDER",identifier:!1,notNull:!1,order:e.order??t,dbAttrs:[]}:{modelId:e.modelId,name:e.name,type:e.type,customType:e.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order??t,dbAttrs:e.dbAttrs.map(ds)}}function hm(e){const{modelId:t,name:o,visibility:i,sourceCode:a,description:l,order:r,personalInfoAttributeType:s,style:c,...d}=e;return{modelId:t,name:o,visibility:i,sourceCode:a,description:l?{ko:l}:void 0,order:r??0,personalInfoAttributeType:s,legacyRaw:Object.keys(d).length?d:void 0}}function ym(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,columns:e.indexColumns.map(t=>({columnRef:t.targetColumn.refId,descending:t.descending}))}}function gm(e){var t,o;return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.map(pm),operations:(t=e.operations)==null?void 0:t.map(hm),indexes:(o=e.indexes)==null?void 0:o.map(ym),jpaAttrs:e.jpaAttrs,table:e.dbAttrs?{physicalName:e.dbAttrs.physicalName,logicalName:e.dbAttrs.logicalName}:void 0}}function bm(e){const t={};for(const i of e.attributes)i.style&&(t[i.modelId]=i.style);const o={};for(const i of e.operations??[])i.style&&(o[i.modelId]=i.style);return{entityRef:e.modelId,geo:e.geo??{...cs},style:e.style,attributeStyles:Object.keys(t).length?t:void 0,operationStyles:Object.keys(o).length?o:void 0,collapsed:e.collapsed,locked:e.locked}}function us(e){return e.jpaAttribute?{fetchType:e.jpaAttribute.fetchType,cascadeTypes:e.jpaAttribute.cascadeTypes,orphanRemoval:e.jpaAttribute.orphanRemoval,orderBy:e.jpaAttribute.orderBy,collectionType:e.jpaAttribute.collectionType,collectionTable:e.jpaAttribute.collectionTable,orderColumn:e.jpaAttribute.orderColumn}:void 0}function $a(e){var t;return{entityRef:e.endModel.refId,multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,attributeRef:(t=e.attribute)==null?void 0:t.modelId,jpa:us(e)}}function _m(e){var i,a;const t={modelId:e.modelId,description:e.description,end1:$a(e.end1),end2:$a(e.end2)},o={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:(i=e.end1.attribute)==null?void 0:i.modelId,targetColumnRef:(a=e.end2.attribute)==null?void 0:a.modelId,style:e.style};return{assoc:t,layout:o}}function fs(e){var t;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("RELATION")&&(((t=e.dbAttrs)==null?void 0:t.length)??0)>0}function ms(e){var t;return!!e&&typeof e.attrType=="string"&&e.attrType.startsWith("EMBED")&&(((t=e.dbAttrs)==null?void 0:t.length)??0)>0}function ps(e){var o;const t=e.attribute;return(t==null?void 0:t.attrType)==="EMBED_OWN"&&(((o=t.dbAttrs)==null?void 0:o.length)??0)===0&&(e.multiplicity==="ZERO_OR_MORE_INSTANCES"||e.multiplicity==="ONE_OR_MORE_INSTANCES")}function hs(e,t){return{modelId:e.modelId,name:e.name??"",type:e.type??"",customType:e.customType,attrType:e.attrType??"RELATION_OWN",identifier:e.identifier??!1,notNull:e.notNull??!1,transient:e.transient_,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:t,dbAttrs:(e.dbAttrs??[]).map(ds)}}function wm(e,t,o){var b,g;const i=fs(e.end1.attribute),a=fs(e.end2.attribute);if(i===a)return _m(e);const l=i?e.end1:e.end2,r=i?e.end2:e.end1,s=l.attribute,c=(g=(b=s.dbAttrs)==null?void 0:b[0])==null?void 0:g.targetModelId,d=c?o.get(c):void 0,u=t.get(r.endModel.refId),f=u?u.attributes.reduce((I,y)=>Math.max(I,y.order),-1)+1:s.order??0,p={...hs(s,f),attrType:"RELATION_OWN",derivedFrom:d?{associationRef:e.modelId,sourceAttributeRef:d}:void 0};u&&u.attributes.push(p);const m=(I,y)=>({entityRef:I.endModel.refId,multiplicity:I.multiplicity,navigable:I.navigable,composition:I.composition,attributeRef:y?d:p.modelId,legacyNavRaw:y?void 0:I.attribute,jpa:us(I)}),h={modelId:e.modelId,description:e.description,end1:m(e.end1,i),end2:m(e.end2,a)},_={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:h.end1.attributeRef,targetColumnRef:h.end2.attributeRef,style:e.style};return{assoc:h,layout:_}}function vm(e,t){const o=e.targetModelId?t.get(e.targetModelId):void 0;return{modelId:e.modelId,physicalName:e.physicalName||(o==null?void 0:o.physicalName)||"",logicalName:e.logicalName??(o==null?void 0:o.logicalName),dataType:e.dataType||(o==null?void 0:o.dataType)||"",length:e.length??(o==null?void 0:o.length),scale:e.scale??(o==null?void 0:o.scale),unique:e.unique??(o==null?void 0:o.unique),autoIncrement:e.autoIncrement??(o==null?void 0:o.autoIncrement),updatable:e.updatable??(o==null?void 0:o.updatable),insertable:e.insertable??(o==null?void 0:o.insertable)}}function km(e,t,o){var h;const i=((h=e.end1.attribute)==null?void 0:h.attrType)==="EMBED_OWN",a=i?e.end1:e.end2,l=i?e.end2:e.end1,r=a.attribute,s=t.get(l.endModel.refId),c=s?s.attributes.reduce((_,b)=>Math.max(_,b.order),-1)+1:r.order??0,d={...hs(r,c),attrType:r.attrType??"EMBED_OWN",dbAttrs:(r.dbAttrs??[]).map(_=>vm(_,o)),embedded:{associationRef:e.modelId,embeddableRef:a.endModel.refId}};s&&s.attributes.push(d);const u=_=>({...$a(_),legacyEmbedRaw:_.attribute}),f={modelId:e.modelId,description:e.description,end1:u(e.end1),end2:u(e.end2)},p=!i,m={associationRef:e.modelId,waypoints:e.locations??[],sourceColumnRef:p?d.modelId:void 0,targetColumnRef:p?void 0:d.modelId,style:e.style};return{assoc:f,layout:m}}function Em(e,t){var i,a,l,r;const o=[];for(const s of t){const c=(a=(i=s.end1)==null?void 0:i.endModel)==null?void 0:a.refId,d=(r=(l=s.end2)==null?void 0:l.endModel)==null?void 0:r.refId,u=c===e?d:c;!u||u===e||o.push({targetRef:u,waypoints:s.locations??[]})}return o}function ys(e,t={x:0,y:0}){const{modelId:o,memo:i,geo:a,style:l,connections:r,ownedConnections:s,...c}=e;let d=r;if(!d&&Array.isArray(s)){const u=Em(o,s);u.length&&(d=u)}return{modelId:o,memo:i,geo:{location:{x:a.location.x+t.x,y:a.location.y+t.y},size:a.size},style:l,connections:d,legacyRaw:Object.keys(c).length?c:void 0}}function Nm(e){return(e.schemaVersion??1)>=2&&"logical"in e?$m(e):xm(e)}function $m(e){const t=e.id??e.logical.modelId??"",o={},i=f=>{const{rev:p,...m}=f;return p!=null&&(o[f.modelId]=p),m},a=e.logical.entities.map(i),l=e.logical.associations.map(i),r=e.logical.groups.map(i),{version:s,...c}=e.layout,d={logical:{modelId:e.logical.modelId??t,packageName:e.logical.packageName,entities:a,associations:l,groups:r},layout:{...c,diagramId:c.diagramId??t,logicalModelRef:c.logicalModelRef??t}},u={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion,opWriteEnabled:e.opWriteEnabled,revSeed:{revs:o,layoutVersion:s??0,logicalVersion:e.logical.version??0}};return{state:d,meta:u}}function xm(e){var g,I;const t=e.id??"",o=[],i=[],a=[],l=[],r=[],s=[],c=[],d=(y,N)=>{o.push(gm(y));const q=bm(y);q.geo={location:{x:q.geo.location.x+N.x,y:q.geo.location.y+N.y},size:q.geo.size},i.push(q);for(const U of y.ownedAssociations??[])c.push(U)},u={x:0,y:0};for(const y of e.entities??[])d(y,u);const f=[];for(const y of e.groups??[]){const N=y.entities??[];r.push({modelId:y.modelId,name:y.name,description:y.description,packageName:y.packageName,excludeDDLGeneration:y.excludeDDLGeneration??!1,memberEntityRefs:N.map(U=>U.modelId)});const q=((g=y.geo)==null?void 0:g.location)??u;if(y.geo){const U=(y.notes??[]).map(X=>X.modelId);s.push({groupRef:y.modelId,geo:y.geo,style:y.style,locked:y.locked,memberNoteRefs:U.length?U:void 0})}for(const U of N)d(U,q);for(const U of y.notes??[])f.push(ys(U,q))}const p=new Map(o.map(y=>[y.modelId,y])),m=new Map,h=new Map;for(const y of o)for(const N of y.attributes)for(const q of N.dbAttrs)m.set(q.modelId,N.modelId),h.set(q.modelId,q);for(const y of c)for(const N of[y.end1,y.end2]){const q=N.attribute;if(q&&(((I=q.dbAttrs)==null?void 0:I.length)??0)>0)for(const U of q.dbAttrs)U.modelId&&m.set(U.modelId,q.modelId)}for(const y of c){const N=ms(y.end1.attribute),q=ms(y.end2.attribute),U=ps(y.end1)||ps(y.end2),{assoc:X,layout:K}=N!==q||U?km(y,p,h):wm(y,p,m);a.push(X),l.push(K)}const _={logical:{modelId:t,packageName:e.packageName,entities:o,associations:a,groups:r},layout:{diagramId:t,logicalModelRef:t,canvasSize:e.size,entityLayouts:i,associationLayouts:l,groupLayouts:s,notes:[...(e.notes??[]).map(y=>ys(y)),...f]}},b={id:e.id,version:e.version,diagramVersion:e.diagramVersion,size:e.size,packageName:e.packageName,schemaVersion:e.schemaVersion??1};return{state:_,meta:b}}function gs(e){return{modelId:e.modelId,physicalName:e.physicalName,logicalName:e.logicalName,dataType:e.dataType,length:e.length,scale:e.scale,unique:e.unique,autoIncrement:e.autoIncrement,updatable:e.updatable,insertable:e.insertable,sharedColumnRef:e.sharedColumnRef,multiValue:e.multiValue,multiValueSeparator:e.multiValueSeparator,sequenceName:e.sequenceName}}function Im(e,t){return{modelId:e.modelId,name:e.name,type:e.type,customType:e.customType,attrType:e.attrType,identifier:e.identifier,notNull:e.notNull,transient_:e.transient,naturalId:e.naturalId,naturalIdMutable:e.naturalIdMutable,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,defaultValue:e.defaultValue,personalInfoAttributeType:e.personalInfoAttributeType,order:e.order,dbAttrs:e.dbAttrs.map(gs),style:t}}function Sm(e,t){var o;return{...e.legacyRaw,modelId:e.modelId,name:e.name,visibility:e.visibility,sourceCode:e.sourceCode,description:(o=e.description)==null?void 0:o.ko,order:e.order,personalInfoAttributeType:e.personalInfoAttributeType,style:t}}function Cm(e){return{modelId:e.modelId,name:e.name,unique:e.unique,description:e.description,parameters:e.parameters,indexColumns:e.columns.map(t=>({targetColumn:{refId:t.columnRef},descending:t.descending}))}}function Ut(e,t){return{endModel:{refId:e.entityRef},multiplicity:e.multiplicity,navigable:e.navigable,composition:e.composition,jpaAttribute:e.jpa,attribute:t??(e.attributeRef?{modelId:e.attributeRef}:void 0)}}function Rm(e,t){const o=t==null?void 0:t.attributes.find(i=>{var a;return i.modelId===((a=e.derivedFrom)==null?void 0:a.sourceAttributeRef)});return{modelId:e.modelId,name:e.name,type:e.type,attrType:"RELATION_REF",identifier:e.identifier,notNull:e.notNull,transient_:e.transient,description:e.description,attributeGroup:e.attributeGroup,groupCode:e.groupCode,order:e.order,dbAttrs:e.dbAttrs.map((i,a)=>{var l;return{...gs(i),targetModelId:(l=o==null?void 0:o.dbAttrs[a])==null?void 0:l.modelId}})}}function Vm(e){const t=new Set;for(const o of e.logical.associations){const i=o.end1.legacyNavRaw?o.end1:o.end2.legacyNavRaw?o.end2:void 0;i!=null&&i.attributeRef&&t.add(i.attributeRef)}return t}function Am(e){const t=new Set;for(const o of e.logical.entities)for(const i of o.attributes)i.embedded&&t.add(i.modelId);return t}function Tm(e,t){return e===t||JSON.stringify(e??null)===JSON.stringify(t??null)}function Mm(e,t){const o=(i,a)=>i===a?void 0:i;return{modelId:e.modelId,targetModelId:t==null?void 0:t.modelId,physicalName:e.physicalName===((t==null?void 0:t.physicalName)??"")?"":e.physicalName,logicalName:Tm(e.logicalName,t==null?void 0:t.logicalName)?void 0:e.logicalName,dataType:e.dataType===((t==null?void 0:t.dataType)??"")?"":e.dataType,length:o(e.length,t==null?void 0:t.length),scale:o(e.scale,t==null?void 0:t.scale),unique:o(e.unique,t==null?void 0:t.unique),autoIncrement:o(e.autoIncrement,t==null?void 0:t.autoIncrement),updatable:o(e.updatable,t==null?void 0:t.updatable),insertable:o(e.insertable,t==null?void 0:t.insertable)}}function Bm(e,t,o){let i;for(const f of t.logical.entities){const p=f.attributes.find(m=>{var h;return((h=m.embedded)==null?void 0:h.associationRef)===e.modelId});if(p){i=p;break}}if(!i)return;const a=i.embedded.embeddableRef,l=t.logical.entities.find(f=>f.modelId===a);if(!l)return;const r=l.attributes.flatMap(f=>f.dbAttrs),s={modelId:i.modelId,name:i.name,type:i.type,attrType:i.attrType,identifier:i.identifier,notNull:i.notNull,transient_:i.transient,description:i.description,attributeGroup:i.attributeGroup,groupCode:i.groupCode,order:i.order,dbAttrs:i.dbAttrs.map((f,p)=>Mm(f,r[p]))},c=e.end1.entityRef===a,d=c?e.end2:e.end1,u=d.attributeRef?{modelId:d.attributeRef,attrType:"EMBED_REF",dbAttrs:[]}:void 0;return{...o,end1:Ut(e.end1,c?s:u),end2:Ut(e.end2,c?u:s)}}function Dm(e,t,o){const i={modelId:e.modelId,description:e.description,locations:(o==null?void 0:o.waypoints)??[],style:o==null?void 0:o.style};if(e.end1.legacyEmbedRaw||e.end2.legacyEmbedRaw)return{...i,end1:Ut(e.end1,e.end1.legacyEmbedRaw),end2:Ut(e.end2,e.end2.legacyEmbedRaw)};const a=Bm(e,t,i);if(a)return a;const l=!!e.end1.legacyNavRaw,r=!!e.end2.legacyNavRaw;if(l!==r){const s=l?e.end1:e.end2,c=l?e.end2:e.end1,d=t.logical.entities.find(h=>h.modelId===s.entityRef),u=d==null?void 0:d.attributes.find(h=>h.modelId===s.attributeRef),f=t.logical.entities.find(h=>h.modelId===c.entityRef),p=u?Rm(u,f):void 0,m=s.legacyNavRaw;return{...i,end1:Ut(e.end1,l?m:p),end2:Ut(e.end2,r?m:p)}}return{...i,end1:Ut(e.end1),end2:Ut(e.end2)}}function bs(e,t,o,i,a={x:0,y:0}){var u,f;const l=t.layout.entityLayouts.find(p=>p.entityRef===e.modelId),r=t.logical.associations.filter(p=>p.end1.entityRef===e.modelId),s=p=>t.layout.associationLayouts.find(m=>m.associationRef===p),c=(l==null?void 0:l.geo)??{...cs},d={location:{x:c.location.x-a.x,y:c.location.y-a.y},size:c.size};return{modelId:e.modelId,name:e.name,stereotype:e.stereotype,packageName:e.packageName,superClass:e.superClass,schema:e.schema,description:e.description,abstractClass:e.abstractClass,hasPersonalInfo:e.hasPersonalInfo,declarationOfInterfaces:e.declarationOfInterfaces,attributes:e.attributes.filter(p=>!o.has(p.modelId)&&!i.has(p.modelId)).map(p=>{var m;return Im(p,(m=l==null?void 0:l.attributeStyles)==null?void 0:m[p.modelId])}),operations:(u=e.operations)==null?void 0:u.map(p=>{var m;return Sm(p,(m=l==null?void 0:l.operationStyles)==null?void 0:m[p.modelId])}),ownedAssociations:r.map(p=>Dm(p,t,s(p.modelId))),indexes:(f=e.indexes)==null?void 0:f.map(Cm),jpaAttrs:e.jpaAttrs,dbAttrs:e.table?{physicalName:e.table.physicalName,logicalName:e.table.logicalName}:void 0,geo:d,style:l==null?void 0:l.style,collapsed:l==null?void 0:l.collapsed,locked:l==null?void 0:l.locked}}function Om(e,t,o,i){const a=t.layout.groupLayouts.find(c=>c.groupRef===e.modelId),l=e.memberEntityRefs.map(c=>t.logical.entities.find(d=>d.modelId===c)).filter(c=>!!c),r=(a==null?void 0:a.geo.location)??{x:0,y:0},s=((a==null?void 0:a.memberNoteRefs)??[]).map(c=>t.layout.notes.find(d=>d.modelId===c)).filter(c=>!!c).map(c=>_s(c,r));return{modelId:e.modelId,name:e.name,description:e.description,packageName:e.packageName,excludeDDLGeneration:e.excludeDDLGeneration,entities:l.map(c=>bs(c,t,o,i,r)),notes:s.length?s:void 0,geo:a==null?void 0:a.geo,style:a==null?void 0:a.style,locked:a==null?void 0:a.locked}}function _s(e,t={x:0,y:0}){return{...e.legacyRaw,modelId:e.modelId,memo:e.memo,geo:{location:{x:e.geo.location.x-t.x,y:e.geo.location.y-t.y},size:e.geo.size},style:e.style,connections:e.connections}}function Lm(e,t={}){const o=new Set(e.logical.groups.flatMap(s=>s.memberEntityRefs)),i=e.logical.entities.filter(s=>!o.has(s.modelId)),a=Vm(e),l=Am(e),r=new Set(e.layout.groupLayouts.flatMap(s=>s.memberNoteRefs??[]));return{id:t.id,diagramVersion:t.diagramVersion,version:t.version,size:t.size??e.layout.canvasSize,packageName:t.packageName??e.logical.packageName,entities:i.map(s=>bs(s,e,a,l)),groups:e.logical.groups.map(s=>Om(s,e,a,l)),notes:e.layout.notes.filter(s=>!r.has(s.modelId)).map(s=>_s(s))}}function Pm(e,t={}){var a,l,r;const o=((a=t.revSeed)==null?void 0:a.revs)??{},i=s=>({...s,rev:o[s.modelId]??0});return{id:t.id,schemaVersion:2,opWriteEnabled:t.opWriteEnabled,version:t.version,diagramVersion:t.diagramVersion,packageName:t.packageName,size:t.size,logical:{version:((l=t.revSeed)==null?void 0:l.logicalVersion)??0,modelId:e.logical.modelId,packageName:e.logical.packageName,entities:e.logical.entities.map(i),associations:e.logical.associations.map(i),groups:e.logical.groups.map(i)},layout:{...e.layout,version:((r=t.revSeed)==null?void 0:r.layoutVersion)??0}}}function Qn(e){return n.getCurrentScope()?(n.onScopeDispose(e),!0):!1}function Ct(e){return typeof e=="function"?e():n.unref(e)}const zm=typeof window<"u"&&typeof document<"u",Um=e=>typeof e<"u",Hm=Object.prototype.toString,Fm=e=>Hm.call(e)==="[object Object]",Gm=()=>{};function Ym(e,t){function o(...i){return new Promise((a,l)=>{Promise.resolve(e(()=>t.apply(this,i),{fn:t,thisArg:this,args:i})).then(a).catch(l)})}return o}const ws=e=>e();function Wm(e=ws){const t=n.ref(!0);function o(){t.value=!1}function i(){t.value=!0}const a=(...l)=>{t.value&&e(...l)};return{isActive:n.readonly(t),pause:o,resume:i,eventFilter:a}}function vs(e,t=!1,o="Timeout"){return new Promise((i,a)=>{setTimeout(t?()=>a(o):i,e)})}function Km(e,t,o={}){const{eventFilter:i=ws,...a}=o;return n.watch(e,Ym(i,t),a)}function xn(e,t,o={}){const{eventFilter:i,...a}=o,{eventFilter:l,pause:r,resume:s,isActive:c}=Wm(i);return{stop:Km(e,t,{...a,eventFilter:l}),pause:r,resume:s,isActive:c}}function qm(e,t={}){if(!n.isRef(e))return n.toRefs(e);const o=Array.isArray(e.value)?Array.from({length:e.value.length}):{};for(const i in e.value)o[i]=n.customRef(()=>({get(){return e.value[i]},set(a){var l;if((l=Ct(t.replaceRef))!=null?l:!0)if(Array.isArray(e.value)){const s=[...e.value];s[i]=a,e.value=s}else{const s={...e.value,[i]:a};Object.setPrototypeOf(s,Object.getPrototypeOf(e.value)),e.value=s}else e.value[i]=a}}));return o}function xa(e,t=!1){function o(f,{flush:p="sync",deep:m=!1,timeout:h,throwOnTimeout:_}={}){let b=null;const I=[new Promise(y=>{b=n.watch(e,N=>{f(N)!==t&&(b==null||b(),y(N))},{flush:p,deep:m,immediate:!0})})];return h!=null&&I.push(vs(h,_).then(()=>Ct(e)).finally(()=>b==null?void 0:b())),Promise.race(I)}function i(f,p){if(!n.isRef(f))return o(N=>N===f,p);const{flush:m="sync",deep:h=!1,timeout:_,throwOnTimeout:b}=p??{};let g=null;const y=[new Promise(N=>{g=n.watch([e,f],([q,U])=>{t!==(q===U)&&(g==null||g(),N(q))},{flush:m,deep:h,immediate:!0})})];return _!=null&&y.push(vs(_,b).then(()=>Ct(e)).finally(()=>(g==null||g(),Ct(e)))),Promise.race(y)}function a(f){return o(p=>!!p,f)}function l(f){return i(null,f)}function r(f){return i(void 0,f)}function s(f){return o(Number.isNaN,f)}function c(f,p){return o(m=>{const h=Array.from(m);return h.includes(f)||h.includes(Ct(f))},p)}function d(f){return u(1,f)}function u(f=1,p){let m=-1;return o(()=>(m+=1,m>=f),p)}return Array.isArray(Ct(e))?{toMatch:o,toContains:c,changed:d,changedTimes:u,get not(){return xa(e,!t)}}:{toMatch:o,toBe:i,toBeTruthy:a,toBeNull:l,toBeNaN:s,toBeUndefined:r,changed:d,changedTimes:u,get not(){return xa(e,!t)}}}function Ia(e){return xa(e)}function Xm(e){var t;const o=Ct(e);return(t=o==null?void 0:o.$el)!=null?t:o}const ks=zm?window:void 0;function Es(...e){let t,o,i,a;if(typeof e[0]=="string"||Array.isArray(e[0])?([o,i,a]=e,t=ks):[t,o,i,a]=e,!t)return Gm;Array.isArray(o)||(o=[o]),Array.isArray(i)||(i=[i]);const l=[],r=()=>{l.forEach(u=>u()),l.length=0},s=(u,f,p,m)=>(u.addEventListener(f,p,m),()=>u.removeEventListener(f,p,m)),c=n.watch(()=>[Xm(t),Ct(a)],([u,f])=>{if(r(),!u)return;const p=Fm(f)?{...f}:f;l.push(...o.flatMap(m=>i.map(h=>s(u,m,h,p))))},{immediate:!0,flush:"post"}),d=()=>{c(),r()};return Qn(d),d}function jm(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}function Ns(...e){let t,o,i={};e.length===3?(t=e[0],o=e[1],i=e[2]):e.length===2?typeof e[1]=="object"?(t=!0,o=e[0],i=e[1]):(t=e[0],o=e[1]):(t=!0,o=e[0]);const{target:a=ks,eventName:l="keydown",passive:r=!1,dedupe:s=!1}=i,c=jm(t);return Es(a,l,u=>{u.repeat&&Ct(s)||c(u)&&o(u)},r)}function Zm(e){return JSON.parse(JSON.stringify(e))}function Sa(e,t,o,i={}){var a,l,r;const{clone:s=!1,passive:c=!1,eventName:d,deep:u=!1,defaultValue:f,shouldEmit:p}=i,m=n.getCurrentInstance(),h=o||(m==null?void 0:m.emit)||((a=m==null?void 0:m.$emit)==null?void 0:a.bind(m))||((r=(l=m==null?void 0:m.proxy)==null?void 0:l.$emit)==null?void 0:r.bind(m==null?void 0:m.proxy));let _=d;t||(t="modelValue"),_=_||`update:${t.toString()}`;const b=y=>s?typeof s=="function"?s(y):Zm(y):y,g=()=>Um(e[t])?b(e[t]):f,I=y=>{p?p(y)&&h(_,y):h(_,y)};if(c){const y=g(),N=n.ref(y);let q=!1;return n.watch(()=>e[t],U=>{q||(q=!0,N.value=b(U),n.nextTick(()=>q=!1))}),n.watch(N,U=>{!q&&(U!==e[t]||u)&&I(U)},{deep:u}),N}else return n.computed({get(){return g()},set(y){I(y)}})}var Jm={value:()=>{}};function Jo(){for(var e=0,t=arguments.length,o={},i;e<t;++e){if(!(i=arguments[e]+"")||i in o||/[\s.]/.test(i))throw new Error("illegal type: "+i);o[i]=[]}return new Qo(o)}function Qo(e){this._=e}function Qm(e,t){return e.trim().split(/^|\s+/).map(function(o){var i="",a=o.indexOf(".");if(a>=0&&(i=o.slice(a+1),o=o.slice(0,a)),o&&!t.hasOwnProperty(o))throw new Error("unknown type: "+o);return{type:o,name:i}})}Qo.prototype=Jo.prototype={constructor:Qo,on:function(e,t){var o=this._,i=Qm(e+"",o),a,l=-1,r=i.length;if(arguments.length<2){for(;++l<r;)if((a=(e=i[l]).type)&&(a=ep(o[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++l<r;)if(a=(e=i[l]).type)o[a]=$s(o[a],e.name,t);else if(t==null)for(a in o)o[a]=$s(o[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var o in t)e[o]=t[o].slice();return new Qo(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var o=new Array(a),i=0,a,l;i<a;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],i=0,a=l.length;i<a;++i)l[i].value.apply(t,o)},apply:function(e,t,o){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],a=0,l=i.length;a<l;++a)i[a].value.apply(t,o)}};function ep(e,t){for(var o=0,i=e.length,a;o<i;++o)if((a=e[o]).name===t)return a.value}function $s(e,t,o){for(var i=0,a=e.length;i<a;++i)if(e[i].name===t){e[i]=Jm,e=e.slice(0,i).concat(e.slice(i+1));break}return o!=null&&e.push({name:t,value:o}),e}var Ca="http://www.w3.org/1999/xhtml";const xs={svg:"http://www.w3.org/2000/svg",xhtml:Ca,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function ei(e){var t=e+="",o=t.indexOf(":");return o>=0&&(t=e.slice(0,o))!=="xmlns"&&(e=e.slice(o+1)),xs.hasOwnProperty(t)?{space:xs[t],local:e}:e}function tp(e){return function(){var t=this.ownerDocument,o=this.namespaceURI;return o===Ca&&t.documentElement.namespaceURI===Ca?t.createElement(e):t.createElementNS(o,e)}}function np(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Is(e){var t=ei(e);return(t.local?np:tp)(t)}function op(){}function Ra(e){return e==null?op:function(){return this.querySelector(e)}}function ip(e){typeof e!="function"&&(e=Ra(e));for(var t=this._groups,o=t.length,i=new Array(o),a=0;a<o;++a)for(var l=t[a],r=l.length,s=i[a]=new Array(r),c,d,u=0;u<r;++u)(c=l[u])&&(d=e.call(c,c.__data__,u,l))&&("__data__"in c&&(d.__data__=c.__data__),s[u]=d);return new st(i,this._parents)}function ap(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function lp(){return[]}function Ss(e){return e==null?lp:function(){return this.querySelectorAll(e)}}function rp(e){return function(){return ap(e.apply(this,arguments))}}function sp(e){typeof e=="function"?e=rp(e):e=Ss(e);for(var t=this._groups,o=t.length,i=[],a=[],l=0;l<o;++l)for(var r=t[l],s=r.length,c,d=0;d<s;++d)(c=r[d])&&(i.push(e.call(c,c.__data__,d,r)),a.push(c));return new st(i,a)}function Cs(e){return function(){return this.matches(e)}}function Rs(e){return function(t){return t.matches(e)}}var cp=Array.prototype.find;function dp(e){return function(){return cp.call(this.children,e)}}function up(){return this.firstElementChild}function fp(e){return this.select(e==null?up:dp(typeof e=="function"?e:Rs(e)))}var mp=Array.prototype.filter;function pp(){return Array.from(this.children)}function hp(e){return function(){return mp.call(this.children,e)}}function yp(e){return this.selectAll(e==null?pp:hp(typeof e=="function"?e:Rs(e)))}function gp(e){typeof e!="function"&&(e=Cs(e));for(var t=this._groups,o=t.length,i=new Array(o),a=0;a<o;++a)for(var l=t[a],r=l.length,s=i[a]=[],c,d=0;d<r;++d)(c=l[d])&&e.call(c,c.__data__,d,l)&&s.push(c);return new st(i,this._parents)}function Vs(e){return new Array(e.length)}function bp(){return new st(this._enter||this._groups.map(Vs),this._parents)}function ti(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ti.prototype={constructor:ti,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function _p(e){return function(){return e}}function wp(e,t,o,i,a,l){for(var r=0,s,c=t.length,d=l.length;r<d;++r)(s=t[r])?(s.__data__=l[r],i[r]=s):o[r]=new ti(e,l[r]);for(;r<c;++r)(s=t[r])&&(a[r]=s)}function vp(e,t,o,i,a,l,r){var s,c,d=new Map,u=t.length,f=l.length,p=new Array(u),m;for(s=0;s<u;++s)(c=t[s])&&(p[s]=m=r.call(c,c.__data__,s,t)+"",d.has(m)?a[s]=c:d.set(m,c));for(s=0;s<f;++s)m=r.call(e,l[s],s,l)+"",(c=d.get(m))?(i[s]=c,c.__data__=l[s],d.delete(m)):o[s]=new ti(e,l[s]);for(s=0;s<u;++s)(c=t[s])&&d.get(p[s])===c&&(a[s]=c)}function kp(e){return e.__data__}function Ep(e,t){if(!arguments.length)return Array.from(this,kp);var o=t?vp:wp,i=this._parents,a=this._groups;typeof e!="function"&&(e=_p(e));for(var l=a.length,r=new Array(l),s=new Array(l),c=new Array(l),d=0;d<l;++d){var u=i[d],f=a[d],p=f.length,m=Np(e.call(u,u&&u.__data__,d,i)),h=m.length,_=s[d]=new Array(h),b=r[d]=new Array(h),g=c[d]=new Array(p);o(u,f,_,b,g,m,t);for(var I=0,y=0,N,q;I<h;++I)if(N=_[I]){for(I>=y&&(y=I+1);!(q=b[y])&&++y<h;);N._next=q||null}}return r=new st(r,i),r._enter=s,r._exit=c,r}function Np(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function $p(){return new st(this._exit||this._groups.map(Vs),this._parents)}function xp(e,t,o){var i=this.enter(),a=this,l=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),o==null?l.remove():o(l),i&&a?i.merge(a).order():a}function Ip(e){for(var t=e.selection?e.selection():e,o=this._groups,i=t._groups,a=o.length,l=i.length,r=Math.min(a,l),s=new Array(a),c=0;c<r;++c)for(var d=o[c],u=i[c],f=d.length,p=s[c]=new Array(f),m,h=0;h<f;++h)(m=d[h]||u[h])&&(p[h]=m);for(;c<a;++c)s[c]=o[c];return new st(s,this._parents)}function Sp(){for(var e=this._groups,t=-1,o=e.length;++t<o;)for(var i=e[t],a=i.length-1,l=i[a],r;--a>=0;)(r=i[a])&&(l&&r.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(r,l),l=r);return this}function Cp(e){e||(e=Rp);function t(f,p){return f&&p?e(f.__data__,p.__data__):!f-!p}for(var o=this._groups,i=o.length,a=new Array(i),l=0;l<i;++l){for(var r=o[l],s=r.length,c=a[l]=new Array(s),d,u=0;u<s;++u)(d=r[u])&&(c[u]=d);c.sort(t)}return new st(a,this._parents).order()}function Rp(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Vp(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ap(){return Array.from(this)}function Tp(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var i=e[t],a=0,l=i.length;a<l;++a){var r=i[a];if(r)return r}return null}function Mp(){let e=0;for(const t of this)++e;return e}function Bp(){return!this.node()}function Dp(e){for(var t=this._groups,o=0,i=t.length;o<i;++o)for(var a=t[o],l=0,r=a.length,s;l<r;++l)(s=a[l])&&e.call(s,s.__data__,l,a);return this}function Op(e){return function(){this.removeAttribute(e)}}function Lp(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Pp(e,t){return function(){this.setAttribute(e,t)}}function zp(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Up(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttribute(e):this.setAttribute(e,o)}}function Hp(e,t){return function(){var o=t.apply(this,arguments);o==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,o)}}function Fp(e,t){var o=ei(e);if(arguments.length<2){var i=this.node();return o.local?i.getAttributeNS(o.space,o.local):i.getAttribute(o)}return this.each((t==null?o.local?Lp:Op:typeof t=="function"?o.local?Hp:Up:o.local?zp:Pp)(o,t))}function As(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Gp(e){return function(){this.style.removeProperty(e)}}function Yp(e,t,o){return function(){this.style.setProperty(e,t,o)}}function Wp(e,t,o){return function(){var i=t.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,o)}}function Kp(e,t,o){return arguments.length>1?this.each((t==null?Gp:typeof t=="function"?Wp:Yp)(e,t,o??"")):In(this.node(),e)}function In(e,t){return e.style.getPropertyValue(t)||As(e).getComputedStyle(e,null).getPropertyValue(t)}function qp(e){return function(){delete this[e]}}function Xp(e,t){return function(){this[e]=t}}function jp(e,t){return function(){var o=t.apply(this,arguments);o==null?delete this[e]:this[e]=o}}function Zp(e,t){return arguments.length>1?this.each((t==null?qp:typeof t=="function"?jp:Xp)(e,t)):this.node()[e]}function Ts(e){return e.trim().split(/^|\s+/)}function Va(e){return e.classList||new Ms(e)}function Ms(e){this._node=e,this._names=Ts(e.getAttribute("class")||"")}Ms.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Bs(e,t){for(var o=Va(e),i=-1,a=t.length;++i<a;)o.add(t[i])}function Ds(e,t){for(var o=Va(e),i=-1,a=t.length;++i<a;)o.remove(t[i])}function Jp(e){return function(){Bs(this,e)}}function Qp(e){return function(){Ds(this,e)}}function eh(e,t){return function(){(t.apply(this,arguments)?Bs:Ds)(this,e)}}function th(e,t){var o=Ts(e+"");if(arguments.length<2){for(var i=Va(this.node()),a=-1,l=o.length;++a<l;)if(!i.contains(o[a]))return!1;return!0}return this.each((typeof t=="function"?eh:t?Jp:Qp)(o,t))}function nh(){this.textContent=""}function oh(e){return function(){this.textContent=e}}function ih(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ah(e){return arguments.length?this.each(e==null?nh:(typeof e=="function"?ih:oh)(e)):this.node().textContent}function lh(){this.innerHTML=""}function rh(e){return function(){this.innerHTML=e}}function sh(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function ch(e){return arguments.length?this.each(e==null?lh:(typeof e=="function"?sh:rh)(e)):this.node().innerHTML}function dh(){this.nextSibling&&this.parentNode.appendChild(this)}function uh(){return this.each(dh)}function fh(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function mh(){return this.each(fh)}function ph(e){var t=typeof e=="function"?e:Is(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function hh(){return null}function yh(e,t){var o=typeof e=="function"?e:Is(e),i=t==null?hh:typeof t=="function"?t:Ra(t);return this.select(function(){return this.insertBefore(o.apply(this,arguments),i.apply(this,arguments)||null)})}function gh(){var e=this.parentNode;e&&e.removeChild(this)}function bh(){return this.each(gh)}function _h(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function wh(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function vh(e){return this.select(e?wh:_h)}function kh(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Eh(e){return function(t){e.call(this,t,this.__data__)}}function Nh(e){return e.trim().split(/^|\s+/).map(function(t){var o="",i=t.indexOf(".");return i>=0&&(o=t.slice(i+1),t=t.slice(0,i)),{type:t,name:o}})}function $h(e){return function(){var t=this.__on;if(t){for(var o=0,i=-1,a=t.length,l;o<a;++o)l=t[o],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):t[++i]=l;++i?t.length=i:delete this.__on}}}function xh(e,t,o){return function(){var i=this.__on,a,l=Eh(t);if(i){for(var r=0,s=i.length;r<s;++r)if((a=i[r]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=l,a.options=o),a.value=t;return}}this.addEventListener(e.type,l,o),a={type:e.type,name:e.name,value:t,listener:l,options:o},i?i.push(a):this.__on=[a]}}function Ih(e,t,o){var i=Nh(e+""),a,l=i.length,r;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,d=s.length,u;c<d;++c)for(a=0,u=s[c];a<l;++a)if((r=i[a]).type===u.type&&r.name===u.name)return u.value}return}for(s=t?xh:$h,a=0;a<l;++a)this.each(s(i[a],t,o));return this}function Os(e,t,o){var i=As(e),a=i.CustomEvent;typeof a=="function"?a=new a(t,o):(a=i.document.createEvent("Event"),o?(a.initEvent(t,o.bubbles,o.cancelable),a.detail=o.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function Sh(e,t){return function(){return Os(this,e,t)}}function Ch(e,t){return function(){return Os(this,e,t.apply(this,arguments))}}function Rh(e,t){return this.each((typeof t=="function"?Ch:Sh)(e,t))}function*Vh(){for(var e=this._groups,t=0,o=e.length;t<o;++t)for(var i=e[t],a=0,l=i.length,r;a<l;++a)(r=i[a])&&(yield r)}var Ls=[null];function st(e,t){this._groups=e,this._parents=t}function eo(){return new st([[document.documentElement]],Ls)}function Ah(){return this}st.prototype=eo.prototype={constructor:st,select:ip,selectAll:sp,selectChild:fp,selectChildren:yp,filter:gp,data:Ep,enter:bp,exit:$p,join:xp,merge:Ip,selection:Ah,order:Sp,sort:Cp,call:Vp,nodes:Ap,node:Tp,size:Mp,empty:Bp,each:Dp,attr:Fp,style:Kp,property:Zp,classed:th,text:ah,html:ch,raise:uh,lower:mh,append:ph,insert:yh,remove:bh,clone:vh,datum:kh,on:Ih,dispatch:Rh,[Symbol.iterator]:Vh};function ft(e){return typeof e=="string"?new st([[document.querySelector(e)]],[document.documentElement]):new st([[e]],Ls)}function Th(e){let t;for(;t=e.sourceEvent;)e=t;return e}function _t(e,t){if(e=Th(e),t===void 0&&(t=e.currentTarget),t){var o=t.ownerSVGElement||t;if(o.createSVGPoint){var i=o.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(t.getScreenCTM().inverse()),[i.x,i.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const Mh={passive:!1},to={capture:!0,passive:!1};function Aa(e){e.stopImmediatePropagation()}function Sn(e){e.preventDefault(),e.stopImmediatePropagation()}function Ps(e){var t=e.document.documentElement,o=ft(e).on("dragstart.drag",Sn,to);"onselectstart"in t?o.on("selectstart.drag",Sn,to):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function zs(e,t){var o=e.document.documentElement,i=ft(e).on("dragstart.drag",null);t&&(i.on("click.drag",Sn,to),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in o?i.on("selectstart.drag",null):(o.style.MozUserSelect=o.__noselect,delete o.__noselect)}const ni=e=>()=>e;function Ta(e,{sourceEvent:t,subject:o,target:i,identifier:a,active:l,x:r,y:s,dx:c,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:o,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:a,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:r,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}Ta.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Bh(e){return!e.ctrlKey&&!e.button}function Dh(){return this.parentNode}function Oh(e,t){return t??{x:e.x,y:e.y}}function Lh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ph(){var e=Bh,t=Dh,o=Oh,i=Lh,a={},l=Jo("start","drag","end"),r=0,s,c,d,u,f=0;function p(N){N.on("mousedown.drag",m).filter(i).on("touchstart.drag",b).on("touchmove.drag",g,Mh).on("touchend.drag touchcancel.drag",I).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(N,q){if(!(u||!e.call(this,N,q))){var U=y(this,t.call(this,N,q),N,q,"mouse");U&&(ft(N.view).on("mousemove.drag",h,to).on("mouseup.drag",_,to),Ps(N.view),Aa(N),d=!1,s=N.clientX,c=N.clientY,U("start",N))}}function h(N){if(Sn(N),!d){var q=N.clientX-s,U=N.clientY-c;d=q*q+U*U>f}a.mouse("drag",N)}function _(N){ft(N.view).on("mousemove.drag mouseup.drag",null),zs(N.view,d),Sn(N),a.mouse("end",N)}function b(N,q){if(e.call(this,N,q)){var U=N.changedTouches,X=t.call(this,N,q),K=U.length,W,ne;for(W=0;W<K;++W)(ne=y(this,X,N,q,U[W].identifier,U[W]))&&(Aa(N),ne("start",N,U[W]))}}function g(N){var q=N.changedTouches,U=q.length,X,K;for(X=0;X<U;++X)(K=a[q[X].identifier])&&(Sn(N),K("drag",N,q[X]))}function I(N){var q=N.changedTouches,U=q.length,X,K;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),X=0;X<U;++X)(K=a[q[X].identifier])&&(Aa(N),K("end",N,q[X]))}function y(N,q,U,X,K,W){var ne=l.copy(),re=_t(W||U,q),L,Q,v;if((v=o.call(N,new Ta("beforestart",{sourceEvent:U,target:p,identifier:K,active:r,x:re[0],y:re[1],dx:0,dy:0,dispatch:ne}),X))!=null)return L=v.x-re[0]||0,Q=v.y-re[1]||0,function T($,P,H){var te=re,M;switch($){case"start":a[K]=T,M=r++;break;case"end":delete a[K],--r;case"drag":re=_t(H||P,q),M=r;break}ne.call($,N,new Ta($,{sourceEvent:P,subject:v,target:p,identifier:K,active:M,x:re[0]+L,y:re[1]+Q,dx:re[0]-te[0],dy:re[1]-te[1],dispatch:ne}),X)}}return p.filter=function(N){return arguments.length?(e=typeof N=="function"?N:ni(!!N),p):e},p.container=function(N){return arguments.length?(t=typeof N=="function"?N:ni(N),p):t},p.subject=function(N){return arguments.length?(o=typeof N=="function"?N:ni(N),p):o},p.touchable=function(N){return arguments.length?(i=typeof N=="function"?N:ni(!!N),p):i},p.on=function(){var N=l.on.apply(l,arguments);return N===l?p:N},p.clickDistance=function(N){return arguments.length?(f=(N=+N)*N,p):Math.sqrt(f)},p}function Ma(e,t,o){e.prototype=t.prototype=o,o.constructor=e}function Us(e,t){var o=Object.create(e.prototype);for(var i in t)o[i]=t[i];return o}function no(){}var oo=.7,oi=1/oo,Cn="\\s*([+-]?\\d+)\\s*",io="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",zh=/^#([0-9a-f]{3,8})$/,Uh=new RegExp(`^rgb\\(${Cn},${Cn},${Cn}\\)$`),Hh=new RegExp(`^rgb\\(${wt},${wt},${wt}\\)$`),Fh=new RegExp(`^rgba\\(${Cn},${Cn},${Cn},${io}\\)$`),Gh=new RegExp(`^rgba\\(${wt},${wt},${wt},${io}\\)$`),Yh=new RegExp(`^hsl\\(${io},${wt},${wt}\\)$`),Wh=new RegExp(`^hsla\\(${io},${wt},${wt},${io}\\)$`),Hs={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ma(no,tn,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Fs,formatHex:Fs,formatHex8:Kh,formatHsl:qh,formatRgb:Gs,toString:Gs});function Fs(){return this.rgb().formatHex()}function Kh(){return this.rgb().formatHex8()}function qh(){return Xs(this).formatHsl()}function Gs(){return this.rgb().formatRgb()}function tn(e){var t,o;return e=(e+"").trim().toLowerCase(),(t=zh.exec(e))?(o=t[1].length,t=parseInt(t[1],16),o===6?Ys(t):o===3?new at(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):o===8?ii(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):o===4?ii(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Uh.exec(e))?new at(t[1],t[2],t[3],1):(t=Hh.exec(e))?new at(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Fh.exec(e))?ii(t[1],t[2],t[3],t[4]):(t=Gh.exec(e))?ii(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Yh.exec(e))?qs(t[1],t[2]/100,t[3]/100,1):(t=Wh.exec(e))?qs(t[1],t[2]/100,t[3]/100,t[4]):Hs.hasOwnProperty(e)?Ys(Hs[e]):e==="transparent"?new at(NaN,NaN,NaN,0):null}function Ys(e){return new at(e>>16&255,e>>8&255,e&255,1)}function ii(e,t,o,i){return i<=0&&(e=t=o=NaN),new at(e,t,o,i)}function Xh(e){return e instanceof no||(e=tn(e)),e?(e=e.rgb(),new at(e.r,e.g,e.b,e.opacity)):new at}function Ba(e,t,o,i){return arguments.length===1?Xh(e):new at(e,t,o,i??1)}function at(e,t,o,i){this.r=+e,this.g=+t,this.b=+o,this.opacity=+i}Ma(at,Ba,Us(no,{brighter(e){return e=e==null?oi:Math.pow(oi,e),new at(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new at(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new at(nn(this.r),nn(this.g),nn(this.b),ai(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ws,formatHex:Ws,formatHex8:jh,formatRgb:Ks,toString:Ks}));function Ws(){return`#${on(this.r)}${on(this.g)}${on(this.b)}`}function jh(){return`#${on(this.r)}${on(this.g)}${on(this.b)}${on((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ks(){const e=ai(this.opacity);return`${e===1?"rgb(":"rgba("}${nn(this.r)}, ${nn(this.g)}, ${nn(this.b)}${e===1?")":`, ${e})`}`}function ai(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function nn(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function on(e){return e=nn(e),(e<16?"0":"")+e.toString(16)}function qs(e,t,o,i){return i<=0?e=t=o=NaN:o<=0||o>=1?e=t=NaN:t<=0&&(e=NaN),new mt(e,t,o,i)}function Xs(e){if(e instanceof mt)return new mt(e.h,e.s,e.l,e.opacity);if(e instanceof no||(e=tn(e)),!e)return new mt;if(e instanceof mt)return e;e=e.rgb();var t=e.r/255,o=e.g/255,i=e.b/255,a=Math.min(t,o,i),l=Math.max(t,o,i),r=NaN,s=l-a,c=(l+a)/2;return s?(t===l?r=(o-i)/s+(o<i)*6:o===l?r=(i-t)/s+2:r=(t-o)/s+4,s/=c<.5?l+a:2-l-a,r*=60):s=c>0&&c<1?0:r,new mt(r,s,c,e.opacity)}function Zh(e,t,o,i){return arguments.length===1?Xs(e):new mt(e,t,o,i??1)}function mt(e,t,o,i){this.h=+e,this.s=+t,this.l=+o,this.opacity=+i}Ma(mt,Zh,Us(no,{brighter(e){return e=e==null?oi:Math.pow(oi,e),new mt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?oo:Math.pow(oo,e),new mt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,o=this.l,i=o+(o<.5?o:1-o)*t,a=2*o-i;return new at(Da(e>=240?e-240:e+120,a,i),Da(e,a,i),Da(e<120?e+240:e-120,a,i),this.opacity)},clamp(){return new mt(js(this.h),li(this.s),li(this.l),ai(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ai(this.opacity);return`${e===1?"hsl(":"hsla("}${js(this.h)}, ${li(this.s)*100}%, ${li(this.l)*100}%${e===1?")":`, ${e})`}`}}));function js(e){return e=(e||0)%360,e<0?e+360:e}function li(e){return Math.max(0,Math.min(1,e||0))}function Da(e,t,o){return(e<60?t+(o-t)*e/60:e<180?o:e<240?t+(o-t)*(240-e)/60:t)*255}const Oa=e=>()=>e;function Jh(e,t){return function(o){return e+o*t}}function Qh(e,t,o){return e=Math.pow(e,o),t=Math.pow(t,o)-e,o=1/o,function(i){return Math.pow(e+i*t,o)}}function ey(e){return(e=+e)==1?Zs:function(t,o){return o-t?Qh(t,o,e):Oa(isNaN(t)?o:t)}}function Zs(e,t){var o=t-e;return o?Jh(e,o):Oa(isNaN(e)?t:e)}const ri=(function e(t){var o=ey(t);function i(a,l){var r=o((a=Ba(a)).r,(l=Ba(l)).r),s=o(a.g,l.g),c=o(a.b,l.b),d=Zs(a.opacity,l.opacity);return function(u){return a.r=r(u),a.g=s(u),a.b=c(u),a.opacity=d(u),a+""}}return i.gamma=e,i})(1);function ty(e,t){t||(t=[]);var o=e?Math.min(t.length,e.length):0,i=t.slice(),a;return function(l){for(a=0;a<o;++a)i[a]=e[a]*(1-l)+t[a]*l;return i}}function ny(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function oy(e,t){var o=t?t.length:0,i=e?Math.min(o,e.length):0,a=new Array(i),l=new Array(o),r;for(r=0;r<i;++r)a[r]=ao(e[r],t[r]);for(;r<o;++r)l[r]=t[r];return function(s){for(r=0;r<i;++r)l[r]=a[r](s);return l}}function iy(e,t){var o=new Date;return e=+e,t=+t,function(i){return o.setTime(e*(1-i)+t*i),o}}function vt(e,t){return e=+e,t=+t,function(o){return e*(1-o)+t*o}}function ay(e,t){var o={},i={},a;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(a in t)a in e?o[a]=ao(e[a],t[a]):i[a]=t[a];return function(l){for(a in o)i[a]=o[a](l);return i}}var La=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Pa=new RegExp(La.source,"g");function ly(e){return function(){return e}}function ry(e){return function(t){return e(t)+""}}function Js(e,t){var o=La.lastIndex=Pa.lastIndex=0,i,a,l,r=-1,s=[],c=[];for(e=e+"",t=t+"";(i=La.exec(e))&&(a=Pa.exec(t));)(l=a.index)>o&&(l=t.slice(o,l),s[r]?s[r]+=l:s[++r]=l),(i=i[0])===(a=a[0])?s[r]?s[r]+=a:s[++r]=a:(s[++r]=null,c.push({i:r,x:vt(i,a)})),o=Pa.lastIndex;return o<t.length&&(l=t.slice(o),s[r]?s[r]+=l:s[++r]=l),s.length<2?c[0]?ry(c[0].x):ly(t):(t=c.length,function(d){for(var u=0,f;u<t;++u)s[(f=c[u]).i]=f.x(d);return s.join("")})}function ao(e,t){var o=typeof t,i;return t==null||o==="boolean"?Oa(t):(o==="number"?vt:o==="string"?(i=tn(t))?(t=i,ri):Js:t instanceof tn?ri:t instanceof Date?iy:ny(t)?ty:Array.isArray(t)?oy:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?ay:vt)(e,t)}var Qs=180/Math.PI,za={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ec(e,t,o,i,a,l){var r,s,c;return(r=Math.sqrt(e*e+t*t))&&(e/=r,t/=r),(c=e*o+t*i)&&(o-=e*c,i-=t*c),(s=Math.sqrt(o*o+i*i))&&(o/=s,i/=s,c/=s),e*i<t*o&&(e=-e,t=-t,c=-c,r=-r),{translateX:a,translateY:l,rotate:Math.atan2(t,e)*Qs,skewX:Math.atan(c)*Qs,scaleX:r,scaleY:s}}var si;function sy(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?za:ec(t.a,t.b,t.c,t.d,t.e,t.f)}function cy(e){return e==null||(si||(si=document.createElementNS("http://www.w3.org/2000/svg","g")),si.setAttribute("transform",e),!(e=si.transform.baseVal.consolidate()))?za:(e=e.matrix,ec(e.a,e.b,e.c,e.d,e.e,e.f))}function tc(e,t,o,i){function a(d){return d.length?d.pop()+" ":""}function l(d,u,f,p,m,h){if(d!==f||u!==p){var _=m.push("translate(",null,t,null,o);h.push({i:_-4,x:vt(d,f)},{i:_-2,x:vt(u,p)})}else(f||p)&&m.push("translate("+f+t+p+o)}function r(d,u,f,p){d!==u?(d-u>180?u+=360:u-d>180&&(d+=360),p.push({i:f.push(a(f)+"rotate(",null,i)-2,x:vt(d,u)})):u&&f.push(a(f)+"rotate("+u+i)}function s(d,u,f,p){d!==u?p.push({i:f.push(a(f)+"skewX(",null,i)-2,x:vt(d,u)}):u&&f.push(a(f)+"skewX("+u+i)}function c(d,u,f,p,m,h){if(d!==f||u!==p){var _=m.push(a(m)+"scale(",null,",",null,")");h.push({i:_-4,x:vt(d,f)},{i:_-2,x:vt(u,p)})}else(f!==1||p!==1)&&m.push(a(m)+"scale("+f+","+p+")")}return function(d,u){var f=[],p=[];return d=e(d),u=e(u),l(d.translateX,d.translateY,u.translateX,u.translateY,f,p),r(d.rotate,u.rotate,f,p),s(d.skewX,u.skewX,f,p),c(d.scaleX,d.scaleY,u.scaleX,u.scaleY,f,p),d=u=null,function(m){for(var h=-1,_=p.length,b;++h<_;)f[(b=p[h]).i]=b.x(m);return f.join("")}}}var dy=tc(sy,"px, ","px)","deg)"),uy=tc(cy,", ",")",")"),fy=1e-12;function nc(e){return((e=Math.exp(e))+1/e)/2}function my(e){return((e=Math.exp(e))-1/e)/2}function py(e){return((e=Math.exp(2*e))-1)/(e+1)}const ci=(function e(t,o,i){function a(l,r){var s=l[0],c=l[1],d=l[2],u=r[0],f=r[1],p=r[2],m=u-s,h=f-c,_=m*m+h*h,b,g;if(_<fy)g=Math.log(p/d)/t,b=function(X){return[s+X*m,c+X*h,d*Math.exp(t*X*g)]};else{var I=Math.sqrt(_),y=(p*p-d*d+i*_)/(2*d*o*I),N=(p*p-d*d-i*_)/(2*p*o*I),q=Math.log(Math.sqrt(y*y+1)-y),U=Math.log(Math.sqrt(N*N+1)-N);g=(U-q)/t,b=function(X){var K=X*g,W=nc(q),ne=d/(o*I)*(W*py(t*K+q)-my(q));return[s+ne*m,c+ne*h,d*W/nc(t*K+q)]}}return b.duration=g*1e3*t/Math.SQRT2,b}return a.rho=function(l){var r=Math.max(.001,+l),s=r*r,c=s*s;return e(r,s,c)},a})(Math.SQRT2,2,4);var Rn=0,lo=0,ro=0,oc=1e3,di,so,ui=0,an=0,fi=0,co=typeof performance=="object"&&performance.now?performance:Date,ic=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ua(){return an||(ic(hy),an=co.now()+fi)}function hy(){an=0}function mi(){this._call=this._time=this._next=null}mi.prototype=ac.prototype={constructor:mi,restart:function(e,t,o){if(typeof e!="function")throw new TypeError("callback is not a function");o=(o==null?Ua():+o)+(t==null?0:+t),!this._next&&so!==this&&(so?so._next=this:di=this,so=this),this._call=e,this._time=o,Ha()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ha())}};function ac(e,t,o){var i=new mi;return i.restart(e,t,o),i}function yy(){Ua(),++Rn;for(var e=di,t;e;)(t=an-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Rn}function lc(){an=(ui=co.now())+fi,Rn=lo=0;try{yy()}finally{Rn=0,by(),an=0}}function gy(){var e=co.now(),t=e-ui;t>oc&&(fi-=t,ui=e)}function by(){for(var e,t=di,o,i=1/0;t;)t._call?(i>t._time&&(i=t._time),e=t,t=t._next):(o=t._next,t._next=null,t=e?e._next=o:di=o);so=e,Ha(i)}function Ha(e){if(!Rn){lo&&(lo=clearTimeout(lo));var t=e-an;t>24?(e<1/0&&(lo=setTimeout(lc,e-co.now()-fi)),ro&&(ro=clearInterval(ro))):(ro||(ui=co.now(),ro=setInterval(gy,oc)),Rn=1,ic(lc))}}function rc(e,t,o){var i=new mi;return t=t==null?0:+t,i.restart(a=>{i.stop(),e(a+t)},t,o),i}var _y=Jo("start","end","cancel","interrupt"),wy=[],sc=0,cc=1,Fa=2,pi=3,dc=4,Ga=5,hi=6;function yi(e,t,o,i,a,l){var r=e.__transition;if(!r)e.__transition={};else if(o in r)return;vy(e,o,{name:t,index:i,group:a,on:_y,tween:wy,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:sc})}function Ya(e,t){var o=pt(e,t);if(o.state>sc)throw new Error("too late; already scheduled");return o}function kt(e,t){var o=pt(e,t);if(o.state>pi)throw new Error("too late; already running");return o}function pt(e,t){var o=e.__transition;if(!o||!(o=o[t]))throw new Error("transition not found");return o}function vy(e,t,o){var i=e.__transition,a;i[t]=o,o.timer=ac(l,0,o.time);function l(d){o.state=cc,o.timer.restart(r,o.delay,o.time),o.delay<=d&&r(d-o.delay)}function r(d){var u,f,p,m;if(o.state!==cc)return c();for(u in i)if(m=i[u],m.name===o.name){if(m.state===pi)return rc(r);m.state===dc?(m.state=hi,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete i[u]):+u<t&&(m.state=hi,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete i[u])}if(rc(function(){o.state===pi&&(o.state=dc,o.timer.restart(s,o.delay,o.time),s(d))}),o.state=Fa,o.on.call("start",e,e.__data__,o.index,o.group),o.state===Fa){for(o.state=pi,a=new Array(p=o.tween.length),u=0,f=-1;u<p;++u)(m=o.tween[u].value.call(e,e.__data__,o.index,o.group))&&(a[++f]=m);a.length=f+1}}function s(d){for(var u=d<o.duration?o.ease.call(null,d/o.duration):(o.timer.restart(c),o.state=Ga,1),f=-1,p=a.length;++f<p;)a[f].call(e,u);o.state===Ga&&(o.on.call("end",e,e.__data__,o.index,o.group),c())}function c(){o.state=hi,o.timer.stop(),delete i[t];for(var d in i)return;delete e.__transition}}function gi(e,t){var o=e.__transition,i,a,l=!0,r;if(o){t=t==null?null:t+"";for(r in o){if((i=o[r]).name!==t){l=!1;continue}a=i.state>Fa&&i.state<Ga,i.state=hi,i.timer.stop(),i.on.call(a?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete o[r]}l&&delete e.__transition}}function ky(e){return this.each(function(){gi(this,e)})}function Ey(e,t){var o,i;return function(){var a=kt(this,e),l=a.tween;if(l!==o){i=o=l;for(var r=0,s=i.length;r<s;++r)if(i[r].name===t){i=i.slice(),i.splice(r,1);break}}a.tween=i}}function Ny(e,t,o){var i,a;if(typeof o!="function")throw new Error;return function(){var l=kt(this,e),r=l.tween;if(r!==i){a=(i=r).slice();for(var s={name:t,value:o},c=0,d=a.length;c<d;++c)if(a[c].name===t){a[c]=s;break}c===d&&a.push(s)}l.tween=a}}function $y(e,t){var o=this._id;if(e+="",arguments.length<2){for(var i=pt(this.node(),o).tween,a=0,l=i.length,r;a<l;++a)if((r=i[a]).name===e)return r.value;return null}return this.each((t==null?Ey:Ny)(o,e,t))}function Wa(e,t,o){var i=e._id;return e.each(function(){var a=kt(this,i);(a.value||(a.value={}))[t]=o.apply(this,arguments)}),function(a){return pt(a,i).value[t]}}function uc(e,t){var o;return(typeof t=="number"?vt:t instanceof tn?ri:(o=tn(t))?(t=o,ri):Js)(e,t)}function xy(e){return function(){this.removeAttribute(e)}}function Iy(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Sy(e,t,o){var i,a=o+"",l;return function(){var r=this.getAttribute(e);return r===a?null:r===i?l:l=t(i=r,o)}}function Cy(e,t,o){var i,a=o+"",l;return function(){var r=this.getAttributeNS(e.space,e.local);return r===a?null:r===i?l:l=t(i=r,o)}}function Ry(e,t,o){var i,a,l;return function(){var r,s=o(this),c;return s==null?void this.removeAttribute(e):(r=this.getAttribute(e),c=s+"",r===c?null:r===i&&c===a?l:(a=c,l=t(i=r,s)))}}function Vy(e,t,o){var i,a,l;return function(){var r,s=o(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(r=this.getAttributeNS(e.space,e.local),c=s+"",r===c?null:r===i&&c===a?l:(a=c,l=t(i=r,s)))}}function Ay(e,t){var o=ei(e),i=o==="transform"?uy:uc;return this.attrTween(e,typeof t=="function"?(o.local?Vy:Ry)(o,i,Wa(this,"attr."+e,t)):t==null?(o.local?Iy:xy)(o):(o.local?Cy:Sy)(o,i,t))}function Ty(e,t){return function(o){this.setAttribute(e,t.call(this,o))}}function My(e,t){return function(o){this.setAttributeNS(e.space,e.local,t.call(this,o))}}function By(e,t){var o,i;function a(){var l=t.apply(this,arguments);return l!==i&&(o=(i=l)&&My(e,l)),o}return a._value=t,a}function Dy(e,t){var o,i;function a(){var l=t.apply(this,arguments);return l!==i&&(o=(i=l)&&Ty(e,l)),o}return a._value=t,a}function Oy(e,t){var o="attr."+e;if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;var i=ei(e);return this.tween(o,(i.local?By:Dy)(i,t))}function Ly(e,t){return function(){Ya(this,e).delay=+t.apply(this,arguments)}}function Py(e,t){return t=+t,function(){Ya(this,e).delay=t}}function zy(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Ly:Py)(t,e)):pt(this.node(),t).delay}function Uy(e,t){return function(){kt(this,e).duration=+t.apply(this,arguments)}}function Hy(e,t){return t=+t,function(){kt(this,e).duration=t}}function Fy(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Uy:Hy)(t,e)):pt(this.node(),t).duration}function Gy(e,t){if(typeof t!="function")throw new Error;return function(){kt(this,e).ease=t}}function Yy(e){var t=this._id;return arguments.length?this.each(Gy(t,e)):pt(this.node(),t).ease}function Wy(e,t){return function(){var o=t.apply(this,arguments);if(typeof o!="function")throw new Error;kt(this,e).ease=o}}function Ky(e){if(typeof e!="function")throw new Error;return this.each(Wy(this._id,e))}function qy(e){typeof e!="function"&&(e=Cs(e));for(var t=this._groups,o=t.length,i=new Array(o),a=0;a<o;++a)for(var l=t[a],r=l.length,s=i[a]=[],c,d=0;d<r;++d)(c=l[d])&&e.call(c,c.__data__,d,l)&&s.push(c);return new Rt(i,this._parents,this._name,this._id)}function Xy(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,o=e._groups,i=t.length,a=o.length,l=Math.min(i,a),r=new Array(i),s=0;s<l;++s)for(var c=t[s],d=o[s],u=c.length,f=r[s]=new Array(u),p,m=0;m<u;++m)(p=c[m]||d[m])&&(f[m]=p);for(;s<i;++s)r[s]=t[s];return new Rt(r,this._parents,this._name,this._id)}function jy(e){return(e+"").trim().split(/^|\s+/).every(function(t){var o=t.indexOf(".");return o>=0&&(t=t.slice(0,o)),!t||t==="start"})}function Zy(e,t,o){var i,a,l=jy(t)?Ya:kt;return function(){var r=l(this,e),s=r.on;s!==i&&(a=(i=s).copy()).on(t,o),r.on=a}}function Jy(e,t){var o=this._id;return arguments.length<2?pt(this.node(),o).on.on(e):this.each(Zy(o,e,t))}function Qy(e){return function(){var t=this.parentNode;for(var o in this.__transition)if(+o!==e)return;t&&t.removeChild(this)}}function eg(){return this.on("end.remove",Qy(this._id))}function tg(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ra(e));for(var i=this._groups,a=i.length,l=new Array(a),r=0;r<a;++r)for(var s=i[r],c=s.length,d=l[r]=new Array(c),u,f,p=0;p<c;++p)(u=s[p])&&(f=e.call(u,u.__data__,p,s))&&("__data__"in u&&(f.__data__=u.__data__),d[p]=f,yi(d[p],t,o,p,d,pt(u,o)));return new Rt(l,this._parents,t,o)}function ng(e){var t=this._name,o=this._id;typeof e!="function"&&(e=Ss(e));for(var i=this._groups,a=i.length,l=[],r=[],s=0;s<a;++s)for(var c=i[s],d=c.length,u,f=0;f<d;++f)if(u=c[f]){for(var p=e.call(u,u.__data__,f,c),m,h=pt(u,o),_=0,b=p.length;_<b;++_)(m=p[_])&&yi(m,t,o,_,p,h);l.push(p),r.push(u)}return new Rt(l,r,t,o)}var og=eo.prototype.constructor;function ig(){return new og(this._groups,this._parents)}function ag(e,t){var o,i,a;return function(){var l=In(this,e),r=(this.style.removeProperty(e),In(this,e));return l===r?null:l===o&&r===i?a:a=t(o=l,i=r)}}function fc(e){return function(){this.style.removeProperty(e)}}function lg(e,t,o){var i,a=o+"",l;return function(){var r=In(this,e);return r===a?null:r===i?l:l=t(i=r,o)}}function rg(e,t,o){var i,a,l;return function(){var r=In(this,e),s=o(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(e),In(this,e))),r===c?null:r===i&&c===a?l:(a=c,l=t(i=r,s))}}function sg(e,t){var o,i,a,l="style."+t,r="end."+l,s;return function(){var c=kt(this,e),d=c.on,u=c.value[l]==null?s||(s=fc(t)):void 0;(d!==o||a!==u)&&(i=(o=d).copy()).on(r,a=u),c.on=i}}function cg(e,t,o){var i=(e+="")=="transform"?dy:uc;return t==null?this.styleTween(e,ag(e,i)).on("end.style."+e,fc(e)):typeof t=="function"?this.styleTween(e,rg(e,i,Wa(this,"style."+e,t))).each(sg(this._id,e)):this.styleTween(e,lg(e,i,t),o).on("end.style."+e,null)}function dg(e,t,o){return function(i){this.style.setProperty(e,t.call(this,i),o)}}function ug(e,t,o){var i,a;function l(){var r=t.apply(this,arguments);return r!==a&&(i=(a=r)&&dg(e,r,o)),i}return l._value=t,l}function fg(e,t,o){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(t==null)return this.tween(i,null);if(typeof t!="function")throw new Error;return this.tween(i,ug(e,t,o??""))}function mg(e){return function(){this.textContent=e}}function pg(e){return function(){var t=e(this);this.textContent=t??""}}function hg(e){return this.tween("text",typeof e=="function"?pg(Wa(this,"text",e)):mg(e==null?"":e+""))}function yg(e){return function(t){this.textContent=e.call(this,t)}}function gg(e){var t,o;function i(){var a=e.apply(this,arguments);return a!==o&&(t=(o=a)&&yg(a)),t}return i._value=e,i}function bg(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,gg(e))}function _g(){for(var e=this._name,t=this._id,o=mc(),i=this._groups,a=i.length,l=0;l<a;++l)for(var r=i[l],s=r.length,c,d=0;d<s;++d)if(c=r[d]){var u=pt(c,t);yi(c,e,o,d,r,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Rt(i,this._parents,e,o)}function wg(){var e,t,o=this,i=o._id,a=o.size();return new Promise(function(l,r){var s={value:r},c={value:function(){--a===0&&l()}};o.each(function(){var d=kt(this,i),u=d.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),d.on=t}),a===0&&l()})}var vg=0;function Rt(e,t,o,i){this._groups=e,this._parents=t,this._name=o,this._id=i}function mc(){return++vg}var Vt=eo.prototype;Rt.prototype={constructor:Rt,select:tg,selectAll:ng,selectChild:Vt.selectChild,selectChildren:Vt.selectChildren,filter:qy,merge:Xy,selection:ig,transition:_g,call:Vt.call,nodes:Vt.nodes,node:Vt.node,size:Vt.size,empty:Vt.empty,each:Vt.each,on:Jy,attr:Ay,attrTween:Oy,style:cg,styleTween:fg,text:hg,textTween:bg,remove:eg,tween:$y,delay:zy,duration:Fy,ease:Yy,easeVarying:Ky,end:wg,[Symbol.iterator]:Vt[Symbol.iterator]};function kg(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Eg={time:null,delay:0,duration:250,ease:kg};function Ng(e,t){for(var o;!(o=e.__transition)||!(o=o[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return o}function $g(e){var t,o;e instanceof Rt?(t=e._id,e=e._name):(t=mc(),(o=Eg).time=Ua(),e=e==null?null:e+"");for(var i=this._groups,a=i.length,l=0;l<a;++l)for(var r=i[l],s=r.length,c,d=0;d<s;++d)(c=r[d])&&yi(c,e,t,d,r,o||Ng(c,t));return new Rt(i,this._parents,e,t)}eo.prototype.interrupt=ky,eo.prototype.transition=$g;const bi=e=>()=>e;function xg(e,{sourceEvent:t,target:o,transform:i,dispatch:a}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:a}})}function At(e,t,o){this.k=e,this.x=t,this.y=o}At.prototype={constructor:At,scale:function(e){return e===1?this:new At(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new At(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Vn=new At(1,0,0);At.prototype;function Ka(e){e.stopImmediatePropagation()}function uo(e){e.preventDefault(),e.stopImmediatePropagation()}function Ig(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Sg(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function pc(){return this.__zoom||Vn}function Cg(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Rg(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vg(e,t,o){var i=e.invertX(t[0][0])-o[0][0],a=e.invertX(t[1][0])-o[1][0],l=e.invertY(t[0][1])-o[0][1],r=e.invertY(t[1][1])-o[1][1];return e.translate(a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a),r>l?(l+r)/2:Math.min(0,l)||Math.max(0,r))}function Ag(){var e=Ig,t=Sg,o=Vg,i=Cg,a=Rg,l=[0,1/0],r=[[-1/0,-1/0],[1/0,1/0]],s=250,c=ci,d=Jo("start","zoom","end"),u,f,p,m=500,h=150,_=0,b=10;function g(v){v.property("__zoom",pc).on("wheel.zoom",K,{passive:!1}).on("mousedown.zoom",W).on("dblclick.zoom",ne).filter(a).on("touchstart.zoom",re).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",Q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(v,T,$,P){var H=v.selection?v.selection():v;H.property("__zoom",pc),v!==H?q(v,T,$,P):H.interrupt().each(function(){U(this,arguments).event(P).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},g.scaleBy=function(v,T,$,P){g.scaleTo(v,function(){var H=this.__zoom.k,te=typeof T=="function"?T.apply(this,arguments):T;return H*te},$,P)},g.scaleTo=function(v,T,$,P){g.transform(v,function(){var H=t.apply(this,arguments),te=this.__zoom,M=$==null?N(H):typeof $=="function"?$.apply(this,arguments):$,ee=te.invert(M),le=typeof T=="function"?T.apply(this,arguments):T;return o(y(I(te,le),M,ee),H,r)},$,P)},g.translateBy=function(v,T,$,P){g.transform(v,function(){return o(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof $=="function"?$.apply(this,arguments):$),t.apply(this,arguments),r)},null,P)},g.translateTo=function(v,T,$,P,H){g.transform(v,function(){var te=t.apply(this,arguments),M=this.__zoom,ee=P==null?N(te):typeof P=="function"?P.apply(this,arguments):P;return o(Vn.translate(ee[0],ee[1]).scale(M.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof $=="function"?-$.apply(this,arguments):-$),te,r)},P,H)};function I(v,T){return T=Math.max(l[0],Math.min(l[1],T)),T===v.k?v:new At(T,v.x,v.y)}function y(v,T,$){var P=T[0]-$[0]*v.k,H=T[1]-$[1]*v.k;return P===v.x&&H===v.y?v:new At(v.k,P,H)}function N(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function q(v,T,$,P){v.on("start.zoom",function(){U(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){U(this,arguments).event(P).end()}).tween("zoom",function(){var H=this,te=arguments,M=U(H,te).event(P),ee=t.apply(H,te),le=$==null?N(ee):typeof $=="function"?$.apply(H,te):$,me=Math.max(ee[1][0]-ee[0][0],ee[1][1]-ee[0][1]),ye=H.__zoom,ce=typeof T=="function"?T.apply(H,te):T,ue=c(ye.invert(le).concat(me/ye.k),ce.invert(le).concat(me/ce.k));return function(he){if(he===1)he=ce;else{var ve=ue(he),Se=me/ve[2];he=new At(Se,le[0]-ve[0]*Se,le[1]-ve[1]*Se)}M.zoom(null,he)}})}function U(v,T,$){return!$&&v.__zooming||new X(v,T)}function X(v,T){this.that=v,this.args=T,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,T),this.taps=0}X.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,T){return this.mouse&&v!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var T=ft(this.that).datum();d.call(v,this.that,new xg(v,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:d}),T)}};function K(v,...T){if(!e.apply(this,arguments))return;var $=U(this,T).event(v),P=this.__zoom,H=Math.max(l[0],Math.min(l[1],P.k*Math.pow(2,i.apply(this,arguments)))),te=_t(v);if($.wheel)($.mouse[0][0]!==te[0]||$.mouse[0][1]!==te[1])&&($.mouse[1]=P.invert($.mouse[0]=te)),clearTimeout($.wheel);else{if(P.k===H)return;$.mouse=[te,P.invert(te)],gi(this),$.start()}uo(v),$.wheel=setTimeout(M,h),$.zoom("mouse",o(y(I(P,H),$.mouse[0],$.mouse[1]),$.extent,r));function M(){$.wheel=null,$.end()}}function W(v,...T){if(p||!e.apply(this,arguments))return;var $=v.currentTarget,P=U(this,T,!0).event(v),H=ft(v.view).on("mousemove.zoom",le,!0).on("mouseup.zoom",me,!0),te=_t(v,$),M=v.clientX,ee=v.clientY;Ps(v.view),Ka(v),P.mouse=[te,this.__zoom.invert(te)],gi(this),P.start();function le(ye){if(uo(ye),!P.moved){var ce=ye.clientX-M,ue=ye.clientY-ee;P.moved=ce*ce+ue*ue>_}P.event(ye).zoom("mouse",o(y(P.that.__zoom,P.mouse[0]=_t(ye,$),P.mouse[1]),P.extent,r))}function me(ye){H.on("mousemove.zoom mouseup.zoom",null),zs(ye.view,P.moved),uo(ye),P.event(ye).end()}}function ne(v,...T){if(e.apply(this,arguments)){var $=this.__zoom,P=_t(v.changedTouches?v.changedTouches[0]:v,this),H=$.invert(P),te=$.k*(v.shiftKey?.5:2),M=o(y(I($,te),P,H),t.apply(this,T),r);uo(v),s>0?ft(this).transition().duration(s).call(q,M,P,v):ft(this).call(g.transform,M,P,v)}}function re(v,...T){if(e.apply(this,arguments)){var $=v.touches,P=$.length,H=U(this,T,v.changedTouches.length===P).event(v),te,M,ee,le;for(Ka(v),M=0;M<P;++M)ee=$[M],le=_t(ee,this),le=[le,this.__zoom.invert(le),ee.identifier],H.touch0?!H.touch1&&H.touch0[2]!==le[2]&&(H.touch1=le,H.taps=0):(H.touch0=le,te=!0,H.taps=1+!!u);u&&(u=clearTimeout(u)),te&&(H.taps<2&&(f=le[0],u=setTimeout(function(){u=null},m)),gi(this),H.start())}}function L(v,...T){if(this.__zooming){var $=U(this,T).event(v),P=v.changedTouches,H=P.length,te,M,ee,le;for(uo(v),te=0;te<H;++te)M=P[te],ee=_t(M,this),$.touch0&&$.touch0[2]===M.identifier?$.touch0[0]=ee:$.touch1&&$.touch1[2]===M.identifier&&($.touch1[0]=ee);if(M=$.that.__zoom,$.touch1){var me=$.touch0[0],ye=$.touch0[1],ce=$.touch1[0],ue=$.touch1[1],he=(he=ce[0]-me[0])*he+(he=ce[1]-me[1])*he,ve=(ve=ue[0]-ye[0])*ve+(ve=ue[1]-ye[1])*ve;M=I(M,Math.sqrt(he/ve)),ee=[(me[0]+ce[0])/2,(me[1]+ce[1])/2],le=[(ye[0]+ue[0])/2,(ye[1]+ue[1])/2]}else if($.touch0)ee=$.touch0[0],le=$.touch0[1];else return;$.zoom("touch",o(y(M,ee,le),$.extent,r))}}function Q(v,...T){if(this.__zooming){var $=U(this,T).event(v),P=v.changedTouches,H=P.length,te,M;for(Ka(v),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),te=0;te<H;++te)M=P[te],$.touch0&&$.touch0[2]===M.identifier?delete $.touch0:$.touch1&&$.touch1[2]===M.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(M=_t(M,this),Math.hypot(f[0]-M[0],f[1]-M[1])<b)){var ee=ft(this).on("dblclick.zoom");ee&&ee.apply(this,arguments)}}}return g.wheelDelta=function(v){return arguments.length?(i=typeof v=="function"?v:bi(+v),g):i},g.filter=function(v){return arguments.length?(e=typeof v=="function"?v:bi(!!v),g):e},g.touchable=function(v){return arguments.length?(a=typeof v=="function"?v:bi(!!v),g):a},g.extent=function(v){return arguments.length?(t=typeof v=="function"?v:bi([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),g):t},g.scaleExtent=function(v){return arguments.length?(l[0]=+v[0],l[1]=+v[1],g):[l[0],l[1]]},g.translateExtent=function(v){return arguments.length?(r[0][0]=+v[0][0],r[1][0]=+v[1][0],r[0][1]=+v[0][1],r[1][1]=+v[1][1],g):[[r[0][0],r[0][1]],[r[1][0],r[1][1]]]},g.constrain=function(v){return arguments.length?(o=v,g):o},g.duration=function(v){return arguments.length?(s=+v,g):s},g.interpolate=function(v){return arguments.length?(c=v,g):c},g.on=function(){var v=d.on.apply(d,arguments);return v===d?g:v},g.clickDistance=function(v){return arguments.length?(_=(v=+v)*v,g):Math.sqrt(_)},g.tapDistance=function(v){return arguments.length?(b=+v,g):b},g}var $e=(e=>(e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom",e))($e||{}),qa=(e=>(e.Partial="partial",e.Full="full",e))(qa||{}),ln=(e=>(e.Bezier="default",e.SimpleBezier="simple-bezier",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e))(ln||{}),Tt=(e=>(e.Strict="strict",e.Loose="loose",e))(Tt||{}),Xa=(e=>(e.Arrow="arrow",e.ArrowClosed="arrowclosed",e))(Xa||{}),fo=(e=>(e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal",e))(fo||{}),hc=(e=>(e.TopLeft="top-left",e.TopCenter="top-center",e.TopRight="top-right",e.BottomLeft="bottom-left",e.BottomCenter="bottom-center",e.BottomRight="bottom-right",e))(hc||{});const Tg=["INPUT","SELECT","TEXTAREA"],Mg=typeof document<"u"?document:null;function ja(e){var t,o;const i=((o=(t=e.composedPath)==null?void 0:t.call(e))==null?void 0:o[0])||e.target,a=typeof(i==null?void 0:i.hasAttribute)=="function"?i.hasAttribute("contenteditable"):!1,l=typeof(i==null?void 0:i.closest)=="function"?i.closest(".nokey"):null;return Tg.includes(i==null?void 0:i.nodeName)||a||!!l}function Bg(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function yc(e,t,o,i){const a=t.replace("+",`
|
|
3
3
|
`).replace(`
|
|
4
4
|
|
|
5
5
|
`,`
|