@g1cloud/bpmn-modeler-next 5.0.0-beta.60 → 5.0.0-beta.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,13 @@
1
- (function(se,Se){typeof exports=="object"&&typeof module<"u"?Se(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Se):(se=typeof globalThis<"u"?globalThis:se||self,Se(se.BpmnModeler={},se.Vue))})(this,(function(se,Se){"use strict";var sF=Object.defineProperty;var cF=(se,Se,Rr)=>Se in se?sF(se,Se,{enumerable:!0,configurable:!0,writable:!0,value:Rr}):se[Se]=Rr;var $n=(se,Se,Rr)=>cF(se,typeof Se!="symbol"?Se+"":Se,Rr);const Rr=["startEvent","endEvent","userTask","serviceTask","task","sendTask","receiveTask","exclusiveGateway","parallelGateway","subProcess","boundaryEvent","intermediateCatchEvent"],Ac=["startEvent","endEvent","userTask","serviceTask","task","sendTask","receiveTask","exclusiveGateway","parallelGateway","intermediateCatchEvent"];function qg(e){return Rr.includes(e)}function Yg(e){return Ac.includes(e)}const Pc=["timer"],Tc={timer:"bpmn:TimerEventDefinition"};function Kg(e){return typeof e=="string"&&Pc.includes(e)}function kp(e){if(e.length===1)return Pc.find(t=>Tc[t]===e[0])}const kc=["ko","en","ja","zh"];function BS(e){return typeof e=="string"&&kc.includes(e)}const Xg="http://g1project.net/spec/bpmn/bwl/1.0",Op="bwl",Dp=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"],Oc="bwl:ReviewRequest",Zg={name:"bwl-hints",uri:Xg,prefix:Op,xml:{tagAlias:"lowerCase"},types:[{name:"Placement",superClass:["Element"],properties:[{name:"anchor",isAttr:!0,type:"String"},{name:"side",isAttr:!0,type:"String"},{name:"offset",isAttr:!0,type:"Real"}]},{name:"Members",superClass:["Element"],properties:[{name:"refs",isAttr:!0,type:"String"}]},{name:"BandHint",extends:["bpmn:FlowNode"],properties:[{name:"band",isAttr:!0,type:"Integer"}]},{name:"AfterColumnHint",extends:["bpmn:FlowNode"],properties:[{name:"afterColumn",isAttr:!0,type:"String"}]},{name:"PoolOrderHint",extends:["bpmn:Participant"],properties:[{name:"poolOrder",isAttr:!0,type:"Integer"}]},{name:"ReviewRequest",superClass:["Element"],properties:[{name:"locale",isAttr:!0,type:"String"},{name:"sourceLocale",isAttr:!0,type:"String"},{name:"previous",isBody:!0,type:"String"}]}]},Lp="bwl.undoEpisode",Qg=new WeakSet;function NS(e){Qg.has(e)||(e.register(Lp,{preExecute(t){try{t.run()}catch(n){t.error=n}}}),Qg.add(e))}function Jg(e,t){NS(e);const n={run:t};if(e.execute(Lp,n),n.error!==void 0)throw e.canUndo()&&e.undo(),n.error}function Ip(e){return Array.prototype.concat.apply([],e)}const as=Object.prototype.toString,$S=Object.prototype.hasOwnProperty;function Cr(e){return e===void 0}function gn(e){return e!==void 0}function ra(e){return e==null}function Ze(e){return as.call(e)==="[object Array]"}function mn(e){return as.call(e)==="[object Object]"}function Qe(e){return as.call(e)==="[object Number]"}function _n(e){const t=as.call(e);return t==="[object Function]"||t==="[object AsyncFunction]"||t==="[object GeneratorFunction]"||t==="[object AsyncGeneratorFunction]"||t==="[object Proxy]"}function ei(e){return as.call(e)==="[object String]"}function FS(e){if(!Ze(e))throw new Error("must supply array")}function ti(e,t){return!ra(e)&&$S.call(e,t)}function It(e,t){const n=Lc(t);let i;return V(e,function(o,r){if(n(o,r))return i=o,!1}),i}function em(e,t){const n=Lc(t);let i=Ze(e)?-1:void 0;return V(e,function(o,r){if(n(o,r))return i=r,!1}),i}function ct(e,t){const n=Lc(t);let i=[];return V(e,function(o,r){n(o,r)&&i.push(o)}),i}function V(e,t){let n,i;if(Cr(e))return;const o=Ze(e)?VS:GS;for(let r in e)if(ti(e,r)&&(n=e[r],i=t(n,o(r)),i===!1))return n}function jS(e,t){if(Cr(e))return[];FS(e);const n=Lc(t);return e.filter(function(i,o){return!n(i,o)})}function ni(e,t,n){return V(e,function(i,o){n=t(n,i,o)}),n}function Io(e,t){return!!ni(e,function(n,i,o){return n&&t(i,o)},!0)}function Bo(e,t){return!!It(e,t)}function Fn(e,t){let n=[];return V(e,function(i,o){n.push(t(i,o))}),n}function Dc(e){return e&&Object.keys(e)||[]}function HS(e){return Dc(e).length}function aa(e){return Fn(e,t=>t)}function sa(e,t,n={}){return t=Bp(t),V(e,function(i){let o=t(i)||"_",r=n[o];r||(r=n[o]=[]),r.push(i)}),n}function tm(e,...t){e=Bp(e);let n={};return V(t,o=>sa(o,e,n)),Fn(n,function(o,r){return o[0]})}const zS=tm;function qi(e,t){t=Bp(t);let n=[];return V(e,function(i,o){let r=t(i,o),a={d:r,v:i};for(var s=0;s<n.length;s++){let{d:c}=n[s];if(r<c){n.splice(s,0,a);return}}n.push(a)}),Fn(n,i=>i.v)}function ca(e){return function(t){return Io(e,function(n,i){return t[i]===n})}}function Bp(e){return _n(e)?e:t=>t[e]}function Lc(e){return _n(e)?e:t=>t===e}function GS(e){return e}function VS(e){return Number(e)}function Np(e,t){let n,i,o,r;function a(p){let f=Date.now(),d=p?0:r+t-f;if(d>0)return s(d);e.apply(o,i),c()}function s(p){n=setTimeout(a,p)}function c(){n&&clearTimeout(n),n=r=i=o=void 0}function l(){n&&a(!0),c()}function u(...p){r=Date.now(),i=p,o=this,n||s(t)}return u.flush=l,u.cancel=c,u}function Kn(e,t){return e.bind(t)}function Y(e,...t){return Object.assign(e,...t)}function WS(e,t,n){let i=e;return V(t,function(o,r){if(typeof o!="number"&&typeof o!="string")throw new Error("illegal key type: "+typeof o+". Key should be of type number or string.");if(o==="constructor")throw new Error("illegal key: constructor");if(o==="__proto__")throw new Error("illegal key: __proto__");let a=t[r+1],s=i[o];gn(a)&&ra(s)&&(s=i[o]=isNaN(+a)?{}:[]),Cr(a)?Cr(n)?delete i[o]:i[o]=n:i=s}),e}function Ni(e,t){let n={},i=Object(e);return V(t,function(o){o in i&&(n[o]=e[o])}),n}function Yi(e,t){let n={},i=Object(e);return V(i,function(o,r){t.indexOf(r)===-1&&(n[r]=o)}),n}function M(e,t){var n=_e(e);return n&&typeof n.$instanceOf=="function"&&n.$instanceOf(t)}function st(e,t){return Bo(t,function(n){return M(e,n)})}function _e(e){return e&&e.businessObject||e}function mt(e){return e&&e.di}const US="http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",nm="i18n",Mr="i18n:Translation";function Ar(e){if(e){if(M(e,"bpmn:TextAnnotation"))return{target:e,key:"text"};if(M(e,"bpmn:Group"))return e.categoryValueRef?{target:e.categoryValueRef,key:"value"}:void 0;if(M(e,"bpmn:FlowElement")||M(e,"bpmn:Participant")||M(e,"bpmn:Lane")||M(e,"bpmn:MessageFlow")||M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput"))return{target:e,key:"name"}}}function No(e){var t;return(((t=e==null?void 0:e.extensionElements)==null?void 0:t.values)??[]).filter(n=>{var i;return(i=n==null?void 0:n.$instanceOf)==null?void 0:i.call(n,Mr)})}function Rn(e){return e.get("xml:lang")}function $o(e){var t;return(((t=e==null?void 0:e.extensionElements)==null?void 0:t.values)??[]).filter(n=>{var i;return(i=n==null?void 0:n.$instanceOf)==null?void 0:i.call(n,Oc)})}function ss(e){const{designLocale:t,companionLocales:n}=e;return[t,...n.filter((i,o,r)=>i!==t&&r.indexOf(i)===o)]}function $p(e){var n,i;const t=((n=e==null?void 0:e.get)==null?void 0:n.call(e,"xml:lang"))??((i=e==null?void 0:e.$attrs)==null?void 0:i["xml:lang"]);return typeof t=="string"&&t?t:void 0}function Fp(e,t,n){const i=Ar(e);if(!i)return{};const o=i.target[i.key]??"",r=No(e).filter(u=>Rn(u)),a=u=>u.body??"",s=o?r.filter(u=>a(u)===o).map(Rn):[],c=o?s.length?s:[n??t.designLocale]:[],l={};for(const u of ss(t)){if(c.includes(u)){l[u]=o;continue}const p=r.find(f=>Rn(f)===u&&a(f));p&&(l[u]=a(p))}return l}const Ic="bwl.updateTranslation";class jp{constructor(t){this.moddle=t}execute(t){const{element:n,text:i,designLocale:o,locales:r,rootLang:a,nameChangedFrom:s}=t,c=n.businessObject,l=Ar(c),u=[];t.undo=u;const p=No(c).filter(k=>Rn(k)),f=s??(l?l.target[l.key]??"":""),d=a??o,h=(k=>{if(!k)return[];const H=p.filter(F=>F.body===k).map(Rn);return H.length?H:[d]})(f),m=s!==void 0&&f&&!h.includes(t.locale)?h[0]:t.locale,w=k=>{var H;return((H=p.find(F=>Rn(F)===k&&F.body))==null?void 0:H.body)??(h.includes(k)?f:"")},y=k=>$o(c).some(H=>H.locale===k),v=w(m);if(v===i)return[];const x=!!v&&!y(m),E=x?r.filter(k=>k!==m&&w(k)&&!y(k)):[],A=()=>{let k=c.extensionElements;return k||(k=this.moddle.create("bpmn:ExtensionElements",{values:[]}),k.$parent=c,c.extensionElements=k,u.push(()=>delete c.extensionElements)),k.get("values")},B=(k,H)=>{const F=A();let G=F.find(ee=>{var ce;return((ce=ee.$instanceOf)==null?void 0:ce.call(ee,Mr))&&Rn(ee)===k});if(G){const ee=G.body;G.body=H,u.push(()=>G.body=ee)}else G=this.moddle.create(Mr,{body:H}),G.set("xml:lang",k),G.$parent=c.extensionElements,F.push(G),u.push(()=>F.splice(F.indexOf(G),1))},P=k=>{const H=A(),F=H.indexOf(k);H.splice(F,1),u.push(()=>H.splice(F,0,k))};if(s===void 0){if(m===o&&l){if(f&&!p.some(H=>H.body===f)){const H=a&&a!==o?a:void 0;H&&B(H,f)}const k=Object.prototype.hasOwnProperty.call(l.target,l.key);l.target[l.key]=i,u.push(()=>{k?l.target[l.key]=f:delete l.target[l.key]})}B(m,i)}else(p.some(k=>Rn(k)===m)||!f&&m!==d)&&B(m,i);if(!x)for(const k of $o(c).filter(H=>H.locale===m))P(k);for(const k of E){const H=A(),F=this.moddle.create(Oc,{locale:k,sourceLocale:m,previous:v});F.$parent=c.extensionElements,H.push(F),u.push(()=>H.splice(H.indexOf(F),1))}for(const k of $o(c).filter(H=>H.sourceLocale===m&&(H.previous??"")===i))P(k);return u.length?[n,n.label].filter(Boolean):[]}revert(t){for(const n of[...t.undo].reverse())n();return t.undo.length?[t.element,t.element.label].filter(Boolean):[]}}$n(jp,"$inject",["moddle"]);const Hp="bwl.setTranslations",qS=(e,t)=>e.locale===t.locale&&(e.sourceLocale??void 0)===t.sourceLocale&&(e.previous??"")===t.previous;class zp{constructor(t){this.moddle=t}execute(t){const{element:n,texts:i,confirm:o=[],designLocale:r,locales:a,rootLang:s,before:c}=t,l=n.businessObject,u=[];if(t.undo=u,!Ar(l))return[];const p=()=>{let w=l.extensionElements;return w||(w=this.moddle.create("bpmn:ExtensionElements",{values:[]}),w.$parent=l,l.extensionElements=w,u.push(()=>delete l.extensionElements)),w.get("values")},f=w=>{const y=p(),v=y.indexOf(w);v<0||(y.splice(v,1),u.push(()=>y.splice(v,0,w)))},d=w=>No(l).find(y=>Rn(y)===w);if(i===null)for(const w of a){const y=d(w);y&&f(y)}else if(i)for(const w of a){const y=i[w];if(y===void 0)continue;const v=d(w);if(v){if(v.body===y)continue;const A=v.body;v.body=y,u.push(()=>v.body=A);continue}if(w===r&&(s??r)===r)continue;const x=p(),E=this.moddle.create(Mr,{body:y});E.set("xml:lang",w),E.$parent=l.extensionElements,x.push(E),u.push(()=>x.splice(x.indexOf(E),1))}const h=[...i===null?[]:c.requests.filter(w=>!o.includes(w.locale)&&!(i&&i[w.locale]!==void 0&&i[w.locale]!==c.texts[w.locale])&&!(i&&w.sourceLocale&&i[w.sourceLocale]===w.previous))];for(const w of $o(l)){const y=h.findIndex(v=>qS(w,v));y>=0?h.splice(y,1):f(w)}for(const w of h){const y=p(),v=this.moddle.create(Oc,{locale:w.locale,...w.sourceLocale?{sourceLocale:w.sourceLocale}:{},previous:w.previous});v.$parent=l.extensionElements,y.push(v),u.push(()=>y.splice(y.indexOf(v),1))}const m=l.extensionElements;return m&&!m.get("values").length&&(delete l.extensionElements,u.push(()=>l.extensionElements=m)),u.length?[n,n.label].filter(Boolean):[]}revert(t){for(const n of[...t.undo].reverse())n();return t.undo.length?[t.element,t.element.label].filter(Boolean):[]}}$n(zp,"$inject",["moddle"]);function Gp(e){return $o(e).map(t=>({locale:t.locale,...t.sourceLocale?{sourceLocale:t.sourceLocale}:{},previous:t.previous??""}))}class Vp{constructor(t){t.registerHandler(Ic,jp),t.registerHandler(Hp,zp)}}$n(Vp,"$inject",["commandStack"]);const Wp={__init__:["translationCommands"],translationCommands:["type",Vp]},im=["participant.add","participant.update","node.add","node.update","sequenceFlow.add","sequenceFlow.update","messageFlow.add","messageFlow.update","dataStore.add","dataStore.update","dataAssociation.add","association.add","annotation.add","annotation.update","group.add","group.update","translation.confirm","element.remove"],YS={description:"생략 = 보존, null = 제거.",anyOf:[{type:"string"},{type:"null"}]},KS={type:"object",description:"다국어 그룹의 문구 — 로케일 → 문구. **그 문서의 문서 언어(설계 + 병기 · describe 의 i18n) 전부**를 담는다(빠지거나 밖의 언어면 거부). 평문 name/text 와 함께 주면 거부. 문서 언어 설정이 없는 문서(describe 에 i18n 이 없다)는 이것 대신 평문을 쓴다.",properties:Object.fromEntries(kc.map(e=>[e,{type:"string"}])),additionalProperties:!1},XS={type:"object",description:"레인. 배열 선언 순서 = 풀 내 상→하 순서.",properties:{id:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"}},required:["id"],additionalProperties:!1},ZS={type:"object",description:"풀(participant). 레인은 여기 선언하고 노드가 lane 인자로 배정된다 — 별도 레인 op 없음.",properties:{id:{type:"string",description:"문서 내 유일, XML NCName(공백 없이 문자/밑줄로 시작)."},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},blackBox:{type:"boolean",description:"true = 내부 프로세스 없는 블랙박스 풀."},lanes:{type:"array",items:{$ref:"#/$defs/irLane"}}},required:["id"],additionalProperties:!1},QS={type:"string",enum:[...Pc],description:"이벤트 정의. **type 이 intermediateCatchEvent 일 때만 쓰고, 그때는 반드시 준다**(다른 타입에 주거나 빠뜨리면 거부). timer = 시한 대기(「30분 경과」·「확정 기간 경과」처럼 시간이 지나야 다음으로 가는 자리). 시한 값은 name 에 쓴다 — 표현식 필드는 없다."},JS={type:"object",description:"플로우 노드. 좌표는 지정하지 않는다 — 배치는 resolver 가 결정한다. ⚠ type 집합은 **읽을 수 있는 것보다 좁다** — describe 는 subProcess·boundaryEvent 도 노드로 내지만 그 둘을 새로 만드는 배치는 미실증이라 여기서 받지 않는다(B-87 ⓐ). intermediateCatchEvent 는 eventDefinition 과 짝으로만 받는다.",properties:{id:{type:"string"},type:{type:"string",enum:[...Ac]},eventDefinition:{$ref:"#/$defs/eventDefinition"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},participant:{type:"string",description:"소속 풀 id(협업 문서)."},lane:{type:"string",description:"소속 레인 id(풀 정의에 선언된 것)."}},required:["id","type"],additionalProperties:!1},eR={type:"object",description:"분기 조건 — 게이트웨이가 아닌 플로우에 붙인다. MVP 는 label 만. ⚠ 다국어 그룹(describe 에 i18n 이 있다)에서는 쓰지 않는다 — 조건 라벨도 그 플로우의 names 로 준다.",properties:{label:{type:"string"}},required:["label"],additionalProperties:!1},tR={type:"object",description:"시퀀스 플로우(같은 풀 안 노드 간).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},condition:{$ref:"#/$defs/irFlowCondition"}},required:["id","source","target"],additionalProperties:!1},nR={type:"object",description:"메시지 플로우(풀 경계를 넘는 연결 — 노드 또는 블랙박스 풀 자체가 끝점).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"}},required:["id","source","target"],additionalProperties:!1},iR={type:"object",properties:{id:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"}},required:["id"],additionalProperties:!1},oR={type:"object",description:"데이터 입출력 연관. 방향 = source→target(태스크→스토어 = 쓰기, 스토어→태스크 = 읽기).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"}},required:["source","target"],additionalProperties:!1},rR={type:"object",description:"텍스트 주석. 본문은 text(평문) 또는 texts(다국어 그룹) 중 하나를 반드시 준다.",properties:{id:{type:"string"},text:{type:"string"},texts:{$ref:"#/$defs/localeTexts"}},required:["id"],additionalProperties:!1},aR={type:"object",description:"연관선(주석 ↔ 요소).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"}},required:["source","target"],additionalProperties:!1},sR={type:"object",description:"그룹 — members(요소 id 목록)가 bwl:members 힌트로 기록되고 바운즈는 멤버 bbox 로 산출된다.",properties:{id:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},members:{type:"array",items:{type:"string"}}},required:["id"],additionalProperties:!1},cR={type:"object",description:"주석 방위 힌트 — 앵커 요소 기준 상대 배치. 있으면 결정적 배치, 없으면 휴리스틱.",properties:{anchor:{type:"string",description:"기준 요소 id."},side:{type:"string",enum:[...Dp]},offset:{type:"number",description:"앵커 가장자리 → 주석 가장자리 간격(px). 생략 시 50."}},required:["anchor","side"],additionalProperties:!1};function Pn(e,t){return{type:"object",description:t.description,properties:{kind:{const:e},...t.properties},required:["kind",...t.required??[]],additionalProperties:!1}}const lR={"participant.add":Pn("participant.add",{description:"풀 추가. order = 풀 세로 순서 힌트 — **작을수록 위**(생략 시 op 순서가 곧 배치 순서). 값은 상대 순서만 쓰므로 1,2,3… 연속이든 10,20,30 간격이든 같다.",properties:{participant:{$ref:"#/$defs/irParticipant"},order:{type:"integer"}},required:["participant"]}),"participant.update":Pn("participant.update",{description:"풀 이름/레인 갱신. lanes 는 전체 재선언(생략 = 보존) — 기존 레인을 유지하려면 함께 다시 나열한다.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},lanes:{type:"array",items:{$ref:"#/$defs/irLane"}}},required:["id"]}),"node.add":Pn("node.add",{description:'플로우 노드 추가. band = 가로 밴드 순번 힌트(주 흐름 0, 갈래 1, 2…) — 위/아래가 아니라 "주 흐름에서 몇 번째 갈래"다. 행 배치(어느 갈래가 위/아래인지)는 호스트가 정한다(대칭·메시지 방향). 레인이 있으면 그 레인 안의 밴드다 — 한 레인 안에서 게이트웨이 출구를 갈라 놓을 때 쓴다. 컨테이너(풀·레인)는 밴드 수만큼 자란다.',properties:{node:{$ref:"#/$defs/irNode"},band:{type:"integer",description:"0 이상 정수(음수는 payload-invalid 로 거부)."},afterColumn:{type:"string",description:"열 지목 힌트 — 그 노드보다 **뒤(오른쪽) 열**에 둔다. 좌표가 아니라 관계다(실제 x 는 호스트가 산출하고 정렬·압축은 그 뒤에도 적용된다). 🔴 **쓸 자리는 하나다 — 시퀀스 유입이 없는 수신 노드**(메시지만 받는 노드). 그런 노드는 열을 정할 근거가 도구에 없어 풀 좌단에 남고, 시간축(x)상 뒤쪽인 프로세스가 앞쪽에 놓여 선이 먼 거리를 돌아온다. 시퀀스로 이어지는 노드에는 쓰지 마라 — 열은 상류가 이미 정한다. 참조가 해소되지 않으면 힌트가 없는 것과 같이 동작한다."}},required:["node"]}),"node.update":Pn("node.update",{description:"노드 이름/레인/타입/밴드 갱신. lane = 레인 재배정(이동), type = 태스크·이벤트 타입 전환, band = 행 재지정. 🔴 **기존 문서에서 band 는 「몇 번째 갈래」가 아니라 그 컨테이너의 행 번호**다(describe 의 hints.bands 가 보여 주는 값) — 신규 배치의 band 가 대칭으로 펴지는 것과 다르다. 간선이 도형을 가로지르거나 반대 방향으로 겹칠 때 그 노드를 다른 행으로 옮기는 채널이다.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},lane:{type:"string"},type:{type:"string",enum:[...Ac]},eventDefinition:{$ref:"#/$defs/eventDefinition"},band:{type:"integer",description:"0 이상 정수(음수는 payload-invalid 로 거부)."}},required:["id"]}),"sequenceFlow.add":Pn("sequenceFlow.add",{description:"시퀀스 플로우 추가. 분기 조건은 게이트웨이가 아닌 플로우의 condition 에 싣는다.",properties:{flow:{$ref:"#/$defs/irSequenceFlow"}},required:["flow"]}),"sequenceFlow.update":Pn("sequenceFlow.update",{description:"시퀀스 플로우 이름/조건/끝점 갱신. condition: null = 조건 제거. source/target = 끝점 재배선 — 중간 삽입은 기존 플로우를 지우지 말고 이것으로 한쪽 끝을 옮긴 뒤 새 플로우를 추가한다.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},condition:{description:"생략 = 보존, null = 제거.",anyOf:[{$ref:"#/$defs/irFlowCondition"},{type:"null"}]},source:{description:"새 출발 노드 id(생략 = 보존). 같은 배치에서 추가한 노드도 지목할 수 있다.",type:"string"},target:{description:"새 도착 노드 id(생략 = 보존). 같은 배치에서 추가한 노드도 지목할 수 있다.",type:"string"}},required:["id"]}),"messageFlow.add":Pn("messageFlow.add",{description:"메시지 플로우 추가(풀 경계를 넘는 연결).",properties:{flow:{$ref:"#/$defs/irMessageFlow"}},required:["flow"]}),"messageFlow.update":Pn("messageFlow.update",{description:"메시지 플로우 이름 갱신.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"}},required:["id"]}),"dataStore.add":Pn("dataStore.add",{description:"데이터 스토어 추가(+ 입출력 연관 동반 가능).",properties:{dataStore:{$ref:"#/$defs/irDataStore"},associations:{type:"array",items:{$ref:"#/$defs/irDataAssociation"}}},required:["dataStore"]}),"dataStore.update":Pn("dataStore.update",{description:"데이터 스토어 이름 갱신.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"}},required:["id"]}),"dataAssociation.add":Pn("dataAssociation.add",{description:"기존 노드 ↔ 기존 데이터 스토어의 입출력 연관 추가.",properties:{association:{$ref:"#/$defs/irDataAssociation"}},required:["association"]}),"association.add":Pn("association.add",{description:"주석 ↔ 요소 연관 추가(한쪽 끝은 주석). 주석 신설과 함께면 annotation.add 의 association 을 쓰고, 이 op 는 추가 연관(한 주석에 여러 연관)용.",properties:{association:{$ref:"#/$defs/irAssociation"}},required:["association"]}),"annotation.add":Pn("annotation.add",{description:"텍스트 주석 추가. association 으로 대상 요소와 연결하고, placement 로 방위를 지정하면 결정적 배치된다.",properties:{annotation:{$ref:"#/$defs/irTextAnnotation"},association:{$ref:"#/$defs/irAssociation"},placement:{$ref:"#/$defs/bwlPlacement"}},required:["annotation"]}),"annotation.update":Pn("annotation.update",{description:"주석 본문/방위 힌트 갱신. placement: null = 힌트 제거(휴리스틱 복귀). 주석 삭제는 element.remove.",properties:{id:{type:"string"},text:{type:"string"},texts:{$ref:"#/$defs/localeTexts"},placement:{description:"생략 = 보존, null = 힌트 제거.",anyOf:[{$ref:"#/$defs/bwlPlacement"},{type:"null"}]}},required:["id"]}),"group.add":Pn("group.add",{description:"그룹 추가 — 바운즈는 members 의 bbox 로 산출되므로 좌표를 지정하지 않는다.",properties:{group:{$ref:"#/$defs/irGroup"}},required:["group"]}),"group.update":Pn("group.update",{description:"그룹 이름/멤버 갱신. members 는 전체 재선언(생략 = 보존).",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},members:{type:"array",items:{type:"string"}}},required:["id"]}),"translation.confirm":Pn("translation.confirm",{description:"확인만 — 그 요소의 locale 칸에 걸린 확인 요청(describe 의 i18n.reviewRequests)을 문구를 바꾸지 않고 해소한다. 다른 언어가 고쳐졌지만(sourceLocale · previous → 지금 문구) 이 칸의 번역이 여전히 맞을 때(오타 수준) 쓴다. 번역을 고쳐야 하면 이것 대신 그 요소의 update 에 names/texts(문서 언어 전부)를 준다 — 문구가 실제로 바뀐 칸의 표식만 해소된다. 다국어 그룹에서만 받고, 그 칸에 표식이 없으면 거부한다.",properties:{id:{type:"string",description:"확인 요청이 걸린 요소 id."},locale:{type:"string",enum:[...kc],description:"확인 요청을 받은 칸의 언어(reviewRequests 의 locale)."}},required:["id","locale"]}),"element.remove":Pn("element.remove",{description:"요소 제거(카테고리 무관). 부착된 연결선은 함께 제거된다.",properties:{id:{type:"string"}},required:["id"]})},om={anyOf:im.map(e=>lR[e])},uR={type:"object",description:"BPMN 문서에 요소를 추가·수정·삭제할 때 호출한다. 기존 요소는 describeProcess 가 노출하는 id 로 지정하고, 신규 요소 id 는 문서 내 유일한 XML NCName(공백 없이 문자/밑줄 시작)으로 짓는다. 좌표는 지정하지 않는다 — 배치는 서버가 결정하며, 필요하면 힌트(placement/band/order)로 의도만 전달하라. 문서에 문서 언어 설정이 있으면(describe 의 i18n) 문구는 평문 name/text 가 아니라 names/texts 로 문서 언어 전부를 준다.",properties:{ops:{type:"array",items:{$ref:"#/$defs/symbolicOp"}}},required:["ops"],additionalProperties:!1,$defs:{irLane:XS,irParticipant:ZS,irNode:JS,irFlowCondition:eR,irSequenceFlow:tR,irMessageFlow:nR,irDataStore:iR,irDataAssociation:oR,irTextAnnotation:rR,irAssociation:aR,irGroup:sR,bwlPlacement:cR,eventDefinition:QS,localeTexts:KS,nullableString:YS,symbolicOp:om}};function Up(){}Up.prototype.get=function(e){return this.$model.properties.get(this,e)},Up.prototype.set=function(e,t){this.$model.properties.set(this,e,t)};function rm(e,t){this.model=e,this.properties=t}rm.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(Up.prototype);V(e.properties,function(a){!a.isMany&&a.default!==void 0&&(i[a.name]=a.default)}),n.defineModel(i,t),n.defineDescriptor(i,e);var o=e.ns.name;function r(a){n.define(this,"$type",{value:o,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),V(a,Kn(function(s,c){this.set(c,s)},this))}return r.prototype=i,r.hasType=i.$instanceOf=this.model.hasType,n.defineModel(r,t),n.defineDescriptor(r,e),r};var pR=Y(Object.create(null),{String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0}),am=Y(Object.create(null),{String:function(e){return e},Boolean:function(e){return e==="true"},Integer:function(e){return parseInt(e,10)},Real:function(e){return parseFloat(e)}});function qp(e,t){var n=am[e];return n?n(t):t}function Yp(e){return!!pR[e]}function sm(e){return!!am[e]}function jn(e,t){var n=e.split(/:/),i,o;if(n.length===1)i=e,o=t;else if(n.length===2)i=n[1],o=n[0];else throw new Error("expected <prefix:localName> or <localName>, got "+e);return e=(o?o+":":"")+i,{name:e,prefix:o,localName:i}}function di(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName=Object.create(null),this.properties=[],this.propertiesByName=Object.create(null)}di.prototype.build=function(){return Ni(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])},di.prototype.addProperty=function(e,t,n){typeof t=="boolean"&&(n=t,t=void 0),this.addNamedProperty(e,n!==!1);var i=this.properties;t!==void 0?i.splice(t,0,e):i.push(e)},di.prototype.replaceProperty=function(e,t,n){var i=e.ns,o=this.properties,r=this.propertiesByName,a=e.name!==t.name;if(e.isId){if(!t.isId)throw new Error("property <"+t.ns.name+"> must be id property to refine <"+e.ns.name+">");this.setIdProperty(t,!1)}if(e.isBody){if(!t.isBody)throw new Error("property <"+t.ns.name+"> must be body property to refine <"+e.ns.name+">");this.setBodyProperty(t,!1)}var s=o.indexOf(e);if(s===-1)throw new Error("property <"+i.name+"> not found in property list");o.splice(s,1),this.addProperty(t,n?void 0:s,a),r[i.name]=r[i.localName]=t},di.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,o=t.split("#"),r=jn(o[0],i),a=jn(o[1],r.prefix).name,s=this.propertiesByName[a];if(s)this.replaceProperty(s,e,n);else throw new Error("refined property <"+a+"> not found");delete e.redefines},di.prototype.addNamedProperty=function(e,t){var n=e.ns,i=this.propertiesByName;t&&(this.assertNotDefined(e,n.name),this.assertNotDefined(e,n.localName)),i[n.name]=i[n.localName]=e},di.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},di.prototype.setBodyProperty=function(e,t){if(t&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+e.ns.name+">)");this.bodyProperty=e},di.prototype.setIdProperty=function(e,t){if(t&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+e.ns.name+">)");this.idProperty=e},di.prototype.assertNotTrait=function(e){if((e.extends||[]).length)throw new Error(`cannot create <${e.name}> extending <${e.extends}>`)},di.prototype.assertNotDefined=function(e,t){var n=e.name,i=this.propertiesByName[n];if(i)throw new Error("property <"+n+"> already defined; override of <"+i.definedBy.ns.name+"#"+i.ns.name+"> by <"+e.definedBy.ns.name+"#"+e.ns.name+"> not allowed without redefines")},di.prototype.hasProperty=function(e){return this.propertiesByName[e]},di.prototype.addTrait=function(e,t){t&&this.assertNotTrait(e);var n=this.allTypesByName,i=this.allTypes,o=e.name;o in n||(V(e.properties,Kn(function(r){r=Y({},r,{name:r.ns.localName,inherited:t}),Object.defineProperty(r,"definedBy",{value:e});var a=r.replaces,s=r.redefines;a||s?this.redefineProperty(r,a||s,a):(r.isBody&&this.setBodyProperty(r),r.isId&&this.setIdProperty(r),this.addProperty(r))},this)),i.push(e),n[o]=e)};function Fo(e,t){this.packageMap=Object.create(null),this.typeMap=Object.create(null),this.packages=[],this.properties=t,V(e,Kn(this.registerPackage,this))}Fo.prototype.getPackage=function(e){return this.packageMap[e]},Fo.prototype.getPackages=function(){return this.packages},Fo.prototype.registerPackage=function(e){e=Y({},e);var t=this.packageMap;cm(t,e,"prefix"),cm(t,e,"uri"),V(e.types,Kn(function(n){this.registerType(n,e)},this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)},Fo.prototype.registerType=function(e,t){e=Y({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:Y({},e.meta||{})});var n=jn(e.name,t.prefix),i=n.name,o=Object.create(null);V(e.properties,Kn(function(r){var a=jn(r.name,n.prefix),s=a.name;Yp(r.type)||(r.type=jn(r.type,a.prefix).name),Y(r,{ns:a,name:s}),o[s]=r},this)),Y(e,{ns:n,name:i,propertiesByName:o}),V(e.extends,Kn(function(r){var a=jn(r,n.prefix),s=this.typeMap[a.name];s.traits=s.traits||[],s.traits.push(i)},this)),this.definePackage(e,t),this.typeMap[i]=e},Fo.prototype.mapTypes=function(e,t,n){var i=Yp(e.name)?{name:e.name}:this.typeMap[e.name],o=this;function r(c,l){var u=jn(c,Yp(c)?"":e.prefix);o.mapTypes(u,t,l)}function a(c){return r(c,!0)}function s(c){return r(c,!1)}if(!i)throw new Error("unknown type <"+e.name+">");V(i.superClass,n?a:s),t(i,!n),V(i.traits,a)},Fo.prototype.getEffectiveDescriptor=function(e){var t=jn(e),n=new di(t);this.mapTypes(t,function(o,r){n.addTrait(o,r)});var i=n.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i},Fo.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})};function cm(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function Pr(e){this.model=e}Pr.prototype.set=function(e,t,n){if(!ei(t)||!t.length)throw new TypeError("property name must be a non-empty string");var i=this.getProperty(e,t),o=i&&i.name;fR(n)?i?delete e[o]:delete e.$attrs[Kp(t)]:i?o in e?e[o]=n:lm(e,i,n):e.$attrs[Kp(t)]=n},Pr.prototype.get=function(e,t){var n=this.getProperty(e,t);if(!n)return e.$attrs[Kp(t)];var i=n.name;return!e[i]&&n.isMany&&lm(e,n,[]),e[i]},Pr.prototype.define=function(e,t,n){if(!n.writable){var i=n.value;n=Y({},n,{get:function(){return i}}),delete n.value}Object.defineProperty(e,t,n)},Pr.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},Pr.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},Pr.prototype.getProperty=function(e,t){var n=this.model,i=n.getPropertyDescriptor(e,t);if(i)return i;if(t.includes(":"))return null;const o=n.config.strict;if(typeof o<"u"){const r=new TypeError(`unknown property <${t}> on <${e.$type}>`);if(o)throw r;typeof console<"u"&&console.warn(r)}return null};function fR(e){return typeof e>"u"}function lm(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function Kp(e){return e.replace(/^:/,"")}function xi(e,t={}){this.properties=new Pr(this),this.factory=new rm(this,this.properties),this.registry=new Fo(e,this.properties),this.typeCache=Object.create(null),this.config=t}xi.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},xi.prototype.getType=function(e){var t=this.typeCache,n=ei(e)?e:e.ns.name,i=t[n];return i||(e=this.registry.getEffectiveDescriptor(n),i=t[n]=this.factory.createType(e)),i},xi.prototype.createAny=function(e,t,n){var i=jn(e),o={$type:e,$instanceOf:function(a){return a===this.$type},get:function(a){return this[a]},set:function(a,s){WS(this,[a],s)}},r={name:e,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:t}};return this.properties.defineDescriptor(o,r),this.properties.defineModel(o,this),this.properties.define(o,"get",{enumerable:!1,writable:!0}),this.properties.define(o,"set",{enumerable:!1,writable:!0}),this.properties.define(o,"$parent",{enumerable:!1,writable:!0}),this.properties.define(o,"$instanceOf",{enumerable:!1,writable:!0}),V(n,function(a,s){mn(a)&&a.value!==void 0?o[a.name]=a.value:o[s]=a}),o},xi.prototype.getPackage=function(e){return this.registry.getPackage(e)},xi.prototype.getPackages=function(){return this.registry.getPackages()},xi.prototype.getElementDescriptor=function(e){return e.$descriptor},xi.prototype.hasType=function(e,t){t===void 0&&(t=e,e=this);var n=e.$model.getElementDescriptor(e);return t in n.allTypesByName},xi.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},xi.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var um=String.fromCharCode,dR=Object.prototype.hasOwnProperty,hR=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,cs={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(cs).forEach(function(e){cs[e.toUpperCase()]=cs[e]});function gR(e,t,n,i){return i?dR.call(cs,i)?cs[i]:"&"+i+";":um(t||parseInt(n,16))}function Tr(e){return e.length>3&&e.indexOf("&")!==-1?e.replace(hR,gR):e}var pm="non-whitespace outside of root node";function jo(e){return new Error(e)}function mR(e){return"missing namespace for prefix <"+e+">"}function Bc(e){return{get:e,enumerable:!0}}function yR(e){var t=Object.create(null),n;for(n in e)t[n]=e[n];return t}var fm=Symbol("nameCache");function Xp(e){return e+"$uri"}function vR(e){var t=Object.create(null),n,i;for(n in e)i=e[n],t[i]=i,t[Xp(i)]=n;return t}function Nc(){return{line:0,column:0}}function bR(e){throw e}function dm(e){if(!this)return new dm(e);var t=e&&e.proxy,n,i,o,r,a=bR,s,c,l,u,p=Nc,f=!1,d=!1,g="",h=!1,m=!1,w=null,y=!1,v,x,E,A;function B(F){F instanceof Error||(F=jo(F)),w=F,a(F,p)}function P(F){s&&(F instanceof Error||(F=jo(F)),s(F,p))}this.on=function(F,G){if(typeof G!="function")throw jo("required args <name, cb>");switch(F){case"openTag":i=G;break;case"text":n=G;break;case"closeTag":o=G;break;case"error":a=G;break;case"warn":s=G;break;case"cdata":r=G;break;case"attention":u=G;break;case"question":l=G;break;case"comment":c=G;break;default:throw jo("unsupported event: "+F)}return this},this.ns=function(F){if(typeof F>"u"&&(F={}),typeof F!="object")throw jo("required args <nsMap={}>");var G=Object.create(null),ee;for(ee in F)G[ee]=F[ee];return m=!0,A=G,this};function k(){v=m?[]:null,x=m?vR(A):null,E=[],p=Nc,y=!1,w=null,d=!1,g=""}this.parse=function(F){if(typeof F!="string")throw jo("required args <xml=string>");if(f)throw jo("parse during stream; call end() first");return k(),H(F),p=Nc,y=!1,w},this.write=function(F){if(typeof F!="string")throw jo("required args <xml=string>");return f||(k(),f=!0),w||(g=H(g+F,!0)||""),this},this.end=function(){return f||k(),f=!1,w||H(g),g="",p=Nc,y=!1,w},this.stop=function(){y=!0};function H(F,G=!1){var ee=null,ce=null,ie,be=0,de=!1,me=!1,Ee=0,U=0,ue,K,J,he,Re,ze,$,C,R,W="",q=0,fe;function Oe(St,nn){var An=St.indexOf(":");if(An===-1)return St;var Vn=x[St.substring(0,An)];return Vn?nn===Vn?St.substr(An+1):Vn+St.substr(An):(P(mR(St.substring(0,An))),null)}function nt(){if(fe!==null)return fe;var St,nn,An=m&&x.xmlns,Vn=m&&h?[]:null,Tt=q,$t=W,xn=$t.length,vr,Qn,Jn,bi,hn,Do={},Qa=new Set,pi,xt,Rt;e:for(;Tt<xn;Tt++)if(pi=!1,xt=$t.charCodeAt(Tt),!(xt===32||xt<14&&xt>8)){for((xt<65||xt>122||xt>90&&xt<97)&&xt!==95&&xt!==58&&(P("illegal first char attribute name"),pi=!0),Rt=Tt+1;Rt<xn;Rt++)if(xt=$t.charCodeAt(Rt),!(xt>96&&xt<123||xt>64&&xt<91||xt>47&&xt<59||xt===46||xt===45||xt===95)){if(xt===32||xt<14&&xt>8){P("missing attribute value"),Tt=Rt;continue e}if(xt===61)break;P("illegal attribute name char"),pi=!0}if(hn=$t.substring(Tt,Rt),hn==="xmlns:xmlns"&&(P("illegal declaration of xmlns"),pi=!0),xt=$t.charCodeAt(Rt+1),xt===34)Rt=$t.indexOf('"',Tt=Rt+2),Rt===-1&&(Rt=$t.indexOf("'",Tt),Rt!==-1&&(P("attribute value quote missmatch"),pi=!0));else if(xt===39)Rt=$t.indexOf("'",Tt=Rt+2),Rt===-1&&(Rt=$t.indexOf('"',Tt),Rt!==-1&&(P("attribute value quote missmatch"),pi=!0));else for(P("missing attribute value quotes"),pi=!0,Rt=Rt+1;Rt<xn&&(xt=$t.charCodeAt(Rt+1),!(xt===32||xt<14&&xt>8));Rt++);for(Rt===-1&&(P("missing closing quotes"),Rt=xn,pi=!0),pi||(Jn=$t.substring(Tt,Rt)),Tt=Rt;Rt+1<xn&&(xt=$t.charCodeAt(Rt+1),!(xt===32||xt<14&&xt>8));Rt++)Tt===Rt&&(P("illegal character after attribute end"),pi=!0);if(Tt=Rt+1,pi)continue e;if(Qa.has(hn)){P("attribute <"+hn+"> already defined");continue}if(Qa.add(hn),!m){Do[hn]=Jn;continue}if(h){if(Qn=hn==="xmlns"?"xmlns":hn.charCodeAt(0)===120&&hn.substr(0,6)==="xmlns:"?hn.substr(6):null,Qn!==null){if(St=Tr(Jn),nn=Xp(Qn),bi=A[St],!bi){if(Qn==="xmlns"||nn in x&&x[nn]!==St)do bi="ns"+be++;while(typeof x[bi]<"u");else bi=Qn;A[St]=bi}x[Qn]!==bi&&(vr||(x=yR(x),vr=!0),x[Qn]=bi,Qn==="xmlns"&&(x[Xp(bi)]=St,An=bi),x[nn]=St),Do[hn]=Jn;continue}Vn.push(hn,Jn);continue}hn=Oe(hn,An),hn!==null&&(Do[hn]=Jn)}if(h)for(Tt=0,xn=Vn.length;Tt<xn;Tt++)hn=Oe(Vn[Tt++],An),Jn=Vn[Tt],hn!==null&&(Do[hn]=Jn);return fe=Do}function lt(){for(var St=/(\r\n|\r|\n)/g,nn=0,An=0,Vn=0,Tt=U,$t,xn;Ee>=Vn&&($t=St.exec(F),!(!$t||(Tt=$t[0].length+$t.index,Tt>Ee)));)nn+=1,Vn=Tt;return Ee==-1?(An=Tt,xn=F.substring(U)):U===0?xn=F.substring(U,Ee):(An=Ee-Vn,xn=U==-1?F.substring(Ee):F.substring(Ee,U+1)),{data:xn,line:nn,column:An}}for(p=lt,t&&(R=Object.create({},{name:Bc(function(){return $}),originalName:Bc(function(){return C}),attrs:Bc(nt),ns:Bc(function(){return x})}));U!==-1;){if(F.charCodeAt(U)===60?Ee=U:Ee=F.indexOf("<",U),Ee===-1){if(G)return F.substring(U);if(E.length)return B("unexpected end of file");if(!d)return B("missing start tag");U<F.length&&F.substring(U).trim()&&P(pm);return}if(d||(d=!0),U!==Ee){if(E.length){if(n&&(n(F.substring(U,Ee),Tr,p),y))return}else if(F.substring(U,Ee).trim()&&(P(pm),y))return}if(he=F.charCodeAt(Ee+1),he===33){if(J=F.charCodeAt(Ee+2),J===91&&F.substr(Ee+3,6)==="CDATA["){if(U=F.indexOf("]]>",Ee),U===-1)return G?F.substring(Ee):B("unclosed cdata");if(r&&(r(F.substring(Ee+9,U),p),y))return;U+=3;continue}if(J===45&&F.charCodeAt(Ee+3)===45){if(U=F.indexOf("-->",Ee),U===-1)return G?F.substring(Ee):B("unclosed comment");if(c&&(c(F.substring(Ee+4,U),Tr,p),y))return;U+=3;continue}}if(he===63){if(U=F.indexOf("?>",Ee),U===-1)return G?F.substring(Ee):B("unclosed question");if(l&&(l(F.substring(Ee,U+2),p),y))return;U+=2;continue}for(ue=Ee+1;;ue++){if(Re=F.charCodeAt(ue),isNaN(Re))return G?F.substring(Ee):(U=-1,B("unclosed tag"));if(Re===34)J=F.indexOf('"',ue+1),ue=J!==-1?J:ue;else if(Re===39)J=F.indexOf("'",ue+1),ue=J!==-1?J:ue;else if(Re===62){U=ue;break}}if(he===33){if(u&&(u(F.substring(Ee,U+1),Tr,p),y))return;U+=1;continue}if(fe={},he===47){if(de=!1,me=!0,!E.length)return B("missing open tag");if(ue=$=E.pop(),J=Ee+2+ue.length,F.substring(Ee+2,J)!==ue)return B("closing tag mismatch");for(;J<U;J++)if(he=F.charCodeAt(J),!(he===32||he>8&&he<14))return B("close tag")}else{if(F.charCodeAt(U-1)===47?(ue=$=F.substring(Ee+1,U-1),de=!0,me=!0):(ue=$=F.substring(Ee+1,U),de=!0,me=!1),!(he>96&&he<123||he>64&&he<91||he===95||he===58))return B("illegal first char nodeName");for(J=1,K=ue.length;J<K;J++)if(he=ue.charCodeAt(J),!(he>96&&he<123||he>64&&he<91||he>47&&he<59||he===45||he===95||he==46)){if(he===32||he<14&&he>8){$=ue.substring(0,J),fe=null;break}return B("invalid nodeName")}me||E.push($)}if(m){ie=x,de&&(me||v.push(ie),fe===null&&(h=ue.indexOf("xmlns",J)!==-1)&&(q=J,W=ue,nt(),h=!1)),C=$,ce!==x&&(ee=x[fm],ee===void 0&&(ee=x[fm]=Object.create(null)),ce=x);var Vt=ee[$];if(Vt!==void 0)$=Vt;else{if(he=$.indexOf(":"),he!==-1){if(ze=x[$.substring(0,he)],!ze)return B("missing namespace on <"+C+">");$=$.substr(he+1)}else ze=x.xmlns;ze&&($=ze+":"+$),ee[C]=$}}if(de&&(q=J,W=ue,i&&(t?i(R,Tr,me,p):i($,nt,Tr,me,p),y)))return;if(me){if(o&&(o(t?R:$,Tr,de,p),y))return;m&&(de?x=ie:x=v.pop())}U+=1}}}function hm(e){return e.xml&&e.xml.tagAlias==="lowerCase"}var Zp={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},gm="property";function mm(e){return e.xml&&e.xml.serialize}function xR(e){const t=mm(e);return t!==gm&&(t||null)}function wR(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ym(e,t){return hm(t)?e.prefix+":"+wR(e.localName):e.name}function _R(e,t){var n=e.name,i=e.localName,o=t&&t.xml&&t.xml.typePrefix;return o&&i.indexOf(o)===0?e.prefix+":"+i.slice(o.length):n}function ER(e,t,n){const i=jn(e,t.xmlns),o=`${t[i.prefix]||i.prefix}:${i.localName}`,r=jn(o);var a=n.getPackage(r.prefix);return _R(r,a)}function Ho(e){return new Error(e)}function ho(e){return e.$descriptor}function SR(e){Y(this,e),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(t){this.references.push(t)},this.addElement=function(t){if(!t)throw Ho("expected element");var n=this.elementsById,i=ho(t),o=i.idProperty,r;if(o&&(r=t.get(o.name),r)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(r))throw new Error("illegal ID <"+r+">");if(n[r])throw Ho("duplicate ID <"+r+">");n[r]=t}},this.addWarning=function(t){this.warnings.push(t)}}function ls(){}ls.prototype.handleEnd=function(){},ls.prototype.handleText=function(){},ls.prototype.handleNode=function(){};function Qp(){}Qp.prototype=Object.create(ls.prototype),Qp.prototype.handleNode=function(){return this};function la(){}la.prototype=Object.create(ls.prototype),la.prototype.handleText=function(e){this.body=(this.body||"")+e};function us(e,t){this.property=e,this.context=t}us.prototype=Object.create(la.prototype),us.prototype.handleNode=function(e){if(this.element)throw Ho("expected no sub nodes");return this.element=this.createReference(e),this},us.prototype.handleEnd=function(){this.element.id=this.body},us.prototype.createReference=function(e){return{property:this.property.ns.name,id:""}};function Jp(e,t){this.element=t,this.propertyDesc=e}Jp.prototype=Object.create(la.prototype),Jp.prototype.handleEnd=function(){var e=this.body||"",t=this.element,n=this.propertyDesc;e=qp(n.type,e),n.isMany?t.get(n.name).push(e):t.set(n.name,e)};function $c(){}$c.prototype=Object.create(la.prototype),$c.prototype.handleNode=function(e){var t=this,n=this.element;return n?t=this.handleChild(e):(n=this.element=this.createElement(e),this.context.addElement(n)),t};function Wn(e,t,n){this.model=e,this.type=e.getType(t),this.context=n}Wn.prototype=Object.create($c.prototype),Wn.prototype.addReference=function(e){this.context.addReference(e)},Wn.prototype.handleText=function(e){var t=this.element,n=ho(t),i=n.bodyProperty;if(!i)throw Ho("unexpected body text <"+e+">");la.prototype.handleText.call(this,e)},Wn.prototype.handleEnd=function(){var e=this.body,t=this.element,n=ho(t),i=n.bodyProperty;i&&e!==void 0&&(e=qp(i.type,e),t.set(i.name,e))},Wn.prototype.createElement=function(e){var t=e.attributes,n=this.type,i=ho(n),o=this.context,r=new n({}),a=this.model,s;return V(t,function(c,l){var u=i.propertiesByName[l],p;u&&u.isReference?u.isMany?(p=c.split(" "),V(p,function(f){o.addReference({element:r,property:u.ns.name,id:f})})):o.addReference({element:r,property:u.ns.name,id:c}):(u?c=qp(u.type,c):l==="xmlns"?l=":"+l:(s=jn(l,i.ns.prefix),a.getPackage(s.prefix)&&o.addWarning({message:"unknown attribute <"+l+">",element:r,property:l,value:c})),r.set(l,c))}),r},Wn.prototype.getPropertyForNode=function(e){var t=e.name,n=jn(t),i=this.type,o=this.model,r=ho(i),a=n.name,s=r.propertiesByName[a];if(s&&!s.isAttr){const l=xR(s);if(l){const u=e.attributes[l];if(u){const p=ER(u,e.ns,o),f=o.getType(p);return Y({},s,{effectiveType:ho(f).name})}}return s}var c=o.getPackage(n.prefix);if(c){const l=ym(n,c),u=o.getType(l);if(s=It(r.properties,function(p){return!p.isVirtual&&!p.isReference&&!p.isAttribute&&u.hasType(p.type)}),s)return Y({},s,{effectiveType:ho(u).name})}else if(s=It(r.properties,function(l){return!l.isReference&&!l.isAttribute&&l.type==="Element"}),s)return s;throw Ho("unrecognized element <"+n.name+">")},Wn.prototype.toString=function(){return"ElementDescriptor["+ho(this.type).name+"]"},Wn.prototype.valueHandler=function(e,t){return new Jp(e,t)},Wn.prototype.referenceHandler=function(e){return new us(e,this.context)},Wn.prototype.handler=function(e){return e==="Element"?new ua(this.model,e,this.context):new Wn(this.model,e,this.context)},Wn.prototype.handleChild=function(e){var t,n,i,o;if(t=this.getPropertyForNode(e),i=this.element,n=t.effectiveType||t.type,sm(n))return this.valueHandler(t,i);t.isReference?o=this.referenceHandler(t).handleNode(e):o=this.handler(n).handleNode(e);var r=o.element;return r!==void 0&&(t.isMany?i.get(t.name).push(r):i.set(t.name,r),t.isReference?(Y(r,{element:i}),this.context.addReference(r)):r.$parent=i),o};function ef(e,t,n){Wn.call(this,e,t,n)}ef.prototype=Object.create(Wn.prototype),ef.prototype.createElement=function(e){var t=e.name,n=jn(t),i=this.model,o=this.type,r=i.getPackage(n.prefix),a=r&&ym(n,r)||t;if(!o.hasType(a))throw Ho("unexpected element <"+e.originalName+">");return Wn.prototype.createElement.call(this,e)};function ua(e,t,n){this.model=e,this.context=n}ua.prototype=Object.create($c.prototype),ua.prototype.createElement=function(e){var t=e.name,n=jn(t),i=n.prefix,o=e.ns[i+"$uri"],r=e.attributes;return this.model.createAny(t,o,r)},ua.prototype.handleChild=function(e){var t=new ua(this.model,"Element",this.context).handleNode(e),n=this.element,i=t.element,o;return i!==void 0&&(o=n.$children=n.$children||[],o.push(i),i.$parent=n),t},ua.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function tf(e){e instanceof xi&&(e={model:e}),Y(this,{lax:!1},e)}tf.prototype.fromXML=function(e,t,n){var i=t.rootHandler;t instanceof Wn?(i=t,t={}):typeof t=="string"?(i=this.handler(t),t={}):typeof i=="string"&&(i=this.handler(i));var o=this.model,r=this.lax,a=new SR(Y({},t,{rootHandler:i})),s=new dm({proxy:!0}),c=RR();i.context=a,c.push(i);function l(E,A,B){var P=A(),k=P.line,H=P.column,F=P.data;F.charAt(0)==="<"&&F.indexOf(" ")!==-1&&(F=F.slice(0,F.indexOf(" "))+">");var G="unparsable content "+(F?F+" ":"")+`detected
1
+ (function(se,Se){typeof exports=="object"&&typeof module<"u"?Se(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],Se):(se=typeof globalThis<"u"?globalThis:se||self,Se(se.BpmnModeler={},se.Vue))})(this,(function(se,Se){"use strict";var sF=Object.defineProperty;var cF=(se,Se,Rr)=>Se in se?sF(se,Se,{enumerable:!0,configurable:!0,writable:!0,value:Rr}):se[Se]=Rr;var $n=(se,Se,Rr)=>cF(se,typeof Se!="symbol"?Se+"":Se,Rr);const Rr=["startEvent","endEvent","userTask","serviceTask","task","sendTask","receiveTask","exclusiveGateway","parallelGateway","subProcess","boundaryEvent","intermediateCatchEvent"],Ac=["startEvent","endEvent","userTask","serviceTask","task","sendTask","receiveTask","exclusiveGateway","parallelGateway","intermediateCatchEvent"];function qg(e){return Rr.includes(e)}function Yg(e){return Ac.includes(e)}const Pc=["timer"],Tc={timer:"bpmn:TimerEventDefinition"};function Kg(e){return typeof e=="string"&&Pc.includes(e)}function kp(e){if(e.length===1)return Pc.find(t=>Tc[t]===e[0])}const kc=["ko","en","ja","zh"];function BS(e){return typeof e=="string"&&kc.includes(e)}const Xg="http://g1project.net/spec/bpmn/bwl/1.0",Op="bwl",Dp=["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"],Oc="bwl:ReviewRequest",Zg={name:"bwl-hints",uri:Xg,prefix:Op,xml:{tagAlias:"lowerCase"},types:[{name:"Placement",superClass:["Element"],properties:[{name:"anchor",isAttr:!0,type:"String"},{name:"side",isAttr:!0,type:"String"},{name:"offset",isAttr:!0,type:"Real"}]},{name:"Members",superClass:["Element"],properties:[{name:"refs",isAttr:!0,type:"String"}]},{name:"BandHint",extends:["bpmn:FlowNode"],properties:[{name:"band",isAttr:!0,type:"Integer"}]},{name:"AfterColumnHint",extends:["bpmn:FlowNode"],properties:[{name:"afterColumn",isAttr:!0,type:"String"}]},{name:"PoolOrderHint",extends:["bpmn:Participant"],properties:[{name:"poolOrder",isAttr:!0,type:"Integer"}]},{name:"ReviewRequest",superClass:["Element"],properties:[{name:"locale",isAttr:!0,type:"String"},{name:"sourceLocale",isAttr:!0,type:"String"},{name:"previous",isBody:!0,type:"String"}]}]},Lp="bwl.undoEpisode",Qg=new WeakSet;function NS(e){Qg.has(e)||(e.register(Lp,{preExecute(t){try{t.run()}catch(n){t.error=n}}}),Qg.add(e))}function Jg(e,t){NS(e);const n={run:t};if(e.execute(Lp,n),n.error!==void 0)throw e.canUndo()&&e.undo(),n.error}function Ip(e){return Array.prototype.concat.apply([],e)}const as=Object.prototype.toString,$S=Object.prototype.hasOwnProperty;function Cr(e){return e===void 0}function gn(e){return e!==void 0}function ra(e){return e==null}function Ze(e){return as.call(e)==="[object Array]"}function mn(e){return as.call(e)==="[object Object]"}function Qe(e){return as.call(e)==="[object Number]"}function _n(e){const t=as.call(e);return t==="[object Function]"||t==="[object AsyncFunction]"||t==="[object GeneratorFunction]"||t==="[object AsyncGeneratorFunction]"||t==="[object Proxy]"}function ei(e){return as.call(e)==="[object String]"}function FS(e){if(!Ze(e))throw new Error("must supply array")}function ti(e,t){return!ra(e)&&$S.call(e,t)}function It(e,t){const n=Lc(t);let i;return V(e,function(o,r){if(n(o,r))return i=o,!1}),i}function em(e,t){const n=Lc(t);let i=Ze(e)?-1:void 0;return V(e,function(o,r){if(n(o,r))return i=r,!1}),i}function ct(e,t){const n=Lc(t);let i=[];return V(e,function(o,r){n(o,r)&&i.push(o)}),i}function V(e,t){let n,i;if(Cr(e))return;const o=Ze(e)?VS:GS;for(let r in e)if(ti(e,r)&&(n=e[r],i=t(n,o(r)),i===!1))return n}function jS(e,t){if(Cr(e))return[];FS(e);const n=Lc(t);return e.filter(function(i,o){return!n(i,o)})}function ni(e,t,n){return V(e,function(i,o){n=t(n,i,o)}),n}function Io(e,t){return!!ni(e,function(n,i,o){return n&&t(i,o)},!0)}function Bo(e,t){return!!It(e,t)}function Fn(e,t){let n=[];return V(e,function(i,o){n.push(t(i,o))}),n}function Dc(e){return e&&Object.keys(e)||[]}function HS(e){return Dc(e).length}function aa(e){return Fn(e,t=>t)}function sa(e,t,n={}){return t=Bp(t),V(e,function(i){let o=t(i)||"_",r=n[o];r||(r=n[o]=[]),r.push(i)}),n}function tm(e,...t){e=Bp(e);let n={};return V(t,o=>sa(o,e,n)),Fn(n,function(o,r){return o[0]})}const zS=tm;function qi(e,t){t=Bp(t);let n=[];return V(e,function(i,o){let r=t(i,o),a={d:r,v:i};for(var s=0;s<n.length;s++){let{d:c}=n[s];if(r<c){n.splice(s,0,a);return}}n.push(a)}),Fn(n,i=>i.v)}function ca(e){return function(t){return Io(e,function(n,i){return t[i]===n})}}function Bp(e){return _n(e)?e:t=>t[e]}function Lc(e){return _n(e)?e:t=>t===e}function GS(e){return e}function VS(e){return Number(e)}function Np(e,t){let n,i,o,r;function a(p){let f=Date.now(),d=p?0:r+t-f;if(d>0)return s(d);e.apply(o,i),c()}function s(p){n=setTimeout(a,p)}function c(){n&&clearTimeout(n),n=r=i=o=void 0}function l(){n&&a(!0),c()}function u(...p){r=Date.now(),i=p,o=this,n||s(t)}return u.flush=l,u.cancel=c,u}function Kn(e,t){return e.bind(t)}function Y(e,...t){return Object.assign(e,...t)}function WS(e,t,n){let i=e;return V(t,function(o,r){if(typeof o!="number"&&typeof o!="string")throw new Error("illegal key type: "+typeof o+". Key should be of type number or string.");if(o==="constructor")throw new Error("illegal key: constructor");if(o==="__proto__")throw new Error("illegal key: __proto__");let a=t[r+1],s=i[o];gn(a)&&ra(s)&&(s=i[o]=isNaN(+a)?{}:[]),Cr(a)?Cr(n)?delete i[o]:i[o]=n:i=s}),e}function Ni(e,t){let n={},i=Object(e);return V(t,function(o){o in i&&(n[o]=e[o])}),n}function Yi(e,t){let n={},i=Object(e);return V(i,function(o,r){t.indexOf(r)===-1&&(n[r]=o)}),n}function M(e,t){var n=_e(e);return n&&typeof n.$instanceOf=="function"&&n.$instanceOf(t)}function st(e,t){return Bo(t,function(n){return M(e,n)})}function _e(e){return e&&e.businessObject||e}function mt(e){return e&&e.di}const US="http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",nm="i18n",Mr="i18n:Translation";function Ar(e){if(e){if(M(e,"bpmn:TextAnnotation"))return{target:e,key:"text"};if(M(e,"bpmn:Group"))return e.categoryValueRef?{target:e.categoryValueRef,key:"value"}:void 0;if(M(e,"bpmn:FlowElement")||M(e,"bpmn:Participant")||M(e,"bpmn:Lane")||M(e,"bpmn:MessageFlow")||M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput"))return{target:e,key:"name"}}}function No(e){var t;return(((t=e==null?void 0:e.extensionElements)==null?void 0:t.values)??[]).filter(n=>{var i;return(i=n==null?void 0:n.$instanceOf)==null?void 0:i.call(n,Mr)})}function Rn(e){return e.get("xml:lang")}function $o(e){var t;return(((t=e==null?void 0:e.extensionElements)==null?void 0:t.values)??[]).filter(n=>{var i;return(i=n==null?void 0:n.$instanceOf)==null?void 0:i.call(n,Oc)})}function ss(e){const{designLocale:t,companionLocales:n}=e;return[t,...n.filter((i,o,r)=>i!==t&&r.indexOf(i)===o)]}function $p(e){var n,i;const t=((n=e==null?void 0:e.get)==null?void 0:n.call(e,"xml:lang"))??((i=e==null?void 0:e.$attrs)==null?void 0:i["xml:lang"]);return typeof t=="string"&&t?t:void 0}function Fp(e,t,n){const i=Ar(e);if(!i)return{};const o=i.target[i.key]??"",r=No(e).filter(u=>Rn(u)),a=u=>u.body??"",s=o?r.filter(u=>a(u)===o).map(Rn):[],c=o?s.length?s:[n??t.designLocale]:[],l={};for(const u of ss(t)){if(c.includes(u)){l[u]=o;continue}const p=r.find(f=>Rn(f)===u&&a(f));p&&(l[u]=a(p))}return l}const Ic="bwl.updateTranslation";class jp{constructor(t){this.moddle=t}execute(t){const{element:n,text:i,designLocale:o,locales:r,rootLang:a,nameChangedFrom:s}=t,c=n.businessObject,l=Ar(c),u=[];t.undo=u;const p=No(c).filter(k=>Rn(k)),f=s??(l?l.target[l.key]??"":""),d=a??o,h=(k=>{if(!k)return[];const H=p.filter(F=>F.body===k).map(Rn);return H.length?H:[d]})(f),m=s!==void 0&&f&&!h.includes(t.locale)?h[0]:t.locale,w=k=>{var H;return((H=p.find(F=>Rn(F)===k&&F.body))==null?void 0:H.body)??(h.includes(k)?f:"")},y=k=>$o(c).some(H=>H.locale===k),v=w(m);if(v===i)return[];const x=!!v&&!y(m),E=x?r.filter(k=>k!==m&&w(k)&&!y(k)):[],A=()=>{let k=c.extensionElements;return k||(k=this.moddle.create("bpmn:ExtensionElements",{values:[]}),k.$parent=c,c.extensionElements=k,u.push(()=>delete c.extensionElements)),k.get("values")},I=(k,H)=>{const F=A();let G=F.find(ee=>{var ce;return((ce=ee.$instanceOf)==null?void 0:ce.call(ee,Mr))&&Rn(ee)===k});if(G){const ee=G.body;G.body=H,u.push(()=>G.body=ee)}else G=this.moddle.create(Mr,{body:H}),G.set("xml:lang",k),G.$parent=c.extensionElements,F.push(G),u.push(()=>F.splice(F.indexOf(G),1))},P=k=>{const H=A(),F=H.indexOf(k);H.splice(F,1),u.push(()=>H.splice(F,0,k))};if(s===void 0){if(m===o&&l){if(f&&!p.some(H=>H.body===f)){const H=a&&a!==o?a:void 0;H&&I(H,f)}const k=Object.prototype.hasOwnProperty.call(l.target,l.key);l.target[l.key]=i,u.push(()=>{k?l.target[l.key]=f:delete l.target[l.key]})}I(m,i)}else(p.some(k=>Rn(k)===m)||!f&&m!==d)&&I(m,i);if(!x)for(const k of $o(c).filter(H=>H.locale===m))P(k);for(const k of E){const H=A(),F=this.moddle.create(Oc,{locale:k,sourceLocale:m,previous:v});F.$parent=c.extensionElements,H.push(F),u.push(()=>H.splice(H.indexOf(F),1))}for(const k of $o(c).filter(H=>H.sourceLocale===m&&(H.previous??"")===i))P(k);return u.length?[n,n.label].filter(Boolean):[]}revert(t){for(const n of[...t.undo].reverse())n();return t.undo.length?[t.element,t.element.label].filter(Boolean):[]}}$n(jp,"$inject",["moddle"]);const Hp="bwl.setTranslations",qS=(e,t)=>e.locale===t.locale&&(e.sourceLocale??void 0)===t.sourceLocale&&(e.previous??"")===t.previous;class zp{constructor(t){this.moddle=t}execute(t){const{element:n,texts:i,confirm:o=[],designLocale:r,locales:a,rootLang:s,before:c}=t,l=n.businessObject,u=[];if(t.undo=u,!Ar(l))return[];const p=()=>{let w=l.extensionElements;return w||(w=this.moddle.create("bpmn:ExtensionElements",{values:[]}),w.$parent=l,l.extensionElements=w,u.push(()=>delete l.extensionElements)),w.get("values")},f=w=>{const y=p(),v=y.indexOf(w);v<0||(y.splice(v,1),u.push(()=>y.splice(v,0,w)))},d=w=>No(l).find(y=>Rn(y)===w);if(i===null)for(const w of a){const y=d(w);y&&f(y)}else if(i)for(const w of a){const y=i[w];if(y===void 0)continue;const v=d(w);if(v){if(v.body===y)continue;const A=v.body;v.body=y,u.push(()=>v.body=A);continue}if(w===r&&(s??r)===r)continue;const x=p(),E=this.moddle.create(Mr,{body:y});E.set("xml:lang",w),E.$parent=l.extensionElements,x.push(E),u.push(()=>x.splice(x.indexOf(E),1))}const h=[...i===null?[]:c.requests.filter(w=>!o.includes(w.locale)&&!(i&&i[w.locale]!==void 0&&i[w.locale]!==c.texts[w.locale])&&!(i&&w.sourceLocale&&i[w.sourceLocale]===w.previous))];for(const w of $o(l)){const y=h.findIndex(v=>qS(w,v));y>=0?h.splice(y,1):f(w)}for(const w of h){const y=p(),v=this.moddle.create(Oc,{locale:w.locale,...w.sourceLocale?{sourceLocale:w.sourceLocale}:{},previous:w.previous});v.$parent=l.extensionElements,y.push(v),u.push(()=>y.splice(y.indexOf(v),1))}const m=l.extensionElements;return m&&!m.get("values").length&&(delete l.extensionElements,u.push(()=>l.extensionElements=m)),u.length?[n,n.label].filter(Boolean):[]}revert(t){for(const n of[...t.undo].reverse())n();return t.undo.length?[t.element,t.element.label].filter(Boolean):[]}}$n(zp,"$inject",["moddle"]);function Gp(e){return $o(e).map(t=>({locale:t.locale,...t.sourceLocale?{sourceLocale:t.sourceLocale}:{},previous:t.previous??""}))}class Vp{constructor(t){t.registerHandler(Ic,jp),t.registerHandler(Hp,zp)}}$n(Vp,"$inject",["commandStack"]);const Wp={__init__:["translationCommands"],translationCommands:["type",Vp]},im=["participant.add","participant.update","node.add","node.update","sequenceFlow.add","sequenceFlow.update","messageFlow.add","messageFlow.update","dataStore.add","dataStore.update","dataAssociation.add","association.add","annotation.add","annotation.update","group.add","group.update","translation.confirm","element.remove"],YS={description:"생략 = 보존, null = 제거.",anyOf:[{type:"string"},{type:"null"}]},KS={type:"object",description:"다국어 그룹의 문구 — 로케일 → 문구. **그 문서의 문서 언어(설계 + 병기 · describe 의 i18n) 전부**를 담는다(빠지거나 밖의 언어면 거부). 평문 name/text 와 함께 주면 거부. 문서 언어 설정이 없는 문서(describe 에 i18n 이 없다)는 이것 대신 평문을 쓴다.",properties:Object.fromEntries(kc.map(e=>[e,{type:"string"}])),additionalProperties:!1},XS={type:"object",description:"레인. 배열 선언 순서 = 풀 내 상→하 순서.",properties:{id:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"}},required:["id"],additionalProperties:!1},ZS={type:"object",description:"풀(participant). 레인은 여기 선언하고 노드가 lane 인자로 배정된다 — 별도 레인 op 없음.",properties:{id:{type:"string",description:"문서 내 유일, XML NCName(공백 없이 문자/밑줄로 시작)."},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},blackBox:{type:"boolean",description:"true = 내부 프로세스 없는 블랙박스 풀."},lanes:{type:"array",items:{$ref:"#/$defs/irLane"}}},required:["id"],additionalProperties:!1},QS={type:"string",enum:[...Pc],description:"이벤트 정의. **type 이 intermediateCatchEvent 일 때만 쓰고, 그때는 반드시 준다**(다른 타입에 주거나 빠뜨리면 거부). timer = 시한 대기(「30분 경과」·「확정 기간 경과」처럼 시간이 지나야 다음으로 가는 자리). 시한 값은 name 에 쓴다 — 표현식 필드는 없다."},JS={type:"object",description:"플로우 노드. 좌표는 지정하지 않는다 — 배치는 resolver 가 결정한다. ⚠ type 집합은 **읽을 수 있는 것보다 좁다** — describe 는 subProcess·boundaryEvent 도 노드로 내지만 그 둘을 새로 만드는 배치는 미실증이라 여기서 받지 않는다(B-87 ⓐ). intermediateCatchEvent 는 eventDefinition 과 짝으로만 받는다.",properties:{id:{type:"string"},type:{type:"string",enum:[...Ac]},eventDefinition:{$ref:"#/$defs/eventDefinition"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},participant:{type:"string",description:"소속 풀 id(협업 문서)."},lane:{type:"string",description:"소속 레인 id(풀 정의에 선언된 것)."}},required:["id","type"],additionalProperties:!1},eR={type:"object",description:"분기 조건 — 게이트웨이가 아닌 플로우에 붙인다. MVP 는 label 만. ⚠ 다국어 그룹(describe 에 i18n 이 있다)에서는 쓰지 않는다 — 조건 라벨도 그 플로우의 names 로 준다.",properties:{label:{type:"string"}},required:["label"],additionalProperties:!1},tR={type:"object",description:"시퀀스 플로우(같은 풀 안 노드 간).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},condition:{$ref:"#/$defs/irFlowCondition"}},required:["id","source","target"],additionalProperties:!1},nR={type:"object",description:"메시지 플로우(풀 경계를 넘는 연결 — 노드 또는 블랙박스 풀 자체가 끝점).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"}},required:["id","source","target"],additionalProperties:!1},iR={type:"object",properties:{id:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"}},required:["id"],additionalProperties:!1},oR={type:"object",description:"데이터 입출력 연관. 방향 = source→target(태스크→스토어 = 쓰기, 스토어→태스크 = 읽기).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"}},required:["source","target"],additionalProperties:!1},rR={type:"object",description:"텍스트 주석. 본문은 text(평문) 또는 texts(다국어 그룹) 중 하나를 반드시 준다.",properties:{id:{type:"string"},text:{type:"string"},texts:{$ref:"#/$defs/localeTexts"}},required:["id"],additionalProperties:!1},aR={type:"object",description:"연관선(주석 ↔ 요소).",properties:{id:{type:"string"},source:{type:"string"},target:{type:"string"}},required:["source","target"],additionalProperties:!1},sR={type:"object",description:"그룹 — members(요소 id 목록)가 bwl:members 힌트로 기록되고 바운즈는 멤버 bbox 로 산출된다.",properties:{id:{type:"string"},name:{type:"string"},names:{$ref:"#/$defs/localeTexts"},members:{type:"array",items:{type:"string"}}},required:["id"],additionalProperties:!1},cR={type:"object",description:"주석 방위 힌트 — 앵커 요소 기준 상대 배치. 있으면 결정적 배치, 없으면 휴리스틱.",properties:{anchor:{type:"string",description:"기준 요소 id."},side:{type:"string",enum:[...Dp]},offset:{type:"number",description:"앵커 가장자리 → 주석 가장자리 간격(px). 생략 시 50."}},required:["anchor","side"],additionalProperties:!1};function Pn(e,t){return{type:"object",description:t.description,properties:{kind:{const:e},...t.properties},required:["kind",...t.required??[]],additionalProperties:!1}}const lR={"participant.add":Pn("participant.add",{description:"풀 추가. order = 풀 세로 순서 힌트 — **작을수록 위**(생략 시 op 순서가 곧 배치 순서). 값은 상대 순서만 쓰므로 1,2,3… 연속이든 10,20,30 간격이든 같다.",properties:{participant:{$ref:"#/$defs/irParticipant"},order:{type:"integer"}},required:["participant"]}),"participant.update":Pn("participant.update",{description:"풀 이름/레인 갱신. lanes 는 전체 재선언(생략 = 보존) — 기존 레인을 유지하려면 함께 다시 나열한다.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},lanes:{type:"array",items:{$ref:"#/$defs/irLane"}}},required:["id"]}),"node.add":Pn("node.add",{description:'플로우 노드 추가. band = 가로 밴드 순번 힌트(주 흐름 0, 갈래 1, 2…) — 위/아래가 아니라 "주 흐름에서 몇 번째 갈래"다. 행 배치(어느 갈래가 위/아래인지)는 호스트가 정한다(대칭·메시지 방향). 레인이 있으면 그 레인 안의 밴드다 — 한 레인 안에서 게이트웨이 출구를 갈라 놓을 때 쓴다. 컨테이너(풀·레인)는 밴드 수만큼 자란다.',properties:{node:{$ref:"#/$defs/irNode"},band:{type:"integer",description:"0 이상 정수(음수는 payload-invalid 로 거부)."},afterColumn:{type:"string",description:"열 지목 힌트 — 그 노드보다 **뒤(오른쪽) 열**에 둔다. 좌표가 아니라 관계다(실제 x 는 호스트가 산출하고 정렬·압축은 그 뒤에도 적용된다). 🔴 **쓸 자리는 하나다 — 시퀀스 유입이 없는 수신 노드**(메시지만 받는 노드). 그런 노드는 열을 정할 근거가 도구에 없어 풀 좌단에 남고, 시간축(x)상 뒤쪽인 프로세스가 앞쪽에 놓여 선이 먼 거리를 돌아온다. 시퀀스로 이어지는 노드에는 쓰지 마라 — 열은 상류가 이미 정한다. 참조가 해소되지 않으면 힌트가 없는 것과 같이 동작한다."}},required:["node"]}),"node.update":Pn("node.update",{description:"노드 이름/레인/타입/밴드 갱신. lane = 레인 재배정(이동), type = 태스크·이벤트 타입 전환, band = 행 재지정. 🔴 **기존 문서에서 band 는 「몇 번째 갈래」가 아니라 그 컨테이너의 행 번호**다(describe 의 hints.bands 가 보여 주는 값) — 신규 배치의 band 가 대칭으로 펴지는 것과 다르다. 간선이 도형을 가로지르거나 반대 방향으로 겹칠 때 그 노드를 다른 행으로 옮기는 채널이다.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},lane:{type:"string"},type:{type:"string",enum:[...Ac]},eventDefinition:{$ref:"#/$defs/eventDefinition"},band:{type:"integer",description:"0 이상 정수(음수는 payload-invalid 로 거부)."}},required:["id"]}),"sequenceFlow.add":Pn("sequenceFlow.add",{description:"시퀀스 플로우 추가. 분기 조건은 게이트웨이가 아닌 플로우의 condition 에 싣는다.",properties:{flow:{$ref:"#/$defs/irSequenceFlow"}},required:["flow"]}),"sequenceFlow.update":Pn("sequenceFlow.update",{description:"시퀀스 플로우 이름/조건/끝점 갱신. condition: null = 조건 제거. source/target = 끝점 재배선 — 중간 삽입은 기존 플로우를 지우지 말고 이것으로 한쪽 끝을 옮긴 뒤 새 플로우를 추가한다.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},condition:{description:"생략 = 보존, null = 제거.",anyOf:[{$ref:"#/$defs/irFlowCondition"},{type:"null"}]},source:{description:"새 출발 노드 id(생략 = 보존). 같은 배치에서 추가한 노드도 지목할 수 있다.",type:"string"},target:{description:"새 도착 노드 id(생략 = 보존). 같은 배치에서 추가한 노드도 지목할 수 있다.",type:"string"}},required:["id"]}),"messageFlow.add":Pn("messageFlow.add",{description:"메시지 플로우 추가(풀 경계를 넘는 연결).",properties:{flow:{$ref:"#/$defs/irMessageFlow"}},required:["flow"]}),"messageFlow.update":Pn("messageFlow.update",{description:"메시지 플로우 이름 갱신.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"}},required:["id"]}),"dataStore.add":Pn("dataStore.add",{description:"데이터 스토어 추가(+ 입출력 연관 동반 가능).",properties:{dataStore:{$ref:"#/$defs/irDataStore"},associations:{type:"array",items:{$ref:"#/$defs/irDataAssociation"}}},required:["dataStore"]}),"dataStore.update":Pn("dataStore.update",{description:"데이터 스토어 이름 갱신.",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"}},required:["id"]}),"dataAssociation.add":Pn("dataAssociation.add",{description:"기존 노드 ↔ 기존 데이터 스토어의 입출력 연관 추가.",properties:{association:{$ref:"#/$defs/irDataAssociation"}},required:["association"]}),"association.add":Pn("association.add",{description:"주석 ↔ 요소 연관 추가(한쪽 끝은 주석). 주석 신설과 함께면 annotation.add 의 association 을 쓰고, 이 op 는 추가 연관(한 주석에 여러 연관)용.",properties:{association:{$ref:"#/$defs/irAssociation"}},required:["association"]}),"annotation.add":Pn("annotation.add",{description:"텍스트 주석 추가. association 으로 대상 요소와 연결하고, placement 로 방위를 지정하면 결정적 배치된다.",properties:{annotation:{$ref:"#/$defs/irTextAnnotation"},association:{$ref:"#/$defs/irAssociation"},placement:{$ref:"#/$defs/bwlPlacement"}},required:["annotation"]}),"annotation.update":Pn("annotation.update",{description:"주석 본문/방위 힌트 갱신. placement: null = 힌트 제거(휴리스틱 복귀). 주석 삭제는 element.remove.",properties:{id:{type:"string"},text:{type:"string"},texts:{$ref:"#/$defs/localeTexts"},placement:{description:"생략 = 보존, null = 힌트 제거.",anyOf:[{$ref:"#/$defs/bwlPlacement"},{type:"null"}]}},required:["id"]}),"group.add":Pn("group.add",{description:"그룹 추가 — 바운즈는 members 의 bbox 로 산출되므로 좌표를 지정하지 않는다.",properties:{group:{$ref:"#/$defs/irGroup"}},required:["group"]}),"group.update":Pn("group.update",{description:"그룹 이름/멤버 갱신. members 는 전체 재선언(생략 = 보존).",properties:{id:{type:"string"},name:{$ref:"#/$defs/nullableString"},names:{$ref:"#/$defs/localeTexts"},members:{type:"array",items:{type:"string"}}},required:["id"]}),"translation.confirm":Pn("translation.confirm",{description:"확인만 — 그 요소의 locale 칸에 걸린 확인 요청(describe 의 i18n.reviewRequests)을 문구를 바꾸지 않고 해소한다. 다른 언어가 고쳐졌지만(sourceLocale · previous → 지금 문구) 이 칸의 번역이 여전히 맞을 때(오타 수준) 쓴다. 번역을 고쳐야 하면 이것 대신 그 요소의 update 에 names/texts(문서 언어 전부)를 준다 — 문구가 실제로 바뀐 칸의 표식만 해소된다. 다국어 그룹에서만 받고, 그 칸에 표식이 없으면 거부한다.",properties:{id:{type:"string",description:"확인 요청이 걸린 요소 id."},locale:{type:"string",enum:[...kc],description:"확인 요청을 받은 칸의 언어(reviewRequests 의 locale)."}},required:["id","locale"]}),"element.remove":Pn("element.remove",{description:"요소 제거(카테고리 무관). 부착된 연결선은 함께 제거된다.",properties:{id:{type:"string"}},required:["id"]})},om={anyOf:im.map(e=>lR[e])},uR={type:"object",description:"BPMN 문서에 요소를 추가·수정·삭제할 때 호출한다. 기존 요소는 describeProcess 가 노출하는 id 로 지정하고, 신규 요소 id 는 문서 내 유일한 XML NCName(공백 없이 문자/밑줄 시작)으로 짓는다. 좌표는 지정하지 않는다 — 배치는 서버가 결정하며, 필요하면 힌트(placement/band/order)로 의도만 전달하라. 문서에 문서 언어 설정이 있으면(describe 의 i18n) 문구는 평문 name/text 가 아니라 names/texts 로 문서 언어 전부를 준다.",properties:{ops:{type:"array",items:{$ref:"#/$defs/symbolicOp"}}},required:["ops"],additionalProperties:!1,$defs:{irLane:XS,irParticipant:ZS,irNode:JS,irFlowCondition:eR,irSequenceFlow:tR,irMessageFlow:nR,irDataStore:iR,irDataAssociation:oR,irTextAnnotation:rR,irAssociation:aR,irGroup:sR,bwlPlacement:cR,eventDefinition:QS,localeTexts:KS,nullableString:YS,symbolicOp:om}};function Up(){}Up.prototype.get=function(e){return this.$model.properties.get(this,e)},Up.prototype.set=function(e,t){this.$model.properties.set(this,e,t)};function rm(e,t){this.model=e,this.properties=t}rm.prototype.createType=function(e){var t=this.model,n=this.properties,i=Object.create(Up.prototype);V(e.properties,function(a){!a.isMany&&a.default!==void 0&&(i[a.name]=a.default)}),n.defineModel(i,t),n.defineDescriptor(i,e);var o=e.ns.name;function r(a){n.define(this,"$type",{value:o,enumerable:!0}),n.define(this,"$attrs",{value:{}}),n.define(this,"$parent",{writable:!0}),V(a,Kn(function(s,c){this.set(c,s)},this))}return r.prototype=i,r.hasType=i.$instanceOf=this.model.hasType,n.defineModel(r,t),n.defineDescriptor(r,e),r};var pR=Y(Object.create(null),{String:!0,Boolean:!0,Integer:!0,Real:!0,Element:!0}),am=Y(Object.create(null),{String:function(e){return e},Boolean:function(e){return e==="true"},Integer:function(e){return parseInt(e,10)},Real:function(e){return parseFloat(e)}});function qp(e,t){var n=am[e];return n?n(t):t}function Yp(e){return!!pR[e]}function sm(e){return!!am[e]}function jn(e,t){var n=e.split(/:/),i,o;if(n.length===1)i=e,o=t;else if(n.length===2)i=n[1],o=n[0];else throw new Error("expected <prefix:localName> or <localName>, got "+e);return e=(o?o+":":"")+i,{name:e,prefix:o,localName:i}}function di(e){this.ns=e,this.name=e.name,this.allTypes=[],this.allTypesByName=Object.create(null),this.properties=[],this.propertiesByName=Object.create(null)}di.prototype.build=function(){return Ni(this,["ns","name","allTypes","allTypesByName","properties","propertiesByName","bodyProperty","idProperty"])},di.prototype.addProperty=function(e,t,n){typeof t=="boolean"&&(n=t,t=void 0),this.addNamedProperty(e,n!==!1);var i=this.properties;t!==void 0?i.splice(t,0,e):i.push(e)},di.prototype.replaceProperty=function(e,t,n){var i=e.ns,o=this.properties,r=this.propertiesByName,a=e.name!==t.name;if(e.isId){if(!t.isId)throw new Error("property <"+t.ns.name+"> must be id property to refine <"+e.ns.name+">");this.setIdProperty(t,!1)}if(e.isBody){if(!t.isBody)throw new Error("property <"+t.ns.name+"> must be body property to refine <"+e.ns.name+">");this.setBodyProperty(t,!1)}var s=o.indexOf(e);if(s===-1)throw new Error("property <"+i.name+"> not found in property list");o.splice(s,1),this.addProperty(t,n?void 0:s,a),r[i.name]=r[i.localName]=t},di.prototype.redefineProperty=function(e,t,n){var i=e.ns.prefix,o=t.split("#"),r=jn(o[0],i),a=jn(o[1],r.prefix).name,s=this.propertiesByName[a];if(s)this.replaceProperty(s,e,n);else throw new Error("refined property <"+a+"> not found");delete e.redefines},di.prototype.addNamedProperty=function(e,t){var n=e.ns,i=this.propertiesByName;t&&(this.assertNotDefined(e,n.name),this.assertNotDefined(e,n.localName)),i[n.name]=i[n.localName]=e},di.prototype.removeNamedProperty=function(e){var t=e.ns,n=this.propertiesByName;delete n[t.name],delete n[t.localName]},di.prototype.setBodyProperty=function(e,t){if(t&&this.bodyProperty)throw new Error("body property defined multiple times (<"+this.bodyProperty.ns.name+">, <"+e.ns.name+">)");this.bodyProperty=e},di.prototype.setIdProperty=function(e,t){if(t&&this.idProperty)throw new Error("id property defined multiple times (<"+this.idProperty.ns.name+">, <"+e.ns.name+">)");this.idProperty=e},di.prototype.assertNotTrait=function(e){if((e.extends||[]).length)throw new Error(`cannot create <${e.name}> extending <${e.extends}>`)},di.prototype.assertNotDefined=function(e,t){var n=e.name,i=this.propertiesByName[n];if(i)throw new Error("property <"+n+"> already defined; override of <"+i.definedBy.ns.name+"#"+i.ns.name+"> by <"+e.definedBy.ns.name+"#"+e.ns.name+"> not allowed without redefines")},di.prototype.hasProperty=function(e){return this.propertiesByName[e]},di.prototype.addTrait=function(e,t){t&&this.assertNotTrait(e);var n=this.allTypesByName,i=this.allTypes,o=e.name;o in n||(V(e.properties,Kn(function(r){r=Y({},r,{name:r.ns.localName,inherited:t}),Object.defineProperty(r,"definedBy",{value:e});var a=r.replaces,s=r.redefines;a||s?this.redefineProperty(r,a||s,a):(r.isBody&&this.setBodyProperty(r),r.isId&&this.setIdProperty(r),this.addProperty(r))},this)),i.push(e),n[o]=e)};function Fo(e,t){this.packageMap=Object.create(null),this.typeMap=Object.create(null),this.packages=[],this.properties=t,V(e,Kn(this.registerPackage,this))}Fo.prototype.getPackage=function(e){return this.packageMap[e]},Fo.prototype.getPackages=function(){return this.packages},Fo.prototype.registerPackage=function(e){e=Y({},e);var t=this.packageMap;cm(t,e,"prefix"),cm(t,e,"uri"),V(e.types,Kn(function(n){this.registerType(n,e)},this)),t[e.uri]=t[e.prefix]=e,this.packages.push(e)},Fo.prototype.registerType=function(e,t){e=Y({},e,{superClass:(e.superClass||[]).slice(),extends:(e.extends||[]).slice(),properties:(e.properties||[]).slice(),meta:Y({},e.meta||{})});var n=jn(e.name,t.prefix),i=n.name,o=Object.create(null);V(e.properties,Kn(function(r){var a=jn(r.name,n.prefix),s=a.name;Yp(r.type)||(r.type=jn(r.type,a.prefix).name),Y(r,{ns:a,name:s}),o[s]=r},this)),Y(e,{ns:n,name:i,propertiesByName:o}),V(e.extends,Kn(function(r){var a=jn(r,n.prefix),s=this.typeMap[a.name];s.traits=s.traits||[],s.traits.push(i)},this)),this.definePackage(e,t),this.typeMap[i]=e},Fo.prototype.mapTypes=function(e,t,n){var i=Yp(e.name)?{name:e.name}:this.typeMap[e.name],o=this;function r(c,l){var u=jn(c,Yp(c)?"":e.prefix);o.mapTypes(u,t,l)}function a(c){return r(c,!0)}function s(c){return r(c,!1)}if(!i)throw new Error("unknown type <"+e.name+">");V(i.superClass,n?a:s),t(i,!n),V(i.traits,a)},Fo.prototype.getEffectiveDescriptor=function(e){var t=jn(e),n=new di(t);this.mapTypes(t,function(o,r){n.addTrait(o,r)});var i=n.build();return this.definePackage(i,i.allTypes[i.allTypes.length-1].$pkg),i},Fo.prototype.definePackage=function(e,t){this.properties.define(e,"$pkg",{value:t})};function cm(e,t,n){var i=t[n];if(i in e)throw new Error("package with "+n+" <"+i+"> already defined")}function Pr(e){this.model=e}Pr.prototype.set=function(e,t,n){if(!ei(t)||!t.length)throw new TypeError("property name must be a non-empty string");var i=this.getProperty(e,t),o=i&&i.name;fR(n)?i?delete e[o]:delete e.$attrs[Kp(t)]:i?o in e?e[o]=n:lm(e,i,n):e.$attrs[Kp(t)]=n},Pr.prototype.get=function(e,t){var n=this.getProperty(e,t);if(!n)return e.$attrs[Kp(t)];var i=n.name;return!e[i]&&n.isMany&&lm(e,n,[]),e[i]},Pr.prototype.define=function(e,t,n){if(!n.writable){var i=n.value;n=Y({},n,{get:function(){return i}}),delete n.value}Object.defineProperty(e,t,n)},Pr.prototype.defineDescriptor=function(e,t){this.define(e,"$descriptor",{value:t})},Pr.prototype.defineModel=function(e,t){this.define(e,"$model",{value:t})},Pr.prototype.getProperty=function(e,t){var n=this.model,i=n.getPropertyDescriptor(e,t);if(i)return i;if(t.includes(":"))return null;const o=n.config.strict;if(typeof o<"u"){const r=new TypeError(`unknown property <${t}> on <${e.$type}>`);if(o)throw r;typeof console<"u"&&console.warn(r)}return null};function fR(e){return typeof e>"u"}function lm(e,t,n){Object.defineProperty(e,t.name,{enumerable:!t.isReference,writable:!0,value:n,configurable:!0})}function Kp(e){return e.replace(/^:/,"")}function xi(e,t={}){this.properties=new Pr(this),this.factory=new rm(this,this.properties),this.registry=new Fo(e,this.properties),this.typeCache=Object.create(null),this.config=t}xi.prototype.create=function(e,t){var n=this.getType(e);if(!n)throw new Error("unknown type <"+e+">");return new n(t)},xi.prototype.getType=function(e){var t=this.typeCache,n=ei(e)?e:e.ns.name,i=t[n];return i||(e=this.registry.getEffectiveDescriptor(n),i=t[n]=this.factory.createType(e)),i},xi.prototype.createAny=function(e,t,n){var i=jn(e),o={$type:e,$instanceOf:function(a){return a===this.$type},get:function(a){return this[a]},set:function(a,s){WS(this,[a],s)}},r={name:e,isGeneric:!0,ns:{prefix:i.prefix,localName:i.localName,uri:t}};return this.properties.defineDescriptor(o,r),this.properties.defineModel(o,this),this.properties.define(o,"get",{enumerable:!1,writable:!0}),this.properties.define(o,"set",{enumerable:!1,writable:!0}),this.properties.define(o,"$parent",{enumerable:!1,writable:!0}),this.properties.define(o,"$instanceOf",{enumerable:!1,writable:!0}),V(n,function(a,s){mn(a)&&a.value!==void 0?o[a.name]=a.value:o[s]=a}),o},xi.prototype.getPackage=function(e){return this.registry.getPackage(e)},xi.prototype.getPackages=function(){return this.registry.getPackages()},xi.prototype.getElementDescriptor=function(e){return e.$descriptor},xi.prototype.hasType=function(e,t){t===void 0&&(t=e,e=this);var n=e.$model.getElementDescriptor(e);return t in n.allTypesByName},xi.prototype.getPropertyDescriptor=function(e,t){return this.getElementDescriptor(e).propertiesByName[t]},xi.prototype.getTypeDescriptor=function(e){return this.registry.typeMap[e]};var um=String.fromCharCode,dR=Object.prototype.hasOwnProperty,hR=/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig,cs={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'};Object.keys(cs).forEach(function(e){cs[e.toUpperCase()]=cs[e]});function gR(e,t,n,i){return i?dR.call(cs,i)?cs[i]:"&"+i+";":um(t||parseInt(n,16))}function Tr(e){return e.length>3&&e.indexOf("&")!==-1?e.replace(hR,gR):e}var pm="non-whitespace outside of root node";function jo(e){return new Error(e)}function mR(e){return"missing namespace for prefix <"+e+">"}function Bc(e){return{get:e,enumerable:!0}}function yR(e){var t=Object.create(null),n;for(n in e)t[n]=e[n];return t}var fm=Symbol("nameCache");function Xp(e){return e+"$uri"}function vR(e){var t=Object.create(null),n,i;for(n in e)i=e[n],t[i]=i,t[Xp(i)]=n;return t}function Nc(){return{line:0,column:0}}function bR(e){throw e}function dm(e){if(!this)return new dm(e);var t=e&&e.proxy,n,i,o,r,a=bR,s,c,l,u,p=Nc,f=!1,d=!1,g="",h=!1,m=!1,w=null,y=!1,v,x,E,A;function I(F){F instanceof Error||(F=jo(F)),w=F,a(F,p)}function P(F){s&&(F instanceof Error||(F=jo(F)),s(F,p))}this.on=function(F,G){if(typeof G!="function")throw jo("required args <name, cb>");switch(F){case"openTag":i=G;break;case"text":n=G;break;case"closeTag":o=G;break;case"error":a=G;break;case"warn":s=G;break;case"cdata":r=G;break;case"attention":u=G;break;case"question":l=G;break;case"comment":c=G;break;default:throw jo("unsupported event: "+F)}return this},this.ns=function(F){if(typeof F>"u"&&(F={}),typeof F!="object")throw jo("required args <nsMap={}>");var G=Object.create(null),ee;for(ee in F)G[ee]=F[ee];return m=!0,A=G,this};function k(){v=m?[]:null,x=m?vR(A):null,E=[],p=Nc,y=!1,w=null,d=!1,g=""}this.parse=function(F){if(typeof F!="string")throw jo("required args <xml=string>");if(f)throw jo("parse during stream; call end() first");return k(),H(F),p=Nc,y=!1,w},this.write=function(F){if(typeof F!="string")throw jo("required args <xml=string>");return f||(k(),f=!0),w||(g=H(g+F,!0)||""),this},this.end=function(){return f||k(),f=!1,w||H(g),g="",p=Nc,y=!1,w},this.stop=function(){y=!0};function H(F,G=!1){var ee=null,ce=null,ie,be=0,he=!1,ye=!1,Ee=0,U=0,ue,K,J,ge,Re,ze,$,C,R,W="",q=0,fe;function Oe(St,nn){var An=St.indexOf(":");if(An===-1)return St;var Vn=x[St.substring(0,An)];return Vn?nn===Vn?St.substr(An+1):Vn+St.substr(An):(P(mR(St.substring(0,An))),null)}function nt(){if(fe!==null)return fe;var St,nn,An=m&&x.xmlns,Vn=m&&h?[]:null,Tt=q,$t=W,xn=$t.length,vr,Qn,Jn,bi,hn,Do={},Qa=new Set,pi,xt,Rt;e:for(;Tt<xn;Tt++)if(pi=!1,xt=$t.charCodeAt(Tt),!(xt===32||xt<14&&xt>8)){for((xt<65||xt>122||xt>90&&xt<97)&&xt!==95&&xt!==58&&(P("illegal first char attribute name"),pi=!0),Rt=Tt+1;Rt<xn;Rt++)if(xt=$t.charCodeAt(Rt),!(xt>96&&xt<123||xt>64&&xt<91||xt>47&&xt<59||xt===46||xt===45||xt===95)){if(xt===32||xt<14&&xt>8){P("missing attribute value"),Tt=Rt;continue e}if(xt===61)break;P("illegal attribute name char"),pi=!0}if(hn=$t.substring(Tt,Rt),hn==="xmlns:xmlns"&&(P("illegal declaration of xmlns"),pi=!0),xt=$t.charCodeAt(Rt+1),xt===34)Rt=$t.indexOf('"',Tt=Rt+2),Rt===-1&&(Rt=$t.indexOf("'",Tt),Rt!==-1&&(P("attribute value quote missmatch"),pi=!0));else if(xt===39)Rt=$t.indexOf("'",Tt=Rt+2),Rt===-1&&(Rt=$t.indexOf('"',Tt),Rt!==-1&&(P("attribute value quote missmatch"),pi=!0));else for(P("missing attribute value quotes"),pi=!0,Rt=Rt+1;Rt<xn&&(xt=$t.charCodeAt(Rt+1),!(xt===32||xt<14&&xt>8));Rt++);for(Rt===-1&&(P("missing closing quotes"),Rt=xn,pi=!0),pi||(Jn=$t.substring(Tt,Rt)),Tt=Rt;Rt+1<xn&&(xt=$t.charCodeAt(Rt+1),!(xt===32||xt<14&&xt>8));Rt++)Tt===Rt&&(P("illegal character after attribute end"),pi=!0);if(Tt=Rt+1,pi)continue e;if(Qa.has(hn)){P("attribute <"+hn+"> already defined");continue}if(Qa.add(hn),!m){Do[hn]=Jn;continue}if(h){if(Qn=hn==="xmlns"?"xmlns":hn.charCodeAt(0)===120&&hn.substr(0,6)==="xmlns:"?hn.substr(6):null,Qn!==null){if(St=Tr(Jn),nn=Xp(Qn),bi=A[St],!bi){if(Qn==="xmlns"||nn in x&&x[nn]!==St)do bi="ns"+be++;while(typeof x[bi]<"u");else bi=Qn;A[St]=bi}x[Qn]!==bi&&(vr||(x=yR(x),vr=!0),x[Qn]=bi,Qn==="xmlns"&&(x[Xp(bi)]=St,An=bi),x[nn]=St),Do[hn]=Jn;continue}Vn.push(hn,Jn);continue}hn=Oe(hn,An),hn!==null&&(Do[hn]=Jn)}if(h)for(Tt=0,xn=Vn.length;Tt<xn;Tt++)hn=Oe(Vn[Tt++],An),Jn=Vn[Tt],hn!==null&&(Do[hn]=Jn);return fe=Do}function lt(){for(var St=/(\r\n|\r|\n)/g,nn=0,An=0,Vn=0,Tt=U,$t,xn;Ee>=Vn&&($t=St.exec(F),!(!$t||(Tt=$t[0].length+$t.index,Tt>Ee)));)nn+=1,Vn=Tt;return Ee==-1?(An=Tt,xn=F.substring(U)):U===0?xn=F.substring(U,Ee):(An=Ee-Vn,xn=U==-1?F.substring(Ee):F.substring(Ee,U+1)),{data:xn,line:nn,column:An}}for(p=lt,t&&(R=Object.create({},{name:Bc(function(){return $}),originalName:Bc(function(){return C}),attrs:Bc(nt),ns:Bc(function(){return x})}));U!==-1;){if(F.charCodeAt(U)===60?Ee=U:Ee=F.indexOf("<",U),Ee===-1){if(G)return F.substring(U);if(E.length)return I("unexpected end of file");if(!d)return I("missing start tag");U<F.length&&F.substring(U).trim()&&P(pm);return}if(d||(d=!0),U!==Ee){if(E.length){if(n&&(n(F.substring(U,Ee),Tr,p),y))return}else if(F.substring(U,Ee).trim()&&(P(pm),y))return}if(ge=F.charCodeAt(Ee+1),ge===33){if(J=F.charCodeAt(Ee+2),J===91&&F.substr(Ee+3,6)==="CDATA["){if(U=F.indexOf("]]>",Ee),U===-1)return G?F.substring(Ee):I("unclosed cdata");if(r&&(r(F.substring(Ee+9,U),p),y))return;U+=3;continue}if(J===45&&F.charCodeAt(Ee+3)===45){if(U=F.indexOf("-->",Ee),U===-1)return G?F.substring(Ee):I("unclosed comment");if(c&&(c(F.substring(Ee+4,U),Tr,p),y))return;U+=3;continue}}if(ge===63){if(U=F.indexOf("?>",Ee),U===-1)return G?F.substring(Ee):I("unclosed question");if(l&&(l(F.substring(Ee,U+2),p),y))return;U+=2;continue}for(ue=Ee+1;;ue++){if(Re=F.charCodeAt(ue),isNaN(Re))return G?F.substring(Ee):(U=-1,I("unclosed tag"));if(Re===34)J=F.indexOf('"',ue+1),ue=J!==-1?J:ue;else if(Re===39)J=F.indexOf("'",ue+1),ue=J!==-1?J:ue;else if(Re===62){U=ue;break}}if(ge===33){if(u&&(u(F.substring(Ee,U+1),Tr,p),y))return;U+=1;continue}if(fe={},ge===47){if(he=!1,ye=!0,!E.length)return I("missing open tag");if(ue=$=E.pop(),J=Ee+2+ue.length,F.substring(Ee+2,J)!==ue)return I("closing tag mismatch");for(;J<U;J++)if(ge=F.charCodeAt(J),!(ge===32||ge>8&&ge<14))return I("close tag")}else{if(F.charCodeAt(U-1)===47?(ue=$=F.substring(Ee+1,U-1),he=!0,ye=!0):(ue=$=F.substring(Ee+1,U),he=!0,ye=!1),!(ge>96&&ge<123||ge>64&&ge<91||ge===95||ge===58))return I("illegal first char nodeName");for(J=1,K=ue.length;J<K;J++)if(ge=ue.charCodeAt(J),!(ge>96&&ge<123||ge>64&&ge<91||ge>47&&ge<59||ge===45||ge===95||ge==46)){if(ge===32||ge<14&&ge>8){$=ue.substring(0,J),fe=null;break}return I("invalid nodeName")}ye||E.push($)}if(m){ie=x,he&&(ye||v.push(ie),fe===null&&(h=ue.indexOf("xmlns",J)!==-1)&&(q=J,W=ue,nt(),h=!1)),C=$,ce!==x&&(ee=x[fm],ee===void 0&&(ee=x[fm]=Object.create(null)),ce=x);var Vt=ee[$];if(Vt!==void 0)$=Vt;else{if(ge=$.indexOf(":"),ge!==-1){if(ze=x[$.substring(0,ge)],!ze)return I("missing namespace on <"+C+">");$=$.substr(ge+1)}else ze=x.xmlns;ze&&($=ze+":"+$),ee[C]=$}}if(he&&(q=J,W=ue,i&&(t?i(R,Tr,ye,p):i($,nt,Tr,ye,p),y)))return;if(ye){if(o&&(o(t?R:$,Tr,he,p),y))return;m&&(he?x=ie:x=v.pop())}U+=1}}}function hm(e){return e.xml&&e.xml.tagAlias==="lowerCase"}var Zp={xsi:"http://www.w3.org/2001/XMLSchema-instance",xml:"http://www.w3.org/XML/1998/namespace"},gm="property";function mm(e){return e.xml&&e.xml.serialize}function xR(e){const t=mm(e);return t!==gm&&(t||null)}function wR(e){return e.charAt(0).toUpperCase()+e.slice(1)}function ym(e,t){return hm(t)?e.prefix+":"+wR(e.localName):e.name}function _R(e,t){var n=e.name,i=e.localName,o=t&&t.xml&&t.xml.typePrefix;return o&&i.indexOf(o)===0?e.prefix+":"+i.slice(o.length):n}function ER(e,t,n){const i=jn(e,t.xmlns),o=`${t[i.prefix]||i.prefix}:${i.localName}`,r=jn(o);var a=n.getPackage(r.prefix);return _R(r,a)}function Ho(e){return new Error(e)}function ho(e){return e.$descriptor}function SR(e){Y(this,e),this.elementsById={},this.references=[],this.warnings=[],this.addReference=function(t){this.references.push(t)},this.addElement=function(t){if(!t)throw Ho("expected element");var n=this.elementsById,i=ho(t),o=i.idProperty,r;if(o&&(r=t.get(o.name),r)){if(!/^([a-z][\w-.]*:)?[a-z_][\w-.]*$/i.test(r))throw new Error("illegal ID <"+r+">");if(n[r])throw Ho("duplicate ID <"+r+">");n[r]=t}},this.addWarning=function(t){this.warnings.push(t)}}function ls(){}ls.prototype.handleEnd=function(){},ls.prototype.handleText=function(){},ls.prototype.handleNode=function(){};function Qp(){}Qp.prototype=Object.create(ls.prototype),Qp.prototype.handleNode=function(){return this};function la(){}la.prototype=Object.create(ls.prototype),la.prototype.handleText=function(e){this.body=(this.body||"")+e};function us(e,t){this.property=e,this.context=t}us.prototype=Object.create(la.prototype),us.prototype.handleNode=function(e){if(this.element)throw Ho("expected no sub nodes");return this.element=this.createReference(e),this},us.prototype.handleEnd=function(){this.element.id=this.body},us.prototype.createReference=function(e){return{property:this.property.ns.name,id:""}};function Jp(e,t){this.element=t,this.propertyDesc=e}Jp.prototype=Object.create(la.prototype),Jp.prototype.handleEnd=function(){var e=this.body||"",t=this.element,n=this.propertyDesc;e=qp(n.type,e),n.isMany?t.get(n.name).push(e):t.set(n.name,e)};function $c(){}$c.prototype=Object.create(la.prototype),$c.prototype.handleNode=function(e){var t=this,n=this.element;return n?t=this.handleChild(e):(n=this.element=this.createElement(e),this.context.addElement(n)),t};function Wn(e,t,n){this.model=e,this.type=e.getType(t),this.context=n}Wn.prototype=Object.create($c.prototype),Wn.prototype.addReference=function(e){this.context.addReference(e)},Wn.prototype.handleText=function(e){var t=this.element,n=ho(t),i=n.bodyProperty;if(!i)throw Ho("unexpected body text <"+e+">");la.prototype.handleText.call(this,e)},Wn.prototype.handleEnd=function(){var e=this.body,t=this.element,n=ho(t),i=n.bodyProperty;i&&e!==void 0&&(e=qp(i.type,e),t.set(i.name,e))},Wn.prototype.createElement=function(e){var t=e.attributes,n=this.type,i=ho(n),o=this.context,r=new n({}),a=this.model,s;return V(t,function(c,l){var u=i.propertiesByName[l],p;u&&u.isReference?u.isMany?(p=c.split(" "),V(p,function(f){o.addReference({element:r,property:u.ns.name,id:f})})):o.addReference({element:r,property:u.ns.name,id:c}):(u?c=qp(u.type,c):l==="xmlns"?l=":"+l:(s=jn(l,i.ns.prefix),a.getPackage(s.prefix)&&o.addWarning({message:"unknown attribute <"+l+">",element:r,property:l,value:c})),r.set(l,c))}),r},Wn.prototype.getPropertyForNode=function(e){var t=e.name,n=jn(t),i=this.type,o=this.model,r=ho(i),a=n.name,s=r.propertiesByName[a];if(s&&!s.isAttr){const l=xR(s);if(l){const u=e.attributes[l];if(u){const p=ER(u,e.ns,o),f=o.getType(p);return Y({},s,{effectiveType:ho(f).name})}}return s}var c=o.getPackage(n.prefix);if(c){const l=ym(n,c),u=o.getType(l);if(s=It(r.properties,function(p){return!p.isVirtual&&!p.isReference&&!p.isAttribute&&u.hasType(p.type)}),s)return Y({},s,{effectiveType:ho(u).name})}else if(s=It(r.properties,function(l){return!l.isReference&&!l.isAttribute&&l.type==="Element"}),s)return s;throw Ho("unrecognized element <"+n.name+">")},Wn.prototype.toString=function(){return"ElementDescriptor["+ho(this.type).name+"]"},Wn.prototype.valueHandler=function(e,t){return new Jp(e,t)},Wn.prototype.referenceHandler=function(e){return new us(e,this.context)},Wn.prototype.handler=function(e){return e==="Element"?new ua(this.model,e,this.context):new Wn(this.model,e,this.context)},Wn.prototype.handleChild=function(e){var t,n,i,o;if(t=this.getPropertyForNode(e),i=this.element,n=t.effectiveType||t.type,sm(n))return this.valueHandler(t,i);t.isReference?o=this.referenceHandler(t).handleNode(e):o=this.handler(n).handleNode(e);var r=o.element;return r!==void 0&&(t.isMany?i.get(t.name).push(r):i.set(t.name,r),t.isReference?(Y(r,{element:i}),this.context.addReference(r)):r.$parent=i),o};function ef(e,t,n){Wn.call(this,e,t,n)}ef.prototype=Object.create(Wn.prototype),ef.prototype.createElement=function(e){var t=e.name,n=jn(t),i=this.model,o=this.type,r=i.getPackage(n.prefix),a=r&&ym(n,r)||t;if(!o.hasType(a))throw Ho("unexpected element <"+e.originalName+">");return Wn.prototype.createElement.call(this,e)};function ua(e,t,n){this.model=e,this.context=n}ua.prototype=Object.create($c.prototype),ua.prototype.createElement=function(e){var t=e.name,n=jn(t),i=n.prefix,o=e.ns[i+"$uri"],r=e.attributes;return this.model.createAny(t,o,r)},ua.prototype.handleChild=function(e){var t=new ua(this.model,"Element",this.context).handleNode(e),n=this.element,i=t.element,o;return i!==void 0&&(o=n.$children=n.$children||[],o.push(i),i.$parent=n),t},ua.prototype.handleEnd=function(){this.body&&(this.element.$body=this.body)};function tf(e){e instanceof xi&&(e={model:e}),Y(this,{lax:!1},e)}tf.prototype.fromXML=function(e,t,n){var i=t.rootHandler;t instanceof Wn?(i=t,t={}):typeof t=="string"?(i=this.handler(t),t={}):typeof i=="string"&&(i=this.handler(i));var o=this.model,r=this.lax,a=new SR(Y({},t,{rootHandler:i})),s=new dm({proxy:!0}),c=RR();i.context=a,c.push(i);function l(E,A,I){var P=A(),k=P.line,H=P.column,F=P.data;F.charAt(0)==="<"&&F.indexOf(" ")!==-1&&(F=F.slice(0,F.indexOf(" "))+">");var G="unparsable content "+(F?F+" ":"")+`detected
2
2
  line: `+k+`
3
3
  column: `+H+`
4
- nested error: `+E.message;if(B)return a.addWarning({message:G,error:E}),!0;throw Ho(G)}function u(E,A){return l(E,A,!0)}function p(){var E=a.elementsById,A=a.references,B,P;for(B=0;P=A[B];B++){var k=P.element,H=E[P.id],F=ho(k).propertiesByName[P.property];if(H||a.addWarning({message:"unresolved reference <"+P.id+">",element:P.element,property:P.property,value:P.id}),F.isMany){var G=k.get(F.name),ee=G.indexOf(P);ee===-1&&(ee=G.length),H?G[ee]=H:G.splice(ee,1)}else k.set(F.name,H)}}function f(){c.pop().handleEnd()}var d=/^<\?xml /i,g=/ encoding="([^"]+)"/i,h=/^utf-8$/i;function m(E){if(d.test(E)){var A=g.exec(E),B=A&&A[1];!B||h.test(B)||a.addWarning({message:"unsupported document encoding <"+B+">, falling back to UTF-8"})}}function w(E,A){var B=c.peek();try{c.push(B.handleNode(E))}catch(P){l(P,A,r)&&c.push(new Qp)}}function y(E,A){try{c.peek().handleText(E)}catch(B){u(B,A)}}function v(E,A){E.trim()&&y(E,A)}var x=o.getPackages().reduce(function(E,A){return E[A.uri]=A.prefix,E},Object.entries(Zp).reduce(function(E,[A,B]){return E[B]=A,E},o.config&&o.config.nsMap||{}));return s.ns(x).on("openTag",function(E,A,B,P){var k=E.attrs||{},H=Object.keys(k).reduce(function(G,ee){var ce=A(k[ee]);return G[ee]=ce,G},{}),F={name:E.name,originalName:E.originalName,attributes:H,ns:E.ns};w(F,P)}).on("question",m).on("closeTag",f).on("cdata",y).on("text",function(E,A,B){v(A(E),B)}).on("error",l).on("warn",u),new Promise(function(E,A){var B;try{s.parse(e),p()}catch(G){B=G}var P=i.element;!B&&!P&&(B=Ho("failed to parse document as <"+i.type.$descriptor.name+">"));var k=a.warnings,H=a.references,F=a.elementsById;return B?(B.warnings=k,A(B)):E({rootElement:P,elementsById:F,references:H,warnings:k})})},tf.prototype.handler=function(e){return new ef(this.model,e)};function RR(){var e=[];return Object.defineProperty(e,"peek",{value:function(){return this[this.length-1]}}),e}var CR=`<?xml version="1.0" encoding="UTF-8"?>
4
+ nested error: `+E.message;if(I)return a.addWarning({message:G,error:E}),!0;throw Ho(G)}function u(E,A){return l(E,A,!0)}function p(){var E=a.elementsById,A=a.references,I,P;for(I=0;P=A[I];I++){var k=P.element,H=E[P.id],F=ho(k).propertiesByName[P.property];if(H||a.addWarning({message:"unresolved reference <"+P.id+">",element:P.element,property:P.property,value:P.id}),F.isMany){var G=k.get(F.name),ee=G.indexOf(P);ee===-1&&(ee=G.length),H?G[ee]=H:G.splice(ee,1)}else k.set(F.name,H)}}function f(){c.pop().handleEnd()}var d=/^<\?xml /i,g=/ encoding="([^"]+)"/i,h=/^utf-8$/i;function m(E){if(d.test(E)){var A=g.exec(E),I=A&&A[1];!I||h.test(I)||a.addWarning({message:"unsupported document encoding <"+I+">, falling back to UTF-8"})}}function w(E,A){var I=c.peek();try{c.push(I.handleNode(E))}catch(P){l(P,A,r)&&c.push(new Qp)}}function y(E,A){try{c.peek().handleText(E)}catch(I){u(I,A)}}function v(E,A){E.trim()&&y(E,A)}var x=o.getPackages().reduce(function(E,A){return E[A.uri]=A.prefix,E},Object.entries(Zp).reduce(function(E,[A,I]){return E[I]=A,E},o.config&&o.config.nsMap||{}));return s.ns(x).on("openTag",function(E,A,I,P){var k=E.attrs||{},H=Object.keys(k).reduce(function(G,ee){var ce=A(k[ee]);return G[ee]=ce,G},{}),F={name:E.name,originalName:E.originalName,attributes:H,ns:E.ns};w(F,P)}).on("question",m).on("closeTag",f).on("cdata",y).on("text",function(E,A,I){v(A(E),I)}).on("error",l).on("warn",u),new Promise(function(E,A){var I;try{s.parse(e),p()}catch(G){I=G}var P=i.element;!I&&!P&&(I=Ho("failed to parse document as <"+i.type.$descriptor.name+">"));var k=a.warnings,H=a.references,F=a.elementsById;return I?(I.warnings=k,A(I)):E({rootElement:P,elementsById:F,references:H,warnings:k})})},tf.prototype.handler=function(e){return new ef(this.model,e)};function RR(){var e=[];return Object.defineProperty(e,"peek",{value:function(){return this[this.length-1]}}),e}var CR=`<?xml version="1.0" encoding="UTF-8"?>
5
5
  `,MR=/<|>|'|"|&|\n\r|\n/g,vm=/<|>|&/g;function Ki(e){this.prefixMap={},this.uriMap={},this.used={},this.wellknown=[],this.custom=[],this.parent=e,this.defaultPrefixMap=e&&e.defaultPrefixMap||{}}Ki.prototype.mapDefaultPrefixes=function(e){this.defaultPrefixMap=e},Ki.prototype.defaultUriByPrefix=function(e){return this.defaultPrefixMap[e]},Ki.prototype.byUri=function(e){return this.uriMap[e]||this.parent&&this.parent.byUri(e)},Ki.prototype.add=function(e,t){this.uriMap[e.uri]=e,t?this.wellknown.push(e):this.custom.push(e),this.mapPrefix(e.prefix,e.uri)},Ki.prototype.uriByPrefix=function(e){return this.prefixMap[e||"xmlns"]||this.parent&&this.parent.uriByPrefix(e)},Ki.prototype.mapPrefix=function(e,t){this.prefixMap[e||"xmlns"]=t},Ki.prototype.getNSKey=function(e){return e.prefix!==void 0?e.uri+"|"+e.prefix:e.uri},Ki.prototype.logUsed=function(e){var t=e.uri,n=this.getNSKey(e);this.used[n]=this.byUri(t),this.parent&&this.parent.logUsed(e)},Ki.prototype.getUsed=function(e){var t=[].concat(this.wellknown,this.custom);return t.filter(n=>{var i=this.getNSKey(n);return this.used[i]})};function AR(e){return e.charAt(0).toLowerCase()+e.slice(1)}function PR(e,t){return hm(t)?AR(e):e}function bm(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function xm(e){return ei(e)?e:(e.prefix?e.prefix+":":"")+e.localName}function TR(e){return e.getUsed().filter(function(t){return t.prefix!=="xml"}).map(function(t){var n="xmlns"+(t.prefix?":"+t.prefix:"");return{name:n,value:t.uri}})}function kR(e,t){return t.isGeneric?Y({localName:t.ns.localName},e):Y({localName:PR(t.ns.localName,t.$pkg)},e)}function OR(e,t){return Y({localName:t.ns.localName},e)}function DR(e){var t=e.$descriptor;return ct(t.properties,function(n){var i=n.name;if(n.isVirtual||!ti(e,i))return!1;var o=e[i];return o===n.default||o===null?!1:n.isMany?o.length:!0})}var LR={"\n":"#10","\n\r":"#10",'"':"#34","'":"#39","<":"#60",">":"#62","&":"#38"},IR={"<":"lt",">":"gt","&":"amp"};function wm(e,t,n){return e=ei(e)?e:""+e,e.replace(t,function(i){return"&"+n[i]+";"})}function BR(e){return wm(e,MR,LR)}function NR(e){return wm(e,vm,IR)}function $R(e){return ct(e,function(t){return t.isAttr})}function FR(e){return ct(e,function(t){return!t.isAttr})}function nf(e){this.tagName=e}nf.prototype.build=function(e){return this.element=e,this},nf.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"+this.element.id+"</"+this.tagName+">").appendNewLine()};function kr(){}kr.prototype.serializeValue=kr.prototype.serializeTo=function(e){e.append(this.escape?NR(this.value):this.value)},kr.prototype.build=function(e,t){return this.value=t,e.type==="String"&&t.search(vm)!==-1&&(this.escape=!0),this};function of(e){this.tagName=e}bm(of,kr),of.prototype.serializeTo=function(e){e.appendIndent().append("<"+this.tagName+">"),this.serializeValue(e),e.append("</"+this.tagName+">").appendNewLine()};function Gt(e,t){this.body=[],this.attrs=[],this.parent=e,this.propertyDescriptor=t}Gt.prototype.build=function(e){this.element=e;var t=e.$descriptor,n=this.propertyDescriptor,i,o,r=t.isGeneric;return r?i=this.parseGenericNsAttributes(e):i=this.parseNsAttributes(e),n?this.ns=this.nsPropertyTagName(n):this.ns=this.nsTagName(t),this.tagName=this.addTagName(this.ns),r?this.parseGenericContainments(e):(o=DR(e),this.parseAttributes($R(o)),this.parseContainments(FR(o))),this.parseGenericAttributes(e,i),this},Gt.prototype.nsTagName=function(e){var t=this.logNamespaceUsed(e.ns);return kR(t,e)},Gt.prototype.nsPropertyTagName=function(e){var t=this.logNamespaceUsed(e.ns);return OR(t,e)},Gt.prototype.isLocalNs=function(e){return e.uri===this.ns.uri},Gt.prototype.nsAttributeName=function(e){var t;if(ei(e)?t=jn(e):t=e.ns,e.inherited)return{localName:t.localName};var n=this.logNamespaceUsed(t);return this.getNamespaces().logUsed(n),this.isLocalNs(n)?{localName:t.localName}:Y({localName:t.localName},n)},Gt.prototype.parseGenericNsAttributes=function(e){return Object.entries(e).filter(([t,n])=>!t.startsWith("$")&&this.parseNsAttribute(e,t,n)).map(([t,n])=>({name:t,value:n}))},Gt.prototype.parseGenericContainments=function(e){var t=e.$body;t&&this.body.push(new kr().build({type:"String"},t));var n=e.$children;n&&V(n,i=>{this.body.push(new Gt(this).build(i))})},Gt.prototype.parseNsAttribute=function(e,t,n){var i=e.$model,o=jn(t),r;if(o.prefix==="xmlns"&&(r={prefix:o.localName,uri:n}),!o.prefix&&o.localName==="xmlns"&&(r={uri:n}),!r)return{name:t,value:n};if(i&&i.getPackage(n))this.logNamespace(r,!0,!0);else{var a=this.logNamespaceUsed(r,!0);this.getNamespaces().logUsed(a)}},Gt.prototype.parseNsAttributes=function(e){var t=this,n=e.$attrs,i=[];return V(n,function(o,r){var a=t.parseNsAttribute(e,r,o);a&&i.push(a)}),i},Gt.prototype.parseGenericAttributes=function(e,t){var n=this;V(t,function(i){try{n.addAttribute(n.nsAttributeName(i.name),i.value)}catch(o){typeof console<"u"&&console.warn(`missing namespace information for <${i.name}=${i.value}> on`,e,o)}})},Gt.prototype.parseContainments=function(e){var t=this,n=this.body,i=this.element;V(e,function(o){var r=i.get(o.name),a=o.isReference,s=o.isMany;if(s||(r=[r]),o.isBody)n.push(new kr().build(o,r[0]));else if(sm(o.type))V(r,function(l){n.push(new of(t.addTagName(t.nsPropertyTagName(o))).build(o,l))});else if(a)V(r,function(l){n.push(new nf(t.addTagName(t.nsPropertyTagName(o))).build(l))});else{var c=mm(o);V(r,function(l){var u;c?c===gm?u=new Gt(t,o):u=new Fc(t,o,c):u=new Gt(t),n.push(u.build(l))})}})},Gt.prototype.getNamespaces=function(e){var t=this.namespaces,n=this.parent,i;return t||(i=n&&n.getNamespaces(),e||!i?this.namespaces=t=new Ki(i):t=i),t},Gt.prototype.logNamespace=function(e,t,n){var i=this.getNamespaces(n),o=e.uri,r=e.prefix,a=i.byUri(o);return(!a||n)&&i.add(e,t),i.mapPrefix(r,o),e},Gt.prototype.logNamespaceUsed=function(e,t){var n=this.getNamespaces(t),i=e.prefix,o=e.uri,r,a,s;if(!i&&!o)return{localName:e.localName};if(s=n.defaultUriByPrefix(i),o=o||s||n.uriByPrefix(i),!o)throw new Error("no namespace uri given for prefix <"+i+">");if(e=n.byUri(o),!e&&!i&&(e=this.logNamespace({uri:o},s===o,!0)),!e){for(r=i,a=1;n.uriByPrefix(r);)r=i+"_"+a++;e=this.logNamespace({prefix:r,uri:o},s===o)}return i&&n.mapPrefix(i,o),e},Gt.prototype.parseAttributes=function(e){var t=this,n=this.element;V(e,function(i){var o=n.get(i.name);if(i.isReference)if(!i.isMany)o=o.id;else{var r=[];V(o,function(a){r.push(a.id)}),o=r.join(" ")}t.addAttribute(t.nsAttributeName(i),o)})},Gt.prototype.addTagName=function(e){var t=this.logNamespaceUsed(e);return this.getNamespaces().logUsed(t),xm(e)},Gt.prototype.addAttribute=function(e,t){var n=this.attrs;ei(t)&&(t=BR(t));var i=em(n,function(r){return r.name.localName===e.localName&&r.name.uri===e.uri&&r.name.prefix===e.prefix}),o={name:e,value:t};i!==-1?n.splice(i,1,o):n.push(o)},Gt.prototype.serializeAttributes=function(e){var t=this.attrs,n=this.namespaces;n&&(t=TR(n).concat(t)),V(t,function(i){e.append(" ").append(xm(i.name)).append('="').append(i.value).append('"')})},Gt.prototype.serializeTo=function(e){var t=this.body[0],n=t&&t.constructor!==kr;e.appendIndent().append("<"+this.tagName),this.serializeAttributes(e),e.append(t?">":" />"),t&&(n&&e.appendNewLine().indent(),V(this.body,function(i){i.serializeTo(e)}),n&&e.unindent().appendIndent(),e.append("</"+this.tagName+">")),e.appendNewLine()};function Fc(e,t,n){Gt.call(this,e,t),this.serialization=n}bm(Fc,Gt),Fc.prototype.parseNsAttributes=function(e){var t=Gt.prototype.parseNsAttributes.call(this,e).filter(a=>a.name!==this.serialization),n=e.$descriptor;if(n.name===this.propertyDescriptor.type)return t;var i=this.typeNs=this.nsTagName(n);this.getNamespaces().logUsed(this.typeNs);var o=e.$model.getPackage(i.uri),r=o.xml&&o.xml.typePrefix||"";return this.addAttribute(this.nsAttributeName(this.serialization),(i.prefix?i.prefix+":":"")+r+n.ns.localName),t},Fc.prototype.isLocalNs=function(e){return e.uri===(this.typeNs||this.ns).uri};function jR(){this.value="",this.write=function(e){this.value+=e}}function HR(e,t){var n=[""];this.append=function(i){return e.write(i),this},this.appendNewLine=function(){return t&&e.write(`
6
- `),this},this.appendIndent=function(){return t&&e.write(n.join(" ")),this},this.indent=function(){return n.push(""),this},this.unindent=function(){return n.pop(),this}}function zR(e){e=Y({format:!1,preamble:!0},e||{});function t(n,i){var o=i||new jR,r=new HR(o,e.format);e.preamble&&r.append(CR);var a=new Gt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(GR(s)),a.build(n).serializeTo(r),!i)return o.value}return{toXML:t}}function GR(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in Zp)n[i]=Zp[i];for(const i in t){const o=t[i];n[o]=i}for(const i of e.getPackages())n[i.prefix]=i.uri;return n}function jc(e,t){xi.call(this,e,t)}jc.prototype=Object.create(xi.prototype),jc.prototype.fromXML=function(e,t,n){ei(t)||(n=t,t="bpmn:Definitions");var i=new tf(Y({model:this,lax:!0},n)),o=i.handler(t);return i.fromXML(e,o)},jc.prototype.toXML=function(e,t){var n=new zR(t);return new Promise(function(i,o){try{var r=n.toXML(e);return i({xml:r})}catch(a){return o(a)}})};var VR="BPMN20",WR="http://www.omg.org/spec/BPMN/20100524/MODEL",UR="bpmn",qR=[],YR=[{name:"Interface",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"operations",type:"Operation",isMany:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"Operation",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"inMessageRef",type:"Message",isReference:!0},{name:"outMessageRef",type:"Message",isReference:!0},{name:"errorRef",type:"Error",isMany:!0,isReference:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"EndPoint",superClass:["RootElement"]},{name:"Auditing",superClass:["BaseElement"]},{name:"GlobalTask",superClass:["CallableElement"],properties:[{name:"resources",type:"ResourceRole",isMany:!0}]},{name:"Monitoring",superClass:["BaseElement"]},{name:"Performer",superClass:["ResourceRole"]},{name:"Process",superClass:["FlowElementsContainer","CallableElement"],properties:[{name:"processType",type:"ProcessType",isAttr:!0},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"properties",type:"Property",isMany:!0},{name:"laneSets",isMany:!0,replaces:"FlowElementsContainer#laneSets",type:"LaneSet"},{name:"flowElements",isMany:!0,replaces:"FlowElementsContainer#flowElements",type:"FlowElement"},{name:"artifacts",type:"Artifact",isMany:!0},{name:"resources",type:"ResourceRole",isMany:!0},{name:"correlationSubscriptions",type:"CorrelationSubscription",isMany:!0},{name:"supports",type:"Process",isMany:!0,isReference:!0},{name:"definitionalCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"isExecutable",isAttr:!0,type:"Boolean"}]},{name:"LaneSet",superClass:["BaseElement"],properties:[{name:"lanes",type:"Lane",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Lane",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"partitionElementRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"partitionElement",type:"BaseElement"},{name:"flowNodeRef",type:"FlowNode",isMany:!0,isReference:!0},{name:"childLaneSet",type:"LaneSet",xml:{serialize:"xsi:type"}}]},{name:"GlobalManualTask",superClass:["GlobalTask"]},{name:"ManualTask",superClass:["Task"]},{name:"UserTask",superClass:["Task"],properties:[{name:"renderings",type:"Rendering",isMany:!0},{name:"implementation",isAttr:!0,type:"String"}]},{name:"Rendering",superClass:["BaseElement"]},{name:"HumanPerformer",superClass:["Performer"]},{name:"PotentialOwner",superClass:["HumanPerformer"]},{name:"GlobalUserTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"renderings",type:"Rendering",isMany:!0}]},{name:"Gateway",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"gatewayDirection",type:"GatewayDirection",default:"Unspecified",isAttr:!0}]},{name:"EventBasedGateway",superClass:["Gateway"],properties:[{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"eventGatewayType",type:"EventBasedGatewayType",isAttr:!0,default:"Exclusive"}]},{name:"ComplexGateway",superClass:["Gateway"],properties:[{name:"activationCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ExclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"InclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ParallelGateway",superClass:["Gateway"]},{name:"RootElement",isAbstract:!0,superClass:["BaseElement"]},{name:"Relationship",superClass:["BaseElement"],properties:[{name:"type",isAttr:!0,type:"String"},{name:"direction",type:"RelationshipDirection",isAttr:!0},{name:"source",isMany:!0,isReference:!0,type:"Element"},{name:"target",isMany:!0,isReference:!0,type:"Element"}]},{name:"BaseElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,type:"String",isId:!0},{name:"documentation",type:"Documentation",isMany:!0},{name:"extensionDefinitions",type:"ExtensionDefinition",isMany:!0,isReference:!0},{name:"extensionElements",type:"ExtensionElements"}]},{name:"Extension",properties:[{name:"mustUnderstand",default:!1,isAttr:!0,type:"Boolean"},{name:"definition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"extensionAttributeDefinitions",type:"ExtensionAttributeDefinition",isMany:!0}]},{name:"ExtensionAttributeDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"type",isAttr:!0,type:"String"},{name:"isReference",default:!1,isAttr:!0,type:"Boolean"},{name:"extensionDefinition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionElements",properties:[{name:"valueRef",isAttr:!0,isReference:!0,type:"Element"},{name:"values",type:"Element",isMany:!0},{name:"extensionAttributeDefinition",type:"ExtensionAttributeDefinition",isAttr:!0,isReference:!0}]},{name:"Documentation",superClass:["BaseElement"],properties:[{name:"text",type:"String",isBody:!0},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Event",isAbstract:!0,superClass:["FlowNode","InteractionNode"],properties:[{name:"properties",type:"Property",isMany:!0}]},{name:"IntermediateCatchEvent",superClass:["CatchEvent"]},{name:"IntermediateThrowEvent",superClass:["ThrowEvent"]},{name:"EndEvent",superClass:["ThrowEvent"]},{name:"StartEvent",superClass:["CatchEvent"],properties:[{name:"isInterrupting",default:!0,isAttr:!0,type:"Boolean"}]},{name:"ThrowEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"inputSet",type:"InputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"CatchEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"parallelMultiple",isAttr:!0,type:"Boolean",default:!1},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"outputSet",type:"OutputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"BoundaryEvent",superClass:["CatchEvent"],properties:[{name:"cancelActivity",default:!0,isAttr:!0,type:"Boolean"},{name:"attachedToRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"EventDefinition",isAbstract:!0,superClass:["RootElement"]},{name:"CancelEventDefinition",superClass:["EventDefinition"]},{name:"ErrorEventDefinition",superClass:["EventDefinition"],properties:[{name:"errorRef",type:"Error",isAttr:!0,isReference:!0}]},{name:"TerminateEventDefinition",superClass:["EventDefinition"]},{name:"EscalationEventDefinition",superClass:["EventDefinition"],properties:[{name:"escalationRef",type:"Escalation",isAttr:!0,isReference:!0}]},{name:"Escalation",properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"escalationCode",isAttr:!0,type:"String"}],superClass:["RootElement"]},{name:"CompensateEventDefinition",superClass:["EventDefinition"],properties:[{name:"waitForCompletion",isAttr:!0,type:"Boolean",default:!0},{name:"activityRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"TimerEventDefinition",superClass:["EventDefinition"],properties:[{name:"timeDate",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeCycle",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeDuration",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"LinkEventDefinition",superClass:["EventDefinition"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"target",type:"LinkEventDefinition",isReference:!0},{name:"source",type:"LinkEventDefinition",isMany:!0,isReference:!0}]},{name:"MessageEventDefinition",superClass:["EventDefinition"],properties:[{name:"messageRef",type:"Message",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isReference:!0}]},{name:"ConditionalEventDefinition",superClass:["EventDefinition"],properties:[{name:"condition",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"SignalEventDefinition",superClass:["EventDefinition"],properties:[{name:"signalRef",type:"Signal",isAttr:!0,isReference:!0}]},{name:"Signal",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ImplicitThrowEvent",superClass:["ThrowEvent"]},{name:"DataState",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"ItemAwareElement",superClass:["BaseElement"],properties:[{name:"itemSubjectRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"dataState",type:"DataState"}]},{name:"DataAssociation",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"ItemAwareElement",isMany:!0,isReference:!0},{name:"targetRef",type:"ItemAwareElement",isReference:!0},{name:"transformation",type:"FormalExpression",xml:{serialize:"property"}},{name:"assignment",type:"Assignment",isMany:!0}]},{name:"DataInput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"inputSetRef",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithOptional",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithWhileExecuting",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"DataOutput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"outputSetRef",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithOptional",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithWhileExecuting",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"InputSet",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"dataInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"optionalInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"whileExecutingInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"outputSetRefs",type:"OutputSet",isMany:!0,isReference:!0}]},{name:"OutputSet",superClass:["BaseElement"],properties:[{name:"dataOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"inputSetRefs",type:"InputSet",isMany:!0,isReference:!0},{name:"optionalOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"whileExecutingOutputRefs",type:"DataOutput",isMany:!0,isReference:!0}]},{name:"Property",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"DataInputAssociation",superClass:["DataAssociation"]},{name:"DataOutputAssociation",superClass:["DataAssociation"]},{name:"InputOutputSpecification",superClass:["BaseElement"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"inputSets",type:"InputSet",isMany:!0},{name:"outputSets",type:"OutputSet",isMany:!0}]},{name:"DataObject",superClass:["FlowElement","ItemAwareElement"],properties:[{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"}]},{name:"InputOutputBinding",properties:[{name:"inputDataRef",type:"InputSet",isAttr:!0,isReference:!0},{name:"outputDataRef",type:"OutputSet",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"Assignment",superClass:["BaseElement"],properties:[{name:"from",type:"Expression",xml:{serialize:"xsi:type"}},{name:"to",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"DataStore",superClass:["RootElement","ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"capacity",isAttr:!0,type:"Integer"},{name:"isUnlimited",default:!0,isAttr:!0,type:"Boolean"}]},{name:"DataStoreReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataStoreRef",type:"DataStore",isAttr:!0,isReference:!0}]},{name:"DataObjectReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataObjectRef",type:"DataObject",isAttr:!0,isReference:!0}]},{name:"ConversationLink",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ConversationAssociation",superClass:["BaseElement"],properties:[{name:"innerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0},{name:"outerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0}]},{name:"CallConversation",superClass:["ConversationNode"],properties:[{name:"calledCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"Conversation",superClass:["ConversationNode"]},{name:"SubConversation",superClass:["ConversationNode"],properties:[{name:"conversationNodes",type:"ConversationNode",isMany:!0}]},{name:"ConversationNode",isAbstract:!0,superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"messageFlowRefs",type:"MessageFlow",isMany:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0}]},{name:"GlobalConversation",superClass:["Collaboration"]},{name:"PartnerEntity",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"PartnerRole",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"CorrelationProperty",superClass:["RootElement"],properties:[{name:"correlationPropertyRetrievalExpression",type:"CorrelationPropertyRetrievalExpression",isMany:!0},{name:"name",isAttr:!0,type:"String"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Error",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"errorCode",isAttr:!0,type:"String"}]},{name:"CorrelationKey",superClass:["BaseElement"],properties:[{name:"correlationPropertyRef",type:"CorrelationProperty",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Expression",superClass:["BaseElement"],isAbstract:!1,properties:[{name:"body",isBody:!0,type:"String"}]},{name:"FormalExpression",superClass:["Expression"],properties:[{name:"language",isAttr:!0,type:"String"},{name:"evaluatesToTypeRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Message",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"itemRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"ItemDefinition",superClass:["RootElement"],properties:[{name:"itemKind",type:"ItemKind",isAttr:!0},{name:"structureRef",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"import",type:"Import",isAttr:!0,isReference:!0}]},{name:"FlowElement",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"categoryValueRef",type:"CategoryValue",isMany:!0,isReference:!0}]},{name:"SequenceFlow",superClass:["FlowElement"],properties:[{name:"isImmediate",isAttr:!0,type:"Boolean"},{name:"conditionExpression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"sourceRef",type:"FlowNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"FlowNode",isAttr:!0,isReference:!0}]},{name:"FlowElementsContainer",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"laneSets",type:"LaneSet",isMany:!0},{name:"flowElements",type:"FlowElement",isMany:!0}]},{name:"CallableElement",isAbstract:!0,superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"supportedInterfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"ioBinding",type:"InputOutputBinding",isMany:!0,xml:{serialize:"property"}}]},{name:"FlowNode",isAbstract:!0,superClass:["FlowElement"],properties:[{name:"incoming",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"outgoing",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"lanes",type:"Lane",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"CorrelationPropertyRetrievalExpression",superClass:["BaseElement"],properties:[{name:"messagePath",type:"FormalExpression"},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"CorrelationPropertyBinding",superClass:["BaseElement"],properties:[{name:"dataPath",type:"FormalExpression"},{name:"correlationPropertyRef",type:"CorrelationProperty",isAttr:!0,isReference:!0}]},{name:"Resource",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"resourceParameters",type:"ResourceParameter",isMany:!0}]},{name:"ResourceParameter",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isRequired",isAttr:!0,type:"Boolean"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"CorrelationSubscription",superClass:["BaseElement"],properties:[{name:"correlationKeyRef",type:"CorrelationKey",isAttr:!0,isReference:!0},{name:"correlationPropertyBinding",type:"CorrelationPropertyBinding",isMany:!0}]},{name:"MessageFlow",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"MessageFlowAssociation",superClass:["BaseElement"],properties:[{name:"innerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0},{name:"outerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0}]},{name:"InteractionNode",isAbstract:!0,properties:[{name:"incomingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0},{name:"outgoingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"Participant",superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"interfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"participantMultiplicity",type:"ParticipantMultiplicity"},{name:"endPointRefs",type:"EndPoint",isMany:!0,isReference:!0},{name:"processRef",type:"Process",isAttr:!0,isReference:!0}]},{name:"ParticipantAssociation",superClass:["BaseElement"],properties:[{name:"innerParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"outerParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"ParticipantMultiplicity",properties:[{name:"minimum",default:0,isAttr:!0,type:"Integer"},{name:"maximum",default:1,isAttr:!0,type:"Integer"}],superClass:["BaseElement"]},{name:"Collaboration",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"participants",type:"Participant",isMany:!0},{name:"messageFlows",type:"MessageFlow",isMany:!0},{name:"artifacts",type:"Artifact",isMany:!0},{name:"conversations",type:"ConversationNode",isMany:!0},{name:"conversationAssociations",type:"ConversationAssociation"},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0},{name:"messageFlowAssociations",type:"MessageFlowAssociation",isMany:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"choreographyRef",type:"Choreography",isMany:!0,isReference:!0},{name:"conversationLinks",type:"ConversationLink",isMany:!0}]},{name:"ChoreographyActivity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"loopType",type:"ChoreographyLoopType",default:"None",isAttr:!0}]},{name:"CallChoreography",superClass:["ChoreographyActivity"],properties:[{name:"calledChoreographyRef",type:"Choreography",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"SubChoreography",superClass:["ChoreographyActivity","FlowElementsContainer"],properties:[{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"ChoreographyTask",superClass:["ChoreographyActivity"],properties:[{name:"messageFlowRef",type:"MessageFlow",isMany:!0,isReference:!0}]},{name:"Choreography",superClass:["Collaboration","FlowElementsContainer"]},{name:"GlobalChoreographyTask",superClass:["Choreography"],properties:[{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"TextAnnotation",superClass:["Artifact"],properties:[{name:"text",type:"String"},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Group",superClass:["Artifact"],properties:[{name:"categoryValueRef",type:"CategoryValue",isAttr:!0,isReference:!0}]},{name:"Association",superClass:["Artifact"],properties:[{name:"associationDirection",type:"AssociationDirection",isAttr:!0},{name:"sourceRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"targetRef",type:"BaseElement",isAttr:!0,isReference:!0}]},{name:"Category",superClass:["RootElement"],properties:[{name:"categoryValue",type:"CategoryValue",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Artifact",isAbstract:!0,superClass:["BaseElement"]},{name:"CategoryValue",superClass:["BaseElement"],properties:[{name:"categorizedFlowElements",type:"FlowElement",isMany:!0,isVirtual:!0,isReference:!0},{name:"value",isAttr:!0,type:"String"}]},{name:"Activity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"isForCompensation",default:!1,isAttr:!0,type:"Boolean"},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"boundaryEventRefs",type:"BoundaryEvent",isMany:!0,isReference:!0},{name:"properties",type:"Property",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"startQuantity",default:1,isAttr:!0,type:"Integer"},{name:"resources",type:"ResourceRole",isMany:!0},{name:"completionQuantity",default:1,isAttr:!0,type:"Integer"},{name:"loopCharacteristics",type:"LoopCharacteristics"}]},{name:"ServiceTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"SubProcess",superClass:["Activity","FlowElementsContainer","InteractionNode"],properties:[{name:"triggeredByEvent",default:!1,isAttr:!0,type:"Boolean"},{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"LoopCharacteristics",isAbstract:!0,superClass:["BaseElement"]},{name:"MultiInstanceLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"isSequential",default:!1,isAttr:!0,type:"Boolean"},{name:"behavior",type:"MultiInstanceBehavior",default:"All",isAttr:!0},{name:"loopCardinality",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopDataInputRef",type:"ItemAwareElement",isReference:!0},{name:"loopDataOutputRef",type:"ItemAwareElement",isReference:!0},{name:"inputDataItem",type:"DataInput",xml:{serialize:"property"}},{name:"outputDataItem",type:"DataOutput",xml:{serialize:"property"}},{name:"complexBehaviorDefinition",type:"ComplexBehaviorDefinition",isMany:!0},{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"oneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0},{name:"noneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0}]},{name:"StandardLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"testBefore",default:!1,isAttr:!0,type:"Boolean"},{name:"loopCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopMaximum",type:"Integer",isAttr:!0}]},{name:"CallActivity",superClass:["Activity","InteractionNode"],properties:[{name:"calledElement",type:"String",isAttr:!0}]},{name:"Task",superClass:["Activity","InteractionNode"]},{name:"SendTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ReceiveTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ScriptTask",superClass:["Task"],properties:[{name:"scriptFormat",isAttr:!0,type:"String"},{name:"script",type:"String"}]},{name:"BusinessRuleTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"AdHocSubProcess",superClass:["SubProcess"],properties:[{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"ordering",type:"AdHocOrdering",isAttr:!0},{name:"cancelRemainingInstances",default:!0,isAttr:!0,type:"Boolean"}]},{name:"Transaction",superClass:["SubProcess"],properties:[{name:"protocol",isAttr:!0,type:"String"},{name:"method",isAttr:!0,type:"String"}]},{name:"GlobalScriptTask",superClass:["GlobalTask"],properties:[{name:"scriptLanguage",isAttr:!0,type:"String"},{name:"script",isAttr:!0,type:"String"}]},{name:"GlobalBusinessRuleTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"ComplexBehaviorDefinition",superClass:["BaseElement"],properties:[{name:"condition",type:"FormalExpression"},{name:"event",type:"ImplicitThrowEvent"}]},{name:"ResourceRole",superClass:["BaseElement"],properties:[{name:"resourceRef",type:"Resource",isReference:!0},{name:"resourceParameterBindings",type:"ResourceParameterBinding",isMany:!0},{name:"resourceAssignmentExpression",type:"ResourceAssignmentExpression"},{name:"name",isAttr:!0,type:"String"}]},{name:"ResourceParameterBinding",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"parameterRef",type:"ResourceParameter",isAttr:!0,isReference:!0}],superClass:["BaseElement"]},{name:"ResourceAssignmentExpression",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}}],superClass:["BaseElement"]},{name:"Import",properties:[{name:"importType",isAttr:!0,type:"String"},{name:"location",isAttr:!0,type:"String"},{name:"namespace",isAttr:!0,type:"String"}]},{name:"Definitions",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"targetNamespace",isAttr:!0,type:"String"},{name:"expressionLanguage",default:"http://www.w3.org/1999/XPath",isAttr:!0,type:"String"},{name:"typeLanguage",default:"http://www.w3.org/2001/XMLSchema",isAttr:!0,type:"String"},{name:"imports",type:"Import",isMany:!0},{name:"extensions",type:"Extension",isMany:!0},{name:"rootElements",type:"RootElement",isMany:!0},{name:"diagrams",isMany:!0,type:"bpmndi:BPMNDiagram"},{name:"exporter",isAttr:!0,type:"String"},{name:"relationships",type:"Relationship",isMany:!0},{name:"exporterVersion",isAttr:!0,type:"String"}]}],KR=[{name:"ProcessType",literalValues:[{name:"None"},{name:"Public"},{name:"Private"}]},{name:"GatewayDirection",literalValues:[{name:"Unspecified"},{name:"Converging"},{name:"Diverging"},{name:"Mixed"}]},{name:"EventBasedGatewayType",literalValues:[{name:"Parallel"},{name:"Exclusive"}]},{name:"RelationshipDirection",literalValues:[{name:"None"},{name:"Forward"},{name:"Backward"},{name:"Both"}]},{name:"ItemKind",literalValues:[{name:"Physical"},{name:"Information"}]},{name:"ChoreographyLoopType",literalValues:[{name:"None"},{name:"Standard"},{name:"MultiInstanceSequential"},{name:"MultiInstanceParallel"}]},{name:"AssociationDirection",literalValues:[{name:"None"},{name:"One"},{name:"Both"}]},{name:"MultiInstanceBehavior",literalValues:[{name:"None"},{name:"One"},{name:"All"},{name:"Complex"}]},{name:"AdHocOrdering",literalValues:[{name:"Parallel"},{name:"Sequential"}]}],XR={tagAlias:"lowerCase",typePrefix:"t"},ZR={name:VR,uri:WR,prefix:UR,associations:qR,types:YR,enumerations:KR,xml:XR},QR="BPMNDI",JR="http://www.omg.org/spec/BPMN/20100524/DI",eC="bpmndi",tC=[{name:"BPMNDiagram",properties:[{name:"plane",type:"BPMNPlane",redefines:"di:Diagram#rootElement"},{name:"labelStyle",type:"BPMNLabelStyle",isMany:!0}],superClass:["di:Diagram"]},{name:"BPMNPlane",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"}],superClass:["di:Plane"]},{name:"BPMNShape",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"isHorizontal",isAttr:!0,type:"Boolean"},{name:"isExpanded",isAttr:!0,type:"Boolean"},{name:"isMarkerVisible",isAttr:!0,type:"Boolean"},{name:"label",type:"BPMNLabel"},{name:"isMessageVisible",isAttr:!0,type:"Boolean"},{name:"participantBandKind",type:"ParticipantBandKind",isAttr:!0},{name:"choreographyActivityShape",type:"BPMNShape",isAttr:!0,isReference:!0}],superClass:["di:LabeledShape"]},{name:"BPMNEdge",properties:[{name:"label",type:"BPMNLabel"},{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"sourceElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#source"},{name:"targetElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#target"},{name:"messageVisibleKind",type:"MessageVisibleKind",isAttr:!0,default:"initiating"}],superClass:["di:LabeledEdge"]},{name:"BPMNLabel",properties:[{name:"labelStyle",type:"BPMNLabelStyle",isAttr:!0,isReference:!0,redefines:"di:DiagramElement#style"}],superClass:["di:Label"]},{name:"BPMNLabelStyle",properties:[{name:"font",type:"dc:Font"}],superClass:["di:Style"]}],nC=[{name:"ParticipantBandKind",literalValues:[{name:"top_initiating"},{name:"middle_initiating"},{name:"bottom_initiating"},{name:"top_non_initiating"},{name:"middle_non_initiating"},{name:"bottom_non_initiating"}]},{name:"MessageVisibleKind",literalValues:[{name:"initiating"},{name:"non_initiating"}]}],iC=[],oC={name:QR,uri:JR,prefix:eC,types:tC,enumerations:nC,associations:iC},rC="DC",aC="http://www.omg.org/spec/DD/20100524/DC",sC="dc",cC=[{name:"Boolean"},{name:"Integer"},{name:"Real"},{name:"String"},{name:"Font",properties:[{name:"name",type:"String",isAttr:!0},{name:"size",type:"Real",isAttr:!0},{name:"isBold",type:"Boolean",isAttr:!0},{name:"isItalic",type:"Boolean",isAttr:!0},{name:"isUnderline",type:"Boolean",isAttr:!0},{name:"isStrikeThrough",type:"Boolean",isAttr:!0}]},{name:"Point",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0}]},{name:"Bounds",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0},{name:"width",type:"Real",isAttr:!0},{name:"height",type:"Real",isAttr:!0}]}],lC=[],uC={name:rC,uri:aC,prefix:sC,types:cC,associations:lC},pC="DI",fC="http://www.omg.org/spec/DD/20100524/DI",dC="di",hC=[{name:"DiagramElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"extension",type:"Extension"},{name:"owningDiagram",type:"Diagram",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"owningElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"modelElement",isReadOnly:!0,isVirtual:!0,isReference:!0,type:"Element"},{name:"style",type:"Style",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"ownedElement",type:"DiagramElement",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Node",isAbstract:!0,superClass:["DiagramElement"]},{name:"Edge",isAbstract:!0,superClass:["DiagramElement"],properties:[{name:"source",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"target",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"waypoint",isUnique:!1,isMany:!0,type:"dc:Point",xml:{serialize:"xsi:type"}}]},{name:"Diagram",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"rootElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0},{name:"name",isAttr:!0,type:"String"},{name:"documentation",isAttr:!0,type:"String"},{name:"resolution",isAttr:!0,type:"Real"},{name:"ownedStyle",type:"Style",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Shape",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Plane",isAbstract:!0,superClass:["Node"],properties:[{name:"planeElement",type:"DiagramElement",subsettedProperty:"DiagramElement-ownedElement",isMany:!0}]},{name:"LabeledEdge",isAbstract:!0,superClass:["Edge"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"LabeledShape",isAbstract:!0,superClass:["Shape"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"Label",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Style",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"}]},{name:"Extension",properties:[{name:"values",isMany:!0,type:"Element"}]}],gC=[],mC={tagAlias:"lowerCase"},yC={name:pC,uri:fC,prefix:dC,types:hC,associations:gC,xml:mC},vC="bpmn.io colors for BPMN",bC="http://bpmn.io/schema/bpmn/biocolor/1.0",xC="bioc",wC=[{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]}],_C=[],EC=[],SC={name:vC,uri:bC,prefix:xC,types:wC,enumerations:_C,associations:EC},RC="BPMN in Color",CC="http://www.omg.org/spec/BPMN/non-normative/color/1.0",MC="color",AC=[{name:"ColoredLabel",extends:["bpmndi:BPMNLabel"],properties:[{name:"color",isAttr:!0,type:"String"}]},{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"background-color",isAttr:!0,type:"String"},{name:"border-color",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"border-color",isAttr:!0,type:"String"}]}],PC=[],TC=[],kC={name:RC,uri:CC,prefix:MC,types:AC,enumerations:PC,associations:TC};const OC={bpmn:ZR,bpmndi:oC,dc:uC,di:yC,bioc:SC,color:kC};function _m(e,t){const n=Y({},OC,e);return new jc(n,t)}const DC={name:"bpmn-i18n",uri:"http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",prefix:"i18n",types:[{name:"Translation",superClass:["Element"],properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"body",isBody:!0,type:"String"},{name:"target",isAttr:!0,type:"String",default:"@name"},{name:"textFormat",isAttr:"true",type:"String",default:"text/plain"}]}],enumerations:[],associations:[],xml:{tagAlias:"lowerCase",typePrefix:"t"}},Hc={[nm]:DC,[Op]:Zg};function Em(){return _m(Hc)}const Sm=Em();async function pa(e){const{rootElement:t,warnings:n}=await Sm.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function LC(e){const{xml:t}=await Sm.toXML(e,{format:!0});return t}function rf(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const fa={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},IC=/[ᄀ-ᇿ -〿぀-ヿ㐀-鿿가-힯＀-⦆]/;function BC(e){const t=fa;return IC.test(e)?t.cjkEm:e===" "?t.spaceEm:e>="0"&&e<="9"?t.digitEm:e>="A"&&e<="Z"?t.upperEm:e>="a"&&e<="z"?t.lowerEm:t.otherEm}function da(e,t){let n=0;for(const i of e)n+=t*BC(i);return n}function Rm(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&NC(e),$C(e),FC(e),jC(e)}function NC(e){var i;const t=(i=e.HTMLCanvasElement)==null?void 0:i.prototype;if(!t||t.__headlessTextMeasurement)return;t.__headlessTextMeasurement=!0;const n={font:"12px sans-serif",letterSpacing:"0px",measureText(o){var a;const r=Number.parseFloat(((a=String(n.font).match(/(\d+(?:\.\d+)?)px/))==null?void 0:a[1])??"12");return{width:da(o,r),fontBoundingBoxAscent:r*fa.ascentEm,fontBoundingBoxDescent:r*fa.descentEm,actualBoundingBoxAscent:r*fa.ascentEm,actualBoundingBoxDescent:r*fa.descentEm}}};t.getContext=()=>n}function $C(e){if(e.SVGMatrix)return;class t{constructor(){$n(this,"a",1);$n(this,"b",0);$n(this,"c",0);$n(this,"d",1);$n(this,"e",0);$n(this,"f",0)}static of(i,o,r,a,s,c){return Object.assign(new t,{a:i,b:o,c:r,d:a,e:s,f:c})}multiply(i){return t.of(this.a*i.a+this.c*i.b,this.b*i.a+this.d*i.b,this.a*i.c+this.c*i.d,this.b*i.c+this.d*i.d,this.a*i.e+this.c*i.f+this.e,this.b*i.e+this.d*i.f+this.f)}translate(i,o){return this.multiply(t.of(1,0,0,1,i,o))}scale(i,o=i){return this.multiply(t.of(i,0,0,o,0,0))}inverse(){const i=this.a*this.d-this.b*this.c;return t.of(this.d/i,-this.b/i,-this.c/i,this.a/i,(this.c*this.f-this.d*this.e)/i,(this.b*this.e-this.a*this.f)/i)}}e.SVGMatrix=t}function FC(e){var r;const t=()=>{const a=new e.SVGMatrix;return{type:0,matrix:a,setTranslate(s,c){a.e=s,a.f=c},setScale(s,c){a.a=s,a.d=c},setRotate(s,c=0,l=0){const u=s*Math.PI/180,p=Math.cos(u),f=Math.sin(u);a.a=p,a.b=f,a.c=-f,a.d=p,a.e=c-p*c+f*l,a.f=l-f*c-p*l},setMatrix(s){Object.assign(a,s)}}},n=a=>{const s=t();return Object.assign(s.matrix,a),s},i=(r=e.SVGSVGElement)==null?void 0:r.prototype;i&&!i.createSVGTransform&&(i.createSVGTransform=t,i.createSVGTransformFromMatrix=n,i.createSVGMatrix=()=>new e.SVGMatrix,i.createSVGPoint=()=>({x:0,y:0,matrixTransform:()=>({x:0,y:0})}));const o=e.SVGElement.prototype;Object.getOwnPropertyDescriptor(o,"transform")||Object.defineProperty(o,"transform",{configurable:!0,get(){if(!this.__headlessTransformList){const a=[];this.__headlessTransformList={baseVal:{get numberOfItems(){return a.length},clear:()=>{a.length=0},appendItem:s=>(a.push(s),s),getItem:s=>a[s],createSVGTransformFromMatrix:n,consolidate:()=>a[a.length-1]??null}}}return this.__headlessTransformList}})}function jC(e){const t=e.SVGElement.prototype;if(!t.getCTM){const n=()=>new e.SVGMatrix;t.getCTM=n,t.getScreenCTM=n}t.getBBox||(t.getBBox=function(){const n=String(this.textContent??"");return{x:0,y:0,width:da(n,12),height:14}})}const zc=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),HC=new Set(["bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),zC=1,Gc=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),GC=2;function pt(e){switch(e.kind){case"label-over-line":return`L|${e.edge}|${e.line}`;case"label-over-shape":return`ls|${e.edge}|${e.shape}`;case"edge-crosses-shape":return`x|${e.edge}|${e.shape}`;case"edge-endpoint-detached":return`d|${e.edge}|${e.shape}`;case"shape-overlap":return`o|${e.shapes[0]}|${e.shapes[1]}`;case"shape-outside-container":return`c|${e.shape}|${e.container}`;case"edge-overlap-opposite":return`p|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-mixed":return`m|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-unrelated":return`u|${e.edges[0]}|${e.edges[1]}`;case"label-on-shared-segment":return`l|${e.edge}|${e.other}`;case"annotation-over-label":return`a|${e.annotation}|${e.label}`;case"pool-overlap":return`P|${e.pools[0]}|${e.pools[1]}`;case"edge-crosses-subprocess":return`S|${e.edge}|${e.subProcess}`;case"group-overlap-unintended":return`g|${e.groups[0]}|${e.groups[1]}${e.container?`|⊃${e.container}`:""}`;case"group-overlap-unreadable":return e.reason==="minority"?`gu*|${e.group}|${e.shapes.join(",")}`:e.reason==="throughpass"?`gu>|${e.group}|${e.shapes.join(",")}`:`gu|${e.groups[0]}|${e.groups[1]}|${e.shapes.join(",")}`;case"group-stack-unreadable":return`gs|${e.groups.join("|")}|${e.shapes.join(",")}`;case"group-on-container-boundary":return`gb|${e.group}|${e.container}|${e.side}`;case"group-on-group-boundary":return`gg|${e.groups[0]}|${e.groups[1]}|${e.axis}`;case"group-cuts-shape":return`gc|${e.group}|${e.shape}|${e.side}`;case"edge-along-group-boundary":return`eg|${e.edge}|${e.group}`;case"pool-name-over-label":return`pn|${e.pool}|${e.label}`}}const Cm=20,Vc=5,Mm=3,VC=8,ha=15,af=50,Am=12,WC=Am*1.2;function sf(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(r=>da(r,Am))),o=n.length*WC;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-o/2,width:i,height:o}}const Pm=1;function an(e){const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],o=e.waypoints[n+1];Math.abs(i.y-o.y)<.5&&Math.abs(i.x-o.x)>=.5?t.push({axis:"h",at:i.y,lo:Math.min(i.x,o.x),hi:Math.max(i.x,o.x),dir:o.x>i.x?1:-1}):Math.abs(i.x-o.x)<.5&&Math.abs(i.y-o.y)>=.5&&t.push({axis:"v",at:i.x,lo:Math.min(i.y,o.y),hi:Math.max(i.y,o.y),dir:o.y>i.y?1:-1})}return t}function Or(e,t){let n=null;const i=e.type!==t.type,r=!!(e.source&&e.target&&t.source&&t.target)&&e.source!==t.source&&e.source!==t.target&&e.target!==t.source&&e.target!==t.target;for(const a of an(e))for(const s of an(t)){if(a.axis!==s.axis||Math.abs(a.at-s.at)>Pm)continue;const c=a.dir!==s.dir?"opposite":i?"mixed":r?"unrelated":null;if(!c)continue;const l=Math.min(a.hi,s.hi)-Math.max(a.lo,s.lo);l>=Cm&&(!n||l>n.length)&&(n={axis:a.axis,length:l,kind:c})}return n}function cf(e){return e.kind==="edge-overlap-opposite"||e.kind==="edge-overlap-mixed"||e.kind==="edge-overlap-unrelated"}function Tm(e,t){const n=Or(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function UC(e,t){let n=0;for(const i of t)i.id!==e.id&&Tm(e,i)&&n++;return n}function hi(e,t){let n=0;for(const i of t)i.id!==e.id&&Or(e,i)&&n++;return n}const km=15,Om=20;function qC(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Om||t.at>n[1]+Om)return null;const i=t.axis==="v"?[e.y,e.y+e.height]:[e.x,e.x+e.width],o=Math.max(i[0],t.lo),r=Math.min(i[1],t.hi);return r>o?[o,r]:null}const lf=20;function Wc(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Pm)continue;const o=Math.max(e.lo,i.lo),r=Math.min(e.hi,i.hi);r-o<Cm||n.push([o-lf,r+lf])}return n}function Uc(e,t){const n=e.label;if(!n)return null;let i=null;for(const o of an(e)){const r=qC(n,o);if(r){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of Wc(o,an(a)))if(Math.min(c,r[1])>Math.max(s,r[0])){i={other:a.id,axis:o.axis};break}}}}return i}const YC=10,KC=1,XC=(e,t,n)=>t.x>=e.x-n&&t.y>=e.y-n&&t.x+t.width<=e.x+e.width+n&&t.y+t.height<=e.y+e.height+n;function ZC(e,t,n,i){const o=n.x+i,r=n.y+i,a=n.x+n.width-i,s=n.y+n.height-i;if(a<=o||s<=r)return!1;const c=t.x-e.x,l=t.y-e.y;let u=0,p=1;const f=(d,g)=>{if(g===0)return d<=0;const h=d/g;if(g>0){if(h>p)return!1;h>u&&(u=h)}else{if(h<u)return!1;h<p&&(p=h)}return!0};return f(o-e.x,c)&&f(e.x-a,-c)&&f(r-e.y,l)&&f(e.y-s,-l)&&p>u}function uf(e,t,n){return e.x+n<t.x+t.width-n&&t.x+n<e.x+e.width-n&&e.y+n<t.y+t.height-n&&t.y+n<e.y+e.height-n}const QC=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,ga=1;function $i(e,t){const n=e.x+ga,i=e.x+e.width-ga,o=e.y+ga,r=e.y+e.height-ga;return t.axis==="h"?t.at>o&&t.at<r&&t.lo<i&&t.hi>n:t.at>n&&t.at<i&&t.lo<r&&t.hi>o}function ma(e){return[{axis:"h",at:e.y,lo:e.x,hi:e.x+e.width,dir:1},{axis:"h",at:e.y+e.height,lo:e.x,hi:e.x+e.width,dir:1},{axis:"v",at:e.x,lo:e.y,hi:e.y+e.height,dir:1},{axis:"v",at:e.x+e.width,lo:e.y,hi:e.y+e.height,dir:1}]}function Dm(e,t){const n=e.label;if(!n)return null;if(an(e).some(i=>$i(n,i)))return e.id;for(const i of[...t.edges].filter(o=>o.id!==e.id).sort((o,r)=>o.id.localeCompare(r.id)))if(an(i).some(o=>$i(n,o)))return i.id;for(const i of t.shapes.filter(o=>o.container).sort((o,r)=>o.id.localeCompare(r.id)))if(ma(i).some(o=>$i(n,o)))return i.id;return null}function Ht(e,t){const n=new Set(e.endpoints),i=[];for(const o of t)if(!n.has(o.id)){for(let r=0;r+1<e.waypoints.length;r++)if(ZC(e.waypoints[r],e.waypoints[r+1],o,GC)){i.push(o);break}}return i}const ps=(e,t,n)=>{const i=n.x-t.x,o=n.y-t.y,r=i*i+o*o,a=r===0?0:Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*o)/r));return Math.hypot(e.x-(t.x+a*i),e.y-(t.y+a*o))},JC=(e,t,n,i)=>Im(e,t,n,i)?0:Math.min(ps(e,n,i),ps(t,n,i),ps(n,e,t),ps(i,e,t)),Lm=(e,t)=>{let n=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const r=t[i],a=t[o];r.y>e.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(n=!n)}return n};function Dr(e,t,n){const{x:i,y:o,width:r,height:a}=n;if(/Event$/.test(n.type)){const l=Math.min(r,a)/2;return Math.max(0,ps({x:i+r/2,y:o+a/2},e,t)-l)}const s=/Gateway$/.test(n.type)?[{x:i+r/2,y:o},{x:i+r,y:o+a/2},{x:i+r/2,y:o+a},{x:i,y:o+a/2}]:[{x:i,y:o},{x:i+r,y:o},{x:i+r,y:o+a},{x:i,y:o+a}];if(Lm(e,s)||Lm(t,s))return 0;let c=1/0;for(let l=0;l<s.length;l++)c=Math.min(c,JC(e,t,s[l],s[(l+1)%s.length]));return c}function Im(e,t,n,i){const o=(l,u,p)=>(u.x-l.x)*(p.y-l.y)-(u.y-l.y)*(p.x-l.x),r=o(n,i,e),a=o(n,i,t),s=o(e,t,n),c=o(e,t,i);return r*a<0&&s*c<0}const pf=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function Bm(e,t){for(let n=0;n+1<e.waypoints.length;n++)for(let i=0;i+1<t.waypoints.length;i++)if(Im(e.waypoints[n],e.waypoints[n+1],t.waypoints[i],t.waypoints[i+1]))return!0;return!1}function fs(e,t){let n=0;for(const i of t)i.id===e.id||pf(e,i)||Bm(e,i)&&n++;return n}function gi(e,t){let n=0;for(const i of t)i.id===e.id||pf(e,i)||fs(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Nm(e){let t=0;const n=e.edges;for(let i=0;i<n.length;i++)for(let o=i+1;o<n.length;o++)fs(n[i],[n[o]])>0&&(t+=n[i].type===n[o].type?2:1);return t}function go(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let o=i+1;o<n.length;o++)if(fs(n[i],[n[o]])>0){const r=n[i].id,a=n[o].id;t.push(r<a?[r,a]:[a,r])}return t.sort((i,o)=>`${i[0]}|${i[1]}`.localeCompare(`${o[0]}|${o[1]}`))}function Fi(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let o=i+1;o<n.length;o++)if(pf(n[i],n[o])&&Bm(n[i],n[o])){const r=n[i].id,a=n[o].id;t.push(r<a?[r,a]:[a,r])}return t.sort((i,o)=>`${i[0]}|${i[1]}`.localeCompare(`${o[0]}|${o[1]}`))}function $m(e){const t=go(e),n=a=>a==="bpmn:MessageFlow"||a.endsWith("Association")?"dashed":"solid",i=new Map(e.edges.map(a=>[a.id,a]));let o=0,r=0;for(const[a,s]of t){const c=i.get(a),l=i.get(s);if(!c||!l)continue;const u=n(c.type),p=n(l.type);u==="solid"&&p==="solid"?o++:u==="dashed"&&p==="dashed"&&r++}return{pairs:t,solidPairs:o,dashedPairs:r,mixedPairs:t.length-o-r,crossPoolMessages:eM(e)}}function eM(e){const t=e.shapes.filter(o=>o.type==="bpmn:Participant");if(t.length<3)return 0;const n=o=>{const r=e.shapes.find(a=>a.id===o);if(r)return t.find(a=>r.x>=a.x&&r.y>=a.y&&r.x+r.width<=a.x+a.width&&r.y+r.height<=a.y+a.height)};let i=0;for(const o of e.edges){if(o.type!=="bpmn:MessageFlow"||o.endpoints.length<2)continue;const r=n(o.endpoints[0]),a=n(o.endpoints[1]);if(!r||!a||r.id===a.id)continue;const s=Math.min(r.y,a.y),c=Math.max(r.y+r.height,a.y+a.height);t.some(l=>l.id!==r.id&&l.id!==a.id&&l.y>s&&l.y+l.height<c)&&i++}return i}function Fm(e,t,n){const i=new Set(t.flatMap(o=>[...o.members]));return e.shapes.filter(o=>!o.container&&!Gc.has(o.type)&&!i.has(o.id)&&o.x>=n.x&&o.y>=n.y&&o.x+o.width<=n.right&&o.y+o.height<=n.bottom).map(o=>o.id).sort()}function jm(e){var n;const t=(n=zt(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const o=zt(i);if((o==null?void 0:o.$type)!=="bwl:Members"||typeof o.refs!="string")continue;const r=o.refs.split(/\s+/).filter(Boolean);return r.length?r:void 0}}const Hm=e=>e?{members:e}:{},Hn=e=>e.shapes.filter(t=>!t.container);function tM(e,t,n){if(e.type==="bpmn:TextAnnotation")for(const i of t.edges){if(!/Association$/.test(i.type)||!i.endpoints.includes(e.id))continue;const o=i.endpoints.find(a=>a!==e.id),r=o?n.get(o):void 0;if(r&&r.type!=="bpmn:Group"){if(r.container)return r.id;if(r.parent)return r.parent}}}function nM(e,t,n){if(e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height)return!0;const o=e.x+e.width/2,r=e.y+e.height/2;return n.shapes.some(a=>a.container&&a.id!==t.id&&a.id!==e.id&&a.type!=="bpmn:Group"&&o>=a.x&&o<=a.x+a.width&&r>=a.y&&r<=a.y+a.height)}function zm(e,t){const n=e.label;if(!n)return null;for(const i of[...t.edges].sort((o,r)=>o.id.localeCompare(r.id)))if(an(i).some(o=>$i(n,o)))return i.id;for(const i of[...t.shapes].filter(o=>o.container).sort((o,r)=>o.id.localeCompare(r.id)))if(ma(i).some(o=>$i(n,o)))return i.id;return null}function zo(e){const t=[];for(const n of e.shapes)n.label&&t.push({owner:n.id,rect:n.label});for(const n of e.edges)n.label&&t.push({owner:n.id,rect:n.label});return t}const Gm=3;function Vm(e,t){const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),i=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);if(n<=0||i<=0)return 0;const o=/Event$/.test(t.type);if(!o&&!/Gateway$/.test(t.type))return Math.min(n,i);const r=t.x+t.width/2,a=t.y+t.height/2,s=Math.min(Math.max(r,e.x),e.x+e.width),c=Math.min(Math.max(a,e.y),e.y+e.height);if(o)return Math.max(0,t.width/2-Math.hypot(s-r,c-a));const l=t.width/2,u=t.height/2;return Math.max(0,(1-(Math.abs(s-r)/l+Math.abs(c-a)/u))*Math.min(l,u))}function ds(e,t){const n=[];for(const i of t.shapes){if(i.container||Gc.has(i.type))continue;const o=Vm(e,i);o>=Gm&&n.push({shape:i.id,depth:o})}return n.sort((i,o)=>i.shape.localeCompare(o.shape))}function ff(e){const t=[],n=e.filter(o=>o.type==="bpmn:Participant"),i=(o,r)=>o.x<=r.x&&o.y<=r.y&&o.x+o.width>=r.x+r.width&&o.y+o.height>=r.y+r.height;for(let o=0;o<n.length;o++)for(let r=o+1;r<n.length;r++){const a=n[o],s=n[r];a.x+a.width<=s.x||s.x+s.width<=a.x||a.y+a.height<=s.y||s.y+s.height<=a.y||t.push({pools:[a.id,s.id],contained:i(a,s)||i(s,a)})}return t}function ft(e,t={}){const n=[],i=e.shapes.filter(y=>!y.container);for(const y of e.edges)for(const v of Ht(y,i))n.push({kind:"edge-crosses-shape",edge:y.id,shape:v.id});const o=e.shapes.filter(y=>y.container&&HC.has(y.type));if(o.length){const y=(v,x)=>{const E=e.shapes.find(A=>A.id===x);return!!E&&E.x>=v.x&&E.y>=v.y&&E.x+E.width<=v.x+v.width&&E.y+E.height<=v.y+v.height};for(const v of e.edges)for(const x of Ht(v,o))v.endpoints.includes(x.id)||v.endpoints.some(E=>y(x,E))||n.push({kind:"edge-crosses-subprocess",edge:v.id,subProcess:x.id})}for(const y of e.edges){if(y.waypoints.length<2)continue;const v=[[y.source,y.waypoints[0]],[y.target,y.waypoints[y.waypoints.length-1]]];for(const[x,E]of v){if(!x)continue;const A=e.shapes.find(H=>H.id===x);if(!A||A.container)continue;const B=Math.max(A.x-E.x,E.x-(A.x+A.width),0),P=Math.max(A.y-E.y,E.y-(A.y+A.height),0),k=Math.hypot(B,P);k>YC&&n.push({kind:"edge-endpoint-detached",edge:y.id,shape:x,distance:Math.round(k)})}}for(const y of ff(e.shapes))n.push({kind:"pool-overlap",...y});const r=i.filter(y=>!y.attached);for(let y=0;y<r.length;y++)for(let v=y+1;v<r.length;v++){const x=r[y],E=r[v];if(!uf(x,E,zC))continue;const A=x.id<E.id?[x.id,E.id]:[E.id,x.id];n.push({kind:"shape-overlap",shapes:A,identical:QC(x,E)})}const a=e.shapes.filter(y=>y.type==="bpmn:Group"&&Array.isArray(y.members)&&y.members.length>0);for(let y=0;y<a.length;y++)for(let v=y+1;v<a.length;v++){const x=a[y],E=a[v],A=Math.min(x.x+x.width,E.x+E.width)-Math.max(x.x,E.x),B=Math.min(x.y+x.height,E.y+E.height)-Math.max(x.y,E.y);if(A<=Vc||B<=Vc)continue;const P=x.id<E.id?[x.id,E.id]:[E.id,x.id],k=new Set(E.members);if(x.members.some(F=>k.has(F))){const F=Fm(e,a,{x:Math.max(x.x,E.x),y:Math.max(x.y,E.y),right:Math.min(x.x+x.width,E.x+E.width),bottom:Math.min(x.y+x.height,E.y+E.height)});F.length&&n.push({kind:"group-overlap-unreadable",reason:"orphan",groups:P,shapes:F});continue}const H=x.x<=E.x&&x.y<=E.y&&x.x+x.width>=E.x+E.width&&x.y+x.height>=E.y+E.height?x.id:E.x<=x.x&&E.y<=x.y&&E.x+E.width>=x.x+x.width&&E.y+E.height>=x.y+x.height?E.id:void 0;n.push({kind:"group-overlap-unintended",groups:P,...H?{container:H}:{}})}const s=new Set(a.flatMap(y=>[...y.members])),c=y=>e.shapes.filter(v=>!v.container&&!Gc.has(v.type)&&v.x>=y.x&&v.y>=y.y&&v.x+v.width<=y.x+y.width&&v.y+v.height<=y.y+y.height);for(const y of a){const v=c(y);if(!v.length)continue;const x=new Set(y.members),E=v.filter(A=>!x.has(A.id));E.some(A=>s.has(A.id))&&(E.length*2<v.length||n.push({kind:"group-overlap-unreadable",reason:"minority",group:y.id,shapes:E.map(A=>A.id).sort()}))}for(const y of a){const v=new Set(c(y).map(k=>k.id)),x=new Set(y.members),E=new Set([...v].filter(k=>!x.has(k)&&s.has(k)));if(!E.size)continue;let A=!1,B=!1,P=!1;for(const k of e.edges){if(k.type!=="bpmn:SequenceFlow"||!k.source||!k.target)continue;const H=E.has(k.source),F=E.has(k.target);!H&&F&&!v.has(k.source)?A=!0:H&&!F&&!v.has(k.target)?B=!0:H&&F&&(P=!0)}A&&B&&P&&n.push({kind:"group-overlap-unreadable",reason:"throughpass",group:y.id,shapes:[...E].sort()})}const l=e.shapes.filter(y=>y.type==="bpmn:Group");for(let y=0;y<l.length;y++)for(let v=y+1;v<l.length;v++)for(let x=v+1;x<l.length;x++){const E=[l[y],l[v],l[x]],A={x:Math.max(...E.map(k=>k.x)),y:Math.max(...E.map(k=>k.y)),right:Math.min(...E.map(k=>k.x+k.width)),bottom:Math.min(...E.map(k=>k.y+k.height))};if(A.right-A.x<=Vc||A.bottom-A.y<=Vc)continue;const B=Fm(e,[],A);if(!B.length)continue;const P=E.map(k=>k.id).sort();n.push({kind:"group-stack-unreadable",groups:P,shapes:B})}for(const y of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of e.shapes){if(v.container||v.attached||Gc.has(v.type)||v.width<=0||v.height<=0)continue;const x=[["top",y.y,"h",y.x,y.x+y.width],["bottom",y.y+y.height,"h",y.x,y.x+y.width],["left",y.x,"v",y.y,y.y+y.height],["right",y.x+y.width,"v",y.y,y.y+y.height]];for(const[E,A,B,P,k]of x){const H=B==="h"?v.x:v.y,F=B==="h"?v.x+v.width:v.y+v.height;if(!(H<k&&P<F))continue;const G=B==="h"?v.y:v.x,ee=B==="h"?v.y+v.height:v.x+v.width;if(!(G<A&&A<ee))continue;const ce=Math.min(A-G,ee-A);ce<VC||n.push({kind:"group-cuts-shape",group:y.id,shape:v.id,side:E,depth:ce})}}const u=t.includeObservationOnly?e.shapes.filter(y=>y.type==="bpmn:Group"&&y.width>0&&y.height>0):[];if(u.length){const y=new Map(e.shapes.filter(v=>!v.container).map(v=>[v.id,{x:v.x+v.width/2,y:v.y+v.height/2}]));for(const v of e.edges){if(v.type!=="bpmn:SequenceFlow"&&v.type!=="bpmn:MessageFlow")continue;const x=an(v);if(x.length)for(const E of u){const A=E.x+E.width,B=E.y+E.height,P=v.endpoints.some(H=>{const F=y.get(H);return!!F&&E.x<F.x&&F.x<A&&E.y<F.y&&F.y<B});let k=null;for(const H of x){const[F,G,ee]=H.axis==="v"?[E.y,B,[["left",E.x],["right",A]]]:[E.x,A,[["top",E.y],["bottom",B]]],ce=Math.min(H.hi,G)-Math.max(H.lo,F);if(ce<af)continue;const ie=H.axis==="v"?E.x<H.at&&H.at<A:E.y<H.at&&H.at<B;if(!(ie&&P))for(const[be,de]of ee){const me=Math.abs(H.at-de);me<=ha&&(!k||me<k.distance)&&(k={side:be,inside:ie,distance:me,length:ce})}}k&&n.push({kind:"edge-along-group-boundary",edge:v.id,group:E.id,side:k.side,inside:k.inside,distance:Math.round(k.distance),length:Math.round(k.length)})}}}const p=e.shapes.filter(y=>y.container&&y.type!=="bpmn:Group"&&y.type!=="bpmn:Lane");for(const y of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of p){const x=y.x<v.x+v.width&&v.x<y.x+y.width,E=y.y<v.y+v.height&&v.y<y.y+y.height,A=[["top",y.y,v.y,x],["bottom",y.y+y.height,v.y+v.height,x],["left",y.x,v.x,E],["right",y.x+y.width,v.x+v.width,E]];for(const[B,P,k,H]of A)H&&Math.abs(P-k)<=Mm&&n.push({kind:"group-on-container-boundary",group:y.id,container:v.id,side:B})}const f=e.shapes.filter(y=>y.type==="bpmn:Group");for(let y=0;y<f.length;y++)for(let v=y+1;v<f.length;v++){const x=f[y],E=f[v],A=x.x<E.x+E.width&&E.x<x.x+x.width,B=x.y<E.y+E.height&&E.y<x.y+x.height,P=[["x",x.x+x.width,E.x,B],["x",E.x+E.width,x.x,B],["y",x.y+x.height,E.y,A],["y",E.y+E.height,x.y,A]];for(const[k,H,F,G]of P)if(G&&Math.abs(H-F)<=Mm){n.push({kind:"group-on-group-boundary",groups:x.id<E.id?[x.id,E.id]:[E.id,x.id],axis:k});break}}for(let y=0;y<e.edges.length;y++)for(let v=y+1;v<e.edges.length;v++){const x=e.edges[y],E=e.edges[v],A=Or(x,E);if(!A)continue;const B=x.id<E.id?[x.id,E.id]:[E.id,x.id];n.push({kind:A.kind==="opposite"?"edge-overlap-opposite":A.kind==="mixed"?"edge-overlap-mixed":"edge-overlap-unrelated",edges:B,axis:A.axis,length:Math.round(A.length)})}for(const y of e.edges){if(!y.label)continue;const v=Uc(y,e.edges);v&&n.push({kind:"label-on-shared-segment",edge:y.id,other:v.other,axis:v.axis})}for(const y of e.edges){if(!y.label)continue;const v=Dm(y,e);v&&n.push({kind:"label-over-line",edge:y.id,line:v})}if(t.includeObservationOnly){for(const y of e.edges)if(!(!y.label||y.type!=="bpmn:SequenceFlow"))for(const{shape:v,depth:x}of ds(y.label,e))n.push({kind:"label-over-shape",edge:y.id,shape:v,depth:Math.round(x)})}const d=new Set(i.map(y=>y.id)),g=e.shapes.filter(y=>y.type==="bpmn:Participant"&&y.label);for(const y of[...i,...g.filter(v=>!d.has(v.id))]){if(!y.label)continue;const v=zm(y,e);v&&n.push({kind:"label-over-line",edge:y.id,line:v})}const h=new Set(e.shapes.filter(y=>y.type==="bpmn:TextAnnotation").map(y=>y.id));for(const y of g)for(const{owner:v,rect:x}of zo(e))v===y.id||h.has(v)||uf(y.label,x,ga)&&n.push({kind:"pool-name-over-label",pool:y.id,label:v});const m=zo(e);for(const y of i)if(y.type==="bpmn:TextAnnotation")for(const{owner:v,rect:x}of m)v!==y.id&&uf(y,x,ga)&&n.push({kind:"annotation-over-label",annotation:y.id,label:v});const w=new Map(e.shapes.map(y=>[y.id,y]));for(const y of i){const v=y.parent??tM(y,e,w);if(!v)continue;const x=w.get(v);!x||!x.container||XC(x,y,KC)||y.type==="bpmn:TextAnnotation"&&!nM(y,x,e)||n.push({kind:"shape-outside-container",shape:y.id,container:x.id})}return n.sort((y,v)=>pt(y).localeCompare(pt(v)))}const zt=e=>typeof e=="object"&&e!==null?e:void 0,en=e=>typeof e=="number"?e:0,mo=e=>{const t=zt(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function iM(e){const t=zt(e);if(!t)return[];const n=[];for(const i of["sourceRef","targetRef"]){const o=t[i];for(const r of Array.isArray(o)?o:[o]){const a=mo(r);a&&n.push(a)}}return n}function oM(e){const t=zt(e);if(!t)return{};const n=Array.isArray(t.sourceRef)?void 0:mo(t.sourceRef),i=Array.isArray(t.targetRef)?void 0:mo(t.targetRef);return n&&i?{source:n,target:i}:{}}function rM(e,t){const n=zt(e.$parent);if(!n)return;const i=typeof n.$type=="string"?n.$type:"";if(i==="bpmn:Process"){const o=mo(n);return o?t.get(o):void 0}if(zc.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return mo(n)}function Wm(e){var a,s,c,l,u;const t=[],n=[],i=((a=zt(e))==null?void 0:a.diagrams)??[],o=new Map,r=new Set;for(const p of((s=zt(e))==null?void 0:s.rootElements)??[]){const f=zt(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=zt(d),h=mo(g),m=mo(g==null?void 0:g.processRef);h&&m?o.set(m,h):h&&r.add(h)}}for(const p of i){const f=zt((c=zt(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=zt(g);if(!h)continue;const m=zt(h.bpmnElement),w=typeof(m==null?void 0:m.id)=="string"?m.id:void 0;if(!w)continue;const y=typeof(m==null?void 0:m.$type)=="string"?m.$type:"",v=zt(h.bounds);if(v){const E=h.isExpanded===!1&&y!=="bpmn:Participant",A=zt((l=zt(h.label))==null?void 0:l.bounds),B={id:w,type:y,x:en(v.x),y:en(v.y),width:en(v.width),height:en(v.height),container:zc.has(y)&&!E,attached:(m==null?void 0:m.attachedToRef)!==void 0,...m?{parent:rM(m,o)}:{},...A?{label:{x:en(A.x),y:en(A.y),width:en(A.width),height:en(A.height)}}:{},...y==="bpmn:Group"?Hm(jm(m)):{}},P=h.isHorizontal!==!1,k=typeof(m==null?void 0:m.name)=="string"?m.name:"";r.has(w)&&P&&k&&(B.label=sf(B,k)),t.push(B);continue}const x=h.waypoint;if(Array.isArray(x)){const E=zt((u=zt(h.label))==null?void 0:u.bounds);n.push({id:w,type:y,waypoints:x.map(A=>{var B,P;return{x:en((B=zt(A))==null?void 0:B.x),y:en((P=zt(A))==null?void 0:P.y)}}),endpoints:iM(m),...oM(m),...E?{label:{x:en(E.x),y:en(E.y),width:en(E.width),height:en(E.height)}}:{}})}}}return{shapes:t,edges:n}}function Um(e){return ft(Wm(e),{includeObservationOnly:!0})}async function aM(e){const{definitions:t,warnings:n}=await pa(e);return{findings:Um(t),warnings:n}}function Ue(e){var i;const t=[],n=[];for(const o of e.getAll()){const r=o;if(r.type==="label"||r.labelTarget)continue;const a=typeof r.type=="string"?r.type:"";if(a==="bpmn:Definitions"||a.startsWith("bpmndi:"))continue;const s=r.waypoints;if(s){const h=zt(r.label),m=mo(r.source),w=mo(r.target);n.push({id:r.id,type:a,waypoints:s.map(y=>({x:en(y.x),y:en(y.y)})),endpoints:[m,w].filter(y=>!!y),...m&&w?{source:m,target:w}:{},...h&&typeof h.x=="number"?{label:{x:h.x,y:en(h.y),width:en(h.width),height:en(h.height)}}:{}});continue}if(typeof r.x!="number"||typeof r.y!="number")continue;const c=zt(r.businessObject),l=zt(r.label);let u=zt(r.parent);for(;u&&u.type==="bpmn:Lane";)u=zt(u.parent);const p=typeof(u==null?void 0:u.type)=="string"?u.type:"",f=u&&zc.has(p)&&p!=="bpmn:Group"&&typeof u.id=="string"?u.id:void 0,d={id:r.id,type:a,x:r.x,y:r.y,width:en(r.width),height:en(r.height),container:zc.has(a)&&(a==="bpmn:Participant"||r.collapsed!==!0),attached:(c==null?void 0:c.attachedToRef)!==void 0,...f!==void 0?{parent:f}:{},...l&&typeof l.x=="number"?{label:{x:l.x,y:en(l.y),width:en(l.width),height:en(l.height)}}:{},...a==="bpmn:Group"?Hm(jm(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=zt(r.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=sf(d,g)),t.push(d)}return{shapes:t,edges:n}}const sM={"bpmn:Participant":"participant","bpmn:Lane":"lane","bpmn:SequenceFlow":"sequenceFlow","bpmn:MessageFlow":"messageFlow","bpmn:DataStoreReference":"dataStore","bpmn:DataInputAssociation":"dataAssociation","bpmn:DataOutputAssociation":"dataAssociation","bpmn:TextAnnotation":"annotation","bpmn:Association":"association","bpmn:Group":"group"};function cM(e,t){const n=sM[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function qm(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Ym(e){const t=()=>e.getAll().filter(n=>n.type!=="label"&&!("labelTarget"in n&&n.labelTarget));return{isCollaboration:()=>t().some(n=>n.type==="bpmn:Participant"),categoryOf:n=>{const i=e.get(n);if(!(!i||i.type==="label"))return cM(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&qm(i)===n).sort((i,o)=>i.y-o.y).map(i=>i.id),laneDeclarationOrderOf:n=>{var s;const i=e.get(n),o=(s=i==null?void 0:i.businessObject)==null?void 0:s.processRef,r=[],a=c=>{for(const l of c??[])for(const u of l.lanes??[])r.push(u.id),a(u.childLaneSet?[u.childLaneSet]:void 0)};return a(o==null?void 0:o.laneSets),r},participantOf:n=>{const i=e.get(n);return i?qm(i):void 0},endpointsOf:n=>{var o,r;const i=e.get(n);if(!(!i||i.type==="label")&&"waypoints"in i)return{source:(o=i.source)==null?void 0:o.id,target:(r=i.target)==null?void 0:r.id}},eventDefinitionOf:n=>{var r;const i=e.get(n);if(!i||i.type!=="bpmn:IntermediateCatchEvent")return;const o=(((r=i.businessObject)==null?void 0:r.eventDefinitions)??[]).map(a=>a.$type);return kp(o)},reviewRequestLocalesOf:n=>{const i=e.get(n);return!i||i.type==="label"?[]:$o(i.businessObject).map(o=>o.locale)}}}const df=20,lM=4,Ke=(e,t)=>Math.abs(e-t)<.5;function qc(e,t,n,i=df){if(Ke(e.y,t.y)&&!Ke(e.x,t.x)){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x);if(!(o<n.x-i&&n.x+n.width+i<r))return null;const a=e.x<t.x?n.x-i:n.x+n.width+i,s=e.x<t.x?n.x+n.width+i:n.x-i,c=l=>[{x:a,y:e.y},{x:a,y:l},{x:s,y:l},{x:s,y:e.y}];return[c(n.y-i),c(n.y+n.height+i)]}if(Ke(e.x,t.x)&&!Ke(e.y,t.y)){const o=Math.min(e.y,t.y),r=Math.max(e.y,t.y);if(!(o<n.y-i&&n.y+n.height+i<r))return null;const a=e.y<t.y?n.y-i:n.y+n.height+i,s=e.y<t.y?n.y+n.height+i:n.y-i,c=l=>[{x:e.x,y:a},{x:l,y:a},{x:l,y:s},{x:e.x,y:s}];return[c(n.x-i),c(n.x+n.width+i)]}return null}function Km(e,t,n,i=df){if(n.length<2)return null;if(Ke(e.y,t.y)&&!Ke(e.x,t.x)){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x),a=Math.min(...n.map(d=>d.x))-i,s=Math.max(...n.map(d=>d.x+d.width))+i;if(!(o<a&&s<r))return null;const c=e.x<t.x?a:s,l=e.x<t.x?s:a,u=Math.min(...n.map(d=>d.y))-i,p=Math.max(...n.map(d=>d.y+d.height))+i,f=d=>[{x:c,y:e.y},{x:c,y:d},{x:l,y:d},{x:l,y:e.y}];return[f(u),f(p)]}if(Ke(e.x,t.x)&&!Ke(e.y,t.y)){const o=Math.min(e.y,t.y),r=Math.max(e.y,t.y),a=Math.min(...n.map(d=>d.y))-i,s=Math.max(...n.map(d=>d.y+d.height))+i;if(!(o<a&&s<r))return null;const c=e.y<t.y?a:s,l=e.y<t.y?s:a,u=Math.min(...n.map(d=>d.x))-i,p=Math.max(...n.map(d=>d.x+d.width))+i,f=d=>[{x:e.x,y:c},{x:d,y:c},{x:d,y:l},{x:e.x,y:l}];return[f(u),f(p)]}return null}function Xm(e,t,n=df){if(e.length!==4)return null;const[i,o,r,a]=e;if(Ke(i.y,o.y)&&Ke(o.x,r.x)&&Ke(r.y,a.y)){const s=c=>[i,{x:c,y:i.y},{x:c,y:a.y},a];return[s(t.x-n),s(t.x+t.width+n)]}if(Ke(i.x,o.x)&&Ke(o.y,r.y)&&Ke(r.x,a.x)){const s=c=>[i,{x:i.x,y:c},{x:a.x,y:c},a];return[s(t.y-n),s(t.y+t.height+n)]}return null}function Yc(e,t){if(e.endpoints.length!==2)return[];const n=t.find(p=>p.id===e.endpoints[0]),i=t.find(p=>p.id===e.endpoints[1]);if(!n||!i)return[];if(i.x<=n.x+n.width)return[];const o=n.y+n.height/2,r=i.y+i.height/2;if(o>=i.y&&o<=i.y+i.height)return[];const a=i.x+i.width/2,s=n.x+n.width/2,c=o>r,l=[{x:n.x+n.width,y:o},{x:a,y:o},{x:a,y:c?i.y+i.height:i.y}],u=[{x:s,y:c?n.y:n.y+n.height},{x:s,y:r},{x:i.x,y:r}];return[l,u]}const Kc=30,uM=[0,-25,25,-40,40];function pM(e,t){if(e.type!=="bpmn:MessageFlow"||e.endpoints.length!==2)return[];const n=t.find(f=>f.id===e.endpoints[0]),i=t.find(f=>f.id===e.endpoints[1]);if(!n||!i)return[];const o=n.y+n.height/2,r=i.y+i.height/2;if(i.y<n.y+n.height&&i.y+i.height>n.y)return[];const a=r<o,s=a?n.y+n.height:n.y,c=a?s+Kc:s-Kc,l=a?i.y+i.height:i.y,u=n.x+n.width/2,p=i.x+i.width/2;return uM.map(f=>[{x:u,y:s},{x:u,y:c},{x:p+f,y:c},{x:p+f,y:l}]).filter(f=>Ht({...e,endpoints:[],waypoints:f},[n]).length===0)}const hf=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],ya=(e,t,n)=>Ht({...e,waypoints:t},n).length;function Xc(e,t,n,i){let o=[...e.waypoints],r=ya(e,o,t);if(r===0)return null;let a=!1;for(const p of Yc(e,t))if(ya(e,p,t)===0)return p;const s=(i??[]).filter(p=>p.id!==e.id).flatMap(an),c=p=>an({...e,waypoints:p}).some(f=>Wc(f,s).length>0),l=pM(e,t).filter(p=>ya(e,p,t)===0);if(l.length)return l.find(p=>!c(p))??l[0];const u=p=>!n||p.every(f=>f.x>=n.x&&f.x<=n.x+n.width&&f.y>=n.y&&f.y<=n.y+n.height);if(e.endpoints.length===2&&o.length>2){const p=t.find(d=>d.id===e.endpoints[0]),f=t.find(d=>d.id===e.endpoints[1]);if(p&&f&&Ke(p.y+p.height/2,f.y+f.height/2)){const d=[o[0],o[o.length-1]];if(Ke(d[0].y,d[1].y)&&!Ke(d[0].x,d[1].x)){const g=t.filter(y=>!e.endpoints.includes(y.id)&&Ht({...e,waypoints:d},[y]).length>0),h=g.length>=2?Km(d[0],d[1],g):null,w=(h?h.map(y=>[d[0],...y,d[1]]):g.length===1?(qc(d[0],d[1],g[0])??[]).map(y=>[d[0],...y,d[1]]):g.length===0?[d]:[]).filter(y=>ya(e,y,t)===0&&y.length<=o.length).sort((y,v)=>Number(u(v))-Number(u(y)));if(w.length)return w.find(y=>!c(y))??w[0]}}}for(let p=0;p+1<o.length;p++){const f=o[p],d=o[p+1],g=t.filter(w=>!e.endpoints.includes(w.id)&&Ht({...e,waypoints:[f,d]},[w]).length>0);if(g.length<2)continue;const h=Km(f,d,g);if(!h)continue;const m=h.map(w=>hf(o,p,w)).filter(w=>ya(e,w,t)===0).sort((w,y)=>Number(u(y))-Number(u(w)));if(m.length)return m.find(w=>!c(w))??m[0]}for(let p=0;p<lM&&r>0;p++){let f=!1;for(let d=0;d+1<o.length&&!f;d++){const g=o[d],h=o[d+1];for(const m of t){if(e.endpoints.includes(m.id)||Ht({...e,waypoints:[g,h]},[m]).length===0)continue;const w=qc(g,h,m),y=w?w.map(x=>hf(o,d,x)):Xm(o,m)??[];if(!y.length)continue;const v=[...y].sort((x,E)=>Number(u(E))-Number(u(x)));for(const x of v){const E=ya(e,x,t);if(E<r){o=x,r=E,f=!0,a=!0;break}}if(f)break}}if(!f)break}return a&&r===0?o:null}function gf(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=Hn(r),s=new Set,c=ft(r).filter(u=>u.kind==="edge-crosses-shape"&&!t.has(pt(u)));if(!c.length)return s;const l=new Map;for(const u of c){if(u.kind!=="edge-crosses-shape"||l.has(u.edge))continue;const p=r.edges.find(f=>f.id===u.edge);p&&l.set(u.edge,p)}for(const[u,p]of l){if(n&&!n.has(u))continue;const f=i.get(u);if(!f)continue;const d=f.parent,g=d&&typeof d.x=="number"&&typeof d.width=="number"?{x:d.x,y:d.y,width:d.width,height:d.height}:void 0,h=Ht(p,a);if(!n&&h.length&&h.every(x=>x.type==="bpmn:TextAnnotation")){s.add(u);continue}const m=Xc(p,a,g,r.edges);if(!m){h.some(x=>x.type==="bpmn:TextAnnotation")&&s.add(u);continue}const w=r.edges.filter(x=>x.id!==u),y=hi(p,w);hi({...p,waypoints:m},w)>y||o.updateWaypoints(f,m)}return s}const fM=e=>{const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],o=e.waypoints[n+1];t.push({id:`__ghost:${e.id}:${n}`,type:"bpmn:Task",x:Math.min(i.x,o.x)-1,y:Math.min(i.y,o.y)-1,width:Math.max(2,Math.abs(o.x-i.x)+2),height:Math.max(2,Math.abs(o.y-i.y)+2),container:!1,attached:!1})}return t};function Zc(e){const t=e.parent;return t&&typeof t.x=="number"&&typeof t.width=="number"?{x:t.x,y:t.y,width:t.width,height:t.height}:void 0}const mf=(e,t)=>!t||e.every(n=>n.x>=t.x&&n.x<=t.x+t.width&&n.y>=t.y&&n.y<=t.y+t.height),yf=(e,t)=>fs(e,[t])>0;function Zm(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=Hn(r);let s=r;const c=new Set(ft(r).map(pt));for(const[l,u]of go(r))if(!t.has(`${l}|${u}`))for(const[p,f]of[[l,u],[u,l]]){if(n.has(p))continue;const d=s.edges.find(B=>B.id===p),g=s.edges.find(B=>B.id===f);if(!d||!g)continue;const h=i.get(p);if(!h)continue;const m=Zc(h),w=fM(g),y=[...Yc(d,a)??[]],v=Xc(d,[...a,...w],m,r.edges);v&&y.push(v);for(let B=0;B+1<d.waypoints.length;B++)for(const P of w)for(const k of qc(d.waypoints[B],d.waypoints[B+1],P)??[])y.push(hf(d.waypoints,B,k));const x=s.edges.filter(B=>B.id!==p),E=B=>({...s,edges:s.edges.map(P=>P.id===p?{...P,waypoints:B}:P)}),A=y.find(B=>{const P={...d,waypoints:B};return yf(P,g)||!mf(B,m)||x.some(k=>k.id!==f&&!yf(d,k)&&yf(P,k))?!1:ft(E(B)).every(k=>c.has(pt(k)))});if(A){o.updateWaypoints(h,A),s=E(A);break}}}const dM=["top","bottom","left","right"],Qm={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}},hs=20,hM=20;function gM(e,t){const n=e.x>=t.x-.5&&e.x<=t.x+t.width+.5,i=e.y>=t.y-.5&&e.y<=t.y+t.height+.5,o=[];return n&&Ke(e.y,t.y)&&o.push("top"),n&&Ke(e.y,t.y+t.height)&&o.push("bottom"),i&&Ke(e.x,t.x)&&o.push("left"),i&&Ke(e.x,t.x+t.width)&&o.push("right"),o.length===1?o[0]:null}const mM=(e,t)=>t==="top"?{x:e.x+e.width/2,y:e.y}:t==="bottom"?{x:e.x+e.width/2,y:e.y+e.height}:t==="left"?{x:e.x,y:e.y+e.height/2}:{x:e.x+e.width,y:e.y+e.height/2};function Jm(e,t,n,i){const o=Qm[t],r=Qm[i],a=o.x===0,s=r.x===0;if(a===s){const p=a?"y":"x",f=a?"x":"y",d=o[p],g=r[p];if(Ke(e[f],n[f]))return d===-g&&d*(n[p]-e[p])>=hs?[e,n]:null;let h;if(d===-g){const w=e[p]+d*hs,y=n[p]-d*hs;if(d*(y-w)<0)return null;h=Math.round((e[p]+n[p])/2)}else h=d>0?Math.max(e[p],n[p])+Kc:Math.min(e[p],n[p])-Kc;const m=(w,y)=>a?{x:y,y:w}:{x:w,y};return[e,m(h,e[f]),m(h,n[f]),n]}const c=a?{x:e.x,y:n.y}:{x:n.x,y:e.y},l=a?o.y*(c.y-e.y):o.x*(c.x-e.x),u=s?r.y*(c.y-n.y):r.x*(c.x-n.x);return l>=hs&&u>=hs?[e,c,n]:null}function yM(e,t,n){const i=e.waypoints;if(i.length<2||!e.source||!e.target||e.source===e.target)return[];const o=e.source===t.id,r=n.get(o?e.target:e.source),a=o?i[i.length-1]:i[0],s=r?gM(a,r):null;if(!s)return[];const c=[];for(const l of dM){const u=mM(t,l),p=o?Jm(u,l,a,s):Jm(a,s,u,l);p&&c.push(p)}return c}const ey=e=>e.slice(1).reduce((t,n,i)=>t+Math.abs(n.x-e[i].x)+Math.abs(n.y-e[i].y),0);function vM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=new Map(r.shapes.map(l=>[l.id,l])),s=new Set(ft(r).map(pt));let c=r;for(const[l,u]of Fi(r)){if(t.has(`${l}|${u}`))continue;const p=c.edges.find(k=>k.id===l),f=c.edges.find(k=>k.id===u);if(!p||!f||p.type!=="bpmn:SequenceFlow"||f.type!=="bpmn:SequenceFlow"||n.has(l)&&n.has(u)||!Fi({edges:[p,f]}).length)continue;const d=p.endpoints.find(k=>f.endpoints.includes(k)),g=d?a.get(d):void 0;if(!g||g.container)continue;const h=i.get(l),m=i.get(u);if(!h||!m)continue;const w=k=>n.has(k.id)?[k.waypoints]:[k.waypoints,...yM(k,g,a)],y=k=>k.length-2,v=w(p).flatMap(k=>w(f).map(H=>({pa:k,pb:H}))).filter(({pa:k,pb:H})=>k!==p.waypoints||H!==f.waypoints).map(k=>({...k,cost:ey(k.pa)+ey(k.pb)+hM*(y(k.pa)+y(k.pb))})).sort((k,H)=>k.cost-H.cost),x=Zc(h),E=Zc(m),A=Fi(c).length,B=new Set(go(c).map(([k,H])=>`${k}|${H}`)),P=v.find(({pa:k,pb:H})=>{const F={...p,waypoints:k},G={...f,waypoints:H};if(Fi({edges:[F,G]}).length||Or(F,G)||!mf(k,x)||!mf(H,E))return!1;const ee={...c,edges:c.edges.map(ce=>ce.id===l?F:ce.id===u?G:ce)};return Fi(ee).length>=A||go(ee).some(([ce,ie])=>!B.has(`${ce}|${ie}`))?!1:ft(ee).every(ce=>s.has(pt(ce)))});P&&(P.pa!==p.waypoints&&o.updateWaypoints(h,P.pa),P.pb!==f.waypoints&&o.updateWaypoints(m,P.pb),c={...c,edges:c.edges.map(k=>k.id===l?{...p,waypoints:P.pa}:k.id===u?{...f,waypoints:P.pb}:k)})}}const bM=40,xM=20;function wM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=l=>{const u=Ue(i),p=Fi(u);return{keys:new Set(ft(u).map(pt)),crossings:go(u).length,shared:p.length,mine:p.filter(([f,d])=>f===l||d===l).length}},a=(l,u)=>{const p=Ue(i),f=p.edges.find(d=>d.id===l);return f?new Set(Ht({...f,waypoints:u},Hn(p)).map(d=>d.id)):null},s=l=>!!l&&l.type==="bpmn:Participant"&&!(l.children??[]).length&&n.has(l.id),c=i.getAll().filter(l=>l.type==="bpmn:MessageFlow"&&!t.has(l.id));for(const l of c){const u=l.source,p=l.target,f=s(u)?u:s(p)?p:void 0;if(!f)continue;const d=f===u?p:u;if(!d||d.type==="bpmn:Participant")continue;const g=d.x+d.width/2;if(g>=f.x+10&&g<=f.x+f.width-10)continue;const h=g>f.x+f.width,m=f.y>d.y,w=m?d.y+d.height:d.y,y=m?f.y:f.y+f.height,v=Math.round((w+y)/2),x=H=>f===u?[...H].reverse():H,E=(l.waypoints??[]).map(H=>({x:H.x,y:H.y})),A=r(l.id),B=a(l.id,E)??new Set,P=h?f.x+f.width:f.x,k=f.x+f.width/2;for(let H=Math.min(bM,f.width/4);h?P-H>k:P+H<k;H+=xM){const F=Math.round(h?P-H:P+H),G=x([{x:g,y:w},{x:g,y:v},{x:F,y:v},{x:F,y}]),ee=a(l.id,G);if(!ee||[...ee].some(ie=>!B.has(ie)))continue;o.updateWaypoints(l,G);const ce=r(l.id);if(ce.crossings<=A.crossings&&ce.shared<=A.shared&&ce.mine<=A.mine&&[...ce.keys].every(ie=>A.keys.has(ie)))break;o.updateWaypoints(l,E)}}}const _M=10;function ty(e,t){if(e.parent){const o=t.find(r=>r.id===e.parent);if(o)return o}const n=e.x+e.width/2,i=e.y+e.height/2;return t.find(o=>n>=o.x&&n<=o.x+o.width&&i>=o.y&&i<=o.y+o.height)}function ny(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter(G=>G.type==="bpmn:Participant"&&G.container),i=t.shapes.find(G=>G.id===e.endpoints[0]),o=t.shapes.find(G=>G.id===e.endpoints[1]);if(!i||!o)return null;const r=ty(i,n),a=ty(o,n);if(!r||!a||r.id===a.id)return null;const s=a.y>r.y,c=s?r:a,l=s?a:r,u=n.filter(G=>G.id!==r.id&&G.id!==a.id&&G.y>=c.y+c.height&&G.y+G.height<=l.y).sort((G,ee)=>G.y-ee.y);if(!u.length)return null;const p=u[0],f=u[u.length-1],d=(c.y+c.height+p.y)/2,g=(f.y+f.height+l.y)/2,h=s?d:g,m=s?g:d,w=e.waypoints[0],y=e.waypoints[e.waypoints.length-1],v=Hn(t),x=t.edges.filter(G=>G.id!==e.id),E=gi(e,x),A=Ht(e,v).length;if(E===0&&A===0||A===0&&e.waypoints.length===2)return null;const B=Math.min(...u.map(G=>G.x)),P=Math.max(...u.map(G=>G.x+G.width)),k=(w.x+y.x)/2,H=G=>G.filter((ee,ce)=>ce===0||!(Ke(ee.x,G[ce-1].x)&&Ke(ee.y,G[ce-1].y)));let F;for(let G=B;G<=P;G+=_M){const ee=H([w,{x:w.x,y:h},{x:G,y:h},{x:G,y:m},{x:y.x,y:m},y]),ce={...e,waypoints:ee};if(Ht(ce,v).length>0)continue;const ie=gi(ce,x),be=Math.abs(G-k);(!F||ie<F.cross||ie===F.cross&&be<F.detour)&&(F={pts:ee,cross:ie,detour:be})}return F&&(A>0?F.cross<=E:F.cross<E)?F.pts:null}const EM=new Set(["bpmn:SequenceFlow","bpmn:MessageFlow"]);function SM(e,t,n){var l,u;const{elementRegistry:i}=e,o=e.modeling,r=new Map(t.shapes.map(p=>[p.id,p])),a=Ue(i),s=new Map(a.shapes.map(p=>[p.id,p])),c=Hn(a);for(const p of t.edges){if(!EM.has(p.type)||!p.source||!p.target||n.has(p.id))continue;const f=i.get(p.id);if(!(f!=null&&f.waypoints)||((l=f.source)==null?void 0:l.id)!==p.source||((u=f.target)==null?void 0:u.id)!==p.target)continue;const d=r.get(p.source),g=r.get(p.target),h=s.get(p.source),m=s.get(p.target);if(!d||!g||!h||!m||!Ke(d.width,h.width)||!Ke(d.height,h.height)||!Ke(g.width,m.width)||!Ke(g.height,m.height))continue;const w=h.x-d.x,y=h.y-d.y;if(Ke(w,0)&&Ke(y,0)||!Ke(m.x-g.x,w)||!Ke(m.y-g.y,y))continue;const v=p.waypoints.map(A=>({x:A.x+w,y:A.y+y})),x=f.waypoints.map(A=>({x:A.x,y:A.y}));x.length===v.length&&x.every((A,B)=>Ke(A.x,v[B].x)&&Ke(A.y,v[B].y))||x.length===2&&(Ke(x[0].x,x[1].x)||Ke(x[0].y,x[1].y))&&Ht({...p,waypoints:x},c).length===0||Ht({...p,waypoints:v},c).length>0||o.updateWaypoints(f,v)}}function iy(e,t){const{elementRegistry:n}=e,i=e.modeling,o=Ue(n);for(const r of o.edges){if(r.type!=="bpmn:MessageFlow"||t.has(r.id))continue;const a=Ue(n),s=a.edges.find(u=>u.id===r.id);if(!s)continue;const c=ny(s,a);if(!c)continue;const l=n.get(r.id);l&&i.updateWaypoints(l,c)}}const vf=20,oy=10,ji=10,bf=40,RM=6,CM=40,ry=50;function MM(e,t){return t.some(n=>{const[i,o,r,a]=e.axis==="h"?[n.x,n.x+n.width,n.y,n.y+n.height]:[n.y,n.y+n.height,n.x,n.x+n.width];if(e.hi<=i||e.lo>=o||e.at>r&&e.at<a)return!1;const s=Math.min(Math.abs(e.at-r),Math.abs(e.at-a));return s>0&&s<=RM})}function xf(e,t,n){let i=0;for(let o=1;o<e.length;o++){const r=e[o-1],a=e[o];if(Ke(r.y,a.y))for(const s of n)t.has(s.id)||r.y<=s.y+1||r.y>=s.y+s.height-1||(i+=Math.max(0,Math.min(Math.max(r.x,a.x),s.x+s.width)-Math.max(Math.min(r.x,a.x),s.x)))}return i}function AM(e,t){if(e.axis!=="h")return!1;const n=(i,o)=>e.lo<o&&e.hi>i;return t.some(i=>{const o=i.label;return!o||i.container||!n(i.x,i.x+i.width)||!n(o.x,o.x+o.width)?!1:o.y>=i.y+i.height?e.at>=i.y+i.height&&e.at<=o.y:o.y+o.height<=i.y?e.at>=o.y+o.height&&e.at<=i.y:!1})}function wf(e,t,n){if(t>n)return[];const i=[Math.min(Math.max(e,t),n)];for(let o=oy;o<=n-t;o+=oy)e+o<=n&&i.push(e+o),e-o>=t&&i.push(e-o);return i}function PM(e,t,n,i,o){const r=[],a=e.type==="bpmn:Participant",s=t.type==="bpmn:Participant",c=t.y>=e.y+e.height;if(!c&&t.y+t.height>e.y)return{inPools:r,outside:[]};const l=c?e.y+e.height:e.y,u=c?t.y:t.y+t.height,p=e.x+e.width/2,f=t.x+t.width/2,d=(ie,be)=>be>ie.x+ji&&be<ie.x+ie.width-ji,g=(ie,be)=>ie.width<=2*bf?ie.x+ie.width/2:Math.min(Math.max(be,ie.x+bf),ie.x+ie.width-bf),h=Math.max(e.x,t.x)+ji,m=Math.min(e.x+e.width,t.x+t.width)-ji;if(h<=m){const ie=!a&&d(t,p)?p:!s&&d(e,f)?f:Math.round((h+m)/2);r.push([{x:ie,y:l},{x:ie,y:u}])}const w=s?g(t,p):f,y=a?g(e,f):p;if(!a&&!d(e,w)){const ie=w<e.x?e.x:e.x+e.width;for(const be of wf(e.y+e.height/2,e.y+ji,e.y+e.height-ji))r.push([{x:ie,y:be},{x:w,y:be},{x:w,y:u}])}if(!s&&!d(t,y)){const ie=y<t.x?t.x:t.x+t.width;for(const be of wf(t.y+t.height/2,t.y+ji,t.y+t.height-ji))r.push([{x:y,y:l},{x:y,y:be},{x:ie,y:be}])}const v=(ie,be)=>{if(Math.abs(be-ie)<2*ji)return[];const de=Math.min(ie,be)+ji,me=Math.max(ie,be)-ji;return wf(Math.round((ie+be)/2),de,me)};if(!a&&n)for(const ie of v(l,c?n.y+n.height:n.y))r.push([{x:p,y:l},{x:p,y:ie},{x:w,y:ie},{x:w,y:u}]);if(!s&&i)for(const ie of v(u,c?i.y:i.y+i.height))r.push([{x:y,y:l},{x:y,y:ie},{x:f,y:ie},{x:f,y:u}]);const x=Math.min(y,w),E=Math.max(y,w),A=[];for(const[ie,be]of o.filter(de=>de.x<E&&de.x+de.width>x).map(de=>[de.y,de.y+de.height]).sort((de,me)=>de[0]-me[0])){const de=A[A.length-1];de&&ie<=de[1]?de[1]=Math.max(de[1],be):A.push([ie,be])}const B=[];for(let ie=1;ie<A.length;ie++)A[ie][0]-A[ie-1][1]>=CM&&B.push(Math.round((A[ie-1][1]+A[ie][0])/2));A.length&&B.push(A[0][0]-ry,A[A.length-1][1]+ry);const P=(ie,be)=>be<ie.y?ie.y:be>ie.y+ie.height?ie.y+ie.height:void 0,k=new Set([a?e.id:n==null?void 0:n.id,s?t.id:i==null?void 0:i.id].filter(ie=>!!ie)),H=e.y+e.height/2,F=t.y+t.height/2,G=F>H?1:-1,ee=(ie,be,de)=>o.some(me=>!k.has(me.id)&&me.x<ie&&ie<me.x+me.width&&me.y<Math.max(be,de)-1&&me.y+me.height>Math.min(be,de)+1),ce=[];for(const ie of B){const be=P(e,ie),de=P(t,ie);be===void 0||de===void 0||(ie-H)*G<0&&ee(y,be,ie)||(ie-F)*G>0&&ee(w,de,ie)||ce.push({pts:[{x:y,y:be},{x:y,y:ie},{x:w,y:ie},{x:w,y:de}],len:Math.abs(ie-be)+(E-x)+Math.abs(de-ie)})}return{inPools:r,outside:ce.sort((ie,be)=>ie.len-be.len).map(ie=>ie.pts)}}function TM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=new Map(n.edges.map(d=>[d.id,d.waypoints])),a=n.shapes.filter(d=>d.type==="bpmn:Participant"),s=d=>{let g=d;for(;g&&g.type!=="bpmn:Participant";)g=g.parent;return g==null?void 0:g.id},c=()=>{const d=Ue(i);return{keys:new Set(ft(d).map(pt)),crossings:go(d).length,shared:Fi(d).length}},l=(d,g)=>d.length===g.length&&d.every((h,m)=>Ke(h.x,g[m].x)&&Ke(h.y,g[m].y)),u=d=>{const g=d.source,h=d.target;if(!g||!h)return"skip";const m=Ue(i),w=new Map(m.shapes.map(U=>[U.id,U])),y=s(g),v=s(h),x=new Set([y,v].filter(U=>!!U)),E=m.shapes.filter(U=>U.type==="bpmn:Participant"),A=(d.waypoints??[]).map(U=>({x:U.x,y:U.y})),B=xf(A,x,E);if(B<vf)return"skip";if(t.has(d.id)){const U=r.get(d.id);if(U&&l(U,A)||B-(U?xf(U,x,a):0)<vf)return"skip"}const P=w.get(g.id),k=w.get(h.id),H=m.edges.find(U=>U.id===d.id);if(!P||!k||!H)return"skip";const F=Hn(m),G=new Set(Ht(H,F).map(U=>U.id)),ee=zo(m).filter(U=>U.owner!==d.id&&U.owner!==P.id&&U.owner!==k.id),ce=[...m.shapes.filter(U=>!U.container&&U.id!==P.id&&U.id!==k.id),...ee.map(U=>U.rect)],ie=U=>an({...H,waypoints:U}).some(ue=>MM(ue,ce)),be=PM(P,k,y?w.get(y):void 0,v?w.get(v):void 0,E),de=U=>U.map((ue,K)=>({pts:ue,i:K,key:ue.length*2+(ie(ue)?1:0)})).sort((ue,K)=>ue.key-K.key||ue.i-K.i).map(ue=>ue.pts),me=[...de(be.inPools),...de(be.outside)],Ee=c();for(const U of me){if(xf(U,x,E)>=vf)continue;const ue={...H,waypoints:U};if(Ht(ue,F).some(he=>!G.has(he.id))||an(ue).some(he=>AM(he,m.shapes)||ee.some(Re=>$i(Re.rect,he))))continue;o.updateWaypoints(d,U);const J=c();if(J.crossings<=Ee.crossings&&J.shared<=Ee.shared&&[...J.keys].every(he=>Ee.keys.has(he)))return"fixed";o.updateWaypoints(d,A)}return"stuck"},p=i.getAll().filter(d=>d.type==="bpmn:MessageFlow"),f=[];for(const d of p)u(d)==="stuck"&&f.push(d);for(const d of f)u(d)}const Hi=[25,-25,40,-40],va=35;function kM(e,t,n=[]){const i=e.x+e.width/2,o=t.x+t.width/2,r=[],a=n.filter(s=>!s.container&&s.id!==e.id&&s.id!==t.id&&s.label).map(s=>({...s.label,id:`${s.id}:label`,type:"label",container:!1,attached:!1}));for(const s of[!0,!1]){const c=s?e.y:e.y+e.height,l=s?t.y:t.y+t.height,u=s?Math.min(e.y,t.y)-va:Math.max(e.y+e.height,t.y+t.height)+va,p=DM(e,t,s,u,n),f=p===null?[[u,0]]:[[u,0],[p,OM]];for(const[d,g]of f)for(const h of[0,...Hi])if(!(Math.abs(h)>=e.width/2-5))for(const m of[0,...Hi]){if(Math.abs(m)>=t.width/2-5)continue;const w=i+h,y=o+m,v=[{x:w,y:c},{x:w,y:d},{x:y,y:d},{x:y,y:l}];g&&Ht({endpoints:[],waypoints:v},a).length||r.push({pts:v,cost:g+Math.abs(m)+Math.abs(h)})}}return r}const OM=45,Qc=20;function DM(e,t,n,i,o){if(!o.length)return null;const r=e.x+e.width/2,a=t.x+t.width/2,s=Math.min(r,a),c=Math.max(r,a),l=n?Math.min(e.y,t.y):Math.max(e.y+e.height,t.y+t.height),u=o.filter(m=>m.container&&(m.type==="bpmn:Lane"||m.type==="bpmn:Participant")&&r>=m.x&&r<=m.x+m.width&&e.y>=m.y&&e.y+e.height<=m.y+m.height).sort((m,w)=>m.width*m.height-w.width*w.height)[0];if(!u)return null;const p=o.filter(m=>!m.container&&m.id!==e.id&&m.id!==t.id),f=p.filter(m=>m.x<c&&m.x+m.width>s&&(n?m.y<l&&m.y+m.height>i:m.y+m.height>l&&m.y<i));if(!f.length)return null;const d=[...p,...p.flatMap(m=>m.label?[m.label]:[])].filter(m=>m.x<c&&m.x+m.width>s);if(n){let m=Math.min(...f.map(y=>y.y));for(let y=!0;y;){y=!1;for(const v of d)v.y<m&&v.y<l&&v.y+v.height>m-Qc&&(m=v.y,y=!0)}const w=Math.max(u.y,...d.filter(y=>y.y+y.height<=m).map(y=>y.y+y.height));return m-w>=Qc?Math.round((m+w)/2):null}let g=Math.max(...f.map(m=>m.y+m.height));for(let m=!0;m;){m=!1;for(const w of d)w.y+w.height>g&&w.y+w.height>l&&w.y<g+Qc&&(g=w.y+w.height,m=!0)}const h=Math.min(u.y+u.height,...d.filter(m=>m.y>=g).map(m=>m.y));return h-g>=Qc?Math.round((g+h)/2):null}function Jc(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(i.x+i.width>n.x)return[];const o=n.y+n.height/2;if(o>=i.y&&o<=i.y+i.height)return kM(n,i,[...t.values()]);const r=i.x+i.width/2,a=n.x+n.width/2,s=o<i.y,c=s?i.y:i.y+i.height,l=s?n.y:n.y+n.height,u=s?n.y-va:n.y+n.height+va,p=[];for(const y of[0,...Hi]){if(Math.abs(y)>=i.width/2-5)continue;const v=r+y;p.push({pts:[{x:n.x,y:o},{x:v,y:o},{x:v,y:c}],cost:Math.abs(y)});for(const x of[0,...Hi]){if(Math.abs(x)>=n.width/2-5)continue;const E=a+x;p.push({pts:[{x:E,y:l},{x:E,y:u},{x:v,y:u},{x:v,y:c}],cost:Math.abs(y)+Math.abs(x)})}}const f=50,d=i.y+i.height/2,g=s?n.y+n.height:n.y;for(const y of[0,...Hi]){if(Math.abs(y)>=n.width/2-5)continue;const v=a+y;p.push({pts:[{x:v,y:g},{x:v,y:d},{x:i.x+i.width,y:d}],cost:f+Math.abs(y)})}const h=60,m=s?i.y+i.height:i.y,w=s?i.y+i.height+va:i.y-va;for(const y of[0,...Hi]){if(Math.abs(y)>=i.width/2-5)continue;const v=r+y;for(const x of[0,...Hi]){if(Math.abs(x)>=n.width/2-5)continue;const E=a+x;p.push({pts:[{x:E,y:g},{x:E,y:w},{x:v,y:w},{x:v,y:m}],cost:h+Math.abs(y)+Math.abs(x)})}}return p}const el=30;function ay(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],o=e[n+1],r=Ke(i.y,o.y)&&!Ke(i.x,o.x),a=Ke(i.x,o.x)&&!Ke(i.y,o.y);if(!(!r&&!a))for(const s of t)if(r){const c=Math.min(i.x,o.x);if(Math.max(i.x,o.x)<=s.x||c>=s.x+s.width)continue;if(Math.abs(i.y-s.y)<el||Math.abs(i.y-(s.y+s.height))<el)return!0}else{const c=Math.min(i.y,o.y);if(Math.max(i.y,o.y)<=s.y||c>=s.y+s.height)continue;if(Math.abs(i.x-s.x)<el||Math.abs(i.x-(s.x+s.width))<el)return!0}}return!1}const tl=40;function LM(e,t,n){let i=0;for(const o of t){if(o.container||n.includes(o.id))continue;const r=o.x-tl,a=o.x+o.width+tl,s=o.y-tl,c=o.y+o.height+tl;for(let l=1;l<e.length-2;l++){const u=e[l],p=e[l+1],f={x:Math.min(u.x,p.x),y:Math.min(u.y,p.y)},d={x:Math.max(u.x,p.x),y:Math.max(u.y,p.y)};if(f.x<a&&d.x>r&&f.y<c&&d.y>s){i++;break}}}return i}function sy(e,t){if(e.type!=="bpmn:SequenceFlow")return null;const n=t.shapes.filter(A=>A.container),i=new Map(t.shapes.map(A=>[A.id,A])),o=Hn(t),r=t.edges.filter(A=>A.id!==e.id),a=hi(e,r),s=gi(e,r),c=A=>LM(A,t.shapes,e.endpoints)+(ay(A,n)?1:0),l=c(e.waypoints),u=A=>{if(!A)return;const B=A.x+A.width/2,P=A.y+A.height/2;return n.find(k=>k.type==="bpmn:Lane"&&B>=k.x&&B<=k.x+k.width&&P>=k.y&&P<=k.y+k.height)},p=u(i.get(e.endpoints[0]??"")),f=u(i.get(e.endpoints[1]??"")),d=!!p&&!!f&&p.id!==f.id,g=A=>{if(!d||!f)return!1;for(let B=1;B<A.length-2;B++){const P=A[B],k=A[B+1];if(Ke(P.y,k.y)&&!Ke(P.x,k.x)&&P.y>f.y&&P.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),w=(A=>{if(!A)return;const B=A.x+A.width/2,P=A.y+A.height/2;return n.filter(k=>k.type==="bpmn:Participant"&&B>=k.x&&B<=k.x+k.width&&P>=k.y&&P<=k.y+k.height).sort((k,H)=>k.width*k.height-H.width*H.height)[0]})(i.get(e.endpoints[0]??"")),y=A=>{if(!w)return 0;let B=0;for(let P=1;P<A.length-1;P++){const k=A[P];(k.x<w.x||k.x>w.x+w.width||k.y<w.y||k.y>w.y+w.height)&&B++}return B},v=y(e.waypoints);if(!ay(e.waypoints,n)&&!(d&&!h)&&v===0)return null;const x=A=>A.reduce((B,P,k)=>k?B+Math.abs(P.x-A[k-1].x)+Math.abs(P.y-A[k-1].y):0,0);let E;for(const{pts:A,cost:B}of Jc(e,i)){const P={...e,waypoints:A};if(Ht(P,o).length>0)continue;const k=hi(P,r);if(k>a)continue;const H=y(A);if(H>v)continue;const F=H<v&&k===0;if(!F&&gi(P,r)>s)continue;const G=c(A),ee=g(A);if(!F&&!(ee&&!h)&&G>=l)continue;const ie=ee?0:1,be=x(A);(!E||H<E.out||H===E.out&&(ie<E.lane||ie===E.lane&&(k<E.opp||k===E.opp&&(G<E.sc||G===E.sc&&(B<E.cost||B===E.cost&&be<E.len)))))&&(E={pts:A,out:H,sc:G,lane:ie,opp:k,cost:B,len:be})}return(E==null?void 0:E.pts)??null}function IM(e,t){if(e.type!=="bpmn:SequenceFlow"||e.endpoints.length!==2)return!1;const[n,i]=e.endpoints,o=t.edges.filter(p=>p.type==="bpmn:SequenceFlow"&&p.endpoints.length===2),r=o.filter(p=>p.endpoints[1]===i),a=o.filter(p=>p.endpoints[0]===i);if(r.length!==1||a.length!==1)return!1;const s=t.shapes.find(p=>p.id===n),c=t.shapes.find(p=>p.id===i),l=t.shapes.find(p=>p.id===a[0].endpoints[1]);if(!s||!c||!l||!(s.x+s.width<c.x&&c.x+c.width<l.x))return!1;const u=s.y+s.height/2;return u<l.y||u>l.y+l.height?!1:u<c.y||u>c.y+c.height}function BM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i).edges.filter(a=>(!t.has(a.id)||n.has(a.id))&&a.waypoints.length>=4).map(a=>a.id).sort();for(const a of r){const s=Ue(i),c=s.edges.find(m=>m.id===a);if(!c||c.waypoints.length<4)continue;const l=Hn(s),u=s.edges.filter(m=>m.id!==a),p=Ht(c,l).length,f=hi(c,u),d=gi(c,u),g=n.has(a)?new Set(ft(s).map(pt)):null,h=Yc(c,s.shapes);h.length===2&&IM(c,s)&&h.reverse();for(const m of h){if(m.length>=c.waypoints.length)continue;const w={...c,waypoints:m};if(Ht(w,l).length>p||hi(w,u)>f||gi(w,u)>d)continue;if(g){const v=new Set(ft({...s,edges:s.edges.map(A=>A.id===a?w:A)}).map(pt)),x=[...v].filter(A=>!g.has(A)).length,E=[...g].filter(A=>!v.has(A)).length;if(x>E)continue}const y=i.get(a);y&&o.updateWaypoints(y,m);break}}}function cy(e,t){const{elementRegistry:n}=e,i=e.modeling,o=Ue(n).edges.filter(r=>r.type==="bpmn:SequenceFlow"&&!t.has(r.id)).map(r=>r.id).sort();for(const r of o){const a=Ue(n),s=a.edges.find(u=>u.id===r);if(!s)continue;const c=sy(s,a);if(!c)continue;const l=n.get(r);l&&i.updateWaypoints(l,c)}}function _f(e,t){const n=e.waypoints;if(n.length<3)return[];const i=[],o=t.get(e.endpoints[0]??""),r=t.get(e.endpoints[1]??""),a=Ke(n[0].x,n[1].x)&&!Ke(n[0].y,n[1].y),s=Ke(n[n.length-1].x,n[n.length-2].x)&&!Ke(n[n.length-1].y,n[n.length-2].y);for(const c of Hi){if(a&&o&&Math.abs(c)<o.width/2-5){const l=n.map(u=>({...u}));l[0].x+=c,l[1].x+=c,i.push({pts:l,cost:Math.abs(c)})}if(s&&r&&Math.abs(c)<r.width/2-5){const l=n.map(u=>({...u}));l[l.length-1].x+=c,l[l.length-2].x+=c,i.push({pts:l,cost:Math.abs(c)})}}return i}const ly=e=>e==="bpmn:SequenceFlow"||e==="bpmn:MessageFlow";function NM(e,t,n){const i=e.waypoints;if(i.length<2||!ly(e.type))return[];const o=i[0],r=i[1],a=Ke(o.y,r.y)&&!Ke(o.x,r.x),s=Ke(o.x,r.x)&&!Ke(o.y,r.y);if(!a&&!s)return[];const c=Math.sign(a?r.x-o.x:r.y-o.y);if(!t.some(g=>{if(!ly(g.type)||g.type===e.type||g.waypoints.length<2)return!1;const h=g.waypoints[0],m=g.waypoints[1];return!Ke(h.x,o.x)||!Ke(h.y,o.y)?!1:a?Ke(h.y,m.y)&&Math.sign(m.x-h.x)===c:Ke(h.x,m.x)&&Math.sign(m.y-h.y)===c}))return[];const u=n.get(e.endpoints[0]??""),p=n.get(e.endpoints[1]??"");if(!u)return[];const f=(g,h)=>a?h>g.y+5&&h<g.y+g.height-5:h>g.x+5&&h<g.x+g.width-5,d=[];for(const g of Hi){const h=(a?o.y:o.x)+g;if(!f(u,h)||i.length===2&&(!p||!f(p,h)))continue;const m=i.map(w=>({...w}));for(const w of[m[0],m[1]])a?w.y=h:w.x=h;d.push({pts:m,cost:Math.abs(g)})}return d}function $M(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(Math.min(n.x+n.width,i.x+i.width)-Math.max(n.x,i.x)>=1)return[];const o=i.y+i.height<=n.y,r=n.y+n.height<=i.y;if(!o&&!r)return[];const a=i.x>=n.x+n.width,s=i.x+i.width<=n.x;if(!a&&!s)return[];const c=n.x+n.width/2,l=n.y+n.height/2,u=i.x+i.width/2,p=i.y+i.height/2,f=a?n.x+n.width:n.x,d=r?n.y+n.height:n.y,g=a?i.x:i.x+i.width,h=r?i.y:i.y+i.height,m=[];for(const w of[0,...Hi])Math.abs(w)<i.width/2-5&&m.push({pts:[{x:f,y:l},{x:u+w,y:l},{x:u+w,y:h}],cost:Math.abs(w)}),Math.abs(w)<i.height/2-5&&m.push({pts:[{x:c,y:d},{x:c,y:p+w},{x:g,y:p+w}],cost:Math.abs(w)});return m}const FM=[[1/2,0],[1/3,25],[2/3,25]],uy=20;function jM(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];const o=n.y+n.height/2,r=i.y+i.height/2;if(Math.abs(o-r)<1)return[];const a=[],s=(c,l)=>{for(const[u,p]of FM){const f=Math.round(c+(l-c)*u);a.push({pts:[{x:c,y:o},{x:f,y:o},{x:f,y:r},{x:l,y:r}],cost:p})}};return n.x+n.width+uy<=i.x&&s(n.x+n.width,i.x),i.x+i.width+uy<=n.x&&s(n.x,i.x+i.width),a}function Ef(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];const o=Math.max(n.x,i.x),r=Math.min(n.x+n.width,i.x+i.width);if(r-o<1)return[];const a=i.y+i.height<=n.y,s=n.y+n.height<=i.y;if(!a&&!s)return[];const c=a?n.y:n.y+n.height,l=a?i.y+i.height:i.y,u=(o+r)/2,p=[];for(const f of[0,...Hi]){const d=u+f;d<=o||d>=r||p.push({pts:[{x:d,y:c},{x:d,y:l}],cost:Math.abs(f)})}return p}function py(e,t,n={}){const i=new Map(t.shapes.map(g=>[g.id,g])),o=Hn(t),r=t.edges.filter(g=>g.id!==e.id),a=hi(e,r);if(a===0)return null;const s=gi(e,r);let c;const l=g=>g.reduce((h,m,w)=>w?h+Math.abs(m.x-g[w-1].x)+Math.abs(m.y-g[w-1].y):0,0),u=3,p=g=>{const h=g[0],m=g[g.length-1],w=Math.hypot(m.x-h.x,m.y-h.y);return w>=1&&l(g)/w>=u?1:0},f=p(e.waypoints),d=[...Jc(e,i),...Ef(e,i),..._f(e,i),...NM(e,r,i),...n.sideEntry?jM(e,i):[]];for(const{pts:g,cost:h}of d){const m={...e,waypoints:g};if(Ht(m,o).length>0)continue;const w=hi(m,r),y=gi(m,r),v=a-w+(f-p(g));if(w>=a||y-s>v)continue;const x=l(g);(!c||w<c.opposite||w===c.opposite&&(y<c.cross||y===c.cross&&(h<c.cost||h===c.cost&&x<c.len)))&&(c={pts:g,opposite:w,cross:y,cost:h,len:x})}return(c==null?void 0:c.pts)??null}function fy(e,t){var i;let n=0;for(const o of t)o.id!==e.id&&((i=Or(e,o))==null?void 0:i.kind)==="unrelated"&&n++;return n}function HM(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=Hn(t),o=t.edges.filter(f=>f.id!==e.id),r=fy(e,o);if(r===0)return null;const a=hi(e,o),s=gi(e,o),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[...Jc(e,n),...Ef(e,n),...$M(e,n),..._f(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(Ht(g,i).length>0)continue;const h=fy(g,o);if(h>=r)continue;const m=hi(g,o);if(m-h>a-r)continue;const w=gi(g,o);if(w-s>(r-h)*l)continue;const y=c(f);(!u||h<u.fake||h===u.fake&&(m<u.unreadable||m===u.unreadable&&(w<u.cross||w===u.cross&&(d<u.cost||d===u.cost&&y<u.length))))&&(u={pts:f,fake:h,unreadable:m,cross:w,cost:d,length:y})}return(u==null?void 0:u.pts)??null}function dy(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=ft(Ue(i)).filter(s=>s.kind==="edge-overlap-unrelated"&&!t.has(pt(s)));if(!r.length)return;const a=new Set;for(const s of r)if(s.kind==="edge-overlap-unrelated")for(const c of s.edges)n.has(c)||a.add(c);for(const s of[...a].sort()){const c=Ue(i),l=c.edges.find(f=>f.id===s);if(!l)continue;const u=HM(l,c);if(!u)continue;const p=i.get(s);p&&o.updateWaypoints(p,u)}}function hy(e,t){const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");return!!n&&!!i&&i.x+i.width>n.x}function gy(e,t,n){var l;if(e.type!=="bpmn:SequenceFlow"||t.type!=="bpmn:SequenceFlow"||((l=Or(e,t))==null?void 0:l.kind)!=="opposite")return!1;const[i,o]=e.endpoints,[r,a]=t.endpoints,s=[i,o].filter(u=>u&&(u===r||u===a)).length;return!(!!o&&o===r||!!a&&a===i)||s!==1?!1:hy(e,n)&&hy(t,n)}function my(e,t,n){let i=0;for(const o of t)o.id!==e.id&&gy(e,o,n)&&i++;return i}function zM(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=Hn(t),o=t.edges.filter(f=>f.id!==e.id),r=my(e,o,n);if(r===0)return null;const a=hi(e,o),s=gi(e,o),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[...Jc(e,n),...Ef(e,n),..._f(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(Ht(g,i).length>0)continue;const h=my(g,o,n);if(h>=r)continue;const m=hi(g,o);if(m-h>a-r)continue;const w=gi(g,o);if(w-s>(r-h)*l)continue;const y=c(f);(!u||h<u.chain||h===u.chain&&(m<u.unreadable||m===u.unreadable&&(w<u.cross||w===u.cross&&(d<u.cost||d===u.cost&&y<u.length))))&&(u={pts:f,chain:h,unreadable:m,cross:w,cost:d,length:y})}return(u==null?void 0:u.pts)??null}function GM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=new Map(r.shapes.map(l=>[l.id,l])),s=ft(r).filter(l=>l.kind==="edge-overlap-opposite"&&!t.has(pt(l)));if(!s.length)return;const c=new Set;for(const l of s){if(l.kind!=="edge-overlap-opposite")continue;const[u,p]=l.edges.map(f=>r.edges.find(d=>d.id===f));if(!(!u||!p||!gy(u,p,a)))for(const f of l.edges)n.has(f)||c.add(f)}for(const l of[...c].sort()){const u=Ue(i),p=u.edges.find(g=>g.id===l);if(!p)continue;const f=zM(p,u);if(!f)continue;const d=i.get(l);d&&o.updateWaypoints(d,f)}}function yy(e,t,n,i=new Set){const{elementRegistry:o}=e,r=e.modeling,a=new Set,s=Ue(o),c=ft(s).filter(f=>cf(f)&&!t.has(pt(f)));if(!c.length)return a;const l=new Set;for(const f of c)if(cf(f))for(const d of f.edges)n.has(d)||l.add(d);const u=f=>{var d;return((d=s.edges.find(g=>g.id===f))==null?void 0:d.type)??""},p=[...l].sort((f,d)=>{const g=u(f)==="bpmn:SequenceFlow"?0:1,h=u(d)==="bpmn:SequenceFlow"?0:1;return g!==h?g-h:f.localeCompare(d)});for(const f of p){const d=Ue(o),g=d.edges.find(w=>w.id===f);if(!g)continue;const h=py(g,d,{sideEntry:i.has(f)});if(!h)continue;const m=o.get(f);m&&(r.updateWaypoints(m,h),a.add(f))}return a}const VM=10,WM=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;function vy(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!Uc(e,i))return null;const o=Hn(t),r=i.flatMap(an);for(const a of an(e)){let s=[[a.lo,a.hi]];for(const[d,g]of Wc(a,r))s=s.flatMap(([h,m])=>{const w=[];return d>h&&w.push([h,Math.min(m,d)]),g<m&&w.push([Math.max(h,g),m]),w.filter(([y,v])=>v>y)});const c=a.axis==="h"?n.width:n.height,l=s.find(([d,g])=>g-d>=c+VM*2);if(!l)continue;const u=(l[0]+l[1])/2,p=a.axis==="h"?{x:u,y:a.at-km}:{x:a.at+Tn+n.width/2,y:u},f={x:p.x-n.width/2,y:p.y-n.height/2,width:n.width,height:n.height};if(!Uc({...e,label:f},i)&&!o.some(d=>!e.endpoints.includes(d.id)&&WM(f,d)))return f}return null}const Tn=8;function Sf(e,t){const n=e.label;if(!n)return null;const i=an(e);if(!i.length)return null;const o=n.x+n.width/2,r=n.y+n.height/2,a=f=>{const d=f.axis==="h"?o:r,g=f.axis==="h"?r-f.at:o-f.at,h=d<f.lo?f.lo-d:d>f.hi?d-f.hi:0;return Math.hypot(g,h)},s=i.reduce((f,d)=>a(d)<a(f)?d:f,i[0]),c=[...i,...t.edges.filter(f=>f.id!==e.id).flatMap(an),...t.shapes.filter(f=>f.container).flatMap(ma)],l=f=>!c.some(d=>$i(f,d));if(l(n))return null;const u=(s.axis==="v"?n.height:n.width)+Tn,p=[0,-u,u,-2*u,2*u];if(s.axis==="v")for(const f of[s.at+Tn,s.at-Tn-n.width])for(const d of p){const g=n.y+d;if(g<s.lo||g+n.height>s.hi)continue;const h={...n,x:f,y:g};if(l(h))return h}else for(const f of[s.at-Tn-n.height,s.at+Tn])for(const d of p){const g=n.x+d;if(g<s.lo||g+n.width>s.hi)continue;const h={...n,x:g,y:f};if(l(h))return h}return null}const by=30,UM=(e,t)=>{let n=1/0;for(let i=0;i+1<t.length;i++){const o=t[i],r=t[i+1],a=r.x-o.x,s=r.y-o.y,c=a*a+s*s,l=c?Math.max(0,Math.min(1,((e.x-o.x)*a+(e.y-o.y)*s)/c)):0;n=Math.min(n,Math.hypot(e.x-(o.x+l*a),e.y-(o.y+l*s)))}return n},xy=(e,t)=>UM({x:e.x+e.width/2,y:e.y+e.height/2},t);function qM(e,t){const n=e.label;if(!n)return null;const i=an(e);if(!i.length)return null;const o=[...i,...t.edges.filter(c=>c.id!==e.id).flatMap(an),...t.shapes.filter(c=>c.container).flatMap(ma)],r=zo(t).filter(c=>c.owner!==e.id).map(c=>c.rect),a=(c,l)=>c.x<l.x+l.width&&l.x<c.x+c.width&&c.y<l.y+l.height&&l.y<c.y+c.height,s=c=>!o.some(l=>$i(c,l))&&!ds(c,t).length&&!r.some(l=>a(c,l));for(const c of i){const l=(c.lo+c.hi)/2,u=c.axis==="h"?[c.at+Tn,c.at-Tn-n.height].map(p=>({...n,x:l-n.width/2,y:p})):[c.at+Tn,c.at-Tn-n.width].map(p=>({...n,x:p,y:l-n.height/2}));for(const p of u)if(s(p))return p}return null}function wy(e,t,n=new Set){var s,c;const{elementRegistry:i}=e,o=e.modeling;let r=Ue(i),a=new Set(ft(r).map(pt));for(const[l,u]of t){const p=u.wps,f=i.get(l),d=f==null?void 0:f.label;if(!d||!(f!=null&&f.waypoints))continue;const g=f.waypoints[0].x-p[0].x,h=f.waypoints[0].y-p[0].y;if(!(f.waypoints.length===p.length&&f.waypoints.every((B,P)=>B.x-p[P].x===g&&B.y-p[P].y===h))){if(((s=f.source)==null?void 0:s.id)===u.source&&((c=f.target)==null?void 0:c.id)===u.target)continue;const B=r.edges.find(G=>G.id===l);if(!(B!=null&&B.label)||!ds(B.label,r).length&&!n.has(l))continue;let P={...B.label,x:u.label.x,y:u.label.y};if((ds(P,r).length||xy(P,B.waypoints)>by)&&(P=null),!P&&xy(B.label,B.waypoints)>by&&(P=qM(B,r)),!P)continue;const k=P;if(k.x===d.x&&k.y===d.y)continue;const H={...r,edges:r.edges.map(G=>G.id===l?{...G,label:k}:G)},F=ft(H);if(F.some(G=>!a.has(pt(G))))continue;o.moveElements([d],{x:k.x-d.x,y:k.y-d.y}),r=H,a=new Set(F.map(pt));continue}const w=u.label.x+g-d.x,y=u.label.y+h-d.y;if(w===0&&y===0)continue;const v=r.edges.find(B=>B.id===l);if(!(v!=null&&v.label))continue;const x={...v.label,x:v.label.x+w,y:v.label.y+y},E={...r,edges:r.edges.map(B=>B.id===l?{...B,label:x}:B)},A=ft(E);A.some(B=>!a.has(pt(B)))||(o.moveElements([d],{x:w,y}),r=E,a=new Set(A.map(pt)))}}function _y(e,t,n=new Set){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i);for(const a of r.edges){if(!a.label||t.has(a.id)&&!n.has(a.id))continue;const s=Sf(a,r);if(!s)continue;const c=i.get(a.id),l=c==null?void 0:c.label;l&&o.moveElements([l],{x:s.x-l.x,y:s.y-l.y})}}function Ey(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=ft(r).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(pt(s)));for(const s of a){if(s.kind!=="label-on-shared-segment"||n.has(s.edge))continue;const c=r.edges.find(f=>f.id===s.edge);if(!c)continue;const l=vy(c,r);if(!l)continue;const u=i.get(s.edge),p=u==null?void 0:u.label;p&&o.moveElements([p],{x:l.x-p.x,y:l.y-p.y})}}function Sy(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(an),...t.shapes.filter(f=>f.container).flatMap(ma)],o=i.filter(f=>$i(n,f));if(!o.length)return null;const r=t.shapes.filter(f=>!f.container&&f.id!==e.id),a=zo(t).filter(f=>f.owner!==e.id).map(f=>f.rect),s=(f,d)=>f.x<d.x+d.width&&d.x<f.x+f.width&&f.y<d.y+d.height&&d.y<f.y+f.height,c=f=>!i.some(d=>$i(f,d))&&!r.some(d=>s(f,d))&&!a.some(d=>s(f,d)),l=[];for(const f of o)f.axis==="h"?l.push({...n,y:f.at-Tn-n.height},{...n,y:f.at+Tn}):l.push({...n,x:f.at-Tn-n.width},{...n,x:f.at+Tn});const u=e.x+e.width/2,p=e.y+e.height/2;return l.push({...n,x:u-n.width/2,y:e.y+e.height+Tn},{...n,x:u-n.width/2,y:e.y-Tn-n.height},{...n,x:e.x+e.width+Tn,y:p-n.height/2},{...n,x:e.x-Tn-n.width,y:p-n.height/2}),l.find(c)??null}function Ry(e,t){const{elementRegistry:n}=e,i=e.modeling,o=Ue(n);for(const r of o.shapes){if(r.container||!r.label||t.has(r.id))continue;const a=Sy(r,Ue(n));if(!a)continue;const s=n.get(r.id),c=s==null?void 0:s.label;c&&i.moveElements([c],{x:a.x-c.x,y:a.y-c.y})}}function YM(e,t){const n=e.x,i=e.x+e.width,o=e.y,r=e.y+e.height;if(t.x<n||t.x>i||t.y<o||t.y>r)return{x:Math.round(Math.min(Math.max(t.x,n),i)),y:Math.round(Math.min(Math.max(t.y,o),r))};const s=[[t.x-n,{x:n,y:t.y}],[i-t.x,{x:i,y:t.y}],[t.y-o,{x:t.x,y:o}],[r-t.y,{x:t.x,y:r}]].reduce((c,l)=>l[0]<c[0]?l:c);return{x:Math.round(s[1].x),y:Math.round(s[1].y)}}function Cy(e,t){const{elementRegistry:n}=e,i=e.modeling;let o=Ue(n),r=new Set(ft(o).map(pt));const a=[...new Set(ft(o).filter(s=>s.kind==="edge-endpoint-detached"&&!t.has(pt(s))).map(s=>s.edge))].sort();for(const s of a){const c=o.edges.find(h=>h.id===s);if(!c||c.waypoints.length<2)continue;const l=c.waypoints.map(h=>({...h})),u=[[c.endpoints[0],0],[c.endpoints[1],l.length-1]];let p=!1;for(const[h,m]of u){const w=h?o.shapes.find(v=>v.id===h):void 0;if(!w)continue;const y=YM(w,l[m]);y.x===l[m].x&&y.y===l[m].y||(l[m]=y,p=!0)}if(!p)continue;const f={...o,edges:o.edges.map(h=>h.id===s?{...h,waypoints:l}:h)},d=ft(f);if(d.some(h=>!r.has(pt(h))))continue;const g=n.get(s);g&&(i.updateWaypoints(g,l),o=f,r=new Set(d.map(pt)))}}const Rf=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function My(e,t){const n=(o,r,a,s="name")=>{const c=s==="text"?"texts":"names",l=u=>r?`${r}.${u}`:u;return{id:o,plainField:l(s),mapField:l(c),plain:a[s],map:a[c]}},i=e;switch(e.kind){case"participant.add":return[n(e.participant.id,"participant",e.participant),...(e.participant.lanes??[]).map((o,r)=>n(o.id,`participant.lanes[${r}]`,o))];case"participant.update":return[n(e.id,"",i),...(e.lanes??[]).map((o,r)=>({...n(o.id,`lanes[${r}]`,o),omittedMeansRemove:(t==null?void 0:t.categoryOf(o.id))==="lane"}))];case"node.add":return[n(e.node.id,"node",e.node)];case"sequenceFlow.add":return[{...n(e.flow.id,"flow",e.flow),condition:e.flow.condition,conditionField:"flow.condition"}];case"sequenceFlow.update":return[{...n(e.id,"",i),condition:e.condition,conditionField:"condition"}];case"messageFlow.add":return[n(e.flow.id,"flow",e.flow)];case"dataStore.add":return[n(e.dataStore.id,"dataStore",e.dataStore)];case"annotation.add":return[n(e.annotation.id,"annotation",e.annotation,"text")];case"annotation.update":return[n(e.id,"",i,"text")];case"group.add":return[n(e.group.id,"group",e.group)];case"node.update":case"messageFlow.update":case"dataStore.update":case"group.update":return[n(e.id,"",i)];default:return[]}}function KM(e,t,n){const i=[],o=n?ss(n):[];return e.forEach((r,a)=>{if(r.kind==="translation.confirm"){if(!n){i.push({kind:"locale-texts-not-enabled",opIndex:a,id:r.id,field:"locale"});return}if(!o.includes(r.locale)){i.push({kind:"locale-not-in-document",opIndex:a,id:r.id,field:"locale",locale:r.locale,locales:o});return}t.categoryOf(r.id)!==void 0&&!t.reviewRequestLocalesOf(r.id).includes(r.locale)&&i.push({kind:"review-request-missing",opIndex:a,id:r.id,locale:r.locale});return}for(const s of My(r,t)){const c=s.plain!==void 0,l=s.map!==void 0;if(c&&l){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.mapField});continue}if(l&&s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.conditionField});continue}if(!n){l&&i.push({kind:"locale-texts-not-enabled",opIndex:a,id:s.id,field:s.mapField});continue}if(c&&s.plain!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.plainField,locales:o});continue}if(s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.conditionField,locales:o});continue}if(!l)continue;if(!Rf(s.map)){i.push({kind:"payload-invalid",opIndex:a,field:s.mapField});continue}const u=s.map;let p=!0;for(const[d,g]of Object.entries(u))typeof g!="string"||g===""?(i.push({kind:"payload-invalid",opIndex:a,field:`${s.mapField}.${d}`}),p=!1):o.includes(d)||(i.push({kind:"locale-not-in-document",opIndex:a,id:s.id,field:s.mapField,locale:d,locales:o}),p=!1);if(!p)continue;const f=o.filter(d=>!(d in u));f.length&&i.push({kind:"locale-texts-incomplete",opIndex:a,id:s.id,field:s.mapField,missing:f})}}),i}function wi(e,t,n){const i=t==="text"?"texts":"names",{[i]:o,...r}=e;return n===void 0?r:{...r,[t]:n}}function XM(e,t,n){const i=new Map;if(!n)return{ops:[...e],writes:i};const{designLocale:o}=n,r=c=>{let l=i.get(c);return l||i.set(c,l={}),l},a=c=>{if(Rf(c.map)){const l=c.map;return r(c.id).texts={...l},l[o]}if(c.plain===null||c.condition===null&&c.plain===void 0){r(c.id).texts=null;return}c.plain===void 0&&c.omittedMeansRemove&&(r(c.id).texts=null)},s=[];for(const c of e){if(c.kind==="translation.confirm"){const u=r(c.id);u.confirm=[...u.confirm??[],c.locale];continue}const l=My(c,t);if(!l.length){s.push(c);continue}switch(c.kind){case"participant.add":{const[u,...p]=l,f=wi(c.participant,"name",a(u));c.participant.lanes&&(f.lanes=c.participant.lanes.map((d,g)=>wi(d,"name",a(p[g])))),s.push({...c,participant:f});break}case"participant.update":{const[u,...p]=l,f=wi(c,"name",a(u));c.lanes&&(f.lanes=c.lanes.map((d,g)=>wi(d,"name",a(p[g])))),s.push(f);break}case"node.add":s.push({...c,node:wi(c.node,"name",a(l[0]))});break;case"sequenceFlow.add":s.push({...c,flow:wi(c.flow,"name",a(l[0]))});break;case"messageFlow.add":s.push({...c,flow:wi(c.flow,"name",a(l[0]))});break;case"dataStore.add":s.push({...c,dataStore:wi(c.dataStore,"name",a(l[0]))});break;case"annotation.add":s.push({...c,annotation:wi(c.annotation,"text",a(l[0]))});break;case"group.add":s.push({...c,group:wi(c.group,"name",a(l[0]))});break;case"annotation.update":s.push(wi(c,"text",a(l[0])));break;default:s.push(Rf(l[0].map)?wi(c,"name",a(l[0])):(a(l[0]),c))}}return{ops:s,writes:i}}const ZM=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,Ay=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),Py={"participant.add":[{path:"participant",shape:["id"]},{path:"participant.lanes[]",shape:["id"],optional:!0}],"participant.update":[{path:"id",shape:null},{path:"lanes[]",shape:["id"],optional:!0}],"node.add":[{path:"node",shape:["id","type"]}],"node.update":[{path:"id",shape:null}],"sequenceFlow.add":[{path:"flow",shape:["id","source","target"]}],"sequenceFlow.update":[{path:"id",shape:null}],"messageFlow.add":[{path:"flow",shape:["id","source","target"]}],"messageFlow.update":[{path:"id",shape:null}],"dataStore.add":[{path:"dataStore",shape:["id"]},{path:"associations[]",shape:["source","target"],optional:!0}],"dataStore.update":[{path:"id",shape:null}],"dataAssociation.add":[{path:"association",shape:["source","target"]}],"association.add":[{path:"association",shape:["source","target"]}],"annotation.add":[{path:"annotation",shape:["id"]},{path:"association",shape:["source","target"],optional:!0},{path:"placement",shape:["anchor","side"],optional:!0}],"annotation.update":[{path:"id",shape:null},{path:"placement",shape:["anchor","side"],optional:!0}],"group.add":[{path:"group",shape:["id"]},{path:"group.members[]",shape:null,optional:!0}],"group.update":[{path:"id",shape:null},{path:"members[]",shape:null,optional:!0}],"translation.confirm":[{path:"id",shape:null},{path:"locale",shape:null}],"element.remove":[{path:"id",shape:null}]},gs=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),nl=e=>typeof e=="string"&&e!=="";function QM(e){const t=[];function n(i,o,r,a){if(a===null){nl(r)||t.push({kind:"payload-invalid",opIndex:i,field:o});return}if(!gs(r)){t.push({kind:"payload-invalid",opIndex:i,field:o});return}for(const s of a)nl(r[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${o}.${s}`})}return e.forEach((i,o)=>{var r,a,s;if(!gs(i)||!nl(i.kind)||!(i.kind in Py)){t.push({kind:"payload-invalid",opIndex:o,field:"kind"});return}for(const c of Py[i.kind]){const l=c.path.endsWith("[]"),u=l?c.path.slice(0,-2):c.path,p=u.split(".");let f=i;for(const g of p.slice(0,-1)){if(!gs(f))break;f=f[g]}if(!gs(f))continue;const d=f[p[p.length-1]];if(!(d===void 0&&c.optional)&&!(d===null&&c.optional)){if(!l){n(o,c.path,d,c.shape);continue}if(!Array.isArray(d)){t.push({kind:"payload-invalid",opIndex:o,field:c.path});continue}d.forEach((g,h)=>n(o,`${u}[${h}]`,g,c.shape))}}if(i.kind==="annotation.add"){const c=i.annotation;gs(c)&&!nl(c.text)&&c.texts===void 0&&t.push({kind:"payload-invalid",opIndex:o,field:"annotation.text"})}if(i.kind==="node.add"||i.kind==="node.update"){const c=i.band;c!==void 0&&(!Number.isInteger(c)||c<0)&&t.push({kind:"payload-invalid",opIndex:o,field:"band"});const l=i.kind==="node.add"?(r=i.node)==null?void 0:r.type:i.type,u=(i.kind==="node.add"?(a=i.node)==null?void 0:a.id:i.id)??"";if(typeof l=="string"&&!Yg(l)){t.push({kind:"node-type-unsupported",opIndex:o,id:u,type:l});return}const p=i.kind==="node.add"?(s=i.node)==null?void 0:s.eventDefinition:i.eventDefinition;if(p!==void 0&&!Kg(p)){t.push({kind:"payload-invalid",opIndex:o,field:i.kind==="node.add"?"node.eventDefinition":"eventDefinition"});return}l==="intermediateCatchEvent"!==(p!==void 0)&&t.push({kind:"event-definition-mismatch",opIndex:o,id:u,...typeof l=="string"?{type:l}:{},...p!==void 0?{eventDefinition:p}:{}})}}),t}function Ty(e,t,n={}){const i=QM(e);if(i.length>0)return i;const o=[],r=new Map,a=new Map;function s(h,m,w){if(!ZM.test(m)){o.push({kind:"id-invalid",opIndex:h,id:m});return}if(t.categoryOf(m)!==void 0||r.has(m)){o.push({kind:"id-duplicate",opIndex:h,id:m});return}r.set(m,{...w,opIndex:h})}e.forEach((h,m)=>{var w;switch(h.kind){case"participant.add":s(m,h.participant.id,{category:"participant",lanes:(h.participant.lanes??[]).map(y=>y.id)});for(const y of h.participant.lanes??[])s(m,y.id,{category:"lane"});break;case"node.add":s(m,h.node.id,{category:"flowNode",participant:h.node.participant});break;case"sequenceFlow.add":s(m,h.flow.id,{category:"sequenceFlow"});break;case"messageFlow.add":s(m,h.flow.id,{category:"messageFlow"});break;case"dataStore.add":s(m,h.dataStore.id,{category:"dataStore"});for(const y of h.associations??[])y.id&&s(m,y.id,{category:"dataAssociation"});break;case"dataAssociation.add":h.association.id&&s(m,h.association.id,{category:"dataAssociation"});break;case"association.add":h.association.id&&s(m,h.association.id,{category:"association"});break;case"annotation.add":s(m,h.annotation.id,{category:"annotation"}),(w=h.association)!=null&&w.id&&s(m,h.association.id,{category:"association"});break;case"group.add":s(m,h.group.id,{category:"group"});break;case"participant.update":if(h.lanes){a.set(h.id,h.lanes.map(y=>y.id));for(const y of h.lanes)t.categoryOf(y.id)===void 0&&s(m,y.id,{category:"lane"})}break}});const c=h=>{var m;return((m=r.get(h))==null?void 0:m.category)??t.categoryOf(h)},l=h=>{const m=r.get(h);return m?m.category==="participant"?h:m.participant:t.categoryOf(h)==="participant"?h:t.participantOf(h)};function u(h,m,w,y){const v=c(m);if(v===void 0){o.push({kind:"ref-missing",opIndex:h,ref:m,role:w});return}if(y&&!y.includes(v)){o.push({kind:"ref-category",opIndex:h,ref:m,role:w,expected:y.join("|"),actual:v});return}return v}const p=t.isCollaboration()||e.some(h=>h.kind==="participant.add"),f=new Map;for(const h of e)h.kind==="node.add"?f.set(h.node.id,h.node.eventDefinition):h.kind==="node.update"&&h.type!==void 0&&f.set(h.id,h.eventDefinition);const d=h=>f.has(h)?f.get(h)==="timer":t.eventDefinitionOf(h)==="timer";return e.forEach((h,m)=>{var w,y;switch(h.kind){case"participant.add":break;case"node.add":{const{participant:v,lane:x}=h.node;if(v===void 0){(p||x!==void 0)&&o.push({kind:"participant-required",opIndex:m,id:h.node.id});break}if(u(m,v,"participant",["participant"])===void 0)break;x!==void 0&&((((w=r.get(v))==null?void 0:w.lanes)??a.get(v)??t.lanesOf(v)).includes(x)||o.push({kind:"lane-unknown",opIndex:m,lane:x,participant:v}));break}case"sequenceFlow.add":{const{id:v,source:x,target:E,name:A,condition:B}=h.flow,P=u(m,x,"source",["flowNode"]),k=u(m,E,"target",["flowNode"]);P&&k&&l(x)!==l(E)&&o.push({kind:"flow-cross-pool",opIndex:m,id:v}),A!==void 0&&B!==void 0&&o.push({kind:"condition-name-conflict",opIndex:m,id:v});break}case"messageFlow.add":{const{id:v,source:x,target:E}=h.flow,A=u(m,x,"source",["flowNode","participant"]),B=u(m,E,"target",["flowNode","participant"]);if(A&&B){const P=l(x),k=l(E);P!==void 0&&P===k&&o.push({kind:"message-flow-same-pool",opIndex:m,id:v})}for(const P of[x,E])d(P)&&o.push({kind:"message-flow-timer-endpoint",opIndex:m,id:v,ref:P});break}case"dataStore.add":{for(const v of h.associations??[]){if([v.source,v.target].filter(A=>A===h.dataStore.id).length!==1){o.push({kind:"data-association-ends",opIndex:m,source:v.source,target:v.target});continue}const E=v.source===h.dataStore.id?v.target:v.source;u(m,E,"dataAssociation",["flowNode"])}break}case"dataAssociation.add":{const{source:v,target:x}=h.association,E=u(m,v,"source"),A=u(m,x,"target");if(E&&A){const B=new Set([E,A]);B.has("dataStore")&&B.has("flowNode")||o.push({kind:"data-association-ends",opIndex:m,source:v,target:x})}break}case"association.add":{const{id:v,source:x,target:E}=h.association,A=u(m,x,"source"),B=u(m,E,"target");A&&B&&A!=="annotation"&&B!=="annotation"&&o.push({kind:"association-detached",opIndex:m,annotation:v??`${x}->${E}`});break}case"annotation.add":{if(h.association){const{source:v,target:x}=h.association;if(v!==h.annotation.id&&x!==h.annotation.id)o.push({kind:"association-detached",opIndex:m,annotation:h.annotation.id});else{const E=v===h.annotation.id?x:v;u(m,E,"association")}}h.placement&&u(m,h.placement.anchor,"anchor");break}case"group.add":{for(const v of h.group.members??[]){const x=u(m,v,"member");x&&Ay.has(x)&&o.push({kind:"ref-category",opIndex:m,ref:v,role:"member",expected:"shape",actual:x})}break}case"participant.update":{if(g(m,h.id,"participant")===void 0)break;if(h.lanes){const v=t.lanesOf(h.id),x=h.lanes.map(P=>P.id);for(const P of v)x.includes(P)||o.push({kind:"lane-shrink-unsupported",opIndex:m,participant:h.id,lane:P});for(const P of x)t.categoryOf(P)!==void 0&&!v.includes(P)&&o.push({kind:"id-duplicate",opIndex:m,id:P});const E=x.filter(P=>v.includes(P)),A=P=>E.every((k,H)=>k===P[H]),B=(((y=t.laneDeclarationOrderOf)==null?void 0:y.call(t,h.id))??v).filter(P=>v.includes(P));E.length===v.length&&!A(v)&&!A(B)&&o.push({kind:"lane-reorder-unsupported",opIndex:m,participant:h.id})}break}case"node.update":{if(g(m,h.id,"flowNode")===void 0)break;if(h.lane!==void 0){const v=t.participantOf(h.id);(v?a.get(v)??t.lanesOf(v):[]).includes(h.lane)||o.push({kind:"lane-unknown",opIndex:m,lane:h.lane,participant:v??""})}break}case"sequenceFlow.update":{if(g(m,h.id,"sequenceFlow")===void 0)break;if(h.name!==void 0&&h.condition!==void 0&&o.push({kind:"condition-name-conflict",opIndex:m,id:h.id}),h.source!==void 0||h.target!==void 0){const v=h.source===void 0||u(m,h.source,"source",["flowNode"])!==void 0,x=h.target===void 0||u(m,h.target,"target",["flowNode"])!==void 0,E=t.endpointsOf(h.id),A=h.source??(E==null?void 0:E.source),B=h.target??(E==null?void 0:E.target);v&&x&&A!==void 0&&B!==void 0&&new Set([l(A),l(B),l(h.id)]).size>1&&o.push({kind:"flow-cross-pool",opIndex:m,id:h.id})}break}case"messageFlow.update":g(m,h.id,"messageFlow");break;case"dataStore.update":g(m,h.id,"dataStore");break;case"annotation.update":{if(g(m,h.id,"annotation")===void 0)break;h.placement&&u(m,h.placement.anchor,"anchor");break}case"group.update":{if(g(m,h.id,"group")===void 0)break;for(const v of h.members??[]){const x=u(m,v,"member");x&&Ay.has(x)&&o.push({kind:"ref-category",opIndex:m,ref:v,role:"member",expected:"shape",actual:x})}break}case"translation.confirm":g(m,h.id);break;case"element.remove":{g(m,h.id)==="lane"&&o.push({kind:"ref-category",opIndex:m,ref:h.id,role:"target",expected:"removable",actual:"lane"});break}}}),o.push(...KM(e,t,n.i18n)),o;function g(h,m,w){if(r.has(m)){o.push({kind:"target-added-in-batch",opIndex:h,id:m});return}const y=t.categoryOf(m);if(y===void 0){o.push({kind:"ref-missing",opIndex:h,ref:m,role:"target"});return}if(w&&y!==w){o.push({kind:"ref-category",opIndex:h,ref:m,role:"target",expected:w,actual:y});return}return y}}function ky(e){return{modeling:e.get("modeling"),bpmnFactory:e.get("bpmnFactory"),elementFactory:e.get("elementFactory"),elementRegistry:e.get("elementRegistry"),canvas:e.get("canvas"),autoPlace:e.get("autoPlace"),bpmnReplace:e.get("bpmnReplace"),spaceTool:e.get("spaceTool")}}function il(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const ol={"top-left":[-1,-1],top:[0,-1],"top-right":[1,-1],right:[1,0],"bottom-right":[1,1],bottom:[0,1],"bottom-left":[-1,1],left:[-1,0]},kn=10,JM=300,eA=160,Oy=20,Cf=100,Dy=40,tA=10,nA=["top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"];function Ly(e,t,n){if(!(t.width>0))return;const i=t.x+t.width/2,o=t.y+t.height/2;let r;for(const a of e.getAll()){if(a.type!=="bpmn:Lane")continue;const s=a;typeof s.x!="number"||typeof s.width!="number"||i>=s.x&&i<=s.x+s.width&&o>=s.y&&o<=s.y+s.height&&(!r||s.width*s.height<r.width*r.height)&&(r=s)}return r?{x:n.x,width:n.width,y:r.y,height:r.height}:void 0}const rl=(e,t,n)=>e.y-t.height/2>=n.y&&e.y+t.height/2<=n.y+n.height;function al(e,t,n,i,o){const r=n,a=Ly(e,t,i),s=a??i,c=(ee,ce,ie=s)=>{const[be,de]=ol[ee];let me={x:t.x+t.width/2+be*(t.width/2+r.width/2+ce),y:t.y+t.height/2+de*(t.height/2+r.height/2+ce)};const Ee=ie.x+kn+r.width/2,U=ie.x+ie.width-kn-r.width/2,ue=ie.y+kn+r.height/2,K=ie.y+ie.height-kn-r.height/2,J={x:Math.min(U,Math.max(Ee,me.x)),y:Math.min(K,Math.max(ue,me.y))};return(J.x!==me.x||J.y!==me.y)&&(me=Math.abs(J.x-(t.x+t.width/2))<(t.width+r.width)/2+kn&&Math.abs(J.y-(t.y+t.height/2))<(t.height+r.height)/2+kn?{x:t.x+t.width+kn+r.width/2,y:J.y}:J),me},l=(i.children??[]).filter(ee=>!("waypoints"in ee&&ee.waypoints)&&ee.type!=="bpmn:Lane"&&ee.type!=="label"&&typeof ee.x=="number"&&ee.id!==o.selfId),u=Ue(e),p=ee=>{var ie,be;if(!o.selfId)return!1;const ce=e.get(ee);return!!ce&&(((ie=ce.source)==null?void 0:ie.id)===o.selfId||((be=ce.target)==null?void 0:be.id)===o.selfId)},f=u.edges.filter(ee=>!p(ee.id)).flatMap(an),d=zo(u).filter(ee=>ee.owner!==o.selfId).map(ee=>ee.rect),g=ee=>({x0:ee.x-r.width/2-kn,x1:ee.x+r.width/2+kn,y0:ee.y-r.height/2-kn,y1:ee.y+r.height/2+kn}),h=ee=>{const ce=g(ee);return l.some(ie=>ce.x0<ie.x+ie.width&&ce.x1>ie.x&&ce.y0<ie.y+ie.height&&ce.y1>ie.y)},m=ee=>{const ce=g(ee);return f.some(ie=>ie.axis==="h"?ie.at>ce.y0&&ie.at<ce.y1&&ie.lo<ce.x1&&ie.hi>ce.x0:ie.at>ce.x0&&ie.at<ce.x1&&ie.lo<ce.y1&&ie.hi>ce.y0)},w=ee=>{const ce=g(ee);return d.some(ie=>ce.x0<ie.x+ie.width&&ce.x1>ie.x&&ce.y0<ie.y+ie.height&&ce.y1>ie.y)},y=u.shapes.filter(ee=>ee.type==="bpmn:Group").flatMap(ee=>[{axis:"h",at:ee.y,lo:ee.x,hi:ee.x+ee.width},{axis:"h",at:ee.y+ee.height,lo:ee.x,hi:ee.x+ee.width},{axis:"v",at:ee.x,lo:ee.y,hi:ee.y+ee.height},{axis:"v",at:ee.x+ee.width,lo:ee.y,hi:ee.y+ee.height}]),v=ee=>{const ce=g(ee);return y.some(ie=>ie.axis==="h"?ie.at>ce.y0&&ie.at<ce.y1&&ie.lo<ce.x1&&ie.hi>ce.x0:ie.at>ce.x0&&ie.at<ce.x1&&ie.lo<ce.y1&&ie.hi>ce.y0)},x=ee=>h(ee)||m(ee)||w(ee)||v(ee),E=ee=>ee.x-r.width/2>=i.x&&ee.x+r.width/2<=i.x+i.width&&ee.y-r.height/2>=i.y&&ee.y+r.height/2<=i.y+i.height,A=ee=>E(ee)&&(!a||rl(ee,r,a));if(o.placement){const ee=Ee=>Ee.startsWith("top")?Ee.replace(/^top/,"bottom"):Ee.replace(/^bottom/,"top"),ce=Ee=>Ee.endsWith("left")?Ee.replace(/left$/,"right"):Ee.replace(/right$/,"left"),ie=o.placement.side,be=[ie,ee(ie),ce(ie),ee(ce(ie)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],de=o.placement.offset??50;let me=c(ie,de);if(x(me)||a&&!rl(me,r,a)){const Ee=(U,ue)=>{const K=new Set;for(const J of be){if(K.has(J))continue;K.add(J);const he=c(J,de,U);if(ue(he)&&!x(he))return me=he,!0}return!1};!Ee(s,A)&&a&&Ee(i,E)}return me}const B=o.from,P=s.x+kn+r.width/2,k=s.x+s.width-kn-r.width/2,H=s.y+kn+r.height/2,F=s.y+s.height-kn-r.height/2;let G={x:Math.min(k,Math.max(P,B.x)),y:Math.min(F,Math.max(H,B.y))};if(x(G)){const ee=(t.width+r.width)/2+kn,ie=[{x:G.x+ee,y:G.y},{x:G.x-ee,y:G.y},{x:G.x,y:G.y-r.height-kn},{x:G.x,y:G.y+r.height+kn}].filter(A).find(be=>!x(be));ie&&(G=ie)}return G}function Ft(e,t){return e.filter(n=>n.kind===t)}function Iy(e,t){const n=new Map,i=new Set(Ft(e,"node.add").map(s=>s.node.id)),o=Ft(e,"sequenceFlow.update"),r=new Set(o.flatMap(s=>s.target!==void 0?[s.target]:[])),a=new Set;for(const s of o){const c=s.source;if(s.target!==void 0||c===void 0||!i.has(c)||r.has(c)||a.has(c))continue;const l=t(s.id),u=l&&Ft(e,"sequenceFlow.add").find(f=>f.flow.source===l&&f.flow.target===c);if(!u)continue;const p=JSON.stringify(u.flow.id);e.some(f=>f!==u&&JSON.stringify(f).includes(p))||(a.add(c),n.set(s.id,u))}return n}class By extends Error{constructor(t){super(t.kind),this.issue=t,this.name="LowerIssueError"}}const Ny=new WeakMap;function iA(e){return Ny.get(e)??new Set}function $y(e,t){var sS,cS,lS,uS,pS,fS,dS,hS,gS,mS,yS,vS,bS,xS,wS,_S,ES,SS,RS,CS,MS,AS,PS,TS,kS,OS,DS,LS,IS;const{modeling:n,bpmnFactory:i,elementFactory:o,elementRegistry:r,canvas:a,autoPlace:s,bpmnReplace:c,spaceTool:l}=t,u=new Set;Ny.set(t,u);const p=()=>a.getRootElement(),f=b=>r.get(b),d=b=>{const _=f(b);if(!_)throw new Error(`하강 참조 해소 실패: ${b}`);return _},g=b=>{let _=b.parent;for(;_;){if(_.type==="bpmn:Participant")return _;_=_.parent}},h=new Map;for(const b of r.filter(_=>!("waypoints"in _&&_.waypoints)&&_.type!=="bpmn:Lane"&&_.type!=="label"&&typeof _.x=="number"))h.set(b.id,{x:b.x,y:b.y});const m=Ft(e,"participant.add"),w=Ft(e,"node.add"),y=Ft(e,"sequenceFlow.add"),v=Ft(e,"messageFlow.add"),x=Ft(e,"dataStore.add"),E=Ft(e,"dataAssociation.add"),A=Ft(e,"annotation.add"),B=Ft(e,"group.add"),P=new Map(w.map(b=>[b.node.id,b])),k=Iy(e,b=>{var _,S;return(S=(_=f(b))==null?void 0:_.source)==null?void 0:S.id}),H=new Set([...k.values()].map(b=>b.flow.id)),F=y.filter(b=>!H.has(b.flow.id)),G=new Set([...k.values()].map(b=>b.flow.target)),ee=b=>Ft(e,"sequenceFlow.update").filter(_=>_.target===b).length+(G.has(b)?1:0),ce=(b,_,S)=>{var L;const O=b.businessObject,I=(((L=O.extensionElements)==null?void 0:L.values)??[]).filter(D=>D.$type!==_),T=S?[...I,i.create(_,S)]:I;if(!T.length){O.extensionElements&&n.updateProperties(b,{extensionElements:void 0});return}const N=i.create("bpmn:ExtensionElements",{values:T});T.forEach(D=>{D.$parent=N}),n.updateProperties(b,{extensionElements:N})},ie=b=>({anchor:b.anchor,side:b.side,...b.offset!==void 0?{offset:b.offset}:{}});for(const b of Ft(e,"element.remove")){const _=f(b.id);if(!_)continue;const S="waypoints"in _?[]:[..._.incoming??[],..._.outgoing??[]];n.removeElements([...S,_])}const be=b=>r.filter(_=>{var S;return _.type==="bpmn:Lane"&&((S=g(_))==null?void 0:S.id)===b}).sort((_,S)=>_.y-S.y),de=[];for(const b of Ft(e,"participant.update")){const _=d(b.id);if(b.name!==void 0&&n.updateProperties(_,{name:b.name??void 0}),!b.lanes)continue;const S=be(b.id);if(!S.length){n.splitLane(_,b.lanes.length),be(b.id).forEach((T,N)=>{const L=b.lanes[N];L&&n.updateProperties(T,{id:L.id,name:L.name})}),de.push({pool:b.id,lanes:new Set(b.lanes.map(T=>T.id))});continue}const O=new Set(S.map(T=>T.id)),I=b.lanes.reduce((T,N,L)=>O.has(N.id)?L:T,-1);b.lanes.forEach((T,N)=>{if(O.has(T.id)){n.updateProperties(d(T.id),{name:T.name});return}const L=N===I+1&&I>=0,D=N===0?n.addLane(be(b.id)[0],"top"):L?n.addLane(be(b.id).at(-1),"bottom"):n.addLane(d(b.lanes[N-1].id),"bottom");n.updateProperties(D,{id:T.id,name:T.name})})}const me=150,Ee=130,U=80,ue=90,K=180,J=30,he=30,Re=10,ze=300,$=5,C=(b,_,S,O,I)=>{const T=S-_.width/2,N=O-_.height/2;return(b.children??[]).find(L=>!("waypoints"in L&&L.waypoints)&&L.type!=="bpmn:Lane"&&L.type!=="label"&&!(I!=null&&I.has(L.id))&&typeof L.x=="number"&&T<L.x+L.width+he&&T+_.width+he>L.x&&N<L.y+L.height&&N+_.height>L.y)},R=new Set;for(const b of m){R.add(`pool:${b.participant.id}`);for(const _ of b.participant.lanes??[])R.add(_.id)}const W=new Map;for(const b of w){const _=b.node.lane??`pool:${b.node.participant??""}`;let S=W.get(_);S||W.set(_,S=new Set([0])),b.band!==void 0&&S.add(b.band)}const q=new Map;for(const[b,_]of W){if(!R.has(b))continue;const S=[..._].sort((T,N)=>T-N),O=S.map((T,N)=>N===0?0:N%2===1?Math.ceil(N/2):-(N/2)),I=Math.min(...O);q.set(b,new Map(S.map((T,N)=>[T,O[N]-I])))}{const b=new Map;for(const _ of m)(_.participant.lanes??[]).forEach((S,O)=>b.set(S.id,O));for(const[_,S]of q){if(!b.has(_)||S.size<2)continue;const O=b.get(_),I=S.get(0)??0,T=new Set;for(const ne of w){if(ne.node.lane!==_||(ne.band??0)!==0||!ne.node.type.endsWith("Gateway"))continue;const le={in:new Set,out:new Set,cross:new Set};for(const ae of F){const oe=ae.flow.source===ne.node.id;if(!oe&&ae.flow.target!==ne.node.id)continue;const ye=P.get(oe?ae.flow.target:ae.flow.source);if(!ye||ye.node.participant!==ne.node.participant||!ye.node.lane)continue;let ge,te=!1;if(ye.node.lane!==_){const Z=b.get(ye.node.lane);if(Z===void 0)continue;ge=Z>O?"down":"up",te=!0}else{const Z=S.get(ye.band??0)??I;ge=Z>I?"down":Z<I?"up":void 0}ge&&(le[oe?"out":"in"].add(ge),te&&le.cross.add(ge))}for(const ae of["up","down"])le.in.has(ae)&&le.out.has(ae)&&le.cross.has(ae)&&T.add(ae)}if(T.size!==1)continue;const[N]=T,L=Math.max(...S.values()),D=N==="down"?L:0;if(I===D)continue;const z=[...S.entries()].filter(([ne])=>ne!==0).sort((ne,le)=>ne[1]-le[1]),j=[...Array(L+1).keys()].filter(ne=>ne!==D),X=new Map([[0,D]]);z.forEach(([ne],le)=>X.set(ne,j[le])),q.set(_,X)}}const fe=b=>{var _;return(((_=W.get(b))==null?void 0:_.size)??0)>1},Oe=b=>b.band??(b.node.lane||!fe(`pool:${b.node.participant??""}`)?void 0:0),nt=new Map,lt=b=>nt.get(b.node.id)??Oe(b),Vt=new Set,St=new Set,nn=new Set,An=new Set,Vn=new Set,Tt=b=>A.some(_=>{var S,O;return(((S=_.placement)==null?void 0:S.anchor)??(_.association?_.association.source===_.annotation.id?_.association.target:_.association.source:void 0))===b&&((O=_.placement)==null?void 0:O.side.startsWith("bottom"))});{const b=new Map;for(const O of F)b.set(O.flow.target,(b.get(O.flow.target)??0)+1);const _=O=>{const I=[],T=new Set([O]),N=[O];for(;N.length;){const L=N.shift();I.push(L);for(const D of F)D.flow.source!==L||T.has(D.flow.target)||(b.get(D.flow.target)??0)!==1||(T.add(D.flow.target),N.push(D.flow.target))}return I},S=(O,I)=>{var T;return((T=q.get(O))==null?void 0:T.get(I))??I};for(const O of w){if(!O.node.type.endsWith("Gateway"))continue;const I=O.node.lane??`pool:${O.node.participant??""}`,T=q.get(I);if(!T||T.size<2)continue;const N=lt(O);if(N===void 0||S(I,N)!==S(I,0))continue;const L=S(I,N),D=F.filter(ae=>ae.flow.source===O.node.id).map(ae=>P.get(ae.flow.target)).filter(ae=>!!ae&&(ae.node.lane??`pool:${ae.node.participant??""}`)===I),z=D.filter(ae=>{const oe=lt(ae);return oe!==void 0&&S(I,oe)===L&&(b.get(ae.node.id)??0)===1}),j=D.some(ae=>{const oe=lt(ae);return oe!==void 0&&S(I,oe)>L});if(z.length!==1||!j)continue;const X=new Set(D.flatMap(ae=>_(ae.node.id)));if(!F.some(ae=>ae.flow.target===O.node.id&&X.has(ae.flow.source)))continue;const le=new Map;for(const[ae,oe]of T)le.set(ae,oe+1);le.set(-1,0),q.set(I,le);for(const ae of _(z[0].node.id))P.has(ae)&&(nt.set(ae,-1),St.add(ae));Vt.add(O.node.id)}}{const b=j=>j.node.lane??`pool:${j.node.participant??""}`,_=j=>lt(j)??0,S=new Map(m.map((j,X)=>({id:j.participant.id,order:j.order??Number.POSITIVE_INFINITY,declared:X})).sort((j,X)=>j.order!==X.order?j.order-X.order:j.declared-X.declared).map((j,X)=>[j.id,X])),O=j=>j===void 0?void 0:S.get(j)??-1,I=j=>{var le;const X=P.get(j);if(X)return X.node.participant;if(S.has(j))return j;const ne=f(j);if(ne)return ne.type==="bpmn:Participant"?ne.id:(le=g(ne))==null?void 0:le.id},T=new Map;for(const j of F)T.set(j.flow.target,(T.get(j.flow.target)??0)+1);const N=j=>{const X=[j],ne=new Set([j.node.id]);for(let le=0;le<X.length;le++)for(const ae of F){if(ae.flow.source!==X[le].node.id||ne.has(ae.flow.target)||(T.get(ae.flow.target)??0)!==1)continue;const oe=P.get(ae.flow.target);!oe||oe.node.participant!==j.node.participant||(ne.add(oe.node.id),X.push(oe))}return X},L=j=>{const X=new Set(j.map(ae=>ae.node.id)),ne=O(j[0].node.participant);if(ne===void 0)return;const le=new Set;for(const ae of v){const oe=X.has(ae.flow.source)?ae.flow.target:X.has(ae.flow.target)?ae.flow.source:void 0;if(oe===void 0)continue;const ye=O(I(oe));ye===void 0||ye===ne||le.add(ye<ne?"up":"down")}return le.size===1?[...le][0]:void 0},D=new Map;{const j=new Map;for(const oe of F){if(!P.has(oe.flow.source)||!P.has(oe.flow.target))continue;const ye=j.get(oe.flow.source)??[];ye.push(oe.flow.target),j.set(oe.flow.source,ye)}const X=new Map,ne=[],le=new Set,ae=oe=>{X.set(oe,"open");for(const ye of j.get(oe)??[]){const ge=X.get(ye);ge==="open"?le.add(`${oe}>${ye}`):ge||ae(ye)}X.set(oe,"done"),ne.push(oe)};for(const oe of w)X.has(oe.node.id)||ae(oe.node.id);for(const oe of ne.reverse()){const ye=D.get(oe)??0;D.set(oe,ye);for(const ge of j.get(oe)??[])!le.has(`${oe}>${ge}`)&&(D.get(ge)??-1)<ye+1&&D.set(ge,ye+1)}}let z=-1e3;for(const j of w){if(!j.node.type.endsWith("Gateway"))continue;const X=b(j),ne=q.get(X);if(!ne)continue;const le=ne.get(_(j))??0,ae=te=>(ne.get(_(te))??0)-le,oe=F.filter(te=>te.flow.source===j.node.id).map(te=>P.get(te.flow.target)).filter(te=>!!te&&b(te)===X&&(T.get(te.node.id)??0)===1&&!St.has(te.node.id)).map(te=>{const Z=N(te);return{root:te,subtree:Z,dir:L(Z)}});if(oe.some(te=>te.dir==="up")&&oe.some(te=>te.dir==="down"))continue;const ye=F.some(te=>{const Z=te.flow.source===j.node.id?P.get(te.flow.target):void 0;return!!Z&&b(Z)===X&&ae(Z)===0});let ge=!1;if(!ye){const te=F.filter(ve=>ve.flow.source===j.node.id).map(ve=>P.get(ve.flow.target)).filter(ve=>!!ve&&b(ve)===X&&(!!ve.node.lane||Oe(ve)!==void 0)&&ae(ve)<0),Z=te.length?Math.max(...te.map(ae)):void 0,re=te.filter(ve=>ae(ve)===Z);if(!Tt(j.node.id)&&re.length===1&&(T.get(re[0].node.id)??0)===1&&!Vt.has(j.node.id))continue;ge=!0}for(const te of oe){const Z=te.dir;if(!Z||oe.some(Me=>Me!==te&&Me.dir===Z))continue;const re=ae(te.root);if(re===0||(Z==="up"?re<0:re>0)||F.some(Me=>{const ke=Me.flow.target===j.node.id?P.get(Me.flow.source):void 0;if(!ke||b(ke)!==X)return!1;const Fe=ae(ke);return Z==="up"?Fe<0:Fe>0}))continue;const ve=[...ne].map(([Me,ke])=>({band:Me,rel:ke-le})).filter(Me=>Z==="up"?Me.rel<0:Me.rel>0).sort((Me,ke)=>Math.abs(ke.rel)-Math.abs(Me.rel));if(!ve.length&&Z==="down")continue;const $e=_(te.root),De=te.subtree.filter(Me=>b(Me)===X&&_(Me)===$e),Xe=new Set(te.subtree.map(Me=>Me.node.id)),Ae=De.map(Me=>D.get(Me.node.id)??0),Pe=Math.min(...Ae)-1,Ce=Math.max(...Ae)+1,Te=Me=>!w.some(ke=>{if(Xe.has(ke.node.id)||b(ke)!==X||_(ke)!==Me)return!1;if(!nn.has(Me))return!0;const Fe=D.get(ke.node.id)??0;return Fe>=Pe&&Fe<=Ce});let pe=ge?_(j):(sS=ve.find(Me=>Te(Me.band)))==null?void 0:sS.band;if(pe===void 0){if(pe=z--,nn.add(pe),Z==="up"){const Me=new Map;for(const[ke,Fe]of ne)Me.set(ke,Fe+1);Me.set(pe,0),q.set(X,Me)}else ne.set(pe,Math.max(...ne.values())+1);(cS=W.get(X))==null||cS.add(pe)}for(const Me of De)nt.set(Me.node.id,pe)}}{const j=oe=>{const ye=F.find(ge=>ge.flow.target===oe.node.id);return ye?P.get(ye.flow.source):void 0},X=oe=>{const ye=j(oe);if(!ye||!ye.node.type.endsWith("Gateway")||b(ye)!==b(oe))return!1;const ge=q.get(b(ye));if(!ge)return!1;const te=ge.get(_(ye))??0,Z=De=>b(De)===b(ye)?(ge.get(_(De))??0)-te:Number.NaN,re=F.filter(De=>De.flow.source===ye.node.id).map(De=>P.get(De.flow.target)).filter(De=>!!De&&(!!De.node.lane||Oe(De)!==void 0));if(re.some(De=>Z(De)===0))return!1;const Q=re.filter(De=>De.node.lane===ye.node.lane&&Z(De)<0);if(!Q.length)return!1;const ve=Math.max(...Q.map(Z)),$e=Q.filter(De=>Z(De)===ve);return $e.length===1&&$e[0]===oe&&(T.get(oe.node.id)??0)===1&&!Tt(ye.node.id)&&!Vt.has(ye.node.id)},ne=new Set;for(const oe of w){if(!oe.node.type.endsWith("Gateway")||Tt(oe.node.id))continue;const ye=q.get(b(oe));if(!ye)continue;const ge=ye.get(_(oe))??0;let te;for(const Z of F){if(Z.flow.source!==oe.node.id)continue;const re=P.get(Z.flow.target);if(!re||b(re)!==b(oe)||!re.node.lane&&Oe(re)===void 0)continue;const Q=ye.get(_(re))??0;Q<=ge||(!te||Q>te.row?te={id:re.node.id,row:Q,count:1}:Q===te.row&&te.count++)}te&&te.count===1&&(T.get(te.id)??0)===1&&ne.add(te.id)}const le=new Set,ae=[...w].sort((oe,ye)=>Number(ne.has(oe.node.id))-Number(ne.has(ye.node.id)));for(const oe of ae){const ye=b(oe),ge=q.get(ye);if(!ge)continue;const te=oe.node.id,Z=v.filter(wt=>wt.flow.target===te);if(Z.length!==1||!(T.get(te)??0)||!oe.node.lane&&Oe(oe)===void 0||St.has(te)||An.has(te))continue;const re=(lS=P.get(Z[0].flow.source))==null?void 0:lS.node.participant;if(!re||re===oe.node.participant)continue;const Q=O(oe.node.participant),ve=O(re);if(Q===void 0||ve===void 0||Q===ve)continue;const $e=ve<Q,De=ge.get(0)??0,Xe=(ge.get(_(oe))??De)-De;if(Xe===0||($e?Xe<0:Xe>0)||X(oe))continue;let Ae;for(const[wt,rn]of ge){if(nn.has(wt))continue;const Kt=rn-De;($e?Kt<0&&(!Ae||Kt<Ae.row):Kt>0&&(!Ae||Kt>Ae.row))&&(Ae={band:wt,row:Kt})}if(!Ae)continue;const Pe=_(oe),Ce=N(oe).filter(wt=>b(wt)===ye&&_(wt)===Pe&&!St.has(wt.node.id)),Te=j(oe),pe=Te!=null&&Te.node.type.endsWith("Gateway")?`${Te.node.id}|${ye}|${Ae.band}`:void 0,Me=Ae,ke=!!pe&&ne.has(te)&&F.some(wt=>{if(wt.flow.source!==Te.node.id||wt.flow.target===te)return!1;const rn=P.get(wt.flow.target);return!!rn&&b(rn)===ye&&!Ce.includes(rn)&&_(rn)===Me.band});let Fe=Ae.band;if(pe&&(le.has(pe)||ke)){if(Fe=z--,nn.add(Fe),$e){const wt=new Map;for(const[rn,Kt]of ge)wt.set(rn,Kt+1);wt.set(Fe,0),q.set(ye,wt)}else ge.set(Fe,Math.max(...ge.values())+1);(uS=W.get(ye))==null||uS.add(Fe)}pe&&le.add(pe);for(const wt of Ce)nt.set(wt.node.id,Fe),An.add(wt.node.id);$e&&ne.has(te)&&Vn.add(te)}}}const $t=(b,_)=>{var S;return((S=q.get(b))==null?void 0:S.get(_))??_},xn=(b,_,S,O)=>{const I=b?f(b):_?f(_):void 0;if(!I)return!1;const T=b?I.y+Math.min(I.height/2,ue):I.y+U;return Math.abs(T+$t(b??`pool:${_??""}`,S)*me-O)<=me/2},vr=new Map;for(const[b,_]of W){let S=0;for(const O of _)S=Math.max(S,$t(b,O));vr.set(b,S)}const Qn=b=>K+me*b,Jn=(b,_,S)=>{const O=p().children.filter(I=>!("waypoints"in I&&I.waypoints)&&I.type!=="label"&&I.id!==_&&typeof I.y=="number"&&I.y>=b);O.length&&n.moveElements(O,{x:0,y:S})},bi=(b,_,S)=>{const O=b.type==="bpmn:Participant"?b:void 0;if(!O||O.children.some(L=>L.type==="bpmn:Lane"))return;const I=S+_.height/2+J-O.y;if(O.height>=I)return;const T=I-O.height,N=O.y+O.height;n.resizeShape(O,{x:O.x,y:O.y,width:O.width,height:I}),Jn(N,O.id,T)},hn=(b,_)=>{const S=_-b.height;if(S<=0)return;const O=g(b)??b,I=[],T=D=>{I.push(D);for(const z of D.children??[])T(z)};T(O);const N=b.y+b.height-10,L=l.calculateAdjustments(I,"y",S,N);l.makeSpace(L.movingShapes,L.resizingShapes,{x:0,y:S},"s",N)},Do=(b,_,S)=>{if(b){const N=d(b),L=Qn(_);if(N.height>=L)return;const D=L-N.height,z=g(N),j=z?z.y+z.height:N.y+N.height;hn(N,L),Jn(j,z==null?void 0:z.id,D);return}if(!S)return;const O=me*(_+1);if(S.height>=O)return;const I=O-S.height,T=S.y+S.height;n.resizeShape(S,{x:S.x,y:S.y,width:S.width,height:O}),Jn(T,S.id,I)},Qa=new Map;for(const b of F)Qa.set(b.flow.target,(Qa.get(b.flow.target)??0)+1);const pi=b=>(Qa.get(b)??0)<=1,xt=new Set(w.map(b=>b.node.id).filter(b=>ee(b)===1&&!F.some(_=>_.flow.target===b||_.flow.source===b&&P.has(_.flow.target)))),Rt=new Map,P1=(b,_)=>{if(!b)return;const S=f(b);if(!S||S.height>=Qn(_))return;const O=S.y+S.height-10,I=g(S);if(I)return new Set((I.children??[]).filter(T=>T.type!=="bpmn:Lane"&&typeof T.y=="number"&&T.y>O).map(T=>T.id))},xp=(b,_,S)=>{if(!b)return!0;const O=f(b);return O?S-_.height/2>=O.y&&S+_.height/2<=O.y+O.height:!0},E3=10,S3=/(Task|Event|Gateway|CallActivity|SubProcess|Transaction)$/;for(const{pool:b,lanes:_}of de){const S=f(b),O=be(b);if(!S||O.length<2)continue;const I=Qn(0),T=E3,N=new Set(Ft(e,"node.update").filter(Q=>Q.lane!==void 0&&_.has(Q.lane)).map(Q=>Q.id)),L=S.children??[],D=L.filter(Q=>!("waypoints"in Q&&Q.waypoints)&&Q.type!=="bpmn:Lane"&&Q.type!=="label"&&typeof Q.y=="number"),z=[];for(const Q of D){z.push([Q.y,Q.y+Q.height]);const ve=Q.label;ve&&z.push([ve.y,ve.y+ve.height])}for(const Q of L){const ve="waypoints"in Q&&Q.waypoints?Q.label:void 0;ve&&ve.y+ve.height>S.y&&ve.y<S.y+S.height&&z.push([ve.y,ve.y+ve.height])}z.sort((Q,ve)=>Q[0]-ve[0]);const j=S.y,X=S.y+S.height,ne=[];let le=j;for(const[Q,ve]of z)Q>le&&ne.push([le,Q]),le=Math.max(le,ve);const ae=D.filter(Q=>S3.test(Q.type)&&!N.has(Q.id)),oe=(Q,ve)=>ae.some($e=>$e.y+$e.height/2>=Q&&$e.y+$e.height/2<=ve),ye=Q=>z.some(([ve,$e])=>ve<Q-.5&&Q+.5<$e),ge=[];let te=j;for(const Q of O.slice(1).map(ve=>ve.y)){const ve=te+2*T,$e=!ye(Q)&&Q>=ve&&Q<=X-2*T?[Q]:[];for(const[Xe,Ae]of ne){const Pe=Math.max(Xe+T,ve),Ce=Math.min(Ae-T,X-2*T);Pe<=Ce&&$e.push(Math.min(Math.max(Q,Pe),Ce))}$e.push(Math.max(le+T,ve));let De;for(const Xe of $e){const Ae=!oe(te,Xe)&&Xe-te<I?D.filter(Te=>Te.y>=Xe).length:0,Pe=Math.abs(Xe-Q),Ce=De?Math.abs(De.y-Q):0;(!De||Ae<De.cost||Ae===De.cost&&(Pe<Ce||Pe===Ce&&Xe>De.y))&&(De={y:Xe,cost:Ae})}ge.push(De.y),te=De.y}const Z=ge[ge.length-1]+2*T-X;Z>0&&(n.resizeShape(S,{x:S.x,y:S.y,width:S.width,height:S.height+Z}),Jn(X,S.id,Z));const re=[j,...ge,S.y+S.height];O.forEach((Q,ve)=>{const $e=re[ve],De=re[ve+1]-$e;(Q.y!==$e||Q.height!==De)&&n.resizeShape(Q,{x:Q.x,y:$e,width:Q.width,height:De})});for(const Q of O){if(Q.height>=I||oe(Q.y,Q.y+Q.height))continue;const ve=I-Q.height,$e=S.y+S.height;hn(Q,I),Jn($e,S.id,ve)}}const wp=m.map((b,_)=>({op:b,declared:_}));wp.sort((b,_)=>{const S=b.op.order??Number.POSITIVE_INFINITY,O=_.op.order??Number.POSITIVE_INFINITY;return S!==O?S-O:b.declared-_.declared});let xc=80;for(const b of r.getAll())b.parent===p()&&"height"in b&&typeof b.y=="number"&&(xc=Math.max(xc,b.y+b.height+60));const Og=r.getAll().filter(b=>b.type==="bpmn:Participant"&&b.parent===p()),R3=(()=>{if(!Og.length)return;const b=Og.filter(I=>!Fy(I)),_=b.length?b:Og,S=Math.min(..._.map(I=>I.x)),O=Math.max(..._.map(I=>I.x+I.width));return O>S?{x:S,width:O-S}:void 0})();for(const{op:b}of wp){const _=b.participant,S=w.filter(oe=>oe.node.participant===_.id).length,O=((pS=_.lanes)==null?void 0:pS.length)??0,I=Math.max(1200,S*160+300),T=(_.lanes??[]).map(oe=>Qn(vr.get(oe.id)??0)),N=T.reduce((oe,ye)=>oe+ye,0);O&&N<300&&(T[O-1]+=300-N);const L=Math.max(300,me*((vr.get(`pool:${_.id}`)??0)+1)),D=_.blackBox||S+O===0?120:O?Math.max(300,N):L,z=_.blackBox?R3:void 0,j=(z==null?void 0:z.x)??100,X=(z==null?void 0:z.width)??I,ne=o.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:_.id,name:_.name,...b.order!==void 0?{"bwl:poolOrder":b.order}:{},..._.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:X,height:D,isExpanded:!0}),le=n.createShape(ne,{x:j+X/2,y:xc+D/2},p()),ae=_.lanes??[];if(ae.length&&n.splitLane(le,ae.length),ae.length){const oe=r.filter(ye=>{var ge;return ye.type==="bpmn:Lane"&&((ge=g(ye))==null?void 0:ge.id)===_.id}).sort((ye,ge)=>ye.y-ge.y);if(oe.forEach((ye,ge)=>{const te=ae[ge];te&&n.updateProperties(ye,{id:te.id,name:te.name})}),T.some(ye=>ye!==le.height/O)){let ye=le.y;oe.forEach((ge,te)=>{const Z=T[te];n.resizeShape(ge,{x:ge.x,y:ye,width:ge.width,height:Z}),ye+=Z})}}xc=le.y+le.height+60}const C3=b=>{var O;const _=P.get(b);if(_)return _.node.participant??"";const S=f(b);return S?S.type==="bpmn:Participant"?S.id:((O=g(S))==null?void 0:O.id)??"":""},wc=new Map,T1=b=>{let _=wc.get(b);return _||wc.set(b,_={nodes:[],flows:[]}),_};for(const b of w)T1(b.node.participant??"").nodes.push(b);for(const b of F)T1(C3(b.flow.source)).flows.push(b);const _p=b=>{var _;return i.create("bpmn:SequenceFlow",{id:b.id,name:b.name??((_=b.condition)==null?void 0:_.label)})},Dg=(b,_,S)=>o.createShape({type:il(b.type),...b.eventDefinition?{eventDefinitionType:Tc[b.eventDefinition]}:{},businessObject:i.create(il(b.type),{id:b.id,name:b.name,..._!==void 0?{"bwl:band":_}:{},...S!==void 0?{"bwl:afterColumn":S}:{}})}),M3=[...wp.map(({op:b})=>b.participant.id).filter(b=>wc.has(b)),...[...wc.keys()].filter(b=>!m.some(_=>_.participant.id===b))],Lg=b=>b.endsWith("Gateway");for(const b of M3){const _=wc.get(b),S=b?d(b):void 0,O=S?S.x+150:250;let I=S?S.y+80:120;const T=(Z,re,Q)=>{if(Z){const ve=d(Z);return ve.y+Math.min(ve.height/2,ue)+$t(Z,re??0)*me}return re!==void 0&&S?S.y+U+$t(`pool:${b}`,re)*me:Q},N=(Z,re,Q)=>{if(Z){const ve=d(Z);return ve.y+Math.min(ve.height/2,ue)+re*me}return S?S.y+U+re*me:Q},L=Z=>Z.participant?d(Z.participant):p(),D=(Z,re,Q,ve,$e,De,Xe,Ae)=>{const Pe=Q!==void 0||ve!==void 0,Ce=ke=>{const Fe=()=>Do(Q,ke,S);Ae?Ae(Fe):Fe()},Te=$t(Q??`pool:${b}`,ve??0);if((ve===void 0||xn(Q,b,ve,Xe??Number.NaN))&&Xe!==void 0&&xp(Q,re,Xe)&&!C(Z,re,$e,Xe))return{x:$e,y:Xe};if(Pe)for(let ke=0;ke<4;ke++){const Fe=N(Q,Te+ke,De);if(!C(Z,re,$e,Fe,P1(Q,Te+ke)))return Ce(Te+ke),{x:$e,y:Fe}}const pe=T(Q,ve,De);Pe?Ce(Te):Ae?Ae(()=>bi(Z,re,re.y+re.height/2)):bi(Z,re,pe);let Me=$e;for(let ke=0;ke<64;ke++){const Fe=C(Z,re,Me,pe);if(!Fe)break;Me=Fe.x+Fe.width+Ee+re.width/2}return{x:Me,y:pe}},z=(Z,re,Q)=>{const ve=r.getAll().filter(De=>{var Xe;return/Association$/.test(De.type)&&(((Xe=De.waypoints)==null?void 0:Xe.length)??0)>=2});if(!ve.length)return Q;const $e=De=>{const Xe={id:re.id,type:re.type,x:De-re.width/2,y:Q.y-re.height/2,width:re.width,height:re.height};return ve.some(Ae=>Ae.waypoints.some((Pe,Ce)=>!!Ae.waypoints[Ce+1]&&Dr(Pe,Ae.waypoints[Ce+1],Xe)<=Re))};if(!$e(Q.x))return Q;for(let De=$;De<=ze;De+=$){const Xe=Q.x+De;if(!$e(Xe)&&!C(Z,re,Xe,Q.y))return{x:Xe,y:Q.y}}return Q},j=new Set(_.flows.map(Z=>Z.flow.target)),X=new Map,ne=Z=>{if(Z===void 0)return;const re=r.get(Z);if(!(!re||typeof re.x!="number"||typeof re.width!="number"))return re.x+re.width+Ee},le=Z=>{if(ee(Z)>0)return;const re=_.flows.filter(ve=>ve.flow.source===Z);if(re.length!==1)return;const Q=r.get(re[0].flow.target);return Q&&typeof Q.y=="number"&&typeof Q.height=="number"?Q.y+Q.height/2:void 0};for(const Z of _.nodes){if(j.has(Z.node.id))continue;const re=Dg(Z.node,Z.band,Z.afterColumn),Q=Oe(Z),ve=Z.node.lane?`${Z.node.lane}|${Q??""}`:Q!==void 0?`band:${Q}`:"",$e=L(Z.node),De=X.get(ve)??O,Xe=ne(Z.afterColumn),Ae=Xe===void 0?De:Math.max(De,Xe);let Pe;const Ce=D($e,re,Z.node.lane,Q,Ae,I,le(Z.node.id),xt.has(Z.node.id)&&Z.node.participant!==void 0?Te=>Pe=Te:void 0);if(Pe?n.createShape(re,Ce,$e,{autoResize:!1}):n.createShape(re,Ce,$e),Pe){const Te=Z.node.lane?d(Z.node.lane):$e;Rt.set(Z.node.id,{container:Te,relCy:Ce.y-Te.y,grow:Pe})}X.set(ve,Ce.x+re.width+Ee),!Z.node.lane&&Q===void 0&&(I+=160)}const ae=new Set,oe=new Map,ye=new Map;if(b&&R.has(`pool:${b}`)){const Z=new Map;for(const Ae of _.flows)Z.set(Ae.flow.target,(Z.get(Ae.flow.target)??0)+1);const re=Ae=>T(Ae.node.lane,lt(Ae),Number.NaN),Q=new Set,ve=Ae=>{var Te;const Pe=(Te=P.get(Ae))==null?void 0:Te.node.participant;if(Pe)return f(Pe);const Ce=f(Ae);if(Ce)return Ce.type==="bpmn:Participant"?Ce:g(Ce)},$e=Ae=>{const Pe=[],Ce=new Set([Ae]),Te=[Ae];for(;Te.length;){const pe=Te.shift(),Me=P.get(pe);Me&&Pe.push(Me);for(const ke of _.flows)ke.flow.source!==pe||Ce.has(ke.flow.target)||(Z.get(ke.flow.target)??0)!==1||(Ce.add(ke.flow.target),Te.push(ke.flow.target))}return Pe},De=Ae=>{if(!S)return;const Pe=new Set(Ae.map(pe=>pe.node.id));let Ce=!1,Te=!1;for(const pe of v){if(!Pe.has(pe.flow.source))continue;const Me=ve(pe.flow.target);!Me||Me.id===S.id||(Me.y<S.y?Ce=!0:Te=!0)}return Ce&&!Te?"up":Te&&!Ce?"down":void 0};for(const Ae of _.nodes){if(!Lg(Ae.node.type))continue;const Pe=T(Ae.node.lane,Oe(Ae),Number.NaN);if(Number.isNaN(Pe))continue;const Ce=[];for(const ke of _.flows){if(ke.flow.source!==Ae.node.id)continue;const Fe=P.get(ke.flow.target);if(!Fe||Fe.node.lane!==Ae.node.lane||(Z.get(Fe.node.id)??0)!==1)continue;const wt=Oe(Fe);if(wt===void 0)continue;const rn=T(Fe.node.lane,wt,Number.NaN);if(Number.isNaN(rn))continue;const Kt=$e(Fe.node.id),Xt=De(Kt);Xt&&Ce.push({subtree:Kt,band:wt,row:rn,dir:Xt})}if(!Ce.some(ke=>ke.dir==="up")||!Ce.some(ke=>ke.dir==="down")||!Ce.some(ke=>ke.dir==="up"&&Ce.some(Fe=>Fe.dir==="down"&&Fe.row<ke.row)))continue;const pe=[...Ce].sort((ke,Fe)=>ke.row-Fe.row);[...Ce.filter(ke=>ke.dir==="up"),...Ce.filter(ke=>ke.dir==="down")].sort((ke,Fe)=>ke.dir===Fe.dir?ke.row-Fe.row:ke.dir==="up"?-1:1).forEach((ke,Fe)=>{const wt=pe[Fe].band;if(wt!==ke.band){Q.add(Ae.node.id);for(const rn of ke.subtree)Oe(rn)===ke.band&&nt.set(rn.node.id,wt)}})}const Xe=Ae=>{if(!S)return;const Pe=new Set(Ae.map(pe=>pe.node.id));let Ce=!1,Te=!1;for(const pe of v){if(!Pe.has(pe.flow.target))continue;const Me=ve(pe.flow.source);!Me||Me.id===S.id||(Me.y<S.y?Ce=!0:Te=!0)}return Ce&&!Te?"up":Te&&!Ce?"down":void 0};for(const Ae of _.nodes){if(!Lg(Ae.node.type))continue;const Pe=Ae.node.lane??`pool:${b}`,Ce=q.get(Pe);if(!Ce||Ce.size<2)continue;const Te=Ce.get(0);if(Te===void 0)continue;const pe=Math.max(...Ce.values()),Me=Te===pe&&Te!==0?"down":void 0;if(!Me)continue;const ke=[];for(const Xt of _.flows){if(Xt.flow.source!==Ae.node.id)continue;const Nn=P.get(Xt.flow.target);if(!Nn||Nn.node.lane!==Ae.node.lane||(Z.get(Nn.node.id)??0)!==1)continue;const wn=lt(Nn);wn!==void 0&&ke.push({t:Nn,subtree:$e(Nn.node.id),band:wn})}const Fe=ke.find(Xt=>(Ce.get(Xt.band)??Xt.band)===Te);if(!Fe||Xe(Fe.subtree)===Me||De(Fe.subtree)===Me)continue;const wt=ke.find(Xt=>Xt!==Fe&&Xe(Xt.subtree)===Me);if(!wt)continue;const rn=Fe.band,Kt=wt.band;for(const Xt of Fe.subtree)lt(Xt)===rn&&nt.set(Xt.node.id,Kt);for(const Xt of wt.subtree)lt(Xt)===Kt&&nt.set(Xt.node.id,rn);Q.add(Ae.node.id)}for(const Ae of _.nodes){if(!Lg(Ae.node.type))continue;const Pe=re(Ae);if(Number.isNaN(Pe)||Tt(Ae.node.id))continue;let Ce,Te=!1,pe;for(const Me of _.flows){if(Me.flow.source!==Ae.node.id)continue;const ke=P.get(Me.flow.target);if(!ke||!ke.node.lane&&Oe(ke)===void 0)continue;const Fe=re(ke);Number.isNaN(Fe)||(Math.abs(Fe-Pe)<.5&&(Te=!0),Fe>Pe?!Ce||Fe>Ce.row?Ce={id:ke.node.id,row:Fe,count:1}:Fe===Ce.row&&Ce.count++:Fe<Pe&&ke.node.lane===Ae.node.lane&&!An.has(ke.node.id)&&(!pe||Fe>pe.row?pe={op:ke,row:Fe,count:1}:Fe===pe.row&&pe.count++))}Ce&&Ce.count===1&&(Z.get(Ce.id)??0)===1&&!Q.has(Ae.node.id)&&ae.add(Ce.id),!Te&&pe&&pe.count===1&&(Z.get(pe.op.node.id)??0)===1&&!Vt.has(Ae.node.id)&&oe.set(pe.op.node.id,{lane:Ae.node.lane,band:lt(Ae)})}for(const Ae of Vn){const Pe=(fS=_.flows.find(Ce=>Ce.flow.target===Ae))==null?void 0:fS.flow.source;Pe&&!Q.has(Pe)&&ae.add(Ae)}}const ge=new Set;let te=0;for(;te++<_.nodes.length+2;){for(let Q=0;Q<_.nodes.length+_.flows.length+2;Q++){let ve=!1;for(const $e of _.flows){const De=$e.flow;if(ge.has(De.id))continue;const Xe=f(De.source);if(!Xe)continue;const Ae=f(De.target),Pe=P.get(De.target);if(!Ae&&Pe){const Ce=Dg(Pe.node,Pe.band),Te=lt(Pe);if(Pe.node.lane||Te!==void 0){const pe=L(Pe.node),Me=Xe,ke=Me.x+(ye.get(De.source)??0)+Me.width+Ee,Fe=oe.get(De.target),wt=D(pe,Ce,Fe?Fe.lane:Pe.node.lane,Fe?Fe.band:Te,ae.has(De.target)?Me.x+Me.width/2:ke,Number.NaN,Fe||!pi(De.target)?void 0:Me.y+Me.height/2),rn=P.has(De.source)?wt:z(pe,Ce,wt),Kt=n.createShape(Ce,rn,pe);ae.has(De.target)&&ye.set(De.target,ke-(Kt.x+Kt.width/2)),n.connect(Xe,Kt,{type:"bpmn:SequenceFlow",businessObject:_p(De)})}else s.append(Xe,Ce,{connection:{type:"bpmn:SequenceFlow",businessObject:_p(De)}})}else if(Ae)n.connect(Xe,Ae,{type:"bpmn:SequenceFlow",businessObject:_p(De)});else continue;ge.add(De.id),ve=!0}if(!ve)break}const Z=_.nodes.filter(Q=>!f(Q.node.id));if(!Z.length)break;const re=Z[0];{const Q=Dg(re.node,re.band),ve=L(re.node),$e=Oe(re);n.createShape(Q,D(ve,Q,re.node.lane,$e,O,I),ve),!re.node.lane&&$e===void 0&&(I+=160)}}}const k1=new Map;for(const[b,_]of k){const S=f(b),O=f(_.flow.target);if(!(S!=null&&S.target)||!O)continue;const I=S.label&&{x:S.label.x,y:S.label.y,width:S.label.width,height:S.label.height};k1.set(b,{waypoints:S.waypoints.map(L=>({x:L.x,y:L.y})),label:I});const T=S.target,N=L=>({x:L.x+L.width/2,y:L.y+L.height/2});n.reconnect(S,O,T,[N(O),N(T)]),n.layoutConnection(S,{waypoints:[]})}const O1=new Set;{const b=T=>T.endsWith("Task")||T==="bpmn:CallActivity"||T==="bpmn:SubProcess",_=T=>b(T)||T==="bpmn:EndEvent"||T==="bpmn:IntermediateThrowEvent"||T==="bpmn:IntermediateCatchEvent",S=T=>(T??[]).filter(N=>N.type==="bpmn:SequenceFlow"),O=Ft(e,"sequenceFlow.update"),I=(T,N)=>{if(!T)return;const L=N.x+N.width/2,D=N.y+N.height/2;let z;const j=X=>{for(const ne of X.children??[])if(ne.type==="bpmn:Lane"){const le=ne;L>=le.x&&L<=le.x+le.width&&D>=le.y&&D<=le.y+le.height&&(z=le,j(le))}};return j(T),z==null?void 0:z.id};for(const T of O){if(T.source===void 0&&T.target===void 0||k.has(T.id))continue;const N=f(T.id);if(!N)continue;const L=T.source!==void 0?f(T.source):N.source,D=T.target!==void 0?f(T.target):N.target;if(!L||!D||L.id===D.id||P.has(L.id)||P.has(D.id)||!b(L.type)||!_(D.type)||L.parent!==D.parent||S(D.incoming).some(te=>te.id!==N.id)||S(D.outgoing).some(te=>te.id!==N.id)||O.some(te=>te!==T&&(te.target===D.id||te.source===D.id))||D.x>=L.x+L.width)continue;const z=L.parent,j=g(L),X=L.x+L.width+Ee,ne=L.y+L.height/2,le=D.y+D.height/2,ae=I(j,L)===I(j,D),oe=new Set([D.id]),ye=[ae?ne:le,le].find(te=>!C(z,D,X,te,oe));if(ye===void 0)continue;if(n.moveElements([D],{x:X-(D.x+D.width/2),y:ye-le}),j){const te=D.x+D.width+Af-(j.x+j.width);te>0&&sl(n,j,j.width+te)}const ge=te=>({x:te.x+te.width/2,y:te.y+te.height/2});n.reconnect(N,L,D,[ge(L),ge(D)]),Math.abs(ge(L).y-ge(D).y)>1&&n.layoutConnection(N,{waypoints:[]}),O1.add(T.id)}}const br=40,A3=10,Ep=b=>{const _=j=>j.kind==="label-over-line"||j.kind==="label-over-shape"||j.kind==="label-on-shared-segment"?j.edge===b.id:j.kind==="annotation-over-label"||j.kind==="pool-name-over-label"?j.label===b.id:!1,S=()=>new Map(ft(Ue(r)).filter(j=>!_(j)).map(j=>[pt(j),j])),O=S(),I=j=>[...j].filter(([X])=>!O.has(X)).map(([,X])=>X),T=j=>I(j).length<=[...O.keys()].filter(X=>!j.has(X)).length,N=b.waypoints.map(j=>({x:j.x,y:j.y})),L=b.label,D=L&&{x:L.x,y:L.y};n.layoutConnection(b,{waypoints:[]});const z=S();if(!T(z)){if(I(z).every(j=>j.kind==="edge-crosses-shape"&&j.edge===b.id)){const j=Ue(r),X=j.edges.find(oe=>oe.id===b.id),ne=Hn(j),le=X?Ht(X,ne):[],ae=X&&le.length&&!le.every(oe=>oe.type==="bpmn:TextAnnotation")?Xc(X,ne,Zc(b),j.edges):null;if(ae&&(n.updateWaypoints(b,ae),T(S())))return}n.updateWaypoints(b,N),L&&D&&(L.x!==D.x||L.y!==D.y)&&n.moveElements([L],{x:D.x-L.x,y:D.y-L.y})}},Ig=5,Li=10,D1=200,_c=new Set([...F.map(b=>b.flow.id),...v.map(b=>b.flow.id),...Ft(e,"sequenceFlow.update").map(b=>b.id),...Ft(e,"messageFlow.update").map(b=>b.id)].filter(b=>!!b)),P3=(b,_,S,O,I,T)=>{const N=new Set(b.map(te=>te.id)),L=Math.min(...b.map(te=>te.x))+_-Li,D=Math.max(...b.map(te=>te.x+te.width))+_+D1+Li,z=Math.min(...b.map(te=>te.y+Math.min(0,...S)))-Li,j=Math.max(...b.map(te=>te.y+te.height+Math.max(0,...S)))+Li,X=r.getAll().filter(te=>{if(te.type!=="bpmn:SequenceFlow"&&te.type!=="bpmn:MessageFlow")return!1;const Z=te;return _c.has(Z.id)||!Z.waypoints||Z.waypoints.length<2||[Z.source,Z.target].some(Q=>!Q||N.has(Q.id)||Q.x>=O)?!1:Z.waypoints.some((Q,ve)=>{const $e=Z.waypoints[ve+1];return!!$e&&Math.max(Q.x,$e.x)>=L&&Math.min(Q.x,$e.x)<=D&&Math.max(Q.y,$e.y)>=z&&Math.min(Q.y,$e.y)<=j})});if(!X.length)return 0;const ne=te=>{const Z=new Map;for(const re of b)for(const Q of S){const ve={id:re.id,type:re.type,x:re.x+_+te,y:re.y+Q,width:re.width,height:re.height};for(const $e of X){let De=1/0;for(let Ae=0;Ae+1<$e.waypoints.length;Ae++)De=Math.min(De,Dr($e.waypoints[Ae],$e.waypoints[Ae+1],ve));const Xe=`${$e.id}|${re.id}`;Z.set(Xe,Math.min(Z.get(Xe)??1/0,De))}}return Z},le=[...ne(0)].filter(([,te])=>te<=Ig).map(([te])=>te);if(!le.length)return 0;let ae=0;for(let te=1;te<=D1;te++){const Z=ne(te);if([...Z.values()].every(re=>re>Ig)&&le.every(re=>(Z.get(re)??1/0)>=Li)){ae=te;break}}if(!ae)return 0;const oe=Math.min(...b.map(te=>te.x))+_+ae,ye=new Set(le.map(te=>te.slice(0,te.indexOf("|"))));return X.some(te=>te.type==="bpmn:SequenceFlow"&&ye.has(te.id)&&te.waypoints.some((Z,re)=>{const Q=te.waypoints[re+1];if(!Q||Math.min(Z.y,Q.y)>T||Math.max(Z.y,Q.y)<T||Z.y===Q.y)return!1;const ve=Z.x+(T-Z.y)*(Q.x-Z.x)/(Q.y-Z.y);return ve>I&&ve<oe}))?0:ae},xr=(b,_=()=>!0)=>{const S=f(b);if(!S)return[];const O=[S],I=new Set([b]);for(let T=0;T<O.length;T++){const N=O[T].id;for(const L of F){const D=L.flow.target;if(L.flow.source!==N||I.has(D)||!P.has(D))continue;I.add(D);const z=f(D);z&&_(z)&&O.push(z)}}return O},T3=(b,_=()=>!0)=>{const S=f(b);if(!S)return[];const O=[S],I=new Set([b]);for(let T=0;T<O.length;T++){const N=O[T].id;for(const L of F){const D=L.flow.source;if(L.flow.target!==N||I.has(D)||!P.has(D))continue;I.add(D);const z=f(D);z&&_(z)&&O.push(z)}}return O},Ii=30,Bi=b=>!("waypoints"in b&&b.waypoints)&&b.type!=="bpmn:Lane"&&b.type!=="label"&&typeof b.x=="number",Ja=(b,_)=>sl(n,b,_),es=(b,_,S=!1)=>{const O=new Set(b.flatMap(D=>D.subtree.map(z=>z.id)));for(const D of b){const z=(D.pool.children??[]).filter(Bi).filter(X=>!O.has(X.id));if(D.subtree.some(X=>z.some(ne=>X.x+_<ne.x+ne.width+Ii&&X.x+_+X.width+Ii>ne.x&&X.y<ne.y+ne.height&&X.y+X.height>ne.y)))return null}const I=b.map(D=>D.pool.width),T=S?r.filter(D=>Array.isArray(D.waypoints)).map(D=>({c:D,wps:D.waypoints.map(z=>({x:z.x,y:z.y}))})):[],N=r.filter(D=>D.type==="label").map(D=>({label:D,x:D.x,y:D.y}));n.moveElements(b.flatMap(D=>D.subtree),{x:_,y:0});const L=b.map(D=>{const j=Math.max(...D.subtree.map(X=>X.x+X.width))+Af-(D.pool.x+D.pool.width);return j>0&&Ja(D.pool,D.pool.width+j),j});return()=>{n.moveElements(b.flatMap(D=>D.subtree),{x:-_,y:0}),b.forEach((D,z)=>{L[z]>0&&Ja(D.pool,I[z])});for(const{c:D,wps:z}of T){const j=D.waypoints??[];j.length===z.length&&j.every((ne,le)=>Math.abs(ne.x-z[le].x)<=.5&&Math.abs(ne.y-z[le].y)<=.5)||n.updateWaypoints(D,z.map(ne=>({x:ne.x,y:ne.y})))}for(let D=0;D<3;D++){let z=0;for(const j of N){const X=j.x-j.label.x,ne=j.y-j.label.y;Math.abs(X)<=.5&&Math.abs(ne)<=.5||(n.moveElements([j.label],{x:X,y:ne}),z++)}if(!z)break}}},Bg=b=>{var I,T;const _=new Map,S=new Map;for(const N of r.getAll()){if(N.type!=="bpmn:Participant")continue;const L=N;(L.children??[]).length||(_.set(L.id,L),S.set(L.id,[]))}for(const N of r.getAll()){if(N.type!=="bpmn:MessageFlow")continue;const L=N,D=(I=L.source)==null?void 0:I.id,z=(T=L.target)==null?void 0:T.id;D&&z&&S.has(D)&&S.get(D).push(z),D&&z&&S.has(z)&&S.get(z).push(D)}const O=[];for(const[N,L]of S)L.length&&L.every(D=>b.has(D))&&O.push(_.get(N));return O},L1=(b,_)=>{if(!b.length)return null;const S=new Set(b.map(j=>j.id)),O=r.getAll().filter(j=>j.type==="bpmn:Participant"&&!S.has(j.id)),I=Math.min(...O.filter(j=>(j.children??[]).length>0).map(j=>j.x)),T=new Set(b.filter(j=>Math.abs(j.x-I)<=2).map(j=>j.id));if(b.some(j=>{const X=T.has(j.id)?j.x:j.x+_,ne=T.has(j.id)?j.width+_:j.width;return O.some(le=>X<le.x+le.width+Ii&&X+ne+Ii>le.x&&j.y<le.y+le.height&&j.y+j.height>le.y)}))return null;const L=r.filter(j=>j.type==="label").map(j=>({label:j,x:j.x,y:j.y})),D=b.filter(j=>!T.has(j.id)),z=b.filter(j=>T.has(j.id)).map(j=>({pool:j,was:{x:j.x,y:j.y,width:j.width,height:j.height}}));D.length&&n.moveElements(D,{x:_,y:0});for(const{pool:j,was:X}of z)n.resizeShape(j,{...X,width:X.width+_});return()=>{for(const{pool:j,was:X}of z)n.resizeShape(j,X);D.length&&n.moveElements(D,{x:-_,y:0});for(let j=0;j<3;j++){let X=0;for(const ne of L){const le=ne.x-ne.label.x,ae=ne.y-ne.label.y;Math.abs(le)<=.5&&Math.abs(ae)<=.5||(n.moveElements([ne.label],{x:le,y:ae}),X++)}if(!X)break}}},I1=(b,_,S)=>{const O=S.x+S.width/2,I=_.y>S.y,T=I?S.y+S.height:S.y,N=I?_.y:_.y+_.height,L=b.source===_?[{x:O,y:N},{x:O,y:T}]:[{x:O,y:T},{x:O,y:N}],D=Ue(r),z={...D.edges.find(j=>j.id===b.id),waypoints:L};return Ht(z,Hn(D)).length?!1:(n.updateWaypoints(b,L),!0)},k3=()=>{const b=r.filter(N=>N.type==="bpmn:Participant"),_=Math.min(...b.filter(N=>(N.children??[]).length>0).map(N=>N.x)),S=N=>m.some(L=>L.participant.id===N.id),O=N=>!!N&&N.type==="bpmn:Participant"&&!(N.children??[]).length&&Math.abs(N.x-_)<=2&&!S(N),I=N=>!!N&&N.type==="bpmn:Participant"&&(N.children??[]).length>0&&!S(N),T=new Set;for(const N of r.getAll()){if(N.type!=="bpmn:MessageFlow")continue;const L=N;if((L.waypoints??[]).length!==2)continue;const D=[L.source,L.target].find(X=>O(X)||I(X)),z=D===L.source?L.target:L.source;if(!D||!z||z.type==="bpmn:Participant")continue;const j=z.x+z.width/2;I(D)&&(j<D.x||j>D.x+D.width)||T.add(L.id)}return T},O3=b=>{var S;const _=new Map;for(const O of b){const I=r.get(O);if(!I||(I.waypoints??[]).length===2)continue;const T=((S=I.source)==null?void 0:S.type)==="bpmn:Participant"?I.source:I.target,N=T===I.source?I.target:I.source;if(N.x+N.width/2<=T.x+T.width)continue;const L=_.get(T.id)??{pool:T,msgs:[]};L.msgs.push({conn:I,other:N}),_.set(T.id,L)}for(const{pool:O,msgs:I}of _.values()){const T=Math.max(...I.map(({other:ae})=>ae.x+ae.width/2))+Cf;if(r.getAll().some(ae=>{if(ae.type!=="bpmn:Participant"||ae.id===O.id)return!1;const oe=ae;return O.x<oe.x+oe.width+Ii&&T+Ii>oe.x&&O.y<oe.y+oe.height&&O.y+O.height>oe.y}))continue;const L={x:O.x,y:O.y,width:O.width,height:O.height},D=[...O.incoming??[],...O.outgoing??[]],z=D.map(ae=>({c:ae,wps:(ae.waypoints??[]).map(oe=>({x:oe.x,y:oe.y}))})),j=D.flatMap(ae=>{const oe=ae.label;return oe?[{label:oe,x:oe.x,y:oe.y}]:[]}),X=wr();Ja(O,T-O.x);const ne=I.filter(({conn:ae,other:oe})=>I1(ae,O,oe)).length,le=wr();if(!(ne>0&&le.messages>X.messages&&le.lines>=X.lines)){Ja(O,L.width);for(const{c:ae,wps:oe}of z){const ye=ae.waypoints??[];ye.length===oe.length&&ye.every((te,Z)=>Math.abs(te.x-oe[Z].x)<=.5&&Math.abs(te.y-oe[Z].y)<=.5)||n.updateWaypoints(ae,oe.map(te=>({x:te.x,y:te.y})))}for(let ae=0;ae<3;ae++){let oe=0;for(const ye of j){const ge=ye.x-ye.label.x,te=ye.y-ye.label.y;Math.abs(ge)<=.5&&Math.abs(te)<=.5||(n.moveElements([ye.label],{x:ge,y:te}),oe++)}if(!oe)break}}}},B1=()=>{let b=0;for(const _ of r.getAll()){if(_.type!=="bpmn:DataInputAssociation"&&_.type!=="bpmn:DataOutputAssociation")continue;const S=_.waypoints??[];for(let O=1;O<S.length;O++)b+=Math.hypot(S[O].x-S[O-1].x,S[O].y-S[O-1].y)}return b},N1=()=>{let b=0;for(const _ of r.getAll()){if(_.type!=="bpmn:Association")continue;const S=_.waypoints??[];for(let O=1;O<S.length;O++)b+=Math.hypot(S[O].x-S[O-1].x,S[O].y-S[O-1].y)}return b},D3=b=>{const _=[];for(const S of r.getAll()){if(S.type!=="bpmn:TextAnnotation")continue;const O=S;if(b.has(O.id))continue;const T=[...O.incoming??[],...O.outgoing??[]].filter(D=>D.type==="bpmn:Association").map(D=>D.source===O?D.target:D.source);if(!T.length||T.some(D=>D===void 0))continue;const N=D=>{if(!("waypoints"in D&&D.waypoints))return[D.id];const z=D,j=[z.source,z.target];return j.some(X=>!X)?[]:j.map(X=>X.id)},L=T.flatMap(D=>N(D));L.length&&L.every(D=>b.has(D))&&_.push(O)}return _},$1=()=>ft(Ue(r)).filter(b=>b.kind==="edge-crosses-shape").length,F1=b=>{const _=(b.children??[]).filter(Bi);let S=0;for(let O=0;O<_.length;O++)for(let I=O+1;I<_.length;I++){const T=_[O],N=_[I];T.x<N.x+N.width&&T.x+T.width>N.x&&T.y<N.y+N.height&&T.y+T.height>N.y&&S++}return S},wr=()=>{const b=Ue(r),_=S=>S.length>=2&&(S.every(O=>Math.abs(O.x-S[0].x)<.01)||S.every(O=>Math.abs(O.y-S[0].y)<.01));return{messages:b.edges.filter(S=>S.type==="bpmn:MessageFlow"&&S.waypoints.length===2).length,lines:b.edges.filter(S=>_(S.waypoints)).length}},j1=b=>{const _=new Map;for(const O of r.getAll()){if(O.type!=="bpmn:MessageFlow")continue;const I=O;if(!I.waypoints||I.waypoints.length!==2)continue;const T=I.source,N=I.target;if(!T||!N)continue;const L=b.has(T.id);if(L===b.has(N.id))continue;const D=L?N:T,z=g(D);if(!z||b.has(D.id))continue;const j=_.get(z.id);j?D.x<j.minX&&(j.minX=D.x):_.set(z.id,{pool:z,minX:D.x})}const S=[];for(const{pool:O,minX:I}of _.values()){const T=(O.children??[]).filter(N=>Bi(N)&&!b.has(N.id)&&N.x>=I);T.length&&S.push({subtree:T,pool:O})}return S},L3=(b,_,S)=>{const O=new Map(_.map(N=>[N.pool.id,{subtree:[...N.subtree],pool:N.pool}])),I=new Set(b);for(const N of _)for(const L of N.subtree)I.add(L.id);let T=!1;for(;;){let N=0;for(const L of j1(I)){if(L.pool===S)continue;const D=O.get(L.pool.id);D?D.subtree.push(...L.subtree):O.set(L.pool.id,{subtree:[...L.subtree],pool:L.pool});for(const z of L.subtree)I.add(z.id);N+=L.subtree.length}if(!N)break;T=!0}return T?[...O.values()]:null},I3=(b,_)=>{const S=new Map;for(const I of r.getAll()){if(I.type!=="bpmn:DataInputAssociation"&&I.type!=="bpmn:DataOutputAssociation")continue;const T=I,N=T.waypoints;if(!N||N.length<2||!N.every(le=>Math.abs(le.x-N[0].x)<1))continue;const L=T.source,D=T.target;if(!L||!D)continue;const z=b.has(L.id);if(z===b.has(D.id))continue;const j=z?D:L,X=g(j);if(!X||X===_||X===g(z?L:D))continue;const ne=S.get(X.id);ne?j.x<ne.minX&&(ne.minX=j.x):S.set(X.id,{pool:X,minX:j.x})}const O=[];for(const{pool:I,minX:T}of S.values()){const N=(I.children??[]).filter(L=>Bi(L)&&!b.has(L.id)&&L.x>=T);N.length&&O.push({subtree:N,pool:I})}return O},H1=b=>{const _=Ue(r),S=_.shapes.filter(I=>b.has(I.id)),O=new Set;for(const I of _.edges)if(!(I.type!=="bpmn:SequenceFlow"&&I.type!=="bpmn:MessageFlow"))for(const T of Ht(I,S))O.add(`${I.id}|${T.id}`);return O},Ng=new Map,B3=Ft(e,"sequenceFlow.update").flatMap(b=>{if(b.target!==void 0)return[{id:b.id,target:b.target,source:b.source}];const _=k.get(b.id);return _?[{id:b.id,target:_.flow.target,source:_.flow.source}]:[]});for(const b of B3){if(b.target===void 0)continue;const _=P.get(b.target);if(!_)continue;const S=f(b.target),O=f(b.id);if(!S||!O)continue;const I=b.source!==void 0?f(b.source):O.source,T=O.target;if(!I||!T||T.id===S.id)continue;const N=k1.get(O.id)??{waypoints:O.waypoints,label:O.label},L=N.waypoints&&N.waypoints.length>=3&&Math.abs(N.waypoints[0].x-N.waypoints[1].x)<1&&Math.abs(N.waypoints[0].y-N.waypoints[1].y)>1?{x:N.waypoints[0].x,y:N.waypoints[0].y}:void 0,D=L?N.waypoints[1].y:void 0,z=L&&N.label?{x:N.label.x,y:N.label.y}:void 0,j=z&&N.label&&Math.abs(z.y+N.label.height/2-D)<=me/5&&z.x+N.label.width>L.x?z.x+N.label.width+6:void 0,X=(I.outgoing??[]).filter(Le=>Le.type==="bpmn:SequenceFlow"&&Le.id!==O.id&&Le.target&&!_c.has(Le.id)),ne=new Set(X.map(Le=>Le.target.id)),le=Le=>{const Mt={type:"bpmn:Task",x:Le.x+2,y:Le.y+2,width:Le.width-4,height:Le.height-4};return X.find(vt=>(vt.waypoints??[]).some((Zt,je)=>!!vt.waypoints[je+1]&&Dr(Zt,vt.waypoints[je+1],Mt)===0))},ae=xr(b.target),oe=new Set(ae.map(Le=>Le.id)),ye=Rt.has(b.target)?{autoResize:!1}:void 0,ge=Math.min(...ae.map(Le=>Le.x)),te=Math.max(...ae.map(Le=>Le.x+Le.width)),Z=I.x+I.width,re=T.x+T.width<=I.x,Q=(()=>{if(!re)return;const Le=g(S),Mt=((Le==null?void 0:Le.children)??[]).filter(Ge=>Bi(Ge)&&!oe.has(Ge.id)&&Ge.type!=="bpmn:Group"&&Ge.type!=="bpmn:Participant"),vt=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],Zt=r.getAll().filter(Ge=>{if(!vt.includes(Ge.type))return!1;const Bt=Ge;return Bt.id===O.id||_c.has(Bt.id)||!Bt.waypoints||Bt.waypoints.length<2?!1:![Bt.source,Bt.target].some(kt=>!kt||oe.has(kt.id))}),je=(Ge,Bt)=>ae.every(kt=>{var ta;const _t={id:kt.id,type:kt.type,x:kt.x+Ge,y:kt.y+Bt,width:kt.width,height:kt.height};return Le&&(_t.x<Le.x||_t.x+_t.width>Le.x+Le.width||_t.y<Le.y||_t.y+_t.height>Le.y+Le.height)||!xp((ta=P.get(kt.id))==null?void 0:ta.node.lane,kt,kt.y+Bt+kt.height/2)||Mt.some(Yn=>_t.x<Yn.x+Yn.width+Li&&_t.x+_t.width+Li>Yn.x&&_t.y<Yn.y+Yn.height+Li&&_t.y+_t.height+Li>Yn.y)?!1:Zt.every(Yn=>{for(let po=0;po+1<Yn.waypoints.length;po++)if(Dr(Yn.waypoints[po],Yn.waypoints[po+1],_t)<Li)return!1;return!0})}),Ye=I.x+I.width/2,gt=I.y+I.height/2,it=N.waypoints??[],Pt=it.length>=2&&Math.abs(it[0].y-it[1].y)<1&&it[1].x<it[0].x;return[...D!==void 0?[{cx:Ye,cy:D}]:[],...Pt?[{cx:I.x-br-S.width/2,cy:it[0].y}]:[],{cx:Ye,cy:gt+me},{cx:Ye,cy:gt-me}].find(Ge=>je(Ge.cx-(S.x+S.width/2),Ge.cy-(S.y+S.height/2)))})(),ve=re&&!Q?Z:T.x,$e=(()=>{var gt;if(L||re)return 0;const Le=N.label,Mt=((gt=O.businessObject)==null?void 0:gt.name)??"";if(!Le||Le.width==null||!Mt.trim())return 0;const vt=Z+br,Zt=I.y+I.height/2-S.height/2;if(Math.min(Le.y+Le.height,Zt+S.height)-Math.max(Le.y,Zt)<3||Le.x+Le.width-vt<3)return 0;const Ye=Le.x+Le.width+A3-vt;return Ye<=S.width?Ye:0})();$e>0&&u.add(O.id);const De=S.y+S.height/2,Xe=P3(ae,Z+br+$e-ge,[0,I.y+I.height/2-De,T.y+T.height/2-De],ve,Z,I.y+I.height/2),Ae=Z+br+$e+Xe,Pe=(()=>{if(j===void 0)return 0;const Le=Z+br,Mt=I.y+I.height/2-S.height/2,vt={x:Le,y:Mt,width:te-ge,height:S.height},Zt=g(I);return((Zt==null?void 0:Zt.children)??[]).some(Ye=>Bi(Ye)&&!oe.has(Ye.id)&&Ye.id!==I.id&&Ye.id!==T.id&&Ye.type!=="bpmn:Group"&&Ye.type!=="bpmn:Participant"&&Ye.x<vt.x+vt.width&&Ye.x+Ye.width>vt.x&&Ye.y<vt.y+vt.height&&Ye.y+Ye.height>vt.y)||le(vt)?Math.max(0,j-Le):0})(),Ce=Q?0:te-ge+br*2+Xe+Pe+$e-(re?0:T.x-Z);let Te=[];if(Ce>0){const Le=g(S),Mt=(Le==null?void 0:Le.children)??[],vt=it=>it.type==="bpmn:Lane";Te=(()=>{const it=new Set;for(const We of Mt)Bi(We)&&!oe.has(We.id)&&We.id!==I.id&&We.x>=ve&&it.add(We.id);const Pt=[];for(const We of Mt){if(We.type!=="bpmn:DataStoreReference"&&We.type!=="bpmn:DataObjectReference")continue;const Ge=We,kt=[...Ge.incoming??[],...Ge.outgoing??[]].filter(_t=>_t.type==="bpmn:DataInputAssociation"||_t.type==="bpmn:DataOutputAssociation").map(_t=>_t.source===Ge?_t.target:_t.source);kt.length&&kt.every(_t=>_t!==void 0&&it.has(_t.id))&&Pt.push(Ge)}return Pt})();const je=Mt.filter(it=>!("waypoints"in it&&it.waypoints)&&!vt(it)&&it.type!=="label"&&!oe.has(it.id)&&it.id!==I.id&&it.x>=ve),Ye=je.flatMap(it=>it.labels??[]),gt=Le?[Le,...Mt.filter(it=>vt(it))]:[];if(je.length){const it=new Set(je.map(rt=>rt.id)),Pt=j1(it),We=Pt.length?L3(it,Pt,Le):null,Ge=rt=>{const Et=new Set(it);for(const Nt of rt)for(const Lo of Nt.subtree)Et.add(Lo.id);return D3(Et)},Bt=Ge(Pt),kt=We?Ge(We):Bt,_t=Bg(it),ta=new Set(it);for(const rt of Pt)for(const Et of rt.subtree)ta.add(Et.id);const Yn=Pt.length?Bg(ta):_t,po=(()=>{if(!We)return[];const rt=new Set(it);for(const Et of We)for(const Nt of Et.subtree)rt.add(Nt.id);return Bg(rt)})(),os=We??Pt,na=(()=>{const rt=new Set(it);for(const Et of os)for(const Nt of Et.subtree)rt.add(Nt.id);return I3(rt,Le)})(),Ug=na.length?Ge([...os,...na]):Bt,Ui=new Set([...je,...gt].map(rt=>rt.id)),bt=Mt.filter(rt=>{const Et=rt.labelTarget;return rt.type==="label"&&!!Et&&"waypoints"in Et&&!!Et.source&&!!Et.target&&Ui.has(Et.source.id)&&Ui.has(Et.target.id)}),Sn=k3();n.createSpace([...je,...Ye,...bt],gt,{x:Ce,y:0},"e",ve-1);const Qt=(rt,Et,Nt)=>{const Lo=wr(),Ap=Nt?H1(Nt):null,Pp=es(rt,Ce,!!Nt);if(!Pp)return!1;const Cc=Et.length?L1(Et,Ce):null,Tp=wr(),Jt=!!Nt&&!!Ap&&[...H1(Nt)].some(oa=>!Ap.has(oa));return Tp.messages>Lo.messages&&Tp.lines>=Lo.lines&&!Jt?!0:(Cc==null||Cc(),Pp(),!1)},fi=na.length>0&&Qt([...os,...na],We?po:Yn,new Set(na.flatMap(rt=>rt.subtree.map(Et=>Et.id)))),ia=!fi&&We?Qt(We,po):!1;let fo=fi||ia;!fo&&Pt.length&&(fo=Qt(Pt,Yn));const rs=fi?Ug:ia?kt:Bt;if(!fo){for(const rt of Pt){const Et=wr(),Nt=es([rt],Ce);if(!Nt)continue;const Lo=wr();(Lo.messages<=Et.messages||Lo.lines<Et.lines)&&Nt()}if(_t.length){const rt=wr(),Et=L1(_t,Ce);if(Et){const Nt=wr();(Nt.messages<=rt.messages||Nt.lines<rt.lines)&&Et()}}}if(O3(Sn),rs.length){const rt=()=>new Set(ft(Ue(r)).map(Nt=>pt(Nt))),Et=Nt=>{const Lo=N1(),Ap=rt(),Pp=Nt.map(Jt=>({a:Jt,x:Jt.x,y:Jt.y})),Cc=r.filter(Jt=>Jt.type==="label").map(Jt=>({label:Jt,x:Jt.x,y:Jt.y}));n.moveElements(Nt,{x:Ce,y:0});const Tp=[...rt()].filter(Jt=>!Ap.has(Jt));if(N1()<Lo&&Tp.length===0)return!0;for(const{a:Jt,x:oa,y:Mc}of Pp)(Jt.x!==oa||Jt.y!==Mc)&&n.moveElements([Jt],{x:oa-Jt.x,y:Mc-Jt.y});for(const Jt of Cc){const oa=Jt.x-Jt.label.x,Mc=Jt.y-Jt.label.y;(oa!==0||Mc!==0)&&n.moveElements([Jt.label],{x:oa,y:Mc})}return!1};if(!Et(rs)&&rs.length>1)for(const Nt of rs)Et([Nt])}}}const pe=_.node.lane!==void 0?f(_.node.lane):_.node.participant!==void 0?f(_.node.participant):void 0,Me=Le=>{if(!pe)return!0;const Mt=Le.y+Le.height/2;return Mt>=pe.y&&Mt<=pe.y+pe.height},ke=!Me(I)&&Me(T),Fe=Le=>Le.y+Le.height/2,wt=()=>{const Le=I.x+I.width,Mt=T.x,vt=Fe(T)-S.height/2,Zt=Fe(T)+S.height/2;return!r.getAll().some(je=>Bi(je)&&je.type!=="bpmn:Participant"&&je.type!=="bpmn:Group"&&je.type!=="bpmn:TextAnnotation"&&je.id!==I.id&&je.id!==T.id&&je.id!==S.id&&je.x<Mt&&je.x+je.width>Le&&je.y<Zt&&je.y+je.height>vt)},rn=!ke&&_.band!==void 0&&Me(T)&&!xn(_.node.lane,_.node.participant,_.band,Fe(I))&&xn(_.node.lane,_.node.participant,_.band,Fe(T))&&T.x>=I.x+I.width&&wt(),Kt=ke||rn?T:I,Xt=Kt.y+Kt.height/2,Nn=Xt-(S.y+S.height/2),wn=_.band!==void 0,Mp=wn?[S]:ae,Wg=(_.band===void 0||xn(_.node.lane,_.node.participant,_.band,Xt))&&pi(b.target)&&Mp.every(Le=>{var Mt;return xp((Mt=P.get(Le.id))==null?void 0:Mt.node.lane,Le,Le.y+Le.height/2+Nn)}),aF=Le=>Math.abs(Le.y+Le.height/2-(S.y+S.height/2))<=me/2;if(Wg&&wn){const Le=Math.abs(Nn)<=me/2?ae.filter(je=>je.id!==S.id&&aF(je)):[],Mt=S.y+S.height/2,Zt=_.band!==void 0&&!xn(_.node.lane,_.node.participant,_.band,Mt)?ae.filter(je=>{var Ye,gt;return je.id!==S.id&&!Le.includes(je)&&((Ye=P.get(je.id))==null?void 0:Ye.band)===_.band&&((gt=P.get(je.id))==null?void 0:gt.node.lane)===_.node.lane&&(Math.abs(je.y+je.height/2-Mt)<=me/2||xn(_.node.lane,_.node.participant,_.band,je.y+je.height/2))}).map(je=>({t:je,dy:Xt-(je.y+je.height/2)})).filter(({dy:je})=>je!==0):[];if(n.moveElements(ae,{x:Ae-ge,y:0},void 0,ye),n.moveElements([S],{x:0,y:Nn},void 0,ye),Le.length){const je=()=>new Set(ft(Ue(r)).map(Ge=>pt(Ge))),Ye=je(),gt=r.filter(Ge=>Ge.type==="label").map(Ge=>({label:Ge,x:Ge.x,y:Ge.y}));n.moveElements(Le,{x:0,y:Nn});const it=je(),Pt=[...it].filter(Ge=>!Ye.has(Ge)).length,We=[...Ye].filter(Ge=>!it.has(Ge)).length;if(Pt>We){n.moveElements(Le,{x:0,y:-Nn});for(const Ge of gt){const Bt=Ge.x-Ge.label.x,kt=Ge.y-Ge.label.y;(Bt!==0||kt!==0)&&n.moveElements([Ge.label],{x:Bt,y:kt})}}}if(Zt.length){const je=new Set(ae.map(Ye=>Ye.id));for(const{t:Ye,dy:gt}of Zt)C(Ye.parent,Ye,Ye.x+Ye.width/2,Ye.y+Ye.height/2+gt,je)||n.moveElements([Ye],{x:0,y:gt})}}else n.moveElements(ae,{x:Ae-ge,y:Wg?Nn:0},void 0,ye);const Wi=g(S);if(!Wg&&_.node.lane===void 0&&_.band!==void 0&&Wi){const Le=Wi.y+U+$t(`pool:${_.node.participant??""}`,_.band)*me,Mt=Le-(S.y+S.height/2);Mt!==0&&!C(Wi,S,S.x+S.width/2,Le,oe)&&n.moveElements([S],{x:0,y:Mt},void 0,ye)}if(Q)n.moveElements(ae,{x:Q.cx-(S.x+S.width/2),y:Q.cy-(S.y+S.height/2)},void 0,ye);else if(Wi){const Le=(Wi.children??[]).filter(je=>Bi(je)&&!oe.has(je.id)&&je.type!=="bpmn:Group"&&je.type!=="bpmn:Participant"),Mt=(je,Ye,gt,it,Pt)=>je.x+Ye<Pt.x+Pt.width+it&&je.x+Ye+je.width+it>Pt.x&&je.y+gt<Pt.y+Pt.height+it&&je.y+gt+je.height+it>Pt.y,vt=Le.find(je=>Mt(S,0,0,0,je)),Zt=vt?void 0:le(S);if(vt||Zt){const je=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],Ye=r.getAll().filter(bt=>{if(!je.includes(bt.type))return!1;const Sn=bt;return _c.has(Sn.id)||!Sn.waypoints||Sn.waypoints.length<2?!1:![Sn.source,Sn.target].some(Qt=>!Qt||oe.has(Qt.id))}),gt=(bt,Sn,Qt)=>{var fi;return xp((fi=P.get(bt.id))==null?void 0:fi.node.lane,bt,bt.y+Qt+bt.height/2)&&bt.x+Sn>=Wi.x&&bt.x+Sn+bt.width<=Wi.x+Wi.width&&bt.y+Qt>=Wi.y&&bt.y+Qt+bt.height<=Wi.y+Wi.height},it=(bt,Sn)=>ae.every(Qt=>gt(Qt,bt,Sn)&&!Le.some(fi=>Mt(Qt,bt,Sn,Li,fi))&&Ye.every(fi=>{const ia={id:Qt.id,type:Qt.type,x:Qt.x+bt,y:Qt.y+Sn,width:Qt.width,height:Qt.height};for(let fo=0;fo+1<fi.waypoints.length;fo++)if(Dr(fi.waypoints[fo],fi.waypoints[fo+1],ia)<Li)return!1;return!0})),Pt=S.y+S.height/2,We=[D,T.y+T.height/2].filter(bt=>bt!==void 0&&Math.abs(bt-Pt)>=1),Ge=vt&&ne.has(vt.id)?vt:Zt==null?void 0:Zt.target,Bt=Ge?Ge.x-S.x:0,kt=Math.max(...ae.map(bt=>bt.x+bt.width)),_t=[...Bt!==0?[Bt]:[],...Xe!==0?[-Xe]:[],0],ta=j===void 0?[]:_t.map(bt=>Math.max(bt,j-S.x)),Yn=bt=>kt+bt+br<=T.x,po=[...new Set([...ta,..._t])].filter(Yn),os=vt&&ne.has(vt.id)?[vt.x+vt.width+br-S.x]:[],na=j===void 0?[]:os.map(bt=>Math.max(bt,j-S.x)),Ug=[...new Set([...na,...os])].filter(bt=>Yn(bt)&&!po.includes(bt));let Ui;for(const bt of[po,Ug]){for(const Sn of We){for(const Qt of bt)if(it(Qt,Sn-Pt)){Ui={dx:Qt,dy:Sn-Pt};break}if(Ui)break}if(Ui)break}if(Ui){const bt=rt=>{const Et=rt;return[Et.edge,Et.other,...Array.isArray(Et.edges)?Et.edges:[]].some(Nt=>typeof Nt=="string"&&_c.has(Nt))},Sn=()=>new Set(ft(Ue(r)).filter(rt=>!bt(rt)).map(rt=>pt(rt))),Qt=Sn(),fi=r.filter(rt=>rt.type==="label").map(rt=>({label:rt,x:rt.x,y:rt.y}));n.moveElements(ae,{x:Ui.dx,y:Ui.dy},void 0,ye);const ia=Sn(),fo=[...ia].filter(rt=>!Qt.has(rt)).length,rs=[...Qt].filter(rt=>!ia.has(rt)).length;if(fo>rs){n.moveElements(ae,{x:-Ui.dx,y:-Ui.dy},void 0,ye);for(const rt of fi){const Et=rt.x-rt.label.x,Nt=rt.y-rt.label.y;(Et!==0||Nt!==0)&&n.moveElements([rt.label],{x:Et,y:Nt})}}else L&&Ng.set(O.id,{exit:L,channelY:D,label:z})}}}{const Le=new Set(ae.map(Ye=>Ye.id)),Mt=new Set(F.map(Ye=>Ye.flow.id)),vt=20,Zt=Ye=>{const gt=Ye.source,it=Ye.target,Pt=Math.min(gt.x,it.x)-vt,We=Math.max(gt.x+gt.width,it.x+it.width)+vt,Ge=Math.min(gt.y,it.y)-vt,Bt=Math.max(gt.y+gt.height,it.y+it.height)+vt;return Ye.waypoints.some(kt=>kt.x<Pt||kt.x>We||kt.y<Ge||kt.y>Bt)},je=new Map;for(const Ye of ae)for(const gt of[...Ye.incoming??[],...Ye.outgoing??[]])(k.has(gt.id)||gt.id!==b.id&&Mt.has(gt.id))&&!(Le.has(gt.source.id)&&Le.has(gt.target.id))&&je.set(gt.id,gt);for(const Ye of je.values())Zt(Ye)&&Ep(Ye)}const uo=Te.length?g(Te[0]):void 0;if(uo){const Le={assoc:B1(),overlaps:F1(uo),crosses:$1()},Mt=Te.map(We=>({st:We,x:We.x})),vt=r.filter(We=>We.type==="label").map(We=>({label:We,x:We.x,y:We.y})),Zt=Math.min(...Te.flatMap(We=>[...We.incoming??[],...We.outgoing??[]].filter(Ge=>Ge.type==="bpmn:DataInputAssociation"||Ge.type==="bpmn:DataOutputAssociation").map(Ge=>(Ge.source===We?Ge.target:Ge.source).x))),je=new Set(Te.map(We=>We.id)),Ye=(uo.children??[]).filter(Bi).filter(We=>!je.has(We.id));let gt=Zt;for(const We of[...Te].sort((Ge,Bt)=>Ge.x-Bt.x)){let Ge=gt;for(let Bt=0;Bt<100;Bt++){const kt=Ye.find(_t=>Ge<_t.x+_t.width+Ii&&Ge+We.width+Ii>_t.x&&We.y<_t.y+_t.height&&We.y+We.height>_t.y);if(!kt)break;Ge=kt.x+kt.width+Ii}Ge!==We.x&&n.moveElements([We],{x:Ge-We.x,y:0}),gt=Ge+We.width+Ii}const it=gt+150-(uo.x+uo.width);it>0&&Ja(uo,uo.width+it);const Pt={assoc:B1(),overlaps:F1(uo),crosses:$1()};if(Pt.assoc>=Le.assoc||Pt.overlaps>Le.overlaps||Pt.crosses>Le.crosses){for(const{st:We,x:Ge}of Mt)We.x!==Ge&&n.moveElements([We],{x:Ge-We.x,y:0});it>0&&Ja(uo,uo.width-it);for(const We of vt){const Ge=We.x-We.label.x,Bt=We.y-We.label.y;(Ge!==0||Bt!==0)&&n.moveElements([We.label],{x:Ge,y:Bt})}}}}for(const[b,_]of Rt){const S=f(b);if(!S)continue;const O=_.container,I=Math.abs(S.y+S.height/2-O.y-_.relCy)>=.5,T=S.label,N=Math.min(S.y,T&&!T.hidden?T.y:S.y),L=Math.max(S.y+S.height,T&&!T.hidden?T.y+T.height:0);if(I&&N>=O.y&&L<=O.y+O.height)continue;const D=S.y;_.grow(),S.y!==D&&n.moveElements([S],{x:0,y:D-S.y},void 0,{autoResize:!1})}const z1=(b,_)=>{const S=_.target===b,O=d(_.source),I=d(_.target),T=S?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(O,I,_.id?{type:T,businessObject:i.create(T,{id:_.id})}:{type:T})},G1=b=>{for(const _ of m){if(!_.participant.blackBox)continue;const S=f(_.participant.id);if(!S)continue;const O=[];for(const T of v){const N=T.flow.source===_.participant.id?T.flow.target:T.flow.target===_.participant.id?T.flow.source:void 0,L=N?f(N):void 0;L&&typeof L.x=="number"&&L.type!=="bpmn:Participant"&&O.push(L)}if(!O.length)continue;if(!b&&_.order===void 0){const T=(()=>{var L;const N=new Map;for(const D of O){const z=g(D);if(!z)continue;const j=N.get(z.id);j?j.n+=1:N.set(z.id,{shape:z,n:1})}return(L=[...N.values()].sort((D,z)=>z.n-D.n)[0])==null?void 0:L.shape})();if(T){const N=z=>z.reduce((j,X)=>j+X,0)/z.length,L=N(O.map(z=>z.y+z.height/2))<T.y+T.height/2,D=r.filter(z=>z.type==="bpmn:Participant"&&z.id!==_.participant.id&&z.id!==T.id).filter(z=>L?z.y+z.height<=T.y+5:z.y>=T.y+T.height-5);if(D.length){const z=[...D.reduce((re,Q)=>re.set(Q.y,(re.get(Q.y)??0)+1),new Map)].sort((re,Q)=>Q[1]-re[1]||(L?Q[0]-re[0]:re[0]-Q[0]))[0][0],j=Math.min(S.width,JM),X=eA,ne=O.map(re=>re.x+re.width/2),le=Math.round(N(ne)-j/2),ae=Math.max(...ne)+Cf,oe=re=>({x:re,width:Math.max(j,ae-re)}),ye=D.filter(re=>Math.min(re.y+re.height,z+X)-Math.max(re.y,z)>0),ge=re=>{const Q=oe(re);return ye.some(ve=>ve.x<Q.x+Q.width&&Q.x<ve.x+ve.width)},te=re=>{const Q=oe(re);return ne.filter(ve=>ve>=Q.x+10&&ve<=Q.x+Q.width-10).length},Z=(()=>{if(!ge(le))return le;const re=te(le);return ye.flatMap(Q=>[Q.x+Q.width+Oy,Q.x-Oy-j]).map(Q=>Math.round(Q)).filter(Q=>!ge(Q)&&te(Q)>=re).sort((Q,ve)=>Math.abs(Q-le)-Math.abs(ve-le))[0]??le})();if(Z!==S.x||z!==S.y||j!==S.width||X!==S.height){const re=()=>new Set(ft(Ue(r)).map(Ae=>pt(Ae))),Q=re(),ve={x:S.x,y:S.y,width:S.width,height:S.height};n.resizeShape(S,{x:Z,y:z,width:j,height:X});const $e=re(),De=[...$e].filter(Ae=>!Q.has(Ae)).length,Xe=[...Q].filter(Ae=>!$e.has(Ae)).length;De>Xe&&n.resizeShape(S,ve)}}}}const I=Math.max(...O.map(T=>T.x+T.width/2))+Cf;if(I>S.x+S.width&&n.resizeShape(S,{x:S.x,y:S.y,width:I-S.x,height:S.height}),!!b)for(const T of v){const N=f(T.flow.id),L=T.flow.source===_.participant.id?T.flow.target:T.flow.target===_.participant.id?T.flow.source:void 0,D=L?f(L):void 0;if(!N||!D||D.type==="bpmn:Participant")continue;const z=D.x+D.width/2;z<S.x+10||z>S.x+S.width-10||I1(N,S,D)}}};G1(!1);for(const b of v){const _=b.flow;n.connect(d(_.source),d(_.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:_.id,name:_.name})})}{const S=new Set([...F.map(D=>D.flow.id),...v.map(D=>D.flow.id)].filter(D=>!!D)),O=r.filter(D=>!!D.waypoints),I=(D,z)=>Math.abs(z.x-D.x)<2?"L":Math.abs(z.x-(D.x+D.width))<2?"R":Math.abs(z.y-D.y)<2?"T":Math.abs(z.y-(D.y+D.height))<2?"B":void 0,T=new Map,N=(D,z,j)=>{if(!D||!z||typeof D.x!="number")return;const X=I(D,z);if(!X)return;let ne=T.get(D.id);ne||T.set(D.id,ne=new Map),ne.set(X,[...ne.get(X)??[],j])};for(const D of O){const z=D.waypoints;!z||z.length<2||(N(D.source,z[0],{id:D.id,dir:"out"}),N(D.target,z[z.length-1],{id:D.id,dir:"in"}))}const L=new Set;for(const[D,z]of T){const j=f(D);if(!j||typeof j.x!="number")continue;const X=te=>{var re;const Z=(re=f(te.id))==null?void 0:re.source;return!!Z&&typeof Z.x=="number"&&Z.x+Z.width/2>j.x+j.width/2};if(![...z.values()].some(te=>te.length>=3&&te.some(Z=>Z.dir==="out")&&te.some(Z=>Z.dir==="in"&&S.has(Z.id)&&X(Z))))continue;const le=g(j);if(!le||L.has(le.id)||(le.children??[]).some(te=>te.type==="bpmn:Lane"))continue;const ae=(dS=z.get("T"))!=null&&dS.length?(hS=z.get("B"))!=null&&hS.length?void 0:"B":"T";if(!ae||(ae==="T"?j.y-le.y:le.y+le.height-(j.y+j.height))>=me)continue;const ye=(le.children??[]).filter(te=>!("waypoints"in te&&te.waypoints)&&te.type!=="label"&&typeof te.x=="number"),ge=le.y+le.height;n.resizeShape(le,{x:le.x,y:le.y,width:le.width,height:le.height+me}),Jn(ge,le.id,me),ae==="T"&&ye.length&&n.moveElements(ye,{x:0,y:me}),L.add(le.id)}}const $g=20,V1=4,N3=3,$3=2,F3=2,j3=[10,30,80],Qr=()=>{const b=Ue(r);return{bad:ft(b).filter(_=>_.kind==="edge-crosses-shape"||_.kind==="edge-overlap-opposite"||_.kind==="edge-overlap-mixed").length,crossings:Nm(b),straight:b.edges.filter(_=>_.type==="bpmn:MessageFlow"&&_.waypoints.length===2).length}},_r=b=>{const _=Ue(r),S=_.edges.find(O=>O.id===b);return S?Ht(S,Hn(_)).length:0},Ec=b=>_r(b)>0,ts=b=>Ue(r).edges.filter(_=>_.type==="bpmn:MessageFlow"&&_.id!==b&&_.waypoints.length===2).length,W1=(b,_,S)=>es([{subtree:b,pool:_}],S),U1=(b,_)=>_.bad>b.bad||_.crossings>b.crossings&&_.straight<=b.straight&&_.bad>=b.bad,ns=(b,_)=>U1(b,_)||_.straight<b.straight,Er=(b,_,S=()=>!0,O=U1,I=!1)=>{const T=Qr(),N=es(b,_,I);if(!N)return!1;const L=Qr();return O(T,L)||!S()?(N(),!1):!0},H3=(b,_,S,O=()=>!0)=>Er([{subtree:b,pool:_}],S,O),Jr=b=>{var _;return!!((_=P.get(b))!=null&&_.node.participant)},is=new Map;for(const b of v){if(!Jr(b.flow.target))continue;const _=is.get(b.flow.target)??[];_.push(b),is.set(b.flow.target,_)}const Sc=[...is.keys()],Fg=new Set(F.map(b=>b.flow.target)),q1=b=>wp.findIndex(({op:_})=>_.participant.id===b);Sc.sort((b,_)=>{var I,T;const S=Fg.has(b)?1:0,O=Fg.has(_)?1:0;return S!==O?S-O:q1((I=P.get(b))==null?void 0:I.node.participant)-q1((T=P.get(_))==null?void 0:T.node.participant)});const Sr=b=>b.x+b.width/2,z3=b=>{const _=new Map;for(const I of r.getAll()){const T=I;if(!T.waypoints||!T.source||!T.target)continue;(_.get(T.source.id)??_.set(T.source.id,[]).get(T.source.id)).push(T.target.id)}const S=new Set([b]),O=[b];for(let I=0;I<O.length;I++)for(const T of _.get(O[I])??[])S.has(T)||(S.add(T),O.push(T));return S},G3=(b,_)=>{const S=z3(_);let O;for(const I of r.getAll()){const T=I;if(T.type!=="bpmn:MessageFlow"||!T.source||!T.target||T.target.id!==b||S.has(T.source.id))continue;const N=T.source;if(typeof N.x!="number"||N.type==="bpmn:Participant")continue;const L=Sr(N);(O===void 0||L>O)&&(O=L)}return O},jg=(b,_)=>{const S=f(b.flow.source);if(S)return S.type==="bpmn:Participant"?G3(S.id,_):Sr(S)},Y1=b=>{let _;for(const S of is.get(b)??[]){const O=jg(S,b);O!==void 0&&(!_||O>_.cx)&&(_={op:S,cx:O})}return _==null?void 0:_.op},V3=b=>{const _=Y1(b),S=f(b),O=_?jg(_,b):void 0;return S&&O!==void 0?O-Sr(S):void 0},W3=b=>{const _=V3(b);return _!==void 0&&Math.abs(_)<$g},Sp=(b,_,S,O,I)=>{var T;for(let N=!0;N;){N=!1;for(const L of v){if(L.flow.id===S)continue;const D=_.has(L.flow.source),z=_.has(L.flow.target);if(D===z||O(D?L.flow.source:L.flow.target))continue;const j=D?L.flow.target:L.flow.source;if(I(j)||!Jr(j))continue;const X=f(L.flow.id);if(!(X!=null&&X.waypoints)||X.waypoints.length!==2)continue;const ne=f(j),le=(T=P.get(j))==null?void 0:T.node.participant;if(!ne||!le)continue;const ae=xr(j,oe=>oe.x>=ne.x).filter(oe=>!_.has(oe.id));if(!(!ae.length||ae.some(oe=>I(oe.id)))){for(const oe of ae)_.add(oe.id);b.set(le,[...b.get(le)??[],...ae]),N=!0}}}return[...b].map(([N,L])=>({subtree:L,pool:d(N)}))},K1=(b,_,S,O,I)=>Sp(new Map([[_,[...b]]]),new Set(b.map(T=>T.id)),O,T=>T===S,T=>T===I),Hg=b=>{const _=Y1(b);if(!_)return null;const S=f(b),O=f(_.flow.source),I=jg(_,b);if(!S||!O||I===void 0)return null;const T=I-Sr(S);if(T>=$g){const N=P.get(b).node.participant,L=xr(b,D=>D.x>=S.x);return{groups:K1(L,N,b,_.flow.id,_.flow.source),dx:T}}if(-T>=$g&&Jr(_.flow.source)){const N=P.get(_.flow.source).node.participant,L=xr(_.flow.source,D=>D.x>=O.x&&!W3(D.id));return{groups:K1(L,N,_.flow.source,_.flow.id,b),dx:-T}}return null},X1=()=>Sc.map(b=>({id:b,plan:Hg(b)})).filter(b=>!!b.plan).sort((b,_)=>Math.min(...b.plan.groups.flatMap(S=>S.subtree.map(O=>O.x)))-Math.min(..._.plan.groups.flatMap(S=>S.subtree.map(O=>O.x)))).map(b=>b.id);for(let b=0;b<3;b++){const _=Qr(),S=[];for(const I of X1()){const T=Hg(I);if(!T)continue;const N=es(T.groups,T.dx);N&&S.push(N)}if(!S.length)break;if(!ns(_,Qr()))continue;for(const I of S.reverse())I();let O=!1;for(const I of X1()){const T=Hg(I);T&&Er(T.groups,T.dx,()=>!0,ns)&&(O=!0)}if(!O)break}for(const b of Sc){if(Fg.has(b))continue;const _=P.get(b);if(!_||_.node.lane!==void 0)continue;const S=Oe(_);if(S===void 0)continue;const O=f(b),I=O?g(O):void 0;if(!O||!I)continue;const T=I.y+U+$t(`pool:${_.node.participant??""}`,S)*me,N=T-(O.y+O.height/2);N!==0&&!C(I,O,O.x+O.width/2,T)&&n.moveElements([O],{x:0,y:N})}const Rp=()=>{const b=r.filter(O=>O.type==="bpmn:Participant"),_=new Map(b.map(O=>[O.id,O]));let S=0;for(const{pools:[O,I]}of ff(b)){const T=_.get(O),N=_.get(I);S+=(Math.min(T.x+T.width,N.x+N.width)-Math.max(T.x,N.x))*(Math.min(T.y+T.height,N.y+N.height)-Math.max(T.y,N.y))}return S},zg=new Set,Z1=new Set;for(let b=0,_=!0;_&&b<N3;b++){_=!1;for(const S of Sc.flatMap(O=>is.get(O)??[])){if(zg.has(S.flow.id)||!Ec(S.flow.id))continue;const O=f(S.flow.target);if(!O)continue;const I=d(P.get(S.flow.target).node.participant),T=xr(S.flow.target,j=>j.x>=O.x),N=O.width+Ee,L=_r(S.flow.id),D=ts(S.flow.id),z=Rp();for(let j=1;j<=V1;j++){const X=()=>_r(S.flow.id)>=L||Rp()>z?!1:ts(S.flow.id)>=D?!0:(Z1.add(S.flow.id),!1);if(H3(T,I,N*j,X)){zg.add(S.flow.id),_=!0;break}}}}const Q1=()=>r.filter(b=>b.type==="bpmn:SequenceFlow").filter(b=>{const _=b.source,S=b.target;return!!_&&!!S&&S.x+S.width<_.x}).length;for(const b of Sc.flatMap(_=>is.get(_)??[])){if(zg.has(b.flow.id)||!Z1.has(b.flow.id)||!Ec(b.flow.id))continue;const _=f(b.flow.target);if(!_)continue;const S=d(P.get(b.flow.target).node.participant),O=xr(b.flow.target,ne=>ne.x>=_.x),I=new Set(O.map(ne=>ne.id)),T=new Map;for(const ne of r.filter(le=>le.type==="bpmn:MessageFlow")){if(((gS=ne.waypoints)==null?void 0:gS.length)!==2||!ne.source||!ne.target)continue;const le=I.has(ne.source.id);if(le===I.has(ne.target.id))continue;const ae=le?ne.target:ne.source,oe=(mS=P.get(ae.id))==null?void 0:mS.node.participant;!oe||T.has(ae.id)||T.set(ae.id,{subtree:[ae],pool:d(oe)})}if(!T.size)continue;const N=_.width+Ee,L=_r(b.flow.id),D=ts(b.flow.id),z=Rp(),j=Q1(),X=()=>_r(b.flow.id)<L&&ts(b.flow.id)>=D&&Rp()<=z&&Q1()<=j;for(let ne=1;ne<=$3&&!Er([{subtree:O,pool:S},...T.values()],N*ne,X);ne++);}const Gg=v.map(b=>({id:b.flow.id,source:b.flow.source,target:b.flow.target,preexisting:!1})),J1=new Set(Gg.map(b=>b.id));for(const b of r.filter(_=>_.type==="bpmn:MessageFlow"))J1.has(b.id)||!b.source||!b.target||b.source.type==="bpmn:Participant"!=(b.target.type==="bpmn:Participant")&&Gg.push({id:b.id,source:b.source.id,target:b.target.id,preexisting:!0});for(const b of Gg){if(!Ec(b.id))continue;const _=f(b.source),S=f(b.target);if(!_||!S)continue;let O,I,T;if(b.preexisting){const[L,D]=_.type==="bpmn:Participant"?[S,_]:[_,S];if(O=Sr(L),O<D.x||O>D.x+D.width)continue;[I,T]=L.y<D.y?[L.y+L.height,D.y]:[D.y+D.height,L.y]}else{if(_.type==="bpmn:Participant"||S.type==="bpmn:Participant"||(O=_.x+_.width/2,Math.abs(O-(S.x+S.width/2))>15))continue;[I,T]=_.y<S.y?[_.y+_.height,S.y]:[S.y+S.height,_.y]}const N=[...P.values()].map(L=>f(L.node.id)).filter(L=>!!L&&L.id!==_.id&&L.id!==S.id).filter(L=>L.x<=O&&O<=L.x+L.width&&L.y+L.height>I&&L.y<T).sort((L,D)=>L.x-D.x);for(const L of N){const D=(yS=P.get(L.id))==null?void 0:yS.node.participant,z=D?f(D):void 0;if(!D||!z)continue;const j=[...P.values()].filter(Z=>Z.node.participant===D).map(Z=>Z.node.id),X=Z=>Z.map(re=>f(re)).filter(re=>!!re),le=[T3(L.id,Z=>{var re;return((re=P.get(Z.id))==null?void 0:re.node.participant)===D}),X(j)].filter(Z=>Z.length).map(Z=>[{subtree:Z,pool:z}]);if(b.preexisting){const Z=X(j);Z.length&&le.push(Sp(new Map([[D,[...Z]]]),new Set(Z.map(re=>re.id)),b.id,()=>!1,re=>re===_.id||re===S.id))}const ae=L.width+Ee,oe=_r(b.id),ye=ts(b.id),ge=()=>_r(b.id)<oe&&ts(b.id)>=ye;let te=!1;for(const Z of le){for(let re=1;re<=V1;re++)if(Er(Z,ae*re,ge)){te=!0;break}if(te)break}if(!Ec(b.id))break}}const Cp=()=>{var _;const b=new Set;for(const S of ft(Ue(r)))S.kind!=="edge-crosses-shape"||J1.has(S.edge)||((_=f(S.edge))==null?void 0:_.type)==="bpmn:MessageFlow"&&b.add(`${S.edge}>${S.shape}`);return b},U3=(b,_)=>Qr().bad>=b&&[...Cp()].some(S=>!_.has(S)),eS=b=>{var _,S;return _r(b)===0&&((S=(_=f(b))==null?void 0:_.waypoints)==null?void 0:S.length)===2},q3=(b,_,S)=>{const O=new Set(b.flatMap(T=>T.subtree.map(N=>N.id))),I=[...Cp()].filter(T=>!S.has(T)).map(T=>T.split(">")[1]);return[...new Set(I)].filter(T=>O.has(T)&&T!==_.source&&T!==_.target)},Y3=(b,_,S,O,I)=>{const T=b.map(z=>({...z,subtree:z.subtree.filter(j=>!I.includes(j.id))})).filter(z=>z.subtree.length),N=new Set(T.flatMap(z=>z.subtree.map(j=>j.id))),L=()=>I.every(z=>{const j=f(z);return!!j&&F.filter(X=>X.flow.target===z&&N.has(X.flow.source)).every(X=>{const ne=f(X.flow.source);return!!ne&&ne.x+ne.width<=j.x})});return Er(T,_,()=>eS(S.id)&&[...Cp()].every(z=>O.has(z))&&L(),ns,!0)};for(const b of v){if(!Ec(b.flow.id))continue;const _=f(b.flow.id);if(((vS=_==null?void 0:_.waypoints)==null?void 0:vS.length)!==2)continue;const S=f(b.flow.source),O=f(b.flow.target);if(!S||!O||S.type==="bpmn:Participant"||O.type==="bpmn:Participant"||!Jr(b.flow.source)||!Jr(b.flow.target)||Math.abs(Sr(S)-Sr(O))>F3)continue;const I=Sr(S),T=_.waypoints.map(oe=>oe.y),[N,L]=[Math.min(...T),Math.max(...T)],D=Hn(Ue(r)).filter(oe=>oe.id!==S.id&&oe.id!==O.id&&oe.x<I&&I<oe.x+oe.width&&N<oe.y+oe.height&&oe.y<L);if(!D.length)continue;const z=(bS=P.get(b.flow.source))==null?void 0:bS.node.participant,j=(xS=P.get(b.flow.target))==null?void 0:xS.node.participant;if(!z||!j)continue;const X=new Map;for(const[oe,ye,ge]of[[b.flow.source,S,z],[b.flow.target,O,j]]){const te=X.get(ge)??[],Z=xr(oe,re=>re.x>=ye.x).filter(re=>!te.some(Q=>Q.id===re.id));X.set(ge,[...te,...Z])}const ne=new Set([...X.values()].flat().map(oe=>oe.id)),le=Sp(X,ne,b.flow.id,oe=>oe===b.flow.source||oe===b.flow.target,()=>!1),ae=Math.max(...D.map(oe=>oe.x+oe.width));for(const oe of j3){const ye=ae+oe-I;if(ye<=0)continue;const ge=Qr().bad,te=Cp();let Z=[],re=!0;const Q=()=>!eS(b.flow.id)||re&&(Z=q3(le,b.flow,te),Z.length)?!1:!U3(ge,te);if(Er(le,ye,Q,ns))break;if(Z.length&&(Y3(le,ye,b.flow,te,Z)||(re=!1,Er(le,ye,Q,ns))))break}}{const b=T=>T.y+T.height/2,_=/(Task|Event|Gateway|CallActivity|SubProcess)$/,S=()=>{const T=Ue(r),N=new Set(ft(T).flatMap(z=>z.kind==="edge-crosses-shape"?[`${z.edge}|${z.shape}`]:[])),L=T.shapes.filter(z=>!z.container&&_.test(z.type)),D=new Set;for(const z of T.edges){if(z.type!=="bpmn:SequenceFlow"&&z.type!=="bpmn:MessageFlow")continue;const j=new Set(z.endpoints);for(const X of[z.waypoints[0],z.waypoints[z.waypoints.length-1]])for(const ne of L)ne.x-4<=X.x&&X.x<=ne.x+ne.width+4&&ne.y-4<=X.y&&X.y<=ne.y+ne.height+4&&j.add(ne.id);for(const X of L)if(!(j.has(X.id)||N.has(`${z.id}|${X.id}`))){for(let ne=0;ne+1<z.waypoints.length;ne++)if(Dr(z.waypoints[ne],z.waypoints[ne+1],X)<=Ig){D.add(`${z.id}|${X.id}`);break}}}return D},O=()=>({...Qr(),grazes:S()}),I=[];for(const T of P.keys()){if(!Jr(T))continue;const N=F.filter(z=>z.flow.target===T);if(N.length!==1)continue;const L=f(N[0].flow.source),D=f(T);!L||!D||!P.has(L.id)||Math.abs(b(L)-b(D))>1||D.x-(L.x+L.width)<=Ee+1||I.push({id:T,pred:L,node:D})}I.sort((T,N)=>T.node.x-N.node.x);for(const{id:T}of I){const N=P.get(T),L=f(T),D=f(F.find(Z=>Z.flow.target===T).flow.source);if(!L||!D)continue;const z=L.x-(D.x+D.width);if(z<=Ee+1)continue;const j=d(N.node.participant),X=xr(T,Z=>Z.x>=L.x),ne=-(z-Ee),le=(Z,re)=>re.bad>Z.bad||re.crossings>=Z.crossings||re.straight<Z.straight||[...re.grazes].some(Q=>!Z.grazes.has(Q)),ae=Sp(new Map([[N.node.participant,[...X]]]),new Set(X.map(Z=>Z.id)),"",()=>!1,()=>!1),oe=ae.some(Z=>Z.pool!==j)||ae.reduce((Z,re)=>Z+re.subtree.length,0)>X.length,ye=O(),ge=W1(X,j,ne);if(!ge)continue;const te=O();if(oe&&!le(ye,te)){ge();const Z=es(ae,ne);if(Z){const re=O();if(!le(ye,re)&&re.bad<=te.bad&&re.crossings<=te.crossings)continue;Z()}W1(X,j,ne);continue}le(ye,te)&&ge()}}G1(!0);const K3=10,X3=400,Z3=b=>[...b.incoming??[],...b.outgoing??[]].filter(_=>_.type==="bpmn:DataInputAssociation"||_.type==="bpmn:DataOutputAssociation").map(_=>_.source===b?_.target:_.source).filter(_=>!!_&&typeof _.y=="number"),Q3=r.filter(b=>b.type==="bpmn:DataStoreReference"&&h.has(b.id)),J3=(b,_)=>{const S=b.x+b.width/2,O=b.y+b.height/2;let I;for(const T of Q3){if((g(T)??p())!==_||T.y<b.y+b.height)continue;const N=Math.abs(T.x+T.width/2-S);N>X3||N<T.width||!Z3(T).some(D=>D.height===b.height&&Math.abs(D.y+D.height/2-O)<=K3&&T.y>=D.y+D.height)||(!I||N<I.dx||N===I.dx&&T.id<I.id)&&(I={dx:N,id:T.id,cy:T.y+T.height/2})}return I==null?void 0:I.cy};for(const b of x){const _=b.associations??[],S=_.map(T=>T.source===b.dataStore.id?T.target:T.source).map(f).find(Boolean),O=S?g(S)??p():p(),I=S?{x:S.x+S.width/2,y:J3(S,O)??S.y+S.height+110}:{x:200,y:xc+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:b.dataStore.id,name:b.dataStore.name})},I,O);for(const T of _)z1(b.dataStore.id,T)}for(const b of E){const S=d(b.association.target).type==="bpmn:DataStoreReference"?b.association.target:b.association.source;z1(S,b.association)}let tS=0;const ea=10,nS=40,eF=(b,_)=>{const S=_.map(D=>g(D)).filter(D=>!!D);for(const D of S){const z=ea,j=D.y,X=D.y+D.height,ne=D.x,le=D.x+D.width;if(Math.abs(b.y-j)<z){const ae=j+z-b.y;b.y+=ae,b.height-=ae}if(Math.abs(b.y+b.height-X)<z&&(b.height=X-z-b.y),Math.abs(b.x-ne)<z){const ae=ne+z-b.x;b.x+=ae,b.width-=ae}Math.abs(b.x+b.width-le)<z&&(b.width=le-z-b.x)}if(!S.length)return;const O=Math.min(...S.map(D=>D.y)),I=Math.max(...S.map(D=>D.y+D.height)),T=O-b.y,N=b.y+b.height-I,L=nS-ea;if(T>0!=N>0)if(T>0&&T<L){const D=T+ea;b.y+=D,b.height-=D}else N>0&&N<L&&(b.height-=N+ea)},tF=(b,_)=>{const S=ea,O=30,I=r.filter(T=>T.type==="bpmn:Group"&&T.id!==_);for(const T of I){const N=T.x,L=T.x+T.width,D=T.y,z=T.y+T.height,j=b.y<z&&D<b.y+b.height,X=b.x<L&&N<b.x+b.width;if(j){if(Math.abs(b.x-L)<S){const ne=Math.min(L+S-b.x,O);ne>0&&b.width-ne>0&&(b.x+=ne,b.width-=ne)}if(Math.abs(b.x+b.width-N)<S){const ne=Math.min(b.x+b.width-(N-S),O);ne>0&&b.width-ne>0&&(b.width-=ne)}}if(X){if(Math.abs(b.y-z)<S){const ne=Math.min(z+S-b.y,O);ne>0&&b.height-ne>0&&(b.y+=ne,b.height-=ne)}if(Math.abs(b.y+b.height-D)<S){const ne=Math.min(b.y+b.height-(D-S),O);ne>0&&b.height-ne>0&&(b.height-=ne)}}}},Vg=(b,_)=>{const S=nS,O=Math.min(...b.map(D=>D.x))-S,I=Math.min(...b.map(D=>D.y))-S,T=Math.max(...b.map(D=>D.x+D.width))+S,N=Math.max(...b.map(D=>D.y+D.height))+S,L={x:O,y:I,width:T-O,height:N-I};return eF(L,b),tF(L,_),L};for(const b of B){const _=(b.group.members??[]).map(f).filter(I=>!!I);let S;_.length?S=Vg(_,b.group.id):(S={x:300+tS*350,y:40,width:300,height:200},tS++);const O=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:b.group.id}),width:S.width,height:S.height},{x:S.x+S.width/2,y:S.y+S.height/2},p());b.group.name&&n.updateLabel(O,b.group.name),(wS=b.group.members)!=null&&wS.length&&ce(O,"bwl:Members",{refs:b.group.members.join(" ")})}{const b=r.filter(I=>!!I.waypoints),_=new Map,S=(I,T)=>{!I||!T||(_.has(I)||_.set(I,new Set),_.get(I).add(T))};for(const I of b){const T=(_S=I.source)==null?void 0:_S.id,N=(ES=I.target)==null?void 0:ES.id;S(T,N),((SS=I.type)!=null&&SS.includes("DataOutputAssociation")||(RS=I.type)!=null&&RS.includes("DataInputAssociation")||I.type==="bpmn:Association")&&S(N,T)}const O=r.filter(I=>I.type==="bpmn:Group");for(const I of O){const N=(((CS=I.businessObject.extensionElements)==null?void 0:CS.values)??[]).find(ge=>ge.$type==="bwl:Members"),L=((N==null?void 0:N.refs)??"").split(" ").filter(Boolean);if(!L.length)continue;const D=new Set(L),z=[...L];for(;z.length;){const ge=z.shift();for(const te of _.get(ge)??[])D.has(te)||(D.add(te),z.push(te))}const j=I.x,X=I.x+I.width,ne=I.y,le=I.y+I.height,ae=ge=>F.filter(te=>te.flow.target===ge).length,oe=ge=>{var Z;const te=((Z=f(ge))==null?void 0:Z.type)??"";if(te==="bpmn:StartEvent"&&ae(ge)===0)return!1;if(te.endsWith("Gateway")){const re=F.filter(Q=>Q.flow.target===ge).map(Q=>Q.flow.source);if(re.length&&re.every(Q=>{var ve;return((ve=f(Q))==null?void 0:ve.type)==="bpmn:StartEvent"&&ae(Q)===0}))return!1}return!0},ye=r.filter(ge=>Bi(ge)).filter(ge=>ge.type!=="bpmn:Group"&&ge.type!=="bpmn:Participant"&&ge.type!=="bpmn:TextAnnotation"&&!D.has(ge.id)&&Jr(ge.id)&&oe(ge.id)&&ge.x<X&&ge.x+ge.width>j&&ge.y<le&&ge.y+ge.height>ne);if(ye.length)for(const ge of[-1,1]){const te=ye.filter(Pe=>(Pe.x+Pe.width-j<=X-Pe.x?-1:1)===ge);if(!te.length)continue;const Z=[];for(const Pe of te){const Ce=Z.find(Te=>Te.some(pe=>Pe.y<pe.y+pe.height&&Pe.y+Pe.height>pe.y));Ce?Ce.push(Pe):Z.push([Pe])}const re=new Map;for(const Pe of Z){let Ce=ge<0?j-ea:X+ea;for(const Te of[...Pe].sort((pe,Me)=>ge<0?Me.x-pe.x:pe.x-Me.x)){const pe=ge<0?Math.min(Te.x,Ce-Te.width):Math.max(Te.x,Ce);Ce=ge<0?pe-Ii:pe+Te.width+Ii,pe!==Te.x&&Math.sign(pe-Te.x)===ge&&re.set(Te.id,pe-Te.x)}}const Q=new Map,ve=Pe=>Q.get(Pe)===Pe||!Q.get(Pe)?Pe:ve(Q.get(Pe));for(const Pe of te)Q.set(Pe.id,Pe.id);for(const Pe of v){const Ce=re.has(Pe.flow.source)?Pe.flow.source:void 0,Te=re.has(Pe.flow.target)?Pe.flow.target:void 0;if(!Ce||!Te)continue;const pe=f(Pe.flow.id);((MS=pe==null?void 0:pe.waypoints)==null?void 0:MS.length)===2&&Q.set(ve(Ce),ve(Te))}const $e=new Map;for(const Pe of te){if(!re.has(Pe.id))continue;const Ce=ve(Pe.id);$e.set(Ce,[...$e.get(Ce)??[],Pe])}const De=[...$e.values()].sort((Pe,Ce)=>ge<0?Math.min(...Pe.map(Te=>Te.x))-Math.min(...Ce.map(Te=>Te.x)):Math.max(...Ce.map(Te=>Te.x))-Math.max(...Pe.map(Te=>Te.x))),Xe=[];let Ae=!0;for(const Pe of De){const Ce=Pe.map(Me=>re.get(Me.id)??0).reduce((Me,ke)=>Math.abs(ke)>Math.abs(Me)?ke:Me,0),Te=new Map;let pe=!0;for(const Me of Pe){const ke=g(Me);if(!ke){pe=!1;break}Te.has(ke.id)||Te.set(ke.id,{subtree:[],pool:ke}),Te.get(ke.id).subtree.push(Me)}pe&&Er([...Te.values()],Ce,()=>!0,ns)?Xe.push({shapes:Pe,dx:Ce}):Ae=!1}if(!Ae)for(const Pe of Xe.reverse())n.moveElements(Pe.shapes,{x:-Pe.dx,y:0})}}}{const b=new Set([...B.map(_=>_.group.id),...Ft(e,"group.update").map(_=>_.id)]);for(const _ of r.filter(S=>S.type==="bpmn:Group")){if(b.has(_.id))continue;const O=(((AS=_.businessObject.extensionElements)==null?void 0:AS.values)??[]).find(L=>L.$type==="bwl:Members"),I=((O==null?void 0:O.refs)??"").split(" ").filter(Boolean).map(f).filter(L=>!!L);!I.length||!I.some(L=>{const D=h.get(L.id);return!D||D.x!==L.x||D.y!==L.y})||!I.some(L=>L.x<_.x||L.y<_.y||L.x+L.width>_.x+_.width||L.y+L.height>_.y+_.height)||n.resizeShape(_,Vg(I,_.id))}}{const _=new Map(zo(Ue(r)).map(L=>[L.owner,L.rect])),S=r.filter(L=>!!L.waypoints),O=new Map,I=(L,D)=>{!L||!D||(O.has(L)||O.set(L,new Set),O.get(L).add(D))};for(const L of S){const D=(PS=L.source)==null?void 0:PS.id,z=(TS=L.target)==null?void 0:TS.id;I(D,z),((kS=L.type)!=null&&kS.includes("DataOutputAssociation")||(OS=L.type)!=null&&OS.includes("DataInputAssociation")||L.type==="bpmn:Association")&&I(z,D)}const T=L=>F.filter(D=>D.flow.target===L).length,N=L=>{var z;const D=((z=f(L))==null?void 0:z.type)??"";if(D==="bpmn:StartEvent"&&T(L)===0)return!1;if(D.endsWith("Gateway")){const j=F.filter(X=>X.flow.target===L).map(X=>X.flow.source);if(j.length&&j.every(X=>{var ne;return((ne=f(X))==null?void 0:ne.type)==="bpmn:StartEvent"&&T(X)===0}))return!1}return!0};for(const L of r.filter(D=>D.type==="bpmn:Group")){const z=(((DS=L.businessObject.extensionElements)==null?void 0:DS.values)??[]).find(pe=>pe.$type==="bwl:Members"),j=((z==null?void 0:z.refs)??"").split(" ").filter(Boolean);if(!j.length)continue;const X=j.map(f).filter(pe=>!!pe);if(!X.length||!(B.some(pe=>pe.group.id===L.id)||Ft(e,"group.update").some(pe=>pe.id===L.id)||X.some(pe=>{const Me=h.get(pe.id);return!Me||Me.x!==pe.x||Me.y!==pe.y})))continue;const le=new Set(j),ae=[...j];for(;ae.length;){const pe=ae.shift();for(const Me of O.get(pe)??[])le.has(Me)||(le.add(Me),ae.push(Me))}const oe=L.x,ye=L.x+L.width,ge=L.y,te=L.y+L.height,Z=pe=>{const Me=_.get(pe.id),ke={x:pe.x,y:pe.y,width:pe.width,height:pe.height};return Me?[ke,{x:Me.x,y:Me.y,width:Me.width,height:Me.height}]:[ke]},re=X.flatMap(Z),Q=Math.min(...re.map(pe=>pe.x)),ve=Math.max(...re.map(pe=>pe.x+pe.width)),$e=Math.min(...re.map(pe=>pe.y)),De=Math.max(...re.map(pe=>pe.y+pe.height)),Xe={L:Q-oe,R:ye-ve,T:$e-ge,B:te-De},Ae=new Set(j),Pe=pe=>pe.x>=oe&&pe.x+pe.width<=ye&&pe.y>=ge&&pe.y+pe.height<=te,Ce=r.filter(pe=>Bi(pe)).filter(pe=>pe.type!=="bpmn:Group"&&pe.type!=="bpmn:Participant"&&pe.type!=="bpmn:TextAnnotation"&&!Ae.has(pe.id)&&(!le.has(pe.id)||!Pe(pe))&&N(pe.id)&&pe.x<ye&&pe.x+pe.width>oe&&pe.y<te&&pe.y+pe.height>ge);if(!Ce.length)continue;const Te={L:0,R:0,T:0,B:0};for(const pe of Ce){const Me=Z(pe),ke=Math.min(...Me.map(wn=>wn.x)),Fe=Math.max(...Me.map(wn=>wn.x+wn.width)),wt=Math.min(...Me.map(wn=>wn.y)),rn=Math.max(...Me.map(wn=>wn.y+wn.height)),Kt={L:Fe-oe,R:ye-ke,T:rn-ge,B:te-wt},Xt=["L","R","T","B"].filter(wn=>Kt[wn]<=Xe[wn]+.001);if(!Xt.length)continue;const Nn=Xt.reduce((wn,Mp)=>Kt[Mp]<Kt[wn]?Mp:wn,Xt[0]);Te[Nn]=Math.max(Te[Nn],Math.min(Kt[Nn]+10,Xe[Nn]))}!Te.L&&!Te.R&&!Te.T&&!Te.B||n.resizeShape(L,{x:L.x+Te.L,y:L.y+Te.T,width:L.width-Te.L-Te.R,height:L.height-Te.T-Te.B})}}const iS=b=>{const _=b.waypoints;if(_!=null&&_.length){const O=_[Math.floor((_.length-1)/2)];return{x:O.x,y:O.y,width:0,height:0}}const S=b;return{x:S.x,y:S.y,width:S.width,height:S.height}};let Rc=0;const oS=12,rS=14,nF=15,iF=300,oF=b=>{const _=b.split(`
7
- `),S=Math.max(..._.map(T=>da(T,oS))),O=Math.max(100,Math.min(iF,Math.ceil(S)+rS)),I=_.reduce((T,N)=>T+Math.max(1,Math.ceil((da(N,oS)+rS)/O)),0);return{width:O,height:Math.max(30,I*nF+10)}};for(const b of A){const _=b.association,S=((LS=b.placement)==null?void 0:LS.anchor)??(_?_.source===b.annotation.id?_.target:_.source:void 0),O=S?f(S):void 0,I=O?iS(O):void 0,T=oF(b.annotation.text??"");let N;if(I&&b.placement){const[j,X]=ol[b.placement.side],ne=b.placement.offset??50;N={x:I.x+I.width/2+j*(I.width/2+T.width/2+ne),y:I.y+I.height/2+X*(I.height/2+T.height/2+ne)}}else I?(N={x:I.x+I.width/2+180+Rc%3*260,y:I.y-110-Rc%2*95},Rc++):(N={x:300+Rc*260,y:60},Rc++);const L=O?g(O)??p():p(),D=L;I&&typeof D.x=="number"&&typeof D.width=="number"&&D.type==="bpmn:Participant"&&(N=al(r,I,T,D,b.placement?{placement:b.placement}:{from:N}));const z=n.createShape({type:"bpmn:TextAnnotation",width:T.width,height:T.height,businessObject:i.create("bpmn:TextAnnotation",{id:b.annotation.id,text:b.annotation.text})},N,L);if(_){const j=X=>X===b.annotation.id?z:d(X);n.connect(j(_.source),j(_.target),_.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:_.id})}:{type:"bpmn:Association"})}b.placement&&ce(z,"bwl:Placement",ie(b.placement))}for(const b of Ft(e,"association.add")){const _=b.association;n.connect(d(_.source),d(_.target),_.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:_.id})}:{type:"bpmn:Association"})}const rF=(b,_,S,O)=>{const I=b.parent;if(!I)return O;const T=b.x+b.width/2,N=new Set([b.id]);if(!C(I,b,T,O,N))return O;const L=_?_.y+Math.min(_.height/2,ue):S?S.y+U:void 0;if(L===void 0)return O;const D=Math.floor((O-L)/me+1e-6);for(let z=1;z<=3;z++){const j=D+z,X=L+j*me,ne=P1(_==null?void 0:_.id,j);if(!C(I,b,T,X,ne?new Set([...N,...ne]):N))return Do(_==null?void 0:_.id,j,S),X}return O},aS=()=>new Set(r.getAll().filter(b=>b.type!=="label").map(b=>b.id));for(const b of Ft(e,"node.update")){let _=d(b.id);if(b.type&&il(b.type)!==_.type){const S=_.x+_.width/2,O=_.y+_.height/2,I=aS();_=c.replaceElement(_,{type:il(b.type),...b.eventDefinition?{eventDefinitionType:Tc[b.eventDefinition]}:{}});const T=aS(),N=[...I].filter(z=>z!==b.id&&!T.has(z));if(N.length)throw new By({kind:"type-change-drops-elements",opIndex:e.indexOf(b),id:b.id,type:b.type,dropped:N});const L=Math.round(S-(_.x+_.width/2)),D=Math.round(O-(_.y+_.height/2));if(L!==0||D!==0){n.moveShape(_,{x:L,y:D});for(const z of[..._.incoming??[],..._.outgoing??[]])Ep(z)}}if(b.name!==void 0&&n.updateProperties(_,{name:b.name??void 0}),b.lane||b.band!==void 0){b.band!==void 0&&n.updateProperties(_,{"bwl:band":b.band});const S=_.y+_.height/2,O=g(_),I=b.lane?d(b.lane):((O==null?void 0:O.children)??[]).find(N=>N.type==="bpmn:Lane"&&S>=N.y&&S<=N.y+N.height);b.band!==void 0&&Do(I==null?void 0:I.id,b.band,O);const T=I?I.y+(b.band===void 0?I.height/2:Math.min(I.height/2,ue)+$t(I.id,b.band)*me):b.band!==void 0&&O?O.y+U+$t(`pool:${O.id}`,b.band)*me:void 0;if(T!==void 0){const N=rF(_,I,O,T),L=N===T?T-S:N-(_.y+_.height/2);L!==0&&n.moveElements([_],{x:0,y:L})}}}for(const b of Ft(e,"sequenceFlow.update")){const _=d(b.id),S=k.get(b.id);if(S){const O=z=>({x:z.x+z.width/2,y:z.y+z.height/2}),I=d(S.flow.source),T=d(S.flow.target),N=n.connect(I,T,{type:"bpmn:SequenceFlow",businessObject:_p(S.flow)}),L=Ng.get(b.id),D=T.y+T.height/2;L&&T.x>L.exit.x&&Math.abs(D-L.exit.y)>1?n.updateWaypoints(N,[L.exit,{x:L.exit.x,y:D},{x:T.x,y:D}]):(n.reconnect(N,I,T,[O(I),O(T)]),Math.abs(D-(I.y+I.height/2))>1&&Ep(N))}else if((b.source!==void 0||b.target!==void 0)&&!O1.has(b.id)){const O=_,I=b.source!==void 0?d(b.source):O.source,T=b.target!==void 0?d(b.target):O.target,N=z=>({x:z.x+z.width/2,y:z.y+z.height/2});n.reconnect(O,I,T,[N(I),N(T)]);const L=Ng.get(O.id),D=T.y+T.height/2;if(L&&T.x>L.exit.x&&Math.abs(D-L.exit.y)>1){n.updateWaypoints(O,[L.exit,{x:L.exit.x,y:D},{x:T.x,y:D}]);const z=O.label;if(z&&L.label){const X=Math.abs(L.label.y+z.height/2-L.channelY)<=me/5&&L.label.x+z.width>L.exit.x,ne=L.exit.x+6,le=T.x-6-z.width,ae=X?le>=ne?{x:Math.max(ne,Math.min(L.label.x,le)),y:L.label.y+(D-L.channelY)}:void 0:L.label;ae&&(ae.x!==z.x||ae.y!==z.y)&&n.moveElements([z],{x:ae.x-z.x,y:ae.y-z.y})}}else Math.abs(D-(I.y+I.height/2))>1&&Ep(O)}b.name!==void 0&&n.updateProperties(_,{name:b.name??void 0}),b.condition!==void 0&&n.updateProperties(_,{name:((IS=b.condition)==null?void 0:IS.label)??void 0})}for(const b of Ft(e,"messageFlow.update"))b.name!==void 0&&n.updateProperties(d(b.id),{name:b.name??void 0});for(const b of Ft(e,"dataStore.update"))b.name!==void 0&&n.updateProperties(d(b.id),{name:b.name??void 0});for(const b of Ft(e,"annotation.update")){const _=d(b.id);if(b.text!==void 0&&n.updateProperties(_,{text:b.text}),b.placement===null)ce(_,"bwl:Placement",null);else if(b.placement){const S=d(b.placement.anchor),O=iS(S),I=g(S)??p(),T=typeof I.x=="number"&&typeof I.width=="number"&&I.type==="bpmn:Participant",[N,L]=ol[b.placement.side],D=b.placement.offset??50,z={x:O.x+O.width/2+N*(O.width/2+_.width/2+D),y:O.y+O.height/2+L*(O.height/2+_.height/2+D)},j=T?al(r,O,{width:_.width,height:_.height},I,{placement:b.placement,selfId:b.id}):z;n.moveElements([_],{x:j.x-(_.x+_.width/2),y:j.y-(_.y+_.height/2)}),ce(_,"bwl:Placement",ie(b.placement))}}for(const b of Ft(e,"group.update")){const _=d(b.id);if(b.name!==void 0&&n.updateLabel(_,b.name??""),b.members){const S=b.members.map(f).filter(O=>!!O);S.length&&n.resizeShape(_,Vg(S,b.id)),ce(_,"bwl:Members",{refs:b.members.join(" ")})}}}function Mf(e){switch(e.kind){case"annotation-over-label":return[e.annotation];case"edge-crosses-shape":return[e.shape];case"shape-outside-container":return[e.shape];case"shape-overlap":return e.shapes;default:return[]}}function oA(e,t,n,i){const{elementRegistry:o}=e,r=e.modeling,a=[...t.incoming??[],...t.outgoing??[]].filter(d=>d.type==="bpmn:Association");if(!a.length)return 0;const s=d=>d.map(g=>g.original?{x:g.x,y:g.y,original:{x:g.original.x,y:g.original.y}}:{x:g.x,y:g.y}),c=(d,g)=>d.length===g.length&&d.every((h,m)=>{var w,y,v,x;return h.x===g[m].x&&h.y===g[m].y&&((w=h.original)==null?void 0:w.x)===((y=g[m].original)==null?void 0:y.x)&&((v=h.original)==null?void 0:v.y)===((x=g[m].original)==null?void 0:x.y)}),l=a.map(d=>s(d.waypoints)),u=new Set(a.map(d=>d.id));r.moveElements([t],{x:n,y:i});const p=Ue(o),f=[...go(p),...Fi(p)].filter(([d,g])=>u.has(d)!==u.has(g)).length;return r.moveElements([t],{x:-n,y:-i}),a.forEach((d,g)=>{c(d.waypoints,l[g])||r.updateWaypoints(d,l[g])}),f}function rA(e,t,n){var u,p;const{elementRegistry:i}=e,o=e.modeling,r=f=>ft(f).filter(d=>!t.has(pt(d))),a=f=>{var d;return((d=i.get(f))==null?void 0:d.type)==="bpmn:TextAnnotation"},s=Ue(i),c=r(s),l=[...new Set(c.flatMap(Mf))].filter(f=>n.has(f)&&a(f));if(l.length)for(const f of l){const d=i.get(f);if(!d||typeof d.x!="number"||typeof d.width!="number")continue;let g=d.parent,h;for(;g;){if(g.type==="bpmn:Participant"){h=g;break}g=g.parent}if(!h){const be=d.x+d.width/2,de=d.y+d.height/2;h=i.getAll().find(me=>{if(me.type!=="bpmn:Participant")return!1;const Ee=me;return typeof Ee.x=="number"&&typeof Ee.width=="number"&&be>=Ee.x&&be<=Ee.x+Ee.width&&de>=Ee.y&&de<=Ee.y+Ee.height})}if(!h||typeof h.x!="number"||typeof h.width!="number")continue;const w=(((u=d.businessObject.extensionElements)==null?void 0:u.values)??[]).find(be=>be.$type==="bwl:Placement"),y=[...d.incoming??[],...d.outgoing??[]].find(be=>be.type==="bpmn:Association"),v=(w!=null&&w.anchor?i.get(w.anchor):void 0)??(y?((p=y.source)==null?void 0:p.id)===f?y.target:y.source:void 0);if(!v)continue;const x=v.waypoints,E=x!=null&&x.length?{x:x[Math.floor((x.length-1)/2)].x,y:x[Math.floor((x.length-1)/2)].y,width:0,height:0}:{x:v.x,y:v.y,width:v.width,height:v.height},A={width:d.width,height:d.height},B={x:d.x+d.width/2,y:d.y+d.height/2},P=w==null?void 0:w.side,k=Ly(i,E,h),H=[];if(P&&P in ol&&H.push(al(i,E,A,h,{placement:{side:P,offset:(w==null?void 0:w.offset)??null},selfId:f})),k&&!rl(B,A,k))for(const be of nA)H.push(al(i,E,A,h,{placement:{side:be,offset:null},selfId:f}));for(const[be,de]of[[-1,0],[1,0],[0,-1],[0,1]])for(let me=1;me<=tA;me++)H.push({x:B.x+be*Dy*me,y:B.y+de*Dy*me});const F={...s,edges:s.edges.filter(be=>be.id!==(y==null?void 0:y.id))},G=r(F),ee=G.filter(be=>Mf(be).includes(f)).length;if(!ee)continue;let ce,ie=!1;for(const be of H){const de=be.x-B.x,me=be.y-B.y;if(!de&&!me||be.x-A.width/2<h.x||be.x+A.width/2>h.x+h.width||be.y-A.height/2<h.y||be.y+A.height/2>h.y+h.height||k&&!rl(be,A,k))continue;const Ee={...F,shapes:F.shapes.map(J=>J.id===f?{...J,x:J.x+de,y:J.y+me}:J)},U=r(Ee),ue=U.filter(J=>Mf(J).includes(f)).length;if(ue>=ee||U.length>G.length)continue;const K=Math.abs(de)+Math.abs(me);if(ie||((!ce||ue<ce.mine||ue===ce.mine&&(U.length<ce.all||U.length===ce.all&&K<ce.dist))&&(ce={x:be.x,y:be.y,mine:ue,all:U.length,dist:K}),ce.mine===0&&ce.all<G.length&&(ie=!0)),ue===0&&U.length<G.length&&oA(e,d,de,me)===0){ce={x:be.x,y:be.y,mine:ue,all:U.length,dist:K};break}}ce&&o.moveElements([d],{x:ce.x-B.x,y:ce.y-B.y})}}const aA=60;function sl(e,t,n,i){const o=t.x+t.width,r=[],a=c=>{for(const l of c.children??[])l.type==="bpmn:Lane"&&(r.push(l),a(l))};a(t),e.resizeShape(t,{x:t.x,y:t.y,width:n,height:t.height},void 0,i);const s=t.x+n;for(const c of r)Math.abs(c.x+c.width-o)<1&&e.resizeShape(c,{x:c.x,y:c.y,width:s-c.x,height:c.height},void 0,i)}function sA(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=w=>ft(w).filter(y=>!t.has(pt(y))),a=w=>w.filter(y=>y.kind==="pool-overlap"),s=new Map(n.shapes.map(w=>[w.id,w])),c=(w,y)=>y.x>=w.x&&y.y>=w.y&&y.x+y.width<=w.x+w.width&&y.y+y.height<=w.y+w.height,l=w=>{if(!s.get(w))return[w];const v=new Set,x=new Set([w]);for(let A=0;A<4;A++){let B=!1;for(const P of n.shapes)P.type!=="bpmn:Group"||v.has(P.id)||[...x].some(k=>{const H=s.get(k);return H&&c(P,H)})&&(v.add(P.id),B=!0);for(const P of n.shapes)P.type!=="bpmn:Participant"||x.has(P.id)||[...v].some(k=>{const H=s.get(k);return H&&c(H,P)})&&(x.add(P.id),B=!0);if(!B)break}const E=n.shapes.filter(A=>!A.parent&&!x.has(A.id)&&!v.has(A.id)&&A.type!=="bpmn:Group"&&A.type!=="bpmn:Participant").filter(A=>[...v].some(B=>{const P=s.get(B);return P&&c(P,A)})).map(A=>A.id);return[...x,...v,...E]},u=r(Ue(i)),p=a(u).length;if(!p)return;const f=u.length,d=[];let g=0,h=p,m=f;for(let w=0;w<6;w++){const y=Ue(i),v=a(r(y));if(!v.length)break;const x=new Map(y.shapes.map(k=>[k.id,k]));let E=null;for(const k of v){if(k.kind!=="pool-overlap")continue;const[H,F]=k.pools,G=x.get(H),ee=x.get(F);if(!G||!ee)continue;const[ce,ie]=G.x<=ee.x?[G,ee]:[ee,G];if(k.contained)continue;const be=s.get(ce.id),de=s.get(ie.id),me=be&&de?Math.max(de.x-(be.x+be.width),0):aA,Ee=ce.x+ce.width+me-ie.x;if(Ee<=0)continue;const U=l(ie.id).filter(ue=>i.get(ue));U.length&&(!E||Ee>E.dx)&&(E={movers:U,dx:Ee})}if(!E)break;const A=E.movers.map(k=>i.get(k)).filter(k=>!!k&&typeof k.x=="number");if(!A.length)break;o.moveElements(A,{x:E.dx,y:0}),d.push({els:A,dx:E.dx});const B=r(Ue(i)),P=a(B).length;P<p&&B.length<=f&&(P<h||P===h&&B.length<m||g===0)&&(g=d.length,h=P,m=B.length)}for(const{els:w,dx:y}of d.slice(g).reverse())o.moveElements(w,{x:-y,y:0})}const ms=.5,Af=150;function cA(e,t){const n=t.shapes.filter(i=>i.type==="bpmn:Participant");if(!(n.length<2))for(const i of lA(n))i.length<n.length&&i.some(r=>Fy(e.elementRegistry.get(r.id)))||uA(e,i)}function lA(e){const t=[...e].sort((i,o)=>i.x+i.width-(o.x+o.width)),n=[];for(const i of t){const o=n[n.length-1],r=o==null?void 0:o[o.length-1];o&&r&&i.x+i.width-(r.x+r.width)<=ms?o.push(i):n.push([i])}return n.filter(i=>i.length>=2)}function Fy(e){var i,o,r;const t=(i=e==null?void 0:e.businessObject)==null?void 0:i.processRef;if(!t)return!0;const n=(t.laneSets??[]).reduce((a,s)=>{var c;return a+(((c=s.lanes)==null?void 0:c.length)??0)},0);return(((o=t.flowElements)==null?void 0:o.length)??0)+n+(((r=t.artifacts)==null?void 0:r.length)??0)===0}function uA(e,t){const{elementRegistry:n}=e,i=e.modeling,o=t.map(y=>y.x+y.width),r=Math.max(...o);if(r-Math.min(...o)>ms)return;const a=t.map(y=>n.get(y.id)).filter(y=>!!y&&typeof y.x=="number");if(a.length<2)return;const s=new Map(t.map(y=>[y.id,y.x]));if(a.some(y=>Math.abs(y.x-s.get(y.id))>ms))return;const c=a.map(y=>y.x+y.width);if(Math.max(...c)-Math.min(...c)<=ms)return;const l=y=>y.x+y.width,u=y=>!!y&&typeof y.width=="number",p=y=>{const v={shapes:[],edges:[],lanes:[]},x=E=>{for(const A of E.children??[]){if("waypoints"in A&&A.waypoints){v.edges.push(A);continue}A.type!=="label"&&(A.type==="bpmn:Lane"?v.lanes.push(A):v.shapes.push(A),x(A))}};return x(y),v},f=new Map(a.map(y=>[y.id,p(y)]));let d=r;for(const y of a){const{shapes:v}=f.get(y.id),x=v.flatMap(E=>[l(E),...u(E.label)?[l(E.label)]:[]]);x.length&&(d=Math.max(d,Math.max(...x)+Af))}const g=a.filter(y=>Math.abs(l(y)-d)>ms);if(!g.length)return;for(const y of g){const v=l(y),{shapes:x,edges:E,lanes:A}=f.get(y.id);if([...x.flatMap(k=>[l(k),...u(k.label)?[l(k.label)]:[]]),...E.flatMap(k=>[...k.waypoints.map(H=>H.x),...u(k.label)?[l(k.label)]:[]])].some(k=>k>d)||[...(y.incoming??[]).map(k=>k.waypoints[k.waypoints.length-1]),...(y.outgoing??[]).map(k=>k.waypoints[0])].some(k=>!k||k.x>d||Math.abs(k.x-v)<1))return;if(d>v){const k={x:v,y:y.y,width:d-v,height:y.height},H=new Set([y.id,...x.map(G=>G.id),...E.map(G=>G.id),...A.map(G=>G.id)]);if(n.getAll().some(G=>{var ie;if("waypoints"in G&&G.waypoints||G.type==="bpmn:Group"||!u(G))return!1;const ee=G.type==="label"?(ie=G.labelTarget)==null?void 0:ie.id:G.id;if(!ee||H.has(ee)||H.has(G.id))return!1;const ce=G;return ce.x<k.x+k.width&&ce.x+ce.width>k.x&&ce.y<k.y+k.height&&ce.y+ce.height>k.y}))return}}const h=()=>new Set(ft(Ue(n)).map(pt)),m=h(),w=g.map(y=>y.width);for(const y of g)sl(i,y,d-y.x,{layout:!1});[...h()].every(y=>m.has(y))||g.forEach((y,v)=>sl(i,y,w[v],{layout:!1}))}function pA(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=l=>ft(l).filter(u=>!t.has(pt(u))),a=(l,u)=>u.x>=l.x&&u.y>=l.y&&u.x+u.width<=l.x+l.width&&u.y+u.height<=l.y+l.height,s=l=>({l:Math.min(...l.map(u=>u.x)),t:Math.min(...l.map(u=>u.y)),r:Math.max(...l.map(u=>u.x+u.width)),b:Math.max(...l.map(u=>u.y+u.height))}),c=n.shapes.filter(l=>{var u;return l.type==="bpmn:Group"&&!((u=l.members)!=null&&u.length)});if(c.length)for(const l of c){const u=i.get(l.id);if(!u||typeof u.x!="number")continue;const p=n.shapes.filter(A=>A.id!==l.id&&A.type!=="bpmn:Group"&&a(l,A));if(!p.length)continue;const f=p.map(A=>i.get(A.id)).filter(A=>!!A&&typeof A.x=="number");if(f.length!==p.length)continue;const d=s(p),g=s(f),h=g.l+(l.x-d.l),m=g.t+(l.y-d.t),w=g.r+(l.x+l.width-d.r),y=g.b+(l.y+l.height-d.b),v={x:h,y:m,width:w-h,height:y-m};if(v.width<=0||v.height<=0||Math.abs(v.x-u.x)<1&&Math.abs(v.y-u.y)<1&&Math.abs(v.width-u.width)<1&&Math.abs(v.height-u.height)<1)continue;const x=r(Ue(i)).length,E={x:u.x,y:u.y,width:u.width,height:u.height};o.resizeShape(u,v),r(Ue(i)).length>x&&o.resizeShape(u,E)}}const cl=20,ll=10;function fA(e,t,n,i){var p,f;const{elementRegistry:o}=e,r=e.modeling,a=d=>new Set(ft(d,{includeObservationOnly:!0}).filter(g=>g.kind==="edge-along-group-boundary").map(pt)),s=Ue(o),c=ft(s,{includeObservationOnly:!0}).filter(d=>d.kind==="edge-along-group-boundary"&&!t.has(pt(d)));if(!c.length)return;const l=new Map(n.shapes.map(d=>[d.id,d])),u=new Map;for(const d of c)u.set(d.group,[...u.get(d.group)??[],d]);for(const[d,g]of u){const h=s.shapes.find(ze=>ze.id===d);if(!((p=h==null?void 0:h.members)!=null&&p.length))continue;const m=l.get(d);if(!(!m||Math.abs(m.x-h.x)>=.5||Math.abs(m.y-h.y)>=.5||Math.abs(m.width-h.width)>=.5||Math.abs(m.height-h.height)>=.5))continue;const y=h.members.map(ze=>o.get(ze)).filter(ze=>!!ze&&typeof ze.x=="number");if(!y.length)continue;const v=Math.min(...y.map(ze=>ze.x)),x=Math.min(...y.map(ze=>ze.y)),E=Math.max(...y.map(ze=>ze.x+ze.width)),A=Math.max(...y.map(ze=>ze.y+ze.height)),B=h.x,P=h.y,k=h.x+h.width,H=h.y+h.height;let F=B,G=P,ee=k,ce=H;for(const ze of g){const $=s.edges.find(R=>R.id===ze.edge);if(!$)continue;const C=$.endpoints.some(R=>{const W=s.shapes.find(Oe=>Oe.id===R);if(!W||W.container)return!1;const q=W.x+W.width/2,fe=W.y+W.height/2;return B<q&&q<k&&P<fe&&fe<H});for(const R of an($)){const W=R.axis==="v"?[P,H]:[B,k];Math.min(R.hi,W[1])-Math.max(R.lo,W[0])<af||(R.axis==="v"?B<R.at&&R.at<k:P<R.at&&R.at<H)&&C||(R.axis==="v"?(Math.abs(R.at-B)<=ha&&(F=Math.max(F,R.at+cl)),Math.abs(R.at-k)<=ha&&(ee=Math.min(ee,R.at-cl))):(Math.abs(R.at-P)<=ha&&(G=Math.max(G,R.at+cl)),Math.abs(R.at-H)<=ha&&(ce=Math.min(ce,R.at-cl))))}}if(F>v-ll&&(F=B),G>x-ll&&(G=P),ee<E+ll&&(ee=k),ce<A+ll&&(ce=H),F===B&&G===P&&ee===k&&ce===H)continue;const ie=o.get(d),be={x:ie.x,y:ie.y,width:ie.width,height:ie.height},de=Ue(o),me=new Set(ft(de).map(pt)),Ee=a(de);r.resizeShape(ie,{x:F,y:G,width:ee-F,height:ce-G});let U=Ue(o),ue=ft(U).filter(ze=>!me.has(pt(ze)));const K=[];if(ue.length>0&&ue.every(ze=>ze.kind==="label-over-line"&&!i.has(ze.edge)&&U.edges.some($=>$.id===ze.edge))){for(const ze of ue){if(ze.kind!=="label-over-line")continue;const $=U.edges.find(fe=>fe.id===ze.edge),C=$&&Sf($,U),R=(f=o.get(ze.edge))==null?void 0:f.label;if(!C||!R)continue;const W=C.x-R.x,q=C.y-R.y;r.moveElements([R],{x:W,y:q}),K.push({label:R,dx:W,dy:q})}U=Ue(o),ue=ft(U).filter(ze=>!me.has(pt(ze)))}const he=a(U),Re=[...he].some(ze=>!Ee.has(ze));if(ue.length||Re||he.size>=Ee.size){for(const ze of K.reverse())r.moveElements([ze.label],{x:-ze.dx,y:-ze.dy});r.resizeShape(ie,be)}}}function dA(e,t,n,i){var c;const o=n.getRootElement().businessObject,r=$p((o==null?void 0:o.$parent)??o),a=ss(i),s=new Map;for(const l of e.keys()){const u=(c=t.get(l))==null?void 0:c.businessObject;s.set(l,u?{texts:Fp(u,i,r),requests:Gp(u)}:{texts:{},requests:[]})}return{contexts:()=>[...e].flatMap(([l,u])=>{const p=t.get(l);return p?[{element:p,...u.texts!==void 0?{texts:u.texts}:{},...u.confirm?{confirm:u.confirm}:{},designLocale:i.designLocale,locales:a,...r?{rootLang:r}:{},before:s.get(l)}]:[]})}}function jy(e,t,n={}){var ie,be;const{i18n:i,lower:o=$y}=n,r=ky(e),a=Ym(r.elementRegistry),s=Ty(t,a,{i18n:i}),c={edgeCrossings:{before:0,after:0,pairs:[],solidPairs:0,dashedPairs:0,mixedPairs:0,crossPoolMessages:0},sharedEndpointCrossings:{before:0,after:0,pairs:[]}};if(s.length)return{ok:!1,issues:s,findings:[],stats:c};const l=XM(t,a,i),u=i&&l.writes.size?dA(l.writes,r.elementRegistry,r.canvas,i):void 0,p=Ue(r.elementRegistry),f=new Set(ft(p).map(pt)),d=new Set(ft(p,{includeObservationOnly:!0}).map(pt)),g=new Set(Iy(l.ops,de=>{var me,Ee;return(Ee=(me=r.elementRegistry.get(de))==null?void 0:me.source)==null?void 0:Ee.id}).keys()),h=new Set(p.edges.map(de=>de.id).filter(de=>!g.has(de))),m=new Set(t.flatMap(de=>de.kind==="sequenceFlow.update"&&(de.source!==void 0||de.target!==void 0)?[de.id]:[])),w=()=>new Set(p.edges.filter(de=>{var Ee;const me=(Ee=r.elementRegistry.get(de.id))==null?void 0:Ee.waypoints;return me?!(me.length===de.waypoints.length&&de.waypoints.every((U,ue)=>Math.round(U.x)===Math.round(me[ue].x)&&Math.round(U.y)===Math.round(me[ue].y))):!1}).map(de=>de.id)),y=(de,me)=>new Set([...de].filter(Ee=>!me.has(Ee))),v=new Set(p.shapes.map(de=>de.id)),x=go(p),E=x.length,A=new Set(x.map(([de,me])=>`${de}|${me}`)),B=Fi(p),P=new Set(B.map(([de,me])=>`${de}|${me}`)),k=new Map;for(const de of r.elementRegistry.filter(me=>"waypoints"in me&&!!me.waypoints))de.label&&k.set(de.id,{wps:de.waypoints.map(me=>({x:me.x,y:me.y})),label:{x:de.label.x,y:de.label.y},source:(ie=de.source)==null?void 0:ie.id,target:(be=de.target)==null?void 0:be.id});const H=e.get("commandStack");try{Jg(H,()=>{o(l.ops,r);for(const U of(u==null?void 0:u.contexts())??[])H.execute(Hp,U);sA(r,f,p),cA(r,p),pA(r,f,p),SM(r,p,m),wM(r,h,v),iy(r,h);const de=gf(r,f);Zm(r,A,h);const me=w(),Ee=yy(r,f,y(h,me),me);cy(r,h),BM(r,h,m),dy(r,f,h),GM(r,f,h),vM(r,P,h),TM(r,h,p),Ey(r,f,y(h,w())),_y(r,h,new Set([...m,...Ee])),Ry(r,v),rA(r,f,v),gf(r,f,de),fA(r,d,p,h),Cy(r,f),wy(r,k,iA(r))})}catch(de){return{ok:!1,issues:[de instanceof By?de.issue:{kind:"lower-failed",message:de instanceof Error?de.message:String(de)}],findings:[],stats:c}}const F=Ue(r.elementRegistry),G=ft(F,{includeObservationOnly:!0}).filter(de=>!d.has(pt(de))),ee=$m(F),ce=Fi(F);return{ok:!0,issues:[],findings:G,stats:{edgeCrossings:{before:E,after:ee.pairs.length,pairs:ee.pairs,solidPairs:ee.solidPairs,dashedPairs:ee.dashedPairs,mixedPairs:ee.mixedPairs,crossPoolMessages:ee.crossPoolMessages},sharedEndpointCrossings:{before:B.length,after:ce.length,pairs:ce}}}}function hA(e){const t=e.slice(e.indexOf(":")+1);return t.charAt(0).toLowerCase()+t.slice(1)}function Hy(e,t){return typeof e.get=="function"?e.get(t):e[t]}function zy(e,t){const n=Hy(e,t);return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Gy(e,t){var i;return(((i=e.extensionElements)==null?void 0:i.values)??[]).find(o=>(o==null?void 0:o.$type)===t)}function gA(e){return typeof e=="string"&&Dp.includes(e)}function zi(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function Vy(e,t={}){const n=e.rootElements??[],i=n.find(U=>U.$type==="bpmn:Collaboration"),o=new Map(n.filter(U=>U.$type==="bpmn:Process").map(U=>[U.id,U])),r=[],a=[],s=[],c=[],l=[],u=[],p={poolOrders:{},bands:{},placements:{},afterColumns:{}},f=[],d=[],g=[],h=[],m=[],w=[],y=[],v=new Map,x=new Set,E=new Set,A=U=>{U&&x.add(U)},B=U=>{x.add(U),E.add(U)},P=U=>{const ue=Gy(U,"bwl:Placement");if(!ue)return;const K=typeof ue.anchor=="string"?ue.anchor:void 0;if(!K||!gA(ue.side))return;const J=typeof ue.offset=="number"?ue.offset:void 0;m.push({owner:U.id,anchor:K,side:ue.side,...J!==void 0?{offset:J}:{}})},k=U=>{const ue=Gy(U,"bwl:Members"),K=typeof(ue==null?void 0:ue.refs)=="string"?ue.refs.split(/\s+/).filter(Boolean):[];K.length&&y.push({owner:U.id,refs:K})},H=U=>{var ue;for(const K of U)switch(A(K.id),K.$type){case"bpmn:TextAnnotation":B(K.id),v.set(K.id,K),c.push({id:K.id,text:typeof K.text=="string"?K.text:""}),P(K);break;case"bpmn:Association":g.push({id:K.id,type:K.$type,source:zi(K.sourceRef),target:zi(K.targetRef)});break;case"bpmn:Group":{B(K.id),v.set(K.id,K);const J=(ue=K.categoryValueRef)==null?void 0:ue.value;l.push({id:K.id,...typeof J=="string"&&J?{name:J}:{}}),k(K);break}default:u.push({id:K.id,type:K.$type,reason:"type-outside-mvp"})}},F=U=>{for(const ue of U.flowElements??[])A(ue.id),u.push({id:ue.id,type:ue.$type,reason:"inside-container"}),(ue.flowElements??[]).length&&F(ue);for(const ue of U.artifacts??[])A(ue.id),u.push({id:ue.id,type:ue.$type,reason:"inside-container"})},G=(U,ue)=>{const K=U.flowElements??[],J=(U.laneSets??[]).flatMap(Re=>Re.lanes??[]),he=new Map;for(const Re of J){A(Re.id),v.set(Re.id,Re);for(const ze of Re.flowNodeRef??[]){const $=zi(ze);$&&he.set($,Re.id)}}for(const Re of K){if(A(Re.id),v.set(Re.id,Re),Re.$type==="bpmn:SequenceFlow"){f.push({id:Re.id,source:zi(Re.sourceRef),target:zi(Re.targetRef),...typeof Re.name=="string"&&Re.name?{name:Re.name}:{}});continue}if(Re.$type==="bpmn:DataStoreReference"){B(Re.id),s.push({id:Re.id,...Re.name?{name:Re.name}:{}});continue}const ze=hA(Re.$type),$=ze==="intermediateCatchEvent"?kp((Re.eventDefinitions??[]).map(q=>q.$type)):void 0;if(!qg(ze)||ze==="intermediateCatchEvent"&&!$){u.push({id:Re.id,type:Re.$type,reason:"type-outside-mvp"});continue}B(Re.id);const C=ze==="boundaryEvent"?zi(Re.attachedToRef):void 0;a.push({id:Re.id,type:ze,...Re.name?{name:Re.name}:{},...ue?{participant:ue}:{},...he.has(Re.id)?{lane:he.get(Re.id)}:{},...C?{attachedTo:C}:{},...$?{eventDefinition:$}:{}}),ze==="subProcess"&&F(Re);const R=zy(Re,"bwl:band");R!==void 0&&(p.bands[Re.id]=R);const W=Hy(Re,"bwl:afterColumn");typeof W=="string"&&W!==""&&w.push([Re.id,W]);for(const q of Re.dataOutputAssociations??[])A(q.id),h.push({id:q.id,type:q.$type,source:Re.id,target:zi(q.targetRef)});for(const q of Re.dataInputAssociations??[])A(q.id),h.push({id:q.id,type:q.$type,source:zi((q.sourceRef??[])[0]),target:Re.id})}H(U.artifacts??[])};if(i){const U=new Set;for(const ue of i.participants??[]){B(ue.id),v.set(ue.id,ue);const K=zi(ue.processRef);K&&U.add(K);const J=K?o.get(K):void 0,he=((J==null?void 0:J.laneSets)??[]).flatMap(C=>C.lanes??[]),Re=he.map(C=>({id:C.id,...C.name?{name:C.name}:{}}));for(const C of Re)B(C.id);const ze=!J||(J.flowElements??[]).length===0&&he.length===0&&(J.artifacts??[]).length===0;r.push({id:ue.id,...ue.name?{name:ue.name}:{},...ze?{blackBox:!0}:{},...Re.length?{lanes:Re}:{}});const $=zy(ue,"bwl:poolOrder");$!==void 0&&(p.poolOrders[ue.id]=$),J&&G(J,ue.id)}for(const ue of i.messageFlows??[])A(ue.id),v.set(ue.id,ue),d.push({id:ue.id,source:zi(ue.sourceRef),target:zi(ue.targetRef),...typeof ue.name=="string"&&ue.name?{name:ue.name}:{}});H(i.artifacts??[]);for(const[ue,K]of o)!U.has(ue)&&(K.flowElements??[]).length>0&&u.push({id:ue,type:K.$type,reason:"unreachable-process"})}else for(const U of o.values())G(U);const ee=[],ce=[],ie=[],be=[],de=(U,ue)=>!!U&&!!ue&&E.has(U)&&E.has(ue);for(const U of f){if(!de(U.source,U.target)){u.push({id:U.id,type:"bpmn:SequenceFlow",reason:"endpoint-outside-mvp"});continue}ee.push({id:U.id,source:U.source,target:U.target,...U.name?{name:U.name}:{}}),E.add(U.id)}for(const U of d){if(!de(U.source,U.target)){u.push({id:U.id,type:"bpmn:MessageFlow",reason:"endpoint-outside-mvp"});continue}ce.push({id:U.id,source:U.source,target:U.target,...U.name?{name:U.name}:{}}),E.add(U.id)}for(const U of h){if(!de(U.source,U.target)){u.push({id:U.id??"",type:U.type,reason:"endpoint-outside-mvp"});continue}be.push({...U.id?{id:U.id}:{},source:U.source,target:U.target}),U.id&&E.add(U.id)}for(const U of g){if(!de(U.source,U.target)){u.push({id:U.id??"",type:U.type,reason:"endpoint-outside-mvp"});continue}ie.push({...U.id?{id:U.id}:{},source:U.source,target:U.target})}const me=new Map(l.map(U=>[U.id,U]));for(const{owner:U,refs:ue}of y){const K=ue.filter(he=>x.has(he)),J=me.get(U);J&&K.length&&(J.members=K)}for(const U of m)x.has(U.anchor)&&(p.placements[U.owner]={anchor:U.anchor,side:U.side,...U.offset!==void 0?{offset:U.offset}:{}});for(const[U,ue]of w)x.has(ue)&&(p.afterColumns[U]=ue);const Ee={...r.length?{participants:r}:{},nodes:a,sequenceFlows:ee,...ce.length?{messageFlows:ce}:{},...s.length?{dataStores:s}:{},...be.length?{dataAssociations:be}:{},...c.length?{annotations:c}:{},...ie.length?{associations:ie}:{},...l.length?{groups:l}:{}};return t.i18n?{definition:Ee,hints:p,omitted:u,i18n:mA(Ee,v,e,t.i18n)}:{definition:Ee,hints:p,omitted:u}}function mA(e,t,n,i){const o=$p(n),r=ss(i),a=[],s=(c,l)=>{const u=t.get(c.id);if(!u)return;const p=Fp(u,i,o);Object.keys(p).length&&(c[l]=p);for(const f of Gp(u))r.includes(f.locale)&&a.push({id:c.id,...f})};for(const c of e.participants??[]){s(c,"names");for(const l of c.lanes??[])s(l,"names")}for(const c of[e.nodes,e.sequenceFlows,e.messageFlows,e.dataStores,e.groups])for(const l of c??[])s(l,"names");for(const c of e.annotations??[])s(c,"texts");return{designLocale:i.designLocale,companionLocales:r.slice(1),reviewRequests:a}}async function yA(e,t={}){const{definitions:n,warnings:i}=await pa(e);return{...Vy(n,t),warnings:i}}const vA=new Set(["bpmn:ExclusiveGateway","bpmn:ParallelGateway","bpmn:InclusiveGateway","bpmn:EventBasedGateway","bpmn:ComplexGateway"]);function Pf(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function bA(e){return Pf(e.processRef)!==void 0}function xA(e){const t=new Set,n=o=>{const r=Pf(o);r&&t.add(r)},i=o=>{for(const r of o.flowElements??[]){n(r.sourceRef),n(r.targetRef),r.attachedToRef&&(n(r.attachedToRef),t.add(r.id));for(const a of r.dataOutputAssociations??[])t.add(r.id),n(a.targetRef);for(const a of r.dataInputAssociations??[]){t.add(r.id);for(const s of a.sourceRef??[])n(s)}(r.flowElements??[]).length&&i(r)}for(const r of o.artifacts??[])n(r.sourceRef),n(r.targetRef)};for(const o of e.rootElements??[])if(o.$type==="bpmn:Process")i(o);else if(o.$type==="bpmn:Collaboration"){for(const r of o.messageFlows??[])n(r.sourceRef),n(r.targetRef);for(const r of o.artifacts??[])n(r.sourceRef),n(r.targetRef)}return t}function wA(e){const t=[],n=i=>{for(const o of i.flowElements??[])vA.has(o.$type)&&t.push(o),(o.flowElements??[]).length&&n(o)};for(const i of e.rootElements??[])i.$type==="bpmn:Process"&&n(i);return t}function _A(e){if(!e)return!0;const t=(e.laneSets??[]).flatMap(n=>n.lanes??[]);return(e.flowElements??[]).length===0&&t.length===0&&(e.artifacts??[]).length===0}function Tf(e){const t=[],n=e.rootElements??[],i=xA(e);for(const r of wA(e))i.has(r.id)||t.push({ruleId:"CHK-FLOW-1",severity:"warning",targetKind:"flowNode",targetRefs:[r.id],params:{type:r.$type}});const o=n.find(r=>r.$type==="bpmn:Collaboration");if(o){const r=new Map(n.filter(s=>s.$type==="bpmn:Process").map(s=>[s.id,s])),a=[];for(const s of o.participants??[])bA(s)&&_A(r.get(Pf(s.processRef)))&&a.push(s.id);a.length&&t.push({ruleId:"CHK-POOL-1",severity:"info",targetKind:"participant",targetRefs:a,params:{count:a.length}})}return t}async function EA(e){const{definitions:t,warnings:n}=await pa(e);return{issues:Tf(t),warnings:n}}const SA=.5,RA=8,CA=new Set(["bpmn:Definitions","bpmn:Collaboration","bpmn:Process","bpmn:LaneSet","bpmn:ExtensionElements","bpmn:Documentation","bpmn:Relationship","bpmn:Property","bpmn:Category","bpmn:CategoryValue"]),ba=e=>typeof e=="number"?e:Number(e??NaN),ul=e=>{if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:""};function MA(e){const t=e,n=[],i=typeof t.name=="string"?t.name:typeof t.text=="string"?t.text:"";n.push(`n=${i.replace(/\s+/g," ").trim()}`);for(const r of["sourceRef","targetRef","attachedToRef","processRef","default"])t[r]!==void 0&&n.push(`${r}=${ul(t[r])}`);if(String(e.$type)==="bpmn:Group"){const r=t.categoryValueRef,a=Array.isArray(r)?r:r==null?[]:[r];n.push(`cat=[${a.map(s=>`${ul(s)}:${typeof(s==null?void 0:s.value)=="string"?s.value:""}`).sort().join(",")}]`)}Array.isArray(t.flowNodeRef)&&n.push(`lane=[${t.flowNodeRef.map(ul).sort().join(",")}]`);const o=t.conditionExpression;return o&&typeof o.body=="string"&&n.push(`cond=${o.body}`),n.join("|")}function AA(e){const t=new Map,n=new Map,i=(a,s)=>{a&&t.set(a,[...t.get(a)??[],...s])},o=a=>{const s=a;return s?[ba(s.x),ba(s.y),ba(s.width),ba(s.height)]:[]},r=a=>{if(Array.isArray(a))return a.forEach(r);if(!a||typeof a!="object")return;const s=a,c=String(s.$type??"");if(c==="bpmndi:BPMNShape"||c==="bpmndi:BPMNEdge"){const l=ul(s.bpmnElement);if(c==="bpmndi:BPMNShape")i(l,o(s.bounds));else{const p=Array.isArray(s.waypoint)?s.waypoint:[];i(l,p.flatMap(f=>[ba(f.x),ba(f.y)]))}const u=s.label;u!=null&&u.bounds&&l&&n.set(l,o(u.bounds).slice(0,2));return}for(const l of Object.values(s))(Array.isArray(l)||l&&typeof l=="object"&&"$type"in l)&&r(l)};return r(e.diagrams),{body:t,labels:n}}function Wy(e){const t=AA(e),n=new Map,i=new Set,o=r=>{if(Array.isArray(r))return r.forEach(o);if(!r||typeof r!="object"||i.has(r))return;i.add(r);const a=r,s=String(a.$type??"");if(s.startsWith("bpmndi:")||s.startsWith("dc:")||s.startsWith("di:"))return;const c=typeof a.id=="string"?a.id:"";c&&s.startsWith("bpmn:")&&!CA.has(s)&&n.set(c,{type:s,props:MA(a),geometry:(t.body.get(c)??[]).join(","),label:(t.labels.get(c)??[]).join(",")});for(const l of Object.values(a))(Array.isArray(l)||l&&typeof l=="object")&&o(l)};return o(e),n}function Uy(e,t,n){if(e===t)return!1;const i=e===""?[]:e.split(",").map(Number),o=t===""?[]:t.split(",").map(Number);return i.length!==o.length?!0:i.some((r,a)=>Math.abs(r-o[a])>n)}function qy(e,t,n={}){const i=n.moveTolerance??SA,o=Wy(e),r=Wy(t),a=[],s=[],c=[];for(const[l,u]of r){const p=o.get(l);if(!p){a.push(l);continue}(p.type!==u.type||p.props!==u.props||Uy(p.geometry,u.geometry,i)||Uy(p.label,u.label,n.labelTolerance??RA))&&c.push(l)}for(const l of o.keys())r.has(l)||s.push(l);return{added:a.sort(),removed:s.sort(),modified:c.sort()}}async function PA(e,t,n={}){const[i,o]=await Promise.all([pa(e),pa(t)]);return{...qy(i.definitions,o.definitions,n),warnings:[...i.warnings,...o.warnings]}}function TA(e){return new Set([...e.added,...e.modified])}function kA(e,t,n,i={}){return{documentId:e,baseVersion:t,ops:[...n],origin:i.origin??"agent",clientOpId:(i.mkClientOpId??(()=>crypto.randomUUID()))()}}async function Yy(e,t,{currentVersion:n,i18n:i}){if(t.baseVersion!==n)return{status:"conflict",baseVersion:t.baseVersion,currentVersion:n};const o=jy(e,t.ops,{i18n:i});if(!o.ok)return{status:"rejected",issues:o.issues};const{xml:r}=await e.saveXML({format:!0});return{status:"applied",version:n+1,xml:r??"",findings:o.findings,stats:o.stats}}const OA=new Set(["lasso","lasso.selection","hand","hand.move"]),Ky=1e4,DA="bwl-edit-locked",Xy=new WeakMap;function LA(e){const t=Xy.get(e);if(t)return t;const n=e.get("eventBus"),i=e.get("dragging",!1);let o=!1,r=!1;n.on("drag.init",Ky,()=>{var s;if(o)return OA.has((s=i==null?void 0:i.context())==null?void 0:s.prefix)?void 0:!1}),n.on(["contextPad.open.allowed","contextPad.trigger","palette.trigger","element.dblclick"],Ky,()=>o?!1:void 0);const a={get locked(){return o},set(s){var l,u,p;if(s===o)return;o=s,e.get("canvas").getContainer().classList.toggle(DA,s);const c=e.get("keyboard",!1);s?(i==null||i.cancel(),(l=e.get("contextPad",!1))==null||l.close(),(u=e.get("popupMenu",!1))==null||u.close(),(p=e.get("directEditing",!1))==null||p.complete(),r=!!(c!=null&&c.getBinding()),c==null||c.unbind()):r&&(c.bind(),r=!1)}};return Xy.set(e,a),a}const IA=Symbol("bpmn-editor"),kf={geometry:[],semantic:[]};function BA(){const e=Se.ref(!1),t=Se.ref(!0),n=Se.ref(!1),i=Se.shallowRef(kf),o=Se.shallowRef(void 0),r=Se.shallowRef(void 0);let a,s,c;const l=()=>{if(p(),!c){i.value=kf;return}const w=ft(Ue(c.get("elementRegistry")),{includeObservationOnly:!0}),y=c.getDefinitions();i.value={geometry:w,semantic:y?Tf(y):[]}};function u(){return(c==null?void 0:c.get("i18nDisplay",!1))??void 0}function p(){const w=u();if(!w||!a){r.value=void 0;return}const y=w.locales(),v={};for(const x of y)v[x]={untranslated:w.untranslatedCount(x),reviewRequested:w.reviewRequestedCount(x)};r.value={designLocale:a.designLocale,locales:y,displayLocale:w.getDisplayLocale()??a.designLocale,counts:v}}function f(){const w=u();w&&(w.configure(a),a&&s&&(s=w.setDisplayLocale(s)))}const d=()=>{e.value=!0,l()};function g(w,y){LA(w).set(!y)}function h(){if(!c)throw new Error("modeler not attached — 뷰 @ready 후 attach() 필요");return c}function m(){return c==null?void 0:c.get("commandStack")}return{dirty:e,editable:t,agentBusy:n,issues:i,revalidate:l,changeScope:o,i18n:r,configureI18n(w){a=w,f(),p()},setDisplayLocale(w){var v;s=w;const y=(v=u())==null?void 0:v.setDisplayLocale(w);y&&(s=y),p()},setChangeScope(w){o.value=w===void 0?void 0:new Set(w)},requestFocus(w){if(!c)return;const y=c.get("elementRegistry").get(w);y&&(c.get("canvas").scrollToElement(y,180),c.get("selection").select(y))},describeElement(w){const y=c==null?void 0:c.get("elementRegistry").get(w),v=y==null?void 0:y.businessObject;if(!v)return;const x=typeof v.name=="string"&&v.name.trim()!==""?v.name:v.text;return{name:typeof x=="string"&&x.trim()!==""?x.trim():void 0,type:typeof v.$type=="string"?v.$type:""}},attach(w){c&&this.detach(),c=w,c.get("eventBus").on("commandStack.changed",d),t.value||g(c,!1),f(),l()},detach(){c==null||c.get("eventBus").off("commandStack.changed",d),c&&!t.value&&g(c,!0),c=void 0,i.value=kf,o.value=void 0,r.value=void 0},setEditable(w){t.value=w,c&&g(c,w)},async applyAgentBatch(w,y){const v=h();n.value=!0;try{const x=await Yy(v,w,{currentVersion:y,...a?{i18n:{designLocale:a.designLocale,companionLocales:a.companionLocales}}:{}});return x.status==="applied"&&(e.value=!1),x}finally{n.value=!1}},async importXml(w){const{warnings:y}=await h().importXML(w);return e.value=!1,o.value=void 0,l(),{warnings:rf(y)}},async saveXml(){const{xml:w}=await h().saveXML({format:!0});return e.value=!1,w??""},undo:()=>{var w;return(w=m())==null?void 0:w.undo()},redo:()=>{var w;return(w=m())==null?void 0:w.redo()},canUndo:()=>{var w;return((w=m())==null?void 0:w.canUndo())??!1},canRedo:()=>{var w;return((w=m())==null?void 0:w.canRedo())??!1}}}const NA=new RegExp("\\p{Script=Hangul}","u"),$A=/[\p{Script=Hiragana}\p{Script=Katakana}]/u,FA=new RegExp("\\p{Script=Han}","u");function pl(e){const t=NA.test(e),n=$A.test(e);return t&&n?{script:"mixed"}:t?{script:"hangul",locale:"ko"}:n?{script:"kana",locale:"ja"}:{script:FA.test(e)?"han":"other"}}function Zy(e){var t,n;return((t=e==null?void 0:e.get)==null?void 0:t.call(e,"xml:lang"))??((n=e==null?void 0:e.$attrs)==null?void 0:n["xml:lang"])}function Qy(e){var i;const t=new Set,n=[];for(const o of(e==null?void 0:e.diagrams)??[])for(const r of((i=o==null?void 0:o.plane)==null?void 0:i.planeElement)??[]){const a=r==null?void 0:r.bpmnElement;if(!a||t.has(a))continue;t.add(a);const s=Ar(a);if(!s)continue;const c=s.target[s.key]??"";c&&n.push({bo:a,name:c,trs:No(a).filter(l=>Rn(l))})}return n}const ys=e=>({id:e.bo.id,type:e.bo.$type,name:e.name});function jA(e,t={}){const n=Zy(e),i=Qy(e);let o;const r={},a=[],s=[],c=[];for(const h of i){const m=h.trs.filter(w=>(w.body??"")===h.name).map(Rn);if(m.length){const w=[...m].sort().join("+");r[w]=(r[w]??0)+1,o=o?new Set([...o].filter(y=>m.includes(y))):new Set(m)}else h.trs.some(w=>w.body)?a.push(ys(h)):c.push({e:h,inference:pl(h.name)});for(const w of h.trs){const y=Rn(w),v=w.body??"",x=pl(v);x.locale&&x.locale!==y?s.push({...ys(h),locale:y,script:x.script}):y==="ko"&&x.script==="han"&&h.trs.some(E=>E!==w&&E.body===v)&&s.push({...ys(h),locale:y,script:"han"})}}const l=new Set(c.map(h=>h.inference.locale).filter(Boolean));let u,p;if(n)p="kept";else if(o&&o.size===1)[u,p]=[[...o][0],"matched"];else if(o&&o.size>1){const h=l.size===1?[...l][0]:void 0;h&&o.has(h)?[u,p]=[h,"matched"]:p="ambiguous"}else o?p="mixed":l.size===1?[u,p]=[[...l][0],"script"]:p=l.size>1?"mixed":"no-evidence";u&&t.designLocale&&u!==t.designLocale&&([u,p]=[void 0,"non-design"]);const f=n??u,d=[],g=[];for(const{e:h,inference:m}of c)m.locale?m.locale!==f&&d.push({...ys(h),locale:m.locale}):g.push({...ys(h),script:m.script});return{root:{current:n,proposed:u,reason:p},additions:d,undecided:g,drift:a,matchedBy:r,scriptMismatch:s}}function HA(e,t){const n=e.$model;let i=0;if(t.root.proposed&&!Zy(e)&&(e.set("xml:lang",t.root.proposed),i++),!t.additions.length)return i;const o=new Map(Qy(e).map(r=>[r.bo.id,r]));for(const{id:r,name:a,locale:s}of t.additions){const c=o.get(r);if(!c||c.name!==a||c.trs.some(f=>f.body))continue;const l=c.trs.find(f=>Rn(f)===s);if(l){l.body=c.name,i++;continue}let u=c.bo.extensionElements;u||(u=n.create("bpmn:ExtensionElements",{values:[]}),u.$parent=c.bo,c.bo.extensionElements=u);const p=n.create(Mr,{body:c.name});p.set("xml:lang",s),p.$parent=u,u.get("values").push(p),i++}return i}function Jy(e){var i;const t=new Set,n=[];for(const o of(e==null?void 0:e.diagrams)??[])for(const r of((i=o==null?void 0:o.plane)==null?void 0:i.planeElement)??[]){const a=r==null?void 0:r.bpmnElement;!(a!=null&&a.id)||t.has(a)||(t.add(a),n.push(a))}return n}const Of=e=>Rn(e)||void 0,ev=e=>e.body??"";function tv(e){const t=new Map;for(const n of Jy(e)){const i=No(n);i.length&&t.set(n.id,{type:n.$type,cells:i.map(o=>({locale:Of(o),body:ev(o)}))})}return t}const nv=e=>JSON.stringify(e.map(t=>t.body).sort());class zA{constructor(){$n(this,"byId",new Map);$n(this,"byBodies",new Map)}add(t,n,i){for(const[o,r]of i){if(!r.cells.some(s=>s.locale))continue;const a={doc:t,version:n,id:o,state:r};iv(this.byId,o,a),iv(this.byBodies,nv(r.cells),a)}}sameId(t){return this.byId.get(t)??[]}sameBodies(t){return this.byBodies.get(nv(t))??[]}}function iv(e,t,n){const i=e.get(t);i?i.push(n):e.set(t,[n])}function GA(e,t,n){var s;const i=new Set(t.cells.filter(c=>c.locale).map(c=>c.body)),o=new Map,r=(c,l)=>(c??[]).filter(u=>!u.locale&&u.body===l).length,a=t.cells.every(c=>!c.locale);for(const c of t.cells){if(c.locale||i.has(c.body)||o.has(c.body))continue;const l=r(t.cells,c.body)-(a?0:n?r((s=n.get(e))==null?void 0:s.cells,c.body):1/0);l>0&&o.set(c.body,l)}return o}function Df(e,t){return[...t.keys()].every(n=>e.cells.some(i=>i.body===n))&&e.cells.some(n=>n.locale&&t.has(n.body))}function VA(e,t,n){const i=new Set(e.cells.filter(r=>r.locale).map(r=>r.locale)),o={cells:[],stale:[],overflow:!1};for(const[r,a]of n){const s=[...new Set(t.cells.filter(l=>l.body===r&&l.locale).map(l=>l.locale))],c=s.filter(l=>!i.has(l));for(const l of s)i.has(l)&&o.stale.push({body:r,locale:l});c.length>a&&(o.overflow=!0);for(const l of c.slice(0,a))o.cells.push({body:r,locale:l}),i.add(l)}return o}const WA=e=>JSON.stringify([...e.cells].sort((t,n)=>(t.body+t.locale).localeCompare(n.body+n.locale)));function UA(e,t){const n={restores:[],ambiguous:[],stale:[],unresolved:[]},i=tv(e),o=new Set([...i.values()].flatMap(a=>a.cells.map(s=>s.locale).filter(s=>!!s))),r=a=>!o.size||[...o].some(s=>!a.cells.some(c=>c.locale===s));for(const[a,s]of i){const c=GA(a,s,t.baseline);if(!c.size)continue;const l={id:a,type:s.type},p=[["history",t.index.sameId(a).filter(m=>m.doc===t.doc&&Df(m.state,c)).sort((m,w)=>w.version-m.version).slice(0,1).map(m=>m.state)],["lineage",t.index.sameId(a).filter(m=>m.doc!==t.doc&&Df(m.state,c)).map(m=>m.state)],["bodies",t.index.sameBodies(s.cells).filter(m=>!(m.doc===t.doc&&m.id===a)&&Df(m.state,c)).map(m=>m.state)]].find(([,m])=>m.length);if(!p){if(!r(s))continue;for(const[m,w]of c)for(let y=0;y<w;y++)n.unresolved.push({...l,body:m,script:pl(m).script});continue}const[f,d]=p,g=d.map(m=>VA(s,m,c));if(g.some(m=>m.overflow)||new Set(g.map(WA)).size>1){n.ambiguous.push({...l,source:f});continue}const[h]=g;for(const m of h.stale)n.stale.push({...l,...m});h.cells.length&&n.restores.push({...l,source:f,cells:h.cells})}return n}function qA(e,t){if(!t.restores.length)return 0;const n=new Map(Jy(e).map(o=>[o.id,o]));let i=0;for(const o of t.restores){const r=n.get(o.id);if(!r)continue;const a=No(r),s=new Set(a.map(Of).filter(Boolean));for(const{body:c,locale:l}of o.cells){if(s.has(l))continue;const u=a.find(p=>!Of(p)&&ev(p)===c);u&&(u.set("xml:lang",l),s.add(l),i++)}}return i}function Ne(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}function YA(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lf={exports:{}},ov;function KA(){if(ov)return Lf.exports;ov=1;var e=Lf.exports=function(t,n){if(n||(n=16),t===void 0&&(t=128),t<=0)return"0";for(var i=Math.log(Math.pow(2,t))/Math.log(n),o=2;i===1/0;o*=2)i=Math.log(Math.pow(2,t/o))/Math.log(n)*o;for(var r=i-Math.floor(i),a="",o=0;o<Math.floor(i);o++){var s=Math.floor(Math.random()*n).toString(n);a=s+a}if(r){var c=Math.pow(n,r),s=Math.floor(Math.random()*c).toString(n);a=s+a}var l=parseInt(a,n);return l!==1/0&&l>=Math.pow(2,t)?e(t,n):a};return e.rack=function(t,n,i){var o=function(a){var s=0;do{if(s++>10)if(i)t+=i;else throw new Error("too many ID collisions, use more bits");var c=e(t,n)}while(Object.hasOwnProperty.call(r,c));return r[c]=a,c},r=o.hats={};return o.get=function(a){return o.hats[a]},o.set=function(a,s){return o.hats[a]=s,o},o.bits=t||128,o.base=n||16,o},Lf.exports}var XA=KA(),ZA=YA(XA);function Xi(e){if(!(this instanceof Xi))return new Xi(e);e=e||[128,36,1],this._seed=e.length?ZA.rack(e[0],e[1],e[2]):e}Xi.prototype.next=function(e){return this._seed(e||!0)},Xi.prototype.nextPrefixed=function(e,t){var n;do n=e+this.next(!0);while(this.assigned(n));return this.claim(n,t),n},Xi.prototype.claim=function(e,t){this._seed.set(e,t||!0)},Xi.prototype.assigned=function(e){return this._seed.get(e)||!1},Xi.prototype.unclaim=function(e){delete this._seed.hats[e]},Xi.prototype.clear=function(){var e=this._seed.hats,t;for(t in e)this.unclaim(t)};const yn={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};yn.td=yn.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],yn.option=yn.optgroup=[1,'<select multiple="multiple">',"</select>"],yn.thead=yn.tbody=yn.colgroup=yn.caption=yn.tfoot=[1,"<table>","</table>"],yn.polyline=yn.ellipse=yn.polygon=yn.circle=yn.text=yn.line=yn.path=yn.rect=yn.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function jt(e,t=globalThis.document){var l;if(typeof e!="string")throw new TypeError("String expected");const n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);const i=(l=/<([\w:]+)/.exec(e))==null?void 0:l[1];if(!i)return t.createTextNode(e);if(e=e.trim(),i==="body"){const u=t.createElement("html");u.innerHTML=e;const{lastChild:p}=u;return p.remove(),p}let[o,r,a]=Object.hasOwn(yn,i)?yn[i]:yn._default,s=t.createElement("div");for(s.innerHTML=r+e+a;o--;)s=s.lastChild;if(s.firstChild===s.lastChild){const{firstChild:u}=s;return u.remove(),u}const c=t.createDocumentFragment();return c.append(...s.childNodes),c}function QA(e,t){return t.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(i){if(i!=="default"&&!(i in e)){var o=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return n[i]}})}})}),Object.freeze(e)}function Un(e,...t){const n=e.style;return V(t,function(i){i&&V(i,function(o,r){n[r]=o})}),e}function Cn(e,t,n){return arguments.length==2?e.getAttribute(t):n===null?e.removeAttribute(t):(e.setAttribute(t,n),e)}const JA=Object.prototype.toString;function At(e){return new Go(e)}function Go(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Go.prototype.add=function(e){return this.list.add(e),this},Go.prototype.remove=function(e){return JA.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},Go.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Go.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Go.prototype.array=function(){return Array.from(this.list)},Go.prototype.has=Go.prototype.contains=function(e){return this.list.contains(e)};function fl(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Lr(e,t,n){var i=n?e:e.parentNode;return i&&typeof i.closest=="function"&&i.closest(t)||null}function eP(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dl={},rv;function tP(){if(rv)return dl;rv=1;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n=e!=="addEventListener"?"on":""}return dl.bind=function(o,r,a,s){return e||i(),o[e](n+r,a,s||!1),a},dl.unbind=function(o,r,a,s){return t||i(),o[t](n+r,a,s||!1),a},dl}var av=tP(),nP=eP(av),Ve=QA({__proto__:null,default:nP},[av]),sv=["focus","blur"];function iP(e,t,n,i,o){return sv.indexOf(n)!==-1&&(o=!0),Ve.bind(e,n,function(r){var a=r.target||r.srcElement;r.delegateTarget=Lr(a,t,!0),r.delegateTarget&&i.call(e,r)},o)}function oP(e,t,n,i){return sv.indexOf(t)!==-1&&(i=!0),Ve.unbind(e,t,n,i)}var ii={bind:iP,unbind:oP};function If(e,t){return e&&typeof e.matches=="function"&&e.matches(t)||!1}function Ct(e,t){return t=t||document,t.querySelector(e)}function vs(e,t){return t=t||document,t.querySelectorAll(e)}function Zi(e){e.parentNode&&e.parentNode.removeChild(e)}function rP(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch{}return e}function aP(e,t){return t.appendChild(rP(e,t))}function tt(e,t){return aP(t,e),e}var Bf=2,cv={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":Bf,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":Bf,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function sP(e,t){return cv[t]?e.style[t]:e.getAttributeNS(null,t)}function lv(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=cv[i];o?(o===Bf&&typeof n=="number"&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function cP(e,t){var n=Object.keys(t),i,o;for(i=0,o;o=n[i];i++)lv(e,o,t[o])}function Ie(e,t,n){if(typeof t=="string")if(n!==void 0)lv(e,t,n);else return sP(e,t);else cP(e,t);return e}const lP=Object.prototype.toString;function dt(e){return new Vo(e)}function Vo(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Vo.prototype.add=function(e){return this.list.add(e),this},Vo.prototype.remove=function(e){return lP.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},Vo.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Vo.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Vo.prototype.array=function(){return Array.from(this.list)},Vo.prototype.has=Vo.prototype.contains=function(e){return this.list.contains(e)};function bs(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Nf(e){return e.cloneNode(!0)}var $f={svg:"http://www.w3.org/2000/svg"},uv='<svg xmlns="'+$f.svg+'"';function uP(e){var t=!1;e.substring(0,4)==="<svg"?e.indexOf($f.svg)===-1&&(e=uv+e.substring(4)):(e=uv+">"+e+"</svg>",t=!0);var n=pP(e);if(!t)return n;for(var i=document.createDocumentFragment(),o=n.firstChild;o.firstChild;)i.appendChild(o.firstChild);return i}function pP(e){var t;return t=new DOMParser,t.async=!1,t.parseFromString(e,"text/xml")}function He(e,t){var n;return e=e.trim(),e.charAt(0)==="<"?(n=uP(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS($f.svg,e),t&&Ie(n,t),n}var Ff=null;function pv(){return Ff===null&&(Ff=He("svg")),Ff}function fv(e,t){var n,i,o=Object.keys(t);for(n=0;i=o[n];n++)e[i]=t[i];return e}function fP(e,t,n,i,o,r){var a=pv().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return fv(a,e);case 6:return fv(a,{a:e,b:t,c:n,d:i,e:o,f:r})}}function xs(e){return pv().createSVGTransform()}var dv=/([&<>]{1})/g,dP=/([&<>\n\r"]{1})/g,hP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function jf(e,t){function n(i,o){return hP[o]||o}return e.replace(t,n)}function hv(e,t){var n,i,o,r,a;switch(e.nodeType){case 3:t.push(jf(e.textContent,dv));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(o=e.attributes,n=0,i=o.length;n<i;++n)r=o.item(n),t.push(" ",r.name,'="',jf(r.value,dP),'"');if(e.hasChildNodes()){for(t.push(">"),a=e.childNodes,n=0,i=a.length;n<i;++n)hv(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("<!--",jf(e.nodeValue,dv),"-->");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function gP(e){for(var t=e.firstChild,n=[];t;)hv(t,n),t=t.nextSibling;return n.join("")}function gv(e,t){return gP(e)}function sn(e){var t=e.parentNode;return t&&t.removeChild(e),e}function mP(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function yP(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(mP(e,i))}function ws(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),yP(n,t)),n.consolidate()}const vP=/^class[ {]/;function bP(e){return vP.test(e.toString())}function Hf(e){return Array.isArray(e)}function zf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function hl(...e){e.length===1&&Hf(e[0])&&(e=e[0]),e=[...e];const t=e.pop();return t.$inject=e,t}const xP=/constructor\s*[^(]*\(\s*([^)]*)\)/m,wP=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,_P=/\/\*([^*]*)\*\//m;function EP(e){if(typeof e!="function")throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(bP(e)?xP:wP);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(i=>{const o=i.match(_P);return(o&&o[1]||i).trim()})||[]}function mv(e,t){const n=t||{get:function(v,x){if(i.push(v),x===!1)return null;throw s(`No provider for "${v}"!`)}},i=[],o=this._providers=Object.create(n._providers||null),r=this._instances=Object.create(null),a=r.injector=this,s=function(v){const x=i.join(" -> ");return i.length=0,new Error(x?`${v} (Resolving: ${x})`:v)};function c(v,x){if(!o[v]&&v.includes(".")){const E=v.split(".");let A=c(E.shift());for(;E.length;)A=A[E.shift()];return A}if(zf(r,v))return r[v];if(zf(o,v)){if(i.indexOf(v)!==-1)throw i.push(v),s("Cannot resolve circular dependency!");return i.push(v),r[v]=o[v][0](o[v][1]),i.pop(),r[v]}return n.get(v,x)}function l(v,x){if(typeof x>"u"&&(x={}),typeof v!="function")if(Hf(v))v=hl(v.slice());else throw s(`Cannot invoke "${v}". Expected a function!`);const A=(v.$inject||EP(v)).map(B=>zf(x,B)?x[B]:c(B));return{fn:v,dependencies:A}}function u(v){const{fn:x,dependencies:E}=l(v),A=Function.prototype.bind.call(x,null,...E);return new A}function p(v,x,E){const{fn:A,dependencies:B}=l(v,E);return A.apply(x,B)}function f(v){return hl(x=>v.get(x))}function d(v,x){if(x&&x.length){const E=Object.create(null),A=Object.create(null),B=[],P=[],k=[];let H,F,G,ee;for(let ce in o)H=o[ce],x.indexOf(ce)!==-1&&(H[2]==="private"?(F=B.indexOf(H[3]),F===-1?(G=H[3].createChild([],x),ee=f(G),B.push(H[3]),P.push(G),k.push(ee),E[ce]=[ee,ce,"private",G]):E[ce]=[k[F],ce,"private",P[F]]):E[ce]=[H[2],H[1]],A[ce]=!0),(H[2]==="factory"||H[2]==="type")&&H[1].$scope&&x.forEach(ie=>{H[1].$scope.indexOf(ie)!==-1&&(E[ce]=[H[2],H[1]],A[ie]=!0)});x.forEach(ce=>{if(!A[ce])throw new Error('No provider for "'+ce+'". Cannot use provider from the parent!')}),v.unshift(E)}return new mv(v,a)}const g={factory:p,type:u,value:function(v){return v}};function h(v,x){const E=v.__init__||[];return function(){E.forEach(A=>{typeof A=="string"?x.get(A):x.invoke(A)})}}function m(v){const x=v.__exports__;if(x){const E=v.__modules__,A=Object.keys(v).reduce((F,G)=>(G!=="__exports__"&&G!=="__modules__"&&G!=="__init__"&&G!=="__depends__"&&(F[G]=v[G]),F),Object.create(null)),B=(E||[]).concat(A),P=d(B),k=hl(function(F){return P.get(F)});x.forEach(function(F){o[F]=[k,F,"private",P]});const H=(v.__init__||[]).slice();return H.unshift(function(){P.init()}),v=Object.assign({},v,{__init__:H}),h(v,P)}return Object.keys(v).forEach(function(E){if(E==="__init__"||E==="__depends__")return;const A=v[E];if(A[2]==="private"){o[E]=A;return}const B=A[0],P=A[1];o[E]=[g[B],SP(B,P),B]}),h(v,a)}function w(v,x){return v.indexOf(x)!==-1||(v=(x.__depends__||[]).reduce(w,v),v.indexOf(x)!==-1)?v:v.concat(x)}function y(v){const x=v.reduce(w,[]).map(m);let E=!1;return function(){E||(E=!0,x.forEach(A=>A()))}}this.get=c,this.invoke=p,this.instantiate=u,this.createChild=d,this.init=y(e)}function SP(e,t){return e!=="value"&&Hf(t)&&(t=hl(t.slice())),t}var RP=1e3;function yo(e,t){var n=this;t=t||RP,e.on(["render.shape","render.connection"],t,function(i,o){var r=i.type,a=o.element,s=o.gfx,c=o.attrs;if(n.canRender(a))return r==="render.shape"?n.drawShape(s,a,c):n.drawConnection(s,a,c)}),e.on(["render.getShapePath","render.getConnectionPath"],t,function(i,o){if(n.canRender(o))return i.type==="render.getShapePath"?n.getShapePath(o):n.getConnectionPath(o)})}yo.prototype.canRender=function(e){},yo.prototype.drawShape=function(e,t){},yo.prototype.drawConnection=function(e,t){},yo.prototype.getShapePath=function(e){},yo.prototype.getConnectionPath=function(e){};function Ir(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function CP(e){return["M",e.x,e.y]}function Gf(e){return["L",e.x,e.y]}function MP(e,t,n){return["C",e.x,e.y,t.x,t.y,n.x,n.y]}function AP(e,t){const n=e.length,i=[CP(e[0])];for(let o=1;o<n;o++){const r=e[o-1],a=e[o],s=e[o+1];if(!s||!t){i.push(Gf(a));continue}const c=Math.min(t,Vf(a.x-r.x,a.y-r.y),Vf(s.x-a.x,s.y-a.y));if(!c){i.push(Gf(a));continue}const l=gl(a,r,c),u=gl(a,r,c*.5),p=gl(a,s,c),f=gl(a,s,c*.5);i.push(Gf(l)),i.push(MP(u,f,p))}return i}function gl(e,t,n){const i=t.x-e.x,o=t.y-e.y,r=Vf(i,o),a=n/r;return{x:e.x+i*a,y:e.y+o*a}}function Vf(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function _s(e,t,n){Qe(t)&&(n=t,t=null),t||(t={});const i=He("path",t);return Qe(n)&&(i.dataset.cornerRadius=String(n)),Wf(i,e)}function Wf(e,t){const n=parseInt(e.dataset.cornerRadius,10)||0;return Ie(e,{d:Ir(AP(t,n))}),e}function ml(e){var t=new Set(e);return ct(e,function(n){for(var i=n.parent;i;){if(t.has(i))return!1;i=i.parent}return!0})}function Br(e,t,n){n=n||0,Ze(e)||(e=[e]),V(e,function(i,o){var r=t(i,o,n);Ze(r)&&r.length&&Br(r,t,n+1)})}function Uf(e,t,n){var i=new Set,o=new Set;return Br(e,function(r,a,s){i.add(r);var c=r.children;if(c&&!o.has(c))return o.add(c),c}),Array.from(i)}function Es(e,t){return Uf(e)}function PP(e,t,n){Cr(t)&&(t=!0),mn(t)&&(n=t,t=!0),n=n||{};var i=Ss(n.allShapes),o=Ss(n.allConnections),r=Ss(n.enclosedElements),a=Ss(n.enclosedConnections),s=Ss(n.topLevel,t&&sa(e,function(u){return u.id}));function c(u){s[u.source.id]&&s[u.target.id]&&(s[u.id]=[u]),i[u.source.id]&&i[u.target.id]&&(a[u.id]=r[u.id]=u),o[u.id]=u}function l(u){if(r[u.id]=u,u.waypoints)a[u.id]=o[u.id]=u;else return i[u.id]=u,V(u.incoming,c),V(u.outgoing,c),u.children}return Br(e,l),{allShapes:i,allConnections:o,topLevel:s,enclosedConnections:a,enclosedElements:r}}function cn(e,t){t=!!t,Ze(e)||(e=[e]);var n,i,o,r;return V(e,function(a){var s=a;a.waypoints&&!t&&(s=cn(a.waypoints,!0));var c=s.x,l=s.y,u=s.height||0,p=s.width||0;(c<n||n===void 0)&&(n=c),(l<i||i===void 0)&&(i=l),(c+p>o||o===void 0)&&(o=c+p),(l+u>r||r===void 0)&&(r=l+u)}),{x:n,y:i,height:r-i,width:o-n}}function xa(e,t){var n={};return V(e,function(i){var o=i;o.waypoints&&(o=cn(o)),!Qe(t.y)&&o.x>t.x&&(n[i.id]=i),!Qe(t.x)&&o.y>t.y&&(n[i.id]=i),o.x>t.x&&o.y>t.y&&(Qe(t.width)&&Qe(t.height)&&o.width+o.x<t.width+t.x&&o.height+o.y<t.height+t.y||!Qe(t.width)||!Qe(t.height))&&(n[i.id]=i)}),n}function yv(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function vv(e){return!!(e&&e.isFrame)}function Ss(e,t){return Y({},e||{},t||{})}var TP=1;function Wo(e,t){yo.call(this,e,TP),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}Ne(Wo,yo),Wo.prototype.canRender=function(){return!0},Wo.prototype.drawShape=function(t,n,i){var o=He("rect");return Ie(o,{x:0,y:0,width:n.width||0,height:n.height||0}),vv(n)?Ie(o,Y({},this.FRAME_STYLE,i||{})):Ie(o,Y({},this.SHAPE_STYLE,i||{})),tt(t,o),o},Wo.prototype.drawConnection=function(t,n,i){var o=_s(n.waypoints,Y({},this.CONNECTION_STYLE,i||{}));return tt(t,o),o},Wo.prototype.getShapePath=function(t){var n=t.x,i=t.y,o=t.width,r=t.height,a=[["M",n,i],["l",o,0],["l",0,r],["l",-o,0],["z"]];return Ir(a)},Wo.prototype.getConnectionPath=function(t){var n=t.waypoints,i,o,r=[];for(i=0;o=n[i];i++)o=o.original||o,r.push([i===0?"M":"L",o.x,o.y]);return Ir(r)},Wo.$inject=["eventBus","styles"];function kP(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(n,i,o){var r=this.style(i,o);return Y(r,{class:n})},this.style=function(n,i){!Ze(n)&&!i&&(i=n,n=[]);var o=ni(n,function(r,a){return Y(r,e[a]||{})},{});return i?Y(o,i):o},this.computeStyle=function(n,i,o){return Ze(i)||(o=i,i=[]),t.style(i||[],Y({},o,n||{}))}}const OP={__init__:["defaultRenderer"],defaultRenderer:["type",Wo],styles:["type",kP]};function tn(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return n!==-1&&e.splice(n,1),n}function on(e,t,n){if(!(!e||!t)){typeof n!="number"&&(n=-1);var i=e.indexOf(t);if(i!==-1){if(i===n)return;if(n!==-1)e.splice(i,1);else return}n!==-1?e.splice(n,0,t):e.push(t)}}function qf(e,t){return!e||!t?-1:e.indexOf(t)}function Rs(e,t){return!e||!t?-1:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Yf(e,t,n,i){if(typeof i>"u"&&(i=5),!e||!t||!n)return!1;var o=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),r=Rs(e,t);return Math.abs(o/r)<=i}var DP=2;function vo(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[o,r]of Object.entries(i))if(LP(o,n))return r;return!1}function LP(e,t){const n=t[0];return Io(t,function(i){return Math.abs(n[e]-i[e])<=DP})}function bv(e,t,n){return n=n||0,e.x>t.x-n&&e.y>t.y-n&&e.x<t.x+t.width+n&&e.y<t.y+t.height+n}function Kf(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var IP=/,?([a-z]),?/gi,xv=parseFloat,ln=Math,Uo=ln.PI,Qi=ln.min,Ji=ln.max,wv=ln.pow,qo=ln.abs,BP=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/ig,NP=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/ig,_v=Array.isArray||function(e){return e instanceof Array};function $P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function FP(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return e.push(e.splice(n,1)[0])}function jP(e){function t(){var n=Array.prototype.slice.call(arguments,0),i=n.join("␀"),o=t.cache=t.cache||{},r=t.count=t.count||[];return $P(o,i)?(FP(r,i),o[i]):(r.length>=1e3&&delete o[r.shift()],r.push(i),o[i]=e(...arguments),o[i])}return t}function HP(e){if(!e)return null;var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=[];return String(e).replace(BP,function(i,o,r){var a=[],s=o.toLowerCase();for(r.replace(NP,function(c,l){l&&a.push(+l)}),s=="m"&&a.length>2&&(n.push([o,...a.splice(0,2)]),s="l",o=o=="m"?"l":"L");a.length>=t[s]&&(n.push([o,...a.splice(0,t[s])]),!!t[s]););}),n.toString=Zf,n}function zP(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if(typeof i=="string"&&i!==i.toUpperCase())return!1}return!0}function GP(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if(i!=="M"&&i!=="C")return!1}return!0}function Xf(e,t,n,i){return arguments.length===1&&(t=e.y,n=e.width,i=e.height,e=e.x),{x:e,y:t,width:n,height:i,x2:e+n,y2:t+i}}function Zf(){return this.join(",").replace(IP,"$1")}function VP(e){for(var t=new Array(e.length),n=0,i=e.length;n<i;n++)for(var o=e[n],r=t[n]=new Array(o.length),a=0,s=o.length;a<s;a++)r[a]=o[a];return t.toString=Zf,t}function Ev(e,t,n,i,o,r,a,s,c){var l=1-c,u=wv(l,3),p=wv(l,2),f=c*c,d=f*c,g=u*e+p*3*c*n+l*3*c*c*o+d*a,h=u*t+p*3*c*i+l*3*c*c*r+d*s;return{x:yl(g),y:yl(h)}}function Sv(e){var t=XP(...e);return Xf(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function Yo(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function WP(e,t){return e=Xf(e),t=Xf(t),Yo(t,e.x,e.y)||Yo(t,e.x2,e.y)||Yo(t,e.x,e.y2)||Yo(t,e.x2,e.y2)||Yo(e,t.x,t.y)||Yo(e,t.x2,t.y)||Yo(e,t.x,t.y2)||Yo(e,t.x2,t.y2)||(e.x<t.x2&&e.x>t.x||t.x<e.x2&&t.x>e.x)&&(e.y<t.y2&&e.y>t.y||t.y<e.y2&&t.y>e.y)}function Rv(e,t,n,i,o){var r=-3*t+9*n-9*i+3*o,a=e*r+6*t-12*n+6*i;return e*a-3*t+3*n}function Cv(e,t,n,i,o,r,a,s,c){c==null&&(c=1),c=c>1?1:c<0?0:c;for(var l=c/2,u=12,p=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],f=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],d=0,g=0;g<u;g++){var h=l*p[g]+l,m=Rv(h,e,n,o,a),w=Rv(h,t,i,r,s),y=m*m+w*w;d+=f[g]*ln.sqrt(y)}return l*d}function UP(e,t,n,i,o,r,a,s){if(!(Ji(e,n)<Qi(o,a)||Qi(e,n)>Ji(o,a)||Ji(t,i)<Qi(r,s)||Qi(t,i)>Ji(r,s))){var c=(e*i-t*n)*(o-a)-(e-n)*(o*s-r*a),l=(e*i-t*n)*(r-s)-(t-i)*(o*s-r*a),u=(e-n)*(r-s)-(t-i)*(o-a);if(u){var p=yl(c/u),f=yl(l/u),d=+p.toFixed(2),g=+f.toFixed(2);if(!(d<+Qi(e,n).toFixed(2)||d>+Ji(e,n).toFixed(2)||d<+Qi(o,a).toFixed(2)||d>+Ji(o,a).toFixed(2)||g<+Qi(t,i).toFixed(2)||g>+Ji(t,i).toFixed(2)||g<+Qi(r,s).toFixed(2)||g>+Ji(r,s).toFixed(2)))return{x:p,y:f}}}}function yl(e){return Math.round(e*1e11)/1e11}function qP(e,t,n){var i=Sv(e),o=Sv(t);if(!WP(i,o))return[];var r=Cv(...e),a=Cv(...t),s=Av(e)?1:~~(r/5)||1,c=Av(t)?1:~~(a/5)||1,l=new Array(s+1),u=new Array(c+1),p={},f=[],d,g;for(d=0;d<s+1;d++){var h=Ev(...e,d/s);l[d]={x:h.x,y:h.y,t:d/s}}for(d=0;d<c+1;d++)h=Ev(...t,d/c),u[d]={x:h.x,y:h.y,t:d/c};for(d=0;d<s;d++)for(g=0;g<c;g++){var m=l[d],w=l[d+1],y=u[g],v=u[g+1],x=qo(w.x-m.x)<.01?"y":"x",E=qo(v.x-y.x)<.01?"y":"x",A=UP(m.x,m.y,w.x,w.y,y.x,y.y,v.x,v.y),B;if(A){if(B=A.x.toFixed(9)+"#"+A.y.toFixed(9),p[B])continue;p[B]=!0;var P=m.t+qo((A[x]-m[x])/(w[x]-m[x]))*(w.t-m.t),k=y.t+qo((A[E]-y[E])/(v[E]-y[E]))*(v.t-y.t);P>=0&&P<=1&&k>=0&&k<=1&&f.push({x:A.x,y:A.y,t1:P,t2:k})}}return f}function Mv(e,t,n){e=kv(e),t=kv(t);for(var i,o,r,a,s,c,l,u,p,f,d=n?0:[],g=0,h=e.length;g<h;g++){var m=e[g];if(m[0]=="M")i=s=m[1],o=c=m[2];else{m[0]=="C"?(p=[i,o,...m.slice(1)],i=p[6],o=p[7]):(p=[i,o,i,o,s,c,s,c],i=s,o=c);for(var w=0,y=t.length;w<y;w++){var v=t[w];if(v[0]=="M")r=l=v[1],a=u=v[2];else{v[0]=="C"?(f=[r,a,...v.slice(1)],r=f[6],a=f[7]):(f=[r,a,r,a,l,u,l,u],r=l,a=u);var x=qP(p,f);{for(var E=0,A=x.length;E<A;E++)x[E].segment1=g,x[E].segment2=w,x[E].bez1=p,x[E].bez2=f;d=d.concat(x)}}}}}return d}function YP(e){return _v(e)&&_v(e[0])}function KP(e){if(zP(e))return e;var t=new Array(e.length),n=0,i=0,o=0,r=0,a=0,s;e[0][0]=="M"&&(n=+e[0][1],i=+e[0][2],o=n,r=i,a++,t[0]=["M",n,i]);for(var c,l,u=a,p=e.length;u<p;u++){if(l=e[u],s=l[0],t[u]=c=new Array(l.length),s!=s.toUpperCase())switch(c[0]=s.toUpperCase(),c[0]){case"A":c[1]=l[1],c[2]=l[2],c[3]=l[3],c[4]=l[4],c[5]=l[5],c[6]=+l[6]+n,c[7]=+l[7]+i;break;case"V":c[1]=+l[1]+i;break;case"H":c[1]=+l[1]+n;break;case"M":o=+l[1]+n,r=+l[2]+i;default:for(var f=1,d=l.length;f<d;f++)c[f]=+l[f]+(f%2?n:i)}else for(var g=0,h=l.length;g<h;g++)c[g]=l[g];switch(s=s.toUpperCase(),c[0]){case"Z":n=+o,i=+r;break;case"H":n=c[1];break;case"V":i=c[1];break;case"M":o=c[c.length-2],r=c[c.length-1];default:n=c[c.length-2],i=c[c.length-1]}}return t.toString=Zf,t}function Av(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function vl(e,t,n,i){return[e,t,n,i,n,i]}function Pv(e,t,n,i,o,r){var a=.3333333333333333,s=2/3;return[a*e+s*n,a*t+s*i,a*o+s*n,a*r+s*i,o,r]}function Tv(e,t,n,i,o,r,a,s,c,l){var u=Uo*120/180,p=Uo/180*(+o||0),f=[],d,g=jP(function($,C,R){var W=$*ln.cos(R)-C*ln.sin(R),q=$*ln.sin(R)+C*ln.cos(R);return{x:W,y:q}});if(l)B=l[0],P=l[1],E=l[2],A=l[3];else{d=g(e,t,-p),e=d.x,t=d.y,d=g(s,c,-p),s=d.x,c=d.y;var h=(e-s)/2,m=(t-c)/2,w=h*h/(n*n)+m*m/(i*i);w>1&&(w=ln.sqrt(w),n=w*n,i=w*i);var y=n*n,v=i*i,x=(r==a?-1:1)*ln.sqrt(qo((y*v-y*m*m-v*h*h)/(y*m*m+v*h*h))),E=x*n*m/i+(e+s)/2,A=x*-i*h/n+(t+c)/2,B=ln.asin(((t-A)/i).toFixed(9)),P=ln.asin(((c-A)/i).toFixed(9));B=e<E?Uo-B:B,P=s<E?Uo-P:P,B<0&&(B=Uo*2+B),P<0&&(P=Uo*2+P),a&&B>P&&(B=B-Uo*2),!a&&P>B&&(P=P-Uo*2)}var k=P-B;if(qo(k)>u){var H=P,F=s,G=c;P=B+u*(a&&P>B?1:-1),s=E+n*ln.cos(P),c=A+i*ln.sin(P),f=Tv(s,c,n,i,o,0,a,F,G,[P,H,E,A])}k=P-B;var ee=ln.cos(B),ce=ln.sin(B),ie=ln.cos(P),be=ln.sin(P),de=ln.tan(k/4),me=4/3*n*de,Ee=4/3*i*de,U=[e,t],ue=[e+me*ce,t-Ee*ee],K=[s+me*be,c-Ee*ie],J=[s,c];if(ue[0]=2*U[0]-ue[0],ue[1]=2*U[1]-ue[1],l)return[ue,K,J].concat(f);f=[ue,K,J].concat(f).join().split(",");for(var he=[],Re=0,ze=f.length;Re<ze;Re++)he[Re]=Re%2?g(f[Re-1],f[Re],p).y:g(f[Re],f[Re+1],p).x;return he}function XP(e,t,n,i,o,r,a,s){for(var c=[],l=[[],[]],u,p,f,d,g,h,m,w,y=0;y<2;++y){if(y==0?(p=6*e-12*n+6*o,u=-3*e+9*n-9*o+3*a,f=3*n-3*e):(p=6*t-12*i+6*r,u=-3*t+9*i-9*r+3*s,f=3*i-3*t),qo(u)<1e-12){if(qo(p)<1e-12)continue;d=-f/p,0<d&&d<1&&c.push(d);continue}m=p*p-4*f*u,w=ln.sqrt(m),!(m<0)&&(g=(-p+w)/(2*u),0<g&&g<1&&c.push(g),h=(-p-w)/(2*u),0<h&&h<1&&c.push(h))}for(var v=c.length,x=v,E;v--;)d=c[v],E=1-d,l[0][v]=E*E*E*e+3*E*E*d*n+3*E*d*d*o+d*d*d*a,l[1][v]=E*E*E*t+3*E*E*d*i+3*E*d*d*r+d*d*d*s;return l[0][x]=e,l[1][x]=t,l[0][x+1]=a,l[1][x+1]=s,l[0].length=l[1].length=x+2,{x0:Qi(...l[0]),y0:Qi(...l[1]),x1:Ji(...l[0]),y1:Ji(...l[1])}}function kv(e){if(YP(e)||(e=HP(e)),GP(e))return e;for(var t=VP(KP(e)),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=function(f,d,g){var h,m;if(!f)return["C",d.x,d.y,d.x,d.y,d.x,d.y];switch(!(f[0]in{T:1,Q:1})&&(d.qx=d.qy=null),f[0]){case"M":d.X=f[1],d.Y=f[2];break;case"A":f=["C",...Tv(d.x,d.y,...f.slice(1))];break;case"S":g=="C"||g=="S"?(h=d.x*2-d.bx,m=d.y*2-d.by):(h=d.x,m=d.y),f=["C",h,m,...f.slice(1)];break;case"T":g=="Q"||g=="T"?(d.qx=d.x*2-d.qx,d.qy=d.y*2-d.qy):(d.qx=d.x,d.qy=d.y),f=["C",...Pv(d.x,d.y,d.qx,d.qy,f[1],f[2])];break;case"Q":d.qx=f[1],d.qy=f[2],f=["C",...Pv(d.x,d.y,f[1],f[2],f[3],f[4])];break;case"L":f=["C",...vl(d.x,d.y,f[1],f[2])];break;case"H":f=["C",...vl(d.x,d.y,f[1],d.y)];break;case"V":f=["C",...vl(d.x,d.y,d.x,f[1])];break;case"Z":f=["C",...vl(d.x,d.y,d.X,d.Y)];break}return f},o=function(f,d){if(f[d].length>7){f[d].shift();for(var g=f[d];g.length;)r[d]="A",f.splice(d++,0,["C",...g.splice(0,6)]);f.splice(d,1),l=t.length}},r=[],a="",s="",c=0,l=t.length;c<l;c++){t[c]&&(a=t[c][0]),a!="C"&&(r[c]=a,c&&(s=r[c-1])),t[c]=i(t[c],n,s),r[c]!="A"&&a=="C"&&(r[c]="C"),o(t,c);var u=t[c],p=u.length;n.x=u[p-2],n.y=u[p-1],n.bx=xv(u[p-4])||n.x,n.by=xv(u[p-3])||n.y}return t}function Ot(e){return mn(e)&&ti(e,"waypoints")}function at(e){return mn(e)&&ti(e,"labelTarget")}function ZP(e){return mn(e)&&ra(e.parent)}function Ov(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function bo(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function qe(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function bl(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function QP(e){return bo({x:e.x+(e.width||0)/2,y:e.y+(e.height||0)/2})}function JP(e){for(var t=e.waypoints,n=t.reduce(function(l,u,p){var f=t[p-1];if(f){var d=l[l.length-1],g=d&&d.endLength||0,h=nT(f,u);l.push({start:f,end:u,startLength:g,endLength:g+h,length:h})}return l},[]),i=n.reduce(function(l,u){return l+u.length},0),o=i/2,r=0,a=n[r];a.endLength<o;)a=n[++r];var s=(o-a.startLength)/a.length,c={x:a.start.x+(a.end.x-a.start.x)*s,y:a.start.y+(a.end.y-a.start.y)*s};return c}function Je(e){return Ot(e)?JP(e):QP(e)}function On(e,t,n){n=n||0,mn(n)||(n={x:n,y:n});var i=qe(e),o=qe(t),r=i.bottom+n.y<=o.top,a=i.left-n.x>=o.right,s=i.top-n.y>=o.bottom,c=i.right+n.x<=o.left,l=r?"top":s?"bottom":null,u=c?"left":a?"right":null;return u&&l?l+"-"+u:u||l||"intersect"}function Cs(e,t,n){var i=eT(e,t);return i.length===1||i.length===2&&Rs(i[0],i[1])<1?bo(i[0]):i.length>1?(i=qi(i,function(o){var r=Math.floor(o.t2*100)||1;return r=100-r,r=(r<10?"0":"")+r,o.segment2+"#"+r}),bo(i[n?0:i.length-1])):null}function eT(e,t){return Mv(e,t)}function tT(e){e=e.slice();for(var t=0,n,i,o;e[t];)n=e[t],i=e[t-1],o=e[t+1],Rs(n,o)===0||Yf(i,o,n)?e.splice(t,1):t++;return e}function nT(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xl(e,t){return Math.round(e*t)/t}function Dv(e){return Qe(e)?e+"px":e}function iT(e){for(;e.parent;)e=e.parent;return e}function oT(e){e=Y({},{width:"100%",height:"100%"},e);const t=e.container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),Un(n,{position:"relative",overflow:"hidden",width:Dv(e.width),height:Dv(e.height)}),t.appendChild(n),n}function Lv(e,t,n){const i=He("g");dt(i).add(t);const o=n!==void 0?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[o]||null),i}const rT="base",Iv=0,aT=1,sT={shape:["x","y","width","height"],connection:["waypoints"]};function et(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(e||{})}et.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],et.prototype._init=function(e){const t=this._eventBus,n=this._container=oT(e),i=this._svg=He("svg");Ie(i,{width:"100%",height:"100%"}),Cn(i,"tabindex",0),e.autoFocus&&t.on("element.hover",()=>{this.restoreFocus()}),t.on("element.mousedown",500,r=>{this.focus()}),i.addEventListener("focusin",()=>{this._setFocused(!0)}),i.addEventListener("focusout",()=>{this._setFocused(!1)}),i.addEventListener("mouseover",()=>{this._eventBus.fire("canvas.mouseover")}),i.addEventListener("mouseout",()=>{this._eventBus.fire("canvas.mouseout")}),tt(n,i);const o=this._viewport=Lv(i,"viewport");e.deferUpdate&&(this._viewboxChanged=Np(this._viewboxChanged,300)),this._restoreFocus=Np(this._restoreFocus,0),t.on("diagram.init",()=>{t.fire("canvas.init",{svg:i,viewport:o})}),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},et.prototype._destroy=function(){this._restoreFocus.cancel(),this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});const e=this._container.parentNode;e&&e.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport},et.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},et.prototype._clear=function(){this._elementRegistry.getAll().forEach(t=>{const n=yv(t);n==="root"?this.removeRootElement(t):this._removeElement(t,n)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox},et.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},et.prototype.restoreFocus=function(){this._restoreFocus()},et.prototype._restoreFocus=function(){document.activeElement===document.body&&this.focus()},et.prototype.isFocused=function(){return this._focused},et.prototype.getDefaultLayer=function(){return this.getLayer(rT,Iv)},et.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");let n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),typeof t<"u"&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group},et.prototype._getChildIndex=function(e){return ni(this._layers,function(t,n){return n.visible&&e>=n.index&&t++,t},0)},et.prototype._createLayer=function(e,t){typeof t>"u"&&(t=aT);const n=this._getChildIndex(t);return{group:Lv(this._viewport,"layer-"+e,n),index:t,visible:!0}},et.prototype.showLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=this._viewport,i=t.group,o=t.index;if(t.visible)return i;const r=this._getChildIndex(o);return n.insertBefore(i,n.childNodes[r]||null),t.visible=!0,i},et.prototype.hideLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=t.group;return t.visible&&(sn(n),t.visible=!1),n},et.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],sn(t.group))},et.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},et.prototype.findRoot=function(e){const t=this._resolveElements(e);let n;for(const i of t){const o=this._findPlaneForRoot(iT(i));if(!o||n&&o.rootElement!==n)return;n=o.rootElement}return n},et.prototype.getRootElements=function(){return this._planes.map(function(e){return e.rootElement})},et.prototype._findPlaneForRoot=function(e){return It(this._planes,function(t){return t.rootElement===e})},et.prototype._resolveElement=function(e){return typeof e=="string"?this._elementRegistry.get(e):e},et.prototype._resolveElements=function(e){return Ze(e)||(e=[e]),e.map(t=>this._resolveElement(t)).filter(Boolean)},et.prototype.getContainer=function(){return this._container},et.prototype._updateMarker=function(e,t,n){let i;e=this._resolveElement(e),e.markers=e.markers||new Set,i=this._elementRegistry._elements[e.id],i&&(V([i.gfx,i.secondaryGfx],function(o){o&&(n?(e.markers.add(t),dt(o).add(t)):(e.markers.delete(t),dt(o).remove(t)))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},et.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},et.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},et.prototype.hasMarker=function(e,t){return e=this._resolveElement(e),e.markers?e.markers.has(t):!1},et.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},et.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},et.prototype.addRootElement=function(e){const t=this._rootsIdx++;e||(e={id:"__implicitroot_"+t,children:[],isImplicit:!0});const n=e.layer="root-"+t;this._ensureValid("root",e);const i=this.getLayer(n,Iv);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},et.prototype.removeRootElement=function(e){if(e=this._resolveElement(e),!!this._findPlaneForRoot(e))return this._removeRoot(e),this._removeLayer(e.layer),this._planes=this._planes.filter(function(n){return n.rootElement!==e}),this._rootElement===e&&(this._rootElement=null),e},et.prototype.setRootElement=function(e){if(e===this._rootElement)return e;let t;if(!e)throw new Error("rootElement required");return t=this._findPlaneForRoot(e),t||(e=this.addRootElement(e)),this._setRoot(e),e},et.prototype._removeRoot=function(e){const t=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:e}),n.fire("root.removed",{element:e}),t.remove(e)},et.prototype._addRoot=function(e,t){const n=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:e}),n.add(e,t),i.fire("root.added",{element:e,gfx:t})},et.prototype._setRoot=function(e,t){const n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),e&&(t||(t=this._findPlaneForRoot(e).layer),this._elementRegistry.updateGraphics(e,this._svg,!0),this.showLayer(e.layer)),this._rootElement=e,this._eventBus.fire("root.set",{element:e})},et.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element <"+t.id+"> already exists");const n=sT[e];if(!Io(n,function(o){return typeof t[o]<"u"}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},et.prototype._setParent=function(e,t,n){on(t.children,e,n),e.parent=t},et.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();const o=this._eventBus,r=this._graphicsFactory;this._ensureValid(e,t),o.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);const a=r.create(e,t,i);return this._elementRegistry.add(t,a),r.update(e,t,a),o.fire(e+".added",{element:t,gfx:a}),t},et.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},et.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},et.prototype._removeElement=function(e,t){const n=this._elementRegistry,i=this._graphicsFactory,o=this._eventBus;if(e=n.get(e.id||e),!!e)return o.fire(t+".remove",{element:e}),i.remove(e),tn(e.parent&&e.parent.children,e),e.parent=null,o.fire(t+".removed",{element:e}),n.remove(e),e},et.prototype.removeShape=function(e){return this._removeElement(e,"shape")},et.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},et.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},et.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},et.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},et.prototype.viewbox=function(e){if(e===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);const t=this._viewport,n=this.getSize();let i,o,r,a,s,c,l;if(e)this._changeViewbox(function(){s=Math.min(n.width/e.width,n.height/e.height);const u=this._svg.createSVGMatrix().scale(s).translate(-e.x,-e.y);ws(t,u)});else return r=this._rootElement?this.getActiveLayer():null,i=r&&r.getBBox()||{},a=ws(t),o=a?a.matrix:fP(),s=xl(o.a,1e3),c=xl(-o.e||0,1e3),l=xl(-o.f||0,1e3),e=this._cachedViewbox={x:c?c/s:0,y:l?l/s:0,width:n.width/s,height:n.height/s,scale:s,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:n},e;return e},et.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox(function(){e=Y({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),Bv(t,n)}),{x:n.e,y:n.f}},et.prototype.scrollToElement=function(e,t){let n=100;const i=this._resolveElements(e);if(!i.length)return;const o=this.findRoot(i);if(!o)return;o!==this.getRootElement()&&this.setRootElement(o);const r=i.filter(g=>g!=o);if(!r.length)return;t||(t={}),typeof t=="number"&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};const a=cn(r),s=qe(a),c=this.viewbox(),l=this.zoom();let u,p;c.y+=t.top/l,c.x+=t.left/l,c.width-=(t.right+t.left)/l,c.height-=(t.bottom+t.top)/l;const f=qe(c);if(!(a.width<c.width&&a.height<c.height))u=a.x-c.x,p=a.y-c.y;else{const g=Math.max(0,s.right-f.right),h=Math.min(0,s.left-f.left),m=Math.max(0,s.bottom-f.bottom),w=Math.min(0,s.top-f.top);u=g||h,p=m||w}this.scroll({dx:-u*l,dy:-p*l})},et.prototype.zoom=function(e,t){if(!e)return this.viewbox(e).scale;if(e==="fit-viewport")return this._fitViewport(t);let n,i;return this._changeViewbox(function(){typeof t!="object"&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)}),xl(i.a,1e3)};function Bv(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}et.prototype._fitViewport=function(e){const t=this.viewbox(),n=t.outer,i=t.inner;let o,r;return i.x>=0&&i.y>=0&&i.x+i.width<=n.width&&i.y+i.height<=n.height&&!e?r={x:0,y:0,width:Math.max(i.width+i.x,n.width),height:Math.max(i.height+i.y,n.height)}:(o=Math.min(1,n.width/i.width,n.height/i.height),r={x:i.x+(e?i.width/2-n.width/o/2:0),y:i.y+(e?i.height/2-n.height/o/2:0),width:n.width/o,height:n.height/o}),this.viewbox(r),this.viewbox(!1).scale},et.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,o=n.createSVGMatrix(),r=n.createSVGPoint();let a,s,c,l,u;c=i.getCTM();const p=c.a;return t?(a=Y(r,t),s=a.matrixTransform(c.inverse()),l=o.translate(s.x,s.y).scale(1/p*e).translate(-s.x,-s.y),u=c.multiply(l)):u=o.scale(e),Bv(this._viewport,u),u},et.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},et.prototype.getAbsoluteBBox=function(e){const t=this.viewbox();let n;e.waypoints?n=this.getGraphics(e).getBBox():n=e;const i=n.x*t.scale-t.x*t.scale,o=n.y*t.scale-t.y*t.scale,r=n.width*t.scale,a=n.height*t.scale;return{x:i,y:o,width:r,height:a}},et.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var wa="data-element-id";function mi(e){this._elements={},this._eventBus=e}mi.$inject=["eventBus"],mi.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),Ie(t,wa,i),n&&Ie(n,wa,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},mi.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(Ie(i.gfx,wa,""),i.secondaryGfx&&Ie(i.secondaryGfx,wa,""),delete t[n])},mi.prototype.updateId=function(e,t){this._validateId(t),typeof e=="string"&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),i=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,i)},mi.prototype.updateGraphics=function(e,t,n){var i=e.id||e,o=this._elements[i];return n?o.secondaryGfx=t:o.gfx=t,t&&Ie(t,wa,i),t},mi.prototype.get=function(e){var t;typeof e=="string"?t=e:t=e&&Ie(e,wa);var n=this._elements[t];return n&&n.element},mi.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},mi.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var o=n[i],r=t[o],a=r.element,s=r.gfx;if(e(a,s))return a}},mi.prototype.getAll=function(){return this.filter(function(e){return e})},mi.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach(function(n){var i=t[n],o=i.element,r=i.gfx;return e(o,r)})},mi.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},mi.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")};function cT(e,t,n,i){var o=n.inverse;return Object.defineProperty(e,"remove",{value:function(r){var a=this.indexOf(r);return a!==-1&&(this.splice(a,1),t.unset(r,o,i)),r}}),Object.defineProperty(e,"contains",{value:function(r){return this.indexOf(r)!==-1}}),Object.defineProperty(e,"add",{value:function(r,a){var s=this.indexOf(r);if(typeof a>"u"){if(s!==-1)return;a=this.length}s!==-1&&this.splice(s,1),this.splice(a,0,r),s===-1&&t.set(r,o,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e}function lT(e){return e.__refs_collection===!0}function uT(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)}function Nv(e,t,n){var i=cT(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:i}),i.length&&i.forEach(function(o){e.set(o,t.inverse,n)})}function pT(e,t,n){var i=t.inverse,o=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return o},set:function(r){if(r!==o){var a=o;o=null,a&&e.unset(a,i,n),o=r,e.set(o,i,n)}}})}function _i(e,t){if(!(this instanceof _i))return new _i(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}_i.prototype.bind=function(e,t){if(typeof t=="string"){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?Nv(this,t,e):pT(this,t,e)},_i.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return lT(n)||Nv(this,t,e),n},_i.prototype.ensureBound=function(e,t){uT(e,t)||this.bind(e,t)},_i.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},_i.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Qf=new _i({name:"children",enumerable:!0,collection:!0},{name:"parent"}),$v=new _i({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Fv=new _i({name:"attachers",collection:!0},{name:"host"}),jv=new _i({name:"outgoing",collection:!0},{name:"source"}),Hv=new _i({name:"incoming",collection:!0},{name:"target"});function _a(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),Qf.bind(this,"parent"),$v.bind(this,"labels"),jv.bind(this,"outgoing"),Hv.bind(this,"incoming")}function Ms(){_a.call(this),Qf.bind(this,"children"),Fv.bind(this,"host"),Fv.bind(this,"attachers")}Ne(Ms,_a);function zv(){_a.call(this),Qf.bind(this,"children")}Ne(zv,Ms);function Gv(){Ms.call(this),$v.bind(this,"labelTarget")}Ne(Gv,Ms);function Vv(){_a.call(this),jv.bind(this,"source"),Hv.bind(this,"target")}Ne(Vv,_a);var fT={connection:Vv,shape:Ms,label:Gv,root:zv};function dT(e,t){var n=fT[e];if(!n)throw new Error("unknown type: <"+e+">");return Y(new n,t)}function hT(e){return e instanceof _a}function xo(){this._uid=12}xo.prototype.createRoot=function(e){return this.create("root",e)},xo.prototype.createLabel=function(e){return this.create("label",e)},xo.prototype.createShape=function(e){return this.create("shape",e)},xo.prototype.createConnection=function(e){return this.create("connection",e)},xo.prototype.create=function(e,t){return t=Y({},t||{}),t.id||(t.id=e+"_"+this._uid++),dT(e,t)};var wl="__fn",Wv=1e3,gT=Array.prototype.slice;function oi(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}oi.prototype.on=function(e,t,n,i){if(e=Ze(e)?e:[e],_n(t)&&(i=n,n=t,t=Wv),!Qe(t))throw new Error("priority must be a number");var o=n;i&&(o=Kn(n,i),o[wl]=n[wl]||n);var r=this;e.forEach(function(a){r._addListener(a,{priority:t,callback:o,next:null})})},oi.prototype.once=function(e,t,n,i){var o=this;if(_n(t)&&(i=n,n=t,t=Wv),!Qe(t))throw new Error("priority must be a number");function r(){r.__isTomb=!0;var a=n.apply(i,arguments);return o.off(e,r),a}r[wl]=n,this.on(e,t,r)},oi.prototype.off=function(e,t){e=Ze(e)?e:[e];var n=this;e.forEach(function(i){n._removeListener(i,t)})},oi.prototype.createEvent=function(e){var t=new As;return t.init(e),t},oi.prototype.fire=function(e,t){var n,i,o,r;if(r=gT.call(arguments),typeof e=="object"&&(t=e,e=t.type),!e)throw new Error("no event type specified");if(i=this._listeners[e],!!i){t instanceof As?n=t:n=this.createEvent(t),r[0]=n;var a=n.type;e!==a&&(n.type=e);try{o=this._invokeListeners(n,r,i)}finally{e!==a&&(n.type=a)}return o===void 0&&n.defaultPrevented&&(o=!1),o}},oi.prototype.handleError=function(e){return this.fire("error",{error:e})===!1},oi.prototype._destroy=function(){this._listeners={}},oi.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},oi.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=mT(n.callback,t),i!==void 0&&(e.returnValue=i,e.stopPropagation()),i===!1&&e.preventDefault()}catch(o){if(!this.handleError(o))throw console.error("unhandled error in event listener",o),o}return i},oi.prototype._addListener=function(e,t){var n=this._getListeners(e),i;if(!n){this._setListeners(e,t);return}for(;n;){if(n.priority<t.priority){t.next=n,i?i.next=t:this._setListeners(e,t);return}i=n,n=n.next}i.next=t},oi.prototype._getListeners=function(e){return this._listeners[e]},oi.prototype._setListeners=function(e,t){this._listeners[e]=t},oi.prototype._removeListener=function(e,t){var n=this._getListeners(e),i,o,r;if(!t){this._setListeners(e,null);return}for(;n;)i=n.next,r=n.callback,(r===t||r[wl]===t)&&(o?o.next=i:this._setListeners(e,i)),o=n,n=i};function As(){}As.prototype.stopPropagation=function(){this.cancelBubble=!0},As.prototype.preventDefault=function(){this.defaultPrevented=!0},As.prototype.init=function(e){Y(this,e||{})};function mT(e,t){return e.apply(null,t)}function Ko(e){return e.childNodes[0]}function yT(e){return e.parentNode.childNodes[1]}function _l(e,t,n,i,o){var r=xs();r.setTranslate(t,n);var a=xs();a.setRotate(i||0,0,0);var s=xs();s.setScale(1,1),ws(e,[r,a,s])}function Dn(e,t,n){var i=xs();i.setTranslate(t,n),ws(e,i)}function Uv(e,t){var n=xs();n.setRotate(t,0,0),ws(e,n)}function yi(e,t){this._eventBus=e,this._elementRegistry=t}yi.$inject=["eventBus","elementRegistry"],yi.prototype._getChildrenContainer=function(e){var t=this._elementRegistry.getGraphics(e),n;return e.parent?(n=yT(t),n||(n=He("g"),dt(n).add("djs-children"),tt(t.parentNode,n))):n=t,n},yi.prototype._clear=function(e){var t=Ko(e);return fl(t),t},yi.prototype._createContainer=function(e,t,n,i){var o=He("g");dt(o).add("djs-group"),typeof n<"u"?vT(o,t,t.childNodes[n]):tt(t,o);var r=He("g");dt(r).add("djs-element"),dt(r).add("djs-"+e),i&&dt(r).add("djs-frame"),tt(o,r);var a=He("g");return dt(a).add("djs-visual"),tt(r,a),r},yi.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);return this._createContainer(e,i,n,vv(t))},yi.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry,i;i=ni(e,function(o,r){return r.parent&&(o[r.parent.id]=r.parent),o},{}),V(i,function(o){var r=o.children;if(r){var a=t._getChildrenContainer(o),s=a.firstChild;V(r,function(c){var l=n.getGraphics(c).parentNode;l===s?s=s.nextSibling:a.insertBefore(l,s)})}})},yi.prototype.drawShape=function(e,t,n={}){var i=this._eventBus;return i.fire("render.shape",{gfx:e,element:t,attrs:n})},yi.prototype.getShapePath=function(e){var t=this._eventBus;return t.fire("render.getShapePath",e)},yi.prototype.drawConnection=function(e,t,n={}){var i=this._eventBus;return i.fire("render.connection",{gfx:e,element:t,attrs:n})},yi.prototype.getConnectionPath=function(e){var t=this._eventBus;return t.fire("render.getConnectionPath",e)},yi.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if(e==="shape")this.drawShape(i,t),Dn(n,t.x,t.y);else if(e==="connection")this.drawConnection(i,t);else throw new Error("unknown type: "+e);t.hidden?Ie(n,"display","none"):Ie(n,"display","block")}},yi.prototype.remove=function(e){var t=this._elementRegistry.getGraphics(e);sn(t.parentNode)};function vT(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}const bT={__depends__:[OP],__init__:["canvas"],canvas:["type",et],elementRegistry:["type",mi],elementFactory:["type",xo],eventBus:["type",oi],graphicsFactory:["type",yi]};function xT(e){var t=new mv(e);return t.init(),t}function wT(e){e=e||{};var t={config:["value",e]},n=[t,bT].concat(e.modules||[]);return xT(n)}function Xo(e,t){this._injector=t||wT(e),this.get("eventBus").fire("diagram.init")}Xo.prototype.get=function(e,t){return this._injector.get(e,t)},Xo.prototype.invoke=function(e,t,n){return this._injector.invoke(e,t,n)},Xo.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},Xo.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};function zn(e){return e?"<"+e.$type+(e.id?' id="'+e.id:"")+'" />':"<null>"}function Xn(e,t){return e.$instanceOf(t)}function _T(e){return It(e.rootElements,function(t){return Xn(t,"bpmn:Process")||Xn(t,"bpmn:Collaboration")})}function ET(e){var t={},n=[],i={};function o(K,J){return function(he){K(he,J)}}function r(K){t[K.id]=K}function a(K){return t[K.id]}function s(K,J){var he=K.gfx;if(he)throw new Error(`already rendered ${zn(K)}`);return e.element(K,i[K.id],J)}function c(K,J){return e.root(K,i[K.id],J)}function l(K,J){try{var he=i[K.id]&&s(K,J);return r(K),he}catch(Re){u(Re.message,{element:K,error:Re}),console.error(`failed to import ${zn(K)}`,Re)}}function u(K,J){e.error(K,J)}var p=this.registerDi=function(J){var he=J.bpmnElement;he?i[he.id]?u(`multiple DI elements defined for ${zn(he)}`,{element:he}):i[he.id]=J:u(`no bpmnElement referenced in ${zn(J)}`,{element:J})};function f(K){d(K.plane)}function d(K){p(K),V(K.planeElement,g)}function g(K){p(K)}this.handleDefinitions=function(J,he){var Re=J.diagrams;if(he&&Re.indexOf(he)===-1)throw new Error("diagram not part of <bpmn:Definitions />");if(!he&&Re&&Re.length&&(he=Re[0]),!he)throw new Error("no diagram to display");i={},f(he);var ze=he.plane;if(!ze)throw new Error(`no plane for ${zn(he)}`);var $=ze.bpmnElement;if(!$)if($=_T(J),$)u(`correcting missing bpmnElement on ${zn(ze)} to ${zn($)}`),ze.bpmnElement=$,p(ze);else throw new Error("no process or collaboration to display");var C=c($,ze);if(Xn($,"bpmn:Process")||Xn($,"bpmn:SubProcess"))m($,C);else if(Xn($,"bpmn:Collaboration"))U($,C),w(J.rootElements,C);else throw new Error(`unsupported bpmnElement for ${zn(ze)}: ${zn($)}`);h(n)};var h=this.handleDeferred=function(){for(var J;n.length;)J=n.shift(),J()};function m(K,J){de(K,J),k(K.ioSpecification,J),P(K.artifacts,J),r(K)}function w(K,J){var he=ct(K,function(Re){return!a(Re)&&Xn(Re,"bpmn:Process")&&Re.laneSets});he.forEach(o(m,J))}function y(K,J){l(K,J)}function v(K,J){V(K,o(y,J))}function x(K,J){l(K,J)}function E(K,J){l(K,J)}function A(K,J){l(K,J)}function B(K,J){l(K,J)}function P(K,J){V(K,function(he){Xn(he,"bpmn:Association")?n.push(function(){B(he,J)}):B(he,J)})}function k(K,J){K&&(V(K.dataInputs,o(E,J)),V(K.dataOutputs,o(A,J)))}var H=this.handleSubProcess=function(J,he){de(J,he),P(J.artifacts,he)};function F(K,J){var he=l(K,J);Xn(K,"bpmn:SubProcess")&&H(K,he||J),Xn(K,"bpmn:Activity")&&k(K.ioSpecification,J),n.push(function(){V(K.dataInputAssociations,o(x,J)),V(K.dataOutputAssociations,o(x,J))})}function G(K,J){l(K,J)}function ee(K,J){l(K,J)}function ce(K,J){n.push(function(){var he=l(K,J);K.childLaneSet&&ie(K.childLaneSet,he||J),ue(K)})}function ie(K,J){V(K.lanes,o(ce,J))}function be(K,J){V(K,o(ie,J))}function de(K,J){me(K.flowElements,J),K.laneSets&&be(K.laneSets,J)}function me(K,J){V(K,function(he){Xn(he,"bpmn:SequenceFlow")?n.push(function(){G(he,J)}):Xn(he,"bpmn:BoundaryEvent")?n.unshift(function(){F(he,J)}):Xn(he,"bpmn:FlowNode")?F(he,J):Xn(he,"bpmn:DataObject")||(Xn(he,"bpmn:DataStoreReference")||Xn(he,"bpmn:DataObjectReference")?ee(he,J):u(`unrecognized flowElement ${zn(he)} in context ${zn(J&&J.businessObject)}`,{element:he,context:J}))})}function Ee(K,J){var he=l(K,J),Re=K.processRef;Re&&m(Re,he||J)}function U(K,J){V(K.participants,o(Ee,J)),n.push(function(){v(K.messageFlows,J)}),P(K.artifacts,J)}function ue(K){V(K.flowNodeRef,function(J){var he=J.get("lanes");he&&he.push(K)})}}function ST(e,t,n){var i,o,r,a,s=[];function c(l,u){var p={root:function(h,m){return i.add(h,m)},element:function(h,m,w){return i.add(h,m,w)},error:function(h,m){s.push({message:h,context:m})}},f=new ET(p);u=u||l.diagrams&&l.diagrams[0];var d=RT(l,u);if(!d)throw new Error("no diagram to display");V(d,function(h){f.handleDefinitions(l,h)});var g=u.plane.bpmnElement.id;r.setRootElement(r.findRoot(g+"_plane")||r.findRoot(g))}return new Promise(function(l,u){try{return i=e.get("bpmnImporter"),o=e.get("eventBus"),r=e.get("canvas"),o.fire("import.render.start",{definitions:t}),c(t,n),o.fire("import.render.complete",{error:a,warnings:s}),l({warnings:s})}catch(p){return p.warnings=s,u(p)}})}function RT(e,t){if(!(!t||!t.plane)){var n=t.plane.bpmnElement,i=n;!M(n,"bpmn:Process")&&!M(n,"bpmn:Collaboration")&&(i=CT(n));var o;M(i,"bpmn:Collaboration")?o=i:o=It(e.rootElements,function(l){if(M(l,"bpmn:Collaboration"))return It(l.participants,function(u){return u.processRef===i})});var r=[i];o&&(r=Fn(o.participants,function(l){return l.processRef}),r.push(o));var a=qv(r),s=[t],c=[n];return V(e.diagrams,function(l){if(l.plane){var u=l.plane.bpmnElement;a.indexOf(u)!==-1&&c.indexOf(u)===-1&&(s.push(l),c.push(u))}}),s}}function qv(e){var t=[];return V(e,function(n){n&&(t.push(n),t=t.concat(qv(n.flowElements)))}),t}function CT(e){for(var t=e;t;){if(M(t,"bpmn:Process"))return t;t=t.$parent}}var MT='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.02 5.57" width="53" height="21"><path fill="currentColor" d="M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"/><path fill="currentColor" d="M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"/></svg>',Yv=MT,Kv={verticalAlign:"middle"},Xv={color:"#404040"},AT={zIndex:"1001",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"},PT={width:"100%",height:"100%",background:"rgba(40,40,40,0.2)"},TT={position:"absolute",left:"50%",top:"40%",transform:"translate(-50%)",width:"260px",padding:"10px",background:"white",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",fontFamily:"Helvetica, Arial, sans-serif",fontSize:"14px",display:"flex",lineHeight:"1.3"},kT='<div class="bjs-powered-by-lightbox"><div class="backdrop"></div><div class="notice"><a href="https://bpmn.io" target="_blank" rel="noopener" class="link">'+Yv+'</a><span>Web-based tooling for BPMN, DMN and forms powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.</span></div></div>',eo;function OT(){eo=jt(kT),Un(eo,AT),Un(Ct("svg",eo),Kv),Un(Ct(".backdrop",eo),PT),Un(Ct(".notice",eo),TT),Un(Ct(".link",eo),Xv,{margin:"15px 20px 15px 10px",alignSelf:"center"})}function DT(){eo||(OT(),ii.bind(eo,".backdrop","click",function(e){document.body.removeChild(eo)})),document.body.appendChild(eo)}const El=5,Zv="djs-outline-hidden";function Wt(e){e=Y({},IT,e),this._moddle=this._createModdle(e),this._container=this._createContainer(e),this._init(this._container,this._moddle,e),NT(this._container)}Ne(Wt,Xo),Wt.prototype.importXML=async function(t,n){const i=this;function o(a){return i.get("eventBus").createEvent(a)}let r=[];try{t=this._emit("import.parse.start",{xml:t})||t;let a;try{a=await this._moddle.fromXML(t,"bpmn:Definitions")}catch(f){throw this._emit("import.parse.complete",{error:f}),f}let s=a.rootElement;const c=a.references,l=a.warnings,u=a.elementsById;r=r.concat(l),s=this._emit("import.parse.complete",o({error:null,definitions:s,elementsById:u,references:c,warnings:r}))||s;const p=await this.importDefinitions(s,n);return r=r.concat(p.warnings),this._emit("import.done",{error:null,warnings:r}),{warnings:r}}catch(a){let s=a;throw r=r.concat(s.warnings||[]),Sl(s,r),s=LT(s),this._emit("import.done",{error:s,warnings:s.warnings}),s}},Wt.prototype.importDefinitions=async function(t,n){return this._setDefinitions(t),{warnings:(await this.open(n)).warnings}},Wt.prototype.open=async function(t){const n=this._definitions;let i=t;if(!n){const r=new Error("no XML imported");throw Sl(r,[]),r}if(typeof t=="string"&&(i=BT(n,t),!i)){const r=new Error("BPMNDiagram <"+t+"> not found");throw Sl(r,[]),r}try{this.clear()}catch(r){throw Sl(r,[]),r}const{warnings:o}=await ST(this,n,i);return{warnings:o}},Wt.prototype.saveXML=async function(t){t=t||{};let n=this._definitions,i,o;try{if(!n)throw new Error("no definitions loaded");n=this._emit("saveXML.start",{definitions:n})||n,o=(await this._moddle.toXML(n,t)).xml,o=this._emit("saveXML.serialized",{xml:o})||o}catch(a){i=a}const r=i?{error:i}:{xml:o};if(this._emit("saveXML.done",r),i)throw i;return r},Wt.prototype.saveSVG=async function(){this._emit("saveSVG.start");let t,n;try{const i=this.get("canvas"),o=i.getActiveLayer(),r=Ct(":scope > defs",i._svg),a=gv(o),s=r?"<defs>"+gv(r)+"</defs>":"",c=i.getContainer();At(c).add(Zv);let l;try{l=o.getBBox()}finally{At(c).remove(Zv)}const u=l.x-El,p=l.y-El,f=l.width+El*2,d=l.height+El*2;t=`<?xml version="1.0" encoding="utf-8"?>
6
+ `),this},this.appendIndent=function(){return t&&e.write(n.join(" ")),this},this.indent=function(){return n.push(""),this},this.unindent=function(){return n.pop(),this}}function zR(e){e=Y({format:!1,preamble:!0},e||{});function t(n,i){var o=i||new jR,r=new HR(o,e.format);e.preamble&&r.append(CR);var a=new Gt,s=n.$model;if(a.getNamespaces().mapDefaultPrefixes(GR(s)),a.build(n).serializeTo(r),!i)return o.value}return{toXML:t}}function GR(e){const t=e.config&&e.config.nsMap||{},n={};for(const i in Zp)n[i]=Zp[i];for(const i in t){const o=t[i];n[o]=i}for(const i of e.getPackages())n[i.prefix]=i.uri;return n}function jc(e,t){xi.call(this,e,t)}jc.prototype=Object.create(xi.prototype),jc.prototype.fromXML=function(e,t,n){ei(t)||(n=t,t="bpmn:Definitions");var i=new tf(Y({model:this,lax:!0},n)),o=i.handler(t);return i.fromXML(e,o)},jc.prototype.toXML=function(e,t){var n=new zR(t);return new Promise(function(i,o){try{var r=n.toXML(e);return i({xml:r})}catch(a){return o(a)}})};var VR="BPMN20",WR="http://www.omg.org/spec/BPMN/20100524/MODEL",UR="bpmn",qR=[],YR=[{name:"Interface",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"operations",type:"Operation",isMany:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"Operation",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"inMessageRef",type:"Message",isReference:!0},{name:"outMessageRef",type:"Message",isReference:!0},{name:"errorRef",type:"Error",isMany:!0,isReference:!0},{name:"implementationRef",isAttr:!0,type:"String"}]},{name:"EndPoint",superClass:["RootElement"]},{name:"Auditing",superClass:["BaseElement"]},{name:"GlobalTask",superClass:["CallableElement"],properties:[{name:"resources",type:"ResourceRole",isMany:!0}]},{name:"Monitoring",superClass:["BaseElement"]},{name:"Performer",superClass:["ResourceRole"]},{name:"Process",superClass:["FlowElementsContainer","CallableElement"],properties:[{name:"processType",type:"ProcessType",isAttr:!0},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"properties",type:"Property",isMany:!0},{name:"laneSets",isMany:!0,replaces:"FlowElementsContainer#laneSets",type:"LaneSet"},{name:"flowElements",isMany:!0,replaces:"FlowElementsContainer#flowElements",type:"FlowElement"},{name:"artifacts",type:"Artifact",isMany:!0},{name:"resources",type:"ResourceRole",isMany:!0},{name:"correlationSubscriptions",type:"CorrelationSubscription",isMany:!0},{name:"supports",type:"Process",isMany:!0,isReference:!0},{name:"definitionalCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"isExecutable",isAttr:!0,type:"Boolean"}]},{name:"LaneSet",superClass:["BaseElement"],properties:[{name:"lanes",type:"Lane",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Lane",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"partitionElementRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"partitionElement",type:"BaseElement"},{name:"flowNodeRef",type:"FlowNode",isMany:!0,isReference:!0},{name:"childLaneSet",type:"LaneSet",xml:{serialize:"xsi:type"}}]},{name:"GlobalManualTask",superClass:["GlobalTask"]},{name:"ManualTask",superClass:["Task"]},{name:"UserTask",superClass:["Task"],properties:[{name:"renderings",type:"Rendering",isMany:!0},{name:"implementation",isAttr:!0,type:"String"}]},{name:"Rendering",superClass:["BaseElement"]},{name:"HumanPerformer",superClass:["Performer"]},{name:"PotentialOwner",superClass:["HumanPerformer"]},{name:"GlobalUserTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"renderings",type:"Rendering",isMany:!0}]},{name:"Gateway",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"gatewayDirection",type:"GatewayDirection",default:"Unspecified",isAttr:!0}]},{name:"EventBasedGateway",superClass:["Gateway"],properties:[{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"eventGatewayType",type:"EventBasedGatewayType",isAttr:!0,default:"Exclusive"}]},{name:"ComplexGateway",superClass:["Gateway"],properties:[{name:"activationCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ExclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"InclusiveGateway",superClass:["Gateway"],properties:[{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0}]},{name:"ParallelGateway",superClass:["Gateway"]},{name:"RootElement",isAbstract:!0,superClass:["BaseElement"]},{name:"Relationship",superClass:["BaseElement"],properties:[{name:"type",isAttr:!0,type:"String"},{name:"direction",type:"RelationshipDirection",isAttr:!0},{name:"source",isMany:!0,isReference:!0,type:"Element"},{name:"target",isMany:!0,isReference:!0,type:"Element"}]},{name:"BaseElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,type:"String",isId:!0},{name:"documentation",type:"Documentation",isMany:!0},{name:"extensionDefinitions",type:"ExtensionDefinition",isMany:!0,isReference:!0},{name:"extensionElements",type:"ExtensionElements"}]},{name:"Extension",properties:[{name:"mustUnderstand",default:!1,isAttr:!0,type:"Boolean"},{name:"definition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"extensionAttributeDefinitions",type:"ExtensionAttributeDefinition",isMany:!0}]},{name:"ExtensionAttributeDefinition",properties:[{name:"name",isAttr:!0,type:"String"},{name:"type",isAttr:!0,type:"String"},{name:"isReference",default:!1,isAttr:!0,type:"Boolean"},{name:"extensionDefinition",type:"ExtensionDefinition",isAttr:!0,isReference:!0}]},{name:"ExtensionElements",properties:[{name:"valueRef",isAttr:!0,isReference:!0,type:"Element"},{name:"values",type:"Element",isMany:!0},{name:"extensionAttributeDefinition",type:"ExtensionAttributeDefinition",isAttr:!0,isReference:!0}]},{name:"Documentation",superClass:["BaseElement"],properties:[{name:"text",type:"String",isBody:!0},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Event",isAbstract:!0,superClass:["FlowNode","InteractionNode"],properties:[{name:"properties",type:"Property",isMany:!0}]},{name:"IntermediateCatchEvent",superClass:["CatchEvent"]},{name:"IntermediateThrowEvent",superClass:["ThrowEvent"]},{name:"EndEvent",superClass:["ThrowEvent"]},{name:"StartEvent",superClass:["CatchEvent"],properties:[{name:"isInterrupting",default:!0,isAttr:!0,type:"Boolean"}]},{name:"ThrowEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"inputSet",type:"InputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"CatchEvent",isAbstract:!0,superClass:["Event"],properties:[{name:"parallelMultiple",isAttr:!0,type:"Boolean",default:!1},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"outputSet",type:"OutputSet"},{name:"eventDefinitions",type:"EventDefinition",isMany:!0},{name:"eventDefinitionRef",type:"EventDefinition",isMany:!0,isReference:!0}]},{name:"BoundaryEvent",superClass:["CatchEvent"],properties:[{name:"cancelActivity",default:!0,isAttr:!0,type:"Boolean"},{name:"attachedToRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"EventDefinition",isAbstract:!0,superClass:["RootElement"]},{name:"CancelEventDefinition",superClass:["EventDefinition"]},{name:"ErrorEventDefinition",superClass:["EventDefinition"],properties:[{name:"errorRef",type:"Error",isAttr:!0,isReference:!0}]},{name:"TerminateEventDefinition",superClass:["EventDefinition"]},{name:"EscalationEventDefinition",superClass:["EventDefinition"],properties:[{name:"escalationRef",type:"Escalation",isAttr:!0,isReference:!0}]},{name:"Escalation",properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"escalationCode",isAttr:!0,type:"String"}],superClass:["RootElement"]},{name:"CompensateEventDefinition",superClass:["EventDefinition"],properties:[{name:"waitForCompletion",isAttr:!0,type:"Boolean",default:!0},{name:"activityRef",type:"Activity",isAttr:!0,isReference:!0}]},{name:"TimerEventDefinition",superClass:["EventDefinition"],properties:[{name:"timeDate",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeCycle",type:"Expression",xml:{serialize:"xsi:type"}},{name:"timeDuration",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"LinkEventDefinition",superClass:["EventDefinition"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"target",type:"LinkEventDefinition",isReference:!0},{name:"source",type:"LinkEventDefinition",isMany:!0,isReference:!0}]},{name:"MessageEventDefinition",superClass:["EventDefinition"],properties:[{name:"messageRef",type:"Message",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isReference:!0}]},{name:"ConditionalEventDefinition",superClass:["EventDefinition"],properties:[{name:"condition",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"SignalEventDefinition",superClass:["EventDefinition"],properties:[{name:"signalRef",type:"Signal",isAttr:!0,isReference:!0}]},{name:"Signal",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ImplicitThrowEvent",superClass:["ThrowEvent"]},{name:"DataState",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"ItemAwareElement",superClass:["BaseElement"],properties:[{name:"itemSubjectRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"dataState",type:"DataState"}]},{name:"DataAssociation",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"ItemAwareElement",isMany:!0,isReference:!0},{name:"targetRef",type:"ItemAwareElement",isReference:!0},{name:"transformation",type:"FormalExpression",xml:{serialize:"property"}},{name:"assignment",type:"Assignment",isMany:!0}]},{name:"DataInput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"inputSetRef",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithOptional",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"inputSetWithWhileExecuting",type:"InputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"DataOutput",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"outputSetRef",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithOptional",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0},{name:"outputSetWithWhileExecuting",type:"OutputSet",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"InputSet",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"dataInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"optionalInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"whileExecutingInputRefs",type:"DataInput",isMany:!0,isReference:!0},{name:"outputSetRefs",type:"OutputSet",isMany:!0,isReference:!0}]},{name:"OutputSet",superClass:["BaseElement"],properties:[{name:"dataOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"inputSetRefs",type:"InputSet",isMany:!0,isReference:!0},{name:"optionalOutputRefs",type:"DataOutput",isMany:!0,isReference:!0},{name:"whileExecutingOutputRefs",type:"DataOutput",isMany:!0,isReference:!0}]},{name:"Property",superClass:["ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"}]},{name:"DataInputAssociation",superClass:["DataAssociation"]},{name:"DataOutputAssociation",superClass:["DataAssociation"]},{name:"InputOutputSpecification",superClass:["BaseElement"],properties:[{name:"dataInputs",type:"DataInput",isMany:!0},{name:"dataOutputs",type:"DataOutput",isMany:!0},{name:"inputSets",type:"InputSet",isMany:!0},{name:"outputSets",type:"OutputSet",isMany:!0}]},{name:"DataObject",superClass:["FlowElement","ItemAwareElement"],properties:[{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"}]},{name:"InputOutputBinding",properties:[{name:"inputDataRef",type:"InputSet",isAttr:!0,isReference:!0},{name:"outputDataRef",type:"OutputSet",isAttr:!0,isReference:!0},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"Assignment",superClass:["BaseElement"],properties:[{name:"from",type:"Expression",xml:{serialize:"xsi:type"}},{name:"to",type:"Expression",xml:{serialize:"xsi:type"}}]},{name:"DataStore",superClass:["RootElement","ItemAwareElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"capacity",isAttr:!0,type:"Integer"},{name:"isUnlimited",default:!0,isAttr:!0,type:"Boolean"}]},{name:"DataStoreReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataStoreRef",type:"DataStore",isAttr:!0,isReference:!0}]},{name:"DataObjectReference",superClass:["ItemAwareElement","FlowElement"],properties:[{name:"dataObjectRef",type:"DataObject",isAttr:!0,isReference:!0}]},{name:"ConversationLink",superClass:["BaseElement"],properties:[{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"ConversationAssociation",superClass:["BaseElement"],properties:[{name:"innerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0},{name:"outerConversationNodeRef",type:"ConversationNode",isAttr:!0,isReference:!0}]},{name:"CallConversation",superClass:["ConversationNode"],properties:[{name:"calledCollaborationRef",type:"Collaboration",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"Conversation",superClass:["ConversationNode"]},{name:"SubConversation",superClass:["ConversationNode"],properties:[{name:"conversationNodes",type:"ConversationNode",isMany:!0}]},{name:"ConversationNode",isAbstract:!0,superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"messageFlowRefs",type:"MessageFlow",isMany:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0}]},{name:"GlobalConversation",superClass:["Collaboration"]},{name:"PartnerEntity",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"PartnerRole",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"participantRef",type:"Participant",isMany:!0,isReference:!0}]},{name:"CorrelationProperty",superClass:["RootElement"],properties:[{name:"correlationPropertyRetrievalExpression",type:"CorrelationPropertyRetrievalExpression",isMany:!0},{name:"name",isAttr:!0,type:"String"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Error",superClass:["RootElement"],properties:[{name:"structureRef",type:"ItemDefinition",isAttr:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"},{name:"errorCode",isAttr:!0,type:"String"}]},{name:"CorrelationKey",superClass:["BaseElement"],properties:[{name:"correlationPropertyRef",type:"CorrelationProperty",isMany:!0,isReference:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Expression",superClass:["BaseElement"],isAbstract:!1,properties:[{name:"body",isBody:!0,type:"String"}]},{name:"FormalExpression",superClass:["Expression"],properties:[{name:"language",isAttr:!0,type:"String"},{name:"evaluatesToTypeRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"Message",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"itemRef",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"ItemDefinition",superClass:["RootElement"],properties:[{name:"itemKind",type:"ItemKind",isAttr:!0},{name:"structureRef",isAttr:!0,type:"String"},{name:"isCollection",default:!1,isAttr:!0,type:"Boolean"},{name:"import",type:"Import",isAttr:!0,isReference:!0}]},{name:"FlowElement",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"auditing",type:"Auditing"},{name:"monitoring",type:"Monitoring"},{name:"categoryValueRef",type:"CategoryValue",isMany:!0,isReference:!0}]},{name:"SequenceFlow",superClass:["FlowElement"],properties:[{name:"isImmediate",isAttr:!0,type:"Boolean"},{name:"conditionExpression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"sourceRef",type:"FlowNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"FlowNode",isAttr:!0,isReference:!0}]},{name:"FlowElementsContainer",isAbstract:!0,superClass:["BaseElement"],properties:[{name:"laneSets",type:"LaneSet",isMany:!0},{name:"flowElements",type:"FlowElement",isMany:!0}]},{name:"CallableElement",isAbstract:!0,superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"supportedInterfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"ioBinding",type:"InputOutputBinding",isMany:!0,xml:{serialize:"property"}}]},{name:"FlowNode",isAbstract:!0,superClass:["FlowElement"],properties:[{name:"incoming",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"outgoing",type:"SequenceFlow",isMany:!0,isReference:!0},{name:"lanes",type:"Lane",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"CorrelationPropertyRetrievalExpression",superClass:["BaseElement"],properties:[{name:"messagePath",type:"FormalExpression"},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"CorrelationPropertyBinding",superClass:["BaseElement"],properties:[{name:"dataPath",type:"FormalExpression"},{name:"correlationPropertyRef",type:"CorrelationProperty",isAttr:!0,isReference:!0}]},{name:"Resource",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"resourceParameters",type:"ResourceParameter",isMany:!0}]},{name:"ResourceParameter",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isRequired",isAttr:!0,type:"Boolean"},{name:"type",type:"ItemDefinition",isAttr:!0,isReference:!0}]},{name:"CorrelationSubscription",superClass:["BaseElement"],properties:[{name:"correlationKeyRef",type:"CorrelationKey",isAttr:!0,isReference:!0},{name:"correlationPropertyBinding",type:"CorrelationPropertyBinding",isMany:!0}]},{name:"MessageFlow",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"sourceRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"targetRef",type:"InteractionNode",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"MessageFlowAssociation",superClass:["BaseElement"],properties:[{name:"innerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0},{name:"outerMessageFlowRef",type:"MessageFlow",isAttr:!0,isReference:!0}]},{name:"InteractionNode",isAbstract:!0,properties:[{name:"incomingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0},{name:"outgoingConversationLinks",type:"ConversationLink",isMany:!0,isVirtual:!0,isReference:!0}]},{name:"Participant",superClass:["InteractionNode","BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"interfaceRef",type:"Interface",isMany:!0,isReference:!0},{name:"participantMultiplicity",type:"ParticipantMultiplicity"},{name:"endPointRefs",type:"EndPoint",isMany:!0,isReference:!0},{name:"processRef",type:"Process",isAttr:!0,isReference:!0}]},{name:"ParticipantAssociation",superClass:["BaseElement"],properties:[{name:"innerParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"outerParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"ParticipantMultiplicity",properties:[{name:"minimum",default:0,isAttr:!0,type:"Integer"},{name:"maximum",default:1,isAttr:!0,type:"Integer"}],superClass:["BaseElement"]},{name:"Collaboration",superClass:["RootElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"isClosed",isAttr:!0,type:"Boolean"},{name:"participants",type:"Participant",isMany:!0},{name:"messageFlows",type:"MessageFlow",isMany:!0},{name:"artifacts",type:"Artifact",isMany:!0},{name:"conversations",type:"ConversationNode",isMany:!0},{name:"conversationAssociations",type:"ConversationAssociation"},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0},{name:"messageFlowAssociations",type:"MessageFlowAssociation",isMany:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"choreographyRef",type:"Choreography",isMany:!0,isReference:!0},{name:"conversationLinks",type:"ConversationLink",isMany:!0}]},{name:"ChoreographyActivity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"participantRef",type:"Participant",isMany:!0,isReference:!0},{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0},{name:"correlationKeys",type:"CorrelationKey",isMany:!0},{name:"loopType",type:"ChoreographyLoopType",default:"None",isAttr:!0}]},{name:"CallChoreography",superClass:["ChoreographyActivity"],properties:[{name:"calledChoreographyRef",type:"Choreography",isAttr:!0,isReference:!0},{name:"participantAssociations",type:"ParticipantAssociation",isMany:!0}]},{name:"SubChoreography",superClass:["ChoreographyActivity","FlowElementsContainer"],properties:[{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"ChoreographyTask",superClass:["ChoreographyActivity"],properties:[{name:"messageFlowRef",type:"MessageFlow",isMany:!0,isReference:!0}]},{name:"Choreography",superClass:["Collaboration","FlowElementsContainer"]},{name:"GlobalChoreographyTask",superClass:["Choreography"],properties:[{name:"initiatingParticipantRef",type:"Participant",isAttr:!0,isReference:!0}]},{name:"TextAnnotation",superClass:["Artifact"],properties:[{name:"text",type:"String"},{name:"textFormat",default:"text/plain",isAttr:!0,type:"String"}]},{name:"Group",superClass:["Artifact"],properties:[{name:"categoryValueRef",type:"CategoryValue",isAttr:!0,isReference:!0}]},{name:"Association",superClass:["Artifact"],properties:[{name:"associationDirection",type:"AssociationDirection",isAttr:!0},{name:"sourceRef",type:"BaseElement",isAttr:!0,isReference:!0},{name:"targetRef",type:"BaseElement",isAttr:!0,isReference:!0}]},{name:"Category",superClass:["RootElement"],properties:[{name:"categoryValue",type:"CategoryValue",isMany:!0},{name:"name",isAttr:!0,type:"String"}]},{name:"Artifact",isAbstract:!0,superClass:["BaseElement"]},{name:"CategoryValue",superClass:["BaseElement"],properties:[{name:"categorizedFlowElements",type:"FlowElement",isMany:!0,isVirtual:!0,isReference:!0},{name:"value",isAttr:!0,type:"String"}]},{name:"Activity",isAbstract:!0,superClass:["FlowNode"],properties:[{name:"isForCompensation",default:!1,isAttr:!0,type:"Boolean"},{name:"default",type:"SequenceFlow",isAttr:!0,isReference:!0},{name:"ioSpecification",type:"InputOutputSpecification",xml:{serialize:"property"}},{name:"boundaryEventRefs",type:"BoundaryEvent",isMany:!0,isReference:!0},{name:"properties",type:"Property",isMany:!0},{name:"dataInputAssociations",type:"DataInputAssociation",isMany:!0},{name:"dataOutputAssociations",type:"DataOutputAssociation",isMany:!0},{name:"startQuantity",default:1,isAttr:!0,type:"Integer"},{name:"resources",type:"ResourceRole",isMany:!0},{name:"completionQuantity",default:1,isAttr:!0,type:"Integer"},{name:"loopCharacteristics",type:"LoopCharacteristics"}]},{name:"ServiceTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0}]},{name:"SubProcess",superClass:["Activity","FlowElementsContainer","InteractionNode"],properties:[{name:"triggeredByEvent",default:!1,isAttr:!0,type:"Boolean"},{name:"artifacts",type:"Artifact",isMany:!0}]},{name:"LoopCharacteristics",isAbstract:!0,superClass:["BaseElement"]},{name:"MultiInstanceLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"isSequential",default:!1,isAttr:!0,type:"Boolean"},{name:"behavior",type:"MultiInstanceBehavior",default:"All",isAttr:!0},{name:"loopCardinality",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopDataInputRef",type:"ItemAwareElement",isReference:!0},{name:"loopDataOutputRef",type:"ItemAwareElement",isReference:!0},{name:"inputDataItem",type:"DataInput",xml:{serialize:"property"}},{name:"outputDataItem",type:"DataOutput",xml:{serialize:"property"}},{name:"complexBehaviorDefinition",type:"ComplexBehaviorDefinition",isMany:!0},{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"oneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0},{name:"noneBehaviorEventRef",type:"EventDefinition",isAttr:!0,isReference:!0}]},{name:"StandardLoopCharacteristics",superClass:["LoopCharacteristics"],properties:[{name:"testBefore",default:!1,isAttr:!0,type:"Boolean"},{name:"loopCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"loopMaximum",type:"Integer",isAttr:!0}]},{name:"CallActivity",superClass:["Activity","InteractionNode"],properties:[{name:"calledElement",type:"String",isAttr:!0}]},{name:"Task",superClass:["Activity","InteractionNode"]},{name:"SendTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ReceiveTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"},{name:"instantiate",default:!1,isAttr:!0,type:"Boolean"},{name:"operationRef",type:"Operation",isAttr:!0,isReference:!0},{name:"messageRef",type:"Message",isAttr:!0,isReference:!0}]},{name:"ScriptTask",superClass:["Task"],properties:[{name:"scriptFormat",isAttr:!0,type:"String"},{name:"script",type:"String"}]},{name:"BusinessRuleTask",superClass:["Task"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"AdHocSubProcess",superClass:["SubProcess"],properties:[{name:"completionCondition",type:"Expression",xml:{serialize:"xsi:type"}},{name:"ordering",type:"AdHocOrdering",isAttr:!0},{name:"cancelRemainingInstances",default:!0,isAttr:!0,type:"Boolean"}]},{name:"Transaction",superClass:["SubProcess"],properties:[{name:"protocol",isAttr:!0,type:"String"},{name:"method",isAttr:!0,type:"String"}]},{name:"GlobalScriptTask",superClass:["GlobalTask"],properties:[{name:"scriptLanguage",isAttr:!0,type:"String"},{name:"script",isAttr:!0,type:"String"}]},{name:"GlobalBusinessRuleTask",superClass:["GlobalTask"],properties:[{name:"implementation",isAttr:!0,type:"String"}]},{name:"ComplexBehaviorDefinition",superClass:["BaseElement"],properties:[{name:"condition",type:"FormalExpression"},{name:"event",type:"ImplicitThrowEvent"}]},{name:"ResourceRole",superClass:["BaseElement"],properties:[{name:"resourceRef",type:"Resource",isReference:!0},{name:"resourceParameterBindings",type:"ResourceParameterBinding",isMany:!0},{name:"resourceAssignmentExpression",type:"ResourceAssignmentExpression"},{name:"name",isAttr:!0,type:"String"}]},{name:"ResourceParameterBinding",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}},{name:"parameterRef",type:"ResourceParameter",isAttr:!0,isReference:!0}],superClass:["BaseElement"]},{name:"ResourceAssignmentExpression",properties:[{name:"expression",type:"Expression",xml:{serialize:"xsi:type"}}],superClass:["BaseElement"]},{name:"Import",properties:[{name:"importType",isAttr:!0,type:"String"},{name:"location",isAttr:!0,type:"String"},{name:"namespace",isAttr:!0,type:"String"}]},{name:"Definitions",superClass:["BaseElement"],properties:[{name:"name",isAttr:!0,type:"String"},{name:"targetNamespace",isAttr:!0,type:"String"},{name:"expressionLanguage",default:"http://www.w3.org/1999/XPath",isAttr:!0,type:"String"},{name:"typeLanguage",default:"http://www.w3.org/2001/XMLSchema",isAttr:!0,type:"String"},{name:"imports",type:"Import",isMany:!0},{name:"extensions",type:"Extension",isMany:!0},{name:"rootElements",type:"RootElement",isMany:!0},{name:"diagrams",isMany:!0,type:"bpmndi:BPMNDiagram"},{name:"exporter",isAttr:!0,type:"String"},{name:"relationships",type:"Relationship",isMany:!0},{name:"exporterVersion",isAttr:!0,type:"String"}]}],KR=[{name:"ProcessType",literalValues:[{name:"None"},{name:"Public"},{name:"Private"}]},{name:"GatewayDirection",literalValues:[{name:"Unspecified"},{name:"Converging"},{name:"Diverging"},{name:"Mixed"}]},{name:"EventBasedGatewayType",literalValues:[{name:"Parallel"},{name:"Exclusive"}]},{name:"RelationshipDirection",literalValues:[{name:"None"},{name:"Forward"},{name:"Backward"},{name:"Both"}]},{name:"ItemKind",literalValues:[{name:"Physical"},{name:"Information"}]},{name:"ChoreographyLoopType",literalValues:[{name:"None"},{name:"Standard"},{name:"MultiInstanceSequential"},{name:"MultiInstanceParallel"}]},{name:"AssociationDirection",literalValues:[{name:"None"},{name:"One"},{name:"Both"}]},{name:"MultiInstanceBehavior",literalValues:[{name:"None"},{name:"One"},{name:"All"},{name:"Complex"}]},{name:"AdHocOrdering",literalValues:[{name:"Parallel"},{name:"Sequential"}]}],XR={tagAlias:"lowerCase",typePrefix:"t"},ZR={name:VR,uri:WR,prefix:UR,associations:qR,types:YR,enumerations:KR,xml:XR},QR="BPMNDI",JR="http://www.omg.org/spec/BPMN/20100524/DI",eC="bpmndi",tC=[{name:"BPMNDiagram",properties:[{name:"plane",type:"BPMNPlane",redefines:"di:Diagram#rootElement"},{name:"labelStyle",type:"BPMNLabelStyle",isMany:!0}],superClass:["di:Diagram"]},{name:"BPMNPlane",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"}],superClass:["di:Plane"]},{name:"BPMNShape",properties:[{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"isHorizontal",isAttr:!0,type:"Boolean"},{name:"isExpanded",isAttr:!0,type:"Boolean"},{name:"isMarkerVisible",isAttr:!0,type:"Boolean"},{name:"label",type:"BPMNLabel"},{name:"isMessageVisible",isAttr:!0,type:"Boolean"},{name:"participantBandKind",type:"ParticipantBandKind",isAttr:!0},{name:"choreographyActivityShape",type:"BPMNShape",isAttr:!0,isReference:!0}],superClass:["di:LabeledShape"]},{name:"BPMNEdge",properties:[{name:"label",type:"BPMNLabel"},{name:"bpmnElement",isAttr:!0,isReference:!0,type:"bpmn:BaseElement",redefines:"di:DiagramElement#modelElement"},{name:"sourceElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#source"},{name:"targetElement",isAttr:!0,isReference:!0,type:"di:DiagramElement",redefines:"di:Edge#target"},{name:"messageVisibleKind",type:"MessageVisibleKind",isAttr:!0,default:"initiating"}],superClass:["di:LabeledEdge"]},{name:"BPMNLabel",properties:[{name:"labelStyle",type:"BPMNLabelStyle",isAttr:!0,isReference:!0,redefines:"di:DiagramElement#style"}],superClass:["di:Label"]},{name:"BPMNLabelStyle",properties:[{name:"font",type:"dc:Font"}],superClass:["di:Style"]}],nC=[{name:"ParticipantBandKind",literalValues:[{name:"top_initiating"},{name:"middle_initiating"},{name:"bottom_initiating"},{name:"top_non_initiating"},{name:"middle_non_initiating"},{name:"bottom_non_initiating"}]},{name:"MessageVisibleKind",literalValues:[{name:"initiating"},{name:"non_initiating"}]}],iC=[],oC={name:QR,uri:JR,prefix:eC,types:tC,enumerations:nC,associations:iC},rC="DC",aC="http://www.omg.org/spec/DD/20100524/DC",sC="dc",cC=[{name:"Boolean"},{name:"Integer"},{name:"Real"},{name:"String"},{name:"Font",properties:[{name:"name",type:"String",isAttr:!0},{name:"size",type:"Real",isAttr:!0},{name:"isBold",type:"Boolean",isAttr:!0},{name:"isItalic",type:"Boolean",isAttr:!0},{name:"isUnderline",type:"Boolean",isAttr:!0},{name:"isStrikeThrough",type:"Boolean",isAttr:!0}]},{name:"Point",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0}]},{name:"Bounds",properties:[{name:"x",type:"Real",default:"0",isAttr:!0},{name:"y",type:"Real",default:"0",isAttr:!0},{name:"width",type:"Real",isAttr:!0},{name:"height",type:"Real",isAttr:!0}]}],lC=[],uC={name:rC,uri:aC,prefix:sC,types:cC,associations:lC},pC="DI",fC="http://www.omg.org/spec/DD/20100524/DI",dC="di",hC=[{name:"DiagramElement",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"extension",type:"Extension"},{name:"owningDiagram",type:"Diagram",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"owningElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"modelElement",isReadOnly:!0,isVirtual:!0,isReference:!0,type:"Element"},{name:"style",type:"Style",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"ownedElement",type:"DiagramElement",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Node",isAbstract:!0,superClass:["DiagramElement"]},{name:"Edge",isAbstract:!0,superClass:["DiagramElement"],properties:[{name:"source",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"target",type:"DiagramElement",isReadOnly:!0,isVirtual:!0,isReference:!0},{name:"waypoint",isUnique:!1,isMany:!0,type:"dc:Point",xml:{serialize:"xsi:type"}}]},{name:"Diagram",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"rootElement",type:"DiagramElement",isReadOnly:!0,isVirtual:!0},{name:"name",isAttr:!0,type:"String"},{name:"documentation",isAttr:!0,type:"String"},{name:"resolution",isAttr:!0,type:"Real"},{name:"ownedStyle",type:"Style",isReadOnly:!0,isMany:!0,isVirtual:!0}]},{name:"Shape",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Plane",isAbstract:!0,superClass:["Node"],properties:[{name:"planeElement",type:"DiagramElement",subsettedProperty:"DiagramElement-ownedElement",isMany:!0}]},{name:"LabeledEdge",isAbstract:!0,superClass:["Edge"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"LabeledShape",isAbstract:!0,superClass:["Shape"],properties:[{name:"ownedLabel",type:"Label",isReadOnly:!0,subsettedProperty:"DiagramElement-ownedElement",isMany:!0,isVirtual:!0}]},{name:"Label",isAbstract:!0,superClass:["Node"],properties:[{name:"bounds",type:"dc:Bounds"}]},{name:"Style",isAbstract:!0,properties:[{name:"id",isAttr:!0,isId:!0,type:"String"}]},{name:"Extension",properties:[{name:"values",isMany:!0,type:"Element"}]}],gC=[],mC={tagAlias:"lowerCase"},yC={name:pC,uri:fC,prefix:dC,types:hC,associations:gC,xml:mC},vC="bpmn.io colors for BPMN",bC="http://bpmn.io/schema/bpmn/biocolor/1.0",xC="bioc",wC=[{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"stroke",isAttr:!0,type:"String"},{name:"fill",isAttr:!0,type:"String"}]}],_C=[],EC=[],SC={name:vC,uri:bC,prefix:xC,types:wC,enumerations:_C,associations:EC},RC="BPMN in Color",CC="http://www.omg.org/spec/BPMN/non-normative/color/1.0",MC="color",AC=[{name:"ColoredLabel",extends:["bpmndi:BPMNLabel"],properties:[{name:"color",isAttr:!0,type:"String"}]},{name:"ColoredShape",extends:["bpmndi:BPMNShape"],properties:[{name:"background-color",isAttr:!0,type:"String"},{name:"border-color",isAttr:!0,type:"String"}]},{name:"ColoredEdge",extends:["bpmndi:BPMNEdge"],properties:[{name:"border-color",isAttr:!0,type:"String"}]}],PC=[],TC=[],kC={name:RC,uri:CC,prefix:MC,types:AC,enumerations:PC,associations:TC};const OC={bpmn:ZR,bpmndi:oC,dc:uC,di:yC,bioc:SC,color:kC};function _m(e,t){const n=Y({},OC,e);return new jc(n,t)}const DC={name:"bpmn-i18n",uri:"http://www.omg.org/spec/BPMN/non-normative/extensions/i18n/1.0",prefix:"i18n",types:[{name:"Translation",superClass:["Element"],properties:[{name:"id",isAttr:!0,isId:!0,type:"String"},{name:"body",isBody:!0,type:"String"},{name:"target",isAttr:!0,type:"String",default:"@name"},{name:"textFormat",isAttr:"true",type:"String",default:"text/plain"}]}],enumerations:[],associations:[],xml:{tagAlias:"lowerCase",typePrefix:"t"}},Hc={[nm]:DC,[Op]:Zg};function Em(){return _m(Hc)}const Sm=Em();async function pa(e){const{rootElement:t,warnings:n}=await Sm.fromXML(e,"bpmn:Definitions");return{definitions:t,warnings:n}}async function LC(e){const{xml:t}=await Sm.toXML(e,{format:!0});return t}function rf(e){return e.map(t=>typeof t=="string"?t:t.message??String(t))}const fa={cjkEm:.865,upperEm:.68,lowerEm:.5,digitEm:.556,spaceEm:.278,otherEm:.35,ascentEm:.9,descentEm:.25},IC=/[ᄀ-ᇿ -〿぀-ヿ㐀-鿿가-힯＀-⦆]/;function BC(e){const t=fa;return IC.test(e)?t.cjkEm:e===" "?t.spaceEm:e>="0"&&e<="9"?t.digitEm:e>="A"&&e<="Z"?t.upperEm:e>="a"&&e<="z"?t.lowerEm:t.otherEm}function da(e,t){let n=0;for(const i of e)n+=t*BC(i);return n}function Rm(e=globalThis,{textMeasurement:t="approximate"}={}){if(!(e!=null&&e.SVGElement))throw new Error("installHeadlessBpmnDom: DOM 전역이 없다 — jsdom window 를 전역에 올린 뒤 호출할 것");t==="approximate"&&NC(e),$C(e),FC(e),jC(e)}function NC(e){var i;const t=(i=e.HTMLCanvasElement)==null?void 0:i.prototype;if(!t||t.__headlessTextMeasurement)return;t.__headlessTextMeasurement=!0;const n={font:"12px sans-serif",letterSpacing:"0px",measureText(o){var a;const r=Number.parseFloat(((a=String(n.font).match(/(\d+(?:\.\d+)?)px/))==null?void 0:a[1])??"12");return{width:da(o,r),fontBoundingBoxAscent:r*fa.ascentEm,fontBoundingBoxDescent:r*fa.descentEm,actualBoundingBoxAscent:r*fa.ascentEm,actualBoundingBoxDescent:r*fa.descentEm}}};t.getContext=()=>n}function $C(e){if(e.SVGMatrix)return;class t{constructor(){$n(this,"a",1);$n(this,"b",0);$n(this,"c",0);$n(this,"d",1);$n(this,"e",0);$n(this,"f",0)}static of(i,o,r,a,s,c){return Object.assign(new t,{a:i,b:o,c:r,d:a,e:s,f:c})}multiply(i){return t.of(this.a*i.a+this.c*i.b,this.b*i.a+this.d*i.b,this.a*i.c+this.c*i.d,this.b*i.c+this.d*i.d,this.a*i.e+this.c*i.f+this.e,this.b*i.e+this.d*i.f+this.f)}translate(i,o){return this.multiply(t.of(1,0,0,1,i,o))}scale(i,o=i){return this.multiply(t.of(i,0,0,o,0,0))}inverse(){const i=this.a*this.d-this.b*this.c;return t.of(this.d/i,-this.b/i,-this.c/i,this.a/i,(this.c*this.f-this.d*this.e)/i,(this.b*this.e-this.a*this.f)/i)}}e.SVGMatrix=t}function FC(e){var r;const t=()=>{const a=new e.SVGMatrix;return{type:0,matrix:a,setTranslate(s,c){a.e=s,a.f=c},setScale(s,c){a.a=s,a.d=c},setRotate(s,c=0,l=0){const u=s*Math.PI/180,p=Math.cos(u),f=Math.sin(u);a.a=p,a.b=f,a.c=-f,a.d=p,a.e=c-p*c+f*l,a.f=l-f*c-p*l},setMatrix(s){Object.assign(a,s)}}},n=a=>{const s=t();return Object.assign(s.matrix,a),s},i=(r=e.SVGSVGElement)==null?void 0:r.prototype;i&&!i.createSVGTransform&&(i.createSVGTransform=t,i.createSVGTransformFromMatrix=n,i.createSVGMatrix=()=>new e.SVGMatrix,i.createSVGPoint=()=>({x:0,y:0,matrixTransform:()=>({x:0,y:0})}));const o=e.SVGElement.prototype;Object.getOwnPropertyDescriptor(o,"transform")||Object.defineProperty(o,"transform",{configurable:!0,get(){if(!this.__headlessTransformList){const a=[];this.__headlessTransformList={baseVal:{get numberOfItems(){return a.length},clear:()=>{a.length=0},appendItem:s=>(a.push(s),s),getItem:s=>a[s],createSVGTransformFromMatrix:n,consolidate:()=>a[a.length-1]??null}}}return this.__headlessTransformList}})}function jC(e){const t=e.SVGElement.prototype;if(!t.getCTM){const n=()=>new e.SVGMatrix;t.getCTM=n,t.getScreenCTM=n}t.getBBox||(t.getBBox=function(){const n=String(this.textContent??"");return{x:0,y:0,width:da(n,12),height:14}})}const zc=new Set(["bpmn:Participant","bpmn:Lane","bpmn:Group","bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),HC=new Set(["bpmn:SubProcess","bpmn:AdHocSubProcess","bpmn:Transaction"]),zC=1,Gc=new Set(["bpmn:TextAnnotation","bpmn:DataStoreReference","bpmn:DataObjectReference","bpmn:DataInput","bpmn:DataOutput"]),GC=2;function pt(e){switch(e.kind){case"label-over-line":return`L|${e.edge}|${e.line}`;case"label-over-shape":return`ls|${e.edge}|${e.shape}`;case"edge-crosses-shape":return`x|${e.edge}|${e.shape}`;case"edge-endpoint-detached":return`d|${e.edge}|${e.shape}`;case"shape-overlap":return`o|${e.shapes[0]}|${e.shapes[1]}`;case"shape-outside-container":return`c|${e.shape}|${e.container}`;case"edge-overlap-opposite":return`p|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-mixed":return`m|${e.edges[0]}|${e.edges[1]}`;case"edge-overlap-unrelated":return`u|${e.edges[0]}|${e.edges[1]}`;case"label-on-shared-segment":return`l|${e.edge}|${e.other}`;case"annotation-over-label":return`a|${e.annotation}|${e.label}`;case"pool-overlap":return`P|${e.pools[0]}|${e.pools[1]}`;case"edge-crosses-subprocess":return`S|${e.edge}|${e.subProcess}`;case"group-overlap-unintended":return`g|${e.groups[0]}|${e.groups[1]}${e.container?`|⊃${e.container}`:""}`;case"group-overlap-unreadable":return e.reason==="minority"?`gu*|${e.group}|${e.shapes.join(",")}`:e.reason==="throughpass"?`gu>|${e.group}|${e.shapes.join(",")}`:`gu|${e.groups[0]}|${e.groups[1]}|${e.shapes.join(",")}`;case"group-stack-unreadable":return`gs|${e.groups.join("|")}|${e.shapes.join(",")}`;case"group-on-container-boundary":return`gb|${e.group}|${e.container}|${e.side}`;case"group-on-group-boundary":return`gg|${e.groups[0]}|${e.groups[1]}|${e.axis}`;case"group-cuts-shape":return`gc|${e.group}|${e.shape}|${e.side}`;case"edge-along-group-boundary":return`eg|${e.edge}|${e.group}`;case"pool-name-over-label":return`pn|${e.pool}|${e.label}`}}const Cm=20,Vc=5,Mm=3,VC=8,ha=15,af=50,Am=12,WC=Am*1.2;function sf(e,t){const n=t.split(/\r?\n/),i=Math.max(...n.map(r=>da(r,Am))),o=n.length*WC;return{x:e.x+e.width/2-i/2,y:e.y+e.height/2-o/2,width:i,height:o}}const Pm=1;function an(e){const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],o=e.waypoints[n+1];Math.abs(i.y-o.y)<.5&&Math.abs(i.x-o.x)>=.5?t.push({axis:"h",at:i.y,lo:Math.min(i.x,o.x),hi:Math.max(i.x,o.x),dir:o.x>i.x?1:-1}):Math.abs(i.x-o.x)<.5&&Math.abs(i.y-o.y)>=.5&&t.push({axis:"v",at:i.x,lo:Math.min(i.y,o.y),hi:Math.max(i.y,o.y),dir:o.y>i.y?1:-1})}return t}function Or(e,t){let n=null;const i=e.type!==t.type,r=!!(e.source&&e.target&&t.source&&t.target)&&e.source!==t.source&&e.source!==t.target&&e.target!==t.source&&e.target!==t.target;for(const a of an(e))for(const s of an(t)){if(a.axis!==s.axis||Math.abs(a.at-s.at)>Pm)continue;const c=a.dir!==s.dir?"opposite":i?"mixed":r?"unrelated":null;if(!c)continue;const l=Math.min(a.hi,s.hi)-Math.max(a.lo,s.lo);l>=Cm&&(!n||l>n.length)&&(n={axis:a.axis,length:l,kind:c})}return n}function cf(e){return e.kind==="edge-overlap-opposite"||e.kind==="edge-overlap-mixed"||e.kind==="edge-overlap-unrelated"}function Tm(e,t){const n=Or(e,t);return n&&n.kind==="opposite"?{axis:n.axis,length:n.length}:null}function UC(e,t){let n=0;for(const i of t)i.id!==e.id&&Tm(e,i)&&n++;return n}function hi(e,t){let n=0;for(const i of t)i.id!==e.id&&Or(e,i)&&n++;return n}const km=15,Om=20;function qC(e,t){const n=t.axis==="v"?[e.x,e.x+e.width]:[e.y,e.y+e.height];if(t.at<n[0]-Om||t.at>n[1]+Om)return null;const i=t.axis==="v"?[e.y,e.y+e.height]:[e.x,e.x+e.width],o=Math.max(i[0],t.lo),r=Math.min(i[1],t.hi);return r>o?[o,r]:null}const lf=20;function Wc(e,t){const n=[];for(const i of t){if(i.axis!==e.axis||Math.abs(i.at-e.at)>Pm)continue;const o=Math.max(e.lo,i.lo),r=Math.min(e.hi,i.hi);r-o<Cm||n.push([o-lf,r+lf])}return n}function Uc(e,t){const n=e.label;if(!n)return null;let i=null;for(const o of an(e)){const r=qC(n,o);if(r){for(const a of t)if(a.id!==e.id&&!(i&&a.id>=i.other)){for(const[s,c]of Wc(o,an(a)))if(Math.min(c,r[1])>Math.max(s,r[0])){i={other:a.id,axis:o.axis};break}}}}return i}const YC=10,KC=1,XC=(e,t,n)=>t.x>=e.x-n&&t.y>=e.y-n&&t.x+t.width<=e.x+e.width+n&&t.y+t.height<=e.y+e.height+n;function ZC(e,t,n,i){const o=n.x+i,r=n.y+i,a=n.x+n.width-i,s=n.y+n.height-i;if(a<=o||s<=r)return!1;const c=t.x-e.x,l=t.y-e.y;let u=0,p=1;const f=(d,g)=>{if(g===0)return d<=0;const h=d/g;if(g>0){if(h>p)return!1;h>u&&(u=h)}else{if(h<u)return!1;h<p&&(p=h)}return!0};return f(o-e.x,c)&&f(e.x-a,-c)&&f(r-e.y,l)&&f(e.y-s,-l)&&p>u}function uf(e,t,n){return e.x+n<t.x+t.width-n&&t.x+n<e.x+e.width-n&&e.y+n<t.y+t.height-n&&t.y+n<e.y+e.height-n}const QC=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,ga=1;function $i(e,t){const n=e.x+ga,i=e.x+e.width-ga,o=e.y+ga,r=e.y+e.height-ga;return t.axis==="h"?t.at>o&&t.at<r&&t.lo<i&&t.hi>n:t.at>n&&t.at<i&&t.lo<r&&t.hi>o}function ma(e){return[{axis:"h",at:e.y,lo:e.x,hi:e.x+e.width,dir:1},{axis:"h",at:e.y+e.height,lo:e.x,hi:e.x+e.width,dir:1},{axis:"v",at:e.x,lo:e.y,hi:e.y+e.height,dir:1},{axis:"v",at:e.x+e.width,lo:e.y,hi:e.y+e.height,dir:1}]}function Dm(e,t){const n=e.label;if(!n)return null;if(an(e).some(i=>$i(n,i)))return e.id;for(const i of[...t.edges].filter(o=>o.id!==e.id).sort((o,r)=>o.id.localeCompare(r.id)))if(an(i).some(o=>$i(n,o)))return i.id;for(const i of t.shapes.filter(o=>o.container).sort((o,r)=>o.id.localeCompare(r.id)))if(ma(i).some(o=>$i(n,o)))return i.id;return null}function Ht(e,t){const n=new Set(e.endpoints),i=[];for(const o of t)if(!n.has(o.id)){for(let r=0;r+1<e.waypoints.length;r++)if(ZC(e.waypoints[r],e.waypoints[r+1],o,GC)){i.push(o);break}}return i}const ps=(e,t,n)=>{const i=n.x-t.x,o=n.y-t.y,r=i*i+o*o,a=r===0?0:Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*o)/r));return Math.hypot(e.x-(t.x+a*i),e.y-(t.y+a*o))},JC=(e,t,n,i)=>Im(e,t,n,i)?0:Math.min(ps(e,n,i),ps(t,n,i),ps(n,e,t),ps(i,e,t)),Lm=(e,t)=>{let n=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const r=t[i],a=t[o];r.y>e.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(n=!n)}return n};function Dr(e,t,n){const{x:i,y:o,width:r,height:a}=n;if(/Event$/.test(n.type)){const l=Math.min(r,a)/2;return Math.max(0,ps({x:i+r/2,y:o+a/2},e,t)-l)}const s=/Gateway$/.test(n.type)?[{x:i+r/2,y:o},{x:i+r,y:o+a/2},{x:i+r/2,y:o+a},{x:i,y:o+a/2}]:[{x:i,y:o},{x:i+r,y:o},{x:i+r,y:o+a},{x:i,y:o+a}];if(Lm(e,s)||Lm(t,s))return 0;let c=1/0;for(let l=0;l<s.length;l++)c=Math.min(c,JC(e,t,s[l],s[(l+1)%s.length]));return c}function Im(e,t,n,i){const o=(l,u,p)=>(u.x-l.x)*(p.y-l.y)-(u.y-l.y)*(p.x-l.x),r=o(n,i,e),a=o(n,i,t),s=o(e,t,n),c=o(e,t,i);return r*a<0&&s*c<0}const pf=(e,t)=>e.endpoints.some(n=>t.endpoints.includes(n));function Bm(e,t){for(let n=0;n+1<e.waypoints.length;n++)for(let i=0;i+1<t.waypoints.length;i++)if(Im(e.waypoints[n],e.waypoints[n+1],t.waypoints[i],t.waypoints[i+1]))return!0;return!1}function fs(e,t){let n=0;for(const i of t)i.id===e.id||pf(e,i)||Bm(e,i)&&n++;return n}function gi(e,t){let n=0;for(const i of t)i.id===e.id||pf(e,i)||fs(e,[i])>0&&(n+=i.type===e.type?2:1);return n}function Nm(e){let t=0;const n=e.edges;for(let i=0;i<n.length;i++)for(let o=i+1;o<n.length;o++)fs(n[i],[n[o]])>0&&(t+=n[i].type===n[o].type?2:1);return t}function go(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let o=i+1;o<n.length;o++)if(fs(n[i],[n[o]])>0){const r=n[i].id,a=n[o].id;t.push(r<a?[r,a]:[a,r])}return t.sort((i,o)=>`${i[0]}|${i[1]}`.localeCompare(`${o[0]}|${o[1]}`))}function Fi(e){const t=[],n=e.edges;for(let i=0;i<n.length;i++)for(let o=i+1;o<n.length;o++)if(pf(n[i],n[o])&&Bm(n[i],n[o])){const r=n[i].id,a=n[o].id;t.push(r<a?[r,a]:[a,r])}return t.sort((i,o)=>`${i[0]}|${i[1]}`.localeCompare(`${o[0]}|${o[1]}`))}function $m(e){const t=go(e),n=a=>a==="bpmn:MessageFlow"||a.endsWith("Association")?"dashed":"solid",i=new Map(e.edges.map(a=>[a.id,a]));let o=0,r=0;for(const[a,s]of t){const c=i.get(a),l=i.get(s);if(!c||!l)continue;const u=n(c.type),p=n(l.type);u==="solid"&&p==="solid"?o++:u==="dashed"&&p==="dashed"&&r++}return{pairs:t,solidPairs:o,dashedPairs:r,mixedPairs:t.length-o-r,crossPoolMessages:eM(e)}}function eM(e){const t=e.shapes.filter(o=>o.type==="bpmn:Participant");if(t.length<3)return 0;const n=o=>{const r=e.shapes.find(a=>a.id===o);if(r)return t.find(a=>r.x>=a.x&&r.y>=a.y&&r.x+r.width<=a.x+a.width&&r.y+r.height<=a.y+a.height)};let i=0;for(const o of e.edges){if(o.type!=="bpmn:MessageFlow"||o.endpoints.length<2)continue;const r=n(o.endpoints[0]),a=n(o.endpoints[1]);if(!r||!a||r.id===a.id)continue;const s=Math.min(r.y,a.y),c=Math.max(r.y+r.height,a.y+a.height);t.some(l=>l.id!==r.id&&l.id!==a.id&&l.y>s&&l.y+l.height<c)&&i++}return i}function Fm(e,t,n){const i=new Set(t.flatMap(o=>[...o.members]));return e.shapes.filter(o=>!o.container&&!Gc.has(o.type)&&!i.has(o.id)&&o.x>=n.x&&o.y>=n.y&&o.x+o.width<=n.right&&o.y+o.height<=n.bottom).map(o=>o.id).sort()}function jm(e){var n;const t=(n=zt(e==null?void 0:e.extensionElements))==null?void 0:n.values;if(Array.isArray(t))for(const i of t){const o=zt(i);if((o==null?void 0:o.$type)!=="bwl:Members"||typeof o.refs!="string")continue;const r=o.refs.split(/\s+/).filter(Boolean);return r.length?r:void 0}}const Hm=e=>e?{members:e}:{},Hn=e=>e.shapes.filter(t=>!t.container);function tM(e,t,n){if(e.type==="bpmn:TextAnnotation")for(const i of t.edges){if(!/Association$/.test(i.type)||!i.endpoints.includes(e.id))continue;const o=i.endpoints.find(a=>a!==e.id),r=o?n.get(o):void 0;if(r&&r.type!=="bpmn:Group"){if(r.container)return r.id;if(r.parent)return r.parent}}}function nM(e,t,n){if(e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height)return!0;const o=e.x+e.width/2,r=e.y+e.height/2;return n.shapes.some(a=>a.container&&a.id!==t.id&&a.id!==e.id&&a.type!=="bpmn:Group"&&o>=a.x&&o<=a.x+a.width&&r>=a.y&&r<=a.y+a.height)}function zm(e,t){const n=e.label;if(!n)return null;for(const i of[...t.edges].sort((o,r)=>o.id.localeCompare(r.id)))if(an(i).some(o=>$i(n,o)))return i.id;for(const i of[...t.shapes].filter(o=>o.container).sort((o,r)=>o.id.localeCompare(r.id)))if(ma(i).some(o=>$i(n,o)))return i.id;return null}function zo(e){const t=[];for(const n of e.shapes)n.label&&t.push({owner:n.id,rect:n.label});for(const n of e.edges)n.label&&t.push({owner:n.id,rect:n.label});return t}const Gm=3;function Vm(e,t){const n=Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x),i=Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y);if(n<=0||i<=0)return 0;const o=/Event$/.test(t.type);if(!o&&!/Gateway$/.test(t.type))return Math.min(n,i);const r=t.x+t.width/2,a=t.y+t.height/2,s=Math.min(Math.max(r,e.x),e.x+e.width),c=Math.min(Math.max(a,e.y),e.y+e.height);if(o)return Math.max(0,t.width/2-Math.hypot(s-r,c-a));const l=t.width/2,u=t.height/2;return Math.max(0,(1-(Math.abs(s-r)/l+Math.abs(c-a)/u))*Math.min(l,u))}function ds(e,t){const n=[];for(const i of t.shapes){if(i.container||Gc.has(i.type))continue;const o=Vm(e,i);o>=Gm&&n.push({shape:i.id,depth:o})}return n.sort((i,o)=>i.shape.localeCompare(o.shape))}function ff(e){const t=[],n=e.filter(o=>o.type==="bpmn:Participant"),i=(o,r)=>o.x<=r.x&&o.y<=r.y&&o.x+o.width>=r.x+r.width&&o.y+o.height>=r.y+r.height;for(let o=0;o<n.length;o++)for(let r=o+1;r<n.length;r++){const a=n[o],s=n[r];a.x+a.width<=s.x||s.x+s.width<=a.x||a.y+a.height<=s.y||s.y+s.height<=a.y||t.push({pools:[a.id,s.id],contained:i(a,s)||i(s,a)})}return t}function ft(e,t={}){const n=[],i=e.shapes.filter(y=>!y.container);for(const y of e.edges)for(const v of Ht(y,i))n.push({kind:"edge-crosses-shape",edge:y.id,shape:v.id});const o=e.shapes.filter(y=>y.container&&HC.has(y.type));if(o.length){const y=(v,x)=>{const E=e.shapes.find(A=>A.id===x);return!!E&&E.x>=v.x&&E.y>=v.y&&E.x+E.width<=v.x+v.width&&E.y+E.height<=v.y+v.height};for(const v of e.edges)for(const x of Ht(v,o))v.endpoints.includes(x.id)||v.endpoints.some(E=>y(x,E))||n.push({kind:"edge-crosses-subprocess",edge:v.id,subProcess:x.id})}for(const y of e.edges){if(y.waypoints.length<2)continue;const v=[[y.source,y.waypoints[0]],[y.target,y.waypoints[y.waypoints.length-1]]];for(const[x,E]of v){if(!x)continue;const A=e.shapes.find(H=>H.id===x);if(!A||A.container)continue;const I=Math.max(A.x-E.x,E.x-(A.x+A.width),0),P=Math.max(A.y-E.y,E.y-(A.y+A.height),0),k=Math.hypot(I,P);k>YC&&n.push({kind:"edge-endpoint-detached",edge:y.id,shape:x,distance:Math.round(k)})}}for(const y of ff(e.shapes))n.push({kind:"pool-overlap",...y});const r=i.filter(y=>!y.attached);for(let y=0;y<r.length;y++)for(let v=y+1;v<r.length;v++){const x=r[y],E=r[v];if(!uf(x,E,zC))continue;const A=x.id<E.id?[x.id,E.id]:[E.id,x.id];n.push({kind:"shape-overlap",shapes:A,identical:QC(x,E)})}const a=e.shapes.filter(y=>y.type==="bpmn:Group"&&Array.isArray(y.members)&&y.members.length>0);for(let y=0;y<a.length;y++)for(let v=y+1;v<a.length;v++){const x=a[y],E=a[v],A=Math.min(x.x+x.width,E.x+E.width)-Math.max(x.x,E.x),I=Math.min(x.y+x.height,E.y+E.height)-Math.max(x.y,E.y);if(A<=Vc||I<=Vc)continue;const P=x.id<E.id?[x.id,E.id]:[E.id,x.id],k=new Set(E.members);if(x.members.some(F=>k.has(F))){const F=Fm(e,a,{x:Math.max(x.x,E.x),y:Math.max(x.y,E.y),right:Math.min(x.x+x.width,E.x+E.width),bottom:Math.min(x.y+x.height,E.y+E.height)});F.length&&n.push({kind:"group-overlap-unreadable",reason:"orphan",groups:P,shapes:F});continue}const H=x.x<=E.x&&x.y<=E.y&&x.x+x.width>=E.x+E.width&&x.y+x.height>=E.y+E.height?x.id:E.x<=x.x&&E.y<=x.y&&E.x+E.width>=x.x+x.width&&E.y+E.height>=x.y+x.height?E.id:void 0;n.push({kind:"group-overlap-unintended",groups:P,...H?{container:H}:{}})}const s=new Set(a.flatMap(y=>[...y.members])),c=y=>e.shapes.filter(v=>!v.container&&!Gc.has(v.type)&&v.x>=y.x&&v.y>=y.y&&v.x+v.width<=y.x+y.width&&v.y+v.height<=y.y+y.height);for(const y of a){const v=c(y);if(!v.length)continue;const x=new Set(y.members),E=v.filter(A=>!x.has(A.id));E.some(A=>s.has(A.id))&&(E.length*2<v.length||n.push({kind:"group-overlap-unreadable",reason:"minority",group:y.id,shapes:E.map(A=>A.id).sort()}))}for(const y of a){const v=new Set(c(y).map(k=>k.id)),x=new Set(y.members),E=new Set([...v].filter(k=>!x.has(k)&&s.has(k)));if(!E.size)continue;let A=!1,I=!1,P=!1;for(const k of e.edges){if(k.type!=="bpmn:SequenceFlow"||!k.source||!k.target)continue;const H=E.has(k.source),F=E.has(k.target);!H&&F&&!v.has(k.source)?A=!0:H&&!F&&!v.has(k.target)?I=!0:H&&F&&(P=!0)}A&&I&&P&&n.push({kind:"group-overlap-unreadable",reason:"throughpass",group:y.id,shapes:[...E].sort()})}const l=e.shapes.filter(y=>y.type==="bpmn:Group");for(let y=0;y<l.length;y++)for(let v=y+1;v<l.length;v++)for(let x=v+1;x<l.length;x++){const E=[l[y],l[v],l[x]],A={x:Math.max(...E.map(k=>k.x)),y:Math.max(...E.map(k=>k.y)),right:Math.min(...E.map(k=>k.x+k.width)),bottom:Math.min(...E.map(k=>k.y+k.height))};if(A.right-A.x<=Vc||A.bottom-A.y<=Vc)continue;const I=Fm(e,[],A);if(!I.length)continue;const P=E.map(k=>k.id).sort();n.push({kind:"group-stack-unreadable",groups:P,shapes:I})}for(const y of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of e.shapes){if(v.container||v.attached||Gc.has(v.type)||v.width<=0||v.height<=0)continue;const x=[["top",y.y,"h",y.x,y.x+y.width],["bottom",y.y+y.height,"h",y.x,y.x+y.width],["left",y.x,"v",y.y,y.y+y.height],["right",y.x+y.width,"v",y.y,y.y+y.height]];for(const[E,A,I,P,k]of x){const H=I==="h"?v.x:v.y,F=I==="h"?v.x+v.width:v.y+v.height;if(!(H<k&&P<F))continue;const G=I==="h"?v.y:v.x,ee=I==="h"?v.y+v.height:v.x+v.width;if(!(G<A&&A<ee))continue;const ce=Math.min(A-G,ee-A);ce<VC||n.push({kind:"group-cuts-shape",group:y.id,shape:v.id,side:E,depth:ce})}}const u=t.includeObservationOnly?e.shapes.filter(y=>y.type==="bpmn:Group"&&y.width>0&&y.height>0):[];if(u.length){const y=new Map(e.shapes.filter(v=>!v.container).map(v=>[v.id,{x:v.x+v.width/2,y:v.y+v.height/2}]));for(const v of e.edges){if(v.type!=="bpmn:SequenceFlow"&&v.type!=="bpmn:MessageFlow")continue;const x=an(v);if(x.length)for(const E of u){const A=E.x+E.width,I=E.y+E.height,P=v.endpoints.some(H=>{const F=y.get(H);return!!F&&E.x<F.x&&F.x<A&&E.y<F.y&&F.y<I});let k=null;for(const H of x){const[F,G,ee]=H.axis==="v"?[E.y,I,[["left",E.x],["right",A]]]:[E.x,A,[["top",E.y],["bottom",I]]],ce=Math.min(H.hi,G)-Math.max(H.lo,F);if(ce<af)continue;const ie=H.axis==="v"?E.x<H.at&&H.at<A:E.y<H.at&&H.at<I;if(!(ie&&P))for(const[be,he]of ee){const ye=Math.abs(H.at-he);ye<=ha&&(!k||ye<k.distance)&&(k={side:be,inside:ie,distance:ye,length:ce})}}k&&n.push({kind:"edge-along-group-boundary",edge:v.id,group:E.id,side:k.side,inside:k.inside,distance:Math.round(k.distance),length:Math.round(k.length)})}}}const p=e.shapes.filter(y=>y.container&&y.type!=="bpmn:Group"&&y.type!=="bpmn:Lane");for(const y of e.shapes.filter(v=>v.type==="bpmn:Group"))for(const v of p){const x=y.x<v.x+v.width&&v.x<y.x+y.width,E=y.y<v.y+v.height&&v.y<y.y+y.height,A=[["top",y.y,v.y,x],["bottom",y.y+y.height,v.y+v.height,x],["left",y.x,v.x,E],["right",y.x+y.width,v.x+v.width,E]];for(const[I,P,k,H]of A)H&&Math.abs(P-k)<=Mm&&n.push({kind:"group-on-container-boundary",group:y.id,container:v.id,side:I})}const f=e.shapes.filter(y=>y.type==="bpmn:Group");for(let y=0;y<f.length;y++)for(let v=y+1;v<f.length;v++){const x=f[y],E=f[v],A=x.x<E.x+E.width&&E.x<x.x+x.width,I=x.y<E.y+E.height&&E.y<x.y+x.height,P=[["x",x.x+x.width,E.x,I],["x",E.x+E.width,x.x,I],["y",x.y+x.height,E.y,A],["y",E.y+E.height,x.y,A]];for(const[k,H,F,G]of P)if(G&&Math.abs(H-F)<=Mm){n.push({kind:"group-on-group-boundary",groups:x.id<E.id?[x.id,E.id]:[E.id,x.id],axis:k});break}}for(let y=0;y<e.edges.length;y++)for(let v=y+1;v<e.edges.length;v++){const x=e.edges[y],E=e.edges[v],A=Or(x,E);if(!A)continue;const I=x.id<E.id?[x.id,E.id]:[E.id,x.id];n.push({kind:A.kind==="opposite"?"edge-overlap-opposite":A.kind==="mixed"?"edge-overlap-mixed":"edge-overlap-unrelated",edges:I,axis:A.axis,length:Math.round(A.length)})}for(const y of e.edges){if(!y.label)continue;const v=Uc(y,e.edges);v&&n.push({kind:"label-on-shared-segment",edge:y.id,other:v.other,axis:v.axis})}for(const y of e.edges){if(!y.label)continue;const v=Dm(y,e);v&&n.push({kind:"label-over-line",edge:y.id,line:v})}if(t.includeObservationOnly){for(const y of e.edges)if(!(!y.label||y.type!=="bpmn:SequenceFlow"))for(const{shape:v,depth:x}of ds(y.label,e))n.push({kind:"label-over-shape",edge:y.id,shape:v,depth:Math.round(x)})}const d=new Set(i.map(y=>y.id)),g=e.shapes.filter(y=>y.type==="bpmn:Participant"&&y.label);for(const y of[...i,...g.filter(v=>!d.has(v.id))]){if(!y.label)continue;const v=zm(y,e);v&&n.push({kind:"label-over-line",edge:y.id,line:v})}const h=new Set(e.shapes.filter(y=>y.type==="bpmn:TextAnnotation").map(y=>y.id));for(const y of g)for(const{owner:v,rect:x}of zo(e))v===y.id||h.has(v)||uf(y.label,x,ga)&&n.push({kind:"pool-name-over-label",pool:y.id,label:v});const m=zo(e);for(const y of i)if(y.type==="bpmn:TextAnnotation")for(const{owner:v,rect:x}of m)v!==y.id&&uf(y,x,ga)&&n.push({kind:"annotation-over-label",annotation:y.id,label:v});const w=new Map(e.shapes.map(y=>[y.id,y]));for(const y of i){const v=y.parent??tM(y,e,w);if(!v)continue;const x=w.get(v);!x||!x.container||XC(x,y,KC)||y.type==="bpmn:TextAnnotation"&&!nM(y,x,e)||n.push({kind:"shape-outside-container",shape:y.id,container:x.id})}return n.sort((y,v)=>pt(y).localeCompare(pt(v)))}const zt=e=>typeof e=="object"&&e!==null?e:void 0,en=e=>typeof e=="number"?e:0,mo=e=>{const t=zt(e);return typeof(t==null?void 0:t.id)=="string"?t.id:void 0};function iM(e){const t=zt(e);if(!t)return[];const n=[];for(const i of["sourceRef","targetRef"]){const o=t[i];for(const r of Array.isArray(o)?o:[o]){const a=mo(r);a&&n.push(a)}}return n}function oM(e){const t=zt(e);if(!t)return{};const n=Array.isArray(t.sourceRef)?void 0:mo(t.sourceRef),i=Array.isArray(t.targetRef)?void 0:mo(t.targetRef);return n&&i?{source:n,target:i}:{}}function rM(e,t){const n=zt(e.$parent);if(!n)return;const i=typeof n.$type=="string"?n.$type:"";if(i==="bpmn:Process"){const o=mo(n);return o?t.get(o):void 0}if(zc.has(i)&&i!=="bpmn:Lane"&&i!=="bpmn:Group")return mo(n)}function Wm(e){var a,s,c,l,u;const t=[],n=[],i=((a=zt(e))==null?void 0:a.diagrams)??[],o=new Map,r=new Set;for(const p of((s=zt(e))==null?void 0:s.rootElements)??[]){const f=zt(p);if((f==null?void 0:f.$type)==="bpmn:Collaboration")for(const d of f.participants??[]){const g=zt(d),h=mo(g),m=mo(g==null?void 0:g.processRef);h&&m?o.set(m,h):h&&r.add(h)}}for(const p of i){const f=zt((c=zt(p))==null?void 0:c.plane),d=(f==null?void 0:f.planeElement)??[];for(const g of d){const h=zt(g);if(!h)continue;const m=zt(h.bpmnElement),w=typeof(m==null?void 0:m.id)=="string"?m.id:void 0;if(!w)continue;const y=typeof(m==null?void 0:m.$type)=="string"?m.$type:"",v=zt(h.bounds);if(v){const E=h.isExpanded===!1&&y!=="bpmn:Participant",A=zt((l=zt(h.label))==null?void 0:l.bounds),I={id:w,type:y,x:en(v.x),y:en(v.y),width:en(v.width),height:en(v.height),container:zc.has(y)&&!E,attached:(m==null?void 0:m.attachedToRef)!==void 0,...m?{parent:rM(m,o)}:{},...A?{label:{x:en(A.x),y:en(A.y),width:en(A.width),height:en(A.height)}}:{},...y==="bpmn:Group"?Hm(jm(m)):{}},P=h.isHorizontal!==!1,k=typeof(m==null?void 0:m.name)=="string"?m.name:"";r.has(w)&&P&&k&&(I.label=sf(I,k)),t.push(I);continue}const x=h.waypoint;if(Array.isArray(x)){const E=zt((u=zt(h.label))==null?void 0:u.bounds);n.push({id:w,type:y,waypoints:x.map(A=>{var I,P;return{x:en((I=zt(A))==null?void 0:I.x),y:en((P=zt(A))==null?void 0:P.y)}}),endpoints:iM(m),...oM(m),...E?{label:{x:en(E.x),y:en(E.y),width:en(E.width),height:en(E.height)}}:{}})}}}return{shapes:t,edges:n}}function Um(e){return ft(Wm(e),{includeObservationOnly:!0})}async function aM(e){const{definitions:t,warnings:n}=await pa(e);return{findings:Um(t),warnings:n}}function Ue(e){var i;const t=[],n=[];for(const o of e.getAll()){const r=o;if(r.type==="label"||r.labelTarget)continue;const a=typeof r.type=="string"?r.type:"";if(a==="bpmn:Definitions"||a.startsWith("bpmndi:"))continue;const s=r.waypoints;if(s){const h=zt(r.label),m=mo(r.source),w=mo(r.target);n.push({id:r.id,type:a,waypoints:s.map(y=>({x:en(y.x),y:en(y.y)})),endpoints:[m,w].filter(y=>!!y),...m&&w?{source:m,target:w}:{},...h&&typeof h.x=="number"?{label:{x:h.x,y:en(h.y),width:en(h.width),height:en(h.height)}}:{}});continue}if(typeof r.x!="number"||typeof r.y!="number")continue;const c=zt(r.businessObject),l=zt(r.label);let u=zt(r.parent);for(;u&&u.type==="bpmn:Lane";)u=zt(u.parent);const p=typeof(u==null?void 0:u.type)=="string"?u.type:"",f=u&&zc.has(p)&&p!=="bpmn:Group"&&typeof u.id=="string"?u.id:void 0,d={id:r.id,type:a,x:r.x,y:r.y,width:en(r.width),height:en(r.height),container:zc.has(a)&&(a==="bpmn:Participant"||r.collapsed!==!0),attached:(c==null?void 0:c.attachedToRef)!==void 0,...f!==void 0?{parent:f}:{},...l&&typeof l.x=="number"?{label:{x:l.x,y:en(l.y),width:en(l.width),height:en(l.height)}}:{},...a==="bpmn:Group"?Hm(jm(c)):{}},g=typeof(c==null?void 0:c.name)=="string"?c.name:"";a==="bpmn:Participant"&&!(c!=null&&c.processRef)&&g&&((i=zt(r.di))==null?void 0:i.isHorizontal)!==!1&&(d.label=sf(d,g)),t.push(d)}return{shapes:t,edges:n}}const sM={"bpmn:Participant":"participant","bpmn:Lane":"lane","bpmn:SequenceFlow":"sequenceFlow","bpmn:MessageFlow":"messageFlow","bpmn:DataStoreReference":"dataStore","bpmn:DataInputAssociation":"dataAssociation","bpmn:DataOutputAssociation":"dataAssociation","bpmn:TextAnnotation":"annotation","bpmn:Association":"association","bpmn:Group":"group"};function cM(e,t){const n=sM[e];return n||(e==="label"||e.startsWith("bpmndi:")?"other":e.startsWith("bpmn:")&&!("waypoints"in t&&t.waypoints)?"flowNode":"other")}function qm(e){let t=e.parent;for(;t;){if(t.type==="bpmn:Participant")return t.id;t=t.parent}}function Ym(e){const t=()=>e.getAll().filter(n=>n.type!=="label"&&!("labelTarget"in n&&n.labelTarget));return{isCollaboration:()=>t().some(n=>n.type==="bpmn:Participant"),categoryOf:n=>{const i=e.get(n);if(!(!i||i.type==="label"))return cM(i.type,i)},lanesOf:n=>t().filter(i=>i.type==="bpmn:Lane"&&qm(i)===n).sort((i,o)=>i.y-o.y).map(i=>i.id),laneDeclarationOrderOf:n=>{var s;const i=e.get(n),o=(s=i==null?void 0:i.businessObject)==null?void 0:s.processRef,r=[],a=c=>{for(const l of c??[])for(const u of l.lanes??[])r.push(u.id),a(u.childLaneSet?[u.childLaneSet]:void 0)};return a(o==null?void 0:o.laneSets),r},participantOf:n=>{const i=e.get(n);return i?qm(i):void 0},endpointsOf:n=>{var o,r;const i=e.get(n);if(!(!i||i.type==="label")&&"waypoints"in i)return{source:(o=i.source)==null?void 0:o.id,target:(r=i.target)==null?void 0:r.id}},eventDefinitionOf:n=>{var r;const i=e.get(n);if(!i||i.type!=="bpmn:IntermediateCatchEvent")return;const o=(((r=i.businessObject)==null?void 0:r.eventDefinitions)??[]).map(a=>a.$type);return kp(o)},reviewRequestLocalesOf:n=>{const i=e.get(n);return!i||i.type==="label"?[]:$o(i.businessObject).map(o=>o.locale)}}}const df=20,lM=4,Ke=(e,t)=>Math.abs(e-t)<.5;function qc(e,t,n,i=df){if(Ke(e.y,t.y)&&!Ke(e.x,t.x)){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x);if(!(o<n.x-i&&n.x+n.width+i<r))return null;const a=e.x<t.x?n.x-i:n.x+n.width+i,s=e.x<t.x?n.x+n.width+i:n.x-i,c=l=>[{x:a,y:e.y},{x:a,y:l},{x:s,y:l},{x:s,y:e.y}];return[c(n.y-i),c(n.y+n.height+i)]}if(Ke(e.x,t.x)&&!Ke(e.y,t.y)){const o=Math.min(e.y,t.y),r=Math.max(e.y,t.y);if(!(o<n.y-i&&n.y+n.height+i<r))return null;const a=e.y<t.y?n.y-i:n.y+n.height+i,s=e.y<t.y?n.y+n.height+i:n.y-i,c=l=>[{x:e.x,y:a},{x:l,y:a},{x:l,y:s},{x:e.x,y:s}];return[c(n.x-i),c(n.x+n.width+i)]}return null}function Km(e,t,n,i=df){if(n.length<2)return null;if(Ke(e.y,t.y)&&!Ke(e.x,t.x)){const o=Math.min(e.x,t.x),r=Math.max(e.x,t.x),a=Math.min(...n.map(d=>d.x))-i,s=Math.max(...n.map(d=>d.x+d.width))+i;if(!(o<a&&s<r))return null;const c=e.x<t.x?a:s,l=e.x<t.x?s:a,u=Math.min(...n.map(d=>d.y))-i,p=Math.max(...n.map(d=>d.y+d.height))+i,f=d=>[{x:c,y:e.y},{x:c,y:d},{x:l,y:d},{x:l,y:e.y}];return[f(u),f(p)]}if(Ke(e.x,t.x)&&!Ke(e.y,t.y)){const o=Math.min(e.y,t.y),r=Math.max(e.y,t.y),a=Math.min(...n.map(d=>d.y))-i,s=Math.max(...n.map(d=>d.y+d.height))+i;if(!(o<a&&s<r))return null;const c=e.y<t.y?a:s,l=e.y<t.y?s:a,u=Math.min(...n.map(d=>d.x))-i,p=Math.max(...n.map(d=>d.x+d.width))+i,f=d=>[{x:e.x,y:c},{x:d,y:c},{x:d,y:l},{x:e.x,y:l}];return[f(u),f(p)]}return null}function Xm(e,t,n=df){if(e.length!==4)return null;const[i,o,r,a]=e;if(Ke(i.y,o.y)&&Ke(o.x,r.x)&&Ke(r.y,a.y)){const s=c=>[i,{x:c,y:i.y},{x:c,y:a.y},a];return[s(t.x-n),s(t.x+t.width+n)]}if(Ke(i.x,o.x)&&Ke(o.y,r.y)&&Ke(r.x,a.x)){const s=c=>[i,{x:i.x,y:c},{x:a.x,y:c},a];return[s(t.y-n),s(t.y+t.height+n)]}return null}function Yc(e,t){if(e.endpoints.length!==2)return[];const n=t.find(p=>p.id===e.endpoints[0]),i=t.find(p=>p.id===e.endpoints[1]);if(!n||!i)return[];if(i.x<=n.x+n.width)return[];const o=n.y+n.height/2,r=i.y+i.height/2;if(o>=i.y&&o<=i.y+i.height)return[];const a=i.x+i.width/2,s=n.x+n.width/2,c=o>r,l=[{x:n.x+n.width,y:o},{x:a,y:o},{x:a,y:c?i.y+i.height:i.y}],u=[{x:s,y:c?n.y:n.y+n.height},{x:s,y:r},{x:i.x,y:r}];return[l,u]}const Kc=30,uM=[0,-25,25,-40,40];function pM(e,t){if(e.type!=="bpmn:MessageFlow"||e.endpoints.length!==2)return[];const n=t.find(f=>f.id===e.endpoints[0]),i=t.find(f=>f.id===e.endpoints[1]);if(!n||!i)return[];const o=n.y+n.height/2,r=i.y+i.height/2;if(i.y<n.y+n.height&&i.y+i.height>n.y)return[];const a=r<o,s=a?n.y+n.height:n.y,c=a?s+Kc:s-Kc,l=a?i.y+i.height:i.y,u=n.x+n.width/2,p=i.x+i.width/2;return uM.map(f=>[{x:u,y:s},{x:u,y:c},{x:p+f,y:c},{x:p+f,y:l}]).filter(f=>Ht({...e,endpoints:[],waypoints:f},[n]).length===0)}const hf=(e,t,n)=>[...e.slice(0,t+1),...n,...e.slice(t+1)],ya=(e,t,n)=>Ht({...e,waypoints:t},n).length;function Xc(e,t,n,i){let o=[...e.waypoints],r=ya(e,o,t);if(r===0)return null;let a=!1;for(const p of Yc(e,t))if(ya(e,p,t)===0)return p;const s=(i??[]).filter(p=>p.id!==e.id).flatMap(an),c=p=>an({...e,waypoints:p}).some(f=>Wc(f,s).length>0),l=pM(e,t).filter(p=>ya(e,p,t)===0);if(l.length)return l.find(p=>!c(p))??l[0];const u=p=>!n||p.every(f=>f.x>=n.x&&f.x<=n.x+n.width&&f.y>=n.y&&f.y<=n.y+n.height);if(e.endpoints.length===2&&o.length>2){const p=t.find(d=>d.id===e.endpoints[0]),f=t.find(d=>d.id===e.endpoints[1]);if(p&&f&&Ke(p.y+p.height/2,f.y+f.height/2)){const d=[o[0],o[o.length-1]];if(Ke(d[0].y,d[1].y)&&!Ke(d[0].x,d[1].x)){const g=t.filter(y=>!e.endpoints.includes(y.id)&&Ht({...e,waypoints:d},[y]).length>0),h=g.length>=2?Km(d[0],d[1],g):null,w=(h?h.map(y=>[d[0],...y,d[1]]):g.length===1?(qc(d[0],d[1],g[0])??[]).map(y=>[d[0],...y,d[1]]):g.length===0?[d]:[]).filter(y=>ya(e,y,t)===0&&y.length<=o.length).sort((y,v)=>Number(u(v))-Number(u(y)));if(w.length)return w.find(y=>!c(y))??w[0]}}}for(let p=0;p+1<o.length;p++){const f=o[p],d=o[p+1],g=t.filter(w=>!e.endpoints.includes(w.id)&&Ht({...e,waypoints:[f,d]},[w]).length>0);if(g.length<2)continue;const h=Km(f,d,g);if(!h)continue;const m=h.map(w=>hf(o,p,w)).filter(w=>ya(e,w,t)===0).sort((w,y)=>Number(u(y))-Number(u(w)));if(m.length)return m.find(w=>!c(w))??m[0]}for(let p=0;p<lM&&r>0;p++){let f=!1;for(let d=0;d+1<o.length&&!f;d++){const g=o[d],h=o[d+1];for(const m of t){if(e.endpoints.includes(m.id)||Ht({...e,waypoints:[g,h]},[m]).length===0)continue;const w=qc(g,h,m),y=w?w.map(x=>hf(o,d,x)):Xm(o,m)??[];if(!y.length)continue;const v=[...y].sort((x,E)=>Number(u(E))-Number(u(x)));for(const x of v){const E=ya(e,x,t);if(E<r){o=x,r=E,f=!0,a=!0;break}}if(f)break}}if(!f)break}return a&&r===0?o:null}function gf(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=Hn(r),s=new Set,c=ft(r).filter(u=>u.kind==="edge-crosses-shape"&&!t.has(pt(u)));if(!c.length)return s;const l=new Map;for(const u of c){if(u.kind!=="edge-crosses-shape"||l.has(u.edge))continue;const p=r.edges.find(f=>f.id===u.edge);p&&l.set(u.edge,p)}for(const[u,p]of l){if(n&&!n.has(u))continue;const f=i.get(u);if(!f)continue;const d=f.parent,g=d&&typeof d.x=="number"&&typeof d.width=="number"?{x:d.x,y:d.y,width:d.width,height:d.height}:void 0,h=Ht(p,a);if(!n&&h.length&&h.every(x=>x.type==="bpmn:TextAnnotation")){s.add(u);continue}const m=Xc(p,a,g,r.edges);if(!m){h.some(x=>x.type==="bpmn:TextAnnotation")&&s.add(u);continue}const w=r.edges.filter(x=>x.id!==u),y=hi(p,w);hi({...p,waypoints:m},w)>y||o.updateWaypoints(f,m)}return s}const fM=e=>{const t=[];for(let n=0;n+1<e.waypoints.length;n++){const i=e.waypoints[n],o=e.waypoints[n+1];t.push({id:`__ghost:${e.id}:${n}`,type:"bpmn:Task",x:Math.min(i.x,o.x)-1,y:Math.min(i.y,o.y)-1,width:Math.max(2,Math.abs(o.x-i.x)+2),height:Math.max(2,Math.abs(o.y-i.y)+2),container:!1,attached:!1})}return t};function Zc(e){const t=e.parent;return t&&typeof t.x=="number"&&typeof t.width=="number"?{x:t.x,y:t.y,width:t.width,height:t.height}:void 0}const mf=(e,t)=>!t||e.every(n=>n.x>=t.x&&n.x<=t.x+t.width&&n.y>=t.y&&n.y<=t.y+t.height),yf=(e,t)=>fs(e,[t])>0;function Zm(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=Hn(r);let s=r;const c=new Set(ft(r).map(pt));for(const[l,u]of go(r))if(!t.has(`${l}|${u}`))for(const[p,f]of[[l,u],[u,l]]){if(n.has(p))continue;const d=s.edges.find(I=>I.id===p),g=s.edges.find(I=>I.id===f);if(!d||!g)continue;const h=i.get(p);if(!h)continue;const m=Zc(h),w=fM(g),y=[...Yc(d,a)??[]],v=Xc(d,[...a,...w],m,r.edges);v&&y.push(v);for(let I=0;I+1<d.waypoints.length;I++)for(const P of w)for(const k of qc(d.waypoints[I],d.waypoints[I+1],P)??[])y.push(hf(d.waypoints,I,k));const x=s.edges.filter(I=>I.id!==p),E=I=>({...s,edges:s.edges.map(P=>P.id===p?{...P,waypoints:I}:P)}),A=y.find(I=>{const P={...d,waypoints:I};return yf(P,g)||!mf(I,m)||x.some(k=>k.id!==f&&!yf(d,k)&&yf(P,k))?!1:ft(E(I)).every(k=>c.has(pt(k)))});if(A){o.updateWaypoints(h,A),s=E(A);break}}}const dM=["top","bottom","left","right"],Qm={top:{x:0,y:-1},bottom:{x:0,y:1},left:{x:-1,y:0},right:{x:1,y:0}},hs=20,hM=20;function gM(e,t){const n=e.x>=t.x-.5&&e.x<=t.x+t.width+.5,i=e.y>=t.y-.5&&e.y<=t.y+t.height+.5,o=[];return n&&Ke(e.y,t.y)&&o.push("top"),n&&Ke(e.y,t.y+t.height)&&o.push("bottom"),i&&Ke(e.x,t.x)&&o.push("left"),i&&Ke(e.x,t.x+t.width)&&o.push("right"),o.length===1?o[0]:null}const mM=(e,t)=>t==="top"?{x:e.x+e.width/2,y:e.y}:t==="bottom"?{x:e.x+e.width/2,y:e.y+e.height}:t==="left"?{x:e.x,y:e.y+e.height/2}:{x:e.x+e.width,y:e.y+e.height/2};function Jm(e,t,n,i){const o=Qm[t],r=Qm[i],a=o.x===0,s=r.x===0;if(a===s){const p=a?"y":"x",f=a?"x":"y",d=o[p],g=r[p];if(Ke(e[f],n[f]))return d===-g&&d*(n[p]-e[p])>=hs?[e,n]:null;let h;if(d===-g){const w=e[p]+d*hs,y=n[p]-d*hs;if(d*(y-w)<0)return null;h=Math.round((e[p]+n[p])/2)}else h=d>0?Math.max(e[p],n[p])+Kc:Math.min(e[p],n[p])-Kc;const m=(w,y)=>a?{x:y,y:w}:{x:w,y};return[e,m(h,e[f]),m(h,n[f]),n]}const c=a?{x:e.x,y:n.y}:{x:n.x,y:e.y},l=a?o.y*(c.y-e.y):o.x*(c.x-e.x),u=s?r.y*(c.y-n.y):r.x*(c.x-n.x);return l>=hs&&u>=hs?[e,c,n]:null}function yM(e,t,n){const i=e.waypoints;if(i.length<2||!e.source||!e.target||e.source===e.target)return[];const o=e.source===t.id,r=n.get(o?e.target:e.source),a=o?i[i.length-1]:i[0],s=r?gM(a,r):null;if(!s)return[];const c=[];for(const l of dM){const u=mM(t,l),p=o?Jm(u,l,a,s):Jm(a,s,u,l);p&&c.push(p)}return c}const ey=e=>e.slice(1).reduce((t,n,i)=>t+Math.abs(n.x-e[i].x)+Math.abs(n.y-e[i].y),0);function vM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=new Map(r.shapes.map(l=>[l.id,l])),s=new Set(ft(r).map(pt));let c=r;for(const[l,u]of Fi(r)){if(t.has(`${l}|${u}`))continue;const p=c.edges.find(k=>k.id===l),f=c.edges.find(k=>k.id===u);if(!p||!f||p.type!=="bpmn:SequenceFlow"||f.type!=="bpmn:SequenceFlow"||n.has(l)&&n.has(u)||!Fi({edges:[p,f]}).length)continue;const d=p.endpoints.find(k=>f.endpoints.includes(k)),g=d?a.get(d):void 0;if(!g||g.container)continue;const h=i.get(l),m=i.get(u);if(!h||!m)continue;const w=k=>n.has(k.id)?[k.waypoints]:[k.waypoints,...yM(k,g,a)],y=k=>k.length-2,v=w(p).flatMap(k=>w(f).map(H=>({pa:k,pb:H}))).filter(({pa:k,pb:H})=>k!==p.waypoints||H!==f.waypoints).map(k=>({...k,cost:ey(k.pa)+ey(k.pb)+hM*(y(k.pa)+y(k.pb))})).sort((k,H)=>k.cost-H.cost),x=Zc(h),E=Zc(m),A=Fi(c).length,I=new Set(go(c).map(([k,H])=>`${k}|${H}`)),P=v.find(({pa:k,pb:H})=>{const F={...p,waypoints:k},G={...f,waypoints:H};if(Fi({edges:[F,G]}).length||Or(F,G)||!mf(k,x)||!mf(H,E))return!1;const ee={...c,edges:c.edges.map(ce=>ce.id===l?F:ce.id===u?G:ce)};return Fi(ee).length>=A||go(ee).some(([ce,ie])=>!I.has(`${ce}|${ie}`))?!1:ft(ee).every(ce=>s.has(pt(ce)))});P&&(P.pa!==p.waypoints&&o.updateWaypoints(h,P.pa),P.pb!==f.waypoints&&o.updateWaypoints(m,P.pb),c={...c,edges:c.edges.map(k=>k.id===l?{...p,waypoints:P.pa}:k.id===u?{...f,waypoints:P.pb}:k)})}}const bM=40,xM=20;function wM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=l=>{const u=Ue(i),p=Fi(u);return{keys:new Set(ft(u).map(pt)),crossings:go(u).length,shared:p.length,mine:p.filter(([f,d])=>f===l||d===l).length}},a=(l,u)=>{const p=Ue(i),f=p.edges.find(d=>d.id===l);return f?new Set(Ht({...f,waypoints:u},Hn(p)).map(d=>d.id)):null},s=l=>!!l&&l.type==="bpmn:Participant"&&!(l.children??[]).length&&n.has(l.id),c=i.getAll().filter(l=>l.type==="bpmn:MessageFlow"&&!t.has(l.id));for(const l of c){const u=l.source,p=l.target,f=s(u)?u:s(p)?p:void 0;if(!f)continue;const d=f===u?p:u;if(!d||d.type==="bpmn:Participant")continue;const g=d.x+d.width/2;if(g>=f.x+10&&g<=f.x+f.width-10)continue;const h=g>f.x+f.width,m=f.y>d.y,w=m?d.y+d.height:d.y,y=m?f.y:f.y+f.height,v=Math.round((w+y)/2),x=H=>f===u?[...H].reverse():H,E=(l.waypoints??[]).map(H=>({x:H.x,y:H.y})),A=r(l.id),I=a(l.id,E)??new Set,P=h?f.x+f.width:f.x,k=f.x+f.width/2;for(let H=Math.min(bM,f.width/4);h?P-H>k:P+H<k;H+=xM){const F=Math.round(h?P-H:P+H),G=x([{x:g,y:w},{x:g,y:v},{x:F,y:v},{x:F,y}]),ee=a(l.id,G);if(!ee||[...ee].some(ie=>!I.has(ie)))continue;o.updateWaypoints(l,G);const ce=r(l.id);if(ce.crossings<=A.crossings&&ce.shared<=A.shared&&ce.mine<=A.mine&&[...ce.keys].every(ie=>A.keys.has(ie)))break;o.updateWaypoints(l,E)}}}const _M=10;function ty(e,t){if(e.parent){const o=t.find(r=>r.id===e.parent);if(o)return o}const n=e.x+e.width/2,i=e.y+e.height/2;return t.find(o=>n>=o.x&&n<=o.x+o.width&&i>=o.y&&i<=o.y+o.height)}function ny(e,t){if(e.waypoints.length<2||e.endpoints.length!==2)return null;const n=t.shapes.filter(G=>G.type==="bpmn:Participant"&&G.container),i=t.shapes.find(G=>G.id===e.endpoints[0]),o=t.shapes.find(G=>G.id===e.endpoints[1]);if(!i||!o)return null;const r=ty(i,n),a=ty(o,n);if(!r||!a||r.id===a.id)return null;const s=a.y>r.y,c=s?r:a,l=s?a:r,u=n.filter(G=>G.id!==r.id&&G.id!==a.id&&G.y>=c.y+c.height&&G.y+G.height<=l.y).sort((G,ee)=>G.y-ee.y);if(!u.length)return null;const p=u[0],f=u[u.length-1],d=(c.y+c.height+p.y)/2,g=(f.y+f.height+l.y)/2,h=s?d:g,m=s?g:d,w=e.waypoints[0],y=e.waypoints[e.waypoints.length-1],v=Hn(t),x=t.edges.filter(G=>G.id!==e.id),E=gi(e,x),A=Ht(e,v).length;if(E===0&&A===0||A===0&&e.waypoints.length===2)return null;const I=Math.min(...u.map(G=>G.x)),P=Math.max(...u.map(G=>G.x+G.width)),k=(w.x+y.x)/2,H=G=>G.filter((ee,ce)=>ce===0||!(Ke(ee.x,G[ce-1].x)&&Ke(ee.y,G[ce-1].y)));let F;for(let G=I;G<=P;G+=_M){const ee=H([w,{x:w.x,y:h},{x:G,y:h},{x:G,y:m},{x:y.x,y:m},y]),ce={...e,waypoints:ee};if(Ht(ce,v).length>0)continue;const ie=gi(ce,x),be=Math.abs(G-k);(!F||ie<F.cross||ie===F.cross&&be<F.detour)&&(F={pts:ee,cross:ie,detour:be})}return F&&(A>0?F.cross<=E:F.cross<E)?F.pts:null}const EM=new Set(["bpmn:SequenceFlow","bpmn:MessageFlow"]);function SM(e,t,n){var l,u;const{elementRegistry:i}=e,o=e.modeling,r=new Map(t.shapes.map(p=>[p.id,p])),a=Ue(i),s=new Map(a.shapes.map(p=>[p.id,p])),c=Hn(a);for(const p of t.edges){if(!EM.has(p.type)||!p.source||!p.target||n.has(p.id))continue;const f=i.get(p.id);if(!(f!=null&&f.waypoints)||((l=f.source)==null?void 0:l.id)!==p.source||((u=f.target)==null?void 0:u.id)!==p.target)continue;const d=r.get(p.source),g=r.get(p.target),h=s.get(p.source),m=s.get(p.target);if(!d||!g||!h||!m||!Ke(d.width,h.width)||!Ke(d.height,h.height)||!Ke(g.width,m.width)||!Ke(g.height,m.height))continue;const w=h.x-d.x,y=h.y-d.y;if(Ke(w,0)&&Ke(y,0)||!Ke(m.x-g.x,w)||!Ke(m.y-g.y,y))continue;const v=p.waypoints.map(A=>({x:A.x+w,y:A.y+y})),x=f.waypoints.map(A=>({x:A.x,y:A.y}));x.length===v.length&&x.every((A,I)=>Ke(A.x,v[I].x)&&Ke(A.y,v[I].y))||x.length===2&&(Ke(x[0].x,x[1].x)||Ke(x[0].y,x[1].y))&&Ht({...p,waypoints:x},c).length===0||Ht({...p,waypoints:v},c).length>0||o.updateWaypoints(f,v)}}function iy(e,t){const{elementRegistry:n}=e,i=e.modeling,o=Ue(n);for(const r of o.edges){if(r.type!=="bpmn:MessageFlow"||t.has(r.id))continue;const a=Ue(n),s=a.edges.find(u=>u.id===r.id);if(!s)continue;const c=ny(s,a);if(!c)continue;const l=n.get(r.id);l&&i.updateWaypoints(l,c)}}const vf=20,oy=10,ji=10,bf=40,RM=6,CM=40,ry=50;function MM(e,t){return t.some(n=>{const[i,o,r,a]=e.axis==="h"?[n.x,n.x+n.width,n.y,n.y+n.height]:[n.y,n.y+n.height,n.x,n.x+n.width];if(e.hi<=i||e.lo>=o||e.at>r&&e.at<a)return!1;const s=Math.min(Math.abs(e.at-r),Math.abs(e.at-a));return s>0&&s<=RM})}function xf(e,t,n){let i=0;for(let o=1;o<e.length;o++){const r=e[o-1],a=e[o];if(Ke(r.y,a.y))for(const s of n)t.has(s.id)||r.y<=s.y+1||r.y>=s.y+s.height-1||(i+=Math.max(0,Math.min(Math.max(r.x,a.x),s.x+s.width)-Math.max(Math.min(r.x,a.x),s.x)))}return i}function AM(e,t){if(e.axis!=="h")return!1;const n=(i,o)=>e.lo<o&&e.hi>i;return t.some(i=>{const o=i.label;return!o||i.container||!n(i.x,i.x+i.width)||!n(o.x,o.x+o.width)?!1:o.y>=i.y+i.height?e.at>=i.y+i.height&&e.at<=o.y:o.y+o.height<=i.y?e.at>=o.y+o.height&&e.at<=i.y:!1})}function wf(e,t,n){if(t>n)return[];const i=[Math.min(Math.max(e,t),n)];for(let o=oy;o<=n-t;o+=oy)e+o<=n&&i.push(e+o),e-o>=t&&i.push(e-o);return i}function PM(e,t,n,i,o){const r=[],a=e.type==="bpmn:Participant",s=t.type==="bpmn:Participant",c=t.y>=e.y+e.height;if(!c&&t.y+t.height>e.y)return{inPools:r,outside:[]};const l=c?e.y+e.height:e.y,u=c?t.y:t.y+t.height,p=e.x+e.width/2,f=t.x+t.width/2,d=(ie,be)=>be>ie.x+ji&&be<ie.x+ie.width-ji,g=(ie,be)=>ie.width<=2*bf?ie.x+ie.width/2:Math.min(Math.max(be,ie.x+bf),ie.x+ie.width-bf),h=Math.max(e.x,t.x)+ji,m=Math.min(e.x+e.width,t.x+t.width)-ji;if(h<=m){const ie=!a&&d(t,p)?p:!s&&d(e,f)?f:Math.round((h+m)/2);r.push([{x:ie,y:l},{x:ie,y:u}])}const w=s?g(t,p):f,y=a?g(e,f):p;if(!a&&!d(e,w)){const ie=w<e.x?e.x:e.x+e.width;for(const be of wf(e.y+e.height/2,e.y+ji,e.y+e.height-ji))r.push([{x:ie,y:be},{x:w,y:be},{x:w,y:u}])}if(!s&&!d(t,y)){const ie=y<t.x?t.x:t.x+t.width;for(const be of wf(t.y+t.height/2,t.y+ji,t.y+t.height-ji))r.push([{x:y,y:l},{x:y,y:be},{x:ie,y:be}])}const v=(ie,be)=>{if(Math.abs(be-ie)<2*ji)return[];const he=Math.min(ie,be)+ji,ye=Math.max(ie,be)-ji;return wf(Math.round((ie+be)/2),he,ye)};if(!a&&n)for(const ie of v(l,c?n.y+n.height:n.y))r.push([{x:p,y:l},{x:p,y:ie},{x:w,y:ie},{x:w,y:u}]);if(!s&&i)for(const ie of v(u,c?i.y:i.y+i.height))r.push([{x:y,y:l},{x:y,y:ie},{x:f,y:ie},{x:f,y:u}]);const x=Math.min(y,w),E=Math.max(y,w),A=[];for(const[ie,be]of o.filter(he=>he.x<E&&he.x+he.width>x).map(he=>[he.y,he.y+he.height]).sort((he,ye)=>he[0]-ye[0])){const he=A[A.length-1];he&&ie<=he[1]?he[1]=Math.max(he[1],be):A.push([ie,be])}const I=[];for(let ie=1;ie<A.length;ie++)A[ie][0]-A[ie-1][1]>=CM&&I.push(Math.round((A[ie-1][1]+A[ie][0])/2));A.length&&I.push(A[0][0]-ry,A[A.length-1][1]+ry);const P=(ie,be)=>be<ie.y?ie.y:be>ie.y+ie.height?ie.y+ie.height:void 0,k=new Set([a?e.id:n==null?void 0:n.id,s?t.id:i==null?void 0:i.id].filter(ie=>!!ie)),H=e.y+e.height/2,F=t.y+t.height/2,G=F>H?1:-1,ee=(ie,be,he)=>o.some(ye=>!k.has(ye.id)&&ye.x<ie&&ie<ye.x+ye.width&&ye.y<Math.max(be,he)-1&&ye.y+ye.height>Math.min(be,he)+1),ce=[];for(const ie of I){const be=P(e,ie),he=P(t,ie);be===void 0||he===void 0||(ie-H)*G<0&&ee(y,be,ie)||(ie-F)*G>0&&ee(w,he,ie)||ce.push({pts:[{x:y,y:be},{x:y,y:ie},{x:w,y:ie},{x:w,y:he}],len:Math.abs(ie-be)+(E-x)+Math.abs(he-ie)})}return{inPools:r,outside:ce.sort((ie,be)=>ie.len-be.len).map(ie=>ie.pts)}}function TM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=new Map(n.edges.map(d=>[d.id,d.waypoints])),a=n.shapes.filter(d=>d.type==="bpmn:Participant"),s=d=>{let g=d;for(;g&&g.type!=="bpmn:Participant";)g=g.parent;return g==null?void 0:g.id},c=()=>{const d=Ue(i);return{keys:new Set(ft(d).map(pt)),crossings:go(d).length,shared:Fi(d).length}},l=(d,g)=>d.length===g.length&&d.every((h,m)=>Ke(h.x,g[m].x)&&Ke(h.y,g[m].y)),u=d=>{const g=d.source,h=d.target;if(!g||!h)return"skip";const m=Ue(i),w=new Map(m.shapes.map(U=>[U.id,U])),y=s(g),v=s(h),x=new Set([y,v].filter(U=>!!U)),E=m.shapes.filter(U=>U.type==="bpmn:Participant"),A=(d.waypoints??[]).map(U=>({x:U.x,y:U.y})),I=xf(A,x,E);if(I<vf)return"skip";if(t.has(d.id)){const U=r.get(d.id);if(U&&l(U,A)||I-(U?xf(U,x,a):0)<vf)return"skip"}const P=w.get(g.id),k=w.get(h.id),H=m.edges.find(U=>U.id===d.id);if(!P||!k||!H)return"skip";const F=Hn(m),G=new Set(Ht(H,F).map(U=>U.id)),ee=zo(m).filter(U=>U.owner!==d.id&&U.owner!==P.id&&U.owner!==k.id),ce=[...m.shapes.filter(U=>!U.container&&U.id!==P.id&&U.id!==k.id),...ee.map(U=>U.rect)],ie=U=>an({...H,waypoints:U}).some(ue=>MM(ue,ce)),be=PM(P,k,y?w.get(y):void 0,v?w.get(v):void 0,E),he=U=>U.map((ue,K)=>({pts:ue,i:K,key:ue.length*2+(ie(ue)?1:0)})).sort((ue,K)=>ue.key-K.key||ue.i-K.i).map(ue=>ue.pts),ye=[...he(be.inPools),...he(be.outside)],Ee=c();for(const U of ye){if(xf(U,x,E)>=vf)continue;const ue={...H,waypoints:U};if(Ht(ue,F).some(ge=>!G.has(ge.id))||an(ue).some(ge=>AM(ge,m.shapes)||ee.some(Re=>$i(Re.rect,ge))))continue;o.updateWaypoints(d,U);const J=c();if(J.crossings<=Ee.crossings&&J.shared<=Ee.shared&&[...J.keys].every(ge=>Ee.keys.has(ge)))return"fixed";o.updateWaypoints(d,A)}return"stuck"},p=i.getAll().filter(d=>d.type==="bpmn:MessageFlow"),f=[];for(const d of p)u(d)==="stuck"&&f.push(d);for(const d of f)u(d)}const Hi=[25,-25,40,-40],va=35;function kM(e,t,n=[]){const i=e.x+e.width/2,o=t.x+t.width/2,r=[],a=n.filter(s=>!s.container&&s.id!==e.id&&s.id!==t.id&&s.label).map(s=>({...s.label,id:`${s.id}:label`,type:"label",container:!1,attached:!1}));for(const s of[!0,!1]){const c=s?e.y:e.y+e.height,l=s?t.y:t.y+t.height,u=s?Math.min(e.y,t.y)-va:Math.max(e.y+e.height,t.y+t.height)+va,p=DM(e,t,s,u,n),f=p===null?[[u,0]]:[[u,0],[p,OM]];for(const[d,g]of f)for(const h of[0,...Hi])if(!(Math.abs(h)>=e.width/2-5))for(const m of[0,...Hi]){if(Math.abs(m)>=t.width/2-5)continue;const w=i+h,y=o+m,v=[{x:w,y:c},{x:w,y:d},{x:y,y:d},{x:y,y:l}];g&&Ht({endpoints:[],waypoints:v},a).length||r.push({pts:v,cost:g+Math.abs(m)+Math.abs(h)})}}return r}const OM=45,Qc=20;function DM(e,t,n,i,o){if(!o.length)return null;const r=e.x+e.width/2,a=t.x+t.width/2,s=Math.min(r,a),c=Math.max(r,a),l=n?Math.min(e.y,t.y):Math.max(e.y+e.height,t.y+t.height),u=o.filter(m=>m.container&&(m.type==="bpmn:Lane"||m.type==="bpmn:Participant")&&r>=m.x&&r<=m.x+m.width&&e.y>=m.y&&e.y+e.height<=m.y+m.height).sort((m,w)=>m.width*m.height-w.width*w.height)[0];if(!u)return null;const p=o.filter(m=>!m.container&&m.id!==e.id&&m.id!==t.id),f=p.filter(m=>m.x<c&&m.x+m.width>s&&(n?m.y<l&&m.y+m.height>i:m.y+m.height>l&&m.y<i));if(!f.length)return null;const d=[...p,...p.flatMap(m=>m.label?[m.label]:[])].filter(m=>m.x<c&&m.x+m.width>s);if(n){let m=Math.min(...f.map(y=>y.y));for(let y=!0;y;){y=!1;for(const v of d)v.y<m&&v.y<l&&v.y+v.height>m-Qc&&(m=v.y,y=!0)}const w=Math.max(u.y,...d.filter(y=>y.y+y.height<=m).map(y=>y.y+y.height));return m-w>=Qc?Math.round((m+w)/2):null}let g=Math.max(...f.map(m=>m.y+m.height));for(let m=!0;m;){m=!1;for(const w of d)w.y+w.height>g&&w.y+w.height>l&&w.y<g+Qc&&(g=w.y+w.height,m=!0)}const h=Math.min(u.y+u.height,...d.filter(m=>m.y>=g).map(m=>m.y));return h-g>=Qc?Math.round((g+h)/2):null}function Jc(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(i.x+i.width>n.x)return[];const o=n.y+n.height/2;if(o>=i.y&&o<=i.y+i.height)return kM(n,i,[...t.values()]);const r=i.x+i.width/2,a=n.x+n.width/2,s=o<i.y,c=s?i.y:i.y+i.height,l=s?n.y:n.y+n.height,u=s?n.y-va:n.y+n.height+va,p=[];for(const y of[0,...Hi]){if(Math.abs(y)>=i.width/2-5)continue;const v=r+y;p.push({pts:[{x:n.x,y:o},{x:v,y:o},{x:v,y:c}],cost:Math.abs(y)});for(const x of[0,...Hi]){if(Math.abs(x)>=n.width/2-5)continue;const E=a+x;p.push({pts:[{x:E,y:l},{x:E,y:u},{x:v,y:u},{x:v,y:c}],cost:Math.abs(y)+Math.abs(x)})}}const f=50,d=i.y+i.height/2,g=s?n.y+n.height:n.y;for(const y of[0,...Hi]){if(Math.abs(y)>=n.width/2-5)continue;const v=a+y;p.push({pts:[{x:v,y:g},{x:v,y:d},{x:i.x+i.width,y:d}],cost:f+Math.abs(y)})}const h=60,m=s?i.y+i.height:i.y,w=s?i.y+i.height+va:i.y-va;for(const y of[0,...Hi]){if(Math.abs(y)>=i.width/2-5)continue;const v=r+y;for(const x of[0,...Hi]){if(Math.abs(x)>=n.width/2-5)continue;const E=a+x;p.push({pts:[{x:E,y:g},{x:E,y:w},{x:v,y:w},{x:v,y:m}],cost:h+Math.abs(y)+Math.abs(x)})}}return p}const el=30;function ay(e,t){for(let n=1;n<e.length-2;n++){const i=e[n],o=e[n+1],r=Ke(i.y,o.y)&&!Ke(i.x,o.x),a=Ke(i.x,o.x)&&!Ke(i.y,o.y);if(!(!r&&!a))for(const s of t)if(r){const c=Math.min(i.x,o.x);if(Math.max(i.x,o.x)<=s.x||c>=s.x+s.width)continue;if(Math.abs(i.y-s.y)<el||Math.abs(i.y-(s.y+s.height))<el)return!0}else{const c=Math.min(i.y,o.y);if(Math.max(i.y,o.y)<=s.y||c>=s.y+s.height)continue;if(Math.abs(i.x-s.x)<el||Math.abs(i.x-(s.x+s.width))<el)return!0}}return!1}const tl=40;function LM(e,t,n){let i=0;for(const o of t){if(o.container||n.includes(o.id))continue;const r=o.x-tl,a=o.x+o.width+tl,s=o.y-tl,c=o.y+o.height+tl;for(let l=1;l<e.length-2;l++){const u=e[l],p=e[l+1],f={x:Math.min(u.x,p.x),y:Math.min(u.y,p.y)},d={x:Math.max(u.x,p.x),y:Math.max(u.y,p.y)};if(f.x<a&&d.x>r&&f.y<c&&d.y>s){i++;break}}}return i}function sy(e,t){if(e.type!=="bpmn:SequenceFlow")return null;const n=t.shapes.filter(A=>A.container),i=new Map(t.shapes.map(A=>[A.id,A])),o=Hn(t),r=t.edges.filter(A=>A.id!==e.id),a=hi(e,r),s=gi(e,r),c=A=>LM(A,t.shapes,e.endpoints)+(ay(A,n)?1:0),l=c(e.waypoints),u=A=>{if(!A)return;const I=A.x+A.width/2,P=A.y+A.height/2;return n.find(k=>k.type==="bpmn:Lane"&&I>=k.x&&I<=k.x+k.width&&P>=k.y&&P<=k.y+k.height)},p=u(i.get(e.endpoints[0]??"")),f=u(i.get(e.endpoints[1]??"")),d=!!p&&!!f&&p.id!==f.id,g=A=>{if(!d||!f)return!1;for(let I=1;I<A.length-2;I++){const P=A[I],k=A[I+1];if(Ke(P.y,k.y)&&!Ke(P.x,k.x)&&P.y>f.y&&P.y<f.y+f.height)return!0}return!1},h=g(e.waypoints),w=(A=>{if(!A)return;const I=A.x+A.width/2,P=A.y+A.height/2;return n.filter(k=>k.type==="bpmn:Participant"&&I>=k.x&&I<=k.x+k.width&&P>=k.y&&P<=k.y+k.height).sort((k,H)=>k.width*k.height-H.width*H.height)[0]})(i.get(e.endpoints[0]??"")),y=A=>{if(!w)return 0;let I=0;for(let P=1;P<A.length-1;P++){const k=A[P];(k.x<w.x||k.x>w.x+w.width||k.y<w.y||k.y>w.y+w.height)&&I++}return I},v=y(e.waypoints);if(!ay(e.waypoints,n)&&!(d&&!h)&&v===0)return null;const x=A=>A.reduce((I,P,k)=>k?I+Math.abs(P.x-A[k-1].x)+Math.abs(P.y-A[k-1].y):0,0);let E;for(const{pts:A,cost:I}of Jc(e,i)){const P={...e,waypoints:A};if(Ht(P,o).length>0)continue;const k=hi(P,r);if(k>a)continue;const H=y(A);if(H>v)continue;const F=H<v&&k===0;if(!F&&gi(P,r)>s)continue;const G=c(A),ee=g(A);if(!F&&!(ee&&!h)&&G>=l)continue;const ie=ee?0:1,be=x(A);(!E||H<E.out||H===E.out&&(ie<E.lane||ie===E.lane&&(k<E.opp||k===E.opp&&(G<E.sc||G===E.sc&&(I<E.cost||I===E.cost&&be<E.len)))))&&(E={pts:A,out:H,sc:G,lane:ie,opp:k,cost:I,len:be})}return(E==null?void 0:E.pts)??null}function IM(e,t){if(e.type!=="bpmn:SequenceFlow"||e.endpoints.length!==2)return!1;const[n,i]=e.endpoints,o=t.edges.filter(p=>p.type==="bpmn:SequenceFlow"&&p.endpoints.length===2),r=o.filter(p=>p.endpoints[1]===i),a=o.filter(p=>p.endpoints[0]===i);if(r.length!==1||a.length!==1)return!1;const s=t.shapes.find(p=>p.id===n),c=t.shapes.find(p=>p.id===i),l=t.shapes.find(p=>p.id===a[0].endpoints[1]);if(!s||!c||!l||!(s.x+s.width<c.x&&c.x+c.width<l.x))return!1;const u=s.y+s.height/2;return u<l.y||u>l.y+l.height?!1:u<c.y||u>c.y+c.height}function BM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i).edges.filter(a=>(!t.has(a.id)||n.has(a.id))&&a.waypoints.length>=4).map(a=>a.id).sort();for(const a of r){const s=Ue(i),c=s.edges.find(m=>m.id===a);if(!c||c.waypoints.length<4)continue;const l=Hn(s),u=s.edges.filter(m=>m.id!==a),p=Ht(c,l).length,f=hi(c,u),d=gi(c,u),g=n.has(a)?new Set(ft(s).map(pt)):null,h=Yc(c,s.shapes);h.length===2&&IM(c,s)&&h.reverse();for(const m of h){if(m.length>=c.waypoints.length)continue;const w={...c,waypoints:m};if(Ht(w,l).length>p||hi(w,u)>f||gi(w,u)>d)continue;if(g){const v=new Set(ft({...s,edges:s.edges.map(A=>A.id===a?w:A)}).map(pt)),x=[...v].filter(A=>!g.has(A)).length,E=[...g].filter(A=>!v.has(A)).length;if(x>E)continue}const y=i.get(a);y&&o.updateWaypoints(y,m);break}}}function cy(e,t){const{elementRegistry:n}=e,i=e.modeling,o=Ue(n).edges.filter(r=>r.type==="bpmn:SequenceFlow"&&!t.has(r.id)).map(r=>r.id).sort();for(const r of o){const a=Ue(n),s=a.edges.find(u=>u.id===r);if(!s)continue;const c=sy(s,a);if(!c)continue;const l=n.get(r);l&&i.updateWaypoints(l,c)}}function _f(e,t){const n=e.waypoints;if(n.length<3)return[];const i=[],o=t.get(e.endpoints[0]??""),r=t.get(e.endpoints[1]??""),a=Ke(n[0].x,n[1].x)&&!Ke(n[0].y,n[1].y),s=Ke(n[n.length-1].x,n[n.length-2].x)&&!Ke(n[n.length-1].y,n[n.length-2].y);for(const c of Hi){if(a&&o&&Math.abs(c)<o.width/2-5){const l=n.map(u=>({...u}));l[0].x+=c,l[1].x+=c,i.push({pts:l,cost:Math.abs(c)})}if(s&&r&&Math.abs(c)<r.width/2-5){const l=n.map(u=>({...u}));l[l.length-1].x+=c,l[l.length-2].x+=c,i.push({pts:l,cost:Math.abs(c)})}}return i}const ly=e=>e==="bpmn:SequenceFlow"||e==="bpmn:MessageFlow";function NM(e,t,n){const i=e.waypoints;if(i.length<2||!ly(e.type))return[];const o=i[0],r=i[1],a=Ke(o.y,r.y)&&!Ke(o.x,r.x),s=Ke(o.x,r.x)&&!Ke(o.y,r.y);if(!a&&!s)return[];const c=Math.sign(a?r.x-o.x:r.y-o.y);if(!t.some(g=>{if(!ly(g.type)||g.type===e.type||g.waypoints.length<2)return!1;const h=g.waypoints[0],m=g.waypoints[1];return!Ke(h.x,o.x)||!Ke(h.y,o.y)?!1:a?Ke(h.y,m.y)&&Math.sign(m.x-h.x)===c:Ke(h.x,m.x)&&Math.sign(m.y-h.y)===c}))return[];const u=n.get(e.endpoints[0]??""),p=n.get(e.endpoints[1]??"");if(!u)return[];const f=(g,h)=>a?h>g.y+5&&h<g.y+g.height-5:h>g.x+5&&h<g.x+g.width-5,d=[];for(const g of Hi){const h=(a?o.y:o.x)+g;if(!f(u,h)||i.length===2&&(!p||!f(p,h)))continue;const m=i.map(w=>({...w}));for(const w of[m[0],m[1]])a?w.y=h:w.x=h;d.push({pts:m,cost:Math.abs(g)})}return d}function $M(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];if(Math.min(n.x+n.width,i.x+i.width)-Math.max(n.x,i.x)>=1)return[];const o=i.y+i.height<=n.y,r=n.y+n.height<=i.y;if(!o&&!r)return[];const a=i.x>=n.x+n.width,s=i.x+i.width<=n.x;if(!a&&!s)return[];const c=n.x+n.width/2,l=n.y+n.height/2,u=i.x+i.width/2,p=i.y+i.height/2,f=a?n.x+n.width:n.x,d=r?n.y+n.height:n.y,g=a?i.x:i.x+i.width,h=r?i.y:i.y+i.height,m=[];for(const w of[0,...Hi])Math.abs(w)<i.width/2-5&&m.push({pts:[{x:f,y:l},{x:u+w,y:l},{x:u+w,y:h}],cost:Math.abs(w)}),Math.abs(w)<i.height/2-5&&m.push({pts:[{x:c,y:d},{x:c,y:p+w},{x:g,y:p+w}],cost:Math.abs(w)});return m}const FM=[[1/2,0],[1/3,25],[2/3,25]],uy=20;function jM(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];const o=n.y+n.height/2,r=i.y+i.height/2;if(Math.abs(o-r)<1)return[];const a=[],s=(c,l)=>{for(const[u,p]of FM){const f=Math.round(c+(l-c)*u);a.push({pts:[{x:c,y:o},{x:f,y:o},{x:f,y:r},{x:l,y:r}],cost:p})}};return n.x+n.width+uy<=i.x&&s(n.x+n.width,i.x),i.x+i.width+uy<=n.x&&s(n.x,i.x+i.width),a}function Ef(e,t){if(e.type!=="bpmn:SequenceFlow")return[];const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");if(!n||!i)return[];const o=Math.max(n.x,i.x),r=Math.min(n.x+n.width,i.x+i.width);if(r-o<1)return[];const a=i.y+i.height<=n.y,s=n.y+n.height<=i.y;if(!a&&!s)return[];const c=a?n.y:n.y+n.height,l=a?i.y+i.height:i.y,u=(o+r)/2,p=[];for(const f of[0,...Hi]){const d=u+f;d<=o||d>=r||p.push({pts:[{x:d,y:c},{x:d,y:l}],cost:Math.abs(f)})}return p}function py(e,t,n={}){const i=new Map(t.shapes.map(g=>[g.id,g])),o=Hn(t),r=t.edges.filter(g=>g.id!==e.id),a=hi(e,r);if(a===0)return null;const s=gi(e,r);let c;const l=g=>g.reduce((h,m,w)=>w?h+Math.abs(m.x-g[w-1].x)+Math.abs(m.y-g[w-1].y):0,0),u=3,p=g=>{const h=g[0],m=g[g.length-1],w=Math.hypot(m.x-h.x,m.y-h.y);return w>=1&&l(g)/w>=u?1:0},f=p(e.waypoints),d=[...Jc(e,i),...Ef(e,i),..._f(e,i),...NM(e,r,i),...n.sideEntry?jM(e,i):[]];for(const{pts:g,cost:h}of d){const m={...e,waypoints:g};if(Ht(m,o).length>0)continue;const w=hi(m,r),y=gi(m,r),v=a-w+(f-p(g));if(w>=a||y-s>v)continue;const x=l(g);(!c||w<c.opposite||w===c.opposite&&(y<c.cross||y===c.cross&&(h<c.cost||h===c.cost&&x<c.len)))&&(c={pts:g,opposite:w,cross:y,cost:h,len:x})}return(c==null?void 0:c.pts)??null}function fy(e,t){var i;let n=0;for(const o of t)o.id!==e.id&&((i=Or(e,o))==null?void 0:i.kind)==="unrelated"&&n++;return n}function HM(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=Hn(t),o=t.edges.filter(f=>f.id!==e.id),r=fy(e,o);if(r===0)return null;const a=hi(e,o),s=gi(e,o),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[...Jc(e,n),...Ef(e,n),...$M(e,n),..._f(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(Ht(g,i).length>0)continue;const h=fy(g,o);if(h>=r)continue;const m=hi(g,o);if(m-h>a-r)continue;const w=gi(g,o);if(w-s>(r-h)*l)continue;const y=c(f);(!u||h<u.fake||h===u.fake&&(m<u.unreadable||m===u.unreadable&&(w<u.cross||w===u.cross&&(d<u.cost||d===u.cost&&y<u.length))))&&(u={pts:f,fake:h,unreadable:m,cross:w,cost:d,length:y})}return(u==null?void 0:u.pts)??null}function dy(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=ft(Ue(i)).filter(s=>s.kind==="edge-overlap-unrelated"&&!t.has(pt(s)));if(!r.length)return;const a=new Set;for(const s of r)if(s.kind==="edge-overlap-unrelated")for(const c of s.edges)n.has(c)||a.add(c);for(const s of[...a].sort()){const c=Ue(i),l=c.edges.find(f=>f.id===s);if(!l)continue;const u=HM(l,c);if(!u)continue;const p=i.get(s);p&&o.updateWaypoints(p,u)}}function hy(e,t){const n=t.get(e.endpoints[0]??""),i=t.get(e.endpoints[1]??"");return!!n&&!!i&&i.x+i.width>n.x}function gy(e,t,n){var l;if(e.type!=="bpmn:SequenceFlow"||t.type!=="bpmn:SequenceFlow"||((l=Or(e,t))==null?void 0:l.kind)!=="opposite")return!1;const[i,o]=e.endpoints,[r,a]=t.endpoints,s=[i,o].filter(u=>u&&(u===r||u===a)).length;return!(!!o&&o===r||!!a&&a===i)||s!==1?!1:hy(e,n)&&hy(t,n)}function my(e,t,n){let i=0;for(const o of t)o.id!==e.id&&gy(e,o,n)&&i++;return i}function zM(e,t){const n=new Map(t.shapes.map(f=>[f.id,f])),i=Hn(t),o=t.edges.filter(f=>f.id!==e.id),r=my(e,o,n);if(r===0)return null;const a=hi(e,o),s=gi(e,o),c=f=>f.reduce((d,g,h)=>h?d+Math.abs(g.x-f[h-1].x)+Math.abs(g.y-f[h-1].y):0,0),l=2;let u;const p=[...Jc(e,n),...Ef(e,n),..._f(e,n)];for(const{pts:f,cost:d}of p){const g={...e,waypoints:f};if(Ht(g,i).length>0)continue;const h=my(g,o,n);if(h>=r)continue;const m=hi(g,o);if(m-h>a-r)continue;const w=gi(g,o);if(w-s>(r-h)*l)continue;const y=c(f);(!u||h<u.chain||h===u.chain&&(m<u.unreadable||m===u.unreadable&&(w<u.cross||w===u.cross&&(d<u.cost||d===u.cost&&y<u.length))))&&(u={pts:f,chain:h,unreadable:m,cross:w,cost:d,length:y})}return(u==null?void 0:u.pts)??null}function GM(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=new Map(r.shapes.map(l=>[l.id,l])),s=ft(r).filter(l=>l.kind==="edge-overlap-opposite"&&!t.has(pt(l)));if(!s.length)return;const c=new Set;for(const l of s){if(l.kind!=="edge-overlap-opposite")continue;const[u,p]=l.edges.map(f=>r.edges.find(d=>d.id===f));if(!(!u||!p||!gy(u,p,a)))for(const f of l.edges)n.has(f)||c.add(f)}for(const l of[...c].sort()){const u=Ue(i),p=u.edges.find(g=>g.id===l);if(!p)continue;const f=zM(p,u);if(!f)continue;const d=i.get(l);d&&o.updateWaypoints(d,f)}}function yy(e,t,n,i=new Set){const{elementRegistry:o}=e,r=e.modeling,a=new Set,s=Ue(o),c=ft(s).filter(f=>cf(f)&&!t.has(pt(f)));if(!c.length)return a;const l=new Set;for(const f of c)if(cf(f))for(const d of f.edges)n.has(d)||l.add(d);const u=f=>{var d;return((d=s.edges.find(g=>g.id===f))==null?void 0:d.type)??""},p=[...l].sort((f,d)=>{const g=u(f)==="bpmn:SequenceFlow"?0:1,h=u(d)==="bpmn:SequenceFlow"?0:1;return g!==h?g-h:f.localeCompare(d)});for(const f of p){const d=Ue(o),g=d.edges.find(w=>w.id===f);if(!g)continue;const h=py(g,d,{sideEntry:i.has(f)});if(!h)continue;const m=o.get(f);m&&(r.updateWaypoints(m,h),a.add(f))}return a}const VM=10,WM=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;function vy(e,t){const n=e.label;if(!n)return null;const i=t.edges.filter(a=>a.id!==e.id);if(!Uc(e,i))return null;const o=Hn(t),r=i.flatMap(an);for(const a of an(e)){let s=[[a.lo,a.hi]];for(const[d,g]of Wc(a,r))s=s.flatMap(([h,m])=>{const w=[];return d>h&&w.push([h,Math.min(m,d)]),g<m&&w.push([Math.max(h,g),m]),w.filter(([y,v])=>v>y)});const c=a.axis==="h"?n.width:n.height,l=s.find(([d,g])=>g-d>=c+VM*2);if(!l)continue;const u=(l[0]+l[1])/2,p=a.axis==="h"?{x:u,y:a.at-km}:{x:a.at+Tn+n.width/2,y:u},f={x:p.x-n.width/2,y:p.y-n.height/2,width:n.width,height:n.height};if(!Uc({...e,label:f},i)&&!o.some(d=>!e.endpoints.includes(d.id)&&WM(f,d)))return f}return null}const Tn=8;function Sf(e,t){const n=e.label;if(!n)return null;const i=an(e);if(!i.length)return null;const o=n.x+n.width/2,r=n.y+n.height/2,a=f=>{const d=f.axis==="h"?o:r,g=f.axis==="h"?r-f.at:o-f.at,h=d<f.lo?f.lo-d:d>f.hi?d-f.hi:0;return Math.hypot(g,h)},s=i.reduce((f,d)=>a(d)<a(f)?d:f,i[0]),c=[...i,...t.edges.filter(f=>f.id!==e.id).flatMap(an),...t.shapes.filter(f=>f.container).flatMap(ma)],l=f=>!c.some(d=>$i(f,d));if(l(n))return null;const u=(s.axis==="v"?n.height:n.width)+Tn,p=[0,-u,u,-2*u,2*u];if(s.axis==="v")for(const f of[s.at+Tn,s.at-Tn-n.width])for(const d of p){const g=n.y+d;if(g<s.lo||g+n.height>s.hi)continue;const h={...n,x:f,y:g};if(l(h))return h}else for(const f of[s.at-Tn-n.height,s.at+Tn])for(const d of p){const g=n.x+d;if(g<s.lo||g+n.width>s.hi)continue;const h={...n,x:g,y:f};if(l(h))return h}return null}const by=30,UM=(e,t)=>{let n=1/0;for(let i=0;i+1<t.length;i++){const o=t[i],r=t[i+1],a=r.x-o.x,s=r.y-o.y,c=a*a+s*s,l=c?Math.max(0,Math.min(1,((e.x-o.x)*a+(e.y-o.y)*s)/c)):0;n=Math.min(n,Math.hypot(e.x-(o.x+l*a),e.y-(o.y+l*s)))}return n},xy=(e,t)=>UM({x:e.x+e.width/2,y:e.y+e.height/2},t);function qM(e,t){const n=e.label;if(!n)return null;const i=an(e);if(!i.length)return null;const o=[...i,...t.edges.filter(c=>c.id!==e.id).flatMap(an),...t.shapes.filter(c=>c.container).flatMap(ma)],r=zo(t).filter(c=>c.owner!==e.id).map(c=>c.rect),a=(c,l)=>c.x<l.x+l.width&&l.x<c.x+c.width&&c.y<l.y+l.height&&l.y<c.y+c.height,s=c=>!o.some(l=>$i(c,l))&&!ds(c,t).length&&!r.some(l=>a(c,l));for(const c of i){const l=(c.lo+c.hi)/2,u=c.axis==="h"?[c.at+Tn,c.at-Tn-n.height].map(p=>({...n,x:l-n.width/2,y:p})):[c.at+Tn,c.at-Tn-n.width].map(p=>({...n,x:p,y:l-n.height/2}));for(const p of u)if(s(p))return p}return null}function wy(e,t,n=new Set){var s,c;const{elementRegistry:i}=e,o=e.modeling;let r=Ue(i),a=new Set(ft(r).map(pt));for(const[l,u]of t){const p=u.wps,f=i.get(l),d=f==null?void 0:f.label;if(!d||!(f!=null&&f.waypoints))continue;const g=f.waypoints[0].x-p[0].x,h=f.waypoints[0].y-p[0].y;if(!(f.waypoints.length===p.length&&f.waypoints.every((I,P)=>I.x-p[P].x===g&&I.y-p[P].y===h))){if(((s=f.source)==null?void 0:s.id)===u.source&&((c=f.target)==null?void 0:c.id)===u.target)continue;const I=r.edges.find(G=>G.id===l);if(!(I!=null&&I.label)||!ds(I.label,r).length&&!n.has(l))continue;let P={...I.label,x:u.label.x,y:u.label.y};if((ds(P,r).length||xy(P,I.waypoints)>by)&&(P=null),!P&&xy(I.label,I.waypoints)>by&&(P=qM(I,r)),!P)continue;const k=P;if(k.x===d.x&&k.y===d.y)continue;const H={...r,edges:r.edges.map(G=>G.id===l?{...G,label:k}:G)},F=ft(H);if(F.some(G=>!a.has(pt(G))))continue;o.moveElements([d],{x:k.x-d.x,y:k.y-d.y}),r=H,a=new Set(F.map(pt));continue}const w=u.label.x+g-d.x,y=u.label.y+h-d.y;if(w===0&&y===0)continue;const v=r.edges.find(I=>I.id===l);if(!(v!=null&&v.label))continue;const x={...v.label,x:v.label.x+w,y:v.label.y+y},E={...r,edges:r.edges.map(I=>I.id===l?{...I,label:x}:I)},A=ft(E);A.some(I=>!a.has(pt(I)))||(o.moveElements([d],{x:w,y}),r=E,a=new Set(A.map(pt)))}}function _y(e,t,n=new Set){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i);for(const a of r.edges){if(!a.label||t.has(a.id)&&!n.has(a.id))continue;const s=Sf(a,r);if(!s)continue;const c=i.get(a.id),l=c==null?void 0:c.label;l&&o.moveElements([l],{x:s.x-l.x,y:s.y-l.y})}}function Ey(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=Ue(i),a=ft(r).filter(s=>s.kind==="label-on-shared-segment"&&!t.has(pt(s)));for(const s of a){if(s.kind!=="label-on-shared-segment"||n.has(s.edge))continue;const c=r.edges.find(f=>f.id===s.edge);if(!c)continue;const l=vy(c,r);if(!l)continue;const u=i.get(s.edge),p=u==null?void 0:u.label;p&&o.moveElements([p],{x:l.x-p.x,y:l.y-p.y})}}function Sy(e,t){const n=e.label;if(!n)return null;const i=[...t.edges.flatMap(an),...t.shapes.filter(f=>f.container).flatMap(ma)],o=i.filter(f=>$i(n,f));if(!o.length)return null;const r=t.shapes.filter(f=>!f.container&&f.id!==e.id),a=zo(t).filter(f=>f.owner!==e.id).map(f=>f.rect),s=(f,d)=>f.x<d.x+d.width&&d.x<f.x+f.width&&f.y<d.y+d.height&&d.y<f.y+f.height,c=f=>!i.some(d=>$i(f,d))&&!r.some(d=>s(f,d))&&!a.some(d=>s(f,d)),l=[];for(const f of o)f.axis==="h"?l.push({...n,y:f.at-Tn-n.height},{...n,y:f.at+Tn}):l.push({...n,x:f.at-Tn-n.width},{...n,x:f.at+Tn});const u=e.x+e.width/2,p=e.y+e.height/2;return l.push({...n,x:u-n.width/2,y:e.y+e.height+Tn},{...n,x:u-n.width/2,y:e.y-Tn-n.height},{...n,x:e.x+e.width+Tn,y:p-n.height/2},{...n,x:e.x-Tn-n.width,y:p-n.height/2}),l.find(c)??null}function Ry(e,t){const{elementRegistry:n}=e,i=e.modeling,o=Ue(n);for(const r of o.shapes){if(r.container||!r.label||t.has(r.id))continue;const a=Sy(r,Ue(n));if(!a)continue;const s=n.get(r.id),c=s==null?void 0:s.label;c&&i.moveElements([c],{x:a.x-c.x,y:a.y-c.y})}}function YM(e,t){const n=e.x,i=e.x+e.width,o=e.y,r=e.y+e.height;if(t.x<n||t.x>i||t.y<o||t.y>r)return{x:Math.round(Math.min(Math.max(t.x,n),i)),y:Math.round(Math.min(Math.max(t.y,o),r))};const s=[[t.x-n,{x:n,y:t.y}],[i-t.x,{x:i,y:t.y}],[t.y-o,{x:t.x,y:o}],[r-t.y,{x:t.x,y:r}]].reduce((c,l)=>l[0]<c[0]?l:c);return{x:Math.round(s[1].x),y:Math.round(s[1].y)}}function Cy(e,t){const{elementRegistry:n}=e,i=e.modeling;let o=Ue(n),r=new Set(ft(o).map(pt));const a=[...new Set(ft(o).filter(s=>s.kind==="edge-endpoint-detached"&&!t.has(pt(s))).map(s=>s.edge))].sort();for(const s of a){const c=o.edges.find(h=>h.id===s);if(!c||c.waypoints.length<2)continue;const l=c.waypoints.map(h=>({...h})),u=[[c.endpoints[0],0],[c.endpoints[1],l.length-1]];let p=!1;for(const[h,m]of u){const w=h?o.shapes.find(v=>v.id===h):void 0;if(!w)continue;const y=YM(w,l[m]);y.x===l[m].x&&y.y===l[m].y||(l[m]=y,p=!0)}if(!p)continue;const f={...o,edges:o.edges.map(h=>h.id===s?{...h,waypoints:l}:h)},d=ft(f);if(d.some(h=>!r.has(pt(h))))continue;const g=n.get(s);g&&(i.updateWaypoints(g,l),o=f,r=new Set(d.map(pt)))}}const Rf=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function My(e,t){const n=(o,r,a,s="name")=>{const c=s==="text"?"texts":"names",l=u=>r?`${r}.${u}`:u;return{id:o,plainField:l(s),mapField:l(c),plain:a[s],map:a[c]}},i=e;switch(e.kind){case"participant.add":return[n(e.participant.id,"participant",e.participant),...(e.participant.lanes??[]).map((o,r)=>n(o.id,`participant.lanes[${r}]`,o))];case"participant.update":return[n(e.id,"",i),...(e.lanes??[]).map((o,r)=>({...n(o.id,`lanes[${r}]`,o),omittedMeansRemove:(t==null?void 0:t.categoryOf(o.id))==="lane"}))];case"node.add":return[n(e.node.id,"node",e.node)];case"sequenceFlow.add":return[{...n(e.flow.id,"flow",e.flow),condition:e.flow.condition,conditionField:"flow.condition"}];case"sequenceFlow.update":return[{...n(e.id,"",i),condition:e.condition,conditionField:"condition"}];case"messageFlow.add":return[n(e.flow.id,"flow",e.flow)];case"dataStore.add":return[n(e.dataStore.id,"dataStore",e.dataStore)];case"annotation.add":return[n(e.annotation.id,"annotation",e.annotation,"text")];case"annotation.update":return[n(e.id,"",i,"text")];case"group.add":return[n(e.group.id,"group",e.group)];case"node.update":case"messageFlow.update":case"dataStore.update":case"group.update":return[n(e.id,"",i)];default:return[]}}function KM(e,t,n){const i=[],o=n?ss(n):[];return e.forEach((r,a)=>{if(r.kind==="translation.confirm"){if(!n){i.push({kind:"locale-texts-not-enabled",opIndex:a,id:r.id,field:"locale"});return}if(!o.includes(r.locale)){i.push({kind:"locale-not-in-document",opIndex:a,id:r.id,field:"locale",locale:r.locale,locales:o});return}t.categoryOf(r.id)!==void 0&&!t.reviewRequestLocalesOf(r.id).includes(r.locale)&&i.push({kind:"review-request-missing",opIndex:a,id:r.id,locale:r.locale});return}for(const s of My(r,t)){const c=s.plain!==void 0,l=s.map!==void 0;if(c&&l){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.mapField});continue}if(l&&s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-conflict",opIndex:a,id:s.id,field:s.conditionField});continue}if(!n){l&&i.push({kind:"locale-texts-not-enabled",opIndex:a,id:s.id,field:s.mapField});continue}if(c&&s.plain!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.plainField,locales:o});continue}if(s.condition!==void 0&&s.condition!==null){i.push({kind:"locale-texts-required",opIndex:a,id:s.id,field:s.conditionField,locales:o});continue}if(!l)continue;if(!Rf(s.map)){i.push({kind:"payload-invalid",opIndex:a,field:s.mapField});continue}const u=s.map;let p=!0;for(const[d,g]of Object.entries(u))typeof g!="string"||g===""?(i.push({kind:"payload-invalid",opIndex:a,field:`${s.mapField}.${d}`}),p=!1):o.includes(d)||(i.push({kind:"locale-not-in-document",opIndex:a,id:s.id,field:s.mapField,locale:d,locales:o}),p=!1);if(!p)continue;const f=o.filter(d=>!(d in u));f.length&&i.push({kind:"locale-texts-incomplete",opIndex:a,id:s.id,field:s.mapField,missing:f})}}),i}function wi(e,t,n){const i=t==="text"?"texts":"names",{[i]:o,...r}=e;return n===void 0?r:{...r,[t]:n}}function XM(e,t,n){const i=new Map;if(!n)return{ops:[...e],writes:i};const{designLocale:o}=n,r=c=>{let l=i.get(c);return l||i.set(c,l={}),l},a=c=>{if(Rf(c.map)){const l=c.map;return r(c.id).texts={...l},l[o]}if(c.plain===null||c.condition===null&&c.plain===void 0){r(c.id).texts=null;return}c.plain===void 0&&c.omittedMeansRemove&&(r(c.id).texts=null)},s=[];for(const c of e){if(c.kind==="translation.confirm"){const u=r(c.id);u.confirm=[...u.confirm??[],c.locale];continue}const l=My(c,t);if(!l.length){s.push(c);continue}switch(c.kind){case"participant.add":{const[u,...p]=l,f=wi(c.participant,"name",a(u));c.participant.lanes&&(f.lanes=c.participant.lanes.map((d,g)=>wi(d,"name",a(p[g])))),s.push({...c,participant:f});break}case"participant.update":{const[u,...p]=l,f=wi(c,"name",a(u));c.lanes&&(f.lanes=c.lanes.map((d,g)=>wi(d,"name",a(p[g])))),s.push(f);break}case"node.add":s.push({...c,node:wi(c.node,"name",a(l[0]))});break;case"sequenceFlow.add":s.push({...c,flow:wi(c.flow,"name",a(l[0]))});break;case"messageFlow.add":s.push({...c,flow:wi(c.flow,"name",a(l[0]))});break;case"dataStore.add":s.push({...c,dataStore:wi(c.dataStore,"name",a(l[0]))});break;case"annotation.add":s.push({...c,annotation:wi(c.annotation,"text",a(l[0]))});break;case"group.add":s.push({...c,group:wi(c.group,"name",a(l[0]))});break;case"annotation.update":s.push(wi(c,"text",a(l[0])));break;default:s.push(Rf(l[0].map)?wi(c,"name",a(l[0])):(a(l[0]),c))}}return{ops:s,writes:i}}const ZM=/^[\p{L}_][\p{L}\p{N}_.\-]*$/u,Ay=new Set(["sequenceFlow","messageFlow","dataAssociation","association"]),Py={"participant.add":[{path:"participant",shape:["id"]},{path:"participant.lanes[]",shape:["id"],optional:!0}],"participant.update":[{path:"id",shape:null},{path:"lanes[]",shape:["id"],optional:!0}],"node.add":[{path:"node",shape:["id","type"]}],"node.update":[{path:"id",shape:null}],"sequenceFlow.add":[{path:"flow",shape:["id","source","target"]}],"sequenceFlow.update":[{path:"id",shape:null}],"messageFlow.add":[{path:"flow",shape:["id","source","target"]}],"messageFlow.update":[{path:"id",shape:null}],"dataStore.add":[{path:"dataStore",shape:["id"]},{path:"associations[]",shape:["source","target"],optional:!0}],"dataStore.update":[{path:"id",shape:null}],"dataAssociation.add":[{path:"association",shape:["source","target"]}],"association.add":[{path:"association",shape:["source","target"]}],"annotation.add":[{path:"annotation",shape:["id"]},{path:"association",shape:["source","target"],optional:!0},{path:"placement",shape:["anchor","side"],optional:!0}],"annotation.update":[{path:"id",shape:null},{path:"placement",shape:["anchor","side"],optional:!0}],"group.add":[{path:"group",shape:["id"]},{path:"group.members[]",shape:null,optional:!0}],"group.update":[{path:"id",shape:null},{path:"members[]",shape:null,optional:!0}],"translation.confirm":[{path:"id",shape:null},{path:"locale",shape:null}],"element.remove":[{path:"id",shape:null}]},gs=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),nl=e=>typeof e=="string"&&e!=="";function QM(e){const t=[];function n(i,o,r,a){if(a===null){nl(r)||t.push({kind:"payload-invalid",opIndex:i,field:o});return}if(!gs(r)){t.push({kind:"payload-invalid",opIndex:i,field:o});return}for(const s of a)nl(r[s])||t.push({kind:"payload-invalid",opIndex:i,field:`${o}.${s}`})}return e.forEach((i,o)=>{var r,a,s;if(!gs(i)||!nl(i.kind)||!(i.kind in Py)){t.push({kind:"payload-invalid",opIndex:o,field:"kind"});return}for(const c of Py[i.kind]){const l=c.path.endsWith("[]"),u=l?c.path.slice(0,-2):c.path,p=u.split(".");let f=i;for(const g of p.slice(0,-1)){if(!gs(f))break;f=f[g]}if(!gs(f))continue;const d=f[p[p.length-1]];if(!(d===void 0&&c.optional)&&!(d===null&&c.optional)){if(!l){n(o,c.path,d,c.shape);continue}if(!Array.isArray(d)){t.push({kind:"payload-invalid",opIndex:o,field:c.path});continue}d.forEach((g,h)=>n(o,`${u}[${h}]`,g,c.shape))}}if(i.kind==="annotation.add"){const c=i.annotation;gs(c)&&!nl(c.text)&&c.texts===void 0&&t.push({kind:"payload-invalid",opIndex:o,field:"annotation.text"})}if(i.kind==="node.add"||i.kind==="node.update"){const c=i.band;c!==void 0&&(!Number.isInteger(c)||c<0)&&t.push({kind:"payload-invalid",opIndex:o,field:"band"});const l=i.kind==="node.add"?(r=i.node)==null?void 0:r.type:i.type,u=(i.kind==="node.add"?(a=i.node)==null?void 0:a.id:i.id)??"";if(typeof l=="string"&&!Yg(l)){t.push({kind:"node-type-unsupported",opIndex:o,id:u,type:l});return}const p=i.kind==="node.add"?(s=i.node)==null?void 0:s.eventDefinition:i.eventDefinition;if(p!==void 0&&!Kg(p)){t.push({kind:"payload-invalid",opIndex:o,field:i.kind==="node.add"?"node.eventDefinition":"eventDefinition"});return}l==="intermediateCatchEvent"!==(p!==void 0)&&t.push({kind:"event-definition-mismatch",opIndex:o,id:u,...typeof l=="string"?{type:l}:{},...p!==void 0?{eventDefinition:p}:{}})}}),t}function Ty(e,t,n={}){const i=QM(e);if(i.length>0)return i;const o=[],r=new Map,a=new Map;function s(h,m,w){if(!ZM.test(m)){o.push({kind:"id-invalid",opIndex:h,id:m});return}if(t.categoryOf(m)!==void 0||r.has(m)){o.push({kind:"id-duplicate",opIndex:h,id:m});return}r.set(m,{...w,opIndex:h})}e.forEach((h,m)=>{var w;switch(h.kind){case"participant.add":s(m,h.participant.id,{category:"participant",lanes:(h.participant.lanes??[]).map(y=>y.id)});for(const y of h.participant.lanes??[])s(m,y.id,{category:"lane"});break;case"node.add":s(m,h.node.id,{category:"flowNode",participant:h.node.participant});break;case"sequenceFlow.add":s(m,h.flow.id,{category:"sequenceFlow"});break;case"messageFlow.add":s(m,h.flow.id,{category:"messageFlow"});break;case"dataStore.add":s(m,h.dataStore.id,{category:"dataStore"});for(const y of h.associations??[])y.id&&s(m,y.id,{category:"dataAssociation"});break;case"dataAssociation.add":h.association.id&&s(m,h.association.id,{category:"dataAssociation"});break;case"association.add":h.association.id&&s(m,h.association.id,{category:"association"});break;case"annotation.add":s(m,h.annotation.id,{category:"annotation"}),(w=h.association)!=null&&w.id&&s(m,h.association.id,{category:"association"});break;case"group.add":s(m,h.group.id,{category:"group"});break;case"participant.update":if(h.lanes){a.set(h.id,h.lanes.map(y=>y.id));for(const y of h.lanes)t.categoryOf(y.id)===void 0&&s(m,y.id,{category:"lane"})}break}});const c=h=>{var m;return((m=r.get(h))==null?void 0:m.category)??t.categoryOf(h)},l=h=>{const m=r.get(h);return m?m.category==="participant"?h:m.participant:t.categoryOf(h)==="participant"?h:t.participantOf(h)};function u(h,m,w,y){const v=c(m);if(v===void 0){o.push({kind:"ref-missing",opIndex:h,ref:m,role:w});return}if(y&&!y.includes(v)){o.push({kind:"ref-category",opIndex:h,ref:m,role:w,expected:y.join("|"),actual:v});return}return v}const p=t.isCollaboration()||e.some(h=>h.kind==="participant.add"),f=new Map;for(const h of e)h.kind==="node.add"?f.set(h.node.id,h.node.eventDefinition):h.kind==="node.update"&&h.type!==void 0&&f.set(h.id,h.eventDefinition);const d=h=>f.has(h)?f.get(h)==="timer":t.eventDefinitionOf(h)==="timer";return e.forEach((h,m)=>{var w,y;switch(h.kind){case"participant.add":break;case"node.add":{const{participant:v,lane:x}=h.node;if(v===void 0){(p||x!==void 0)&&o.push({kind:"participant-required",opIndex:m,id:h.node.id});break}if(u(m,v,"participant",["participant"])===void 0)break;x!==void 0&&((((w=r.get(v))==null?void 0:w.lanes)??a.get(v)??t.lanesOf(v)).includes(x)||o.push({kind:"lane-unknown",opIndex:m,lane:x,participant:v}));break}case"sequenceFlow.add":{const{id:v,source:x,target:E,name:A,condition:I}=h.flow,P=u(m,x,"source",["flowNode"]),k=u(m,E,"target",["flowNode"]);P&&k&&l(x)!==l(E)&&o.push({kind:"flow-cross-pool",opIndex:m,id:v}),A!==void 0&&I!==void 0&&o.push({kind:"condition-name-conflict",opIndex:m,id:v});break}case"messageFlow.add":{const{id:v,source:x,target:E}=h.flow,A=u(m,x,"source",["flowNode","participant"]),I=u(m,E,"target",["flowNode","participant"]);if(A&&I){const P=l(x),k=l(E);P!==void 0&&P===k&&o.push({kind:"message-flow-same-pool",opIndex:m,id:v})}for(const P of[x,E])d(P)&&o.push({kind:"message-flow-timer-endpoint",opIndex:m,id:v,ref:P});break}case"dataStore.add":{for(const v of h.associations??[]){if([v.source,v.target].filter(A=>A===h.dataStore.id).length!==1){o.push({kind:"data-association-ends",opIndex:m,source:v.source,target:v.target});continue}const E=v.source===h.dataStore.id?v.target:v.source;u(m,E,"dataAssociation",["flowNode"])}break}case"dataAssociation.add":{const{source:v,target:x}=h.association,E=u(m,v,"source"),A=u(m,x,"target");if(E&&A){const I=new Set([E,A]);I.has("dataStore")&&I.has("flowNode")||o.push({kind:"data-association-ends",opIndex:m,source:v,target:x})}break}case"association.add":{const{id:v,source:x,target:E}=h.association,A=u(m,x,"source"),I=u(m,E,"target");A&&I&&A!=="annotation"&&I!=="annotation"&&o.push({kind:"association-detached",opIndex:m,annotation:v??`${x}->${E}`});break}case"annotation.add":{if(h.association){const{source:v,target:x}=h.association;if(v!==h.annotation.id&&x!==h.annotation.id)o.push({kind:"association-detached",opIndex:m,annotation:h.annotation.id});else{const E=v===h.annotation.id?x:v;u(m,E,"association")}}h.placement&&u(m,h.placement.anchor,"anchor");break}case"group.add":{for(const v of h.group.members??[]){const x=u(m,v,"member");x&&Ay.has(x)&&o.push({kind:"ref-category",opIndex:m,ref:v,role:"member",expected:"shape",actual:x})}break}case"participant.update":{if(g(m,h.id,"participant")===void 0)break;if(h.lanes){const v=t.lanesOf(h.id),x=h.lanes.map(P=>P.id);for(const P of v)x.includes(P)||o.push({kind:"lane-shrink-unsupported",opIndex:m,participant:h.id,lane:P});for(const P of x)t.categoryOf(P)!==void 0&&!v.includes(P)&&o.push({kind:"id-duplicate",opIndex:m,id:P});const E=x.filter(P=>v.includes(P)),A=P=>E.every((k,H)=>k===P[H]),I=(((y=t.laneDeclarationOrderOf)==null?void 0:y.call(t,h.id))??v).filter(P=>v.includes(P));E.length===v.length&&!A(v)&&!A(I)&&o.push({kind:"lane-reorder-unsupported",opIndex:m,participant:h.id})}break}case"node.update":{if(g(m,h.id,"flowNode")===void 0)break;if(h.lane!==void 0){const v=t.participantOf(h.id);(v?a.get(v)??t.lanesOf(v):[]).includes(h.lane)||o.push({kind:"lane-unknown",opIndex:m,lane:h.lane,participant:v??""})}break}case"sequenceFlow.update":{if(g(m,h.id,"sequenceFlow")===void 0)break;if(h.name!==void 0&&h.condition!==void 0&&o.push({kind:"condition-name-conflict",opIndex:m,id:h.id}),h.source!==void 0||h.target!==void 0){const v=h.source===void 0||u(m,h.source,"source",["flowNode"])!==void 0,x=h.target===void 0||u(m,h.target,"target",["flowNode"])!==void 0,E=t.endpointsOf(h.id),A=h.source??(E==null?void 0:E.source),I=h.target??(E==null?void 0:E.target);v&&x&&A!==void 0&&I!==void 0&&new Set([l(A),l(I),l(h.id)]).size>1&&o.push({kind:"flow-cross-pool",opIndex:m,id:h.id})}break}case"messageFlow.update":g(m,h.id,"messageFlow");break;case"dataStore.update":g(m,h.id,"dataStore");break;case"annotation.update":{if(g(m,h.id,"annotation")===void 0)break;h.placement&&u(m,h.placement.anchor,"anchor");break}case"group.update":{if(g(m,h.id,"group")===void 0)break;for(const v of h.members??[]){const x=u(m,v,"member");x&&Ay.has(x)&&o.push({kind:"ref-category",opIndex:m,ref:v,role:"member",expected:"shape",actual:x})}break}case"translation.confirm":g(m,h.id);break;case"element.remove":{g(m,h.id)==="lane"&&o.push({kind:"ref-category",opIndex:m,ref:h.id,role:"target",expected:"removable",actual:"lane"});break}}}),o.push(...KM(e,t,n.i18n)),o;function g(h,m,w){if(r.has(m)){o.push({kind:"target-added-in-batch",opIndex:h,id:m});return}const y=t.categoryOf(m);if(y===void 0){o.push({kind:"ref-missing",opIndex:h,ref:m,role:"target"});return}if(w&&y!==w){o.push({kind:"ref-category",opIndex:h,ref:m,role:"target",expected:w,actual:y});return}return y}}function ky(e){return{modeling:e.get("modeling"),bpmnFactory:e.get("bpmnFactory"),elementFactory:e.get("elementFactory"),elementRegistry:e.get("elementRegistry"),canvas:e.get("canvas"),autoPlace:e.get("autoPlace"),bpmnReplace:e.get("bpmnReplace"),spaceTool:e.get("spaceTool")}}function il(e){return`bpmn:${e[0].toUpperCase()}${e.slice(1)}`}const ol={"top-left":[-1,-1],top:[0,-1],"top-right":[1,-1],right:[1,0],"bottom-right":[1,1],bottom:[0,1],"bottom-left":[-1,1],left:[-1,0]},kn=10,JM=300,eA=160,Oy=20,Cf=100,Dy=40,tA=10,nA=["top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"];function Ly(e,t,n){if(!(t.width>0))return;const i=t.x+t.width/2,o=t.y+t.height/2;let r;for(const a of e.getAll()){if(a.type!=="bpmn:Lane")continue;const s=a;typeof s.x!="number"||typeof s.width!="number"||i>=s.x&&i<=s.x+s.width&&o>=s.y&&o<=s.y+s.height&&(!r||s.width*s.height<r.width*r.height)&&(r=s)}return r?{x:n.x,width:n.width,y:r.y,height:r.height}:void 0}const rl=(e,t,n)=>e.y-t.height/2>=n.y&&e.y+t.height/2<=n.y+n.height;function al(e,t,n,i,o){const r=n,a=Ly(e,t,i),s=a??i,c=(ee,ce,ie=s)=>{const[be,he]=ol[ee];let ye={x:t.x+t.width/2+be*(t.width/2+r.width/2+ce),y:t.y+t.height/2+he*(t.height/2+r.height/2+ce)};const Ee=ie.x+kn+r.width/2,U=ie.x+ie.width-kn-r.width/2,ue=ie.y+kn+r.height/2,K=ie.y+ie.height-kn-r.height/2,J={x:Math.min(U,Math.max(Ee,ye.x)),y:Math.min(K,Math.max(ue,ye.y))};return(J.x!==ye.x||J.y!==ye.y)&&(ye=Math.abs(J.x-(t.x+t.width/2))<(t.width+r.width)/2+kn&&Math.abs(J.y-(t.y+t.height/2))<(t.height+r.height)/2+kn?{x:t.x+t.width+kn+r.width/2,y:J.y}:J),ye},l=(i.children??[]).filter(ee=>!("waypoints"in ee&&ee.waypoints)&&ee.type!=="bpmn:Lane"&&ee.type!=="label"&&typeof ee.x=="number"&&ee.id!==o.selfId),u=Ue(e),p=ee=>{var ie,be;if(!o.selfId)return!1;const ce=e.get(ee);return!!ce&&(((ie=ce.source)==null?void 0:ie.id)===o.selfId||((be=ce.target)==null?void 0:be.id)===o.selfId)},f=u.edges.filter(ee=>!p(ee.id)).flatMap(an),d=zo(u).filter(ee=>ee.owner!==o.selfId).map(ee=>ee.rect),g=ee=>({x0:ee.x-r.width/2-kn,x1:ee.x+r.width/2+kn,y0:ee.y-r.height/2-kn,y1:ee.y+r.height/2+kn}),h=ee=>{const ce=g(ee);return l.some(ie=>ce.x0<ie.x+ie.width&&ce.x1>ie.x&&ce.y0<ie.y+ie.height&&ce.y1>ie.y)},m=ee=>{const ce=g(ee);return f.some(ie=>ie.axis==="h"?ie.at>ce.y0&&ie.at<ce.y1&&ie.lo<ce.x1&&ie.hi>ce.x0:ie.at>ce.x0&&ie.at<ce.x1&&ie.lo<ce.y1&&ie.hi>ce.y0)},w=ee=>{const ce=g(ee);return d.some(ie=>ce.x0<ie.x+ie.width&&ce.x1>ie.x&&ce.y0<ie.y+ie.height&&ce.y1>ie.y)},y=u.shapes.filter(ee=>ee.type==="bpmn:Group").flatMap(ee=>[{axis:"h",at:ee.y,lo:ee.x,hi:ee.x+ee.width},{axis:"h",at:ee.y+ee.height,lo:ee.x,hi:ee.x+ee.width},{axis:"v",at:ee.x,lo:ee.y,hi:ee.y+ee.height},{axis:"v",at:ee.x+ee.width,lo:ee.y,hi:ee.y+ee.height}]),v=ee=>{const ce=g(ee);return y.some(ie=>ie.axis==="h"?ie.at>ce.y0&&ie.at<ce.y1&&ie.lo<ce.x1&&ie.hi>ce.x0:ie.at>ce.x0&&ie.at<ce.x1&&ie.lo<ce.y1&&ie.hi>ce.y0)},x=ee=>h(ee)||m(ee)||w(ee)||v(ee),E=ee=>ee.x-r.width/2>=i.x&&ee.x+r.width/2<=i.x+i.width&&ee.y-r.height/2>=i.y&&ee.y+r.height/2<=i.y+i.height,A=ee=>E(ee)&&(!a||rl(ee,r,a));if(o.placement){const ee=Ee=>Ee.startsWith("top")?Ee.replace(/^top/,"bottom"):Ee.replace(/^bottom/,"top"),ce=Ee=>Ee.endsWith("left")?Ee.replace(/left$/,"right"):Ee.replace(/right$/,"left"),ie=o.placement.side,be=[ie,ee(ie),ce(ie),ee(ce(ie)),"top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],he=o.placement.offset??50;let ye=c(ie,he);if(x(ye)||a&&!rl(ye,r,a)){const Ee=(U,ue)=>{const K=new Set;for(const J of be){if(K.has(J))continue;K.add(J);const ge=c(J,he,U);if(ue(ge)&&!x(ge))return ye=ge,!0}return!1};!Ee(s,A)&&a&&Ee(i,E)}return ye}const I=o.from,P=s.x+kn+r.width/2,k=s.x+s.width-kn-r.width/2,H=s.y+kn+r.height/2,F=s.y+s.height-kn-r.height/2;let G={x:Math.min(k,Math.max(P,I.x)),y:Math.min(F,Math.max(H,I.y))};if(x(G)){const ee=(t.width+r.width)/2+kn,ie=[{x:G.x+ee,y:G.y},{x:G.x-ee,y:G.y},{x:G.x,y:G.y-r.height-kn},{x:G.x,y:G.y+r.height+kn}].filter(A).find(be=>!x(be));ie&&(G=ie)}return G}function Ft(e,t){return e.filter(n=>n.kind===t)}function Iy(e,t){const n=new Map,i=new Set(Ft(e,"node.add").map(s=>s.node.id)),o=Ft(e,"sequenceFlow.update"),r=new Set(o.flatMap(s=>s.target!==void 0?[s.target]:[])),a=new Set;for(const s of o){const c=s.source;if(s.target!==void 0||c===void 0||!i.has(c)||r.has(c)||a.has(c))continue;const l=t(s.id),u=l&&Ft(e,"sequenceFlow.add").find(f=>f.flow.source===l&&f.flow.target===c);if(!u)continue;const p=JSON.stringify(u.flow.id);e.some(f=>f!==u&&JSON.stringify(f).includes(p))||(a.add(c),n.set(s.id,u))}return n}class By extends Error{constructor(t){super(t.kind),this.issue=t,this.name="LowerIssueError"}}const Ny=new WeakMap;function iA(e){return Ny.get(e)??new Set}function $y(e,t){var sS,cS,lS,uS,pS,fS,dS,hS,gS,mS,yS,vS,bS,xS,wS,_S,ES,SS,RS,CS,MS,AS,PS,TS,kS,OS,DS,LS,IS;const{modeling:n,bpmnFactory:i,elementFactory:o,elementRegistry:r,canvas:a,autoPlace:s,bpmnReplace:c,spaceTool:l}=t,u=new Set;Ny.set(t,u);const p=()=>a.getRootElement(),f=b=>r.get(b),d=b=>{const _=f(b);if(!_)throw new Error(`하강 참조 해소 실패: ${b}`);return _},g=b=>{let _=b.parent;for(;_;){if(_.type==="bpmn:Participant")return _;_=_.parent}},h=new Map;for(const b of r.filter(_=>!("waypoints"in _&&_.waypoints)&&_.type!=="bpmn:Lane"&&_.type!=="label"&&typeof _.x=="number"))h.set(b.id,{x:b.x,y:b.y});const m=Ft(e,"participant.add"),w=Ft(e,"node.add"),y=Ft(e,"sequenceFlow.add"),v=Ft(e,"messageFlow.add"),x=Ft(e,"dataStore.add"),E=Ft(e,"dataAssociation.add"),A=Ft(e,"annotation.add"),I=Ft(e,"group.add"),P=new Map(w.map(b=>[b.node.id,b])),k=Iy(e,b=>{var _,S;return(S=(_=f(b))==null?void 0:_.source)==null?void 0:S.id}),H=new Set([...k.values()].map(b=>b.flow.id)),F=y.filter(b=>!H.has(b.flow.id)),G=new Set([...k.values()].map(b=>b.flow.target)),ee=b=>Ft(e,"sequenceFlow.update").filter(_=>_.target===b).length+(G.has(b)?1:0),ce=(b,_,S)=>{var L;const O=b.businessObject,B=(((L=O.extensionElements)==null?void 0:L.values)??[]).filter(D=>D.$type!==_),T=S?[...B,i.create(_,S)]:B;if(!T.length){O.extensionElements&&n.updateProperties(b,{extensionElements:void 0});return}const N=i.create("bpmn:ExtensionElements",{values:T});T.forEach(D=>{D.$parent=N}),n.updateProperties(b,{extensionElements:N})},ie=b=>({anchor:b.anchor,side:b.side,...b.offset!==void 0?{offset:b.offset}:{}});for(const b of Ft(e,"element.remove")){const _=f(b.id);if(!_)continue;const S="waypoints"in _?[]:[..._.incoming??[],..._.outgoing??[]];n.removeElements([...S,_])}const be=b=>r.filter(_=>{var S;return _.type==="bpmn:Lane"&&((S=g(_))==null?void 0:S.id)===b}).sort((_,S)=>_.y-S.y),he=[];for(const b of Ft(e,"participant.update")){const _=d(b.id);if(b.name!==void 0&&n.updateProperties(_,{name:b.name??void 0}),!b.lanes)continue;const S=be(b.id);if(!S.length){n.splitLane(_,b.lanes.length),be(b.id).forEach((T,N)=>{const L=b.lanes[N];L&&n.updateProperties(T,{id:L.id,name:L.name})}),he.push({pool:b.id,lanes:new Set(b.lanes.map(T=>T.id))});continue}const O=new Set(S.map(T=>T.id)),B=b.lanes.reduce((T,N,L)=>O.has(N.id)?L:T,-1);b.lanes.forEach((T,N)=>{if(O.has(T.id)){n.updateProperties(d(T.id),{name:T.name});return}const L=N===B+1&&B>=0,D=N===0?n.addLane(be(b.id)[0],"top"):L?n.addLane(be(b.id).at(-1),"bottom"):n.addLane(d(b.lanes[N-1].id),"bottom");n.updateProperties(D,{id:T.id,name:T.name})})}const ye=150,Ee=130,U=80,ue=90,K=180,J=30,ge=30,Re=10,ze=300,$=5,C=(b,_,S,O,B)=>{const T=S-_.width/2,N=O-_.height/2;return(b.children??[]).find(L=>!("waypoints"in L&&L.waypoints)&&L.type!=="bpmn:Lane"&&L.type!=="label"&&!(B!=null&&B.has(L.id))&&typeof L.x=="number"&&T<L.x+L.width+ge&&T+_.width+ge>L.x&&N<L.y+L.height&&N+_.height>L.y)},R=new Set;for(const b of m){R.add(`pool:${b.participant.id}`);for(const _ of b.participant.lanes??[])R.add(_.id)}const W=new Map;for(const b of w){const _=b.node.lane??`pool:${b.node.participant??""}`;let S=W.get(_);S||W.set(_,S=new Set([0])),b.band!==void 0&&S.add(b.band)}const q=new Map;for(const[b,_]of W){if(!R.has(b))continue;const S=[..._].sort((T,N)=>T-N),O=S.map((T,N)=>N===0?0:N%2===1?Math.ceil(N/2):-(N/2)),B=Math.min(...O);q.set(b,new Map(S.map((T,N)=>[T,O[N]-B])))}{const b=new Map;for(const _ of m)(_.participant.lanes??[]).forEach((S,O)=>b.set(S.id,O));for(const[_,S]of q){if(!b.has(_)||S.size<2)continue;const O=b.get(_),B=S.get(0)??0,T=new Set;for(const ne of w){if(ne.node.lane!==_||(ne.band??0)!==0||!ne.node.type.endsWith("Gateway"))continue;const le={in:new Set,out:new Set,cross:new Set};for(const ae of F){const oe=ae.flow.source===ne.node.id;if(!oe&&ae.flow.target!==ne.node.id)continue;const ve=P.get(oe?ae.flow.target:ae.flow.source);if(!ve||ve.node.participant!==ne.node.participant||!ve.node.lane)continue;let me,te=!1;if(ve.node.lane!==_){const Z=b.get(ve.node.lane);if(Z===void 0)continue;me=Z>O?"down":"up",te=!0}else{const Z=S.get(ve.band??0)??B;me=Z>B?"down":Z<B?"up":void 0}me&&(le[oe?"out":"in"].add(me),te&&le.cross.add(me))}for(const ae of["up","down"])le.in.has(ae)&&le.out.has(ae)&&le.cross.has(ae)&&T.add(ae)}if(T.size!==1)continue;const[N]=T,L=Math.max(...S.values()),D=N==="down"?L:0;if(B===D)continue;const z=[...S.entries()].filter(([ne])=>ne!==0).sort((ne,le)=>ne[1]-le[1]),j=[...Array(L+1).keys()].filter(ne=>ne!==D),X=new Map([[0,D]]);z.forEach(([ne],le)=>X.set(ne,j[le])),q.set(_,X)}}const fe=b=>{var _;return(((_=W.get(b))==null?void 0:_.size)??0)>1},Oe=b=>b.band??(b.node.lane||!fe(`pool:${b.node.participant??""}`)?void 0:0),nt=new Map,lt=b=>nt.get(b.node.id)??Oe(b),Vt=new Set,St=new Set,nn=new Set,An=new Set,Vn=new Set,Tt=b=>A.some(_=>{var S,O;return(((S=_.placement)==null?void 0:S.anchor)??(_.association?_.association.source===_.annotation.id?_.association.target:_.association.source:void 0))===b&&((O=_.placement)==null?void 0:O.side.startsWith("bottom"))});{const b=new Map;for(const O of F)b.set(O.flow.target,(b.get(O.flow.target)??0)+1);const _=O=>{const B=[],T=new Set([O]),N=[O];for(;N.length;){const L=N.shift();B.push(L);for(const D of F)D.flow.source!==L||T.has(D.flow.target)||(b.get(D.flow.target)??0)!==1||(T.add(D.flow.target),N.push(D.flow.target))}return B},S=(O,B)=>{var T;return((T=q.get(O))==null?void 0:T.get(B))??B};for(const O of w){if(!O.node.type.endsWith("Gateway"))continue;const B=O.node.lane??`pool:${O.node.participant??""}`,T=q.get(B);if(!T||T.size<2)continue;const N=lt(O);if(N===void 0||S(B,N)!==S(B,0))continue;const L=S(B,N),D=F.filter(ae=>ae.flow.source===O.node.id).map(ae=>P.get(ae.flow.target)).filter(ae=>!!ae&&(ae.node.lane??`pool:${ae.node.participant??""}`)===B),z=D.filter(ae=>{const oe=lt(ae);return oe!==void 0&&S(B,oe)===L&&(b.get(ae.node.id)??0)===1}),j=D.some(ae=>{const oe=lt(ae);return oe!==void 0&&S(B,oe)>L});if(z.length!==1||!j)continue;const X=new Set(D.flatMap(ae=>_(ae.node.id)));if(!F.some(ae=>ae.flow.target===O.node.id&&X.has(ae.flow.source)))continue;const le=new Map;for(const[ae,oe]of T)le.set(ae,oe+1);le.set(-1,0),q.set(B,le);for(const ae of _(z[0].node.id))P.has(ae)&&(nt.set(ae,-1),St.add(ae));Vt.add(O.node.id)}}{const b=j=>j.node.lane??`pool:${j.node.participant??""}`,_=j=>lt(j)??0,S=new Map(m.map((j,X)=>({id:j.participant.id,order:j.order??Number.POSITIVE_INFINITY,declared:X})).sort((j,X)=>j.order!==X.order?j.order-X.order:j.declared-X.declared).map((j,X)=>[j.id,X])),O=j=>j===void 0?void 0:S.get(j)??-1,B=j=>{var le;const X=P.get(j);if(X)return X.node.participant;if(S.has(j))return j;const ne=f(j);if(ne)return ne.type==="bpmn:Participant"?ne.id:(le=g(ne))==null?void 0:le.id},T=new Map;for(const j of F)T.set(j.flow.target,(T.get(j.flow.target)??0)+1);const N=j=>{const X=[j],ne=new Set([j.node.id]);for(let le=0;le<X.length;le++)for(const ae of F){if(ae.flow.source!==X[le].node.id||ne.has(ae.flow.target)||(T.get(ae.flow.target)??0)!==1)continue;const oe=P.get(ae.flow.target);!oe||oe.node.participant!==j.node.participant||(ne.add(oe.node.id),X.push(oe))}return X},L=j=>{const X=new Set(j.map(ae=>ae.node.id)),ne=O(j[0].node.participant);if(ne===void 0)return;const le=new Set;for(const ae of v){const oe=X.has(ae.flow.source)?ae.flow.target:X.has(ae.flow.target)?ae.flow.source:void 0;if(oe===void 0)continue;const ve=O(B(oe));ve===void 0||ve===ne||le.add(ve<ne?"up":"down")}return le.size===1?[...le][0]:void 0},D=new Map;{const j=new Map;for(const oe of F){if(!P.has(oe.flow.source)||!P.has(oe.flow.target))continue;const ve=j.get(oe.flow.source)??[];ve.push(oe.flow.target),j.set(oe.flow.source,ve)}const X=new Map,ne=[],le=new Set,ae=oe=>{X.set(oe,"open");for(const ve of j.get(oe)??[]){const me=X.get(ve);me==="open"?le.add(`${oe}>${ve}`):me||ae(ve)}X.set(oe,"done"),ne.push(oe)};for(const oe of w)X.has(oe.node.id)||ae(oe.node.id);for(const oe of ne.reverse()){const ve=D.get(oe)??0;D.set(oe,ve);for(const me of j.get(oe)??[])!le.has(`${oe}>${me}`)&&(D.get(me)??-1)<ve+1&&D.set(me,ve+1)}}let z=-1e3;for(const j of w){if(!j.node.type.endsWith("Gateway"))continue;const X=b(j),ne=q.get(X);if(!ne)continue;const le=ne.get(_(j))??0,ae=te=>(ne.get(_(te))??0)-le,oe=F.filter(te=>te.flow.source===j.node.id).map(te=>P.get(te.flow.target)).filter(te=>!!te&&b(te)===X&&(T.get(te.node.id)??0)===1&&!St.has(te.node.id)).map(te=>{const Z=N(te);return{root:te,subtree:Z,dir:L(Z)}});if(oe.some(te=>te.dir==="up")&&oe.some(te=>te.dir==="down"))continue;const ve=F.some(te=>{const Z=te.flow.source===j.node.id?P.get(te.flow.target):void 0;return!!Z&&b(Z)===X&&ae(Z)===0});let me=!1;if(!ve){const te=F.filter(de=>de.flow.source===j.node.id).map(de=>P.get(de.flow.target)).filter(de=>!!de&&b(de)===X&&(!!de.node.lane||Oe(de)!==void 0)&&ae(de)<0),Z=te.length?Math.max(...te.map(ae)):void 0,re=te.filter(de=>ae(de)===Z);if(!Tt(j.node.id)&&re.length===1&&(T.get(re[0].node.id)??0)===1&&!Vt.has(j.node.id))continue;me=!0}for(const te of oe){const Z=te.dir;if(!Z||oe.some(Me=>Me!==te&&Me.dir===Z))continue;const re=ae(te.root);if(re===0||(Z==="up"?re<0:re>0)||F.some(Me=>{const ke=Me.flow.target===j.node.id?P.get(Me.flow.source):void 0;if(!ke||b(ke)!==X)return!1;const Fe=ae(ke);return Z==="up"?Fe<0:Fe>0}))continue;const de=[...ne].map(([Me,ke])=>({band:Me,rel:ke-le})).filter(Me=>Z==="up"?Me.rel<0:Me.rel>0).sort((Me,ke)=>Math.abs(ke.rel)-Math.abs(Me.rel));if(!de.length&&Z==="down")continue;const $e=_(te.root),De=te.subtree.filter(Me=>b(Me)===X&&_(Me)===$e),Xe=new Set(te.subtree.map(Me=>Me.node.id)),Ae=De.map(Me=>D.get(Me.node.id)??0),Pe=Math.min(...Ae)-1,Ce=Math.max(...Ae)+1,Te=Me=>!w.some(ke=>{if(Xe.has(ke.node.id)||b(ke)!==X||_(ke)!==Me)return!1;if(!nn.has(Me))return!0;const Fe=D.get(ke.node.id)??0;return Fe>=Pe&&Fe<=Ce});let pe=me?_(j):(sS=de.find(Me=>Te(Me.band)))==null?void 0:sS.band;if(pe===void 0){if(pe=z--,nn.add(pe),Z==="up"){const Me=new Map;for(const[ke,Fe]of ne)Me.set(ke,Fe+1);Me.set(pe,0),q.set(X,Me)}else ne.set(pe,Math.max(...ne.values())+1);(cS=W.get(X))==null||cS.add(pe)}for(const Me of De)nt.set(Me.node.id,pe)}}{const j=oe=>{const ve=F.find(me=>me.flow.target===oe.node.id);return ve?P.get(ve.flow.source):void 0},X=oe=>{const ve=j(oe);if(!ve||!ve.node.type.endsWith("Gateway")||b(ve)!==b(oe))return!1;const me=q.get(b(ve));if(!me)return!1;const te=me.get(_(ve))??0,Z=De=>b(De)===b(ve)?(me.get(_(De))??0)-te:Number.NaN,re=F.filter(De=>De.flow.source===ve.node.id).map(De=>P.get(De.flow.target)).filter(De=>!!De&&(!!De.node.lane||Oe(De)!==void 0));if(re.some(De=>Z(De)===0))return!1;const Q=re.filter(De=>De.node.lane===ve.node.lane&&Z(De)<0);if(!Q.length)return!1;const de=Math.max(...Q.map(Z)),$e=Q.filter(De=>Z(De)===de);return $e.length===1&&$e[0]===oe&&(T.get(oe.node.id)??0)===1&&!Tt(ve.node.id)&&!Vt.has(ve.node.id)},ne=new Set;for(const oe of w){if(!oe.node.type.endsWith("Gateway")||Tt(oe.node.id))continue;const ve=q.get(b(oe));if(!ve)continue;const me=ve.get(_(oe))??0;let te;for(const Z of F){if(Z.flow.source!==oe.node.id)continue;const re=P.get(Z.flow.target);if(!re||b(re)!==b(oe)||!re.node.lane&&Oe(re)===void 0)continue;const Q=ve.get(_(re))??0;Q<=me||(!te||Q>te.row?te={id:re.node.id,row:Q,count:1}:Q===te.row&&te.count++)}te&&te.count===1&&(T.get(te.id)??0)===1&&ne.add(te.id)}const le=new Set,ae=[...w].sort((oe,ve)=>Number(ne.has(oe.node.id))-Number(ne.has(ve.node.id)));for(const oe of ae){const ve=b(oe),me=q.get(ve);if(!me)continue;const te=oe.node.id,Z=v.filter(wt=>wt.flow.target===te);if(Z.length!==1||!(T.get(te)??0)||!oe.node.lane&&Oe(oe)===void 0||St.has(te)||An.has(te))continue;const re=(lS=P.get(Z[0].flow.source))==null?void 0:lS.node.participant;if(!re||re===oe.node.participant)continue;const Q=O(oe.node.participant),de=O(re);if(Q===void 0||de===void 0||Q===de)continue;const $e=de<Q,De=me.get(0)??0,Xe=(me.get(_(oe))??De)-De;if(Xe===0||($e?Xe<0:Xe>0)||X(oe))continue;let Ae;for(const[wt,rn]of me){if(nn.has(wt))continue;const Kt=rn-De;($e?Kt<0&&(!Ae||Kt<Ae.row):Kt>0&&(!Ae||Kt>Ae.row))&&(Ae={band:wt,row:Kt})}if(!Ae)continue;const Pe=_(oe),Ce=N(oe).filter(wt=>b(wt)===ve&&_(wt)===Pe&&!St.has(wt.node.id)),Te=j(oe),pe=Te!=null&&Te.node.type.endsWith("Gateway")?`${Te.node.id}|${ve}|${Ae.band}`:void 0,Me=Ae,ke=!!pe&&ne.has(te)&&F.some(wt=>{if(wt.flow.source!==Te.node.id||wt.flow.target===te)return!1;const rn=P.get(wt.flow.target);return!!rn&&b(rn)===ve&&!Ce.includes(rn)&&_(rn)===Me.band});let Fe=Ae.band;if(pe&&(le.has(pe)||ke)){if(Fe=z--,nn.add(Fe),$e){const wt=new Map;for(const[rn,Kt]of me)wt.set(rn,Kt+1);wt.set(Fe,0),q.set(ve,wt)}else me.set(Fe,Math.max(...me.values())+1);(uS=W.get(ve))==null||uS.add(Fe)}pe&&le.add(pe);for(const wt of Ce)nt.set(wt.node.id,Fe),An.add(wt.node.id);$e&&ne.has(te)&&Vn.add(te)}}}const $t=(b,_)=>{var S;return((S=q.get(b))==null?void 0:S.get(_))??_},xn=(b,_,S,O)=>{const B=b?f(b):_?f(_):void 0;if(!B)return!1;const T=b?B.y+Math.min(B.height/2,ue):B.y+U;return Math.abs(T+$t(b??`pool:${_??""}`,S)*ye-O)<=ye/2},vr=new Map;for(const[b,_]of W){let S=0;for(const O of _)S=Math.max(S,$t(b,O));vr.set(b,S)}const Qn=b=>K+ye*b,Jn=(b,_,S,O)=>{const B=p().children.filter(T=>!("waypoints"in T&&T.waypoints)&&T.type!=="label"&&T.id!==_&&!(O!=null&&O.has(T.id))&&typeof T.y=="number"&&T.y>=b);B.length&&n.moveElements(B,{x:0,y:S})},bi=(b,_,S)=>{const O=b.type==="bpmn:Participant"?b:void 0;if(!O||O.children.some(L=>L.type==="bpmn:Lane"))return;const B=S+_.height/2+J-O.y;if(O.height>=B)return;const T=B-O.height,N=O.y+O.height;n.resizeShape(O,{x:O.x,y:O.y,width:O.width,height:B}),Jn(N,O.id,T)},hn=(b,_)=>{const S=_-b.height;if(S<=0)return new Set;const O=g(b)??b,B=[],T=D=>{B.push(D);for(const z of D.children??[])T(z)};T(O);const N=b.y+b.height-10,L=l.calculateAdjustments(B,"y",S,N);return l.makeSpace(L.movingShapes,L.resizingShapes,{x:0,y:S},"s",N),new Set(L.movingShapes.map(D=>D.id))},Do=(b,_,S)=>{if(b){const N=d(b),L=Qn(_);if(N.height>=L)return;const D=L-N.height,z=g(N),j=z?z.y+z.height:N.y+N.height,X=hn(N,L);Jn(j,z==null?void 0:z.id,D,X);return}if(!S)return;const O=ye*(_+1);if(S.height>=O)return;const B=O-S.height,T=S.y+S.height;n.resizeShape(S,{x:S.x,y:S.y,width:S.width,height:O}),Jn(T,S.id,B)},Qa=new Map;for(const b of F)Qa.set(b.flow.target,(Qa.get(b.flow.target)??0)+1);const pi=b=>(Qa.get(b)??0)<=1,xt=new Set(w.map(b=>b.node.id).filter(b=>ee(b)===1&&!F.some(_=>_.flow.target===b||_.flow.source===b&&P.has(_.flow.target)))),Rt=new Map,P1=(b,_)=>{if(!b)return;const S=f(b);if(!S||S.height>=Qn(_))return;const O=S.y+S.height-10,B=g(S);if(B)return new Set((B.children??[]).filter(T=>T.type!=="bpmn:Lane"&&typeof T.y=="number"&&T.y>O).map(T=>T.id))},xp=(b,_,S)=>{if(!b)return!0;const O=f(b);return O?S-_.height/2>=O.y&&S+_.height/2<=O.y+O.height:!0},E3=10,S3=/(Task|Event|Gateway|CallActivity|SubProcess|Transaction)$/;for(const{pool:b,lanes:_}of he){const S=f(b),O=be(b);if(!S||O.length<2)continue;const B=Qn(0),T=E3,N=new Set(Ft(e,"node.update").filter(Q=>Q.lane!==void 0&&_.has(Q.lane)).map(Q=>Q.id)),L=S.children??[],D=L.filter(Q=>!("waypoints"in Q&&Q.waypoints)&&Q.type!=="bpmn:Lane"&&Q.type!=="label"&&typeof Q.y=="number"),z=[];for(const Q of D){z.push([Q.y,Q.y+Q.height]);const de=Q.label;de&&z.push([de.y,de.y+de.height])}for(const Q of L){const de="waypoints"in Q&&Q.waypoints?Q.label:void 0;de&&de.y+de.height>S.y&&de.y<S.y+S.height&&z.push([de.y,de.y+de.height])}for(const Q of p().children){if(Q.type!=="bpmn:TextAnnotation")continue;const de=Q;de.x<S.x+S.width&&de.x+de.width>S.x&&de.y<S.y+S.height&&de.y+de.height>S.y&&z.push([de.y,de.y+de.height])}z.sort((Q,de)=>Q[0]-de[0]);const j=S.y,X=S.y+S.height,ne=[];let le=j;for(const[Q,de]of z)Q>le&&ne.push([le,Q]),le=Math.max(le,de);const ae=D.filter(Q=>S3.test(Q.type)&&!N.has(Q.id)),oe=(Q,de)=>ae.some($e=>$e.y+$e.height/2>=Q&&$e.y+$e.height/2<=de),ve=Q=>z.some(([de,$e])=>de<Q-.5&&Q+.5<$e),me=[];let te=j;for(const Q of O.slice(1).map(de=>de.y)){const de=te+2*T,$e=!ve(Q)&&Q>=de&&Q<=X-2*T?[Q]:[];for(const[Xe,Ae]of ne){const Pe=Math.max(Xe+T,de),Ce=Math.min(Ae-T,X-2*T);Pe<=Ce&&$e.push(Math.min(Math.max(Q,Pe),Ce))}$e.push(Math.max(le+T,de));let De;for(const Xe of $e){const Ae=!oe(te,Xe)&&Xe-te<B?D.filter(Te=>Te.y>=Xe).length:0,Pe=Math.abs(Xe-Q),Ce=De?Math.abs(De.y-Q):0;(!De||Ae<De.cost||Ae===De.cost&&(Pe<Ce||Pe===Ce&&Xe>De.y))&&(De={y:Xe,cost:Ae})}me.push(De.y),te=De.y}const Z=me[me.length-1]+2*T-X;Z>0&&(n.resizeShape(S,{x:S.x,y:S.y,width:S.width,height:S.height+Z}),Jn(X,S.id,Z));const re=[j,...me,S.y+S.height];O.forEach((Q,de)=>{const $e=re[de],De=re[de+1]-$e;(Q.y!==$e||Q.height!==De)&&n.resizeShape(Q,{x:Q.x,y:$e,width:Q.width,height:De})});for(const Q of O){if(Q.height>=B||oe(Q.y,Q.y+Q.height))continue;const de=B-Q.height,$e=S.y+S.height,De=hn(Q,B);Jn($e,S.id,de,De)}}const wp=m.map((b,_)=>({op:b,declared:_}));wp.sort((b,_)=>{const S=b.op.order??Number.POSITIVE_INFINITY,O=_.op.order??Number.POSITIVE_INFINITY;return S!==O?S-O:b.declared-_.declared});let xc=80;for(const b of r.getAll())b.parent===p()&&"height"in b&&typeof b.y=="number"&&(xc=Math.max(xc,b.y+b.height+60));const Og=r.getAll().filter(b=>b.type==="bpmn:Participant"&&b.parent===p()),R3=(()=>{if(!Og.length)return;const b=Og.filter(B=>!Fy(B)),_=b.length?b:Og,S=Math.min(..._.map(B=>B.x)),O=Math.max(..._.map(B=>B.x+B.width));return O>S?{x:S,width:O-S}:void 0})();for(const{op:b}of wp){const _=b.participant,S=w.filter(oe=>oe.node.participant===_.id).length,O=((pS=_.lanes)==null?void 0:pS.length)??0,B=Math.max(1200,S*160+300),T=(_.lanes??[]).map(oe=>Qn(vr.get(oe.id)??0)),N=T.reduce((oe,ve)=>oe+ve,0);O&&N<300&&(T[O-1]+=300-N);const L=Math.max(300,ye*((vr.get(`pool:${_.id}`)??0)+1)),D=_.blackBox||S+O===0?120:O?Math.max(300,N):L,z=_.blackBox?R3:void 0,j=(z==null?void 0:z.x)??100,X=(z==null?void 0:z.width)??B,ne=o.createShape({type:"bpmn:Participant",businessObject:i.create("bpmn:Participant",{id:_.id,name:_.name,...b.order!==void 0?{"bwl:poolOrder":b.order}:{},..._.blackBox?{}:{processRef:i.create("bpmn:Process")}}),width:X,height:D,isExpanded:!0}),le=n.createShape(ne,{x:j+X/2,y:xc+D/2},p()),ae=_.lanes??[];if(ae.length&&n.splitLane(le,ae.length),ae.length){const oe=r.filter(ve=>{var me;return ve.type==="bpmn:Lane"&&((me=g(ve))==null?void 0:me.id)===_.id}).sort((ve,me)=>ve.y-me.y);if(oe.forEach((ve,me)=>{const te=ae[me];te&&n.updateProperties(ve,{id:te.id,name:te.name})}),T.some(ve=>ve!==le.height/O)){let ve=le.y;oe.forEach((me,te)=>{const Z=T[te];n.resizeShape(me,{x:me.x,y:ve,width:me.width,height:Z}),ve+=Z})}}xc=le.y+le.height+60}const C3=b=>{var O;const _=P.get(b);if(_)return _.node.participant??"";const S=f(b);return S?S.type==="bpmn:Participant"?S.id:((O=g(S))==null?void 0:O.id)??"":""},wc=new Map,T1=b=>{let _=wc.get(b);return _||wc.set(b,_={nodes:[],flows:[]}),_};for(const b of w)T1(b.node.participant??"").nodes.push(b);for(const b of F)T1(C3(b.flow.source)).flows.push(b);const _p=b=>{var _;return i.create("bpmn:SequenceFlow",{id:b.id,name:b.name??((_=b.condition)==null?void 0:_.label)})},Dg=(b,_,S)=>o.createShape({type:il(b.type),...b.eventDefinition?{eventDefinitionType:Tc[b.eventDefinition]}:{},businessObject:i.create(il(b.type),{id:b.id,name:b.name,..._!==void 0?{"bwl:band":_}:{},...S!==void 0?{"bwl:afterColumn":S}:{}})}),M3=[...wp.map(({op:b})=>b.participant.id).filter(b=>wc.has(b)),...[...wc.keys()].filter(b=>!m.some(_=>_.participant.id===b))],Lg=b=>b.endsWith("Gateway");for(const b of M3){const _=wc.get(b),S=b?d(b):void 0,O=S?S.x+150:250;let B=S?S.y+80:120;const T=(Z,re,Q)=>{if(Z){const de=d(Z);return de.y+Math.min(de.height/2,ue)+$t(Z,re??0)*ye}return re!==void 0&&S?S.y+U+$t(`pool:${b}`,re)*ye:Q},N=(Z,re,Q)=>{if(Z){const de=d(Z);return de.y+Math.min(de.height/2,ue)+re*ye}return S?S.y+U+re*ye:Q},L=Z=>Z.participant?d(Z.participant):p(),D=(Z,re,Q,de,$e,De,Xe,Ae)=>{const Pe=Q!==void 0||de!==void 0,Ce=ke=>{const Fe=()=>Do(Q,ke,S);Ae?Ae(Fe):Fe()},Te=$t(Q??`pool:${b}`,de??0);if((de===void 0||xn(Q,b,de,Xe??Number.NaN))&&Xe!==void 0&&xp(Q,re,Xe)&&!C(Z,re,$e,Xe))return{x:$e,y:Xe};if(Pe)for(let ke=0;ke<4;ke++){const Fe=N(Q,Te+ke,De);if(!C(Z,re,$e,Fe,P1(Q,Te+ke)))return Ce(Te+ke),{x:$e,y:Fe}}const pe=T(Q,de,De);Pe?Ce(Te):Ae?Ae(()=>bi(Z,re,re.y+re.height/2)):bi(Z,re,pe);let Me=$e;for(let ke=0;ke<64;ke++){const Fe=C(Z,re,Me,pe);if(!Fe)break;Me=Fe.x+Fe.width+Ee+re.width/2}return{x:Me,y:pe}},z=(Z,re,Q)=>{const de=r.getAll().filter(De=>{var Xe;return/Association$/.test(De.type)&&(((Xe=De.waypoints)==null?void 0:Xe.length)??0)>=2});if(!de.length)return Q;const $e=De=>{const Xe={id:re.id,type:re.type,x:De-re.width/2,y:Q.y-re.height/2,width:re.width,height:re.height};return de.some(Ae=>Ae.waypoints.some((Pe,Ce)=>!!Ae.waypoints[Ce+1]&&Dr(Pe,Ae.waypoints[Ce+1],Xe)<=Re))};if(!$e(Q.x))return Q;for(let De=$;De<=ze;De+=$){const Xe=Q.x+De;if(!$e(Xe)&&!C(Z,re,Xe,Q.y))return{x:Xe,y:Q.y}}return Q},j=new Set(_.flows.map(Z=>Z.flow.target)),X=new Map,ne=Z=>{if(Z===void 0)return;const re=r.get(Z);if(!(!re||typeof re.x!="number"||typeof re.width!="number"))return re.x+re.width+Ee},le=Z=>{if(ee(Z)>0)return;const re=_.flows.filter(de=>de.flow.source===Z);if(re.length!==1)return;const Q=r.get(re[0].flow.target);return Q&&typeof Q.y=="number"&&typeof Q.height=="number"?Q.y+Q.height/2:void 0};for(const Z of _.nodes){if(j.has(Z.node.id))continue;const re=Dg(Z.node,Z.band,Z.afterColumn),Q=Oe(Z),de=Z.node.lane?`${Z.node.lane}|${Q??""}`:Q!==void 0?`band:${Q}`:"",$e=L(Z.node),De=X.get(de)??O,Xe=ne(Z.afterColumn),Ae=Xe===void 0?De:Math.max(De,Xe);let Pe;const Ce=D($e,re,Z.node.lane,Q,Ae,B,le(Z.node.id),xt.has(Z.node.id)&&Z.node.participant!==void 0?Te=>Pe=Te:void 0);if(Pe?n.createShape(re,Ce,$e,{autoResize:!1}):n.createShape(re,Ce,$e),Pe){const Te=Z.node.lane?d(Z.node.lane):$e;Rt.set(Z.node.id,{container:Te,relCy:Ce.y-Te.y,grow:Pe})}X.set(de,Ce.x+re.width+Ee),!Z.node.lane&&Q===void 0&&(B+=160)}const ae=new Set,oe=new Map,ve=new Map;if(b&&R.has(`pool:${b}`)){const Z=new Map;for(const Ae of _.flows)Z.set(Ae.flow.target,(Z.get(Ae.flow.target)??0)+1);const re=Ae=>T(Ae.node.lane,lt(Ae),Number.NaN),Q=new Set,de=Ae=>{var Te;const Pe=(Te=P.get(Ae))==null?void 0:Te.node.participant;if(Pe)return f(Pe);const Ce=f(Ae);if(Ce)return Ce.type==="bpmn:Participant"?Ce:g(Ce)},$e=Ae=>{const Pe=[],Ce=new Set([Ae]),Te=[Ae];for(;Te.length;){const pe=Te.shift(),Me=P.get(pe);Me&&Pe.push(Me);for(const ke of _.flows)ke.flow.source!==pe||Ce.has(ke.flow.target)||(Z.get(ke.flow.target)??0)!==1||(Ce.add(ke.flow.target),Te.push(ke.flow.target))}return Pe},De=Ae=>{if(!S)return;const Pe=new Set(Ae.map(pe=>pe.node.id));let Ce=!1,Te=!1;for(const pe of v){if(!Pe.has(pe.flow.source))continue;const Me=de(pe.flow.target);!Me||Me.id===S.id||(Me.y<S.y?Ce=!0:Te=!0)}return Ce&&!Te?"up":Te&&!Ce?"down":void 0};for(const Ae of _.nodes){if(!Lg(Ae.node.type))continue;const Pe=T(Ae.node.lane,Oe(Ae),Number.NaN);if(Number.isNaN(Pe))continue;const Ce=[];for(const ke of _.flows){if(ke.flow.source!==Ae.node.id)continue;const Fe=P.get(ke.flow.target);if(!Fe||Fe.node.lane!==Ae.node.lane||(Z.get(Fe.node.id)??0)!==1)continue;const wt=Oe(Fe);if(wt===void 0)continue;const rn=T(Fe.node.lane,wt,Number.NaN);if(Number.isNaN(rn))continue;const Kt=$e(Fe.node.id),Xt=De(Kt);Xt&&Ce.push({subtree:Kt,band:wt,row:rn,dir:Xt})}if(!Ce.some(ke=>ke.dir==="up")||!Ce.some(ke=>ke.dir==="down")||!Ce.some(ke=>ke.dir==="up"&&Ce.some(Fe=>Fe.dir==="down"&&Fe.row<ke.row)))continue;const pe=[...Ce].sort((ke,Fe)=>ke.row-Fe.row);[...Ce.filter(ke=>ke.dir==="up"),...Ce.filter(ke=>ke.dir==="down")].sort((ke,Fe)=>ke.dir===Fe.dir?ke.row-Fe.row:ke.dir==="up"?-1:1).forEach((ke,Fe)=>{const wt=pe[Fe].band;if(wt!==ke.band){Q.add(Ae.node.id);for(const rn of ke.subtree)Oe(rn)===ke.band&&nt.set(rn.node.id,wt)}})}const Xe=Ae=>{if(!S)return;const Pe=new Set(Ae.map(pe=>pe.node.id));let Ce=!1,Te=!1;for(const pe of v){if(!Pe.has(pe.flow.target))continue;const Me=de(pe.flow.source);!Me||Me.id===S.id||(Me.y<S.y?Ce=!0:Te=!0)}return Ce&&!Te?"up":Te&&!Ce?"down":void 0};for(const Ae of _.nodes){if(!Lg(Ae.node.type))continue;const Pe=Ae.node.lane??`pool:${b}`,Ce=q.get(Pe);if(!Ce||Ce.size<2)continue;const Te=Ce.get(0);if(Te===void 0)continue;const pe=Math.max(...Ce.values()),Me=Te===pe&&Te!==0?"down":void 0;if(!Me)continue;const ke=[];for(const Xt of _.flows){if(Xt.flow.source!==Ae.node.id)continue;const Nn=P.get(Xt.flow.target);if(!Nn||Nn.node.lane!==Ae.node.lane||(Z.get(Nn.node.id)??0)!==1)continue;const wn=lt(Nn);wn!==void 0&&ke.push({t:Nn,subtree:$e(Nn.node.id),band:wn})}const Fe=ke.find(Xt=>(Ce.get(Xt.band)??Xt.band)===Te);if(!Fe||Xe(Fe.subtree)===Me||De(Fe.subtree)===Me)continue;const wt=ke.find(Xt=>Xt!==Fe&&Xe(Xt.subtree)===Me);if(!wt)continue;const rn=Fe.band,Kt=wt.band;for(const Xt of Fe.subtree)lt(Xt)===rn&&nt.set(Xt.node.id,Kt);for(const Xt of wt.subtree)lt(Xt)===Kt&&nt.set(Xt.node.id,rn);Q.add(Ae.node.id)}for(const Ae of _.nodes){if(!Lg(Ae.node.type))continue;const Pe=re(Ae);if(Number.isNaN(Pe)||Tt(Ae.node.id))continue;let Ce,Te=!1,pe;for(const Me of _.flows){if(Me.flow.source!==Ae.node.id)continue;const ke=P.get(Me.flow.target);if(!ke||!ke.node.lane&&Oe(ke)===void 0)continue;const Fe=re(ke);Number.isNaN(Fe)||(Math.abs(Fe-Pe)<.5&&(Te=!0),Fe>Pe?!Ce||Fe>Ce.row?Ce={id:ke.node.id,row:Fe,count:1}:Fe===Ce.row&&Ce.count++:Fe<Pe&&ke.node.lane===Ae.node.lane&&!An.has(ke.node.id)&&(!pe||Fe>pe.row?pe={op:ke,row:Fe,count:1}:Fe===pe.row&&pe.count++))}Ce&&Ce.count===1&&(Z.get(Ce.id)??0)===1&&!Q.has(Ae.node.id)&&ae.add(Ce.id),!Te&&pe&&pe.count===1&&(Z.get(pe.op.node.id)??0)===1&&!Vt.has(Ae.node.id)&&oe.set(pe.op.node.id,{lane:Ae.node.lane,band:lt(Ae)})}for(const Ae of Vn){const Pe=(fS=_.flows.find(Ce=>Ce.flow.target===Ae))==null?void 0:fS.flow.source;Pe&&!Q.has(Pe)&&ae.add(Ae)}}const me=new Set;let te=0;for(;te++<_.nodes.length+2;){for(let Q=0;Q<_.nodes.length+_.flows.length+2;Q++){let de=!1;for(const $e of _.flows){const De=$e.flow;if(me.has(De.id))continue;const Xe=f(De.source);if(!Xe)continue;const Ae=f(De.target),Pe=P.get(De.target);if(!Ae&&Pe){const Ce=Dg(Pe.node,Pe.band),Te=lt(Pe);if(Pe.node.lane||Te!==void 0){const pe=L(Pe.node),Me=Xe,ke=Me.x+(ve.get(De.source)??0)+Me.width+Ee,Fe=oe.get(De.target),wt=D(pe,Ce,Fe?Fe.lane:Pe.node.lane,Fe?Fe.band:Te,ae.has(De.target)?Me.x+Me.width/2:ke,Number.NaN,Fe||!pi(De.target)?void 0:Me.y+Me.height/2),rn=P.has(De.source)?wt:z(pe,Ce,wt),Kt=n.createShape(Ce,rn,pe);ae.has(De.target)&&ve.set(De.target,ke-(Kt.x+Kt.width/2)),n.connect(Xe,Kt,{type:"bpmn:SequenceFlow",businessObject:_p(De)})}else s.append(Xe,Ce,{connection:{type:"bpmn:SequenceFlow",businessObject:_p(De)}})}else if(Ae)n.connect(Xe,Ae,{type:"bpmn:SequenceFlow",businessObject:_p(De)});else continue;me.add(De.id),de=!0}if(!de)break}const Z=_.nodes.filter(Q=>!f(Q.node.id));if(!Z.length)break;const re=Z[0];{const Q=Dg(re.node,re.band),de=L(re.node),$e=Oe(re);n.createShape(Q,D(de,Q,re.node.lane,$e,O,B),de),!re.node.lane&&$e===void 0&&(B+=160)}}}const k1=new Map;for(const[b,_]of k){const S=f(b),O=f(_.flow.target);if(!(S!=null&&S.target)||!O)continue;const B=S.label&&{x:S.label.x,y:S.label.y,width:S.label.width,height:S.label.height};k1.set(b,{waypoints:S.waypoints.map(L=>({x:L.x,y:L.y})),label:B});const T=S.target,N=L=>({x:L.x+L.width/2,y:L.y+L.height/2});n.reconnect(S,O,T,[N(O),N(T)]),n.layoutConnection(S,{waypoints:[]})}const O1=new Set;{const b=T=>T.endsWith("Task")||T==="bpmn:CallActivity"||T==="bpmn:SubProcess",_=T=>b(T)||T==="bpmn:EndEvent"||T==="bpmn:IntermediateThrowEvent"||T==="bpmn:IntermediateCatchEvent",S=T=>(T??[]).filter(N=>N.type==="bpmn:SequenceFlow"),O=Ft(e,"sequenceFlow.update"),B=(T,N)=>{if(!T)return;const L=N.x+N.width/2,D=N.y+N.height/2;let z;const j=X=>{for(const ne of X.children??[])if(ne.type==="bpmn:Lane"){const le=ne;L>=le.x&&L<=le.x+le.width&&D>=le.y&&D<=le.y+le.height&&(z=le,j(le))}};return j(T),z==null?void 0:z.id};for(const T of O){if(T.source===void 0&&T.target===void 0||k.has(T.id))continue;const N=f(T.id);if(!N)continue;const L=T.source!==void 0?f(T.source):N.source,D=T.target!==void 0?f(T.target):N.target;if(!L||!D||L.id===D.id||P.has(L.id)||P.has(D.id)||!b(L.type)||!_(D.type)||L.parent!==D.parent||S(D.incoming).some(te=>te.id!==N.id)||S(D.outgoing).some(te=>te.id!==N.id)||O.some(te=>te!==T&&(te.target===D.id||te.source===D.id))||D.x>=L.x+L.width)continue;const z=L.parent,j=g(L),X=L.x+L.width+Ee,ne=L.y+L.height/2,le=D.y+D.height/2,ae=B(j,L)===B(j,D),oe=new Set([D.id]),ve=[ae?ne:le,le].find(te=>!C(z,D,X,te,oe));if(ve===void 0)continue;if(n.moveElements([D],{x:X-(D.x+D.width/2),y:ve-le}),j){const te=D.x+D.width+Af-(j.x+j.width);te>0&&sl(n,j,j.width+te)}const me=te=>({x:te.x+te.width/2,y:te.y+te.height/2});n.reconnect(N,L,D,[me(L),me(D)]),Math.abs(me(L).y-me(D).y)>1&&n.layoutConnection(N,{waypoints:[]}),O1.add(T.id)}}const br=40,A3=10,Ep=b=>{const _=j=>j.kind==="label-over-line"||j.kind==="label-over-shape"||j.kind==="label-on-shared-segment"?j.edge===b.id:j.kind==="annotation-over-label"||j.kind==="pool-name-over-label"?j.label===b.id:!1,S=()=>new Map(ft(Ue(r)).filter(j=>!_(j)).map(j=>[pt(j),j])),O=S(),B=j=>[...j].filter(([X])=>!O.has(X)).map(([,X])=>X),T=j=>B(j).length<=[...O.keys()].filter(X=>!j.has(X)).length,N=b.waypoints.map(j=>({x:j.x,y:j.y})),L=b.label,D=L&&{x:L.x,y:L.y};n.layoutConnection(b,{waypoints:[]});const z=S();if(!T(z)){if(B(z).every(j=>j.kind==="edge-crosses-shape"&&j.edge===b.id)){const j=Ue(r),X=j.edges.find(oe=>oe.id===b.id),ne=Hn(j),le=X?Ht(X,ne):[],ae=X&&le.length&&!le.every(oe=>oe.type==="bpmn:TextAnnotation")?Xc(X,ne,Zc(b),j.edges):null;if(ae&&(n.updateWaypoints(b,ae),T(S())))return}n.updateWaypoints(b,N),L&&D&&(L.x!==D.x||L.y!==D.y)&&n.moveElements([L],{x:D.x-L.x,y:D.y-L.y})}},Ig=5,Li=10,D1=200,_c=new Set([...F.map(b=>b.flow.id),...v.map(b=>b.flow.id),...Ft(e,"sequenceFlow.update").map(b=>b.id),...Ft(e,"messageFlow.update").map(b=>b.id)].filter(b=>!!b)),P3=(b,_,S,O,B,T)=>{const N=new Set(b.map(te=>te.id)),L=Math.min(...b.map(te=>te.x))+_-Li,D=Math.max(...b.map(te=>te.x+te.width))+_+D1+Li,z=Math.min(...b.map(te=>te.y+Math.min(0,...S)))-Li,j=Math.max(...b.map(te=>te.y+te.height+Math.max(0,...S)))+Li,X=r.getAll().filter(te=>{if(te.type!=="bpmn:SequenceFlow"&&te.type!=="bpmn:MessageFlow")return!1;const Z=te;return _c.has(Z.id)||!Z.waypoints||Z.waypoints.length<2||[Z.source,Z.target].some(Q=>!Q||N.has(Q.id)||Q.x>=O)?!1:Z.waypoints.some((Q,de)=>{const $e=Z.waypoints[de+1];return!!$e&&Math.max(Q.x,$e.x)>=L&&Math.min(Q.x,$e.x)<=D&&Math.max(Q.y,$e.y)>=z&&Math.min(Q.y,$e.y)<=j})});if(!X.length)return 0;const ne=te=>{const Z=new Map;for(const re of b)for(const Q of S){const de={id:re.id,type:re.type,x:re.x+_+te,y:re.y+Q,width:re.width,height:re.height};for(const $e of X){let De=1/0;for(let Ae=0;Ae+1<$e.waypoints.length;Ae++)De=Math.min(De,Dr($e.waypoints[Ae],$e.waypoints[Ae+1],de));const Xe=`${$e.id}|${re.id}`;Z.set(Xe,Math.min(Z.get(Xe)??1/0,De))}}return Z},le=[...ne(0)].filter(([,te])=>te<=Ig).map(([te])=>te);if(!le.length)return 0;let ae=0;for(let te=1;te<=D1;te++){const Z=ne(te);if([...Z.values()].every(re=>re>Ig)&&le.every(re=>(Z.get(re)??1/0)>=Li)){ae=te;break}}if(!ae)return 0;const oe=Math.min(...b.map(te=>te.x))+_+ae,ve=new Set(le.map(te=>te.slice(0,te.indexOf("|"))));return X.some(te=>te.type==="bpmn:SequenceFlow"&&ve.has(te.id)&&te.waypoints.some((Z,re)=>{const Q=te.waypoints[re+1];if(!Q||Math.min(Z.y,Q.y)>T||Math.max(Z.y,Q.y)<T||Z.y===Q.y)return!1;const de=Z.x+(T-Z.y)*(Q.x-Z.x)/(Q.y-Z.y);return de>B&&de<oe}))?0:ae},xr=(b,_=()=>!0)=>{const S=f(b);if(!S)return[];const O=[S],B=new Set([b]);for(let T=0;T<O.length;T++){const N=O[T].id;for(const L of F){const D=L.flow.target;if(L.flow.source!==N||B.has(D)||!P.has(D))continue;B.add(D);const z=f(D);z&&_(z)&&O.push(z)}}return O},T3=(b,_=()=>!0)=>{const S=f(b);if(!S)return[];const O=[S],B=new Set([b]);for(let T=0;T<O.length;T++){const N=O[T].id;for(const L of F){const D=L.flow.source;if(L.flow.target!==N||B.has(D)||!P.has(D))continue;B.add(D);const z=f(D);z&&_(z)&&O.push(z)}}return O},Ii=30,Bi=b=>!("waypoints"in b&&b.waypoints)&&b.type!=="bpmn:Lane"&&b.type!=="label"&&typeof b.x=="number",Ja=(b,_)=>sl(n,b,_),es=(b,_,S=!1)=>{const O=new Set(b.flatMap(D=>D.subtree.map(z=>z.id)));for(const D of b){const z=(D.pool.children??[]).filter(Bi).filter(X=>!O.has(X.id));if(D.subtree.some(X=>z.some(ne=>X.x+_<ne.x+ne.width+Ii&&X.x+_+X.width+Ii>ne.x&&X.y<ne.y+ne.height&&X.y+X.height>ne.y)))return null}const B=b.map(D=>D.pool.width),T=S?r.filter(D=>Array.isArray(D.waypoints)).map(D=>({c:D,wps:D.waypoints.map(z=>({x:z.x,y:z.y}))})):[],N=r.filter(D=>D.type==="label").map(D=>({label:D,x:D.x,y:D.y}));n.moveElements(b.flatMap(D=>D.subtree),{x:_,y:0});const L=b.map(D=>{const j=Math.max(...D.subtree.map(X=>X.x+X.width))+Af-(D.pool.x+D.pool.width);return j>0&&Ja(D.pool,D.pool.width+j),j});return()=>{n.moveElements(b.flatMap(D=>D.subtree),{x:-_,y:0}),b.forEach((D,z)=>{L[z]>0&&Ja(D.pool,B[z])});for(const{c:D,wps:z}of T){const j=D.waypoints??[];j.length===z.length&&j.every((ne,le)=>Math.abs(ne.x-z[le].x)<=.5&&Math.abs(ne.y-z[le].y)<=.5)||n.updateWaypoints(D,z.map(ne=>({x:ne.x,y:ne.y})))}for(let D=0;D<3;D++){let z=0;for(const j of N){const X=j.x-j.label.x,ne=j.y-j.label.y;Math.abs(X)<=.5&&Math.abs(ne)<=.5||(n.moveElements([j.label],{x:X,y:ne}),z++)}if(!z)break}}},Bg=b=>{var B,T;const _=new Map,S=new Map;for(const N of r.getAll()){if(N.type!=="bpmn:Participant")continue;const L=N;(L.children??[]).length||(_.set(L.id,L),S.set(L.id,[]))}for(const N of r.getAll()){if(N.type!=="bpmn:MessageFlow")continue;const L=N,D=(B=L.source)==null?void 0:B.id,z=(T=L.target)==null?void 0:T.id;D&&z&&S.has(D)&&S.get(D).push(z),D&&z&&S.has(z)&&S.get(z).push(D)}const O=[];for(const[N,L]of S)L.length&&L.every(D=>b.has(D))&&O.push(_.get(N));return O},L1=(b,_)=>{if(!b.length)return null;const S=new Set(b.map(j=>j.id)),O=r.getAll().filter(j=>j.type==="bpmn:Participant"&&!S.has(j.id)),B=Math.min(...O.filter(j=>(j.children??[]).length>0).map(j=>j.x)),T=new Set(b.filter(j=>Math.abs(j.x-B)<=2).map(j=>j.id));if(b.some(j=>{const X=T.has(j.id)?j.x:j.x+_,ne=T.has(j.id)?j.width+_:j.width;return O.some(le=>X<le.x+le.width+Ii&&X+ne+Ii>le.x&&j.y<le.y+le.height&&j.y+j.height>le.y)}))return null;const L=r.filter(j=>j.type==="label").map(j=>({label:j,x:j.x,y:j.y})),D=b.filter(j=>!T.has(j.id)),z=b.filter(j=>T.has(j.id)).map(j=>({pool:j,was:{x:j.x,y:j.y,width:j.width,height:j.height}}));D.length&&n.moveElements(D,{x:_,y:0});for(const{pool:j,was:X}of z)n.resizeShape(j,{...X,width:X.width+_});return()=>{for(const{pool:j,was:X}of z)n.resizeShape(j,X);D.length&&n.moveElements(D,{x:-_,y:0});for(let j=0;j<3;j++){let X=0;for(const ne of L){const le=ne.x-ne.label.x,ae=ne.y-ne.label.y;Math.abs(le)<=.5&&Math.abs(ae)<=.5||(n.moveElements([ne.label],{x:le,y:ae}),X++)}if(!X)break}}},I1=(b,_,S)=>{const O=S.x+S.width/2,B=_.y>S.y,T=B?S.y+S.height:S.y,N=B?_.y:_.y+_.height,L=b.source===_?[{x:O,y:N},{x:O,y:T}]:[{x:O,y:T},{x:O,y:N}],D=Ue(r),z={...D.edges.find(j=>j.id===b.id),waypoints:L};return Ht(z,Hn(D)).length?!1:(n.updateWaypoints(b,L),!0)},k3=()=>{const b=r.filter(N=>N.type==="bpmn:Participant"),_=Math.min(...b.filter(N=>(N.children??[]).length>0).map(N=>N.x)),S=N=>m.some(L=>L.participant.id===N.id),O=N=>!!N&&N.type==="bpmn:Participant"&&!(N.children??[]).length&&Math.abs(N.x-_)<=2&&!S(N),B=N=>!!N&&N.type==="bpmn:Participant"&&(N.children??[]).length>0&&!S(N),T=new Set;for(const N of r.getAll()){if(N.type!=="bpmn:MessageFlow")continue;const L=N;if((L.waypoints??[]).length!==2)continue;const D=[L.source,L.target].find(X=>O(X)||B(X)),z=D===L.source?L.target:L.source;if(!D||!z||z.type==="bpmn:Participant")continue;const j=z.x+z.width/2;B(D)&&(j<D.x||j>D.x+D.width)||T.add(L.id)}return T},O3=b=>{var S;const _=new Map;for(const O of b){const B=r.get(O);if(!B||(B.waypoints??[]).length===2)continue;const T=((S=B.source)==null?void 0:S.type)==="bpmn:Participant"?B.source:B.target,N=T===B.source?B.target:B.source;if(N.x+N.width/2<=T.x+T.width)continue;const L=_.get(T.id)??{pool:T,msgs:[]};L.msgs.push({conn:B,other:N}),_.set(T.id,L)}for(const{pool:O,msgs:B}of _.values()){const T=Math.max(...B.map(({other:ae})=>ae.x+ae.width/2))+Cf;if(r.getAll().some(ae=>{if(ae.type!=="bpmn:Participant"||ae.id===O.id)return!1;const oe=ae;return O.x<oe.x+oe.width+Ii&&T+Ii>oe.x&&O.y<oe.y+oe.height&&O.y+O.height>oe.y}))continue;const L={x:O.x,y:O.y,width:O.width,height:O.height},D=[...O.incoming??[],...O.outgoing??[]],z=D.map(ae=>({c:ae,wps:(ae.waypoints??[]).map(oe=>({x:oe.x,y:oe.y}))})),j=D.flatMap(ae=>{const oe=ae.label;return oe?[{label:oe,x:oe.x,y:oe.y}]:[]}),X=wr();Ja(O,T-O.x);const ne=B.filter(({conn:ae,other:oe})=>I1(ae,O,oe)).length,le=wr();if(!(ne>0&&le.messages>X.messages&&le.lines>=X.lines)){Ja(O,L.width);for(const{c:ae,wps:oe}of z){const ve=ae.waypoints??[];ve.length===oe.length&&ve.every((te,Z)=>Math.abs(te.x-oe[Z].x)<=.5&&Math.abs(te.y-oe[Z].y)<=.5)||n.updateWaypoints(ae,oe.map(te=>({x:te.x,y:te.y})))}for(let ae=0;ae<3;ae++){let oe=0;for(const ve of j){const me=ve.x-ve.label.x,te=ve.y-ve.label.y;Math.abs(me)<=.5&&Math.abs(te)<=.5||(n.moveElements([ve.label],{x:me,y:te}),oe++)}if(!oe)break}}}},B1=()=>{let b=0;for(const _ of r.getAll()){if(_.type!=="bpmn:DataInputAssociation"&&_.type!=="bpmn:DataOutputAssociation")continue;const S=_.waypoints??[];for(let O=1;O<S.length;O++)b+=Math.hypot(S[O].x-S[O-1].x,S[O].y-S[O-1].y)}return b},N1=()=>{let b=0;for(const _ of r.getAll()){if(_.type!=="bpmn:Association")continue;const S=_.waypoints??[];for(let O=1;O<S.length;O++)b+=Math.hypot(S[O].x-S[O-1].x,S[O].y-S[O-1].y)}return b},D3=b=>{const _=[];for(const S of r.getAll()){if(S.type!=="bpmn:TextAnnotation")continue;const O=S;if(b.has(O.id))continue;const T=[...O.incoming??[],...O.outgoing??[]].filter(D=>D.type==="bpmn:Association").map(D=>D.source===O?D.target:D.source);if(!T.length||T.some(D=>D===void 0))continue;const N=D=>{if(!("waypoints"in D&&D.waypoints))return[D.id];const z=D,j=[z.source,z.target];return j.some(X=>!X)?[]:j.map(X=>X.id)},L=T.flatMap(D=>N(D));L.length&&L.every(D=>b.has(D))&&_.push(O)}return _},$1=()=>ft(Ue(r)).filter(b=>b.kind==="edge-crosses-shape").length,F1=b=>{const _=(b.children??[]).filter(Bi);let S=0;for(let O=0;O<_.length;O++)for(let B=O+1;B<_.length;B++){const T=_[O],N=_[B];T.x<N.x+N.width&&T.x+T.width>N.x&&T.y<N.y+N.height&&T.y+T.height>N.y&&S++}return S},wr=()=>{const b=Ue(r),_=S=>S.length>=2&&(S.every(O=>Math.abs(O.x-S[0].x)<.01)||S.every(O=>Math.abs(O.y-S[0].y)<.01));return{messages:b.edges.filter(S=>S.type==="bpmn:MessageFlow"&&S.waypoints.length===2).length,lines:b.edges.filter(S=>_(S.waypoints)).length}},j1=b=>{const _=new Map;for(const O of r.getAll()){if(O.type!=="bpmn:MessageFlow")continue;const B=O;if(!B.waypoints||B.waypoints.length!==2)continue;const T=B.source,N=B.target;if(!T||!N)continue;const L=b.has(T.id);if(L===b.has(N.id))continue;const D=L?N:T,z=g(D);if(!z||b.has(D.id))continue;const j=_.get(z.id);j?D.x<j.minX&&(j.minX=D.x):_.set(z.id,{pool:z,minX:D.x})}const S=[];for(const{pool:O,minX:B}of _.values()){const T=(O.children??[]).filter(N=>Bi(N)&&!b.has(N.id)&&N.x>=B);T.length&&S.push({subtree:T,pool:O})}return S},L3=(b,_,S)=>{const O=new Map(_.map(N=>[N.pool.id,{subtree:[...N.subtree],pool:N.pool}])),B=new Set(b);for(const N of _)for(const L of N.subtree)B.add(L.id);let T=!1;for(;;){let N=0;for(const L of j1(B)){if(L.pool===S)continue;const D=O.get(L.pool.id);D?D.subtree.push(...L.subtree):O.set(L.pool.id,{subtree:[...L.subtree],pool:L.pool});for(const z of L.subtree)B.add(z.id);N+=L.subtree.length}if(!N)break;T=!0}return T?[...O.values()]:null},I3=(b,_)=>{const S=new Map;for(const B of r.getAll()){if(B.type!=="bpmn:DataInputAssociation"&&B.type!=="bpmn:DataOutputAssociation")continue;const T=B,N=T.waypoints;if(!N||N.length<2||!N.every(le=>Math.abs(le.x-N[0].x)<1))continue;const L=T.source,D=T.target;if(!L||!D)continue;const z=b.has(L.id);if(z===b.has(D.id))continue;const j=z?D:L,X=g(j);if(!X||X===_||X===g(z?L:D))continue;const ne=S.get(X.id);ne?j.x<ne.minX&&(ne.minX=j.x):S.set(X.id,{pool:X,minX:j.x})}const O=[];for(const{pool:B,minX:T}of S.values()){const N=(B.children??[]).filter(L=>Bi(L)&&!b.has(L.id)&&L.x>=T);N.length&&O.push({subtree:N,pool:B})}return O},H1=b=>{const _=Ue(r),S=_.shapes.filter(B=>b.has(B.id)),O=new Set;for(const B of _.edges)if(!(B.type!=="bpmn:SequenceFlow"&&B.type!=="bpmn:MessageFlow"))for(const T of Ht(B,S))O.add(`${B.id}|${T.id}`);return O},Ng=new Map,B3=Ft(e,"sequenceFlow.update").flatMap(b=>{if(b.target!==void 0)return[{id:b.id,target:b.target,source:b.source}];const _=k.get(b.id);return _?[{id:b.id,target:_.flow.target,source:_.flow.source}]:[]});for(const b of B3){if(b.target===void 0)continue;const _=P.get(b.target);if(!_)continue;const S=f(b.target),O=f(b.id);if(!S||!O)continue;const B=b.source!==void 0?f(b.source):O.source,T=O.target;if(!B||!T||T.id===S.id)continue;const N=k1.get(O.id)??{waypoints:O.waypoints,label:O.label},L=N.waypoints&&N.waypoints.length>=3&&Math.abs(N.waypoints[0].x-N.waypoints[1].x)<1&&Math.abs(N.waypoints[0].y-N.waypoints[1].y)>1?{x:N.waypoints[0].x,y:N.waypoints[0].y}:void 0,D=L?N.waypoints[1].y:void 0,z=L&&N.label?{x:N.label.x,y:N.label.y}:void 0,j=z&&N.label&&Math.abs(z.y+N.label.height/2-D)<=ye/5&&z.x+N.label.width>L.x?z.x+N.label.width+6:void 0,X=(B.outgoing??[]).filter(Le=>Le.type==="bpmn:SequenceFlow"&&Le.id!==O.id&&Le.target&&!_c.has(Le.id)),ne=new Set(X.map(Le=>Le.target.id)),le=Le=>{const Mt={type:"bpmn:Task",x:Le.x+2,y:Le.y+2,width:Le.width-4,height:Le.height-4};return X.find(vt=>(vt.waypoints??[]).some((Zt,je)=>!!vt.waypoints[je+1]&&Dr(Zt,vt.waypoints[je+1],Mt)===0))},ae=xr(b.target),oe=new Set(ae.map(Le=>Le.id)),ve=Rt.has(b.target)?{autoResize:!1}:void 0,me=Math.min(...ae.map(Le=>Le.x)),te=Math.max(...ae.map(Le=>Le.x+Le.width)),Z=B.x+B.width,re=T.x+T.width<=B.x,Q=(()=>{if(!re)return;const Le=g(S),Mt=((Le==null?void 0:Le.children)??[]).filter(Ge=>Bi(Ge)&&!oe.has(Ge.id)&&Ge.type!=="bpmn:Group"&&Ge.type!=="bpmn:Participant"),vt=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],Zt=r.getAll().filter(Ge=>{if(!vt.includes(Ge.type))return!1;const Bt=Ge;return Bt.id===O.id||_c.has(Bt.id)||!Bt.waypoints||Bt.waypoints.length<2?!1:![Bt.source,Bt.target].some(kt=>!kt||oe.has(kt.id))}),je=(Ge,Bt)=>ae.every(kt=>{var ta;const _t={id:kt.id,type:kt.type,x:kt.x+Ge,y:kt.y+Bt,width:kt.width,height:kt.height};return Le&&(_t.x<Le.x||_t.x+_t.width>Le.x+Le.width||_t.y<Le.y||_t.y+_t.height>Le.y+Le.height)||!xp((ta=P.get(kt.id))==null?void 0:ta.node.lane,kt,kt.y+Bt+kt.height/2)||Mt.some(Yn=>_t.x<Yn.x+Yn.width+Li&&_t.x+_t.width+Li>Yn.x&&_t.y<Yn.y+Yn.height+Li&&_t.y+_t.height+Li>Yn.y)?!1:Zt.every(Yn=>{for(let po=0;po+1<Yn.waypoints.length;po++)if(Dr(Yn.waypoints[po],Yn.waypoints[po+1],_t)<Li)return!1;return!0})}),Ye=B.x+B.width/2,gt=B.y+B.height/2,it=N.waypoints??[],Pt=it.length>=2&&Math.abs(it[0].y-it[1].y)<1&&it[1].x<it[0].x;return[...D!==void 0?[{cx:Ye,cy:D}]:[],...Pt?[{cx:B.x-br-S.width/2,cy:it[0].y}]:[],{cx:Ye,cy:gt+ye},{cx:Ye,cy:gt-ye}].find(Ge=>je(Ge.cx-(S.x+S.width/2),Ge.cy-(S.y+S.height/2)))})(),de=re&&!Q?Z:T.x,$e=(()=>{var gt;if(L||re)return 0;const Le=N.label,Mt=((gt=O.businessObject)==null?void 0:gt.name)??"";if(!Le||Le.width==null||!Mt.trim())return 0;const vt=Z+br,Zt=B.y+B.height/2-S.height/2;if(Math.min(Le.y+Le.height,Zt+S.height)-Math.max(Le.y,Zt)<3||Le.x+Le.width-vt<3)return 0;const Ye=Le.x+Le.width+A3-vt;return Ye<=S.width?Ye:0})();$e>0&&u.add(O.id);const De=S.y+S.height/2,Xe=P3(ae,Z+br+$e-me,[0,B.y+B.height/2-De,T.y+T.height/2-De],de,Z,B.y+B.height/2),Ae=Z+br+$e+Xe,Pe=(()=>{if(j===void 0)return 0;const Le=Z+br,Mt=B.y+B.height/2-S.height/2,vt={x:Le,y:Mt,width:te-me,height:S.height},Zt=g(B);return((Zt==null?void 0:Zt.children)??[]).some(Ye=>Bi(Ye)&&!oe.has(Ye.id)&&Ye.id!==B.id&&Ye.id!==T.id&&Ye.type!=="bpmn:Group"&&Ye.type!=="bpmn:Participant"&&Ye.x<vt.x+vt.width&&Ye.x+Ye.width>vt.x&&Ye.y<vt.y+vt.height&&Ye.y+Ye.height>vt.y)||le(vt)?Math.max(0,j-Le):0})(),Ce=Q?0:te-me+br*2+Xe+Pe+$e-(re?0:T.x-Z);let Te=[];if(Ce>0){const Le=g(S),Mt=(Le==null?void 0:Le.children)??[],vt=it=>it.type==="bpmn:Lane";Te=(()=>{const it=new Set;for(const We of Mt)Bi(We)&&!oe.has(We.id)&&We.id!==B.id&&We.x>=de&&it.add(We.id);const Pt=[];for(const We of Mt){if(We.type!=="bpmn:DataStoreReference"&&We.type!=="bpmn:DataObjectReference")continue;const Ge=We,kt=[...Ge.incoming??[],...Ge.outgoing??[]].filter(_t=>_t.type==="bpmn:DataInputAssociation"||_t.type==="bpmn:DataOutputAssociation").map(_t=>_t.source===Ge?_t.target:_t.source);kt.length&&kt.every(_t=>_t!==void 0&&it.has(_t.id))&&Pt.push(Ge)}return Pt})();const je=Mt.filter(it=>!("waypoints"in it&&it.waypoints)&&!vt(it)&&it.type!=="label"&&!oe.has(it.id)&&it.id!==B.id&&it.x>=de),Ye=je.flatMap(it=>it.labels??[]),gt=Le?[Le,...Mt.filter(it=>vt(it))]:[];if(je.length){const it=new Set(je.map(rt=>rt.id)),Pt=j1(it),We=Pt.length?L3(it,Pt,Le):null,Ge=rt=>{const Et=new Set(it);for(const Nt of rt)for(const Lo of Nt.subtree)Et.add(Lo.id);return D3(Et)},Bt=Ge(Pt),kt=We?Ge(We):Bt,_t=Bg(it),ta=new Set(it);for(const rt of Pt)for(const Et of rt.subtree)ta.add(Et.id);const Yn=Pt.length?Bg(ta):_t,po=(()=>{if(!We)return[];const rt=new Set(it);for(const Et of We)for(const Nt of Et.subtree)rt.add(Nt.id);return Bg(rt)})(),os=We??Pt,na=(()=>{const rt=new Set(it);for(const Et of os)for(const Nt of Et.subtree)rt.add(Nt.id);return I3(rt,Le)})(),Ug=na.length?Ge([...os,...na]):Bt,Ui=new Set([...je,...gt].map(rt=>rt.id)),bt=Mt.filter(rt=>{const Et=rt.labelTarget;return rt.type==="label"&&!!Et&&"waypoints"in Et&&!!Et.source&&!!Et.target&&Ui.has(Et.source.id)&&Ui.has(Et.target.id)}),Sn=k3();n.createSpace([...je,...Ye,...bt],gt,{x:Ce,y:0},"e",de-1);const Qt=(rt,Et,Nt)=>{const Lo=wr(),Ap=Nt?H1(Nt):null,Pp=es(rt,Ce,!!Nt);if(!Pp)return!1;const Cc=Et.length?L1(Et,Ce):null,Tp=wr(),Jt=!!Nt&&!!Ap&&[...H1(Nt)].some(oa=>!Ap.has(oa));return Tp.messages>Lo.messages&&Tp.lines>=Lo.lines&&!Jt?!0:(Cc==null||Cc(),Pp(),!1)},fi=na.length>0&&Qt([...os,...na],We?po:Yn,new Set(na.flatMap(rt=>rt.subtree.map(Et=>Et.id)))),ia=!fi&&We?Qt(We,po):!1;let fo=fi||ia;!fo&&Pt.length&&(fo=Qt(Pt,Yn));const rs=fi?Ug:ia?kt:Bt;if(!fo){for(const rt of Pt){const Et=wr(),Nt=es([rt],Ce);if(!Nt)continue;const Lo=wr();(Lo.messages<=Et.messages||Lo.lines<Et.lines)&&Nt()}if(_t.length){const rt=wr(),Et=L1(_t,Ce);if(Et){const Nt=wr();(Nt.messages<=rt.messages||Nt.lines<rt.lines)&&Et()}}}if(O3(Sn),rs.length){const rt=()=>new Set(ft(Ue(r)).map(Nt=>pt(Nt))),Et=Nt=>{const Lo=N1(),Ap=rt(),Pp=Nt.map(Jt=>({a:Jt,x:Jt.x,y:Jt.y})),Cc=r.filter(Jt=>Jt.type==="label").map(Jt=>({label:Jt,x:Jt.x,y:Jt.y}));n.moveElements(Nt,{x:Ce,y:0});const Tp=[...rt()].filter(Jt=>!Ap.has(Jt));if(N1()<Lo&&Tp.length===0)return!0;for(const{a:Jt,x:oa,y:Mc}of Pp)(Jt.x!==oa||Jt.y!==Mc)&&n.moveElements([Jt],{x:oa-Jt.x,y:Mc-Jt.y});for(const Jt of Cc){const oa=Jt.x-Jt.label.x,Mc=Jt.y-Jt.label.y;(oa!==0||Mc!==0)&&n.moveElements([Jt.label],{x:oa,y:Mc})}return!1};if(!Et(rs)&&rs.length>1)for(const Nt of rs)Et([Nt])}}}const pe=_.node.lane!==void 0?f(_.node.lane):_.node.participant!==void 0?f(_.node.participant):void 0,Me=Le=>{if(!pe)return!0;const Mt=Le.y+Le.height/2;return Mt>=pe.y&&Mt<=pe.y+pe.height},ke=!Me(B)&&Me(T),Fe=Le=>Le.y+Le.height/2,wt=()=>{const Le=B.x+B.width,Mt=T.x,vt=Fe(T)-S.height/2,Zt=Fe(T)+S.height/2;return!r.getAll().some(je=>Bi(je)&&je.type!=="bpmn:Participant"&&je.type!=="bpmn:Group"&&je.type!=="bpmn:TextAnnotation"&&je.id!==B.id&&je.id!==T.id&&je.id!==S.id&&je.x<Mt&&je.x+je.width>Le&&je.y<Zt&&je.y+je.height>vt)},rn=!ke&&_.band!==void 0&&Me(T)&&!xn(_.node.lane,_.node.participant,_.band,Fe(B))&&xn(_.node.lane,_.node.participant,_.band,Fe(T))&&T.x>=B.x+B.width&&wt(),Kt=ke||rn?T:B,Xt=Kt.y+Kt.height/2,Nn=Xt-(S.y+S.height/2),wn=_.band!==void 0,Mp=wn?[S]:ae,Wg=(_.band===void 0||xn(_.node.lane,_.node.participant,_.band,Xt))&&pi(b.target)&&Mp.every(Le=>{var Mt;return xp((Mt=P.get(Le.id))==null?void 0:Mt.node.lane,Le,Le.y+Le.height/2+Nn)}),aF=Le=>Math.abs(Le.y+Le.height/2-(S.y+S.height/2))<=ye/2;if(Wg&&wn){const Le=Math.abs(Nn)<=ye/2?ae.filter(je=>je.id!==S.id&&aF(je)):[],Mt=S.y+S.height/2,Zt=_.band!==void 0&&!xn(_.node.lane,_.node.participant,_.band,Mt)?ae.filter(je=>{var Ye,gt;return je.id!==S.id&&!Le.includes(je)&&((Ye=P.get(je.id))==null?void 0:Ye.band)===_.band&&((gt=P.get(je.id))==null?void 0:gt.node.lane)===_.node.lane&&(Math.abs(je.y+je.height/2-Mt)<=ye/2||xn(_.node.lane,_.node.participant,_.band,je.y+je.height/2))}).map(je=>({t:je,dy:Xt-(je.y+je.height/2)})).filter(({dy:je})=>je!==0):[];if(n.moveElements(ae,{x:Ae-me,y:0},void 0,ve),n.moveElements([S],{x:0,y:Nn},void 0,ve),Le.length){const je=()=>new Set(ft(Ue(r)).map(Ge=>pt(Ge))),Ye=je(),gt=r.filter(Ge=>Ge.type==="label").map(Ge=>({label:Ge,x:Ge.x,y:Ge.y}));n.moveElements(Le,{x:0,y:Nn});const it=je(),Pt=[...it].filter(Ge=>!Ye.has(Ge)).length,We=[...Ye].filter(Ge=>!it.has(Ge)).length;if(Pt>We){n.moveElements(Le,{x:0,y:-Nn});for(const Ge of gt){const Bt=Ge.x-Ge.label.x,kt=Ge.y-Ge.label.y;(Bt!==0||kt!==0)&&n.moveElements([Ge.label],{x:Bt,y:kt})}}}if(Zt.length){const je=new Set(ae.map(Ye=>Ye.id));for(const{t:Ye,dy:gt}of Zt)C(Ye.parent,Ye,Ye.x+Ye.width/2,Ye.y+Ye.height/2+gt,je)||n.moveElements([Ye],{x:0,y:gt})}}else n.moveElements(ae,{x:Ae-me,y:Wg?Nn:0},void 0,ve);const Wi=g(S);if(!Wg&&_.node.lane===void 0&&_.band!==void 0&&Wi){const Le=Wi.y+U+$t(`pool:${_.node.participant??""}`,_.band)*ye,Mt=Le-(S.y+S.height/2);Mt!==0&&!C(Wi,S,S.x+S.width/2,Le,oe)&&n.moveElements([S],{x:0,y:Mt},void 0,ve)}if(Q)n.moveElements(ae,{x:Q.cx-(S.x+S.width/2),y:Q.cy-(S.y+S.height/2)},void 0,ve);else if(Wi){const Le=(Wi.children??[]).filter(je=>Bi(je)&&!oe.has(je.id)&&je.type!=="bpmn:Group"&&je.type!=="bpmn:Participant"),Mt=(je,Ye,gt,it,Pt)=>je.x+Ye<Pt.x+Pt.width+it&&je.x+Ye+je.width+it>Pt.x&&je.y+gt<Pt.y+Pt.height+it&&je.y+gt+je.height+it>Pt.y,vt=Le.find(je=>Mt(S,0,0,0,je)),Zt=vt?void 0:le(S);if(vt||Zt){const je=["bpmn:SequenceFlow","bpmn:MessageFlow","bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation"],Ye=r.getAll().filter(bt=>{if(!je.includes(bt.type))return!1;const Sn=bt;return _c.has(Sn.id)||!Sn.waypoints||Sn.waypoints.length<2?!1:![Sn.source,Sn.target].some(Qt=>!Qt||oe.has(Qt.id))}),gt=(bt,Sn,Qt)=>{var fi;return xp((fi=P.get(bt.id))==null?void 0:fi.node.lane,bt,bt.y+Qt+bt.height/2)&&bt.x+Sn>=Wi.x&&bt.x+Sn+bt.width<=Wi.x+Wi.width&&bt.y+Qt>=Wi.y&&bt.y+Qt+bt.height<=Wi.y+Wi.height},it=(bt,Sn)=>ae.every(Qt=>gt(Qt,bt,Sn)&&!Le.some(fi=>Mt(Qt,bt,Sn,Li,fi))&&Ye.every(fi=>{const ia={id:Qt.id,type:Qt.type,x:Qt.x+bt,y:Qt.y+Sn,width:Qt.width,height:Qt.height};for(let fo=0;fo+1<fi.waypoints.length;fo++)if(Dr(fi.waypoints[fo],fi.waypoints[fo+1],ia)<Li)return!1;return!0})),Pt=S.y+S.height/2,We=[D,T.y+T.height/2].filter(bt=>bt!==void 0&&Math.abs(bt-Pt)>=1),Ge=vt&&ne.has(vt.id)?vt:Zt==null?void 0:Zt.target,Bt=Ge?Ge.x-S.x:0,kt=Math.max(...ae.map(bt=>bt.x+bt.width)),_t=[...Bt!==0?[Bt]:[],...Xe!==0?[-Xe]:[],0],ta=j===void 0?[]:_t.map(bt=>Math.max(bt,j-S.x)),Yn=bt=>kt+bt+br<=T.x,po=[...new Set([...ta,..._t])].filter(Yn),os=vt&&ne.has(vt.id)?[vt.x+vt.width+br-S.x]:[],na=j===void 0?[]:os.map(bt=>Math.max(bt,j-S.x)),Ug=[...new Set([...na,...os])].filter(bt=>Yn(bt)&&!po.includes(bt));let Ui;for(const bt of[po,Ug]){for(const Sn of We){for(const Qt of bt)if(it(Qt,Sn-Pt)){Ui={dx:Qt,dy:Sn-Pt};break}if(Ui)break}if(Ui)break}if(Ui){const bt=rt=>{const Et=rt;return[Et.edge,Et.other,...Array.isArray(Et.edges)?Et.edges:[]].some(Nt=>typeof Nt=="string"&&_c.has(Nt))},Sn=()=>new Set(ft(Ue(r)).filter(rt=>!bt(rt)).map(rt=>pt(rt))),Qt=Sn(),fi=r.filter(rt=>rt.type==="label").map(rt=>({label:rt,x:rt.x,y:rt.y}));n.moveElements(ae,{x:Ui.dx,y:Ui.dy},void 0,ve);const ia=Sn(),fo=[...ia].filter(rt=>!Qt.has(rt)).length,rs=[...Qt].filter(rt=>!ia.has(rt)).length;if(fo>rs){n.moveElements(ae,{x:-Ui.dx,y:-Ui.dy},void 0,ve);for(const rt of fi){const Et=rt.x-rt.label.x,Nt=rt.y-rt.label.y;(Et!==0||Nt!==0)&&n.moveElements([rt.label],{x:Et,y:Nt})}}else L&&Ng.set(O.id,{exit:L,channelY:D,label:z})}}}{const Le=new Set(ae.map(Ye=>Ye.id)),Mt=new Set(F.map(Ye=>Ye.flow.id)),vt=20,Zt=Ye=>{const gt=Ye.source,it=Ye.target,Pt=Math.min(gt.x,it.x)-vt,We=Math.max(gt.x+gt.width,it.x+it.width)+vt,Ge=Math.min(gt.y,it.y)-vt,Bt=Math.max(gt.y+gt.height,it.y+it.height)+vt;return Ye.waypoints.some(kt=>kt.x<Pt||kt.x>We||kt.y<Ge||kt.y>Bt)},je=new Map;for(const Ye of ae)for(const gt of[...Ye.incoming??[],...Ye.outgoing??[]])(k.has(gt.id)||gt.id!==b.id&&Mt.has(gt.id))&&!(Le.has(gt.source.id)&&Le.has(gt.target.id))&&je.set(gt.id,gt);for(const Ye of je.values())Zt(Ye)&&Ep(Ye)}const uo=Te.length?g(Te[0]):void 0;if(uo){const Le={assoc:B1(),overlaps:F1(uo),crosses:$1()},Mt=Te.map(We=>({st:We,x:We.x})),vt=r.filter(We=>We.type==="label").map(We=>({label:We,x:We.x,y:We.y})),Zt=Math.min(...Te.flatMap(We=>[...We.incoming??[],...We.outgoing??[]].filter(Ge=>Ge.type==="bpmn:DataInputAssociation"||Ge.type==="bpmn:DataOutputAssociation").map(Ge=>(Ge.source===We?Ge.target:Ge.source).x))),je=new Set(Te.map(We=>We.id)),Ye=(uo.children??[]).filter(Bi).filter(We=>!je.has(We.id));let gt=Zt;for(const We of[...Te].sort((Ge,Bt)=>Ge.x-Bt.x)){let Ge=gt;for(let Bt=0;Bt<100;Bt++){const kt=Ye.find(_t=>Ge<_t.x+_t.width+Ii&&Ge+We.width+Ii>_t.x&&We.y<_t.y+_t.height&&We.y+We.height>_t.y);if(!kt)break;Ge=kt.x+kt.width+Ii}Ge!==We.x&&n.moveElements([We],{x:Ge-We.x,y:0}),gt=Ge+We.width+Ii}const it=gt+150-(uo.x+uo.width);it>0&&Ja(uo,uo.width+it);const Pt={assoc:B1(),overlaps:F1(uo),crosses:$1()};if(Pt.assoc>=Le.assoc||Pt.overlaps>Le.overlaps||Pt.crosses>Le.crosses){for(const{st:We,x:Ge}of Mt)We.x!==Ge&&n.moveElements([We],{x:Ge-We.x,y:0});it>0&&Ja(uo,uo.width-it);for(const We of vt){const Ge=We.x-We.label.x,Bt=We.y-We.label.y;(Ge!==0||Bt!==0)&&n.moveElements([We.label],{x:Ge,y:Bt})}}}}for(const[b,_]of Rt){const S=f(b);if(!S)continue;const O=_.container,B=Math.abs(S.y+S.height/2-O.y-_.relCy)>=.5,T=S.label,N=Math.min(S.y,T&&!T.hidden?T.y:S.y),L=Math.max(S.y+S.height,T&&!T.hidden?T.y+T.height:0);if(B&&N>=O.y&&L<=O.y+O.height)continue;const D=S.y;_.grow(),S.y!==D&&n.moveElements([S],{x:0,y:D-S.y},void 0,{autoResize:!1})}const z1=(b,_)=>{const S=_.target===b,O=d(_.source),B=d(_.target),T=S?"bpmn:DataOutputAssociation":"bpmn:DataInputAssociation";n.connect(O,B,_.id?{type:T,businessObject:i.create(T,{id:_.id})}:{type:T})},G1=b=>{for(const _ of m){if(!_.participant.blackBox)continue;const S=f(_.participant.id);if(!S)continue;const O=[];for(const T of v){const N=T.flow.source===_.participant.id?T.flow.target:T.flow.target===_.participant.id?T.flow.source:void 0,L=N?f(N):void 0;L&&typeof L.x=="number"&&L.type!=="bpmn:Participant"&&O.push(L)}if(!O.length)continue;if(!b&&_.order===void 0){const T=(()=>{var L;const N=new Map;for(const D of O){const z=g(D);if(!z)continue;const j=N.get(z.id);j?j.n+=1:N.set(z.id,{shape:z,n:1})}return(L=[...N.values()].sort((D,z)=>z.n-D.n)[0])==null?void 0:L.shape})();if(T){const N=z=>z.reduce((j,X)=>j+X,0)/z.length,L=N(O.map(z=>z.y+z.height/2))<T.y+T.height/2,D=r.filter(z=>z.type==="bpmn:Participant"&&z.id!==_.participant.id&&z.id!==T.id).filter(z=>L?z.y+z.height<=T.y+5:z.y>=T.y+T.height-5);if(D.length){const z=[...D.reduce((re,Q)=>re.set(Q.y,(re.get(Q.y)??0)+1),new Map)].sort((re,Q)=>Q[1]-re[1]||(L?Q[0]-re[0]:re[0]-Q[0]))[0][0],j=Math.min(S.width,JM),X=eA,ne=O.map(re=>re.x+re.width/2),le=Math.round(N(ne)-j/2),ae=Math.max(...ne)+Cf,oe=re=>({x:re,width:Math.max(j,ae-re)}),ve=D.filter(re=>Math.min(re.y+re.height,z+X)-Math.max(re.y,z)>0),me=re=>{const Q=oe(re);return ve.some(de=>de.x<Q.x+Q.width&&Q.x<de.x+de.width)},te=re=>{const Q=oe(re);return ne.filter(de=>de>=Q.x+10&&de<=Q.x+Q.width-10).length},Z=(()=>{if(!me(le))return le;const re=te(le);return ve.flatMap(Q=>[Q.x+Q.width+Oy,Q.x-Oy-j]).map(Q=>Math.round(Q)).filter(Q=>!me(Q)&&te(Q)>=re).sort((Q,de)=>Math.abs(Q-le)-Math.abs(de-le))[0]??le})();if(Z!==S.x||z!==S.y||j!==S.width||X!==S.height){const re=()=>new Set(ft(Ue(r)).map(Ae=>pt(Ae))),Q=re(),de={x:S.x,y:S.y,width:S.width,height:S.height};n.resizeShape(S,{x:Z,y:z,width:j,height:X});const $e=re(),De=[...$e].filter(Ae=>!Q.has(Ae)).length,Xe=[...Q].filter(Ae=>!$e.has(Ae)).length;De>Xe&&n.resizeShape(S,de)}}}}const B=Math.max(...O.map(T=>T.x+T.width/2))+Cf;if(B>S.x+S.width&&n.resizeShape(S,{x:S.x,y:S.y,width:B-S.x,height:S.height}),!!b)for(const T of v){const N=f(T.flow.id),L=T.flow.source===_.participant.id?T.flow.target:T.flow.target===_.participant.id?T.flow.source:void 0,D=L?f(L):void 0;if(!N||!D||D.type==="bpmn:Participant")continue;const z=D.x+D.width/2;z<S.x+10||z>S.x+S.width-10||I1(N,S,D)}}};G1(!1);for(const b of v){const _=b.flow;n.connect(d(_.source),d(_.target),{type:"bpmn:MessageFlow",businessObject:i.create("bpmn:MessageFlow",{id:_.id,name:_.name})})}{const S=new Set([...F.map(D=>D.flow.id),...v.map(D=>D.flow.id)].filter(D=>!!D)),O=r.filter(D=>!!D.waypoints),B=(D,z)=>Math.abs(z.x-D.x)<2?"L":Math.abs(z.x-(D.x+D.width))<2?"R":Math.abs(z.y-D.y)<2?"T":Math.abs(z.y-(D.y+D.height))<2?"B":void 0,T=new Map,N=(D,z,j)=>{if(!D||!z||typeof D.x!="number")return;const X=B(D,z);if(!X)return;let ne=T.get(D.id);ne||T.set(D.id,ne=new Map),ne.set(X,[...ne.get(X)??[],j])};for(const D of O){const z=D.waypoints;!z||z.length<2||(N(D.source,z[0],{id:D.id,dir:"out"}),N(D.target,z[z.length-1],{id:D.id,dir:"in"}))}const L=new Set;for(const[D,z]of T){const j=f(D);if(!j||typeof j.x!="number")continue;const X=te=>{var re;const Z=(re=f(te.id))==null?void 0:re.source;return!!Z&&typeof Z.x=="number"&&Z.x+Z.width/2>j.x+j.width/2};if(![...z.values()].some(te=>te.length>=3&&te.some(Z=>Z.dir==="out")&&te.some(Z=>Z.dir==="in"&&S.has(Z.id)&&X(Z))))continue;const le=g(j);if(!le||L.has(le.id)||(le.children??[]).some(te=>te.type==="bpmn:Lane"))continue;const ae=(dS=z.get("T"))!=null&&dS.length?(hS=z.get("B"))!=null&&hS.length?void 0:"B":"T";if(!ae||(ae==="T"?j.y-le.y:le.y+le.height-(j.y+j.height))>=ye)continue;const ve=(le.children??[]).filter(te=>!("waypoints"in te&&te.waypoints)&&te.type!=="label"&&typeof te.x=="number"),me=le.y+le.height;n.resizeShape(le,{x:le.x,y:le.y,width:le.width,height:le.height+ye}),Jn(me,le.id,ye),ae==="T"&&ve.length&&n.moveElements(ve,{x:0,y:ye}),L.add(le.id)}}const $g=20,V1=4,N3=3,$3=2,F3=2,j3=[10,30,80],Qr=()=>{const b=Ue(r);return{bad:ft(b).filter(_=>_.kind==="edge-crosses-shape"||_.kind==="edge-overlap-opposite"||_.kind==="edge-overlap-mixed").length,crossings:Nm(b),straight:b.edges.filter(_=>_.type==="bpmn:MessageFlow"&&_.waypoints.length===2).length}},_r=b=>{const _=Ue(r),S=_.edges.find(O=>O.id===b);return S?Ht(S,Hn(_)).length:0},Ec=b=>_r(b)>0,ts=b=>Ue(r).edges.filter(_=>_.type==="bpmn:MessageFlow"&&_.id!==b&&_.waypoints.length===2).length,W1=(b,_,S)=>es([{subtree:b,pool:_}],S),U1=(b,_)=>_.bad>b.bad||_.crossings>b.crossings&&_.straight<=b.straight&&_.bad>=b.bad,ns=(b,_)=>U1(b,_)||_.straight<b.straight,Er=(b,_,S=()=>!0,O=U1,B=!1)=>{const T=Qr(),N=es(b,_,B);if(!N)return!1;const L=Qr();return O(T,L)||!S()?(N(),!1):!0},H3=(b,_,S,O=()=>!0)=>Er([{subtree:b,pool:_}],S,O),Jr=b=>{var _;return!!((_=P.get(b))!=null&&_.node.participant)},is=new Map;for(const b of v){if(!Jr(b.flow.target))continue;const _=is.get(b.flow.target)??[];_.push(b),is.set(b.flow.target,_)}const Sc=[...is.keys()],Fg=new Set(F.map(b=>b.flow.target)),q1=b=>wp.findIndex(({op:_})=>_.participant.id===b);Sc.sort((b,_)=>{var B,T;const S=Fg.has(b)?1:0,O=Fg.has(_)?1:0;return S!==O?S-O:q1((B=P.get(b))==null?void 0:B.node.participant)-q1((T=P.get(_))==null?void 0:T.node.participant)});const Sr=b=>b.x+b.width/2,z3=b=>{const _=new Map;for(const B of r.getAll()){const T=B;if(!T.waypoints||!T.source||!T.target)continue;(_.get(T.source.id)??_.set(T.source.id,[]).get(T.source.id)).push(T.target.id)}const S=new Set([b]),O=[b];for(let B=0;B<O.length;B++)for(const T of _.get(O[B])??[])S.has(T)||(S.add(T),O.push(T));return S},G3=(b,_)=>{const S=z3(_);let O;for(const B of r.getAll()){const T=B;if(T.type!=="bpmn:MessageFlow"||!T.source||!T.target||T.target.id!==b||S.has(T.source.id))continue;const N=T.source;if(typeof N.x!="number"||N.type==="bpmn:Participant")continue;const L=Sr(N);(O===void 0||L>O)&&(O=L)}return O},jg=(b,_)=>{const S=f(b.flow.source);if(S)return S.type==="bpmn:Participant"?G3(S.id,_):Sr(S)},Y1=b=>{let _;for(const S of is.get(b)??[]){const O=jg(S,b);O!==void 0&&(!_||O>_.cx)&&(_={op:S,cx:O})}return _==null?void 0:_.op},V3=b=>{const _=Y1(b),S=f(b),O=_?jg(_,b):void 0;return S&&O!==void 0?O-Sr(S):void 0},W3=b=>{const _=V3(b);return _!==void 0&&Math.abs(_)<$g},Sp=(b,_,S,O,B)=>{var T;for(let N=!0;N;){N=!1;for(const L of v){if(L.flow.id===S)continue;const D=_.has(L.flow.source),z=_.has(L.flow.target);if(D===z||O(D?L.flow.source:L.flow.target))continue;const j=D?L.flow.target:L.flow.source;if(B(j)||!Jr(j))continue;const X=f(L.flow.id);if(!(X!=null&&X.waypoints)||X.waypoints.length!==2)continue;const ne=f(j),le=(T=P.get(j))==null?void 0:T.node.participant;if(!ne||!le)continue;const ae=xr(j,oe=>oe.x>=ne.x).filter(oe=>!_.has(oe.id));if(!(!ae.length||ae.some(oe=>B(oe.id)))){for(const oe of ae)_.add(oe.id);b.set(le,[...b.get(le)??[],...ae]),N=!0}}}return[...b].map(([N,L])=>({subtree:L,pool:d(N)}))},K1=(b,_,S,O,B)=>Sp(new Map([[_,[...b]]]),new Set(b.map(T=>T.id)),O,T=>T===S,T=>T===B),Hg=b=>{const _=Y1(b);if(!_)return null;const S=f(b),O=f(_.flow.source),B=jg(_,b);if(!S||!O||B===void 0)return null;const T=B-Sr(S);if(T>=$g){const N=P.get(b).node.participant,L=xr(b,D=>D.x>=S.x);return{groups:K1(L,N,b,_.flow.id,_.flow.source),dx:T}}if(-T>=$g&&Jr(_.flow.source)){const N=P.get(_.flow.source).node.participant,L=xr(_.flow.source,D=>D.x>=O.x&&!W3(D.id));return{groups:K1(L,N,_.flow.source,_.flow.id,b),dx:-T}}return null},X1=()=>Sc.map(b=>({id:b,plan:Hg(b)})).filter(b=>!!b.plan).sort((b,_)=>Math.min(...b.plan.groups.flatMap(S=>S.subtree.map(O=>O.x)))-Math.min(..._.plan.groups.flatMap(S=>S.subtree.map(O=>O.x)))).map(b=>b.id);for(let b=0;b<3;b++){const _=Qr(),S=[];for(const B of X1()){const T=Hg(B);if(!T)continue;const N=es(T.groups,T.dx);N&&S.push(N)}if(!S.length)break;if(!ns(_,Qr()))continue;for(const B of S.reverse())B();let O=!1;for(const B of X1()){const T=Hg(B);T&&Er(T.groups,T.dx,()=>!0,ns)&&(O=!0)}if(!O)break}for(const b of Sc){if(Fg.has(b))continue;const _=P.get(b);if(!_||_.node.lane!==void 0)continue;const S=Oe(_);if(S===void 0)continue;const O=f(b),B=O?g(O):void 0;if(!O||!B)continue;const T=B.y+U+$t(`pool:${_.node.participant??""}`,S)*ye,N=T-(O.y+O.height/2);N!==0&&!C(B,O,O.x+O.width/2,T)&&n.moveElements([O],{x:0,y:N})}const Rp=()=>{const b=r.filter(O=>O.type==="bpmn:Participant"),_=new Map(b.map(O=>[O.id,O]));let S=0;for(const{pools:[O,B]}of ff(b)){const T=_.get(O),N=_.get(B);S+=(Math.min(T.x+T.width,N.x+N.width)-Math.max(T.x,N.x))*(Math.min(T.y+T.height,N.y+N.height)-Math.max(T.y,N.y))}return S},zg=new Set,Z1=new Set;for(let b=0,_=!0;_&&b<N3;b++){_=!1;for(const S of Sc.flatMap(O=>is.get(O)??[])){if(zg.has(S.flow.id)||!Ec(S.flow.id))continue;const O=f(S.flow.target);if(!O)continue;const B=d(P.get(S.flow.target).node.participant),T=xr(S.flow.target,j=>j.x>=O.x),N=O.width+Ee,L=_r(S.flow.id),D=ts(S.flow.id),z=Rp();for(let j=1;j<=V1;j++){const X=()=>_r(S.flow.id)>=L||Rp()>z?!1:ts(S.flow.id)>=D?!0:(Z1.add(S.flow.id),!1);if(H3(T,B,N*j,X)){zg.add(S.flow.id),_=!0;break}}}}const Q1=()=>r.filter(b=>b.type==="bpmn:SequenceFlow").filter(b=>{const _=b.source,S=b.target;return!!_&&!!S&&S.x+S.width<_.x}).length;for(const b of Sc.flatMap(_=>is.get(_)??[])){if(zg.has(b.flow.id)||!Z1.has(b.flow.id)||!Ec(b.flow.id))continue;const _=f(b.flow.target);if(!_)continue;const S=d(P.get(b.flow.target).node.participant),O=xr(b.flow.target,ne=>ne.x>=_.x),B=new Set(O.map(ne=>ne.id)),T=new Map;for(const ne of r.filter(le=>le.type==="bpmn:MessageFlow")){if(((gS=ne.waypoints)==null?void 0:gS.length)!==2||!ne.source||!ne.target)continue;const le=B.has(ne.source.id);if(le===B.has(ne.target.id))continue;const ae=le?ne.target:ne.source,oe=(mS=P.get(ae.id))==null?void 0:mS.node.participant;!oe||T.has(ae.id)||T.set(ae.id,{subtree:[ae],pool:d(oe)})}if(!T.size)continue;const N=_.width+Ee,L=_r(b.flow.id),D=ts(b.flow.id),z=Rp(),j=Q1(),X=()=>_r(b.flow.id)<L&&ts(b.flow.id)>=D&&Rp()<=z&&Q1()<=j;for(let ne=1;ne<=$3&&!Er([{subtree:O,pool:S},...T.values()],N*ne,X);ne++);}const Gg=v.map(b=>({id:b.flow.id,source:b.flow.source,target:b.flow.target,preexisting:!1})),J1=new Set(Gg.map(b=>b.id));for(const b of r.filter(_=>_.type==="bpmn:MessageFlow"))J1.has(b.id)||!b.source||!b.target||b.source.type==="bpmn:Participant"!=(b.target.type==="bpmn:Participant")&&Gg.push({id:b.id,source:b.source.id,target:b.target.id,preexisting:!0});for(const b of Gg){if(!Ec(b.id))continue;const _=f(b.source),S=f(b.target);if(!_||!S)continue;let O,B,T;if(b.preexisting){const[L,D]=_.type==="bpmn:Participant"?[S,_]:[_,S];if(O=Sr(L),O<D.x||O>D.x+D.width)continue;[B,T]=L.y<D.y?[L.y+L.height,D.y]:[D.y+D.height,L.y]}else{if(_.type==="bpmn:Participant"||S.type==="bpmn:Participant"||(O=_.x+_.width/2,Math.abs(O-(S.x+S.width/2))>15))continue;[B,T]=_.y<S.y?[_.y+_.height,S.y]:[S.y+S.height,_.y]}const N=[...P.values()].map(L=>f(L.node.id)).filter(L=>!!L&&L.id!==_.id&&L.id!==S.id).filter(L=>L.x<=O&&O<=L.x+L.width&&L.y+L.height>B&&L.y<T).sort((L,D)=>L.x-D.x);for(const L of N){const D=(yS=P.get(L.id))==null?void 0:yS.node.participant,z=D?f(D):void 0;if(!D||!z)continue;const j=[...P.values()].filter(Z=>Z.node.participant===D).map(Z=>Z.node.id),X=Z=>Z.map(re=>f(re)).filter(re=>!!re),le=[T3(L.id,Z=>{var re;return((re=P.get(Z.id))==null?void 0:re.node.participant)===D}),X(j)].filter(Z=>Z.length).map(Z=>[{subtree:Z,pool:z}]);if(b.preexisting){const Z=X(j);Z.length&&le.push(Sp(new Map([[D,[...Z]]]),new Set(Z.map(re=>re.id)),b.id,()=>!1,re=>re===_.id||re===S.id))}const ae=L.width+Ee,oe=_r(b.id),ve=ts(b.id),me=()=>_r(b.id)<oe&&ts(b.id)>=ve;let te=!1;for(const Z of le){for(let re=1;re<=V1;re++)if(Er(Z,ae*re,me)){te=!0;break}if(te)break}if(!Ec(b.id))break}}const Cp=()=>{var _;const b=new Set;for(const S of ft(Ue(r)))S.kind!=="edge-crosses-shape"||J1.has(S.edge)||((_=f(S.edge))==null?void 0:_.type)==="bpmn:MessageFlow"&&b.add(`${S.edge}>${S.shape}`);return b},U3=(b,_)=>Qr().bad>=b&&[...Cp()].some(S=>!_.has(S)),eS=b=>{var _,S;return _r(b)===0&&((S=(_=f(b))==null?void 0:_.waypoints)==null?void 0:S.length)===2},q3=(b,_,S)=>{const O=new Set(b.flatMap(T=>T.subtree.map(N=>N.id))),B=[...Cp()].filter(T=>!S.has(T)).map(T=>T.split(">")[1]);return[...new Set(B)].filter(T=>O.has(T)&&T!==_.source&&T!==_.target)},Y3=(b,_,S,O,B)=>{const T=b.map(z=>({...z,subtree:z.subtree.filter(j=>!B.includes(j.id))})).filter(z=>z.subtree.length),N=new Set(T.flatMap(z=>z.subtree.map(j=>j.id))),L=()=>B.every(z=>{const j=f(z);return!!j&&F.filter(X=>X.flow.target===z&&N.has(X.flow.source)).every(X=>{const ne=f(X.flow.source);return!!ne&&ne.x+ne.width<=j.x})});return Er(T,_,()=>eS(S.id)&&[...Cp()].every(z=>O.has(z))&&L(),ns,!0)};for(const b of v){if(!Ec(b.flow.id))continue;const _=f(b.flow.id);if(((vS=_==null?void 0:_.waypoints)==null?void 0:vS.length)!==2)continue;const S=f(b.flow.source),O=f(b.flow.target);if(!S||!O||S.type==="bpmn:Participant"||O.type==="bpmn:Participant"||!Jr(b.flow.source)||!Jr(b.flow.target)||Math.abs(Sr(S)-Sr(O))>F3)continue;const B=Sr(S),T=_.waypoints.map(oe=>oe.y),[N,L]=[Math.min(...T),Math.max(...T)],D=Hn(Ue(r)).filter(oe=>oe.id!==S.id&&oe.id!==O.id&&oe.x<B&&B<oe.x+oe.width&&N<oe.y+oe.height&&oe.y<L);if(!D.length)continue;const z=(bS=P.get(b.flow.source))==null?void 0:bS.node.participant,j=(xS=P.get(b.flow.target))==null?void 0:xS.node.participant;if(!z||!j)continue;const X=new Map;for(const[oe,ve,me]of[[b.flow.source,S,z],[b.flow.target,O,j]]){const te=X.get(me)??[],Z=xr(oe,re=>re.x>=ve.x).filter(re=>!te.some(Q=>Q.id===re.id));X.set(me,[...te,...Z])}const ne=new Set([...X.values()].flat().map(oe=>oe.id)),le=Sp(X,ne,b.flow.id,oe=>oe===b.flow.source||oe===b.flow.target,()=>!1),ae=Math.max(...D.map(oe=>oe.x+oe.width));for(const oe of j3){const ve=ae+oe-B;if(ve<=0)continue;const me=Qr().bad,te=Cp();let Z=[],re=!0;const Q=()=>!eS(b.flow.id)||re&&(Z=q3(le,b.flow,te),Z.length)?!1:!U3(me,te);if(Er(le,ve,Q,ns))break;if(Z.length&&(Y3(le,ve,b.flow,te,Z)||(re=!1,Er(le,ve,Q,ns))))break}}{const b=T=>T.y+T.height/2,_=/(Task|Event|Gateway|CallActivity|SubProcess)$/,S=()=>{const T=Ue(r),N=new Set(ft(T).flatMap(z=>z.kind==="edge-crosses-shape"?[`${z.edge}|${z.shape}`]:[])),L=T.shapes.filter(z=>!z.container&&_.test(z.type)),D=new Set;for(const z of T.edges){if(z.type!=="bpmn:SequenceFlow"&&z.type!=="bpmn:MessageFlow")continue;const j=new Set(z.endpoints);for(const X of[z.waypoints[0],z.waypoints[z.waypoints.length-1]])for(const ne of L)ne.x-4<=X.x&&X.x<=ne.x+ne.width+4&&ne.y-4<=X.y&&X.y<=ne.y+ne.height+4&&j.add(ne.id);for(const X of L)if(!(j.has(X.id)||N.has(`${z.id}|${X.id}`))){for(let ne=0;ne+1<z.waypoints.length;ne++)if(Dr(z.waypoints[ne],z.waypoints[ne+1],X)<=Ig){D.add(`${z.id}|${X.id}`);break}}}return D},O=()=>({...Qr(),grazes:S()}),B=[];for(const T of P.keys()){if(!Jr(T))continue;const N=F.filter(z=>z.flow.target===T);if(N.length!==1)continue;const L=f(N[0].flow.source),D=f(T);!L||!D||!P.has(L.id)||Math.abs(b(L)-b(D))>1||D.x-(L.x+L.width)<=Ee+1||B.push({id:T,pred:L,node:D})}B.sort((T,N)=>T.node.x-N.node.x);for(const{id:T}of B){const N=P.get(T),L=f(T),D=f(F.find(Z=>Z.flow.target===T).flow.source);if(!L||!D)continue;const z=L.x-(D.x+D.width);if(z<=Ee+1)continue;const j=d(N.node.participant),X=xr(T,Z=>Z.x>=L.x),ne=-(z-Ee),le=(Z,re)=>re.bad>Z.bad||re.crossings>=Z.crossings||re.straight<Z.straight||[...re.grazes].some(Q=>!Z.grazes.has(Q)),ae=Sp(new Map([[N.node.participant,[...X]]]),new Set(X.map(Z=>Z.id)),"",()=>!1,()=>!1),oe=ae.some(Z=>Z.pool!==j)||ae.reduce((Z,re)=>Z+re.subtree.length,0)>X.length,ve=O(),me=W1(X,j,ne);if(!me)continue;const te=O();if(oe&&!le(ve,te)){me();const Z=es(ae,ne);if(Z){const re=O();if(!le(ve,re)&&re.bad<=te.bad&&re.crossings<=te.crossings)continue;Z()}W1(X,j,ne);continue}le(ve,te)&&me()}}G1(!0);const K3=10,X3=400,Z3=b=>[...b.incoming??[],...b.outgoing??[]].filter(_=>_.type==="bpmn:DataInputAssociation"||_.type==="bpmn:DataOutputAssociation").map(_=>_.source===b?_.target:_.source).filter(_=>!!_&&typeof _.y=="number"),Q3=r.filter(b=>b.type==="bpmn:DataStoreReference"&&h.has(b.id)),J3=(b,_)=>{const S=b.x+b.width/2,O=b.y+b.height/2;let B;for(const T of Q3){if((g(T)??p())!==_||T.y<b.y+b.height)continue;const N=Math.abs(T.x+T.width/2-S);N>X3||N<T.width||!Z3(T).some(D=>D.height===b.height&&Math.abs(D.y+D.height/2-O)<=K3&&T.y>=D.y+D.height)||(!B||N<B.dx||N===B.dx&&T.id<B.id)&&(B={dx:N,id:T.id,cy:T.y+T.height/2})}return B==null?void 0:B.cy};for(const b of x){const _=b.associations??[],S=_.map(T=>T.source===b.dataStore.id?T.target:T.source).map(f).find(Boolean),O=S?g(S)??p():p(),B=S?{x:S.x+S.width/2,y:J3(S,O)??S.y+S.height+110}:{x:200,y:xc+60};n.createShape({type:"bpmn:DataStoreReference",businessObject:i.create("bpmn:DataStoreReference",{id:b.dataStore.id,name:b.dataStore.name})},B,O);for(const T of _)z1(b.dataStore.id,T)}for(const b of E){const S=d(b.association.target).type==="bpmn:DataStoreReference"?b.association.target:b.association.source;z1(S,b.association)}let tS=0;const ea=10,nS=40,eF=(b,_)=>{const S=_.map(D=>g(D)).filter(D=>!!D);for(const D of S){const z=ea,j=D.y,X=D.y+D.height,ne=D.x,le=D.x+D.width;if(Math.abs(b.y-j)<z){const ae=j+z-b.y;b.y+=ae,b.height-=ae}if(Math.abs(b.y+b.height-X)<z&&(b.height=X-z-b.y),Math.abs(b.x-ne)<z){const ae=ne+z-b.x;b.x+=ae,b.width-=ae}Math.abs(b.x+b.width-le)<z&&(b.width=le-z-b.x)}if(!S.length)return;const O=Math.min(...S.map(D=>D.y)),B=Math.max(...S.map(D=>D.y+D.height)),T=O-b.y,N=b.y+b.height-B,L=nS-ea;if(T>0!=N>0)if(T>0&&T<L){const D=T+ea;b.y+=D,b.height-=D}else N>0&&N<L&&(b.height-=N+ea)},tF=(b,_)=>{const S=ea,O=30,B=r.filter(T=>T.type==="bpmn:Group"&&T.id!==_);for(const T of B){const N=T.x,L=T.x+T.width,D=T.y,z=T.y+T.height,j=b.y<z&&D<b.y+b.height,X=b.x<L&&N<b.x+b.width;if(j){if(Math.abs(b.x-L)<S){const ne=Math.min(L+S-b.x,O);ne>0&&b.width-ne>0&&(b.x+=ne,b.width-=ne)}if(Math.abs(b.x+b.width-N)<S){const ne=Math.min(b.x+b.width-(N-S),O);ne>0&&b.width-ne>0&&(b.width-=ne)}}if(X){if(Math.abs(b.y-z)<S){const ne=Math.min(z+S-b.y,O);ne>0&&b.height-ne>0&&(b.y+=ne,b.height-=ne)}if(Math.abs(b.y+b.height-D)<S){const ne=Math.min(b.y+b.height-(D-S),O);ne>0&&b.height-ne>0&&(b.height-=ne)}}}},Vg=(b,_)=>{const S=nS,O=Math.min(...b.map(D=>D.x))-S,B=Math.min(...b.map(D=>D.y))-S,T=Math.max(...b.map(D=>D.x+D.width))+S,N=Math.max(...b.map(D=>D.y+D.height))+S,L={x:O,y:B,width:T-O,height:N-B};return eF(L,b),tF(L,_),L};for(const b of I){const _=(b.group.members??[]).map(f).filter(B=>!!B);let S;_.length?S=Vg(_,b.group.id):(S={x:300+tS*350,y:40,width:300,height:200},tS++);const O=n.createShape({type:"bpmn:Group",businessObject:i.create("bpmn:Group",{id:b.group.id}),width:S.width,height:S.height},{x:S.x+S.width/2,y:S.y+S.height/2},p());b.group.name&&n.updateLabel(O,b.group.name),(wS=b.group.members)!=null&&wS.length&&ce(O,"bwl:Members",{refs:b.group.members.join(" ")})}{const b=r.filter(B=>!!B.waypoints),_=new Map,S=(B,T)=>{!B||!T||(_.has(B)||_.set(B,new Set),_.get(B).add(T))};for(const B of b){const T=(_S=B.source)==null?void 0:_S.id,N=(ES=B.target)==null?void 0:ES.id;S(T,N),((SS=B.type)!=null&&SS.includes("DataOutputAssociation")||(RS=B.type)!=null&&RS.includes("DataInputAssociation")||B.type==="bpmn:Association")&&S(N,T)}const O=r.filter(B=>B.type==="bpmn:Group");for(const B of O){const N=(((CS=B.businessObject.extensionElements)==null?void 0:CS.values)??[]).find(me=>me.$type==="bwl:Members"),L=((N==null?void 0:N.refs)??"").split(" ").filter(Boolean);if(!L.length)continue;const D=new Set(L),z=[...L];for(;z.length;){const me=z.shift();for(const te of _.get(me)??[])D.has(te)||(D.add(te),z.push(te))}const j=B.x,X=B.x+B.width,ne=B.y,le=B.y+B.height,ae=me=>F.filter(te=>te.flow.target===me).length,oe=me=>{var Z;const te=((Z=f(me))==null?void 0:Z.type)??"";if(te==="bpmn:StartEvent"&&ae(me)===0)return!1;if(te.endsWith("Gateway")){const re=F.filter(Q=>Q.flow.target===me).map(Q=>Q.flow.source);if(re.length&&re.every(Q=>{var de;return((de=f(Q))==null?void 0:de.type)==="bpmn:StartEvent"&&ae(Q)===0}))return!1}return!0},ve=r.filter(me=>Bi(me)).filter(me=>me.type!=="bpmn:Group"&&me.type!=="bpmn:Participant"&&me.type!=="bpmn:TextAnnotation"&&!D.has(me.id)&&Jr(me.id)&&oe(me.id)&&me.x<X&&me.x+me.width>j&&me.y<le&&me.y+me.height>ne);if(ve.length)for(const me of[-1,1]){const te=ve.filter(Pe=>(Pe.x+Pe.width-j<=X-Pe.x?-1:1)===me);if(!te.length)continue;const Z=[];for(const Pe of te){const Ce=Z.find(Te=>Te.some(pe=>Pe.y<pe.y+pe.height&&Pe.y+Pe.height>pe.y));Ce?Ce.push(Pe):Z.push([Pe])}const re=new Map;for(const Pe of Z){let Ce=me<0?j-ea:X+ea;for(const Te of[...Pe].sort((pe,Me)=>me<0?Me.x-pe.x:pe.x-Me.x)){const pe=me<0?Math.min(Te.x,Ce-Te.width):Math.max(Te.x,Ce);Ce=me<0?pe-Ii:pe+Te.width+Ii,pe!==Te.x&&Math.sign(pe-Te.x)===me&&re.set(Te.id,pe-Te.x)}}const Q=new Map,de=Pe=>Q.get(Pe)===Pe||!Q.get(Pe)?Pe:de(Q.get(Pe));for(const Pe of te)Q.set(Pe.id,Pe.id);for(const Pe of v){const Ce=re.has(Pe.flow.source)?Pe.flow.source:void 0,Te=re.has(Pe.flow.target)?Pe.flow.target:void 0;if(!Ce||!Te)continue;const pe=f(Pe.flow.id);((MS=pe==null?void 0:pe.waypoints)==null?void 0:MS.length)===2&&Q.set(de(Ce),de(Te))}const $e=new Map;for(const Pe of te){if(!re.has(Pe.id))continue;const Ce=de(Pe.id);$e.set(Ce,[...$e.get(Ce)??[],Pe])}const De=[...$e.values()].sort((Pe,Ce)=>me<0?Math.min(...Pe.map(Te=>Te.x))-Math.min(...Ce.map(Te=>Te.x)):Math.max(...Ce.map(Te=>Te.x))-Math.max(...Pe.map(Te=>Te.x))),Xe=[];let Ae=!0;for(const Pe of De){const Ce=Pe.map(Me=>re.get(Me.id)??0).reduce((Me,ke)=>Math.abs(ke)>Math.abs(Me)?ke:Me,0),Te=new Map;let pe=!0;for(const Me of Pe){const ke=g(Me);if(!ke){pe=!1;break}Te.has(ke.id)||Te.set(ke.id,{subtree:[],pool:ke}),Te.get(ke.id).subtree.push(Me)}pe&&Er([...Te.values()],Ce,()=>!0,ns)?Xe.push({shapes:Pe,dx:Ce}):Ae=!1}if(!Ae)for(const Pe of Xe.reverse())n.moveElements(Pe.shapes,{x:-Pe.dx,y:0})}}}{const b=new Set([...I.map(_=>_.group.id),...Ft(e,"group.update").map(_=>_.id)]);for(const _ of r.filter(S=>S.type==="bpmn:Group")){if(b.has(_.id))continue;const O=(((AS=_.businessObject.extensionElements)==null?void 0:AS.values)??[]).find(L=>L.$type==="bwl:Members"),B=((O==null?void 0:O.refs)??"").split(" ").filter(Boolean).map(f).filter(L=>!!L);!B.length||!B.some(L=>{const D=h.get(L.id);return!D||D.x!==L.x||D.y!==L.y})||!B.some(L=>L.x<_.x||L.y<_.y||L.x+L.width>_.x+_.width||L.y+L.height>_.y+_.height)||n.resizeShape(_,Vg(B,_.id))}}{const _=new Map(zo(Ue(r)).map(L=>[L.owner,L.rect])),S=r.filter(L=>!!L.waypoints),O=new Map,B=(L,D)=>{!L||!D||(O.has(L)||O.set(L,new Set),O.get(L).add(D))};for(const L of S){const D=(PS=L.source)==null?void 0:PS.id,z=(TS=L.target)==null?void 0:TS.id;B(D,z),((kS=L.type)!=null&&kS.includes("DataOutputAssociation")||(OS=L.type)!=null&&OS.includes("DataInputAssociation")||L.type==="bpmn:Association")&&B(z,D)}const T=L=>F.filter(D=>D.flow.target===L).length,N=L=>{var z;const D=((z=f(L))==null?void 0:z.type)??"";if(D==="bpmn:StartEvent"&&T(L)===0)return!1;if(D.endsWith("Gateway")){const j=F.filter(X=>X.flow.target===L).map(X=>X.flow.source);if(j.length&&j.every(X=>{var ne;return((ne=f(X))==null?void 0:ne.type)==="bpmn:StartEvent"&&T(X)===0}))return!1}return!0};for(const L of r.filter(D=>D.type==="bpmn:Group")){const z=(((DS=L.businessObject.extensionElements)==null?void 0:DS.values)??[]).find(pe=>pe.$type==="bwl:Members"),j=((z==null?void 0:z.refs)??"").split(" ").filter(Boolean);if(!j.length)continue;const X=j.map(f).filter(pe=>!!pe);if(!X.length||!(I.some(pe=>pe.group.id===L.id)||Ft(e,"group.update").some(pe=>pe.id===L.id)||X.some(pe=>{const Me=h.get(pe.id);return!Me||Me.x!==pe.x||Me.y!==pe.y})))continue;const le=new Set(j),ae=[...j];for(;ae.length;){const pe=ae.shift();for(const Me of O.get(pe)??[])le.has(Me)||(le.add(Me),ae.push(Me))}const oe=L.x,ve=L.x+L.width,me=L.y,te=L.y+L.height,Z=pe=>{const Me=_.get(pe.id),ke={x:pe.x,y:pe.y,width:pe.width,height:pe.height};return Me?[ke,{x:Me.x,y:Me.y,width:Me.width,height:Me.height}]:[ke]},re=X.flatMap(Z),Q=Math.min(...re.map(pe=>pe.x)),de=Math.max(...re.map(pe=>pe.x+pe.width)),$e=Math.min(...re.map(pe=>pe.y)),De=Math.max(...re.map(pe=>pe.y+pe.height)),Xe={L:Q-oe,R:ve-de,T:$e-me,B:te-De},Ae=new Set(j),Pe=pe=>pe.x>=oe&&pe.x+pe.width<=ve&&pe.y>=me&&pe.y+pe.height<=te,Ce=r.filter(pe=>Bi(pe)).filter(pe=>pe.type!=="bpmn:Group"&&pe.type!=="bpmn:Participant"&&pe.type!=="bpmn:TextAnnotation"&&!Ae.has(pe.id)&&(!le.has(pe.id)||!Pe(pe))&&N(pe.id)&&pe.x<ve&&pe.x+pe.width>oe&&pe.y<te&&pe.y+pe.height>me);if(!Ce.length)continue;const Te={L:0,R:0,T:0,B:0};for(const pe of Ce){const Me=Z(pe),ke=Math.min(...Me.map(wn=>wn.x)),Fe=Math.max(...Me.map(wn=>wn.x+wn.width)),wt=Math.min(...Me.map(wn=>wn.y)),rn=Math.max(...Me.map(wn=>wn.y+wn.height)),Kt={L:Fe-oe,R:ve-ke,T:rn-me,B:te-wt},Xt=["L","R","T","B"].filter(wn=>Kt[wn]<=Xe[wn]+.001);if(!Xt.length)continue;const Nn=Xt.reduce((wn,Mp)=>Kt[Mp]<Kt[wn]?Mp:wn,Xt[0]);Te[Nn]=Math.max(Te[Nn],Math.min(Kt[Nn]+10,Xe[Nn]))}!Te.L&&!Te.R&&!Te.T&&!Te.B||n.resizeShape(L,{x:L.x+Te.L,y:L.y+Te.T,width:L.width-Te.L-Te.R,height:L.height-Te.T-Te.B})}}const iS=b=>{const _=b.waypoints;if(_!=null&&_.length){const O=_[Math.floor((_.length-1)/2)];return{x:O.x,y:O.y,width:0,height:0}}const S=b;return{x:S.x,y:S.y,width:S.width,height:S.height}};let Rc=0;const oS=12,rS=14,nF=15,iF=300,oF=b=>{const _=b.split(`
7
+ `),S=Math.max(..._.map(T=>da(T,oS))),O=Math.max(100,Math.min(iF,Math.ceil(S)+rS)),B=_.reduce((T,N)=>T+Math.max(1,Math.ceil((da(N,oS)+rS)/O)),0);return{width:O,height:Math.max(30,B*nF+10)}};for(const b of A){const _=b.association,S=((LS=b.placement)==null?void 0:LS.anchor)??(_?_.source===b.annotation.id?_.target:_.source:void 0),O=S?f(S):void 0,B=O?iS(O):void 0,T=oF(b.annotation.text??"");let N;if(B&&b.placement){const[j,X]=ol[b.placement.side],ne=b.placement.offset??50;N={x:B.x+B.width/2+j*(B.width/2+T.width/2+ne),y:B.y+B.height/2+X*(B.height/2+T.height/2+ne)}}else B?(N={x:B.x+B.width/2+180+Rc%3*260,y:B.y-110-Rc%2*95},Rc++):(N={x:300+Rc*260,y:60},Rc++);const L=O?g(O)??p():p(),D=L;B&&typeof D.x=="number"&&typeof D.width=="number"&&D.type==="bpmn:Participant"&&(N=al(r,B,T,D,b.placement?{placement:b.placement}:{from:N}));const z=n.createShape({type:"bpmn:TextAnnotation",width:T.width,height:T.height,businessObject:i.create("bpmn:TextAnnotation",{id:b.annotation.id,text:b.annotation.text})},N,L);if(_){const j=X=>X===b.annotation.id?z:d(X);n.connect(j(_.source),j(_.target),_.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:_.id})}:{type:"bpmn:Association"})}b.placement&&ce(z,"bwl:Placement",ie(b.placement))}for(const b of Ft(e,"association.add")){const _=b.association;n.connect(d(_.source),d(_.target),_.id?{type:"bpmn:Association",businessObject:i.create("bpmn:Association",{id:_.id})}:{type:"bpmn:Association"})}const rF=(b,_,S,O)=>{const B=b.parent;if(!B)return O;const T=b.x+b.width/2,N=new Set([b.id]);if(!C(B,b,T,O,N))return O;const L=_?_.y+Math.min(_.height/2,ue):S?S.y+U:void 0;if(L===void 0)return O;const D=Math.floor((O-L)/ye+1e-6);for(let z=1;z<=3;z++){const j=D+z,X=L+j*ye,ne=P1(_==null?void 0:_.id,j);if(!C(B,b,T,X,ne?new Set([...N,...ne]):N))return Do(_==null?void 0:_.id,j,S),X}return O},aS=()=>new Set(r.getAll().filter(b=>b.type!=="label").map(b=>b.id));for(const b of Ft(e,"node.update")){let _=d(b.id);if(b.type&&il(b.type)!==_.type){const S=_.x+_.width/2,O=_.y+_.height/2,B=aS();_=c.replaceElement(_,{type:il(b.type),...b.eventDefinition?{eventDefinitionType:Tc[b.eventDefinition]}:{}});const T=aS(),N=[...B].filter(z=>z!==b.id&&!T.has(z));if(N.length)throw new By({kind:"type-change-drops-elements",opIndex:e.indexOf(b),id:b.id,type:b.type,dropped:N});const L=Math.round(S-(_.x+_.width/2)),D=Math.round(O-(_.y+_.height/2));if(L!==0||D!==0){n.moveShape(_,{x:L,y:D});for(const z of[..._.incoming??[],..._.outgoing??[]])Ep(z)}}if(b.name!==void 0&&n.updateProperties(_,{name:b.name??void 0}),b.lane||b.band!==void 0){b.band!==void 0&&n.updateProperties(_,{"bwl:band":b.band});const S=_.y+_.height/2,O=g(_),B=b.lane?d(b.lane):((O==null?void 0:O.children)??[]).find(N=>N.type==="bpmn:Lane"&&S>=N.y&&S<=N.y+N.height);b.band!==void 0&&Do(B==null?void 0:B.id,b.band,O);const T=B?B.y+(b.band===void 0?B.height/2:Math.min(B.height/2,ue)+$t(B.id,b.band)*ye):b.band!==void 0&&O?O.y+U+$t(`pool:${O.id}`,b.band)*ye:void 0;if(T!==void 0){const N=rF(_,B,O,T),L=N===T?T-S:N-(_.y+_.height/2);L!==0&&n.moveElements([_],{x:0,y:L})}}}for(const b of Ft(e,"sequenceFlow.update")){const _=d(b.id),S=k.get(b.id);if(S){const O=z=>({x:z.x+z.width/2,y:z.y+z.height/2}),B=d(S.flow.source),T=d(S.flow.target),N=n.connect(B,T,{type:"bpmn:SequenceFlow",businessObject:_p(S.flow)}),L=Ng.get(b.id),D=T.y+T.height/2;L&&T.x>L.exit.x&&Math.abs(D-L.exit.y)>1?n.updateWaypoints(N,[L.exit,{x:L.exit.x,y:D},{x:T.x,y:D}]):(n.reconnect(N,B,T,[O(B),O(T)]),Math.abs(D-(B.y+B.height/2))>1&&Ep(N))}else if((b.source!==void 0||b.target!==void 0)&&!O1.has(b.id)){const O=_,B=b.source!==void 0?d(b.source):O.source,T=b.target!==void 0?d(b.target):O.target,N=z=>({x:z.x+z.width/2,y:z.y+z.height/2});n.reconnect(O,B,T,[N(B),N(T)]);const L=Ng.get(O.id),D=T.y+T.height/2;if(L&&T.x>L.exit.x&&Math.abs(D-L.exit.y)>1){n.updateWaypoints(O,[L.exit,{x:L.exit.x,y:D},{x:T.x,y:D}]);const z=O.label;if(z&&L.label){const X=Math.abs(L.label.y+z.height/2-L.channelY)<=ye/5&&L.label.x+z.width>L.exit.x,ne=L.exit.x+6,le=T.x-6-z.width,ae=X?le>=ne?{x:Math.max(ne,Math.min(L.label.x,le)),y:L.label.y+(D-L.channelY)}:void 0:L.label;ae&&(ae.x!==z.x||ae.y!==z.y)&&n.moveElements([z],{x:ae.x-z.x,y:ae.y-z.y})}}else Math.abs(D-(B.y+B.height/2))>1&&Ep(O)}b.name!==void 0&&n.updateProperties(_,{name:b.name??void 0}),b.condition!==void 0&&n.updateProperties(_,{name:((IS=b.condition)==null?void 0:IS.label)??void 0})}for(const b of Ft(e,"messageFlow.update"))b.name!==void 0&&n.updateProperties(d(b.id),{name:b.name??void 0});for(const b of Ft(e,"dataStore.update"))b.name!==void 0&&n.updateProperties(d(b.id),{name:b.name??void 0});for(const b of Ft(e,"annotation.update")){const _=d(b.id);if(b.text!==void 0&&n.updateProperties(_,{text:b.text}),b.placement===null)ce(_,"bwl:Placement",null);else if(b.placement){const S=d(b.placement.anchor),O=iS(S),B=g(S)??p(),T=typeof B.x=="number"&&typeof B.width=="number"&&B.type==="bpmn:Participant",[N,L]=ol[b.placement.side],D=b.placement.offset??50,z={x:O.x+O.width/2+N*(O.width/2+_.width/2+D),y:O.y+O.height/2+L*(O.height/2+_.height/2+D)},j=T?al(r,O,{width:_.width,height:_.height},B,{placement:b.placement,selfId:b.id}):z;n.moveElements([_],{x:j.x-(_.x+_.width/2),y:j.y-(_.y+_.height/2)}),ce(_,"bwl:Placement",ie(b.placement))}}for(const b of Ft(e,"group.update")){const _=d(b.id);if(b.name!==void 0&&n.updateLabel(_,b.name??""),b.members){const S=b.members.map(f).filter(O=>!!O);S.length&&n.resizeShape(_,Vg(S,b.id)),ce(_,"bwl:Members",{refs:b.members.join(" ")})}}}function Mf(e){switch(e.kind){case"annotation-over-label":return[e.annotation];case"edge-crosses-shape":return[e.shape];case"shape-outside-container":return[e.shape];case"shape-overlap":return e.shapes;default:return[]}}function oA(e,t,n,i){const{elementRegistry:o}=e,r=e.modeling,a=[...t.incoming??[],...t.outgoing??[]].filter(d=>d.type==="bpmn:Association");if(!a.length)return 0;const s=d=>d.map(g=>g.original?{x:g.x,y:g.y,original:{x:g.original.x,y:g.original.y}}:{x:g.x,y:g.y}),c=(d,g)=>d.length===g.length&&d.every((h,m)=>{var w,y,v,x;return h.x===g[m].x&&h.y===g[m].y&&((w=h.original)==null?void 0:w.x)===((y=g[m].original)==null?void 0:y.x)&&((v=h.original)==null?void 0:v.y)===((x=g[m].original)==null?void 0:x.y)}),l=a.map(d=>s(d.waypoints)),u=new Set(a.map(d=>d.id));r.moveElements([t],{x:n,y:i});const p=Ue(o),f=[...go(p),...Fi(p)].filter(([d,g])=>u.has(d)!==u.has(g)).length;return r.moveElements([t],{x:-n,y:-i}),a.forEach((d,g)=>{c(d.waypoints,l[g])||r.updateWaypoints(d,l[g])}),f}function rA(e,t,n){var u,p;const{elementRegistry:i}=e,o=e.modeling,r=f=>ft(f).filter(d=>!t.has(pt(d))),a=f=>{var d;return((d=i.get(f))==null?void 0:d.type)==="bpmn:TextAnnotation"},s=Ue(i),c=r(s),l=[...new Set(c.flatMap(Mf))].filter(f=>n.has(f)&&a(f));if(l.length)for(const f of l){const d=i.get(f);if(!d||typeof d.x!="number"||typeof d.width!="number")continue;let g=d.parent,h;for(;g;){if(g.type==="bpmn:Participant"){h=g;break}g=g.parent}if(!h){const be=d.x+d.width/2,he=d.y+d.height/2;h=i.getAll().find(ye=>{if(ye.type!=="bpmn:Participant")return!1;const Ee=ye;return typeof Ee.x=="number"&&typeof Ee.width=="number"&&be>=Ee.x&&be<=Ee.x+Ee.width&&he>=Ee.y&&he<=Ee.y+Ee.height})}if(!h||typeof h.x!="number"||typeof h.width!="number")continue;const w=(((u=d.businessObject.extensionElements)==null?void 0:u.values)??[]).find(be=>be.$type==="bwl:Placement"),y=[...d.incoming??[],...d.outgoing??[]].find(be=>be.type==="bpmn:Association"),v=(w!=null&&w.anchor?i.get(w.anchor):void 0)??(y?((p=y.source)==null?void 0:p.id)===f?y.target:y.source:void 0);if(!v)continue;const x=v.waypoints,E=x!=null&&x.length?{x:x[Math.floor((x.length-1)/2)].x,y:x[Math.floor((x.length-1)/2)].y,width:0,height:0}:{x:v.x,y:v.y,width:v.width,height:v.height},A={width:d.width,height:d.height},I={x:d.x+d.width/2,y:d.y+d.height/2},P=w==null?void 0:w.side,k=Ly(i,E,h),H=[];if(P&&P in ol&&H.push(al(i,E,A,h,{placement:{side:P,offset:(w==null?void 0:w.offset)??null},selfId:f})),k&&!rl(I,A,k))for(const be of nA)H.push(al(i,E,A,h,{placement:{side:be,offset:null},selfId:f}));for(const[be,he]of[[-1,0],[1,0],[0,-1],[0,1]])for(let ye=1;ye<=tA;ye++)H.push({x:I.x+be*Dy*ye,y:I.y+he*Dy*ye});const F={...s,edges:s.edges.filter(be=>be.id!==(y==null?void 0:y.id))},G=r(F),ee=G.filter(be=>Mf(be).includes(f)).length;if(!ee)continue;let ce,ie=!1;for(const be of H){const he=be.x-I.x,ye=be.y-I.y;if(!he&&!ye||be.x-A.width/2<h.x||be.x+A.width/2>h.x+h.width||be.y-A.height/2<h.y||be.y+A.height/2>h.y+h.height||k&&!rl(be,A,k))continue;const Ee={...F,shapes:F.shapes.map(J=>J.id===f?{...J,x:J.x+he,y:J.y+ye}:J)},U=r(Ee),ue=U.filter(J=>Mf(J).includes(f)).length;if(ue>=ee||U.length>G.length)continue;const K=Math.abs(he)+Math.abs(ye);if(ie||((!ce||ue<ce.mine||ue===ce.mine&&(U.length<ce.all||U.length===ce.all&&K<ce.dist))&&(ce={x:be.x,y:be.y,mine:ue,all:U.length,dist:K}),ce.mine===0&&ce.all<G.length&&(ie=!0)),ue===0&&U.length<G.length&&oA(e,d,he,ye)===0){ce={x:be.x,y:be.y,mine:ue,all:U.length,dist:K};break}}ce&&o.moveElements([d],{x:ce.x-I.x,y:ce.y-I.y})}}const aA=60;function sl(e,t,n,i){const o=t.x+t.width,r=[],a=c=>{for(const l of c.children??[])l.type==="bpmn:Lane"&&(r.push(l),a(l))};a(t),e.resizeShape(t,{x:t.x,y:t.y,width:n,height:t.height},void 0,i);const s=t.x+n;for(const c of r)Math.abs(c.x+c.width-o)<1&&e.resizeShape(c,{x:c.x,y:c.y,width:s-c.x,height:c.height},void 0,i)}function sA(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=w=>ft(w).filter(y=>!t.has(pt(y))),a=w=>w.filter(y=>y.kind==="pool-overlap"),s=new Map(n.shapes.map(w=>[w.id,w])),c=(w,y)=>y.x>=w.x&&y.y>=w.y&&y.x+y.width<=w.x+w.width&&y.y+y.height<=w.y+w.height,l=w=>{if(!s.get(w))return[w];const v=new Set,x=new Set([w]);for(let A=0;A<4;A++){let I=!1;for(const P of n.shapes)P.type!=="bpmn:Group"||v.has(P.id)||[...x].some(k=>{const H=s.get(k);return H&&c(P,H)})&&(v.add(P.id),I=!0);for(const P of n.shapes)P.type!=="bpmn:Participant"||x.has(P.id)||[...v].some(k=>{const H=s.get(k);return H&&c(H,P)})&&(x.add(P.id),I=!0);if(!I)break}const E=n.shapes.filter(A=>!A.parent&&!x.has(A.id)&&!v.has(A.id)&&A.type!=="bpmn:Group"&&A.type!=="bpmn:Participant").filter(A=>[...v].some(I=>{const P=s.get(I);return P&&c(P,A)})).map(A=>A.id);return[...x,...v,...E]},u=r(Ue(i)),p=a(u).length;if(!p)return;const f=u.length,d=[];let g=0,h=p,m=f;for(let w=0;w<6;w++){const y=Ue(i),v=a(r(y));if(!v.length)break;const x=new Map(y.shapes.map(k=>[k.id,k]));let E=null;for(const k of v){if(k.kind!=="pool-overlap")continue;const[H,F]=k.pools,G=x.get(H),ee=x.get(F);if(!G||!ee)continue;const[ce,ie]=G.x<=ee.x?[G,ee]:[ee,G];if(k.contained)continue;const be=s.get(ce.id),he=s.get(ie.id),ye=be&&he?Math.max(he.x-(be.x+be.width),0):aA,Ee=ce.x+ce.width+ye-ie.x;if(Ee<=0)continue;const U=l(ie.id).filter(ue=>i.get(ue));U.length&&(!E||Ee>E.dx)&&(E={movers:U,dx:Ee})}if(!E)break;const A=E.movers.map(k=>i.get(k)).filter(k=>!!k&&typeof k.x=="number");if(!A.length)break;o.moveElements(A,{x:E.dx,y:0}),d.push({els:A,dx:E.dx});const I=r(Ue(i)),P=a(I).length;P<p&&I.length<=f&&(P<h||P===h&&I.length<m||g===0)&&(g=d.length,h=P,m=I.length)}for(const{els:w,dx:y}of d.slice(g).reverse())o.moveElements(w,{x:-y,y:0})}const ms=.5,Af=150;function cA(e,t){const n=t.shapes.filter(i=>i.type==="bpmn:Participant");if(!(n.length<2))for(const i of lA(n))i.length<n.length&&i.some(r=>Fy(e.elementRegistry.get(r.id)))||uA(e,i)}function lA(e){const t=[...e].sort((i,o)=>i.x+i.width-(o.x+o.width)),n=[];for(const i of t){const o=n[n.length-1],r=o==null?void 0:o[o.length-1];o&&r&&i.x+i.width-(r.x+r.width)<=ms?o.push(i):n.push([i])}return n.filter(i=>i.length>=2)}function Fy(e){var i,o,r;const t=(i=e==null?void 0:e.businessObject)==null?void 0:i.processRef;if(!t)return!0;const n=(t.laneSets??[]).reduce((a,s)=>{var c;return a+(((c=s.lanes)==null?void 0:c.length)??0)},0);return(((o=t.flowElements)==null?void 0:o.length)??0)+n+(((r=t.artifacts)==null?void 0:r.length)??0)===0}function uA(e,t){const{elementRegistry:n}=e,i=e.modeling,o=t.map(y=>y.x+y.width),r=Math.max(...o);if(r-Math.min(...o)>ms)return;const a=t.map(y=>n.get(y.id)).filter(y=>!!y&&typeof y.x=="number");if(a.length<2)return;const s=new Map(t.map(y=>[y.id,y.x]));if(a.some(y=>Math.abs(y.x-s.get(y.id))>ms))return;const c=a.map(y=>y.x+y.width);if(Math.max(...c)-Math.min(...c)<=ms)return;const l=y=>y.x+y.width,u=y=>!!y&&typeof y.width=="number",p=y=>{const v={shapes:[],edges:[],lanes:[]},x=E=>{for(const A of E.children??[]){if("waypoints"in A&&A.waypoints){v.edges.push(A);continue}A.type!=="label"&&(A.type==="bpmn:Lane"?v.lanes.push(A):v.shapes.push(A),x(A))}};return x(y),v},f=new Map(a.map(y=>[y.id,p(y)]));let d=r;for(const y of a){const{shapes:v}=f.get(y.id),x=v.flatMap(E=>[l(E),...u(E.label)?[l(E.label)]:[]]);x.length&&(d=Math.max(d,Math.max(...x)+Af))}const g=a.filter(y=>Math.abs(l(y)-d)>ms);if(!g.length)return;for(const y of g){const v=l(y),{shapes:x,edges:E,lanes:A}=f.get(y.id);if([...x.flatMap(k=>[l(k),...u(k.label)?[l(k.label)]:[]]),...E.flatMap(k=>[...k.waypoints.map(H=>H.x),...u(k.label)?[l(k.label)]:[]])].some(k=>k>d)||[...(y.incoming??[]).map(k=>k.waypoints[k.waypoints.length-1]),...(y.outgoing??[]).map(k=>k.waypoints[0])].some(k=>!k||k.x>d||Math.abs(k.x-v)<1))return;if(d>v){const k={x:v,y:y.y,width:d-v,height:y.height},H=new Set([y.id,...x.map(G=>G.id),...E.map(G=>G.id),...A.map(G=>G.id)]);if(n.getAll().some(G=>{var ie;if("waypoints"in G&&G.waypoints||G.type==="bpmn:Group"||!u(G))return!1;const ee=G.type==="label"?(ie=G.labelTarget)==null?void 0:ie.id:G.id;if(!ee||H.has(ee)||H.has(G.id))return!1;const ce=G;return ce.x<k.x+k.width&&ce.x+ce.width>k.x&&ce.y<k.y+k.height&&ce.y+ce.height>k.y}))return}}const h=()=>new Set(ft(Ue(n)).map(pt)),m=h(),w=g.map(y=>y.width);for(const y of g)sl(i,y,d-y.x,{layout:!1});[...h()].every(y=>m.has(y))||g.forEach((y,v)=>sl(i,y,w[v],{layout:!1}))}function pA(e,t,n){const{elementRegistry:i}=e,o=e.modeling,r=l=>ft(l).filter(u=>!t.has(pt(u))),a=(l,u)=>u.x>=l.x&&u.y>=l.y&&u.x+u.width<=l.x+l.width&&u.y+u.height<=l.y+l.height,s=l=>({l:Math.min(...l.map(u=>u.x)),t:Math.min(...l.map(u=>u.y)),r:Math.max(...l.map(u=>u.x+u.width)),b:Math.max(...l.map(u=>u.y+u.height))}),c=n.shapes.filter(l=>{var u;return l.type==="bpmn:Group"&&!((u=l.members)!=null&&u.length)});if(c.length)for(const l of c){const u=i.get(l.id);if(!u||typeof u.x!="number")continue;const p=n.shapes.filter(A=>A.id!==l.id&&A.type!=="bpmn:Group"&&a(l,A));if(!p.length)continue;const f=p.map(A=>i.get(A.id)).filter(A=>!!A&&typeof A.x=="number");if(f.length!==p.length)continue;const d=s(p),g=s(f),h=g.l+(l.x-d.l),m=g.t+(l.y-d.t),w=g.r+(l.x+l.width-d.r),y=g.b+(l.y+l.height-d.b),v={x:h,y:m,width:w-h,height:y-m};if(v.width<=0||v.height<=0||Math.abs(v.x-u.x)<1&&Math.abs(v.y-u.y)<1&&Math.abs(v.width-u.width)<1&&Math.abs(v.height-u.height)<1)continue;const x=r(Ue(i)).length,E={x:u.x,y:u.y,width:u.width,height:u.height};o.resizeShape(u,v),r(Ue(i)).length>x&&o.resizeShape(u,E)}}const cl=20,ll=10;function fA(e,t,n,i){var p,f;const{elementRegistry:o}=e,r=e.modeling,a=d=>new Set(ft(d,{includeObservationOnly:!0}).filter(g=>g.kind==="edge-along-group-boundary").map(pt)),s=Ue(o),c=ft(s,{includeObservationOnly:!0}).filter(d=>d.kind==="edge-along-group-boundary"&&!t.has(pt(d)));if(!c.length)return;const l=new Map(n.shapes.map(d=>[d.id,d])),u=new Map;for(const d of c)u.set(d.group,[...u.get(d.group)??[],d]);for(const[d,g]of u){const h=s.shapes.find(ze=>ze.id===d);if(!((p=h==null?void 0:h.members)!=null&&p.length))continue;const m=l.get(d);if(!(!m||Math.abs(m.x-h.x)>=.5||Math.abs(m.y-h.y)>=.5||Math.abs(m.width-h.width)>=.5||Math.abs(m.height-h.height)>=.5))continue;const y=h.members.map(ze=>o.get(ze)).filter(ze=>!!ze&&typeof ze.x=="number");if(!y.length)continue;const v=Math.min(...y.map(ze=>ze.x)),x=Math.min(...y.map(ze=>ze.y)),E=Math.max(...y.map(ze=>ze.x+ze.width)),A=Math.max(...y.map(ze=>ze.y+ze.height)),I=h.x,P=h.y,k=h.x+h.width,H=h.y+h.height;let F=I,G=P,ee=k,ce=H;for(const ze of g){const $=s.edges.find(R=>R.id===ze.edge);if(!$)continue;const C=$.endpoints.some(R=>{const W=s.shapes.find(Oe=>Oe.id===R);if(!W||W.container)return!1;const q=W.x+W.width/2,fe=W.y+W.height/2;return I<q&&q<k&&P<fe&&fe<H});for(const R of an($)){const W=R.axis==="v"?[P,H]:[I,k];Math.min(R.hi,W[1])-Math.max(R.lo,W[0])<af||(R.axis==="v"?I<R.at&&R.at<k:P<R.at&&R.at<H)&&C||(R.axis==="v"?(Math.abs(R.at-I)<=ha&&(F=Math.max(F,R.at+cl)),Math.abs(R.at-k)<=ha&&(ee=Math.min(ee,R.at-cl))):(Math.abs(R.at-P)<=ha&&(G=Math.max(G,R.at+cl)),Math.abs(R.at-H)<=ha&&(ce=Math.min(ce,R.at-cl))))}}if(F>v-ll&&(F=I),G>x-ll&&(G=P),ee<E+ll&&(ee=k),ce<A+ll&&(ce=H),F===I&&G===P&&ee===k&&ce===H)continue;const ie=o.get(d),be={x:ie.x,y:ie.y,width:ie.width,height:ie.height},he=Ue(o),ye=new Set(ft(he).map(pt)),Ee=a(he);r.resizeShape(ie,{x:F,y:G,width:ee-F,height:ce-G});let U=Ue(o),ue=ft(U).filter(ze=>!ye.has(pt(ze)));const K=[];if(ue.length>0&&ue.every(ze=>ze.kind==="label-over-line"&&!i.has(ze.edge)&&U.edges.some($=>$.id===ze.edge))){for(const ze of ue){if(ze.kind!=="label-over-line")continue;const $=U.edges.find(fe=>fe.id===ze.edge),C=$&&Sf($,U),R=(f=o.get(ze.edge))==null?void 0:f.label;if(!C||!R)continue;const W=C.x-R.x,q=C.y-R.y;r.moveElements([R],{x:W,y:q}),K.push({label:R,dx:W,dy:q})}U=Ue(o),ue=ft(U).filter(ze=>!ye.has(pt(ze)))}const ge=a(U),Re=[...ge].some(ze=>!Ee.has(ze));if(ue.length||Re||ge.size>=Ee.size){for(const ze of K.reverse())r.moveElements([ze.label],{x:-ze.dx,y:-ze.dy});r.resizeShape(ie,be)}}}function dA(e,t,n,i){var c;const o=n.getRootElement().businessObject,r=$p((o==null?void 0:o.$parent)??o),a=ss(i),s=new Map;for(const l of e.keys()){const u=(c=t.get(l))==null?void 0:c.businessObject;s.set(l,u?{texts:Fp(u,i,r),requests:Gp(u)}:{texts:{},requests:[]})}return{contexts:()=>[...e].flatMap(([l,u])=>{const p=t.get(l);return p?[{element:p,...u.texts!==void 0?{texts:u.texts}:{},...u.confirm?{confirm:u.confirm}:{},designLocale:i.designLocale,locales:a,...r?{rootLang:r}:{},before:s.get(l)}]:[]})}}function jy(e,t,n={}){var ie,be;const{i18n:i,lower:o=$y}=n,r=ky(e),a=Ym(r.elementRegistry),s=Ty(t,a,{i18n:i}),c={edgeCrossings:{before:0,after:0,pairs:[],solidPairs:0,dashedPairs:0,mixedPairs:0,crossPoolMessages:0},sharedEndpointCrossings:{before:0,after:0,pairs:[]}};if(s.length)return{ok:!1,issues:s,findings:[],stats:c};const l=XM(t,a,i),u=i&&l.writes.size?dA(l.writes,r.elementRegistry,r.canvas,i):void 0,p=Ue(r.elementRegistry),f=new Set(ft(p).map(pt)),d=new Set(ft(p,{includeObservationOnly:!0}).map(pt)),g=new Set(Iy(l.ops,he=>{var ye,Ee;return(Ee=(ye=r.elementRegistry.get(he))==null?void 0:ye.source)==null?void 0:Ee.id}).keys()),h=new Set(p.edges.map(he=>he.id).filter(he=>!g.has(he))),m=new Set(t.flatMap(he=>he.kind==="sequenceFlow.update"&&(he.source!==void 0||he.target!==void 0)?[he.id]:[])),w=()=>new Set(p.edges.filter(he=>{var Ee;const ye=(Ee=r.elementRegistry.get(he.id))==null?void 0:Ee.waypoints;return ye?!(ye.length===he.waypoints.length&&he.waypoints.every((U,ue)=>Math.round(U.x)===Math.round(ye[ue].x)&&Math.round(U.y)===Math.round(ye[ue].y))):!1}).map(he=>he.id)),y=(he,ye)=>new Set([...he].filter(Ee=>!ye.has(Ee))),v=new Set(p.shapes.map(he=>he.id)),x=go(p),E=x.length,A=new Set(x.map(([he,ye])=>`${he}|${ye}`)),I=Fi(p),P=new Set(I.map(([he,ye])=>`${he}|${ye}`)),k=new Map;for(const he of r.elementRegistry.filter(ye=>"waypoints"in ye&&!!ye.waypoints))he.label&&k.set(he.id,{wps:he.waypoints.map(ye=>({x:ye.x,y:ye.y})),label:{x:he.label.x,y:he.label.y},source:(ie=he.source)==null?void 0:ie.id,target:(be=he.target)==null?void 0:be.id});const H=e.get("commandStack");try{Jg(H,()=>{o(l.ops,r);for(const U of(u==null?void 0:u.contexts())??[])H.execute(Hp,U);sA(r,f,p),cA(r,p),pA(r,f,p),SM(r,p,m),wM(r,h,v),iy(r,h);const he=gf(r,f);Zm(r,A,h);const ye=w(),Ee=yy(r,f,y(h,ye),ye);cy(r,h),BM(r,h,m),dy(r,f,h),GM(r,f,h),vM(r,P,h),TM(r,h,p),Ey(r,f,y(h,w())),_y(r,h,new Set([...m,...Ee])),Ry(r,v),rA(r,f,v),gf(r,f,he),fA(r,d,p,h),Cy(r,f),wy(r,k,iA(r))})}catch(he){return{ok:!1,issues:[he instanceof By?he.issue:{kind:"lower-failed",message:he instanceof Error?he.message:String(he)}],findings:[],stats:c}}const F=Ue(r.elementRegistry),G=ft(F,{includeObservationOnly:!0}).filter(he=>!d.has(pt(he))),ee=$m(F),ce=Fi(F);return{ok:!0,issues:[],findings:G,stats:{edgeCrossings:{before:E,after:ee.pairs.length,pairs:ee.pairs,solidPairs:ee.solidPairs,dashedPairs:ee.dashedPairs,mixedPairs:ee.mixedPairs,crossPoolMessages:ee.crossPoolMessages},sharedEndpointCrossings:{before:I.length,after:ce.length,pairs:ce}}}}function hA(e){const t=e.slice(e.indexOf(":")+1);return t.charAt(0).toLowerCase()+t.slice(1)}function Hy(e,t){return typeof e.get=="function"?e.get(t):e[t]}function zy(e,t){const n=Hy(e,t);return typeof n=="number"&&Number.isFinite(n)?n:void 0}function Gy(e,t){var i;return(((i=e.extensionElements)==null?void 0:i.values)??[]).find(o=>(o==null?void 0:o.$type)===t)}function gA(e){return typeof e=="string"&&Dp.includes(e)}function zi(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function Vy(e,t={}){const n=e.rootElements??[],i=n.find(U=>U.$type==="bpmn:Collaboration"),o=new Map(n.filter(U=>U.$type==="bpmn:Process").map(U=>[U.id,U])),r=[],a=[],s=[],c=[],l=[],u=[],p={poolOrders:{},bands:{},placements:{},afterColumns:{}},f=[],d=[],g=[],h=[],m=[],w=[],y=[],v=new Map,x=new Set,E=new Set,A=U=>{U&&x.add(U)},I=U=>{x.add(U),E.add(U)},P=U=>{const ue=Gy(U,"bwl:Placement");if(!ue)return;const K=typeof ue.anchor=="string"?ue.anchor:void 0;if(!K||!gA(ue.side))return;const J=typeof ue.offset=="number"?ue.offset:void 0;m.push({owner:U.id,anchor:K,side:ue.side,...J!==void 0?{offset:J}:{}})},k=U=>{const ue=Gy(U,"bwl:Members"),K=typeof(ue==null?void 0:ue.refs)=="string"?ue.refs.split(/\s+/).filter(Boolean):[];K.length&&y.push({owner:U.id,refs:K})},H=U=>{var ue;for(const K of U)switch(A(K.id),K.$type){case"bpmn:TextAnnotation":I(K.id),v.set(K.id,K),c.push({id:K.id,text:typeof K.text=="string"?K.text:""}),P(K);break;case"bpmn:Association":g.push({id:K.id,type:K.$type,source:zi(K.sourceRef),target:zi(K.targetRef)});break;case"bpmn:Group":{I(K.id),v.set(K.id,K);const J=(ue=K.categoryValueRef)==null?void 0:ue.value;l.push({id:K.id,...typeof J=="string"&&J?{name:J}:{}}),k(K);break}default:u.push({id:K.id,type:K.$type,reason:"type-outside-mvp"})}},F=U=>{for(const ue of U.flowElements??[])A(ue.id),u.push({id:ue.id,type:ue.$type,reason:"inside-container"}),(ue.flowElements??[]).length&&F(ue);for(const ue of U.artifacts??[])A(ue.id),u.push({id:ue.id,type:ue.$type,reason:"inside-container"})},G=(U,ue)=>{const K=U.flowElements??[],J=(U.laneSets??[]).flatMap(Re=>Re.lanes??[]),ge=new Map;for(const Re of J){A(Re.id),v.set(Re.id,Re);for(const ze of Re.flowNodeRef??[]){const $=zi(ze);$&&ge.set($,Re.id)}}for(const Re of K){if(A(Re.id),v.set(Re.id,Re),Re.$type==="bpmn:SequenceFlow"){f.push({id:Re.id,source:zi(Re.sourceRef),target:zi(Re.targetRef),...typeof Re.name=="string"&&Re.name?{name:Re.name}:{}});continue}if(Re.$type==="bpmn:DataStoreReference"){I(Re.id),s.push({id:Re.id,...Re.name?{name:Re.name}:{}});continue}const ze=hA(Re.$type),$=ze==="intermediateCatchEvent"?kp((Re.eventDefinitions??[]).map(q=>q.$type)):void 0;if(!qg(ze)||ze==="intermediateCatchEvent"&&!$){u.push({id:Re.id,type:Re.$type,reason:"type-outside-mvp"});continue}I(Re.id);const C=ze==="boundaryEvent"?zi(Re.attachedToRef):void 0;a.push({id:Re.id,type:ze,...Re.name?{name:Re.name}:{},...ue?{participant:ue}:{},...ge.has(Re.id)?{lane:ge.get(Re.id)}:{},...C?{attachedTo:C}:{},...$?{eventDefinition:$}:{}}),ze==="subProcess"&&F(Re);const R=zy(Re,"bwl:band");R!==void 0&&(p.bands[Re.id]=R);const W=Hy(Re,"bwl:afterColumn");typeof W=="string"&&W!==""&&w.push([Re.id,W]);for(const q of Re.dataOutputAssociations??[])A(q.id),h.push({id:q.id,type:q.$type,source:Re.id,target:zi(q.targetRef)});for(const q of Re.dataInputAssociations??[])A(q.id),h.push({id:q.id,type:q.$type,source:zi((q.sourceRef??[])[0]),target:Re.id})}H(U.artifacts??[])};if(i){const U=new Set;for(const ue of i.participants??[]){I(ue.id),v.set(ue.id,ue);const K=zi(ue.processRef);K&&U.add(K);const J=K?o.get(K):void 0,ge=((J==null?void 0:J.laneSets)??[]).flatMap(C=>C.lanes??[]),Re=ge.map(C=>({id:C.id,...C.name?{name:C.name}:{}}));for(const C of Re)I(C.id);const ze=!J||(J.flowElements??[]).length===0&&ge.length===0&&(J.artifacts??[]).length===0;r.push({id:ue.id,...ue.name?{name:ue.name}:{},...ze?{blackBox:!0}:{},...Re.length?{lanes:Re}:{}});const $=zy(ue,"bwl:poolOrder");$!==void 0&&(p.poolOrders[ue.id]=$),J&&G(J,ue.id)}for(const ue of i.messageFlows??[])A(ue.id),v.set(ue.id,ue),d.push({id:ue.id,source:zi(ue.sourceRef),target:zi(ue.targetRef),...typeof ue.name=="string"&&ue.name?{name:ue.name}:{}});H(i.artifacts??[]);for(const[ue,K]of o)!U.has(ue)&&(K.flowElements??[]).length>0&&u.push({id:ue,type:K.$type,reason:"unreachable-process"})}else for(const U of o.values())G(U);const ee=[],ce=[],ie=[],be=[],he=(U,ue)=>!!U&&!!ue&&E.has(U)&&E.has(ue);for(const U of f){if(!he(U.source,U.target)){u.push({id:U.id,type:"bpmn:SequenceFlow",reason:"endpoint-outside-mvp"});continue}ee.push({id:U.id,source:U.source,target:U.target,...U.name?{name:U.name}:{}}),E.add(U.id)}for(const U of d){if(!he(U.source,U.target)){u.push({id:U.id,type:"bpmn:MessageFlow",reason:"endpoint-outside-mvp"});continue}ce.push({id:U.id,source:U.source,target:U.target,...U.name?{name:U.name}:{}}),E.add(U.id)}for(const U of h){if(!he(U.source,U.target)){u.push({id:U.id??"",type:U.type,reason:"endpoint-outside-mvp"});continue}be.push({...U.id?{id:U.id}:{},source:U.source,target:U.target}),U.id&&E.add(U.id)}for(const U of g){if(!he(U.source,U.target)){u.push({id:U.id??"",type:U.type,reason:"endpoint-outside-mvp"});continue}ie.push({...U.id?{id:U.id}:{},source:U.source,target:U.target})}const ye=new Map(l.map(U=>[U.id,U]));for(const{owner:U,refs:ue}of y){const K=ue.filter(ge=>x.has(ge)),J=ye.get(U);J&&K.length&&(J.members=K)}for(const U of m)x.has(U.anchor)&&(p.placements[U.owner]={anchor:U.anchor,side:U.side,...U.offset!==void 0?{offset:U.offset}:{}});for(const[U,ue]of w)x.has(ue)&&(p.afterColumns[U]=ue);const Ee={...r.length?{participants:r}:{},nodes:a,sequenceFlows:ee,...ce.length?{messageFlows:ce}:{},...s.length?{dataStores:s}:{},...be.length?{dataAssociations:be}:{},...c.length?{annotations:c}:{},...ie.length?{associations:ie}:{},...l.length?{groups:l}:{}};return t.i18n?{definition:Ee,hints:p,omitted:u,i18n:mA(Ee,v,e,t.i18n)}:{definition:Ee,hints:p,omitted:u}}function mA(e,t,n,i){const o=$p(n),r=ss(i),a=[],s=(c,l)=>{const u=t.get(c.id);if(!u)return;const p=Fp(u,i,o);Object.keys(p).length&&(c[l]=p);for(const f of Gp(u))r.includes(f.locale)&&a.push({id:c.id,...f})};for(const c of e.participants??[]){s(c,"names");for(const l of c.lanes??[])s(l,"names")}for(const c of[e.nodes,e.sequenceFlows,e.messageFlows,e.dataStores,e.groups])for(const l of c??[])s(l,"names");for(const c of e.annotations??[])s(c,"texts");return{designLocale:i.designLocale,companionLocales:r.slice(1),reviewRequests:a}}async function yA(e,t={}){const{definitions:n,warnings:i}=await pa(e);return{...Vy(n,t),warnings:i}}const vA=new Set(["bpmn:ExclusiveGateway","bpmn:ParallelGateway","bpmn:InclusiveGateway","bpmn:EventBasedGateway","bpmn:ComplexGateway"]);function Pf(e){if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:void 0}function bA(e){return Pf(e.processRef)!==void 0}function xA(e){const t=new Set,n=o=>{const r=Pf(o);r&&t.add(r)},i=o=>{for(const r of o.flowElements??[]){n(r.sourceRef),n(r.targetRef),r.attachedToRef&&(n(r.attachedToRef),t.add(r.id));for(const a of r.dataOutputAssociations??[])t.add(r.id),n(a.targetRef);for(const a of r.dataInputAssociations??[]){t.add(r.id);for(const s of a.sourceRef??[])n(s)}(r.flowElements??[]).length&&i(r)}for(const r of o.artifacts??[])n(r.sourceRef),n(r.targetRef)};for(const o of e.rootElements??[])if(o.$type==="bpmn:Process")i(o);else if(o.$type==="bpmn:Collaboration"){for(const r of o.messageFlows??[])n(r.sourceRef),n(r.targetRef);for(const r of o.artifacts??[])n(r.sourceRef),n(r.targetRef)}return t}function wA(e){const t=[],n=i=>{for(const o of i.flowElements??[])vA.has(o.$type)&&t.push(o),(o.flowElements??[]).length&&n(o)};for(const i of e.rootElements??[])i.$type==="bpmn:Process"&&n(i);return t}function _A(e){if(!e)return!0;const t=(e.laneSets??[]).flatMap(n=>n.lanes??[]);return(e.flowElements??[]).length===0&&t.length===0&&(e.artifacts??[]).length===0}function Tf(e){const t=[],n=e.rootElements??[],i=xA(e);for(const r of wA(e))i.has(r.id)||t.push({ruleId:"CHK-FLOW-1",severity:"warning",targetKind:"flowNode",targetRefs:[r.id],params:{type:r.$type}});const o=n.find(r=>r.$type==="bpmn:Collaboration");if(o){const r=new Map(n.filter(s=>s.$type==="bpmn:Process").map(s=>[s.id,s])),a=[];for(const s of o.participants??[])bA(s)&&_A(r.get(Pf(s.processRef)))&&a.push(s.id);a.length&&t.push({ruleId:"CHK-POOL-1",severity:"info",targetKind:"participant",targetRefs:a,params:{count:a.length}})}return t}async function EA(e){const{definitions:t,warnings:n}=await pa(e);return{issues:Tf(t),warnings:n}}const SA=.5,RA=8,CA=new Set(["bpmn:Definitions","bpmn:Collaboration","bpmn:Process","bpmn:LaneSet","bpmn:ExtensionElements","bpmn:Documentation","bpmn:Relationship","bpmn:Property","bpmn:Category","bpmn:CategoryValue"]),ba=e=>typeof e=="number"?e:Number(e??NaN),ul=e=>{if(typeof e=="string")return e;const t=e==null?void 0:e.id;return typeof t=="string"?t:""};function MA(e){const t=e,n=[],i=typeof t.name=="string"?t.name:typeof t.text=="string"?t.text:"";n.push(`n=${i.replace(/\s+/g," ").trim()}`);for(const r of["sourceRef","targetRef","attachedToRef","processRef","default"])t[r]!==void 0&&n.push(`${r}=${ul(t[r])}`);if(String(e.$type)==="bpmn:Group"){const r=t.categoryValueRef,a=Array.isArray(r)?r:r==null?[]:[r];n.push(`cat=[${a.map(s=>`${ul(s)}:${typeof(s==null?void 0:s.value)=="string"?s.value:""}`).sort().join(",")}]`)}Array.isArray(t.flowNodeRef)&&n.push(`lane=[${t.flowNodeRef.map(ul).sort().join(",")}]`);const o=t.conditionExpression;return o&&typeof o.body=="string"&&n.push(`cond=${o.body}`),n.join("|")}function AA(e){const t=new Map,n=new Map,i=(a,s)=>{a&&t.set(a,[...t.get(a)??[],...s])},o=a=>{const s=a;return s?[ba(s.x),ba(s.y),ba(s.width),ba(s.height)]:[]},r=a=>{if(Array.isArray(a))return a.forEach(r);if(!a||typeof a!="object")return;const s=a,c=String(s.$type??"");if(c==="bpmndi:BPMNShape"||c==="bpmndi:BPMNEdge"){const l=ul(s.bpmnElement);if(c==="bpmndi:BPMNShape")i(l,o(s.bounds));else{const p=Array.isArray(s.waypoint)?s.waypoint:[];i(l,p.flatMap(f=>[ba(f.x),ba(f.y)]))}const u=s.label;u!=null&&u.bounds&&l&&n.set(l,o(u.bounds).slice(0,2));return}for(const l of Object.values(s))(Array.isArray(l)||l&&typeof l=="object"&&"$type"in l)&&r(l)};return r(e.diagrams),{body:t,labels:n}}function Wy(e){const t=AA(e),n=new Map,i=new Set,o=r=>{if(Array.isArray(r))return r.forEach(o);if(!r||typeof r!="object"||i.has(r))return;i.add(r);const a=r,s=String(a.$type??"");if(s.startsWith("bpmndi:")||s.startsWith("dc:")||s.startsWith("di:"))return;const c=typeof a.id=="string"?a.id:"";c&&s.startsWith("bpmn:")&&!CA.has(s)&&n.set(c,{type:s,props:MA(a),geometry:(t.body.get(c)??[]).join(","),label:(t.labels.get(c)??[]).join(",")});for(const l of Object.values(a))(Array.isArray(l)||l&&typeof l=="object")&&o(l)};return o(e),n}function Uy(e,t,n){if(e===t)return!1;const i=e===""?[]:e.split(",").map(Number),o=t===""?[]:t.split(",").map(Number);return i.length!==o.length?!0:i.some((r,a)=>Math.abs(r-o[a])>n)}function qy(e,t,n={}){const i=n.moveTolerance??SA,o=Wy(e),r=Wy(t),a=[],s=[],c=[];for(const[l,u]of r){const p=o.get(l);if(!p){a.push(l);continue}(p.type!==u.type||p.props!==u.props||Uy(p.geometry,u.geometry,i)||Uy(p.label,u.label,n.labelTolerance??RA))&&c.push(l)}for(const l of o.keys())r.has(l)||s.push(l);return{added:a.sort(),removed:s.sort(),modified:c.sort()}}async function PA(e,t,n={}){const[i,o]=await Promise.all([pa(e),pa(t)]);return{...qy(i.definitions,o.definitions,n),warnings:[...i.warnings,...o.warnings]}}function TA(e){return new Set([...e.added,...e.modified])}function kA(e,t,n,i={}){return{documentId:e,baseVersion:t,ops:[...n],origin:i.origin??"agent",clientOpId:(i.mkClientOpId??(()=>crypto.randomUUID()))()}}async function Yy(e,t,{currentVersion:n,i18n:i}){if(t.baseVersion!==n)return{status:"conflict",baseVersion:t.baseVersion,currentVersion:n};const o=jy(e,t.ops,{i18n:i});if(!o.ok)return{status:"rejected",issues:o.issues};const{xml:r}=await e.saveXML({format:!0});return{status:"applied",version:n+1,xml:r??"",findings:o.findings,stats:o.stats}}const OA=new Set(["lasso","lasso.selection","hand","hand.move"]),Ky=1e4,DA="bwl-edit-locked",Xy=new WeakMap;function LA(e){const t=Xy.get(e);if(t)return t;const n=e.get("eventBus"),i=e.get("dragging",!1);let o=!1,r=!1;n.on("drag.init",Ky,()=>{var s;if(o)return OA.has((s=i==null?void 0:i.context())==null?void 0:s.prefix)?void 0:!1}),n.on(["contextPad.open.allowed","contextPad.trigger","palette.trigger","element.dblclick"],Ky,()=>o?!1:void 0);const a={get locked(){return o},set(s){var l,u,p;if(s===o)return;o=s,e.get("canvas").getContainer().classList.toggle(DA,s);const c=e.get("keyboard",!1);s?(i==null||i.cancel(),(l=e.get("contextPad",!1))==null||l.close(),(u=e.get("popupMenu",!1))==null||u.close(),(p=e.get("directEditing",!1))==null||p.complete(),r=!!(c!=null&&c.getBinding()),c==null||c.unbind()):r&&(c.bind(),r=!1)}};return Xy.set(e,a),a}const IA=Symbol("bpmn-editor"),kf={geometry:[],semantic:[]};function BA(){const e=Se.ref(!1),t=Se.ref(!0),n=Se.ref(!1),i=Se.shallowRef(kf),o=Se.shallowRef(void 0),r=Se.shallowRef(void 0);let a,s,c;const l=()=>{if(p(),!c){i.value=kf;return}const w=ft(Ue(c.get("elementRegistry")),{includeObservationOnly:!0}),y=c.getDefinitions();i.value={geometry:w,semantic:y?Tf(y):[]}};function u(){return(c==null?void 0:c.get("i18nDisplay",!1))??void 0}function p(){const w=u();if(!w||!a){r.value=void 0;return}const y=w.locales(),v={};for(const x of y)v[x]={untranslated:w.untranslatedCount(x),reviewRequested:w.reviewRequestedCount(x)};r.value={designLocale:a.designLocale,locales:y,displayLocale:w.getDisplayLocale()??a.designLocale,counts:v}}function f(){const w=u();w&&(w.configure(a),a&&s&&(s=w.setDisplayLocale(s)))}const d=()=>{e.value=!0,l()};function g(w,y){LA(w).set(!y)}function h(){if(!c)throw new Error("modeler not attached — 뷰 @ready 후 attach() 필요");return c}function m(){return c==null?void 0:c.get("commandStack")}return{dirty:e,editable:t,agentBusy:n,issues:i,revalidate:l,changeScope:o,i18n:r,configureI18n(w){a=w,f(),p()},setDisplayLocale(w){var v;s=w;const y=(v=u())==null?void 0:v.setDisplayLocale(w);y&&(s=y),p()},setChangeScope(w){o.value=w===void 0?void 0:new Set(w)},requestFocus(w){if(!c)return;const y=c.get("elementRegistry").get(w);y&&(c.get("canvas").scrollToElement(y,180),c.get("selection").select(y))},describeElement(w){const y=c==null?void 0:c.get("elementRegistry").get(w),v=y==null?void 0:y.businessObject;if(!v)return;const x=typeof v.name=="string"&&v.name.trim()!==""?v.name:v.text;return{name:typeof x=="string"&&x.trim()!==""?x.trim():void 0,type:typeof v.$type=="string"?v.$type:""}},attach(w){c&&this.detach(),c=w,c.get("eventBus").on("commandStack.changed",d),t.value||g(c,!1),f(),l()},detach(){c==null||c.get("eventBus").off("commandStack.changed",d),c&&!t.value&&g(c,!0),c=void 0,i.value=kf,o.value=void 0,r.value=void 0},setEditable(w){t.value=w,c&&g(c,w)},async applyAgentBatch(w,y){const v=h();n.value=!0;try{const x=await Yy(v,w,{currentVersion:y,...a?{i18n:{designLocale:a.designLocale,companionLocales:a.companionLocales}}:{}});return x.status==="applied"&&(e.value=!1),x}finally{n.value=!1}},async importXml(w){const{warnings:y}=await h().importXML(w);return e.value=!1,o.value=void 0,l(),{warnings:rf(y)}},async saveXml(){const{xml:w}=await h().saveXML({format:!0});return e.value=!1,w??""},undo:()=>{var w;return(w=m())==null?void 0:w.undo()},redo:()=>{var w;return(w=m())==null?void 0:w.redo()},canUndo:()=>{var w;return((w=m())==null?void 0:w.canUndo())??!1},canRedo:()=>{var w;return((w=m())==null?void 0:w.canRedo())??!1}}}const NA=new RegExp("\\p{Script=Hangul}","u"),$A=/[\p{Script=Hiragana}\p{Script=Katakana}]/u,FA=new RegExp("\\p{Script=Han}","u");function pl(e){const t=NA.test(e),n=$A.test(e);return t&&n?{script:"mixed"}:t?{script:"hangul",locale:"ko"}:n?{script:"kana",locale:"ja"}:{script:FA.test(e)?"han":"other"}}function Zy(e){var t,n;return((t=e==null?void 0:e.get)==null?void 0:t.call(e,"xml:lang"))??((n=e==null?void 0:e.$attrs)==null?void 0:n["xml:lang"])}function Qy(e){var i;const t=new Set,n=[];for(const o of(e==null?void 0:e.diagrams)??[])for(const r of((i=o==null?void 0:o.plane)==null?void 0:i.planeElement)??[]){const a=r==null?void 0:r.bpmnElement;if(!a||t.has(a))continue;t.add(a);const s=Ar(a);if(!s)continue;const c=s.target[s.key]??"";c&&n.push({bo:a,name:c,trs:No(a).filter(l=>Rn(l))})}return n}const ys=e=>({id:e.bo.id,type:e.bo.$type,name:e.name});function jA(e,t={}){const n=Zy(e),i=Qy(e);let o;const r={},a=[],s=[],c=[];for(const h of i){const m=h.trs.filter(w=>(w.body??"")===h.name).map(Rn);if(m.length){const w=[...m].sort().join("+");r[w]=(r[w]??0)+1,o=o?new Set([...o].filter(y=>m.includes(y))):new Set(m)}else h.trs.some(w=>w.body)?a.push(ys(h)):c.push({e:h,inference:pl(h.name)});for(const w of h.trs){const y=Rn(w),v=w.body??"",x=pl(v);x.locale&&x.locale!==y?s.push({...ys(h),locale:y,script:x.script}):y==="ko"&&x.script==="han"&&h.trs.some(E=>E!==w&&E.body===v)&&s.push({...ys(h),locale:y,script:"han"})}}const l=new Set(c.map(h=>h.inference.locale).filter(Boolean));let u,p;if(n)p="kept";else if(o&&o.size===1)[u,p]=[[...o][0],"matched"];else if(o&&o.size>1){const h=l.size===1?[...l][0]:void 0;h&&o.has(h)?[u,p]=[h,"matched"]:p="ambiguous"}else o?p="mixed":l.size===1?[u,p]=[[...l][0],"script"]:p=l.size>1?"mixed":"no-evidence";u&&t.designLocale&&u!==t.designLocale&&([u,p]=[void 0,"non-design"]);const f=n??u,d=[],g=[];for(const{e:h,inference:m}of c)m.locale?m.locale!==f&&d.push({...ys(h),locale:m.locale}):g.push({...ys(h),script:m.script});return{root:{current:n,proposed:u,reason:p},additions:d,undecided:g,drift:a,matchedBy:r,scriptMismatch:s}}function HA(e,t){const n=e.$model;let i=0;if(t.root.proposed&&!Zy(e)&&(e.set("xml:lang",t.root.proposed),i++),!t.additions.length)return i;const o=new Map(Qy(e).map(r=>[r.bo.id,r]));for(const{id:r,name:a,locale:s}of t.additions){const c=o.get(r);if(!c||c.name!==a||c.trs.some(f=>f.body))continue;const l=c.trs.find(f=>Rn(f)===s);if(l){l.body=c.name,i++;continue}let u=c.bo.extensionElements;u||(u=n.create("bpmn:ExtensionElements",{values:[]}),u.$parent=c.bo,c.bo.extensionElements=u);const p=n.create(Mr,{body:c.name});p.set("xml:lang",s),p.$parent=u,u.get("values").push(p),i++}return i}function Jy(e){var i;const t=new Set,n=[];for(const o of(e==null?void 0:e.diagrams)??[])for(const r of((i=o==null?void 0:o.plane)==null?void 0:i.planeElement)??[]){const a=r==null?void 0:r.bpmnElement;!(a!=null&&a.id)||t.has(a)||(t.add(a),n.push(a))}return n}const Of=e=>Rn(e)||void 0,ev=e=>e.body??"";function tv(e){const t=new Map;for(const n of Jy(e)){const i=No(n);i.length&&t.set(n.id,{type:n.$type,cells:i.map(o=>({locale:Of(o),body:ev(o)}))})}return t}const nv=e=>JSON.stringify(e.map(t=>t.body).sort());class zA{constructor(){$n(this,"byId",new Map);$n(this,"byBodies",new Map)}add(t,n,i){for(const[o,r]of i){if(!r.cells.some(s=>s.locale))continue;const a={doc:t,version:n,id:o,state:r};iv(this.byId,o,a),iv(this.byBodies,nv(r.cells),a)}}sameId(t){return this.byId.get(t)??[]}sameBodies(t){return this.byBodies.get(nv(t))??[]}}function iv(e,t,n){const i=e.get(t);i?i.push(n):e.set(t,[n])}function GA(e,t,n){var s;const i=new Set(t.cells.filter(c=>c.locale).map(c=>c.body)),o=new Map,r=(c,l)=>(c??[]).filter(u=>!u.locale&&u.body===l).length,a=t.cells.every(c=>!c.locale);for(const c of t.cells){if(c.locale||i.has(c.body)||o.has(c.body))continue;const l=r(t.cells,c.body)-(a?0:n?r((s=n.get(e))==null?void 0:s.cells,c.body):1/0);l>0&&o.set(c.body,l)}return o}function Df(e,t){return[...t.keys()].every(n=>e.cells.some(i=>i.body===n))&&e.cells.some(n=>n.locale&&t.has(n.body))}function VA(e,t,n){const i=new Set(e.cells.filter(r=>r.locale).map(r=>r.locale)),o={cells:[],stale:[],overflow:!1};for(const[r,a]of n){const s=[...new Set(t.cells.filter(l=>l.body===r&&l.locale).map(l=>l.locale))],c=s.filter(l=>!i.has(l));for(const l of s)i.has(l)&&o.stale.push({body:r,locale:l});c.length>a&&(o.overflow=!0);for(const l of c.slice(0,a))o.cells.push({body:r,locale:l}),i.add(l)}return o}const WA=e=>JSON.stringify([...e.cells].sort((t,n)=>(t.body+t.locale).localeCompare(n.body+n.locale)));function UA(e,t){const n={restores:[],ambiguous:[],stale:[],unresolved:[]},i=tv(e),o=new Set([...i.values()].flatMap(a=>a.cells.map(s=>s.locale).filter(s=>!!s))),r=a=>!o.size||[...o].some(s=>!a.cells.some(c=>c.locale===s));for(const[a,s]of i){const c=GA(a,s,t.baseline);if(!c.size)continue;const l={id:a,type:s.type},p=[["history",t.index.sameId(a).filter(m=>m.doc===t.doc&&Df(m.state,c)).sort((m,w)=>w.version-m.version).slice(0,1).map(m=>m.state)],["lineage",t.index.sameId(a).filter(m=>m.doc!==t.doc&&Df(m.state,c)).map(m=>m.state)],["bodies",t.index.sameBodies(s.cells).filter(m=>!(m.doc===t.doc&&m.id===a)&&Df(m.state,c)).map(m=>m.state)]].find(([,m])=>m.length);if(!p){if(!r(s))continue;for(const[m,w]of c)for(let y=0;y<w;y++)n.unresolved.push({...l,body:m,script:pl(m).script});continue}const[f,d]=p,g=d.map(m=>VA(s,m,c));if(g.some(m=>m.overflow)||new Set(g.map(WA)).size>1){n.ambiguous.push({...l,source:f});continue}const[h]=g;for(const m of h.stale)n.stale.push({...l,...m});h.cells.length&&n.restores.push({...l,source:f,cells:h.cells})}return n}function qA(e,t){if(!t.restores.length)return 0;const n=new Map(Jy(e).map(o=>[o.id,o]));let i=0;for(const o of t.restores){const r=n.get(o.id);if(!r)continue;const a=No(r),s=new Set(a.map(Of).filter(Boolean));for(const{body:c,locale:l}of o.cells){if(s.has(l))continue;const u=a.find(p=>!Of(p)&&ev(p)===c);u&&(u.set("xml:lang",l),s.add(l),i++)}}return i}function Ne(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}function YA(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Lf={exports:{}},ov;function KA(){if(ov)return Lf.exports;ov=1;var e=Lf.exports=function(t,n){if(n||(n=16),t===void 0&&(t=128),t<=0)return"0";for(var i=Math.log(Math.pow(2,t))/Math.log(n),o=2;i===1/0;o*=2)i=Math.log(Math.pow(2,t/o))/Math.log(n)*o;for(var r=i-Math.floor(i),a="",o=0;o<Math.floor(i);o++){var s=Math.floor(Math.random()*n).toString(n);a=s+a}if(r){var c=Math.pow(n,r),s=Math.floor(Math.random()*c).toString(n);a=s+a}var l=parseInt(a,n);return l!==1/0&&l>=Math.pow(2,t)?e(t,n):a};return e.rack=function(t,n,i){var o=function(a){var s=0;do{if(s++>10)if(i)t+=i;else throw new Error("too many ID collisions, use more bits");var c=e(t,n)}while(Object.hasOwnProperty.call(r,c));return r[c]=a,c},r=o.hats={};return o.get=function(a){return o.hats[a]},o.set=function(a,s){return o.hats[a]=s,o},o.bits=t||128,o.base=n||16,o},Lf.exports}var XA=KA(),ZA=YA(XA);function Xi(e){if(!(this instanceof Xi))return new Xi(e);e=e||[128,36,1],this._seed=e.length?ZA.rack(e[0],e[1],e[2]):e}Xi.prototype.next=function(e){return this._seed(e||!0)},Xi.prototype.nextPrefixed=function(e,t){var n;do n=e+this.next(!0);while(this.assigned(n));return this.claim(n,t),n},Xi.prototype.claim=function(e,t){this._seed.set(e,t||!0)},Xi.prototype.assigned=function(e){return this._seed.get(e)||!1},Xi.prototype.unclaim=function(e){delete this._seed.hats[e]},Xi.prototype.clear=function(){var e=this._seed.hats,t;for(t in e)this.unclaim(t)};const yn={legend:[1,"<fieldset>","</fieldset>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],_default:[0,"",""]};yn.td=yn.th=[3,"<table><tbody><tr>","</tr></tbody></table>"],yn.option=yn.optgroup=[1,'<select multiple="multiple">',"</select>"],yn.thead=yn.tbody=yn.colgroup=yn.caption=yn.tfoot=[1,"<table>","</table>"],yn.polyline=yn.ellipse=yn.polygon=yn.circle=yn.text=yn.line=yn.path=yn.rect=yn.g=[1,'<svg xmlns="http://www.w3.org/2000/svg" version="1.1">',"</svg>"];function jt(e,t=globalThis.document){var l;if(typeof e!="string")throw new TypeError("String expected");const n=/^<!--(.*?)-->$/s.exec(e);if(n)return t.createComment(n[1]);const i=(l=/<([\w:]+)/.exec(e))==null?void 0:l[1];if(!i)return t.createTextNode(e);if(e=e.trim(),i==="body"){const u=t.createElement("html");u.innerHTML=e;const{lastChild:p}=u;return p.remove(),p}let[o,r,a]=Object.hasOwn(yn,i)?yn[i]:yn._default,s=t.createElement("div");for(s.innerHTML=r+e+a;o--;)s=s.lastChild;if(s.firstChild===s.lastChild){const{firstChild:u}=s;return u.remove(),u}const c=t.createDocumentFragment();return c.append(...s.childNodes),c}function QA(e,t){return t.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(i){if(i!=="default"&&!(i in e)){var o=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:function(){return n[i]}})}})}),Object.freeze(e)}function Un(e,...t){const n=e.style;return V(t,function(i){i&&V(i,function(o,r){n[r]=o})}),e}function Cn(e,t,n){return arguments.length==2?e.getAttribute(t):n===null?e.removeAttribute(t):(e.setAttribute(t,n),e)}const JA=Object.prototype.toString;function At(e){return new Go(e)}function Go(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Go.prototype.add=function(e){return this.list.add(e),this},Go.prototype.remove=function(e){return JA.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},Go.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Go.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Go.prototype.array=function(){return Array.from(this.list)},Go.prototype.has=Go.prototype.contains=function(e){return this.list.contains(e)};function fl(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Lr(e,t,n){var i=n?e:e.parentNode;return i&&typeof i.closest=="function"&&i.closest(t)||null}function eP(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var dl={},rv;function tP(){if(rv)return dl;rv=1;var e,t,n;function i(){e=window.addEventListener?"addEventListener":"attachEvent",t=window.removeEventListener?"removeEventListener":"detachEvent",n=e!=="addEventListener"?"on":""}return dl.bind=function(o,r,a,s){return e||i(),o[e](n+r,a,s||!1),a},dl.unbind=function(o,r,a,s){return t||i(),o[t](n+r,a,s||!1),a},dl}var av=tP(),nP=eP(av),Ve=QA({__proto__:null,default:nP},[av]),sv=["focus","blur"];function iP(e,t,n,i,o){return sv.indexOf(n)!==-1&&(o=!0),Ve.bind(e,n,function(r){var a=r.target||r.srcElement;r.delegateTarget=Lr(a,t,!0),r.delegateTarget&&i.call(e,r)},o)}function oP(e,t,n,i){return sv.indexOf(t)!==-1&&(i=!0),Ve.unbind(e,t,n,i)}var ii={bind:iP,unbind:oP};function If(e,t){return e&&typeof e.matches=="function"&&e.matches(t)||!1}function Ct(e,t){return t=t||document,t.querySelector(e)}function vs(e,t){return t=t||document,t.querySelectorAll(e)}function Zi(e){e.parentNode&&e.parentNode.removeChild(e)}function rP(e,t){if(e.ownerDocument!==t.ownerDocument)try{return t.ownerDocument.importNode(e,!0)}catch{}return e}function aP(e,t){return t.appendChild(rP(e,t))}function tt(e,t){return aP(t,e),e}var Bf=2,cv={"alignment-baseline":1,"baseline-shift":1,clip:1,"clip-path":1,"clip-rule":1,color:1,"color-interpolation":1,"color-interpolation-filters":1,"color-profile":1,"color-rendering":1,cursor:1,direction:1,display:1,"dominant-baseline":1,"enable-background":1,fill:1,"fill-opacity":1,"fill-rule":1,filter:1,"flood-color":1,"flood-opacity":1,font:1,"font-family":1,"font-size":Bf,"font-size-adjust":1,"font-stretch":1,"font-style":1,"font-variant":1,"font-weight":1,"glyph-orientation-horizontal":1,"glyph-orientation-vertical":1,"image-rendering":1,kerning:1,"letter-spacing":1,"lighting-color":1,marker:1,"marker-end":1,"marker-mid":1,"marker-start":1,mask:1,opacity:1,overflow:1,"pointer-events":1,"shape-rendering":1,"stop-color":1,"stop-opacity":1,stroke:1,"stroke-dasharray":1,"stroke-dashoffset":1,"stroke-linecap":1,"stroke-linejoin":1,"stroke-miterlimit":1,"stroke-opacity":1,"stroke-width":Bf,"text-anchor":1,"text-decoration":1,"text-rendering":1,"unicode-bidi":1,visibility:1,"word-spacing":1,"writing-mode":1};function sP(e,t){return cv[t]?e.style[t]:e.getAttributeNS(null,t)}function lv(e,t,n){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),o=cv[i];o?(o===Bf&&typeof n=="number"&&(n=String(n)+"px"),e.style[i]=n):e.setAttributeNS(null,t,n)}function cP(e,t){var n=Object.keys(t),i,o;for(i=0,o;o=n[i];i++)lv(e,o,t[o])}function Ie(e,t,n){if(typeof t=="string")if(n!==void 0)lv(e,t,n);else return sP(e,t);else cP(e,t);return e}const lP=Object.prototype.toString;function dt(e){return new Vo(e)}function Vo(e){if(!e||!e.nodeType)throw new Error("A DOM element reference is required");this.el=e,this.list=e.classList}Vo.prototype.add=function(e){return this.list.add(e),this},Vo.prototype.remove=function(e){return lP.call(e)=="[object RegExp]"?this.removeMatching(e):(this.list.remove(e),this)},Vo.prototype.removeMatching=function(e){const t=this.array();for(let n=0;n<t.length;n++)e.test(t[n])&&this.remove(t[n]);return this},Vo.prototype.toggle=function(e,t){return typeof t<"u"?t!==this.list.toggle(e,t)&&this.list.toggle(e):this.list.toggle(e),this},Vo.prototype.array=function(){return Array.from(this.list)},Vo.prototype.has=Vo.prototype.contains=function(e){return this.list.contains(e)};function bs(e){for(var t;t=e.firstChild;)e.removeChild(t);return e}function Nf(e){return e.cloneNode(!0)}var $f={svg:"http://www.w3.org/2000/svg"},uv='<svg xmlns="'+$f.svg+'"';function uP(e){var t=!1;e.substring(0,4)==="<svg"?e.indexOf($f.svg)===-1&&(e=uv+e.substring(4)):(e=uv+">"+e+"</svg>",t=!0);var n=pP(e);if(!t)return n;for(var i=document.createDocumentFragment(),o=n.firstChild;o.firstChild;)i.appendChild(o.firstChild);return i}function pP(e){var t;return t=new DOMParser,t.async=!1,t.parseFromString(e,"text/xml")}function He(e,t){var n;return e=e.trim(),e.charAt(0)==="<"?(n=uP(e).firstChild,n=document.importNode(n,!0)):n=document.createElementNS($f.svg,e),t&&Ie(n,t),n}var Ff=null;function pv(){return Ff===null&&(Ff=He("svg")),Ff}function fv(e,t){var n,i,o=Object.keys(t);for(n=0;i=o[n];n++)e[i]=t[i];return e}function fP(e,t,n,i,o,r){var a=pv().createSVGMatrix();switch(arguments.length){case 0:return a;case 1:return fv(a,e);case 6:return fv(a,{a:e,b:t,c:n,d:i,e:o,f:r})}}function xs(e){return pv().createSVGTransform()}var dv=/([&<>]{1})/g,dP=/([&<>\n\r"]{1})/g,hP={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"'"};function jf(e,t){function n(i,o){return hP[o]||o}return e.replace(t,n)}function hv(e,t){var n,i,o,r,a;switch(e.nodeType){case 3:t.push(jf(e.textContent,dv));break;case 1:if(t.push("<",e.tagName),e.hasAttributes())for(o=e.attributes,n=0,i=o.length;n<i;++n)r=o.item(n),t.push(" ",r.name,'="',jf(r.value,dP),'"');if(e.hasChildNodes()){for(t.push(">"),a=e.childNodes,n=0,i=a.length;n<i;++n)hv(a.item(n),t);t.push("</",e.tagName,">")}else t.push("/>");break;case 8:t.push("<!--",jf(e.nodeValue,dv),"-->");break;case 4:t.push("<![CDATA[",e.nodeValue,"]]>");break;default:throw new Error("unable to handle node "+e.nodeType)}return t}function gP(e){for(var t=e.firstChild,n=[];t;)hv(t,n),t=t.nextSibling;return n.join("")}function gv(e,t){return gP(e)}function sn(e){var t=e.parentNode;return t&&t.removeChild(e),e}function mP(e,t){return t instanceof SVGMatrix?e.createSVGTransformFromMatrix(t):t}function yP(e,t){var n,i;for(e.clear(),n=0;i=t[n];n++)e.appendItem(mP(e,i))}function ws(e,t){var n=e.transform.baseVal;return t&&(Array.isArray(t)||(t=[t]),yP(n,t)),n.consolidate()}const vP=/^class[ {]/;function bP(e){return vP.test(e.toString())}function Hf(e){return Array.isArray(e)}function zf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function hl(...e){e.length===1&&Hf(e[0])&&(e=e[0]),e=[...e];const t=e.pop();return t.$inject=e,t}const xP=/constructor\s*[^(]*\(\s*([^)]*)\)/m,wP=/^(?:async\s+)?(?:function\s*[^(]*)?(?:\(\s*([^)]*)\)|(\w+))/m,_P=/\/\*([^*]*)\*\//m;function EP(e){if(typeof e!="function")throw new Error(`Cannot annotate "${e}". Expected a function!`);const t=e.toString().match(bP(e)?xP:wP);if(!t)return[];const n=t[1]||t[2];return n&&n.split(",").map(i=>{const o=i.match(_P);return(o&&o[1]||i).trim()})||[]}function mv(e,t){const n=t||{get:function(v,x){if(i.push(v),x===!1)return null;throw s(`No provider for "${v}"!`)}},i=[],o=this._providers=Object.create(n._providers||null),r=this._instances=Object.create(null),a=r.injector=this,s=function(v){const x=i.join(" -> ");return i.length=0,new Error(x?`${v} (Resolving: ${x})`:v)};function c(v,x){if(!o[v]&&v.includes(".")){const E=v.split(".");let A=c(E.shift());for(;E.length;)A=A[E.shift()];return A}if(zf(r,v))return r[v];if(zf(o,v)){if(i.indexOf(v)!==-1)throw i.push(v),s("Cannot resolve circular dependency!");return i.push(v),r[v]=o[v][0](o[v][1]),i.pop(),r[v]}return n.get(v,x)}function l(v,x){if(typeof x>"u"&&(x={}),typeof v!="function")if(Hf(v))v=hl(v.slice());else throw s(`Cannot invoke "${v}". Expected a function!`);const A=(v.$inject||EP(v)).map(I=>zf(x,I)?x[I]:c(I));return{fn:v,dependencies:A}}function u(v){const{fn:x,dependencies:E}=l(v),A=Function.prototype.bind.call(x,null,...E);return new A}function p(v,x,E){const{fn:A,dependencies:I}=l(v,E);return A.apply(x,I)}function f(v){return hl(x=>v.get(x))}function d(v,x){if(x&&x.length){const E=Object.create(null),A=Object.create(null),I=[],P=[],k=[];let H,F,G,ee;for(let ce in o)H=o[ce],x.indexOf(ce)!==-1&&(H[2]==="private"?(F=I.indexOf(H[3]),F===-1?(G=H[3].createChild([],x),ee=f(G),I.push(H[3]),P.push(G),k.push(ee),E[ce]=[ee,ce,"private",G]):E[ce]=[k[F],ce,"private",P[F]]):E[ce]=[H[2],H[1]],A[ce]=!0),(H[2]==="factory"||H[2]==="type")&&H[1].$scope&&x.forEach(ie=>{H[1].$scope.indexOf(ie)!==-1&&(E[ce]=[H[2],H[1]],A[ie]=!0)});x.forEach(ce=>{if(!A[ce])throw new Error('No provider for "'+ce+'". Cannot use provider from the parent!')}),v.unshift(E)}return new mv(v,a)}const g={factory:p,type:u,value:function(v){return v}};function h(v,x){const E=v.__init__||[];return function(){E.forEach(A=>{typeof A=="string"?x.get(A):x.invoke(A)})}}function m(v){const x=v.__exports__;if(x){const E=v.__modules__,A=Object.keys(v).reduce((F,G)=>(G!=="__exports__"&&G!=="__modules__"&&G!=="__init__"&&G!=="__depends__"&&(F[G]=v[G]),F),Object.create(null)),I=(E||[]).concat(A),P=d(I),k=hl(function(F){return P.get(F)});x.forEach(function(F){o[F]=[k,F,"private",P]});const H=(v.__init__||[]).slice();return H.unshift(function(){P.init()}),v=Object.assign({},v,{__init__:H}),h(v,P)}return Object.keys(v).forEach(function(E){if(E==="__init__"||E==="__depends__")return;const A=v[E];if(A[2]==="private"){o[E]=A;return}const I=A[0],P=A[1];o[E]=[g[I],SP(I,P),I]}),h(v,a)}function w(v,x){return v.indexOf(x)!==-1||(v=(x.__depends__||[]).reduce(w,v),v.indexOf(x)!==-1)?v:v.concat(x)}function y(v){const x=v.reduce(w,[]).map(m);let E=!1;return function(){E||(E=!0,x.forEach(A=>A()))}}this.get=c,this.invoke=p,this.instantiate=u,this.createChild=d,this.init=y(e)}function SP(e,t){return e!=="value"&&Hf(t)&&(t=hl(t.slice())),t}var RP=1e3;function yo(e,t){var n=this;t=t||RP,e.on(["render.shape","render.connection"],t,function(i,o){var r=i.type,a=o.element,s=o.gfx,c=o.attrs;if(n.canRender(a))return r==="render.shape"?n.drawShape(s,a,c):n.drawConnection(s,a,c)}),e.on(["render.getShapePath","render.getConnectionPath"],t,function(i,o){if(n.canRender(o))return i.type==="render.getShapePath"?n.getShapePath(o):n.getConnectionPath(o)})}yo.prototype.canRender=function(e){},yo.prototype.drawShape=function(e,t){},yo.prototype.drawConnection=function(e,t){},yo.prototype.getShapePath=function(e){},yo.prototype.getConnectionPath=function(e){};function Ir(e){return e.flat().join(",").replace(/,?([A-Za-z]),?/g,"$1")}function CP(e){return["M",e.x,e.y]}function Gf(e){return["L",e.x,e.y]}function MP(e,t,n){return["C",e.x,e.y,t.x,t.y,n.x,n.y]}function AP(e,t){const n=e.length,i=[CP(e[0])];for(let o=1;o<n;o++){const r=e[o-1],a=e[o],s=e[o+1];if(!s||!t){i.push(Gf(a));continue}const c=Math.min(t,Vf(a.x-r.x,a.y-r.y),Vf(s.x-a.x,s.y-a.y));if(!c){i.push(Gf(a));continue}const l=gl(a,r,c),u=gl(a,r,c*.5),p=gl(a,s,c),f=gl(a,s,c*.5);i.push(Gf(l)),i.push(MP(u,f,p))}return i}function gl(e,t,n){const i=t.x-e.x,o=t.y-e.y,r=Vf(i,o),a=n/r;return{x:e.x+i*a,y:e.y+o*a}}function Vf(e,t){return Math.sqrt(Math.pow(e,2)+Math.pow(t,2))}function _s(e,t,n){Qe(t)&&(n=t,t=null),t||(t={});const i=He("path",t);return Qe(n)&&(i.dataset.cornerRadius=String(n)),Wf(i,e)}function Wf(e,t){const n=parseInt(e.dataset.cornerRadius,10)||0;return Ie(e,{d:Ir(AP(t,n))}),e}function ml(e){var t=new Set(e);return ct(e,function(n){for(var i=n.parent;i;){if(t.has(i))return!1;i=i.parent}return!0})}function Br(e,t,n){n=n||0,Ze(e)||(e=[e]),V(e,function(i,o){var r=t(i,o,n);Ze(r)&&r.length&&Br(r,t,n+1)})}function Uf(e,t,n){var i=new Set,o=new Set;return Br(e,function(r,a,s){i.add(r);var c=r.children;if(c&&!o.has(c))return o.add(c),c}),Array.from(i)}function Es(e,t){return Uf(e)}function PP(e,t,n){Cr(t)&&(t=!0),mn(t)&&(n=t,t=!0),n=n||{};var i=Ss(n.allShapes),o=Ss(n.allConnections),r=Ss(n.enclosedElements),a=Ss(n.enclosedConnections),s=Ss(n.topLevel,t&&sa(e,function(u){return u.id}));function c(u){s[u.source.id]&&s[u.target.id]&&(s[u.id]=[u]),i[u.source.id]&&i[u.target.id]&&(a[u.id]=r[u.id]=u),o[u.id]=u}function l(u){if(r[u.id]=u,u.waypoints)a[u.id]=o[u.id]=u;else return i[u.id]=u,V(u.incoming,c),V(u.outgoing,c),u.children}return Br(e,l),{allShapes:i,allConnections:o,topLevel:s,enclosedConnections:a,enclosedElements:r}}function cn(e,t){t=!!t,Ze(e)||(e=[e]);var n,i,o,r;return V(e,function(a){var s=a;a.waypoints&&!t&&(s=cn(a.waypoints,!0));var c=s.x,l=s.y,u=s.height||0,p=s.width||0;(c<n||n===void 0)&&(n=c),(l<i||i===void 0)&&(i=l),(c+p>o||o===void 0)&&(o=c+p),(l+u>r||r===void 0)&&(r=l+u)}),{x:n,y:i,height:r-i,width:o-n}}function xa(e,t){var n={};return V(e,function(i){var o=i;o.waypoints&&(o=cn(o)),!Qe(t.y)&&o.x>t.x&&(n[i.id]=i),!Qe(t.x)&&o.y>t.y&&(n[i.id]=i),o.x>t.x&&o.y>t.y&&(Qe(t.width)&&Qe(t.height)&&o.width+o.x<t.width+t.x&&o.height+o.y<t.height+t.y||!Qe(t.width)||!Qe(t.height))&&(n[i.id]=i)}),n}function yv(e){return"waypoints"in e?"connection":"x"in e?"shape":"root"}function vv(e){return!!(e&&e.isFrame)}function Ss(e,t){return Y({},e||{},t||{})}var TP=1;function Wo(e,t){yo.call(this,e,TP),this.CONNECTION_STYLE=t.style(["no-fill"],{strokeWidth:5,stroke:"fuchsia"}),this.SHAPE_STYLE=t.style({fill:"white",stroke:"fuchsia",strokeWidth:2}),this.FRAME_STYLE=t.style(["no-fill"],{stroke:"fuchsia",strokeDasharray:4,strokeWidth:2})}Ne(Wo,yo),Wo.prototype.canRender=function(){return!0},Wo.prototype.drawShape=function(t,n,i){var o=He("rect");return Ie(o,{x:0,y:0,width:n.width||0,height:n.height||0}),vv(n)?Ie(o,Y({},this.FRAME_STYLE,i||{})):Ie(o,Y({},this.SHAPE_STYLE,i||{})),tt(t,o),o},Wo.prototype.drawConnection=function(t,n,i){var o=_s(n.waypoints,Y({},this.CONNECTION_STYLE,i||{}));return tt(t,o),o},Wo.prototype.getShapePath=function(t){var n=t.x,i=t.y,o=t.width,r=t.height,a=[["M",n,i],["l",o,0],["l",0,r],["l",-o,0],["z"]];return Ir(a)},Wo.prototype.getConnectionPath=function(t){var n=t.waypoints,i,o,r=[];for(i=0;o=n[i];i++)o=o.original||o,r.push([i===0?"M":"L",o.x,o.y]);return Ir(r)},Wo.$inject=["eventBus","styles"];function kP(){var e={"no-fill":{fill:"none"},"no-border":{strokeOpacity:0},"no-events":{pointerEvents:"none"}},t=this;this.cls=function(n,i,o){var r=this.style(i,o);return Y(r,{class:n})},this.style=function(n,i){!Ze(n)&&!i&&(i=n,n=[]);var o=ni(n,function(r,a){return Y(r,e[a]||{})},{});return i?Y(o,i):o},this.computeStyle=function(n,i,o){return Ze(i)||(o=i,i=[]),t.style(i||[],Y({},o,n||{}))}}const OP={__init__:["defaultRenderer"],defaultRenderer:["type",Wo],styles:["type",kP]};function tn(e,t){if(!e||!t)return-1;var n=e.indexOf(t);return n!==-1&&e.splice(n,1),n}function on(e,t,n){if(!(!e||!t)){typeof n!="number"&&(n=-1);var i=e.indexOf(t);if(i!==-1){if(i===n)return;if(n!==-1)e.splice(i,1);else return}n!==-1?e.splice(n,0,t):e.push(t)}}function qf(e,t){return!e||!t?-1:e.indexOf(t)}function Rs(e,t){return!e||!t?-1:Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Yf(e,t,n,i){if(typeof i>"u"&&(i=5),!e||!t||!n)return!1;var o=(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x),r=Rs(e,t);return Math.abs(o/r)<=i}var DP=2;function vo(e,t){var n=Array.from(arguments).flat();const i={x:"v",y:"h"};for(const[o,r]of Object.entries(i))if(LP(o,n))return r;return!1}function LP(e,t){const n=t[0];return Io(t,function(i){return Math.abs(n[e]-i[e])<=DP})}function bv(e,t,n){return n=n||0,e.x>t.x-n&&e.y>t.y-n&&e.x<t.x+t.width+n&&e.y<t.y+t.height+n}function Kf(e,t){return{x:Math.round(e.x+(t.x-e.x)/2),y:Math.round(e.y+(t.y-e.y)/2)}}var IP=/,?([a-z]),?/gi,xv=parseFloat,ln=Math,Uo=ln.PI,Qi=ln.min,Ji=ln.max,wv=ln.pow,qo=ln.abs,BP=/([a-z])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?[\s]*,?[\s]*)+)/ig,NP=/(-?\d*\.?\d*(?:e[-+]?\d+)?)[\s]*,?[\s]*/ig,_v=Array.isArray||function(e){return e instanceof Array};function $P(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function FP(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return e.push(e.splice(n,1)[0])}function jP(e){function t(){var n=Array.prototype.slice.call(arguments,0),i=n.join("␀"),o=t.cache=t.cache||{},r=t.count=t.count||[];return $P(o,i)?(FP(r,i),o[i]):(r.length>=1e3&&delete o[r.shift()],r.push(i),o[i]=e(...arguments),o[i])}return t}function HP(e){if(!e)return null;var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},n=[];return String(e).replace(BP,function(i,o,r){var a=[],s=o.toLowerCase();for(r.replace(NP,function(c,l){l&&a.push(+l)}),s=="m"&&a.length>2&&(n.push([o,...a.splice(0,2)]),s="l",o=o=="m"?"l":"L");a.length>=t[s]&&(n.push([o,...a.splice(0,t[s])]),!!t[s]););}),n.toString=Zf,n}function zP(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if(typeof i=="string"&&i!==i.toUpperCase())return!1}return!0}function GP(e){for(var t=0,n=e.length;t<n;t++){var i=e[t][0];if(i!=="M"&&i!=="C")return!1}return!0}function Xf(e,t,n,i){return arguments.length===1&&(t=e.y,n=e.width,i=e.height,e=e.x),{x:e,y:t,width:n,height:i,x2:e+n,y2:t+i}}function Zf(){return this.join(",").replace(IP,"$1")}function VP(e){for(var t=new Array(e.length),n=0,i=e.length;n<i;n++)for(var o=e[n],r=t[n]=new Array(o.length),a=0,s=o.length;a<s;a++)r[a]=o[a];return t.toString=Zf,t}function Ev(e,t,n,i,o,r,a,s,c){var l=1-c,u=wv(l,3),p=wv(l,2),f=c*c,d=f*c,g=u*e+p*3*c*n+l*3*c*c*o+d*a,h=u*t+p*3*c*i+l*3*c*c*r+d*s;return{x:yl(g),y:yl(h)}}function Sv(e){var t=XP(...e);return Xf(t.x0,t.y0,t.x1-t.x0,t.y1-t.y0)}function Yo(e,t,n){return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height}function WP(e,t){return e=Xf(e),t=Xf(t),Yo(t,e.x,e.y)||Yo(t,e.x2,e.y)||Yo(t,e.x,e.y2)||Yo(t,e.x2,e.y2)||Yo(e,t.x,t.y)||Yo(e,t.x2,t.y)||Yo(e,t.x,t.y2)||Yo(e,t.x2,t.y2)||(e.x<t.x2&&e.x>t.x||t.x<e.x2&&t.x>e.x)&&(e.y<t.y2&&e.y>t.y||t.y<e.y2&&t.y>e.y)}function Rv(e,t,n,i,o){var r=-3*t+9*n-9*i+3*o,a=e*r+6*t-12*n+6*i;return e*a-3*t+3*n}function Cv(e,t,n,i,o,r,a,s,c){c==null&&(c=1),c=c>1?1:c<0?0:c;for(var l=c/2,u=12,p=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],f=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],d=0,g=0;g<u;g++){var h=l*p[g]+l,m=Rv(h,e,n,o,a),w=Rv(h,t,i,r,s),y=m*m+w*w;d+=f[g]*ln.sqrt(y)}return l*d}function UP(e,t,n,i,o,r,a,s){if(!(Ji(e,n)<Qi(o,a)||Qi(e,n)>Ji(o,a)||Ji(t,i)<Qi(r,s)||Qi(t,i)>Ji(r,s))){var c=(e*i-t*n)*(o-a)-(e-n)*(o*s-r*a),l=(e*i-t*n)*(r-s)-(t-i)*(o*s-r*a),u=(e-n)*(r-s)-(t-i)*(o-a);if(u){var p=yl(c/u),f=yl(l/u),d=+p.toFixed(2),g=+f.toFixed(2);if(!(d<+Qi(e,n).toFixed(2)||d>+Ji(e,n).toFixed(2)||d<+Qi(o,a).toFixed(2)||d>+Ji(o,a).toFixed(2)||g<+Qi(t,i).toFixed(2)||g>+Ji(t,i).toFixed(2)||g<+Qi(r,s).toFixed(2)||g>+Ji(r,s).toFixed(2)))return{x:p,y:f}}}}function yl(e){return Math.round(e*1e11)/1e11}function qP(e,t,n){var i=Sv(e),o=Sv(t);if(!WP(i,o))return[];var r=Cv(...e),a=Cv(...t),s=Av(e)?1:~~(r/5)||1,c=Av(t)?1:~~(a/5)||1,l=new Array(s+1),u=new Array(c+1),p={},f=[],d,g;for(d=0;d<s+1;d++){var h=Ev(...e,d/s);l[d]={x:h.x,y:h.y,t:d/s}}for(d=0;d<c+1;d++)h=Ev(...t,d/c),u[d]={x:h.x,y:h.y,t:d/c};for(d=0;d<s;d++)for(g=0;g<c;g++){var m=l[d],w=l[d+1],y=u[g],v=u[g+1],x=qo(w.x-m.x)<.01?"y":"x",E=qo(v.x-y.x)<.01?"y":"x",A=UP(m.x,m.y,w.x,w.y,y.x,y.y,v.x,v.y),I;if(A){if(I=A.x.toFixed(9)+"#"+A.y.toFixed(9),p[I])continue;p[I]=!0;var P=m.t+qo((A[x]-m[x])/(w[x]-m[x]))*(w.t-m.t),k=y.t+qo((A[E]-y[E])/(v[E]-y[E]))*(v.t-y.t);P>=0&&P<=1&&k>=0&&k<=1&&f.push({x:A.x,y:A.y,t1:P,t2:k})}}return f}function Mv(e,t,n){e=kv(e),t=kv(t);for(var i,o,r,a,s,c,l,u,p,f,d=n?0:[],g=0,h=e.length;g<h;g++){var m=e[g];if(m[0]=="M")i=s=m[1],o=c=m[2];else{m[0]=="C"?(p=[i,o,...m.slice(1)],i=p[6],o=p[7]):(p=[i,o,i,o,s,c,s,c],i=s,o=c);for(var w=0,y=t.length;w<y;w++){var v=t[w];if(v[0]=="M")r=l=v[1],a=u=v[2];else{v[0]=="C"?(f=[r,a,...v.slice(1)],r=f[6],a=f[7]):(f=[r,a,r,a,l,u,l,u],r=l,a=u);var x=qP(p,f);{for(var E=0,A=x.length;E<A;E++)x[E].segment1=g,x[E].segment2=w,x[E].bez1=p,x[E].bez2=f;d=d.concat(x)}}}}}return d}function YP(e){return _v(e)&&_v(e[0])}function KP(e){if(zP(e))return e;var t=new Array(e.length),n=0,i=0,o=0,r=0,a=0,s;e[0][0]=="M"&&(n=+e[0][1],i=+e[0][2],o=n,r=i,a++,t[0]=["M",n,i]);for(var c,l,u=a,p=e.length;u<p;u++){if(l=e[u],s=l[0],t[u]=c=new Array(l.length),s!=s.toUpperCase())switch(c[0]=s.toUpperCase(),c[0]){case"A":c[1]=l[1],c[2]=l[2],c[3]=l[3],c[4]=l[4],c[5]=l[5],c[6]=+l[6]+n,c[7]=+l[7]+i;break;case"V":c[1]=+l[1]+i;break;case"H":c[1]=+l[1]+n;break;case"M":o=+l[1]+n,r=+l[2]+i;default:for(var f=1,d=l.length;f<d;f++)c[f]=+l[f]+(f%2?n:i)}else for(var g=0,h=l.length;g<h;g++)c[g]=l[g];switch(s=s.toUpperCase(),c[0]){case"Z":n=+o,i=+r;break;case"H":n=c[1];break;case"V":i=c[1];break;case"M":o=c[c.length-2],r=c[c.length-1];default:n=c[c.length-2],i=c[c.length-1]}}return t.toString=Zf,t}function Av(e){return e[0]===e[2]&&e[1]===e[3]&&e[4]===e[6]&&e[5]===e[7]}function vl(e,t,n,i){return[e,t,n,i,n,i]}function Pv(e,t,n,i,o,r){var a=.3333333333333333,s=2/3;return[a*e+s*n,a*t+s*i,a*o+s*n,a*r+s*i,o,r]}function Tv(e,t,n,i,o,r,a,s,c,l){var u=Uo*120/180,p=Uo/180*(+o||0),f=[],d,g=jP(function($,C,R){var W=$*ln.cos(R)-C*ln.sin(R),q=$*ln.sin(R)+C*ln.cos(R);return{x:W,y:q}});if(l)I=l[0],P=l[1],E=l[2],A=l[3];else{d=g(e,t,-p),e=d.x,t=d.y,d=g(s,c,-p),s=d.x,c=d.y;var h=(e-s)/2,m=(t-c)/2,w=h*h/(n*n)+m*m/(i*i);w>1&&(w=ln.sqrt(w),n=w*n,i=w*i);var y=n*n,v=i*i,x=(r==a?-1:1)*ln.sqrt(qo((y*v-y*m*m-v*h*h)/(y*m*m+v*h*h))),E=x*n*m/i+(e+s)/2,A=x*-i*h/n+(t+c)/2,I=ln.asin(((t-A)/i).toFixed(9)),P=ln.asin(((c-A)/i).toFixed(9));I=e<E?Uo-I:I,P=s<E?Uo-P:P,I<0&&(I=Uo*2+I),P<0&&(P=Uo*2+P),a&&I>P&&(I=I-Uo*2),!a&&P>I&&(P=P-Uo*2)}var k=P-I;if(qo(k)>u){var H=P,F=s,G=c;P=I+u*(a&&P>I?1:-1),s=E+n*ln.cos(P),c=A+i*ln.sin(P),f=Tv(s,c,n,i,o,0,a,F,G,[P,H,E,A])}k=P-I;var ee=ln.cos(I),ce=ln.sin(I),ie=ln.cos(P),be=ln.sin(P),he=ln.tan(k/4),ye=4/3*n*he,Ee=4/3*i*he,U=[e,t],ue=[e+ye*ce,t-Ee*ee],K=[s+ye*be,c-Ee*ie],J=[s,c];if(ue[0]=2*U[0]-ue[0],ue[1]=2*U[1]-ue[1],l)return[ue,K,J].concat(f);f=[ue,K,J].concat(f).join().split(",");for(var ge=[],Re=0,ze=f.length;Re<ze;Re++)ge[Re]=Re%2?g(f[Re-1],f[Re],p).y:g(f[Re],f[Re+1],p).x;return ge}function XP(e,t,n,i,o,r,a,s){for(var c=[],l=[[],[]],u,p,f,d,g,h,m,w,y=0;y<2;++y){if(y==0?(p=6*e-12*n+6*o,u=-3*e+9*n-9*o+3*a,f=3*n-3*e):(p=6*t-12*i+6*r,u=-3*t+9*i-9*r+3*s,f=3*i-3*t),qo(u)<1e-12){if(qo(p)<1e-12)continue;d=-f/p,0<d&&d<1&&c.push(d);continue}m=p*p-4*f*u,w=ln.sqrt(m),!(m<0)&&(g=(-p+w)/(2*u),0<g&&g<1&&c.push(g),h=(-p-w)/(2*u),0<h&&h<1&&c.push(h))}for(var v=c.length,x=v,E;v--;)d=c[v],E=1-d,l[0][v]=E*E*E*e+3*E*E*d*n+3*E*d*d*o+d*d*d*a,l[1][v]=E*E*E*t+3*E*E*d*i+3*E*d*d*r+d*d*d*s;return l[0][x]=e,l[1][x]=t,l[0][x+1]=a,l[1][x+1]=s,l[0].length=l[1].length=x+2,{x0:Qi(...l[0]),y0:Qi(...l[1]),x1:Ji(...l[0]),y1:Ji(...l[1])}}function kv(e){if(YP(e)||(e=HP(e)),GP(e))return e;for(var t=VP(KP(e)),n={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null},i=function(f,d,g){var h,m;if(!f)return["C",d.x,d.y,d.x,d.y,d.x,d.y];switch(!(f[0]in{T:1,Q:1})&&(d.qx=d.qy=null),f[0]){case"M":d.X=f[1],d.Y=f[2];break;case"A":f=["C",...Tv(d.x,d.y,...f.slice(1))];break;case"S":g=="C"||g=="S"?(h=d.x*2-d.bx,m=d.y*2-d.by):(h=d.x,m=d.y),f=["C",h,m,...f.slice(1)];break;case"T":g=="Q"||g=="T"?(d.qx=d.x*2-d.qx,d.qy=d.y*2-d.qy):(d.qx=d.x,d.qy=d.y),f=["C",...Pv(d.x,d.y,d.qx,d.qy,f[1],f[2])];break;case"Q":d.qx=f[1],d.qy=f[2],f=["C",...Pv(d.x,d.y,f[1],f[2],f[3],f[4])];break;case"L":f=["C",...vl(d.x,d.y,f[1],f[2])];break;case"H":f=["C",...vl(d.x,d.y,f[1],d.y)];break;case"V":f=["C",...vl(d.x,d.y,d.x,f[1])];break;case"Z":f=["C",...vl(d.x,d.y,d.X,d.Y)];break}return f},o=function(f,d){if(f[d].length>7){f[d].shift();for(var g=f[d];g.length;)r[d]="A",f.splice(d++,0,["C",...g.splice(0,6)]);f.splice(d,1),l=t.length}},r=[],a="",s="",c=0,l=t.length;c<l;c++){t[c]&&(a=t[c][0]),a!="C"&&(r[c]=a,c&&(s=r[c-1])),t[c]=i(t[c],n,s),r[c]!="A"&&a=="C"&&(r[c]="C"),o(t,c);var u=t[c],p=u.length;n.x=u[p-2],n.y=u[p-1],n.bx=xv(u[p-4])||n.x,n.by=xv(u[p-3])||n.y}return t}function Ot(e){return mn(e)&&ti(e,"waypoints")}function at(e){return mn(e)&&ti(e,"labelTarget")}function ZP(e){return mn(e)&&ra(e.parent)}function Ov(e){return{x:Math.round(e.x),y:Math.round(e.y),width:Math.round(e.width),height:Math.round(e.height)}}function bo(e){return{x:Math.round(e.x),y:Math.round(e.y)}}function qe(e){return{top:e.y,right:e.x+(e.width||0),bottom:e.y+(e.height||0),left:e.x}}function bl(e){return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function QP(e){return bo({x:e.x+(e.width||0)/2,y:e.y+(e.height||0)/2})}function JP(e){for(var t=e.waypoints,n=t.reduce(function(l,u,p){var f=t[p-1];if(f){var d=l[l.length-1],g=d&&d.endLength||0,h=nT(f,u);l.push({start:f,end:u,startLength:g,endLength:g+h,length:h})}return l},[]),i=n.reduce(function(l,u){return l+u.length},0),o=i/2,r=0,a=n[r];a.endLength<o;)a=n[++r];var s=(o-a.startLength)/a.length,c={x:a.start.x+(a.end.x-a.start.x)*s,y:a.start.y+(a.end.y-a.start.y)*s};return c}function Je(e){return Ot(e)?JP(e):QP(e)}function On(e,t,n){n=n||0,mn(n)||(n={x:n,y:n});var i=qe(e),o=qe(t),r=i.bottom+n.y<=o.top,a=i.left-n.x>=o.right,s=i.top-n.y>=o.bottom,c=i.right+n.x<=o.left,l=r?"top":s?"bottom":null,u=c?"left":a?"right":null;return u&&l?l+"-"+u:u||l||"intersect"}function Cs(e,t,n){var i=eT(e,t);return i.length===1||i.length===2&&Rs(i[0],i[1])<1?bo(i[0]):i.length>1?(i=qi(i,function(o){var r=Math.floor(o.t2*100)||1;return r=100-r,r=(r<10?"0":"")+r,o.segment2+"#"+r}),bo(i[n?0:i.length-1])):null}function eT(e,t){return Mv(e,t)}function tT(e){e=e.slice();for(var t=0,n,i,o;e[t];)n=e[t],i=e[t-1],o=e[t+1],Rs(n,o)===0||Yf(i,o,n)?e.splice(t,1):t++;return e}function nT(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function xl(e,t){return Math.round(e*t)/t}function Dv(e){return Qe(e)?e+"px":e}function iT(e){for(;e.parent;)e=e.parent;return e}function oT(e){e=Y({},{width:"100%",height:"100%"},e);const t=e.container||document.body,n=document.createElement("div");return n.setAttribute("class","djs-container djs-parent"),Un(n,{position:"relative",overflow:"hidden",width:Dv(e.width),height:Dv(e.height)}),t.appendChild(n),n}function Lv(e,t,n){const i=He("g");dt(i).add(t);const o=n!==void 0?n:e.childNodes.length-1;return e.insertBefore(i,e.childNodes[o]||null),i}const rT="base",Iv=0,aT=1,sT={shape:["x","y","width","height"],connection:["waypoints"]};function et(e,t,n,i){this._eventBus=t,this._elementRegistry=i,this._graphicsFactory=n,this._rootsIdx=0,this._layers={},this._planes=[],this._rootElement=null,this._focused=!1,this._init(e||{})}et.$inject=["config.canvas","eventBus","graphicsFactory","elementRegistry"],et.prototype._init=function(e){const t=this._eventBus,n=this._container=oT(e),i=this._svg=He("svg");Ie(i,{width:"100%",height:"100%"}),Cn(i,"tabindex",0),e.autoFocus&&t.on("element.hover",()=>{this.restoreFocus()}),t.on("element.mousedown",500,r=>{this.focus()}),i.addEventListener("focusin",()=>{this._setFocused(!0)}),i.addEventListener("focusout",()=>{this._setFocused(!1)}),i.addEventListener("mouseover",()=>{this._eventBus.fire("canvas.mouseover")}),i.addEventListener("mouseout",()=>{this._eventBus.fire("canvas.mouseout")}),tt(n,i);const o=this._viewport=Lv(i,"viewport");e.deferUpdate&&(this._viewboxChanged=Np(this._viewboxChanged,300)),this._restoreFocus=Np(this._restoreFocus,0),t.on("diagram.init",()=>{t.fire("canvas.init",{svg:i,viewport:o})}),t.on(["shape.added","connection.added","shape.removed","connection.removed","elements.changed","root.set"],()=>{delete this._cachedViewbox}),t.on("diagram.destroy",500,this._destroy,this),t.on("diagram.clear",500,this._clear,this)},et.prototype._destroy=function(){this._restoreFocus.cancel(),this._eventBus.fire("canvas.destroy",{svg:this._svg,viewport:this._viewport});const e=this._container.parentNode;e&&e.removeChild(this._container),delete this._svg,delete this._container,delete this._layers,delete this._planes,delete this._rootElement,delete this._viewport},et.prototype._setFocused=function(e){e!=this._focused&&(this._focused=e,this._eventBus.fire("canvas.focus.changed",{focused:e}))},et.prototype._clear=function(){this._elementRegistry.getAll().forEach(t=>{const n=yv(t);n==="root"?this.removeRootElement(t):this._removeElement(t,n)}),this._planes=[],this._rootElement=null,delete this._cachedViewbox},et.prototype.focus=function(){this._svg.focus({preventScroll:!0}),this._setFocused(!0)},et.prototype.restoreFocus=function(){this._restoreFocus()},et.prototype._restoreFocus=function(){document.activeElement===document.body&&this.focus()},et.prototype.isFocused=function(){return this._focused},et.prototype.getDefaultLayer=function(){return this.getLayer(rT,Iv)},et.prototype.getLayer=function(e,t){if(!e)throw new Error("must specify a name");let n=this._layers[e];if(n||(n=this._layers[e]=this._createLayer(e,t)),typeof t<"u"&&n.index!==t)throw new Error("layer <"+e+"> already created at index <"+t+">");return n.group},et.prototype._getChildIndex=function(e){return ni(this._layers,function(t,n){return n.visible&&e>=n.index&&t++,t},0)},et.prototype._createLayer=function(e,t){typeof t>"u"&&(t=aT);const n=this._getChildIndex(t);return{group:Lv(this._viewport,"layer-"+e,n),index:t,visible:!0}},et.prototype.showLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=this._viewport,i=t.group,o=t.index;if(t.visible)return i;const r=this._getChildIndex(o);return n.insertBefore(i,n.childNodes[r]||null),t.visible=!0,i},et.prototype.hideLayer=function(e){if(!e)throw new Error("must specify a name");const t=this._layers[e];if(!t)throw new Error("layer <"+e+"> does not exist");const n=t.group;return t.visible&&(sn(n),t.visible=!1),n},et.prototype._removeLayer=function(e){const t=this._layers[e];t&&(delete this._layers[e],sn(t.group))},et.prototype.getActiveLayer=function(){const e=this._findPlaneForRoot(this.getRootElement());return e?e.layer:null},et.prototype.findRoot=function(e){const t=this._resolveElements(e);let n;for(const i of t){const o=this._findPlaneForRoot(iT(i));if(!o||n&&o.rootElement!==n)return;n=o.rootElement}return n},et.prototype.getRootElements=function(){return this._planes.map(function(e){return e.rootElement})},et.prototype._findPlaneForRoot=function(e){return It(this._planes,function(t){return t.rootElement===e})},et.prototype._resolveElement=function(e){return typeof e=="string"?this._elementRegistry.get(e):e},et.prototype._resolveElements=function(e){return Ze(e)||(e=[e]),e.map(t=>this._resolveElement(t)).filter(Boolean)},et.prototype.getContainer=function(){return this._container},et.prototype._updateMarker=function(e,t,n){let i;e=this._resolveElement(e),e.markers=e.markers||new Set,i=this._elementRegistry._elements[e.id],i&&(V([i.gfx,i.secondaryGfx],function(o){o&&(n?(e.markers.add(t),dt(o).add(t)):(e.markers.delete(t),dt(o).remove(t)))}),this._eventBus.fire("element.marker.update",{element:e,gfx:i.gfx,marker:t,add:!!n}))},et.prototype.addMarker=function(e,t){this._updateMarker(e,t,!0)},et.prototype.removeMarker=function(e,t){this._updateMarker(e,t,!1)},et.prototype.hasMarker=function(e,t){return e=this._resolveElement(e),e.markers?e.markers.has(t):!1},et.prototype.toggleMarker=function(e,t){this.hasMarker(e,t)?this.removeMarker(e,t):this.addMarker(e,t)},et.prototype.getRootElement=function(){const e=this._rootElement;return e||this._planes.length?e:this.setRootElement(this.addRootElement(null))},et.prototype.addRootElement=function(e){const t=this._rootsIdx++;e||(e={id:"__implicitroot_"+t,children:[],isImplicit:!0});const n=e.layer="root-"+t;this._ensureValid("root",e);const i=this.getLayer(n,Iv);return this.hideLayer(n),this._addRoot(e,i),this._planes.push({rootElement:e,layer:i}),e},et.prototype.removeRootElement=function(e){if(e=this._resolveElement(e),!!this._findPlaneForRoot(e))return this._removeRoot(e),this._removeLayer(e.layer),this._planes=this._planes.filter(function(n){return n.rootElement!==e}),this._rootElement===e&&(this._rootElement=null),e},et.prototype.setRootElement=function(e){if(e===this._rootElement)return e;let t;if(!e)throw new Error("rootElement required");return t=this._findPlaneForRoot(e),t||(e=this.addRootElement(e)),this._setRoot(e),e},et.prototype._removeRoot=function(e){const t=this._elementRegistry,n=this._eventBus;n.fire("root.remove",{element:e}),n.fire("root.removed",{element:e}),t.remove(e)},et.prototype._addRoot=function(e,t){const n=this._elementRegistry,i=this._eventBus;i.fire("root.add",{element:e}),n.add(e,t),i.fire("root.added",{element:e,gfx:t})},et.prototype._setRoot=function(e,t){const n=this._rootElement;n&&(this._elementRegistry.updateGraphics(n,null,!0),this.hideLayer(n.layer)),e&&(t||(t=this._findPlaneForRoot(e).layer),this._elementRegistry.updateGraphics(e,this._svg,!0),this.showLayer(e.layer)),this._rootElement=e,this._eventBus.fire("root.set",{element:e})},et.prototype._ensureValid=function(e,t){if(!t.id)throw new Error("element must have an id");if(this._elementRegistry.get(t.id))throw new Error("element <"+t.id+"> already exists");const n=sT[e];if(!Io(n,function(o){return typeof t[o]<"u"}))throw new Error("must supply { "+n.join(", ")+" } with "+e)},et.prototype._setParent=function(e,t,n){on(t.children,e,n),e.parent=t},et.prototype._addElement=function(e,t,n,i){n=n||this.getRootElement();const o=this._eventBus,r=this._graphicsFactory;this._ensureValid(e,t),o.fire(e+".add",{element:t,parent:n}),this._setParent(t,n,i);const a=r.create(e,t,i);return this._elementRegistry.add(t,a),r.update(e,t,a),o.fire(e+".added",{element:t,gfx:a}),t},et.prototype.addShape=function(e,t,n){return this._addElement("shape",e,t,n)},et.prototype.addConnection=function(e,t,n){return this._addElement("connection",e,t,n)},et.prototype._removeElement=function(e,t){const n=this._elementRegistry,i=this._graphicsFactory,o=this._eventBus;if(e=n.get(e.id||e),!!e)return o.fire(t+".remove",{element:e}),i.remove(e),tn(e.parent&&e.parent.children,e),e.parent=null,o.fire(t+".removed",{element:e}),n.remove(e),e},et.prototype.removeShape=function(e){return this._removeElement(e,"shape")},et.prototype.removeConnection=function(e){return this._removeElement(e,"connection")},et.prototype.getGraphics=function(e,t){return this._elementRegistry.getGraphics(e,t)},et.prototype._changeViewbox=function(e){this._eventBus.fire("canvas.viewbox.changing"),e.apply(this),this._cachedViewbox=null,this._viewboxChanged()},et.prototype._viewboxChanged=function(){this._eventBus.fire("canvas.viewbox.changed",{viewbox:this.viewbox()})},et.prototype.viewbox=function(e){if(e===void 0&&this._cachedViewbox)return structuredClone(this._cachedViewbox);const t=this._viewport,n=this.getSize();let i,o,r,a,s,c,l;if(e)this._changeViewbox(function(){s=Math.min(n.width/e.width,n.height/e.height);const u=this._svg.createSVGMatrix().scale(s).translate(-e.x,-e.y);ws(t,u)});else return r=this._rootElement?this.getActiveLayer():null,i=r&&r.getBBox()||{},a=ws(t),o=a?a.matrix:fP(),s=xl(o.a,1e3),c=xl(-o.e||0,1e3),l=xl(-o.f||0,1e3),e=this._cachedViewbox={x:c?c/s:0,y:l?l/s:0,width:n.width/s,height:n.height/s,scale:s,inner:{width:i.width||0,height:i.height||0,x:i.x||0,y:i.y||0},outer:n},e;return e},et.prototype.scroll=function(e){const t=this._viewport;let n=t.getCTM();return e&&this._changeViewbox(function(){e=Y({dx:0,dy:0},e||{}),n=this._svg.createSVGMatrix().translate(e.dx,e.dy).multiply(n),Bv(t,n)}),{x:n.e,y:n.f}},et.prototype.scrollToElement=function(e,t){let n=100;const i=this._resolveElements(e);if(!i.length)return;const o=this.findRoot(i);if(!o)return;o!==this.getRootElement()&&this.setRootElement(o);const r=i.filter(g=>g!=o);if(!r.length)return;t||(t={}),typeof t=="number"&&(n=t),t={top:t.top||n,right:t.right||n,bottom:t.bottom||n,left:t.left||n};const a=cn(r),s=qe(a),c=this.viewbox(),l=this.zoom();let u,p;c.y+=t.top/l,c.x+=t.left/l,c.width-=(t.right+t.left)/l,c.height-=(t.bottom+t.top)/l;const f=qe(c);if(!(a.width<c.width&&a.height<c.height))u=a.x-c.x,p=a.y-c.y;else{const g=Math.max(0,s.right-f.right),h=Math.min(0,s.left-f.left),m=Math.max(0,s.bottom-f.bottom),w=Math.min(0,s.top-f.top);u=g||h,p=m||w}this.scroll({dx:-u*l,dy:-p*l})},et.prototype.zoom=function(e,t){if(!e)return this.viewbox(e).scale;if(e==="fit-viewport")return this._fitViewport(t);let n,i;return this._changeViewbox(function(){typeof t!="object"&&(n=this.viewbox().outer,t={x:n.width/2,y:n.height/2}),i=this._setZoom(e,t)}),xl(i.a,1e3)};function Bv(e,t){const n="matrix("+t.a+","+t.b+","+t.c+","+t.d+","+t.e+","+t.f+")";e.setAttribute("transform",n)}et.prototype._fitViewport=function(e){const t=this.viewbox(),n=t.outer,i=t.inner;let o,r;return i.x>=0&&i.y>=0&&i.x+i.width<=n.width&&i.y+i.height<=n.height&&!e?r={x:0,y:0,width:Math.max(i.width+i.x,n.width),height:Math.max(i.height+i.y,n.height)}:(o=Math.min(1,n.width/i.width,n.height/i.height),r={x:i.x+(e?i.width/2-n.width/o/2:0),y:i.y+(e?i.height/2-n.height/o/2:0),width:n.width/o,height:n.height/o}),this.viewbox(r),this.viewbox(!1).scale},et.prototype._setZoom=function(e,t){const n=this._svg,i=this._viewport,o=n.createSVGMatrix(),r=n.createSVGPoint();let a,s,c,l,u;c=i.getCTM();const p=c.a;return t?(a=Y(r,t),s=a.matrixTransform(c.inverse()),l=o.translate(s.x,s.y).scale(1/p*e).translate(-s.x,-s.y),u=c.multiply(l)):u=o.scale(e),Bv(this._viewport,u),u},et.prototype.getSize=function(){return{width:this._container.clientWidth,height:this._container.clientHeight}},et.prototype.getAbsoluteBBox=function(e){const t=this.viewbox();let n;e.waypoints?n=this.getGraphics(e).getBBox():n=e;const i=n.x*t.scale-t.x*t.scale,o=n.y*t.scale-t.y*t.scale,r=n.width*t.scale,a=n.height*t.scale;return{x:i,y:o,width:r,height:a}},et.prototype.resized=function(){delete this._cachedViewbox,this._eventBus.fire("canvas.resized")};var wa="data-element-id";function mi(e){this._elements={},this._eventBus=e}mi.$inject=["eventBus"],mi.prototype.add=function(e,t,n){var i=e.id;this._validateId(i),Ie(t,wa,i),n&&Ie(n,wa,i),this._elements[i]={element:e,gfx:t,secondaryGfx:n}},mi.prototype.remove=function(e){var t=this._elements,n=e.id||e,i=n&&t[n];i&&(Ie(i.gfx,wa,""),i.secondaryGfx&&Ie(i.secondaryGfx,wa,""),delete t[n])},mi.prototype.updateId=function(e,t){this._validateId(t),typeof e=="string"&&(e=this.get(e)),this._eventBus.fire("element.updateId",{element:e,newId:t});var n=this.getGraphics(e),i=this.getGraphics(e,!0);this.remove(e),e.id=t,this.add(e,n,i)},mi.prototype.updateGraphics=function(e,t,n){var i=e.id||e,o=this._elements[i];return n?o.secondaryGfx=t:o.gfx=t,t&&Ie(t,wa,i),t},mi.prototype.get=function(e){var t;typeof e=="string"?t=e:t=e&&Ie(e,wa);var n=this._elements[t];return n&&n.element},mi.prototype.filter=function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(n)}),t},mi.prototype.find=function(e){for(var t=this._elements,n=Object.keys(t),i=0;i<n.length;i++){var o=n[i],r=t[o],a=r.element,s=r.gfx;if(e(a,s))return a}},mi.prototype.getAll=function(){return this.filter(function(e){return e})},mi.prototype.forEach=function(e){var t=this._elements;Object.keys(t).forEach(function(n){var i=t[n],o=i.element,r=i.gfx;return e(o,r)})},mi.prototype.getGraphics=function(e,t){var n=e.id||e,i=this._elements[n];return i&&(t?i.secondaryGfx:i.gfx)},mi.prototype._validateId=function(e){if(!e)throw new Error("element must have an id");if(this._elements[e])throw new Error("element with id "+e+" already added")};function cT(e,t,n,i){var o=n.inverse;return Object.defineProperty(e,"remove",{value:function(r){var a=this.indexOf(r);return a!==-1&&(this.splice(a,1),t.unset(r,o,i)),r}}),Object.defineProperty(e,"contains",{value:function(r){return this.indexOf(r)!==-1}}),Object.defineProperty(e,"add",{value:function(r,a){var s=this.indexOf(r);if(typeof a>"u"){if(s!==-1)return;a=this.length}s!==-1&&this.splice(s,1),this.splice(a,0,r),s===-1&&t.set(r,o,i)}}),Object.defineProperty(e,"__refs_collection",{value:!0}),e}function lT(e){return e.__refs_collection===!0}function uT(e,t){return Object.prototype.hasOwnProperty.call(e,t.name||t)}function Nv(e,t,n){var i=cT(n[t.name]||[],e,t,n);Object.defineProperty(n,t.name,{enumerable:t.enumerable,value:i}),i.length&&i.forEach(function(o){e.set(o,t.inverse,n)})}function pT(e,t,n){var i=t.inverse,o=n[t.name];Object.defineProperty(n,t.name,{configurable:t.configurable,enumerable:t.enumerable,get:function(){return o},set:function(r){if(r!==o){var a=o;o=null,a&&e.unset(a,i,n),o=r,e.set(o,i,n)}}})}function _i(e,t){if(!(this instanceof _i))return new _i(e,t);e.inverse=t,t.inverse=e,this.props={},this.props[e.name]=e,this.props[t.name]=t}_i.prototype.bind=function(e,t){if(typeof t=="string"){if(!this.props[t])throw new Error("no property <"+t+"> in ref");t=this.props[t]}t.collection?Nv(this,t,e):pT(this,t,e)},_i.prototype.ensureRefsCollection=function(e,t){var n=e[t.name];return lT(n)||Nv(this,t,e),n},_i.prototype.ensureBound=function(e,t){uT(e,t)||this.bind(e,t)},_i.prototype.unset=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).remove(n):e[t.name]=void 0)},_i.prototype.set=function(e,t,n){e&&(this.ensureBound(e,t),t.collection?this.ensureRefsCollection(e,t).add(n):e[t.name]=n)};var Qf=new _i({name:"children",enumerable:!0,collection:!0},{name:"parent"}),$v=new _i({name:"labels",enumerable:!0,collection:!0},{name:"labelTarget"}),Fv=new _i({name:"attachers",collection:!0},{name:"host"}),jv=new _i({name:"outgoing",collection:!0},{name:"source"}),Hv=new _i({name:"incoming",collection:!0},{name:"target"});function _a(){Object.defineProperty(this,"businessObject",{writable:!0}),Object.defineProperty(this,"label",{get:function(){return this.labels[0]},set:function(e){var t=this.label,n=this.labels;!e&&t?n.remove(t):n.add(e,0)}}),Qf.bind(this,"parent"),$v.bind(this,"labels"),jv.bind(this,"outgoing"),Hv.bind(this,"incoming")}function Ms(){_a.call(this),Qf.bind(this,"children"),Fv.bind(this,"host"),Fv.bind(this,"attachers")}Ne(Ms,_a);function zv(){_a.call(this),Qf.bind(this,"children")}Ne(zv,Ms);function Gv(){Ms.call(this),$v.bind(this,"labelTarget")}Ne(Gv,Ms);function Vv(){_a.call(this),jv.bind(this,"source"),Hv.bind(this,"target")}Ne(Vv,_a);var fT={connection:Vv,shape:Ms,label:Gv,root:zv};function dT(e,t){var n=fT[e];if(!n)throw new Error("unknown type: <"+e+">");return Y(new n,t)}function hT(e){return e instanceof _a}function xo(){this._uid=12}xo.prototype.createRoot=function(e){return this.create("root",e)},xo.prototype.createLabel=function(e){return this.create("label",e)},xo.prototype.createShape=function(e){return this.create("shape",e)},xo.prototype.createConnection=function(e){return this.create("connection",e)},xo.prototype.create=function(e,t){return t=Y({},t||{}),t.id||(t.id=e+"_"+this._uid++),dT(e,t)};var wl="__fn",Wv=1e3,gT=Array.prototype.slice;function oi(){this._listeners={},this.on("diagram.destroy",1,this._destroy,this)}oi.prototype.on=function(e,t,n,i){if(e=Ze(e)?e:[e],_n(t)&&(i=n,n=t,t=Wv),!Qe(t))throw new Error("priority must be a number");var o=n;i&&(o=Kn(n,i),o[wl]=n[wl]||n);var r=this;e.forEach(function(a){r._addListener(a,{priority:t,callback:o,next:null})})},oi.prototype.once=function(e,t,n,i){var o=this;if(_n(t)&&(i=n,n=t,t=Wv),!Qe(t))throw new Error("priority must be a number");function r(){r.__isTomb=!0;var a=n.apply(i,arguments);return o.off(e,r),a}r[wl]=n,this.on(e,t,r)},oi.prototype.off=function(e,t){e=Ze(e)?e:[e];var n=this;e.forEach(function(i){n._removeListener(i,t)})},oi.prototype.createEvent=function(e){var t=new As;return t.init(e),t},oi.prototype.fire=function(e,t){var n,i,o,r;if(r=gT.call(arguments),typeof e=="object"&&(t=e,e=t.type),!e)throw new Error("no event type specified");if(i=this._listeners[e],!!i){t instanceof As?n=t:n=this.createEvent(t),r[0]=n;var a=n.type;e!==a&&(n.type=e);try{o=this._invokeListeners(n,r,i)}finally{e!==a&&(n.type=a)}return o===void 0&&n.defaultPrevented&&(o=!1),o}},oi.prototype.handleError=function(e){return this.fire("error",{error:e})===!1},oi.prototype._destroy=function(){this._listeners={}},oi.prototype._invokeListeners=function(e,t,n){for(var i;n&&!e.cancelBubble;)i=this._invokeListener(e,t,n),n=n.next;return i},oi.prototype._invokeListener=function(e,t,n){var i;if(n.callback.__isTomb)return i;try{i=mT(n.callback,t),i!==void 0&&(e.returnValue=i,e.stopPropagation()),i===!1&&e.preventDefault()}catch(o){if(!this.handleError(o))throw console.error("unhandled error in event listener",o),o}return i},oi.prototype._addListener=function(e,t){var n=this._getListeners(e),i;if(!n){this._setListeners(e,t);return}for(;n;){if(n.priority<t.priority){t.next=n,i?i.next=t:this._setListeners(e,t);return}i=n,n=n.next}i.next=t},oi.prototype._getListeners=function(e){return this._listeners[e]},oi.prototype._setListeners=function(e,t){this._listeners[e]=t},oi.prototype._removeListener=function(e,t){var n=this._getListeners(e),i,o,r;if(!t){this._setListeners(e,null);return}for(;n;)i=n.next,r=n.callback,(r===t||r[wl]===t)&&(o?o.next=i:this._setListeners(e,i)),o=n,n=i};function As(){}As.prototype.stopPropagation=function(){this.cancelBubble=!0},As.prototype.preventDefault=function(){this.defaultPrevented=!0},As.prototype.init=function(e){Y(this,e||{})};function mT(e,t){return e.apply(null,t)}function Ko(e){return e.childNodes[0]}function yT(e){return e.parentNode.childNodes[1]}function _l(e,t,n,i,o){var r=xs();r.setTranslate(t,n);var a=xs();a.setRotate(i||0,0,0);var s=xs();s.setScale(1,1),ws(e,[r,a,s])}function Dn(e,t,n){var i=xs();i.setTranslate(t,n),ws(e,i)}function Uv(e,t){var n=xs();n.setRotate(t,0,0),ws(e,n)}function yi(e,t){this._eventBus=e,this._elementRegistry=t}yi.$inject=["eventBus","elementRegistry"],yi.prototype._getChildrenContainer=function(e){var t=this._elementRegistry.getGraphics(e),n;return e.parent?(n=yT(t),n||(n=He("g"),dt(n).add("djs-children"),tt(t.parentNode,n))):n=t,n},yi.prototype._clear=function(e){var t=Ko(e);return fl(t),t},yi.prototype._createContainer=function(e,t,n,i){var o=He("g");dt(o).add("djs-group"),typeof n<"u"?vT(o,t,t.childNodes[n]):tt(t,o);var r=He("g");dt(r).add("djs-element"),dt(r).add("djs-"+e),i&&dt(r).add("djs-frame"),tt(o,r);var a=He("g");return dt(a).add("djs-visual"),tt(r,a),r},yi.prototype.create=function(e,t,n){var i=this._getChildrenContainer(t.parent);return this._createContainer(e,i,n,vv(t))},yi.prototype.updateContainments=function(e){var t=this,n=this._elementRegistry,i;i=ni(e,function(o,r){return r.parent&&(o[r.parent.id]=r.parent),o},{}),V(i,function(o){var r=o.children;if(r){var a=t._getChildrenContainer(o),s=a.firstChild;V(r,function(c){var l=n.getGraphics(c).parentNode;l===s?s=s.nextSibling:a.insertBefore(l,s)})}})},yi.prototype.drawShape=function(e,t,n={}){var i=this._eventBus;return i.fire("render.shape",{gfx:e,element:t,attrs:n})},yi.prototype.getShapePath=function(e){var t=this._eventBus;return t.fire("render.getShapePath",e)},yi.prototype.drawConnection=function(e,t,n={}){var i=this._eventBus;return i.fire("render.connection",{gfx:e,element:t,attrs:n})},yi.prototype.getConnectionPath=function(e){var t=this._eventBus;return t.fire("render.getConnectionPath",e)},yi.prototype.update=function(e,t,n){if(t.parent){var i=this._clear(n);if(e==="shape")this.drawShape(i,t),Dn(n,t.x,t.y);else if(e==="connection")this.drawConnection(i,t);else throw new Error("unknown type: "+e);t.hidden?Ie(n,"display","none"):Ie(n,"display","block")}},yi.prototype.remove=function(e){var t=this._elementRegistry.getGraphics(e);sn(t.parentNode)};function vT(e,t,n){var i=n||t.firstChild;e!==i&&t.insertBefore(e,i)}const bT={__depends__:[OP],__init__:["canvas"],canvas:["type",et],elementRegistry:["type",mi],elementFactory:["type",xo],eventBus:["type",oi],graphicsFactory:["type",yi]};function xT(e){var t=new mv(e);return t.init(),t}function wT(e){e=e||{};var t={config:["value",e]},n=[t,bT].concat(e.modules||[]);return xT(n)}function Xo(e,t){this._injector=t||wT(e),this.get("eventBus").fire("diagram.init")}Xo.prototype.get=function(e,t){return this._injector.get(e,t)},Xo.prototype.invoke=function(e,t,n){return this._injector.invoke(e,t,n)},Xo.prototype.destroy=function(){this.get("eventBus").fire("diagram.destroy")},Xo.prototype.clear=function(){this.get("eventBus").fire("diagram.clear")};function zn(e){return e?"<"+e.$type+(e.id?' id="'+e.id:"")+'" />':"<null>"}function Xn(e,t){return e.$instanceOf(t)}function _T(e){return It(e.rootElements,function(t){return Xn(t,"bpmn:Process")||Xn(t,"bpmn:Collaboration")})}function ET(e){var t={},n=[],i={};function o(K,J){return function(ge){K(ge,J)}}function r(K){t[K.id]=K}function a(K){return t[K.id]}function s(K,J){var ge=K.gfx;if(ge)throw new Error(`already rendered ${zn(K)}`);return e.element(K,i[K.id],J)}function c(K,J){return e.root(K,i[K.id],J)}function l(K,J){try{var ge=i[K.id]&&s(K,J);return r(K),ge}catch(Re){u(Re.message,{element:K,error:Re}),console.error(`failed to import ${zn(K)}`,Re)}}function u(K,J){e.error(K,J)}var p=this.registerDi=function(J){var ge=J.bpmnElement;ge?i[ge.id]?u(`multiple DI elements defined for ${zn(ge)}`,{element:ge}):i[ge.id]=J:u(`no bpmnElement referenced in ${zn(J)}`,{element:J})};function f(K){d(K.plane)}function d(K){p(K),V(K.planeElement,g)}function g(K){p(K)}this.handleDefinitions=function(J,ge){var Re=J.diagrams;if(ge&&Re.indexOf(ge)===-1)throw new Error("diagram not part of <bpmn:Definitions />");if(!ge&&Re&&Re.length&&(ge=Re[0]),!ge)throw new Error("no diagram to display");i={},f(ge);var ze=ge.plane;if(!ze)throw new Error(`no plane for ${zn(ge)}`);var $=ze.bpmnElement;if(!$)if($=_T(J),$)u(`correcting missing bpmnElement on ${zn(ze)} to ${zn($)}`),ze.bpmnElement=$,p(ze);else throw new Error("no process or collaboration to display");var C=c($,ze);if(Xn($,"bpmn:Process")||Xn($,"bpmn:SubProcess"))m($,C);else if(Xn($,"bpmn:Collaboration"))U($,C),w(J.rootElements,C);else throw new Error(`unsupported bpmnElement for ${zn(ze)}: ${zn($)}`);h(n)};var h=this.handleDeferred=function(){for(var J;n.length;)J=n.shift(),J()};function m(K,J){he(K,J),k(K.ioSpecification,J),P(K.artifacts,J),r(K)}function w(K,J){var ge=ct(K,function(Re){return!a(Re)&&Xn(Re,"bpmn:Process")&&Re.laneSets});ge.forEach(o(m,J))}function y(K,J){l(K,J)}function v(K,J){V(K,o(y,J))}function x(K,J){l(K,J)}function E(K,J){l(K,J)}function A(K,J){l(K,J)}function I(K,J){l(K,J)}function P(K,J){V(K,function(ge){Xn(ge,"bpmn:Association")?n.push(function(){I(ge,J)}):I(ge,J)})}function k(K,J){K&&(V(K.dataInputs,o(E,J)),V(K.dataOutputs,o(A,J)))}var H=this.handleSubProcess=function(J,ge){he(J,ge),P(J.artifacts,ge)};function F(K,J){var ge=l(K,J);Xn(K,"bpmn:SubProcess")&&H(K,ge||J),Xn(K,"bpmn:Activity")&&k(K.ioSpecification,J),n.push(function(){V(K.dataInputAssociations,o(x,J)),V(K.dataOutputAssociations,o(x,J))})}function G(K,J){l(K,J)}function ee(K,J){l(K,J)}function ce(K,J){n.push(function(){var ge=l(K,J);K.childLaneSet&&ie(K.childLaneSet,ge||J),ue(K)})}function ie(K,J){V(K.lanes,o(ce,J))}function be(K,J){V(K,o(ie,J))}function he(K,J){ye(K.flowElements,J),K.laneSets&&be(K.laneSets,J)}function ye(K,J){V(K,function(ge){Xn(ge,"bpmn:SequenceFlow")?n.push(function(){G(ge,J)}):Xn(ge,"bpmn:BoundaryEvent")?n.unshift(function(){F(ge,J)}):Xn(ge,"bpmn:FlowNode")?F(ge,J):Xn(ge,"bpmn:DataObject")||(Xn(ge,"bpmn:DataStoreReference")||Xn(ge,"bpmn:DataObjectReference")?ee(ge,J):u(`unrecognized flowElement ${zn(ge)} in context ${zn(J&&J.businessObject)}`,{element:ge,context:J}))})}function Ee(K,J){var ge=l(K,J),Re=K.processRef;Re&&m(Re,ge||J)}function U(K,J){V(K.participants,o(Ee,J)),n.push(function(){v(K.messageFlows,J)}),P(K.artifacts,J)}function ue(K){V(K.flowNodeRef,function(J){var ge=J.get("lanes");ge&&ge.push(K)})}}function ST(e,t,n){var i,o,r,a,s=[];function c(l,u){var p={root:function(h,m){return i.add(h,m)},element:function(h,m,w){return i.add(h,m,w)},error:function(h,m){s.push({message:h,context:m})}},f=new ET(p);u=u||l.diagrams&&l.diagrams[0];var d=RT(l,u);if(!d)throw new Error("no diagram to display");V(d,function(h){f.handleDefinitions(l,h)});var g=u.plane.bpmnElement.id;r.setRootElement(r.findRoot(g+"_plane")||r.findRoot(g))}return new Promise(function(l,u){try{return i=e.get("bpmnImporter"),o=e.get("eventBus"),r=e.get("canvas"),o.fire("import.render.start",{definitions:t}),c(t,n),o.fire("import.render.complete",{error:a,warnings:s}),l({warnings:s})}catch(p){return p.warnings=s,u(p)}})}function RT(e,t){if(!(!t||!t.plane)){var n=t.plane.bpmnElement,i=n;!M(n,"bpmn:Process")&&!M(n,"bpmn:Collaboration")&&(i=CT(n));var o;M(i,"bpmn:Collaboration")?o=i:o=It(e.rootElements,function(l){if(M(l,"bpmn:Collaboration"))return It(l.participants,function(u){return u.processRef===i})});var r=[i];o&&(r=Fn(o.participants,function(l){return l.processRef}),r.push(o));var a=qv(r),s=[t],c=[n];return V(e.diagrams,function(l){if(l.plane){var u=l.plane.bpmnElement;a.indexOf(u)!==-1&&c.indexOf(u)===-1&&(s.push(l),c.push(u))}}),s}}function qv(e){var t=[];return V(e,function(n){n&&(t.push(n),t=t.concat(qv(n.flowElements)))}),t}function CT(e){for(var t=e;t;){if(M(t,"bpmn:Process"))return t;t=t.$parent}}var MT='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14.02 5.57" width="53" height="21"><path fill="currentColor" d="M1.88.92v.14c0 .41-.13.68-.4.8.33.14.46.44.46.86v.33c0 .61-.33.95-.95.95H0V0h.95c.65 0 .93.3.93.92zM.63.57v1.06h.24c.24 0 .38-.1.38-.43V.98c0-.28-.1-.4-.32-.4zm0 1.63v1.22h.36c.2 0 .32-.1.32-.39v-.35c0-.37-.12-.48-.4-.48H.63zM4.18.99v.52c0 .64-.31.98-.94.98h-.3V4h-.62V0h.92c.63 0 .94.35.94.99zM2.94.57v1.35h.3c.2 0 .3-.09.3-.37v-.6c0-.29-.1-.38-.3-.38h-.3zm2.89 2.27L6.25 0h.88v4h-.6V1.12L6.1 3.99h-.6l-.46-2.82v2.82h-.55V0h.87zM8.14 1.1V4h-.56V0h.79L9 2.4V0h.56v4h-.64zm2.49 2.29v.6h-.6v-.6zM12.12 1c0-.63.33-1 .95-1 .61 0 .95.37.95 1v2.04c0 .64-.34 1-.95 1-.62 0-.95-.37-.95-1zm.62 2.08c0 .28.13.39.33.39s.32-.1.32-.4V.98c0-.29-.12-.4-.32-.4s-.33.11-.33.4z"/><path fill="currentColor" d="M0 4.53h14.02v1.04H0zM11.08 0h.63v.62h-.63zm.63 4V1h-.63v2.98z"/></svg>',Yv=MT,Kv={verticalAlign:"middle"},Xv={color:"#404040"},AT={zIndex:"1001",position:"fixed",top:"0",left:"0",right:"0",bottom:"0"},PT={width:"100%",height:"100%",background:"rgba(40,40,40,0.2)"},TT={position:"absolute",left:"50%",top:"40%",transform:"translate(-50%)",width:"260px",padding:"10px",background:"white",boxShadow:"0 1px 4px rgba(0,0,0,0.3)",fontFamily:"Helvetica, Arial, sans-serif",fontSize:"14px",display:"flex",lineHeight:"1.3"},kT='<div class="bjs-powered-by-lightbox"><div class="backdrop"></div><div class="notice"><a href="https://bpmn.io" target="_blank" rel="noopener" class="link">'+Yv+'</a><span>Web-based tooling for BPMN, DMN and forms powered by <a href="https://bpmn.io" target="_blank" rel="noopener">bpmn.io</a>.</span></div></div>',eo;function OT(){eo=jt(kT),Un(eo,AT),Un(Ct("svg",eo),Kv),Un(Ct(".backdrop",eo),PT),Un(Ct(".notice",eo),TT),Un(Ct(".link",eo),Xv,{margin:"15px 20px 15px 10px",alignSelf:"center"})}function DT(){eo||(OT(),ii.bind(eo,".backdrop","click",function(e){document.body.removeChild(eo)})),document.body.appendChild(eo)}const El=5,Zv="djs-outline-hidden";function Wt(e){e=Y({},IT,e),this._moddle=this._createModdle(e),this._container=this._createContainer(e),this._init(this._container,this._moddle,e),NT(this._container)}Ne(Wt,Xo),Wt.prototype.importXML=async function(t,n){const i=this;function o(a){return i.get("eventBus").createEvent(a)}let r=[];try{t=this._emit("import.parse.start",{xml:t})||t;let a;try{a=await this._moddle.fromXML(t,"bpmn:Definitions")}catch(f){throw this._emit("import.parse.complete",{error:f}),f}let s=a.rootElement;const c=a.references,l=a.warnings,u=a.elementsById;r=r.concat(l),s=this._emit("import.parse.complete",o({error:null,definitions:s,elementsById:u,references:c,warnings:r}))||s;const p=await this.importDefinitions(s,n);return r=r.concat(p.warnings),this._emit("import.done",{error:null,warnings:r}),{warnings:r}}catch(a){let s=a;throw r=r.concat(s.warnings||[]),Sl(s,r),s=LT(s),this._emit("import.done",{error:s,warnings:s.warnings}),s}},Wt.prototype.importDefinitions=async function(t,n){return this._setDefinitions(t),{warnings:(await this.open(n)).warnings}},Wt.prototype.open=async function(t){const n=this._definitions;let i=t;if(!n){const r=new Error("no XML imported");throw Sl(r,[]),r}if(typeof t=="string"&&(i=BT(n,t),!i)){const r=new Error("BPMNDiagram <"+t+"> not found");throw Sl(r,[]),r}try{this.clear()}catch(r){throw Sl(r,[]),r}const{warnings:o}=await ST(this,n,i);return{warnings:o}},Wt.prototype.saveXML=async function(t){t=t||{};let n=this._definitions,i,o;try{if(!n)throw new Error("no definitions loaded");n=this._emit("saveXML.start",{definitions:n})||n,o=(await this._moddle.toXML(n,t)).xml,o=this._emit("saveXML.serialized",{xml:o})||o}catch(a){i=a}const r=i?{error:i}:{xml:o};if(this._emit("saveXML.done",r),i)throw i;return r},Wt.prototype.saveSVG=async function(){this._emit("saveSVG.start");let t,n;try{const i=this.get("canvas"),o=i.getActiveLayer(),r=Ct(":scope > defs",i._svg),a=gv(o),s=r?"<defs>"+gv(r)+"</defs>":"",c=i.getContainer();At(c).add(Zv);let l;try{l=o.getBBox()}finally{At(c).remove(Zv)}const u=l.x-El,p=l.y-El,f=l.width+El*2,d=l.height+El*2;t=`<?xml version="1.0" encoding="utf-8"?>
8
8
  <!-- created with bpmn-js / http://bpmn.io -->
9
9
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
10
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="`+f+'" height="'+d+'" viewBox="'+u+" "+p+" "+f+" "+d+'" version="1.1">'+s+a+"</svg>"}catch(i){n=i}if(this._emit("saveSVG.done",{error:n,svg:t}),n)throw n;return{svg:t}},Wt.prototype._setDefinitions=function(e){this._definitions=e},Wt.prototype.getModules=function(){return this._modules},Wt.prototype.clear=function(){this.getDefinitions()&&Xo.prototype.clear.call(this)},Wt.prototype.destroy=function(){Xo.prototype.destroy.call(this),Zi(this._container)},Wt.prototype.on=function(e,t,n,i){return this.get("eventBus").on(e,t,n,i)},Wt.prototype.off=function(e,t){this.get("eventBus").off(e,t)},Wt.prototype.attachTo=function(e){if(!e)throw new Error("parentNode required");this.detach(),e.get&&e.constructor.prototype.jquery&&(e=e.get(0)),typeof e=="string"&&(e=Ct(e)),e.appendChild(this._container),this._emit("attach",{}),this.get("canvas").resized()},Wt.prototype.getDefinitions=function(){return this._definitions},Wt.prototype.detach=function(){const e=this._container,t=e.parentNode;t&&(this._emit("detach",{}),t.removeChild(e))},Wt.prototype._init=function(e,t,n){const i=n.modules||this.getModules(n),o=n.additionalModules||[],r=[{bpmnjs:["value",this],moddle:["value",t]}],a=[].concat(r,i,o),s=Y(Yi(n,["additionalModules"]),{canvas:Y({},n.canvas,{container:e}),modules:a});Xo.call(this,s),n&&n.container&&this.attachTo(n.container)},Wt.prototype._emit=function(e,t){return this.get("eventBus").fire(e,t)},Wt.prototype._createContainer=function(e){const t=jt('<div class="bjs-container"></div>');return Un(t,{width:Qv(e.width),height:Qv(e.height),position:e.position}),t},Wt.prototype._createModdle=function(e){const t=Y({},this._moddleExtensions,e.moddleExtensions);return new _m(t)},Wt.prototype._modules=[];function Sl(e,t){return e.warnings=t,e}function LT(e){const n=/unparsable content <([^>]+)> detected([\s\S]*)$/.exec(e.message);return n&&(e.message="unparsable content <"+n[1]+"> detected; this may indicate an invalid BPMN 2.0 diagram file"+n[2]),e}const IT={width:"100%",height:"100%",position:"relative"};function Qv(e){return e+(Qe(e)?"px":"")}function BT(e,t){return t&&It(e.diagrams,function(n){return n.id===t})||null}function NT(e){const n='<a href="http://bpmn.io" target="_blank" class="bjs-powered-by" title="Powered by bpmn.io" >'+Yv+"</a>",i=jt(n);Un(Ct("svg",i),Kv),Un(i,Xv,{position:"absolute",bottom:"15px",right:"15px",zIndex:"100"}),e.appendChild(i),Ve.bind(i,"click",function(o){DT(),o.preventDefault()})}function Ea(e){Wt.call(this,e),this.on("import.parse.complete",function(t){t.error||this._collectIds(t.definitions,t.elementsById)},this),this.on("diagram.destroy",function(){this.get("moddle").ids.clear()},this)}Ne(Ea,Wt),Ea.prototype._createModdle=function(e){var t=Wt.prototype._createModdle.call(this,e);return t.ids=new Xi([32,36,1]),t},Ea.prototype._collectIds=function(e,t){var n=e.$model,i=n.ids,o;i.clear();for(o in t)i.claim(o,t[o])};function ht(e,t){return M(e,"bpmn:CallActivity")?!1:M(e,"bpmn:SubProcess")?(t=t||mt(e),t&&M(t,"bpmndi:BPMNPlane")?!0:t&&!!t.isExpanded):M(e,"bpmn:Participant")?!!_e(e).processRef:!0}function En(e){if(!(!M(e,"bpmn:Participant")&&!M(e,"bpmn:Lane"))){var t=mt(e).isHorizontal;return t===void 0?!0:t}}function $T(e){return e&&_e(e).isInterrupting!==!1}function Gn(e){return e&&!!_e(e).triggeredByEvent}function Sa(e,t){var n=_e(e).eventDefinitions;return Bo(n,function(i){return M(i,t)})}function FT(e){return Sa(e,"bpmn:ErrorEventDefinition")}function jT(e){return Sa(e,"bpmn:EscalationEventDefinition")}function HT(e){return Sa(e,"bpmn:CompensateEventDefinition")}var Nr={width:90,height:20},Jv=15;function Zo(e){return M(e,"bpmn:Event")||M(e,"bpmn:Gateway")||M(e,"bpmn:DataStoreReference")||M(e,"bpmn:DataObjectReference")||M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput")||M(e,"bpmn:SequenceFlow")||M(e,"bpmn:MessageFlow")||M(e,"bpmn:Group")}function Rl(e){return at(e.label)}function zT(e){var t=e.length/2-1,n=e[Math.floor(t)],i=e[Math.ceil(t+.01)],o=GT(e),r=Math.atan((i.y-n.y)/(i.x-n.x)),a=o.x,s=o.y;return Math.abs(r)<Math.PI/2?s-=Jv:a+=Jv,{x:a,y:s}}function GT(e){var t=e.length/2-1,n=e[Math.floor(t)],i=e[Math.ceil(t+.01)];return{x:n.x+(i.x-n.x)/2,y:n.y+(i.y-n.y)/2}}function Jf(e){return e.waypoints?zT(e.waypoints):M(e,"bpmn:Group")?{x:e.x+e.width/2,y:e.y+Nr.height/2}:{x:e.x+e.width/2,y:e.y+e.height+Nr.height/2}}function VT(e,t){var n,i,o,r=e.label;return r&&r.bounds?(o=r.bounds,i={width:Math.max(Nr.width,o.width),height:o.height},n={x:o.x+o.width/2,y:o.y+o.height/2}):(n=Jf(t),i=Nr),Y({x:n.x-i.width/2,y:n.y-i.height/2},i)}function eb(e){if(M(e,"bpmn:FlowElement")||M(e,"bpmn:Participant")||M(e,"bpmn:Lane")||M(e,"bpmn:SequenceFlow")||M(e,"bpmn:MessageFlow")||M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput"))return"name";if(M(e,"bpmn:TextAnnotation"))return"text";if(M(e,"bpmn:Group"))return"categoryValueRef"}function WT(e){var t=e.categoryValueRef;return t&&t.value||""}function vi(e){var t=e.businessObject,n=eb(t);if(n)return n==="categoryValueRef"?WT(t):t[n]||""}function UT(e,t){var n=e.businessObject,i=eb(n);if(i)if(i==="categoryValueRef"){if(!n[i])return e;n[i].value=t}else n[i]=t;return e}function qT(e){return at(e)&&Zo(e.labelTarget)}var Ra=7;function tb(e){let t=[];return V(e.incoming,n=>{M(n,"bpmn:Association")&&M(n.source,"bpmn:TextAnnotation")&&t.push({annotation:n.source,association:n})}),V(e.outgoing,n=>{M(n,"bpmn:Association")&&M(n.target,"bpmn:TextAnnotation")&&t.push({annotation:n.target,association:n})}),t}function Ps(e){const t=new Map;return V(Uf(e),n=>{V(tb(n),i=>{t.has(i.annotation)||t.set(i.annotation,{annotation:i.annotation,associations:[]}),t.get(i.annotation).associations.push(i.association)})}),[...t.values()]}var ed="hsl(225, 10%, 15%)",YT="white";function to(e,t){return Bo(e.eventDefinitions,function(n){return n.$type===t})}function KT(e){return e.$type==="bpmn:IntermediateThrowEvent"||e.$type==="bpmn:EndEvent"}function XT(e){var t=e.dataObjectRef;return e.isCollection||t&&t.isCollection}function ut(e,t,n){var i=mt(e);return n||i.get("color:background-color")||i.get("bioc:fill")||t||YT}function Be(e,t,n){var i=mt(e);return n||i.get("color:border-color")||i.get("bioc:stroke")||t||ed}function Ts(e,t,n,i){var o=mt(e),r=o.get("label");return i||r&&r.get("color:color")||t||Be(e,n)}function nb(e){var t=e.x+e.width/2,n=e.y+e.height/2,i=e.width/2,o=[["M",t,n],["m",0,-i],["a",i,i,0,1,1,0,2*i],["a",i,i,0,1,1,0,-2*i],["z"]];return Ir(o)}function td(e,t){var n=e.x,i=e.y,o=e.width,r=e.height,a=[["M",n+t,i],["l",o-t*2,0],["a",t,t,0,0,1,t,t],["l",0,r-t*2],["a",t,t,0,0,1,-t,t],["l",t*2-o,0],["a",t,t,0,0,1,-t,-t],["l",0,t*2-r],["a",t,t,0,0,1,t,-t],["z"]];return Ir(a)}function ZT(e){var t=e.width,n=e.height,i=e.x,o=e.y,r=t/2,a=n/2,s=[["M",i+r,o],["l",r,a],["l",-r,a],["l",-r,-a],["z"]];return Ir(s)}function QT(e){var t=e.x,n=e.y,i=e.width,o=e.height,r=[["M",t,n],["l",i,0],["l",0,o],["l",-i,0],["z"]];return Ir(r)}function ks(e,t={}){return{width:Ei(e,t),height:ri(e,t)}}function Ei(e,t={}){return ti(t,"width")?t.width:e.width}function ri(e,t={}){return ti(t,"height")?t.height:e.height}var JT=new Xi,e2=10,Cl=3,t2=1.5,Ml=10,n2=4,Ca=.95,i2=1,o2=.25;function $r(e,t,n,i,o,r,a){yo.call(this,t,a);var s=e&&e.defaultFillColor,c=e&&e.defaultStrokeColor,l=e&&e.defaultLabelColor;function u($){return n.computeStyle($,{strokeLinecap:"round",strokeLinejoin:"round",stroke:ed,strokeWidth:2,fill:"white"})}function p($){return n.computeStyle($,["no-fill"],{strokeLinecap:"round",strokeLinejoin:"round",stroke:ed,strokeWidth:2})}function f($,C){var{ref:R={x:0,y:0},scale:W=1,element:q,parentGfx:fe=o._svg}=C,Oe=He("marker",{id:$,viewBox:"0 0 20 20",refX:R.x,refY:R.y,markerWidth:20*W,markerHeight:20*W,orient:"auto"});tt(Oe,q);var nt=Ct(":scope > defs",fe);nt||(nt=He("defs"),tt(fe,nt)),tt(nt,Oe)}function d($,C,R,W){var q=JT.nextPrefixed("marker-");return g($,q,C,R,W),"url(#"+q+")"}function g($,C,R,W,q){if(R==="sequenceflow-end"){var fe=He("path",{d:"M 1 5 L 11 10 L 1 15 Z",...u({fill:q,stroke:q,strokeWidth:1})});f(C,{element:fe,ref:{x:11,y:10},scale:.5,parentGfx:$})}if(R==="messageflow-start"){var Oe=He("circle",{cx:6,cy:6,r:3.5,...u({fill:W,stroke:q,strokeWidth:1,strokeDasharray:[1e4,1]})});f(C,{element:Oe,ref:{x:6,y:6},parentGfx:$})}if(R==="messageflow-end"){var nt=He("path",{d:"m 1 5 l 0 -3 l 7 3 l -7 3 z",...u({fill:W,stroke:q,strokeWidth:1,strokeDasharray:[1e4,1]})});f(C,{element:nt,ref:{x:8.5,y:5},parentGfx:$})}if(R==="association-start"){var lt=He("path",{d:"M 11 5 L 1 10 L 11 15",...p({fill:"none",stroke:q,strokeWidth:1.5,strokeDasharray:[1e4,1]})});f(C,{element:lt,ref:{x:1,y:10},scale:.5,parentGfx:$})}if(R==="association-end"){var Vt=He("path",{d:"M 1 5 L 11 10 L 1 15",...p({fill:"none",stroke:q,strokeWidth:1.5,strokeDasharray:[1e4,1]})});f(C,{element:Vt,ref:{x:11,y:10},scale:.5,parentGfx:$})}if(R==="conditional-flow-marker"){var St=He("path",{d:"M 0 10 L 8 6 L 16 10 L 8 14 Z",...u({fill:W,stroke:q})});f(C,{element:St,ref:{x:-1,y:10},scale:.5,parentGfx:$})}if(R==="conditional-default-flow-marker"){var nn=He("path",{d:"M 6 4 L 10 16",...u({stroke:q,fill:"none"})});f(C,{element:nn,ref:{x:0,y:10},scale:.5,parentGfx:$})}}function h($,C,R,W,q={}){mn(W)&&(q=W,W=0),W=W||0,q=u(q);var fe=C/2,Oe=R/2,nt=He("circle",{cx:fe,cy:Oe,r:Math.round((C+R)/4-W),...q});return tt($,nt),nt}function m($,C,R,W,q,fe){mn(q)&&(fe=q,q=0),q=q||0,fe=u(fe);var Oe=He("rect",{x:q,y:q,width:C-q*2,height:R-q*2,rx:W,ry:W,...fe});return tt($,Oe),Oe}function w($,C,R,W){var q=C/2,fe=R/2,Oe=[{x:q,y:0},{x:C,y:fe},{x:q,y:R},{x:0,y:fe}],nt=Oe.map(function(Vt){return Vt.x+","+Vt.y}).join(" ");W=u(W);var lt=He("polygon",{...W,points:nt});return tt($,lt),lt}function y($,C,R,W){R=p(R);var q=_s(C,R,W);return tt($,q),q}function v($,C,R){return y($,C,R,5)}function x($,C,R){R=p(R);var W=He("path",{...R,d:C});return tt($,W),W}function E($,C,R,W){return x(C,R,Y({"data-marker":$},W))}function A($){return ze[$]}function B($){return function(C,R,W){return A($)(C,R,W)}}var P={"bpmn:MessageEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_MESSAGE",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.235,my:.315}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill),Oe=W?ut(C,s,R.fill):Be(C,c,R.stroke),nt=x($,q,{fill:fe,stroke:Oe,strokeWidth:1});return nt},"bpmn:TimerEventDefinition":function($,C,R={}){var W=R.width||C.width,q=R.height||C.height,fe=R.width?1:2,Oe=h($,W,q,.2*q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:fe}),nt=i.getScaledPath("EVENT_TIMER_WH",{xScaleFactor:.75,yScaleFactor:.75,containerWidth:W,containerHeight:q,position:{mx:.5,my:.5}});x($,nt,{stroke:Be(C,c,R.stroke),strokeWidth:fe});for(var lt=0;lt<12;lt++){var Vt=i.getScaledPath("EVENT_TIMER_LINE",{xScaleFactor:.75,yScaleFactor:.75,containerWidth:W,containerHeight:q,position:{mx:.5,my:.5}}),St=W/2,nn=q/2;x($,Vt,{strokeWidth:1,stroke:Be(C,c,R.stroke),transform:"rotate("+lt*30+","+nn+","+St+")"})}return Oe},"bpmn:EscalationEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_ESCALATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.5,my:.2}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:ConditionalEventDefinition":function($,C,R={}){var W=i.getScaledPath("EVENT_CONDITIONAL",{xScaleFactor:1,yScaleFactor:1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.5,my:.222}});return x($,W,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:LinkEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_LINK",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.57,my:.263}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:ErrorEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_ERROR",{xScaleFactor:1.1,yScaleFactor:1.1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.2,my:.722}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:CancelEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_CANCEL_45",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.638,my:-.055}}),fe=W?Be(C,c,R.stroke):"none",Oe=x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1});return Uv(Oe,45),Oe},"bpmn:CompensateEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_COMPENSATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.22,my:.5}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:SignalEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_SIGNAL",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.5,my:.2}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{strokeWidth:1,fill:fe,stroke:Be(C,c,R.stroke)})},"bpmn:MultipleEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_MULTIPLE",{xScaleFactor:1.1,yScaleFactor:1.1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.211,my:.36}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:ParallelMultipleEventDefinition":function($,C,R={}){var W=i.getScaledPath("EVENT_PARALLEL_MULTIPLE",{xScaleFactor:1.2,yScaleFactor:1.2,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.458,my:.194}});return x($,W,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:TerminateEventDefinition":function($,C,R={}){var W=h($,C.width,C.height,8,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:4});return W}};function k($,C,R={},W){var q=_e($),fe=KT(q),Oe=W||$;return q.get("eventDefinitions")&&q.get("eventDefinitions").length>1?q.get("parallelMultiple")?P["bpmn:ParallelMultipleEventDefinition"](C,Oe,R,fe):P["bpmn:MultipleEventDefinition"](C,Oe,R,fe):to(q,"bpmn:MessageEventDefinition")?P["bpmn:MessageEventDefinition"](C,Oe,R,fe):to(q,"bpmn:TimerEventDefinition")?P["bpmn:TimerEventDefinition"](C,Oe,R,fe):to(q,"bpmn:ConditionalEventDefinition")?P["bpmn:ConditionalEventDefinition"](C,Oe,R,fe):to(q,"bpmn:SignalEventDefinition")?P["bpmn:SignalEventDefinition"](C,Oe,R,fe):to(q,"bpmn:EscalationEventDefinition")?P["bpmn:EscalationEventDefinition"](C,Oe,R,fe):to(q,"bpmn:LinkEventDefinition")?P["bpmn:LinkEventDefinition"](C,Oe,R,fe):to(q,"bpmn:ErrorEventDefinition")?P["bpmn:ErrorEventDefinition"](C,Oe,R,fe):to(q,"bpmn:CancelEventDefinition")?P["bpmn:CancelEventDefinition"](C,Oe,R,fe):to(q,"bpmn:CompensateEventDefinition")?P["bpmn:CompensateEventDefinition"](C,Oe,R,fe):to(q,"bpmn:TerminateEventDefinition")?P["bpmn:TerminateEventDefinition"](C,Oe,R,fe):null}var H={ParticipantMultiplicityMarker:function($,C,R={}){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_PARALLEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2-6)/W,my:(q-15)/q}});E("participant-multiplicity",$,fe,{strokeWidth:2,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},SubProcessMarker:function($,C,R={}){var W=m($,14,14,0,{strokeWidth:1,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)});Dn(W,C.width/2-7.5,C.height-20);var q=i.getScaledPath("MARKER_SUB_PROCESS",{xScaleFactor:1.5,yScaleFactor:1.5,containerWidth:C.width,containerHeight:C.height,position:{mx:(C.width/2-7.5)/C.width,my:(C.height-20)/C.height}});E("sub-process",$,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},ParallelMarker:function($,C,R){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_PARALLEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2+R.parallel)/W,my:(q-20)/q}});E("parallel",$,fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},SequentialMarker:function($,C,R){var W=i.getScaledPath("MARKER_SEQUENTIAL",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:(C.width/2+R.seq)/C.width,my:(C.height-19)/C.height}});E("sequential",$,W,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},CompensationMarker:function($,C,R){var W=i.getScaledPath("MARKER_COMPENSATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:(C.width/2+R.compensation)/C.width,my:(C.height-13)/C.height}});E("compensation",$,W,{strokeWidth:1,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},LoopMarker:function($,C,R){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_LOOP",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2+R.loop)/W,my:(q-7)/q}});E("loop",$,fe,{strokeWidth:1.5,fill:"none",stroke:Be(C,c,R.stroke),strokeMiterlimit:.5})},AdhocMarker:function($,C,R){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_ADHOC",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2+R.adhoc)/W,my:(q-15)/q}});E("adhoc",$,fe,{strokeWidth:1,fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke)})}};function F($,C,R,W){H[$](C,R,W)}function G($,C,R=[],W={}){W={fill:W.fill,stroke:W.stroke,width:Ei(C,W),height:ri(C,W)};var q=_e(C),fe=R.includes("SubProcessMarker");fe?W={...W,seq:-21,parallel:-22,compensation:-25,loop:-18,adhoc:10}:W={...W,seq:-5,parallel:-6,compensation:-7,loop:0,adhoc:-8},q.get("isForCompensation")&&R.push("CompensationMarker"),M(q,"bpmn:AdHocSubProcess")&&(R.push("AdhocMarker"),fe||Y(W,{compensation:W.compensation-18}));var Oe=q.get("loopCharacteristics"),nt=Oe&&Oe.get("isSequential");Oe&&(Y(W,{compensation:W.compensation-18}),R.includes("AdhocMarker")&&Y(W,{seq:-23,loop:-18,parallel:-24}),nt===void 0&&R.push("LoopMarker"),nt===!1&&R.push("ParallelMarker"),nt===!0&&R.push("SequentialMarker")),R.includes("CompensationMarker")&&R.length===1&&Y(W,{compensation:-8}),V(R,function(lt){F(lt,$,C,W)})}function ee($,C,R={}){R=Y({size:{width:100}},R);var W=r.createText(C||"",R);return dt(W).add("djs-label"),tt($,W),W}function ce($,C,R,W={}){var q=_e(C),fe=ks({x:C.x,y:C.y,width:C.width,height:C.height},W);return ee($,q.name,{align:R,box:fe,padding:7,style:{fill:Ts(C,l,c,W.stroke)}})}function ie($,C,R={}){var W={width:C.width,height:C.height,x:C.width/2+C.x,y:C.height/2+C.y};return ee($,vi(C),{box:W,style:Y({},r.getExternalStyle(),{fill:Ts(C,l,c,R.stroke)})})}function be($,C,R,W={}){var q=En(R),fe=ee($,C,{box:{height:30,width:q?ri(R,W):Ei(R,W)},align:"center-middle",style:{fill:Ts(R,l,c,W.stroke)}});if(q){var Oe=-1*ri(R,W);_l(fe,0,-Oe,270)}}function de($,C,R={}){var{width:W,height:q}=ks(C,R);return m($,W,q,Ml,{...R,fill:ut(C,s,R.fill),fillOpacity:Ca,stroke:Be(C,c,R.stroke)})}function me($,C,R={}){var W=_e(C),q=ut(C,s,R.fill),fe=Be(C,c,R.stroke);return(W.get("associationDirection")==="One"||W.get("associationDirection")==="Both")&&(R.markerEnd=d($,"association-end",q,fe)),W.get("associationDirection")==="Both"&&(R.markerStart=d($,"association-start",q,fe)),R=yt(R,["markerStart","markerEnd"]),v($,C.waypoints,{...R,stroke:fe,strokeDasharray:"0, 5"})}function Ee($,C,R={}){var W=ut(C,s,R.fill),q=Be(C,c,R.stroke),fe=i.getScaledPath("DATA_OBJECT_PATH",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.474,my:.296}}),Oe=x($,fe,{fill:W,fillOpacity:Ca,stroke:q}),nt=_e(C);if(XT(nt)){var lt=i.getScaledPath("DATA_OBJECT_COLLECTION_PATH",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.33,my:(C.height-18)/C.height}});x($,lt,{strokeWidth:2,fill:W,stroke:q})}return Oe}function U($,C,R={}){return h($,C.width,C.height,{fillOpacity:Ca,...R,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})}function ue($,C,R={}){return w($,C.width,C.height,{fill:ut(C,s,R.fill),fillOpacity:Ca,stroke:Be(C,c,R.stroke)})}function K($,C,R={}){var W=m($,Ei(C,R),ri(C,R),0,{fill:ut(C,s,R.fill),fillOpacity:R.fillOpacity||Ca,stroke:Be(C,c,R.stroke),strokeWidth:1.5}),q=_e(C);if(M(q,"bpmn:Lane")){var fe=q.get("name");be($,fe,C,R)}return W}function J($,C,R={}){var W=de($,C,R),q=ht(C);if(Gn(C)&&(Ie(W,{strokeDasharray:"0, 5.5",strokeWidth:2.5}),!q)){var fe=_e(C).flowElements||[],Oe=fe.filter(nt=>M(nt,"bpmn:StartEvent"));Oe.length===1&&he(Oe[0],$,R,C)}return ce($,C,q?"center-top":"center-middle",R),q?G($,C,void 0,R):G($,C,["SubProcessMarker"],R),W}function he($,C,R,W){var q=22,fe={fill:ut(W,s,R.fill),stroke:Be(W,c,R.stroke),width:q,height:q},Oe=_e($).isInterrupting,nt=Oe?0:3,lt=Oe?1:1.2,Vt=20,St=(q-Vt)/2,nn="translate("+St+","+St+")";h(C,Vt,Vt,{fill:fe.fill,stroke:fe.stroke,strokeWidth:lt,strokeDasharray:nt,transform:nn}),k($,C,fe,W)}function Re($,C,R={}){var W=de($,C,R);return ce($,C,"center-middle",R),G($,C,void 0,R),W}var ze=this.handlers={"bpmn:AdHocSubProcess":function($,C,R={}){return ht(C)?R=yt(R,["fill","stroke","width","height"]):R=yt(R,["fill","stroke"]),J($,C,R)},"bpmn:Association":function($,C,R={}){return R=yt(R,["fill","stroke"]),me($,C,R)},"bpmn:BoundaryEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=_e(C),fe=q.get("cancelActivity");R={strokeWidth:1.5,fill:ut(C,s,R.fill),fillOpacity:i2,stroke:Be(C,c,R.stroke)},fe||(R.strokeDasharray="6");var Oe=U($,C,R);return h($,C.width,C.height,Cl,{...R,fill:"none"}),W&&k(C,$,R),Oe},"bpmn:BusinessRuleTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_BUSINESS_RULE_MAIN",{abspos:{x:8,y:8}}),fe=x($,q);Ie(fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1});var Oe=i.getScaledPath("TASK_TYPE_BUSINESS_RULE_HEADER",{abspos:{x:8,y:8}}),nt=x($,Oe);return Ie(nt,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:CallActivity":function($,C,R={}){return R=yt(R,["fill","stroke"]),J($,C,{strokeWidth:5,...R})},"bpmn:ComplexGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R),q=i.getScaledPath("GATEWAY_COMPLEX",{xScaleFactor:.5,yScaleFactor:.5,containerWidth:C.width,containerHeight:C.height,position:{mx:.46,my:.26}});return x($,q,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:DataInput":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=i.getRawPath("DATA_ARROW"),q=Ee($,C,R);return x($,W,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1}),q},"bpmn:DataInputAssociation":function($,C,R={}){return R=yt(R,["fill","stroke"]),me($,C,{...R,markerEnd:d($,"association-end",ut(C,s,R.fill),Be(C,c,R.stroke))})},"bpmn:DataObject":function($,C,R={}){return R=yt(R,["fill","stroke"]),Ee($,C,R)},"bpmn:DataObjectReference":B("bpmn:DataObject"),"bpmn:DataOutput":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=i.getRawPath("DATA_ARROW"),q=Ee($,C,R);return x($,W,{strokeWidth:1,fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke)}),q},"bpmn:DataOutputAssociation":function($,C,R={}){return R=yt(R,["fill","stroke"]),me($,C,{...R,markerEnd:d($,"association-end",ut(C,s,R.fill),Be(C,c,R.stroke))})},"bpmn:DataStoreReference":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=i.getScaledPath("DATA_STORE",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:0,my:.133}});return x($,W,{fill:ut(C,s,R.fill),fillOpacity:Ca,stroke:Be(C,c,R.stroke),strokeWidth:2})},"bpmn:EndEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=U($,C,{...R,strokeWidth:4});return W&&k(C,$,R),q},"bpmn:EventBasedGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=_e(C),q=ue($,C,R);h($,C.width,C.height,C.height*.2,{fill:ut(C,"none",R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1});var fe=W.get("eventGatewayType"),Oe=!!W.get("instantiate");function nt(){var Vt=i.getScaledPath("GATEWAY_EVENT_BASED",{xScaleFactor:.18,yScaleFactor:.18,containerWidth:C.width,containerHeight:C.height,position:{mx:.36,my:.44}});x($,Vt,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:2})}if(fe==="Parallel"){var lt=i.getScaledPath("GATEWAY_PARALLEL",{xScaleFactor:.4,yScaleFactor:.4,containerWidth:C.width,containerHeight:C.height,position:{mx:.474,my:.296}});x($,lt,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1})}else fe==="Exclusive"&&(Oe||h($,C.width,C.height,C.height*.26,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1}),nt());return q},"bpmn:ExclusiveGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R),q=i.getScaledPath("GATEWAY_EXCLUSIVE",{xScaleFactor:.4,yScaleFactor:.4,containerWidth:C.width,containerHeight:C.height,position:{mx:.32,my:.3}}),fe=mt(C);return fe.get("isMarkerVisible")&&x($,q,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:Gateway":function($,C,R={}){return R=yt(R,["fill","stroke"]),ue($,C,R)},"bpmn:Group":function($,C,R={}){return R=yt(R,["fill","stroke","width","height"]),m($,C.width,C.height,Ml,{stroke:Be(C,c,R.stroke),strokeWidth:1.5,strokeDasharray:"10, 6, 0, 6",fill:"none",pointerEvents:"none",width:Ei(C,R),height:ri(C,R)})},"bpmn:InclusiveGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R);return h($,C.width,C.height,C.height*.24,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:2.5}),W},"bpmn:IntermediateEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=U($,C,{...R,strokeWidth:1.5});return h($,C.width,C.height,Cl,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1.5}),W&&k(C,$,R),q},"bpmn:IntermediateCatchEvent":B("bpmn:IntermediateEvent"),"bpmn:IntermediateThrowEvent":B("bpmn:IntermediateEvent"),"bpmn:Lane":function($,C,R={}){return R=yt(R,["fill","stroke","width","height"]),K($,C,{...R,fillOpacity:o2})},"bpmn:ManualTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_MANUAL",{abspos:{x:17,y:15}});return x($,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:.5}),W},"bpmn:MessageFlow":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=_e(C),q=mt(C),fe=ut(C,s,R.fill),Oe=Be(C,c,R.stroke),nt=v($,C.waypoints,{markerEnd:d($,"messageflow-end",fe,Oe),markerStart:d($,"messageflow-start",fe,Oe),stroke:Oe,strokeDasharray:"10, 11",strokeWidth:1.5});if(W.get("messageRef")){var lt=nt.getPointAtLength(nt.getTotalLength()/2),Vt=i.getScaledPath("MESSAGE_FLOW_MARKER",{abspos:{x:lt.x,y:lt.y}}),St={strokeWidth:1};q.get("messageVisibleKind")==="initiating"?(St.fill=fe,St.stroke=Oe):(St.fill=Oe,St.stroke=fe);var nn=x($,Vt,St),An=W.get("messageRef"),Vn=An.get("name"),Tt=ee($,Vn,{align:"center-top",fitBox:!0,style:{fill:Oe}}),$t=nn.getBBox(),xn=Tt.getBBox(),vr=lt.x-xn.width/2,Qn=lt.y+$t.height/2+e2;_l(Tt,vr,Qn,0)}return nt},"bpmn:ParallelGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R),q=i.getScaledPath("GATEWAY_PARALLEL",{xScaleFactor:.6,yScaleFactor:.6,containerWidth:C.width,containerHeight:C.height,position:{mx:.46,my:.2}});return x($,q,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:Participant":function($,C,R={}){R=yt(R,["fill","stroke","width","height"]);var W=K($,C,R),q=ht(C),fe=En(C),Oe=_e(C),nt=Oe.get("name");if(q){var lt=fe?[{x:30,y:0},{x:30,y:ri(C,R)}]:[{x:0,y:30},{x:Ei(C,R),y:30}];y($,lt,{stroke:Be(C,c,R.stroke),strokeWidth:t2}),be($,nt,C,R)}else{var Vt=ks(C,R);fe||(Vt.height=Ei(C,R),Vt.width=ri(C,R));var St=ee($,nt,{box:Vt,align:"center-middle",style:{fill:Ts(C,l,c,R.stroke)}});if(!fe){var nn=-1*ri(C,R);_l(St,0,-nn,270)}}return Oe.get("participantMultiplicity")&&F("ParticipantMultiplicityMarker",$,C,R),W},"bpmn:ReceiveTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=_e(C),q=Re($,C,R),fe;return W.get("instantiate")?(h($,28,28,20*.22,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),fe=i.getScaledPath("TASK_TYPE_INSTANTIATING_SEND",{abspos:{x:7.77,y:9.52}})):fe=i.getScaledPath("TASK_TYPE_SEND",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:21,containerHeight:14,position:{mx:.3,my:.4}}),x($,fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),q},"bpmn:ScriptTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_SCRIPT",{abspos:{x:15,y:20}});return x($,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:SendTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_SEND",{xScaleFactor:1,yScaleFactor:1,containerWidth:21,containerHeight:14,position:{mx:.285,my:.357}});return x($,q,{fill:Be(C,c,R.stroke),stroke:ut(C,s,R.fill),strokeWidth:1}),W},"bpmn:SequenceFlow":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ut(C,s,R.fill),q=Be(C,c,R.stroke),fe=v($,C.waypoints,{markerEnd:d($,"sequenceflow-end",W,q),stroke:q}),Oe=_e(C),{source:nt}=C;if(nt){var lt=_e(nt);Oe.get("conditionExpression")&&M(lt,"bpmn:Activity")&&Ie(fe,{markerStart:d($,"conditional-flow-marker",W,q)}),lt.get("default")&&(M(lt,"bpmn:Gateway")||M(lt,"bpmn:Activity"))&&lt.get("default")===Oe&&Ie(fe,{markerStart:d($,"conditional-default-flow-marker",W,q)})}return fe},"bpmn:ServiceTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R);h($,10,10,{fill:ut(C,s,R.fill),stroke:"none",transform:"translate(6, 6)"});var q=i.getScaledPath("TASK_TYPE_SERVICE",{abspos:{x:12,y:18}});x($,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),h($,10,10,{fill:ut(C,s,R.fill),stroke:"none",transform:"translate(11, 10)"});var fe=i.getScaledPath("TASK_TYPE_SERVICE",{abspos:{x:17,y:22}});return x($,fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:StartEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=_e(C);q.get("isInterrupting")||(R={...R,strokeDasharray:"6"});var fe=U($,C,R);return W&&k(C,$,R),fe},"bpmn:SubProcess":function($,C,R={}){return ht(C)?R=yt(R,["fill","stroke","width","height"]):R=yt(R,["fill","stroke"]),J($,C,R)},"bpmn:Task":function($,C,R={}){return R=yt(R,["fill","stroke"]),Re($,C,R)},"bpmn:TextAnnotation":function($,C,R={}){R=yt(R,["fill","stroke"]);var{width:W,height:q}=ks(C,R),fe=m($,W,q,0,0,{fill:"none",stroke:"none"}),Oe=i.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:0,my:0}});x($,Oe,{stroke:Be(C,c,R.stroke)});var nt=_e(C),lt=nt.get("text")||"";return ee($,lt,{align:"left-top",box:ks(C,R),padding:Ra,style:{fill:Ts(C,l,c,R.stroke)}}),fe},"bpmn:Transaction":function($,C,R={}){ht(C)?R=yt(R,["fill","stroke","width","height"]):R=yt(R,["fill","stroke"]);var W=J($,C,{strokeWidth:1.5,...R}),q=n.style(["no-fill","no-events"],{stroke:Be(C,c,R.stroke),strokeWidth:1.5}),fe=ht(C);return fe||(R={}),m($,Ei(C,R),ri(C,R),Ml-Cl,Cl,q),W},"bpmn:UserTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=15,fe=12,Oe=i.getScaledPath("TASK_TYPE_USER_1",{abspos:{x:q,y:fe}});x($,Oe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:.5});var nt=i.getScaledPath("TASK_TYPE_USER_2",{abspos:{x:q,y:fe}});x($,nt,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:.5});var lt=i.getScaledPath("TASK_TYPE_USER_3",{abspos:{x:q,y:fe}});return x($,lt,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:.5}),W},label:function($,C,R={}){return ie($,C,R)}};this._drawPath=x,this._renderer=A}Ne($r,yo),$r.$inject=["config.bpmnRenderer","eventBus","styles","pathMap","canvas","textRenderer"],$r.prototype.canRender=function(e){return M(e,"bpmn:BaseElement")},$r.prototype.drawShape=function(e,t,n={}){var{type:i}=t,o=this._renderer(i);return o(e,t,n)},$r.prototype.drawConnection=function(e,t,n={}){var{type:i}=t,o=this._renderer(i);return o(e,t,n)},$r.prototype.getShapePath=function(e){return at(e)?td(e,n2):M(e,"bpmn:Event")?nb(e):M(e,"bpmn:Activity")?td(e,Ml):M(e,"bpmn:Gateway")?ZT(e):QT(e)};function yt(e,t=[]){return t.reduce((n,i)=>(e[i]&&(n[i]=e[i]),n),{})}var r2=0,a2={width:150,height:50};function s2(e){var t=e.split("-");return{horizontal:t[0]||"center",vertical:t[1]||"top"}}function c2(e){return mn(e)?Y({top:0,left:0,right:0,bottom:0},e):{top:e,left:e,right:e,bottom:e}}var nd=null;function l2(){return nd||(nd=document.createElement("canvas").getContext("2d")),nd}function u2(e){var t=[];return e.fontStyle&&t.push(e.fontStyle),e.fontVariant&&t.push(e.fontVariant),e.fontWeight&&t.push(e.fontWeight),e.fontStretch&&t.push(e.fontStretch),t.push(ib(e.fontSize)||"12px"),t.push(e.fontFamily||"sans-serif"),t.join(" ")}function ib(e){if(e!=null)return typeof e=="number"||/^-?\d+(\.\d+)?$/.test(e)?e+"px":e}function p2(e,t){var n=l2();if(!n)return{width:0,height:0};n.font=u2(t),"letterSpacing"in n&&(n.letterSpacing=ib(t.letterSpacing)||"0px");var i=e==="",o=i?"dummy":e.replace(/\s+$/,""),r=n.measureText(o);return{width:i?0:r.width,height:"fontBoundingBoxAscent"in r?r.fontBoundingBoxAscent+r.fontBoundingBoxDescent:r.actualBoundingBoxAscent+r.actualBoundingBoxDescent}}function f2(e,t,n){for(var i=e.shift(),o=i,r;;){if(r=p2(o,n),r.width=o?r.width:0,o===" "||o===""||r.width<Math.round(t)||o.length<2)return d2(e,o,i,r);o=g2(o,r.width,t)}}function d2(e,t,n,i){if(t.length<n.length){var o=n.slice(t.length).trim();e.unshift(o)}return{width:i.width,height:i.height,text:t}}var ob="­";function h2(e,t){var n=e.split(/(\s|-|\u00AD)/g),i,o=[],r=0;if(n.length>1)for(;i=n.shift();)if(i.length+r<t)o.push(i),r+=i.length;else{(i==="-"||i===ob)&&o.pop();break}var a=o[o.length-1];return a&&a===ob&&(o[o.length-1]="-"),o.join("")}function g2(e,t,n){var i=Math.max(e.length*(n/t),1),o=h2(e,i);return o||(o=e.slice(0,Math.max(Math.round(i-1),1))),o}function Al(e){this._config=Y({},{size:a2,padding:r2,style:{},align:"center-top"},e||{})}Al.prototype.createText=function(e,t){return this.layoutText(e,t).element},Al.prototype.getDimensions=function(e,t){return this.layoutText(e,t).dimensions},Al.prototype.layoutText=function(e,t){for(var n=Y({},this._config.size,t.box),i=Y({},this._config.style,t.style),o=s2(t.align||this._config.align),r=c2(t.padding!==void 0?t.padding:this._config.padding),a=t.fitBox||!1,s=m2(i),c=e.split(/\u00AD?\r?\n/),l=[],u=n.width-r.left-r.right;c.length;)l.push(f2(c,u,i));o.vertical==="middle"&&(r.top=r.bottom=0);var p=ni(l,function(m,w,y){return m+(s||w.height)},0)+r.top+r.bottom,f=ni(l,function(m,w,y){return w.width>m?w.width:m},0),d=r.top;o.vertical==="middle"&&(d+=(n.height-p)/2),d-=(s||l[0].height)/4;var g=He("text");Ie(g,i),V(l,function(m){var w;switch(d+=s||m.height,o.horizontal){case"left":w=r.left;break;case"right":w=(a?f:u)-r.right-m.width;break;default:w=Math.max(((a?f:u)-m.width)/2+r.left,0)}var y=He("tspan");Ie(y,{x:w,y:d}),y.textContent=m.text,tt(g,y)});var h={width:f,height:p};return{dimensions:h,element:g}};function m2(e){if("fontSize"in e&&"lineHeight"in e)return e.lineHeight*parseInt(e.fontSize,10)}var y2=12,v2=1.2,b2=40;function rb(e){var t=Y({fontFamily:"Arial, sans-serif",fontSize:y2,fontWeight:"normal",lineHeight:v2},e&&e.defaultStyle||{}),n=parseInt(t.fontSize,10)-1,i=Y({},t,{fontSize:n},e&&e.externalStyle||{}),o=new Al({style:t});this.getExternalLabelBounds=function(a,s){var c={width:Math.max(a.width,Nr.width),height:30},l=r(s,c,{style:i});return{x:Math.round(a.x+a.width/2-l.width/2),y:a.y,width:Math.ceil(l.width),height:Math.ceil(l.height)}},this.getTextAnnotationBounds=function(a,s){var c=r(s,a,{style:t,align:"left-top",padding:Ra});return{x:a.x,y:a.y,width:a.width,height:Math.max(b2,Math.round(c.height))}},this.getDimensions=function(a,s){return o.getDimensions(a,s||{})};function r(a,s,c){return o.getDimensions(a,Y({box:s},c))}this.createText=function(a,s){return o.createText(a,s||{})},this.getDefaultStyle=function(){return t},this.getExternalStyle=function(){return i}}rb.$inject=["config.textRenderer"];function x2(){this.pathMap={EVENT_MESSAGE:{d:"m {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}",height:36,width:36,heightElements:[6,14],widthElements:[10.5,21]},EVENT_SIGNAL:{d:"M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z",height:36,width:36,heightElements:[18],widthElements:[10,20]},EVENT_ESCALATION:{d:"M {mx},{my} l {e.x0},{e.y0} l -{e.x0},-{e.y1} l -{e.x0},{e.y1} Z",height:36,width:36,heightElements:[20,7],widthElements:[8]},EVENT_CONDITIONAL:{d:"M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z M {e.x2},{e.y3} l {e.x0},0 M {e.x2},{e.y4} l {e.x0},0 M {e.x2},{e.y5} l {e.x0},0 M {e.x2},{e.y6} l {e.x0},0 M {e.x2},{e.y7} l {e.x0},0 M {e.x2},{e.y8} l {e.x0},0 ",height:36,width:36,heightElements:[8.5,14.5,18,11.5,14.5,17.5,20.5,23.5,26.5],widthElements:[10.5,14.5,12.5]},EVENT_LINK:{d:"m {mx},{my} 0,{e.y0} -{e.x1},0 0,{e.y1} {e.x1},0 0,{e.y0} {e.x0},-{e.y2} -{e.x0},-{e.y2} z",height:36,width:36,heightElements:[4.4375,6.75,7.8125],widthElements:[9.84375,13.5]},EVENT_ERROR:{d:"m {mx},{my} {e.x0},-{e.y0} {e.x1},-{e.y1} {e.x2},{e.y2} {e.x3},-{e.y3} -{e.x4},{e.y4} -{e.x5},-{e.y5} z",height:36,width:36,heightElements:[.023,8.737,8.151,16.564,10.591,8.714],widthElements:[.085,6.672,6.97,4.273,5.337,6.636]},EVENT_CANCEL_45:{d:"m {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z",height:36,width:36,heightElements:[4.75,8.5],widthElements:[4.75,8.5]},EVENT_COMPENSATION:{d:"m {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x1},-{e.y2} {e.x2},-{e.y3} 0,{e.y1} -{e.x2},-{e.y3} z",height:36,width:36,heightElements:[6.5,13,.4,6.1],widthElements:[9,9.3,8.7]},EVENT_TIMER_WH:{d:"M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ",height:36,width:36,heightElements:[10,2],widthElements:[3,7]},EVENT_TIMER_LINE:{d:"M {mx},{my} m {e.x0},{e.y0} l -{e.x1},{e.y1} ",height:36,width:36,heightElements:[10,3],widthElements:[0,0]},EVENT_MULTIPLE:{d:"m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z",height:36,width:36,heightElements:[6.28099,12.56199],widthElements:[3.1405,9.42149,12.56198]},EVENT_PARALLEL_MULTIPLE:{d:"m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} -{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z",height:36,width:36,heightElements:[2.56228,7.68683],widthElements:[2.56228,7.68683]},GATEWAY_EXCLUSIVE:{d:"m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} {e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} {e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z",height:17.5,width:17.5,heightElements:[8.5,6.5312,-6.5312,-8.5],widthElements:[6.5,-6.5,3,-3,5,-5]},GATEWAY_PARALLEL:{d:"m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z",height:30,width:30,heightElements:[5,12.5],widthElements:[5,12.5]},GATEWAY_EVENT_BASED:{d:"m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z",height:11,width:11,heightElements:[-6,6,12,-12],widthElements:[9,-3,-12]},GATEWAY_COMPLEX:{d:"m {mx},{my} 0,{e.y0} -{e.x0},-{e.y1} -{e.x1},{e.y2} {e.x0},{e.y1} -{e.x2},0 0,{e.y3} {e.x2},0 -{e.x0},{e.y1} l {e.x1},{e.y2} {e.x0},-{e.y1} 0,{e.y0} {e.x3},0 0,-{e.y0} {e.x0},{e.y1} {e.x1},-{e.y2} -{e.x0},-{e.y1} {e.x2},0 0,-{e.y3} -{e.x2},0 {e.x0},-{e.y1} -{e.x1},-{e.y2} -{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z",height:17.125,width:17.125,heightElements:[4.875,3.4375,2.125,3],widthElements:[3.4375,2.125,4.875,3]},DATA_OBJECT_PATH:{d:"m 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0",height:61,width:51,heightElements:[10,50,60],widthElements:[10,40,50,60]},DATA_OBJECT_COLLECTION_PATH:{d:"m{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10",height:10,width:10,heightElements:[],widthElements:[]},DATA_ARROW:{d:"m 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z",height:61,width:51,heightElements:[],widthElements:[]},DATA_STORE:{d:"m {mx},{my} l 0,{e.y2} c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 l 0,-{e.y2} c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 m -{e.x2},{e.y0}c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0m -{e.x2},{e.y0}c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0",height:61,width:61,heightElements:[7,10,45],widthElements:[2,58,60]},TEXT_ANNOTATION:{d:"m {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0",height:30,width:10,heightElements:[30],widthElements:[10]},MARKER_SUB_PROCESS:{d:"m{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0",height:10,width:10,heightElements:[],widthElements:[]},MARKER_PARALLEL:{d:"m{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10",height:10,width:10,heightElements:[],widthElements:[]},MARKER_SEQUENTIAL:{d:"m{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0",height:10,width:10,heightElements:[],widthElements:[]},MARKER_COMPENSATION:{d:"m {mx},{my} 7,-5 0,10 z m 7.1,-0.3 6.9,-4.7 0,10 -6.9,-4.7 z",height:10,width:21,heightElements:[],widthElements:[]},MARKER_LOOP:{d:"m {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 -6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902",height:13.9,width:13.7,heightElements:[],widthElements:[]},MARKER_ADHOC:{d:"m {mx},{my} m 0.84461,2.64411 c 1.05533,-1.23780996 2.64337,-2.07882 4.29653,-1.97997996 2.05163,0.0805 3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 1.2775,-0.64078 1.7542,-1.17511 0,0.56023 0,1.12046 0,1.6807 -0.98706,0.96237996 -2.29792,1.62393996 -3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 -2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z",height:4,width:15,heightElements:[],widthElements:[]},TASK_TYPE_SEND:{d:"m {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}",height:14,width:21,heightElements:[6,14],widthElements:[10.5,21]},TASK_TYPE_SCRIPT:{d:"m {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z m -7,-12 l 5,0 m -4.5,3 l 4.5,0 m -3,3 l 5,0m -4,3 l 5,0",height:15,width:12.6,heightElements:[6,14],widthElements:[10.5,21]},TASK_TYPE_USER_1:{d:"m {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 -4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 zm -8,6 l 0,5.5 m 11,0 l 0,-5"},TASK_TYPE_USER_2:{d:"m {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 -2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 "},TASK_TYPE_USER_3:{d:"m {mx},{my} m -6.9,-3.80 c 0,0 2.25099998,-2.358 4.27399998,-1.177 2.024,1.181 4.221,1.537 4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 -4.20799998,3.36699999 -4.20699998,4.34799999 z"},TASK_TYPE_MANUAL:{d:"m {mx},{my} c 0.234,-0.01 5.604,0.008 8.029,0.004 0.808,0 1.271,-0.172 1.417,-0.752 0.227,-0.898 -0.334,-1.314 -1.338,-1.316 -2.467,-0.01 -7.886,-0.004 -8.108,-0.004 -0.014,-0.079 0.016,-0.533 0,-0.61 0.195,-0.042 8.507,0.006 9.616,0.002 0.877,-0.007 1.35,-0.438 1.353,-1.208 0.003,-0.768 -0.479,-1.09 -1.35,-1.091 -2.968,-0.002 -9.619,-0.013 -9.619,-0.013 v -0.591 c 0,0 5.052,-0.016 7.225,-0.016 0.888,-0.002 1.354,-0.416 1.351,-1.193 -0.006,-0.761 -0.492,-1.196 -1.361,-1.196 -3.473,-0.005 -10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 -0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 -1.516,1.253 -1.882,2.19 -0.37000002,0.95 -0.17,2.01 -0.166,2.979 0.004,0.718 -0.27300002,1.345 -0.055,2.063 0.629,2.087 2.425,3.312 4.859,3.318 4.6179995,0.014 9.2379995,-0.139 13.8569995,-0.158 0.755,-0.004 1.171,-0.301 1.182,-1.033 0.012,-0.754 -0.423,-0.969 -1.183,-0.973 -1.778,-0.01 -5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z"},TASK_TYPE_INSTANTIATING_SEND:{d:"m {mx},{my} l 0,8.4 l 12.6,0 l 0,-8.4 z l 6.3,3.6 l 6.3,-3.6"},TASK_TYPE_SERVICE:{d:"m {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 -1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 -0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 -1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 h -2.241173 l 0.0042,1.63124 c -0.353763,0.0736 -0.705369,0.17977 -1.049785,0.32371 -0.344415,0.14437 -0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z m 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z"},TASK_TYPE_SERVICE_FILL:{d:"m {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z"},TASK_TYPE_BUSINESS_RULE_HEADER:{d:"m {mx},{my} 0,4 20,0 0,-4 z"},TASK_TYPE_BUSINESS_RULE_MAIN:{d:"m {mx},{my} 0,12 20,0 0,-12 zm 0,8 l 20,0 m -13,-4 l 0,8"},MESSAGE_FLOW_MARKER:{d:"m {mx},{my} m -10.5 ,-7 l 0,14 l 21,0 l 0,-14 z l 10.5,6 l 10.5,-6"}},this.getRawPath=function(t){return this.pathMap[t].d},this.getScaledPath=function(t,n){var i=this.pathMap[t],o,r;n.abspos?(o=n.abspos.x,r=n.abspos.y):(o=n.containerWidth*n.position.mx,r=n.containerHeight*n.position.my);var a={};if(n.position){for(var s=n.containerHeight/i.height*n.yScaleFactor,c=n.containerWidth/i.width*n.xScaleFactor,l=0;l<i.heightElements.length;l++)a["y"+l]=i.heightElements[l]*s;for(var u=0;u<i.widthElements.length;u++)a["x"+u]=i.widthElements[u]*c}var p=S2(i.d,{mx:o,my:r,e:a});return p}}var w2=/\{([^{}]+)\}/g,_2=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;function E2(e,t,n){var i=n;return t.replace(_2,function(o,r,a,s,c){r=r||s,i&&(r in i&&(i=i[r]),typeof i=="function"&&c&&(i=i()))}),i=(i==null||i==n?e:i)+"",i}function S2(e,t){return String(e).replace(w2,function(n,i){return E2(n,i,t)})}const R2={__init__:["bpmnRenderer"],bpmnRenderer:["type",$r],textRenderer:["type",rb],pathMap:["type",x2]};function C2(e,t){return t=t||{},e.replace(/{([^}]+)}/g,function(n,i){return t[i]||"{"+i+"}"})}const Os={translate:["value",C2]};function Pl(e,t,n){return Y({id:e.id,type:e.$type,businessObject:e,di:t},n)}function M2(e,t,n){var i=e.waypoint;return!i||i.length<2?[Je(t),Je(n)]:i.map(function(o){return{x:o.x,y:o.y}})}function ab(e,t,n){return new Error(`element ${zn(t)} referenced by ${zn(e)}#${n} not yet drawn`)}function wo(e,t,n,i,o){this._eventBus=e,this._canvas=t,this._elementFactory=n,this._elementRegistry=i,this._textRenderer=o}wo.$inject=["eventBus","canvas","elementFactory","elementRegistry","textRenderer"],wo.prototype.add=function(e,t,n){var i,o,r;if(M(t,"bpmndi:BPMNPlane")){var a=M(e,"bpmn:SubProcess")?{id:e.id+"_plane"}:{};i=this._elementFactory.createRoot(Pl(e,t,a)),this._canvas.addRootElement(i)}else if(M(t,"bpmndi:BPMNShape")){var s=!ht(e,t),c=P2(e);o=n&&(n.hidden||n.collapsed);var l=t.bounds;i=this._elementFactory.createShape(Pl(e,t,{collapsed:s,hidden:o,x:Math.round(l.x),y:Math.round(l.y),width:Math.round(l.width),height:Math.round(l.height),isFrame:c})),M(e,"bpmn:BoundaryEvent")&&this._attachBoundary(e,i),M(e,"bpmn:Lane")&&(r=0),M(e,"bpmn:DataStoreReference")&&(A2(n,Je(l))||(n=this._canvas.findRoot(n))),this._canvas.addShape(i,n,r)}else if(M(t,"bpmndi:BPMNEdge")){var u=this._getSource(e),p=this._getTarget(e);o=n&&(n.hidden||n.collapsed),i=this._elementFactory.createConnection(Pl(e,t,{hidden:o,source:u,target:p,waypoints:M2(t,u,p)})),M(e,"bpmn:DataAssociation")&&(n=this._canvas.findRoot(n)),this._canvas.addConnection(i,n,r)}else throw new Error(`unknown di ${zn(t)} for element ${zn(e)}`);return Zo(e)&&vi(i)&&this.addLabel(e,t,i),this._eventBus.fire("bpmnElement.added",{element:i}),i},wo.prototype._attachBoundary=function(e,t){var n=e.attachedToRef;if(!n)throw new Error(`missing ${zn(e)}#attachedToRef`);var i=this._elementRegistry.get(n.id),o=i&&i.attachers;if(!i)throw ab(e,n,"attachedToRef");t.host=i,o||(i.attachers=o=[]),o.indexOf(t)===-1&&o.push(t)},wo.prototype.addLabel=function(e,t,n){var i,o,r;return i=VT(t,n),o=vi(n),o&&(i=this._textRenderer.getExternalLabelBounds(i,o)),r=this._elementFactory.createLabel(Pl(e,t,{id:e.id+"_label",labelTarget:n,type:"label",hidden:n.hidden||!vi(n),x:Math.round(i.x),y:Math.round(i.y),width:Math.round(i.width),height:Math.round(i.height)})),this._canvas.addShape(r,n.parent)},wo.prototype._getConnectedElement=function(e,t){var n,i,o=e.$type;if(i=e[t+"Ref"],t==="source"&&o==="bpmn:DataInputAssociation"&&(i=i&&i[0]),(t==="source"&&o==="bpmn:DataOutputAssociation"||t==="target"&&o==="bpmn:DataInputAssociation")&&(i=e.$parent),n=i&&this._getElement(i),n)return n;throw i?ab(e,i,t+"Ref"):new Error(`${zn(e)}#${t} Ref not specified`)},wo.prototype._getSource=function(e){return this._getConnectedElement(e,"source")},wo.prototype._getTarget=function(e){return this._getConnectedElement(e,"target")},wo.prototype._getElement=function(e){return this._elementRegistry.get(e.id)};function A2(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}function P2(e){return M(e,"bpmn:Group")}const sb={__depends__:[R2,{__depends__:[Os],bpmnImporter:["type",wo]}]};function Ds(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Gi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function id(e){return Math.log(e)/Math.log(10)}var T2=1e3;function we(e){this._eventBus=e}we.$inject=["eventBus"];function k2(e,t){return function(n){return e.call(t||null,n.context,n.command,n)}}we.prototype.on=function(e,t,n,i,o,r){if((_n(t)||Qe(t))&&(r=o,o=i,i=n,n=t,t=null),_n(n)&&(r=o,o=i,i=n,n=T2),mn(o)&&(r=o,o=!1),!_n(i))throw new Error("handlerFn must be a function");Ze(e)||(e=[e]);var a=this._eventBus;V(e,function(s){var c=["commandStack",s,t].filter(function(l){return l}).join(".");a.on(c,n,o?k2(i,r):i,r)})},we.prototype.canExecute=_o("canExecute"),we.prototype.preExecute=_o("preExecute"),we.prototype.preExecuted=_o("preExecuted"),we.prototype.execute=_o("execute"),we.prototype.executed=_o("executed"),we.prototype.postExecute=_o("postExecute"),we.prototype.postExecuted=_o("postExecuted"),we.prototype.revert=_o("revert"),we.prototype.reverted=_o("reverted");function _o(e){return function(n,i,o,r,a){(_n(n)||Qe(n))&&(a=r,r=o,o=i,i=n,n=null),this.on(n,e,i,o,r,a)}}var od=["top","bottom","left","right"],Tl=10;function rd(e,t){we.call(this,e),this.postExecuted(["connection.create","connection.layout","connection.updateWaypoints"],function(o){var r=o.context,a=r.connection,s=a.source,c=a.target,l=r.hints||{};l.createElementsBehavior!==!1&&(n(s),n(c))}),this.postExecuted(["label.create"],function(o){var r=o.context,a=r.shape,s=r.hints||{};s.createElementsBehavior!==!1&&n(a.labelTarget)}),this.postExecuted(["elements.create"],function(o){var r=o.context,a=r.elements,s=r.hints||{};s.createElementsBehavior!==!1&&a.forEach(function(c){n(c)})});function n(o){if(Rl(o)&&!Ot(o)){var r=L2(o);r&&i(o,r)}}function i(o,r){var a=Je(o),s=o.label,c=Je(s);if(s.parent){var l=qe(o),u;switch(r){case"top":u={x:a.x,y:l.top-Tl-s.height/2};break;case"left":u={x:l.left-Tl-s.width/2,y:a.y};break;case"bottom":u={x:a.x,y:l.bottom+Tl+s.height/2};break;case"right":u={x:l.right+Tl+s.width/2,y:a.y};break}var p=Gi(u,c);t.moveShape(s,p)}}}Ne(rd,we),rd.$inject=["eventBus","modeling"];function O2(e){var t=e.host,n=Je(e),i=On(n,t),o;i.indexOf("-")>=0?o=i.split("-"):o=[i];var r=od.filter(function(a){return o.indexOf(a)===-1});return r}function D2(e){var t=Je(e),n=[].concat(e.incoming.map(function(i){return i.waypoints[i.waypoints.length-2]}),e.outgoing.map(function(i){return i.waypoints[1]})).map(function(i){return cb(t,i)});return n}function L2(e){var t=Je(e.label),n=Je(e),i=cb(n,t);if(I2(i)){var o=D2(e);if(e.host){var r=O2(e);o=o.concat(r)}var a=od.filter(function(s){return o.indexOf(s)===-1});return a.indexOf(i)!==-1?On(e.label,e)!=="intersect"?void 0:i:a[0]}}function cb(e,t){return On(t,e,5)}function I2(e){return od.indexOf(e)!==-1}function ad(e){we.call(this,e),this.preExecute("shape.append",function(t){var n=t.source,i=t.shape;t.position||(M(i,"bpmn:TextAnnotation")?t.position={x:n.x+n.width/2+75,y:n.y-50-i.height/2}:t.position={x:n.x+n.width+80+i.width/2,y:n.y+n.height/2})},!0)}Ne(ad,we),ad.$inject=["eventBus"];var B2=1500;function sd(e,t,n){e.invoke(we,this),this.preExecute("elements.delete",B2,function(o){var r=o.context,a=r.elements,s=i(a);s.length&&(r.elements=a.concat(s))}),t.on("shape.move.start",function(o){var r=o.context.shapes,a=i(r);a.length&&(o.context.shapes=r.concat(a))});function i(o){var r=ct(o,l=>M(l,"bpmn:Participant")||M(l,"bpmn:SubProcess"));if(!r.length)return[];var a=n.getRootElement(),s=new Set(a.children.filter(l=>M(l,"bpmn:Artifact"))),c=new Set;return V(r,l=>{const u=new Set(aa(xa(Array.from(s),cn(l))));c=c.union(u),s=s.difference(u)}),Array.from(c)}}Ne(sd,we),sd.$inject=["injector","eventBus","canvas"];function cd(e,t){e.invoke(we,this),this.postExecute("shape.move",function(n){var i=n.newParent,o=n.shape,r=ct(o.incoming.concat(o.outgoing),function(a){return M(a,"bpmn:Association")});V(r,function(a){t.moveConnection(a,{x:0,y:0},i)})},!0)}Ne(cd,we),cd.$inject=["injector","modeling"];function Ma(e,t){for(ei(t)&&(t=[t]);e=e.parent;)if(st(e,t))return e;return null}function lb(e,t){var n=Ma(e,"bpmn:Process");if(n)return!0;var i=["bpmn:Participant","bpmn:Lane"];if(n=Ma(e,i),n)return En(n);if(st(e,i))return En(e);var o;for(o=_e(e);o&&!M(o,"bpmn:Process");o=o.$parent);if(!t)return!0;var r=t.find(function(a){var s=_e(a);return s&&s.get("processRef")===o});return r?En(r):!0}var ub=500;function kl(e,t){t.invoke(we,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",ub,function(i){var o=i.elements;o=o.filter(function(r){var a=r.host;return pb(r,a)}),o.length===1&&o.map(function(r){return o.indexOf(r)}).forEach(function(r){var a=o[r];i.elements[r]=n._replaceShape(o[r],a)})},!0),this.preExecute("elements.move",ub,function(i){var o=i.shapes,r=i.newHost;if(o.length===1){var a=o[0];pb(a,r)&&(i.shapes=[n._replaceShape(a,r)])}},!0)}kl.$inject=["bpmnReplace","injector"],Ne(kl,we),kl.prototype._replaceShape=function(e,t){var n=N2(e),i={type:"bpmn:BoundaryEvent",host:t};return n&&(i.eventDefinitionType=n.$type),this._bpmnReplace.replaceElement(e,i,{layoutConnection:!1})};function N2(e){var t=_e(e),n=t.eventDefinitions;return n&&n[0]}function pb(e,t){return!at(e)&&st(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}function ld(e,t){we.call(this,e);function n(i){return ct(i.attachers,function(o){return M(o,"bpmn:BoundaryEvent")})}this.postExecute("connection.create",function(i){var o=i.context.source,r=i.context.target,a=n(r);M(o,"bpmn:EventBasedGateway")&&M(r,"bpmn:ReceiveTask")&&a.length>0&&t.removeElements(a)}),this.postExecute("connection.reconnect",function(i){var o=i.context.oldSource,r=i.context.newSource;M(o,"bpmn:Gateway")&&M(r,"bpmn:EventBasedGateway")&&V(r.outgoing,function(a){var s=a.target,c=n(s);M(s,"bpmn:ReceiveTask")&&c.length>0&&t.removeElements(c)})})}ld.$inject=["eventBus","modeling"],Ne(ld,we);function fb(e){return e.create("bpmn:Category")}function $2(e){return e.create("bpmn:CategoryValue")}function db(e,t){var n=t.get("categoryValueRef");return n||(n=t.categoryValueRef=$2(e)),n.$parent||(n.$parent=fb(e)),n}function F2(e,t,n){return on(t.get("categoryValue"),e),e.$parent=t,on(n.get("rootElements"),t),t.$parent=n,e}function j2(e){var t=e.$parent;return t&&(tn(t.get("categoryValue"),e),e.$parent=null),e}function H2(e){var t=e.$parent;return t&&(tn(t.get("rootElements"),e),e.$parent=null),e}var z2=500;function ud(e,t,n){n.invoke(we,this);function i(c){return t.filter(function(l){return M(l,"bpmn:Group")&&!l.labelTarget}).map(_e).filter(function(l){return l!==c})}function o(c,l){return i(l).some(function(u){return u.get("categoryValueRef")===c})}function r(c,l){return i(l).some(function(u){var p=u.get("categoryValueRef");return p&&p.$parent===c})}function a(c,l){c&&l&&F2(c,l,e.getDefinitions())}function s(c,l,u){l&&!r(l,u)&&H2(l),c&&!o(c,u)&&j2(c)}this.executed(["shape.create","label.create"],function(c){var l=c.labelTarget||c.shape;!M(l,"bpmn:Group")||l.labelTarget||a(c.categoryValue,c.category)},!0),this.reverted(["shape.create","label.create"],function(c){var l=c.labelTarget||c.shape;!M(l,"bpmn:Group")||l.labelTarget||s(c.categoryValue,c.category,_e(l))},!0),this.executed(["shape.move","shape.resize"],z2,function(c){a(c.categoryValue,c.category)},!0),this.reverted(["shape.move","shape.resize"],function(c){var l=c.shape;c.categoryValue&&s(c.categoryValue,c.category,_e(l))},!0),this.executed("group.updateRefs",function(c){hb(c).forEach(function(l){a(l.categoryValue,l.category)})},!0),this.reverted("group.updateRefs",function(c){hb(c).forEach(function(l){s(l.categoryValue,l.category,_e(l.groupShape))})},!0),this.executed("shape.delete",function(c){var l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||s(c.categoryValue,c.category,_e(l))},!0),this.reverted("shape.delete",function(c){var l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||a(c.categoryValue,c.category)},!0)}ud.$inject=["bpmnjs","elementRegistry","injector"],Ne(ud,we);function hb(e){var t;return((t=e.updates)==null?void 0:t.groups)||[]}function pd(e,t,n){we.call(this,e),this.preExecute("shape.replace",s,!0),this.postExecuted("shape.replace",c,!0),this.preExecute("connection.create",o,!0),this.postExecuted("connection.delete",i,!0),this.postExecuted("connection.reconnect",r,!0),this.postExecuted("element.updateProperties",a,!0);function i(m){const w=m.source,y=m.target;Aa(w)&&Ls(y)&&u(y)}function o(m){const w=m.connection,y=m.source,v=m.target;Aa(y)&&Ol(v)&&(l(v),f(y,[w]))}function r(m){const w=m.newTarget,y=m.oldSource,v=m.oldTarget;if(v!==w){const x=y;Ls(v)&&u(v),Aa(x)&&Ol(w)&&l(w)}}function a(m){const{element:w}=m;Ls(w)?(p(w),d(w)):Ol(w)&&g(w)}function s(m){const{newData:w,oldShape:y}=m;if(Aa(m.oldShape)&&w.eventDefinitionType!=="bpmn:CompensateEventDefinition"||w.type!=="bpmn:BoundaryEvent"){const v=y.outgoing.find(({target:x})=>Ls(x));v&&v.target&&(m._connectionTarget=v.target)}else if(!Aa(m.oldShape)&&w.eventDefinitionType==="bpmn:CompensateEventDefinition"&&w.type==="bpmn:BoundaryEvent"){const v=y.outgoing.find(({target:x})=>Ol(x));v&&v.target&&(m._connectionTarget=v.target),h(y)}}function c(m){const{_connectionTarget:w,newShape:y}=m;w&&t.connect(y,w)}function l(m){t.updateProperties(m,{isForCompensation:!0})}function u(m){t.updateProperties(m,{isForCompensation:void 0})}function p(m){for(const w of m.incoming)n.canConnect(w.source,m)||t.removeConnection(w);for(const w of m.outgoing)n.canConnect(m,w.target)||t.removeConnection(w)}function f(m,w){m.outgoing.filter(x=>M(x,"bpmn:Association")).filter(x=>Ls(x.target)&&!w.includes(x)).forEach(x=>t.removeConnection(x))}function d(m){const w=m.attachers.slice();w.length&&t.removeElements(w)}function g(m){const w=m.incoming.filter(y=>Aa(y.source));t.removeElements(w)}function h(m){const w=m.outgoing.filter(y=>M(y,"bpmn:SequenceFlow"));t.removeElements(w)}}Ne(pd,we),pd.$inject=["eventBus","modeling","bpmnRules"];function Ls(e){const t=_e(e);return t&&t.get("isForCompensation")}function Aa(e){return e&&M(e,"bpmn:BoundaryEvent")&&Sa(e,"bpmn:CompensateEventDefinition")}function Ol(e){return e&&M(e,"bpmn:Activity")&&!Gn(e)}function fd(e){e.invoke(we,this),this.preExecute("shape.create",1500,function(t){var n=t.context,i=n.parent,o=n.shape;M(i,"bpmn:Lane")&&!M(o,"bpmn:Lane")&&(n.parent=Ma(i,"bpmn:Participant"))})}fd.$inject=["injector"],Ne(fd,we);function dd(e,t){we.call(this,e),this.preExecute("shape.create",function(n){var a;var i=n.context,o=i.shape;if(M(o,"bpmn:DataObjectReference")&&o.type!=="label"){var r=t.create("bpmn:DataObject");r.isCollection=((a=o.businessObject.dataObjectRef)==null?void 0:a.isCollection)||!1,o.businessObject.dataObjectRef=r}})}dd.$inject=["eventBus","bpmnFactory"],Ne(dd,we);var hd=20,gd=20,gb=30,Dl=2e3;function md(e,t,n){we.call(this,t),t.on(["create.start","shape.move.start"],Dl,function(o){var r=o.context,a=r.shape,s=e.getRootElement();if(!(!M(a,"bpmn:Participant")||!M(s,"bpmn:Process")||!s.children.length)){var c=s.children.filter(function(p){return!M(p,"bpmn:Group")&&!at(p)&&!Ot(p)});if(c.length){var l=cn(c),u=G2(a,l);Y(a,u),r.createConstraints=V2(a,l)}}}),t.on("create.start",Dl,function(o){var r=o.context,a=r.shape,s=e.getRootElement(),c=e.getGraphics(s);function l(u){u.element=s,u.gfx=c}M(a,"bpmn:Participant")&&M(s,"bpmn:Process")&&(t.on("element.hover",Dl,l),t.once("create.cleanup",function(){t.off("element.hover",l)}))});function i(){var o=e.getRootElement();return M(o,"bpmn:Collaboration")?o:n.makeCollaboration()}this.preExecute("elements.create",Dl,function(o){var r=o.elements,a=o.parent,s=W2(r),c;s&&M(a,"bpmn:Process")&&(o.parent=i(),c=o.hints=o.hints||{},c.participant=s,c.process=a,c.processRef=_e(s).get("processRef"))},!0),this.preExecute("shape.create",function(o){var r=o.parent,a=o.shape;M(a,"bpmn:Participant")&&M(r,"bpmn:Process")&&(o.parent=i(),o.process=r,o.processRef=_e(a).get("processRef"))},!0),this.execute("shape.create",function(o){var r=o.hints||{},a=o.process||r.process,s=o.shape,c=r.participant;a&&(!c||s===c)&&_e(s).set("processRef",_e(a))},!0),this.revert("shape.create",function(o){var r=o.hints||{},a=o.process||r.process,s=o.processRef||r.processRef,c=o.shape,l=r.participant;a&&(!l||c===l)&&_e(c).set("processRef",s)},!0),this.postExecute("shape.create",function(o){var r=o.hints||{},a=o.process||o.hints.process,s=o.shape,c=r.participant;if(a){var l=a.children.slice();c?s===c&&n.moveElements(l,{x:0,y:0},c):n.moveElements(l,{x:0,y:0},s)}},!0)}md.$inject=["canvas","eventBus","modeling"],Ne(md,we);function G2(e,t){t={width:t.width+hd*2+gb,height:t.height+gd*2};var n=Math.max(e.width,t.width),i=Math.max(e.height,t.height);return{x:-n/2,y:-i/2,width:n,height:i}}function V2(e,t){return t=qe(t),{bottom:t.top+e.height/2-gd,left:t.right-e.width/2+hd,top:t.bottom-e.height/2+gd,right:t.left+e.width/2-hd-gb}}function W2(e){return It(e,function(t){return M(t,"bpmn:Participant")})}var mb="__targetRef_placeholder";function yd(e,t){we.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],yb(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],yb(r));function n(a,s,c){var l=a.get("dataInputAssociations");return It(l,function(u){return u!==c&&u.targetRef===s})}function i(a,s){var c=a.get("properties"),l=It(c,function(u){return u.name===mb});return!l&&s&&(l=t.create("bpmn:Property",{name:mb}),on(c,l)),l}function o(a,s){var c=i(a);c&&(n(a,c,s)||tn(a.get("properties"),c))}function r(a){var s=a.context,c=s.connection,l=c.businessObject,u=c.target,p=u&&u.businessObject,f=s.newTarget,d=f&&f.businessObject,g=s.oldTarget||s.target,h=g&&g.businessObject,m=c.businessObject,w;h&&h!==p&&o(h,l),d&&d!==p&&o(d,l),p?(w=i(p,!0),m.targetRef=w):m.targetRef=null}}yd.$inject=["eventBus","bpmnFactory"],Ne(yd,we);function yb(e){return function(t){var n=t.context,i=n.connection;if(M(i,"bpmn:DataInputAssociation"))return e(t)}}function Ll(e){this._bpmnUpdater=e}Ll.$inject=["bpmnUpdater"],Ll.prototype.execute=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.newSemanticParent,o=e.newDiParent;return e.oldSemanticParent=t.$parent,e.oldDiParent=n.$parent,this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,o),[]},Ll.prototype.revert=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.oldSemanticParent,o=e.oldDiParent;return this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,o),[]};function vd(e,t,n,i){we.call(this,i),t.registerHandler("dataStore.updateContainment",Ll);function o(){return n.filter(function(s){return M(s,"bpmn:Participant")&&_e(s).processRef})[0]}function r(s){return s.children.filter(function(c){return M(c,"bpmn:DataStoreReference")&&!c.labelTarget})}function a(s,c){var l=s.businessObject||s;if(c=c||o(),c){var u=c.businessObject||c;t.execute("dataStore.updateContainment",{dataStoreBo:l,dataStoreDi:mt(s),newSemanticParent:u.processRef||u,newDiParent:mt(c)})}}this.preExecute("shape.create",function(s){var c=s.context,l=c.shape;M(l,"bpmn:DataStoreReference")&&l.type!=="label"&&(c.hints||(c.hints={}),c.hints.autoResize=!1)}),this.preExecute("elements.move",function(s){var c=s.context,l=c.shapes,u=l.filter(function(p){return M(p,"bpmn:DataStoreReference")});u.length&&(c.hints||(c.hints={}),c.hints.autoResize=l.filter(function(p){return!M(p,"bpmn:DataStoreReference")}))}),this.postExecute("shape.create",function(s){var c=s.context,l=c.shape,u=l.parent;M(l,"bpmn:DataStoreReference")&&l.type!=="label"&&M(u,"bpmn:Collaboration")&&a(l)}),this.postExecute("shape.move",function(s){var c=s.context,l=c.shape,u=c.oldParent,p=l.parent;if(!M(u,"bpmn:Collaboration")&&M(l,"bpmn:DataStoreReference")&&l.type!=="label"&&M(p,"bpmn:Collaboration")){var f=M(u,"bpmn:Participant")?u:q2(u,"bpmn:Participant");a(l,f)}}),this.postExecute("shape.delete",function(s){var c=s.context,l=c.shape,u=e.getRootElement();st(l,["bpmn:Participant","bpmn:SubProcess"])&&M(u,"bpmn:Collaboration")&&r(u).filter(function(p){return U2(p,l)}).forEach(function(p){a(p)})}),this.postExecute("canvas.updateRoot",function(s){var c=s.context,l=c.oldRoot,u=c.newRoot,p=r(l);p.forEach(function(f){M(u,"bpmn:Process")&&a(f,u)})})}vd.$inject=["canvas","commandStack","elementRegistry","eventBus"],Ne(vd,we);function U2(e,t){for(var n=e.businessObject||e,i=t.businessObject||t;n.$parent;){if(n.$parent===i.processRef||i)return!0;n=n.$parent}return!1}function q2(e,t){for(;e.parent;){if(M(e.parent,t))return e.parent;e=e.parent}}var Il=Math.max,Bl=Math.min,Y2=20;function vb(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function K2(e,t,n){var i=n.x,o=n.y,r={x:e.x,y:e.y,width:e.width,height:e.height};return t.indexOf("n")!==-1?(r.y=e.y+o,r.height=e.height-o):t.indexOf("s")!==-1&&(r.height=e.height+o),t.indexOf("e")!==-1?r.width=e.width+i:t.indexOf("w")!==-1&&(r.x=e.x+i,r.width=e.width-i),r}function X2(e,t){return{x:e.x+(t.left||0),y:e.y+(t.top||0),width:e.width-(t.left||0)+(t.right||0),height:e.height-(t.top||0)+(t.bottom||0)}}function Nl(e,t,n){var i=t[e],o=n.min&&n.min[e],r=n.max&&n.max[e];return Qe(o)&&(i=(/top|left/.test(e)?Bl:Il)(i,o)),Qe(r)&&(i=(/top|left/.test(e)?Il:Bl)(i,r)),i}function Z2(e,t){if(!t)return e;var n=qe(e);return bl({top:Nl("top",n,t),right:Nl("right",n,t),bottom:Nl("bottom",n,t),left:Nl("left",n,t)})}function Q2(e,t,n,i){var o=qe(t),r={top:/n/.test(e)?o.bottom-n.height:o.top,left:/w/.test(e)?o.right-n.width:o.left,bottom:/s/.test(e)?o.top+n.height:o.bottom,right:/e/.test(e)?o.left+n.width:o.right},a=i?qe(i):r,s={top:Bl(r.top,a.top),left:Bl(r.left,a.left),bottom:Il(r.bottom,a.bottom),right:Il(r.right,a.right)};return bl(s)}function Is(e,t){return typeof e<"u"?e:Y2}function J2(e,t){var n,i,o,r;return typeof t=="object"?(n=Is(t.left),i=Is(t.right),o=Is(t.top),r=Is(t.bottom)):n=i=o=r=Is(t),{x:e.x-n,y:e.y-o,width:e.width+n+i,height:e.height+o+r}}function ek(e){return!(e.waypoints||e.type==="label")}function bb(e,t){var n;if(e.length===void 0?n=ct(e.children,ek):n=e,n.length)return J2(cn(n),t)}var Qo=Math.abs;function tk(e,t){return vb(qe(t),qe(e))}var nk=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],Si=30;function $l(e,t){return t=t||[],e.children.filter(function(n){M(n,"bpmn:Lane")&&($l(n,t),t.push(n))}),t}function Jo(e){return e.children.filter(function(t){return M(t,"bpmn:Lane")})}function Ri(e){return Ma(e,nk)||e}function ik(e,t){var n=Ri(e),i=M(n,"bpmn:Process")?[]:[n],o=$l(n,i),r=qe(e),a=qe(t),s=tk(e,t),c=[],l=En(e);return o.forEach(function(u){if(u!==e){var p=l?0:s.top,f=l?s.right:0,d=l?0:s.bottom,g=l?s.left:0,h=qe(u);s.top&&(Qo(h.bottom-r.top)<10&&(d=a.top-h.bottom),Qo(h.top-r.top)<5&&(p=a.top-h.top)),s.left&&(Qo(h.right-r.left)<10&&(f=a.left-h.right),Qo(h.left-r.left)<5&&(g=a.left-h.left)),s.bottom&&(Qo(h.top-r.bottom)<10&&(p=a.bottom-h.top),Qo(h.bottom-r.bottom)<5&&(d=a.bottom-h.bottom)),s.right&&(Qo(h.left-r.right)<10&&(g=a.right-h.left),Qo(h.right-r.right)<5&&(f=a.right-h.right)),(p||f||d||g)&&c.push({shape:u,newBounds:X2(u,{top:p,right:f,bottom:d,left:g})})}}),c}var ok=500;function bd(e,t){we.call(this,e);function n(i,o){var r=En(i),a=Jo(o),s=[],c=[],l=[],u=[];if(Br(a,function(m){return r?m.y>i.y?c.push(m):s.push(m):m.x>i.x?u.push(m):l.push(m),m.children}),!!a.length){var p;r?c.length&&s.length?p=i.height/2:p=i.height:u.length&&l.length?p=i.width/2:p=i.width;var f,d,g,h;s.length&&(f=t.calculateAdjustments(s,"y",p,i.y-10),t.makeSpace(f.movingShapes,f.resizingShapes,{x:0,y:p},"s")),c.length&&(d=t.calculateAdjustments(c,"y",-p,i.y+i.height+10),t.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:-p},"n")),l.length&&(g=t.calculateAdjustments(l,"x",p,i.x-10),t.makeSpace(g.movingShapes,g.resizingShapes,{x:p,y:0},"e")),u.length&&(h=t.calculateAdjustments(u,"x",-p,i.x+i.width+10),t.makeSpace(h.movingShapes,h.resizingShapes,{x:-p,y:0},"w"))}}this.postExecuted("shape.delete",ok,function(i){var o=i.context,r=o.hints,a=o.shape,s=o.oldParent;M(a,"bpmn:Lane")&&(r&&r.nested||n(a,s))})}bd.$inject=["eventBus","spaceTool"],Ne(bd,we);var xb=500;function Fl(e,t){t.invoke(we,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",xb,function(i){var o=i.elements;o.filter(function(r){var a=r.host;return wb(r,a)}).map(function(r){return o.indexOf(r)}).forEach(function(r){i.elements[r]=n._replaceShape(o[r])})},!0),this.preExecute("elements.move",xb,function(i){var o=i.shapes,r=i.newHost;o.forEach(function(a,s){var c=a.host;wb(a,ak(o,c)?c:r)&&(o[s]=n._replaceShape(a))})},!0)}Fl.$inject=["bpmnReplace","injector"],Ne(Fl,we),Fl.prototype._replaceShape=function(e){var t=rk(e),n;return t?n={type:"bpmn:IntermediateCatchEvent",eventDefinitionType:t.$type}:n={type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,n,{layoutConnection:!1})};function rk(e){var t=_e(e),n=t.eventDefinitions;return n&&n[0]}function wb(e,t){return!at(e)&&M(e,"bpmn:BoundaryEvent")&&!t}function ak(e,t){return e.indexOf(t)!==-1}var jl=Math.round,sk=Math.max;function ck(e,t){var n=e.x,i=e.y;return[["M",n,i],["m",0,-t],["a",t,t,0,1,1,0,2*t],["a",t,t,0,1,1,0,-2*t],["z"]]}function lk(e){var t=[];return e.forEach(function(n,i){t.push([i===0?"M":"L",n.x,n.y])}),t}var _b=10;function uk(e,t){var n,i;for(n=0;i=e[n];n++)if(Rs(i,t)<=_b)return{point:e[n],bendpoint:!0,index:n};return null}function pk(e,t){var n=Mv(ck(t,_b),lk(e)),i=n[0],o=n[n.length-1],r;return i?i!==o?i.segment2!==o.segment2?(r=sk(i.segment2,o.segment2)-1,{point:e[r],bendpoint:!0,index:r}):{point:{x:jl(i.x+o.x)/2,y:jl(i.y+o.y)/2},index:i.segment2}:{point:{x:jl(i.x),y:jl(i.y)},index:i.segment2}:null}function xd(e,t){return uk(e,t)||pk(e,t)}function wd(e,t,n){we.call(this,e);function i(o,r,a){var s=r.waypoints,c,l,u,p,f,d,g,h=o.outgoing.slice(),m=o.incoming.slice(),w;Qe(a.width)?w=Je(a):w=a;var y=xd(s,w);if(y){if(c=s.slice(0,y.index),l=s.slice(y.index+(y.bendpoint?1:0)),!c.length||!l.length)return;u=y.bendpoint?s[y.index]:w,(c.length===1||!Eb(o,c[c.length-1]))&&c.push(Sb(u)),(l.length===1||!Eb(o,l[0]))&&l.unshift(Sb(u))}p=r.source,f=r.target,t.canConnect(p,o,r)&&(n.reconnectEnd(r,o,c||w),d=r),t.canConnect(o,f,r)&&(d?g=n.connect(o,f,{type:r.type,waypoints:l}):(n.reconnectStart(r,o,l||w),g=r));var v=[].concat(d&&ct(m,function(x){return x.source===d.source})||[],g&&ct(h,function(x){return x.target===g.target})||[]);v.length&&n.removeElements(v)}this.preExecute("elements.move",function(o){var r=o.newParent,a=o.shapes,s=o.delta,c=a[0];if(!(!c||!r)){r&&r.waypoints&&(o.newParent=r=r.parent);var l=Je(c),u={x:l.x+s.x,y:l.y+s.y},p=It(r.children,function(f){var d=t.canInsert(a,f);return d&&xd(f.waypoints,u)});p&&(o.targetFlow=p,o.position=u)}},!0),this.postExecuted("elements.move",function(o){var r=o.shapes,a=o.targetFlow,s=o.position;a&&i(r[0],a,s)},!0),this.preExecute("shape.create",function(o){var r=o.parent,a=o.shape;t.canInsert(a,r)&&(o.targetFlow=r,o.parent=r.parent)},!0),this.postExecuted("shape.create",function(o){var r=o.shape,a=o.targetFlow,s=o.position;a&&i(r,a,s)},!0)}Ne(wd,we),wd.$inject=["eventBus","bpmnRules","modeling"];function Eb(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}function Sb(e){return Y({},e)}function _d(e,t){we.call(this,e),this.preExecuted("connection.create",function(n){var i=n.context,o=i.connection,r=i.source,a=i.target,s=i.hints;if(!(s&&s.createElementsBehavior===!1)&&Pa(o)){var c=[];M(r,"bpmn:EventBasedGateway")?c=a.incoming.filter(l=>l!==o&&Pa(l)):c=a.incoming.filter(l=>l!==o&&Pa(l)&&M(l.source,"bpmn:EventBasedGateway")),c.forEach(function(l){t.removeConnection(l)})}}),this.preExecuted("shape.replace",function(n){var i=n.context,o=i.newShape;if(M(o,"bpmn:EventBasedGateway")){var r=o.outgoing.filter(Pa).reduce(function(a,s){return a.includes(s.target)?a:a.concat(s.target)},[]);r.forEach(function(a){a.incoming.filter(Pa).forEach(function(s){const c=a.incoming.filter(Pa).filter(function(l){return l.source===o});(s.source!==o||c.length>1)&&t.removeConnection(s)})})}})}_d.$inject=["eventBus","modeling"],Ne(_d,we);function Pa(e){return M(e,"bpmn:SequenceFlow")}var Hl=1500,Rb=2e3;function Cb(e,t,n){t.on(["create.hover","create.move","create.out","create.end","shape.move.hover","shape.move.move","shape.move.out","shape.move.end"],Hl,function(i){var o=i.context,r=o.shape||i.shape,a=i.hover;M(a,"bpmn:Lane")&&!st(r,["bpmn:Lane","bpmn:Participant"])&&(i.hover=Ri(a),i.hoverGfx=e.getGraphics(i.hover));var s=n.getRootElement();a&&a!==s&&(r.labelTarget||st(r,["bpmn:Group","bpmn:TextAnnotation"]))&&(i.hover=s,i.hoverGfx=e.getGraphics(i.hover))}),t.on(["connect.hover","connect.out","connect.end","connect.cleanup","global-connect.hover","global-connect.out","global-connect.end","global-connect.cleanup"],Hl,function(i){var o=i.hover;M(o,"bpmn:Lane")&&(i.hover=Ri(o)||o,i.hoverGfx=e.getGraphics(i.hover))}),t.on(["bendpoint.move.hover"],Hl,function(i){var o=i.context,r=i.hover,a=o.type;M(r,"bpmn:Lane")&&/reconnect/.test(a)&&(i.hover=Ri(r)||r,i.hoverGfx=e.getGraphics(i.hover))}),t.on(["connect.start"],Hl,function(i){var o=i.context,r=o.start;M(r,"bpmn:Lane")&&(o.start=Ri(r)||r)}),t.on("shape.move.start",Rb,function(i){var o=i.shape;M(o,"bpmn:Lane")&&(i.shape=Ri(o)||o)}),t.on("spaceTool.move",Rb,function(i){var o=i.hover;o&&M(o,"bpmn:Lane")&&(i.hover=Ri(o))})}Cb.$inject=["elementRegistry","eventBus","canvas"];var Mb=770;function Ed(e,t,n,i){n.invoke(we,this);function o(s,c){var l=_e(s),u=c.categoryValue||l.categoryValueRef;u||(u=db(e,l));var p=c.category||u.$parent||fb(e);l.categoryValueRef=u,u.$parent=p,c.categoryValue=u,c.category=p}function r(s,c){var l=_e(s),u=c.categoryValue||l.categoryValueRef,p=c.category||u&&u.$parent;u&&(c.categoryValue=u,c.category=p,l.categoryValueRef=null)}this.execute("label.create",function(s){var c=s.context,l=c.labelTarget;M(l,"bpmn:Group")&&o(l,c)}),this.revert("label.create",function(s){var c=s.context,l=c.labelTarget;M(l,"bpmn:Group")&&r(l,c)}),this.execute("shape.delete",function(s){var c=s.context,l=c.shape,u=_e(l);if(!(!M(l,"bpmn:Group")||l.labelTarget)){var p=c.categoryValue=u.categoryValueRef;p&&(c.category=p.$parent,u.categoryValueRef=null)}}),this.reverted("shape.delete",function(s){var c=s.context,l=c.shape;if(!(!M(l,"bpmn:Group")||l.labelTarget)){var u=c.category,p=c.categoryValue,f=_e(l);p&&(f.categoryValueRef=p,p.$parent=u)}}),this.execute("shape.create",function(s){var c=s.context,l=c.shape,u=c.hints||{};!M(l,"bpmn:Group")||l.labelTarget||u.createElementsBehavior===!1&&!_e(l).categoryValueRef&&!c.categoryValue||o(l,c)}),this.reverted("shape.create",function(s){var c=s.context,l=c.shape,u=c.hints||{};!M(l,"bpmn:Group")||l.labelTarget||u.createElementsBehavior===!1&&!_e(l).categoryValueRef&&!c.categoryValue||r(l,c)}),this.executed(["shape.move","shape.resize"],function(s){var c=s.context,l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||_e(l).categoryValueRef||o(l,c)}),this.reverted(["shape.move","shape.resize"],function(s){var c=s.context,l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||!c.categoryValue||r(l,c)});function a(s,c){var l=e.create(s.$type);return i.copyElement(s,l,null,c)}t.on("copyPaste.copyElement",Mb,function(s){var c=s.descriptor,l=s.element;if(!(!M(l,"bpmn:Group")||l.labelTarget)){var u=_e(l);if(u.categoryValueRef){var p=u.categoryValueRef;c.categoryValue=a(p,!0),p.$parent&&(c.category=a(p.$parent,!0))}}}),t.on("copyPaste.pasteElement",Mb,function(s){var c=s.descriptor,l=c.businessObject,u=c.categoryValue,p=c.category;u&&(u=l.categoryValueRef=a(u)),p&&(u.$parent=a(p)),delete c.category,delete c.categoryValue})}Ed.$inject=["bpmnFactory","eventBus","injector","moddleCopy"],Ne(Ed,we);function Sd(e,t,n,i){var o,r,a,s,c;return o=(i.y-n.y)*(t.x-e.x)-(i.x-n.x)*(t.y-e.y),o==0?null:(r=e.y-n.y,a=e.x-n.x,c=(i.x-n.x)*r-(i.y-n.y)*a,s=c/o,{x:Math.round(e.x+s*(t.x-e.x)),y:Math.round(e.y+s*(t.y-e.y))})}function Ab(e){function t(i,o,r){var a={x:r.x,y:r.y-50},s={x:r.x-50,y:r.y},c=Sd(i,o,r,a),l=Sd(i,o,r,s),u;c&&l?Pb(c,r)>Pb(l,r)?u=l:u=c:u=c||l,i.original=u}function n(i){var o=i.waypoints;t(o[0],o[1],Je(i.source)),t(o[o.length-1],o[o.length-2],Je(i.target))}e.on("bpmnElement.added",function(i){var o=i.element;o.waypoints&&n(o)})}Ab.$inject=["eventBus"];function Pb(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Rd(e){we.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],function(n){var i=n.context.shape,o=_e(i),r=mt(i);if(st(o,t)){var a=r.get("isHorizontal");a===void 0&&(a=!0),r.set("isHorizontal",a)}})}Rd.$inject=["eventBus"],Ne(Rd,we);function Tb(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function kb(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function fk(e,t){return t?{x:Math.cos(t)*e.x-Math.sin(t)*e.y,y:Math.sin(t)*e.x+Math.cos(t)*e.y}:e}function dk(e,t,n){var i=[{n:e[0]-n[0],lambda:t[0]},{n:e[1]-n[1],lambda:t[1]}],o=i[0].n*t[0]+i[1].n*t[1],r=i[0].lambda*t[0]+i[1].lambda*t[1];return-o/r}function Cd(e,t){var n=t[0],i=t[1],o={x:i.x-n.x,y:i.y-n.y},r=dk([n.x,n.y],[o.x,o.y],[e.x,e.y]);return{x:n.x+r*o.x,y:n.y+r*o.y}}function Ob(e,t){var n=Cd(e,t),i={x:n.x-e.x,y:n.y-e.y};return Tb(i)}function Bs(e,t){return Tb({x:e.x-t.x,y:e.y-t.y})}var Db=Math.sqrt,Lb=Math.min,hk=Math.max,Ib=Math.abs;function Bb(e){return Math.pow(e,2)}function Ns(e,t){return Db(Bb(e.x-t.x)+Bb(e.y-t.y))}function gk(e,t){var n=0,i,o,r,a,s,c,l,u,p,f,d;for(n=0;n<t.length-1;n++){if(i=t[n],o=t[n+1],$b(i,o)?l=[i]:(r=Ns(e,i),a=Ns(e,o),c=Lb(r,a),l=mk(i,o,e,c)),l.length<1)throw new Error("expected between [1, 2] circle -> line intersections");l.length===1&&(u={type:"bendpoint",position:l[0],segmentIndex:n,bendpointIndex:$b(i,l[0])?n:n+1}),l.length===2&&(s=vk(l[0],l[1]),u={type:"segment",position:s,segmentIndex:n,relativeLocation:Ns(i,s)/Ns(i,o)}),p=Ns(u.position,e),(!d||f>p)&&(d=u,f=p)}return d}function mk(e,t,n,i){var o=t.x-e.x,r=t.y-e.y,a=n.x-e.x,s=n.y-e.y,c=o*o+r*r,l=o*a+r*s,u=a*a+s*s-i*i,p=l/c,f=u/c,d=p*p-f;if(d<0&&d>-1e-6&&(d=0),d<0)return[];var g=Db(d),h=-p+g,m=-p-g,w={x:e.x-o*h,y:e.y-r*h};if(d===0)return[w];var y={x:e.x-o*m,y:e.y-r*m};return[w,y].filter(function(v){return yk(v,e,t)})}function yk(e,t,n){return Nb(e.x,t.x,n.x)&&Nb(e.y,t.y,n.y)}function Nb(e,t,n){return e>=Lb(t,n)-zl&&e<=hk(t,n)+zl}function vk(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}var zl=.1;function $b(e,t){return Ib(e.x-t.x)<=zl&&Ib(e.y-t.y)<=zl}function bk(e,t,n,i){var o=n.segmentIndex,r=t.length-e.length;if(i.segmentMove){var a=i.segmentMove.segmentStartIndex,s=i.segmentMove.newSegmentStartIndex;return o===a?s:o>=s?o+r<s?s:o+r:o}if(i.bendpointMove){var c=i.bendpointMove.insert,l=i.bendpointMove.bendpointIndex,u;if(r===0)return o;if(o>=l&&(u=c?o+1:o-1),o<l&&(u=o,c&&n.type!=="bendpoint"&&l-1===o)){var p=jb(t,l);p<n.relativeLocation&&u++}return u}return r===0?o:i.connectionStart&&o===0?0:i.connectionEnd&&o===e.length-2?t.length-2:Math.floor((t.length-2)/2)}function Fb(e,t,n,i){var o=0,r=0,a={point:e,delta:{x:0,y:0}},s=gk(e,n),c=s.segmentIndex,l=bk(n,t,s,i);if(l<0||l>t.length-2||l===null)return a;var u=Hb(n,c),p=Hb(t,l),f=s.position,d=wk(u,f),g=xk(u,p);if(s.type==="bendpoint"){var h=t.length-n.length,m=s.bendpointIndex,w=n[m];if(t.indexOf(w)!==-1)return a;if(h===0){var y=t[m];return o=y.x-s.position.x,r=y.y-s.position.y,{delta:{x:o,y:r},point:{x:e.x+o,y:e.y+r}}}h<0&&m!==0&&m<n.length-1&&(d=jb(n,m))}var v={x:(p[1].x-p[0].x)*d+p[0].x,y:(p[1].y-p[0].y)*d+p[0].y},x=fk({x:e.x-f.x,y:e.y-f.y},g);return o=v.x+x.x-e.x,r=v.y+x.y-e.y,{point:bo(v),delta:bo({x:o,y:r})}}function jb(e,t){var n=Bs(e[t-1],e[t]),i=Bs(e[t],e[t+1]),o=n/(n+i);return o}function xk(e,t){var n=kb(e),i=kb(t);return i-n}function Hb(e,t){return[e[t],e[t+1]]}function wk(e,t){var n=Bs(e[0],e[1]),i=Bs(e[0],t);return n===0?0:i/n}function _k(e,t,n,i){var o=Je(e);return Fb(o,t,n,i).delta}function $s(e,t,n){var i=Ds(t),o=Ds(n),r=Gi(e,i),a={x:r.x*(n.width/t.width),y:r.y*(n.height/t.height)};return bo({x:o.x+a.x,y:o.y+a.y})}function zb(e,t,n){var i=Ds(e),o=Ds(t),r=Ds(n),a=Gi(e,i),s=Gi(i,o),c=Ek(i,t,n);if(c)return c;var l={x:s.x*(n.width/t.width),y:s.y*(n.height/t.height)},u={x:r.x+l.x,y:r.y+l.y};return bo({x:u.x+a.x-e.x,y:u.y+a.y-e.y})}function Ek(e,t,n){var i=qe(t),o=qe(n);if(Sk(i,o))return null;var r=On(t,e),a,s,c;if(r==="top")a={x:0,y:o.bottom-i.bottom};else if(r==="bottom")a={x:0,y:o.top-i.top};else if(r==="right")a={x:o.left-i.left,y:0};else if(r==="left")a={x:o.right-i.right,y:0};else return null;return s={x:e.x+a.x,y:e.y+a.y},c=On(n,s),c!==r?null:a}function Sk(e,t){return Rk(e,t)||Ck(e,t)}function Rk(e,t){return e.right!==t.right&&e.left!==t.left}function Ck(e,t){return e.top!==t.top&&e.bottom!==t.bottom}var Gb="name",Vb="text";function Md(e,t,n,i){we.call(this,e),this.postExecute("element.updateProperties",o),this.postExecute("element.updateModdleProperties",a=>{_e(a.context.element)===a.context.moddleElement&&o(a)});function o(a){var s=a.context,c=s.element,l=s.properties;if(Gb in l&&t.updateLabel(c,l[Gb]),Vb in l&&M(c,"bpmn:TextAnnotation")){var u=i.getTextAnnotationBounds({x:c.x,y:c.y,width:c.width,height:c.height},l[Vb]||"");t.updateLabel(c,l.text,u)}}this.postExecute(["shape.create","connection.create"],function(a){var s=a.context,c=s.hints||{};if(c.createElementsBehavior!==!1){var l=s.shape||s.connection;at(l)||!Zo(l)||vi(l)&&t.updateLabel(l,vi(l))}}),this.postExecute("shape.delete",function(a){var s=a.context,c=s.labelTarget,l=s.hints||{};c&&l.unsetLabel!==!1&&t.updateLabel(c,null,null,{removeShape:!1})});function r(a){var s=a.context,c=s.connection,l=c.label,u=Y({},s.hints),p=s.newWaypoints||c.waypoints,f=s.oldWaypoints;return typeof u.startChanged>"u"&&(u.startChanged=!!u.connectionStart),typeof u.endChanged>"u"&&(u.endChanged=!!u.connectionEnd),_k(l,p,f,u)}this.postExecute(["connection.layout","connection.updateWaypoints"],function(a){var s=a.context,c=s.hints||{};if(c.labelBehavior!==!1){var l=s.connection,u=l.label,p;!u||!u.parent||(p=r(a),t.moveShape(u,p))}}),this.postExecute(["shape.replace"],function(a){var s=a.context,c=s.newShape,l=s.oldShape,u=_e(c);u&&Zo(u)&&l.label&&c.label&&(c.label.x=l.label.x,c.label.y=l.label.y)}),this.preExecute("shape.resize",function(a){var s=a.context,c=s.shape,l=s.hints||{};if(!(!at(c)||l.autoResize)){var u=s.newBounds,p=i.getDimensions(vi(c)||"",{box:u,style:i.getExternalStyle()}),f=Math.ceil(p.height),d=u.y!==c.y,g=c.y+c.height;s.newBounds={width:u.width,height:f,x:u.x,y:d?g-f:u.y}}}),this.postExecute("shape.resize",function(a){var s=a.context,c=s.shape,l=s.newBounds,u=s.oldBounds;if(Rl(c)){var p=c.label,f=Je(p),d=Pk(u),g=Ak(f,d),h=Mk(g,u,l);t.moveShape(p,h)}})}Ne(Md,we),Md.$inject=["eventBus","modeling","bpmnFactory","textRenderer"];function Mk(e,t,n){var i=$s(e,t,n);return bo(Gi(i,e))}function Ak(e,t){if(t.length){var n=Tk(e,t);return Cd(e,n)}}function Pk(e){return[[{x:e.x,y:e.y},{x:e.x+(e.width||0),y:e.y}],[{x:e.x+(e.width||0),y:e.y},{x:e.x+(e.width||0),y:e.y+(e.height||0)}],[{x:e.x,y:e.y+(e.height||0)},{x:e.x+(e.width||0),y:e.y+(e.height||0)}],[{x:e.x,y:e.y},{x:e.x,y:e.y+(e.height||0)}]]}function Tk(e,t){var n=t.map(function(o){return{line:o,distance:Ob(e,o)}}),i=qi(n,"distance");return i[0].line}function kk(e,t,n,i){return Fb(e,t,n,i).point}function Ad(e,t){we.call(this,e);function n(i,o){var r=i.context,a=r.connection,s=Y({},r.hints),c=r.newWaypoints||a.waypoints,l=r.oldWaypoints;return typeof s.startChanged>"u"&&(s.startChanged=!!s.connectionStart),typeof s.endChanged>"u"&&(s.endChanged=!!s.connectionEnd),kk(o,c,l,s)}this.postExecute(["connection.layout","connection.updateWaypoints"],function(i){var o=i.context,r=o.connection,a=r.outgoing,s=r.incoming;s.forEach(function(c){var l=c.waypoints[c.waypoints.length-1],u=n(i,l),p=[].concat(c.waypoints.slice(0,-1),[u]);t.updateWaypoints(c,p)}),a.forEach(function(c){var l=c.waypoints[0],u=n(i,l),p=[].concat([u],c.waypoints.slice(1));t.updateWaypoints(c,p)})}),this.postExecute(["connection.move"],function(i){var o=i.context,r=o.connection,a=r.outgoing,s=r.incoming,c=o.delta;s.forEach(function(l){var u=l.waypoints[l.waypoints.length-1],p={x:u.x+c.x,y:u.y+c.y},f=[].concat(l.waypoints.slice(0,-1),[p]);t.updateWaypoints(l,f)}),a.forEach(function(l){var u=l.waypoints[0],p={x:u.x+c.x,y:u.y+c.y},f=[].concat([p],l.waypoints.slice(1));t.updateWaypoints(l,f)})})}Ne(Ad,we),Ad.$inject=["eventBus","modeling"];function Gl(e,t,n){var i=Wl(e),o=Ub(i,t),r=i[0];return o.length?o[o.length-1]:$s(r.original||r,n,t)}function Vl(e,t,n){var i=Wl(e),o=Ub(i,t),r=i[i.length-1];return o.length?o[0]:$s(r.original||r,n,t)}function Pd(e,t,n){var i=Wl(e),o=Wb(t,n),r=i[0];return $s(r.original||r,o,t)}function Td(e,t,n){var i=Wl(e),o=Wb(t,n),r=i[i.length-1];return $s(r.original||r,o,t)}function Wb(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function Wl(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function Ub(e,t){var n=Fn(e,Dk);return ct(n,function(i){return Ok(i,t)})}function Ok(e,t){return On(t,e,1)==="intersect"}function Dk(e){return e.original||e}function kd(e,t){we.call(this,e),this.postExecute("shape.replace",function(n){var i=n.oldShape,o=n.newShape;if(Lk(i,o)){var r=Ik(i);r.incoming.forEach(function(a){var s=Vl(a,o,i);t.reconnectEnd(a,o,s)}),r.outgoing.forEach(function(a){var s=Gl(a,o,i);t.reconnectStart(a,o,s)})}},!0)}kd.$inject=["eventBus","modeling"],Ne(kd,we);function Lk(e,t){return M(e,"bpmn:Participant")&&ht(e)&&M(t,"bpmn:Participant")&&!ht(t)}function Ik(e){var t=Es([e]),n=[],i=[];return t.forEach(function(o){o!==e&&(o.incoming.forEach(function(r){M(r,"bpmn:MessageFlow")&&n.push(r)}),o.outgoing.forEach(function(r){M(r,"bpmn:MessageFlow")&&i.push(r)}))},[]),{incoming:n,outgoing:i}}const Bk=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function qb(e){const t=_e(e);if(!M(t,"bpmn:BoundaryEvent")&&!(M(t,"bpmn:StartEvent")&&Gn(t.$parent)))return!1;const n=t.get("eventDefinitions");return!n||!n.length?!1:Bk.some(i=>M(n[0],i))}function Yb(e){return M(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function Od(e,t){e.invoke(we,this),this.postExecuted("shape.replace",function(n){const i=n.context.oldShape,o=n.context.newShape,r=n.context.hints;if(!qb(o))return;const a=Yb(o);if(r.targetElement&&r.targetElement[a]!==void 0)return;const c=_e(i).get(a),l=_e(o).get(a);c!==l&&t.updateProperties(o,{[a]:c})})}Od.$inject=["injector","modeling"],Ne(Od,we);function Dd(e,t){we.call(this,e),this.preExecute("shape.resize",function(n){var i=n.shape,o=mt(i),r=o&&o.get("label"),a=r&&r.get("bounds");a&&t.updateModdleProperties(i,r,{bounds:void 0})},!0)}Ne(Dd,we),Dd.$inject=["eventBus","modeling"];function Ld(e,t,n){we.call(this,e),this.preExecute("shape.delete",function(i){var o=i.context.shape;if(!(o.incoming.length!==1||o.outgoing.length!==1)){var r=o.incoming[0],a=o.outgoing[0];if(!(!M(r,"bpmn:SequenceFlow")||!M(a,"bpmn:SequenceFlow"))&&t.canConnect(r.source,a.target,r)){var s=Nk(r.waypoints,a.waypoints);n.reconnectEnd(r,a.target,s)}}})}Ne(Ld,we),Ld.$inject=["eventBus","bpmnRules","modeling"];function Ta(e){return e.original||e}function Nk(e,t){var n=Sd(Ta(e[e.length-2]),Ta(e[e.length-1]),Ta(t[1]),Ta(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[Ta(e[0]),Ta(t[t.length-1])]}function Id(e,t){we.call(this,e),this.preExecute("shape.delete",function(n){var i=n.shape,o=i.parent;M(i,"bpmn:Participant")&&(n.collaborationRoot=o)},!0),this.postExecute("shape.delete",function(n){var i=n.collaborationRoot;if(i&&!i.businessObject.participants.length){var o=t.makeProcess(),r=i.children.slice();t.moveElements(r,{x:0,y:0},o)}},!0)}Id.$inject=["eventBus","modeling"],Ne(Id,we);function Bd(e,t,n,i){we.call(this,e);var o=i.get("dragging",!1);function r(c){var l=c.source,u=c.target,p=c.parent;if(p){var f,d;M(c,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(l,u)||(d=!0),n.canConnectMessageFlow(l,u)&&(f="bpmn:MessageFlow")),M(c,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(l,u)||(d=!0),n.canConnectSequenceFlow(l,u)&&(f="bpmn:SequenceFlow")),d&&t.removeConnection(c),f&&t.connect(l,u,{type:f,waypoints:c.waypoints.slice()})}}function a(c){var l=c.context,u=l.connection,p=l.newSource||u.source,f=l.newTarget||u.target,d,g;d=n.canConnect(p,f),!(!d||d.type===u.type)&&(g=t.connect(p,f,{type:d.type,associationDirection:d.associationDirection,waypoints:u.waypoints.slice()}),u.parent&&t.removeConnection(u),l.connection=g,o&&s(u,g))}function s(c,l){var u=o.context(),p=u&&u.payload.previousSelection,f;!p||!p.length||(f=p.indexOf(c),f!==-1&&p.splice(f,1,l))}this.postExecuted("elements.move",function(c){var l=c.closure,u=l.allConnections;V(u,r)},!0),this.preExecute("connection.reconnect",a),this.postExecuted("element.updateProperties",function(c){var l=c.context,u=l.properties,p=l.element,f=p.businessObject,d;u.default&&(d=It(p.outgoing,ca({id:p.businessObject.default.id})),d&&t.updateProperties(d,{conditionExpression:void 0})),u.conditionExpression&&f.sourceRef.default===f&&t.updateProperties(p.source,{default:void 0})})}Ne(Bd,we),Bd.$inject=["eventBus","modeling","bpmnRules","injector"];function Ul(e,t,n,i,o,r){i.invoke(we,this),this._bpmnReplace=e,this._elementRegistry=n,this._selection=r,this.postExecuted(["elements.create"],500,function(a){var s=a.context,c=s.parent,l=s.elements,u=ni(l,function(p,f){var d=t.canReplace([f],f.host||f.parent||c);return d?p.concat(d.replacements):p},[]);u.length&&this._replaceElements(l,u)},this),this.postExecuted(["elements.move"],500,function(a){var s=a.context,c=s.newParent,l=s.newHost,u=[];V(s.closure.topLevel,function(f){Gn(f)?u=u.concat(f.children):u=u.concat(f)}),u.length===1&&l&&(c=l);var p=t.canReplace(u,c);p&&this._replaceElements(u,p.replacements,l)},this),this.postExecute(["shape.replace"],1500,function(a){var s=a.context,c=s.oldShape,l=s.newShape,u=c.attachers,p;u&&u.length&&(p=t.canReplace(u,l),this._replaceElements(u,p.replacements))},this),this.postExecuted(["shape.replace"],1500,function(a){var s=a.context,c=s.oldShape,l=s.newShape;o.unclaimId(c.businessObject.id,c.businessObject),o.updateProperties(l,{id:c.id})})}Ne(Ul,we),Ul.prototype._replaceElements=function(e,t){var n=this._elementRegistry,i=this._bpmnReplace,o=this._selection;V(t,function(r){var a={type:r.newElementType},s=n.get(r.oldElementId),c=e.indexOf(s);e[c]=i.replaceElement(s,a,{select:!1})}),t&&o.select(e)},Ul.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var $k=1500,Fk={width:140,height:120},Nd={width:300,height:60},$d={width:60,height:300},ql={width:300,height:150},Yl={width:150,height:300},Kb={width:140,height:120},Xb={width:100,height:40};function Zb(e){e.on("resize.start",$k,function(t){var n=t.context,i=n.shape,o=n.direction,r=n.balanced;(M(i,"bpmn:Lane")||M(i,"bpmn:Participant"))&&(n.resizeConstraints=Vk(i,o,r)),M(i,"bpmn:SubProcess")&&ht(i)&&(n.minDimensions=Kb),M(i,"bpmn:TextAnnotation")&&(n.minDimensions=Xb)})}Zb.$inject=["eventBus"];var er=Math.abs,jk=Math.min,Hk=Math.max;function Qb(e,t,n,i){var o=e[t];e[t]=o===void 0?n:i(n,o)}function ka(e,t,n){return Qb(e,t,n,jk)}function Oa(e,t,n){return Qb(e,t,n,Hk)}var zk={top:20,left:50,right:20,bottom:20},Gk={top:50,left:20,right:20,bottom:20};function Vk(e,t,n){var i=Ri(e),o=!0,r=!0,a=$l(i,[i]),s=qe(e),c={},l={},u=En(e),p=u?Nd:$d;/n/.test(t)?l.top=s.bottom-p.height:/e/.test(t)?l.right=s.left+p.width:/s/.test(t)?l.bottom=s.top+p.height:/w/.test(t)&&(l.left=s.right-p.width),a.forEach(function(g){var h=qe(g);u?(h.top<s.top-10&&(o=!1),h.bottom>s.bottom+10&&(r=!1)):(h.left<s.left-10&&(o=!1),h.right>s.right+10&&(r=!1)),/n/.test(t)&&(n&&er(s.top-h.bottom)<10&&Oa(c,"top",h.top+p.height),er(s.top-h.top)<5&&ka(l,"top",h.bottom-p.height)),/e/.test(t)&&(n&&er(s.right-h.left)<10&&ka(c,"right",h.right-p.width),er(s.right-h.right)<5&&Oa(l,"right",h.left+p.width)),/s/.test(t)&&(n&&er(s.bottom-h.top)<10&&ka(c,"bottom",h.bottom-p.height),er(s.bottom-h.bottom)<5&&Oa(l,"bottom",h.top+p.height)),/w/.test(t)&&(n&&er(s.left-h.right)<10&&Oa(c,"left",h.left+p.width),er(s.left-h.left)<5&&ka(l,"left",h.right-p.width))});var f=i.children.filter(function(g){return!g.hidden&&!g.waypoints&&(M(g,"bpmn:FlowElement")||M(g,"bpmn:Artifact"))}),d=u?zk:Gk;return f.forEach(function(g){var h=qe(g);/n/.test(t)&&(!u||o)&&ka(l,"top",h.top-d.top),/e/.test(t)&&(u||r)&&Oa(l,"right",h.right+d.right),/s/.test(t)&&(!u||r)&&Oa(l,"bottom",h.bottom+d.bottom),/w/.test(t)&&(u||o)&&ka(l,"left",h.left-d.left)}),{min:l,max:c}}function Jb(e){!e||typeof e.stopPropagation!="function"||e.stopPropagation()}function Da(e){return e.originalEvent||e.srcEvent}function Fd(e){Jb(e),Jb(Da(e))}function Fr(e){return e.pointers&&e.pointers.length&&(e=e.pointers[0]),e.touches&&e.touches.length&&(e=e.touches[0]),e?{x:e.clientX,y:e.clientY}:null}function ex(){return/mac/i.test(navigator.platform)}function tx(e,t){return(Da(e)||e).button===t}function tr(e){return tx(e,0)}function Wk(e){return tx(e,1)}function Fs(e){var t=Da(e)||e;return tr(e)?ex()?t.metaKey:t.ctrlKey:!1}function Kl(e){var t=Da(e)||e;return tr(e)&&t.shiftKey}var nx=1001;function ix(e,t){e.on("resize.start",nx+500,function(n){var i=n.context,o=i.shape;(M(o,"bpmn:Lane")||M(o,"bpmn:Participant"))&&(i.balanced=!Fs(n))}),e.on("resize.end",nx,function(n){var i=n.context,o=i.shape,r=i.canExecute,a=i.newBounds;if(M(o,"bpmn:Lane")||M(o,"bpmn:Participant"))return r&&(a=Ov(a),t.resizeLane(o,a,i.balanced)),!1})}ix.$inject=["eventBus","modeling"];var Uk=500;function jd(e,t,n,i,o){n.invoke(we,this);function r(u){return st(u,["bpmn:ReceiveTask","bpmn:SendTask"])||qk(u,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(u){var p=e.getDefinitions(),f=p.get("rootElements");return!!It(f,ca({id:u.id}))}function s(u){if(M(u,"bpmn:ErrorEventDefinition"))return"errorRef";if(M(u,"bpmn:EscalationEventDefinition"))return"escalationRef";if(M(u,"bpmn:MessageEventDefinition"))return"messageRef";if(M(u,"bpmn:SignalEventDefinition"))return"signalRef"}function c(u){if(st(u,["bpmn:ReceiveTask","bpmn:SendTask"]))return u.get("messageRef");var p=u.get("eventDefinitions"),f=p[0];return f.get(s(f))}function l(u,p){if(st(u,["bpmn:ReceiveTask","bpmn:SendTask"]))return u.set("messageRef",p);var f=u.get("eventDefinitions"),d=f[0];return d.set(s(d),p)}this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],function(u){var p=u.shape||u.element;if(r(p)){var f=_e(p),d=c(f),g;d&&!a(d)&&(g=e.getDefinitions().get("rootElements"),on(g,d),u.addedRootElement=d)}},!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],function(u){var p=u.addedRootElement;if(p){var f=e.getDefinitions().get("rootElements");tn(f,p)}},!0),t.on("copyPaste.copyElement",function(u){var p=u.descriptor,f=u.element;if(!(f.labelTarget||!r(f))){var d=_e(f),g=c(d);g&&(p.referencedRootElement=g)}}),t.on("copyPaste.pasteElement",Uk,function(u){var p=u.descriptor,f=p.businessObject,d=p.referencedRootElement;d&&(a(d)||(d=i.copyElement(d,o.create(d.$type))),l(f,d),delete p.referencedRootElement)})}jd.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],Ne(jd,we);function qk(e,t){return Ze(t)||(t=[t]),Bo(t,function(n){return Sa(e,n)})}var ox=Math.max;function rx(e){e.on("spaceTool.getMinDimensions",function(t){var n=t.shapes,i=t.axis,o=t.start,r={};return V(n,function(a){var s=a.id;M(a,"bpmn:Participant")&&(r[s]=Kk(a,i,o)),M(a,"bpmn:Lane")&&(r[s]=En(a)?Nd:$d),M(a,"bpmn:SubProcess")&&ht(a)&&(r[s]=Kb),M(a,"bpmn:TextAnnotation")&&(r[s]=Xb),M(a,"bpmn:Group")&&(r[s]=Fk)}),r})}rx.$inject=["eventBus"];function Yk(e){return e==="x"}function Kk(e,t,n){var i=En(e);if(!Qk(e))return i?ql:Yl;var o=Yk(t),r={};return o?i?r=ql:r={width:Zk(e,n,o),height:Yl.height}:i?r={width:ql.width,height:Xk(e,n,o)}:r=Yl,r}function Xk(e,t,n){var i;return i=Jk(e,t,n),ox(ql.height,i)}function Zk(e,t,n){var i;return i=eO(e,t,n),ox(Yl.width,i)}function Qk(e){return!!Jo(e).length}function Jk(e,t,n){var i=Jo(e),o;return o=Hd(i,t,n),e.height-o.height+Nd.height}function eO(e,t,n){var i=Jo(e),o;return o=Hd(i,t,n),e.width-o.width+$d.width}function Hd(e,t,n){var i,o,r;for(i=0;i<e.length;i++)if(o=e[i],!n&&t>=o.y&&t<=o.y+o.height||n&&t>=o.x&&t<=o.x+o.width)return r=Jo(o),r.length?Hd(r,t,n):o}var ax="_plane";function sx(e){var t=e.id;return tO(t)}function no(e){var t=e.id;return M(e,"bpmn:SubProcess")?cx(t):t}function jr(e){return cx(e)}function Xl(e){var t=mt(e);return M(t,"bpmndi:BPMNPlane")}function cx(e){return e+ax}function tO(e){return e.replace(new RegExp(ax+"$"),"")}var lx=400,nO=600,ux={x:180,y:160};function Eo(e,t,n,i,o,r,a){we.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=i,this._bpmnFactory=o,this._bpmnjs=r,this._elementRegistry=a;var s=this;function c(p){return M(p,"bpmn:SubProcess")&&!ht(p)}function l(p){var f=p.shape,d=p.newRootElement,g=_e(f);d=s._addDiagram(d||g),p.newRootElement=e.addRootElement(d)}function u(p){var f=p.shape,d=_e(f);s._removeDiagram(d);var g=p.newRootElement=a.get(no(d));e.removeRootElement(g)}this.executed("shape.create",function(p){var f=p.shape;c(f)&&l(p)},!0),this.postExecuted("elements.create",function(p){var f=p.elements;V(f,function(d){if(c(d)){var g=a.get(no(d));if(!(!g||!d.children||!d.children.length)){var h=px(d);s._showRecursively(h),s._moveChildrenToShape(h,g)}}})},!0),this.reverted("shape.create",function(p){var f=p.shape;c(f)&&u(p)},!0),this.preExecute("shape.delete",function(p){var f=p.shape;!M(f,"bpmn:SubProcess")||!ht(f)||V(Ps([f]),d=>{n.removeShape(d.annotation)})},!0),this.preExecuted("shape.delete",function(p){var f=p.shape;if(c(f)){var d=a.get(no(f));d&&n.removeElements(d.children.slice())}},!0),this.executed("shape.delete",function(p){var f=p.shape;c(f)&&u(p)},!0),this.reverted("shape.delete",function(p){var f=p.shape;c(f)&&l(p)},!0),this.preExecuted("shape.replace",function(p){var f=p.oldShape,d=p.newShape;!c(f)||!c(d)||(p.oldRoot=e.removeRootElement(no(f)))},!0),this.postExecuted("shape.replace",function(p){var f=p.newShape,d=p.oldRoot,g=e.findRoot(no(f));if(!(!d||!g)){var h=d.children;n.moveElements(h,{x:0,y:0},g)}},!0),this.executed("element.updateProperties",function(p){var f=p.element;if(M(f,"bpmn:SubProcess")){var d=p.properties,g=p.oldProperties,h=g.id,m=d.id;if(h!==m){if(Xl(f)){a.updateId(f,jr(m)),a.updateId(h,m);return}var w=a.get(jr(h));w&&a.updateId(jr(h),jr(m))}}},!0),this.reverted("element.updateProperties",function(p){var f=p.element;if(M(f,"bpmn:SubProcess")){var d=p.properties,g=p.oldProperties,h=g.id,m=d.id;if(h!==m){if(Xl(f)){a.updateId(f,jr(h)),a.updateId(m,h);return}var w=a.get(jr(m));w&&a.updateId(w,jr(h))}}},!0),t.on("element.changed",function(p){var f=p.element;if(Xl(f)){var d=f,g=a.get(sx(d));!g||g===d||t.fire("element.changed",{element:g})}}),this.executed("shape.toggleCollapse",lx,function(p){var f=p.shape;M(f,"bpmn:SubProcess")&&(ht(f)?u(p):(l(p),s._showRecursively(f.children)))},!0),this.reverted("shape.toggleCollapse",lx,function(p){var f=p.shape;M(f,"bpmn:SubProcess")&&(ht(f)?u(p):(l(p),s._showRecursively(f.children)))},!0),this.postExecuted("shape.toggleCollapse",nO,function(p){var f=p.shape;if(M(f,"bpmn:SubProcess")){var d=p.newRootElement;if(d)if(ht(f))s._moveChildrenToShape(d.children.slice(),f),V(Ps(f.children),h=>{n.moveShape(h.annotation,{x:0,y:0},f.parent),V(h.associations,m=>{n.moveConnection(m,{x:0,y:0},f.parent)})});else{s._disconnectSharedAnnotations(f);var g=px(f);s._moveChildrenToShape(g,d)}}},!0),t.on("copyPaste.createTree",function(p){var f=p.element,d=p.children;if(c(f)){var g=no(f),h=a.get(g);h&&d.push.apply(d,h.children)}}),t.on("copyPaste.copyElement",function(p){var f=p.descriptor,d=p.element,g=p.elements,h=d.parent,m=M(mt(h),"bpmndi:BPMNPlane");if(m){var w=sx(h),y=It(g,function(v){return v.id===w});y&&(f.parent=y.id)}}),t.on("copyPaste.pasteElement",function(p){var f=p.descriptor;f.parent&&(c(f.parent)||f.parent.hidden)&&(f.hidden=!0)})}Ne(Eo,we),Eo.prototype._moveChildrenToShape=function(e,t){var n=this._modeling;if(e.length){var i=e.filter(function(c){return!c.hidden});if(!i.length){n.moveElements(e,{x:0,y:0},t,{autoResize:!1});return}var o=cn(i),r;if(!t.x)r={x:ux.x-o.x,y:ux.y-o.y};else{var a=Je(t),s=Je(o);r={x:a.x-s.x,y:a.y-s.y}}n.moveElements(e,r,t,{autoResize:!1})}},Eo.prototype._disconnectSharedAnnotations=function(e){var t=this._modeling,n=new Set(tb(e).map(i=>i.annotation));n.size&&V(Ps(e.children),i=>{n.has(i.annotation)&&V(i.associations,o=>{t.removeConnection(o)})})},Eo.prototype._showRecursively=function(e,t){var n=this,i=[];return e.forEach(function(o){o.hidden=!!t,i=i.concat(o),o.children&&(i=i.concat(n._showRecursively(o.children,o.collapsed||t)))}),i},Eo.prototype._addDiagram=function(e){var t=this._bpmnjs,n=t.getDefinitions().diagrams;return e.businessObject||(e=this._createNewDiagram(e)),n.push(e.di.$parent),e},Eo.prototype._createNewDiagram=function(e){var t=this._bpmnFactory,n=this._elementFactory,i=t.create("bpmndi:BPMNPlane",{bpmnElement:e}),o=t.create("bpmndi:BPMNDiagram",{plane:i});i.$parent=o;var r=n.createRoot({id:no(e),type:e.$type,di:i,businessObject:e,collapsed:!0});return r},Eo.prototype._removeDiagram=function(e){var t=this._bpmnjs,n=t.getDefinitions().diagrams,i=It(n,function(o){return o.plane.bpmnElement.id===e.id});return n.splice(n.indexOf(i),1),i},Eo.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"];function iO(e){var t=[];return V(Ps(e),n=>{t.push(n.annotation),t.push.apply(t,n.associations)}),t}function px(e){return e.children.slice().concat(iO(e.children)).concat(oO(e))}function oO(e){return Uf(e.children||[]).reduce(function(t,n){return n.label&&n.label.parent!==e&&t.push(n.label),t},[])}function zd(e,t){e.invoke(we,this),this.postExecuted("shape.replace",function(n){var i=n.context.oldShape,o=n.context.newShape;if(!(!M(o,"bpmn:SubProcess")||M(o,"bpmn:AdHocSubProcess")||!(M(i,"bpmn:Task")||M(i,"bpmn:CallActivity"))||!ht(o))){var r=rO(o);t.createShape({type:"bpmn:StartEvent"},r,o)}})}zd.$inject=["injector","modeling"],Ne(zd,we);function rO(e){return{x:e.x+e.width/6,y:e.y+e.height/2}}function Gd(e,t){we.call(this,e),this.preExecute("connection.create",function(n){const{target:i}=n;M(i,"bpmn:TextAnnotation")&&(n.parent=i.parent)},!0),this.preExecute(["shape.create","shape.resize","elements.move"],function(n){const i=n.shapes||[n.shape];i.length===1&&M(i[0],"bpmn:TextAnnotation")&&(n.hints=n.hints||{},n.hints.autoResize=!1)},!0),this.preExecute("shape.resize",function(n){var i=n.context,o=i.shape,r=i.hints||{};if(!(!M(o,"bpmn:TextAnnotation")||r.autoResize)){var a=i.newBounds,s=t.getTextAnnotationBounds(a,vi(o)||""),c=a.y!==o.y&&Math.abs(a.y+a.height-(o.y+o.height))<=1,l=o.y+o.height;i.newBounds={width:a.width,height:s.height,x:a.x,y:c?l-s.height:a.y}}})}Ne(Gd,we),Gd.$inject=["eventBus","textRenderer"];function Vd(e,t){we.call(this,e),this.postExecuted("shape.toggleCollapse",1500,function(n){var i=n.shape;if(ht(i))return;var o=Es(i);o.forEach(function(a){var s=a.incoming.slice(),c=a.outgoing.slice();V(s,function(l){r(l,!0)}),V(c,function(l){r(l,!1)})});function r(a,s){o.indexOf(a.source)!==-1&&o.indexOf(a.target)!==-1||M(a,"bpmn:Association")&&(M(a.source,"bpmn:TextAnnotation")||M(a.target,"bpmn:TextAnnotation"))||(s?t.reconnectEnd(a,i,Je(i)):t.reconnectStart(a,i,Je(i)))}},!0)}Ne(Vd,we),Vd.$inject=["eventBus","modeling"];var Wd=500;function Ud(e,t,n){we.call(this,e);function i(a){a.length&&a.forEach(function(s){s.type==="label"&&!s.businessObject.name&&(s.hidden=!0)})}function o(a,s){var c=a.children,l=s,u,p;return u=aO(c).concat([a]),p=bb(u),p?(l.width=Math.max(p.width,l.width),l.height=Math.max(p.height,l.height),l.x=p.x+(p.width-l.width)/2,l.y=p.y+(p.height-l.height)/2):(l.x=a.x+(a.width-l.width)/2,l.y=a.y+(a.height-l.height)/2),l}function r(a,s){return{x:a.x+(a.width-s.width)/2,y:a.y+(a.height-s.height)/2,width:s.width,height:s.height}}this.executed(["shape.toggleCollapse"],Wd,function(a){var s=a.context,c=s.shape;M(c,"bpmn:SubProcess")&&(c.collapsed?mt(c).isExpanded=!1:(i(c.children),mt(c).isExpanded=!0))}),this.reverted(["shape.toggleCollapse"],Wd,function(a){var s=a.context,c=s.shape;c.collapsed?mt(c).isExpanded=!1:mt(c).isExpanded=!0}),this.postExecuted(["shape.toggleCollapse"],Wd,function(a){var s=a.context.shape,c=t.getDefaultSize(s),l;s.collapsed?l=r(s,c):l=o(s,c),n.resizeShape(s,l,null,{autoResize:s.collapsed?!1:"nwse"})})}Ne(Ud,we),Ud.$inject=["eventBus","elementFactory","modeling"];function aO(e){return e.filter(function(t){return!t.hidden})}function qd(e,t,n,i){t.invoke(we,this),this.preExecute("shape.delete",function(o){var r=o.context,a=r.shape,s=a.businessObject;at(a)||(M(a,"bpmn:Participant")&&ht(a)&&n.ids.unclaim(s.processRef.id),i.unclaimId(s.id,s))}),this.preExecute("connection.delete",function(o){var r=o.context,a=r.connection,s=a.businessObject;i.unclaimId(s.id,s)}),this.preExecute("canvas.updateRoot",function(){var o=e.getRootElement(),r=o.businessObject;M(o,"bpmn:Collaboration")&&n.ids.unclaim(r.id)})}Ne(qd,we),qd.$inject=["canvas","injector","moddle","modeling"];function Yd(e,t){we.call(this,e),this.preExecute("connection.delete",function(n){var i=n.context,o=i.connection,r=o.source;sO(o,r)&&t.updateProperties(r,{default:null})})}Ne(Yd,we),Yd.$inject=["eventBus","modeling"];function sO(e,t){if(!M(e,"bpmn:SequenceFlow"))return!1;var n=_e(t),i=_e(e);return n.get("default")===i}var cO=500,lO=5e3,fx=["shape.create","shape.delete","shape.move","shape.resize"],dx=[...fx,"spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move"];function Kd(e,t){we.call(this,e);var n;function i(){return n=n||new uO,n.enter(),n}function o(){if(!n)throw new Error("out of bounds release");return n}function r(){if(!n)throw new Error("out of bounds release");var a=n.leave();return a&&(t.updateLaneRefs(n.flowNodes,n.lanes),n=null),a}this.preExecute(dx,lO,function(){i()}),this.postExecuted(dx,cO,function(){r()}),this.preExecute(fx,function(a){var s=a.context,c=s.shape,l=o();!c||c.labelTarget||(M(c,"bpmn:Lane")&&l.addLane(c),M(c,"bpmn:FlowNode")&&l.addFlowNode(c))})}Kd.$inject=["eventBus","modeling"],Ne(Kd,we);function uO(){this.flowNodes=[],this.lanes=[],this.counter=0,this.addLane=function(e){this.lanes.push(e)},this.addFlowNode=function(e){this.flowNodes.push(e)},this.enter=function(){this.counter++},this.leave=function(){return this.counter--,!this.counter}}var pO=500,fO=5e3,hx=["connection.create","connection.delete","connection.layout","connection.move","connection.reconnect","connection.updateWaypoints","shape.create","shape.delete","shape.move","shape.resize"],gx=[...hx,"elements.create","elements.delete","elements.move","label.create","spaceTool"];function Xd(e,t){we.call(this,e);var n;function i(){return n=n||new dO,n.enter(),n}function o(){if(!n)throw new Error("out of bounds release");return n}function r(){if(!n)throw new Error("out of bounds release");var a=n.leave();return a&&(t.updateCategoryValueRefs(Array.from(n.affectedFlowElements),Array.from(n.affectedGroupEntries.values())),n=null),a}this.preExecute(gx,fO,function(){i()}),this.postExecuted(gx,pO,function(){r()}),this.preExecute(hx,function(a){var s=a.context.connection||a.context.shape,c=o();!s||s.labelTarget||(M(s,"bpmn:FlowElement")&&c.addFlowElement(s),M(s,"bpmn:Group")&&c.addGroup(s))}),this.preExecute("label.create",function(a){var s=a.context.labelTarget;M(s,"bpmn:Group")&&o().addGroup(s)})}Xd.$inject=["eventBus","modeling"],Ne(Xd,we);function dO(){this.affectedFlowElements=new Set,this.affectedGroupEntries=new Map,this.counter=0,this.addFlowElement=function(e){this.affectedFlowElements.add(e)},this.addGroup=function(e){this.affectedGroupEntries.has(e)||this.affectedGroupEntries.set(e,{categoryValue:e.businessObject.categoryValueRef,groupShape:e})},this.enter=function(){this.counter++},this.leave=function(){return this.counter--,!this.counter}}function Zd(e,t){we.call(this,e),this.postExecuted("elements.create",function(n){const i=n.context,o=i.elements;for(const r of o)hO(r)&&!mO(r)&&t.updateProperties(r,{isForCompensation:void 0})})}Ne(Zd,we),Zd.$inject=["eventBus","modeling"];function hO(e){const t=_e(e);return t&&t.isForCompensation}function gO(e){return e&&M(e,"bpmn:BoundaryEvent")&&Sa(e,"bpmn:CompensateEventDefinition")}function mO(e){return e.incoming.filter(n=>gO(n.source)).length>0}const yO={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","artifactBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","categoryRootElementReferenceBehavior","compensateBoundaryEventBehaviour","createBehavior","createDataObjectBehavior","createParticipantBehavior","dataInputAssociationBehavior","dataStoreBehavior","deleteLaneBehavior","detachEventBehavior","dropOnFlowBehavior","eventBasedGatewayBehavior","fixHoverBehavior","groupBehavior","importDockingFix","isHorizontalFix","labelBehavior","layoutConnectionBehavior","messageFlowBehavior","nonInterruptingBehavior","removeElementBehavior","removeEmbeddedLabelBoundsBehavior","removeParticipantBehavior","replaceConnectionBehavior","replaceElementBehaviour","resizeBehavior","resizeLaneBehavior","rootElementReferenceBehavior","spaceToolBehavior","subProcessPlaneBehavior","subProcessStartEventBehavior","textAnnotationBehavior","toggleCollapseConnectionBehaviour","toggleElementCollapseBehaviour","unclaimIdBehavior","updateFlowNodeRefsBehavior","updateCategoryValueRefsBehavior","unsetDefaultFlowBehavior","setCompensationActivityAfterPasteBehavior"],adaptiveLabelPositioningBehavior:["type",rd],appendBehavior:["type",ad],associationBehavior:["type",cd],attachEventBehavior:["type",kl],artifactBehavior:["type",sd],boundaryEventBehavior:["type",ld],categoryRootElementReferenceBehavior:["type",ud],compensateBoundaryEventBehaviour:["type",pd],createBehavior:["type",fd],createDataObjectBehavior:["type",dd],createParticipantBehavior:["type",md],dataInputAssociationBehavior:["type",yd],dataStoreBehavior:["type",vd],deleteLaneBehavior:["type",bd],detachEventBehavior:["type",Fl],dropOnFlowBehavior:["type",wd],eventBasedGatewayBehavior:["type",_d],fixHoverBehavior:["type",Cb],groupBehavior:["type",Ed],importDockingFix:["type",Ab],isHorizontalFix:["type",Rd],labelBehavior:["type",Md],layoutConnectionBehavior:["type",Ad],messageFlowBehavior:["type",kd],nonInterruptingBehavior:["type",Od],removeElementBehavior:["type",Ld],removeEmbeddedLabelBoundsBehavior:["type",Dd],removeParticipantBehavior:["type",Id],replaceConnectionBehavior:["type",Bd],replaceElementBehaviour:["type",Ul],resizeBehavior:["type",Zb],resizeLaneBehavior:["type",ix],rootElementReferenceBehavior:["type",jd],spaceToolBehavior:["type",rx],subProcessPlaneBehavior:["type",Eo],subProcessStartEventBehavior:["type",zd],textAnnotationBehavior:["type",Gd],toggleCollapseConnectionBehaviour:["type",Vd],toggleElementCollapseBehaviour:["type",Ud],unclaimIdBehavior:["type",qd],unsetDefaultFlowBehavior:["type",Yd],updateFlowNodeRefsBehavior:["type",Kd],updateCategoryValueRefsBehavior:["type",Xd],setCompensationActivityAfterPasteBehavior:["type",Zd]};function Qd(e){this._commandStack=e.get("commandStack",!1)}Qd.$inject=["injector"],Qd.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),n===void 0?!0:n};const io={__init__:["rules"],rules:["type",Qd]};function Ci(e){we.call(this,e),this.init()}Ci.$inject=["eventBus"],Ne(Ci,we),Ci.prototype.addRule=function(e,t,n){var i=this;typeof e=="string"&&(e=[e]),e.forEach(function(o){i.canExecute(o,t,function(r,a,s){return n(r)},!0)})},Ci.prototype.init=function(){};function mx(e,t){var n=On(e,t,-15);return n!=="intersect"?n:null}function Ln(e){Ci.call(this,e)}Ne(Ln,Ci),Ln.$inject=["eventBus"],Ln.prototype.init=function(){this.addRule("connection.start",function(e){var t=e.source;return vO(t)}),this.addRule("connection.create",function(e){var t=e.source,n=e.target,i=e.hints||{},o=i.targetParent,r=i.targetAttach;if(r)return!1;o&&(n.parent=o);try{return Ql(t,n)}finally{o&&(n.parent=null)}}),this.addRule("connection.reconnect",function(e){var t=e.connection,n=e.source,i=e.target;return Ql(n,i,t)}),this.addRule("connection.updateWaypoints",function(e){return{type:e.connection.type}}),this.addRule("shape.resize",function(e){var t=e.shape,n=e.newBounds,i=e.direction;return Px(t,n,i)}),this.addRule("elements.create",function(e){var t=e.elements,n=e.position,i=e.target;return Ot(i)&&!Jl(t,i)?!1:Io(t,function(o){return Ot(o)?Ql(o.source,o.target,o):o.host?js(o,o.host,null,n):nh(o,i)})}),this.addRule("elements.move",function(e){var t=e.target,n=e.shapes,i=e.position,o=e.hints;return o!=null&&o.keyboardMove&&n.some(function(a){return Ex(a)&&!n.includes(a.host)})?!1:js(n,t,null,i)||Mx(n,t,i)||Ax(n,t)||Jl(n,t)}),this.addRule("shape.create",function(e){return nh(e.shape,e.target,e.source,e.position)}),this.addRule("shape.attach",function(e){return js(e.shape,e.target,null,e.position)}),this.addRule("element.copy",function(e){var t=e.element,n=e.elements;return Lx(n,t)})},Ln.prototype.canConnectMessageFlow=Ox,Ln.prototype.canConnectSequenceFlow=Dx,Ln.prototype.canConnectDataAssociation=ih,Ln.prototype.canConnectAssociation=Tx,Ln.prototype.canConnectCompensationAssociation=kx,Ln.prototype.canMove=Ax,Ln.prototype.canAttach=js,Ln.prototype.canReplace=Mx,Ln.prototype.canDrop=La,Ln.prototype.canInsert=Jl,Ln.prototype.canCreate=nh,Ln.prototype.canConnect=Ql,Ln.prototype.canResize=Px,Ln.prototype.canCopy=Lx;function vO(e){return Jd(e)?null:st(e,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference","bpmn:Group","bpmn:TextAnnotation"])}function Jd(e){return!e||at(e)}function yx(e){do{if(M(e,"bpmn:Process"))return _e(e);if(M(e,"bpmn:Participant"))return _e(e).processRef||_e(e)}while(e=e.parent)}function eh(e){return M(e,"bpmn:TextAnnotation")}function th(e){return M(e,"bpmn:Group")&&!e.labelTarget}function vx(e){return M(e,"bpmn:BoundaryEvent")&&oo(e,"bpmn:CompensateEventDefinition")}function Zl(e){return _e(e).isForCompensation}function bO(e,t){var n=yx(e),i=yx(t);return n===i}function xO(e){return M(e,"bpmn:InteractionNode")&&!M(e,"bpmn:BoundaryEvent")&&(!M(e,"bpmn:Event")||M(e,"bpmn:ThrowEvent")&&wx(e,"bpmn:MessageEventDefinition"))}function wO(e){return M(e,"bpmn:InteractionNode")&&!Zl(e)&&(!M(e,"bpmn:Event")||M(e,"bpmn:CatchEvent")&&wx(e,"bpmn:MessageEventDefinition"))&&!(M(e,"bpmn:BoundaryEvent")&&!oo(e,"bpmn:MessageEventDefinition"))}function bx(e){for(var t=e;t=t.parent;){if(M(t,"bpmn:FlowElementsContainer"))return _e(t);if(M(t,"bpmn:Participant"))return _e(t).processRef}return null}function xx(e,t){var n=bx(e),i=bx(t);return n===i}function oo(e,t){var n=_e(e);return!!It(n.eventDefinitions||[],function(i){return M(i,t)})}function wx(e,t){var n=_e(e);return(n.eventDefinitions||[]).every(function(i){return M(i,t)})}function _O(e){return M(e,"bpmn:FlowNode")&&!M(e,"bpmn:EndEvent")&&!Gn(e)&&!(M(e,"bpmn:IntermediateThrowEvent")&&oo(e,"bpmn:LinkEventDefinition"))&&!vx(e)&&!Zl(e)}function EO(e){return M(e,"bpmn:FlowNode")&&!M(e,"bpmn:StartEvent")&&!M(e,"bpmn:BoundaryEvent")&&!Gn(e)&&!(M(e,"bpmn:IntermediateCatchEvent")&&oo(e,"bpmn:LinkEventDefinition"))&&!Zl(e)}function SO(e){return M(e,"bpmn:ReceiveTask")||M(e,"bpmn:IntermediateCatchEvent")&&(oo(e,"bpmn:MessageEventDefinition")||oo(e,"bpmn:TimerEventDefinition")||oo(e,"bpmn:ConditionalEventDefinition")||oo(e,"bpmn:SignalEventDefinition"))}function RO(e){for(var t=[];e;)e=e.parent,e&&t.push(e);return t}function _x(e,t){var n=RO(t);return n.indexOf(e)!==-1}function Ql(e,t,n){if(Jd(e)||Jd(t))return null;if(!M(n,"bpmn:DataAssociation")){if(Ox(e,t))return{type:"bpmn:MessageFlow"};if(Dx(e,t))return{type:"bpmn:SequenceFlow"}}var i=ih(e,t);return i||(kx(e,t)?{type:"bpmn:Association",associationDirection:"One"}:Tx(e,t)?{type:"bpmn:Association",associationDirection:"None"}:!1)}function La(e,t){return at(e)||th(e)?!0:M(t,"bpmn:Participant")&&!ht(t)?!1:M(e,"bpmn:Participant")?M(t,"bpmn:Process")||M(t,"bpmn:Collaboration"):st(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:M(e,"bpmn:Lane")?M(t,"bpmn:Participant")||M(t,"bpmn:Lane"):M(e,"bpmn:BoundaryEvent")&&!CO(e)?!1:M(e,"bpmn:FlowElement")&&!M(e,"bpmn:DataStoreReference")?M(t,"bpmn:FlowElementsContainer")?ht(t):st(t,["bpmn:Participant","bpmn:Lane"]):M(e,"bpmn:DataStoreReference")&&M(t,"bpmn:Collaboration")?Bo(_e(t).get("participants"),function(n){return!!n.get("processRef")}):st(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?st(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):M(e,"bpmn:MessageFlow")?M(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t:!1}function CO(e){return _e(e).cancelActivity&&(Sx(e)||Rx(e))}function Ex(e){return!at(e)&&M(e,"bpmn:BoundaryEvent")}function MO(e){return M(e,"bpmn:Lane")}function AO(e){return Ex(e)||M(e,"bpmn:IntermediateThrowEvent")&&Sx(e)?!0:M(e,"bpmn:IntermediateCatchEvent")&&Rx(e)}function Sx(e){var t=_e(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function Rx(e){return Cx(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function Cx(e,t){return t.some(function(n){return oo(e,n)})}function PO(e){return M(e,"bpmn:ReceiveTask")&&It(e.incoming,function(t){return M(t.source,"bpmn:EventBasedGateway")})}function js(e,t,n,i){if(Array.isArray(e)||(e=[e]),e.length!==1)return!1;var o=e[0];return at(o)||!AO(o)||Gn(t)||!M(t,"bpmn:Activity")||Zl(t)||i&&!mx(i,t)||PO(t)?!1:"attach"}function Mx(e,t,n){if(!t)return!1;var i={replacements:[]};return V(e,function(o){Gn(t)||M(o,"bpmn:StartEvent")&&o.type!=="label"&&La(o,t)&&($T(o)||i.replacements.push({oldElementId:o.id,newElementType:"bpmn:StartEvent"}),(FT(o)||jT(o)||HT(o))&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:StartEvent"}),Cx(o,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&M(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:StartEvent"})),M(t,"bpmn:Transaction")||oo(o,"bpmn:CancelEventDefinition")&&o.type!=="label"&&(M(o,"bpmn:EndEvent")&&La(o,t)&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:EndEvent"}),M(o,"bpmn:BoundaryEvent")&&js(o,t,null,n)&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:BoundaryEvent"}))}),i.replacements.length?i:!1}function Ax(e,t){return Bo(e,MO)?!1:t===void 0?!0:t===null?!1:e.every(function(n){return La(n,t)})}function nh(e,t,n,i){return t?at(e)||th(e)?!0:La(e,t)||Jl(e,t):!1}function Px(e,t,n){return M(e,"bpmn:SubProcess")?ht(e)&&(!t||t.width>=100&&t.height>=80):M(e,"bpmn:Lane")||M(e,"bpmn:Participant")?!0:eh(e)?n?n==="e"||n==="w":!0:th(e)?!0:at(e)?n?n==="e"||n==="w":!0:!1}function TO(e,t){var n=eh(e),i=eh(t);return(n||i)&&n!==i}function Tx(e,t){return _x(t,e)||_x(e,t)?!1:TO(e,t)?!0:!!ih(e,t)}function kx(e,t){return xx(e,t)&&vx(e)&&M(t,"bpmn:Activity")&&!OO(t,e)&&!Gn(t)}function Ox(e,t){return Bx(e)&&!Bx(t)?!1:xO(e)&&wO(t)&&!bO(e,t)}function Dx(e,t){return _O(e)&&EO(t)&&xx(e,t)&&!(M(e,"bpmn:EventBasedGateway")&&!SO(t))}function ih(e,t){return st(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&st(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:st(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&st(e,["bpmn:Activity","bpmn:CatchEvent"])?{type:"bpmn:DataOutputAssociation"}:!1}function Jl(e,t,n){if(!t)return!1;if(Array.isArray(e)){if(e.length!==1)return!1;e=e[0]}return t.source===e||t.target===e?!1:st(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!at(t)&&M(e,"bpmn:FlowNode")&&!M(e,"bpmn:BoundaryEvent")&&La(e,t.parent)}function oh(e,t){return e&&t&&e.indexOf(t)!==-1}function Lx(e,t){return at(t)?!0:!(M(t,"bpmn:Lane")&&!oh(e,t.parent)||M(t,"bpmn:MessageFlow")&&!kO(e,t))}function kO(e,t){var n=Ix(t.source),i=Ix(t.target);return oh(e,n)&&oh(e,i)}function Ix(e){for(;e;e=e.parent)if(M(e,"bpmn:Participant"))return e;return null}function Bx(e){return Ma(e,"bpmn:Process")||Ma(e,"bpmn:Collaboration")}function OO(e,t){return e.attachers.includes(t)}const DO={__depends__:[io],__init__:["bpmnRules"],bpmnRules:["type",Ln]};var LO=2e3;function Nx(e,t){e.on("saveXML.start",LO,n);function n(){var i=t.getRootElements();V(i,function(o){var r=mt(o),a,s;a=Es([o]),a=ct(a,function(c){return c!==o&&!c.labelTarget}),s=Fn(a,mt),r.set("planeElement",s)})}}Nx.$inject=["eventBus","canvas"];const IO={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Nx]};function eu(e){we.call(this,e);var t=this;this.preExecute(["shape.create","connection.create"],function(n){var i=n.context,o=i.shape||i.connection,r=i.parent,a=t.getOrdering(o,r);a&&(a.parent!==void 0&&(i.parent=a.parent),i.parentIndex=a.index)}),this.preExecute(["shape.move","connection.move"],function(n){var i=n.context,o=i.shape||i.connection,r=i.newParent||o.parent,a=t.getOrdering(o,r);a&&(a.parent!==void 0&&(i.newParent=a.parent),i.newParentIndex=a.index)})}eu.prototype.getOrdering=function(e,t){return null},Ne(eu,we);function rh(e,t){eu.call(this,e);var n=[{type:"bpmn:SubProcess",order:{level:6}},{type:"bpmn:SequenceFlow",order:{level:9,containers:["bpmn:Participant","bpmn:FlowElementsContainer"]}},{type:"bpmn:DataAssociation",order:{level:9,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:TextAnnotation",order:{level:9}},{type:"bpmn:MessageFlow",order:{level:9,containers:["bpmn:Collaboration"]}},{type:"bpmn:Association",order:{level:6,containers:["bpmn:Participant","bpmn:FlowElementsContainer","bpmn:Collaboration"]}},{type:"bpmn:BoundaryEvent",order:{level:8}},{type:"bpmn:Group",order:{level:10,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:FlowElement",order:{level:5}},{type:"bpmn:Participant",order:{level:-2}},{type:"bpmn:Lane",order:{level:-1}}];function i(a){if(a.labelTarget)return{level:10};var s=It(n,function(c){return st(a,[c.type])});return s&&s.order||{level:1}}function o(a){var s=a.order;if(s||(a.order=s=i(a)),!s)throw new Error(`no order for <${a.id}>`);return s}function r(a,s,c){for(var l=s;l&&!st(l,c);)l=l.parent;if(!l)throw new Error(`no parent for <${a.id}> in <${s&&s.id}>`);return l}this.getOrdering=function(a,s){if(a.labelTarget||M(a,"bpmn:TextAnnotation"))return{parent:t.findRoot(s)||t.getRootElement(),index:-1};var c=o(a);c.containers&&(s=r(a,s,c.containers));var l=s.children.indexOf(a),u=em(s.children,function(p){return!a.labelTarget&&p.labelTarget?!1:c.level<o(p).level});return u!==-1&&l!==-1&&l<u&&(u-=1),{index:u,parent:s}}}rh.$inject=["eventBus","canvas"],Ne(rh,eu);const BO={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",rh]};function Hs(){}Hs.prototype.get=function(){return this._data},Hs.prototype.set=function(e){this._data=e},Hs.prototype.clear=function(){var e=this._data;return delete this._data,e},Hs.prototype.isEmpty=function(){return!this._data};const NO={clipboard:["type",Hs]};var $x=1500;function Fx(e,t,n){var i=this,o=n.get("dragging",!1);function r(a){if(!a.hover){var s=a.originalEvent,c=i._findTargetGfx(s),l=c&&e.get(c);c&&l&&(a.stopPropagation(),o.hover({element:l,gfx:c}),o.move(s))}}o&&t.on("drag.start",function(a){t.once("drag.move",$x,function(s){r(s)})}),(function(){var a,s;t.on("element.hover",function(c){a=c.gfx,s=c.element}),t.on("element.hover",$x,function(c){s&&t.fire("element.out",{element:s,gfx:a})}),t.on("element.out",function(){a=null,s=null})})(),this._findTargetGfx=function(a){var s,c;if(a instanceof MouseEvent)return s=Fr(a),c=document.elementFromPoint(s.x,s.y),$O(c)}}Fx.$inject=["elementRegistry","eventBus","injector"];function $O(e){return Lr(e,"svg, .djs-element",!0)}const FO={__init__:["hoverFix"],hoverFix:["type",Fx]};function jO(e){return!0}function tu(e){return tr(e)||Wk(e)}var jx=500;function Hx(e,t,n){var i=this;function o(P,k,H){if(!s(P,k)){var F,G,ee;H?G=t.getGraphics(H):(F=k.delegateTarget||k.target,F&&(G=F,H=t.get(G))),!(!G||!H)&&(ee=e.fire(P,{element:H,gfx:G,originalEvent:k}),ee===!1&&(k.stopPropagation(),k.preventDefault()))}}var r={};function a(P){return r[P]}function s(P,k){var H=l[P]||tr;return!H(k)}var c={click:"element.click",contextmenu:"element.contextmenu",dblclick:"element.dblclick",mousedown:"element.mousedown",mousemove:"element.mousemove",mouseover:"element.hover",mouseout:"element.out",mouseup:"element.mouseup"},l={"element.contextmenu":jO,"element.mousedown":tu,"element.mouseup":tu,"element.click":tu,"element.dblclick":tu};function u(P,k,H){var F=c[P];if(!F)throw new Error("unmapped DOM event name <"+P+">");return o(F,k,H)}var p="svg, .djs-element";function f(P,k,H,F){var G=r[H]=function(ee){o(H,ee)};F&&(l[H]=F),G.$delegate=ii.bind(P,p,k,G)}function d(P,k,H){var F=a(H);F&&ii.unbind(P,k,F.$delegate)}function g(P){V(c,function(k,H){f(P,H,k)})}function h(P){V(c,function(k,H){d(P,H,k)})}e.on("canvas.destroy",function(P){h(P.svg)}),e.on("canvas.init",function(P){g(P.svg)}),e.on(["shape.added","connection.added"],function(P){var k=P.element,H=P.gfx;e.fire("interactionEvents.createHit",{element:k,gfx:H})}),e.on(["shape.changed","connection.changed"],jx,function(P){var k=P.element,H=P.gfx;e.fire("interactionEvents.updateHit",{element:k,gfx:H})}),e.on("interactionEvents.createHit",jx,function(P){var k=P.element,H=P.gfx;i.createDefaultHit(k,H)}),e.on("interactionEvents.updateHit",function(P){var k=P.element,H=P.gfx;i.updateDefaultHit(k,H)});var m=E("djs-hit djs-hit-stroke"),w=E("djs-hit djs-hit-click-stroke"),y=E("djs-hit djs-hit-all"),v=E("djs-hit djs-hit-no-move"),x={all:y,"click-stroke":w,stroke:m,"no-move":v};function E(P,k){return k=Y({stroke:"white",strokeWidth:15},k||{}),n.cls(P,["no-fill","no-border"],k)}function A(P,k){var H=x[k];if(!H)throw new Error("invalid hit type <"+k+">");return Ie(P,H),P}function B(P,k){tt(P,k)}this.removeHits=function(P){var k=vs(".djs-hit",P);V(k,sn)},this.createDefaultHit=function(P,k){var H=P.waypoints,F=P.isFrame,G;return H?this.createWaypointsHit(k,H):(G=F?"stroke":"all",this.createBoxHit(k,G,{width:P.width,height:P.height}))},this.createWaypointsHit=function(P,k){var H=_s(k);return A(H,"stroke"),B(P,H),H},this.createBoxHit=function(P,k,H){H=Y({x:0,y:0},H);var F=He("rect");return A(F,k),Ie(F,H),B(P,F),F},this.updateDefaultHit=function(P,k){var H=Ct(".djs-hit",k);if(H)return P.waypoints?Wf(H,P.waypoints):Ie(H,{width:P.width,height:P.height}),H},this.fire=o,this.triggerMouseEvent=u,this.mouseHandler=a,this.registerEvent=f,this.unregisterEvent=d}Hx.$inject=["eventBus","elementRegistry","styles"];const nu={__init__:["interactionEvents"],interactionEvents:["type",Hx]};function Ia(e,t){this._eventBus=e,this._canvas=t,this._selectedElements=new Set;var n=this;e.on(["shape.remove","connection.remove"],function(i){var o=i.element;n.deselect(o)}),e.on(["diagram.clear","root.set"],function(i){n.select(null)})}Ia.$inject=["eventBus","canvas"],Ia.prototype.deselect=function(e){if(this._selectedElements.has(e)){var t=this.get();this._selectedElements.delete(e),this._eventBus.fire("selection.changed",{oldSelection:t,newSelection:this.get()})}},Ia.prototype.get=function(){return Array.from(this._selectedElements)},Ia.prototype.isSelected=function(e){return this._selectedElements.has(e)},Ia.prototype.select=function(e,t){var n=this.get();Ze(e)||(e=e?[e]:[]);var i=this._canvas,o=i.getRootElement();e=e.filter(function(r){var a=i.findRoot(r);return o===a}),t?V(e,r=>{this._selectedElements.add(r)}):this._selectedElements=new Set(e),this._eventBus.fire("selection.changed",{oldSelection:n,newSelection:this.get()})};var zx="hover",Gx="selected";function Vx(e,t){this._canvas=e;function n(o,r){e.addMarker(o,r)}function i(o,r){e.removeMarker(o,r)}t.on("element.hover",function(o){n(o.element,zx)}),t.on("element.out",function(o){i(o.element,zx)}),t.on("selection.changed",function(o){function r(l){i(l,Gx)}function a(l){n(l,Gx)}var s=new Set(o.oldSelection),c=new Set(o.newSelection);for(let l of s)c.has(l)||r(l);for(let l of c)s.has(l)||a(l)})}Vx.$inject=["canvas","eventBus"];function Wx(e,t,n,i){e.on("create.end",500,function(o){var r=o.context,a=r.canExecute,s=r.elements,c=r.hints||{},l=c.autoSelect;if(a){if(l===!1)return;Ze(l)?t.select(l):t.select(s.filter(HO))}}),e.on("connect.end",500,function(o){var r=o.context,a=r.connection;a&&t.select(a)}),e.on("shape.move.end",500,function(o){var r=o.previousSelection||[],a=i.get(o.context.shape.id),s=It(r,function(c){return a.id===c.id});s||t.select(a)}),e.on("element.click",function(o){if(tr(o)){var r=o.element;r===n.getRootElement()&&(r=null);var a=t.isSelected(r),s=t.get().length>1,c=Kl(o);if(a&&s)return c?t.deselect(r):t.select(r);a?t.deselect(r):t.select(r,c)}})}Wx.$inject=["eventBus","selection","canvas","elementRegistry"];function HO(e){return!e.hidden}const Mi={__init__:["selectionVisuals","selectionBehavior"],__depends__:[nu],selection:["type",Ia],selectionVisuals:["type",Vx],selectionBehavior:["type",Wx]};var zO=/^djs-cursor-.*$/;function iu(e){var t=At(document.body);t.removeMatching(zO),e&&t.add("djs-cursor-"+e)}function Ux(){iu(null)}var GO=5e3;function qx(e,t){t=t||"element.click";function n(){return!1}return e.once(t,GO,n),function(){e.off(t,n)}}var VO=["c","C"],WO=["v","V"],UO=["d","D"],qO=["x","X"],YO=["y","Y"],Yx=["z","Z"];function KO(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function ai(e){return e.altKey?!1:e.ctrlKey||e.metaKey}function vn(e,t){return e=Ze(e)?e:[e],e.indexOf(t.key)!==-1||e.indexOf(t.code)!==-1}function ah(e){return e.shiftKey}function XO(e){return ai(e)&&vn(VO,e)}function ZO(e){return ai(e)&&vn(WO,e)}function QO(e){return ai(e)&&vn(UO,e)}function JO(e){return ai(e)&&vn(qO,e)}function eD(e){return ai(e)&&!ah(e)&&vn(Yx,e)}function tD(e){return ai(e)&&(vn(YO,e)||vn(Yx,e)&&ah(e))}var Ba=Math.round,Kx="djs-drag-active";function Hr(e){e.preventDefault()}function nD(e){return typeof TouchEvent<"u"&&e instanceof TouchEvent}function iD(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Xx(e,t,n,i){var o={threshold:5,trapClick:!0},r;function a(v){var x=t.viewbox(),E=t._container.getBoundingClientRect();return{x:x.x+(v.x-E.left)/x.scale,y:x.y+(v.y-E.top)/x.scale}}function s(v,x){x=x||r;var E=e.createEvent(Y({},x.payload,x.data,{isTouch:x.isTouch}));return e.fire("drag."+v,E)===!1?!1:e.fire(x.prefix+"."+v,E)}function c(v){var x=v.filter(function(E){return i.get(E.id)});x.length&&n.select(x)}function l(v,x){var E=r.payload,A=r.displacement,B=r.globalStart,P=Fr(v),k=Gi(P,B),H=r.localStart,F=a(P),G=Gi(F,H);if(!r.active&&(x||iD(k)>r.threshold)){if(Y(E,{x:Ba(H.x+A.x),y:Ba(H.y+A.y),dx:0,dy:0},{originalEvent:v}),s("start")===!1)return m();r.active=!0,r.keepSelection||(E.previousSelection=n.get(),n.select(null)),r.cursor&&iu(r.cursor),t.addMarker(t.getRootElement(),Kx)}Fd(v),r.active&&(Y(E,{x:Ba(F.x+A.x),y:Ba(F.y+A.y),dx:Ba(G.x),dy:Ba(G.y)},{originalEvent:v}),s("move"))}function u(v){var x,E=!0;r.active&&(v&&(r.payload.originalEvent=v,Fd(v)),E=s("end")),E===!1&&s("rejected"),x=w(E!==!0),s("ended",x)}function p(v){vn("Escape",v)&&(Hr(v),m())}function f(v){var x;r.active&&(x=qx(e),setTimeout(x,400),Hr(v)),u(v)}function d(v){l(v)}function g(v){var x=r.payload;x.hoverGfx=v.gfx,x.hover=v.element,s("hover")}function h(v){s("out");var x=r.payload;x.hoverGfx=null,x.hover=null}function m(v){var x;if(r){var E=r.active;E&&s("cancel"),x=w(v),E&&s("canceled",x)}}function w(v){var x,E;s("cleanup"),Ux(),r.trapClick?E=f:E=u,Ve.unbind(document,"mousemove",l),Ve.unbind(document,"dragstart",Hr),Ve.unbind(document,"selectstart",Hr),Ve.unbind(document,"mousedown",E,!0),Ve.unbind(document,"mouseup",E,!0),Ve.unbind(document,"keyup",p),Ve.unbind(document,"touchstart",d,!0),Ve.unbind(document,"touchcancel",m,!0),Ve.unbind(document,"touchmove",l,!0),Ve.unbind(document,"touchend",u,!0),e.off("element.hover",g),e.off("element.out",h),t.removeMarker(t.getRootElement(),Kx);var A=r.payload.previousSelection;return v!==!1&&A&&!n.get().length&&c(A),x=r,r=null,x}function y(v,x,E,A){r&&m(!1),typeof x=="string"&&(A=E,E=x,x=null),A=Y({},o,A||{});var B=A.data||{},P,k,H,F,G;if(A.trapClick?F=f:F=u,v?(P=Da(v)||v,k=Fr(v),Fd(v),P.type==="dragstart"&&Hr(P)):(P=null,k={x:0,y:0}),H=a(k),x||(x=H),G=nD(P),r=Y({prefix:E,data:B,payload:{},globalStart:k,displacement:Gi(x,H),localStart:H,isTouch:G},A),A.manual||(G?(Ve.bind(document,"touchstart",d,!0),Ve.bind(document,"touchcancel",m,!0),Ve.bind(document,"touchmove",l,!0),Ve.bind(document,"touchend",u,!0)):(Ve.bind(document,"mousemove",l),Ve.bind(document,"dragstart",Hr),Ve.bind(document,"selectstart",Hr),Ve.bind(document,"mousedown",F,!0),Ve.bind(document,"mouseup",F,!0)),Ve.bind(document,"keyup",p),e.on("element.hover",g),e.on("element.out",h)),s("init")===!1)return m(),!1;A.autoActivate&&l(v,!0)}e.on("diagram.destroy",m),this.init=y,this.move=l,this.hover=g,this.out=h,this.end=u,this.cancel=m,this.context=function(){return r},this.setOptions=function(v){Y(o,v)}}Xx.$inject=["eventBus","canvas","selection","elementRegistry"];const So={__depends__:[FO,Mi],dragging:["type",Xx]};function zr(e){this._counter=0,this._prefix=(e?e+"-":"")+Math.floor(Math.random()*1e9)+"-"}zr.prototype.next=function(){return this._prefix+ ++this._counter};const oD=new zr("ps");var rD=["marker-start","marker-mid","marker-end"],aD=["circle","ellipse","line","path","polygon","polyline","path","rect"];function nr(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}nr.$inject=["elementRegistry","eventBus","canvas","styles"],nr.prototype.cleanUp=function(){console.warn("PreviewSupport#cleanUp is deprecated and will be removed in future versions. You do not need to manually clean up previews anymore. cf. https://github.com/bpmn-io/diagram-js/pull/906")},nr.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},nr.prototype.addDragger=function(e,t,n,i="djs-dragger"){n=n||this.getGfx(e);var o=Nf(n);return this._cloneMarkers(Ko(o),i),Ie(o,this._styles.cls(i,[])),tt(t,o),Ie(o,"data-preview-support-element-id",e.id),o},nr.prototype.addFrame=function(e,t){var n=He("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return tt(t,n),Ie(n,"data-preview-support-element-id",e.id),n},nr.prototype._cloneMarkers=function(e,t="djs-dragger",n=e){var i=this;e.childNodes&&e.childNodes.forEach(o=>{i._cloneMarkers(o,t,n)}),uD(e)&&rD.forEach(function(o){if(Ie(e,o)){var r=sD(e,o,i._canvas.getContainer());r&&i._cloneMarker(n,e,r,o,t)}})},nr.prototype._cloneMarker=function(e,t,n,i,o="djs-dragger"){var r=[n.id,o,oD.next()].join("-"),a=Ct("marker#"+n.id,e);e=e||this._canvas._svg;var s=a||Nf(n);s.id=r,dt(s).add(o);var c=Ct(":scope > defs",e);c||(c=He("defs"),tt(e,c)),tt(c,s);var l=lD(s.id);Ie(t,i,l)};function sD(e,t,n){var i=cD(Ie(e,t));return Ct("marker#"+i,n||document)}function cD(e){return e.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]}function lD(e){return"url(#"+e+")"}function uD(e){return aD.indexOf(e.nodeName)!==-1}const Na={__init__:["previewSupport"],previewSupport:["type",nr]};var pD="drop-ok",Zx="drop-not-ok",Qx="attach-ok",Jx="new-parent",ew="create",fD=2e3;function tw(e,t,n,i,o){function r(c,l,u,p,f){if(!l)return!1;c=ct(c,function(y){var v=y.labelTarget;return!y.parent&&!(at(y)&&c.indexOf(v)!==-1)});var d=It(c,function(y){return!Ot(y)}),g=!1,h=!1,m=!1;iw(c)&&(g=o.allowed("shape.attach",{position:u,shape:d,target:l})),g||(iw(c)?m=o.allowed("shape.create",{position:u,shape:d,source:p,target:l}):m=o.allowed("elements.create",{elements:c,position:u,target:l}));var w=f.connectionTarget;return m||g?(d&&p&&(h=o.allowed("connection.create",{source:w===p?d:p,target:w===p?p:d,hints:{targetParent:l,targetAttach:g}})),{attach:g,connect:h}):m===null||g===null?null:!1}function a(c,l){[Qx,pD,Zx,Jx].forEach(function(u){u===l?e.addMarker(c,u):e.removeMarker(c,u)})}n.on(["create.move","create.hover"],function(c){var l=c.context,u=l.elements,p=c.hover,f=l.source,d=l.hints||{};if(!p){l.canExecute=!1,l.target=null;return}nw(c);var g={x:c.x,y:c.y},h=l.canExecute=p&&r(u,p,g,f,d);p&&h!==null&&(l.target=p,h&&h.attach?a(p,Qx):a(p,h?Jx:Zx))}),n.on(["create.end","create.out","create.cleanup"],function(c){var l=c.hover;l&&a(l,null)}),n.on("create.end",function(c){var l=c.context,u=l.source,p=l.shape,f=l.elements,d=l.target,g=l.canExecute,h=g&&g.attach,m=g&&g.connect,w=l.hints||{};if(g===!1||!d)return!1;nw(c);var y={x:c.x,y:c.y};m?p=i.appendShape(u,p,y,d,{attach:h,connection:m===!0?{}:m,connectionTarget:w.connectionTarget}):(f=i.createElements(f,y,d,Y({},w,{attach:h})),p=It(f,function(v){return!Ot(v)})),Y(l,{elements:f,shape:p}),Y(c,{elements:f,shape:p})});function s(){var c=t.context();c&&c.prefix===ew&&t.cancel()}n.on("create.init",function(){n.on("elements.changed",s),n.once(["create.cancel","create.end"],fD,function(){n.off("elements.changed",s)})}),this.start=function(c,l,u){Ze(l)||(l=[l]);var p=It(l,function(g){return!Ot(g)});if(p){u=Y({elements:l,hints:{},shape:p},u||{}),V(l,function(g){Qe(g.x)||(g.x=0),Qe(g.y)||(g.y=0)});var f=ct(l,function(g){return!g.hidden}),d=cn(f);V(l,function(g){Ot(g)&&(g.waypoints=Fn(g.waypoints,function(h){return{x:h.x-d.x-d.width/2,y:h.y-d.y-d.height/2}})),Y(g,{x:g.x-d.x-d.width/2,y:g.y-d.y-d.height/2})}),t.init(c,ew,{cursor:"grabbing",autoActivate:!0,data:{shape:p,elements:l,context:u}})}}}tw.$inject=["canvas","dragging","eventBus","modeling","rules"];function nw(e){var t=e.context,n=t.createConstraints;n&&(n.left&&(e.x=Math.max(e.x,n.left)),n.right&&(e.x=Math.min(e.x,n.right)),n.top&&(e.y=Math.max(e.y,n.top)),n.bottom&&(e.y=Math.min(e.y,n.bottom)))}function iw(e){return e&&e.length===1&&!Ot(e[0])}var dD=750;function ow(e,t,n,i,o){function r(a){var s=He("g");Ie(s,o.cls("djs-drag-group",["no-events"]));var c=He("g");return a.forEach(function(l){var u;l.hidden||(l.waypoints?(u=n._createContainer("connection",c),n.drawConnection(Ko(u),l)):(u=n._createContainer("shape",c),n.drawShape(Ko(u),l),Dn(u,l.x,l.y)),i.addDragger(l,s,u))}),s}t.on("create.move",dD,function(a){var s=a.hover,c=a.context,l=c.elements,u=c.dragGroup;u||(u=c.dragGroup=r(l));var p;s?(u.parentNode||(p=e.getActiveLayer(),tt(p,u)),Dn(u,a.x,a.y)):sn(u)}),t.on("create.cleanup",function(a){var s=a.context,c=s.dragGroup;c&&sn(c)})}ow.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];const ou={__depends__:[So,Na,io,Mi],__init__:["create","createPreview"],create:["type",tw],createPreview:["type",ow]};function sh(e){var t=this;this._lastMoveEvent=null;function n(i){t._lastMoveEvent=i}e.on("canvas.init",function(i){var o=t._svg=i.svg;o.addEventListener("mousemove",n)}),e.on("canvas.destroy",function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)})}sh.$inject=["eventBus"],sh.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||hD(0,0)};function hD(e,t){var n=document.createEvent("MouseEvent"),i=e,o=t,r=e,a=t;return n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,o,r,a,!1,!1,!1,!1,0,null),n}const zs={__init__:["mouse"],mouse:["type",sh]};var rw=2e3;function si(e,t,n,i,o,r,a,s){this._canvas=e,this._create=t,this._elementFactory=i,this._eventBus=o,this._modeling=r,this._mouse=a,this._rules=s,o.on("copyPaste.copyElement",function(c){var l=c.descriptor,u=c.element,p=c.elementsSet;l.priority=1,l.id=u.id,p.has(u.parent)&&(l.parent=u.parent.id),gD(u)&&(l.priority=2,l.host=u.host.id),Ot(u)&&(l.priority=3,l.source=u.source.id,l.target=u.target.id,l.waypoints=mD(u)),at(u)&&(l.priority=4,l.labelTarget=u.labelTarget.id),V(["x","y","width","height"],function(f){Qe(u[f])&&(l[f]=u[f])}),l.hidden=u.hidden,l.collapsed=u.collapsed}),o.on("copyPaste.elementsCopied",rw,function(c){var l;((l=c.hints)==null?void 0:l.clip)!==!1&&n.set(c.tree)}),o.on("copyPaste.pasteElements",rw,function(c){c.tree||(c.tree=n.get())}),o.on("copyPaste.pasteElements",function(c){var l=c.hints;Y(l,{createElementsBehavior:!1})})}si.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],si.prototype.copy=function(e,t={}){var n,i;return Ze(e)||(e=e?[e]:[]),n=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}),n===!1?i={}:i=this.createTree(Ze(n)?n:e),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:i,hints:t}),i},si.prototype.paste=function(e={}){var t=this._eventBus.createEvent({type:"copyPaste.pasteElements",hints:{},...e}),n=this._eventBus.fire(t);if(n!==!1){var i=t.tree;if(i){var o=t.hints,r=this._createElements(i);if(t.element&&t.point)return this._paste(r,t.element,t.point,o);this._create.start(this._mouse.getLastMoveEvent(),r,{hints:o})}}},si.prototype.duplicate=function(e,t={}){var n=this.copy(e,{clip:!1});return this.paste({...t,tree:n})},si.prototype.cut=function(e){var t=this.copy(e),n=this._getElementIdsFromTree(t),i=e.filter(function(o){return n[o.id]});return i.length>0&&this._modeling.removeElements(i),t},si.prototype._getElementIdsFromTree=function(e){var t={};return V(e,function(n){V(n,function(i){i.id&&(t[i.id]=!0)})}),t},si.prototype._paste=function(e,t,n,i){V(e,function(r){Qe(r.x)||(r.x=0),Qe(r.y)||(r.y=0)});var o=cn(e);return V(e,function(r){Ot(r)&&(r.waypoints=Fn(r.waypoints,function(a){return{x:a.x-o.x-o.width/2,y:a.y-o.y-o.height/2}})),Y(r,{x:r.x-o.x-o.width/2,y:r.y-o.y-o.height/2})}),this._modeling.createElements(e,n,t,Y({},i))},si.prototype._createElements=function(e){var t=this,n=this._eventBus,i={},o=[];return V(e,function(r,a){r=qi(r,"priority"),V(r,function(s){var c=Y({},Yi(s,["priority"]));i[s.parent]?c.parent=i[s.parent]:delete c.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:c});var l;if(Ot(c)){c.source=i[s.source],c.target=i[s.target],l=i[s.id]=t.createConnection(c),o.push(l);return}if(at(c)){c.labelTarget=i[c.labelTarget],l=i[s.id]=t.createLabel(c),o.push(l);return}c.host&&(c.host=i[c.host]),l=i[s.id]=t.createShape(c),o.push(l)})}),o},si.prototype.createConnection=function(e){var t=this._elementFactory.createConnection(Yi(e,["id"]));return t},si.prototype.createLabel=function(e){var t=this._elementFactory.createLabel(Yi(e,["id"]));return t},si.prototype.createShape=function(e){var t=this._elementFactory.createShape(Yi(e,["id"]));return t},si.prototype.hasRelations=function(e,t,n){return n||(n=new Set(t)),!(Ot(e)&&(!n.has(e.source)||!n.has(e.target))||at(e)&&!n.has(e.labelTarget))},si.prototype.createTree=function(e){var t=this._rules,n=this,i={},o=[],r=new Map,a=ml(e);function s(p,f){return t.allowed("element.copy",{element:p,elements:f})}function c(p,f){var d=r.get(p);if(!d){var g={element:p,depth:f};o.push(g),r.set(p,g);return}if(d.depth<f){o=l(d,o);var h={element:d.element,depth:f};o.push(h),r.set(p,h)}}function l(p,f){var d=f.indexOf(p);return d!==-1&&f.splice(d,1),f}Br(a,function(p,f,d){if(at(p))return;V(p.labels,function(m){c(m,d)});function g(m){m&&m.length&&V(m,function(w){V(w.labels,function(y){c(y,d)}),c(w,d)})}V([p.attachers,p.incoming,p.outgoing],g),c(p,d);var h=[];return p.children&&(h=p.children.slice()),n._eventBus.fire("copyPaste.createTree",{element:p,children:h}),h}),e=Fn(o,function(p){return p.element});var u=new Set(e);return o=Fn(o,function(p){return p.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:p.descriptor,element:p.element,elements:e,elementsSet:u}),p}),o=qi(o,function(p){return p.descriptor.priority}),e=Fn(o,function(p){return p.element}),V(o,function(p){var f=p.depth;if(!n.hasRelations(p.element,e,u)){sw(p.element,e),u.delete(p.element);return}if(!s(p.element,e)){sw(p.element,e),u.delete(p.element);return}i[f]||(i[f]=[]),i[f].push(p.descriptor)}),i};function gD(e){return!!e.host}function mD(e){return Fn(e.waypoints,function(t){return t=aw(t),t.original&&(t.original=aw(t.original)),t})}function aw(e){return Y({},e)}function sw(e,t){var n=t.indexOf(e);return n===-1?t:t.splice(n,1)}const yD={__depends__:[NO,ou,zs,io],__init__:["copyPaste"],copyPaste:["type",si]};function ch(e,t,n){Ze(n)||(n=[n]),V(n,function(i){Cr(e[i])||(t[i]=e[i])})}var lh=750;function cw(e,t,n){function i(c,l){var u=e.create(c.$type);return n.copyElement(c,u,null,l)}t.on("copyPaste.copyElement",lh,function(c){var l=c.descriptor,u=c.element,p=_e(u);if(at(u))return l;var f=l.businessObject=i(p,!0),d=l.di=i(mt(u),!0);d.bpmnElement=f,ch(f,l,"name"),ch(d,l,"isExpanded"),p.default&&(l.default=p.default.id)});var o="-bpmn-js-refs";function r(c){return c[o]=c[o]||{}}function a(c,l){c[o]=l}function s(c,l,u){var p=_e(c);return c.default&&(u[c.default]={element:p,property:"default"}),c.host&&(_e(c).attachedToRef=_e(l[c.host])),Yi(u,ni(u,function(f,d,g){var h=d.element,m=d.property;return g===c.id&&(h.set(m,p),f.push(c.id)),f},[]))}t.on("copyPaste.pasteElement",function(c){var l=c.cache,u=c.descriptor,p=u.businessObject,f=u.di;if(at(u)){u.businessObject=_e(l[u.labelTarget]),u.di=mt(l[u.labelTarget]);return}p=u.businessObject=i(p),f=u.di=i(f),f.bpmnElement=p,ch(u,p,["isExpanded","name"]),u.type=p.$type}),t.on("copyPaste.copyElement",lh,function(c){var l=c.descriptor,u=c.element;if(M(u,"bpmn:Participant")){var p=_e(u);p.processRef&&(l.processRef=i(p.processRef,!0))}}),t.on("copyPaste.pasteElement",function(c){var l=c.descriptor,u=l.processRef;u&&(l.processRef=i(u))}),t.on("copyPaste.createTree",function(c){var l=c.element,u=c.children;M(l,"bpmn:SubProcess")&&V(Ps(u),p=>{u.push(p.annotation)})}),t.on("copyPaste.pasteElement",lh,function(c){var l=c.cache,u=c.descriptor;a(l,s(u,l,r(l)))})}cw.$inject=["bpmnFactory","eventBus","moddleCopy"];const vD=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"],bD=["errorRef","escalationRef","messageRef","signalRef","dataObjectRef"];function Gs(e,t,n){this._bpmnFactory=t,this._eventBus=e,this._moddle=n,e.on("moddleCopy.canCopyProperties",i=>{const{propertyNames:o}=i;if(!(!o||!o.length))return qi(o,r=>r==="extensionElements")}),e.on("moddleCopy.canCopyProperty",i=>{const{parent:o,property:r,propertyName:a}=i,s=mn(o)&&o.$descriptor;if(a&&bD.includes(a))return r;if(a&&vD.includes(a)||a&&s&&!It(s.properties,ca({name:a})))return!1}),e.on("moddleCopy.canSetCopiedProperty",i=>{const{property:o}=i;if(M(o,"bpmn:ExtensionElements")&&(!o.values||!o.values.length))return!1})}Gs.$inject=["eventBus","bpmnFactory","moddle"],Gs.prototype.copyElement=function(e,t,n,i=!1){n&&!Ze(n)&&(n=[n]),n=n||uh(e.$descriptor);const o=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:i});return o===!1||(Ze(o)&&(n=o),V(n,r=>{let a;ti(e,r)&&(a=e.get(r));const s=this.copyProperty(a,t,r,i);!gn(s)||this._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:s,propertyName:r})===!1||t.set(r,s)})),t},Gs.prototype.copyProperty=function(e,t,n,i=!1){let o=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n,clone:i});if(o===!1)return;if(o)return mn(o)&&o.$type&&!o.$parent&&(o.$parent=t),o;const r=this._moddle.getPropertyDescriptor(t,n);if(!r.isReference)return r.isId?e&&this._copyId(e,t,i):Ze(e)?ni(e,(a,s)=>{const c=this.copyProperty(s,t,n,i);return c?a.concat(c):a},[]):mn(e)&&e.$type?this._moddle.getElementDescriptor(e).isGeneric?void 0:(o=this._bpmnFactory.create(e.$type),o.$parent=t,o=this.copyElement(e,o,null,i),o):e},Gs.prototype._copyId=function(e,t,n=!1){if(n)return e;if(!this._moddle.ids.assigned(e))return this._moddle.ids.claim(e,t),e};function uh(e,t){return ni(e.properties,(n,i)=>t&&i.default?n:n.concat(i.name),[])}const lw={__depends__:[yD],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",cw],moddleCopy:["type",Gs]};var uw=Math.round;function ph(e,t){this._modeling=e,this._eventBus=t}ph.$inject=["modeling","eventBus"],ph.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,o=this._eventBus;o.fire("replace.start",{element:e,attrs:t,hints:n});var r=t.width||e.width,a=t.height||e.height,s=t.x||e.x,c=t.y||e.y,l=uw(s+r/2),u=uw(c+a/2),p=i.replaceShape(e,Y({},t,{x:l,y:u,width:r,height:a}),n);return o.fire("replace.end",{element:e,newElement:p,hints:n}),p};function pw(e,t){t.on("replace.end",500,function(n){const{newElement:i,hints:o={}}=n;o.select!==!1&&e.select(i)})}pw.$inject=["selection","eventBus"];const xD={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",pw],replace:["type",ph]};function wD(e,t,n){Ze(n)||(n=[n]),V(n,function(i){Cr(e[i])||(t[i]=e[i])})}var _D=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function ED(e,t){var n=e&&ti(e,"collapsed")?e.collapsed:!ht(e),i;return t&&(ti(t,"collapsed")||ti(t,"isExpanded"))?i=ti(t,"collapsed")?t.collapsed:!t.isExpanded:i=n,n!==i}function fw(e,t,n,i,o,r){function a(s,c,l){l=l||{};var u=c.type,p=s.businessObject;if(ru(p)&&(u==="bpmn:SubProcess"||u==="bpmn:AdHocSubProcess")&&ED(s,c))return i.toggleCollapse(s),s;var f=e.create(u),d={type:u,businessObject:f};d.di={},u==="bpmn:ExclusiveGateway"&&(d.di.isMarkerVisible=!0),wD(s.di,d.di,["fill","stroke","background-color","border-color","color"]);var g=uh(p.$descriptor),h=uh(f.$descriptor,!0),m=SD(g,h);Y(f,Ni(c,_D));var w=ct(m,function(x){return x==="eventDefinitions"?dw(s,c.eventDefinitionType):x==="loopCharacteristics"?!Gn(f):ti(f,x)||x==="processRef"&&c.isExpanded===!1||x==="triggeredByEvent"?!1:x==="isForCompensation"?!Gn(f):!0});if(f=n.copyElement(p,f,w),c.eventDefinitionType&&(dw(f,c.eventDefinitionType)||(d.eventDefinitionType=c.eventDefinitionType,d.eventDefinitionAttrs=c.eventDefinitionAttrs)),M(p,"bpmn:Activity")){if(ru(p))d.isExpanded=ht(s);else if(c&&ti(c,"isExpanded")){d.isExpanded=c.isExpanded;var y=t.getDefaultSize(f,{isExpanded:d.isExpanded});d.width=y.width,d.height=y.height,d.x=s.x-(d.width-s.width)/2,d.y=s.y-(d.height-s.height)/2}ht(s)&&!M(p,"bpmn:Task")&&d.isExpanded&&(d.width=s.width,d.height=s.height)}if(ru(p)&&!ru(f)&&(l.moveChildren=!1),M(p,"bpmn:Participant")){c.isExpanded===!0?f.processRef=e.create("bpmn:Process"):l.moveChildren=!1;var v=En(s);mt(s).isHorizontal||(mt(d).isHorizontal=v),d.width=v?s.width:t.getDefaultSize(d).width,d.height=v?t.getDefaultSize(d).height:s.height}return r.allowed("shape.resize",{shape:f})||(d.height=t.getDefaultSize(d).height,d.width=t.getDefaultSize(d).width),f.name=p.name,st(p,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&st(f,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(f.default=p.default),c.host&&!M(p,"bpmn:BoundaryEvent")&&M(f,"bpmn:BoundaryEvent")&&(d.host=c.host),(d.type==="bpmn:DataStoreReference"||d.type==="bpmn:DataObjectReference")&&(d.x=s.x+(s.width-d.width)/2),o.replaceElement(s,d,{...l,targetElement:c})}this.replaceElement=a}fw.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];function ru(e){return M(e,"bpmn:SubProcess")}function dw(e,t){var n=_e(e);return t&&n.get("eventDefinitions").some(function(i){return M(i,t)})}function SD(e,t){return e.filter(function(n){return t.includes(n)})}const hw={__depends__:[lw,xD,Mi],bpmnReplace:["type",fw]};var RD=250;function Gr(e){this._eventBus=e,this._tools=[],this._active=null}Gr.$inject=["eventBus"],Gr.prototype.registerTool=function(e,t){var n=this._tools;if(!t)throw new Error(`A tool has to be registered with it's "events"`);n.push(e),this.bindEvents(e,t)},Gr.prototype.isActive=function(e){return e&&this._active===e},Gr.prototype.length=function(e){return this._tools.length},Gr.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},Gr.prototype.bindEvents=function(e,t){var n=this._eventBus,i=[];n.on(t.tool+".init",function(o){var r=o.context;if(!r.reactivate&&this.isActive(e)){this.setActive(null);return}this.setActive(e)},this),V(t,function(o){i.push(o+".ended"),i.push(o+".canceled")}),n.on(i,RD,function(o){this._active&&(CD(o)||this.setActive(null))},this)};function CD(e){var t=e.originalEvent&&e.originalEvent.target;return t&&Lr(t,'.group[data-group="tools"]')}const au={__depends__:[So],__init__:["toolManager"],toolManager:["type",Gr]};function MD(e,t){if(e==="x"){if(t>0)return"e";if(t<0)return"w"}if(e==="y"){if(t>0)return"s";if(t<0)return"n"}return null}function AD(e,t){var n=[],i=new Set(e);V(t,function(r){i.add(r)});var o=new Set;return i.forEach(function(r){var a=r.incoming,s=r.outgoing;V(a.concat(s),function(c){var l=c.source,u=c.target;(i.has(l)||i.has(u))&&(o.has(c)||(o.add(c),n.push(c)))})}),n}function PD(e,t,n){var i=e.x,o=e.y,r=e.width,a=e.height,s=n.x,c=n.y;switch(t){case"n":return{x:i,y:o+c,width:r,height:a-c};case"s":return{x:i,y:o,width:r,height:a+c};case"w":return{x:i+s,y:o,width:r-s,height:a};case"e":return{x:i,y:o,width:r+s,height:a};default:throw new Error("unknown direction: "+t)}}var fh=Math.abs,TD=Math.round,Ro={x:"width",y:"height"},gw="crosshair",ir={n:"top",w:"left",s:"bottom",e:"right"},kD=1500,su={n:"s",w:"e",s:"n",e:"w"},cu=20;function Ai(e,t,n,i,o,r,a){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=i,this._rules=o,this._toolManager=r,this._mouse=a;var s=this;r.registerTool("space",{tool:"spaceTool.selection",dragging:"spaceTool"}),n.on("spaceTool.selection.end",function(c){n.once("spaceTool.selection.ended",function(){s.activateMakeSpace(c.originalEvent)})}),n.on("spaceTool.move",kD,function(c){var l=c.context,u=l.initialized;u||(u=l.initialized=s.init(c,l)),u&&yw(c)}),n.on("spaceTool.end",function(c){var l=c.context,u=l.axis,p=l.direction,f=l.movingShapes,d=l.resizingShapes,g=l.start;if(l.initialized){yw(c);var h={x:0,y:0};h[u]=TD(c["d"+u]),s.makeSpace(f,d,h,p,g),n.once("spaceTool.ended",function(m){s.activateSelection(m.originalEvent,!0,!0)})}})}Ai.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],Ai.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:gw,data:{context:{reactivate:n}},trapClick:!1})},Ai.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:gw,data:{context:{}}})},Ai.prototype.makeSpace=function(e,t,n,i,o){return this._modeling.createSpace(e,t,n,i,o)},Ai.prototype.init=function(e,t){var n=fh(e.dx)>fh(e.dy)?"x":"y",i=e["d"+n],o=e[n]-i;if(fh(i)<5)return!1;i<0&&(i*=-1),Fs(e)&&(i*=-1);var r=MD(n,i),a=this._canvas.getRootElement();!Kl(e)&&e.hover&&(a=e.hover);var s=[...Es(a),...a.attachers||[]],c=this.calculateAdjustments(s,n,i,o),l=this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:r,shapes:c.resizingShapes,start:o}),u=OD(c,n,r,o,l);return Y(t,c,{axis:n,direction:r,spaceToolConstraints:u,start:o}),iu("resize-"+(n==="x"?"ew":"ns")),!0},Ai.prototype.calculateAdjustments=function(e,t,n,i){var o=this._rules,r=[],a=[],s=new Set,c=new Set,l=[],u=[];function p(d){s.has(d)||(s.add(d),r.push(d));var g=d.label;g&&!s.has(g)&&(s.add(g),r.push(g))}function f(d){c.has(d)||(c.add(d),a.push(d))}return V(e,function(d){if(!(!d.parent||at(d))){if(Ot(d)){u.push(d);return}var g=d[t],h=g+d[Ro[t]];if(DD(d)&&(n>0&&Je(d)[t]>i||n<0&&Je(d)[t]<i)){l.push(d);return}if(n>0&&g>i||n<0&&h<i){p(d);return}if(g<i&&h>i&&o.allowed("shape.resize",{shape:d})){f(d);return}}}),V(r,function(d){var g=d.attachers;g&&V(g,function(h){p(h)})}),V(l,function(d){var g=d.host;(s.has(g)||c.has(g))&&p(d)}),V(u,function(d){var g=d.source,h=d.target,m=d.label;(s.has(g)||c.has(g))&&(s.has(h)||c.has(h))&&m&&p(m)}),{movingShapes:r,resizingShapes:a}},Ai.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Ai.prototype.isActive=function(){var e=this._dragging.context();return e?/^spaceTool/.test(e.prefix):!1};function mw(e){return{top:e.top-cu,right:e.right+cu,bottom:e.bottom+cu,left:e.left-cu}}function yw(e){var t=e.context,n=t.spaceToolConstraints;if(n){var i,o;Qe(n.left)&&(i=Math.max(e.x,n.left),e.dx=e.dx+i-e.x,e.x=i),Qe(n.right)&&(i=Math.min(e.x,n.right),e.dx=e.dx+i-e.x,e.x=i),Qe(n.top)&&(o=Math.max(e.y,n.top),e.dy=e.dy+o-e.y,e.y=o),Qe(n.bottom)&&(o=Math.min(e.y,n.bottom),e.dy=e.dy+o-e.y,e.y=o)}}function OD(e,t,n,i,o){var r=e.movingShapes,a=e.resizingShapes;if(a.length){var s={},c,l,u=new Set(r),p=new Set(a);return V(a,function(f){var d=f.attachers,g=f.children,h=qe(f),m=ct(g,function(G){return!Ot(G)&&!at(G)&&!u.has(G)&&!p.has(G)}),w=ct(g,function(G){return!Ot(G)&&!at(G)&&u.has(G)}),y,v,x,E=[],A=[],B,P,k,H;m.length&&(v=mw(qe(cn(m))),y=i-h[ir[n]]+v[ir[n]],n==="n"?s.bottom=l=Qe(l)?Math.min(l,y):y:n==="w"?s.right=l=Qe(l)?Math.min(l,y):y:n==="s"?s.top=c=Qe(c)?Math.max(c,y):y:n==="e"&&(s.left=c=Qe(c)?Math.max(c,y):y)),w.length&&(x=mw(qe(cn(w))),y=i-x[ir[su[n]]]+h[ir[su[n]]],n==="n"?s.bottom=l=Qe(l)?Math.min(l,y):y:n==="w"?s.right=l=Qe(l)?Math.min(l,y):y:n==="s"?s.top=c=Qe(c)?Math.max(c,y):y:n==="e"&&(s.left=c=Qe(c)?Math.max(c,y):y)),d&&d.length&&(d.forEach(function(G){u.has(G)?E.push(G):A.push(G)}),E.length&&(B=qe(cn(E.map(Je))),P=h[ir[su[n]]]-(B[ir[su[n]]]-i)),A.length&&(k=qe(cn(A.map(Je))),H=k[ir[n]]-(h[ir[n]]-i)),n==="n"?(y=Math.min(P||1/0,H||1/0),s.bottom=l=Qe(l)?Math.min(l,y):y):n==="w"?(y=Math.min(P||1/0,H||1/0),s.right=l=Qe(l)?Math.min(l,y):y):n==="s"?(y=Math.max(P||-1/0,H||-1/0),s.top=c=Qe(c)?Math.max(c,y):y):n==="e"&&(y=Math.max(P||-1/0,H||-1/0),s.left=c=Qe(c)?Math.max(c,y):y));var F=o&&o[f.id];F&&(n==="n"?(y=i+f[Ro[t]]-F[Ro[t]],s.bottom=l=Qe(l)?Math.min(l,y):y):n==="w"?(y=i+f[Ro[t]]-F[Ro[t]],s.right=l=Qe(l)?Math.min(l,y):y):n==="s"?(y=i-f[Ro[t]]+F[Ro[t]],s.top=c=Qe(c)?Math.max(c,y):y):n==="e"&&(y=i-f[Ro[t]]+F[Ro[t]],s.left=c=Qe(c)?Math.max(c,y):y))}),s}}function DD(e){return!!e.host}var dh="djs-dragging",vw="djs-resizing",LD=250,lu=Math.max;function bw(e,t,n,i,o){function r(a,s){V(a,function(c){o.addDragger(c,s),n.addMarker(c,dh)})}e.on("spaceTool.selection.start",function(a){var s=n.getLayer("space"),c=a.context,l={x:"M 0,-10000 L 0,10000",y:"M -10000,0 L 10000,0"},u=He("g");Ie(u,i.cls("djs-crosshair-group",["no-events"])),tt(s,u);var p=He("path");Ie(p,"d",l.x),dt(p).add("djs-crosshair"),tt(u,p);var f=He("path");Ie(f,"d",l.y),dt(f).add("djs-crosshair"),tt(u,f),c.crosshairGroup=u}),e.on("spaceTool.selection.move",function(a){var s=a.context.crosshairGroup;Dn(s,a.x,a.y)}),e.on("spaceTool.selection.cleanup",function(a){var s=a.context,c=s.crosshairGroup;c&&sn(c)}),e.on("spaceTool.move",LD,function(a){var s=a.context,c=s.line,l=s.axis,u=s.movingShapes,p=s.resizingShapes;if(s.initialized){if(!s.dragGroup){var f=n.getLayer("space");c=He("path"),Ie(c,"d","M0,0 L0,0"),dt(c).add("djs-crosshair"),tt(f,c),s.line=c;var d=He("g");Ie(d,i.cls("djs-drag-group",["no-events"])),tt(n.getActiveLayer(),d),r(u,d);var g=new Set(u);V(p,function(A){g.add(A)});var h=new Set,m=s.movingConnections=[];g.forEach(function(A){V(A.outgoing,function(B){h.has(B)||!Ot(B)||!g.has(B.target)||(h.add(B),m.push(B))})}),r(m,d),s.dragGroup=d}if(!s.frameGroup){var w=He("g");Ie(w,i.cls("djs-frame-group",["no-events"])),tt(n.getActiveLayer(),w);var y=[];V(p,function(A){var B=o.addFrame(A,w),P=B.getBBox();y.push({element:B,initialBounds:P}),n.addMarker(A,vw)}),s.frameGroup=w,s.frames=y}var v={x:"M"+a.x+", -10000 L"+a.x+", 10000",y:"M -10000, "+a.y+" L 10000, "+a.y};Ie(c,{d:v[l]});var x={x:"y",y:"x"},E={x:a.dx,y:a.dy};E[x[s.axis]]=0,Dn(s.dragGroup,E.x,E.y),V(s.frames,function(A){var B=A.element,P=A.initialBounds,k,H;s.direction==="e"?Ie(B,{width:lu(P.width+E.x,5)}):(k=lu(P.width-E.x,5),Ie(B,{width:k,x:P.x+P.width-k})),s.direction==="s"?Ie(B,{height:lu(P.height+E.y,5)}):(H=lu(P.height-E.y,5),Ie(B,{height:H,y:P.y+P.height-H}))})}}),e.on("spaceTool.cleanup",function(a){var s=a.context,c=s.movingShapes,l=s.movingConnections,u=s.resizingShapes,p=s.line,f=s.dragGroup,d=s.frameGroup;V(c,function(g){n.removeMarker(g,dh)}),V(l,function(g){n.removeMarker(g,dh)}),f&&(sn(p),sn(f)),V(u,function(g){n.removeMarker(g,vw)}),d&&sn(d)})}bw.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];const ID={__init__:["spaceToolPreview"],__depends__:[So,io,au,Na,zs],spaceTool:["type",Ai],spaceToolPreview:["type",bw]};function uu(e,t){e.invoke(Ai,this),this._canvas=t}uu.$inject=["injector","canvas"],Ne(uu,Ai),uu.prototype.calculateAdjustments=function(e,t,n,i){var o=this._canvas.getRootElement(),r=e[0]===o?null:e[0],a=[];r&&(a=aa(xa(o.children.filter(l=>M(l,"bpmn:Artifact")),cn(r))));const s=[...e,...a];var c=Ai.prototype.calculateAdjustments.call(this,s,t,n,i);return c.resizingShapes=c.resizingShapes.filter(function(l){return!(M(l,"bpmn:TextAnnotation")||BD(l)&&(t==="y"&&En(l)||t==="x"&&!En(l)))}),c};function BD(e){return M(e,"bpmn:Participant")&&!_e(e).processRef}const xw={__depends__:[ID],spaceTool:["type",uu]};function Ut(e,t){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=t,this._eventBus=e,this._uid=1,e.on(["diagram.destroy","diagram.clear"],function(){this.clear(!1)},this)}Ut.$inject=["eventBus","injector"],Ut.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()},Ut.prototype.canExecute=function(e,t){const n={command:e,context:t},i=this._getHandler(e);let o=this._fire(e,"canExecute",n);if(o===void 0){if(!i)return!1;i.canExecute&&(o=i.canExecute(t))}return o},Ut.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,e!==!1&&this._fire("changed",{trigger:"clear"})},Ut.prototype.undo=function(){let e=this._getUndoAction(),t;if(e){for(this._currentExecution.trigger="undo",this._pushAction(e);e&&(this._internalUndo(e),t=this._getUndoAction(),!(!t||t.id!==e.id));)e=t;this._popAction()}},Ut.prototype.redo=function(){let e=this._getRedoAction(),t;if(e){for(this._currentExecution.trigger="redo",this._pushAction(e);e&&(this._internalExecute(e,!0),t=this._getRedoAction(),!(!t||t.id!==e.id));)e=t;this._popAction()}},Ut.prototype.register=function(e,t){this._setHandler(e,t)},Ut.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(t);this.register(e,n)},Ut.prototype.canUndo=function(){return!!this._getUndoAction()},Ut.prototype.canRedo=function(){return!!this._getRedoAction()},Ut.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},Ut.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},Ut.prototype._internalUndo=function(e){const t=e.command,n=e.context,i=this._getHandler(t);this._atomicDo(()=>{this._fire(t,"revert",e),i.revert&&this._markDirty(i.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)})},Ut.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);const i=t?[e+"."+t,t]:[e];let o;n=this._eventBus.createEvent(n);for(const r of i)if(o=this._eventBus.fire("commandStack."+r,n),n.cancelBubble)break;return o},Ut.prototype._createId=function(){return this._uid++},Ut.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},Ut.prototype._internalExecute=function(e,t){const n=e.command,i=e.context,o=this._getHandler(n);if(!o)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),o.preExecute&&o.preExecute(i),this._fire(n,"preExecuted",e)),this._atomicDo(()=>{this._fire(n,"execute",e),o.execute&&this._markDirty(o.execute(i)),this._executedAction(e,t),this._fire(n,"executed",e)}),t||(this._fire(n,"postExecute",e),o.postExecute&&o.postExecute(i),this._fire(n,"postExecuted",e)),this._popAction()},Ut.prototype._pushAction=function(e){const t=this._currentExecution,n=t.actions,i=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=i&&i.id||this._createId()),n.push(e)},Ut.prototype._popAction=function(){const e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:tm("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},Ut.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=Ze(e)?e:[e],t.dirty=t.dirty.concat(e))},Ut.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},Ut.prototype._revertedAction=function(e){this._stackIdx--},Ut.prototype._getHandler=function(e){return this._handlerMap[e]},Ut.prototype._setHandler=function(e,t){if(!e||!t)throw new Error("command and handler required");if(this._handlerMap[e])throw new Error("overriding handler for command <"+e+">");this._handlerMap[e]=t};const ND={commandStack:["type",Ut]};function or(e,t){if(typeof t!="function")throw new Error("removeFn iterator must be a function");if(!e)return[];for(var n;n=e[0];)t(n);return e}var $D=250,ww=1400;function hh(e,t,n){we.call(this,t);var i=e.get("movePreview",!1);t.on("shape.move.start",ww,function(o){var r=o.context,a=r.shapes,s=r.validatedShapes;r.shapes=_w(a),r.validatedShapes=_w(s)}),i&&t.on("shape.move.start",$D,function(o){var r=o.context,a=new Set(r.shapes),s=new Set;for(const c of a)for(const l of c.labels)!l.hidden&&!a.has(l)&&s.add(l),c.labelTarget&&s.add(c);for(const c of s)i.makeDraggable(r,c,!0)}),this.preExecuted("elements.move",ww,function(o){var r=o.context,a=r.closure,s=a.enclosedElements,c=[];V(s,function(l){V(l.labels,function(u){s[u.id]||c.push(u)})}),a.addAll(c)}),this.preExecute(["connection.delete","shape.delete"],function(o){var r=o.context,a=r.connection||r.shape;or(a.labels,function(s){n.removeShape(s,{nested:!0})})}),this.execute("shape.delete",function(o){var r=o.context,a=r.shape,s=a.labelTarget;s&&(r.labelTargetIndex=qf(s.labels,a),r.labelTarget=s,a.labelTarget=null)}),this.revert("shape.delete",function(o){var r=o.context,a=r.shape,s=r.labelTarget,c=r.labelTargetIndex;s&&(on(s.labels,a,c),a.labelTarget=s)})}Ne(hh,we),hh.$inject=["injector","eventBus","modeling"];function _w(e){var t=new Set(e);return ct(e,function(n){return!t.has(n.labelTarget)})}const FD={__init__:["labelSupport"],labelSupport:["type",hh]};var jD=251,Ew=1401,Sw="attach-ok";function gh(e,t,n,i,o){we.call(this,t);var r=e.get("movePreview",!1);t.on("shape.move.start",Ew,function(a){var s=a.context,c=s.shapes,l=s.validatedShapes;s.shapes=HD(c),s.validatedShapes=zD(l)}),r&&t.on("shape.move.start",jD,function(a){var s=a.context,c=s.shapes,l=mh(c);V(l,function(u){r.makeDraggable(s,u,!0),V(u.labels,function(p){r.makeDraggable(s,p,!0)})})}),r&&t.on("shape.move.start",function(a){var s=a.context,c=s.shapes;if(c.length===1){var l=c[0],u=l.host;u&&(n.addMarker(u,Sw),t.once(["shape.move.out","shape.move.cleanup"],function(){n.removeMarker(u,Sw)}))}}),this.preExecuted("elements.move",Ew,function(a){var s=a.context,c=s.closure,l=s.shapes,u=mh(l);V(u,function(p){c.add(p,c.topLevel[p.host.id])})}),this.postExecuted("elements.move",function(a){var s=a.context,c=s.shapes,l=s.newHost,u;l&&c.length!==1||(l?u=c:u=ct(c,function(p){var f=p.host;return GD(p)&&!VD(c,f)}),V(u,function(p){o.updateAttachment(p,l)}))}),this.postExecuted("elements.move",function(a){var s=a.context.shapes;V(s,function(c){V(c.attachers,function(l){V(l.outgoing.slice(),function(u){var p=i.allowed("connection.reconnect",{connection:u,source:u.source,target:u.target});p||o.removeConnection(u)}),V(l.incoming.slice(),function(u){var p=i.allowed("connection.reconnect",{connection:u,source:u.source,target:u.target});p||o.removeConnection(u)})})})}),this.postExecute("shape.create",function(a){var s=a.context,c=s.shape,l=s.host;l&&o.updateAttachment(c,l)}),this.postExecute("shape.replace",function(a){var s=a.context,c=s.oldShape,l=s.newShape;or(c.attachers,function(u){var p=i.allowed("elements.move",{target:l,shapes:[u]});p==="attach"?o.updateAttachment(u,l):o.removeShape(u)}),l.attachers.length&&V(l.attachers,function(u){var p=zb(u,c,l);o.moveShape(u,p,u.parent)})}),this.postExecute("shape.resize",function(a){var s=a.context,c=s.shape,l=s.oldBounds,u=s.newBounds,p=c.attachers,f=s.hints||{};f.attachSupport!==!1&&V(p,function(d){var g=zb(d,l,u);o.moveShape(d,g,d.parent),V(d.labels,function(h){o.moveShape(h,g,h.parent)})})}),this.preExecute("shape.delete",function(a){var s=a.context.shape;or(s.attachers,function(c){o.removeShape(c)}),s.host&&o.updateAttachment(s,null)})}Ne(gh,we),gh.$inject=["injector","eventBus","canvas","rules","modeling"];function mh(e){return Ip(Fn(e,function(t){return t.attachers||[]}))}function HD(e){var t=mh(e);return zS("id",e,t)}function zD(e){var t=sa(e,"id");return ct(e,function(n){for(;n;){if(n.host&&t[n.host.id])return!1;n=n.parent}return!0})}function GD(e){return!!e.host}function VD(e,t){return e.indexOf(t)!==-1}const WD={__depends__:[io],__init__:["attachSupport"],attachSupport:["type",gh]};function Rw(e,t,n,i){e.on("element.changed",function(o){var r=o.element;(r.parent||r===t.getRootElement())&&(o.gfx=n.getGraphics(r)),o.gfx&&e.fire(yv(r)+".changed",o)}),e.on("elements.changed",function(o){var r=o.elements;r.forEach(function(a){e.fire("element.changed",{element:a})}),i.updateContainments(r)}),e.on("shape.changed",function(o){i.update("shape",o.element,o.gfx)}),e.on("connection.changed",function(o){i.update("connection",o.element,o.gfx)})}Rw.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];const yh={__init__:["changeSupport"],changeSupport:["type",Rw]};function Pi(e){this._model=e}Pi.$inject=["moddle"],Pi.prototype._needsId=function(e){return st(e,["bpmn:RootElement","bpmn:FlowElement","bpmn:MessageFlow","bpmn:DataAssociation","bpmn:Artifact","bpmn:Participant","bpmn:Lane","bpmn:LaneSet","bpmn:Process","bpmn:Collaboration","bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane","bpmn:Property","bpmn:CategoryValue"])},Pi.prototype._ensureId=function(e){if(e.id){this._model.ids.claim(e.id,e);return}var t;M(e,"bpmn:Activity")?t="Activity":M(e,"bpmn:Event")?t="Event":M(e,"bpmn:Gateway")?t="Gateway":st(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?t="Flow":t=(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e))},Pi.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},Pi.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},Pi.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",Y({bpmnElement:e,bounds:this.createDiBounds()},t))},Pi.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},Pi.prototype.createDiWaypoints=function(e){var t=this;return Fn(e,function(n){return t.createDiWaypoint(n)})},Pi.prototype.createDiWaypoint=function(e){return this.create("dc:Point",Ni(e,["x","y"]))},Pi.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",Y({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))},Pi.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",Y({bpmnElement:e},t))};function ci(e,t,n){we.call(this,e),this._bpmnFactory=t;var i=this;function o(d){var g=d.context,h=g.hints||{},m;!g.cropped&&h.createElementsBehavior!==!1&&(m=g.connection,m.waypoints=n.getCroppedWaypoints(m),g.cropped=!0)}this.executed(["connection.layout","connection.create"],o),this.reverted(["connection.layout"],function(d){delete d.context.cropped});function r(d){var g=d.context;i.updateParent(g.shape||g.connection,g.oldParent)}function a(d){var g=d.context,h=g.shape||g.connection,m=g.parent||g.newParent;i.updateParent(h,m)}this.executed(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],li(r)),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],li(a));function s(d){var g=d.context,h=g.oldRoot,m=h.children;V(m,function(w){M(w,"bpmn:BaseElement")&&i.updateParent(w)})}this.executed(["canvas.updateRoot"],s),this.reverted(["canvas.updateRoot"],s);function c(d){var g=d.context.shape;M(g,"bpmn:BaseElement")&&i.updateBounds(g)}this.executed(["shape.move","shape.create","shape.resize"],li(function(d){d.context.shape.type!=="label"&&c(d)})),this.reverted(["shape.move","shape.create","shape.resize"],li(function(d){d.context.shape.type!=="label"&&c(d)})),e.on("shape.changed",function(d){d.element.type==="label"&&c({context:{shape:d.element}})});function l(d){i.updateConnection(d.context)}this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],li(l)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],li(l));function u(d){i.updateConnectionWaypoints(d.context.connection)}this.executed(["connection.layout","connection.move","connection.updateWaypoints"],li(u)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],li(u)),this.executed("connection.reconnect",li(function(d){var g=d.context,h=g.connection,m=g.oldSource,w=g.newSource,y=_e(h),v=_e(m),x=_e(w);y.conditionExpression&&!st(x,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(g.oldConditionExpression=y.conditionExpression,delete y.conditionExpression),m!==w&&v.default===y&&(g.oldDefault=v.default,delete v.default)})),this.reverted("connection.reconnect",li(function(d){var g=d.context,h=g.connection,m=g.oldSource,w=g.newSource,y=_e(h),v=_e(m),x=_e(w);g.oldConditionExpression&&(y.conditionExpression=g.oldConditionExpression),g.oldDefault&&(v.default=g.oldDefault,delete x.default)}));function p(d){i.updateAttachment(d.context)}this.executed(["element.updateAttachment"],li(p)),this.reverted(["element.updateAttachment"],li(p)),this.executed("element.updateLabel",li(f)),this.reverted("element.updateLabel",li(f));function f(d){const{element:g}=d.context,h=vi(g),m=mt(g),w=m&&m.get("label");Zo(g)||Xl(g)||(h&&!w?m.set("label",t.create("bpmndi:BPMNLabel")):!h&&w&&m.set("label",void 0))}}Ne(ci,we),ci.$inject=["eventBus","bpmnFactory","connectionDocking"],ci.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},ci.prototype.updateParent=function(e,t){if(!at(e)&&!(M(e,"bpmn:DataStoreReference")&&e.parent&&M(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,o=mt(e),r=n&&n.businessObject,a=mt(n);M(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,r,t&&t.businessObject),M(e,"bpmn:DataOutputAssociation")&&(e.source?r=e.source.businessObject:r=null),M(e,"bpmn:DataInputAssociation")&&(e.target?r=e.target.businessObject:r=null),this.updateSemanticParent(i,r),M(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,r),this.updateDiParent(o,a)}},ci.prototype.updateBounds=function(e){var t=mt(e),n=qD(e);if(n){var i=Gi(n,t.get("bounds"));Y(n,{x:e.x+i.x,y:e.y+i.y})}var o=at(e)?this._getLabel(t):t,r=o.bounds;r||(r=this._bpmnFactory.createDiBounds(),o.set("bounds",r)),Y(r,{x:e.x,y:e.y,width:e.width,height:e.height})},ci.prototype.updateFlowNodeRefs=function(e,t,n){if(n!==t){var i,o;M(n,"bpmn:Lane")&&(i=n.get("flowNodeRef"),tn(i,e)),M(t,"bpmn:Lane")&&(o=t.get("flowNodeRef"),on(o,e))}},ci.prototype.updateDiConnection=function(e,t,n){var i=mt(e),o=mt(t),r=mt(n);i.sourceElement&&i.sourceElement.bpmnElement!==_e(t)&&(i.sourceElement=t&&o),i.targetElement&&i.targetElement.bpmnElement!==_e(n)&&(i.targetElement=n&&r)},ci.prototype.updateDiParent=function(e,t){if(t&&!M(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(tn(n,e),e.$parent=null)}};function UD(e){for(;e&&!M(e,"bpmn:Definitions");)e=e.$parent;return e}ci.prototype.getLaneSet=function(e){var t,n;return M(e,"bpmn:Lane")?(t=e.childLaneSet,t||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(M(e,"bpmn:Participant")&&(e=e.processRef),n=e.get("laneSets"),t=n[0],t||(t=this._bpmnFactory.create("bpmn:LaneSet"),t.$parent=e,n.push(t)),t)},ci.prototype.updateSemanticParent=function(e,t,n){var i;if(e.$parent!==t&&!((M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput"))&&(M(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),"ioSpecification"in t&&t.ioSpecification===e.$parent))){if(M(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(M(e,"bpmn:FlowElement")){if(t){if(M(t,"bpmn:Participant"))t=t.processRef;else if(M(t,"bpmn:Lane"))do t=t.$parent.$parent;while(M(t,"bpmn:Lane"))}i="flowElements"}else if(M(e,"bpmn:Artifact")){for(;t&&!M(t,"bpmn:Process")&&!M(t,"bpmn:SubProcess")&&!M(t,"bpmn:Collaboration");)if(M(t,"bpmn:Participant")){t=t.processRef;break}else t=t.$parent;i="artifacts"}else if(M(e,"bpmn:MessageFlow"))i="messageFlows";else if(M(e,"bpmn:Participant")){i="participants";var o=e.processRef,r;o&&(r=UD(e.$parent||t),e.$parent&&(tn(r.get("rootElements"),o),o.$parent=null),t&&(on(r.get("rootElements"),o),o.$parent=r))}else M(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":M(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var a;if(e.$parent&&(a=e.$parent.get(i),tn(a,e)),t?(a=t.get(i),a.push(e),e.$parent=t):e.$parent=null,n){var s=n.get(i);tn(a,e),t&&(s||(s=[],t.set(i,s)),s.push(e))}}},ci.prototype.updateConnectionWaypoints=function(e){var t=mt(e);t.set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},ci.prototype.updateConnection=function(e){var t=e.connection,n=_e(t),i=t.source,o=_e(i),r=t.target,a=_e(t.target),s;if(M(n,"bpmn:DataAssociation"))M(n,"bpmn:DataInputAssociation")?(n.get("sourceRef")[0]=o,s=e.parent||e.newParent||a,this.updateSemanticParent(n,a,s)):M(n,"bpmn:DataOutputAssociation")&&(s=e.parent||e.newParent||o,this.updateSemanticParent(n,o,s),n.targetRef=a);else{var c=M(n,"bpmn:SequenceFlow");n.sourceRef!==o&&(c&&(tn(n.sourceRef&&n.sourceRef.get("outgoing"),n),o&&o.get("outgoing")&&o.get("outgoing").push(n)),n.sourceRef=o),n.targetRef!==a&&(c&&(tn(n.targetRef&&n.targetRef.get("incoming"),n),a&&a.get("incoming")&&a.get("incoming").push(n)),n.targetRef=a)}this.updateConnectionWaypoints(t),this.updateDiConnection(t,i,r)},ci.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label};function li(e){return function(t){var n=t.context,i=n.shape||n.connection||n.element;M(i,"bpmn:BaseElement")&&e(t)}}function qD(e){if(M(e,"bpmn:Activity")){var t=mt(e);if(t){var n=t.get("label");if(n)return n.get("bounds")}}}function rr(e,t){xo.call(this),this._bpmnFactory=e,this._moddle=t}Ne(rr,xo),rr.$inject=["bpmnFactory","moddle"],rr.prototype._baseCreate=xo.prototype.create,rr.prototype.create=function(e,t){if(e==="label"){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,Y({type:"label",di:n},Nr,t))}return this.createElement(e,t)},rr.prototype.createElement=function(e,t){t=Y({},t||{});var n,i=t.businessObject,o=t.di;if(!i){if(!t.type)throw new Error("no shape type specified");i=this._bpmnFactory.create(t.type)}if(!KD(o)){var r=Y({},o||{},{id:i.id+"_di"});e==="root"?o=this._bpmnFactory.createDiPlane(i,r):e==="connection"?o=this._bpmnFactory.createDiEdge(i,r):o=this._bpmnFactory.createDiShape(i,r)}M(i,"bpmn:Group")&&(t=Y({isFrame:!0},t)),t=YD(i,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=vh(o,t,"isExpanded")),st(i,["bpmn:Lane","bpmn:Participant"])&&(t=vh(o,t,"isHorizontal")),M(i,"bpmn:SubProcess")&&(t.collapsed=!ht(i,o)),M(i,"bpmn:ExclusiveGateway")&&(ti(o,"isMarkerVisible")?o.isMarkerVisible===void 0&&(o.isMarkerVisible=!1):o.isMarkerVisible=!0),gn(t.triggeredByEvent)&&(i.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),gn(t.cancelActivity)&&(i.cancelActivity=t.cancelActivity,delete t.cancelActivity);var a,s;return t.eventDefinitionType&&(a=i.get("eventDefinitions")||[],s=this._bpmnFactory.create(t.eventDefinitionType,t.eventDefinitionAttrs),t.eventDefinitionType==="bpmn:ConditionalEventDefinition"&&(s.condition=this._bpmnFactory.create("bpmn:FormalExpression")),a.push(s),s.$parent=i,i.eventDefinitions=a,delete t.eventDefinitionType),n=this.getDefaultSize(i,o),t=Y({id:i.id},n,t,{businessObject:i,di:o}),this._baseCreate(e,t)},rr.prototype.getDefaultSize=function(e,t){var n=_e(e);if(t=t||mt(e),M(n,"bpmn:SubProcess"))return ht(n,t)?{width:350,height:200}:{width:100,height:80};if(M(n,"bpmn:Task"))return{width:100,height:80};if(M(n,"bpmn:Gateway"))return{width:50,height:50};if(M(n,"bpmn:Event"))return{width:36,height:36};if(M(n,"bpmn:Participant")){var i=t.isHorizontal===void 0||t.isHorizontal===!0;return ht(n,t)?i?{width:600,height:250}:{width:250,height:600}:i?{width:400,height:60}:{width:60,height:400}}return M(n,"bpmn:Lane")?{width:400,height:100}:M(n,"bpmn:DataObjectReference")?{width:36,height:50}:M(n,"bpmn:DataStoreReference")?{width:50,height:50}:M(n,"bpmn:TextAnnotation")?{width:100,height:40}:M(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},rr.prototype.createParticipantShape=function(e){return mn(e)||(e={isExpanded:e}),e=Y({type:"bpmn:Participant"},e||{}),e.isExpanded!==!1&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)};function YD(e,t,n){return V(n,function(i){t=vh(e,t,i)}),t}function vh(e,t,n){return t[n]===void 0?t:(e[n]=t[n],Yi(t,[n]))}function KD(e){return st(e,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])}function pu(e,t){this._modeling=e,this._canvas=t}pu.$inject=["modeling","canvas"],pu.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;V(n,function(o){var r={x:0,y:0};gn(i.left)?r.x=i.left-o.x:gn(i.right)?r.x=i.right-o.width-o.x:gn(i.center)?r.x=i.center-Math.round(o.width/2)-o.x:gn(i.top)?r.y=i.top-o.y:gn(i.bottom)?r.y=i.bottom-o.height-o.y:gn(i.middle)&&(r.y=i.middle-Math.round(o.height/2)-o.y),t.moveElements([o],r,o.parent)})},pu.prototype.postExecute=function(e){};function fu(e){this._modeling=e}fu.$inject=["modeling"],fu.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,i=e.shape,o=e.hints||{};i=e.shape=this._modeling.createShape(i,e.position,n,{attach:o.attach}),e.shape=i},fu.prototype.postExecute=function(e){var t=e.hints||{};XD(e.source,e.shape)||(t.connectionTarget===e.source?this._modeling.connect(e.shape,e.source,e.connection):this._modeling.connect(e.source,e.shape,e.connection))};function XD(e,t){return Bo(e.outgoing,function(n){return n.target===t})}function du(e,t){this._canvas=e,this._layouter=t}du.$inject=["canvas","layouter"],du.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,o=e.parent,r=e.parentIndex,a=e.hints;if(!n||!i)throw new Error("source and target required");if(!o)throw new Error("parent required");return t.source=n,t.target=i,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,a)),this._canvas.addConnection(t,o,r),t},du.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var hu=Math.round;function bh(e){this._modeling=e}bh.$inject=["modeling"],bh.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,o=e.position,r=e.hints,a=this._modeling;V(t,function(p){Qe(p.x)||(p.x=0),Qe(p.y)||(p.y=0)});var s=ct(t,function(p){return!p.hidden}),c=cn(s);V(t,function(p){Ot(p)&&(p.waypoints=Fn(p.waypoints,function(f){return{x:hu(f.x-c.x-c.width/2+o.x),y:hu(f.y-c.y-c.height/2+o.y)}})),Y(p,{x:hu(p.x-c.x-c.width/2+o.x),y:hu(p.y-c.y-c.height/2+o.y)})});var l=new Set(ml(t)),u={};V(t,function(p){if(Ot(p)){u[p.id]=Qe(i)?a.createConnection(u[p.source.id],u[p.target.id],i,p,p.parent||n,r):a.createConnection(u[p.source.id],u[p.target.id],p,p.parent||n,r);return}var f=Y({},r);l.has(p)||(f.autoResize=!1),at(p)&&(f=Yi(f,["attach"])),u[p.id]=Qe(i)?a.createShape(p,Ni(p,["x","y","width","height"]),p.parent||n,i,f):a.createShape(p,Ni(p,["x","y","width","height"]),p.parent||n,f)}),e.elements=aa(u)};var Cw=Math.round;function ar(e){this._canvas=e}ar.$inject=["canvas"],ar.prototype.execute=function(e){var t=e.shape,n=e.position,i=e.parent,o=e.parentIndex;if(!i)throw new Error("parent required");if(!n)throw new Error("position required");return n.width!==void 0?Y(t,n):Y(t,{x:n.x-Cw(t.width/2),y:n.y-Cw(t.height/2)}),this._canvas.addShape(t,i,o),t},ar.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t};function Vs(e){ar.call(this,e)}Ne(Vs,ar),Vs.$inject=["canvas"];var ZD=ar.prototype.execute;Vs.prototype.execute=function(e){var t=e.shape;return JD(t),t.labelTarget=e.labelTarget,ZD.call(this,e)};var QD=ar.prototype.revert;Vs.prototype.revert=function(e){return e.shape.labelTarget=null,QD.call(this,e)};function JD(e){["width","height"].forEach(function(t){typeof e[t]>"u"&&(e[t]=0)})}function Ws(e,t){this._canvas=e,this._modeling=t}Ws.$inject=["canvas","modeling"],Ws.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;or(n.incoming,function(i){t.removeConnection(i,{nested:!0})}),or(n.outgoing,function(i){t.removeConnection(i,{nested:!0})})},Ws.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=qf(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},Ws.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,on(n.children,t,i),this._canvas.addConnection(t,n),t};function xh(e,t){this._modeling=e,this._elementRegistry=t}xh.$inject=["modeling","elementRegistry"],xh.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry,i=e.elements;V(i,function(o){n.get(o.id)&&(o.waypoints?t.removeConnection(o):t.removeShape(o))})};function Us(e,t){this._canvas=e,this._modeling=t}Us.$inject=["canvas","modeling"],Us.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;or(n.incoming,function(i){t.removeConnection(i,{nested:!0})}),or(n.outgoing,function(i){t.removeConnection(i,{nested:!0})}),or(n.children,function(i){Ot(i)?t.removeConnection(i,{nested:!0}):t.removeShape(i,{nested:!0})})},Us.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=qf(i.children,n),t.removeShape(n),n},Us.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,o=e.oldParentIndex;return on(i.children,n,o),t.addShape(n,i),n};function gu(e){this._modeling=e}gu.$inject=["modeling"];var Mw={x:"y",y:"x"};gu.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,i=e.axis,o=e.dimension;function r(m,w){m.range.min=Math.min(w[i],m.range.min),m.range.max=Math.max(w[i]+w[o],m.range.max)}function a(m){return m[i]+m[o]/2}function s(m){return m.length-1}function c(m){return m.max-m.min}function l(m,w){var y={y:0};y[i]=m-a(w),y[i]&&(y[Mw[i]]=0,t.moveElements([w],y,w.parent))}var u=n[0],p=s(n),f=n[p],d,g,h=0;V(n,function(m,w){var y,v,x;if(m.elements.length<2){w&&w!==n.length-1&&(r(m,m.elements[0]),h+=c(m.range));return}y=qi(m.elements,i),v=y[0],w===p&&(v=y[s(y)]),x=a(v),m.range=null,V(y,function(E){if(l(x,E),m.range===null){m.range={min:E[i],max:E[i]+E[o]};return}r(m,E)}),w&&w!==n.length-1&&(h+=c(m.range))}),g=Math.abs(f.range.min-u.range.max),d=Math.round((g-h)/(n.length-1)),!(d<n.length-1)&&V(n,function(m,w){var y={},v;m===u||m===f||(v=n[w-1],m.range.max=0,V(m.elements,function(x,E){y[Mw[i]]=0,y[i]=v.range.max-x[i]+d,m.range.min!==x[i]&&(y[i]+=x[i]-m.range.min),y[i]&&t.moveElements([x],y,x.parent),m.range.max=Math.max(x[i]+x[o],E?m.range.max:0)}))})},gu.prototype.postExecute=function(e){};function mu(e,t){this._layouter=e,this._canvas=t}mu.$inject=["layouter","canvas"],mu.prototype.execute=function(e){var t=e.connection,n=t.waypoints;return Y(e,{oldWaypoints:n}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},mu.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t};function wh(){}wh.prototype.execute=function(e){var t=e.connection,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldParent=r,e.oldParentIndex=tn(r.children,t),on(i.children,t,o),t.parent=i,V(t.waypoints,function(a){a.x+=n.x,a.y+=n.y,a.original&&(a.original.x+=n.x,a.original.y+=n.y)}),t},wh.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,o=e.oldParentIndex,r=e.delta;return tn(n.children,t),on(i.children,t,o),t.parent=i,V(t.waypoints,function(a){a.x-=r.x,a.y-=r.y,a.original&&(a.original.x-=r.x,a.original.y-=r.y)}),t};function _h(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}_h.prototype.add=function(e,t){return this.addAll([e],t)},_h.prototype.addAll=function(e,t){var n=PP(e,!!t,this);return Y(this,n),this};function qs(e){this._modeling=e}qs.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},qs.prototype.moveClosure=function(e,t,n,i,o){var r=this._modeling,a=e.allShapes,s=e.allConnections,c=e.enclosedConnections,l=e.topLevel,u=!1;o&&o.parent===n&&(u=!0),V(a,function(p){r.moveShape(p,t,l[p.id]&&!u&&n,{recurse:!1,layout:!1})}),V(s,function(p){var f=!!a[p.source.id],d=!!a[p.target.id];c[p.id]&&f&&d?r.moveConnection(p,t,l[p.id]&&!u&&n):r.layoutConnection(p,{connectionStart:f&&Pd(p,p.source,t),connectionEnd:d&&Td(p,p.target,t)})})},qs.prototype.getClosure=function(e){return new _h().addAll(e,!0)};function yu(e){this._helper=new qs(e)}yu.$inject=["modeling"],yu.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},yu.prototype.postExecute=function(e){var t=e.hints,n;t&&t.primaryShape&&(n=t.primaryShape,t.oldParent=n.parent),this._helper.moveClosure(e.closure,e.delta,e.newParent,e.newHost,n)};function Vr(e){this._modeling=e,this._helper=new qs(e)}Vr.$inject=["modeling"],Vr.prototype.execute=function(e){var t=e.shape,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldBounds=Ni(t,["x","y","width","height"]),e.oldParent=r,e.oldParentIndex=tn(r.children,t),on(i.children,t,o),Y(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},Vr.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,o=this._modeling;i.layout!==!1&&(V(t.incoming,function(r){o.layoutConnection(r,{connectionEnd:Td(r,t,n)})}),V(t.outgoing,function(r){o.layoutConnection(r,{connectionStart:Pd(r,t,n)})})),i.recurse!==!1&&this.moveChildren(e)},Vr.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,o=e.delta;return on(n.children,t,i),Y(t,{parent:n,x:t.x-o.x,y:t.y-o.y}),t},Vr.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},Vr.prototype.getNewParent=function(e){return e.newParent||e.shape.parent};function Ys(e){this._modeling=e}Ys.$inject=["modeling"],Ys.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,i=e.connection,o=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return Ze(o)&&(e.oldWaypoints=i.waypoints,i.waypoints=o),t&&(e.oldSource=i.source,i.source=t),n&&(e.oldTarget=i.target,i.target=n),i},Ys.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,o=e.dockingOrPoints,r=e.hints||{},a={};r.connectionStart&&(a.connectionStart=r.connectionStart),r.connectionEnd&&(a.connectionEnd=r.connectionEnd),r.layoutConnection!==!1&&(n&&(!i||r.docking==="source")&&(a.connectionStart=a.connectionStart||Aw(Ze(o)?o[0]:o)),i&&(!n||r.docking==="target")&&(a.connectionEnd=a.connectionEnd||Aw(Ze(o)?o[o.length-1]:o)),r.newWaypoints&&(a.waypoints=r.newWaypoints),this._modeling.layoutConnection(t,a))},Ys.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,i=e.oldWaypoints,o=e.connection;return t&&(o.source=t),n&&(o.target=n),i&&(o.waypoints=i),o};function Aw(e){return e.original||e}function Co(e,t){this._modeling=e,this._rules=t}Co.$inject=["modeling","rules"],Co.prototype.preExecute=function(e){var t=this,n=this._modeling,i=this._rules,o=e.oldShape,r=e.newData,a=e.hints||{},s;function c(g,h,m){return i.allowed("connection.reconnect",{connection:m,source:g,target:h})}var l={x:r.x,y:r.y},u={x:o.x,y:o.y,width:o.width,height:o.height};s=e.newShape=e.newShape||t.createShape(r,l,o.parent,a),o.host&&n.updateAttachment(s,o.host);var p;a.moveChildren!==!1&&(p=o.children.slice(),n.moveElements(p,{x:0,y:0},s,a));var f=o.incoming.slice(),d=o.outgoing.slice();V(f,function(g){var h=g.source,m=c(h,s,g);m&&t.reconnectEnd(g,s,Vl(g,s,u),a)}),V(d,function(g){var h=g.target,m=c(s,h,g);m&&t.reconnectStart(g,s,Gl(g,s,u),a)})},Co.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Co.prototype.execute=function(e){},Co.prototype.revert=function(e){},Co.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Co.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Co.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)};function Ks(e){this._modeling=e}Ks.$inject=["modeling"],Ks.prototype.execute=function(e){var t=e.shape,n=e.newBounds,i=e.minBounds;if(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(n.width<i.width||n.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return e.oldBounds={width:t.width,height:t.height,x:t.x,y:t.y},Y(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Ks.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds,o=e.hints||{};o.layout!==!1&&(V(n.incoming,function(r){t.layoutConnection(r,{connectionEnd:Vl(r,n,i)})}),V(n.outgoing,function(r){t.layoutConnection(r,{connectionStart:Gl(r,n,i)})}))},Ks.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return Y(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t};function sr(e){this._modeling=e}sr.$inject=["modeling"],sr.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,o=e.resizingShapes,r=e.start,a={};this.moveShapes(i,t),V(o,function(s){a[s.id]=tL(s)}),this.resizeShapes(o,t,n),this.updateConnectionWaypoints(AD(i,o),t,n,r,i,o,a)},sr.prototype.execute=function(){},sr.prototype.revert=function(){},sr.prototype.moveShapes=function(e,t){var n=this;V(e,function(i){n._modeling.moveShape(i,t,null,{autoResize:!1,layout:!1,recurse:!1})})},sr.prototype.resizeShapes=function(e,t,n){var i=this;V(e,function(o){var r=PD(o,n,t);i._modeling.resizeShape(o,r,null,{attachSupport:!1,autoResize:!1,layout:!1})})},sr.prototype.updateConnectionWaypoints=function(e,t,n,i,o,r,a){var s=this,c=new Set(o),l=new Set(r);V(e,function(u){var p=u.source,f=u.target,d=eL(u),g=Tw(n),h={},m=c.has(p)||l.has(p),w=c.has(f)||l.has(f);m&&w?(d=Fn(d,function(y){return kw(y,i,n)&&(y[g]=y[g]+t[g]),y.original&&kw(y.original,i,n)&&(y.original[g]=y.original[g]+t[g]),y}),s._modeling.updateWaypoints(u,d,{labelBehavior:!1})):(m||w)&&(c.has(p)?h.connectionStart=Pd(u,p,t):c.has(f)?h.connectionEnd=Td(u,f,t):l.has(p)?h.connectionStart=Gl(u,p,a[p.id]):l.has(f)&&(h.connectionEnd=Vl(u,f,a[f.id])),s._modeling.layoutConnection(u,h))})};function Pw(e){return Y({},e)}function eL(e){return Fn(e.waypoints,function(t){return t=Pw(t),t.original&&(t.original=Pw(t.original)),t})}function Tw(e){switch(e){case"n":return"y";case"w":return"x";case"s":return"y";case"e":return"x"}}function kw(e,t,n){var i=Tw(n);if(/e|s/.test(n))return e[i]>t;if(/n|w/.test(n))return e[i]<t}function tL(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}function vu(e){this._modeling=e}vu.$inject=["modeling"],vu.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Ow(n),t.collapsed=!t.collapsed;var i=Dw(n,t.collapsed);return[t].concat(i)},vu.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=t.children,o=Lw(i,n);return t.collapsed=!t.collapsed,[t].concat(o)};function Ow(e){var t={};return V(e,function(n){t[n.id]=n.hidden,n.children&&(t=Y({},t,Ow(n.children)))}),t}function Dw(e,t){var n=[];return V(e,function(i){i.hidden=t,n=n.concat(i),i.children&&(n=n.concat(Dw(i.children,i.collapsed||t)))}),n}function Lw(e,t){var n=[];return V(e,function(i){i.hidden=t[i.id],n=n.concat(i),i.children&&(n=n.concat(Lw(i.children,t)))}),n}function bu(e){this._modeling=e}bu.$inject=["modeling"],bu.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=Iw(i,t),Bw(n,t),t.host=n,t},bu.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,o=e.attacherIdx;return t.host=i,Iw(n,t),Bw(i,t,o),t};function Iw(e,t){return tn(e&&e.attachers,t)}function Bw(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),on(i,t,n)}}function Eh(){}Eh.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},Eh.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t};function Dt(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",function(){i.registerHandlers(n)})}Dt.$inject=["eventBus","elementFactory","commandStack"],Dt.prototype.getHandlers=function(){return{"shape.append":fu,"shape.create":ar,"shape.delete":Us,"shape.move":Vr,"shape.resize":Ks,"shape.replace":Co,"shape.toggleCollapse":vu,spaceTool:sr,"label.create":Vs,"connection.create":du,"connection.delete":Ws,"connection.move":wh,"connection.layout":mu,"connection.updateWaypoints":Eh,"connection.reconnect":Ys,"elements.create":bh,"elements.move":yu,"elements.delete":xh,"elements.distribute":gu,"elements.align":pu,"element.updateAttachment":bu}},Dt.prototype.registerHandlers=function(e){V(this.getHandlers(),function(t,n){e.registerHandler(n,t)})},Dt.prototype.moveShape=function(e,t,n,i,o){typeof i=="object"&&(o=i,i=null);var r={shape:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("shape.move",r)},Dt.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},Dt.prototype.moveElements=function(e,t,n,i){i=i||{};var o=i.attach,r=n,a;o===!0?(a=n,r=n.parent):o===!1&&(a=null);var s={shapes:e,delta:t,newParent:r,newHost:a,hints:i};this._commandStack.execute("elements.move",s)},Dt.prototype.moveConnection=function(e,t,n,i,o){typeof i=="object"&&(o=i,i=void 0);var r={connection:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("connection.move",r)},Dt.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},Dt.prototype.createConnection=function(e,t,n,i,o,r){typeof n=="object"&&(r=o,o=i,i=n,n=void 0),i=this._create("connection",i);var a={source:e,target:t,parent:o,parentIndex:n,connection:i,hints:r};return this._commandStack.execute("connection.create",a),a.connection},Dt.prototype.createShape=function(e,t,n,i,o){typeof i!="number"&&(o=i,i=void 0),o=o||{};var r=o.attach,a,s;e=this._create("shape",e),r?(a=n.parent,s=n):a=n;var c={position:t,shape:e,parent:a,parentIndex:i,host:s,hints:o};return this._commandStack.execute("shape.create",c),c.shape},Dt.prototype.createElements=function(e,t,n,i,o){Ze(e)||(e=[e]),typeof i!="number"&&(o=i,i=void 0),o=o||{};var r={position:t,elements:e,parent:n,parentIndex:i,hints:o};return this._commandStack.execute("elements.create",r),r.elements},Dt.prototype.createLabel=function(e,t,n,i){n=this._create("label",n);var o={labelTarget:e,position:t,parent:i||e.parent,shape:n};return this._commandStack.execute("label.create",o),o.shape},Dt.prototype.appendShape=function(e,t,n,i,o){o=o||{},t=this._create("shape",t);var r={source:e,position:n,target:i,shape:t,connection:o.connection,connectionParent:o.connectionParent,hints:o};return this._commandStack.execute("shape.append",r),r.shape},Dt.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},Dt.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},Dt.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},Dt.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},Dt.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},Dt.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},Dt.prototype.resizeShape=function(e,t,n,i){var o={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",o)},Dt.prototype.createSpace=function(e,t,n,i,o){var r={delta:n,direction:i,movingShapes:e,resizingShapes:t,start:o};this._commandStack.execute("spaceTool",r)},Dt.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},Dt.prototype.reconnect=function(e,t,n,i,o){var r={connection:e,newSource:t,newTarget:n,dockingOrPoints:i,hints:o||{}};this._commandStack.execute("connection.reconnect",r)},Dt.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,Y(i,{docking:"source"}))},Dt.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,Y(i,{docking:"target"}))},Dt.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},Dt.prototype._create=function(e,t){return hT(t)?t:this._elementFactory.create(e,t)},Dt.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)};function Xs(e){this._elementRegistry=e}Xs.$inject=["elementRegistry"],Xs.prototype.execute=function(e){var t=e.element,n=e.moddleElement,i=e.properties;if(!n)throw new Error("<moddleElement> required");var o=e.changed||this._getVisualReferences(n).concat(t),r=e.oldProperties||nL(n,Dc(i));return Nw(n,i),e.oldProperties=r,e.changed=o,o},Xs.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return Nw(n,t),i},Xs.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return M(e,"bpmn:DataObject")?iL(e,t):[]};function nL(e,t){return ni(t,function(n,i){return n[i]=e.get(i),n},{})}function Nw(e,t){V(t,function(n,i){e.set(i,n)})}function iL(e,t){return t.filter(function(n){return M(n,"bpmn:DataObjectReference")&&_e(n).dataObjectRef===e})}var Zs="default",Mo="id",$w="di",oL={width:0,height:0};function Qs(e,t,n,i){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=i}Qs.$inject=["elementRegistry","moddle","modeling","textRenderer"],Qs.prototype.execute=function(e){var t=e.element,n=[t];if(!t)throw new Error("element required");var i=this._elementRegistry,o=this._moddle.ids,r=t.businessObject,a=lL(e.properties),s=e.oldProperties||rL(t,a);return Fw(a,r)&&(o.unclaim(r[Mo]),i.updateId(t,a[Mo]),o.claim(a[Mo],r)),Zs in a&&(a[Zs]&&n.push(i.get(a[Zs].id)),r[Zs]&&n.push(i.get(r[Zs].id))),jw(t,a),e.oldProperties=s,e.changed=n,n},Qs.prototype.postExecute=function(e){var t=e.element,n=t.label,i=n&&_e(n).name;if(i){var o=this._textRenderer.getExternalLabelBounds(n,i);this._modeling.resizeShape(n,o,oL)}},Qs.prototype.revert=function(e){var t=e.element,n=e.properties,i=e.oldProperties,o=t.businessObject,r=this._elementRegistry,a=this._moddle.ids;return jw(t,i),Fw(n,o)&&(a.unclaim(n[Mo]),r.updateId(t,i[Mo]),a.claim(i[Mo],o)),e.changed};function Fw(e,t){return Mo in e&&e[Mo]!==t[Mo]}function rL(e,t){var n=Dc(t),i=e.businessObject,o=mt(e);return ni(n,function(r,a){return a!==$w?r[a]=i.get(a):r[a]=aL(o,Dc(t.di)),r},{})}function aL(e,t){return ni(t,function(n,i){return n[i]=e&&e.get(i),n},{})}function jw(e,t){var n=e.businessObject,i=mt(e);V(t,function(o,r){r!==$w?n.set(r,o):i&&sL(i,o)})}function sL(e,t){V(t,function(n,i){e.set(i,n)})}var cL=["default"];function lL(e){var t=Y({},e);return cL.forEach(function(n){n in e&&(t[n]=_e(t[n]))}),t}function xu(e,t){this._canvas=e,this._modeling=t}xu.$inject=["canvas","modeling"],xu.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,o=t.getRootElement(),r=o.businessObject,a=r.$parent,s=mt(o);return t.setRootElement(n),t.removeRootElement(o),on(a.rootElements,i),i.$parent=a,tn(a.rootElements,r),r.$parent=null,o.di=null,s.bpmnElement=i,n.di=s,e.oldRoot=o,[]},xu.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,o=e.oldRoot,r=o.businessObject,a=i.$parent,s=mt(n);return t.setRootElement(o),t.removeRootElement(n),tn(a.rootElements,i),i.$parent=null,on(a.rootElements,r),r.$parent=a,n.di=null,s.bpmnElement=r,o.di=s,[]};function Sh(e,t){this._modeling=e,this._spaceTool=t}Sh.$inject=["modeling","spaceTool"],Sh.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,o=e.location,r=Ri(i),a=r===i,s=a?i:i.parent,c=Jo(s),l=En(i);if(l?o==="left"?o="top":o==="right"&&(o="bottom"):o==="top"?o="left":o==="bottom"&&(o="right"),!c.length){var u=l?{x:i.x+Si,y:i.y,width:i.width-Si,height:i.height}:{x:i.x,y:i.y+Si,width:i.width,height:i.height-Si};n.createShape({type:"bpmn:Lane",isHorizontal:l},u,s)}var p=[];Br(r,function(x){return p.push(x),x.label&&p.push(x.label),x===i?[]:ct(x.children,function(E){return E!==i})});var f,d,g,h,m;o==="top"?(f=-120,d=i.y,g=d+10,h="n",m="y"):o==="left"?(f=-120,d=i.x,g=d+10,h="w",m="x"):o==="bottom"?(f=120,d=i.y+i.height,g=d-10,h="s",m="y"):o==="right"&&(f=120,d=i.x+i.width,g=d-10,h="e",m="x");var w=t.calculateAdjustments(p,m,f,g),y=l?{x:0,y:f}:{x:f,y:0};t.makeSpace(w.movingShapes,w.resizingShapes,y,h,g);var v=l?{x:i.x+(a?Si:0),y:d-(o==="top"?120:0),width:i.width-(a?Si:0),height:120}:{x:d-(o==="left"?120:0),y:i.y+(a?Si:0),width:120,height:i.height-(a?Si:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:l},v,s)};function Rh(e){this._modeling=e}Rh.$inject=["modeling"],Rh.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,i=e.count,o=Jo(n),r=o.length;if(r>i)throw new Error(`more than <${i}> child lanes`);var a=En(n),s=a?n.height:n.width,c=Math.round(s/i),l,u,p,f;for(f=0;f<i;f++)f===i-1?l=s-c*f:l=c,u=a?{x:n.x+Si,y:n.y+f*c,width:n.width-Si,height:l}:{x:n.x+f*c,y:n.y+Si,width:l,height:n.height-Si},f<r?t.resizeShape(o[f],u):(p={type:"bpmn:Lane",isHorizontal:a},t.createShape(p,u,n))};function Js(e,t){this._modeling=e,this._spaceTool=t}Js.$inject=["modeling","spaceTool"],Js.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds,i=e.balanced;i!==!1?this.resizeBalanced(t,n):this.resizeSpace(t,n)},Js.prototype.resizeBalanced=function(e,t){var n=this._modeling,i=ik(e,t);n.resizeShape(e,t),i.forEach(function(o){n.resizeShape(o.shape,o.newBounds)})},Js.prototype.resizeSpace=function(e,t){var n=this._spaceTool,i=qe(e),o=qe(t),r=vb(o,i),a=Ri(e),s=[],c=[];Br(a,function(g){return s.push(g),(M(g,"bpmn:Lane")||M(g,"bpmn:Participant"))&&c.push(g),g.children});var l,u,p,f,d;(r.bottom||r.top)&&(l=r.bottom||r.top,u=e.y+(r.bottom?e.height:0)+(r.bottom?-10:10),p=r.bottom?"s":"n",f=r.top>0||r.bottom<0?-l:l,d=n.calculateAdjustments(s,"y",f,u),n.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:l},p)),(r.left||r.right)&&(l=r.right||r.left,u=e.x+(r.right?e.width:0)+(r.right?-10:100),p=r.right?"e":"w",f=r.left>0||r.right<0?-l:l,d=n.calculateAdjustments(c,"x",f,u),n.makeSpace(d.movingShapes,d.resizingShapes,{x:l,y:0},p))};var ec="flowNodeRef",Ch="lanes";function wu(){}wu.prototype._computeUpdates=function(e,t){var n=[],i=[],o={},r=[];function a(u,p){var f=qe(p),d={x:u.x+u.width/2,y:u.y+u.height/2};return d.x>f.left&&d.x<f.right&&d.y>f.top&&d.y<f.bottom}function s(u){n.indexOf(u)===-1&&(r.push(u),n.push(u))}function c(u){var p=Ri(u);return o[p.id]||(o[p.id]=$l(p)),o[p.id]}function l(u){if(!u.parent)return[];var p=c(u);return p.filter(function(f){return a(u,f)}).map(function(f){return f.businessObject})}return t.forEach(function(u){var p=Ri(u);if(!(!p||n.indexOf(p)!==-1)){var f=p.children.filter(function(d){return M(d,"bpmn:FlowNode")});f.forEach(s),n.push(p)}}),e.forEach(s),r.forEach(function(u){var p=u.businessObject,f=p.get(Ch),d=f.slice(),g=l(u);i.push({flowNode:p,remove:d,add:g})}),t.forEach(function(u){var p=u.businessObject;u.parent||p.get(ec).forEach(function(f){i.push({flowNode:f,remove:[p],add:[]})})}),i},wu.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach(function(n){var i=n.flowNode,o=i.get(Ch);n.remove.forEach(function(r){tn(o,r),tn(r.get(ec),i)}),n.add.forEach(function(r){on(o,r),on(r.get(ec),i)})}),[]},wu.prototype.revert=function(e){var t=e.updates;return t.forEach(function(n){var i=n.flowNode,o=i.get(Ch);n.add.forEach(function(r){tn(o,r),tn(r.get(ec),i)}),n.remove.forEach(function(r){on(o,r),on(r.get(ec),i)})}),[]};var Mh="categoryValueRef";function tc(e,t){this._bpmnFactory=e,this._elementRegistry=t}tc.$inject=["bpmnFactory","elementRegistry"],tc.prototype._computeUpdates=function(e,t){var n=this._elementRegistry,i=this._bpmnFactory,o=new Map,r=[],a=new Map;function s(y,v,x){if(v){var E=a.get(y);E||(E={},a.set(y,E)),!(x&&E.present)&&(!x&&E.past||(x?E.present={categoryValue:v,root:Ah(y)}:E.past={categoryValue:v}))}}function c(y){o.set(y,_e(y))}function l(){n.filter(function(y){return M(y,"bpmn:FlowElement")&&!at(y)&&y.parent}).forEach(c)}function u(y){var v=_e(y),x=v.get("categoryValueRef");return x||(x=db(i,v),r.push(uL(y,x))),x}function p(y){return y.reduce(function(v,x){var E=Ah(x),A=v.get(E);return A||(A=[],v.set(E,A)),A.push(x),v},new Map)}e=Array.from(e||[]);var f=p(e);t.length&&l(),e.forEach(c),n.filter(function(y){return M(y,"bpmn:Group")&&!at(y)&&y.parent}).forEach(function(y){var v=_e(y).get("categoryValueRef");if(!v){var x=Ah(y),E=f.get(x)||[],A=xa(E,y),B=Object.keys(A).length>0;B&&(v=u(y))}s(y,v,!0)}),t.forEach(function(y){s(y.groupShape,y.categoryValue,!1)}),r.length&&l();var d=Array.from(o.keys()),g=Array.from(a.values()).reduce(function(y,v){return v.present&&y.add(v.present.categoryValue),v.past&&y.add(v.past.categoryValue),y},new Set),h=new Map,m=p(d);a.forEach(function(y,v){var x=y.present;if(x){var E=m.get(x.root)||[],A=xa(E,v);E.forEach(function(B){if(A[B.id]){var P=h.get(B);P||(P=new Set,h.set(B,P)),P.add(x.categoryValue)}})}});var w=d.reduce(function(y,v){var x=o.get(v),E=x.get(Mh),A=new Set(E),B=h.get(v)||new Set,P=Array.from(B).filter(function(H){return!A.has(H)}),k=E.filter(function(H){return g.has(H)&&!B.has(H)});return(P.length||k.length)&&y.push({businessObject:x,categoryValuesToAdd:P,categoryValuesToRemove:k}),y},[]);return{flowElements:w,groups:r}},tc.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.affectedFlowElements,e.affectedGroupEntries)),pL(t.groups),dL(t.flowElements),[]},tc.prototype.revert=function(e){var t=e.updates;return hL(t.flowElements),fL(t.groups),[]};function uL(e,t){return{groupShape:e,categoryValue:t,category:t.$parent}}function pL(e){e.forEach(function(t){_e(t.groupShape).categoryValueRef=t.categoryValue,t.categoryValue.$parent=t.category})}function fL(e){e.forEach(function(t){_e(t.groupShape).categoryValueRef=null})}function dL(e){e.forEach(function(t){var n=t.businessObject,i=n.get(Mh);t.categoryValuesToRemove.forEach(function(o){tn(i,o)}),t.categoryValuesToAdd.forEach(function(o){on(i,o,!0)})})}function hL(e){e.forEach(function(t){var n=t.businessObject,i=n.get(Mh);t.categoryValuesToAdd.forEach(function(o){tn(i,o)}),t.categoryValuesToRemove.forEach(function(o){on(i,o,!0)})})}function Ah(e){for(;e.parent;)e=e.parent;return e}function _u(e){this._moddle=e}_u.$inject=["moddle"],_u.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element,o=e.claiming;return o?t.claim(n,i):t.unclaim(n),[]},_u.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element,o=e.claiming;return o?t.unclaim(n):t.claim(n,i),[]};var gL={fill:void 0,stroke:void 0};function Ph(e){this._commandStack=e,this._normalizeColor=function(t){if(t){if(ei(t)){var n=mL(t);if(n)return n}throw new Error(`invalid color value: ${t}`)}}}Ph.$inject=["commandStack"],Ph.prototype.postExecute=function(e){var t=e.elements,n=e.colors||gL,i=this,o={};"fill"in n&&Y(o,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&Y(o,{"border-color":this._normalizeColor(n.stroke)}),V(t,function(r){var a=Ot(r)?Ni(o,["border-color"]):o,s=mt(r);if(yL(a),at(r)){if(!s||!M(s.label,"bpmndi:BPMNLabel"))return;i._commandStack.execute("element.updateModdleProperties",{element:r,moddleElement:s.label,properties:{color:o["border-color"]}})}else{if(!st(s,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;i._commandStack.execute("element.updateProperties",{element:r,properties:{di:a}})}})};function mL(e){var t=document.createElement("canvas").getContext("2d");return t.fillStyle="transparent",t.fillStyle=e,/^#[0-9a-fA-F]{6}$/.test(t.fillStyle)?t.fillStyle:null}function yL(e){"border-color"in e&&(e.stroke=e["border-color"]),"background-color"in e&&(e.fill=e["background-color"])}var vL={width:0,height:0};function Hw(e,t,n){function i(c,l){var u=c.label||c,p=c.labelTarget||c;return UT(u,l),[u,p]}function o(c){var l=c.element,u=l.businessObject,p=c.newLabel;if(!at(l)&&Zo(l)&&!Rl(l)&&!zw(p)){var f=7,d=Jf(l);d={x:d.x,y:d.y+f},e.createLabel(l,d,{id:u.id+"_label",businessObject:u,di:l.di})}}function r(c){return c.oldLabel=vi(c.element),i(c.element,c.newLabel)}function a(c){return i(c.element,c.oldLabel)}function s(c){var l=c.element,u=l.label||l,p=c.newLabel,f=c.newBounds,d=c.hints||{};if(!(!at(u)&&!M(u,"bpmn:TextAnnotation"))){if(at(u)&&zw(p)){d.removeShape!==!1&&e.removeShape(u,{unsetLabel:!1});return}var g=vi(l);typeof f>"u"&&(f=t.getExternalLabelBounds(u,g)),f&&e.resizeShape(u,f,vL)}}this.preExecute=o,this.execute=r,this.revert=a,this.postExecute=s}Hw.$inject=["modeling","textRenderer","bpmnFactory"];function zw(e){return!e||!e.trim()}function In(e,t,n,i){Dt.call(this,e,t,n),this._bpmnRules=i}Ne(In,Dt),In.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],In.prototype.getHandlers=function(){var e=Dt.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=Xs,e["element.updateProperties"]=Qs,e["canvas.updateRoot"]=xu,e["lane.add"]=Sh,e["lane.resize"]=Js,e["lane.split"]=Rh,e["lane.updateRefs"]=wu,e["group.updateRefs"]=tc,e["id.updateClaim"]=_u,e["element.setColor"]=Ph,e["element.updateLabel"]=Hw,e},In.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},In.prototype.connect=function(e,t,n,i){var o=this._bpmnRules;if(n||(n=o.canConnect(e,t)),!!n)return this.createConnection(e,t,n,e.parent,i)},In.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},In.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},In.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},In.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},In.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},In.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},In.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},In.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},In.prototype.updateCategoryValueRefs=function(e,t){this._commandStack.execute("group.updateRefs",{affectedFlowElements:e,affectedGroupEntries:t})},In.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},In.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},In.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})};function Gw(){}Gw.prototype.layoutConnection=function(e,t){return t=t||{},[t.connectionStart||Je(t.source||e.source),t.connectionEnd||Je(t.target||e.target)]};var Eu=20,bL=5,Su=Math.round,Vw=20,xL={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function wL(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}function _L(e,t){return{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[e].test(t)}function Ww(e,t,n){var i=On(t,e,bL),o=n.split(":")[0],r=Su((t.x-e.x)/2+e.x),a=Su((t.y-e.y)/2+e.y),s,c,l=_L(o,i),u=/h|r|l/.test(o),p=!1,f=!1;return l?(s=u?{x:r,y:e.y}:{x:e.x,y:a},c=u?"h:h":"v:v"):(p=wL(i,o),c=u?"h:v":"v:h",p?u?(f=a===e.y,s={x:e.x+Eu*(/l/.test(o)?-1:1),y:f?a+Eu:a}):(f=r===e.x,s={x:f?r+Eu:r,y:e.y+Eu*(/t/.test(o)?-1:1)}):s={x:r,y:a}),{waypoints:Th(e,s,c).concat(s),directions:c,turnNextDirections:f}}function EL(e,t,n){return Ww(e,t,n)}function SL(e,t,n){var i=Ww(t,e,Uw(n));return{waypoints:i.waypoints.slice().reverse(),directions:Uw(i.directions),turnNextDirections:i.turnNextDirections}}function RL(e,t){var n=e.directions.split(":")[1],i=t.directions.split(":")[0];e.turnNextDirections&&(n=n=="h"?"v":"h"),t.turnNextDirections&&(i=i=="h"?"v":"h");var o=n+":"+i,r=Th(e.waypoints[e.waypoints.length-1],t.waypoints[0],o);return{waypoints:r,directions:o}}function Uw(e){return e.split(":").reverse().join(":")}function CL(e,t,n){var i=Su((t.x-e.x)/2+e.x),o=Su((t.y-e.y)/2+e.y);if(n==="h:v")return[{x:t.x,y:e.y}];if(n==="v:h")return[{x:e.x,y:t.y}];if(n==="h:h")return[{x:i,y:e.y},{x:i,y:t.y}];if(n==="v:v")return[{x:e.x,y:o},{x:t.x,y:o}];throw new Error("invalid directions: can only handle varians of [hv]:[hv]")}function Th(e,t,n){if(n=n||"h:h",!IL(n))throw new Error("unknown directions: <"+n+">: must be specified as <start>:<end> with start/end in { h,v,t,r,b,l }");if(Yw(n)){var i=EL(e,t,n),o=SL(e,t,n),r=RL(i,o);return[].concat(i.waypoints,r.waypoints,o.waypoints)}return CL(e,t,n)}function ML(e,t,n){var i=Th(e,t,n);return i.unshift(e),i.push(t),Xw(i)}function AL(e,t,n,i,o){var r=o&&o.preferredLayouts||[],a=jS(r,"straight")[0]||"h:h",s=xL[a]||0,c=On(e,t,s),l=LL(c,a);n=n||Je(e),i=i||Je(t);var u=l.split(":"),p=Kw(n,e,u[0],BL(c)),f=Kw(i,t,u[1],c);return ML(p,f,l)}function PL(e,t,n,i,o,r){Ze(n)&&(o=n,r=i,n=Je(e),i=Je(t)),r=Y({preferredLayouts:[]},r),o=o||[];var a=r.preferredLayouts,s=a.indexOf("straight")!==-1,c;return c=s&&kL(e,t,n,i,r),c||(c=r.connectionEnd&&DL(t,e,i,o),c)||(c=r.connectionStart&&OL(e,t,n,o),c)?c:!r.connectionStart&&!r.connectionEnd&&o&&o.length?o:AL(e,t,n,i,r)}function TL(e,t,n){return e>=t&&e<=n}function qw(e,t,n){var i={x:"width",y:"height"};return TL(t[e],n[e],n[e]+n[i[e]])}function kL(e,t,n,i,o){var r={},a,s;return s=On(e,t),/^(top|bottom|left|right)$/.test(s)?(/top|bottom/.test(s)&&(a="x"),/left|right/.test(s)&&(a="y"),o.preserveDocking==="target"?qw(a,i,e)?(r[a]=i[a],[{x:r.x!==void 0?r.x:n.x,y:r.y!==void 0?r.y:n.y,original:{x:r.x!==void 0?r.x:n.x,y:r.y!==void 0?r.y:n.y}},{x:i.x,y:i.y}]):null:qw(a,n,t)?(r[a]=n[a],[{x:n.x,y:n.y},{x:r.x!==void 0?r.x:i.x,y:r.y!==void 0?r.y:i.y,original:{x:r.x!==void 0?r.x:i.x,y:r.y!==void 0?r.y:i.y}}]):null):null}function OL(e,t,n,i){return kh(e,t,n,i)}function DL(e,t,n,i){var o=i.slice().reverse();return o=kh(e,t,n,o),o?o.reverse():null}function kh(e,t,n,i){function o(u){return u.length<3?!0:u.length>4?!1:!!It(u,function(p,f){var d=u[f-1];return d&&Rs(p,d)<3})}function r(u,p,f){var d=vo(p,u);switch(d){case"v":return{x:f.x,y:u.y};case"h":return{x:u.x,y:f.y}}return{x:u.x,y:u.y}}function a(u,p,f){var d;for(d=u.length-2;d!==0;d--)if(bv(u[d],p,Vw)||bv(u[d],f,Vw))return u.slice(d);return u}if(o(i))return null;var s=i[0],c=i.slice(),l;return c[0]=n,c[1]=r(c[1],s,n),l=a(c,e,t),l!==c&&(c=kh(e,t,n,l)),c&&vo(c)?null:c}function LL(e,t){if(Yw(t))return t;switch(e){case"intersect":return"t:t";case"top":case"bottom":return"v:v";case"left":case"right":return"h:h";default:return t}}function IL(e){return e&&/^h|v|t|r|b|l:h|v|t|r|b|l$/.test(e)}function Yw(e){return e&&/t|r|b|l/.test(e)}function BL(e){return{top:"bottom",bottom:"top",left:"right",right:"left","top-left":"bottom-right","bottom-right":"top-left","top-right":"bottom-left","bottom-left":"top-right"}[e]}function Kw(e,t,n,i){if(n==="h"&&(n=/left/.test(i)?"l":"r"),n==="v"&&(n=/top/.test(i)?"t":"b"),n==="t")return{original:e,x:e.x,y:t.y};if(n==="r")return{original:e,x:t.x+t.width,y:e.y};if(n==="b")return{original:e,x:e.x,y:t.y+t.height};if(n==="l")return{original:e,x:t.x,y:e.y};throw new Error("unexpected dockingDirection: <"+n+">")}function Xw(e){return e.reduce(function(t,n,i){var o=t[t.length-1],r=e[i+1];return Yf(o,r,n,0)||t.push(n),t},[])}var NL=-10,$L=40,FL={default:["h:h"],fromGateway:["v:h"],toGateway:["h:v"],loop:{fromTop:["t:r"],fromRight:["r:b"],fromLeft:["l:t"],fromBottom:["b:l"]},boundaryLoop:{alternateHorizontalSide:"b",alternateVerticalSide:"l",default:"v"},messageFlow:["straight","v:v"],subProcess:["straight","h:h"],isHorizontal:!0},jL={default:["v:v"],fromGateway:["h:v"],toGateway:["v:h"],loop:{fromTop:["t:l"],fromRight:["r:t"],fromLeft:["l:b"],fromBottom:["b:r"]},boundaryLoop:{alternateHorizontalSide:"t",alternateVerticalSide:"r",default:"h"},messageFlow:["straight","h:h"],subProcess:["straight","v:v"],isHorizontal:!1},Oh={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},nc={top:"t",right:"r",bottom:"b",left:"l"};function Ru(e){this._elementRegistry=e}Ne(Ru,Gw),Ru.prototype.layoutConnection=function(e,t){t||(t={});var n=t.source||e.source,i=t.target||e.target,o=t.waypoints||e.waypoints,r=t.connectionStart,a=t.connectionEnd,s=this._elementRegistry,c,l;if(r||(r=Zw(o&&o[0],n)),a||(a=Zw(o&&o[o.length-1],i)),(M(e,"bpmn:Association")||M(e,"bpmn:DataAssociation"))&&o&&!Qw(n,i))return[].concat([r],o.slice(1,-1),[a]);var u=lb(n,s)?FL:jL;return M(e,"bpmn:MessageFlow")?c=zL(n,i,u):(M(e,"bpmn:SequenceFlow")||Qw(n,i))&&(n===i?c={preferredLayouts:YL(n,e,u)}:M(n,"bpmn:BoundaryEvent")?c={preferredLayouts:KL(n,i,a,u)}:ic(n)||ic(i)?c={preferredLayouts:u.subProcess,preserveDocking:VL(n)}:M(n,"bpmn:Gateway")?c={preferredLayouts:u.fromGateway}:M(i,"bpmn:Gateway")?c={preferredLayouts:u.toGateway}:c={preferredLayouts:u.default}),c&&(c=Y(c,t),l=Xw(PL(n,i,r,a,o,c))),l||[r,a]};function HL(e){var t=e.host;return On(Je(e),t,NL)}function zL(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:GL(e,t)}}function GL(e,t){return M(t,"bpmn:Participant")?"source":M(e,"bpmn:Participant")?"target":ic(t)?"source":ic(e)||M(t,"bpmn:Event")?"target":M(e,"bpmn:Event")?"source":null}function VL(e){return ic(e)?"target":"source"}function Zw(e,t){return e?e.original||e:Je(t)}function Qw(e,t){return M(t,"bpmn:Activity")&&M(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function ic(e){return M(e,"bpmn:SubProcess")&&ht(e)}function Wr(e,t){return e===t}function WL(e,t){return t.indexOf(e)!==-1}function $a(e){var t=/right|left/.exec(e);return t&&t[0]}function Fa(e){var t=/top|bottom/.exec(e);return t&&t[0]}function Jw(e,t){return Oh[e]===t}function UL(e,t){var n=$a(e),i=Oh[n];return t.indexOf(i)!==-1}function qL(e,t){var n=Fa(e),i=Oh[n];return t.indexOf(i)!==-1}function e_(e){return e==="right"||e==="left"}function YL(e,t,n){var i=t.waypoints,o=i&&i.length&&On(i[0],e);return o==="top"?n.loop.fromTop:o==="right"?n.loop.fromRight:o==="left"?n.loop.fromLeft:n.loop.fromBottom}function KL(e,t,n,i){var o=Je(e),r=Je(t),a=HL(e),s,c,l=Wr(e.host,t),u=WL(a,["top","right","bottom","left"]),p=On(r,o,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return l?XL(a,u,e,t,n,i):(s=ZL(a,p,u,i.isHorizontal),c=QL(a,p,u,i.isHorizontal),[s+":"+c])}function XL(e,t,n,i,o,r){var a=t?e:r.isHorizontal?Fa(e):$a(e),s=nc[a],c;return t?e_(e)?c=t_("y",n,i,o)?"h":r.boundaryLoop.alternateHorizontalSide:c=t_("x",n,i,o)?"v":r.boundaryLoop.alternateVerticalSide:c=r.boundaryLoop.default,[s+":"+c]}function t_(e,t,n,i){var o=$L;return!(Dh(e,i,n,o)||Dh(e,i,{x:n.x+n.width,y:n.y+n.height},o)||Dh(e,i,Je(t),o))}function Dh(e,t,n,i){return Math.abs(t[e]-n[e])<i}function ZL(e,t,n,i){if(n)return nc[e];var o=Fa(e),r=$a(e),a=Fa(t),s=$a(t);if(i){if(Wr(o,a)||Jw(r,s))return nc[o]}else if(Wr(r,s)||Jw(o,a))return nc[r];return nc[i?r:o]}function QL(e,t,n,i){if(n)return e_(e)?UL(e,t)||Wr(e,t)?"h":"v":qL(e,t)||Wr(e,t)?"v":"h";var o=Fa(e),r=$a(e),a=Fa(t),s=$a(t);return a&&!s?"v":s&&!a?"h":i?Wr(o,a)?"h":"v":Wr(r,s)?"v":"h"}Ru.$inject=["elementRegistry"];function n_(e){return Y({original:e.point.original||e.point},e.actual)}function cr(e,t){this._elementRegistry=e,this._graphicsFactory=t}cr.$inject=["elementRegistry","graphicsFactory"],cr.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var i=this.getDockingPoint(e,t,!0),o=this.getDockingPoint(e,n),r=e.waypoints.slice(i.idx+1,o.idx);return r.unshift(n_(i)),r.push(n_(o)),r},cr.prototype.getDockingPoint=function(e,t,n){var i=e.waypoints,o,r,a;return o=n?0:i.length-1,r=i[o],a=this._getIntersection(t,e,n),{point:r,actual:a||r,idx:o}},cr.prototype._getIntersection=function(e,t,n){var i=this._getShapePath(e),o=this._getConnectionPath(t);return Cs(i,o,n)},cr.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},cr.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},cr.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};const Lh={__init__:["modeling","bpmnUpdater"],__depends__:[yO,DO,IO,BO,hw,ND,FD,WD,Mi,yh,xw],bpmnFactory:["type",Pi],bpmnUpdater:["type",ci],elementFactory:["type",rr],modeling:["type",In],layouter:["type",Ru],connectionDocking:["type",cr]};var JL=10,i_=50,eI=250;function Ih(e,t,n,i){for(var o;o=tI(e,n,t);)n=i(t,n,o);return n}function Bh(e){return function(t,n,i){var o={x:n.x,y:n.y};return["x","y"].forEach(function(r){var a=e[r];if(a){var s=r==="x"?"width":"height",c=a.margin,l=a.minDistance;c<0?o[r]=Math.min(i[r]+c-t[s]/2,n[r]-l+c):o[r]=Math.max(i[r]+i[s]+c+t[s]/2,n[r]+l+c)}}),o}}function tI(e,t,n){var i={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height},o=iI(e);return It(o,function(r){if(r===n)return!1;var a=On(r,i,JL);return a==="intersect"})}function nI(e,t){t||(t={});function n(g){return g.source===e?1:-1}var i=t.defaultDistance||i_,o=t.direction||"e",r=t.filter,a=t.getWeight||n,s=t.maxDistance||eI,c=t.reference||"start";r||(r=aI);function l(g,h){return o==="n"?c==="start"?qe(g).top-qe(h).bottom:c==="center"?qe(g).top-Je(h).y:qe(g).top-qe(h).top:o==="w"?c==="start"?qe(g).left-qe(h).right:c==="center"?qe(g).left-Je(h).x:qe(g).left-qe(h).left:o==="s"?c==="start"?qe(h).top-qe(g).bottom:c==="center"?Je(h).y-qe(g).bottom:qe(h).bottom-qe(g).bottom:c==="start"?qe(h).left-qe(g).right:c==="center"?Je(h).x-qe(g).right:qe(h).right-qe(g).right}var u=e.incoming.filter(r).map(function(g){var h=a(g),m=h<0?l(g.source,e):l(e,g.source);return{id:g.source.id,distance:m,weight:h}}),p=e.outgoing.filter(r).map(function(g){var h=a(g),m=h>0?l(e,g.target):l(g.target,e);return{id:g.target.id,distance:m,weight:h}}),f=u.concat(p).reduce(function(g,h){return g[h.id+"__weight_"+h.weight]=h,g},{}),d=ni(f,function(g,h){var m=h.distance,w=h.weight;return m<0||m>s||(g[String(m)]||(g[String(m)]=0),g[String(m)]+=1*w,(!g.distance||g[g.distance]<g[String(m)])&&(g.distance=m)),g},{});return d.distance||i}function iI(e){var t=Nh(e);return e.host&&(t=t.concat(Nh(e.host))),e.attachers&&(t=t.concat(e.attachers.reduce(function(n,i){return n.concat(Nh(i))},[]))),t}function Nh(e){return rI(e).concat(oI(e))}function oI(e){return e.incoming.map(function(t){return t.source})}function rI(e){return e.outgoing.map(function(t){return t.target})}function aI(){return!0}var sI=100;function o_(e,t,n){e.on("autoPlace",sI,function(i){var o=i.shape,r=i.source;return cI(r,o)}),e.on("autoPlace.end",function(i){n.scrollToElement(i.shape)}),this.append=function(i,o,r){e.fire("autoPlace.start",{source:i,shape:o});var a=e.fire("autoPlace",{source:i,shape:o}),s=t.appendShape(i,o,a,i.parent,r);return e.fire("autoPlace.end",{source:i,shape:s}),s}}o_.$inject=["eventBus","modeling","canvas"];function cI(e,t,n){n||(n={});var i=n.defaultDistance||i_,o=Je(e),r=qe(e);return{x:r.right+i+t.width/2,y:o.y}}function r_(e,t){e.on("autoPlace.end",500,function(n){t.select(n.shape)})}r_.$inject=["eventBus","selection"];const lI={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",o_],autoPlaceSelectionBehavior:["type",r_]};function a_(e,t,n){var i=lb(e,n);if(M(t,"bpmn:TextAnnotation"))return pI(e,t,i);if(st(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"]))return fI(e,t,i);if(M(t,"bpmn:FlowNode"))return uI(e,t,i)}function uI(e,t,n){var i=qe(e),o=Je(e),r=n?{directionHint:"e",minDistance:80,baseOrientation:"left",boundaryOrientation:"top",start:"top",end:"bottom"}:{directionHint:"s",minDistance:90,baseOrientation:"top",boundaryOrientation:"left",start:"left",end:"right"},a=nI(e,{filter:function(d){return M(d,"bpmn:SequenceFlow")},direction:r.directionHint}),s=30,c=r.minDistance,l=r.baseOrientation;M(e,"bpmn:BoundaryEvent")&&(l=On(e,e.host,-25),l.indexOf(r.boundaryOrientation)!==-1&&(s*=-1));var u=n?{x:i.right+a+t.width/2,y:o.y+s_(l,c,r)}:{x:o.x+s_(l,c,r),y:i.bottom+a+t.height/2},p={margin:s,minDistance:c},f=n?{y:p}:{x:p};return Ih(e,t,u,Bh(f))}function s_(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function pI(e,t,n){var i=qe(e),o=n?{x:i.right+t.width/2,y:i.top-50-t.height/2}:{x:i.right+50+t.width/2,y:i.bottom+t.height/2};Ot(e)&&(o=Je(e),n?(o.x+=100,o.y-=50):(o.x+=100,o.y+=50));var r={margin:n?-30:30,minDistance:20},a=n?{y:r}:{x:r};return Ih(e,t,o,Bh(a))}function fI(e,t,n){var i=qe(e),o=n?{x:i.right-10+t.width/2,y:i.bottom+40+t.width/2}:{x:i.left-40-t.width/2,y:i.bottom-10+t.height/2},r={margin:30,minDistance:30},a=n?{x:r}:{y:r};return Ih(e,t,o,Bh(a))}function c_(e,t){e.on("autoPlace",function(n){var i=n.shape,o=n.source;return a_(o,i,t)})}c_.$inject=["eventBus","elementRegistry"];const Cu={__depends__:[lI],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",c_]};function Ao(e,t,n,i){we.call(this,e),this._elementRegistry=t,this._modeling=n,this._rules=i;var o=this;this.postExecuted(["shape.create"],function(r){var a=r.context,s=a.hints||{},c=a.shape,l=a.parent||a.newParent;s.autoResize!==!1&&o._expand([c],l)}),this.postExecuted(["elements.move"],function(r){var a=r.context,s=Ip(aa(a.closure.topLevel)),c=a.hints,l=c?c.autoResize:!0;if(l!==!1){var u=sa(s,function(p){return p.parent.id});V(u,function(p,f){Ze(l)&&(p=p.filter(function(d){return It(l,ca({id:d.id}))})),o._expand(p,f)})}}),this.postExecuted(["shape.toggleCollapse"],function(r){var a=r.context,s=a.hints,c=a.shape;s&&s.autoResize===!1||c.collapsed||o._expand(c.children||[],c)}),this.postExecuted(["shape.resize"],function(r){var a=r.context,s=a.hints,c=a.shape,l=c.parent;s&&s.autoResize===!1||l&&o._expand([c],l)})}Ao.$inject=["eventBus","elementRegistry","modeling","rules"],Ne(Ao,we),Ao.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),o=qe(cn(e)),r=qe(t),a={};return o.top-r.top<i.top&&(a.top=o.top-n.top),o.left-r.left<i.left&&(a.left=o.left-n.left),r.right-o.right<i.right&&(a.right=o.right+n.right),r.bottom-o.bottom<i.bottom&&(a.bottom=o.bottom+n.bottom),bl(Y({},r,a))},Ao.prototype._expand=function(e,t){typeof t=="string"&&(t=this._elementRegistry.get(t));var n=this._rules.allowed("element.autoResize",{elements:e,target:t});if(n){var i=this._getOptimalBounds(e,t);if(dI(i,t)){var o=hI(Ni(t,["x","y","width","height"]),i);this.resize(t,i,{autoResize:o});var r=t.parent;r&&this._expand([t],r)}}},Ao.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},Ao.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},Ao.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)};function dI(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function hI(e,t){var n="";return e=qe(e),t=qe(t),e.top>t.top&&(n=n.concat("n")),e.right<t.right&&(n=n.concat("w")),e.bottom<t.bottom&&(n=n.concat("s")),e.left>t.left&&(n=n.concat("e")),n}function Mu(e){e.invoke(Ao,this)}Mu.$inject=["injector"],Ne(Mu,Ao),Mu.prototype.resize=function(e,t,n){M(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)};function oc(e){Ci.call(this,e);var t=this;this.addRule("element.autoResize",function(n){return t.canResize(n.elements,n.target)})}oc.$inject=["eventBus"],Ne(oc,Ci),oc.prototype.canResize=function(e,t){return!1};function Au(e,t){oc.call(this,e),this._modeling=t}Ne(Au,oc),Au.$inject=["eventBus","modeling"],Au.prototype.canResize=function(e,t){if(M(t.di,"bpmndi:BPMNPlane")||!M(t,"bpmn:Participant")&&!M(t,"bpmn:Lane")&&!M(t,"bpmn:SubProcess"))return!1;var n=!0;return V(e,function(i){if(M(i,"bpmn:Lane")||at(i)){n=!1;return}}),n};const l_={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",Mu],bpmnAutoResizeProvider:["type",Au]},gI=1500;class u_{constructor(t){t.on("moddleCopy.canCopyProperties",gI,({sourceElement:n,targetElement:i})=>{var r;if(!((r=n==null?void 0:n.$instanceOf)!=null&&r.call(n,Mr)))return;const o=Rn(n);o!==void 0&&i.set("xml:lang",o)})}}$n(u_,"$inject",["eventBus"]);const p_={__init__:["translationLocaleCopy"],translationLocaleCopy:["type",u_]},mI=500,Pu=1,f_=(e,t)=>{if((e==null?void 0:e.type)!=="bpmn:TextAnnotation"||!(t!=null&&t.original))return;const{x:n,y:i}=t.original;(n<e.x-Pu||n>e.x+e.width+Pu||i<e.y-Pu||i>e.y+e.height+Pu)&&(t.original={x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)})};class d_{constructor(t){t.on("bpmnElement.added",mI,({element:n})=>{if((n==null?void 0:n.type)!=="bpmn:Association")return;const i=n.waypoints;!i||i.length<2||(f_(n.source,i[0]),f_(n.target,i[i.length-1]))})}}$n(d_,"$inject",["eventBus"]);const h_={__init__:["annotationImportDocking"],annotationImportDocking:["type",d_]},g_=[sb,Os,Lh,Cu,l_,Wp,p_,h_];function yI(e={}){Rm(globalThis,e.dom);const t=document.createElement("div");return document.body.appendChild(t),new Ea({container:t,moddleExtensions:e.moddleExtensions??Hc,additionalModules:[...g_,...e.additionalModules??[]]})}const m_={"edge-crosses-shape":"연결","edge-crosses-subprocess":"연결","edge-endpoint-detached":"연결","edge-overlap-opposite":"겹침","edge-overlap-mixed":"겹침","edge-overlap-unrelated":"겹침","shape-overlap":"겹침","shape-outside-container":"소속","label-on-shared-segment":"라벨","label-over-line":"라벨","label-over-shape":"라벨","annotation-over-label":"라벨","pool-name-over-label":"라벨","group-overlap-unintended":"그룹","group-overlap-unreadable":"그룹","group-stack-unreadable":"그룹","group-on-container-boundary":"그룹","group-on-group-boundary":"그룹","group-cuts-shape":"그룹","edge-along-group-boundary":"그룹","pool-overlap":"풀","CHK-FLOW-1":"구조","CHK-POOL-1":"풀"},vI={이:["이","가"],을:["을","를"],와:["과","와"]};function bI(e,t){const[n,i]=vI[t],o=e.at(-1)??"",r=o.charCodeAt(0);return r>=44032&&r<=55203?e+((r-44032)%28===0?i:n):o>="0"&&o<="9"?e+("013678".includes(o)?n:i):e+`${n}(${i})`}const xI={"bpmn:StartEvent":"시작 이벤트","bpmn:EndEvent":"종료 이벤트","bpmn:IntermediateCatchEvent":"중간 이벤트","bpmn:IntermediateThrowEvent":"중간 이벤트","bpmn:BoundaryEvent":"경계 이벤트","bpmn:Task":"작업","bpmn:UserTask":"작업","bpmn:ServiceTask":"작업","bpmn:SendTask":"작업","bpmn:ReceiveTask":"작업","bpmn:ManualTask":"작업","bpmn:ScriptTask":"작업","bpmn:BusinessRuleTask":"작업","bpmn:CallActivity":"작업","bpmn:SubProcess":"서브프로세스","bpmn:ExclusiveGateway":"게이트웨이","bpmn:ParallelGateway":"게이트웨이","bpmn:InclusiveGateway":"게이트웨이","bpmn:EventBasedGateway":"게이트웨이","bpmn:ComplexGateway":"게이트웨이","bpmn:Participant":"풀","bpmn:Lane":"레인","bpmn:TextAnnotation":"주석","bpmn:Group":"그룹","bpmn:DataStoreReference":"데이터 저장소","bpmn:DataObjectReference":"데이터 객체","bpmn:SequenceFlow":"연결선","bpmn:MessageFlow":"메시지 연결선","bpmn:Association":"연관선"},wI="요소";function $h(e){return(e&&xI[e.type])??wI}const y_=20;function _I(e){const t=e.replace(/\s+/g," ").trim();return t.length>y_?`${t.slice(0,y_)}…`:t}function Tu(e,t,n,i=""){const o=e(t),r=(o==null?void 0:o.name)===void 0?void 0:_I(o.name),a=r===void 0?i+$h(o):r,s=r===void 0?a:`「${r}」`;return n?s+bI(a,n).slice(a.length):s}function EI(e,t,n,i,o){const[r,a]=[e(t),e(n)],s=(r==null?void 0:r.name)===void 0&&(a==null?void 0:a.name)===void 0&&$h(r)===$h(a);return[Tu(e,t,i),Tu(e,n,o,s?"다른 ":"")]}function SI(e){switch(e.kind){case"shape-overlap":return e.identical?"error":"warning";case"shape-outside-container":return"error";case"edge-endpoint-detached":return"error";case"pool-overlap":return e.contained?"error":"warning";case"group-cuts-shape":return"error";default:return"warning"}}function RI(e){switch(e.kind){case"edge-crosses-shape":return[e.edge,e.shape];case"edge-crosses-subprocess":return[e.edge,e.subProcess];case"edge-endpoint-detached":return[e.edge,e.shape];case"shape-overlap":return[...e.shapes];case"shape-outside-container":return[e.shape,e.container];case"edge-overlap-opposite":case"edge-overlap-mixed":case"edge-overlap-unrelated":return[...e.edges];case"label-on-shared-segment":return[e.edge,e.other];case"label-over-line":return[e.edge,e.line];case"label-over-shape":return[e.edge,e.shape];case"annotation-over-label":return[e.annotation,e.label];case"group-overlap-unintended":return e.container?[e.container,...e.groups.filter(t=>t!==e.container)]:[...e.groups];case"group-overlap-unreadable":return e.reason==="orphan"?[...e.groups,...e.shapes]:[e.group,...e.shapes];case"group-stack-unreadable":return[...e.groups,...e.shapes];case"group-on-container-boundary":return[e.group,e.container];case"group-on-group-boundary":return[...e.groups];case"group-cuts-shape":return[e.group,e.shape];case"edge-along-group-boundary":return[e.edge,e.group];case"pool-name-over-label":return[e.pool,e.label];case"pool-overlap":return[...e.pools]}}const ku={top:"위",bottom:"아래",left:"왼쪽",right:"오른쪽"};function CI(e,t){const n=(o,r)=>Tu(t,o,r),i=(o,r,a,s)=>EI(t,o,r,a,s);switch(e.kind){case"edge-crosses-shape":return`${n(e.edge,"이")} ${n(e.shape,"을")} 가로지릅니다.`;case"edge-crosses-subprocess":return`${n(e.edge,"이")} 서브프로세스 ${n(e.subProcess)} 안을 지나갑니다.`;case"edge-endpoint-detached":return`${n(e.edge)}의 끝이 ${n(e.shape)}에서 ${Math.round(e.distance)}px 떨어져 연결이 끊겨 보입니다.`;case"shape-overlap":{const[o,r]=i(e.shapes[0],e.shapes[1],"와","이");return e.identical?`${o} ${r} 완전히 같은 자리에 겹쳐 하나가 가려집니다.`:`${o} ${r} 겹칩니다.`}case"shape-outside-container":return`${n(e.shape,"이")} ${n(e.container)} 경계 밖에 놓여 다른 소속으로 읽힙니다.`;case"edge-overlap-opposite":{const[o,r]=i(e.edges[0],e.edges[1],"와","이");return`${o} ${r} 같은 선 위를 ${Math.round(e.length)}px 서로 반대 방향으로 흐릅니다.`}case"edge-overlap-mixed":{const[o,r]=i(e.edges[0],e.edges[1],"와","이");return`${o} ${r} 종류가 다른 선인데 ${Math.round(e.length)}px 겹쳐 흐릅니다.`}case"edge-overlap-unrelated":{const[o,r]=i(e.edges[0],e.edges[1],"와","이");return`${o} ${r} ${Math.round(e.length)}px 한 선처럼 겹쳐 흐르는데 만나는 지점이 없습니다.`}case"label-on-shared-segment":{const[o,r]=i(e.edge,e.other,void 0,"와");return`${o}의 라벨이 ${r} 공유하는 구간 위에 있어 어느 선의 것인지 모호합니다.`}case"label-over-line":return`${n(e.edge)}의 라벨을 선이 가로지릅니다.`;case"label-over-shape":return`${n(e.edge)}의 라벨이 ${n(e.shape)} 위에 ${e.depth}px 겹쳐 있습니다.`;case"annotation-over-label":return`주석 ${n(e.annotation,"이")} ${n(e.label)}의 이름 라벨을 덮습니다.`;case"group-overlap-unintended":{if(e.container)return`${n(e.container,"이")} 다른 그룹을 통째로 덮습니다.`;const[o,r]=i(e.groups[0],e.groups[1],"와","이");return`${o} ${r} 공유 멤버 없이 겹쳐 의도인지 알 수 없습니다.`}case"group-overlap-unreadable":switch(e.reason){case"orphan":{const[o,r]=i(e.groups[0],e.groups[1],"와");return`${o} ${r}의 겹친 영역에 어느 그룹에도 속하지 않은 요소가 ${e.shapes.length}개 있습니다.`}case"minority":return`${n(e.group)} 상자 안에서 자기 멤버가 과반이 아닙니다(다른 요소 ${e.shapes.length}개).`;case"throughpass":return`${n(e.group)} 상자를 자기 멤버가 아닌 요소 ${e.shapes.length}개가 지나갑니다.`}case"group-stack-unreadable":return`그룹 ${e.groups.length}개가 겹쳐 쌓여 요소 ${e.shapes.length}개가 어느 단계인지 읽히지 않습니다.`;case"group-on-container-boundary":return`${n(e.group)} 테두리가 ${n(e.container)}의 ${ku[e.side]} 경계선과 겹쳐 흐릅니다.`;case"group-on-group-boundary":{const[o,r]=i(e.groups[0],e.groups[1],"와");return`${o} ${r}의 테두리가 같은 선 위에 겹칩니다.`}case"group-cuts-shape":return`${n(e.group)} 테두리가 ${n(e.shape)}의 ${ku[e.side]}을(를) ${Math.round(e.depth)}px 가릅니다.`;case"edge-along-group-boundary":return e.distance===0?`${n(e.edge,"이")} ${n(e.group)}의 ${ku[e.side]} 테두리 위를 ${e.length}px 겹쳐 흐릅니다.`:`${n(e.edge,"이")} ${n(e.group)}의 ${ku[e.side]} 테두리 ${e.inside?"안쪽":"바깥쪽"} ${e.distance}px 에 ${e.length}px 나란히 흘러 테두리와 구분되지 않습니다.`;case"pool-name-over-label":return`${n(e.pool)}의 이름 밴드가 ${n(e.label)}의 라벨을 덮습니다.`;case"pool-overlap":{const[o,r]=i(e.pools[0],e.pools[1],"와","이");return e.contained?`${o} ${r} 중 하나가 다른 하나 안에 들어가 있습니다.`:`${o} ${r} 겹칩니다.`}}}function MI(e,t){switch(e.ruleId){case"CHK-FLOW-1":return`${Tu(t,e.targetRefs[0])}에 연결된 선이 하나도 없습니다 — 분기·합류가 없는 게이트웨이는 의미가 정해지지 않습니다.`;case"CHK-POOL-1":return`이 문서에 내용이 없는 풀 ${e.targetRefs.length}개가 펼친 형태로 그려져 있습니다 — 이 문서에서 내용을 그리지 않는 풀은 접힌 형태(블랙박스)가 의미에 맞습니다.`;default:return e.ruleId}}const v_="기타",Fh={error:0,warning:1,info:2};function b_(e,t){const n=[];for(const i of e.geometry)n.push({key:`g:${pt(i)}`,source:"geometry",code:i.kind,severity:SI(i),targetRefs:RI(i),category:m_[i.kind]??v_,message:CI(i,t)});for(const i of e.semantic)n.push({key:`s:${i.ruleId}|${i.targetRefs.join(",")}`,source:"semantic",code:i.ruleId,severity:i.severity,targetRefs:[...i.targetRefs],category:m_[i.ruleId]??v_,message:MI(i,t)});return n}function x_(e){const t={error:0,warning:0,info:0};for(const n of e)t[n.severity]++;return t}function ja(e,t){return t!==void 0&&e.targetRefs.some(n=>t.has(n))}function jh(e,t){if(t===void 0||e.length===0)return!1;const n=ja(e[0],t);return e.some(i=>ja(i,t)!==n)}function w_(e,t){const n=jh(e,t);return e.slice().sort((i,o)=>(n?Number(ja(o,t))-Number(ja(i,t)):0)||Fh[i.severity]-Fh[o.severity])}const __="i18n-untranslated",E_="i18n-review-requested",Hh="i18nDisplay.redrawn",S_=[["untranslated",__],["reviewRequested",E_]];class zh{constructor(t,n,i,o,r,a,s,c){$n(this,"config");$n(this,"displayLocale");this.eventBus=t,this.elementRegistry=n,this.canvas=a,this.textRenderer=s,this.graphicsFactory=c;const l=o.drawShape.bind(o);o.drawShape=(f,d,g)=>this.withDisplayText(d,()=>l(f,d,g),f);const u=r.activate.bind(r);r.activate=f=>this.withDisplayText(f,()=>u(f));const p=r.update.bind(r);r.update=(f,d,g,h)=>{const m=this.resolve(f);if(!m||m.native)return p(f,d,g,h);(d??"").trim()!==(g??"").trim()&&i.execute(Ic,{element:f.labelTarget??f,locale:this.displayLocale,text:d,designLocale:this.config.designLocale,locales:this.locales(),rootLang:this.rootLang()})},t.on("commandStack.element.updateLabel.postExecute",f=>{if(!this.config)return;const{element:d,newLabel:g,oldLabel:h}=f.context;(g??"")!==(h??"")&&i.execute(Ic,{element:d.labelTarget??d,locale:this.displayLocale,text:g??"",designLocale:this.config.designLocale,locales:this.locales(),rootLang:this.rootLang(),nameChangedFrom:h??""})})}configure(t){!t&&!this.config||(this.config=t,this.displayLocale=t==null?void 0:t.designLocale,this.rerenderAll())}locales(){if(!this.config)return[];const{designLocale:t,companionLocales:n}=this.config;return[t,...n.filter(i=>i!==t)]}setDisplayLocale(t){if(this.config)return this.displayLocale=this.locales().includes(t)?t:this.config.designLocale,this.rerenderAll(),this.displayLocale}getDisplayLocale(){return this.displayLocale}rootLang(){var i,o,r;const t=(i=this.canvas.getRootElement())==null?void 0:i.businessObject,n=(t==null?void 0:t.$parent)??t;return((o=n==null?void 0:n.get)==null?void 0:o.call(n,"xml:lang"))??((r=n==null?void 0:n.$attrs)==null?void 0:r["xml:lang"])}resolve(t){if(!this.config||!this.displayLocale)return;const n=(t.labelTarget??t).businessObject,i=Ar(n);if(!i)return;const o=this.displayLocale,r=i.target[i.key]??"",a=No(n).filter(f=>Rn(f)),s=f=>f.body??"",c=a.find(f=>Rn(f)===o&&s(f)),l=$o(n).some(f=>f.locale===o)?"reviewRequested":"ok";if(!r)return c?{text:s(c),status:l,native:!1}:void 0;const u=a.filter(f=>s(f)===r).map(Rn);return(u.length?u:[this.rootLang()??this.config.designLocale]).includes(o)?{text:r,status:l,native:!0}:c?{text:s(c),status:l,native:!1}:{text:r,status:"untranslated",native:!1}}untranslatedCount(t){return this.countStatus(t,"untranslated")}reviewRequestedCount(t){return this.countStatus(t,"reviewRequested")}countStatus(t,n){var r;if(!this.config)return 0;const i=this.displayLocale;this.displayLocale=t;let o=0;try{for(const a of this.elementRegistry.getAll())a.type!=="label"&&((r=this.resolve(a))==null?void 0:r.status)===n&&o++}finally{this.displayLocale=i}return o}withDisplayText(t,n,i){var f;if(!this.config)return n();const o=this.resolve(t),r=(f=i==null?void 0:i.parentNode)==null?void 0:f.classList;if(r)for(const[d,g]of S_)r.toggle(g,(o==null?void 0:o.status)===d);if(!o||o.native)return n();const{target:a,key:s}=Ar((t.labelTarget??t).businessObject),c=Object.prototype.hasOwnProperty.call(a,s),l=a[s];if(l===o.text)return n();a[s]=o.text;const u=this.config.adaptiveExternalLabel??!0,p=t.type==="label"&&u?this.widen(t,o.text):void 0;try{const d=n();return p&&(d!=null&&d.setAttribute)&&d.setAttribute("transform",`translate(${p.dx}, 0)`),d}finally{c?a[s]=l:delete a[s],p==null||p.restore()}}widen(t,n){const{width:i,height:o}=t,r=this.textRenderer.getExternalLabelBounds(t,n);return t.width=r.width,t.height=r.height,{dx:(i-r.width)/2,restore:()=>(t.width=i,t.height=o)}}rerenderAll(){const t=this.canvas.getRootElement();for(const n of this.elementRegistry.getAll()){if(n===t)continue;const i=this.elementRegistry.getGraphics(n);if(i){if(!this.config)for(const[,o]of S_)i.classList.remove(o);this.graphicsFactory.update(n.waypoints?"connection":"shape",n,i)}}this.eventBus.fire(Hh)}}$n(zh,"$inject",["eventBus","elementRegistry","commandStack","bpmnRenderer","labelEditingProvider","canvas","textRenderer","graphicsFactory"]);const R_={__depends__:[Wp],__init__:["i18nDisplay"],i18nDisplay:["type",zh]};var AI=new zr("ov"),PI=500;function Mn(e,t,n,i){this._eventBus=t,this._canvas=n,this._elementRegistry=i,this._ids=AI,this._overlayDefaults=Y({show:null,scale:!0},e&&e.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=TI(n.getContainer()),this._init()}Mn.$inject=["config.overlays","eventBus","canvas","elementRegistry"],Mn.prototype.get=function(e){if(ei(e)&&(e={id:e}),ei(e.element)&&(e.element=this._elementRegistry.get(e.element)),e.element){var t=this._getOverlayContainer(e.element,!0);return t?e.type?ct(t.overlays,ca({type:e.type})):t.overlays.slice():[]}else return e.type?ct(this._overlays,ca({type:e.type})):e.id?this._overlays[e.id]:null},Mn.prototype.add=function(e,t,n){if(mn(t)&&(n=t,t=null),e.id||(e=this._elementRegistry.get(e)),!n.position)throw new Error("must specifiy overlay position");if(!n.html)throw new Error("must specifiy overlay html");if(!e)throw new Error("invalid element specified");var i=this._ids.next();return n=Y({},this._overlayDefaults,n,{id:i,type:t,element:e,html:n.html}),this._addOverlay(n),i},Mn.prototype.remove=function(e){var t=this.get(e)||[];Ze(t)||(t=[t]);var n=this;V(t,function(i){var o=n._getOverlayContainer(i.element,!0);if(i&&(Zi(i.html),Zi(i.htmlContainer),delete i.htmlContainer,delete i.element,delete n._overlays[i.id]),o){var r=o.overlays.indexOf(i);r!==-1&&o.overlays.splice(r,1)}})},Mn.prototype.isShown=function(){return this._overlayRoot.style.display!=="none"},Mn.prototype.show=function(){Ou(this._overlayRoot)},Mn.prototype.hide=function(){Ou(this._overlayRoot,!1)},Mn.prototype.clear=function(){this._overlays={},this._overlayContainers=[],fl(this._overlayRoot)},Mn.prototype._updateOverlayContainer=function(e){var t=e.element,n=e.html,i=t.x,o=t.y;if(t.waypoints){var r=cn(t);i=r.x,o=r.y}C_(n,i,o),Cn(e.html,"data-container-id",t.id)},Mn.prototype._updateOverlay=function(e){var t=e.position,n=e.htmlContainer,i=e.element,o=t.left,r=t.top;if(t.right!==void 0){var a;i.waypoints?a=cn(i).width:a=i.width,o=t.right*-1+a}if(t.bottom!==void 0){var s;i.waypoints?s=cn(i).height:s=i.height,r=t.bottom*-1+s}C_(n,o||0,r||0),this._updateOverlayVisibilty(e,this._canvas.viewbox())},Mn.prototype._createOverlayContainer=function(e){var t=jt('<div class="djs-overlays" />');Un(t,{position:"absolute"}),this._overlayRoot.appendChild(t);var n={html:t,element:e,overlays:[]};return this._updateOverlayContainer(n),this._overlayContainers.push(n),n},Mn.prototype._updateRoot=function(e){var t=e.scale||1,n="matrix("+[t,0,0,t,-1*e.x*t,-1*e.y*t].join(",")+")";M_(this._overlayRoot,n)},Mn.prototype._getOverlayContainer=function(e,t){var n=It(this._overlayContainers,function(i){return i.element===e});return!n&&!t?this._createOverlayContainer(e):n},Mn.prototype._addOverlay=function(e){var t=e.id,n=e.element,i=e.html,o,r;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),ei(i)&&(i=jt(i)),r=this._getOverlayContainer(n),o=jt('<div class="djs-overlay" data-overlay-id="'+t+'">'),Un(o,{position:"absolute"}),o.appendChild(i),e.type&&At(o).add("djs-overlay-"+e.type);var a=this._canvas.findRoot(n),s=this._canvas.getRootElement();Ou(o,a===s),e.htmlContainer=o,r.overlays.push(e),r.html.appendChild(o),this._overlays[t]=e,this._updateOverlay(e),this._updateOverlayVisibilty(e,this._canvas.viewbox())},Mn.prototype._updateOverlayVisibilty=function(e,t){var n=e.show,i=this._canvas.findRoot(e.element),o=n&&n.minZoom,r=n&&n.maxZoom,a=e.htmlContainer,s=this._canvas.getRootElement(),c=!0;(i!==s||n&&(gn(o)&&o>t.scale||gn(r)&&r<t.scale))&&(c=!1),Ou(a,c),this._updateOverlayScale(e,t)},Mn.prototype._updateOverlayScale=function(e,t){var n=e.scale,i,o,r=e.htmlContainer,a,s="";n!==!0&&(n===!1?(i=1,o=1):(i=n.min,o=n.max),gn(i)&&t.scale<i&&(a=(1/t.scale||1)*i),gn(o)&&t.scale>o&&(a=(1/t.scale||1)*o)),gn(a)&&(s="scale("+a+","+a+")"),M_(r,s)},Mn.prototype._updateOverlaysVisibilty=function(e){var t=this;V(this._overlays,function(n){t._updateOverlayVisibilty(n,e)})},Mn.prototype._init=function(){var e=this._eventBus,t=this;function n(i){t._updateRoot(i),t._updateOverlaysVisibilty(i),t.show()}e.on("canvas.viewbox.changing",function(i){t.hide()}),e.on("canvas.viewbox.changed",function(i){n(i.viewbox)}),e.on(["shape.remove","connection.remove"],function(i){var o=i.element,r=t.get({element:o});V(r,function(c){t.remove(c.id)});var a=t._getOverlayContainer(o);if(a){Zi(a.html);var s=t._overlayContainers.indexOf(a);s!==-1&&t._overlayContainers.splice(s,1)}}),e.on("element.changed",PI,function(i){var o=i.element,r=t._getOverlayContainer(o,!0);r&&(V(r.overlays,function(a){t._updateOverlay(a)}),t._updateOverlayContainer(r))}),e.on("element.marker.update",function(i){var o=t._getOverlayContainer(i.element,!0);o&&At(o.html)[i.add?"add":"remove"](i.marker)}),e.on("root.set",function(){t._updateOverlaysVisibilty(t._canvas.viewbox())}),e.on("diagram.clear",this.clear,this)};function TI(e){var t=jt('<div class="djs-overlay-container" />');return Un(t,{position:"absolute",width:0,height:0}),e.insertBefore(t,e.firstChild),t}function C_(e,t,n){Un(e,{left:t+"px",top:n+"px"})}function Ou(e,t){e.style.display=t===!1?"none":""}function M_(e,t){e.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach(function(n){e.style[n+"transform"]=t})}const Du={__init__:["overlays"],overlays:["type",Mn]};function Gh(e,t){t.invoke(we,this),this.executed(function(n){var i=n.context;i.rootElement?e.setRootElement(i.rootElement):i.rootElement=e.getRootElement()}),this.revert(function(n){var i=n.context;i.rootElement&&e.setRootElement(i.rootElement)})}Ne(Gh,we),Gh.$inject=["canvas","injector"];const kI={__init__:["rootElementsBehavior"],rootElementsBehavior:["type",Gh]};function Ur(e){return CSS.escape(e)}var OI={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function A_(e){return e=""+e,e&&e.replace(/[&<>"']/g,function(t){return OI[t]})}var DI="bjs-breadcrumbs-shown";function P_(e,t,n){var i=jt('<ul class="bjs-breadcrumbs"></ul>'),o=n.getContainer(),r=At(o);o.appendChild(i);var a=[];e.on("element.changed",function(c){var l=c.element,u=_e(l),p=It(a,function(f){return f===u});p&&s()});function s(c){c&&(a=LI(c));var l=a.flatMap(function(p){var f=n.findRoot(no(p))||n.findRoot(p.id);if(!f&&M(p,"bpmn:Process")){var d=t.find(function(m){var w=_e(m);return w&&w.get("processRef")===p});f=d&&n.findRoot(d.id)}if(!f)return[];var g=A_(p.name||p.id),h=jt('<li><span class="bjs-crumb"><a title="'+g+'">'+g+"</a></span></li>");return h.addEventListener("click",function(){n.setRootElement(f)}),h});i.innerHTML="";var u=l.length>1;r.toggle(DI,u),l.forEach(function(p){i.appendChild(p)})}e.on("root.set",function(c){s(c.element)})}P_.$inject=["eventBus","elementRegistry","canvas"];function LI(e){for(var t=_e(e),n=[],i=t;i;i=i.$parent)(M(i,"bpmn:SubProcess")||M(i,"bpmn:Process"))&&n.push(i);return n.reverse()}function T_(e,t){var n=null,i=new II;e.on("root.set",function(o){var r=o.element,a=t.viewbox(),s=i.get(r);if(i.set(n,{x:a.x,y:a.y,zoom:a.scale}),n=r,!(!M(r,"bpmn:SubProcess")&&!s)){s=s||{x:0,y:0,zoom:1};var c=(a.x-s.x)*a.scale,l=(a.y-s.y)*a.scale;(c!==0||l!==0)&&t.scroll({dx:c,dy:l}),s.zoom!==a.scale&&t.zoom(s.zoom,{x:0,y:0})}}),e.on("diagram.clear",function(){i.clear(),n=null})}T_.$inject=["eventBus","canvas"];function II(){this._entries=[],this.set=function(e,t){var n=!1;for(var i in this._entries)if(this._entries[i][0]===e){this._entries[i][1]=t,n=!0;break}n||this._entries.push([e,t])},this.get=function(e){for(var t in this._entries)if(this._entries[t][0]===e)return this._entries[t][1];return null},this.clear=function(){this._entries.length=0},this.remove=function(e){var t=-1;for(var n in this._entries)if(this._entries[n][0]===e){t=n;break}t!==-1&&this._entries.splice(t,1)}}var k_={x:180,y:160};function qr(e,t){this._eventBus=e,this._moddle=t;var n=this;e.on("import.render.start",1500,function(i,o){n._handleImport(o.definitions)})}qr.prototype._handleImport=function(e){if(e.diagrams){var t=this;this._definitions=e,this._processToDiagramMap={},e.diagrams.forEach(function(i){!i.plane||!i.plane.bpmnElement||(t._processToDiagramMap[i.plane.bpmnElement.id]=i)});var n=e.diagrams.filter(i=>i.plane).flatMap(i=>t._createNewDiagrams(i.plane));n.forEach(function(i){t._movePlaneElementsToOrigin(i.plane)})}},qr.prototype._createNewDiagrams=function(e){var t=this,n=[],i=[];e.get("planeElement").forEach(function(r){var a=r.bpmnElement;if(a){var s=a.$parent;M(a,"bpmn:SubProcess")&&!r.isExpanded&&n.push(a),NI(a,e)&&i.push({diElement:r,parent:s})}});var o=[];return n.forEach(function(r){if(!t._processToDiagramMap[r.id]){var a=t._createDiagram(r);t._processToDiagramMap[r.id]=a,o.push(a)}}),i.forEach(function(r){for(var a=r.diElement,s=r.parent;s&&n.indexOf(s)===-1;)s=s.$parent;if(s){var c=t._processToDiagramMap[s.id];t._moveToDiPlane(a,c.plane)}}),o},qr.prototype._movePlaneElementsToOrigin=function(e){var t=e.get("planeElement"),n=BI(e),i={x:n.x-k_.x,y:n.y-k_.y};t.forEach(function(o){o.waypoint?o.waypoint.forEach(function(r){r.x=r.x-i.x,r.y=r.y-i.y}):o.bounds&&(o.bounds.x=o.bounds.x-i.x,o.bounds.y=o.bounds.y-i.y)})},qr.prototype._moveToDiPlane=function(e,t){var n=O_(e),i=n.plane.get("planeElement");i.splice(i.indexOf(e),1),t.get("planeElement").push(e)},qr.prototype._createDiagram=function(e){var t=this._moddle.create("bpmndi:BPMNPlane",{bpmnElement:e}),n=this._moddle.create("bpmndi:BPMNDiagram",{plane:t});return t.$parent=n,t.bpmnElement=e,n.$parent=this._definitions,this._definitions.diagrams.push(n),n},qr.$inject=["eventBus","moddle"];function O_(e){return M(e,"bpmndi:BPMNDiagram")?e:O_(e.$parent)}function BI(e){var t={top:1/0,right:-1/0,bottom:-1/0,left:1/0};return e.planeElement.forEach(function(n){if(n.bounds){var i=qe(n.bounds);t.top=Math.min(i.top,t.top),t.left=Math.min(i.left,t.left)}}),bl(t)}function NI(e,t){var n=e.$parent;return!(!M(n,"bpmn:SubProcess")||n===t.bpmnElement||st(e,["bpmn:DataInputAssociation","bpmn:DataOutputAssociation"]))}var Lu=250,$I='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>',FI="bjs-drilldown-empty";function lr(e,t,n,i,o){we.call(this,t),this._canvas=e,this._eventBus=t,this._elementRegistry=n,this._overlays=i,this._translate=o;var r=this;this.executed("shape.toggleCollapse",Lu,function(a){var s=a.shape;r._canDrillDown(s)?r._addOverlay(s):r._removeOverlay(s)},!0),this.reverted("shape.toggleCollapse",Lu,function(a){var s=a.shape;r._canDrillDown(s)?r._addOverlay(s):r._removeOverlay(s)},!0),this.executed(["shape.create","shape.move","shape.delete"],Lu,function(a){var s=a.oldParent,c=a.newParent||a.parent,l=a.shape;r._canDrillDown(l)&&r._addOverlay(l),r._updateDrilldownOverlay(s),r._updateDrilldownOverlay(c),r._updateDrilldownOverlay(l)},!0),this.reverted(["shape.create","shape.move","shape.delete"],Lu,function(a){var s=a.oldParent,c=a.newParent||a.parent,l=a.shape;r._canDrillDown(l)&&r._addOverlay(l),r._updateDrilldownOverlay(s),r._updateDrilldownOverlay(c),r._updateDrilldownOverlay(l)},!0),t.on("import.render.complete",function(){n.filter(function(a){return r._canDrillDown(a)}).map(function(a){r._addOverlay(a)})})}Ne(lr,we),lr.prototype._updateDrilldownOverlay=function(e){var t=this._canvas;if(e){var n=t.findRoot(e);n&&this._updateOverlayVisibility(n)}},lr.prototype._canDrillDown=function(e){var t=this._canvas;return M(e,"bpmn:SubProcess")&&t.findRoot(no(e))},lr.prototype._updateOverlayVisibility=function(e){var t=this._overlays,n=_e(e),i=t.get({element:n.id,type:"drilldown"})[0];if(i){var o=n&&n.get("flowElements")&&n.get("flowElements").length;At(i.html).toggle(FI,!o)}},lr.prototype._addOverlay=function(e){var t=this._canvas,n=this._overlays,i=_e(e),o=n.get({element:e,type:"drilldown"});o.length&&this._removeOverlay(e);var r=jt('<button type="button" class="bjs-drilldown">'+$I+"</button>"),a=i.get("name")||i.get("id"),s=this._translate("Open {element}",{element:a});r.setAttribute("title",s),r.addEventListener("click",function(){t.setRootElement(t.findRoot(no(e)))}),n.add(e,"drilldown",{position:{bottom:-7,right:-8},html:r}),this._updateOverlayVisibility(e)},lr.prototype._removeOverlay=function(e){var t=this._overlays;t.remove({element:e,type:"drilldown"})},lr.$inject=["canvas","eventBus","elementRegistry","overlays","translate"];const jI={__depends__:[Du,yh,kI],__init__:["drilldownBreadcrumbs","drilldownOverlayBehavior","drilldownCentering","subprocessCompatibility"],drilldownBreadcrumbs:["type",P_],drilldownCentering:["type",T_],drilldownOverlayBehavior:["type",lr],subprocessCompatibility:["type",qr]};function ur(e){Wt.call(this,e)}Ne(ur,Wt),ur.prototype._modules=[sb,jI,Du,Mi,Os],ur.prototype._moddleExtensions={};var Iu="keyboard.keydown",HI="keyboard.keyup",zI=1e3,D_="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/issues/661";function qn(e,t){var n=this;this._config=e=e||{},this._eventBus=t,this._keydownHandler=this._keydownHandler.bind(this),this._keyupHandler=this._keyupHandler.bind(this),t.on("diagram.destroy",function(){n._fire("destroy"),n.unbind()}),e.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(D_));var i=e&&e.bind!==!1;t.on("canvas.init",function(o){n._target=o.svg,i&&n.bind(),n._fire("init")})}qn.$inject=["config.keyboard","eventBus"],qn.prototype._keydownHandler=function(e){this._keyHandler(e,Iu)},qn.prototype._keyupHandler=function(e){this._keyHandler(e,HI)},qn.prototype._keyHandler=function(e,t){var n;if(!this._isEventIgnored(e)){var i={keyEvent:e};n=this._eventBus.fire(t||Iu,i),n&&e.preventDefault()}},qn.prototype._isEventIgnored=function(e){return!1},qn.prototype.bind=function(e){e&&console.error("unsupported argument <node>",new Error(D_)),this.unbind(),e=this._node=this._target,Ve.bind(e,"keydown",this._keydownHandler),Ve.bind(e,"keyup",this._keyupHandler),this._fire("bind")},qn.prototype.getBinding=function(){return this._node},qn.prototype.unbind=function(){var e=this._node;e&&(this._fire("unbind"),Ve.unbind(e,"keydown",this._keydownHandler),Ve.unbind(e,"keyup",this._keyupHandler)),this._node=null},qn.prototype._fire=function(e){this._eventBus.fire("keyboard."+e,{node:this._node})},qn.prototype.addListener=function(e,t,n){_n(e)&&(n=t,t=e,e=zI),this._eventBus.on(n||Iu,e,t)},qn.prototype.removeListener=function(e,t){this._eventBus.off(t||Iu,e)},qn.prototype.hasModifier=KO,qn.prototype.isCmd=ai,qn.prototype.isShift=ah,qn.prototype.isKey=vn;var GI=500;function Ha(e,t){var n=this;e.on("editorActions.init",GI,function(i){var o=i.editorActions;n.registerBindings(t,o)})}Ha.$inject=["eventBus","keyboard"],Ha.prototype.registerBindings=function(e,t){function n(i,o){t.isRegistered(i)&&e.addListener(o)}n("undo",function(i){var o=i.keyEvent;if(eD(o))return t.trigger("undo"),!0}),n("redo",function(i){var o=i.keyEvent;if(tD(o))return t.trigger("redo"),!0}),n("copy",function(i){var o=i.keyEvent;if(XO(o))return t.trigger("copy"),!0}),n("paste",function(i){var o=i.keyEvent;if(ZO(o))return t.trigger("paste"),!0}),n("duplicate",function(i){var o=i.keyEvent;if(QO(o))return t.trigger("duplicate"),!0}),n("cut",function(i){var o=i.keyEvent;if(JO(o))return t.trigger("cut"),!0}),n("stepZoom",function(i){var o=i.keyEvent;if(vn(["+","Add","="],o)&&ai(o))return t.trigger("stepZoom",{value:1}),!0}),n("stepZoom",function(i){var o=i.keyEvent;if(vn(["-","Subtract"],o)&&ai(o))return t.trigger("stepZoom",{value:-1}),!0}),n("zoom",function(i){var o=i.keyEvent;if(vn("0",o)&&ai(o))return t.trigger("zoom",{value:1}),!0}),n("removeSelection",function(i){var o=i.keyEvent;if(vn(["Backspace","Delete","Del"],o))return t.trigger("removeSelection"),!0})};const Vh={__init__:["keyboard","keyboardBindings"],keyboard:["type",qn],keyboardBindings:["type",Ha]};var VI={moveSpeed:50,moveSpeedAccelerated:200};function L_(e,t,n){var i=this;this._config=Y({},VI,e||{}),t.addListener(o);function o(r){var a=r.keyEvent,s=i._config;if(t.isCmd(a)&&t.isKey(["ArrowLeft","Left","ArrowUp","Up","ArrowDown","Down","ArrowRight","Right"],a)){var c=t.isShift(a)?s.moveSpeedAccelerated:s.moveSpeed,l;switch(a.key){case"ArrowLeft":case"Left":l="left";break;case"ArrowUp":case"Up":l="up";break;case"ArrowRight":case"Right":l="right";break;case"ArrowDown":case"Down":l="down";break}return i.moveCanvas({speed:c,direction:l}),!0}}this.moveCanvas=function(r){var a=0,s=0,c=r.speed,l=c/Math.min(Math.sqrt(n.viewbox().scale),1);switch(r.direction){case"left":a=l;break;case"up":s=l;break;case"right":a=-l;break;case"down":s=-l;break}n.scroll({dx:a,dy:s})}}L_.$inject=["config.keyboardMove","keyboard","canvas"];const I_={__depends__:[Vh],__init__:["keyboardMove"],keyboardMove:["type",L_]};var WI=15;function B_(e,t){var n;function i(s){return a(s.originalEvent)}e.on("canvas.focus.changed",function(s){s.focused?e.on("element.mousedown",500,i):e.off("element.mousedown",i)});function o(s){var c=n.start,l=n.button,u=Fr(s),p=Gi(u,c);if(!n.dragging&&UI(p)>WI&&(n.dragging=!0,l===0&&qx(e),iu("grab")),n.dragging){var f=n.last||n.start;p=Gi(u,f),t.scroll({dx:p.x,dy:p.y}),n.last=u}s.preventDefault()}function r(s){Ve.unbind(document,"mousemove",o),Ve.unbind(document,"mouseup",r),n=null,Ux()}function a(s){if(!Lr(s.target,".djs-draggable")){var c=s.button;if(!(c>=2||s.ctrlKey||s.shiftKey||s.altKey))return n={button:c,start:Fr(s)},Ve.bind(document,"mousemove",o),Ve.bind(document,"mouseup",r),!0}}this.isActive=function(){return!!n}}B_.$inject=["eventBus","canvas"];function UI(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}const N_={__init__:["moveCanvas"],moveCanvas:["type",B_]};function $_(e,t){var n=id(e.min),i=id(e.max),o=Math.abs(n)+Math.abs(i);return o/t}function qI(e,t){return Math.max(e.min,Math.min(e.max,t))}var YI=Math.sign||function(e){return e>=0?1:-1},Wh={min:.2,max:4},F_=10,KI=.1,XI=.75;function ro(e,t,n){e=e||{},this._enabled=!1,this._canvas=n,this._container=n._container,this._handleWheel=Kn(this._handleWheel,this),this._totalDelta=0,this._scale=e.scale||XI;var i=this;t.on("canvas.mouseover",function(){i._init(e.enabled!==!1)}),t.on("canvas.mouseout",function(){i._init(!1)})}ro.$inject=["config.zoomScroll","eventBus","canvas"],ro.prototype.scroll=function(t){this._canvas.scroll(t)},ro.prototype.reset=function(){this._canvas.zoom("fit-viewport")},ro.prototype.zoom=function(t,n){var i=$_(Wh,F_*2);this._totalDelta+=t,Math.abs(this._totalDelta)>KI&&(this._zoom(t,n,i),this._totalDelta=0)},ro.prototype._handleWheel=function(t){if(this._enabled){var n=this._container;t.preventDefault();var i=t.ctrlKey||ex()&&t.metaKey,o=t.shiftKey,r=-1*this._scale,a;if(i?r*=t.deltaMode===0?.02:.32:r*=t.deltaMode===0?1:16,i){var s=n.getBoundingClientRect(),c={x:t.clientX-s.left,y:t.clientY-s.top};a=Math.sqrt(Math.pow(t.deltaY,2)+Math.pow(t.deltaX,2))*YI(t.deltaY)*r,this.zoom(a,c)}else o?a={dx:r*t.deltaY,dy:0}:a={dx:r*t.deltaX,dy:r*t.deltaY},this.scroll(a)}},ro.prototype.stepZoom=function(t,n){var i=$_(Wh,F_);this._zoom(t,n,i)},ro.prototype._zoom=function(e,t,n){var i=this._canvas,o=e>0?1:-1,r=id(i.zoom()),a=Math.round(r/n)*n;a+=n*o;var s=Math.pow(10,a);i.zoom(qI(Wh,s),t)},ro.prototype.toggle=function(t){var n=this._container,i=this._handleWheel,o=this._enabled;return typeof t>"u"&&(t=!o),o!==t&&Ve[t?"bind":"unbind"](n,"wheel",i,!1),this._enabled=t,t},ro.prototype._init=function(e){this.toggle(e)};const j_={__init__:["zoomScroll"],zoomScroll:["type",ro]};function rc(e){ur.call(this,e)}Ne(rc,ur),rc.prototype._navigationModules=[I_,N_,j_],rc.prototype._modules=[].concat(ur.prototype._modules,rc.prototype._navigationModules);function Uh(e){return e&&e[e.length-1]}function H_(e){return e.y}function z_(e){return e.x}var ZI={left:z_,center:z_,right:function(e){return e.x+e.width},top:H_,middle:H_,bottom:function(e){return e.y+e.height}};function za(e,t){this._modeling=e,this._rules=t}za.$inject=["modeling","rules"],za.prototype._getOrientationDetails=function(e){var t=["top","bottom","middle"],n="x",i="width";return t.indexOf(e)!==-1&&(n="y",i="height"),{axis:n,dimension:i}},za.prototype._isType=function(e,t){return t.indexOf(e)!==-1},za.prototype._alignmentPosition=function(e,t){var n=this._getOrientationDetails(e),i=n.axis,o=n.dimension,r={},a={},s=!1,c,l,u;function p(f,d){return Math.round((f[i]+d[i]+d[o])/2)}if(this._isType(e,["left","top"]))r[e]=t[0][i];else if(this._isType(e,["right","bottom"]))u=Uh(t),r[e]=u[i]+u[o];else if(this._isType(e,["center","middle"])){if(V(t,function(f){var d=f[i]+Math.round(f[o]/2);a[d]?a[d].elements.push(f):a[d]={elements:[f],center:d}}),c=qi(a,function(f){return f.elements.length>1&&(s=!0),f.elements.length}),s)return r[e]=Uh(c).center,r;l=t[0],t=qi(t,function(f){return f[i]+f[o]}),u=Uh(t),r[e]=p(l,u)}return r},za.prototype.trigger=function(e,t){var n=this._modeling,i,o=ct(e,function(c){return!(c.waypoints||c.host||c.labelTarget)});if(i=this._rules.allowed("elements.align",{elements:o}),Ze(i)&&(o=i),!(o.length<2||!i)){var r=ZI[t],a=qi(o,r),s=this._alignmentPosition(t,a);n.alignElements(a,s)}};const QI={__init__:["alignElements"],alignElements:["type",za]},JI=new zr;function Ga(e){this._scheduled={},e.on("diagram.destroy",()=>{Object.keys(this._scheduled).forEach(t=>{this.cancel(t)})})}Ga.$inject=["eventBus"],Ga.prototype.schedule=function(e,t=JI.next()){this.cancel(t);const n=this._schedule(e,t);return this._scheduled[t]=n,n.promise},Ga.prototype._schedule=function(e,t){const n=eB();return{executionId:setTimeout(()=>{try{this._scheduled[t]=null;try{n.resolve(e())}catch(o){n.reject(o)}}catch(o){console.error("Scheduler#_schedule execution failed",o)}}),promise:n.promise}},Ga.prototype.cancel=function(e){const t=this._scheduled[e];t&&(this._cancel(t),this._scheduled[e]=null)},Ga.prototype._cancel=function(e){clearTimeout(e.executionId)};function eB(){const e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}const tB={scheduler:["type",Ga]};var nB="djs-element-hidden",Bu=".entry",iB=1e3,G_=8,oB=300;function un(e,t,n,i){this._canvas=e,this._elementRegistry=t,this._eventBus=n,this._scheduler=i,this._current=null,this._init()}un.$inject=["canvas","elementRegistry","eventBus","scheduler"],un.prototype._init=function(){var e=this;this._eventBus.on("selection.changed",function(t){var n=t.newSelection,i=n.length?n.length===1?n[0]:n:null;i?e.open(i,!0):e.close()}),this._eventBus.on("elements.changed",function(t){var n=t.elements,i=e._current;if(i){var o=i.target,r=Ze(o)?o:[o],a=r.filter(function(c){return n.includes(c)});if(a.length){e.close();var s=r.filter(function(c){return e._elementRegistry.get(c.id)});s.length&&e._updateAndOpen(s.length>1?s:s[0])}}}),this._eventBus.on("canvas.viewbox.changed",function(){e._updatePosition()}),this._eventBus.on("element.marker.update",function(t){if(e.isOpen()){var n=t.element,i=e._current,o=Ze(i.target)?i.target:[i.target];o.includes(n)&&e._updateVisibility()}}),this._container=this._createContainer()},un.prototype._createContainer=function(){var e=jt('<div class="djs-context-pad-parent"></div>');return this._canvas.getContainer().appendChild(e),e},un.prototype.registerProvider=function(e,t){t||(t=e,e=iB),this._eventBus.on("contextPad.getProviders",e,function(n){n.providers.push(t)})},un.prototype.getEntries=function(e){var t=this._getProviders(),n=Ze(e)?"getMultiElementContextPadEntries":"getContextPadEntries",i={};return V(t,function(o){if(_n(o[n])){var r=o[n](e);_n(r)?i=r(i):V(r,function(a,s){i[s]=a})}}),i},un.prototype.trigger=function(e,t,n){var i=this,o,r,a=t.delegateTarget||t.target;if(!a)return t.preventDefault();if(o=Cn(a,"data-action"),r=t.originalEvent||t,e==="mouseover"){this._timeout=setTimeout(function(){i._mouseout=i.triggerEntry(o,"hover",r,n)},oB);return}else if(e==="mouseout"){clearTimeout(this._timeout),this._mouseout&&(this._mouseout(),this._mouseout=null);return}return this.triggerEntry(o,e,r,n)},un.prototype.triggerEntry=function(e,t,n,i){if(this.isShown()){var o=this._current.target,r=this._current.entries,a=r[e];if(a){var s=a.action;if(this._eventBus.fire("contextPad.trigger",{entry:a,event:n})!==!1){if(_n(s)){if(t==="click")return s(n,o,i)}else if(s[t])return s[t](n,o,i);n.preventDefault()}}}},un.prototype.open=function(e,t){if(!(!t&&this.isOpen(e))){var n=this._eventBus.fire("contextPad.open.allowed",{target:e});n!==!1&&(this.close(),this._updateAndOpen(e))}},un.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},un.prototype._updateAndOpen=function(e){var t=this.getEntries(e),n=this._createHtml(e),i;V(t,function(o,r){var a=o.group||"default",s=jt(o.html||'<div class="entry" draggable="true"></div>'),c;Cn(s,"data-action",r),c=Ct("[data-group="+Ur(a)+"]",n),c||(c=jt('<div class="group"></div>'),Cn(c,"data-group",a),n.appendChild(c)),c.appendChild(s),o.className&&rB(s,o.className),o.title&&Cn(s,"title",o.title),o.imageUrl&&(i=jt("<img>"),Cn(i,"src",o.imageUrl),i.style.width="100%",i.style.height="100%",s.appendChild(i))}),At(n).add("open"),this._current={entries:t,html:n,target:e},this._updatePosition(),this._updateVisibility(),this._eventBus.fire("contextPad.open",{current:this._current})},un.prototype._createHtml=function(e){var t=this,n=jt('<div class="djs-context-pad"></div>');return ii.bind(n,Bu,"click",function(i){t.trigger("click",i)}),ii.bind(n,Bu,"dragstart",function(i){t.trigger("dragstart",i)}),ii.bind(n,Bu,"mouseover",function(i){t.trigger("mouseover",i)}),ii.bind(n,Bu,"mouseout",function(i){t.trigger("mouseout",i)}),Ve.bind(n,"mousedown",function(i){i.stopPropagation()}),this._container.appendChild(n),this._eventBus.fire("contextPad.create",{target:e,pad:n}),n},un.prototype.getPad=function(e){console.warn(new Error("ContextPad#getPad is deprecated and will be removed in future library versions, cf. https://github.com/bpmn-io/diagram-js/pull/888"));let t;return this.isOpen()&&sB(this._current.target,e)?t=this._current.html:t=this._createHtml(e),{html:t}},un.prototype.close=function(){this.isOpen()&&(clearTimeout(this._timeout),this._container.innerHTML="",this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)},un.prototype.isOpen=function(e){var t=this._current;if(!t)return!1;if(!e)return!0;var n=t.target;return Ze(e)!==Ze(n)?!1:Ze(e)?e.length===n.length&&Io(e,function(i){return n.includes(i)}):n===e},un.prototype.isShown=function(){return this.isOpen()&&At(this._current.html).has("open")},un.prototype.show=function(){this.isOpen()&&(At(this._current.html).add("open"),this._updatePosition(),this._eventBus.fire("contextPad.show",{current:this._current}))},un.prototype.hide=function(){this.isOpen()&&(At(this._current.html).remove("open"),this._eventBus.fire("contextPad.hide",{current:this._current}))},un.prototype._getPosition=function(e){if(!Ze(e)&&Ot(e)){var t=this._canvas.viewbox(),n=aB(e),i=n.x*t.scale-t.x*t.scale,o=n.y*t.scale-t.y*t.scale;return{left:i+G_*this._canvas.zoom(),top:o}}var r=this._canvas.getContainer(),a=r.getBoundingClientRect(),s=this._getTargetBounds(e);return{left:s.right-a.left+G_*this._canvas.zoom(),top:s.top-a.top}},un.prototype._updatePosition=function(){const e=()=>{if(this.isOpen()){var t=this._current.html,n=this._getPosition(this._current.target);"x"in n&&"y"in n?(t.style.left=n.x+"px",t.style.top=n.y+"px"):["top","right","bottom","left"].forEach(function(i){i in n&&(t.style[i]=n[i]+"px")})}};this._scheduler.schedule(e,"ContextPad#_updatePosition")},un.prototype._updateVisibility=function(){const e=()=>{if(this.isOpen()){var t=this,n=this._current.target,i=Ze(n)?n:[n],o=i.some(function(r){return t._canvas.hasMarker(r,nB)});o?t.hide():t.show()}};this._scheduler.schedule(e,"ContextPad#_updateVisibility")},un.prototype._getTargetBounds=function(e){var t=this,n=Ze(e)?e:[e],i=n.map(function(o){return t._canvas.getGraphics(o)});return i.reduce(function(o,r){const a=r.getBoundingClientRect();return o.top=Math.min(o.top,a.top),o.right=Math.max(o.right,a.right),o.bottom=Math.max(o.bottom,a.bottom),o.left=Math.min(o.left,a.left),o.x=o.left,o.y=o.top,o.width=o.right-o.left,o.height=o.bottom-o.top,o},{top:1/0,right:-1/0,bottom:-1/0,left:1/0})};function rB(e,t){var n=At(e);t=Ze(t)?t:t.split(/\s+/g),t.forEach(function(i){n.add(i)})}function aB(e){return e.waypoints[e.waypoints.length-1]}function sB(e,t){return e=Ze(e)?e:[e],t=Ze(t)?t:[t],e.length===t.length&&Io(e,function(n){return t.includes(n)})}const V_={__depends__:[nu,tB,Du],contextPad:["type",un]};var Nu,qt,W_,pr,U_,q_,Y_,qh,$u,ac,K_,Yh,Kh,Xh,Fu={},ju=[],cB=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Hu=Array.isArray;function Po(e,t){for(var n in t)e[n]=t[n];return e}function Zh(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function X_(e,t,n){var i,o,r,a={};for(r in t)r=="key"?i=t[r]:r=="ref"?o=t[r]:a[r]=t[r];if(arguments.length>2&&(a.children=arguments.length>3?Nu.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)a[r]===void 0&&(a[r]=e.defaultProps[r]);return zu(e,a,i,o,null)}function zu(e,t,n,i,o){var r={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++W_,__i:-1,__u:0};return o==null&&qt.vnode!=null&&qt.vnode(r),r}function Gu(e){return e.children}function Vu(e,t){this.props=e,this.context=t}function Yr(e,t){if(t==null)return e.__?Yr(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Yr(e):null}function lB(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],o=[],r=Po({},t);r.__v=t.__v+1,qt.vnode&&qt.vnode(r),Qh(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??Yr(t),!!(32&t.__u),o),r.__v=t.__v,r.__.__k[r.__i]=r,o0(i,r,o),t.__e=t.__=null,r.__e!=n&&Z_(r)}}function Z_(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Z_(e)}function Q_(e){(!e.__d&&(e.__d=!0)&&pr.push(e)&&!Wu.__r++||U_!=qt.debounceRendering)&&((U_=qt.debounceRendering)||q_)(Wu)}function Wu(){try{for(var e,t=1;pr.length;)pr.length>t&&pr.sort(Y_),e=pr.shift(),t=pr.length,lB(e)}finally{pr.length=Wu.__r=0}}function J_(e,t,n,i,o,r,a,s,c,l,u){var p,f,d,g,h,m,w=i&&i.__k||ju,y=t.length;for(c=uB(n,t,w,c,y),p=0;p<y;p++)(d=n.__k[p])!=null&&(f=d.__i!=-1&&w[d.__i]||Fu,d.__i=p,m=Qh(e,d,f,o,r,a,s,c,l,u),g=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&Jh(f.ref,null,d),u.push(d.ref,d.__c||g,d)),h==null&&g!=null&&(h=g),4&d.__u?(c=e0(d,c,e),f.__e&&(f.__e=null)):typeof d.type=="function"&&m!==void 0?c=m:g&&(c=g.nextSibling),d.__u&=-7);return n.__e=h,c}function uB(e,t,n,i,o){var r,a,s,c,l,u=n.length,p=u,f=0;for(e.__k=new Array(o),r=0;r<o;r++)(a=t[r])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[r]=zu(null,a,null,null,null):Hu(a)?a=e.__k[r]=zu(Gu,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[r]=zu(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[r]=a,c=r+f,a.__=e,a.__b=e.__b+1,s=null,(l=a.__i=pB(a,n,c,p))!=-1&&(p--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(o>u?f--:o<u&&f++),typeof a.type!="function"&&(a.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,a.__u|=4))):e.__k[r]=null;if(p)for(r=0;r<u;r++)(s=n[r])!=null&&(2&s.__u)==0&&(s.__e==i&&(i=Yr(s)),a0(s,s));return i}function e0(e,t,n){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=e0(i[o],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=Yr(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function pB(e,t,n,i){var o,r,a,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(i>(u?1:0)){for(o=n-1,r=n+1;o>=0||r<t.length;)if((l=t[a=o>=0?o--:r++])!=null&&(2&l.__u)==0&&s==l.key&&c==l.type)return a}return-1}function t0(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||cB.test(t)?n:n+"px"}function Uu(e,t,n,i,o){var r,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||t0(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||t0(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(K_,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?i?n[ac]=i[ac]:(n[ac]=Yh,e.addEventListener(t,r?Xh:Kh,r)):e.removeEventListener(t,r?Xh:Kh,r);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function n0(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[$u]==null)t[$u]=Yh++;else if(t[$u]<n[ac])return;return n(qt.event?qt.event(t):t)}}}function Qh(e,t,n,i,o,r,a,s,c,l){var u,p,f,d,g,h,m,w,y,v,x,E,A,B,P,k,H=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),r=[s=t.__e=n.__e]),(u=qt.__b)&&u(t);e:if(typeof H=="function"){p=a.length;try{if(y=t.props,v=H.prototype&&H.prototype.render,x=(u=H.contextType)&&i[u.__c],E=u?x?x.props.value:u.__:i,n.__c?w=(f=t.__c=n.__c).__=f.__E:(v?t.__c=f=new H(y,E):(t.__c=f=new Vu(y,E),f.constructor=H,f.render=dB),x&&x.sub(f),f.state||(f.state={}),f.__n=i,d=f.__d=!0,f.__h=[],f._sb=[]),v&&f.__s==null&&(f.__s=f.state),v&&H.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Po({},f.__s)),Po(f.__s,H.getDerivedStateFromProps(y,f.__s))),g=f.props,h=f.state,f.__v=t,d)v&&H.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),v&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(v&&H.getDerivedStateFromProps==null&&y!==g&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,E),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(y,f.__s,E)===!1){t.__v!=n.__v&&(f.props=y,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(F){F&&(F.__=t)}),ju.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&a.push(f),s=Yr(n);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,E),v&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(g,h,m)})}if(f.context=E,f.props=y,f.__P=e,f.__e=!1,A=qt.__r,B=0,v)f.state=f.__s,f.__d=!1,A&&A(t),u=f.render(f.props,f.state,f.context),ju.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,A&&A(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++B<25);f.state=f.__s,f.getChildContext!=null&&(i=Po(Po({},i),f.getChildContext())),v&&!d&&f.getSnapshotBeforeUpdate!=null&&(m=f.getSnapshotBeforeUpdate(g,h)),P=u!=null&&u.type===Gu&&u.key==null?r0(u.props.children):u,s=J_(e,Hu(P)?P:[P],t,n,i,o,r,a,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&a.push(f),w&&(f.__E=f.__=null)}catch(F){if(a.length=p,t.__v=null,c||r!=null){if(F.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;r!=null&&(r[r.indexOf(s)]=null),t.__e=s}else if(r!=null)for(k=r.length;k--;)Zh(r[k])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),F.then||i0(t),qt.__e(F,t,n)}}else r==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=fB(n.__e,t,n,i,o,r,a,c,l);return(u=qt.diffed)&&u(t),128&t.__u?void 0:s}function i0(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(i0))}function o0(e,t,n){for(var i=0;i<n.length;i++)Jh(n[i],n[++i],n[++i]);qt.__c&&qt.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(r){r.call(o)})}catch(r){qt.__e(r,o.__v)}})}function r0(e){return typeof e!="object"||e==null||e.__b>0?e:Hu(e)?e.map(r0):e.constructor!==void 0?null:Po({},e)}function fB(e,t,n,i,o,r,a,s,c){var l,u,p,f,d,g,h,m=n.props||Fu,w=t.props,y=t.type;if(y=="svg"?o="http://www.w3.org/2000/svg":y=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),r!=null){for(l=0;l<r.length;l++)if((d=r[l])&&"setAttribute"in d==!!y&&(y?d.localName==y:d.nodeType==3)){e=d,r[l]=null;break}}if(e==null){if(y==null)return document.createTextNode(w);e=document.createElementNS(o,y,w.is&&w),s&&(qt.__m&&qt.__m(t,r),s=!1),r=null}if(y==null)m===w||s&&e.data==w||(e.data=w);else{if(r=y=="textarea"&&w.defaultValue!=null?null:r&&Nu.call(e.childNodes),!s&&r!=null)for(m={},l=0;l<e.attributes.length;l++)m[(d=e.attributes[l]).name]=d.value;for(l in m)d=m[l],l=="dangerouslySetInnerHTML"?p=d:l=="children"||l in w||l=="value"&&"defaultValue"in w||l=="checked"&&"defaultChecked"in w||Uu(e,l,null,d,o);for(l in w)d=w[l],l=="children"?f=d:l=="dangerouslySetInnerHTML"?u=d:l=="value"?g=d:l=="checked"?h=d:s&&typeof d!="function"||m[l]===d||Uu(e,l,d,m[l],o);if(u)s||p&&(u.__html==p.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(p&&(e.innerHTML=""),J_(t.type=="template"?e.content:e,Hu(f)?f:[f],t,n,i,y=="foreignObject"?"http://www.w3.org/1999/xhtml":o,r,a,r?r[0]:n.__k&&Yr(n,0),s,c),r!=null)for(l=r.length;l--;)Zh(r[l]);s&&y!="textarea"||(l="value",y=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[l]||y=="progress"&&!g||y=="option"&&g!=m[l])&&Uu(e,l,g,m[l],o),l="checked",h!=null&&h!=e[l]&&Uu(e,l,h,m[l],o))}return e}function Jh(e,t,n){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(o){qt.__e(o,n)}}function a0(e,t,n){var i,o;if(qt.unmount&&qt.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Jh(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(r){qt.__e(r,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(o=0;o<i.length;o++)i[o]&&a0(i[o],t,n||typeof e.type!="function");n||Zh(e.__e),e.__c=e.__=e.__e=void 0}function dB(e,t,n){return this.constructor(e,n)}function s0(e,t,n){var i,o,r,a;t==document&&(t=document.documentElement),qt.__&&qt.__(e,t),o=(i=!1)?null:t.__k,r=[],a=[],Qh(t,e=t.__k=X_(Gu,null,[e]),o||Fu,Fu,t.namespaceURI,o?null:t.firstChild?Nu.call(t.childNodes):null,r,o?o.__e:t.firstChild,i,a),o0(r,e,a),e.props.children=null}Nu=ju.slice,qt={__e:function(e,t,n,i){for(var o,r,a;t=t.__;)if((o=t.__c)&&!o.__)try{if((r=o.constructor)&&r.getDerivedStateFromError!=null&&(o.setState(r.getDerivedStateFromError(e)),a=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,i||{}),a=o.__d),a)return o.__E=o}catch(s){e=s}throw e}},W_=0,Vu.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Po({},this.state),typeof e=="function"&&(e=e(Po({},n),this.props)),e&&Po(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Q_(this))},Vu.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Q_(this))},Vu.prototype.render=Gu,pr=[],q_=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Y_=function(e,t){return e.__v.__b-t.__v.__b},Wu.__r=0,qh=Math.random().toString(8),$u="__d"+qh,ac="__a"+qh,K_=/(PointerCapture)$|Capture$/i,Yh=0,Kh=n0(!1),Xh=n0(!0);var c0=function(e,t,n,i){var o;t[0]=0;for(var r=1;r<t.length;r++){var a=t[r++],s=t[r]?(t[0]|=a?1:2,n[t[r++]]):t[++r];a===3?i[0]=s:a===4?i[1]=Object.assign(i[1]||{},s):a===5?(i[1]=i[1]||{})[t[++r]]=s:a===6?i[1][t[++r]]+=s+"":a?(o=e.apply(s,c0(e,s,n,["",null])),i.push(o),s[0]?t[0]|=2:(t[r-2]=0,t[r]=o)):i.push(s)}return i},l0=new Map;function hB(e){var t=l0.get(this);return t||(t=new Map,l0.set(this,t)),(t=c0(this,t.get(e)||(t.set(e,t=(function(n){for(var i,o,r=1,a="",s="",c=[0],l=function(f){r===1&&(f||(a=a.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?c.push(0,f,a):r===3&&(f||a)?(c.push(3,f,a),r=2):r===2&&a==="..."&&f?c.push(4,f,0):r===2&&a&&!f?c.push(5,0,!0,a):r>=5&&((a||!f&&r===5)&&(c.push(r,0,a,o),r=6),f&&(c.push(r,f,0,o),r=6)),a=""},u=0;u<n.length;u++){u&&(r===1&&l(),l(u));for(var p=0;p<n[u].length;p++)i=n[u][p],r===1?i==="<"?(l(),c=[c],r=3):a+=i:r===4?a==="--"&&i===">"?(r=1,a=""):a=i+a[0]:s?i===s?s="":a+=i:i==='"'||i==="'"?s=i:i===">"?(l(),r=1):r&&(i==="="?(r=5,o=a,a=""):i==="/"&&(r<5||n[u][p+1]===">")?(l(),r===3&&(c=c[0]),r=c,(c=c[0]).push(2,0,r),r=0):i===" "||i===" "||i===`
10
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="`+f+'" height="'+d+'" viewBox="'+u+" "+p+" "+f+" "+d+'" version="1.1">'+s+a+"</svg>"}catch(i){n=i}if(this._emit("saveSVG.done",{error:n,svg:t}),n)throw n;return{svg:t}},Wt.prototype._setDefinitions=function(e){this._definitions=e},Wt.prototype.getModules=function(){return this._modules},Wt.prototype.clear=function(){this.getDefinitions()&&Xo.prototype.clear.call(this)},Wt.prototype.destroy=function(){Xo.prototype.destroy.call(this),Zi(this._container)},Wt.prototype.on=function(e,t,n,i){return this.get("eventBus").on(e,t,n,i)},Wt.prototype.off=function(e,t){this.get("eventBus").off(e,t)},Wt.prototype.attachTo=function(e){if(!e)throw new Error("parentNode required");this.detach(),e.get&&e.constructor.prototype.jquery&&(e=e.get(0)),typeof e=="string"&&(e=Ct(e)),e.appendChild(this._container),this._emit("attach",{}),this.get("canvas").resized()},Wt.prototype.getDefinitions=function(){return this._definitions},Wt.prototype.detach=function(){const e=this._container,t=e.parentNode;t&&(this._emit("detach",{}),t.removeChild(e))},Wt.prototype._init=function(e,t,n){const i=n.modules||this.getModules(n),o=n.additionalModules||[],r=[{bpmnjs:["value",this],moddle:["value",t]}],a=[].concat(r,i,o),s=Y(Yi(n,["additionalModules"]),{canvas:Y({},n.canvas,{container:e}),modules:a});Xo.call(this,s),n&&n.container&&this.attachTo(n.container)},Wt.prototype._emit=function(e,t){return this.get("eventBus").fire(e,t)},Wt.prototype._createContainer=function(e){const t=jt('<div class="bjs-container"></div>');return Un(t,{width:Qv(e.width),height:Qv(e.height),position:e.position}),t},Wt.prototype._createModdle=function(e){const t=Y({},this._moddleExtensions,e.moddleExtensions);return new _m(t)},Wt.prototype._modules=[];function Sl(e,t){return e.warnings=t,e}function LT(e){const n=/unparsable content <([^>]+)> detected([\s\S]*)$/.exec(e.message);return n&&(e.message="unparsable content <"+n[1]+"> detected; this may indicate an invalid BPMN 2.0 diagram file"+n[2]),e}const IT={width:"100%",height:"100%",position:"relative"};function Qv(e){return e+(Qe(e)?"px":"")}function BT(e,t){return t&&It(e.diagrams,function(n){return n.id===t})||null}function NT(e){const n='<a href="http://bpmn.io" target="_blank" class="bjs-powered-by" title="Powered by bpmn.io" >'+Yv+"</a>",i=jt(n);Un(Ct("svg",i),Kv),Un(i,Xv,{position:"absolute",bottom:"15px",right:"15px",zIndex:"100"}),e.appendChild(i),Ve.bind(i,"click",function(o){DT(),o.preventDefault()})}function Ea(e){Wt.call(this,e),this.on("import.parse.complete",function(t){t.error||this._collectIds(t.definitions,t.elementsById)},this),this.on("diagram.destroy",function(){this.get("moddle").ids.clear()},this)}Ne(Ea,Wt),Ea.prototype._createModdle=function(e){var t=Wt.prototype._createModdle.call(this,e);return t.ids=new Xi([32,36,1]),t},Ea.prototype._collectIds=function(e,t){var n=e.$model,i=n.ids,o;i.clear();for(o in t)i.claim(o,t[o])};function ht(e,t){return M(e,"bpmn:CallActivity")?!1:M(e,"bpmn:SubProcess")?(t=t||mt(e),t&&M(t,"bpmndi:BPMNPlane")?!0:t&&!!t.isExpanded):M(e,"bpmn:Participant")?!!_e(e).processRef:!0}function En(e){if(!(!M(e,"bpmn:Participant")&&!M(e,"bpmn:Lane"))){var t=mt(e).isHorizontal;return t===void 0?!0:t}}function $T(e){return e&&_e(e).isInterrupting!==!1}function Gn(e){return e&&!!_e(e).triggeredByEvent}function Sa(e,t){var n=_e(e).eventDefinitions;return Bo(n,function(i){return M(i,t)})}function FT(e){return Sa(e,"bpmn:ErrorEventDefinition")}function jT(e){return Sa(e,"bpmn:EscalationEventDefinition")}function HT(e){return Sa(e,"bpmn:CompensateEventDefinition")}var Nr={width:90,height:20},Jv=15;function Zo(e){return M(e,"bpmn:Event")||M(e,"bpmn:Gateway")||M(e,"bpmn:DataStoreReference")||M(e,"bpmn:DataObjectReference")||M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput")||M(e,"bpmn:SequenceFlow")||M(e,"bpmn:MessageFlow")||M(e,"bpmn:Group")}function Rl(e){return at(e.label)}function zT(e){var t=e.length/2-1,n=e[Math.floor(t)],i=e[Math.ceil(t+.01)],o=GT(e),r=Math.atan((i.y-n.y)/(i.x-n.x)),a=o.x,s=o.y;return Math.abs(r)<Math.PI/2?s-=Jv:a+=Jv,{x:a,y:s}}function GT(e){var t=e.length/2-1,n=e[Math.floor(t)],i=e[Math.ceil(t+.01)];return{x:n.x+(i.x-n.x)/2,y:n.y+(i.y-n.y)/2}}function Jf(e){return e.waypoints?zT(e.waypoints):M(e,"bpmn:Group")?{x:e.x+e.width/2,y:e.y+Nr.height/2}:{x:e.x+e.width/2,y:e.y+e.height+Nr.height/2}}function VT(e,t){var n,i,o,r=e.label;return r&&r.bounds?(o=r.bounds,i={width:Math.max(Nr.width,o.width),height:o.height},n={x:o.x+o.width/2,y:o.y+o.height/2}):(n=Jf(t),i=Nr),Y({x:n.x-i.width/2,y:n.y-i.height/2},i)}function eb(e){if(M(e,"bpmn:FlowElement")||M(e,"bpmn:Participant")||M(e,"bpmn:Lane")||M(e,"bpmn:SequenceFlow")||M(e,"bpmn:MessageFlow")||M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput"))return"name";if(M(e,"bpmn:TextAnnotation"))return"text";if(M(e,"bpmn:Group"))return"categoryValueRef"}function WT(e){var t=e.categoryValueRef;return t&&t.value||""}function vi(e){var t=e.businessObject,n=eb(t);if(n)return n==="categoryValueRef"?WT(t):t[n]||""}function UT(e,t){var n=e.businessObject,i=eb(n);if(i)if(i==="categoryValueRef"){if(!n[i])return e;n[i].value=t}else n[i]=t;return e}function qT(e){return at(e)&&Zo(e.labelTarget)}var Ra=7;function tb(e){let t=[];return V(e.incoming,n=>{M(n,"bpmn:Association")&&M(n.source,"bpmn:TextAnnotation")&&t.push({annotation:n.source,association:n})}),V(e.outgoing,n=>{M(n,"bpmn:Association")&&M(n.target,"bpmn:TextAnnotation")&&t.push({annotation:n.target,association:n})}),t}function Ps(e){const t=new Map;return V(Uf(e),n=>{V(tb(n),i=>{t.has(i.annotation)||t.set(i.annotation,{annotation:i.annotation,associations:[]}),t.get(i.annotation).associations.push(i.association)})}),[...t.values()]}var ed="hsl(225, 10%, 15%)",YT="white";function to(e,t){return Bo(e.eventDefinitions,function(n){return n.$type===t})}function KT(e){return e.$type==="bpmn:IntermediateThrowEvent"||e.$type==="bpmn:EndEvent"}function XT(e){var t=e.dataObjectRef;return e.isCollection||t&&t.isCollection}function ut(e,t,n){var i=mt(e);return n||i.get("color:background-color")||i.get("bioc:fill")||t||YT}function Be(e,t,n){var i=mt(e);return n||i.get("color:border-color")||i.get("bioc:stroke")||t||ed}function Ts(e,t,n,i){var o=mt(e),r=o.get("label");return i||r&&r.get("color:color")||t||Be(e,n)}function nb(e){var t=e.x+e.width/2,n=e.y+e.height/2,i=e.width/2,o=[["M",t,n],["m",0,-i],["a",i,i,0,1,1,0,2*i],["a",i,i,0,1,1,0,-2*i],["z"]];return Ir(o)}function td(e,t){var n=e.x,i=e.y,o=e.width,r=e.height,a=[["M",n+t,i],["l",o-t*2,0],["a",t,t,0,0,1,t,t],["l",0,r-t*2],["a",t,t,0,0,1,-t,t],["l",t*2-o,0],["a",t,t,0,0,1,-t,-t],["l",0,t*2-r],["a",t,t,0,0,1,t,-t],["z"]];return Ir(a)}function ZT(e){var t=e.width,n=e.height,i=e.x,o=e.y,r=t/2,a=n/2,s=[["M",i+r,o],["l",r,a],["l",-r,a],["l",-r,-a],["z"]];return Ir(s)}function QT(e){var t=e.x,n=e.y,i=e.width,o=e.height,r=[["M",t,n],["l",i,0],["l",0,o],["l",-i,0],["z"]];return Ir(r)}function ks(e,t={}){return{width:Ei(e,t),height:ri(e,t)}}function Ei(e,t={}){return ti(t,"width")?t.width:e.width}function ri(e,t={}){return ti(t,"height")?t.height:e.height}var JT=new Xi,e2=10,Cl=3,t2=1.5,Ml=10,n2=4,Ca=.95,i2=1,o2=.25;function $r(e,t,n,i,o,r,a){yo.call(this,t,a);var s=e&&e.defaultFillColor,c=e&&e.defaultStrokeColor,l=e&&e.defaultLabelColor;function u($){return n.computeStyle($,{strokeLinecap:"round",strokeLinejoin:"round",stroke:ed,strokeWidth:2,fill:"white"})}function p($){return n.computeStyle($,["no-fill"],{strokeLinecap:"round",strokeLinejoin:"round",stroke:ed,strokeWidth:2})}function f($,C){var{ref:R={x:0,y:0},scale:W=1,element:q,parentGfx:fe=o._svg}=C,Oe=He("marker",{id:$,viewBox:"0 0 20 20",refX:R.x,refY:R.y,markerWidth:20*W,markerHeight:20*W,orient:"auto"});tt(Oe,q);var nt=Ct(":scope > defs",fe);nt||(nt=He("defs"),tt(fe,nt)),tt(nt,Oe)}function d($,C,R,W){var q=JT.nextPrefixed("marker-");return g($,q,C,R,W),"url(#"+q+")"}function g($,C,R,W,q){if(R==="sequenceflow-end"){var fe=He("path",{d:"M 1 5 L 11 10 L 1 15 Z",...u({fill:q,stroke:q,strokeWidth:1})});f(C,{element:fe,ref:{x:11,y:10},scale:.5,parentGfx:$})}if(R==="messageflow-start"){var Oe=He("circle",{cx:6,cy:6,r:3.5,...u({fill:W,stroke:q,strokeWidth:1,strokeDasharray:[1e4,1]})});f(C,{element:Oe,ref:{x:6,y:6},parentGfx:$})}if(R==="messageflow-end"){var nt=He("path",{d:"m 1 5 l 0 -3 l 7 3 l -7 3 z",...u({fill:W,stroke:q,strokeWidth:1,strokeDasharray:[1e4,1]})});f(C,{element:nt,ref:{x:8.5,y:5},parentGfx:$})}if(R==="association-start"){var lt=He("path",{d:"M 11 5 L 1 10 L 11 15",...p({fill:"none",stroke:q,strokeWidth:1.5,strokeDasharray:[1e4,1]})});f(C,{element:lt,ref:{x:1,y:10},scale:.5,parentGfx:$})}if(R==="association-end"){var Vt=He("path",{d:"M 1 5 L 11 10 L 1 15",...p({fill:"none",stroke:q,strokeWidth:1.5,strokeDasharray:[1e4,1]})});f(C,{element:Vt,ref:{x:11,y:10},scale:.5,parentGfx:$})}if(R==="conditional-flow-marker"){var St=He("path",{d:"M 0 10 L 8 6 L 16 10 L 8 14 Z",...u({fill:W,stroke:q})});f(C,{element:St,ref:{x:-1,y:10},scale:.5,parentGfx:$})}if(R==="conditional-default-flow-marker"){var nn=He("path",{d:"M 6 4 L 10 16",...u({stroke:q,fill:"none"})});f(C,{element:nn,ref:{x:0,y:10},scale:.5,parentGfx:$})}}function h($,C,R,W,q={}){mn(W)&&(q=W,W=0),W=W||0,q=u(q);var fe=C/2,Oe=R/2,nt=He("circle",{cx:fe,cy:Oe,r:Math.round((C+R)/4-W),...q});return tt($,nt),nt}function m($,C,R,W,q,fe){mn(q)&&(fe=q,q=0),q=q||0,fe=u(fe);var Oe=He("rect",{x:q,y:q,width:C-q*2,height:R-q*2,rx:W,ry:W,...fe});return tt($,Oe),Oe}function w($,C,R,W){var q=C/2,fe=R/2,Oe=[{x:q,y:0},{x:C,y:fe},{x:q,y:R},{x:0,y:fe}],nt=Oe.map(function(Vt){return Vt.x+","+Vt.y}).join(" ");W=u(W);var lt=He("polygon",{...W,points:nt});return tt($,lt),lt}function y($,C,R,W){R=p(R);var q=_s(C,R,W);return tt($,q),q}function v($,C,R){return y($,C,R,5)}function x($,C,R){R=p(R);var W=He("path",{...R,d:C});return tt($,W),W}function E($,C,R,W){return x(C,R,Y({"data-marker":$},W))}function A($){return ze[$]}function I($){return function(C,R,W){return A($)(C,R,W)}}var P={"bpmn:MessageEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_MESSAGE",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.235,my:.315}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill),Oe=W?ut(C,s,R.fill):Be(C,c,R.stroke),nt=x($,q,{fill:fe,stroke:Oe,strokeWidth:1});return nt},"bpmn:TimerEventDefinition":function($,C,R={}){var W=R.width||C.width,q=R.height||C.height,fe=R.width?1:2,Oe=h($,W,q,.2*q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:fe}),nt=i.getScaledPath("EVENT_TIMER_WH",{xScaleFactor:.75,yScaleFactor:.75,containerWidth:W,containerHeight:q,position:{mx:.5,my:.5}});x($,nt,{stroke:Be(C,c,R.stroke),strokeWidth:fe});for(var lt=0;lt<12;lt++){var Vt=i.getScaledPath("EVENT_TIMER_LINE",{xScaleFactor:.75,yScaleFactor:.75,containerWidth:W,containerHeight:q,position:{mx:.5,my:.5}}),St=W/2,nn=q/2;x($,Vt,{strokeWidth:1,stroke:Be(C,c,R.stroke),transform:"rotate("+lt*30+","+nn+","+St+")"})}return Oe},"bpmn:EscalationEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_ESCALATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.5,my:.2}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:ConditionalEventDefinition":function($,C,R={}){var W=i.getScaledPath("EVENT_CONDITIONAL",{xScaleFactor:1,yScaleFactor:1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.5,my:.222}});return x($,W,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:LinkEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_LINK",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.57,my:.263}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:ErrorEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_ERROR",{xScaleFactor:1.1,yScaleFactor:1.1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.2,my:.722}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:CancelEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_CANCEL_45",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.638,my:-.055}}),fe=W?Be(C,c,R.stroke):"none",Oe=x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1});return Uv(Oe,45),Oe},"bpmn:CompensateEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_COMPENSATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.22,my:.5}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:SignalEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_SIGNAL",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.5,my:.2}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{strokeWidth:1,fill:fe,stroke:Be(C,c,R.stroke)})},"bpmn:MultipleEventDefinition":function($,C,R={},W){var q=i.getScaledPath("EVENT_MULTIPLE",{xScaleFactor:1.1,yScaleFactor:1.1,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.211,my:.36}}),fe=W?Be(C,c,R.stroke):ut(C,s,R.fill);return x($,q,{fill:fe,stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:ParallelMultipleEventDefinition":function($,C,R={}){var W=i.getScaledPath("EVENT_PARALLEL_MULTIPLE",{xScaleFactor:1.2,yScaleFactor:1.2,containerWidth:R.width||C.width,containerHeight:R.height||C.height,position:{mx:.458,my:.194}});return x($,W,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1})},"bpmn:TerminateEventDefinition":function($,C,R={}){var W=h($,C.width,C.height,8,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:4});return W}};function k($,C,R={},W){var q=_e($),fe=KT(q),Oe=W||$;return q.get("eventDefinitions")&&q.get("eventDefinitions").length>1?q.get("parallelMultiple")?P["bpmn:ParallelMultipleEventDefinition"](C,Oe,R,fe):P["bpmn:MultipleEventDefinition"](C,Oe,R,fe):to(q,"bpmn:MessageEventDefinition")?P["bpmn:MessageEventDefinition"](C,Oe,R,fe):to(q,"bpmn:TimerEventDefinition")?P["bpmn:TimerEventDefinition"](C,Oe,R,fe):to(q,"bpmn:ConditionalEventDefinition")?P["bpmn:ConditionalEventDefinition"](C,Oe,R,fe):to(q,"bpmn:SignalEventDefinition")?P["bpmn:SignalEventDefinition"](C,Oe,R,fe):to(q,"bpmn:EscalationEventDefinition")?P["bpmn:EscalationEventDefinition"](C,Oe,R,fe):to(q,"bpmn:LinkEventDefinition")?P["bpmn:LinkEventDefinition"](C,Oe,R,fe):to(q,"bpmn:ErrorEventDefinition")?P["bpmn:ErrorEventDefinition"](C,Oe,R,fe):to(q,"bpmn:CancelEventDefinition")?P["bpmn:CancelEventDefinition"](C,Oe,R,fe):to(q,"bpmn:CompensateEventDefinition")?P["bpmn:CompensateEventDefinition"](C,Oe,R,fe):to(q,"bpmn:TerminateEventDefinition")?P["bpmn:TerminateEventDefinition"](C,Oe,R,fe):null}var H={ParticipantMultiplicityMarker:function($,C,R={}){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_PARALLEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2-6)/W,my:(q-15)/q}});E("participant-multiplicity",$,fe,{strokeWidth:2,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},SubProcessMarker:function($,C,R={}){var W=m($,14,14,0,{strokeWidth:1,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)});Dn(W,C.width/2-7.5,C.height-20);var q=i.getScaledPath("MARKER_SUB_PROCESS",{xScaleFactor:1.5,yScaleFactor:1.5,containerWidth:C.width,containerHeight:C.height,position:{mx:(C.width/2-7.5)/C.width,my:(C.height-20)/C.height}});E("sub-process",$,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},ParallelMarker:function($,C,R){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_PARALLEL",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2+R.parallel)/W,my:(q-20)/q}});E("parallel",$,fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},SequentialMarker:function($,C,R){var W=i.getScaledPath("MARKER_SEQUENTIAL",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:(C.width/2+R.seq)/C.width,my:(C.height-19)/C.height}});E("sequential",$,W,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},CompensationMarker:function($,C,R){var W=i.getScaledPath("MARKER_COMPENSATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:(C.width/2+R.compensation)/C.width,my:(C.height-13)/C.height}});E("compensation",$,W,{strokeWidth:1,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})},LoopMarker:function($,C,R){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_LOOP",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2+R.loop)/W,my:(q-7)/q}});E("loop",$,fe,{strokeWidth:1.5,fill:"none",stroke:Be(C,c,R.stroke),strokeMiterlimit:.5})},AdhocMarker:function($,C,R){var W=Ei(C,R),q=ri(C,R),fe=i.getScaledPath("MARKER_ADHOC",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:(W/2+R.adhoc)/W,my:(q-15)/q}});E("adhoc",$,fe,{strokeWidth:1,fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke)})}};function F($,C,R,W){H[$](C,R,W)}function G($,C,R=[],W={}){W={fill:W.fill,stroke:W.stroke,width:Ei(C,W),height:ri(C,W)};var q=_e(C),fe=R.includes("SubProcessMarker");fe?W={...W,seq:-21,parallel:-22,compensation:-25,loop:-18,adhoc:10}:W={...W,seq:-5,parallel:-6,compensation:-7,loop:0,adhoc:-8},q.get("isForCompensation")&&R.push("CompensationMarker"),M(q,"bpmn:AdHocSubProcess")&&(R.push("AdhocMarker"),fe||Y(W,{compensation:W.compensation-18}));var Oe=q.get("loopCharacteristics"),nt=Oe&&Oe.get("isSequential");Oe&&(Y(W,{compensation:W.compensation-18}),R.includes("AdhocMarker")&&Y(W,{seq:-23,loop:-18,parallel:-24}),nt===void 0&&R.push("LoopMarker"),nt===!1&&R.push("ParallelMarker"),nt===!0&&R.push("SequentialMarker")),R.includes("CompensationMarker")&&R.length===1&&Y(W,{compensation:-8}),V(R,function(lt){F(lt,$,C,W)})}function ee($,C,R={}){R=Y({size:{width:100}},R);var W=r.createText(C||"",R);return dt(W).add("djs-label"),tt($,W),W}function ce($,C,R,W={}){var q=_e(C),fe=ks({x:C.x,y:C.y,width:C.width,height:C.height},W);return ee($,q.name,{align:R,box:fe,padding:7,style:{fill:Ts(C,l,c,W.stroke)}})}function ie($,C,R={}){var W={width:C.width,height:C.height,x:C.width/2+C.x,y:C.height/2+C.y};return ee($,vi(C),{box:W,style:Y({},r.getExternalStyle(),{fill:Ts(C,l,c,R.stroke)})})}function be($,C,R,W={}){var q=En(R),fe=ee($,C,{box:{height:30,width:q?ri(R,W):Ei(R,W)},align:"center-middle",style:{fill:Ts(R,l,c,W.stroke)}});if(q){var Oe=-1*ri(R,W);_l(fe,0,-Oe,270)}}function he($,C,R={}){var{width:W,height:q}=ks(C,R);return m($,W,q,Ml,{...R,fill:ut(C,s,R.fill),fillOpacity:Ca,stroke:Be(C,c,R.stroke)})}function ye($,C,R={}){var W=_e(C),q=ut(C,s,R.fill),fe=Be(C,c,R.stroke);return(W.get("associationDirection")==="One"||W.get("associationDirection")==="Both")&&(R.markerEnd=d($,"association-end",q,fe)),W.get("associationDirection")==="Both"&&(R.markerStart=d($,"association-start",q,fe)),R=yt(R,["markerStart","markerEnd"]),v($,C.waypoints,{...R,stroke:fe,strokeDasharray:"0, 5"})}function Ee($,C,R={}){var W=ut(C,s,R.fill),q=Be(C,c,R.stroke),fe=i.getScaledPath("DATA_OBJECT_PATH",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.474,my:.296}}),Oe=x($,fe,{fill:W,fillOpacity:Ca,stroke:q}),nt=_e(C);if(XT(nt)){var lt=i.getScaledPath("DATA_OBJECT_COLLECTION_PATH",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:.33,my:(C.height-18)/C.height}});x($,lt,{strokeWidth:2,fill:W,stroke:q})}return Oe}function U($,C,R={}){return h($,C.width,C.height,{fillOpacity:Ca,...R,fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke)})}function ue($,C,R={}){return w($,C.width,C.height,{fill:ut(C,s,R.fill),fillOpacity:Ca,stroke:Be(C,c,R.stroke)})}function K($,C,R={}){var W=m($,Ei(C,R),ri(C,R),0,{fill:ut(C,s,R.fill),fillOpacity:R.fillOpacity||Ca,stroke:Be(C,c,R.stroke),strokeWidth:1.5}),q=_e(C);if(M(q,"bpmn:Lane")){var fe=q.get("name");be($,fe,C,R)}return W}function J($,C,R={}){var W=he($,C,R),q=ht(C);if(Gn(C)&&(Ie(W,{strokeDasharray:"0, 5.5",strokeWidth:2.5}),!q)){var fe=_e(C).flowElements||[],Oe=fe.filter(nt=>M(nt,"bpmn:StartEvent"));Oe.length===1&&ge(Oe[0],$,R,C)}return ce($,C,q?"center-top":"center-middle",R),q?G($,C,void 0,R):G($,C,["SubProcessMarker"],R),W}function ge($,C,R,W){var q=22,fe={fill:ut(W,s,R.fill),stroke:Be(W,c,R.stroke),width:q,height:q},Oe=_e($).isInterrupting,nt=Oe?0:3,lt=Oe?1:1.2,Vt=20,St=(q-Vt)/2,nn="translate("+St+","+St+")";h(C,Vt,Vt,{fill:fe.fill,stroke:fe.stroke,strokeWidth:lt,strokeDasharray:nt,transform:nn}),k($,C,fe,W)}function Re($,C,R={}){var W=he($,C,R);return ce($,C,"center-middle",R),G($,C,void 0,R),W}var ze=this.handlers={"bpmn:AdHocSubProcess":function($,C,R={}){return ht(C)?R=yt(R,["fill","stroke","width","height"]):R=yt(R,["fill","stroke"]),J($,C,R)},"bpmn:Association":function($,C,R={}){return R=yt(R,["fill","stroke"]),ye($,C,R)},"bpmn:BoundaryEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=_e(C),fe=q.get("cancelActivity");R={strokeWidth:1.5,fill:ut(C,s,R.fill),fillOpacity:i2,stroke:Be(C,c,R.stroke)},fe||(R.strokeDasharray="6");var Oe=U($,C,R);return h($,C.width,C.height,Cl,{...R,fill:"none"}),W&&k(C,$,R),Oe},"bpmn:BusinessRuleTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_BUSINESS_RULE_MAIN",{abspos:{x:8,y:8}}),fe=x($,q);Ie(fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1});var Oe=i.getScaledPath("TASK_TYPE_BUSINESS_RULE_HEADER",{abspos:{x:8,y:8}}),nt=x($,Oe);return Ie(nt,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:CallActivity":function($,C,R={}){return R=yt(R,["fill","stroke"]),J($,C,{strokeWidth:5,...R})},"bpmn:ComplexGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R),q=i.getScaledPath("GATEWAY_COMPLEX",{xScaleFactor:.5,yScaleFactor:.5,containerWidth:C.width,containerHeight:C.height,position:{mx:.46,my:.26}});return x($,q,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:DataInput":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=i.getRawPath("DATA_ARROW"),q=Ee($,C,R);return x($,W,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1}),q},"bpmn:DataInputAssociation":function($,C,R={}){return R=yt(R,["fill","stroke"]),ye($,C,{...R,markerEnd:d($,"association-end",ut(C,s,R.fill),Be(C,c,R.stroke))})},"bpmn:DataObject":function($,C,R={}){return R=yt(R,["fill","stroke"]),Ee($,C,R)},"bpmn:DataObjectReference":I("bpmn:DataObject"),"bpmn:DataOutput":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=i.getRawPath("DATA_ARROW"),q=Ee($,C,R);return x($,W,{strokeWidth:1,fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke)}),q},"bpmn:DataOutputAssociation":function($,C,R={}){return R=yt(R,["fill","stroke"]),ye($,C,{...R,markerEnd:d($,"association-end",ut(C,s,R.fill),Be(C,c,R.stroke))})},"bpmn:DataStoreReference":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=i.getScaledPath("DATA_STORE",{xScaleFactor:1,yScaleFactor:1,containerWidth:C.width,containerHeight:C.height,position:{mx:0,my:.133}});return x($,W,{fill:ut(C,s,R.fill),fillOpacity:Ca,stroke:Be(C,c,R.stroke),strokeWidth:2})},"bpmn:EndEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=U($,C,{...R,strokeWidth:4});return W&&k(C,$,R),q},"bpmn:EventBasedGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=_e(C),q=ue($,C,R);h($,C.width,C.height,C.height*.2,{fill:ut(C,"none",R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1});var fe=W.get("eventGatewayType"),Oe=!!W.get("instantiate");function nt(){var Vt=i.getScaledPath("GATEWAY_EVENT_BASED",{xScaleFactor:.18,yScaleFactor:.18,containerWidth:C.width,containerHeight:C.height,position:{mx:.36,my:.44}});x($,Vt,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:2})}if(fe==="Parallel"){var lt=i.getScaledPath("GATEWAY_PARALLEL",{xScaleFactor:.4,yScaleFactor:.4,containerWidth:C.width,containerHeight:C.height,position:{mx:.474,my:.296}});x($,lt,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1})}else fe==="Exclusive"&&(Oe||h($,C.width,C.height,C.height*.26,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1}),nt());return q},"bpmn:ExclusiveGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R),q=i.getScaledPath("GATEWAY_EXCLUSIVE",{xScaleFactor:.4,yScaleFactor:.4,containerWidth:C.width,containerHeight:C.height,position:{mx:.32,my:.3}}),fe=mt(C);return fe.get("isMarkerVisible")&&x($,q,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:Gateway":function($,C,R={}){return R=yt(R,["fill","stroke"]),ue($,C,R)},"bpmn:Group":function($,C,R={}){return R=yt(R,["fill","stroke","width","height"]),m($,C.width,C.height,Ml,{stroke:Be(C,c,R.stroke),strokeWidth:1.5,strokeDasharray:"10, 6, 0, 6",fill:"none",pointerEvents:"none",width:Ei(C,R),height:ri(C,R)})},"bpmn:InclusiveGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R);return h($,C.width,C.height,C.height*.24,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:2.5}),W},"bpmn:IntermediateEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=U($,C,{...R,strokeWidth:1.5});return h($,C.width,C.height,Cl,{fill:"none",stroke:Be(C,c,R.stroke),strokeWidth:1.5}),W&&k(C,$,R),q},"bpmn:IntermediateCatchEvent":I("bpmn:IntermediateEvent"),"bpmn:IntermediateThrowEvent":I("bpmn:IntermediateEvent"),"bpmn:Lane":function($,C,R={}){return R=yt(R,["fill","stroke","width","height"]),K($,C,{...R,fillOpacity:o2})},"bpmn:ManualTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_MANUAL",{abspos:{x:17,y:15}});return x($,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:.5}),W},"bpmn:MessageFlow":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=_e(C),q=mt(C),fe=ut(C,s,R.fill),Oe=Be(C,c,R.stroke),nt=v($,C.waypoints,{markerEnd:d($,"messageflow-end",fe,Oe),markerStart:d($,"messageflow-start",fe,Oe),stroke:Oe,strokeDasharray:"10, 11",strokeWidth:1.5});if(W.get("messageRef")){var lt=nt.getPointAtLength(nt.getTotalLength()/2),Vt=i.getScaledPath("MESSAGE_FLOW_MARKER",{abspos:{x:lt.x,y:lt.y}}),St={strokeWidth:1};q.get("messageVisibleKind")==="initiating"?(St.fill=fe,St.stroke=Oe):(St.fill=Oe,St.stroke=fe);var nn=x($,Vt,St),An=W.get("messageRef"),Vn=An.get("name"),Tt=ee($,Vn,{align:"center-top",fitBox:!0,style:{fill:Oe}}),$t=nn.getBBox(),xn=Tt.getBBox(),vr=lt.x-xn.width/2,Qn=lt.y+$t.height/2+e2;_l(Tt,vr,Qn,0)}return nt},"bpmn:ParallelGateway":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ue($,C,R),q=i.getScaledPath("GATEWAY_PARALLEL",{xScaleFactor:.6,yScaleFactor:.6,containerWidth:C.width,containerHeight:C.height,position:{mx:.46,my:.2}});return x($,q,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:Participant":function($,C,R={}){R=yt(R,["fill","stroke","width","height"]);var W=K($,C,R),q=ht(C),fe=En(C),Oe=_e(C),nt=Oe.get("name");if(q){var lt=fe?[{x:30,y:0},{x:30,y:ri(C,R)}]:[{x:0,y:30},{x:Ei(C,R),y:30}];y($,lt,{stroke:Be(C,c,R.stroke),strokeWidth:t2}),be($,nt,C,R)}else{var Vt=ks(C,R);fe||(Vt.height=Ei(C,R),Vt.width=ri(C,R));var St=ee($,nt,{box:Vt,align:"center-middle",style:{fill:Ts(C,l,c,R.stroke)}});if(!fe){var nn=-1*ri(C,R);_l(St,0,-nn,270)}}return Oe.get("participantMultiplicity")&&F("ParticipantMultiplicityMarker",$,C,R),W},"bpmn:ReceiveTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=_e(C),q=Re($,C,R),fe;return W.get("instantiate")?(h($,28,28,20*.22,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),fe=i.getScaledPath("TASK_TYPE_INSTANTIATING_SEND",{abspos:{x:7.77,y:9.52}})):fe=i.getScaledPath("TASK_TYPE_SEND",{xScaleFactor:.9,yScaleFactor:.9,containerWidth:21,containerHeight:14,position:{mx:.3,my:.4}}),x($,fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),q},"bpmn:ScriptTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_SCRIPT",{abspos:{x:15,y:20}});return x($,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:SendTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=i.getScaledPath("TASK_TYPE_SEND",{xScaleFactor:1,yScaleFactor:1,containerWidth:21,containerHeight:14,position:{mx:.285,my:.357}});return x($,q,{fill:Be(C,c,R.stroke),stroke:ut(C,s,R.fill),strokeWidth:1}),W},"bpmn:SequenceFlow":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=ut(C,s,R.fill),q=Be(C,c,R.stroke),fe=v($,C.waypoints,{markerEnd:d($,"sequenceflow-end",W,q),stroke:q}),Oe=_e(C),{source:nt}=C;if(nt){var lt=_e(nt);Oe.get("conditionExpression")&&M(lt,"bpmn:Activity")&&Ie(fe,{markerStart:d($,"conditional-flow-marker",W,q)}),lt.get("default")&&(M(lt,"bpmn:Gateway")||M(lt,"bpmn:Activity"))&&lt.get("default")===Oe&&Ie(fe,{markerStart:d($,"conditional-default-flow-marker",W,q)})}return fe},"bpmn:ServiceTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R);h($,10,10,{fill:ut(C,s,R.fill),stroke:"none",transform:"translate(6, 6)"});var q=i.getScaledPath("TASK_TYPE_SERVICE",{abspos:{x:12,y:18}});x($,q,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),h($,10,10,{fill:ut(C,s,R.fill),stroke:"none",transform:"translate(11, 10)"});var fe=i.getScaledPath("TASK_TYPE_SERVICE",{abspos:{x:17,y:22}});return x($,fe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:1}),W},"bpmn:StartEvent":function($,C,R={}){var{renderIcon:W=!0}=R;R=yt(R,["fill","stroke"]);var q=_e(C);q.get("isInterrupting")||(R={...R,strokeDasharray:"6"});var fe=U($,C,R);return W&&k(C,$,R),fe},"bpmn:SubProcess":function($,C,R={}){return ht(C)?R=yt(R,["fill","stroke","width","height"]):R=yt(R,["fill","stroke"]),J($,C,R)},"bpmn:Task":function($,C,R={}){return R=yt(R,["fill","stroke"]),Re($,C,R)},"bpmn:TextAnnotation":function($,C,R={}){R=yt(R,["fill","stroke"]);var{width:W,height:q}=ks(C,R),fe=m($,W,q,0,0,{fill:"none",stroke:"none"}),Oe=i.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:W,containerHeight:q,position:{mx:0,my:0}});x($,Oe,{stroke:Be(C,c,R.stroke)});var nt=_e(C),lt=nt.get("text")||"";return ee($,lt,{align:"left-top",box:ks(C,R),padding:Ra,style:{fill:Ts(C,l,c,R.stroke)}}),fe},"bpmn:Transaction":function($,C,R={}){ht(C)?R=yt(R,["fill","stroke","width","height"]):R=yt(R,["fill","stroke"]);var W=J($,C,{strokeWidth:1.5,...R}),q=n.style(["no-fill","no-events"],{stroke:Be(C,c,R.stroke),strokeWidth:1.5}),fe=ht(C);return fe||(R={}),m($,Ei(C,R),ri(C,R),Ml-Cl,Cl,q),W},"bpmn:UserTask":function($,C,R={}){R=yt(R,["fill","stroke"]);var W=Re($,C,R),q=15,fe=12,Oe=i.getScaledPath("TASK_TYPE_USER_1",{abspos:{x:q,y:fe}});x($,Oe,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:.5});var nt=i.getScaledPath("TASK_TYPE_USER_2",{abspos:{x:q,y:fe}});x($,nt,{fill:ut(C,s,R.fill),stroke:Be(C,c,R.stroke),strokeWidth:.5});var lt=i.getScaledPath("TASK_TYPE_USER_3",{abspos:{x:q,y:fe}});return x($,lt,{fill:Be(C,c,R.stroke),stroke:Be(C,c,R.stroke),strokeWidth:.5}),W},label:function($,C,R={}){return ie($,C,R)}};this._drawPath=x,this._renderer=A}Ne($r,yo),$r.$inject=["config.bpmnRenderer","eventBus","styles","pathMap","canvas","textRenderer"],$r.prototype.canRender=function(e){return M(e,"bpmn:BaseElement")},$r.prototype.drawShape=function(e,t,n={}){var{type:i}=t,o=this._renderer(i);return o(e,t,n)},$r.prototype.drawConnection=function(e,t,n={}){var{type:i}=t,o=this._renderer(i);return o(e,t,n)},$r.prototype.getShapePath=function(e){return at(e)?td(e,n2):M(e,"bpmn:Event")?nb(e):M(e,"bpmn:Activity")?td(e,Ml):M(e,"bpmn:Gateway")?ZT(e):QT(e)};function yt(e,t=[]){return t.reduce((n,i)=>(e[i]&&(n[i]=e[i]),n),{})}var r2=0,a2={width:150,height:50};function s2(e){var t=e.split("-");return{horizontal:t[0]||"center",vertical:t[1]||"top"}}function c2(e){return mn(e)?Y({top:0,left:0,right:0,bottom:0},e):{top:e,left:e,right:e,bottom:e}}var nd=null;function l2(){return nd||(nd=document.createElement("canvas").getContext("2d")),nd}function u2(e){var t=[];return e.fontStyle&&t.push(e.fontStyle),e.fontVariant&&t.push(e.fontVariant),e.fontWeight&&t.push(e.fontWeight),e.fontStretch&&t.push(e.fontStretch),t.push(ib(e.fontSize)||"12px"),t.push(e.fontFamily||"sans-serif"),t.join(" ")}function ib(e){if(e!=null)return typeof e=="number"||/^-?\d+(\.\d+)?$/.test(e)?e+"px":e}function p2(e,t){var n=l2();if(!n)return{width:0,height:0};n.font=u2(t),"letterSpacing"in n&&(n.letterSpacing=ib(t.letterSpacing)||"0px");var i=e==="",o=i?"dummy":e.replace(/\s+$/,""),r=n.measureText(o);return{width:i?0:r.width,height:"fontBoundingBoxAscent"in r?r.fontBoundingBoxAscent+r.fontBoundingBoxDescent:r.actualBoundingBoxAscent+r.actualBoundingBoxDescent}}function f2(e,t,n){for(var i=e.shift(),o=i,r;;){if(r=p2(o,n),r.width=o?r.width:0,o===" "||o===""||r.width<Math.round(t)||o.length<2)return d2(e,o,i,r);o=g2(o,r.width,t)}}function d2(e,t,n,i){if(t.length<n.length){var o=n.slice(t.length).trim();e.unshift(o)}return{width:i.width,height:i.height,text:t}}var ob="­";function h2(e,t){var n=e.split(/(\s|-|\u00AD)/g),i,o=[],r=0;if(n.length>1)for(;i=n.shift();)if(i.length+r<t)o.push(i),r+=i.length;else{(i==="-"||i===ob)&&o.pop();break}var a=o[o.length-1];return a&&a===ob&&(o[o.length-1]="-"),o.join("")}function g2(e,t,n){var i=Math.max(e.length*(n/t),1),o=h2(e,i);return o||(o=e.slice(0,Math.max(Math.round(i-1),1))),o}function Al(e){this._config=Y({},{size:a2,padding:r2,style:{},align:"center-top"},e||{})}Al.prototype.createText=function(e,t){return this.layoutText(e,t).element},Al.prototype.getDimensions=function(e,t){return this.layoutText(e,t).dimensions},Al.prototype.layoutText=function(e,t){for(var n=Y({},this._config.size,t.box),i=Y({},this._config.style,t.style),o=s2(t.align||this._config.align),r=c2(t.padding!==void 0?t.padding:this._config.padding),a=t.fitBox||!1,s=m2(i),c=e.split(/\u00AD?\r?\n/),l=[],u=n.width-r.left-r.right;c.length;)l.push(f2(c,u,i));o.vertical==="middle"&&(r.top=r.bottom=0);var p=ni(l,function(m,w,y){return m+(s||w.height)},0)+r.top+r.bottom,f=ni(l,function(m,w,y){return w.width>m?w.width:m},0),d=r.top;o.vertical==="middle"&&(d+=(n.height-p)/2),d-=(s||l[0].height)/4;var g=He("text");Ie(g,i),V(l,function(m){var w;switch(d+=s||m.height,o.horizontal){case"left":w=r.left;break;case"right":w=(a?f:u)-r.right-m.width;break;default:w=Math.max(((a?f:u)-m.width)/2+r.left,0)}var y=He("tspan");Ie(y,{x:w,y:d}),y.textContent=m.text,tt(g,y)});var h={width:f,height:p};return{dimensions:h,element:g}};function m2(e){if("fontSize"in e&&"lineHeight"in e)return e.lineHeight*parseInt(e.fontSize,10)}var y2=12,v2=1.2,b2=40;function rb(e){var t=Y({fontFamily:"Arial, sans-serif",fontSize:y2,fontWeight:"normal",lineHeight:v2},e&&e.defaultStyle||{}),n=parseInt(t.fontSize,10)-1,i=Y({},t,{fontSize:n},e&&e.externalStyle||{}),o=new Al({style:t});this.getExternalLabelBounds=function(a,s){var c={width:Math.max(a.width,Nr.width),height:30},l=r(s,c,{style:i});return{x:Math.round(a.x+a.width/2-l.width/2),y:a.y,width:Math.ceil(l.width),height:Math.ceil(l.height)}},this.getTextAnnotationBounds=function(a,s){var c=r(s,a,{style:t,align:"left-top",padding:Ra});return{x:a.x,y:a.y,width:a.width,height:Math.max(b2,Math.round(c.height))}},this.getDimensions=function(a,s){return o.getDimensions(a,s||{})};function r(a,s,c){return o.getDimensions(a,Y({box:s},c))}this.createText=function(a,s){return o.createText(a,s||{})},this.getDefaultStyle=function(){return t},this.getExternalStyle=function(){return i}}rb.$inject=["config.textRenderer"];function x2(){this.pathMap={EVENT_MESSAGE:{d:"m {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}",height:36,width:36,heightElements:[6,14],widthElements:[10.5,21]},EVENT_SIGNAL:{d:"M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z",height:36,width:36,heightElements:[18],widthElements:[10,20]},EVENT_ESCALATION:{d:"M {mx},{my} l {e.x0},{e.y0} l -{e.x0},-{e.y1} l -{e.x0},{e.y1} Z",height:36,width:36,heightElements:[20,7],widthElements:[8]},EVENT_CONDITIONAL:{d:"M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z M {e.x2},{e.y3} l {e.x0},0 M {e.x2},{e.y4} l {e.x0},0 M {e.x2},{e.y5} l {e.x0},0 M {e.x2},{e.y6} l {e.x0},0 M {e.x2},{e.y7} l {e.x0},0 M {e.x2},{e.y8} l {e.x0},0 ",height:36,width:36,heightElements:[8.5,14.5,18,11.5,14.5,17.5,20.5,23.5,26.5],widthElements:[10.5,14.5,12.5]},EVENT_LINK:{d:"m {mx},{my} 0,{e.y0} -{e.x1},0 0,{e.y1} {e.x1},0 0,{e.y0} {e.x0},-{e.y2} -{e.x0},-{e.y2} z",height:36,width:36,heightElements:[4.4375,6.75,7.8125],widthElements:[9.84375,13.5]},EVENT_ERROR:{d:"m {mx},{my} {e.x0},-{e.y0} {e.x1},-{e.y1} {e.x2},{e.y2} {e.x3},-{e.y3} -{e.x4},{e.y4} -{e.x5},-{e.y5} z",height:36,width:36,heightElements:[.023,8.737,8.151,16.564,10.591,8.714],widthElements:[.085,6.672,6.97,4.273,5.337,6.636]},EVENT_CANCEL_45:{d:"m {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z",height:36,width:36,heightElements:[4.75,8.5],widthElements:[4.75,8.5]},EVENT_COMPENSATION:{d:"m {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x1},-{e.y2} {e.x2},-{e.y3} 0,{e.y1} -{e.x2},-{e.y3} z",height:36,width:36,heightElements:[6.5,13,.4,6.1],widthElements:[9,9.3,8.7]},EVENT_TIMER_WH:{d:"M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ",height:36,width:36,heightElements:[10,2],widthElements:[3,7]},EVENT_TIMER_LINE:{d:"M {mx},{my} m {e.x0},{e.y0} l -{e.x1},{e.y1} ",height:36,width:36,heightElements:[10,3],widthElements:[0,0]},EVENT_MULTIPLE:{d:"m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z",height:36,width:36,heightElements:[6.28099,12.56199],widthElements:[3.1405,9.42149,12.56198]},EVENT_PARALLEL_MULTIPLE:{d:"m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} -{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z",height:36,width:36,heightElements:[2.56228,7.68683],widthElements:[2.56228,7.68683]},GATEWAY_EXCLUSIVE:{d:"m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} {e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} {e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z",height:17.5,width:17.5,heightElements:[8.5,6.5312,-6.5312,-8.5],widthElements:[6.5,-6.5,3,-3,5,-5]},GATEWAY_PARALLEL:{d:"m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z",height:30,width:30,heightElements:[5,12.5],widthElements:[5,12.5]},GATEWAY_EVENT_BASED:{d:"m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z",height:11,width:11,heightElements:[-6,6,12,-12],widthElements:[9,-3,-12]},GATEWAY_COMPLEX:{d:"m {mx},{my} 0,{e.y0} -{e.x0},-{e.y1} -{e.x1},{e.y2} {e.x0},{e.y1} -{e.x2},0 0,{e.y3} {e.x2},0 -{e.x0},{e.y1} l {e.x1},{e.y2} {e.x0},-{e.y1} 0,{e.y0} {e.x3},0 0,-{e.y0} {e.x0},{e.y1} {e.x1},-{e.y2} -{e.x0},-{e.y1} {e.x2},0 0,-{e.y3} -{e.x2},0 {e.x0},-{e.y1} -{e.x1},-{e.y2} -{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z",height:17.125,width:17.125,heightElements:[4.875,3.4375,2.125,3],widthElements:[3.4375,2.125,4.875,3]},DATA_OBJECT_PATH:{d:"m 0,0 {e.x1},0 {e.x0},{e.y0} 0,{e.y1} -{e.x2},0 0,-{e.y2} {e.x1},0 0,{e.y0} {e.x0},0",height:61,width:51,heightElements:[10,50,60],widthElements:[10,40,50,60]},DATA_OBJECT_COLLECTION_PATH:{d:"m{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10",height:10,width:10,heightElements:[],widthElements:[]},DATA_ARROW:{d:"m 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z",height:61,width:51,heightElements:[],widthElements:[]},DATA_STORE:{d:"m {mx},{my} l 0,{e.y2} c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 l 0,-{e.y2} c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 m -{e.x2},{e.y0}c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0m -{e.x2},{e.y0}c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0",height:61,width:61,heightElements:[7,10,45],widthElements:[2,58,60]},TEXT_ANNOTATION:{d:"m {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0",height:30,width:10,heightElements:[30],widthElements:[10]},MARKER_SUB_PROCESS:{d:"m{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0",height:10,width:10,heightElements:[],widthElements:[]},MARKER_PARALLEL:{d:"m{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10",height:10,width:10,heightElements:[],widthElements:[]},MARKER_SEQUENTIAL:{d:"m{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0",height:10,width:10,heightElements:[],widthElements:[]},MARKER_COMPENSATION:{d:"m {mx},{my} 7,-5 0,10 z m 7.1,-0.3 6.9,-4.7 0,10 -6.9,-4.7 z",height:10,width:21,heightElements:[],widthElements:[]},MARKER_LOOP:{d:"m {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 -6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902",height:13.9,width:13.7,heightElements:[],widthElements:[]},MARKER_ADHOC:{d:"m {mx},{my} m 0.84461,2.64411 c 1.05533,-1.23780996 2.64337,-2.07882 4.29653,-1.97997996 2.05163,0.0805 3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 1.2775,-0.64078 1.7542,-1.17511 0,0.56023 0,1.12046 0,1.6807 -0.98706,0.96237996 -2.29792,1.62393996 -3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 -2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z",height:4,width:15,heightElements:[],widthElements:[]},TASK_TYPE_SEND:{d:"m {mx},{my} l 0,{e.y1} l {e.x1},0 l 0,-{e.y1} z l {e.x0},{e.y0} l {e.x0},-{e.y0}",height:14,width:21,heightElements:[6,14],widthElements:[10.5,21]},TASK_TYPE_SCRIPT:{d:"m {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z m -7,-12 l 5,0 m -4.5,3 l 4.5,0 m -3,3 l 5,0m -4,3 l 5,0",height:15,width:12.6,heightElements:[6,14],widthElements:[10.5,21]},TASK_TYPE_USER_1:{d:"m {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 -4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 zm -8,6 l 0,5.5 m 11,0 l 0,-5"},TASK_TYPE_USER_2:{d:"m {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 -2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 "},TASK_TYPE_USER_3:{d:"m {mx},{my} m -6.9,-3.80 c 0,0 2.25099998,-2.358 4.27399998,-1.177 2.024,1.181 4.221,1.537 4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 -4.20799998,3.36699999 -4.20699998,4.34799999 z"},TASK_TYPE_MANUAL:{d:"m {mx},{my} c 0.234,-0.01 5.604,0.008 8.029,0.004 0.808,0 1.271,-0.172 1.417,-0.752 0.227,-0.898 -0.334,-1.314 -1.338,-1.316 -2.467,-0.01 -7.886,-0.004 -8.108,-0.004 -0.014,-0.079 0.016,-0.533 0,-0.61 0.195,-0.042 8.507,0.006 9.616,0.002 0.877,-0.007 1.35,-0.438 1.353,-1.208 0.003,-0.768 -0.479,-1.09 -1.35,-1.091 -2.968,-0.002 -9.619,-0.013 -9.619,-0.013 v -0.591 c 0,0 5.052,-0.016 7.225,-0.016 0.888,-0.002 1.354,-0.416 1.351,-1.193 -0.006,-0.761 -0.492,-1.196 -1.361,-1.196 -3.473,-0.005 -10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 -0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 -1.516,1.253 -1.882,2.19 -0.37000002,0.95 -0.17,2.01 -0.166,2.979 0.004,0.718 -0.27300002,1.345 -0.055,2.063 0.629,2.087 2.425,3.312 4.859,3.318 4.6179995,0.014 9.2379995,-0.139 13.8569995,-0.158 0.755,-0.004 1.171,-0.301 1.182,-1.033 0.012,-0.754 -0.423,-0.969 -1.183,-0.973 -1.778,-0.01 -5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z"},TASK_TYPE_INSTANTIATING_SEND:{d:"m {mx},{my} l 0,8.4 l 12.6,0 l 0,-8.4 z l 6.3,3.6 l 6.3,-3.6"},TASK_TYPE_SERVICE:{d:"m {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 -1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 -0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 -1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 h -2.241173 l 0.0042,1.63124 c -0.353763,0.0736 -0.705369,0.17977 -1.049785,0.32371 -0.344415,0.14437 -0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z m 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z"},TASK_TYPE_SERVICE_FILL:{d:"m {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z"},TASK_TYPE_BUSINESS_RULE_HEADER:{d:"m {mx},{my} 0,4 20,0 0,-4 z"},TASK_TYPE_BUSINESS_RULE_MAIN:{d:"m {mx},{my} 0,12 20,0 0,-12 zm 0,8 l 20,0 m -13,-4 l 0,8"},MESSAGE_FLOW_MARKER:{d:"m {mx},{my} m -10.5 ,-7 l 0,14 l 21,0 l 0,-14 z l 10.5,6 l 10.5,-6"}},this.getRawPath=function(t){return this.pathMap[t].d},this.getScaledPath=function(t,n){var i=this.pathMap[t],o,r;n.abspos?(o=n.abspos.x,r=n.abspos.y):(o=n.containerWidth*n.position.mx,r=n.containerHeight*n.position.my);var a={};if(n.position){for(var s=n.containerHeight/i.height*n.yScaleFactor,c=n.containerWidth/i.width*n.xScaleFactor,l=0;l<i.heightElements.length;l++)a["y"+l]=i.heightElements[l]*s;for(var u=0;u<i.widthElements.length;u++)a["x"+u]=i.widthElements[u]*c}var p=S2(i.d,{mx:o,my:r,e:a});return p}}var w2=/\{([^{}]+)\}/g,_2=/(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g;function E2(e,t,n){var i=n;return t.replace(_2,function(o,r,a,s,c){r=r||s,i&&(r in i&&(i=i[r]),typeof i=="function"&&c&&(i=i()))}),i=(i==null||i==n?e:i)+"",i}function S2(e,t){return String(e).replace(w2,function(n,i){return E2(n,i,t)})}const R2={__init__:["bpmnRenderer"],bpmnRenderer:["type",$r],textRenderer:["type",rb],pathMap:["type",x2]};function C2(e,t){return t=t||{},e.replace(/{([^}]+)}/g,function(n,i){return t[i]||"{"+i+"}"})}const Os={translate:["value",C2]};function Pl(e,t,n){return Y({id:e.id,type:e.$type,businessObject:e,di:t},n)}function M2(e,t,n){var i=e.waypoint;return!i||i.length<2?[Je(t),Je(n)]:i.map(function(o){return{x:o.x,y:o.y}})}function ab(e,t,n){return new Error(`element ${zn(t)} referenced by ${zn(e)}#${n} not yet drawn`)}function wo(e,t,n,i,o){this._eventBus=e,this._canvas=t,this._elementFactory=n,this._elementRegistry=i,this._textRenderer=o}wo.$inject=["eventBus","canvas","elementFactory","elementRegistry","textRenderer"],wo.prototype.add=function(e,t,n){var i,o,r;if(M(t,"bpmndi:BPMNPlane")){var a=M(e,"bpmn:SubProcess")?{id:e.id+"_plane"}:{};i=this._elementFactory.createRoot(Pl(e,t,a)),this._canvas.addRootElement(i)}else if(M(t,"bpmndi:BPMNShape")){var s=!ht(e,t),c=P2(e);o=n&&(n.hidden||n.collapsed);var l=t.bounds;i=this._elementFactory.createShape(Pl(e,t,{collapsed:s,hidden:o,x:Math.round(l.x),y:Math.round(l.y),width:Math.round(l.width),height:Math.round(l.height),isFrame:c})),M(e,"bpmn:BoundaryEvent")&&this._attachBoundary(e,i),M(e,"bpmn:Lane")&&(r=0),M(e,"bpmn:DataStoreReference")&&(A2(n,Je(l))||(n=this._canvas.findRoot(n))),this._canvas.addShape(i,n,r)}else if(M(t,"bpmndi:BPMNEdge")){var u=this._getSource(e),p=this._getTarget(e);o=n&&(n.hidden||n.collapsed),i=this._elementFactory.createConnection(Pl(e,t,{hidden:o,source:u,target:p,waypoints:M2(t,u,p)})),M(e,"bpmn:DataAssociation")&&(n=this._canvas.findRoot(n)),this._canvas.addConnection(i,n,r)}else throw new Error(`unknown di ${zn(t)} for element ${zn(e)}`);return Zo(e)&&vi(i)&&this.addLabel(e,t,i),this._eventBus.fire("bpmnElement.added",{element:i}),i},wo.prototype._attachBoundary=function(e,t){var n=e.attachedToRef;if(!n)throw new Error(`missing ${zn(e)}#attachedToRef`);var i=this._elementRegistry.get(n.id),o=i&&i.attachers;if(!i)throw ab(e,n,"attachedToRef");t.host=i,o||(i.attachers=o=[]),o.indexOf(t)===-1&&o.push(t)},wo.prototype.addLabel=function(e,t,n){var i,o,r;return i=VT(t,n),o=vi(n),o&&(i=this._textRenderer.getExternalLabelBounds(i,o)),r=this._elementFactory.createLabel(Pl(e,t,{id:e.id+"_label",labelTarget:n,type:"label",hidden:n.hidden||!vi(n),x:Math.round(i.x),y:Math.round(i.y),width:Math.round(i.width),height:Math.round(i.height)})),this._canvas.addShape(r,n.parent)},wo.prototype._getConnectedElement=function(e,t){var n,i,o=e.$type;if(i=e[t+"Ref"],t==="source"&&o==="bpmn:DataInputAssociation"&&(i=i&&i[0]),(t==="source"&&o==="bpmn:DataOutputAssociation"||t==="target"&&o==="bpmn:DataInputAssociation")&&(i=e.$parent),n=i&&this._getElement(i),n)return n;throw i?ab(e,i,t+"Ref"):new Error(`${zn(e)}#${t} Ref not specified`)},wo.prototype._getSource=function(e){return this._getConnectedElement(e,"source")},wo.prototype._getTarget=function(e){return this._getConnectedElement(e,"target")},wo.prototype._getElement=function(e){return this._elementRegistry.get(e.id)};function A2(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}function P2(e){return M(e,"bpmn:Group")}const sb={__depends__:[R2,{__depends__:[Os],bpmnImporter:["type",wo]}]};function Ds(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Gi(e,t){return{x:e.x-t.x,y:e.y-t.y}}function id(e){return Math.log(e)/Math.log(10)}var T2=1e3;function we(e){this._eventBus=e}we.$inject=["eventBus"];function k2(e,t){return function(n){return e.call(t||null,n.context,n.command,n)}}we.prototype.on=function(e,t,n,i,o,r){if((_n(t)||Qe(t))&&(r=o,o=i,i=n,n=t,t=null),_n(n)&&(r=o,o=i,i=n,n=T2),mn(o)&&(r=o,o=!1),!_n(i))throw new Error("handlerFn must be a function");Ze(e)||(e=[e]);var a=this._eventBus;V(e,function(s){var c=["commandStack",s,t].filter(function(l){return l}).join(".");a.on(c,n,o?k2(i,r):i,r)})},we.prototype.canExecute=_o("canExecute"),we.prototype.preExecute=_o("preExecute"),we.prototype.preExecuted=_o("preExecuted"),we.prototype.execute=_o("execute"),we.prototype.executed=_o("executed"),we.prototype.postExecute=_o("postExecute"),we.prototype.postExecuted=_o("postExecuted"),we.prototype.revert=_o("revert"),we.prototype.reverted=_o("reverted");function _o(e){return function(n,i,o,r,a){(_n(n)||Qe(n))&&(a=r,r=o,o=i,i=n,n=null),this.on(n,e,i,o,r,a)}}var od=["top","bottom","left","right"],Tl=10;function rd(e,t){we.call(this,e),this.postExecuted(["connection.create","connection.layout","connection.updateWaypoints"],function(o){var r=o.context,a=r.connection,s=a.source,c=a.target,l=r.hints||{};l.createElementsBehavior!==!1&&(n(s),n(c))}),this.postExecuted(["label.create"],function(o){var r=o.context,a=r.shape,s=r.hints||{};s.createElementsBehavior!==!1&&n(a.labelTarget)}),this.postExecuted(["elements.create"],function(o){var r=o.context,a=r.elements,s=r.hints||{};s.createElementsBehavior!==!1&&a.forEach(function(c){n(c)})});function n(o){if(Rl(o)&&!Ot(o)){var r=L2(o);r&&i(o,r)}}function i(o,r){var a=Je(o),s=o.label,c=Je(s);if(s.parent){var l=qe(o),u;switch(r){case"top":u={x:a.x,y:l.top-Tl-s.height/2};break;case"left":u={x:l.left-Tl-s.width/2,y:a.y};break;case"bottom":u={x:a.x,y:l.bottom+Tl+s.height/2};break;case"right":u={x:l.right+Tl+s.width/2,y:a.y};break}var p=Gi(u,c);t.moveShape(s,p)}}}Ne(rd,we),rd.$inject=["eventBus","modeling"];function O2(e){var t=e.host,n=Je(e),i=On(n,t),o;i.indexOf("-")>=0?o=i.split("-"):o=[i];var r=od.filter(function(a){return o.indexOf(a)===-1});return r}function D2(e){var t=Je(e),n=[].concat(e.incoming.map(function(i){return i.waypoints[i.waypoints.length-2]}),e.outgoing.map(function(i){return i.waypoints[1]})).map(function(i){return cb(t,i)});return n}function L2(e){var t=Je(e.label),n=Je(e),i=cb(n,t);if(I2(i)){var o=D2(e);if(e.host){var r=O2(e);o=o.concat(r)}var a=od.filter(function(s){return o.indexOf(s)===-1});return a.indexOf(i)!==-1?On(e.label,e)!=="intersect"?void 0:i:a[0]}}function cb(e,t){return On(t,e,5)}function I2(e){return od.indexOf(e)!==-1}function ad(e){we.call(this,e),this.preExecute("shape.append",function(t){var n=t.source,i=t.shape;t.position||(M(i,"bpmn:TextAnnotation")?t.position={x:n.x+n.width/2+75,y:n.y-50-i.height/2}:t.position={x:n.x+n.width+80+i.width/2,y:n.y+n.height/2})},!0)}Ne(ad,we),ad.$inject=["eventBus"];var B2=1500;function sd(e,t,n){e.invoke(we,this),this.preExecute("elements.delete",B2,function(o){var r=o.context,a=r.elements,s=i(a);s.length&&(r.elements=a.concat(s))}),t.on("shape.move.start",function(o){var r=o.context.shapes,a=i(r);a.length&&(o.context.shapes=r.concat(a))});function i(o){var r=ct(o,l=>M(l,"bpmn:Participant")||M(l,"bpmn:SubProcess"));if(!r.length)return[];var a=n.getRootElement(),s=new Set(a.children.filter(l=>M(l,"bpmn:Artifact"))),c=new Set;return V(r,l=>{const u=new Set(aa(xa(Array.from(s),cn(l))));c=c.union(u),s=s.difference(u)}),Array.from(c)}}Ne(sd,we),sd.$inject=["injector","eventBus","canvas"];function cd(e,t){e.invoke(we,this),this.postExecute("shape.move",function(n){var i=n.newParent,o=n.shape,r=ct(o.incoming.concat(o.outgoing),function(a){return M(a,"bpmn:Association")});V(r,function(a){t.moveConnection(a,{x:0,y:0},i)})},!0)}Ne(cd,we),cd.$inject=["injector","modeling"];function Ma(e,t){for(ei(t)&&(t=[t]);e=e.parent;)if(st(e,t))return e;return null}function lb(e,t){var n=Ma(e,"bpmn:Process");if(n)return!0;var i=["bpmn:Participant","bpmn:Lane"];if(n=Ma(e,i),n)return En(n);if(st(e,i))return En(e);var o;for(o=_e(e);o&&!M(o,"bpmn:Process");o=o.$parent);if(!t)return!0;var r=t.find(function(a){var s=_e(a);return s&&s.get("processRef")===o});return r?En(r):!0}var ub=500;function kl(e,t){t.invoke(we,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",ub,function(i){var o=i.elements;o=o.filter(function(r){var a=r.host;return pb(r,a)}),o.length===1&&o.map(function(r){return o.indexOf(r)}).forEach(function(r){var a=o[r];i.elements[r]=n._replaceShape(o[r],a)})},!0),this.preExecute("elements.move",ub,function(i){var o=i.shapes,r=i.newHost;if(o.length===1){var a=o[0];pb(a,r)&&(i.shapes=[n._replaceShape(a,r)])}},!0)}kl.$inject=["bpmnReplace","injector"],Ne(kl,we),kl.prototype._replaceShape=function(e,t){var n=N2(e),i={type:"bpmn:BoundaryEvent",host:t};return n&&(i.eventDefinitionType=n.$type),this._bpmnReplace.replaceElement(e,i,{layoutConnection:!1})};function N2(e){var t=_e(e),n=t.eventDefinitions;return n&&n[0]}function pb(e,t){return!at(e)&&st(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}function ld(e,t){we.call(this,e);function n(i){return ct(i.attachers,function(o){return M(o,"bpmn:BoundaryEvent")})}this.postExecute("connection.create",function(i){var o=i.context.source,r=i.context.target,a=n(r);M(o,"bpmn:EventBasedGateway")&&M(r,"bpmn:ReceiveTask")&&a.length>0&&t.removeElements(a)}),this.postExecute("connection.reconnect",function(i){var o=i.context.oldSource,r=i.context.newSource;M(o,"bpmn:Gateway")&&M(r,"bpmn:EventBasedGateway")&&V(r.outgoing,function(a){var s=a.target,c=n(s);M(s,"bpmn:ReceiveTask")&&c.length>0&&t.removeElements(c)})})}ld.$inject=["eventBus","modeling"],Ne(ld,we);function fb(e){return e.create("bpmn:Category")}function $2(e){return e.create("bpmn:CategoryValue")}function db(e,t){var n=t.get("categoryValueRef");return n||(n=t.categoryValueRef=$2(e)),n.$parent||(n.$parent=fb(e)),n}function F2(e,t,n){return on(t.get("categoryValue"),e),e.$parent=t,on(n.get("rootElements"),t),t.$parent=n,e}function j2(e){var t=e.$parent;return t&&(tn(t.get("categoryValue"),e),e.$parent=null),e}function H2(e){var t=e.$parent;return t&&(tn(t.get("rootElements"),e),e.$parent=null),e}var z2=500;function ud(e,t,n){n.invoke(we,this);function i(c){return t.filter(function(l){return M(l,"bpmn:Group")&&!l.labelTarget}).map(_e).filter(function(l){return l!==c})}function o(c,l){return i(l).some(function(u){return u.get("categoryValueRef")===c})}function r(c,l){return i(l).some(function(u){var p=u.get("categoryValueRef");return p&&p.$parent===c})}function a(c,l){c&&l&&F2(c,l,e.getDefinitions())}function s(c,l,u){l&&!r(l,u)&&H2(l),c&&!o(c,u)&&j2(c)}this.executed(["shape.create","label.create"],function(c){var l=c.labelTarget||c.shape;!M(l,"bpmn:Group")||l.labelTarget||a(c.categoryValue,c.category)},!0),this.reverted(["shape.create","label.create"],function(c){var l=c.labelTarget||c.shape;!M(l,"bpmn:Group")||l.labelTarget||s(c.categoryValue,c.category,_e(l))},!0),this.executed(["shape.move","shape.resize"],z2,function(c){a(c.categoryValue,c.category)},!0),this.reverted(["shape.move","shape.resize"],function(c){var l=c.shape;c.categoryValue&&s(c.categoryValue,c.category,_e(l))},!0),this.executed("group.updateRefs",function(c){hb(c).forEach(function(l){a(l.categoryValue,l.category)})},!0),this.reverted("group.updateRefs",function(c){hb(c).forEach(function(l){s(l.categoryValue,l.category,_e(l.groupShape))})},!0),this.executed("shape.delete",function(c){var l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||s(c.categoryValue,c.category,_e(l))},!0),this.reverted("shape.delete",function(c){var l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||a(c.categoryValue,c.category)},!0)}ud.$inject=["bpmnjs","elementRegistry","injector"],Ne(ud,we);function hb(e){var t;return((t=e.updates)==null?void 0:t.groups)||[]}function pd(e,t,n){we.call(this,e),this.preExecute("shape.replace",s,!0),this.postExecuted("shape.replace",c,!0),this.preExecute("connection.create",o,!0),this.postExecuted("connection.delete",i,!0),this.postExecuted("connection.reconnect",r,!0),this.postExecuted("element.updateProperties",a,!0);function i(m){const w=m.source,y=m.target;Aa(w)&&Ls(y)&&u(y)}function o(m){const w=m.connection,y=m.source,v=m.target;Aa(y)&&Ol(v)&&(l(v),f(y,[w]))}function r(m){const w=m.newTarget,y=m.oldSource,v=m.oldTarget;if(v!==w){const x=y;Ls(v)&&u(v),Aa(x)&&Ol(w)&&l(w)}}function a(m){const{element:w}=m;Ls(w)?(p(w),d(w)):Ol(w)&&g(w)}function s(m){const{newData:w,oldShape:y}=m;if(Aa(m.oldShape)&&w.eventDefinitionType!=="bpmn:CompensateEventDefinition"||w.type!=="bpmn:BoundaryEvent"){const v=y.outgoing.find(({target:x})=>Ls(x));v&&v.target&&(m._connectionTarget=v.target)}else if(!Aa(m.oldShape)&&w.eventDefinitionType==="bpmn:CompensateEventDefinition"&&w.type==="bpmn:BoundaryEvent"){const v=y.outgoing.find(({target:x})=>Ol(x));v&&v.target&&(m._connectionTarget=v.target),h(y)}}function c(m){const{_connectionTarget:w,newShape:y}=m;w&&t.connect(y,w)}function l(m){t.updateProperties(m,{isForCompensation:!0})}function u(m){t.updateProperties(m,{isForCompensation:void 0})}function p(m){for(const w of m.incoming)n.canConnect(w.source,m)||t.removeConnection(w);for(const w of m.outgoing)n.canConnect(m,w.target)||t.removeConnection(w)}function f(m,w){m.outgoing.filter(x=>M(x,"bpmn:Association")).filter(x=>Ls(x.target)&&!w.includes(x)).forEach(x=>t.removeConnection(x))}function d(m){const w=m.attachers.slice();w.length&&t.removeElements(w)}function g(m){const w=m.incoming.filter(y=>Aa(y.source));t.removeElements(w)}function h(m){const w=m.outgoing.filter(y=>M(y,"bpmn:SequenceFlow"));t.removeElements(w)}}Ne(pd,we),pd.$inject=["eventBus","modeling","bpmnRules"];function Ls(e){const t=_e(e);return t&&t.get("isForCompensation")}function Aa(e){return e&&M(e,"bpmn:BoundaryEvent")&&Sa(e,"bpmn:CompensateEventDefinition")}function Ol(e){return e&&M(e,"bpmn:Activity")&&!Gn(e)}function fd(e){e.invoke(we,this),this.preExecute("shape.create",1500,function(t){var n=t.context,i=n.parent,o=n.shape;M(i,"bpmn:Lane")&&!M(o,"bpmn:Lane")&&(n.parent=Ma(i,"bpmn:Participant"))})}fd.$inject=["injector"],Ne(fd,we);function dd(e,t){we.call(this,e),this.preExecute("shape.create",function(n){var a;var i=n.context,o=i.shape;if(M(o,"bpmn:DataObjectReference")&&o.type!=="label"){var r=t.create("bpmn:DataObject");r.isCollection=((a=o.businessObject.dataObjectRef)==null?void 0:a.isCollection)||!1,o.businessObject.dataObjectRef=r}})}dd.$inject=["eventBus","bpmnFactory"],Ne(dd,we);var hd=20,gd=20,gb=30,Dl=2e3;function md(e,t,n){we.call(this,t),t.on(["create.start","shape.move.start"],Dl,function(o){var r=o.context,a=r.shape,s=e.getRootElement();if(!(!M(a,"bpmn:Participant")||!M(s,"bpmn:Process")||!s.children.length)){var c=s.children.filter(function(p){return!M(p,"bpmn:Group")&&!at(p)&&!Ot(p)});if(c.length){var l=cn(c),u=G2(a,l);Y(a,u),r.createConstraints=V2(a,l)}}}),t.on("create.start",Dl,function(o){var r=o.context,a=r.shape,s=e.getRootElement(),c=e.getGraphics(s);function l(u){u.element=s,u.gfx=c}M(a,"bpmn:Participant")&&M(s,"bpmn:Process")&&(t.on("element.hover",Dl,l),t.once("create.cleanup",function(){t.off("element.hover",l)}))});function i(){var o=e.getRootElement();return M(o,"bpmn:Collaboration")?o:n.makeCollaboration()}this.preExecute("elements.create",Dl,function(o){var r=o.elements,a=o.parent,s=W2(r),c;s&&M(a,"bpmn:Process")&&(o.parent=i(),c=o.hints=o.hints||{},c.participant=s,c.process=a,c.processRef=_e(s).get("processRef"))},!0),this.preExecute("shape.create",function(o){var r=o.parent,a=o.shape;M(a,"bpmn:Participant")&&M(r,"bpmn:Process")&&(o.parent=i(),o.process=r,o.processRef=_e(a).get("processRef"))},!0),this.execute("shape.create",function(o){var r=o.hints||{},a=o.process||r.process,s=o.shape,c=r.participant;a&&(!c||s===c)&&_e(s).set("processRef",_e(a))},!0),this.revert("shape.create",function(o){var r=o.hints||{},a=o.process||r.process,s=o.processRef||r.processRef,c=o.shape,l=r.participant;a&&(!l||c===l)&&_e(c).set("processRef",s)},!0),this.postExecute("shape.create",function(o){var r=o.hints||{},a=o.process||o.hints.process,s=o.shape,c=r.participant;if(a){var l=a.children.slice();c?s===c&&n.moveElements(l,{x:0,y:0},c):n.moveElements(l,{x:0,y:0},s)}},!0)}md.$inject=["canvas","eventBus","modeling"],Ne(md,we);function G2(e,t){t={width:t.width+hd*2+gb,height:t.height+gd*2};var n=Math.max(e.width,t.width),i=Math.max(e.height,t.height);return{x:-n/2,y:-i/2,width:n,height:i}}function V2(e,t){return t=qe(t),{bottom:t.top+e.height/2-gd,left:t.right-e.width/2+hd,top:t.bottom-e.height/2+gd,right:t.left+e.width/2-hd-gb}}function W2(e){return It(e,function(t){return M(t,"bpmn:Participant")})}var mb="__targetRef_placeholder";function yd(e,t){we.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],yb(r)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],yb(r));function n(a,s,c){var l=a.get("dataInputAssociations");return It(l,function(u){return u!==c&&u.targetRef===s})}function i(a,s){var c=a.get("properties"),l=It(c,function(u){return u.name===mb});return!l&&s&&(l=t.create("bpmn:Property",{name:mb}),on(c,l)),l}function o(a,s){var c=i(a);c&&(n(a,c,s)||tn(a.get("properties"),c))}function r(a){var s=a.context,c=s.connection,l=c.businessObject,u=c.target,p=u&&u.businessObject,f=s.newTarget,d=f&&f.businessObject,g=s.oldTarget||s.target,h=g&&g.businessObject,m=c.businessObject,w;h&&h!==p&&o(h,l),d&&d!==p&&o(d,l),p?(w=i(p,!0),m.targetRef=w):m.targetRef=null}}yd.$inject=["eventBus","bpmnFactory"],Ne(yd,we);function yb(e){return function(t){var n=t.context,i=n.connection;if(M(i,"bpmn:DataInputAssociation"))return e(t)}}function Ll(e){this._bpmnUpdater=e}Ll.$inject=["bpmnUpdater"],Ll.prototype.execute=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.newSemanticParent,o=e.newDiParent;return e.oldSemanticParent=t.$parent,e.oldDiParent=n.$parent,this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,o),[]},Ll.prototype.revert=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,i=e.oldSemanticParent,o=e.oldDiParent;return this._bpmnUpdater.updateSemanticParent(t,i),this._bpmnUpdater.updateDiParent(n,o),[]};function vd(e,t,n,i){we.call(this,i),t.registerHandler("dataStore.updateContainment",Ll);function o(){return n.filter(function(s){return M(s,"bpmn:Participant")&&_e(s).processRef})[0]}function r(s){return s.children.filter(function(c){return M(c,"bpmn:DataStoreReference")&&!c.labelTarget})}function a(s,c){var l=s.businessObject||s;if(c=c||o(),c){var u=c.businessObject||c;t.execute("dataStore.updateContainment",{dataStoreBo:l,dataStoreDi:mt(s),newSemanticParent:u.processRef||u,newDiParent:mt(c)})}}this.preExecute("shape.create",function(s){var c=s.context,l=c.shape;M(l,"bpmn:DataStoreReference")&&l.type!=="label"&&(c.hints||(c.hints={}),c.hints.autoResize=!1)}),this.preExecute("elements.move",function(s){var c=s.context,l=c.shapes,u=l.filter(function(p){return M(p,"bpmn:DataStoreReference")});u.length&&(c.hints||(c.hints={}),c.hints.autoResize=l.filter(function(p){return!M(p,"bpmn:DataStoreReference")}))}),this.postExecute("shape.create",function(s){var c=s.context,l=c.shape,u=l.parent;M(l,"bpmn:DataStoreReference")&&l.type!=="label"&&M(u,"bpmn:Collaboration")&&a(l)}),this.postExecute("shape.move",function(s){var c=s.context,l=c.shape,u=c.oldParent,p=l.parent;if(!M(u,"bpmn:Collaboration")&&M(l,"bpmn:DataStoreReference")&&l.type!=="label"&&M(p,"bpmn:Collaboration")){var f=M(u,"bpmn:Participant")?u:q2(u,"bpmn:Participant");a(l,f)}}),this.postExecute("shape.delete",function(s){var c=s.context,l=c.shape,u=e.getRootElement();st(l,["bpmn:Participant","bpmn:SubProcess"])&&M(u,"bpmn:Collaboration")&&r(u).filter(function(p){return U2(p,l)}).forEach(function(p){a(p)})}),this.postExecute("canvas.updateRoot",function(s){var c=s.context,l=c.oldRoot,u=c.newRoot,p=r(l);p.forEach(function(f){M(u,"bpmn:Process")&&a(f,u)})})}vd.$inject=["canvas","commandStack","elementRegistry","eventBus"],Ne(vd,we);function U2(e,t){for(var n=e.businessObject||e,i=t.businessObject||t;n.$parent;){if(n.$parent===i.processRef||i)return!0;n=n.$parent}return!1}function q2(e,t){for(;e.parent;){if(M(e.parent,t))return e.parent;e=e.parent}}var Il=Math.max,Bl=Math.min,Y2=20;function vb(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function K2(e,t,n){var i=n.x,o=n.y,r={x:e.x,y:e.y,width:e.width,height:e.height};return t.indexOf("n")!==-1?(r.y=e.y+o,r.height=e.height-o):t.indexOf("s")!==-1&&(r.height=e.height+o),t.indexOf("e")!==-1?r.width=e.width+i:t.indexOf("w")!==-1&&(r.x=e.x+i,r.width=e.width-i),r}function X2(e,t){return{x:e.x+(t.left||0),y:e.y+(t.top||0),width:e.width-(t.left||0)+(t.right||0),height:e.height-(t.top||0)+(t.bottom||0)}}function Nl(e,t,n){var i=t[e],o=n.min&&n.min[e],r=n.max&&n.max[e];return Qe(o)&&(i=(/top|left/.test(e)?Bl:Il)(i,o)),Qe(r)&&(i=(/top|left/.test(e)?Il:Bl)(i,r)),i}function Z2(e,t){if(!t)return e;var n=qe(e);return bl({top:Nl("top",n,t),right:Nl("right",n,t),bottom:Nl("bottom",n,t),left:Nl("left",n,t)})}function Q2(e,t,n,i){var o=qe(t),r={top:/n/.test(e)?o.bottom-n.height:o.top,left:/w/.test(e)?o.right-n.width:o.left,bottom:/s/.test(e)?o.top+n.height:o.bottom,right:/e/.test(e)?o.left+n.width:o.right},a=i?qe(i):r,s={top:Bl(r.top,a.top),left:Bl(r.left,a.left),bottom:Il(r.bottom,a.bottom),right:Il(r.right,a.right)};return bl(s)}function Is(e,t){return typeof e<"u"?e:Y2}function J2(e,t){var n,i,o,r;return typeof t=="object"?(n=Is(t.left),i=Is(t.right),o=Is(t.top),r=Is(t.bottom)):n=i=o=r=Is(t),{x:e.x-n,y:e.y-o,width:e.width+n+i,height:e.height+o+r}}function ek(e){return!(e.waypoints||e.type==="label")}function bb(e,t){var n;if(e.length===void 0?n=ct(e.children,ek):n=e,n.length)return J2(cn(n),t)}var Qo=Math.abs;function tk(e,t){return vb(qe(t),qe(e))}var nk=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],Si=30;function $l(e,t){return t=t||[],e.children.filter(function(n){M(n,"bpmn:Lane")&&($l(n,t),t.push(n))}),t}function Jo(e){return e.children.filter(function(t){return M(t,"bpmn:Lane")})}function Ri(e){return Ma(e,nk)||e}function ik(e,t){var n=Ri(e),i=M(n,"bpmn:Process")?[]:[n],o=$l(n,i),r=qe(e),a=qe(t),s=tk(e,t),c=[],l=En(e);return o.forEach(function(u){if(u!==e){var p=l?0:s.top,f=l?s.right:0,d=l?0:s.bottom,g=l?s.left:0,h=qe(u);s.top&&(Qo(h.bottom-r.top)<10&&(d=a.top-h.bottom),Qo(h.top-r.top)<5&&(p=a.top-h.top)),s.left&&(Qo(h.right-r.left)<10&&(f=a.left-h.right),Qo(h.left-r.left)<5&&(g=a.left-h.left)),s.bottom&&(Qo(h.top-r.bottom)<10&&(p=a.bottom-h.top),Qo(h.bottom-r.bottom)<5&&(d=a.bottom-h.bottom)),s.right&&(Qo(h.left-r.right)<10&&(g=a.right-h.left),Qo(h.right-r.right)<5&&(f=a.right-h.right)),(p||f||d||g)&&c.push({shape:u,newBounds:X2(u,{top:p,right:f,bottom:d,left:g})})}}),c}var ok=500;function bd(e,t){we.call(this,e);function n(i,o){var r=En(i),a=Jo(o),s=[],c=[],l=[],u=[];if(Br(a,function(m){return r?m.y>i.y?c.push(m):s.push(m):m.x>i.x?u.push(m):l.push(m),m.children}),!!a.length){var p;r?c.length&&s.length?p=i.height/2:p=i.height:u.length&&l.length?p=i.width/2:p=i.width;var f,d,g,h;s.length&&(f=t.calculateAdjustments(s,"y",p,i.y-10),t.makeSpace(f.movingShapes,f.resizingShapes,{x:0,y:p},"s")),c.length&&(d=t.calculateAdjustments(c,"y",-p,i.y+i.height+10),t.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:-p},"n")),l.length&&(g=t.calculateAdjustments(l,"x",p,i.x-10),t.makeSpace(g.movingShapes,g.resizingShapes,{x:p,y:0},"e")),u.length&&(h=t.calculateAdjustments(u,"x",-p,i.x+i.width+10),t.makeSpace(h.movingShapes,h.resizingShapes,{x:-p,y:0},"w"))}}this.postExecuted("shape.delete",ok,function(i){var o=i.context,r=o.hints,a=o.shape,s=o.oldParent;M(a,"bpmn:Lane")&&(r&&r.nested||n(a,s))})}bd.$inject=["eventBus","spaceTool"],Ne(bd,we);var xb=500;function Fl(e,t){t.invoke(we,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",xb,function(i){var o=i.elements;o.filter(function(r){var a=r.host;return wb(r,a)}).map(function(r){return o.indexOf(r)}).forEach(function(r){i.elements[r]=n._replaceShape(o[r])})},!0),this.preExecute("elements.move",xb,function(i){var o=i.shapes,r=i.newHost;o.forEach(function(a,s){var c=a.host;wb(a,ak(o,c)?c:r)&&(o[s]=n._replaceShape(a))})},!0)}Fl.$inject=["bpmnReplace","injector"],Ne(Fl,we),Fl.prototype._replaceShape=function(e){var t=rk(e),n;return t?n={type:"bpmn:IntermediateCatchEvent",eventDefinitionType:t.$type}:n={type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,n,{layoutConnection:!1})};function rk(e){var t=_e(e),n=t.eventDefinitions;return n&&n[0]}function wb(e,t){return!at(e)&&M(e,"bpmn:BoundaryEvent")&&!t}function ak(e,t){return e.indexOf(t)!==-1}var jl=Math.round,sk=Math.max;function ck(e,t){var n=e.x,i=e.y;return[["M",n,i],["m",0,-t],["a",t,t,0,1,1,0,2*t],["a",t,t,0,1,1,0,-2*t],["z"]]}function lk(e){var t=[];return e.forEach(function(n,i){t.push([i===0?"M":"L",n.x,n.y])}),t}var _b=10;function uk(e,t){var n,i;for(n=0;i=e[n];n++)if(Rs(i,t)<=_b)return{point:e[n],bendpoint:!0,index:n};return null}function pk(e,t){var n=Mv(ck(t,_b),lk(e)),i=n[0],o=n[n.length-1],r;return i?i!==o?i.segment2!==o.segment2?(r=sk(i.segment2,o.segment2)-1,{point:e[r],bendpoint:!0,index:r}):{point:{x:jl(i.x+o.x)/2,y:jl(i.y+o.y)/2},index:i.segment2}:{point:{x:jl(i.x),y:jl(i.y)},index:i.segment2}:null}function xd(e,t){return uk(e,t)||pk(e,t)}function wd(e,t,n){we.call(this,e);function i(o,r,a){var s=r.waypoints,c,l,u,p,f,d,g,h=o.outgoing.slice(),m=o.incoming.slice(),w;Qe(a.width)?w=Je(a):w=a;var y=xd(s,w);if(y){if(c=s.slice(0,y.index),l=s.slice(y.index+(y.bendpoint?1:0)),!c.length||!l.length)return;u=y.bendpoint?s[y.index]:w,(c.length===1||!Eb(o,c[c.length-1]))&&c.push(Sb(u)),(l.length===1||!Eb(o,l[0]))&&l.unshift(Sb(u))}p=r.source,f=r.target,t.canConnect(p,o,r)&&(n.reconnectEnd(r,o,c||w),d=r),t.canConnect(o,f,r)&&(d?g=n.connect(o,f,{type:r.type,waypoints:l}):(n.reconnectStart(r,o,l||w),g=r));var v=[].concat(d&&ct(m,function(x){return x.source===d.source})||[],g&&ct(h,function(x){return x.target===g.target})||[]);v.length&&n.removeElements(v)}this.preExecute("elements.move",function(o){var r=o.newParent,a=o.shapes,s=o.delta,c=a[0];if(!(!c||!r)){r&&r.waypoints&&(o.newParent=r=r.parent);var l=Je(c),u={x:l.x+s.x,y:l.y+s.y},p=It(r.children,function(f){var d=t.canInsert(a,f);return d&&xd(f.waypoints,u)});p&&(o.targetFlow=p,o.position=u)}},!0),this.postExecuted("elements.move",function(o){var r=o.shapes,a=o.targetFlow,s=o.position;a&&i(r[0],a,s)},!0),this.preExecute("shape.create",function(o){var r=o.parent,a=o.shape;t.canInsert(a,r)&&(o.targetFlow=r,o.parent=r.parent)},!0),this.postExecuted("shape.create",function(o){var r=o.shape,a=o.targetFlow,s=o.position;a&&i(r,a,s)},!0)}Ne(wd,we),wd.$inject=["eventBus","bpmnRules","modeling"];function Eb(e,t){var n=t.x,i=t.y;return n>=e.x&&n<=e.x+e.width&&i>=e.y&&i<=e.y+e.height}function Sb(e){return Y({},e)}function _d(e,t){we.call(this,e),this.preExecuted("connection.create",function(n){var i=n.context,o=i.connection,r=i.source,a=i.target,s=i.hints;if(!(s&&s.createElementsBehavior===!1)&&Pa(o)){var c=[];M(r,"bpmn:EventBasedGateway")?c=a.incoming.filter(l=>l!==o&&Pa(l)):c=a.incoming.filter(l=>l!==o&&Pa(l)&&M(l.source,"bpmn:EventBasedGateway")),c.forEach(function(l){t.removeConnection(l)})}}),this.preExecuted("shape.replace",function(n){var i=n.context,o=i.newShape;if(M(o,"bpmn:EventBasedGateway")){var r=o.outgoing.filter(Pa).reduce(function(a,s){return a.includes(s.target)?a:a.concat(s.target)},[]);r.forEach(function(a){a.incoming.filter(Pa).forEach(function(s){const c=a.incoming.filter(Pa).filter(function(l){return l.source===o});(s.source!==o||c.length>1)&&t.removeConnection(s)})})}})}_d.$inject=["eventBus","modeling"],Ne(_d,we);function Pa(e){return M(e,"bpmn:SequenceFlow")}var Hl=1500,Rb=2e3;function Cb(e,t,n){t.on(["create.hover","create.move","create.out","create.end","shape.move.hover","shape.move.move","shape.move.out","shape.move.end"],Hl,function(i){var o=i.context,r=o.shape||i.shape,a=i.hover;M(a,"bpmn:Lane")&&!st(r,["bpmn:Lane","bpmn:Participant"])&&(i.hover=Ri(a),i.hoverGfx=e.getGraphics(i.hover));var s=n.getRootElement();a&&a!==s&&(r.labelTarget||st(r,["bpmn:Group","bpmn:TextAnnotation"]))&&(i.hover=s,i.hoverGfx=e.getGraphics(i.hover))}),t.on(["connect.hover","connect.out","connect.end","connect.cleanup","global-connect.hover","global-connect.out","global-connect.end","global-connect.cleanup"],Hl,function(i){var o=i.hover;M(o,"bpmn:Lane")&&(i.hover=Ri(o)||o,i.hoverGfx=e.getGraphics(i.hover))}),t.on(["bendpoint.move.hover"],Hl,function(i){var o=i.context,r=i.hover,a=o.type;M(r,"bpmn:Lane")&&/reconnect/.test(a)&&(i.hover=Ri(r)||r,i.hoverGfx=e.getGraphics(i.hover))}),t.on(["connect.start"],Hl,function(i){var o=i.context,r=o.start;M(r,"bpmn:Lane")&&(o.start=Ri(r)||r)}),t.on("shape.move.start",Rb,function(i){var o=i.shape;M(o,"bpmn:Lane")&&(i.shape=Ri(o)||o)}),t.on("spaceTool.move",Rb,function(i){var o=i.hover;o&&M(o,"bpmn:Lane")&&(i.hover=Ri(o))})}Cb.$inject=["elementRegistry","eventBus","canvas"];var Mb=770;function Ed(e,t,n,i){n.invoke(we,this);function o(s,c){var l=_e(s),u=c.categoryValue||l.categoryValueRef;u||(u=db(e,l));var p=c.category||u.$parent||fb(e);l.categoryValueRef=u,u.$parent=p,c.categoryValue=u,c.category=p}function r(s,c){var l=_e(s),u=c.categoryValue||l.categoryValueRef,p=c.category||u&&u.$parent;u&&(c.categoryValue=u,c.category=p,l.categoryValueRef=null)}this.execute("label.create",function(s){var c=s.context,l=c.labelTarget;M(l,"bpmn:Group")&&o(l,c)}),this.revert("label.create",function(s){var c=s.context,l=c.labelTarget;M(l,"bpmn:Group")&&r(l,c)}),this.execute("shape.delete",function(s){var c=s.context,l=c.shape,u=_e(l);if(!(!M(l,"bpmn:Group")||l.labelTarget)){var p=c.categoryValue=u.categoryValueRef;p&&(c.category=p.$parent,u.categoryValueRef=null)}}),this.reverted("shape.delete",function(s){var c=s.context,l=c.shape;if(!(!M(l,"bpmn:Group")||l.labelTarget)){var u=c.category,p=c.categoryValue,f=_e(l);p&&(f.categoryValueRef=p,p.$parent=u)}}),this.execute("shape.create",function(s){var c=s.context,l=c.shape,u=c.hints||{};!M(l,"bpmn:Group")||l.labelTarget||u.createElementsBehavior===!1&&!_e(l).categoryValueRef&&!c.categoryValue||o(l,c)}),this.reverted("shape.create",function(s){var c=s.context,l=c.shape,u=c.hints||{};!M(l,"bpmn:Group")||l.labelTarget||u.createElementsBehavior===!1&&!_e(l).categoryValueRef&&!c.categoryValue||r(l,c)}),this.executed(["shape.move","shape.resize"],function(s){var c=s.context,l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||_e(l).categoryValueRef||o(l,c)}),this.reverted(["shape.move","shape.resize"],function(s){var c=s.context,l=c.shape;!M(l,"bpmn:Group")||l.labelTarget||!c.categoryValue||r(l,c)});function a(s,c){var l=e.create(s.$type);return i.copyElement(s,l,null,c)}t.on("copyPaste.copyElement",Mb,function(s){var c=s.descriptor,l=s.element;if(!(!M(l,"bpmn:Group")||l.labelTarget)){var u=_e(l);if(u.categoryValueRef){var p=u.categoryValueRef;c.categoryValue=a(p,!0),p.$parent&&(c.category=a(p.$parent,!0))}}}),t.on("copyPaste.pasteElement",Mb,function(s){var c=s.descriptor,l=c.businessObject,u=c.categoryValue,p=c.category;u&&(u=l.categoryValueRef=a(u)),p&&(u.$parent=a(p)),delete c.category,delete c.categoryValue})}Ed.$inject=["bpmnFactory","eventBus","injector","moddleCopy"],Ne(Ed,we);function Sd(e,t,n,i){var o,r,a,s,c;return o=(i.y-n.y)*(t.x-e.x)-(i.x-n.x)*(t.y-e.y),o==0?null:(r=e.y-n.y,a=e.x-n.x,c=(i.x-n.x)*r-(i.y-n.y)*a,s=c/o,{x:Math.round(e.x+s*(t.x-e.x)),y:Math.round(e.y+s*(t.y-e.y))})}function Ab(e){function t(i,o,r){var a={x:r.x,y:r.y-50},s={x:r.x-50,y:r.y},c=Sd(i,o,r,a),l=Sd(i,o,r,s),u;c&&l?Pb(c,r)>Pb(l,r)?u=l:u=c:u=c||l,i.original=u}function n(i){var o=i.waypoints;t(o[0],o[1],Je(i.source)),t(o[o.length-1],o[o.length-2],Je(i.target))}e.on("bpmnElement.added",function(i){var o=i.element;o.waypoints&&n(o)})}Ab.$inject=["eventBus"];function Pb(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Rd(e){we.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],function(n){var i=n.context.shape,o=_e(i),r=mt(i);if(st(o,t)){var a=r.get("isHorizontal");a===void 0&&(a=!0),r.set("isHorizontal",a)}})}Rd.$inject=["eventBus"],Ne(Rd,we);function Tb(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function kb(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function fk(e,t){return t?{x:Math.cos(t)*e.x-Math.sin(t)*e.y,y:Math.sin(t)*e.x+Math.cos(t)*e.y}:e}function dk(e,t,n){var i=[{n:e[0]-n[0],lambda:t[0]},{n:e[1]-n[1],lambda:t[1]}],o=i[0].n*t[0]+i[1].n*t[1],r=i[0].lambda*t[0]+i[1].lambda*t[1];return-o/r}function Cd(e,t){var n=t[0],i=t[1],o={x:i.x-n.x,y:i.y-n.y},r=dk([n.x,n.y],[o.x,o.y],[e.x,e.y]);return{x:n.x+r*o.x,y:n.y+r*o.y}}function Ob(e,t){var n=Cd(e,t),i={x:n.x-e.x,y:n.y-e.y};return Tb(i)}function Bs(e,t){return Tb({x:e.x-t.x,y:e.y-t.y})}var Db=Math.sqrt,Lb=Math.min,hk=Math.max,Ib=Math.abs;function Bb(e){return Math.pow(e,2)}function Ns(e,t){return Db(Bb(e.x-t.x)+Bb(e.y-t.y))}function gk(e,t){var n=0,i,o,r,a,s,c,l,u,p,f,d;for(n=0;n<t.length-1;n++){if(i=t[n],o=t[n+1],$b(i,o)?l=[i]:(r=Ns(e,i),a=Ns(e,o),c=Lb(r,a),l=mk(i,o,e,c)),l.length<1)throw new Error("expected between [1, 2] circle -> line intersections");l.length===1&&(u={type:"bendpoint",position:l[0],segmentIndex:n,bendpointIndex:$b(i,l[0])?n:n+1}),l.length===2&&(s=vk(l[0],l[1]),u={type:"segment",position:s,segmentIndex:n,relativeLocation:Ns(i,s)/Ns(i,o)}),p=Ns(u.position,e),(!d||f>p)&&(d=u,f=p)}return d}function mk(e,t,n,i){var o=t.x-e.x,r=t.y-e.y,a=n.x-e.x,s=n.y-e.y,c=o*o+r*r,l=o*a+r*s,u=a*a+s*s-i*i,p=l/c,f=u/c,d=p*p-f;if(d<0&&d>-1e-6&&(d=0),d<0)return[];var g=Db(d),h=-p+g,m=-p-g,w={x:e.x-o*h,y:e.y-r*h};if(d===0)return[w];var y={x:e.x-o*m,y:e.y-r*m};return[w,y].filter(function(v){return yk(v,e,t)})}function yk(e,t,n){return Nb(e.x,t.x,n.x)&&Nb(e.y,t.y,n.y)}function Nb(e,t,n){return e>=Lb(t,n)-zl&&e<=hk(t,n)+zl}function vk(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}var zl=.1;function $b(e,t){return Ib(e.x-t.x)<=zl&&Ib(e.y-t.y)<=zl}function bk(e,t,n,i){var o=n.segmentIndex,r=t.length-e.length;if(i.segmentMove){var a=i.segmentMove.segmentStartIndex,s=i.segmentMove.newSegmentStartIndex;return o===a?s:o>=s?o+r<s?s:o+r:o}if(i.bendpointMove){var c=i.bendpointMove.insert,l=i.bendpointMove.bendpointIndex,u;if(r===0)return o;if(o>=l&&(u=c?o+1:o-1),o<l&&(u=o,c&&n.type!=="bendpoint"&&l-1===o)){var p=jb(t,l);p<n.relativeLocation&&u++}return u}return r===0?o:i.connectionStart&&o===0?0:i.connectionEnd&&o===e.length-2?t.length-2:Math.floor((t.length-2)/2)}function Fb(e,t,n,i){var o=0,r=0,a={point:e,delta:{x:0,y:0}},s=gk(e,n),c=s.segmentIndex,l=bk(n,t,s,i);if(l<0||l>t.length-2||l===null)return a;var u=Hb(n,c),p=Hb(t,l),f=s.position,d=wk(u,f),g=xk(u,p);if(s.type==="bendpoint"){var h=t.length-n.length,m=s.bendpointIndex,w=n[m];if(t.indexOf(w)!==-1)return a;if(h===0){var y=t[m];return o=y.x-s.position.x,r=y.y-s.position.y,{delta:{x:o,y:r},point:{x:e.x+o,y:e.y+r}}}h<0&&m!==0&&m<n.length-1&&(d=jb(n,m))}var v={x:(p[1].x-p[0].x)*d+p[0].x,y:(p[1].y-p[0].y)*d+p[0].y},x=fk({x:e.x-f.x,y:e.y-f.y},g);return o=v.x+x.x-e.x,r=v.y+x.y-e.y,{point:bo(v),delta:bo({x:o,y:r})}}function jb(e,t){var n=Bs(e[t-1],e[t]),i=Bs(e[t],e[t+1]),o=n/(n+i);return o}function xk(e,t){var n=kb(e),i=kb(t);return i-n}function Hb(e,t){return[e[t],e[t+1]]}function wk(e,t){var n=Bs(e[0],e[1]),i=Bs(e[0],t);return n===0?0:i/n}function _k(e,t,n,i){var o=Je(e);return Fb(o,t,n,i).delta}function $s(e,t,n){var i=Ds(t),o=Ds(n),r=Gi(e,i),a={x:r.x*(n.width/t.width),y:r.y*(n.height/t.height)};return bo({x:o.x+a.x,y:o.y+a.y})}function zb(e,t,n){var i=Ds(e),o=Ds(t),r=Ds(n),a=Gi(e,i),s=Gi(i,o),c=Ek(i,t,n);if(c)return c;var l={x:s.x*(n.width/t.width),y:s.y*(n.height/t.height)},u={x:r.x+l.x,y:r.y+l.y};return bo({x:u.x+a.x-e.x,y:u.y+a.y-e.y})}function Ek(e,t,n){var i=qe(t),o=qe(n);if(Sk(i,o))return null;var r=On(t,e),a,s,c;if(r==="top")a={x:0,y:o.bottom-i.bottom};else if(r==="bottom")a={x:0,y:o.top-i.top};else if(r==="right")a={x:o.left-i.left,y:0};else if(r==="left")a={x:o.right-i.right,y:0};else return null;return s={x:e.x+a.x,y:e.y+a.y},c=On(n,s),c!==r?null:a}function Sk(e,t){return Rk(e,t)||Ck(e,t)}function Rk(e,t){return e.right!==t.right&&e.left!==t.left}function Ck(e,t){return e.top!==t.top&&e.bottom!==t.bottom}var Gb="name",Vb="text";function Md(e,t,n,i){we.call(this,e),this.postExecute("element.updateProperties",o),this.postExecute("element.updateModdleProperties",a=>{_e(a.context.element)===a.context.moddleElement&&o(a)});function o(a){var s=a.context,c=s.element,l=s.properties;if(Gb in l&&t.updateLabel(c,l[Gb]),Vb in l&&M(c,"bpmn:TextAnnotation")){var u=i.getTextAnnotationBounds({x:c.x,y:c.y,width:c.width,height:c.height},l[Vb]||"");t.updateLabel(c,l.text,u)}}this.postExecute(["shape.create","connection.create"],function(a){var s=a.context,c=s.hints||{};if(c.createElementsBehavior!==!1){var l=s.shape||s.connection;at(l)||!Zo(l)||vi(l)&&t.updateLabel(l,vi(l))}}),this.postExecute("shape.delete",function(a){var s=a.context,c=s.labelTarget,l=s.hints||{};c&&l.unsetLabel!==!1&&t.updateLabel(c,null,null,{removeShape:!1})});function r(a){var s=a.context,c=s.connection,l=c.label,u=Y({},s.hints),p=s.newWaypoints||c.waypoints,f=s.oldWaypoints;return typeof u.startChanged>"u"&&(u.startChanged=!!u.connectionStart),typeof u.endChanged>"u"&&(u.endChanged=!!u.connectionEnd),_k(l,p,f,u)}this.postExecute(["connection.layout","connection.updateWaypoints"],function(a){var s=a.context,c=s.hints||{};if(c.labelBehavior!==!1){var l=s.connection,u=l.label,p;!u||!u.parent||(p=r(a),t.moveShape(u,p))}}),this.postExecute(["shape.replace"],function(a){var s=a.context,c=s.newShape,l=s.oldShape,u=_e(c);u&&Zo(u)&&l.label&&c.label&&(c.label.x=l.label.x,c.label.y=l.label.y)}),this.preExecute("shape.resize",function(a){var s=a.context,c=s.shape,l=s.hints||{};if(!(!at(c)||l.autoResize)){var u=s.newBounds,p=i.getDimensions(vi(c)||"",{box:u,style:i.getExternalStyle()}),f=Math.ceil(p.height),d=u.y!==c.y,g=c.y+c.height;s.newBounds={width:u.width,height:f,x:u.x,y:d?g-f:u.y}}}),this.postExecute("shape.resize",function(a){var s=a.context,c=s.shape,l=s.newBounds,u=s.oldBounds;if(Rl(c)){var p=c.label,f=Je(p),d=Pk(u),g=Ak(f,d),h=Mk(g,u,l);t.moveShape(p,h)}})}Ne(Md,we),Md.$inject=["eventBus","modeling","bpmnFactory","textRenderer"];function Mk(e,t,n){var i=$s(e,t,n);return bo(Gi(i,e))}function Ak(e,t){if(t.length){var n=Tk(e,t);return Cd(e,n)}}function Pk(e){return[[{x:e.x,y:e.y},{x:e.x+(e.width||0),y:e.y}],[{x:e.x+(e.width||0),y:e.y},{x:e.x+(e.width||0),y:e.y+(e.height||0)}],[{x:e.x,y:e.y+(e.height||0)},{x:e.x+(e.width||0),y:e.y+(e.height||0)}],[{x:e.x,y:e.y},{x:e.x,y:e.y+(e.height||0)}]]}function Tk(e,t){var n=t.map(function(o){return{line:o,distance:Ob(e,o)}}),i=qi(n,"distance");return i[0].line}function kk(e,t,n,i){return Fb(e,t,n,i).point}function Ad(e,t){we.call(this,e);function n(i,o){var r=i.context,a=r.connection,s=Y({},r.hints),c=r.newWaypoints||a.waypoints,l=r.oldWaypoints;return typeof s.startChanged>"u"&&(s.startChanged=!!s.connectionStart),typeof s.endChanged>"u"&&(s.endChanged=!!s.connectionEnd),kk(o,c,l,s)}this.postExecute(["connection.layout","connection.updateWaypoints"],function(i){var o=i.context,r=o.connection,a=r.outgoing,s=r.incoming;s.forEach(function(c){var l=c.waypoints[c.waypoints.length-1],u=n(i,l),p=[].concat(c.waypoints.slice(0,-1),[u]);t.updateWaypoints(c,p)}),a.forEach(function(c){var l=c.waypoints[0],u=n(i,l),p=[].concat([u],c.waypoints.slice(1));t.updateWaypoints(c,p)})}),this.postExecute(["connection.move"],function(i){var o=i.context,r=o.connection,a=r.outgoing,s=r.incoming,c=o.delta;s.forEach(function(l){var u=l.waypoints[l.waypoints.length-1],p={x:u.x+c.x,y:u.y+c.y},f=[].concat(l.waypoints.slice(0,-1),[p]);t.updateWaypoints(l,f)}),a.forEach(function(l){var u=l.waypoints[0],p={x:u.x+c.x,y:u.y+c.y},f=[].concat([p],l.waypoints.slice(1));t.updateWaypoints(l,f)})})}Ne(Ad,we),Ad.$inject=["eventBus","modeling"];function Gl(e,t,n){var i=Wl(e),o=Ub(i,t),r=i[0];return o.length?o[o.length-1]:$s(r.original||r,n,t)}function Vl(e,t,n){var i=Wl(e),o=Ub(i,t),r=i[i.length-1];return o.length?o[0]:$s(r.original||r,n,t)}function Pd(e,t,n){var i=Wl(e),o=Wb(t,n),r=i[0];return $s(r.original||r,o,t)}function Td(e,t,n){var i=Wl(e),o=Wb(t,n),r=i[i.length-1];return $s(r.original||r,o,t)}function Wb(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function Wl(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function Ub(e,t){var n=Fn(e,Dk);return ct(n,function(i){return Ok(i,t)})}function Ok(e,t){return On(t,e,1)==="intersect"}function Dk(e){return e.original||e}function kd(e,t){we.call(this,e),this.postExecute("shape.replace",function(n){var i=n.oldShape,o=n.newShape;if(Lk(i,o)){var r=Ik(i);r.incoming.forEach(function(a){var s=Vl(a,o,i);t.reconnectEnd(a,o,s)}),r.outgoing.forEach(function(a){var s=Gl(a,o,i);t.reconnectStart(a,o,s)})}},!0)}kd.$inject=["eventBus","modeling"],Ne(kd,we);function Lk(e,t){return M(e,"bpmn:Participant")&&ht(e)&&M(t,"bpmn:Participant")&&!ht(t)}function Ik(e){var t=Es([e]),n=[],i=[];return t.forEach(function(o){o!==e&&(o.incoming.forEach(function(r){M(r,"bpmn:MessageFlow")&&n.push(r)}),o.outgoing.forEach(function(r){M(r,"bpmn:MessageFlow")&&i.push(r)}))},[]),{incoming:n,outgoing:i}}const Bk=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function qb(e){const t=_e(e);if(!M(t,"bpmn:BoundaryEvent")&&!(M(t,"bpmn:StartEvent")&&Gn(t.$parent)))return!1;const n=t.get("eventDefinitions");return!n||!n.length?!1:Bk.some(i=>M(n[0],i))}function Yb(e){return M(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function Od(e,t){e.invoke(we,this),this.postExecuted("shape.replace",function(n){const i=n.context.oldShape,o=n.context.newShape,r=n.context.hints;if(!qb(o))return;const a=Yb(o);if(r.targetElement&&r.targetElement[a]!==void 0)return;const c=_e(i).get(a),l=_e(o).get(a);c!==l&&t.updateProperties(o,{[a]:c})})}Od.$inject=["injector","modeling"],Ne(Od,we);function Dd(e,t){we.call(this,e),this.preExecute("shape.resize",function(n){var i=n.shape,o=mt(i),r=o&&o.get("label"),a=r&&r.get("bounds");a&&t.updateModdleProperties(i,r,{bounds:void 0})},!0)}Ne(Dd,we),Dd.$inject=["eventBus","modeling"];function Ld(e,t,n){we.call(this,e),this.preExecute("shape.delete",function(i){var o=i.context.shape;if(!(o.incoming.length!==1||o.outgoing.length!==1)){var r=o.incoming[0],a=o.outgoing[0];if(!(!M(r,"bpmn:SequenceFlow")||!M(a,"bpmn:SequenceFlow"))&&t.canConnect(r.source,a.target,r)){var s=Nk(r.waypoints,a.waypoints);n.reconnectEnd(r,a.target,s)}}})}Ne(Ld,we),Ld.$inject=["eventBus","bpmnRules","modeling"];function Ta(e){return e.original||e}function Nk(e,t){var n=Sd(Ta(e[e.length-2]),Ta(e[e.length-1]),Ta(t[1]),Ta(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[Ta(e[0]),Ta(t[t.length-1])]}function Id(e,t){we.call(this,e),this.preExecute("shape.delete",function(n){var i=n.shape,o=i.parent;M(i,"bpmn:Participant")&&(n.collaborationRoot=o)},!0),this.postExecute("shape.delete",function(n){var i=n.collaborationRoot;if(i&&!i.businessObject.participants.length){var o=t.makeProcess(),r=i.children.slice();t.moveElements(r,{x:0,y:0},o)}},!0)}Id.$inject=["eventBus","modeling"],Ne(Id,we);function Bd(e,t,n,i){we.call(this,e);var o=i.get("dragging",!1);function r(c){var l=c.source,u=c.target,p=c.parent;if(p){var f,d;M(c,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(l,u)||(d=!0),n.canConnectMessageFlow(l,u)&&(f="bpmn:MessageFlow")),M(c,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(l,u)||(d=!0),n.canConnectSequenceFlow(l,u)&&(f="bpmn:SequenceFlow")),d&&t.removeConnection(c),f&&t.connect(l,u,{type:f,waypoints:c.waypoints.slice()})}}function a(c){var l=c.context,u=l.connection,p=l.newSource||u.source,f=l.newTarget||u.target,d,g;d=n.canConnect(p,f),!(!d||d.type===u.type)&&(g=t.connect(p,f,{type:d.type,associationDirection:d.associationDirection,waypoints:u.waypoints.slice()}),u.parent&&t.removeConnection(u),l.connection=g,o&&s(u,g))}function s(c,l){var u=o.context(),p=u&&u.payload.previousSelection,f;!p||!p.length||(f=p.indexOf(c),f!==-1&&p.splice(f,1,l))}this.postExecuted("elements.move",function(c){var l=c.closure,u=l.allConnections;V(u,r)},!0),this.preExecute("connection.reconnect",a),this.postExecuted("element.updateProperties",function(c){var l=c.context,u=l.properties,p=l.element,f=p.businessObject,d;u.default&&(d=It(p.outgoing,ca({id:p.businessObject.default.id})),d&&t.updateProperties(d,{conditionExpression:void 0})),u.conditionExpression&&f.sourceRef.default===f&&t.updateProperties(p.source,{default:void 0})})}Ne(Bd,we),Bd.$inject=["eventBus","modeling","bpmnRules","injector"];function Ul(e,t,n,i,o,r){i.invoke(we,this),this._bpmnReplace=e,this._elementRegistry=n,this._selection=r,this.postExecuted(["elements.create"],500,function(a){var s=a.context,c=s.parent,l=s.elements,u=ni(l,function(p,f){var d=t.canReplace([f],f.host||f.parent||c);return d?p.concat(d.replacements):p},[]);u.length&&this._replaceElements(l,u)},this),this.postExecuted(["elements.move"],500,function(a){var s=a.context,c=s.newParent,l=s.newHost,u=[];V(s.closure.topLevel,function(f){Gn(f)?u=u.concat(f.children):u=u.concat(f)}),u.length===1&&l&&(c=l);var p=t.canReplace(u,c);p&&this._replaceElements(u,p.replacements,l)},this),this.postExecute(["shape.replace"],1500,function(a){var s=a.context,c=s.oldShape,l=s.newShape,u=c.attachers,p;u&&u.length&&(p=t.canReplace(u,l),this._replaceElements(u,p.replacements))},this),this.postExecuted(["shape.replace"],1500,function(a){var s=a.context,c=s.oldShape,l=s.newShape;o.unclaimId(c.businessObject.id,c.businessObject),o.updateProperties(l,{id:c.id})})}Ne(Ul,we),Ul.prototype._replaceElements=function(e,t){var n=this._elementRegistry,i=this._bpmnReplace,o=this._selection;V(t,function(r){var a={type:r.newElementType},s=n.get(r.oldElementId),c=e.indexOf(s);e[c]=i.replaceElement(s,a,{select:!1})}),t&&o.select(e)},Ul.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var $k=1500,Fk={width:140,height:120},Nd={width:300,height:60},$d={width:60,height:300},ql={width:300,height:150},Yl={width:150,height:300},Kb={width:140,height:120},Xb={width:100,height:40};function Zb(e){e.on("resize.start",$k,function(t){var n=t.context,i=n.shape,o=n.direction,r=n.balanced;(M(i,"bpmn:Lane")||M(i,"bpmn:Participant"))&&(n.resizeConstraints=Vk(i,o,r)),M(i,"bpmn:SubProcess")&&ht(i)&&(n.minDimensions=Kb),M(i,"bpmn:TextAnnotation")&&(n.minDimensions=Xb)})}Zb.$inject=["eventBus"];var er=Math.abs,jk=Math.min,Hk=Math.max;function Qb(e,t,n,i){var o=e[t];e[t]=o===void 0?n:i(n,o)}function ka(e,t,n){return Qb(e,t,n,jk)}function Oa(e,t,n){return Qb(e,t,n,Hk)}var zk={top:20,left:50,right:20,bottom:20},Gk={top:50,left:20,right:20,bottom:20};function Vk(e,t,n){var i=Ri(e),o=!0,r=!0,a=$l(i,[i]),s=qe(e),c={},l={},u=En(e),p=u?Nd:$d;/n/.test(t)?l.top=s.bottom-p.height:/e/.test(t)?l.right=s.left+p.width:/s/.test(t)?l.bottom=s.top+p.height:/w/.test(t)&&(l.left=s.right-p.width),a.forEach(function(g){var h=qe(g);u?(h.top<s.top-10&&(o=!1),h.bottom>s.bottom+10&&(r=!1)):(h.left<s.left-10&&(o=!1),h.right>s.right+10&&(r=!1)),/n/.test(t)&&(n&&er(s.top-h.bottom)<10&&Oa(c,"top",h.top+p.height),er(s.top-h.top)<5&&ka(l,"top",h.bottom-p.height)),/e/.test(t)&&(n&&er(s.right-h.left)<10&&ka(c,"right",h.right-p.width),er(s.right-h.right)<5&&Oa(l,"right",h.left+p.width)),/s/.test(t)&&(n&&er(s.bottom-h.top)<10&&ka(c,"bottom",h.bottom-p.height),er(s.bottom-h.bottom)<5&&Oa(l,"bottom",h.top+p.height)),/w/.test(t)&&(n&&er(s.left-h.right)<10&&Oa(c,"left",h.left+p.width),er(s.left-h.left)<5&&ka(l,"left",h.right-p.width))});var f=i.children.filter(function(g){return!g.hidden&&!g.waypoints&&(M(g,"bpmn:FlowElement")||M(g,"bpmn:Artifact"))}),d=u?zk:Gk;return f.forEach(function(g){var h=qe(g);/n/.test(t)&&(!u||o)&&ka(l,"top",h.top-d.top),/e/.test(t)&&(u||r)&&Oa(l,"right",h.right+d.right),/s/.test(t)&&(!u||r)&&Oa(l,"bottom",h.bottom+d.bottom),/w/.test(t)&&(u||o)&&ka(l,"left",h.left-d.left)}),{min:l,max:c}}function Jb(e){!e||typeof e.stopPropagation!="function"||e.stopPropagation()}function Da(e){return e.originalEvent||e.srcEvent}function Fd(e){Jb(e),Jb(Da(e))}function Fr(e){return e.pointers&&e.pointers.length&&(e=e.pointers[0]),e.touches&&e.touches.length&&(e=e.touches[0]),e?{x:e.clientX,y:e.clientY}:null}function ex(){return/mac/i.test(navigator.platform)}function tx(e,t){return(Da(e)||e).button===t}function tr(e){return tx(e,0)}function Wk(e){return tx(e,1)}function Fs(e){var t=Da(e)||e;return tr(e)?ex()?t.metaKey:t.ctrlKey:!1}function Kl(e){var t=Da(e)||e;return tr(e)&&t.shiftKey}var nx=1001;function ix(e,t){e.on("resize.start",nx+500,function(n){var i=n.context,o=i.shape;(M(o,"bpmn:Lane")||M(o,"bpmn:Participant"))&&(i.balanced=!Fs(n))}),e.on("resize.end",nx,function(n){var i=n.context,o=i.shape,r=i.canExecute,a=i.newBounds;if(M(o,"bpmn:Lane")||M(o,"bpmn:Participant"))return r&&(a=Ov(a),t.resizeLane(o,a,i.balanced)),!1})}ix.$inject=["eventBus","modeling"];var Uk=500;function jd(e,t,n,i,o){n.invoke(we,this);function r(u){return st(u,["bpmn:ReceiveTask","bpmn:SendTask"])||qk(u,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(u){var p=e.getDefinitions(),f=p.get("rootElements");return!!It(f,ca({id:u.id}))}function s(u){if(M(u,"bpmn:ErrorEventDefinition"))return"errorRef";if(M(u,"bpmn:EscalationEventDefinition"))return"escalationRef";if(M(u,"bpmn:MessageEventDefinition"))return"messageRef";if(M(u,"bpmn:SignalEventDefinition"))return"signalRef"}function c(u){if(st(u,["bpmn:ReceiveTask","bpmn:SendTask"]))return u.get("messageRef");var p=u.get("eventDefinitions"),f=p[0];return f.get(s(f))}function l(u,p){if(st(u,["bpmn:ReceiveTask","bpmn:SendTask"]))return u.set("messageRef",p);var f=u.get("eventDefinitions"),d=f[0];return d.set(s(d),p)}this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],function(u){var p=u.shape||u.element;if(r(p)){var f=_e(p),d=c(f),g;d&&!a(d)&&(g=e.getDefinitions().get("rootElements"),on(g,d),u.addedRootElement=d)}},!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],function(u){var p=u.addedRootElement;if(p){var f=e.getDefinitions().get("rootElements");tn(f,p)}},!0),t.on("copyPaste.copyElement",function(u){var p=u.descriptor,f=u.element;if(!(f.labelTarget||!r(f))){var d=_e(f),g=c(d);g&&(p.referencedRootElement=g)}}),t.on("copyPaste.pasteElement",Uk,function(u){var p=u.descriptor,f=p.businessObject,d=p.referencedRootElement;d&&(a(d)||(d=i.copyElement(d,o.create(d.$type))),l(f,d),delete p.referencedRootElement)})}jd.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"],Ne(jd,we);function qk(e,t){return Ze(t)||(t=[t]),Bo(t,function(n){return Sa(e,n)})}var ox=Math.max;function rx(e){e.on("spaceTool.getMinDimensions",function(t){var n=t.shapes,i=t.axis,o=t.start,r={};return V(n,function(a){var s=a.id;M(a,"bpmn:Participant")&&(r[s]=Kk(a,i,o)),M(a,"bpmn:Lane")&&(r[s]=En(a)?Nd:$d),M(a,"bpmn:SubProcess")&&ht(a)&&(r[s]=Kb),M(a,"bpmn:TextAnnotation")&&(r[s]=Xb),M(a,"bpmn:Group")&&(r[s]=Fk)}),r})}rx.$inject=["eventBus"];function Yk(e){return e==="x"}function Kk(e,t,n){var i=En(e);if(!Qk(e))return i?ql:Yl;var o=Yk(t),r={};return o?i?r=ql:r={width:Zk(e,n,o),height:Yl.height}:i?r={width:ql.width,height:Xk(e,n,o)}:r=Yl,r}function Xk(e,t,n){var i;return i=Jk(e,t,n),ox(ql.height,i)}function Zk(e,t,n){var i;return i=eO(e,t,n),ox(Yl.width,i)}function Qk(e){return!!Jo(e).length}function Jk(e,t,n){var i=Jo(e),o;return o=Hd(i,t,n),e.height-o.height+Nd.height}function eO(e,t,n){var i=Jo(e),o;return o=Hd(i,t,n),e.width-o.width+$d.width}function Hd(e,t,n){var i,o,r;for(i=0;i<e.length;i++)if(o=e[i],!n&&t>=o.y&&t<=o.y+o.height||n&&t>=o.x&&t<=o.x+o.width)return r=Jo(o),r.length?Hd(r,t,n):o}var ax="_plane";function sx(e){var t=e.id;return tO(t)}function no(e){var t=e.id;return M(e,"bpmn:SubProcess")?cx(t):t}function jr(e){return cx(e)}function Xl(e){var t=mt(e);return M(t,"bpmndi:BPMNPlane")}function cx(e){return e+ax}function tO(e){return e.replace(new RegExp(ax+"$"),"")}var lx=400,nO=600,ux={x:180,y:160};function Eo(e,t,n,i,o,r,a){we.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=i,this._bpmnFactory=o,this._bpmnjs=r,this._elementRegistry=a;var s=this;function c(p){return M(p,"bpmn:SubProcess")&&!ht(p)}function l(p){var f=p.shape,d=p.newRootElement,g=_e(f);d=s._addDiagram(d||g),p.newRootElement=e.addRootElement(d)}function u(p){var f=p.shape,d=_e(f);s._removeDiagram(d);var g=p.newRootElement=a.get(no(d));e.removeRootElement(g)}this.executed("shape.create",function(p){var f=p.shape;c(f)&&l(p)},!0),this.postExecuted("elements.create",function(p){var f=p.elements;V(f,function(d){if(c(d)){var g=a.get(no(d));if(!(!g||!d.children||!d.children.length)){var h=px(d);s._showRecursively(h),s._moveChildrenToShape(h,g)}}})},!0),this.reverted("shape.create",function(p){var f=p.shape;c(f)&&u(p)},!0),this.preExecute("shape.delete",function(p){var f=p.shape;!M(f,"bpmn:SubProcess")||!ht(f)||V(Ps([f]),d=>{n.removeShape(d.annotation)})},!0),this.preExecuted("shape.delete",function(p){var f=p.shape;if(c(f)){var d=a.get(no(f));d&&n.removeElements(d.children.slice())}},!0),this.executed("shape.delete",function(p){var f=p.shape;c(f)&&u(p)},!0),this.reverted("shape.delete",function(p){var f=p.shape;c(f)&&l(p)},!0),this.preExecuted("shape.replace",function(p){var f=p.oldShape,d=p.newShape;!c(f)||!c(d)||(p.oldRoot=e.removeRootElement(no(f)))},!0),this.postExecuted("shape.replace",function(p){var f=p.newShape,d=p.oldRoot,g=e.findRoot(no(f));if(!(!d||!g)){var h=d.children;n.moveElements(h,{x:0,y:0},g)}},!0),this.executed("element.updateProperties",function(p){var f=p.element;if(M(f,"bpmn:SubProcess")){var d=p.properties,g=p.oldProperties,h=g.id,m=d.id;if(h!==m){if(Xl(f)){a.updateId(f,jr(m)),a.updateId(h,m);return}var w=a.get(jr(h));w&&a.updateId(jr(h),jr(m))}}},!0),this.reverted("element.updateProperties",function(p){var f=p.element;if(M(f,"bpmn:SubProcess")){var d=p.properties,g=p.oldProperties,h=g.id,m=d.id;if(h!==m){if(Xl(f)){a.updateId(f,jr(h)),a.updateId(m,h);return}var w=a.get(jr(m));w&&a.updateId(w,jr(h))}}},!0),t.on("element.changed",function(p){var f=p.element;if(Xl(f)){var d=f,g=a.get(sx(d));!g||g===d||t.fire("element.changed",{element:g})}}),this.executed("shape.toggleCollapse",lx,function(p){var f=p.shape;M(f,"bpmn:SubProcess")&&(ht(f)?u(p):(l(p),s._showRecursively(f.children)))},!0),this.reverted("shape.toggleCollapse",lx,function(p){var f=p.shape;M(f,"bpmn:SubProcess")&&(ht(f)?u(p):(l(p),s._showRecursively(f.children)))},!0),this.postExecuted("shape.toggleCollapse",nO,function(p){var f=p.shape;if(M(f,"bpmn:SubProcess")){var d=p.newRootElement;if(d)if(ht(f))s._moveChildrenToShape(d.children.slice(),f),V(Ps(f.children),h=>{n.moveShape(h.annotation,{x:0,y:0},f.parent),V(h.associations,m=>{n.moveConnection(m,{x:0,y:0},f.parent)})});else{s._disconnectSharedAnnotations(f);var g=px(f);s._moveChildrenToShape(g,d)}}},!0),t.on("copyPaste.createTree",function(p){var f=p.element,d=p.children;if(c(f)){var g=no(f),h=a.get(g);h&&d.push.apply(d,h.children)}}),t.on("copyPaste.copyElement",function(p){var f=p.descriptor,d=p.element,g=p.elements,h=d.parent,m=M(mt(h),"bpmndi:BPMNPlane");if(m){var w=sx(h),y=It(g,function(v){return v.id===w});y&&(f.parent=y.id)}}),t.on("copyPaste.pasteElement",function(p){var f=p.descriptor;f.parent&&(c(f.parent)||f.parent.hidden)&&(f.hidden=!0)})}Ne(Eo,we),Eo.prototype._moveChildrenToShape=function(e,t){var n=this._modeling;if(e.length){var i=e.filter(function(c){return!c.hidden});if(!i.length){n.moveElements(e,{x:0,y:0},t,{autoResize:!1});return}var o=cn(i),r;if(!t.x)r={x:ux.x-o.x,y:ux.y-o.y};else{var a=Je(t),s=Je(o);r={x:a.x-s.x,y:a.y-s.y}}n.moveElements(e,r,t,{autoResize:!1})}},Eo.prototype._disconnectSharedAnnotations=function(e){var t=this._modeling,n=new Set(tb(e).map(i=>i.annotation));n.size&&V(Ps(e.children),i=>{n.has(i.annotation)&&V(i.associations,o=>{t.removeConnection(o)})})},Eo.prototype._showRecursively=function(e,t){var n=this,i=[];return e.forEach(function(o){o.hidden=!!t,i=i.concat(o),o.children&&(i=i.concat(n._showRecursively(o.children,o.collapsed||t)))}),i},Eo.prototype._addDiagram=function(e){var t=this._bpmnjs,n=t.getDefinitions().diagrams;return e.businessObject||(e=this._createNewDiagram(e)),n.push(e.di.$parent),e},Eo.prototype._createNewDiagram=function(e){var t=this._bpmnFactory,n=this._elementFactory,i=t.create("bpmndi:BPMNPlane",{bpmnElement:e}),o=t.create("bpmndi:BPMNDiagram",{plane:i});i.$parent=o;var r=n.createRoot({id:no(e),type:e.$type,di:i,businessObject:e,collapsed:!0});return r},Eo.prototype._removeDiagram=function(e){var t=this._bpmnjs,n=t.getDefinitions().diagrams,i=It(n,function(o){return o.plane.bpmnElement.id===e.id});return n.splice(n.indexOf(i),1),i},Eo.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"];function iO(e){var t=[];return V(Ps(e),n=>{t.push(n.annotation),t.push.apply(t,n.associations)}),t}function px(e){return e.children.slice().concat(iO(e.children)).concat(oO(e))}function oO(e){return Uf(e.children||[]).reduce(function(t,n){return n.label&&n.label.parent!==e&&t.push(n.label),t},[])}function zd(e,t){e.invoke(we,this),this.postExecuted("shape.replace",function(n){var i=n.context.oldShape,o=n.context.newShape;if(!(!M(o,"bpmn:SubProcess")||M(o,"bpmn:AdHocSubProcess")||!(M(i,"bpmn:Task")||M(i,"bpmn:CallActivity"))||!ht(o))){var r=rO(o);t.createShape({type:"bpmn:StartEvent"},r,o)}})}zd.$inject=["injector","modeling"],Ne(zd,we);function rO(e){return{x:e.x+e.width/6,y:e.y+e.height/2}}function Gd(e,t){we.call(this,e),this.preExecute("connection.create",function(n){const{target:i}=n;M(i,"bpmn:TextAnnotation")&&(n.parent=i.parent)},!0),this.preExecute(["shape.create","shape.resize","elements.move"],function(n){const i=n.shapes||[n.shape];i.length===1&&M(i[0],"bpmn:TextAnnotation")&&(n.hints=n.hints||{},n.hints.autoResize=!1)},!0),this.preExecute("shape.resize",function(n){var i=n.context,o=i.shape,r=i.hints||{};if(!(!M(o,"bpmn:TextAnnotation")||r.autoResize)){var a=i.newBounds,s=t.getTextAnnotationBounds(a,vi(o)||""),c=a.y!==o.y&&Math.abs(a.y+a.height-(o.y+o.height))<=1,l=o.y+o.height;i.newBounds={width:a.width,height:s.height,x:a.x,y:c?l-s.height:a.y}}})}Ne(Gd,we),Gd.$inject=["eventBus","textRenderer"];function Vd(e,t){we.call(this,e),this.postExecuted("shape.toggleCollapse",1500,function(n){var i=n.shape;if(ht(i))return;var o=Es(i);o.forEach(function(a){var s=a.incoming.slice(),c=a.outgoing.slice();V(s,function(l){r(l,!0)}),V(c,function(l){r(l,!1)})});function r(a,s){o.indexOf(a.source)!==-1&&o.indexOf(a.target)!==-1||M(a,"bpmn:Association")&&(M(a.source,"bpmn:TextAnnotation")||M(a.target,"bpmn:TextAnnotation"))||(s?t.reconnectEnd(a,i,Je(i)):t.reconnectStart(a,i,Je(i)))}},!0)}Ne(Vd,we),Vd.$inject=["eventBus","modeling"];var Wd=500;function Ud(e,t,n){we.call(this,e);function i(a){a.length&&a.forEach(function(s){s.type==="label"&&!s.businessObject.name&&(s.hidden=!0)})}function o(a,s){var c=a.children,l=s,u,p;return u=aO(c).concat([a]),p=bb(u),p?(l.width=Math.max(p.width,l.width),l.height=Math.max(p.height,l.height),l.x=p.x+(p.width-l.width)/2,l.y=p.y+(p.height-l.height)/2):(l.x=a.x+(a.width-l.width)/2,l.y=a.y+(a.height-l.height)/2),l}function r(a,s){return{x:a.x+(a.width-s.width)/2,y:a.y+(a.height-s.height)/2,width:s.width,height:s.height}}this.executed(["shape.toggleCollapse"],Wd,function(a){var s=a.context,c=s.shape;M(c,"bpmn:SubProcess")&&(c.collapsed?mt(c).isExpanded=!1:(i(c.children),mt(c).isExpanded=!0))}),this.reverted(["shape.toggleCollapse"],Wd,function(a){var s=a.context,c=s.shape;c.collapsed?mt(c).isExpanded=!1:mt(c).isExpanded=!0}),this.postExecuted(["shape.toggleCollapse"],Wd,function(a){var s=a.context.shape,c=t.getDefaultSize(s),l;s.collapsed?l=r(s,c):l=o(s,c),n.resizeShape(s,l,null,{autoResize:s.collapsed?!1:"nwse"})})}Ne(Ud,we),Ud.$inject=["eventBus","elementFactory","modeling"];function aO(e){return e.filter(function(t){return!t.hidden})}function qd(e,t,n,i){t.invoke(we,this),this.preExecute("shape.delete",function(o){var r=o.context,a=r.shape,s=a.businessObject;at(a)||(M(a,"bpmn:Participant")&&ht(a)&&n.ids.unclaim(s.processRef.id),i.unclaimId(s.id,s))}),this.preExecute("connection.delete",function(o){var r=o.context,a=r.connection,s=a.businessObject;i.unclaimId(s.id,s)}),this.preExecute("canvas.updateRoot",function(){var o=e.getRootElement(),r=o.businessObject;M(o,"bpmn:Collaboration")&&n.ids.unclaim(r.id)})}Ne(qd,we),qd.$inject=["canvas","injector","moddle","modeling"];function Yd(e,t){we.call(this,e),this.preExecute("connection.delete",function(n){var i=n.context,o=i.connection,r=o.source;sO(o,r)&&t.updateProperties(r,{default:null})})}Ne(Yd,we),Yd.$inject=["eventBus","modeling"];function sO(e,t){if(!M(e,"bpmn:SequenceFlow"))return!1;var n=_e(t),i=_e(e);return n.get("default")===i}var cO=500,lO=5e3,fx=["shape.create","shape.delete","shape.move","shape.resize"],dx=[...fx,"spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move"];function Kd(e,t){we.call(this,e);var n;function i(){return n=n||new uO,n.enter(),n}function o(){if(!n)throw new Error("out of bounds release");return n}function r(){if(!n)throw new Error("out of bounds release");var a=n.leave();return a&&(t.updateLaneRefs(n.flowNodes,n.lanes),n=null),a}this.preExecute(dx,lO,function(){i()}),this.postExecuted(dx,cO,function(){r()}),this.preExecute(fx,function(a){var s=a.context,c=s.shape,l=o();!c||c.labelTarget||(M(c,"bpmn:Lane")&&l.addLane(c),M(c,"bpmn:FlowNode")&&l.addFlowNode(c))})}Kd.$inject=["eventBus","modeling"],Ne(Kd,we);function uO(){this.flowNodes=[],this.lanes=[],this.counter=0,this.addLane=function(e){this.lanes.push(e)},this.addFlowNode=function(e){this.flowNodes.push(e)},this.enter=function(){this.counter++},this.leave=function(){return this.counter--,!this.counter}}var pO=500,fO=5e3,hx=["connection.create","connection.delete","connection.layout","connection.move","connection.reconnect","connection.updateWaypoints","shape.create","shape.delete","shape.move","shape.resize"],gx=[...hx,"elements.create","elements.delete","elements.move","label.create","spaceTool"];function Xd(e,t){we.call(this,e);var n;function i(){return n=n||new dO,n.enter(),n}function o(){if(!n)throw new Error("out of bounds release");return n}function r(){if(!n)throw new Error("out of bounds release");var a=n.leave();return a&&(t.updateCategoryValueRefs(Array.from(n.affectedFlowElements),Array.from(n.affectedGroupEntries.values())),n=null),a}this.preExecute(gx,fO,function(){i()}),this.postExecuted(gx,pO,function(){r()}),this.preExecute(hx,function(a){var s=a.context.connection||a.context.shape,c=o();!s||s.labelTarget||(M(s,"bpmn:FlowElement")&&c.addFlowElement(s),M(s,"bpmn:Group")&&c.addGroup(s))}),this.preExecute("label.create",function(a){var s=a.context.labelTarget;M(s,"bpmn:Group")&&o().addGroup(s)})}Xd.$inject=["eventBus","modeling"],Ne(Xd,we);function dO(){this.affectedFlowElements=new Set,this.affectedGroupEntries=new Map,this.counter=0,this.addFlowElement=function(e){this.affectedFlowElements.add(e)},this.addGroup=function(e){this.affectedGroupEntries.has(e)||this.affectedGroupEntries.set(e,{categoryValue:e.businessObject.categoryValueRef,groupShape:e})},this.enter=function(){this.counter++},this.leave=function(){return this.counter--,!this.counter}}function Zd(e,t){we.call(this,e),this.postExecuted("elements.create",function(n){const i=n.context,o=i.elements;for(const r of o)hO(r)&&!mO(r)&&t.updateProperties(r,{isForCompensation:void 0})})}Ne(Zd,we),Zd.$inject=["eventBus","modeling"];function hO(e){const t=_e(e);return t&&t.isForCompensation}function gO(e){return e&&M(e,"bpmn:BoundaryEvent")&&Sa(e,"bpmn:CompensateEventDefinition")}function mO(e){return e.incoming.filter(n=>gO(n.source)).length>0}const yO={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","artifactBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","categoryRootElementReferenceBehavior","compensateBoundaryEventBehaviour","createBehavior","createDataObjectBehavior","createParticipantBehavior","dataInputAssociationBehavior","dataStoreBehavior","deleteLaneBehavior","detachEventBehavior","dropOnFlowBehavior","eventBasedGatewayBehavior","fixHoverBehavior","groupBehavior","importDockingFix","isHorizontalFix","labelBehavior","layoutConnectionBehavior","messageFlowBehavior","nonInterruptingBehavior","removeElementBehavior","removeEmbeddedLabelBoundsBehavior","removeParticipantBehavior","replaceConnectionBehavior","replaceElementBehaviour","resizeBehavior","resizeLaneBehavior","rootElementReferenceBehavior","spaceToolBehavior","subProcessPlaneBehavior","subProcessStartEventBehavior","textAnnotationBehavior","toggleCollapseConnectionBehaviour","toggleElementCollapseBehaviour","unclaimIdBehavior","updateFlowNodeRefsBehavior","updateCategoryValueRefsBehavior","unsetDefaultFlowBehavior","setCompensationActivityAfterPasteBehavior"],adaptiveLabelPositioningBehavior:["type",rd],appendBehavior:["type",ad],associationBehavior:["type",cd],attachEventBehavior:["type",kl],artifactBehavior:["type",sd],boundaryEventBehavior:["type",ld],categoryRootElementReferenceBehavior:["type",ud],compensateBoundaryEventBehaviour:["type",pd],createBehavior:["type",fd],createDataObjectBehavior:["type",dd],createParticipantBehavior:["type",md],dataInputAssociationBehavior:["type",yd],dataStoreBehavior:["type",vd],deleteLaneBehavior:["type",bd],detachEventBehavior:["type",Fl],dropOnFlowBehavior:["type",wd],eventBasedGatewayBehavior:["type",_d],fixHoverBehavior:["type",Cb],groupBehavior:["type",Ed],importDockingFix:["type",Ab],isHorizontalFix:["type",Rd],labelBehavior:["type",Md],layoutConnectionBehavior:["type",Ad],messageFlowBehavior:["type",kd],nonInterruptingBehavior:["type",Od],removeElementBehavior:["type",Ld],removeEmbeddedLabelBoundsBehavior:["type",Dd],removeParticipantBehavior:["type",Id],replaceConnectionBehavior:["type",Bd],replaceElementBehaviour:["type",Ul],resizeBehavior:["type",Zb],resizeLaneBehavior:["type",ix],rootElementReferenceBehavior:["type",jd],spaceToolBehavior:["type",rx],subProcessPlaneBehavior:["type",Eo],subProcessStartEventBehavior:["type",zd],textAnnotationBehavior:["type",Gd],toggleCollapseConnectionBehaviour:["type",Vd],toggleElementCollapseBehaviour:["type",Ud],unclaimIdBehavior:["type",qd],unsetDefaultFlowBehavior:["type",Yd],updateFlowNodeRefsBehavior:["type",Kd],updateCategoryValueRefsBehavior:["type",Xd],setCompensationActivityAfterPasteBehavior:["type",Zd]};function Qd(e){this._commandStack=e.get("commandStack",!1)}Qd.$inject=["injector"],Qd.prototype.allowed=function(e,t){var n=!0,i=this._commandStack;return i&&(n=i.canExecute(e,t)),n===void 0?!0:n};const io={__init__:["rules"],rules:["type",Qd]};function Ci(e){we.call(this,e),this.init()}Ci.$inject=["eventBus"],Ne(Ci,we),Ci.prototype.addRule=function(e,t,n){var i=this;typeof e=="string"&&(e=[e]),e.forEach(function(o){i.canExecute(o,t,function(r,a,s){return n(r)},!0)})},Ci.prototype.init=function(){};function mx(e,t){var n=On(e,t,-15);return n!=="intersect"?n:null}function Ln(e){Ci.call(this,e)}Ne(Ln,Ci),Ln.$inject=["eventBus"],Ln.prototype.init=function(){this.addRule("connection.start",function(e){var t=e.source;return vO(t)}),this.addRule("connection.create",function(e){var t=e.source,n=e.target,i=e.hints||{},o=i.targetParent,r=i.targetAttach;if(r)return!1;o&&(n.parent=o);try{return Ql(t,n)}finally{o&&(n.parent=null)}}),this.addRule("connection.reconnect",function(e){var t=e.connection,n=e.source,i=e.target;return Ql(n,i,t)}),this.addRule("connection.updateWaypoints",function(e){return{type:e.connection.type}}),this.addRule("shape.resize",function(e){var t=e.shape,n=e.newBounds,i=e.direction;return Px(t,n,i)}),this.addRule("elements.create",function(e){var t=e.elements,n=e.position,i=e.target;return Ot(i)&&!Jl(t,i)?!1:Io(t,function(o){return Ot(o)?Ql(o.source,o.target,o):o.host?js(o,o.host,null,n):nh(o,i)})}),this.addRule("elements.move",function(e){var t=e.target,n=e.shapes,i=e.position,o=e.hints;return o!=null&&o.keyboardMove&&n.some(function(a){return Ex(a)&&!n.includes(a.host)})?!1:js(n,t,null,i)||Mx(n,t,i)||Ax(n,t)||Jl(n,t)}),this.addRule("shape.create",function(e){return nh(e.shape,e.target,e.source,e.position)}),this.addRule("shape.attach",function(e){return js(e.shape,e.target,null,e.position)}),this.addRule("element.copy",function(e){var t=e.element,n=e.elements;return Lx(n,t)})},Ln.prototype.canConnectMessageFlow=Ox,Ln.prototype.canConnectSequenceFlow=Dx,Ln.prototype.canConnectDataAssociation=ih,Ln.prototype.canConnectAssociation=Tx,Ln.prototype.canConnectCompensationAssociation=kx,Ln.prototype.canMove=Ax,Ln.prototype.canAttach=js,Ln.prototype.canReplace=Mx,Ln.prototype.canDrop=La,Ln.prototype.canInsert=Jl,Ln.prototype.canCreate=nh,Ln.prototype.canConnect=Ql,Ln.prototype.canResize=Px,Ln.prototype.canCopy=Lx;function vO(e){return Jd(e)?null:st(e,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference","bpmn:Group","bpmn:TextAnnotation"])}function Jd(e){return!e||at(e)}function yx(e){do{if(M(e,"bpmn:Process"))return _e(e);if(M(e,"bpmn:Participant"))return _e(e).processRef||_e(e)}while(e=e.parent)}function eh(e){return M(e,"bpmn:TextAnnotation")}function th(e){return M(e,"bpmn:Group")&&!e.labelTarget}function vx(e){return M(e,"bpmn:BoundaryEvent")&&oo(e,"bpmn:CompensateEventDefinition")}function Zl(e){return _e(e).isForCompensation}function bO(e,t){var n=yx(e),i=yx(t);return n===i}function xO(e){return M(e,"bpmn:InteractionNode")&&!M(e,"bpmn:BoundaryEvent")&&(!M(e,"bpmn:Event")||M(e,"bpmn:ThrowEvent")&&wx(e,"bpmn:MessageEventDefinition"))}function wO(e){return M(e,"bpmn:InteractionNode")&&!Zl(e)&&(!M(e,"bpmn:Event")||M(e,"bpmn:CatchEvent")&&wx(e,"bpmn:MessageEventDefinition"))&&!(M(e,"bpmn:BoundaryEvent")&&!oo(e,"bpmn:MessageEventDefinition"))}function bx(e){for(var t=e;t=t.parent;){if(M(t,"bpmn:FlowElementsContainer"))return _e(t);if(M(t,"bpmn:Participant"))return _e(t).processRef}return null}function xx(e,t){var n=bx(e),i=bx(t);return n===i}function oo(e,t){var n=_e(e);return!!It(n.eventDefinitions||[],function(i){return M(i,t)})}function wx(e,t){var n=_e(e);return(n.eventDefinitions||[]).every(function(i){return M(i,t)})}function _O(e){return M(e,"bpmn:FlowNode")&&!M(e,"bpmn:EndEvent")&&!Gn(e)&&!(M(e,"bpmn:IntermediateThrowEvent")&&oo(e,"bpmn:LinkEventDefinition"))&&!vx(e)&&!Zl(e)}function EO(e){return M(e,"bpmn:FlowNode")&&!M(e,"bpmn:StartEvent")&&!M(e,"bpmn:BoundaryEvent")&&!Gn(e)&&!(M(e,"bpmn:IntermediateCatchEvent")&&oo(e,"bpmn:LinkEventDefinition"))&&!Zl(e)}function SO(e){return M(e,"bpmn:ReceiveTask")||M(e,"bpmn:IntermediateCatchEvent")&&(oo(e,"bpmn:MessageEventDefinition")||oo(e,"bpmn:TimerEventDefinition")||oo(e,"bpmn:ConditionalEventDefinition")||oo(e,"bpmn:SignalEventDefinition"))}function RO(e){for(var t=[];e;)e=e.parent,e&&t.push(e);return t}function _x(e,t){var n=RO(t);return n.indexOf(e)!==-1}function Ql(e,t,n){if(Jd(e)||Jd(t))return null;if(!M(n,"bpmn:DataAssociation")){if(Ox(e,t))return{type:"bpmn:MessageFlow"};if(Dx(e,t))return{type:"bpmn:SequenceFlow"}}var i=ih(e,t);return i||(kx(e,t)?{type:"bpmn:Association",associationDirection:"One"}:Tx(e,t)?{type:"bpmn:Association",associationDirection:"None"}:!1)}function La(e,t){return at(e)||th(e)?!0:M(t,"bpmn:Participant")&&!ht(t)?!1:M(e,"bpmn:Participant")?M(t,"bpmn:Process")||M(t,"bpmn:Collaboration"):st(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:M(e,"bpmn:Lane")?M(t,"bpmn:Participant")||M(t,"bpmn:Lane"):M(e,"bpmn:BoundaryEvent")&&!CO(e)?!1:M(e,"bpmn:FlowElement")&&!M(e,"bpmn:DataStoreReference")?M(t,"bpmn:FlowElementsContainer")?ht(t):st(t,["bpmn:Participant","bpmn:Lane"]):M(e,"bpmn:DataStoreReference")&&M(t,"bpmn:Collaboration")?Bo(_e(t).get("participants"),function(n){return!!n.get("processRef")}):st(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?st(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):M(e,"bpmn:MessageFlow")?M(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t:!1}function CO(e){return _e(e).cancelActivity&&(Sx(e)||Rx(e))}function Ex(e){return!at(e)&&M(e,"bpmn:BoundaryEvent")}function MO(e){return M(e,"bpmn:Lane")}function AO(e){return Ex(e)||M(e,"bpmn:IntermediateThrowEvent")&&Sx(e)?!0:M(e,"bpmn:IntermediateCatchEvent")&&Rx(e)}function Sx(e){var t=_e(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function Rx(e){return Cx(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function Cx(e,t){return t.some(function(n){return oo(e,n)})}function PO(e){return M(e,"bpmn:ReceiveTask")&&It(e.incoming,function(t){return M(t.source,"bpmn:EventBasedGateway")})}function js(e,t,n,i){if(Array.isArray(e)||(e=[e]),e.length!==1)return!1;var o=e[0];return at(o)||!AO(o)||Gn(t)||!M(t,"bpmn:Activity")||Zl(t)||i&&!mx(i,t)||PO(t)?!1:"attach"}function Mx(e,t,n){if(!t)return!1;var i={replacements:[]};return V(e,function(o){Gn(t)||M(o,"bpmn:StartEvent")&&o.type!=="label"&&La(o,t)&&($T(o)||i.replacements.push({oldElementId:o.id,newElementType:"bpmn:StartEvent"}),(FT(o)||jT(o)||HT(o))&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:StartEvent"}),Cx(o,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&M(t,"bpmn:SubProcess")&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:StartEvent"})),M(t,"bpmn:Transaction")||oo(o,"bpmn:CancelEventDefinition")&&o.type!=="label"&&(M(o,"bpmn:EndEvent")&&La(o,t)&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:EndEvent"}),M(o,"bpmn:BoundaryEvent")&&js(o,t,null,n)&&i.replacements.push({oldElementId:o.id,newElementType:"bpmn:BoundaryEvent"}))}),i.replacements.length?i:!1}function Ax(e,t){return Bo(e,MO)?!1:t===void 0?!0:t===null?!1:e.every(function(n){return La(n,t)})}function nh(e,t,n,i){return t?at(e)||th(e)?!0:La(e,t)||Jl(e,t):!1}function Px(e,t,n){return M(e,"bpmn:SubProcess")?ht(e)&&(!t||t.width>=100&&t.height>=80):M(e,"bpmn:Lane")||M(e,"bpmn:Participant")?!0:eh(e)?n?n==="e"||n==="w":!0:th(e)?!0:at(e)?n?n==="e"||n==="w":!0:!1}function TO(e,t){var n=eh(e),i=eh(t);return(n||i)&&n!==i}function Tx(e,t){return _x(t,e)||_x(e,t)?!1:TO(e,t)?!0:!!ih(e,t)}function kx(e,t){return xx(e,t)&&vx(e)&&M(t,"bpmn:Activity")&&!OO(t,e)&&!Gn(t)}function Ox(e,t){return Bx(e)&&!Bx(t)?!1:xO(e)&&wO(t)&&!bO(e,t)}function Dx(e,t){return _O(e)&&EO(t)&&xx(e,t)&&!(M(e,"bpmn:EventBasedGateway")&&!SO(t))}function ih(e,t){return st(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&st(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:st(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&st(e,["bpmn:Activity","bpmn:CatchEvent"])?{type:"bpmn:DataOutputAssociation"}:!1}function Jl(e,t,n){if(!t)return!1;if(Array.isArray(e)){if(e.length!==1)return!1;e=e[0]}return t.source===e||t.target===e?!1:st(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!at(t)&&M(e,"bpmn:FlowNode")&&!M(e,"bpmn:BoundaryEvent")&&La(e,t.parent)}function oh(e,t){return e&&t&&e.indexOf(t)!==-1}function Lx(e,t){return at(t)?!0:!(M(t,"bpmn:Lane")&&!oh(e,t.parent)||M(t,"bpmn:MessageFlow")&&!kO(e,t))}function kO(e,t){var n=Ix(t.source),i=Ix(t.target);return oh(e,n)&&oh(e,i)}function Ix(e){for(;e;e=e.parent)if(M(e,"bpmn:Participant"))return e;return null}function Bx(e){return Ma(e,"bpmn:Process")||Ma(e,"bpmn:Collaboration")}function OO(e,t){return e.attachers.includes(t)}const DO={__depends__:[io],__init__:["bpmnRules"],bpmnRules:["type",Ln]};var LO=2e3;function Nx(e,t){e.on("saveXML.start",LO,n);function n(){var i=t.getRootElements();V(i,function(o){var r=mt(o),a,s;a=Es([o]),a=ct(a,function(c){return c!==o&&!c.labelTarget}),s=Fn(a,mt),r.set("planeElement",s)})}}Nx.$inject=["eventBus","canvas"];const IO={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",Nx]};function eu(e){we.call(this,e);var t=this;this.preExecute(["shape.create","connection.create"],function(n){var i=n.context,o=i.shape||i.connection,r=i.parent,a=t.getOrdering(o,r);a&&(a.parent!==void 0&&(i.parent=a.parent),i.parentIndex=a.index)}),this.preExecute(["shape.move","connection.move"],function(n){var i=n.context,o=i.shape||i.connection,r=i.newParent||o.parent,a=t.getOrdering(o,r);a&&(a.parent!==void 0&&(i.newParent=a.parent),i.newParentIndex=a.index)})}eu.prototype.getOrdering=function(e,t){return null},Ne(eu,we);function rh(e,t){eu.call(this,e);var n=[{type:"bpmn:SubProcess",order:{level:6}},{type:"bpmn:SequenceFlow",order:{level:9,containers:["bpmn:Participant","bpmn:FlowElementsContainer"]}},{type:"bpmn:DataAssociation",order:{level:9,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:TextAnnotation",order:{level:9}},{type:"bpmn:MessageFlow",order:{level:9,containers:["bpmn:Collaboration"]}},{type:"bpmn:Association",order:{level:6,containers:["bpmn:Participant","bpmn:FlowElementsContainer","bpmn:Collaboration"]}},{type:"bpmn:BoundaryEvent",order:{level:8}},{type:"bpmn:Group",order:{level:10,containers:["bpmn:Collaboration","bpmn:FlowElementsContainer"]}},{type:"bpmn:FlowElement",order:{level:5}},{type:"bpmn:Participant",order:{level:-2}},{type:"bpmn:Lane",order:{level:-1}}];function i(a){if(a.labelTarget)return{level:10};var s=It(n,function(c){return st(a,[c.type])});return s&&s.order||{level:1}}function o(a){var s=a.order;if(s||(a.order=s=i(a)),!s)throw new Error(`no order for <${a.id}>`);return s}function r(a,s,c){for(var l=s;l&&!st(l,c);)l=l.parent;if(!l)throw new Error(`no parent for <${a.id}> in <${s&&s.id}>`);return l}this.getOrdering=function(a,s){if(a.labelTarget||M(a,"bpmn:TextAnnotation"))return{parent:t.findRoot(s)||t.getRootElement(),index:-1};var c=o(a);c.containers&&(s=r(a,s,c.containers));var l=s.children.indexOf(a),u=em(s.children,function(p){return!a.labelTarget&&p.labelTarget?!1:c.level<o(p).level});return u!==-1&&l!==-1&&l<u&&(u-=1),{index:u,parent:s}}}rh.$inject=["eventBus","canvas"],Ne(rh,eu);const BO={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",rh]};function Hs(){}Hs.prototype.get=function(){return this._data},Hs.prototype.set=function(e){this._data=e},Hs.prototype.clear=function(){var e=this._data;return delete this._data,e},Hs.prototype.isEmpty=function(){return!this._data};const NO={clipboard:["type",Hs]};var $x=1500;function Fx(e,t,n){var i=this,o=n.get("dragging",!1);function r(a){if(!a.hover){var s=a.originalEvent,c=i._findTargetGfx(s),l=c&&e.get(c);c&&l&&(a.stopPropagation(),o.hover({element:l,gfx:c}),o.move(s))}}o&&t.on("drag.start",function(a){t.once("drag.move",$x,function(s){r(s)})}),(function(){var a,s;t.on("element.hover",function(c){a=c.gfx,s=c.element}),t.on("element.hover",$x,function(c){s&&t.fire("element.out",{element:s,gfx:a})}),t.on("element.out",function(){a=null,s=null})})(),this._findTargetGfx=function(a){var s,c;if(a instanceof MouseEvent)return s=Fr(a),c=document.elementFromPoint(s.x,s.y),$O(c)}}Fx.$inject=["elementRegistry","eventBus","injector"];function $O(e){return Lr(e,"svg, .djs-element",!0)}const FO={__init__:["hoverFix"],hoverFix:["type",Fx]};function jO(e){return!0}function tu(e){return tr(e)||Wk(e)}var jx=500;function Hx(e,t,n){var i=this;function o(P,k,H){if(!s(P,k)){var F,G,ee;H?G=t.getGraphics(H):(F=k.delegateTarget||k.target,F&&(G=F,H=t.get(G))),!(!G||!H)&&(ee=e.fire(P,{element:H,gfx:G,originalEvent:k}),ee===!1&&(k.stopPropagation(),k.preventDefault()))}}var r={};function a(P){return r[P]}function s(P,k){var H=l[P]||tr;return!H(k)}var c={click:"element.click",contextmenu:"element.contextmenu",dblclick:"element.dblclick",mousedown:"element.mousedown",mousemove:"element.mousemove",mouseover:"element.hover",mouseout:"element.out",mouseup:"element.mouseup"},l={"element.contextmenu":jO,"element.mousedown":tu,"element.mouseup":tu,"element.click":tu,"element.dblclick":tu};function u(P,k,H){var F=c[P];if(!F)throw new Error("unmapped DOM event name <"+P+">");return o(F,k,H)}var p="svg, .djs-element";function f(P,k,H,F){var G=r[H]=function(ee){o(H,ee)};F&&(l[H]=F),G.$delegate=ii.bind(P,p,k,G)}function d(P,k,H){var F=a(H);F&&ii.unbind(P,k,F.$delegate)}function g(P){V(c,function(k,H){f(P,H,k)})}function h(P){V(c,function(k,H){d(P,H,k)})}e.on("canvas.destroy",function(P){h(P.svg)}),e.on("canvas.init",function(P){g(P.svg)}),e.on(["shape.added","connection.added"],function(P){var k=P.element,H=P.gfx;e.fire("interactionEvents.createHit",{element:k,gfx:H})}),e.on(["shape.changed","connection.changed"],jx,function(P){var k=P.element,H=P.gfx;e.fire("interactionEvents.updateHit",{element:k,gfx:H})}),e.on("interactionEvents.createHit",jx,function(P){var k=P.element,H=P.gfx;i.createDefaultHit(k,H)}),e.on("interactionEvents.updateHit",function(P){var k=P.element,H=P.gfx;i.updateDefaultHit(k,H)});var m=E("djs-hit djs-hit-stroke"),w=E("djs-hit djs-hit-click-stroke"),y=E("djs-hit djs-hit-all"),v=E("djs-hit djs-hit-no-move"),x={all:y,"click-stroke":w,stroke:m,"no-move":v};function E(P,k){return k=Y({stroke:"white",strokeWidth:15},k||{}),n.cls(P,["no-fill","no-border"],k)}function A(P,k){var H=x[k];if(!H)throw new Error("invalid hit type <"+k+">");return Ie(P,H),P}function I(P,k){tt(P,k)}this.removeHits=function(P){var k=vs(".djs-hit",P);V(k,sn)},this.createDefaultHit=function(P,k){var H=P.waypoints,F=P.isFrame,G;return H?this.createWaypointsHit(k,H):(G=F?"stroke":"all",this.createBoxHit(k,G,{width:P.width,height:P.height}))},this.createWaypointsHit=function(P,k){var H=_s(k);return A(H,"stroke"),I(P,H),H},this.createBoxHit=function(P,k,H){H=Y({x:0,y:0},H);var F=He("rect");return A(F,k),Ie(F,H),I(P,F),F},this.updateDefaultHit=function(P,k){var H=Ct(".djs-hit",k);if(H)return P.waypoints?Wf(H,P.waypoints):Ie(H,{width:P.width,height:P.height}),H},this.fire=o,this.triggerMouseEvent=u,this.mouseHandler=a,this.registerEvent=f,this.unregisterEvent=d}Hx.$inject=["eventBus","elementRegistry","styles"];const nu={__init__:["interactionEvents"],interactionEvents:["type",Hx]};function Ia(e,t){this._eventBus=e,this._canvas=t,this._selectedElements=new Set;var n=this;e.on(["shape.remove","connection.remove"],function(i){var o=i.element;n.deselect(o)}),e.on(["diagram.clear","root.set"],function(i){n.select(null)})}Ia.$inject=["eventBus","canvas"],Ia.prototype.deselect=function(e){if(this._selectedElements.has(e)){var t=this.get();this._selectedElements.delete(e),this._eventBus.fire("selection.changed",{oldSelection:t,newSelection:this.get()})}},Ia.prototype.get=function(){return Array.from(this._selectedElements)},Ia.prototype.isSelected=function(e){return this._selectedElements.has(e)},Ia.prototype.select=function(e,t){var n=this.get();Ze(e)||(e=e?[e]:[]);var i=this._canvas,o=i.getRootElement();e=e.filter(function(r){var a=i.findRoot(r);return o===a}),t?V(e,r=>{this._selectedElements.add(r)}):this._selectedElements=new Set(e),this._eventBus.fire("selection.changed",{oldSelection:n,newSelection:this.get()})};var zx="hover",Gx="selected";function Vx(e,t){this._canvas=e;function n(o,r){e.addMarker(o,r)}function i(o,r){e.removeMarker(o,r)}t.on("element.hover",function(o){n(o.element,zx)}),t.on("element.out",function(o){i(o.element,zx)}),t.on("selection.changed",function(o){function r(l){i(l,Gx)}function a(l){n(l,Gx)}var s=new Set(o.oldSelection),c=new Set(o.newSelection);for(let l of s)c.has(l)||r(l);for(let l of c)s.has(l)||a(l)})}Vx.$inject=["canvas","eventBus"];function Wx(e,t,n,i){e.on("create.end",500,function(o){var r=o.context,a=r.canExecute,s=r.elements,c=r.hints||{},l=c.autoSelect;if(a){if(l===!1)return;Ze(l)?t.select(l):t.select(s.filter(HO))}}),e.on("connect.end",500,function(o){var r=o.context,a=r.connection;a&&t.select(a)}),e.on("shape.move.end",500,function(o){var r=o.previousSelection||[],a=i.get(o.context.shape.id),s=It(r,function(c){return a.id===c.id});s||t.select(a)}),e.on("element.click",function(o){if(tr(o)){var r=o.element;r===n.getRootElement()&&(r=null);var a=t.isSelected(r),s=t.get().length>1,c=Kl(o);if(a&&s)return c?t.deselect(r):t.select(r);a?t.deselect(r):t.select(r,c)}})}Wx.$inject=["eventBus","selection","canvas","elementRegistry"];function HO(e){return!e.hidden}const Mi={__init__:["selectionVisuals","selectionBehavior"],__depends__:[nu],selection:["type",Ia],selectionVisuals:["type",Vx],selectionBehavior:["type",Wx]};var zO=/^djs-cursor-.*$/;function iu(e){var t=At(document.body);t.removeMatching(zO),e&&t.add("djs-cursor-"+e)}function Ux(){iu(null)}var GO=5e3;function qx(e,t){t=t||"element.click";function n(){return!1}return e.once(t,GO,n),function(){e.off(t,n)}}var VO=["c","C"],WO=["v","V"],UO=["d","D"],qO=["x","X"],YO=["y","Y"],Yx=["z","Z"];function KO(e){return e.ctrlKey||e.metaKey||e.shiftKey||e.altKey}function ai(e){return e.altKey?!1:e.ctrlKey||e.metaKey}function vn(e,t){return e=Ze(e)?e:[e],e.indexOf(t.key)!==-1||e.indexOf(t.code)!==-1}function ah(e){return e.shiftKey}function XO(e){return ai(e)&&vn(VO,e)}function ZO(e){return ai(e)&&vn(WO,e)}function QO(e){return ai(e)&&vn(UO,e)}function JO(e){return ai(e)&&vn(qO,e)}function eD(e){return ai(e)&&!ah(e)&&vn(Yx,e)}function tD(e){return ai(e)&&(vn(YO,e)||vn(Yx,e)&&ah(e))}var Ba=Math.round,Kx="djs-drag-active";function Hr(e){e.preventDefault()}function nD(e){return typeof TouchEvent<"u"&&e instanceof TouchEvent}function iD(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Xx(e,t,n,i){var o={threshold:5,trapClick:!0},r;function a(v){var x=t.viewbox(),E=t._container.getBoundingClientRect();return{x:x.x+(v.x-E.left)/x.scale,y:x.y+(v.y-E.top)/x.scale}}function s(v,x){x=x||r;var E=e.createEvent(Y({},x.payload,x.data,{isTouch:x.isTouch}));return e.fire("drag."+v,E)===!1?!1:e.fire(x.prefix+"."+v,E)}function c(v){var x=v.filter(function(E){return i.get(E.id)});x.length&&n.select(x)}function l(v,x){var E=r.payload,A=r.displacement,I=r.globalStart,P=Fr(v),k=Gi(P,I),H=r.localStart,F=a(P),G=Gi(F,H);if(!r.active&&(x||iD(k)>r.threshold)){if(Y(E,{x:Ba(H.x+A.x),y:Ba(H.y+A.y),dx:0,dy:0},{originalEvent:v}),s("start")===!1)return m();r.active=!0,r.keepSelection||(E.previousSelection=n.get(),n.select(null)),r.cursor&&iu(r.cursor),t.addMarker(t.getRootElement(),Kx)}Fd(v),r.active&&(Y(E,{x:Ba(F.x+A.x),y:Ba(F.y+A.y),dx:Ba(G.x),dy:Ba(G.y)},{originalEvent:v}),s("move"))}function u(v){var x,E=!0;r.active&&(v&&(r.payload.originalEvent=v,Fd(v)),E=s("end")),E===!1&&s("rejected"),x=w(E!==!0),s("ended",x)}function p(v){vn("Escape",v)&&(Hr(v),m())}function f(v){var x;r.active&&(x=qx(e),setTimeout(x,400),Hr(v)),u(v)}function d(v){l(v)}function g(v){var x=r.payload;x.hoverGfx=v.gfx,x.hover=v.element,s("hover")}function h(v){s("out");var x=r.payload;x.hoverGfx=null,x.hover=null}function m(v){var x;if(r){var E=r.active;E&&s("cancel"),x=w(v),E&&s("canceled",x)}}function w(v){var x,E;s("cleanup"),Ux(),r.trapClick?E=f:E=u,Ve.unbind(document,"mousemove",l),Ve.unbind(document,"dragstart",Hr),Ve.unbind(document,"selectstart",Hr),Ve.unbind(document,"mousedown",E,!0),Ve.unbind(document,"mouseup",E,!0),Ve.unbind(document,"keyup",p),Ve.unbind(document,"touchstart",d,!0),Ve.unbind(document,"touchcancel",m,!0),Ve.unbind(document,"touchmove",l,!0),Ve.unbind(document,"touchend",u,!0),e.off("element.hover",g),e.off("element.out",h),t.removeMarker(t.getRootElement(),Kx);var A=r.payload.previousSelection;return v!==!1&&A&&!n.get().length&&c(A),x=r,r=null,x}function y(v,x,E,A){r&&m(!1),typeof x=="string"&&(A=E,E=x,x=null),A=Y({},o,A||{});var I=A.data||{},P,k,H,F,G;if(A.trapClick?F=f:F=u,v?(P=Da(v)||v,k=Fr(v),Fd(v),P.type==="dragstart"&&Hr(P)):(P=null,k={x:0,y:0}),H=a(k),x||(x=H),G=nD(P),r=Y({prefix:E,data:I,payload:{},globalStart:k,displacement:Gi(x,H),localStart:H,isTouch:G},A),A.manual||(G?(Ve.bind(document,"touchstart",d,!0),Ve.bind(document,"touchcancel",m,!0),Ve.bind(document,"touchmove",l,!0),Ve.bind(document,"touchend",u,!0)):(Ve.bind(document,"mousemove",l),Ve.bind(document,"dragstart",Hr),Ve.bind(document,"selectstart",Hr),Ve.bind(document,"mousedown",F,!0),Ve.bind(document,"mouseup",F,!0)),Ve.bind(document,"keyup",p),e.on("element.hover",g),e.on("element.out",h)),s("init")===!1)return m(),!1;A.autoActivate&&l(v,!0)}e.on("diagram.destroy",m),this.init=y,this.move=l,this.hover=g,this.out=h,this.end=u,this.cancel=m,this.context=function(){return r},this.setOptions=function(v){Y(o,v)}}Xx.$inject=["eventBus","canvas","selection","elementRegistry"];const So={__depends__:[FO,Mi],dragging:["type",Xx]};function zr(e){this._counter=0,this._prefix=(e?e+"-":"")+Math.floor(Math.random()*1e9)+"-"}zr.prototype.next=function(){return this._prefix+ ++this._counter};const oD=new zr("ps");var rD=["marker-start","marker-mid","marker-end"],aD=["circle","ellipse","line","path","polygon","polyline","path","rect"];function nr(e,t,n,i){this._elementRegistry=e,this._canvas=n,this._styles=i}nr.$inject=["elementRegistry","eventBus","canvas","styles"],nr.prototype.cleanUp=function(){console.warn("PreviewSupport#cleanUp is deprecated and will be removed in future versions. You do not need to manually clean up previews anymore. cf. https://github.com/bpmn-io/diagram-js/pull/906")},nr.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)},nr.prototype.addDragger=function(e,t,n,i="djs-dragger"){n=n||this.getGfx(e);var o=Nf(n);return this._cloneMarkers(Ko(o),i),Ie(o,this._styles.cls(i,[])),tt(t,o),Ie(o,"data-preview-support-element-id",e.id),o},nr.prototype.addFrame=function(e,t){var n=He("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return tt(t,n),Ie(n,"data-preview-support-element-id",e.id),n},nr.prototype._cloneMarkers=function(e,t="djs-dragger",n=e){var i=this;e.childNodes&&e.childNodes.forEach(o=>{i._cloneMarkers(o,t,n)}),uD(e)&&rD.forEach(function(o){if(Ie(e,o)){var r=sD(e,o,i._canvas.getContainer());r&&i._cloneMarker(n,e,r,o,t)}})},nr.prototype._cloneMarker=function(e,t,n,i,o="djs-dragger"){var r=[n.id,o,oD.next()].join("-"),a=Ct("marker#"+n.id,e);e=e||this._canvas._svg;var s=a||Nf(n);s.id=r,dt(s).add(o);var c=Ct(":scope > defs",e);c||(c=He("defs"),tt(e,c)),tt(c,s);var l=lD(s.id);Ie(t,i,l)};function sD(e,t,n){var i=cD(Ie(e,t));return Ct("marker#"+i,n||document)}function cD(e){return e.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]}function lD(e){return"url(#"+e+")"}function uD(e){return aD.indexOf(e.nodeName)!==-1}const Na={__init__:["previewSupport"],previewSupport:["type",nr]};var pD="drop-ok",Zx="drop-not-ok",Qx="attach-ok",Jx="new-parent",ew="create",fD=2e3;function tw(e,t,n,i,o){function r(c,l,u,p,f){if(!l)return!1;c=ct(c,function(y){var v=y.labelTarget;return!y.parent&&!(at(y)&&c.indexOf(v)!==-1)});var d=It(c,function(y){return!Ot(y)}),g=!1,h=!1,m=!1;iw(c)&&(g=o.allowed("shape.attach",{position:u,shape:d,target:l})),g||(iw(c)?m=o.allowed("shape.create",{position:u,shape:d,source:p,target:l}):m=o.allowed("elements.create",{elements:c,position:u,target:l}));var w=f.connectionTarget;return m||g?(d&&p&&(h=o.allowed("connection.create",{source:w===p?d:p,target:w===p?p:d,hints:{targetParent:l,targetAttach:g}})),{attach:g,connect:h}):m===null||g===null?null:!1}function a(c,l){[Qx,pD,Zx,Jx].forEach(function(u){u===l?e.addMarker(c,u):e.removeMarker(c,u)})}n.on(["create.move","create.hover"],function(c){var l=c.context,u=l.elements,p=c.hover,f=l.source,d=l.hints||{};if(!p){l.canExecute=!1,l.target=null;return}nw(c);var g={x:c.x,y:c.y},h=l.canExecute=p&&r(u,p,g,f,d);p&&h!==null&&(l.target=p,h&&h.attach?a(p,Qx):a(p,h?Jx:Zx))}),n.on(["create.end","create.out","create.cleanup"],function(c){var l=c.hover;l&&a(l,null)}),n.on("create.end",function(c){var l=c.context,u=l.source,p=l.shape,f=l.elements,d=l.target,g=l.canExecute,h=g&&g.attach,m=g&&g.connect,w=l.hints||{};if(g===!1||!d)return!1;nw(c);var y={x:c.x,y:c.y};m?p=i.appendShape(u,p,y,d,{attach:h,connection:m===!0?{}:m,connectionTarget:w.connectionTarget}):(f=i.createElements(f,y,d,Y({},w,{attach:h})),p=It(f,function(v){return!Ot(v)})),Y(l,{elements:f,shape:p}),Y(c,{elements:f,shape:p})});function s(){var c=t.context();c&&c.prefix===ew&&t.cancel()}n.on("create.init",function(){n.on("elements.changed",s),n.once(["create.cancel","create.end"],fD,function(){n.off("elements.changed",s)})}),this.start=function(c,l,u){Ze(l)||(l=[l]);var p=It(l,function(g){return!Ot(g)});if(p){u=Y({elements:l,hints:{},shape:p},u||{}),V(l,function(g){Qe(g.x)||(g.x=0),Qe(g.y)||(g.y=0)});var f=ct(l,function(g){return!g.hidden}),d=cn(f);V(l,function(g){Ot(g)&&(g.waypoints=Fn(g.waypoints,function(h){return{x:h.x-d.x-d.width/2,y:h.y-d.y-d.height/2}})),Y(g,{x:g.x-d.x-d.width/2,y:g.y-d.y-d.height/2})}),t.init(c,ew,{cursor:"grabbing",autoActivate:!0,data:{shape:p,elements:l,context:u}})}}}tw.$inject=["canvas","dragging","eventBus","modeling","rules"];function nw(e){var t=e.context,n=t.createConstraints;n&&(n.left&&(e.x=Math.max(e.x,n.left)),n.right&&(e.x=Math.min(e.x,n.right)),n.top&&(e.y=Math.max(e.y,n.top)),n.bottom&&(e.y=Math.min(e.y,n.bottom)))}function iw(e){return e&&e.length===1&&!Ot(e[0])}var dD=750;function ow(e,t,n,i,o){function r(a){var s=He("g");Ie(s,o.cls("djs-drag-group",["no-events"]));var c=He("g");return a.forEach(function(l){var u;l.hidden||(l.waypoints?(u=n._createContainer("connection",c),n.drawConnection(Ko(u),l)):(u=n._createContainer("shape",c),n.drawShape(Ko(u),l),Dn(u,l.x,l.y)),i.addDragger(l,s,u))}),s}t.on("create.move",dD,function(a){var s=a.hover,c=a.context,l=c.elements,u=c.dragGroup;u||(u=c.dragGroup=r(l));var p;s?(u.parentNode||(p=e.getActiveLayer(),tt(p,u)),Dn(u,a.x,a.y)):sn(u)}),t.on("create.cleanup",function(a){var s=a.context,c=s.dragGroup;c&&sn(c)})}ow.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];const ou={__depends__:[So,Na,io,Mi],__init__:["create","createPreview"],create:["type",tw],createPreview:["type",ow]};function sh(e){var t=this;this._lastMoveEvent=null;function n(i){t._lastMoveEvent=i}e.on("canvas.init",function(i){var o=t._svg=i.svg;o.addEventListener("mousemove",n)}),e.on("canvas.destroy",function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)})}sh.$inject=["eventBus"],sh.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||hD(0,0)};function hD(e,t){var n=document.createEvent("MouseEvent"),i=e,o=t,r=e,a=t;return n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,i,o,r,a,!1,!1,!1,!1,0,null),n}const zs={__init__:["mouse"],mouse:["type",sh]};var rw=2e3;function si(e,t,n,i,o,r,a,s){this._canvas=e,this._create=t,this._elementFactory=i,this._eventBus=o,this._modeling=r,this._mouse=a,this._rules=s,o.on("copyPaste.copyElement",function(c){var l=c.descriptor,u=c.element,p=c.elementsSet;l.priority=1,l.id=u.id,p.has(u.parent)&&(l.parent=u.parent.id),gD(u)&&(l.priority=2,l.host=u.host.id),Ot(u)&&(l.priority=3,l.source=u.source.id,l.target=u.target.id,l.waypoints=mD(u)),at(u)&&(l.priority=4,l.labelTarget=u.labelTarget.id),V(["x","y","width","height"],function(f){Qe(u[f])&&(l[f]=u[f])}),l.hidden=u.hidden,l.collapsed=u.collapsed}),o.on("copyPaste.elementsCopied",rw,function(c){var l;((l=c.hints)==null?void 0:l.clip)!==!1&&n.set(c.tree)}),o.on("copyPaste.pasteElements",rw,function(c){c.tree||(c.tree=n.get())}),o.on("copyPaste.pasteElements",function(c){var l=c.hints;Y(l,{createElementsBehavior:!1})})}si.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"],si.prototype.copy=function(e,t={}){var n,i;return Ze(e)||(e=e?[e]:[]),n=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}),n===!1?i={}:i=this.createTree(Ze(n)?n:e),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:i,hints:t}),i},si.prototype.paste=function(e={}){var t=this._eventBus.createEvent({type:"copyPaste.pasteElements",hints:{},...e}),n=this._eventBus.fire(t);if(n!==!1){var i=t.tree;if(i){var o=t.hints,r=this._createElements(i);if(t.element&&t.point)return this._paste(r,t.element,t.point,o);this._create.start(this._mouse.getLastMoveEvent(),r,{hints:o})}}},si.prototype.duplicate=function(e,t={}){var n=this.copy(e,{clip:!1});return this.paste({...t,tree:n})},si.prototype.cut=function(e){var t=this.copy(e),n=this._getElementIdsFromTree(t),i=e.filter(function(o){return n[o.id]});return i.length>0&&this._modeling.removeElements(i),t},si.prototype._getElementIdsFromTree=function(e){var t={};return V(e,function(n){V(n,function(i){i.id&&(t[i.id]=!0)})}),t},si.prototype._paste=function(e,t,n,i){V(e,function(r){Qe(r.x)||(r.x=0),Qe(r.y)||(r.y=0)});var o=cn(e);return V(e,function(r){Ot(r)&&(r.waypoints=Fn(r.waypoints,function(a){return{x:a.x-o.x-o.width/2,y:a.y-o.y-o.height/2}})),Y(r,{x:r.x-o.x-o.width/2,y:r.y-o.y-o.height/2})}),this._modeling.createElements(e,n,t,Y({},i))},si.prototype._createElements=function(e){var t=this,n=this._eventBus,i={},o=[];return V(e,function(r,a){r=qi(r,"priority"),V(r,function(s){var c=Y({},Yi(s,["priority"]));i[s.parent]?c.parent=i[s.parent]:delete c.parent,n.fire("copyPaste.pasteElement",{cache:i,descriptor:c});var l;if(Ot(c)){c.source=i[s.source],c.target=i[s.target],l=i[s.id]=t.createConnection(c),o.push(l);return}if(at(c)){c.labelTarget=i[c.labelTarget],l=i[s.id]=t.createLabel(c),o.push(l);return}c.host&&(c.host=i[c.host]),l=i[s.id]=t.createShape(c),o.push(l)})}),o},si.prototype.createConnection=function(e){var t=this._elementFactory.createConnection(Yi(e,["id"]));return t},si.prototype.createLabel=function(e){var t=this._elementFactory.createLabel(Yi(e,["id"]));return t},si.prototype.createShape=function(e){var t=this._elementFactory.createShape(Yi(e,["id"]));return t},si.prototype.hasRelations=function(e,t,n){return n||(n=new Set(t)),!(Ot(e)&&(!n.has(e.source)||!n.has(e.target))||at(e)&&!n.has(e.labelTarget))},si.prototype.createTree=function(e){var t=this._rules,n=this,i={},o=[],r=new Map,a=ml(e);function s(p,f){return t.allowed("element.copy",{element:p,elements:f})}function c(p,f){var d=r.get(p);if(!d){var g={element:p,depth:f};o.push(g),r.set(p,g);return}if(d.depth<f){o=l(d,o);var h={element:d.element,depth:f};o.push(h),r.set(p,h)}}function l(p,f){var d=f.indexOf(p);return d!==-1&&f.splice(d,1),f}Br(a,function(p,f,d){if(at(p))return;V(p.labels,function(m){c(m,d)});function g(m){m&&m.length&&V(m,function(w){V(w.labels,function(y){c(y,d)}),c(w,d)})}V([p.attachers,p.incoming,p.outgoing],g),c(p,d);var h=[];return p.children&&(h=p.children.slice()),n._eventBus.fire("copyPaste.createTree",{element:p,children:h}),h}),e=Fn(o,function(p){return p.element});var u=new Set(e);return o=Fn(o,function(p){return p.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:p.descriptor,element:p.element,elements:e,elementsSet:u}),p}),o=qi(o,function(p){return p.descriptor.priority}),e=Fn(o,function(p){return p.element}),V(o,function(p){var f=p.depth;if(!n.hasRelations(p.element,e,u)){sw(p.element,e),u.delete(p.element);return}if(!s(p.element,e)){sw(p.element,e),u.delete(p.element);return}i[f]||(i[f]=[]),i[f].push(p.descriptor)}),i};function gD(e){return!!e.host}function mD(e){return Fn(e.waypoints,function(t){return t=aw(t),t.original&&(t.original=aw(t.original)),t})}function aw(e){return Y({},e)}function sw(e,t){var n=t.indexOf(e);return n===-1?t:t.splice(n,1)}const yD={__depends__:[NO,ou,zs,io],__init__:["copyPaste"],copyPaste:["type",si]};function ch(e,t,n){Ze(n)||(n=[n]),V(n,function(i){Cr(e[i])||(t[i]=e[i])})}var lh=750;function cw(e,t,n){function i(c,l){var u=e.create(c.$type);return n.copyElement(c,u,null,l)}t.on("copyPaste.copyElement",lh,function(c){var l=c.descriptor,u=c.element,p=_e(u);if(at(u))return l;var f=l.businessObject=i(p,!0),d=l.di=i(mt(u),!0);d.bpmnElement=f,ch(f,l,"name"),ch(d,l,"isExpanded"),p.default&&(l.default=p.default.id)});var o="-bpmn-js-refs";function r(c){return c[o]=c[o]||{}}function a(c,l){c[o]=l}function s(c,l,u){var p=_e(c);return c.default&&(u[c.default]={element:p,property:"default"}),c.host&&(_e(c).attachedToRef=_e(l[c.host])),Yi(u,ni(u,function(f,d,g){var h=d.element,m=d.property;return g===c.id&&(h.set(m,p),f.push(c.id)),f},[]))}t.on("copyPaste.pasteElement",function(c){var l=c.cache,u=c.descriptor,p=u.businessObject,f=u.di;if(at(u)){u.businessObject=_e(l[u.labelTarget]),u.di=mt(l[u.labelTarget]);return}p=u.businessObject=i(p),f=u.di=i(f),f.bpmnElement=p,ch(u,p,["isExpanded","name"]),u.type=p.$type}),t.on("copyPaste.copyElement",lh,function(c){var l=c.descriptor,u=c.element;if(M(u,"bpmn:Participant")){var p=_e(u);p.processRef&&(l.processRef=i(p.processRef,!0))}}),t.on("copyPaste.pasteElement",function(c){var l=c.descriptor,u=l.processRef;u&&(l.processRef=i(u))}),t.on("copyPaste.createTree",function(c){var l=c.element,u=c.children;M(l,"bpmn:SubProcess")&&V(Ps(u),p=>{u.push(p.annotation)})}),t.on("copyPaste.pasteElement",lh,function(c){var l=c.cache,u=c.descriptor;a(l,s(u,l,r(l)))})}cw.$inject=["bpmnFactory","eventBus","moddleCopy"];const vD=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"],bD=["errorRef","escalationRef","messageRef","signalRef","dataObjectRef"];function Gs(e,t,n){this._bpmnFactory=t,this._eventBus=e,this._moddle=n,e.on("moddleCopy.canCopyProperties",i=>{const{propertyNames:o}=i;if(!(!o||!o.length))return qi(o,r=>r==="extensionElements")}),e.on("moddleCopy.canCopyProperty",i=>{const{parent:o,property:r,propertyName:a}=i,s=mn(o)&&o.$descriptor;if(a&&bD.includes(a))return r;if(a&&vD.includes(a)||a&&s&&!It(s.properties,ca({name:a})))return!1}),e.on("moddleCopy.canSetCopiedProperty",i=>{const{property:o}=i;if(M(o,"bpmn:ExtensionElements")&&(!o.values||!o.values.length))return!1})}Gs.$inject=["eventBus","bpmnFactory","moddle"],Gs.prototype.copyElement=function(e,t,n,i=!1){n&&!Ze(n)&&(n=[n]),n=n||uh(e.$descriptor);const o=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:i});return o===!1||(Ze(o)&&(n=o),V(n,r=>{let a;ti(e,r)&&(a=e.get(r));const s=this.copyProperty(a,t,r,i);!gn(s)||this._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:s,propertyName:r})===!1||t.set(r,s)})),t},Gs.prototype.copyProperty=function(e,t,n,i=!1){let o=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n,clone:i});if(o===!1)return;if(o)return mn(o)&&o.$type&&!o.$parent&&(o.$parent=t),o;const r=this._moddle.getPropertyDescriptor(t,n);if(!r.isReference)return r.isId?e&&this._copyId(e,t,i):Ze(e)?ni(e,(a,s)=>{const c=this.copyProperty(s,t,n,i);return c?a.concat(c):a},[]):mn(e)&&e.$type?this._moddle.getElementDescriptor(e).isGeneric?void 0:(o=this._bpmnFactory.create(e.$type),o.$parent=t,o=this.copyElement(e,o,null,i),o):e},Gs.prototype._copyId=function(e,t,n=!1){if(n)return e;if(!this._moddle.ids.assigned(e))return this._moddle.ids.claim(e,t),e};function uh(e,t){return ni(e.properties,(n,i)=>t&&i.default?n:n.concat(i.name),[])}const lw={__depends__:[yD],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",cw],moddleCopy:["type",Gs]};var uw=Math.round;function ph(e,t){this._modeling=e,this._eventBus=t}ph.$inject=["modeling","eventBus"],ph.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var i=this._modeling,o=this._eventBus;o.fire("replace.start",{element:e,attrs:t,hints:n});var r=t.width||e.width,a=t.height||e.height,s=t.x||e.x,c=t.y||e.y,l=uw(s+r/2),u=uw(c+a/2),p=i.replaceShape(e,Y({},t,{x:l,y:u,width:r,height:a}),n);return o.fire("replace.end",{element:e,newElement:p,hints:n}),p};function pw(e,t){t.on("replace.end",500,function(n){const{newElement:i,hints:o={}}=n;o.select!==!1&&e.select(i)})}pw.$inject=["selection","eventBus"];const xD={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",pw],replace:["type",ph]};function wD(e,t,n){Ze(n)||(n=[n]),V(n,function(i){Cr(e[i])||(t[i]=e[i])})}var _D=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function ED(e,t){var n=e&&ti(e,"collapsed")?e.collapsed:!ht(e),i;return t&&(ti(t,"collapsed")||ti(t,"isExpanded"))?i=ti(t,"collapsed")?t.collapsed:!t.isExpanded:i=n,n!==i}function fw(e,t,n,i,o,r){function a(s,c,l){l=l||{};var u=c.type,p=s.businessObject;if(ru(p)&&(u==="bpmn:SubProcess"||u==="bpmn:AdHocSubProcess")&&ED(s,c))return i.toggleCollapse(s),s;var f=e.create(u),d={type:u,businessObject:f};d.di={},u==="bpmn:ExclusiveGateway"&&(d.di.isMarkerVisible=!0),wD(s.di,d.di,["fill","stroke","background-color","border-color","color"]);var g=uh(p.$descriptor),h=uh(f.$descriptor,!0),m=SD(g,h);Y(f,Ni(c,_D));var w=ct(m,function(x){return x==="eventDefinitions"?dw(s,c.eventDefinitionType):x==="loopCharacteristics"?!Gn(f):ti(f,x)||x==="processRef"&&c.isExpanded===!1||x==="triggeredByEvent"?!1:x==="isForCompensation"?!Gn(f):!0});if(f=n.copyElement(p,f,w),c.eventDefinitionType&&(dw(f,c.eventDefinitionType)||(d.eventDefinitionType=c.eventDefinitionType,d.eventDefinitionAttrs=c.eventDefinitionAttrs)),M(p,"bpmn:Activity")){if(ru(p))d.isExpanded=ht(s);else if(c&&ti(c,"isExpanded")){d.isExpanded=c.isExpanded;var y=t.getDefaultSize(f,{isExpanded:d.isExpanded});d.width=y.width,d.height=y.height,d.x=s.x-(d.width-s.width)/2,d.y=s.y-(d.height-s.height)/2}ht(s)&&!M(p,"bpmn:Task")&&d.isExpanded&&(d.width=s.width,d.height=s.height)}if(ru(p)&&!ru(f)&&(l.moveChildren=!1),M(p,"bpmn:Participant")){c.isExpanded===!0?f.processRef=e.create("bpmn:Process"):l.moveChildren=!1;var v=En(s);mt(s).isHorizontal||(mt(d).isHorizontal=v),d.width=v?s.width:t.getDefaultSize(d).width,d.height=v?t.getDefaultSize(d).height:s.height}return r.allowed("shape.resize",{shape:f})||(d.height=t.getDefaultSize(d).height,d.width=t.getDefaultSize(d).width),f.name=p.name,st(p,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&st(f,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(f.default=p.default),c.host&&!M(p,"bpmn:BoundaryEvent")&&M(f,"bpmn:BoundaryEvent")&&(d.host=c.host),(d.type==="bpmn:DataStoreReference"||d.type==="bpmn:DataObjectReference")&&(d.x=s.x+(s.width-d.width)/2),o.replaceElement(s,d,{...l,targetElement:c})}this.replaceElement=a}fw.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];function ru(e){return M(e,"bpmn:SubProcess")}function dw(e,t){var n=_e(e);return t&&n.get("eventDefinitions").some(function(i){return M(i,t)})}function SD(e,t){return e.filter(function(n){return t.includes(n)})}const hw={__depends__:[lw,xD,Mi],bpmnReplace:["type",fw]};var RD=250;function Gr(e){this._eventBus=e,this._tools=[],this._active=null}Gr.$inject=["eventBus"],Gr.prototype.registerTool=function(e,t){var n=this._tools;if(!t)throw new Error(`A tool has to be registered with it's "events"`);n.push(e),this.bindEvents(e,t)},Gr.prototype.isActive=function(e){return e&&this._active===e},Gr.prototype.length=function(e){return this._tools.length},Gr.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))},Gr.prototype.bindEvents=function(e,t){var n=this._eventBus,i=[];n.on(t.tool+".init",function(o){var r=o.context;if(!r.reactivate&&this.isActive(e)){this.setActive(null);return}this.setActive(e)},this),V(t,function(o){i.push(o+".ended"),i.push(o+".canceled")}),n.on(i,RD,function(o){this._active&&(CD(o)||this.setActive(null))},this)};function CD(e){var t=e.originalEvent&&e.originalEvent.target;return t&&Lr(t,'.group[data-group="tools"]')}const au={__depends__:[So],__init__:["toolManager"],toolManager:["type",Gr]};function MD(e,t){if(e==="x"){if(t>0)return"e";if(t<0)return"w"}if(e==="y"){if(t>0)return"s";if(t<0)return"n"}return null}function AD(e,t){var n=[],i=new Set(e);V(t,function(r){i.add(r)});var o=new Set;return i.forEach(function(r){var a=r.incoming,s=r.outgoing;V(a.concat(s),function(c){var l=c.source,u=c.target;(i.has(l)||i.has(u))&&(o.has(c)||(o.add(c),n.push(c)))})}),n}function PD(e,t,n){var i=e.x,o=e.y,r=e.width,a=e.height,s=n.x,c=n.y;switch(t){case"n":return{x:i,y:o+c,width:r,height:a-c};case"s":return{x:i,y:o,width:r,height:a+c};case"w":return{x:i+s,y:o,width:r-s,height:a};case"e":return{x:i,y:o,width:r+s,height:a};default:throw new Error("unknown direction: "+t)}}var fh=Math.abs,TD=Math.round,Ro={x:"width",y:"height"},gw="crosshair",ir={n:"top",w:"left",s:"bottom",e:"right"},kD=1500,su={n:"s",w:"e",s:"n",e:"w"},cu=20;function Ai(e,t,n,i,o,r,a){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=i,this._rules=o,this._toolManager=r,this._mouse=a;var s=this;r.registerTool("space",{tool:"spaceTool.selection",dragging:"spaceTool"}),n.on("spaceTool.selection.end",function(c){n.once("spaceTool.selection.ended",function(){s.activateMakeSpace(c.originalEvent)})}),n.on("spaceTool.move",kD,function(c){var l=c.context,u=l.initialized;u||(u=l.initialized=s.init(c,l)),u&&yw(c)}),n.on("spaceTool.end",function(c){var l=c.context,u=l.axis,p=l.direction,f=l.movingShapes,d=l.resizingShapes,g=l.start;if(l.initialized){yw(c);var h={x:0,y:0};h[u]=TD(c["d"+u]),s.makeSpace(f,d,h,p,g),n.once("spaceTool.ended",function(m){s.activateSelection(m.originalEvent,!0,!0)})}})}Ai.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"],Ai.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:gw,data:{context:{reactivate:n}},trapClick:!1})},Ai.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:gw,data:{context:{}}})},Ai.prototype.makeSpace=function(e,t,n,i,o){return this._modeling.createSpace(e,t,n,i,o)},Ai.prototype.init=function(e,t){var n=fh(e.dx)>fh(e.dy)?"x":"y",i=e["d"+n],o=e[n]-i;if(fh(i)<5)return!1;i<0&&(i*=-1),Fs(e)&&(i*=-1);var r=MD(n,i),a=this._canvas.getRootElement();!Kl(e)&&e.hover&&(a=e.hover);var s=[...Es(a),...a.attachers||[]],c=this.calculateAdjustments(s,n,i,o),l=this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:r,shapes:c.resizingShapes,start:o}),u=OD(c,n,r,o,l);return Y(t,c,{axis:n,direction:r,spaceToolConstraints:u,start:o}),iu("resize-"+(n==="x"?"ew":"ns")),!0},Ai.prototype.calculateAdjustments=function(e,t,n,i){var o=this._rules,r=[],a=[],s=new Set,c=new Set,l=[],u=[];function p(d){s.has(d)||(s.add(d),r.push(d));var g=d.label;g&&!s.has(g)&&(s.add(g),r.push(g))}function f(d){c.has(d)||(c.add(d),a.push(d))}return V(e,function(d){if(!(!d.parent||at(d))){if(Ot(d)){u.push(d);return}var g=d[t],h=g+d[Ro[t]];if(DD(d)&&(n>0&&Je(d)[t]>i||n<0&&Je(d)[t]<i)){l.push(d);return}if(n>0&&g>i||n<0&&h<i){p(d);return}if(g<i&&h>i&&o.allowed("shape.resize",{shape:d})){f(d);return}}}),V(r,function(d){var g=d.attachers;g&&V(g,function(h){p(h)})}),V(l,function(d){var g=d.host;(s.has(g)||c.has(g))&&p(d)}),V(u,function(d){var g=d.source,h=d.target,m=d.label;(s.has(g)||c.has(g))&&(s.has(h)||c.has(h))&&m&&p(m)}),{movingShapes:r,resizingShapes:a}},Ai.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},Ai.prototype.isActive=function(){var e=this._dragging.context();return e?/^spaceTool/.test(e.prefix):!1};function mw(e){return{top:e.top-cu,right:e.right+cu,bottom:e.bottom+cu,left:e.left-cu}}function yw(e){var t=e.context,n=t.spaceToolConstraints;if(n){var i,o;Qe(n.left)&&(i=Math.max(e.x,n.left),e.dx=e.dx+i-e.x,e.x=i),Qe(n.right)&&(i=Math.min(e.x,n.right),e.dx=e.dx+i-e.x,e.x=i),Qe(n.top)&&(o=Math.max(e.y,n.top),e.dy=e.dy+o-e.y,e.y=o),Qe(n.bottom)&&(o=Math.min(e.y,n.bottom),e.dy=e.dy+o-e.y,e.y=o)}}function OD(e,t,n,i,o){var r=e.movingShapes,a=e.resizingShapes;if(a.length){var s={},c,l,u=new Set(r),p=new Set(a);return V(a,function(f){var d=f.attachers,g=f.children,h=qe(f),m=ct(g,function(G){return!Ot(G)&&!at(G)&&!u.has(G)&&!p.has(G)}),w=ct(g,function(G){return!Ot(G)&&!at(G)&&u.has(G)}),y,v,x,E=[],A=[],I,P,k,H;m.length&&(v=mw(qe(cn(m))),y=i-h[ir[n]]+v[ir[n]],n==="n"?s.bottom=l=Qe(l)?Math.min(l,y):y:n==="w"?s.right=l=Qe(l)?Math.min(l,y):y:n==="s"?s.top=c=Qe(c)?Math.max(c,y):y:n==="e"&&(s.left=c=Qe(c)?Math.max(c,y):y)),w.length&&(x=mw(qe(cn(w))),y=i-x[ir[su[n]]]+h[ir[su[n]]],n==="n"?s.bottom=l=Qe(l)?Math.min(l,y):y:n==="w"?s.right=l=Qe(l)?Math.min(l,y):y:n==="s"?s.top=c=Qe(c)?Math.max(c,y):y:n==="e"&&(s.left=c=Qe(c)?Math.max(c,y):y)),d&&d.length&&(d.forEach(function(G){u.has(G)?E.push(G):A.push(G)}),E.length&&(I=qe(cn(E.map(Je))),P=h[ir[su[n]]]-(I[ir[su[n]]]-i)),A.length&&(k=qe(cn(A.map(Je))),H=k[ir[n]]-(h[ir[n]]-i)),n==="n"?(y=Math.min(P||1/0,H||1/0),s.bottom=l=Qe(l)?Math.min(l,y):y):n==="w"?(y=Math.min(P||1/0,H||1/0),s.right=l=Qe(l)?Math.min(l,y):y):n==="s"?(y=Math.max(P||-1/0,H||-1/0),s.top=c=Qe(c)?Math.max(c,y):y):n==="e"&&(y=Math.max(P||-1/0,H||-1/0),s.left=c=Qe(c)?Math.max(c,y):y));var F=o&&o[f.id];F&&(n==="n"?(y=i+f[Ro[t]]-F[Ro[t]],s.bottom=l=Qe(l)?Math.min(l,y):y):n==="w"?(y=i+f[Ro[t]]-F[Ro[t]],s.right=l=Qe(l)?Math.min(l,y):y):n==="s"?(y=i-f[Ro[t]]+F[Ro[t]],s.top=c=Qe(c)?Math.max(c,y):y):n==="e"&&(y=i-f[Ro[t]]+F[Ro[t]],s.left=c=Qe(c)?Math.max(c,y):y))}),s}}function DD(e){return!!e.host}var dh="djs-dragging",vw="djs-resizing",LD=250,lu=Math.max;function bw(e,t,n,i,o){function r(a,s){V(a,function(c){o.addDragger(c,s),n.addMarker(c,dh)})}e.on("spaceTool.selection.start",function(a){var s=n.getLayer("space"),c=a.context,l={x:"M 0,-10000 L 0,10000",y:"M -10000,0 L 10000,0"},u=He("g");Ie(u,i.cls("djs-crosshair-group",["no-events"])),tt(s,u);var p=He("path");Ie(p,"d",l.x),dt(p).add("djs-crosshair"),tt(u,p);var f=He("path");Ie(f,"d",l.y),dt(f).add("djs-crosshair"),tt(u,f),c.crosshairGroup=u}),e.on("spaceTool.selection.move",function(a){var s=a.context.crosshairGroup;Dn(s,a.x,a.y)}),e.on("spaceTool.selection.cleanup",function(a){var s=a.context,c=s.crosshairGroup;c&&sn(c)}),e.on("spaceTool.move",LD,function(a){var s=a.context,c=s.line,l=s.axis,u=s.movingShapes,p=s.resizingShapes;if(s.initialized){if(!s.dragGroup){var f=n.getLayer("space");c=He("path"),Ie(c,"d","M0,0 L0,0"),dt(c).add("djs-crosshair"),tt(f,c),s.line=c;var d=He("g");Ie(d,i.cls("djs-drag-group",["no-events"])),tt(n.getActiveLayer(),d),r(u,d);var g=new Set(u);V(p,function(A){g.add(A)});var h=new Set,m=s.movingConnections=[];g.forEach(function(A){V(A.outgoing,function(I){h.has(I)||!Ot(I)||!g.has(I.target)||(h.add(I),m.push(I))})}),r(m,d),s.dragGroup=d}if(!s.frameGroup){var w=He("g");Ie(w,i.cls("djs-frame-group",["no-events"])),tt(n.getActiveLayer(),w);var y=[];V(p,function(A){var I=o.addFrame(A,w),P=I.getBBox();y.push({element:I,initialBounds:P}),n.addMarker(A,vw)}),s.frameGroup=w,s.frames=y}var v={x:"M"+a.x+", -10000 L"+a.x+", 10000",y:"M -10000, "+a.y+" L 10000, "+a.y};Ie(c,{d:v[l]});var x={x:"y",y:"x"},E={x:a.dx,y:a.dy};E[x[s.axis]]=0,Dn(s.dragGroup,E.x,E.y),V(s.frames,function(A){var I=A.element,P=A.initialBounds,k,H;s.direction==="e"?Ie(I,{width:lu(P.width+E.x,5)}):(k=lu(P.width-E.x,5),Ie(I,{width:k,x:P.x+P.width-k})),s.direction==="s"?Ie(I,{height:lu(P.height+E.y,5)}):(H=lu(P.height-E.y,5),Ie(I,{height:H,y:P.y+P.height-H}))})}}),e.on("spaceTool.cleanup",function(a){var s=a.context,c=s.movingShapes,l=s.movingConnections,u=s.resizingShapes,p=s.line,f=s.dragGroup,d=s.frameGroup;V(c,function(g){n.removeMarker(g,dh)}),V(l,function(g){n.removeMarker(g,dh)}),f&&(sn(p),sn(f)),V(u,function(g){n.removeMarker(g,vw)}),d&&sn(d)})}bw.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];const ID={__init__:["spaceToolPreview"],__depends__:[So,io,au,Na,zs],spaceTool:["type",Ai],spaceToolPreview:["type",bw]};function uu(e,t){e.invoke(Ai,this),this._canvas=t}uu.$inject=["injector","canvas"],Ne(uu,Ai),uu.prototype.calculateAdjustments=function(e,t,n,i){var o=this._canvas.getRootElement(),r=e[0]===o?null:e[0],a=[];r&&(a=aa(xa(o.children.filter(l=>M(l,"bpmn:Artifact")),cn(r))));const s=[...e,...a];var c=Ai.prototype.calculateAdjustments.call(this,s,t,n,i);return c.resizingShapes=c.resizingShapes.filter(function(l){return!(M(l,"bpmn:TextAnnotation")||BD(l)&&(t==="y"&&En(l)||t==="x"&&!En(l)))}),c};function BD(e){return M(e,"bpmn:Participant")&&!_e(e).processRef}const xw={__depends__:[ID],spaceTool:["type",uu]};function Ut(e,t){this._handlerMap={},this._stack=[],this._stackIdx=-1,this._currentExecution={actions:[],dirty:[],trigger:null},this._injector=t,this._eventBus=e,this._uid=1,e.on(["diagram.destroy","diagram.clear"],function(){this.clear(!1)},this)}Ut.$inject=["eventBus","injector"],Ut.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";const n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()},Ut.prototype.canExecute=function(e,t){const n={command:e,context:t},i=this._getHandler(e);let o=this._fire(e,"canExecute",n);if(o===void 0){if(!i)return!1;i.canExecute&&(o=i.canExecute(t))}return o},Ut.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,e!==!1&&this._fire("changed",{trigger:"clear"})},Ut.prototype.undo=function(){let e=this._getUndoAction(),t;if(e){for(this._currentExecution.trigger="undo",this._pushAction(e);e&&(this._internalUndo(e),t=this._getUndoAction(),!(!t||t.id!==e.id));)e=t;this._popAction()}},Ut.prototype.redo=function(){let e=this._getRedoAction(),t;if(e){for(this._currentExecution.trigger="redo",this._pushAction(e);e&&(this._internalExecute(e,!0),t=this._getRedoAction(),!(!t||t.id!==e.id));)e=t;this._popAction()}},Ut.prototype.register=function(e,t){this._setHandler(e,t)},Ut.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");const n=this._injector.instantiate(t);this.register(e,n)},Ut.prototype.canUndo=function(){return!!this._getUndoAction()},Ut.prototype.canRedo=function(){return!!this._getRedoAction()},Ut.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]},Ut.prototype._getUndoAction=function(){return this._stack[this._stackIdx]},Ut.prototype._internalUndo=function(e){const t=e.command,n=e.context,i=this._getHandler(t);this._atomicDo(()=>{this._fire(t,"revert",e),i.revert&&this._markDirty(i.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)})},Ut.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);const i=t?[e+"."+t,t]:[e];let o;n=this._eventBus.createEvent(n);for(const r of i)if(o=this._eventBus.fire("commandStack."+r,n),n.cancelBubble)break;return o},Ut.prototype._createId=function(){return this._uid++},Ut.prototype._atomicDo=function(e){const t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}},Ut.prototype._internalExecute=function(e,t){const n=e.command,i=e.context,o=this._getHandler(n);if(!o)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),o.preExecute&&o.preExecute(i),this._fire(n,"preExecuted",e)),this._atomicDo(()=>{this._fire(n,"execute",e),o.execute&&this._markDirty(o.execute(i)),this._executedAction(e,t),this._fire(n,"executed",e)}),t||(this._fire(n,"postExecute",e),o.postExecute&&o.postExecute(i),this._fire(n,"postExecuted",e)),this._popAction()},Ut.prototype._pushAction=function(e){const t=this._currentExecution,n=t.actions,i=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=i&&i.id||this._createId()),n.push(e)},Ut.prototype._popAction=function(){const e=this._currentExecution,t=e.trigger,n=e.actions,i=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:tm("id",i.reverse())}),i.length=0,this._fire("changed",{trigger:t}),e.trigger=null)},Ut.prototype._markDirty=function(e){const t=this._currentExecution;e&&(e=Ze(e)?e:[e],t.dirty=t.dirty.concat(e))},Ut.prototype._executedAction=function(e,t){const n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)},Ut.prototype._revertedAction=function(e){this._stackIdx--},Ut.prototype._getHandler=function(e){return this._handlerMap[e]},Ut.prototype._setHandler=function(e,t){if(!e||!t)throw new Error("command and handler required");if(this._handlerMap[e])throw new Error("overriding handler for command <"+e+">");this._handlerMap[e]=t};const ND={commandStack:["type",Ut]};function or(e,t){if(typeof t!="function")throw new Error("removeFn iterator must be a function");if(!e)return[];for(var n;n=e[0];)t(n);return e}var $D=250,ww=1400;function hh(e,t,n){we.call(this,t);var i=e.get("movePreview",!1);t.on("shape.move.start",ww,function(o){var r=o.context,a=r.shapes,s=r.validatedShapes;r.shapes=_w(a),r.validatedShapes=_w(s)}),i&&t.on("shape.move.start",$D,function(o){var r=o.context,a=new Set(r.shapes),s=new Set;for(const c of a)for(const l of c.labels)!l.hidden&&!a.has(l)&&s.add(l),c.labelTarget&&s.add(c);for(const c of s)i.makeDraggable(r,c,!0)}),this.preExecuted("elements.move",ww,function(o){var r=o.context,a=r.closure,s=a.enclosedElements,c=[];V(s,function(l){V(l.labels,function(u){s[u.id]||c.push(u)})}),a.addAll(c)}),this.preExecute(["connection.delete","shape.delete"],function(o){var r=o.context,a=r.connection||r.shape;or(a.labels,function(s){n.removeShape(s,{nested:!0})})}),this.execute("shape.delete",function(o){var r=o.context,a=r.shape,s=a.labelTarget;s&&(r.labelTargetIndex=qf(s.labels,a),r.labelTarget=s,a.labelTarget=null)}),this.revert("shape.delete",function(o){var r=o.context,a=r.shape,s=r.labelTarget,c=r.labelTargetIndex;s&&(on(s.labels,a,c),a.labelTarget=s)})}Ne(hh,we),hh.$inject=["injector","eventBus","modeling"];function _w(e){var t=new Set(e);return ct(e,function(n){return!t.has(n.labelTarget)})}const FD={__init__:["labelSupport"],labelSupport:["type",hh]};var jD=251,Ew=1401,Sw="attach-ok";function gh(e,t,n,i,o){we.call(this,t);var r=e.get("movePreview",!1);t.on("shape.move.start",Ew,function(a){var s=a.context,c=s.shapes,l=s.validatedShapes;s.shapes=HD(c),s.validatedShapes=zD(l)}),r&&t.on("shape.move.start",jD,function(a){var s=a.context,c=s.shapes,l=mh(c);V(l,function(u){r.makeDraggable(s,u,!0),V(u.labels,function(p){r.makeDraggable(s,p,!0)})})}),r&&t.on("shape.move.start",function(a){var s=a.context,c=s.shapes;if(c.length===1){var l=c[0],u=l.host;u&&(n.addMarker(u,Sw),t.once(["shape.move.out","shape.move.cleanup"],function(){n.removeMarker(u,Sw)}))}}),this.preExecuted("elements.move",Ew,function(a){var s=a.context,c=s.closure,l=s.shapes,u=mh(l);V(u,function(p){c.add(p,c.topLevel[p.host.id])})}),this.postExecuted("elements.move",function(a){var s=a.context,c=s.shapes,l=s.newHost,u;l&&c.length!==1||(l?u=c:u=ct(c,function(p){var f=p.host;return GD(p)&&!VD(c,f)}),V(u,function(p){o.updateAttachment(p,l)}))}),this.postExecuted("elements.move",function(a){var s=a.context.shapes;V(s,function(c){V(c.attachers,function(l){V(l.outgoing.slice(),function(u){var p=i.allowed("connection.reconnect",{connection:u,source:u.source,target:u.target});p||o.removeConnection(u)}),V(l.incoming.slice(),function(u){var p=i.allowed("connection.reconnect",{connection:u,source:u.source,target:u.target});p||o.removeConnection(u)})})})}),this.postExecute("shape.create",function(a){var s=a.context,c=s.shape,l=s.host;l&&o.updateAttachment(c,l)}),this.postExecute("shape.replace",function(a){var s=a.context,c=s.oldShape,l=s.newShape;or(c.attachers,function(u){var p=i.allowed("elements.move",{target:l,shapes:[u]});p==="attach"?o.updateAttachment(u,l):o.removeShape(u)}),l.attachers.length&&V(l.attachers,function(u){var p=zb(u,c,l);o.moveShape(u,p,u.parent)})}),this.postExecute("shape.resize",function(a){var s=a.context,c=s.shape,l=s.oldBounds,u=s.newBounds,p=c.attachers,f=s.hints||{};f.attachSupport!==!1&&V(p,function(d){var g=zb(d,l,u);o.moveShape(d,g,d.parent),V(d.labels,function(h){o.moveShape(h,g,h.parent)})})}),this.preExecute("shape.delete",function(a){var s=a.context.shape;or(s.attachers,function(c){o.removeShape(c)}),s.host&&o.updateAttachment(s,null)})}Ne(gh,we),gh.$inject=["injector","eventBus","canvas","rules","modeling"];function mh(e){return Ip(Fn(e,function(t){return t.attachers||[]}))}function HD(e){var t=mh(e);return zS("id",e,t)}function zD(e){var t=sa(e,"id");return ct(e,function(n){for(;n;){if(n.host&&t[n.host.id])return!1;n=n.parent}return!0})}function GD(e){return!!e.host}function VD(e,t){return e.indexOf(t)!==-1}const WD={__depends__:[io],__init__:["attachSupport"],attachSupport:["type",gh]};function Rw(e,t,n,i){e.on("element.changed",function(o){var r=o.element;(r.parent||r===t.getRootElement())&&(o.gfx=n.getGraphics(r)),o.gfx&&e.fire(yv(r)+".changed",o)}),e.on("elements.changed",function(o){var r=o.elements;r.forEach(function(a){e.fire("element.changed",{element:a})}),i.updateContainments(r)}),e.on("shape.changed",function(o){i.update("shape",o.element,o.gfx)}),e.on("connection.changed",function(o){i.update("connection",o.element,o.gfx)})}Rw.$inject=["eventBus","canvas","elementRegistry","graphicsFactory"];const yh={__init__:["changeSupport"],changeSupport:["type",Rw]};function Pi(e){this._model=e}Pi.$inject=["moddle"],Pi.prototype._needsId=function(e){return st(e,["bpmn:RootElement","bpmn:FlowElement","bpmn:MessageFlow","bpmn:DataAssociation","bpmn:Artifact","bpmn:Participant","bpmn:Lane","bpmn:LaneSet","bpmn:Process","bpmn:Collaboration","bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane","bpmn:Property","bpmn:CategoryValue"])},Pi.prototype._ensureId=function(e){if(e.id){this._model.ids.claim(e.id,e);return}var t;M(e,"bpmn:Activity")?t="Activity":M(e,"bpmn:Event")?t="Event":M(e,"bpmn:Gateway")?t="Gateway":st(e,["bpmn:SequenceFlow","bpmn:MessageFlow"])?t="Flow":t=(e.$type||"").replace(/^[^:]*:/g,""),t+="_",!e.id&&this._needsId(e)&&(e.id=this._model.ids.nextPrefixed(t,e))},Pi.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n},Pi.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})},Pi.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",Y({bpmnElement:e,bounds:this.createDiBounds()},t))},Pi.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)},Pi.prototype.createDiWaypoints=function(e){var t=this;return Fn(e,function(n){return t.createDiWaypoint(n)})},Pi.prototype.createDiWaypoint=function(e){return this.create("dc:Point",Ni(e,["x","y"]))},Pi.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",Y({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))},Pi.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",Y({bpmnElement:e},t))};function ci(e,t,n){we.call(this,e),this._bpmnFactory=t;var i=this;function o(d){var g=d.context,h=g.hints||{},m;!g.cropped&&h.createElementsBehavior!==!1&&(m=g.connection,m.waypoints=n.getCroppedWaypoints(m),g.cropped=!0)}this.executed(["connection.layout","connection.create"],o),this.reverted(["connection.layout"],function(d){delete d.context.cropped});function r(d){var g=d.context;i.updateParent(g.shape||g.connection,g.oldParent)}function a(d){var g=d.context,h=g.shape||g.connection,m=g.parent||g.newParent;i.updateParent(h,m)}this.executed(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],li(r)),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],li(a));function s(d){var g=d.context,h=g.oldRoot,m=h.children;V(m,function(w){M(w,"bpmn:BaseElement")&&i.updateParent(w)})}this.executed(["canvas.updateRoot"],s),this.reverted(["canvas.updateRoot"],s);function c(d){var g=d.context.shape;M(g,"bpmn:BaseElement")&&i.updateBounds(g)}this.executed(["shape.move","shape.create","shape.resize"],li(function(d){d.context.shape.type!=="label"&&c(d)})),this.reverted(["shape.move","shape.create","shape.resize"],li(function(d){d.context.shape.type!=="label"&&c(d)})),e.on("shape.changed",function(d){d.element.type==="label"&&c({context:{shape:d.element}})});function l(d){i.updateConnection(d.context)}this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],li(l)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],li(l));function u(d){i.updateConnectionWaypoints(d.context.connection)}this.executed(["connection.layout","connection.move","connection.updateWaypoints"],li(u)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],li(u)),this.executed("connection.reconnect",li(function(d){var g=d.context,h=g.connection,m=g.oldSource,w=g.newSource,y=_e(h),v=_e(m),x=_e(w);y.conditionExpression&&!st(x,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(g.oldConditionExpression=y.conditionExpression,delete y.conditionExpression),m!==w&&v.default===y&&(g.oldDefault=v.default,delete v.default)})),this.reverted("connection.reconnect",li(function(d){var g=d.context,h=g.connection,m=g.oldSource,w=g.newSource,y=_e(h),v=_e(m),x=_e(w);g.oldConditionExpression&&(y.conditionExpression=g.oldConditionExpression),g.oldDefault&&(v.default=g.oldDefault,delete x.default)}));function p(d){i.updateAttachment(d.context)}this.executed(["element.updateAttachment"],li(p)),this.reverted(["element.updateAttachment"],li(p)),this.executed("element.updateLabel",li(f)),this.reverted("element.updateLabel",li(f));function f(d){const{element:g}=d.context,h=vi(g),m=mt(g),w=m&&m.get("label");Zo(g)||Xl(g)||(h&&!w?m.set("label",t.create("bpmndi:BPMNLabel")):!h&&w&&m.set("label",void 0))}}Ne(ci,we),ci.$inject=["eventBus","bpmnFactory","connectionDocking"],ci.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,i=t.host;n.attachedToRef=i&&i.businessObject},ci.prototype.updateParent=function(e,t){if(!at(e)&&!(M(e,"bpmn:DataStoreReference")&&e.parent&&M(e.parent,"bpmn:Collaboration"))){var n=e.parent,i=e.businessObject,o=mt(e),r=n&&n.businessObject,a=mt(n);M(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(i,r,t&&t.businessObject),M(e,"bpmn:DataOutputAssociation")&&(e.source?r=e.source.businessObject:r=null),M(e,"bpmn:DataInputAssociation")&&(e.target?r=e.target.businessObject:r=null),this.updateSemanticParent(i,r),M(e,"bpmn:DataObjectReference")&&i.dataObjectRef&&this.updateSemanticParent(i.dataObjectRef,r),this.updateDiParent(o,a)}},ci.prototype.updateBounds=function(e){var t=mt(e),n=qD(e);if(n){var i=Gi(n,t.get("bounds"));Y(n,{x:e.x+i.x,y:e.y+i.y})}var o=at(e)?this._getLabel(t):t,r=o.bounds;r||(r=this._bpmnFactory.createDiBounds(),o.set("bounds",r)),Y(r,{x:e.x,y:e.y,width:e.width,height:e.height})},ci.prototype.updateFlowNodeRefs=function(e,t,n){if(n!==t){var i,o;M(n,"bpmn:Lane")&&(i=n.get("flowNodeRef"),tn(i,e)),M(t,"bpmn:Lane")&&(o=t.get("flowNodeRef"),on(o,e))}},ci.prototype.updateDiConnection=function(e,t,n){var i=mt(e),o=mt(t),r=mt(n);i.sourceElement&&i.sourceElement.bpmnElement!==_e(t)&&(i.sourceElement=t&&o),i.targetElement&&i.targetElement.bpmnElement!==_e(n)&&(i.targetElement=n&&r)},ci.prototype.updateDiParent=function(e,t){if(t&&!M(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(tn(n,e),e.$parent=null)}};function UD(e){for(;e&&!M(e,"bpmn:Definitions");)e=e.$parent;return e}ci.prototype.getLaneSet=function(e){var t,n;return M(e,"bpmn:Lane")?(t=e.childLaneSet,t||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(M(e,"bpmn:Participant")&&(e=e.processRef),n=e.get("laneSets"),t=n[0],t||(t=this._bpmnFactory.create("bpmn:LaneSet"),t.$parent=e,n.push(t)),t)},ci.prototype.updateSemanticParent=function(e,t,n){var i;if(e.$parent!==t&&!((M(e,"bpmn:DataInput")||M(e,"bpmn:DataOutput"))&&(M(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),"ioSpecification"in t&&t.ioSpecification===e.$parent))){if(M(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),i="lanes";else if(M(e,"bpmn:FlowElement")){if(t){if(M(t,"bpmn:Participant"))t=t.processRef;else if(M(t,"bpmn:Lane"))do t=t.$parent.$parent;while(M(t,"bpmn:Lane"))}i="flowElements"}else if(M(e,"bpmn:Artifact")){for(;t&&!M(t,"bpmn:Process")&&!M(t,"bpmn:SubProcess")&&!M(t,"bpmn:Collaboration");)if(M(t,"bpmn:Participant")){t=t.processRef;break}else t=t.$parent;i="artifacts"}else if(M(e,"bpmn:MessageFlow"))i="messageFlows";else if(M(e,"bpmn:Participant")){i="participants";var o=e.processRef,r;o&&(r=UD(e.$parent||t),e.$parent&&(tn(r.get("rootElements"),o),o.$parent=null),t&&(on(r.get("rootElements"),o),o.$parent=r))}else M(e,"bpmn:DataOutputAssociation")?i="dataOutputAssociations":M(e,"bpmn:DataInputAssociation")&&(i="dataInputAssociations");if(!i)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var a;if(e.$parent&&(a=e.$parent.get(i),tn(a,e)),t?(a=t.get(i),a.push(e),e.$parent=t):e.$parent=null,n){var s=n.get(i);tn(a,e),t&&(s||(s=[],t.set(i,s)),s.push(e))}}},ci.prototype.updateConnectionWaypoints=function(e){var t=mt(e);t.set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))},ci.prototype.updateConnection=function(e){var t=e.connection,n=_e(t),i=t.source,o=_e(i),r=t.target,a=_e(t.target),s;if(M(n,"bpmn:DataAssociation"))M(n,"bpmn:DataInputAssociation")?(n.get("sourceRef")[0]=o,s=e.parent||e.newParent||a,this.updateSemanticParent(n,a,s)):M(n,"bpmn:DataOutputAssociation")&&(s=e.parent||e.newParent||o,this.updateSemanticParent(n,o,s),n.targetRef=a);else{var c=M(n,"bpmn:SequenceFlow");n.sourceRef!==o&&(c&&(tn(n.sourceRef&&n.sourceRef.get("outgoing"),n),o&&o.get("outgoing")&&o.get("outgoing").push(n)),n.sourceRef=o),n.targetRef!==a&&(c&&(tn(n.targetRef&&n.targetRef.get("incoming"),n),a&&a.get("incoming")&&a.get("incoming").push(n)),n.targetRef=a)}this.updateConnectionWaypoints(t),this.updateDiConnection(t,i,r)},ci.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label};function li(e){return function(t){var n=t.context,i=n.shape||n.connection||n.element;M(i,"bpmn:BaseElement")&&e(t)}}function qD(e){if(M(e,"bpmn:Activity")){var t=mt(e);if(t){var n=t.get("label");if(n)return n.get("bounds")}}}function rr(e,t){xo.call(this),this._bpmnFactory=e,this._moddle=t}Ne(rr,xo),rr.$inject=["bpmnFactory","moddle"],rr.prototype._baseCreate=xo.prototype.create,rr.prototype.create=function(e,t){if(e==="label"){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,Y({type:"label",di:n},Nr,t))}return this.createElement(e,t)},rr.prototype.createElement=function(e,t){t=Y({},t||{});var n,i=t.businessObject,o=t.di;if(!i){if(!t.type)throw new Error("no shape type specified");i=this._bpmnFactory.create(t.type)}if(!KD(o)){var r=Y({},o||{},{id:i.id+"_di"});e==="root"?o=this._bpmnFactory.createDiPlane(i,r):e==="connection"?o=this._bpmnFactory.createDiEdge(i,r):o=this._bpmnFactory.createDiShape(i,r)}M(i,"bpmn:Group")&&(t=Y({isFrame:!0},t)),t=YD(i,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=vh(o,t,"isExpanded")),st(i,["bpmn:Lane","bpmn:Participant"])&&(t=vh(o,t,"isHorizontal")),M(i,"bpmn:SubProcess")&&(t.collapsed=!ht(i,o)),M(i,"bpmn:ExclusiveGateway")&&(ti(o,"isMarkerVisible")?o.isMarkerVisible===void 0&&(o.isMarkerVisible=!1):o.isMarkerVisible=!0),gn(t.triggeredByEvent)&&(i.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),gn(t.cancelActivity)&&(i.cancelActivity=t.cancelActivity,delete t.cancelActivity);var a,s;return t.eventDefinitionType&&(a=i.get("eventDefinitions")||[],s=this._bpmnFactory.create(t.eventDefinitionType,t.eventDefinitionAttrs),t.eventDefinitionType==="bpmn:ConditionalEventDefinition"&&(s.condition=this._bpmnFactory.create("bpmn:FormalExpression")),a.push(s),s.$parent=i,i.eventDefinitions=a,delete t.eventDefinitionType),n=this.getDefaultSize(i,o),t=Y({id:i.id},n,t,{businessObject:i,di:o}),this._baseCreate(e,t)},rr.prototype.getDefaultSize=function(e,t){var n=_e(e);if(t=t||mt(e),M(n,"bpmn:SubProcess"))return ht(n,t)?{width:350,height:200}:{width:100,height:80};if(M(n,"bpmn:Task"))return{width:100,height:80};if(M(n,"bpmn:Gateway"))return{width:50,height:50};if(M(n,"bpmn:Event"))return{width:36,height:36};if(M(n,"bpmn:Participant")){var i=t.isHorizontal===void 0||t.isHorizontal===!0;return ht(n,t)?i?{width:600,height:250}:{width:250,height:600}:i?{width:400,height:60}:{width:60,height:400}}return M(n,"bpmn:Lane")?{width:400,height:100}:M(n,"bpmn:DataObjectReference")?{width:36,height:50}:M(n,"bpmn:DataStoreReference")?{width:50,height:50}:M(n,"bpmn:TextAnnotation")?{width:100,height:40}:M(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}},rr.prototype.createParticipantShape=function(e){return mn(e)||(e={isExpanded:e}),e=Y({type:"bpmn:Participant"},e||{}),e.isExpanded!==!1&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)};function YD(e,t,n){return V(n,function(i){t=vh(e,t,i)}),t}function vh(e,t,n){return t[n]===void 0?t:(e[n]=t[n],Yi(t,[n]))}function KD(e){return st(e,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])}function pu(e,t){this._modeling=e,this._canvas=t}pu.$inject=["modeling","canvas"],pu.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,i=e.alignment;V(n,function(o){var r={x:0,y:0};gn(i.left)?r.x=i.left-o.x:gn(i.right)?r.x=i.right-o.width-o.x:gn(i.center)?r.x=i.center-Math.round(o.width/2)-o.x:gn(i.top)?r.y=i.top-o.y:gn(i.bottom)?r.y=i.bottom-o.height-o.y:gn(i.middle)&&(r.y=i.middle-Math.round(o.height/2)-o.y),t.moveElements([o],r,o.parent)})},pu.prototype.postExecute=function(e){};function fu(e){this._modeling=e}fu.$inject=["modeling"],fu.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,i=e.shape,o=e.hints||{};i=e.shape=this._modeling.createShape(i,e.position,n,{attach:o.attach}),e.shape=i},fu.prototype.postExecute=function(e){var t=e.hints||{};XD(e.source,e.shape)||(t.connectionTarget===e.source?this._modeling.connect(e.shape,e.source,e.connection):this._modeling.connect(e.source,e.shape,e.connection))};function XD(e,t){return Bo(e.outgoing,function(n){return n.target===t})}function du(e,t){this._canvas=e,this._layouter=t}du.$inject=["canvas","layouter"],du.prototype.execute=function(e){var t=e.connection,n=e.source,i=e.target,o=e.parent,r=e.parentIndex,a=e.hints;if(!n||!i)throw new Error("source and target required");if(!o)throw new Error("parent required");return t.source=n,t.target=i,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,a)),this._canvas.addConnection(t,o,r),t},du.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};var hu=Math.round;function bh(e){this._modeling=e}bh.$inject=["modeling"],bh.prototype.preExecute=function(e){var t=e.elements,n=e.parent,i=e.parentIndex,o=e.position,r=e.hints,a=this._modeling;V(t,function(p){Qe(p.x)||(p.x=0),Qe(p.y)||(p.y=0)});var s=ct(t,function(p){return!p.hidden}),c=cn(s);V(t,function(p){Ot(p)&&(p.waypoints=Fn(p.waypoints,function(f){return{x:hu(f.x-c.x-c.width/2+o.x),y:hu(f.y-c.y-c.height/2+o.y)}})),Y(p,{x:hu(p.x-c.x-c.width/2+o.x),y:hu(p.y-c.y-c.height/2+o.y)})});var l=new Set(ml(t)),u={};V(t,function(p){if(Ot(p)){u[p.id]=Qe(i)?a.createConnection(u[p.source.id],u[p.target.id],i,p,p.parent||n,r):a.createConnection(u[p.source.id],u[p.target.id],p,p.parent||n,r);return}var f=Y({},r);l.has(p)||(f.autoResize=!1),at(p)&&(f=Yi(f,["attach"])),u[p.id]=Qe(i)?a.createShape(p,Ni(p,["x","y","width","height"]),p.parent||n,i,f):a.createShape(p,Ni(p,["x","y","width","height"]),p.parent||n,f)}),e.elements=aa(u)};var Cw=Math.round;function ar(e){this._canvas=e}ar.$inject=["canvas"],ar.prototype.execute=function(e){var t=e.shape,n=e.position,i=e.parent,o=e.parentIndex;if(!i)throw new Error("parent required");if(!n)throw new Error("position required");return n.width!==void 0?Y(t,n):Y(t,{x:n.x-Cw(t.width/2),y:n.y-Cw(t.height/2)}),this._canvas.addShape(t,i,o),t},ar.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t};function Vs(e){ar.call(this,e)}Ne(Vs,ar),Vs.$inject=["canvas"];var ZD=ar.prototype.execute;Vs.prototype.execute=function(e){var t=e.shape;return JD(t),t.labelTarget=e.labelTarget,ZD.call(this,e)};var QD=ar.prototype.revert;Vs.prototype.revert=function(e){return e.shape.labelTarget=null,QD.call(this,e)};function JD(e){["width","height"].forEach(function(t){typeof e[t]>"u"&&(e[t]=0)})}function Ws(e,t){this._canvas=e,this._modeling=t}Ws.$inject=["canvas","modeling"],Ws.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;or(n.incoming,function(i){t.removeConnection(i,{nested:!0})}),or(n.outgoing,function(i){t.removeConnection(i,{nested:!0})})},Ws.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=qf(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t},Ws.prototype.revert=function(e){var t=e.connection,n=e.parent,i=e.parentIndex;return t.source=e.source,t.target=e.target,on(n.children,t,i),this._canvas.addConnection(t,n),t};function xh(e,t){this._modeling=e,this._elementRegistry=t}xh.$inject=["modeling","elementRegistry"],xh.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry,i=e.elements;V(i,function(o){n.get(o.id)&&(o.waypoints?t.removeConnection(o):t.removeShape(o))})};function Us(e,t){this._canvas=e,this._modeling=t}Us.$inject=["canvas","modeling"],Us.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;or(n.incoming,function(i){t.removeConnection(i,{nested:!0})}),or(n.outgoing,function(i){t.removeConnection(i,{nested:!0})}),or(n.children,function(i){Ot(i)?t.removeConnection(i,{nested:!0}):t.removeShape(i,{nested:!0})})},Us.prototype.execute=function(e){var t=this._canvas,n=e.shape,i=n.parent;return e.oldParent=i,e.oldParentIndex=qf(i.children,n),t.removeShape(n),n},Us.prototype.revert=function(e){var t=this._canvas,n=e.shape,i=e.oldParent,o=e.oldParentIndex;return on(i.children,n,o),t.addShape(n,i),n};function gu(e){this._modeling=e}gu.$inject=["modeling"];var Mw={x:"y",y:"x"};gu.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,i=e.axis,o=e.dimension;function r(m,w){m.range.min=Math.min(w[i],m.range.min),m.range.max=Math.max(w[i]+w[o],m.range.max)}function a(m){return m[i]+m[o]/2}function s(m){return m.length-1}function c(m){return m.max-m.min}function l(m,w){var y={y:0};y[i]=m-a(w),y[i]&&(y[Mw[i]]=0,t.moveElements([w],y,w.parent))}var u=n[0],p=s(n),f=n[p],d,g,h=0;V(n,function(m,w){var y,v,x;if(m.elements.length<2){w&&w!==n.length-1&&(r(m,m.elements[0]),h+=c(m.range));return}y=qi(m.elements,i),v=y[0],w===p&&(v=y[s(y)]),x=a(v),m.range=null,V(y,function(E){if(l(x,E),m.range===null){m.range={min:E[i],max:E[i]+E[o]};return}r(m,E)}),w&&w!==n.length-1&&(h+=c(m.range))}),g=Math.abs(f.range.min-u.range.max),d=Math.round((g-h)/(n.length-1)),!(d<n.length-1)&&V(n,function(m,w){var y={},v;m===u||m===f||(v=n[w-1],m.range.max=0,V(m.elements,function(x,E){y[Mw[i]]=0,y[i]=v.range.max-x[i]+d,m.range.min!==x[i]&&(y[i]+=x[i]-m.range.min),y[i]&&t.moveElements([x],y,x.parent),m.range.max=Math.max(x[i]+x[o],E?m.range.max:0)}))})},gu.prototype.postExecute=function(e){};function mu(e,t){this._layouter=e,this._canvas=t}mu.$inject=["layouter","canvas"],mu.prototype.execute=function(e){var t=e.connection,n=t.waypoints;return Y(e,{oldWaypoints:n}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t},mu.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t};function wh(){}wh.prototype.execute=function(e){var t=e.connection,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldParent=r,e.oldParentIndex=tn(r.children,t),on(i.children,t,o),t.parent=i,V(t.waypoints,function(a){a.x+=n.x,a.y+=n.y,a.original&&(a.original.x+=n.x,a.original.y+=n.y)}),t},wh.prototype.revert=function(e){var t=e.connection,n=t.parent,i=e.oldParent,o=e.oldParentIndex,r=e.delta;return tn(n.children,t),on(i.children,t,o),t.parent=i,V(t.waypoints,function(a){a.x-=r.x,a.y-=r.y,a.original&&(a.original.x-=r.x,a.original.y-=r.y)}),t};function _h(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}_h.prototype.add=function(e,t){return this.addAll([e],t)},_h.prototype.addAll=function(e,t){var n=PP(e,!!t,this);return Y(this,n),this};function qs(e){this._modeling=e}qs.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]},qs.prototype.moveClosure=function(e,t,n,i,o){var r=this._modeling,a=e.allShapes,s=e.allConnections,c=e.enclosedConnections,l=e.topLevel,u=!1;o&&o.parent===n&&(u=!0),V(a,function(p){r.moveShape(p,t,l[p.id]&&!u&&n,{recurse:!1,layout:!1})}),V(s,function(p){var f=!!a[p.source.id],d=!!a[p.target.id];c[p.id]&&f&&d?r.moveConnection(p,t,l[p.id]&&!u&&n):r.layoutConnection(p,{connectionStart:f&&Pd(p,p.source,t),connectionEnd:d&&Td(p,p.target,t)})})},qs.prototype.getClosure=function(e){return new _h().addAll(e,!0)};function yu(e){this._helper=new qs(e)}yu.$inject=["modeling"],yu.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)},yu.prototype.postExecute=function(e){var t=e.hints,n;t&&t.primaryShape&&(n=t.primaryShape,t.oldParent=n.parent),this._helper.moveClosure(e.closure,e.delta,e.newParent,e.newHost,n)};function Vr(e){this._modeling=e,this._helper=new qs(e)}Vr.$inject=["modeling"],Vr.prototype.execute=function(e){var t=e.shape,n=e.delta,i=e.newParent||t.parent,o=e.newParentIndex,r=t.parent;return e.oldBounds=Ni(t,["x","y","width","height"]),e.oldParent=r,e.oldParentIndex=tn(r.children,t),on(i.children,t,o),Y(t,{parent:i,x:t.x+n.x,y:t.y+n.y}),t},Vr.prototype.postExecute=function(e){var t=e.shape,n=e.delta,i=e.hints,o=this._modeling;i.layout!==!1&&(V(t.incoming,function(r){o.layoutConnection(r,{connectionEnd:Td(r,t,n)})}),V(t.outgoing,function(r){o.layoutConnection(r,{connectionStart:Pd(r,t,n)})})),i.recurse!==!1&&this.moveChildren(e)},Vr.prototype.revert=function(e){var t=e.shape,n=e.oldParent,i=e.oldParentIndex,o=e.delta;return on(n.children,t,i),Y(t,{parent:n,x:t.x-o.x,y:t.y-o.y}),t},Vr.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)},Vr.prototype.getNewParent=function(e){return e.newParent||e.shape.parent};function Ys(e){this._modeling=e}Ys.$inject=["modeling"],Ys.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,i=e.connection,o=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return Ze(o)&&(e.oldWaypoints=i.waypoints,i.waypoints=o),t&&(e.oldSource=i.source,i.source=t),n&&(e.oldTarget=i.target,i.target=n),i},Ys.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,i=e.newTarget,o=e.dockingOrPoints,r=e.hints||{},a={};r.connectionStart&&(a.connectionStart=r.connectionStart),r.connectionEnd&&(a.connectionEnd=r.connectionEnd),r.layoutConnection!==!1&&(n&&(!i||r.docking==="source")&&(a.connectionStart=a.connectionStart||Aw(Ze(o)?o[0]:o)),i&&(!n||r.docking==="target")&&(a.connectionEnd=a.connectionEnd||Aw(Ze(o)?o[o.length-1]:o)),r.newWaypoints&&(a.waypoints=r.newWaypoints),this._modeling.layoutConnection(t,a))},Ys.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,i=e.oldWaypoints,o=e.connection;return t&&(o.source=t),n&&(o.target=n),i&&(o.waypoints=i),o};function Aw(e){return e.original||e}function Co(e,t){this._modeling=e,this._rules=t}Co.$inject=["modeling","rules"],Co.prototype.preExecute=function(e){var t=this,n=this._modeling,i=this._rules,o=e.oldShape,r=e.newData,a=e.hints||{},s;function c(g,h,m){return i.allowed("connection.reconnect",{connection:m,source:g,target:h})}var l={x:r.x,y:r.y},u={x:o.x,y:o.y,width:o.width,height:o.height};s=e.newShape=e.newShape||t.createShape(r,l,o.parent,a),o.host&&n.updateAttachment(s,o.host);var p;a.moveChildren!==!1&&(p=o.children.slice(),n.moveElements(p,{x:0,y:0},s,a));var f=o.incoming.slice(),d=o.outgoing.slice();V(f,function(g){var h=g.source,m=c(h,s,g);m&&t.reconnectEnd(g,s,Vl(g,s,u),a)}),V(d,function(g){var h=g.target,m=c(s,h,g);m&&t.reconnectStart(g,s,Gl(g,s,u),a)})},Co.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)},Co.prototype.execute=function(e){},Co.prototype.revert=function(e){},Co.prototype.createShape=function(e,t,n,i){return this._modeling.createShape(e,t,n,i)},Co.prototype.reconnectStart=function(e,t,n,i){this._modeling.reconnectStart(e,t,n,i)},Co.prototype.reconnectEnd=function(e,t,n,i){this._modeling.reconnectEnd(e,t,n,i)};function Ks(e){this._modeling=e}Ks.$inject=["modeling"],Ks.prototype.execute=function(e){var t=e.shape,n=e.newBounds,i=e.minBounds;if(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)throw new Error("newBounds must have {x, y, width, height} properties");if(i&&(n.width<i.width||n.height<i.height))throw new Error("width and height cannot be less than minimum height and width");if(!i&&n.width<10||n.height<10)throw new Error("width and height cannot be less than 10px");return e.oldBounds={width:t.width,height:t.height,x:t.x,y:t.y},Y(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t},Ks.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,i=e.oldBounds,o=e.hints||{};o.layout!==!1&&(V(n.incoming,function(r){t.layoutConnection(r,{connectionEnd:Vl(r,n,i)})}),V(n.outgoing,function(r){t.layoutConnection(r,{connectionStart:Gl(r,n,i)})}))},Ks.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return Y(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t};function sr(e){this._modeling=e}sr.$inject=["modeling"],sr.prototype.preExecute=function(e){var t=e.delta,n=e.direction,i=e.movingShapes,o=e.resizingShapes,r=e.start,a={};this.moveShapes(i,t),V(o,function(s){a[s.id]=tL(s)}),this.resizeShapes(o,t,n),this.updateConnectionWaypoints(AD(i,o),t,n,r,i,o,a)},sr.prototype.execute=function(){},sr.prototype.revert=function(){},sr.prototype.moveShapes=function(e,t){var n=this;V(e,function(i){n._modeling.moveShape(i,t,null,{autoResize:!1,layout:!1,recurse:!1})})},sr.prototype.resizeShapes=function(e,t,n){var i=this;V(e,function(o){var r=PD(o,n,t);i._modeling.resizeShape(o,r,null,{attachSupport:!1,autoResize:!1,layout:!1})})},sr.prototype.updateConnectionWaypoints=function(e,t,n,i,o,r,a){var s=this,c=new Set(o),l=new Set(r);V(e,function(u){var p=u.source,f=u.target,d=eL(u),g=Tw(n),h={},m=c.has(p)||l.has(p),w=c.has(f)||l.has(f);m&&w?(d=Fn(d,function(y){return kw(y,i,n)&&(y[g]=y[g]+t[g]),y.original&&kw(y.original,i,n)&&(y.original[g]=y.original[g]+t[g]),y}),s._modeling.updateWaypoints(u,d,{labelBehavior:!1})):(m||w)&&(c.has(p)?h.connectionStart=Pd(u,p,t):c.has(f)?h.connectionEnd=Td(u,f,t):l.has(p)?h.connectionStart=Gl(u,p,a[p.id]):l.has(f)&&(h.connectionEnd=Vl(u,f,a[f.id])),s._modeling.layoutConnection(u,h))})};function Pw(e){return Y({},e)}function eL(e){return Fn(e.waypoints,function(t){return t=Pw(t),t.original&&(t.original=Pw(t.original)),t})}function Tw(e){switch(e){case"n":return"y";case"w":return"x";case"s":return"y";case"e":return"x"}}function kw(e,t,n){var i=Tw(n);if(/e|s/.test(n))return e[i]>t;if(/n|w/.test(n))return e[i]<t}function tL(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}function vu(e){this._modeling=e}vu.$inject=["modeling"],vu.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=Ow(n),t.collapsed=!t.collapsed;var i=Dw(n,t.collapsed);return[t].concat(i)},vu.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,i=t.children,o=Lw(i,n);return t.collapsed=!t.collapsed,[t].concat(o)};function Ow(e){var t={};return V(e,function(n){t[n.id]=n.hidden,n.children&&(t=Y({},t,Ow(n.children)))}),t}function Dw(e,t){var n=[];return V(e,function(i){i.hidden=t,n=n.concat(i),i.children&&(n=n.concat(Dw(i.children,i.collapsed||t)))}),n}function Lw(e,t){var n=[];return V(e,function(i){i.hidden=t[i.id],n=n.concat(i),i.children&&(n=n.concat(Lw(i.children,t)))}),n}function bu(e){this._modeling=e}bu.$inject=["modeling"],bu.prototype.execute=function(e){var t=e.shape,n=e.newHost,i=t.host;return e.oldHost=i,e.attacherIdx=Iw(i,t),Bw(n,t),t.host=n,t},bu.prototype.revert=function(e){var t=e.shape,n=e.newHost,i=e.oldHost,o=e.attacherIdx;return t.host=i,Iw(n,t),Bw(i,t,o),t};function Iw(e,t){return tn(e&&e.attachers,t)}function Bw(e,t,n){if(e){var i=e.attachers;i||(e.attachers=i=[]),on(i,t,n)}}function Eh(){}Eh.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t},Eh.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t};function Dt(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var i=this;e.on("diagram.init",function(){i.registerHandlers(n)})}Dt.$inject=["eventBus","elementFactory","commandStack"],Dt.prototype.getHandlers=function(){return{"shape.append":fu,"shape.create":ar,"shape.delete":Us,"shape.move":Vr,"shape.resize":Ks,"shape.replace":Co,"shape.toggleCollapse":vu,spaceTool:sr,"label.create":Vs,"connection.create":du,"connection.delete":Ws,"connection.move":wh,"connection.layout":mu,"connection.updateWaypoints":Eh,"connection.reconnect":Ys,"elements.create":bh,"elements.move":yu,"elements.delete":xh,"elements.distribute":gu,"elements.align":pu,"element.updateAttachment":bu}},Dt.prototype.registerHandlers=function(e){V(this.getHandlers(),function(t,n){e.registerHandler(n,t)})},Dt.prototype.moveShape=function(e,t,n,i,o){typeof i=="object"&&(o=i,i=null);var r={shape:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("shape.move",r)},Dt.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)},Dt.prototype.moveElements=function(e,t,n,i){i=i||{};var o=i.attach,r=n,a;o===!0?(a=n,r=n.parent):o===!1&&(a=null);var s={shapes:e,delta:t,newParent:r,newHost:a,hints:i};this._commandStack.execute("elements.move",s)},Dt.prototype.moveConnection=function(e,t,n,i,o){typeof i=="object"&&(o=i,i=void 0);var r={connection:e,delta:t,newParent:n,newParentIndex:i,hints:o||{}};this._commandStack.execute("connection.move",r)},Dt.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)},Dt.prototype.createConnection=function(e,t,n,i,o,r){typeof n=="object"&&(r=o,o=i,i=n,n=void 0),i=this._create("connection",i);var a={source:e,target:t,parent:o,parentIndex:n,connection:i,hints:r};return this._commandStack.execute("connection.create",a),a.connection},Dt.prototype.createShape=function(e,t,n,i,o){typeof i!="number"&&(o=i,i=void 0),o=o||{};var r=o.attach,a,s;e=this._create("shape",e),r?(a=n.parent,s=n):a=n;var c={position:t,shape:e,parent:a,parentIndex:i,host:s,hints:o};return this._commandStack.execute("shape.create",c),c.shape},Dt.prototype.createElements=function(e,t,n,i,o){Ze(e)||(e=[e]),typeof i!="number"&&(o=i,i=void 0),o=o||{};var r={position:t,elements:e,parent:n,parentIndex:i,hints:o};return this._commandStack.execute("elements.create",r),r.elements},Dt.prototype.createLabel=function(e,t,n,i){n=this._create("label",n);var o={labelTarget:e,position:t,parent:i||e.parent,shape:n};return this._commandStack.execute("label.create",o),o.shape},Dt.prototype.appendShape=function(e,t,n,i,o){o=o||{},t=this._create("shape",t);var r={source:e,position:n,target:i,shape:t,connection:o.connection,connectionParent:o.connectionParent,hints:o};return this._commandStack.execute("shape.append",r),r.shape},Dt.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)},Dt.prototype.distributeElements=function(e,t,n){var i={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",i)},Dt.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)},Dt.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)},Dt.prototype.replaceShape=function(e,t,n){var i={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",i),i.newShape},Dt.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)},Dt.prototype.resizeShape=function(e,t,n,i){var o={shape:e,newBounds:t,minBounds:n,hints:i};this._commandStack.execute("shape.resize",o)},Dt.prototype.createSpace=function(e,t,n,i,o){var r={delta:n,direction:i,movingShapes:e,resizingShapes:t,start:o};this._commandStack.execute("spaceTool",r)},Dt.prototype.updateWaypoints=function(e,t,n){var i={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",i)},Dt.prototype.reconnect=function(e,t,n,i,o){var r={connection:e,newSource:t,newTarget:n,dockingOrPoints:i,hints:o||{}};this._commandStack.execute("connection.reconnect",r)},Dt.prototype.reconnectStart=function(e,t,n,i){i||(i={}),this.reconnect(e,t,e.target,n,Y(i,{docking:"source"}))},Dt.prototype.reconnectEnd=function(e,t,n,i){i||(i={}),this.reconnect(e,e.source,t,n,Y(i,{docking:"target"}))},Dt.prototype.connect=function(e,t,n,i){return this.createConnection(e,t,n||{},e.parent,i)},Dt.prototype._create=function(e,t){return hT(t)?t:this._elementFactory.create(e,t)},Dt.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)};function Xs(e){this._elementRegistry=e}Xs.$inject=["elementRegistry"],Xs.prototype.execute=function(e){var t=e.element,n=e.moddleElement,i=e.properties;if(!n)throw new Error("<moddleElement> required");var o=e.changed||this._getVisualReferences(n).concat(t),r=e.oldProperties||nL(n,Dc(i));return Nw(n,i),e.oldProperties=r,e.changed=o,o},Xs.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,i=e.changed;return Nw(n,t),i},Xs.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return M(e,"bpmn:DataObject")?iL(e,t):[]};function nL(e,t){return ni(t,function(n,i){return n[i]=e.get(i),n},{})}function Nw(e,t){V(t,function(n,i){e.set(i,n)})}function iL(e,t){return t.filter(function(n){return M(n,"bpmn:DataObjectReference")&&_e(n).dataObjectRef===e})}var Zs="default",Mo="id",$w="di",oL={width:0,height:0};function Qs(e,t,n,i){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=i}Qs.$inject=["elementRegistry","moddle","modeling","textRenderer"],Qs.prototype.execute=function(e){var t=e.element,n=[t];if(!t)throw new Error("element required");var i=this._elementRegistry,o=this._moddle.ids,r=t.businessObject,a=lL(e.properties),s=e.oldProperties||rL(t,a);return Fw(a,r)&&(o.unclaim(r[Mo]),i.updateId(t,a[Mo]),o.claim(a[Mo],r)),Zs in a&&(a[Zs]&&n.push(i.get(a[Zs].id)),r[Zs]&&n.push(i.get(r[Zs].id))),jw(t,a),e.oldProperties=s,e.changed=n,n},Qs.prototype.postExecute=function(e){var t=e.element,n=t.label,i=n&&_e(n).name;if(i){var o=this._textRenderer.getExternalLabelBounds(n,i);this._modeling.resizeShape(n,o,oL)}},Qs.prototype.revert=function(e){var t=e.element,n=e.properties,i=e.oldProperties,o=t.businessObject,r=this._elementRegistry,a=this._moddle.ids;return jw(t,i),Fw(n,o)&&(a.unclaim(n[Mo]),r.updateId(t,i[Mo]),a.claim(i[Mo],o)),e.changed};function Fw(e,t){return Mo in e&&e[Mo]!==t[Mo]}function rL(e,t){var n=Dc(t),i=e.businessObject,o=mt(e);return ni(n,function(r,a){return a!==$w?r[a]=i.get(a):r[a]=aL(o,Dc(t.di)),r},{})}function aL(e,t){return ni(t,function(n,i){return n[i]=e&&e.get(i),n},{})}function jw(e,t){var n=e.businessObject,i=mt(e);V(t,function(o,r){r!==$w?n.set(r,o):i&&sL(i,o)})}function sL(e,t){V(t,function(n,i){e.set(i,n)})}var cL=["default"];function lL(e){var t=Y({},e);return cL.forEach(function(n){n in e&&(t[n]=_e(t[n]))}),t}function xu(e,t){this._canvas=e,this._modeling=t}xu.$inject=["canvas","modeling"],xu.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,o=t.getRootElement(),r=o.businessObject,a=r.$parent,s=mt(o);return t.setRootElement(n),t.removeRootElement(o),on(a.rootElements,i),i.$parent=a,tn(a.rootElements,r),r.$parent=null,o.di=null,s.bpmnElement=i,n.di=s,e.oldRoot=o,[]},xu.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,i=n.businessObject,o=e.oldRoot,r=o.businessObject,a=i.$parent,s=mt(n);return t.setRootElement(o),t.removeRootElement(n),tn(a.rootElements,i),i.$parent=null,on(a.rootElements,r),r.$parent=a,n.di=null,s.bpmnElement=r,o.di=s,[]};function Sh(e,t){this._modeling=e,this._spaceTool=t}Sh.$inject=["modeling","spaceTool"],Sh.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,i=e.shape,o=e.location,r=Ri(i),a=r===i,s=a?i:i.parent,c=Jo(s),l=En(i);if(l?o==="left"?o="top":o==="right"&&(o="bottom"):o==="top"?o="left":o==="bottom"&&(o="right"),!c.length){var u=l?{x:i.x+Si,y:i.y,width:i.width-Si,height:i.height}:{x:i.x,y:i.y+Si,width:i.width,height:i.height-Si};n.createShape({type:"bpmn:Lane",isHorizontal:l},u,s)}var p=[];Br(r,function(x){return p.push(x),x.label&&p.push(x.label),x===i?[]:ct(x.children,function(E){return E!==i})});var f,d,g,h,m;o==="top"?(f=-120,d=i.y,g=d+10,h="n",m="y"):o==="left"?(f=-120,d=i.x,g=d+10,h="w",m="x"):o==="bottom"?(f=120,d=i.y+i.height,g=d-10,h="s",m="y"):o==="right"&&(f=120,d=i.x+i.width,g=d-10,h="e",m="x");var w=t.calculateAdjustments(p,m,f,g),y=l?{x:0,y:f}:{x:f,y:0};t.makeSpace(w.movingShapes,w.resizingShapes,y,h,g);var v=l?{x:i.x+(a?Si:0),y:d-(o==="top"?120:0),width:i.width-(a?Si:0),height:120}:{x:d-(o==="left"?120:0),y:i.y+(a?Si:0),width:120,height:i.height-(a?Si:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:l},v,s)};function Rh(e){this._modeling=e}Rh.$inject=["modeling"],Rh.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,i=e.count,o=Jo(n),r=o.length;if(r>i)throw new Error(`more than <${i}> child lanes`);var a=En(n),s=a?n.height:n.width,c=Math.round(s/i),l,u,p,f;for(f=0;f<i;f++)f===i-1?l=s-c*f:l=c,u=a?{x:n.x+Si,y:n.y+f*c,width:n.width-Si,height:l}:{x:n.x+f*c,y:n.y+Si,width:l,height:n.height-Si},f<r?t.resizeShape(o[f],u):(p={type:"bpmn:Lane",isHorizontal:a},t.createShape(p,u,n))};function Js(e,t){this._modeling=e,this._spaceTool=t}Js.$inject=["modeling","spaceTool"],Js.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds,i=e.balanced;i!==!1?this.resizeBalanced(t,n):this.resizeSpace(t,n)},Js.prototype.resizeBalanced=function(e,t){var n=this._modeling,i=ik(e,t);n.resizeShape(e,t),i.forEach(function(o){n.resizeShape(o.shape,o.newBounds)})},Js.prototype.resizeSpace=function(e,t){var n=this._spaceTool,i=qe(e),o=qe(t),r=vb(o,i),a=Ri(e),s=[],c=[];Br(a,function(g){return s.push(g),(M(g,"bpmn:Lane")||M(g,"bpmn:Participant"))&&c.push(g),g.children});var l,u,p,f,d;(r.bottom||r.top)&&(l=r.bottom||r.top,u=e.y+(r.bottom?e.height:0)+(r.bottom?-10:10),p=r.bottom?"s":"n",f=r.top>0||r.bottom<0?-l:l,d=n.calculateAdjustments(s,"y",f,u),n.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:l},p)),(r.left||r.right)&&(l=r.right||r.left,u=e.x+(r.right?e.width:0)+(r.right?-10:100),p=r.right?"e":"w",f=r.left>0||r.right<0?-l:l,d=n.calculateAdjustments(c,"x",f,u),n.makeSpace(d.movingShapes,d.resizingShapes,{x:l,y:0},p))};var ec="flowNodeRef",Ch="lanes";function wu(){}wu.prototype._computeUpdates=function(e,t){var n=[],i=[],o={},r=[];function a(u,p){var f=qe(p),d={x:u.x+u.width/2,y:u.y+u.height/2};return d.x>f.left&&d.x<f.right&&d.y>f.top&&d.y<f.bottom}function s(u){n.indexOf(u)===-1&&(r.push(u),n.push(u))}function c(u){var p=Ri(u);return o[p.id]||(o[p.id]=$l(p)),o[p.id]}function l(u){if(!u.parent)return[];var p=c(u);return p.filter(function(f){return a(u,f)}).map(function(f){return f.businessObject})}return t.forEach(function(u){var p=Ri(u);if(!(!p||n.indexOf(p)!==-1)){var f=p.children.filter(function(d){return M(d,"bpmn:FlowNode")});f.forEach(s),n.push(p)}}),e.forEach(s),r.forEach(function(u){var p=u.businessObject,f=p.get(Ch),d=f.slice(),g=l(u);i.push({flowNode:p,remove:d,add:g})}),t.forEach(function(u){var p=u.businessObject;u.parent||p.get(ec).forEach(function(f){i.push({flowNode:f,remove:[p],add:[]})})}),i},wu.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach(function(n){var i=n.flowNode,o=i.get(Ch);n.remove.forEach(function(r){tn(o,r),tn(r.get(ec),i)}),n.add.forEach(function(r){on(o,r),on(r.get(ec),i)})}),[]},wu.prototype.revert=function(e){var t=e.updates;return t.forEach(function(n){var i=n.flowNode,o=i.get(Ch);n.add.forEach(function(r){tn(o,r),tn(r.get(ec),i)}),n.remove.forEach(function(r){on(o,r),on(r.get(ec),i)})}),[]};var Mh="categoryValueRef";function tc(e,t){this._bpmnFactory=e,this._elementRegistry=t}tc.$inject=["bpmnFactory","elementRegistry"],tc.prototype._computeUpdates=function(e,t){var n=this._elementRegistry,i=this._bpmnFactory,o=new Map,r=[],a=new Map;function s(y,v,x){if(v){var E=a.get(y);E||(E={},a.set(y,E)),!(x&&E.present)&&(!x&&E.past||(x?E.present={categoryValue:v,root:Ah(y)}:E.past={categoryValue:v}))}}function c(y){o.set(y,_e(y))}function l(){n.filter(function(y){return M(y,"bpmn:FlowElement")&&!at(y)&&y.parent}).forEach(c)}function u(y){var v=_e(y),x=v.get("categoryValueRef");return x||(x=db(i,v),r.push(uL(y,x))),x}function p(y){return y.reduce(function(v,x){var E=Ah(x),A=v.get(E);return A||(A=[],v.set(E,A)),A.push(x),v},new Map)}e=Array.from(e||[]);var f=p(e);t.length&&l(),e.forEach(c),n.filter(function(y){return M(y,"bpmn:Group")&&!at(y)&&y.parent}).forEach(function(y){var v=_e(y).get("categoryValueRef");if(!v){var x=Ah(y),E=f.get(x)||[],A=xa(E,y),I=Object.keys(A).length>0;I&&(v=u(y))}s(y,v,!0)}),t.forEach(function(y){s(y.groupShape,y.categoryValue,!1)}),r.length&&l();var d=Array.from(o.keys()),g=Array.from(a.values()).reduce(function(y,v){return v.present&&y.add(v.present.categoryValue),v.past&&y.add(v.past.categoryValue),y},new Set),h=new Map,m=p(d);a.forEach(function(y,v){var x=y.present;if(x){var E=m.get(x.root)||[],A=xa(E,v);E.forEach(function(I){if(A[I.id]){var P=h.get(I);P||(P=new Set,h.set(I,P)),P.add(x.categoryValue)}})}});var w=d.reduce(function(y,v){var x=o.get(v),E=x.get(Mh),A=new Set(E),I=h.get(v)||new Set,P=Array.from(I).filter(function(H){return!A.has(H)}),k=E.filter(function(H){return g.has(H)&&!I.has(H)});return(P.length||k.length)&&y.push({businessObject:x,categoryValuesToAdd:P,categoryValuesToRemove:k}),y},[]);return{flowElements:w,groups:r}},tc.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.affectedFlowElements,e.affectedGroupEntries)),pL(t.groups),dL(t.flowElements),[]},tc.prototype.revert=function(e){var t=e.updates;return hL(t.flowElements),fL(t.groups),[]};function uL(e,t){return{groupShape:e,categoryValue:t,category:t.$parent}}function pL(e){e.forEach(function(t){_e(t.groupShape).categoryValueRef=t.categoryValue,t.categoryValue.$parent=t.category})}function fL(e){e.forEach(function(t){_e(t.groupShape).categoryValueRef=null})}function dL(e){e.forEach(function(t){var n=t.businessObject,i=n.get(Mh);t.categoryValuesToRemove.forEach(function(o){tn(i,o)}),t.categoryValuesToAdd.forEach(function(o){on(i,o,!0)})})}function hL(e){e.forEach(function(t){var n=t.businessObject,i=n.get(Mh);t.categoryValuesToAdd.forEach(function(o){tn(i,o)}),t.categoryValuesToRemove.forEach(function(o){on(i,o,!0)})})}function Ah(e){for(;e.parent;)e=e.parent;return e}function _u(e){this._moddle=e}_u.$inject=["moddle"],_u.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,i=e.element,o=e.claiming;return o?t.claim(n,i):t.unclaim(n),[]},_u.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,i=e.element,o=e.claiming;return o?t.unclaim(n):t.claim(n,i),[]};var gL={fill:void 0,stroke:void 0};function Ph(e){this._commandStack=e,this._normalizeColor=function(t){if(t){if(ei(t)){var n=mL(t);if(n)return n}throw new Error(`invalid color value: ${t}`)}}}Ph.$inject=["commandStack"],Ph.prototype.postExecute=function(e){var t=e.elements,n=e.colors||gL,i=this,o={};"fill"in n&&Y(o,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&Y(o,{"border-color":this._normalizeColor(n.stroke)}),V(t,function(r){var a=Ot(r)?Ni(o,["border-color"]):o,s=mt(r);if(yL(a),at(r)){if(!s||!M(s.label,"bpmndi:BPMNLabel"))return;i._commandStack.execute("element.updateModdleProperties",{element:r,moddleElement:s.label,properties:{color:o["border-color"]}})}else{if(!st(s,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;i._commandStack.execute("element.updateProperties",{element:r,properties:{di:a}})}})};function mL(e){var t=document.createElement("canvas").getContext("2d");return t.fillStyle="transparent",t.fillStyle=e,/^#[0-9a-fA-F]{6}$/.test(t.fillStyle)?t.fillStyle:null}function yL(e){"border-color"in e&&(e.stroke=e["border-color"]),"background-color"in e&&(e.fill=e["background-color"])}var vL={width:0,height:0};function Hw(e,t,n){function i(c,l){var u=c.label||c,p=c.labelTarget||c;return UT(u,l),[u,p]}function o(c){var l=c.element,u=l.businessObject,p=c.newLabel;if(!at(l)&&Zo(l)&&!Rl(l)&&!zw(p)){var f=7,d=Jf(l);d={x:d.x,y:d.y+f},e.createLabel(l,d,{id:u.id+"_label",businessObject:u,di:l.di})}}function r(c){return c.oldLabel=vi(c.element),i(c.element,c.newLabel)}function a(c){return i(c.element,c.oldLabel)}function s(c){var l=c.element,u=l.label||l,p=c.newLabel,f=c.newBounds,d=c.hints||{};if(!(!at(u)&&!M(u,"bpmn:TextAnnotation"))){if(at(u)&&zw(p)){d.removeShape!==!1&&e.removeShape(u,{unsetLabel:!1});return}var g=vi(l);typeof f>"u"&&(f=t.getExternalLabelBounds(u,g)),f&&e.resizeShape(u,f,vL)}}this.preExecute=o,this.execute=r,this.revert=a,this.postExecute=s}Hw.$inject=["modeling","textRenderer","bpmnFactory"];function zw(e){return!e||!e.trim()}function In(e,t,n,i){Dt.call(this,e,t,n),this._bpmnRules=i}Ne(In,Dt),In.$inject=["eventBus","elementFactory","commandStack","bpmnRules"],In.prototype.getHandlers=function(){var e=Dt.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=Xs,e["element.updateProperties"]=Qs,e["canvas.updateRoot"]=xu,e["lane.add"]=Sh,e["lane.resize"]=Js,e["lane.split"]=Rh,e["lane.updateRefs"]=wu,e["group.updateRefs"]=tc,e["id.updateClaim"]=_u,e["element.setColor"]=Ph,e["element.updateLabel"]=Hw,e},In.prototype.updateLabel=function(e,t,n,i){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:i||{}})},In.prototype.connect=function(e,t,n,i){var o=this._bpmnRules;if(n||(n=o.canConnect(e,t)),!!n)return this.createConnection(e,t,n,e.parent,i)},In.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})},In.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})},In.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})},In.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane},In.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})},In.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},In.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e},In.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})},In.prototype.updateCategoryValueRefs=function(e,t){this._commandStack.execute("group.updateRefs",{affectedFlowElements:e,affectedGroupEntries:t})},In.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})},In.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})},In.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})};function Gw(){}Gw.prototype.layoutConnection=function(e,t){return t=t||{},[t.connectionStart||Je(t.source||e.source),t.connectionEnd||Je(t.target||e.target)]};var Eu=20,bL=5,Su=Math.round,Vw=20,xL={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function wL(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}function _L(e,t){return{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[e].test(t)}function Ww(e,t,n){var i=On(t,e,bL),o=n.split(":")[0],r=Su((t.x-e.x)/2+e.x),a=Su((t.y-e.y)/2+e.y),s,c,l=_L(o,i),u=/h|r|l/.test(o),p=!1,f=!1;return l?(s=u?{x:r,y:e.y}:{x:e.x,y:a},c=u?"h:h":"v:v"):(p=wL(i,o),c=u?"h:v":"v:h",p?u?(f=a===e.y,s={x:e.x+Eu*(/l/.test(o)?-1:1),y:f?a+Eu:a}):(f=r===e.x,s={x:f?r+Eu:r,y:e.y+Eu*(/t/.test(o)?-1:1)}):s={x:r,y:a}),{waypoints:Th(e,s,c).concat(s),directions:c,turnNextDirections:f}}function EL(e,t,n){return Ww(e,t,n)}function SL(e,t,n){var i=Ww(t,e,Uw(n));return{waypoints:i.waypoints.slice().reverse(),directions:Uw(i.directions),turnNextDirections:i.turnNextDirections}}function RL(e,t){var n=e.directions.split(":")[1],i=t.directions.split(":")[0];e.turnNextDirections&&(n=n=="h"?"v":"h"),t.turnNextDirections&&(i=i=="h"?"v":"h");var o=n+":"+i,r=Th(e.waypoints[e.waypoints.length-1],t.waypoints[0],o);return{waypoints:r,directions:o}}function Uw(e){return e.split(":").reverse().join(":")}function CL(e,t,n){var i=Su((t.x-e.x)/2+e.x),o=Su((t.y-e.y)/2+e.y);if(n==="h:v")return[{x:t.x,y:e.y}];if(n==="v:h")return[{x:e.x,y:t.y}];if(n==="h:h")return[{x:i,y:e.y},{x:i,y:t.y}];if(n==="v:v")return[{x:e.x,y:o},{x:t.x,y:o}];throw new Error("invalid directions: can only handle varians of [hv]:[hv]")}function Th(e,t,n){if(n=n||"h:h",!IL(n))throw new Error("unknown directions: <"+n+">: must be specified as <start>:<end> with start/end in { h,v,t,r,b,l }");if(Yw(n)){var i=EL(e,t,n),o=SL(e,t,n),r=RL(i,o);return[].concat(i.waypoints,r.waypoints,o.waypoints)}return CL(e,t,n)}function ML(e,t,n){var i=Th(e,t,n);return i.unshift(e),i.push(t),Xw(i)}function AL(e,t,n,i,o){var r=o&&o.preferredLayouts||[],a=jS(r,"straight")[0]||"h:h",s=xL[a]||0,c=On(e,t,s),l=LL(c,a);n=n||Je(e),i=i||Je(t);var u=l.split(":"),p=Kw(n,e,u[0],BL(c)),f=Kw(i,t,u[1],c);return ML(p,f,l)}function PL(e,t,n,i,o,r){Ze(n)&&(o=n,r=i,n=Je(e),i=Je(t)),r=Y({preferredLayouts:[]},r),o=o||[];var a=r.preferredLayouts,s=a.indexOf("straight")!==-1,c;return c=s&&kL(e,t,n,i,r),c||(c=r.connectionEnd&&DL(t,e,i,o),c)||(c=r.connectionStart&&OL(e,t,n,o),c)?c:!r.connectionStart&&!r.connectionEnd&&o&&o.length?o:AL(e,t,n,i,r)}function TL(e,t,n){return e>=t&&e<=n}function qw(e,t,n){var i={x:"width",y:"height"};return TL(t[e],n[e],n[e]+n[i[e]])}function kL(e,t,n,i,o){var r={},a,s;return s=On(e,t),/^(top|bottom|left|right)$/.test(s)?(/top|bottom/.test(s)&&(a="x"),/left|right/.test(s)&&(a="y"),o.preserveDocking==="target"?qw(a,i,e)?(r[a]=i[a],[{x:r.x!==void 0?r.x:n.x,y:r.y!==void 0?r.y:n.y,original:{x:r.x!==void 0?r.x:n.x,y:r.y!==void 0?r.y:n.y}},{x:i.x,y:i.y}]):null:qw(a,n,t)?(r[a]=n[a],[{x:n.x,y:n.y},{x:r.x!==void 0?r.x:i.x,y:r.y!==void 0?r.y:i.y,original:{x:r.x!==void 0?r.x:i.x,y:r.y!==void 0?r.y:i.y}}]):null):null}function OL(e,t,n,i){return kh(e,t,n,i)}function DL(e,t,n,i){var o=i.slice().reverse();return o=kh(e,t,n,o),o?o.reverse():null}function kh(e,t,n,i){function o(u){return u.length<3?!0:u.length>4?!1:!!It(u,function(p,f){var d=u[f-1];return d&&Rs(p,d)<3})}function r(u,p,f){var d=vo(p,u);switch(d){case"v":return{x:f.x,y:u.y};case"h":return{x:u.x,y:f.y}}return{x:u.x,y:u.y}}function a(u,p,f){var d;for(d=u.length-2;d!==0;d--)if(bv(u[d],p,Vw)||bv(u[d],f,Vw))return u.slice(d);return u}if(o(i))return null;var s=i[0],c=i.slice(),l;return c[0]=n,c[1]=r(c[1],s,n),l=a(c,e,t),l!==c&&(c=kh(e,t,n,l)),c&&vo(c)?null:c}function LL(e,t){if(Yw(t))return t;switch(e){case"intersect":return"t:t";case"top":case"bottom":return"v:v";case"left":case"right":return"h:h";default:return t}}function IL(e){return e&&/^h|v|t|r|b|l:h|v|t|r|b|l$/.test(e)}function Yw(e){return e&&/t|r|b|l/.test(e)}function BL(e){return{top:"bottom",bottom:"top",left:"right",right:"left","top-left":"bottom-right","bottom-right":"top-left","top-right":"bottom-left","bottom-left":"top-right"}[e]}function Kw(e,t,n,i){if(n==="h"&&(n=/left/.test(i)?"l":"r"),n==="v"&&(n=/top/.test(i)?"t":"b"),n==="t")return{original:e,x:e.x,y:t.y};if(n==="r")return{original:e,x:t.x+t.width,y:e.y};if(n==="b")return{original:e,x:e.x,y:t.y+t.height};if(n==="l")return{original:e,x:t.x,y:e.y};throw new Error("unexpected dockingDirection: <"+n+">")}function Xw(e){return e.reduce(function(t,n,i){var o=t[t.length-1],r=e[i+1];return Yf(o,r,n,0)||t.push(n),t},[])}var NL=-10,$L=40,FL={default:["h:h"],fromGateway:["v:h"],toGateway:["h:v"],loop:{fromTop:["t:r"],fromRight:["r:b"],fromLeft:["l:t"],fromBottom:["b:l"]},boundaryLoop:{alternateHorizontalSide:"b",alternateVerticalSide:"l",default:"v"},messageFlow:["straight","v:v"],subProcess:["straight","h:h"],isHorizontal:!0},jL={default:["v:v"],fromGateway:["h:v"],toGateway:["v:h"],loop:{fromTop:["t:l"],fromRight:["r:t"],fromLeft:["l:b"],fromBottom:["b:r"]},boundaryLoop:{alternateHorizontalSide:"t",alternateVerticalSide:"r",default:"h"},messageFlow:["straight","h:h"],subProcess:["straight","v:v"],isHorizontal:!1},Oh={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},nc={top:"t",right:"r",bottom:"b",left:"l"};function Ru(e){this._elementRegistry=e}Ne(Ru,Gw),Ru.prototype.layoutConnection=function(e,t){t||(t={});var n=t.source||e.source,i=t.target||e.target,o=t.waypoints||e.waypoints,r=t.connectionStart,a=t.connectionEnd,s=this._elementRegistry,c,l;if(r||(r=Zw(o&&o[0],n)),a||(a=Zw(o&&o[o.length-1],i)),(M(e,"bpmn:Association")||M(e,"bpmn:DataAssociation"))&&o&&!Qw(n,i))return[].concat([r],o.slice(1,-1),[a]);var u=lb(n,s)?FL:jL;return M(e,"bpmn:MessageFlow")?c=zL(n,i,u):(M(e,"bpmn:SequenceFlow")||Qw(n,i))&&(n===i?c={preferredLayouts:YL(n,e,u)}:M(n,"bpmn:BoundaryEvent")?c={preferredLayouts:KL(n,i,a,u)}:ic(n)||ic(i)?c={preferredLayouts:u.subProcess,preserveDocking:VL(n)}:M(n,"bpmn:Gateway")?c={preferredLayouts:u.fromGateway}:M(i,"bpmn:Gateway")?c={preferredLayouts:u.toGateway}:c={preferredLayouts:u.default}),c&&(c=Y(c,t),l=Xw(PL(n,i,r,a,o,c))),l||[r,a]};function HL(e){var t=e.host;return On(Je(e),t,NL)}function zL(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:GL(e,t)}}function GL(e,t){return M(t,"bpmn:Participant")?"source":M(e,"bpmn:Participant")?"target":ic(t)?"source":ic(e)||M(t,"bpmn:Event")?"target":M(e,"bpmn:Event")?"source":null}function VL(e){return ic(e)?"target":"source"}function Zw(e,t){return e?e.original||e:Je(t)}function Qw(e,t){return M(t,"bpmn:Activity")&&M(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function ic(e){return M(e,"bpmn:SubProcess")&&ht(e)}function Wr(e,t){return e===t}function WL(e,t){return t.indexOf(e)!==-1}function $a(e){var t=/right|left/.exec(e);return t&&t[0]}function Fa(e){var t=/top|bottom/.exec(e);return t&&t[0]}function Jw(e,t){return Oh[e]===t}function UL(e,t){var n=$a(e),i=Oh[n];return t.indexOf(i)!==-1}function qL(e,t){var n=Fa(e),i=Oh[n];return t.indexOf(i)!==-1}function e_(e){return e==="right"||e==="left"}function YL(e,t,n){var i=t.waypoints,o=i&&i.length&&On(i[0],e);return o==="top"?n.loop.fromTop:o==="right"?n.loop.fromRight:o==="left"?n.loop.fromLeft:n.loop.fromBottom}function KL(e,t,n,i){var o=Je(e),r=Je(t),a=HL(e),s,c,l=Wr(e.host,t),u=WL(a,["top","right","bottom","left"]),p=On(r,o,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return l?XL(a,u,e,t,n,i):(s=ZL(a,p,u,i.isHorizontal),c=QL(a,p,u,i.isHorizontal),[s+":"+c])}function XL(e,t,n,i,o,r){var a=t?e:r.isHorizontal?Fa(e):$a(e),s=nc[a],c;return t?e_(e)?c=t_("y",n,i,o)?"h":r.boundaryLoop.alternateHorizontalSide:c=t_("x",n,i,o)?"v":r.boundaryLoop.alternateVerticalSide:c=r.boundaryLoop.default,[s+":"+c]}function t_(e,t,n,i){var o=$L;return!(Dh(e,i,n,o)||Dh(e,i,{x:n.x+n.width,y:n.y+n.height},o)||Dh(e,i,Je(t),o))}function Dh(e,t,n,i){return Math.abs(t[e]-n[e])<i}function ZL(e,t,n,i){if(n)return nc[e];var o=Fa(e),r=$a(e),a=Fa(t),s=$a(t);if(i){if(Wr(o,a)||Jw(r,s))return nc[o]}else if(Wr(r,s)||Jw(o,a))return nc[r];return nc[i?r:o]}function QL(e,t,n,i){if(n)return e_(e)?UL(e,t)||Wr(e,t)?"h":"v":qL(e,t)||Wr(e,t)?"v":"h";var o=Fa(e),r=$a(e),a=Fa(t),s=$a(t);return a&&!s?"v":s&&!a?"h":i?Wr(o,a)?"h":"v":Wr(r,s)?"v":"h"}Ru.$inject=["elementRegistry"];function n_(e){return Y({original:e.point.original||e.point},e.actual)}function cr(e,t){this._elementRegistry=e,this._graphicsFactory=t}cr.$inject=["elementRegistry","graphicsFactory"],cr.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var i=this.getDockingPoint(e,t,!0),o=this.getDockingPoint(e,n),r=e.waypoints.slice(i.idx+1,o.idx);return r.unshift(n_(i)),r.push(n_(o)),r},cr.prototype.getDockingPoint=function(e,t,n){var i=e.waypoints,o,r,a;return o=n?0:i.length-1,r=i[o],a=this._getIntersection(t,e,n),{point:r,actual:a||r,idx:o}},cr.prototype._getIntersection=function(e,t,n){var i=this._getShapePath(e),o=this._getConnectionPath(t);return Cs(i,o,n)},cr.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)},cr.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)},cr.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};const Lh={__init__:["modeling","bpmnUpdater"],__depends__:[yO,DO,IO,BO,hw,ND,FD,WD,Mi,yh,xw],bpmnFactory:["type",Pi],bpmnUpdater:["type",ci],elementFactory:["type",rr],modeling:["type",In],layouter:["type",Ru],connectionDocking:["type",cr]};var JL=10,i_=50,eI=250;function Ih(e,t,n,i){for(var o;o=tI(e,n,t);)n=i(t,n,o);return n}function Bh(e){return function(t,n,i){var o={x:n.x,y:n.y};return["x","y"].forEach(function(r){var a=e[r];if(a){var s=r==="x"?"width":"height",c=a.margin,l=a.minDistance;c<0?o[r]=Math.min(i[r]+c-t[s]/2,n[r]-l+c):o[r]=Math.max(i[r]+i[s]+c+t[s]/2,n[r]+l+c)}}),o}}function tI(e,t,n){var i={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height},o=iI(e);return It(o,function(r){if(r===n)return!1;var a=On(r,i,JL);return a==="intersect"})}function nI(e,t){t||(t={});function n(g){return g.source===e?1:-1}var i=t.defaultDistance||i_,o=t.direction||"e",r=t.filter,a=t.getWeight||n,s=t.maxDistance||eI,c=t.reference||"start";r||(r=aI);function l(g,h){return o==="n"?c==="start"?qe(g).top-qe(h).bottom:c==="center"?qe(g).top-Je(h).y:qe(g).top-qe(h).top:o==="w"?c==="start"?qe(g).left-qe(h).right:c==="center"?qe(g).left-Je(h).x:qe(g).left-qe(h).left:o==="s"?c==="start"?qe(h).top-qe(g).bottom:c==="center"?Je(h).y-qe(g).bottom:qe(h).bottom-qe(g).bottom:c==="start"?qe(h).left-qe(g).right:c==="center"?Je(h).x-qe(g).right:qe(h).right-qe(g).right}var u=e.incoming.filter(r).map(function(g){var h=a(g),m=h<0?l(g.source,e):l(e,g.source);return{id:g.source.id,distance:m,weight:h}}),p=e.outgoing.filter(r).map(function(g){var h=a(g),m=h>0?l(e,g.target):l(g.target,e);return{id:g.target.id,distance:m,weight:h}}),f=u.concat(p).reduce(function(g,h){return g[h.id+"__weight_"+h.weight]=h,g},{}),d=ni(f,function(g,h){var m=h.distance,w=h.weight;return m<0||m>s||(g[String(m)]||(g[String(m)]=0),g[String(m)]+=1*w,(!g.distance||g[g.distance]<g[String(m)])&&(g.distance=m)),g},{});return d.distance||i}function iI(e){var t=Nh(e);return e.host&&(t=t.concat(Nh(e.host))),e.attachers&&(t=t.concat(e.attachers.reduce(function(n,i){return n.concat(Nh(i))},[]))),t}function Nh(e){return rI(e).concat(oI(e))}function oI(e){return e.incoming.map(function(t){return t.source})}function rI(e){return e.outgoing.map(function(t){return t.target})}function aI(){return!0}var sI=100;function o_(e,t,n){e.on("autoPlace",sI,function(i){var o=i.shape,r=i.source;return cI(r,o)}),e.on("autoPlace.end",function(i){n.scrollToElement(i.shape)}),this.append=function(i,o,r){e.fire("autoPlace.start",{source:i,shape:o});var a=e.fire("autoPlace",{source:i,shape:o}),s=t.appendShape(i,o,a,i.parent,r);return e.fire("autoPlace.end",{source:i,shape:s}),s}}o_.$inject=["eventBus","modeling","canvas"];function cI(e,t,n){n||(n={});var i=n.defaultDistance||i_,o=Je(e),r=qe(e);return{x:r.right+i+t.width/2,y:o.y}}function r_(e,t){e.on("autoPlace.end",500,function(n){t.select(n.shape)})}r_.$inject=["eventBus","selection"];const lI={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",o_],autoPlaceSelectionBehavior:["type",r_]};function a_(e,t,n){var i=lb(e,n);if(M(t,"bpmn:TextAnnotation"))return pI(e,t,i);if(st(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"]))return fI(e,t,i);if(M(t,"bpmn:FlowNode"))return uI(e,t,i)}function uI(e,t,n){var i=qe(e),o=Je(e),r=n?{directionHint:"e",minDistance:80,baseOrientation:"left",boundaryOrientation:"top",start:"top",end:"bottom"}:{directionHint:"s",minDistance:90,baseOrientation:"top",boundaryOrientation:"left",start:"left",end:"right"},a=nI(e,{filter:function(d){return M(d,"bpmn:SequenceFlow")},direction:r.directionHint}),s=30,c=r.minDistance,l=r.baseOrientation;M(e,"bpmn:BoundaryEvent")&&(l=On(e,e.host,-25),l.indexOf(r.boundaryOrientation)!==-1&&(s*=-1));var u=n?{x:i.right+a+t.width/2,y:o.y+s_(l,c,r)}:{x:o.x+s_(l,c,r),y:i.bottom+a+t.height/2},p={margin:s,minDistance:c},f=n?{y:p}:{x:p};return Ih(e,t,u,Bh(f))}function s_(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function pI(e,t,n){var i=qe(e),o=n?{x:i.right+t.width/2,y:i.top-50-t.height/2}:{x:i.right+50+t.width/2,y:i.bottom+t.height/2};Ot(e)&&(o=Je(e),n?(o.x+=100,o.y-=50):(o.x+=100,o.y+=50));var r={margin:n?-30:30,minDistance:20},a=n?{y:r}:{x:r};return Ih(e,t,o,Bh(a))}function fI(e,t,n){var i=qe(e),o=n?{x:i.right-10+t.width/2,y:i.bottom+40+t.width/2}:{x:i.left-40-t.width/2,y:i.bottom-10+t.height/2},r={margin:30,minDistance:30},a=n?{x:r}:{y:r};return Ih(e,t,o,Bh(a))}function c_(e,t){e.on("autoPlace",function(n){var i=n.shape,o=n.source;return a_(o,i,t)})}c_.$inject=["eventBus","elementRegistry"];const Cu={__depends__:[lI],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",c_]};function Ao(e,t,n,i){we.call(this,e),this._elementRegistry=t,this._modeling=n,this._rules=i;var o=this;this.postExecuted(["shape.create"],function(r){var a=r.context,s=a.hints||{},c=a.shape,l=a.parent||a.newParent;s.autoResize!==!1&&o._expand([c],l)}),this.postExecuted(["elements.move"],function(r){var a=r.context,s=Ip(aa(a.closure.topLevel)),c=a.hints,l=c?c.autoResize:!0;if(l!==!1){var u=sa(s,function(p){return p.parent.id});V(u,function(p,f){Ze(l)&&(p=p.filter(function(d){return It(l,ca({id:d.id}))})),o._expand(p,f)})}}),this.postExecuted(["shape.toggleCollapse"],function(r){var a=r.context,s=a.hints,c=a.shape;s&&s.autoResize===!1||c.collapsed||o._expand(c.children||[],c)}),this.postExecuted(["shape.resize"],function(r){var a=r.context,s=a.hints,c=a.shape,l=c.parent;s&&s.autoResize===!1||l&&o._expand([c],l)})}Ao.$inject=["eventBus","elementRegistry","modeling","rules"],Ne(Ao,we),Ao.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),i=this.getPadding(t),o=qe(cn(e)),r=qe(t),a={};return o.top-r.top<i.top&&(a.top=o.top-n.top),o.left-r.left<i.left&&(a.left=o.left-n.left),r.right-o.right<i.right&&(a.right=o.right+n.right),r.bottom-o.bottom<i.bottom&&(a.bottom=o.bottom+n.bottom),bl(Y({},r,a))},Ao.prototype._expand=function(e,t){typeof t=="string"&&(t=this._elementRegistry.get(t));var n=this._rules.allowed("element.autoResize",{elements:e,target:t});if(n){var i=this._getOptimalBounds(e,t);if(dI(i,t)){var o=hI(Ni(t,["x","y","width","height"]),i);this.resize(t,i,{autoResize:o});var r=t.parent;r&&this._expand([t],r)}}},Ao.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}},Ao.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}},Ao.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)};function dI(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function hI(e,t){var n="";return e=qe(e),t=qe(t),e.top>t.top&&(n=n.concat("n")),e.right<t.right&&(n=n.concat("w")),e.bottom<t.bottom&&(n=n.concat("s")),e.left>t.left&&(n=n.concat("e")),n}function Mu(e){e.invoke(Ao,this)}Mu.$inject=["injector"],Ne(Mu,Ao),Mu.prototype.resize=function(e,t,n){M(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)};function oc(e){Ci.call(this,e);var t=this;this.addRule("element.autoResize",function(n){return t.canResize(n.elements,n.target)})}oc.$inject=["eventBus"],Ne(oc,Ci),oc.prototype.canResize=function(e,t){return!1};function Au(e,t){oc.call(this,e),this._modeling=t}Ne(Au,oc),Au.$inject=["eventBus","modeling"],Au.prototype.canResize=function(e,t){if(M(t.di,"bpmndi:BPMNPlane")||!M(t,"bpmn:Participant")&&!M(t,"bpmn:Lane")&&!M(t,"bpmn:SubProcess"))return!1;var n=!0;return V(e,function(i){if(M(i,"bpmn:Lane")||at(i)){n=!1;return}}),n};const l_={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",Mu],bpmnAutoResizeProvider:["type",Au]},gI=1500;class u_{constructor(t){t.on("moddleCopy.canCopyProperties",gI,({sourceElement:n,targetElement:i})=>{var r;if(!((r=n==null?void 0:n.$instanceOf)!=null&&r.call(n,Mr)))return;const o=Rn(n);o!==void 0&&i.set("xml:lang",o)})}}$n(u_,"$inject",["eventBus"]);const p_={__init__:["translationLocaleCopy"],translationLocaleCopy:["type",u_]},mI=500,Pu=1,f_=(e,t)=>{if((e==null?void 0:e.type)!=="bpmn:TextAnnotation"||!(t!=null&&t.original))return;const{x:n,y:i}=t.original;(n<e.x-Pu||n>e.x+e.width+Pu||i<e.y-Pu||i>e.y+e.height+Pu)&&(t.original={x:Math.round(e.x+e.width/2),y:Math.round(e.y+e.height/2)})};class d_{constructor(t){t.on("bpmnElement.added",mI,({element:n})=>{if((n==null?void 0:n.type)!=="bpmn:Association")return;const i=n.waypoints;!i||i.length<2||(f_(n.source,i[0]),f_(n.target,i[i.length-1]))})}}$n(d_,"$inject",["eventBus"]);const h_={__init__:["annotationImportDocking"],annotationImportDocking:["type",d_]},g_=[sb,Os,Lh,Cu,l_,Wp,p_,h_];function yI(e={}){Rm(globalThis,e.dom);const t=document.createElement("div");return document.body.appendChild(t),new Ea({container:t,moddleExtensions:e.moddleExtensions??Hc,additionalModules:[...g_,...e.additionalModules??[]]})}const m_={"edge-crosses-shape":"연결","edge-crosses-subprocess":"연결","edge-endpoint-detached":"연결","edge-overlap-opposite":"겹침","edge-overlap-mixed":"겹침","edge-overlap-unrelated":"겹침","shape-overlap":"겹침","shape-outside-container":"소속","label-on-shared-segment":"라벨","label-over-line":"라벨","label-over-shape":"라벨","annotation-over-label":"라벨","pool-name-over-label":"라벨","group-overlap-unintended":"그룹","group-overlap-unreadable":"그룹","group-stack-unreadable":"그룹","group-on-container-boundary":"그룹","group-on-group-boundary":"그룹","group-cuts-shape":"그룹","edge-along-group-boundary":"그룹","pool-overlap":"풀","CHK-FLOW-1":"구조","CHK-POOL-1":"풀"},vI={이:["이","가"],을:["을","를"],와:["과","와"]};function bI(e,t){const[n,i]=vI[t],o=e.at(-1)??"",r=o.charCodeAt(0);return r>=44032&&r<=55203?e+((r-44032)%28===0?i:n):o>="0"&&o<="9"?e+("013678".includes(o)?n:i):e+`${n}(${i})`}const xI={"bpmn:StartEvent":"시작 이벤트","bpmn:EndEvent":"종료 이벤트","bpmn:IntermediateCatchEvent":"중간 이벤트","bpmn:IntermediateThrowEvent":"중간 이벤트","bpmn:BoundaryEvent":"경계 이벤트","bpmn:Task":"작업","bpmn:UserTask":"작업","bpmn:ServiceTask":"작업","bpmn:SendTask":"작업","bpmn:ReceiveTask":"작업","bpmn:ManualTask":"작업","bpmn:ScriptTask":"작업","bpmn:BusinessRuleTask":"작업","bpmn:CallActivity":"작업","bpmn:SubProcess":"서브프로세스","bpmn:ExclusiveGateway":"게이트웨이","bpmn:ParallelGateway":"게이트웨이","bpmn:InclusiveGateway":"게이트웨이","bpmn:EventBasedGateway":"게이트웨이","bpmn:ComplexGateway":"게이트웨이","bpmn:Participant":"풀","bpmn:Lane":"레인","bpmn:TextAnnotation":"주석","bpmn:Group":"그룹","bpmn:DataStoreReference":"데이터 저장소","bpmn:DataObjectReference":"데이터 객체","bpmn:SequenceFlow":"연결선","bpmn:MessageFlow":"메시지 연결선","bpmn:Association":"연관선"},wI="요소";function $h(e){return(e&&xI[e.type])??wI}const y_=20;function _I(e){const t=e.replace(/\s+/g," ").trim();return t.length>y_?`${t.slice(0,y_)}…`:t}function Tu(e,t,n,i=""){const o=e(t),r=(o==null?void 0:o.name)===void 0?void 0:_I(o.name),a=r===void 0?i+$h(o):r,s=r===void 0?a:`「${r}」`;return n?s+bI(a,n).slice(a.length):s}function EI(e,t,n,i,o){const[r,a]=[e(t),e(n)],s=(r==null?void 0:r.name)===void 0&&(a==null?void 0:a.name)===void 0&&$h(r)===$h(a);return[Tu(e,t,i),Tu(e,n,o,s?"다른 ":"")]}function SI(e){switch(e.kind){case"shape-overlap":return e.identical?"error":"warning";case"shape-outside-container":return"error";case"edge-endpoint-detached":return"error";case"pool-overlap":return e.contained?"error":"warning";case"group-cuts-shape":return"error";default:return"warning"}}function RI(e){switch(e.kind){case"edge-crosses-shape":return[e.edge,e.shape];case"edge-crosses-subprocess":return[e.edge,e.subProcess];case"edge-endpoint-detached":return[e.edge,e.shape];case"shape-overlap":return[...e.shapes];case"shape-outside-container":return[e.shape,e.container];case"edge-overlap-opposite":case"edge-overlap-mixed":case"edge-overlap-unrelated":return[...e.edges];case"label-on-shared-segment":return[e.edge,e.other];case"label-over-line":return[e.edge,e.line];case"label-over-shape":return[e.edge,e.shape];case"annotation-over-label":return[e.annotation,e.label];case"group-overlap-unintended":return e.container?[e.container,...e.groups.filter(t=>t!==e.container)]:[...e.groups];case"group-overlap-unreadable":return e.reason==="orphan"?[...e.groups,...e.shapes]:[e.group,...e.shapes];case"group-stack-unreadable":return[...e.groups,...e.shapes];case"group-on-container-boundary":return[e.group,e.container];case"group-on-group-boundary":return[...e.groups];case"group-cuts-shape":return[e.group,e.shape];case"edge-along-group-boundary":return[e.edge,e.group];case"pool-name-over-label":return[e.pool,e.label];case"pool-overlap":return[...e.pools]}}const ku={top:"위",bottom:"아래",left:"왼쪽",right:"오른쪽"};function CI(e,t){const n=(o,r)=>Tu(t,o,r),i=(o,r,a,s)=>EI(t,o,r,a,s);switch(e.kind){case"edge-crosses-shape":return`${n(e.edge,"이")} ${n(e.shape,"을")} 가로지릅니다.`;case"edge-crosses-subprocess":return`${n(e.edge,"이")} 서브프로세스 ${n(e.subProcess)} 안을 지나갑니다.`;case"edge-endpoint-detached":return`${n(e.edge)}의 끝이 ${n(e.shape)}에서 ${Math.round(e.distance)}px 떨어져 연결이 끊겨 보입니다.`;case"shape-overlap":{const[o,r]=i(e.shapes[0],e.shapes[1],"와","이");return e.identical?`${o} ${r} 완전히 같은 자리에 겹쳐 하나가 가려집니다.`:`${o} ${r} 겹칩니다.`}case"shape-outside-container":return`${n(e.shape,"이")} ${n(e.container)} 경계 밖에 놓여 다른 소속으로 읽힙니다.`;case"edge-overlap-opposite":{const[o,r]=i(e.edges[0],e.edges[1],"와","이");return`${o} ${r} 같은 선 위를 ${Math.round(e.length)}px 서로 반대 방향으로 흐릅니다.`}case"edge-overlap-mixed":{const[o,r]=i(e.edges[0],e.edges[1],"와","이");return`${o} ${r} 종류가 다른 선인데 ${Math.round(e.length)}px 겹쳐 흐릅니다.`}case"edge-overlap-unrelated":{const[o,r]=i(e.edges[0],e.edges[1],"와","이");return`${o} ${r} ${Math.round(e.length)}px 한 선처럼 겹쳐 흐르는데 만나는 지점이 없습니다.`}case"label-on-shared-segment":{const[o,r]=i(e.edge,e.other,void 0,"와");return`${o}의 라벨이 ${r} 공유하는 구간 위에 있어 어느 선의 것인지 모호합니다.`}case"label-over-line":return`${n(e.edge)}의 라벨을 선이 가로지릅니다.`;case"label-over-shape":return`${n(e.edge)}의 라벨이 ${n(e.shape)} 위에 ${e.depth}px 겹쳐 있습니다.`;case"annotation-over-label":return`주석 ${n(e.annotation,"이")} ${n(e.label)}의 이름 라벨을 덮습니다.`;case"group-overlap-unintended":{if(e.container)return`${n(e.container,"이")} 다른 그룹을 통째로 덮습니다.`;const[o,r]=i(e.groups[0],e.groups[1],"와","이");return`${o} ${r} 공유 멤버 없이 겹쳐 의도인지 알 수 없습니다.`}case"group-overlap-unreadable":switch(e.reason){case"orphan":{const[o,r]=i(e.groups[0],e.groups[1],"와");return`${o} ${r}의 겹친 영역에 어느 그룹에도 속하지 않은 요소가 ${e.shapes.length}개 있습니다.`}case"minority":return`${n(e.group)} 상자 안에서 자기 멤버가 과반이 아닙니다(다른 요소 ${e.shapes.length}개).`;case"throughpass":return`${n(e.group)} 상자를 자기 멤버가 아닌 요소 ${e.shapes.length}개가 지나갑니다.`}case"group-stack-unreadable":return`그룹 ${e.groups.length}개가 겹쳐 쌓여 요소 ${e.shapes.length}개가 어느 단계인지 읽히지 않습니다.`;case"group-on-container-boundary":return`${n(e.group)} 테두리가 ${n(e.container)}의 ${ku[e.side]} 경계선과 겹쳐 흐릅니다.`;case"group-on-group-boundary":{const[o,r]=i(e.groups[0],e.groups[1],"와");return`${o} ${r}의 테두리가 같은 선 위에 겹칩니다.`}case"group-cuts-shape":return`${n(e.group)} 테두리가 ${n(e.shape)}의 ${ku[e.side]}을(를) ${Math.round(e.depth)}px 가릅니다.`;case"edge-along-group-boundary":return e.distance===0?`${n(e.edge,"이")} ${n(e.group)}의 ${ku[e.side]} 테두리 위를 ${e.length}px 겹쳐 흐릅니다.`:`${n(e.edge,"이")} ${n(e.group)}의 ${ku[e.side]} 테두리 ${e.inside?"안쪽":"바깥쪽"} ${e.distance}px 에 ${e.length}px 나란히 흘러 테두리와 구분되지 않습니다.`;case"pool-name-over-label":return`${n(e.pool)}의 이름 밴드가 ${n(e.label)}의 라벨을 덮습니다.`;case"pool-overlap":{const[o,r]=i(e.pools[0],e.pools[1],"와","이");return e.contained?`${o} ${r} 중 하나가 다른 하나 안에 들어가 있습니다.`:`${o} ${r} 겹칩니다.`}}}function MI(e,t){switch(e.ruleId){case"CHK-FLOW-1":return`${Tu(t,e.targetRefs[0])}에 연결된 선이 하나도 없습니다 — 분기·합류가 없는 게이트웨이는 의미가 정해지지 않습니다.`;case"CHK-POOL-1":return`이 문서에 내용이 없는 풀 ${e.targetRefs.length}개가 펼친 형태로 그려져 있습니다 — 이 문서에서 내용을 그리지 않는 풀은 접힌 형태(블랙박스)가 의미에 맞습니다.`;default:return e.ruleId}}const v_="기타",Fh={error:0,warning:1,info:2};function b_(e,t){const n=[];for(const i of e.geometry)n.push({key:`g:${pt(i)}`,source:"geometry",code:i.kind,severity:SI(i),targetRefs:RI(i),category:m_[i.kind]??v_,message:CI(i,t)});for(const i of e.semantic)n.push({key:`s:${i.ruleId}|${i.targetRefs.join(",")}`,source:"semantic",code:i.ruleId,severity:i.severity,targetRefs:[...i.targetRefs],category:m_[i.ruleId]??v_,message:MI(i,t)});return n}function x_(e){const t={error:0,warning:0,info:0};for(const n of e)t[n.severity]++;return t}function ja(e,t){return t!==void 0&&e.targetRefs.some(n=>t.has(n))}function jh(e,t){if(t===void 0||e.length===0)return!1;const n=ja(e[0],t);return e.some(i=>ja(i,t)!==n)}function w_(e,t){const n=jh(e,t);return e.slice().sort((i,o)=>(n?Number(ja(o,t))-Number(ja(i,t)):0)||Fh[i.severity]-Fh[o.severity])}const __="i18n-untranslated",E_="i18n-review-requested",Hh="i18nDisplay.redrawn",S_=[["untranslated",__],["reviewRequested",E_]];class zh{constructor(t,n,i,o,r,a,s,c){$n(this,"config");$n(this,"displayLocale");this.eventBus=t,this.elementRegistry=n,this.canvas=a,this.textRenderer=s,this.graphicsFactory=c;const l=o.drawShape.bind(o);o.drawShape=(f,d,g)=>this.withDisplayText(d,()=>l(f,d,g),f);const u=r.activate.bind(r);r.activate=f=>this.withDisplayText(f,()=>u(f));const p=r.update.bind(r);r.update=(f,d,g,h)=>{const m=this.resolve(f);if(!m||m.native)return p(f,d,g,h);(d??"").trim()!==(g??"").trim()&&i.execute(Ic,{element:f.labelTarget??f,locale:this.displayLocale,text:d,designLocale:this.config.designLocale,locales:this.locales(),rootLang:this.rootLang()})},t.on("commandStack.element.updateLabel.postExecute",f=>{if(!this.config)return;const{element:d,newLabel:g,oldLabel:h}=f.context;(g??"")!==(h??"")&&i.execute(Ic,{element:d.labelTarget??d,locale:this.displayLocale,text:g??"",designLocale:this.config.designLocale,locales:this.locales(),rootLang:this.rootLang(),nameChangedFrom:h??""})})}configure(t){!t&&!this.config||(this.config=t,this.displayLocale=t==null?void 0:t.designLocale,this.rerenderAll())}locales(){if(!this.config)return[];const{designLocale:t,companionLocales:n}=this.config;return[t,...n.filter(i=>i!==t)]}setDisplayLocale(t){if(this.config)return this.displayLocale=this.locales().includes(t)?t:this.config.designLocale,this.rerenderAll(),this.displayLocale}getDisplayLocale(){return this.displayLocale}rootLang(){var i,o,r;const t=(i=this.canvas.getRootElement())==null?void 0:i.businessObject,n=(t==null?void 0:t.$parent)??t;return((o=n==null?void 0:n.get)==null?void 0:o.call(n,"xml:lang"))??((r=n==null?void 0:n.$attrs)==null?void 0:r["xml:lang"])}resolve(t){if(!this.config||!this.displayLocale)return;const n=(t.labelTarget??t).businessObject,i=Ar(n);if(!i)return;const o=this.displayLocale,r=i.target[i.key]??"",a=No(n).filter(f=>Rn(f)),s=f=>f.body??"",c=a.find(f=>Rn(f)===o&&s(f)),l=$o(n).some(f=>f.locale===o)?"reviewRequested":"ok";if(!r)return c?{text:s(c),status:l,native:!1}:void 0;const u=a.filter(f=>s(f)===r).map(Rn);return(u.length?u:[this.rootLang()??this.config.designLocale]).includes(o)?{text:r,status:l,native:!0}:c?{text:s(c),status:l,native:!1}:{text:r,status:"untranslated",native:!1}}untranslatedCount(t){return this.countStatus(t,"untranslated")}reviewRequestedCount(t){return this.countStatus(t,"reviewRequested")}countStatus(t,n){var r;if(!this.config)return 0;const i=this.displayLocale;this.displayLocale=t;let o=0;try{for(const a of this.elementRegistry.getAll())a.type!=="label"&&((r=this.resolve(a))==null?void 0:r.status)===n&&o++}finally{this.displayLocale=i}return o}withDisplayText(t,n,i){var f;if(!this.config)return n();const o=this.resolve(t),r=(f=i==null?void 0:i.parentNode)==null?void 0:f.classList;if(r)for(const[d,g]of S_)r.toggle(g,(o==null?void 0:o.status)===d);if(!o||o.native)return n();const{target:a,key:s}=Ar((t.labelTarget??t).businessObject),c=Object.prototype.hasOwnProperty.call(a,s),l=a[s];if(l===o.text)return n();a[s]=o.text;const u=this.config.adaptiveExternalLabel??!0,p=t.type==="label"&&u?this.widen(t,o.text):void 0;try{const d=n();return p&&(d!=null&&d.setAttribute)&&d.setAttribute("transform",`translate(${p.dx}, 0)`),d}finally{c?a[s]=l:delete a[s],p==null||p.restore()}}widen(t,n){const{width:i,height:o}=t,r=this.textRenderer.getExternalLabelBounds(t,n);return t.width=r.width,t.height=r.height,{dx:(i-r.width)/2,restore:()=>(t.width=i,t.height=o)}}rerenderAll(){const t=this.canvas.getRootElement();for(const n of this.elementRegistry.getAll()){if(n===t)continue;const i=this.elementRegistry.getGraphics(n);if(i){if(!this.config)for(const[,o]of S_)i.classList.remove(o);this.graphicsFactory.update(n.waypoints?"connection":"shape",n,i)}}this.eventBus.fire(Hh)}}$n(zh,"$inject",["eventBus","elementRegistry","commandStack","bpmnRenderer","labelEditingProvider","canvas","textRenderer","graphicsFactory"]);const R_={__depends__:[Wp],__init__:["i18nDisplay"],i18nDisplay:["type",zh]};var AI=new zr("ov"),PI=500;function Mn(e,t,n,i){this._eventBus=t,this._canvas=n,this._elementRegistry=i,this._ids=AI,this._overlayDefaults=Y({show:null,scale:!0},e&&e.defaults),this._overlays={},this._overlayContainers=[],this._overlayRoot=TI(n.getContainer()),this._init()}Mn.$inject=["config.overlays","eventBus","canvas","elementRegistry"],Mn.prototype.get=function(e){if(ei(e)&&(e={id:e}),ei(e.element)&&(e.element=this._elementRegistry.get(e.element)),e.element){var t=this._getOverlayContainer(e.element,!0);return t?e.type?ct(t.overlays,ca({type:e.type})):t.overlays.slice():[]}else return e.type?ct(this._overlays,ca({type:e.type})):e.id?this._overlays[e.id]:null},Mn.prototype.add=function(e,t,n){if(mn(t)&&(n=t,t=null),e.id||(e=this._elementRegistry.get(e)),!n.position)throw new Error("must specifiy overlay position");if(!n.html)throw new Error("must specifiy overlay html");if(!e)throw new Error("invalid element specified");var i=this._ids.next();return n=Y({},this._overlayDefaults,n,{id:i,type:t,element:e,html:n.html}),this._addOverlay(n),i},Mn.prototype.remove=function(e){var t=this.get(e)||[];Ze(t)||(t=[t]);var n=this;V(t,function(i){var o=n._getOverlayContainer(i.element,!0);if(i&&(Zi(i.html),Zi(i.htmlContainer),delete i.htmlContainer,delete i.element,delete n._overlays[i.id]),o){var r=o.overlays.indexOf(i);r!==-1&&o.overlays.splice(r,1)}})},Mn.prototype.isShown=function(){return this._overlayRoot.style.display!=="none"},Mn.prototype.show=function(){Ou(this._overlayRoot)},Mn.prototype.hide=function(){Ou(this._overlayRoot,!1)},Mn.prototype.clear=function(){this._overlays={},this._overlayContainers=[],fl(this._overlayRoot)},Mn.prototype._updateOverlayContainer=function(e){var t=e.element,n=e.html,i=t.x,o=t.y;if(t.waypoints){var r=cn(t);i=r.x,o=r.y}C_(n,i,o),Cn(e.html,"data-container-id",t.id)},Mn.prototype._updateOverlay=function(e){var t=e.position,n=e.htmlContainer,i=e.element,o=t.left,r=t.top;if(t.right!==void 0){var a;i.waypoints?a=cn(i).width:a=i.width,o=t.right*-1+a}if(t.bottom!==void 0){var s;i.waypoints?s=cn(i).height:s=i.height,r=t.bottom*-1+s}C_(n,o||0,r||0),this._updateOverlayVisibilty(e,this._canvas.viewbox())},Mn.prototype._createOverlayContainer=function(e){var t=jt('<div class="djs-overlays" />');Un(t,{position:"absolute"}),this._overlayRoot.appendChild(t);var n={html:t,element:e,overlays:[]};return this._updateOverlayContainer(n),this._overlayContainers.push(n),n},Mn.prototype._updateRoot=function(e){var t=e.scale||1,n="matrix("+[t,0,0,t,-1*e.x*t,-1*e.y*t].join(",")+")";M_(this._overlayRoot,n)},Mn.prototype._getOverlayContainer=function(e,t){var n=It(this._overlayContainers,function(i){return i.element===e});return!n&&!t?this._createOverlayContainer(e):n},Mn.prototype._addOverlay=function(e){var t=e.id,n=e.element,i=e.html,o,r;i.get&&i.constructor.prototype.jquery&&(i=i.get(0)),ei(i)&&(i=jt(i)),r=this._getOverlayContainer(n),o=jt('<div class="djs-overlay" data-overlay-id="'+t+'">'),Un(o,{position:"absolute"}),o.appendChild(i),e.type&&At(o).add("djs-overlay-"+e.type);var a=this._canvas.findRoot(n),s=this._canvas.getRootElement();Ou(o,a===s),e.htmlContainer=o,r.overlays.push(e),r.html.appendChild(o),this._overlays[t]=e,this._updateOverlay(e),this._updateOverlayVisibilty(e,this._canvas.viewbox())},Mn.prototype._updateOverlayVisibilty=function(e,t){var n=e.show,i=this._canvas.findRoot(e.element),o=n&&n.minZoom,r=n&&n.maxZoom,a=e.htmlContainer,s=this._canvas.getRootElement(),c=!0;(i!==s||n&&(gn(o)&&o>t.scale||gn(r)&&r<t.scale))&&(c=!1),Ou(a,c),this._updateOverlayScale(e,t)},Mn.prototype._updateOverlayScale=function(e,t){var n=e.scale,i,o,r=e.htmlContainer,a,s="";n!==!0&&(n===!1?(i=1,o=1):(i=n.min,o=n.max),gn(i)&&t.scale<i&&(a=(1/t.scale||1)*i),gn(o)&&t.scale>o&&(a=(1/t.scale||1)*o)),gn(a)&&(s="scale("+a+","+a+")"),M_(r,s)},Mn.prototype._updateOverlaysVisibilty=function(e){var t=this;V(this._overlays,function(n){t._updateOverlayVisibilty(n,e)})},Mn.prototype._init=function(){var e=this._eventBus,t=this;function n(i){t._updateRoot(i),t._updateOverlaysVisibilty(i),t.show()}e.on("canvas.viewbox.changing",function(i){t.hide()}),e.on("canvas.viewbox.changed",function(i){n(i.viewbox)}),e.on(["shape.remove","connection.remove"],function(i){var o=i.element,r=t.get({element:o});V(r,function(c){t.remove(c.id)});var a=t._getOverlayContainer(o);if(a){Zi(a.html);var s=t._overlayContainers.indexOf(a);s!==-1&&t._overlayContainers.splice(s,1)}}),e.on("element.changed",PI,function(i){var o=i.element,r=t._getOverlayContainer(o,!0);r&&(V(r.overlays,function(a){t._updateOverlay(a)}),t._updateOverlayContainer(r))}),e.on("element.marker.update",function(i){var o=t._getOverlayContainer(i.element,!0);o&&At(o.html)[i.add?"add":"remove"](i.marker)}),e.on("root.set",function(){t._updateOverlaysVisibilty(t._canvas.viewbox())}),e.on("diagram.clear",this.clear,this)};function TI(e){var t=jt('<div class="djs-overlay-container" />');return Un(t,{position:"absolute",width:0,height:0}),e.insertBefore(t,e.firstChild),t}function C_(e,t,n){Un(e,{left:t+"px",top:n+"px"})}function Ou(e,t){e.style.display=t===!1?"none":""}function M_(e,t){e.style["transform-origin"]="top left",["","-ms-","-webkit-"].forEach(function(n){e.style[n+"transform"]=t})}const Du={__init__:["overlays"],overlays:["type",Mn]};function Gh(e,t){t.invoke(we,this),this.executed(function(n){var i=n.context;i.rootElement?e.setRootElement(i.rootElement):i.rootElement=e.getRootElement()}),this.revert(function(n){var i=n.context;i.rootElement&&e.setRootElement(i.rootElement)})}Ne(Gh,we),Gh.$inject=["canvas","injector"];const kI={__init__:["rootElementsBehavior"],rootElementsBehavior:["type",Gh]};function Ur(e){return CSS.escape(e)}var OI={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function A_(e){return e=""+e,e&&e.replace(/[&<>"']/g,function(t){return OI[t]})}var DI="bjs-breadcrumbs-shown";function P_(e,t,n){var i=jt('<ul class="bjs-breadcrumbs"></ul>'),o=n.getContainer(),r=At(o);o.appendChild(i);var a=[];e.on("element.changed",function(c){var l=c.element,u=_e(l),p=It(a,function(f){return f===u});p&&s()});function s(c){c&&(a=LI(c));var l=a.flatMap(function(p){var f=n.findRoot(no(p))||n.findRoot(p.id);if(!f&&M(p,"bpmn:Process")){var d=t.find(function(m){var w=_e(m);return w&&w.get("processRef")===p});f=d&&n.findRoot(d.id)}if(!f)return[];var g=A_(p.name||p.id),h=jt('<li><span class="bjs-crumb"><a title="'+g+'">'+g+"</a></span></li>");return h.addEventListener("click",function(){n.setRootElement(f)}),h});i.innerHTML="";var u=l.length>1;r.toggle(DI,u),l.forEach(function(p){i.appendChild(p)})}e.on("root.set",function(c){s(c.element)})}P_.$inject=["eventBus","elementRegistry","canvas"];function LI(e){for(var t=_e(e),n=[],i=t;i;i=i.$parent)(M(i,"bpmn:SubProcess")||M(i,"bpmn:Process"))&&n.push(i);return n.reverse()}function T_(e,t){var n=null,i=new II;e.on("root.set",function(o){var r=o.element,a=t.viewbox(),s=i.get(r);if(i.set(n,{x:a.x,y:a.y,zoom:a.scale}),n=r,!(!M(r,"bpmn:SubProcess")&&!s)){s=s||{x:0,y:0,zoom:1};var c=(a.x-s.x)*a.scale,l=(a.y-s.y)*a.scale;(c!==0||l!==0)&&t.scroll({dx:c,dy:l}),s.zoom!==a.scale&&t.zoom(s.zoom,{x:0,y:0})}}),e.on("diagram.clear",function(){i.clear(),n=null})}T_.$inject=["eventBus","canvas"];function II(){this._entries=[],this.set=function(e,t){var n=!1;for(var i in this._entries)if(this._entries[i][0]===e){this._entries[i][1]=t,n=!0;break}n||this._entries.push([e,t])},this.get=function(e){for(var t in this._entries)if(this._entries[t][0]===e)return this._entries[t][1];return null},this.clear=function(){this._entries.length=0},this.remove=function(e){var t=-1;for(var n in this._entries)if(this._entries[n][0]===e){t=n;break}t!==-1&&this._entries.splice(t,1)}}var k_={x:180,y:160};function qr(e,t){this._eventBus=e,this._moddle=t;var n=this;e.on("import.render.start",1500,function(i,o){n._handleImport(o.definitions)})}qr.prototype._handleImport=function(e){if(e.diagrams){var t=this;this._definitions=e,this._processToDiagramMap={},e.diagrams.forEach(function(i){!i.plane||!i.plane.bpmnElement||(t._processToDiagramMap[i.plane.bpmnElement.id]=i)});var n=e.diagrams.filter(i=>i.plane).flatMap(i=>t._createNewDiagrams(i.plane));n.forEach(function(i){t._movePlaneElementsToOrigin(i.plane)})}},qr.prototype._createNewDiagrams=function(e){var t=this,n=[],i=[];e.get("planeElement").forEach(function(r){var a=r.bpmnElement;if(a){var s=a.$parent;M(a,"bpmn:SubProcess")&&!r.isExpanded&&n.push(a),NI(a,e)&&i.push({diElement:r,parent:s})}});var o=[];return n.forEach(function(r){if(!t._processToDiagramMap[r.id]){var a=t._createDiagram(r);t._processToDiagramMap[r.id]=a,o.push(a)}}),i.forEach(function(r){for(var a=r.diElement,s=r.parent;s&&n.indexOf(s)===-1;)s=s.$parent;if(s){var c=t._processToDiagramMap[s.id];t._moveToDiPlane(a,c.plane)}}),o},qr.prototype._movePlaneElementsToOrigin=function(e){var t=e.get("planeElement"),n=BI(e),i={x:n.x-k_.x,y:n.y-k_.y};t.forEach(function(o){o.waypoint?o.waypoint.forEach(function(r){r.x=r.x-i.x,r.y=r.y-i.y}):o.bounds&&(o.bounds.x=o.bounds.x-i.x,o.bounds.y=o.bounds.y-i.y)})},qr.prototype._moveToDiPlane=function(e,t){var n=O_(e),i=n.plane.get("planeElement");i.splice(i.indexOf(e),1),t.get("planeElement").push(e)},qr.prototype._createDiagram=function(e){var t=this._moddle.create("bpmndi:BPMNPlane",{bpmnElement:e}),n=this._moddle.create("bpmndi:BPMNDiagram",{plane:t});return t.$parent=n,t.bpmnElement=e,n.$parent=this._definitions,this._definitions.diagrams.push(n),n},qr.$inject=["eventBus","moddle"];function O_(e){return M(e,"bpmndi:BPMNDiagram")?e:O_(e.$parent)}function BI(e){var t={top:1/0,right:-1/0,bottom:-1/0,left:1/0};return e.planeElement.forEach(function(n){if(n.bounds){var i=qe(n.bounds);t.top=Math.min(i.top,t.top),t.left=Math.min(i.left,t.left)}}),bl(t)}function NI(e,t){var n=e.$parent;return!(!M(n,"bpmn:SubProcess")||n===t.bpmnElement||st(e,["bpmn:DataInputAssociation","bpmn:DataOutputAssociation"]))}var Lu=250,$I='<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.81801948,3.50735931 L10.4996894,9.1896894 L10.5,4 L12,4 L12,12 L4,12 L4,10.5 L9.6896894,10.4996894 L3.75735931,4.56801948 C3.46446609,4.27512627 3.46446609,3.80025253 3.75735931,3.50735931 C4.05025253,3.21446609 4.52512627,3.21446609 4.81801948,3.50735931 Z"/></svg>',FI="bjs-drilldown-empty";function lr(e,t,n,i,o){we.call(this,t),this._canvas=e,this._eventBus=t,this._elementRegistry=n,this._overlays=i,this._translate=o;var r=this;this.executed("shape.toggleCollapse",Lu,function(a){var s=a.shape;r._canDrillDown(s)?r._addOverlay(s):r._removeOverlay(s)},!0),this.reverted("shape.toggleCollapse",Lu,function(a){var s=a.shape;r._canDrillDown(s)?r._addOverlay(s):r._removeOverlay(s)},!0),this.executed(["shape.create","shape.move","shape.delete"],Lu,function(a){var s=a.oldParent,c=a.newParent||a.parent,l=a.shape;r._canDrillDown(l)&&r._addOverlay(l),r._updateDrilldownOverlay(s),r._updateDrilldownOverlay(c),r._updateDrilldownOverlay(l)},!0),this.reverted(["shape.create","shape.move","shape.delete"],Lu,function(a){var s=a.oldParent,c=a.newParent||a.parent,l=a.shape;r._canDrillDown(l)&&r._addOverlay(l),r._updateDrilldownOverlay(s),r._updateDrilldownOverlay(c),r._updateDrilldownOverlay(l)},!0),t.on("import.render.complete",function(){n.filter(function(a){return r._canDrillDown(a)}).map(function(a){r._addOverlay(a)})})}Ne(lr,we),lr.prototype._updateDrilldownOverlay=function(e){var t=this._canvas;if(e){var n=t.findRoot(e);n&&this._updateOverlayVisibility(n)}},lr.prototype._canDrillDown=function(e){var t=this._canvas;return M(e,"bpmn:SubProcess")&&t.findRoot(no(e))},lr.prototype._updateOverlayVisibility=function(e){var t=this._overlays,n=_e(e),i=t.get({element:n.id,type:"drilldown"})[0];if(i){var o=n&&n.get("flowElements")&&n.get("flowElements").length;At(i.html).toggle(FI,!o)}},lr.prototype._addOverlay=function(e){var t=this._canvas,n=this._overlays,i=_e(e),o=n.get({element:e,type:"drilldown"});o.length&&this._removeOverlay(e);var r=jt('<button type="button" class="bjs-drilldown">'+$I+"</button>"),a=i.get("name")||i.get("id"),s=this._translate("Open {element}",{element:a});r.setAttribute("title",s),r.addEventListener("click",function(){t.setRootElement(t.findRoot(no(e)))}),n.add(e,"drilldown",{position:{bottom:-7,right:-8},html:r}),this._updateOverlayVisibility(e)},lr.prototype._removeOverlay=function(e){var t=this._overlays;t.remove({element:e,type:"drilldown"})},lr.$inject=["canvas","eventBus","elementRegistry","overlays","translate"];const jI={__depends__:[Du,yh,kI],__init__:["drilldownBreadcrumbs","drilldownOverlayBehavior","drilldownCentering","subprocessCompatibility"],drilldownBreadcrumbs:["type",P_],drilldownCentering:["type",T_],drilldownOverlayBehavior:["type",lr],subprocessCompatibility:["type",qr]};function ur(e){Wt.call(this,e)}Ne(ur,Wt),ur.prototype._modules=[sb,jI,Du,Mi,Os],ur.prototype._moddleExtensions={};var Iu="keyboard.keydown",HI="keyboard.keyup",zI=1e3,D_="Keyboard binding is now implicit; explicit binding to an element got removed. For more information, see https://github.com/bpmn-io/diagram-js/issues/661";function qn(e,t){var n=this;this._config=e=e||{},this._eventBus=t,this._keydownHandler=this._keydownHandler.bind(this),this._keyupHandler=this._keyupHandler.bind(this),t.on("diagram.destroy",function(){n._fire("destroy"),n.unbind()}),e.bindTo&&console.error("unsupported configuration <keyboard.bindTo>",new Error(D_));var i=e&&e.bind!==!1;t.on("canvas.init",function(o){n._target=o.svg,i&&n.bind(),n._fire("init")})}qn.$inject=["config.keyboard","eventBus"],qn.prototype._keydownHandler=function(e){this._keyHandler(e,Iu)},qn.prototype._keyupHandler=function(e){this._keyHandler(e,HI)},qn.prototype._keyHandler=function(e,t){var n;if(!this._isEventIgnored(e)){var i={keyEvent:e};n=this._eventBus.fire(t||Iu,i),n&&e.preventDefault()}},qn.prototype._isEventIgnored=function(e){return!1},qn.prototype.bind=function(e){e&&console.error("unsupported argument <node>",new Error(D_)),this.unbind(),e=this._node=this._target,Ve.bind(e,"keydown",this._keydownHandler),Ve.bind(e,"keyup",this._keyupHandler),this._fire("bind")},qn.prototype.getBinding=function(){return this._node},qn.prototype.unbind=function(){var e=this._node;e&&(this._fire("unbind"),Ve.unbind(e,"keydown",this._keydownHandler),Ve.unbind(e,"keyup",this._keyupHandler)),this._node=null},qn.prototype._fire=function(e){this._eventBus.fire("keyboard."+e,{node:this._node})},qn.prototype.addListener=function(e,t,n){_n(e)&&(n=t,t=e,e=zI),this._eventBus.on(n||Iu,e,t)},qn.prototype.removeListener=function(e,t){this._eventBus.off(t||Iu,e)},qn.prototype.hasModifier=KO,qn.prototype.isCmd=ai,qn.prototype.isShift=ah,qn.prototype.isKey=vn;var GI=500;function Ha(e,t){var n=this;e.on("editorActions.init",GI,function(i){var o=i.editorActions;n.registerBindings(t,o)})}Ha.$inject=["eventBus","keyboard"],Ha.prototype.registerBindings=function(e,t){function n(i,o){t.isRegistered(i)&&e.addListener(o)}n("undo",function(i){var o=i.keyEvent;if(eD(o))return t.trigger("undo"),!0}),n("redo",function(i){var o=i.keyEvent;if(tD(o))return t.trigger("redo"),!0}),n("copy",function(i){var o=i.keyEvent;if(XO(o))return t.trigger("copy"),!0}),n("paste",function(i){var o=i.keyEvent;if(ZO(o))return t.trigger("paste"),!0}),n("duplicate",function(i){var o=i.keyEvent;if(QO(o))return t.trigger("duplicate"),!0}),n("cut",function(i){var o=i.keyEvent;if(JO(o))return t.trigger("cut"),!0}),n("stepZoom",function(i){var o=i.keyEvent;if(vn(["+","Add","="],o)&&ai(o))return t.trigger("stepZoom",{value:1}),!0}),n("stepZoom",function(i){var o=i.keyEvent;if(vn(["-","Subtract"],o)&&ai(o))return t.trigger("stepZoom",{value:-1}),!0}),n("zoom",function(i){var o=i.keyEvent;if(vn("0",o)&&ai(o))return t.trigger("zoom",{value:1}),!0}),n("removeSelection",function(i){var o=i.keyEvent;if(vn(["Backspace","Delete","Del"],o))return t.trigger("removeSelection"),!0})};const Vh={__init__:["keyboard","keyboardBindings"],keyboard:["type",qn],keyboardBindings:["type",Ha]};var VI={moveSpeed:50,moveSpeedAccelerated:200};function L_(e,t,n){var i=this;this._config=Y({},VI,e||{}),t.addListener(o);function o(r){var a=r.keyEvent,s=i._config;if(t.isCmd(a)&&t.isKey(["ArrowLeft","Left","ArrowUp","Up","ArrowDown","Down","ArrowRight","Right"],a)){var c=t.isShift(a)?s.moveSpeedAccelerated:s.moveSpeed,l;switch(a.key){case"ArrowLeft":case"Left":l="left";break;case"ArrowUp":case"Up":l="up";break;case"ArrowRight":case"Right":l="right";break;case"ArrowDown":case"Down":l="down";break}return i.moveCanvas({speed:c,direction:l}),!0}}this.moveCanvas=function(r){var a=0,s=0,c=r.speed,l=c/Math.min(Math.sqrt(n.viewbox().scale),1);switch(r.direction){case"left":a=l;break;case"up":s=l;break;case"right":a=-l;break;case"down":s=-l;break}n.scroll({dx:a,dy:s})}}L_.$inject=["config.keyboardMove","keyboard","canvas"];const I_={__depends__:[Vh],__init__:["keyboardMove"],keyboardMove:["type",L_]};var WI=15;function B_(e,t){var n;function i(s){return a(s.originalEvent)}e.on("canvas.focus.changed",function(s){s.focused?e.on("element.mousedown",500,i):e.off("element.mousedown",i)});function o(s){var c=n.start,l=n.button,u=Fr(s),p=Gi(u,c);if(!n.dragging&&UI(p)>WI&&(n.dragging=!0,l===0&&qx(e),iu("grab")),n.dragging){var f=n.last||n.start;p=Gi(u,f),t.scroll({dx:p.x,dy:p.y}),n.last=u}s.preventDefault()}function r(s){Ve.unbind(document,"mousemove",o),Ve.unbind(document,"mouseup",r),n=null,Ux()}function a(s){if(!Lr(s.target,".djs-draggable")){var c=s.button;if(!(c>=2||s.ctrlKey||s.shiftKey||s.altKey))return n={button:c,start:Fr(s)},Ve.bind(document,"mousemove",o),Ve.bind(document,"mouseup",r),!0}}this.isActive=function(){return!!n}}B_.$inject=["eventBus","canvas"];function UI(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}const N_={__init__:["moveCanvas"],moveCanvas:["type",B_]};function $_(e,t){var n=id(e.min),i=id(e.max),o=Math.abs(n)+Math.abs(i);return o/t}function qI(e,t){return Math.max(e.min,Math.min(e.max,t))}var YI=Math.sign||function(e){return e>=0?1:-1},Wh={min:.2,max:4},F_=10,KI=.1,XI=.75;function ro(e,t,n){e=e||{},this._enabled=!1,this._canvas=n,this._container=n._container,this._handleWheel=Kn(this._handleWheel,this),this._totalDelta=0,this._scale=e.scale||XI;var i=this;t.on("canvas.mouseover",function(){i._init(e.enabled!==!1)}),t.on("canvas.mouseout",function(){i._init(!1)})}ro.$inject=["config.zoomScroll","eventBus","canvas"],ro.prototype.scroll=function(t){this._canvas.scroll(t)},ro.prototype.reset=function(){this._canvas.zoom("fit-viewport")},ro.prototype.zoom=function(t,n){var i=$_(Wh,F_*2);this._totalDelta+=t,Math.abs(this._totalDelta)>KI&&(this._zoom(t,n,i),this._totalDelta=0)},ro.prototype._handleWheel=function(t){if(this._enabled){var n=this._container;t.preventDefault();var i=t.ctrlKey||ex()&&t.metaKey,o=t.shiftKey,r=-1*this._scale,a;if(i?r*=t.deltaMode===0?.02:.32:r*=t.deltaMode===0?1:16,i){var s=n.getBoundingClientRect(),c={x:t.clientX-s.left,y:t.clientY-s.top};a=Math.sqrt(Math.pow(t.deltaY,2)+Math.pow(t.deltaX,2))*YI(t.deltaY)*r,this.zoom(a,c)}else o?a={dx:r*t.deltaY,dy:0}:a={dx:r*t.deltaX,dy:r*t.deltaY},this.scroll(a)}},ro.prototype.stepZoom=function(t,n){var i=$_(Wh,F_);this._zoom(t,n,i)},ro.prototype._zoom=function(e,t,n){var i=this._canvas,o=e>0?1:-1,r=id(i.zoom()),a=Math.round(r/n)*n;a+=n*o;var s=Math.pow(10,a);i.zoom(qI(Wh,s),t)},ro.prototype.toggle=function(t){var n=this._container,i=this._handleWheel,o=this._enabled;return typeof t>"u"&&(t=!o),o!==t&&Ve[t?"bind":"unbind"](n,"wheel",i,!1),this._enabled=t,t},ro.prototype._init=function(e){this.toggle(e)};const j_={__init__:["zoomScroll"],zoomScroll:["type",ro]};function rc(e){ur.call(this,e)}Ne(rc,ur),rc.prototype._navigationModules=[I_,N_,j_],rc.prototype._modules=[].concat(ur.prototype._modules,rc.prototype._navigationModules);function Uh(e){return e&&e[e.length-1]}function H_(e){return e.y}function z_(e){return e.x}var ZI={left:z_,center:z_,right:function(e){return e.x+e.width},top:H_,middle:H_,bottom:function(e){return e.y+e.height}};function za(e,t){this._modeling=e,this._rules=t}za.$inject=["modeling","rules"],za.prototype._getOrientationDetails=function(e){var t=["top","bottom","middle"],n="x",i="width";return t.indexOf(e)!==-1&&(n="y",i="height"),{axis:n,dimension:i}},za.prototype._isType=function(e,t){return t.indexOf(e)!==-1},za.prototype._alignmentPosition=function(e,t){var n=this._getOrientationDetails(e),i=n.axis,o=n.dimension,r={},a={},s=!1,c,l,u;function p(f,d){return Math.round((f[i]+d[i]+d[o])/2)}if(this._isType(e,["left","top"]))r[e]=t[0][i];else if(this._isType(e,["right","bottom"]))u=Uh(t),r[e]=u[i]+u[o];else if(this._isType(e,["center","middle"])){if(V(t,function(f){var d=f[i]+Math.round(f[o]/2);a[d]?a[d].elements.push(f):a[d]={elements:[f],center:d}}),c=qi(a,function(f){return f.elements.length>1&&(s=!0),f.elements.length}),s)return r[e]=Uh(c).center,r;l=t[0],t=qi(t,function(f){return f[i]+f[o]}),u=Uh(t),r[e]=p(l,u)}return r},za.prototype.trigger=function(e,t){var n=this._modeling,i,o=ct(e,function(c){return!(c.waypoints||c.host||c.labelTarget)});if(i=this._rules.allowed("elements.align",{elements:o}),Ze(i)&&(o=i),!(o.length<2||!i)){var r=ZI[t],a=qi(o,r),s=this._alignmentPosition(t,a);n.alignElements(a,s)}};const QI={__init__:["alignElements"],alignElements:["type",za]},JI=new zr;function Ga(e){this._scheduled={},e.on("diagram.destroy",()=>{Object.keys(this._scheduled).forEach(t=>{this.cancel(t)})})}Ga.$inject=["eventBus"],Ga.prototype.schedule=function(e,t=JI.next()){this.cancel(t);const n=this._schedule(e,t);return this._scheduled[t]=n,n.promise},Ga.prototype._schedule=function(e,t){const n=eB();return{executionId:setTimeout(()=>{try{this._scheduled[t]=null;try{n.resolve(e())}catch(o){n.reject(o)}}catch(o){console.error("Scheduler#_schedule execution failed",o)}}),promise:n.promise}},Ga.prototype.cancel=function(e){const t=this._scheduled[e];t&&(this._cancel(t),this._scheduled[e]=null)},Ga.prototype._cancel=function(e){clearTimeout(e.executionId)};function eB(){const e={};return e.promise=new Promise((t,n)=>{e.resolve=t,e.reject=n}),e}const tB={scheduler:["type",Ga]};var nB="djs-element-hidden",Bu=".entry",iB=1e3,G_=8,oB=300;function un(e,t,n,i){this._canvas=e,this._elementRegistry=t,this._eventBus=n,this._scheduler=i,this._current=null,this._init()}un.$inject=["canvas","elementRegistry","eventBus","scheduler"],un.prototype._init=function(){var e=this;this._eventBus.on("selection.changed",function(t){var n=t.newSelection,i=n.length?n.length===1?n[0]:n:null;i?e.open(i,!0):e.close()}),this._eventBus.on("elements.changed",function(t){var n=t.elements,i=e._current;if(i){var o=i.target,r=Ze(o)?o:[o],a=r.filter(function(c){return n.includes(c)});if(a.length){e.close();var s=r.filter(function(c){return e._elementRegistry.get(c.id)});s.length&&e._updateAndOpen(s.length>1?s:s[0])}}}),this._eventBus.on("canvas.viewbox.changed",function(){e._updatePosition()}),this._eventBus.on("element.marker.update",function(t){if(e.isOpen()){var n=t.element,i=e._current,o=Ze(i.target)?i.target:[i.target];o.includes(n)&&e._updateVisibility()}}),this._container=this._createContainer()},un.prototype._createContainer=function(){var e=jt('<div class="djs-context-pad-parent"></div>');return this._canvas.getContainer().appendChild(e),e},un.prototype.registerProvider=function(e,t){t||(t=e,e=iB),this._eventBus.on("contextPad.getProviders",e,function(n){n.providers.push(t)})},un.prototype.getEntries=function(e){var t=this._getProviders(),n=Ze(e)?"getMultiElementContextPadEntries":"getContextPadEntries",i={};return V(t,function(o){if(_n(o[n])){var r=o[n](e);_n(r)?i=r(i):V(r,function(a,s){i[s]=a})}}),i},un.prototype.trigger=function(e,t,n){var i=this,o,r,a=t.delegateTarget||t.target;if(!a)return t.preventDefault();if(o=Cn(a,"data-action"),r=t.originalEvent||t,e==="mouseover"){this._timeout=setTimeout(function(){i._mouseout=i.triggerEntry(o,"hover",r,n)},oB);return}else if(e==="mouseout"){clearTimeout(this._timeout),this._mouseout&&(this._mouseout(),this._mouseout=null);return}return this.triggerEntry(o,e,r,n)},un.prototype.triggerEntry=function(e,t,n,i){if(this.isShown()){var o=this._current.target,r=this._current.entries,a=r[e];if(a){var s=a.action;if(this._eventBus.fire("contextPad.trigger",{entry:a,event:n})!==!1){if(_n(s)){if(t==="click")return s(n,o,i)}else if(s[t])return s[t](n,o,i);n.preventDefault()}}}},un.prototype.open=function(e,t){if(!(!t&&this.isOpen(e))){var n=this._eventBus.fire("contextPad.open.allowed",{target:e});n!==!1&&(this.close(),this._updateAndOpen(e))}},un.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"contextPad.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},un.prototype._updateAndOpen=function(e){var t=this.getEntries(e),n=this._createHtml(e),i;V(t,function(o,r){var a=o.group||"default",s=jt(o.html||'<div class="entry" draggable="true"></div>'),c;Cn(s,"data-action",r),c=Ct("[data-group="+Ur(a)+"]",n),c||(c=jt('<div class="group"></div>'),Cn(c,"data-group",a),n.appendChild(c)),c.appendChild(s),o.className&&rB(s,o.className),o.title&&Cn(s,"title",o.title),o.imageUrl&&(i=jt("<img>"),Cn(i,"src",o.imageUrl),i.style.width="100%",i.style.height="100%",s.appendChild(i))}),At(n).add("open"),this._current={entries:t,html:n,target:e},this._updatePosition(),this._updateVisibility(),this._eventBus.fire("contextPad.open",{current:this._current})},un.prototype._createHtml=function(e){var t=this,n=jt('<div class="djs-context-pad"></div>');return ii.bind(n,Bu,"click",function(i){t.trigger("click",i)}),ii.bind(n,Bu,"dragstart",function(i){t.trigger("dragstart",i)}),ii.bind(n,Bu,"mouseover",function(i){t.trigger("mouseover",i)}),ii.bind(n,Bu,"mouseout",function(i){t.trigger("mouseout",i)}),Ve.bind(n,"mousedown",function(i){i.stopPropagation()}),this._container.appendChild(n),this._eventBus.fire("contextPad.create",{target:e,pad:n}),n},un.prototype.getPad=function(e){console.warn(new Error("ContextPad#getPad is deprecated and will be removed in future library versions, cf. https://github.com/bpmn-io/diagram-js/pull/888"));let t;return this.isOpen()&&sB(this._current.target,e)?t=this._current.html:t=this._createHtml(e),{html:t}},un.prototype.close=function(){this.isOpen()&&(clearTimeout(this._timeout),this._container.innerHTML="",this._eventBus.fire("contextPad.close",{current:this._current}),this._current=null)},un.prototype.isOpen=function(e){var t=this._current;if(!t)return!1;if(!e)return!0;var n=t.target;return Ze(e)!==Ze(n)?!1:Ze(e)?e.length===n.length&&Io(e,function(i){return n.includes(i)}):n===e},un.prototype.isShown=function(){return this.isOpen()&&At(this._current.html).has("open")},un.prototype.show=function(){this.isOpen()&&(At(this._current.html).add("open"),this._updatePosition(),this._eventBus.fire("contextPad.show",{current:this._current}))},un.prototype.hide=function(){this.isOpen()&&(At(this._current.html).remove("open"),this._eventBus.fire("contextPad.hide",{current:this._current}))},un.prototype._getPosition=function(e){if(!Ze(e)&&Ot(e)){var t=this._canvas.viewbox(),n=aB(e),i=n.x*t.scale-t.x*t.scale,o=n.y*t.scale-t.y*t.scale;return{left:i+G_*this._canvas.zoom(),top:o}}var r=this._canvas.getContainer(),a=r.getBoundingClientRect(),s=this._getTargetBounds(e);return{left:s.right-a.left+G_*this._canvas.zoom(),top:s.top-a.top}},un.prototype._updatePosition=function(){const e=()=>{if(this.isOpen()){var t=this._current.html,n=this._getPosition(this._current.target);"x"in n&&"y"in n?(t.style.left=n.x+"px",t.style.top=n.y+"px"):["top","right","bottom","left"].forEach(function(i){i in n&&(t.style[i]=n[i]+"px")})}};this._scheduler.schedule(e,"ContextPad#_updatePosition")},un.prototype._updateVisibility=function(){const e=()=>{if(this.isOpen()){var t=this,n=this._current.target,i=Ze(n)?n:[n],o=i.some(function(r){return t._canvas.hasMarker(r,nB)});o?t.hide():t.show()}};this._scheduler.schedule(e,"ContextPad#_updateVisibility")},un.prototype._getTargetBounds=function(e){var t=this,n=Ze(e)?e:[e],i=n.map(function(o){return t._canvas.getGraphics(o)});return i.reduce(function(o,r){const a=r.getBoundingClientRect();return o.top=Math.min(o.top,a.top),o.right=Math.max(o.right,a.right),o.bottom=Math.max(o.bottom,a.bottom),o.left=Math.min(o.left,a.left),o.x=o.left,o.y=o.top,o.width=o.right-o.left,o.height=o.bottom-o.top,o},{top:1/0,right:-1/0,bottom:-1/0,left:1/0})};function rB(e,t){var n=At(e);t=Ze(t)?t:t.split(/\s+/g),t.forEach(function(i){n.add(i)})}function aB(e){return e.waypoints[e.waypoints.length-1]}function sB(e,t){return e=Ze(e)?e:[e],t=Ze(t)?t:[t],e.length===t.length&&Io(e,function(n){return t.includes(n)})}const V_={__depends__:[nu,tB,Du],contextPad:["type",un]};var Nu,qt,W_,pr,U_,q_,Y_,qh,$u,ac,K_,Yh,Kh,Xh,Fu={},ju=[],cB=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Hu=Array.isArray;function Po(e,t){for(var n in t)e[n]=t[n];return e}function Zh(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function X_(e,t,n){var i,o,r,a={};for(r in t)r=="key"?i=t[r]:r=="ref"?o=t[r]:a[r]=t[r];if(arguments.length>2&&(a.children=arguments.length>3?Nu.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(r in e.defaultProps)a[r]===void 0&&(a[r]=e.defaultProps[r]);return zu(e,a,i,o,null)}function zu(e,t,n,i,o){var r={type:e,props:t,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:o??++W_,__i:-1,__u:0};return o==null&&qt.vnode!=null&&qt.vnode(r),r}function Gu(e){return e.children}function Vu(e,t){this.props=e,this.context=t}function Yr(e,t){if(t==null)return e.__?Yr(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Yr(e):null}function lB(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,i=[],o=[],r=Po({},t);r.__v=t.__v+1,qt.vnode&&qt.vnode(r),Qh(e.__P,r,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,i,n??Yr(t),!!(32&t.__u),o),r.__v=t.__v,r.__.__k[r.__i]=r,o0(i,r,o),t.__e=t.__=null,r.__e!=n&&Z_(r)}}function Z_(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),Z_(e)}function Q_(e){(!e.__d&&(e.__d=!0)&&pr.push(e)&&!Wu.__r++||U_!=qt.debounceRendering)&&((U_=qt.debounceRendering)||q_)(Wu)}function Wu(){try{for(var e,t=1;pr.length;)pr.length>t&&pr.sort(Y_),e=pr.shift(),t=pr.length,lB(e)}finally{pr.length=Wu.__r=0}}function J_(e,t,n,i,o,r,a,s,c,l,u){var p,f,d,g,h,m,w=i&&i.__k||ju,y=t.length;for(c=uB(n,t,w,c,y),p=0;p<y;p++)(d=n.__k[p])!=null&&(f=d.__i!=-1&&w[d.__i]||Fu,d.__i=p,m=Qh(e,d,f,o,r,a,s,c,l,u),g=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&Jh(f.ref,null,d),u.push(d.ref,d.__c||g,d)),h==null&&g!=null&&(h=g),4&d.__u?(c=e0(d,c,e),f.__e&&(f.__e=null)):typeof d.type=="function"&&m!==void 0?c=m:g&&(c=g.nextSibling),d.__u&=-7);return n.__e=h,c}function uB(e,t,n,i,o){var r,a,s,c,l,u=n.length,p=u,f=0;for(e.__k=new Array(o),r=0;r<o;r++)(a=t[r])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=e.__k[r]=zu(null,a,null,null,null):Hu(a)?a=e.__k[r]=zu(Gu,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=e.__k[r]=zu(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):e.__k[r]=a,c=r+f,a.__=e,a.__b=e.__b+1,s=null,(l=a.__i=pB(a,n,c,p))!=-1&&(p--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(o>u?f--:o<u&&f++),typeof a.type!="function"&&(a.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,a.__u|=4))):e.__k[r]=null;if(p)for(r=0;r<u;r++)(s=n[r])!=null&&(2&s.__u)==0&&(s.__e==i&&(i=Yr(s)),a0(s,s));return i}function e0(e,t,n){var i,o;if(typeof e.type=="function"){for(i=e.__k,o=0;i&&o<i.length;o++)i[o]&&(i[o].__=e,t=e0(i[o],t,n));return t}e.__e!=t&&(t&&e.type&&!t.parentNode&&(t=Yr(e)),t=n.insertBefore(e.__e,t||null));do t=t&&t.nextSibling;while(t!=null&&t.nodeType==8);return t}function pB(e,t,n,i){var o,r,a,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(i>(u?1:0)){for(o=n-1,r=n+1;o>=0||r<t.length;)if((l=t[a=o>=0?o--:r++])!=null&&(2&l.__u)==0&&s==l.key&&c==l.type)return a}return-1}function t0(e,t,n){t[0]=="-"?e.setProperty(t,n??""):e[t]=n==null?"":typeof n!="number"||cB.test(t)?n:n+"px"}function Uu(e,t,n,i,o){var r,a;e:if(t=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(t in i)n&&t in n||t0(e.style,t,"");if(n)for(t in n)i&&n[t]==i[t]||t0(e.style,t,n[t])}else if(t[0]=="o"&&t[1]=="n")r=t!=(t=t.replace(K_,"$1")),a=t.toLowerCase(),t=a in e||t=="onFocusOut"||t=="onFocusIn"?a.slice(2):t.slice(2),e.l||(e.l={}),e.l[t+r]=n,n?i?n[ac]=i[ac]:(n[ac]=Yh,e.addEventListener(t,r?Xh:Kh,r)):e.removeEventListener(t,r?Xh:Kh,r);else{if(o=="http://www.w3.org/2000/svg")t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(t!="width"&&t!="height"&&t!="href"&&t!="list"&&t!="form"&&t!="tabIndex"&&t!="download"&&t!="rowSpan"&&t!="colSpan"&&t!="role"&&t!="popover"&&t in e)try{e[t]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&t[4]!="-"?e.removeAttribute(t):e.setAttribute(t,t=="popover"&&n==1?"":n))}}function n0(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t[$u]==null)t[$u]=Yh++;else if(t[$u]<n[ac])return;return n(qt.event?qt.event(t):t)}}}function Qh(e,t,n,i,o,r,a,s,c,l){var u,p,f,d,g,h,m,w,y,v,x,E,A,I,P,k,H=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),r=[s=t.__e=n.__e]),(u=qt.__b)&&u(t);e:if(typeof H=="function"){p=a.length;try{if(y=t.props,v=H.prototype&&H.prototype.render,x=(u=H.contextType)&&i[u.__c],E=u?x?x.props.value:u.__:i,n.__c?w=(f=t.__c=n.__c).__=f.__E:(v?t.__c=f=new H(y,E):(t.__c=f=new Vu(y,E),f.constructor=H,f.render=dB),x&&x.sub(f),f.state||(f.state={}),f.__n=i,d=f.__d=!0,f.__h=[],f._sb=[]),v&&f.__s==null&&(f.__s=f.state),v&&H.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=Po({},f.__s)),Po(f.__s,H.getDerivedStateFromProps(y,f.__s))),g=f.props,h=f.state,f.__v=t,d)v&&H.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),v&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(v&&H.getDerivedStateFromProps==null&&y!==g&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(y,E),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&f.shouldComponentUpdate(y,f.__s,E)===!1){t.__v!=n.__v&&(f.props=y,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(F){F&&(F.__=t)}),ju.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&a.push(f),s=Yr(n);break e}f.componentWillUpdate!=null&&f.componentWillUpdate(y,f.__s,E),v&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(g,h,m)})}if(f.context=E,f.props=y,f.__P=e,f.__e=!1,A=qt.__r,I=0,v)f.state=f.__s,f.__d=!1,A&&A(t),u=f.render(f.props,f.state,f.context),ju.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,A&&A(t),u=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++I<25);f.state=f.__s,f.getChildContext!=null&&(i=Po(Po({},i),f.getChildContext())),v&&!d&&f.getSnapshotBeforeUpdate!=null&&(m=f.getSnapshotBeforeUpdate(g,h)),P=u!=null&&u.type===Gu&&u.key==null?r0(u.props.children):u,s=J_(e,Hu(P)?P:[P],t,n,i,o,r,a,s,c,l),f.base=t.__e,t.__u&=-161,f.__h.length&&a.push(f),w&&(f.__E=f.__=null)}catch(F){if(a.length=p,t.__v=null,c||r!=null){if(F.then){for(t.__u|=c?160:128;s&&s.nodeType==8&&s.nextSibling;)s=s.nextSibling;r!=null&&(r[r.indexOf(s)]=null),t.__e=s}else if(r!=null)for(k=r.length;k--;)Zh(r[k])}else t.__e=n.__e;t.__k==null&&(t.__k=n.__k||[]),F.then||i0(t),qt.__e(F,t,n)}}else r==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):s=t.__e=fB(n.__e,t,n,i,o,r,a,c,l);return(u=qt.diffed)&&u(t),128&t.__u?void 0:s}function i0(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(i0))}function o0(e,t,n){for(var i=0;i<n.length;i++)Jh(n[i],n[++i],n[++i]);qt.__c&&qt.__c(t,e),e.some(function(o){try{e=o.__h,o.__h=[],e.some(function(r){r.call(o)})}catch(r){qt.__e(r,o.__v)}})}function r0(e){return typeof e!="object"||e==null||e.__b>0?e:Hu(e)?e.map(r0):e.constructor!==void 0?null:Po({},e)}function fB(e,t,n,i,o,r,a,s,c){var l,u,p,f,d,g,h,m=n.props||Fu,w=t.props,y=t.type;if(y=="svg"?o="http://www.w3.org/2000/svg":y=="math"?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),r!=null){for(l=0;l<r.length;l++)if((d=r[l])&&"setAttribute"in d==!!y&&(y?d.localName==y:d.nodeType==3)){e=d,r[l]=null;break}}if(e==null){if(y==null)return document.createTextNode(w);e=document.createElementNS(o,y,w.is&&w),s&&(qt.__m&&qt.__m(t,r),s=!1),r=null}if(y==null)m===w||s&&e.data==w||(e.data=w);else{if(r=y=="textarea"&&w.defaultValue!=null?null:r&&Nu.call(e.childNodes),!s&&r!=null)for(m={},l=0;l<e.attributes.length;l++)m[(d=e.attributes[l]).name]=d.value;for(l in m)d=m[l],l=="dangerouslySetInnerHTML"?p=d:l=="children"||l in w||l=="value"&&"defaultValue"in w||l=="checked"&&"defaultChecked"in w||Uu(e,l,null,d,o);for(l in w)d=w[l],l=="children"?f=d:l=="dangerouslySetInnerHTML"?u=d:l=="value"?g=d:l=="checked"?h=d:s&&typeof d!="function"||m[l]===d||Uu(e,l,d,m[l],o);if(u)s||p&&(u.__html==p.__html||u.__html==e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(p&&(e.innerHTML=""),J_(t.type=="template"?e.content:e,Hu(f)?f:[f],t,n,i,y=="foreignObject"?"http://www.w3.org/1999/xhtml":o,r,a,r?r[0]:n.__k&&Yr(n,0),s,c),r!=null)for(l=r.length;l--;)Zh(r[l]);s&&y!="textarea"||(l="value",y=="progress"&&g==null?e.removeAttribute("value"):g!=null&&(g!==e[l]||y=="progress"&&!g||y=="option"&&g!=m[l])&&Uu(e,l,g,m[l],o),l="checked",h!=null&&h!=e[l]&&Uu(e,l,h,m[l],o))}return e}function Jh(e,t,n){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&t==null||(e.__u=e(t))}else e.current=t}catch(o){qt.__e(o,n)}}function a0(e,t,n){var i,o;if(qt.unmount&&qt.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||Jh(i,null,t)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(r){qt.__e(r,t)}i.base=i.__P=i.__n=null}if(i=e.__k)for(o=0;o<i.length;o++)i[o]&&a0(i[o],t,n||typeof e.type!="function");n||Zh(e.__e),e.__c=e.__=e.__e=void 0}function dB(e,t,n){return this.constructor(e,n)}function s0(e,t,n){var i,o,r,a;t==document&&(t=document.documentElement),qt.__&&qt.__(e,t),o=(i=!1)?null:t.__k,r=[],a=[],Qh(t,e=t.__k=X_(Gu,null,[e]),o||Fu,Fu,t.namespaceURI,o?null:t.firstChild?Nu.call(t.childNodes):null,r,o?o.__e:t.firstChild,i,a),o0(r,e,a),e.props.children=null}Nu=ju.slice,qt={__e:function(e,t,n,i){for(var o,r,a;t=t.__;)if((o=t.__c)&&!o.__)try{if((r=o.constructor)&&r.getDerivedStateFromError!=null&&(o.setState(r.getDerivedStateFromError(e)),a=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(e,i||{}),a=o.__d),a)return o.__E=o}catch(s){e=s}throw e}},W_=0,Vu.prototype.setState=function(e,t){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Po({},this.state),typeof e=="function"&&(e=e(Po({},n),this.props)),e&&Po(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),Q_(this))},Vu.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),Q_(this))},Vu.prototype.render=Gu,pr=[],q_=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Y_=function(e,t){return e.__v.__b-t.__v.__b},Wu.__r=0,qh=Math.random().toString(8),$u="__d"+qh,ac="__a"+qh,K_=/(PointerCapture)$|Capture$/i,Yh=0,Kh=n0(!1),Xh=n0(!0);var c0=function(e,t,n,i){var o;t[0]=0;for(var r=1;r<t.length;r++){var a=t[r++],s=t[r]?(t[0]|=a?1:2,n[t[r++]]):t[++r];a===3?i[0]=s:a===4?i[1]=Object.assign(i[1]||{},s):a===5?(i[1]=i[1]||{})[t[++r]]=s:a===6?i[1][t[++r]]+=s+"":a?(o=e.apply(s,c0(e,s,n,["",null])),i.push(o),s[0]?t[0]|=2:(t[r-2]=0,t[r]=o)):i.push(s)}return i},l0=new Map;function hB(e){var t=l0.get(this);return t||(t=new Map,l0.set(this,t)),(t=c0(this,t.get(e)||(t.set(e,t=(function(n){for(var i,o,r=1,a="",s="",c=[0],l=function(f){r===1&&(f||(a=a.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?c.push(0,f,a):r===3&&(f||a)?(c.push(3,f,a),r=2):r===2&&a==="..."&&f?c.push(4,f,0):r===2&&a&&!f?c.push(5,0,!0,a):r>=5&&((a||!f&&r===5)&&(c.push(r,0,a,o),r=6),f&&(c.push(r,f,0,o),r=6)),a=""},u=0;u<n.length;u++){u&&(r===1&&l(),l(u));for(var p=0;p<n[u].length;p++)i=n[u][p],r===1?i==="<"?(l(),c=[c],r=3):a+=i:r===4?a==="--"&&i===">"?(r=1,a=""):a=i+a[0]:s?i===s?s="":a+=i:i==='"'||i==="'"?s=i:i===">"?(l(),r=1):r&&(i==="="?(r=5,o=a,a=""):i==="/"&&(r<5||n[u][p+1]===">")?(l(),r===3&&(c=c[0]),r=c,(c=c[0]).push(2,0,r),r=0):i===" "||i===" "||i===`
11
11
  `||i==="\r"?(l(),r=2):a+=i),r===3&&a==="!--"&&(r=4,c=c[0])}return l(),c})(e)),t),arguments,[])).length>1?t:t[0]}var Lt=hB.bind(X_),Va,pn,eg,u0,sc=0,p0=[],bn=qt,f0=bn.__b,d0=bn.__r,h0=bn.diffed,g0=bn.__c,m0=bn.unmount,y0=bn.__;function qu(e,t){bn.__h&&bn.__h(pn,e,sc||t),sc=0;var n=pn.__H||(pn.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function tg(e){return sc=1,gB(b0,e)}function gB(e,t,n){var i=qu(Va++,2);if(i.t=e,!i.__c&&(i.__=[b0(void 0,t),function(s){var c=i.__N?i.__N[0]:i.__[0],l=i.t(c,s);c!==l&&(i.__N=[l,i.__[1]],i.__c.setState({}))}],i.__c=pn,!pn.__f)){var o=function(s,c,l){if(!i.__c.__H)return!0;var u=!1,p=i.__c.props!==s;if(i.__c.__H.__.some(function(d){if(d.__N){u=!0;var g=d.__[0];d.__=d.__N,d.__N=void 0,g!==d.__[0]&&(p=!0)}}),r){var f=r.call(this,s,c,l);return u?f||p:f}return!u||p};pn.__f=!0;var r=pn.shouldComponentUpdate,a=pn.componentWillUpdate;pn.componentWillUpdate=function(s,c,l){if(this.__e){var u=r;r=void 0,o(s,c,l),r=u}a&&a.call(this,s,c,l)},pn.shouldComponentUpdate=o}return i.__N||i.__}function Yu(e,t){var n=qu(Va++,3);!bn.__s&&og(n.__H,t)&&(n.__=e,n.u=t,pn.__H.__h.push(n))}function ng(e,t){var n=qu(Va++,4);!bn.__s&&og(n.__H,t)&&(n.__=e,n.u=t,pn.__h.push(n))}function Ku(e){return sc=5,To(function(){return{current:e}},[])}function To(e,t){var n=qu(Va++,7);return og(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function cc(e,t){return sc=8,To(function(){return e},t)}function mB(){for(var e;e=p0.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Xu),t.__h.some(ig),t.__h=[]}catch(n){t.__h=[],bn.__e(n,e.__v)}}}bn.__b=function(e){pn=null,f0&&f0(e)},bn.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),y0&&y0(e,t)},bn.__r=function(e){d0&&d0(e),Va=0;var t=(pn=e.__c).__H;t&&(eg===pn?(t.__h=[],pn.__h=[],t.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(t.__h.some(Xu),t.__h.some(ig),t.__h=[],Va=0)),eg=pn},bn.diffed=function(e){h0&&h0(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(p0.push(t)!==1&&u0===bn.requestAnimationFrame||((u0=bn.requestAnimationFrame)||yB)(mB)),t.__H.__.some(function(n){n.u&&(n.__H=n.u,n.u=void 0)})),eg=pn=null},bn.__c=function(e,t){t.some(function(n){try{n.__h.some(Xu),n.__h=n.__h.filter(function(i){return!i.__||ig(i)})}catch(i){t.some(function(o){o.__h&&(o.__h=[])}),t=[],bn.__e(i,n.__v)}}),g0&&g0(e,t)},bn.unmount=function(e){m0&&m0(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(i){try{Xu(i)}catch(o){t=o}}),n.__H=void 0,t&&bn.__e(t,n.__v))};var v0=typeof requestAnimationFrame=="function";function yB(e){var t,n=function(){clearTimeout(i),v0&&cancelAnimationFrame(t),setTimeout(e)},i=setTimeout(n,35);v0&&(t=requestAnimationFrame(n))}function Xu(e){var t=pn,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),pn=t}function ig(e){var t=pn;e.__c=e.__(),pn=t}function og(e,t){return!e||e.length!==t.length||t.some(function(n,i){return n!==e[i]})}function b0(e,t){return typeof t=="function"?t(e):t}function vB(e){const{navigationStack:t,setNavigationStack:n}=e,i=To(()=>t.length<=1?[]:t.slice(0,-1).map((a,s)=>({label:a.label,onClick:()=>n(c=>c.slice(0,s+1))})),[t,n]),o=t.length>0?()=>n([]):null,r=t.length>0?t[t.length-1].label:null;return Lt`
12
12
  <div class="djs-popup-breadcrumbs">
13
13
  ${o&&Lt`
@@ -168,11 +168,11 @@
168
168
  </ul>
169
169
  `)}
170
170
  </div>
171
- `}function _0(e,t){return`${e}-group-${t.id}`}function SB(e){typeof e.scrollIntoViewIfNeeded=="function"?e.scrollIntoViewIfNeeded():e.scrollIntoView({scrollMode:"if-needed",block:"nearest"})}const RB=new zr("djs-popup");function CB(e){const{onClose:t,onSelect:n,className:i,headerEntries:o,position:r,title:a,width:s,scale:c,search:l,emptyPlaceholder:u,searchFn:p,entries:f,onOpened:d,onClosed:g}=e,[h,m]=tg([]);Yu(()=>{m([])},[f]);const[w,y]=tg(""),v=w.trim().length>0,x=To(()=>PB(f),[f]),E=To(()=>gn(l)?x.length>5:!1,[l,x]),A=To(()=>{const K=h.length?h[h.length-1].entries:f;return E?v?p(x.filter(({searchable:J})=>J!==!1),w,{keys:["label","search","description"]}).map(({item:J})=>J):K.filter(({rank:J=0})=>J>=0):K},[E,v,x,w,p,h,f]),B=To(()=>v?A.length?[{id:"default",entries:A}]:[]:TB(A),[A,v]),[P,k]=tg(A[0]),H=Ku(null),F=Ku(!1),G=To(()=>RB.next(),[]),ee=`${G}-results`,ce=P&&w0(G,P);Yu(()=>{const K=H.current;K&&A.includes(K)?k(K):k(A[0]),H.current=null},[A]);const ie=cc(K=>{const J=AB(B);let Re=J.indexOf(P)+K;Re<0&&(Re=J.length-1),Re>=J.length&&(Re=0),F.current=!0,k(J[Re])},[B,P]),be=cc(K=>{K>0&&P&&P.entries&&(F.current=!0,m(J=>[...J,P])),K<0&&h.length>0&&(F.current=!0,H.current=h[h.length+K],m(J=>J.slice(0,K)))},[P,h]),de=cc((K,J,he)=>{if(!(!J||J.disabled))return J.entries?(K.preventDefault(),be(1)):n(K,J,he)},[n,be]),me=cc(K=>{if(K.key==="Enter"&&P){const J=K.target;return!!Lr(J,"a, button",!0)||P.disabled?void 0:de(K,P)}if(K.key==="Backspace"){const J=K.target;if(!(If(J,"input")&&J.value!==""))return be(-1),K.preventDefault()}if(K.key==="ArrowUp")return ie(-1),K.preventDefault();if(K.key==="ArrowDown")return ie(1),K.preventDefault();if(K.key==="ArrowRight")return be(1),K.preventDefault();if(K.key==="ArrowLeft")return be(-1),K.preventDefault()},[P,ie,be,de]),Ee=cc(K=>{If(K.target,"input")&&y(()=>K.target.value)},[y]);Yu(()=>(d(),()=>{g()}),[]);const U=!v&&h.length>0,ue=(a||o.length>0)&&!U;return Lt`
171
+ `}function _0(e,t){return`${e}-group-${t.id}`}function SB(e){typeof e.scrollIntoViewIfNeeded=="function"?e.scrollIntoViewIfNeeded():e.scrollIntoView({scrollMode:"if-needed",block:"nearest"})}const RB=new zr("djs-popup");function CB(e){const{onClose:t,onSelect:n,className:i,headerEntries:o,position:r,title:a,width:s,scale:c,search:l,emptyPlaceholder:u,searchFn:p,entries:f,onOpened:d,onClosed:g}=e,[h,m]=tg([]);Yu(()=>{m([])},[f]);const[w,y]=tg(""),v=w.trim().length>0,x=To(()=>PB(f),[f]),E=To(()=>gn(l)?x.length>5:!1,[l,x]),A=To(()=>{const K=h.length?h[h.length-1].entries:f;return E?v?p(x.filter(({searchable:J})=>J!==!1),w,{keys:["label","search","description"]}).map(({item:J})=>J):K.filter(({rank:J=0})=>J>=0):K},[E,v,x,w,p,h,f]),I=To(()=>v?A.length?[{id:"default",entries:A}]:[]:TB(A),[A,v]),[P,k]=tg(A[0]),H=Ku(null),F=Ku(!1),G=To(()=>RB.next(),[]),ee=`${G}-results`,ce=P&&w0(G,P);Yu(()=>{const K=H.current;K&&A.includes(K)?k(K):k(A[0]),H.current=null},[A]);const ie=cc(K=>{const J=AB(I);let Re=J.indexOf(P)+K;Re<0&&(Re=J.length-1),Re>=J.length&&(Re=0),F.current=!0,k(J[Re])},[I,P]),be=cc(K=>{K>0&&P&&P.entries&&(F.current=!0,m(J=>[...J,P])),K<0&&h.length>0&&(F.current=!0,H.current=h[h.length+K],m(J=>J.slice(0,K)))},[P,h]),he=cc((K,J,ge)=>{if(!(!J||J.disabled))return J.entries?(K.preventDefault(),be(1)):n(K,J,ge)},[n,be]),ye=cc(K=>{if(K.key==="Enter"&&P){const J=K.target;return!!Lr(J,"a, button",!0)||P.disabled?void 0:he(K,P)}if(K.key==="Backspace"){const J=K.target;if(!(If(J,"input")&&J.value!==""))return be(-1),K.preventDefault()}if(K.key==="ArrowUp")return ie(-1),K.preventDefault();if(K.key==="ArrowDown")return ie(1),K.preventDefault();if(K.key==="ArrowRight")return be(1),K.preventDefault();if(K.key==="ArrowLeft")return be(-1),K.preventDefault()},[P,ie,be,he]),Ee=cc(K=>{If(K.target,"input")&&y(()=>K.target.value)},[y]);Yu(()=>(d(),()=>{g()}),[]);const U=!v&&h.length>0,ue=(a||o.length>0)&&!U;return Lt`
172
172
  <${E0}
173
173
  onClose=${t}
174
174
  onKeyup=${Ee}
175
- onKeydown=${me}
175
+ onKeydown=${ye}
176
176
  className=${i}
177
177
  position=${r}
178
178
  width=${s}
@@ -222,11 +222,11 @@
222
222
  `}
223
223
 
224
224
  <${EB}
225
- groupedEntries=${B}
225
+ groupedEntries=${I}
226
226
  selectedEntry=${P}
227
227
  setSelectedEntry=${k}
228
228
  keyboardSelection=${F}
229
- onAction=${de}
229
+ onAction=${he}
230
230
  idPrefix=${G}
231
231
  id=${ee}
232
232
  ariaLabel=${a||"Results"}
@@ -312,7 +312,7 @@
312
312
  <line x1="150" y1="900" x2="1650" y2="900" style="stroke:currentColor;stroke-width:100;stroke-linecap:round;"/>
313
313
  <rect x="150" y="250" width="600" height="1300" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
314
314
  <rect x="1050" y="500" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
315
- </svg>`},FB=900;function Ua(e,t,n,i){e.registerProvider(FB,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=i}Ua.$inject=["contextPad","popupMenu","translate","canvas"],Ua.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&Y(t,this._getEntries(e)),t},Ua.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")},Ua.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${D0.align}</div>`,action:{click:function(t,n){var i=e._getMenuPosition(n);Y(i,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",i)}}}}},Ua.prototype._getMenuPosition=function(e){var t=5,n=this._contextPad.getPad(e).html,i=n.getBoundingClientRect(),o={x:i.left,y:i.bottom+t};return o};var jB=["left","center","right","top","middle","bottom"];function lc(e,t,n,i){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",this)}lc.$inject=["popupMenu","alignElements","translate","rules"],lc.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&Y(t,this._getEntries(e)),t},lc.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})},lc.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,i=this._popupMenu,o={};return V(jB,function(r){o["align-elements-"+r]={group:"align",title:n("Align elements "+r),className:"bjs-align-elements-menu-entry",imageHtml:D0[r],action:function(){t.trigger(e,r),i.close()}}}),o};function Qu(e){Ci.call(this,e)}Qu.$inject=["eventBus"],Ne(Qu,Ci),Qu.prototype.init=function(){this.addRule("elements.align",function(e){var t=e.elements,n=ct(t,function(i){return!(i.waypoints||i.host||i.labelTarget)});return n=ml(n),n.length<2?!1:n})};const HB={__depends__:[QI,V_,rg],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",Ua],alignElementsMenuProvider:["type",lc],bpmnAlignElements:["type",Qu]};function qa(e,t,n){this._canvas=n,this._opts=Y({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},e);var i=this;t.on("drag.move",function(o){var r=i._toBorderPoint(o);i.startScroll(r)}),t.on(["drag.cleanup"],function(){i.stopScroll()})}qa.$inject=["config.autoScroll","eventBus","canvas"],qa.prototype.startScroll=function(e){var t=this._canvas,n=this._opts,i=this,o=t.getContainer().getBoundingClientRect(),r=[e.x,e.y,o.width-e.x,o.height-e.y];this.stopScroll();for(var a=0,s=0,c=0;c<4;c++)zB(r[c],n.scrollThresholdOut[c],n.scrollThresholdIn[c])&&(c===0?a=n.scrollStep:c==1?s=n.scrollStep:c==2?a=-n.scrollStep:c==3&&(s=-n.scrollStep));(a!==0||s!==0)&&(t.scroll({dx:a,dy:s}),this._scrolling=setTimeout(function(){i.startScroll(e)},n.scrollRepeatTimeout))};function zB(e,t,n){return t<e&&e<n}qa.prototype.stopScroll=function(){clearTimeout(this._scrolling)},qa.prototype.setOptions=function(e){this._opts=Y({},this._opts,e)},qa.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=Fr(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};const GB={__depends__:[So],__init__:["autoScroll"],autoScroll:["type",qa]};var L0="djs-bendpoint",I0="djs-segment-dragger";function VB(e,t){var n=Fr(t),i=e._container.getBoundingClientRect(),o;o={x:i.left,y:i.top};var r=e.viewbox();return{x:r.x+(n.x-o.x)/r.scale,y:r.y+(n.y-o.y)/r.scale}}function ag(e,t,n){var i=VB(e,n),o=xd(t,i);return o}function sg(e,t){var n=He("g");dt(n).add(L0),tt(e,n);var i=He("circle");Ie(i,{cx:0,cy:0,r:4}),dt(i).add("djs-visual"),tt(n,i);var o=He("circle");return Ie(o,{cx:0,cy:0,r:10}),dt(o).add("djs-hit"),tt(n,o),t&&dt(n).add(t),n}function WB(e,t,n,i){var o=He("g");tt(e,o);var r=18,a=6,s=11,c=qB(t,n,i),l=a+s,u=He("rect");Ie(u,{x:-r/2,y:-a/2,width:r,height:a}),dt(u).add("djs-visual"),tt(o,u);var p=He("rect");return Ie(p,{x:-c/2,y:-l/2,width:c,height:l}),dt(p).add("djs-hit"),tt(o,p),Uv(o,i==="v"?90:0),o}function B0(e,t,n){var i=He("g"),o=Kf(t,n),r=vo(t,n);return tt(e,i),WB(i,t,n,r),dt(i).add(I0),dt(i).add(r==="h"?"horizontal":"vertical"),Dn(i,o.x,o.y),i}function cg(e){return Math.abs(Math.round(e*2/3))}function UB(e,t){var n=YB(e,t);return Cd(e,n)}function qB(e,t,n){var i=t.x-e.x,o=t.y-e.y;return cg(n==="h"?i:o)}function YB(e,t){for(var n=t.waypoints,i=1/0,o,r=0;r<n.length-1;r++){var a=n[r],s=n[r+1],c=Ob(e,[a,s]);c<i&&(i=c,o=r)}return[n[o],n[o+1]]}function N0(e,t,n,i,o){function r(v,x,E){var A=v.index,B=v.point,P,k,H,F,G,ee;return A<=0||v.bendpoint?!1:(P=x[A-1],k=x[A],H=Kf(P,k),F=vo(P,k),G=Math.abs(B.x-H.x),ee=Math.abs(B.y-H.y),F&&G<=E&&ee<=E)}function a(v,x){var E=v.waypoints,A,B,P,k;return x.index<=0||x.bendpoint||(A={start:E[x.index-1],end:E[x.index]},B=vo(A.start,A.end),!B)?null:(B==="h"?P=A.end.x-A.start.x:P=A.end.y-A.start.y,k=cg(P)/2,k)}function s(v,x){var E=x.waypoints,A=ag(t,E,v),B;if(A){B=a(x,A);var P;if(r(A,E,B)?P=o.start(v,x,A.index):P=i.start(v,x,A.index,!A.bendpoint),P!==!1)return!0}}function c(v,x,E){Ve.bind(v,x,function(A){n.triggerMouseEvent(x,A,E),A.stopPropagation()})}function l(v,x){var E=t.getLayer("overlays"),A=Ct('.djs-bendpoints[data-element-id="'+Ur(v.id)+'"]',E);return!A&&x&&(A=He("g"),Ie(A,{"data-element-id":v.id}),dt(A).add("djs-bendpoints"),tt(E,A),c(A,"mousedown",v),c(A,"click",v),c(A,"dblclick",v)),A}function u(v,x){return Ct('.djs-segment-dragger[data-segment-idx="'+v+'"]',x)}function p(v,x){x.waypoints.forEach(function(E,A){var B=sg(v);tt(v,B),Dn(B,E.x,E.y)}),sg(v,"floating")}function f(v,x){for(var E=x.waypoints,A,B,P,k=1;k<E.length;k++)A=E[k-1],B=E[k],vo(A,B)&&(P=B0(v,A,B),Ie(P,{"data-segment-idx":k}),c(P,"mousemove",x))}function d(v){V(vs("."+L0,v),function(x){sn(x)})}function g(v){V(vs("."+I0,v),function(x){sn(x)})}function h(v){var x=l(v);return x||(x=l(v,!0),p(x,v),f(x,v)),x}function m(v){var x=l(v);x&&(g(x),d(x),f(x,v),p(x,v))}function w(v,x){var E=Ct(".floating",v),A=x.point;E&&(Dn(E,A.x,A.y),dt(E).add("positioned"))}function y(v,x,E){var A=u(x.index,v),B=E[x.index-1],P=E[x.index],k=x.point,H=Kf(B,P),F=vo(B,P),G,ee;A&&(G=KB(A),ee={x:k.x-H.x,y:k.y-H.y},F==="v"&&(ee={x:ee.y,y:ee.x}),Dn(G,ee.x,ee.y))}e.on("connection.changed",function(v){m(v.element)}),e.on("connection.remove",function(v){var x=l(v.element);x&&sn(x)}),e.on("element.marker.update",function(v){var x=v.element,E;x.waypoints&&(E=h(x),v.add?dt(E).add(v.marker):dt(E).remove(v.marker))}),e.on("element.mousemove",function(v){var x=v.element,E=x.waypoints,A,B;if(E){if(A=l(x,!0),B=ag(t,E,v.originalEvent),!B)return;w(A,B),B.bendpoint||y(A,B,E)}}),e.on("element.mousedown",function(v){if(tr(v)){var x=v.originalEvent,E=v.element;if(E.waypoints)return s(x,E)}}),e.on("selection.changed",function(v){var x=v.newSelection,E=x[0];E&&E.waypoints&&h(E)}),e.on("element.hover",function(v){var x=v.element;x.waypoints&&h(x)}),e.on("element.out",function(v){var x=v.element;if(x.waypoints){var E=l(x);if(E){var A=Ct(".floating",E);A&&dt(A).remove("positioned")}}}),e.on("element.updateId",function(v){var x=v.element,E=v.newId;if(x.waypoints){var A=l(x);A&&Ie(A,{"data-element-id":E})}}),this.addHandles=h,this.updateHandles=m,this.getBendpointsContainer=l,this.getSegmentDragger=u}N0.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];function KB(e){return Ct(".djs-visual",e)}var $0=Math.round,Kr="reconnectStart",Xr="reconnectEnd",uc="updateWaypoints";function lg(e,t,n,i,o,r){this._injector=e,this.start=function(a,s,c,l){var u=n.getGraphics(s),p=s.source,f=s.target,d=s.waypoints,g;!l&&c===0?g=Kr:!l&&c===d.length-1?g=Xr:g=uc;var h=g===uc?"connection.updateWaypoints":"connection.reconnect",m=o.allowed(h,{connection:s,source:p,target:f});if(m===!1&&(m=o.allowed(h,{connection:s,source:f,target:p})),m!==!1)return i.init(a,"bendpoint.move",{data:{connection:s,connectionGfx:u,context:{allowed:m,bendpointIndex:c,connection:s,source:p,target:f,insert:l,type:g}}})},t.on("bendpoint.move.hover",function(a){var s=a.context,c=s.connection,l=c.source,u=c.target,p=a.hover,f=s.type;s.hover=p;var d;if(p){var g=f===uc?"connection.updateWaypoints":"connection.reconnect";if(d=s.allowed=o.allowed(g,{connection:c,source:f===Kr?p:l,target:f===Xr?p:u}),d){s.source=f===Kr?p:l,s.target=f===Xr?p:u;return}d===!1&&(d=s.allowed=o.allowed(g,{connection:c,source:f===Xr?p:u,target:f===Kr?p:l})),d&&(s.source=f===Xr?p:u,s.target=f===Kr?p:l)}}),t.on(["bendpoint.move.out","bendpoint.move.cleanup"],function(a){var s=a.context,c=s.type;s.hover=null,s.source=null,s.target=null,c!==uc&&(s.allowed=!1)}),t.on("bendpoint.move.end",function(a){var s=a.context,c=s.allowed,l=s.bendpointIndex,u=s.connection,p=s.insert,f=u.waypoints.slice(),d=s.source,g=s.target,h=s.type,m=s.hints||{},w={x:$0(a.x),y:$0(a.y)};if(!c)return!1;h===uc?(p?f.splice(l,0,w):f[l]=w,m.bendpointMove={insert:p,bendpointIndex:l},f=this.cropWaypoints(u,f),r.updateWaypoints(u,tT(f),m)):(h===Kr?(m.docking="source",Ju(s)&&(m.docking="target",m.newWaypoints=f.reverse())):h===Xr&&(m.docking="target",Ju(s)&&(m.docking="source",m.newWaypoints=f.reverse())),r.reconnect(u,d,g,w,m))},this)}lg.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],lg.prototype.cropWaypoints=function(e,t){var n=this._injector.get("connectionDocking",!1);if(!n)return t;var i=e.waypoints;return e.waypoints=t,e.waypoints=n.getCroppedWaypoints(e),t=e.waypoints,e.waypoints=i,t};function Ju(e){var t=e.hover,n=e.source,i=e.target,o=e.type;if(o===Kr)return t&&i&&t===i&&n!==i;if(o===Xr)return t&&n&&t===n&&n!==i}var XB="reconnectStart",ZB="reconnectEnd",F0="updateWaypoints",pc="connect-ok",ep="connect-not-ok",j0="connect-hover",H0="djs-updating",z0="djs-dragging",G0=1100;function V0(e,t,n,i){this._injector=t;var o=t.get("connectionPreview",!1);n.on("bendpoint.move.start",function(r){var a=r.context,s=a.bendpointIndex,c=a.connection,l=a.insert,u=c.waypoints,p=u.slice();a.waypoints=u,l&&p.splice(s,0,{x:r.x,y:r.y}),c.waypoints=p;var f=a.draggerGfx=sg(i.getLayer("overlays"));dt(f).add("djs-dragging"),i.addMarker(c,z0),i.addMarker(c,H0)}),n.on("bendpoint.move.hover",function(r){var a=r.context,s=a.allowed,c=a.hover,l=a.type;if(c){if(i.addMarker(c,j0),l===F0)return;s?(i.removeMarker(c,ep),i.addMarker(c,pc)):s===!1&&(i.removeMarker(c,pc),i.addMarker(c,ep))}}),n.on(["bendpoint.move.out","bendpoint.move.cleanup"],G0,function(r){var a=r.context,s=a.hover,c=a.target;s&&(i.removeMarker(s,j0),i.removeMarker(s,c?pc:ep))}),n.on("bendpoint.move.move",function(r){var a=r.context,s=a.allowed,c=a.bendpointIndex,l=a.draggerGfx,u=a.hover,p=a.type,f=a.connection,d=f.source,g=f.target,h=f.waypoints.slice(),m={x:r.x,y:r.y},w=a.hints||{},y={};o&&(w.connectionStart&&(y.connectionStart=w.connectionStart),w.connectionEnd&&(y.connectionEnd=w.connectionEnd),p===XB?Ju(a)?(y.connectionEnd=y.connectionEnd||m,y.source=g,y.target=u||d,h=h.reverse()):(y.connectionStart=y.connectionStart||m,y.source=u||d,y.target=g):p===ZB?Ju(a)?(y.connectionStart=y.connectionStart||m,y.source=u||g,y.target=d,h=h.reverse()):(y.connectionEnd=y.connectionEnd||m,y.source=d,y.target=u||g):(y.noCropping=!0,y.noLayout=!0,h[c]=m),p===F0&&(h=e.cropWaypoints(f,h)),y.waypoints=h,o.drawPreview(a,s,y)),Dn(l,r.x,r.y)},this),n.on(["bendpoint.move.end","bendpoint.move.cancel"],G0,function(r){var a=r.context,s=a.connection,c=a.draggerGfx,l=a.hover,u=a.target,p=a.waypoints;s.waypoints=p,sn(c),i.removeMarker(s,H0),i.removeMarker(s,z0),l&&(i.removeMarker(l,pc),i.removeMarker(l,u?pc:ep)),o&&o.cleanUp(a)})}V0.$inject=["bendpointMove","injector","eventBus","canvas"];var W0="connect-hover",U0="djs-updating";function q0(e,t,n){return ug(e,t,e[t]+n)}function ug(e,t,n){return{x:t==="x"?n:e.x,y:t==="y"?n:e.y}}function QB(e,t,n,i){var o=Math.max(t[i],n[i]),r=Math.min(t[i],n[i]),a=20,s=Math.min(Math.max(r+a,e[i]),o-a);return ug(t,i,s)}function Y0(e){return e==="x"?"y":"x"}function K0(e,t,n){var i,o;return e.original?e.original:(i=Je(t),o=Y0(n),ug(e,o,i[o]))}function X0(e,t,n,i,o,r){var a=e.get("connectionDocking",!1);this.start=function(p,f,d){var g,h=n.getGraphics(f),m=d-1,w=d,y=f.waypoints,v=y[m],x=y[w],E=ag(n,y,p),A,B,P;if(A=vo(v,x),!!A)return B=A==="v"?"x":"y",m===0&&(v=K0(v,f.source,B)),w===y.length-1&&(x=K0(x,f.target,B)),E?P=E.point:P={x:(v.x+x.x)/2,y:(v.y+x.y)/2},g={connection:f,segmentStartIndex:m,segmentEndIndex:w,segmentStart:v,segmentEnd:x,axis:B,dragPosition:P},i.init(p,P,"connectionSegment.move",{cursor:B==="x"?"resize-ew":"resize-ns",data:{connection:f,connectionGfx:h,context:g}})};function s(p,f){if(!a)return f;var d=p.waypoints,g;return p.waypoints=f,g=a.getCroppedWaypoints(p),p.waypoints=d,g}function c(p){o.update("connection",p.connection,p.connectionGfx)}function l(p,f,d){var g=p.newWaypoints,h=p.segmentStartIndex+f,m=g[h],w=p.segmentEndIndex+f,y=g[w],v=Y0(p.axis),x=QB(d,m,y,v);Dn(p.draggerGfx,x.x,x.y)}function u(p,f){var d=0,g=p.filter(function(h,m){return Yf(p[m-1],p[m+1],h)?(d=m<=f?d-1:d,!1):!0});return{waypoints:g,segmentOffset:d}}t.on("connectionSegment.move.start",function(p){var f=p.context,d=p.connection,g=n.getLayer("overlays");f.originalWaypoints=d.waypoints.slice(),f.draggerGfx=B0(g,f.segmentStart,f.segmentEnd),dt(f.draggerGfx).add("djs-dragging"),n.addMarker(d,U0)}),t.on("connectionSegment.move.move",function(p){var f=p.context,d=f.connection,g=f.segmentStartIndex,h=f.segmentEndIndex,m=f.segmentStart,w=f.segmentEnd,y=f.axis,v=f.originalWaypoints.slice(),x=q0(m,y,p["d"+y]),E=q0(w,y,p["d"+y]),A=v.length,B=0;v[g]=x,v[h]=E;var P,k;g<2&&(P=On(d.source,x),g===1?P==="intersect"&&(v.shift(),v[0]=x,B--):P!=="intersect"&&(v.unshift(m),B++)),h>A-3&&(k=On(d.target,E),h===A-2?k==="intersect"&&(v.pop(),v[v.length-1]=E):k!=="intersect"&&v.push(w)),f.newWaypoints=d.waypoints=s(d,v),l(f,B,p),f.newSegmentStartIndex=g+B,c(p)}),t.on("connectionSegment.move.hover",function(p){p.context.hover=p.hover,n.addMarker(p.hover,W0)}),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],function(p){var f=p.context.hover;f&&n.removeMarker(f,W0)}),t.on("connectionSegment.move.cleanup",function(p){var f=p.context,d=f.connection;f.draggerGfx&&sn(f.draggerGfx),n.removeMarker(d,U0)}),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],function(p){var f=p.context,d=f.connection;d.waypoints=f.originalWaypoints,c(p)}),t.on("connectionSegment.move.end",function(p){var f=p.context,d=f.connection,g=f.newWaypoints,h=f.newSegmentStartIndex;g=g.map(function(E){return{original:E.original,x:Math.round(E.x),y:Math.round(E.y)}});var m=u(g,h),w=m.waypoints,y=s(d,w),v=m.segmentOffset,x={segmentMove:{segmentStartIndex:f.segmentStartIndex,newSegmentStartIndex:h+v}};r.updateWaypoints(d,y,x)})}X0.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var JB=Math.abs,Z0=Math.round;function eN(e,t,n){n=n===void 0?10:n;var i,o;for(i=0;i<t.length;i++)if(o=t[i],JB(o-e)<=n)return o}function Q0(e){return{x:e.x,y:e.y}}function J0(e){return{x:e.x+e.width,y:e.y+e.height}}function Ti(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:Z0(e.x+e.width/2),y:Z0(e.y+e.height/2)}}function Ya(e,t){var n=e.snapped;return n?typeof t=="string"?n[t]:n.x&&n.y:!1}function fn(e,t,n){if(typeof t!="string")throw new Error("axis must be in [x, y]");if(typeof n!="number"&&n!==!1)throw new Error("value must be Number or false");var i,o=e[t],r=e.snapped=e.snapped||{};return n===!1?r[t]=!1:(r[t]=!0,i=n-o,e[t]+=i,e["d"+t]+=i),o}function eE(e){return e.children||[]}var tN=Math.abs,tE=Math.round,pg=10;function nE(e){function t(r,a){if(Ze(r)){for(var s=r.length;s--;)if(tN(r[s]-a)<=pg)return r[s]}else{r=+r;var c=a%r;if(c<pg)return a-c;if(c>r-pg)return a-c+r}return a}function n(r,a){if(r.waypoints)return UB(a,r);if(r.width)return{x:tE(r.width/2+r.x),y:tE(r.height/2+r.y)}}function i(r){var a=r.context,s=a.snapPoints,c=a.connection,l=c.waypoints,u=a.segmentStart,p=a.segmentStartIndex,f=a.segmentEnd,d=a.segmentEndIndex,g=a.axis;if(s)return s;var h=[l[p-1],u,f,l[d+1]];return p<2&&h.unshift(n(c.source,r)),d>l.length-3&&h.unshift(n(c.target,r)),a.snapPoints=s={horizontal:[],vertical:[]},V(h,function(m){m&&(m=m.original||m,g==="y"&&s.horizontal.push(m.y),g==="x"&&s.vertical.push(m.x))}),s}e.on("connectionSegment.move.move",1500,function(r){var a=i(r),s=r.x,c=r.y,l,u;if(a){l=t(a.vertical,s),u=t(a.horizontal,c);var p=s-l,f=c-u;Y(r,{dx:r.dx-p,dy:r.dy-f,x:l,y:u}),(p||a.vertical.indexOf(s)!==-1)&&fn(r,"x",l),(f||a.horizontal.indexOf(c)!==-1)&&fn(r,"y",u)}});function o(r){var a=r.snapPoints,s=r.connection.waypoints,c=r.bendpointIndex;if(a)return a;var l=[s[c-1],s[c+1]];return r.snapPoints=a={horizontal:[],vertical:[]},V(l,function(u){u&&(u=u.original||u,a.horizontal.push(u.y),a.vertical.push(u.x))}),a}e.on(["connect.hover","connect.move","connect.end"],1500,function(r){var a=r.context,s=a.hover,c=s&&n(s,r);!Ot(s)||!c||!c.x||!c.y||(fn(r,"x",c.x),fn(r,"y",c.y))}),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,function(r){var a=r.context,s=o(a),c=a.hover,l=c&&n(c,r),u=r.x,p=r.y,f,d;if(s){f=t(l?s.vertical.concat([l.x]):s.vertical,u),d=t(l?s.horizontal.concat([l.y]):s.horizontal,p);var g=u-f,h=p-d;Y(r,{dx:r.dx-g,dy:r.dy-h,x:r.x-g,y:r.y-h}),(g||s.vertical.indexOf(u)!==-1)&&fn(r,"x",f),(h||s.horizontal.indexOf(p)!==-1)&&fn(r,"y",d)}})}nE.$inject=["eventBus"];const nN={__depends__:[So,io],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",N0],bendpointMove:["type",lg],bendpointMovePreview:["type",V0],connectionSegmentMove:["type",X0],bendpointSnapping:["type",nE]};function iE(e,t,n,i){function o(a,s){return i.allowed("connection.create",{source:a,target:s})}function r(a,s){return o(s,a)}e.on("connect.hover",function(a){var s=a.context,c=s.start,l=a.hover,u;if(s.hover=l,u=s.canExecute=o(c,l),!ra(u)){if(u!==!1){s.source=c,s.target=l;return}u=s.canExecute=r(c,l),!ra(u)&&u!==!1&&(s.source=l,s.target=c)}}),e.on(["connect.out","connect.cleanup"],function(a){var s=a.context;s.hover=null,s.source=null,s.target=null,s.canExecute=!1}),e.on("connect.end",function(a){var s=a.context,c=s.canExecute,l=s.connectionStart,u={x:a.x,y:a.y},p=s.source,f=s.target;if(!c)return!1;var d=null,g={connectionStart:fg(s)?u:l,connectionEnd:fg(s)?l:u};mn(c)&&(d=c),s.connection=n.connect(p,f,d,g)}),this.start=function(a,s,c,l){mn(c)||(l=c,c=Je(s)),t.init(a,"connect",{autoActivate:l,data:{shape:s,context:{start:s,connectionStart:c}}})}}iE.$inject=["eventBus","dragging","modeling","rules"];function fg(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}var iN=1100,oN=900,oE="connect-ok",rE="connect-not-ok";function aE(e,t,n){var i=e.get("connectionPreview",!1);i&&t.on("connect.move",function(o){var r=o.context,a=r.canExecute,s=r.hover,c=r.source,l=r.start,u=r.startPosition,p=r.target,f=r.connectionStart||u,d=r.connectionEnd||{x:o.x,y:o.y},g=f,h=d;fg(r)&&(g=d,h=f),i.drawPreview(r,a,{source:c||l,target:p||s,connectionStart:g,connectionEnd:h})}),t.on("connect.hover",oN,function(o){var r=o.context,a=o.hover,s=r.canExecute;s!==null&&n.addMarker(a,s?oE:rE)}),t.on(["connect.out","connect.cleanup"],iN,function(o){var r=o.hover;r&&(n.removeMarker(r,oE),n.removeMarker(r,rE))}),i&&t.on("connect.cleanup",function(o){i.cleanUp(o.context)})}aE.$inject=["injector","eventBus","canvas"];const dg={__depends__:[Mi,io,So],__init__:["connectPreview"],connect:["type",iE],connectPreview:["type",aE]};var rN="djs-dragger";function ko(e,t,n,i){this._canvas=t,this._graphicsFactory=n,this._elementFactory=i,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}ko.$inject=["injector","canvas","graphicsFactory","elementFactory"],ko.prototype.drawPreview=function(e,t,n){n=n||{};var i=e.connectionPreviewGfx,o=e.getConnection,r=n.source,a=n.target,s=n.waypoints,c=n.connectionStart,l=n.connectionEnd,u=n.noLayout,p=n.noCropping,f=n.noNoop,d,g=this;if(i||(i=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),bs(i),o||(o=e.getConnection=aN(function(h,m,w){return g.getConnection(h,m,w)})),t&&(d=o(t,r,a)),!d){!f&&this.drawNoopPreview(i,n);return}d.waypoints=s||[],this._layouter&&!u&&(d.waypoints=this._layouter.layoutConnection(d,{source:r,target:a,connectionStart:c,connectionEnd:l,waypoints:n.waypoints||d.waypoints})),(!d.waypoints||!d.waypoints.length)&&(d.waypoints=[r?Je(r):c,a?Je(a):l]),this._connectionDocking&&(r||a)&&!p&&(d.waypoints=this._connectionDocking.getCroppedWaypoints(d,r,a)),this._graphicsFactory.drawConnection(i,d,{stroke:"var(--element-dragger-color)"})},ko.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,o=t.connectionStart||Je(n),r=t.connectionEnd||Je(i),a=this.cropWaypoints(o,r,n,i),s=this.createNoopConnection(a[0],a[1]);tt(e,s)},ko.prototype.cropWaypoints=function(e,t,n,i){var o=this._graphicsFactory,r=n&&o.getShapePath(n),a=i&&o.getShapePath(i),s=o.getConnectionPath({waypoints:[e,t]});return e=n&&Cs(r,s,!0)||e,t=i&&Cs(a,s,!1)||t,[e,t]},ko.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&sn(e.connectionPreviewGfx)},ko.prototype.getConnection=function(e){var t=sN(e);return this._elementFactory.createConnection(t)},ko.prototype.createConnectionPreviewGfx=function(){var e=He("g");return Ie(e,{pointerEvents:"none"}),dt(e).add(rN),tt(this._canvas.getActiveLayer(),e),e},ko.prototype.createNoopConnection=function(e,t){return _s([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};function aN(e){var t={};return function(n){var i=JSON.stringify(n),o=t[i];return o||(o=t[i]=e.apply(null,arguments)),o}}function sN(e){return mn(e)?e:{}}const cN={__init__:["connectionPreview"],connectionPreview:["type",ko]},tp="complex-preview";class sE{constructor(t,n,i){this._canvas=t,this._graphicsFactory=n,this._previewSupport=i,this._markers=[]}create(t){this.cleanUp();const{created:n=[],moved:i=[],removed:o=[],resized:r=[]}=t,a=this._canvas.getLayer(tp);n.filter(s=>!lN(s)).forEach(s=>{let c;Ot(s)?(c=this._graphicsFactory._createContainer("connection",He("g")),this._graphicsFactory.drawConnection(Ko(c),s)):(c=this._graphicsFactory._createContainer("shape",He("g")),this._graphicsFactory.drawShape(Ko(c),s),Dn(c,s.x,s.y)),this._previewSupport.addDragger(s,a,c)}),i.forEach(({element:s,delta:c})=>{this._previewSupport.addDragger(s,a,void 0,"djs-dragging"),this._canvas.addMarker(s,"djs-element-hidden"),this._markers.push([s,"djs-element-hidden"]);const l=this._previewSupport.addDragger(s,a);Ot(s)?Dn(l,c.x,c.y):Dn(l,s.x+c.x,s.y+c.y)}),o.forEach(s=>{this._previewSupport.addDragger(s,a,void 0,"djs-dragging"),this._canvas.addMarker(s,"djs-element-hidden"),this._markers.push([s,"djs-element-hidden"])}),r.forEach(({shape:s,bounds:c})=>{this._canvas.addMarker(s,"djs-hidden"),this._markers.push([s,"djs-hidden"]),this._previewSupport.addDragger(s,a,void 0,"djs-dragging");const l=this._graphicsFactory._createContainer("shape",He("g"));this._graphicsFactory.drawShape(Ko(l),s,{width:c.width,height:c.height}),Dn(l,c.x,c.y),this._previewSupport.addDragger(s,a,l)})}cleanUp(){bs(this._canvas.getLayer(tp)),this._markers.forEach(([t,n])=>this._canvas.removeMarker(t,n)),this._markers=[]}show(){this._canvas.showLayer(tp)}hide(){this._canvas.hideLayer(tp)}}sE.$inject=["canvas","graphicsFactory","previewSupport"];function lN(e){return e.hidden}const uN={__depends__:[Na],__init__:["complexPreview"],complexPreview:["type",sE]},cE=Math.round;function np(e,t,n,i,o,r){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=i,this._layouter=o,this._rules=r}np.prototype.create=function(e,t,n){const i=this._complexPreview,o=this._connectionDocking,r=this._elementFactory,a=this._eventBus,s=this._layouter,c=this._rules,l=r.createShape(Y({type:t},n)),u=a.fire("autoPlace",{source:e,shape:l});if(!u)return;Y(l,{x:u.x-cE(l.width/2),y:u.y-cE(l.height/2)});const p=c.allowed("connection.create",{source:e,target:l,hints:{targetParent:e.parent}});let f=null;p&&(f=r.createConnection(p),f.waypoints=s.layoutConnection(f,{source:e,target:l}),f.waypoints=o.getCroppedWaypoints(f,e,l)),i.create({created:[l,f].filter(d=>!ra(d))})},np.prototype.cleanUp=function(){this._complexPreview.cleanUp()},np.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];const pN={__depends__:[Cu,uN,Lh],__init__:["appendPreview"],appendPreview:["type",np]};var lE=Math.min,uE=Math.max;function hg(e){e.preventDefault()}function fc(e){e.stopPropagation()}function fN(e){return e.nodeType===Node.TEXT_NODE}function dN(e){return[].slice.call(e)}function Vi(e){this.container=e.container,this.parent=jt('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=Ct("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.focusoutHandler=e.focusoutHandler||function(){},this.autoResize=Kn(this.autoResize,this),this.handlePaste=Kn(this.handlePaste,this)}Vi.prototype.create=function(e,t,n,i){var o=this,r=this.parent,a=this.content,s=this.container;i=this.options=i||{},t=this.style=t||{};var c=Ni(t,["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);Y(r.style,{width:e.width+"px",height:e.height+"px",maxWidth:e.maxWidth+"px",maxHeight:e.maxHeight+"px",minWidth:e.minWidth+"px",minHeight:e.minHeight+"px",left:e.x+"px",top:e.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},c);var l=Ni(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return Y(a.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},l),i.centerVertically&&Y(a.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},l),a.innerText=n,Ve.bind(a,"keydown",this.keyHandler),Ve.bind(a,"mousedown",fc),Ve.bind(a,"paste",o.handlePaste),Ve.bind(a,"focusout",this.focusoutHandler),i.autoResize&&Ve.bind(a,"input",this.autoResize),i.resizable&&this.resizable(t),s.appendChild(r),this.setSelection(a.lastChild,a.lastChild&&a.lastChild.length),r},Vi.prototype.handlePaste=function(e){var t=this.options,n=this.style;e.preventDefault();var i;if(e.clipboardData?i=e.clipboardData.getData("text/plain"):i=window.clipboardData.getData("Text"),this.insertText(i),t.autoResize){var o=this.autoResize(n);o&&this.resizeHandler(o)}},Vi.prototype.insertText=function(e){e=hN(e);var t=document.execCommand("insertText",!1,e);t||this._insertTextIE(e)},Vi.prototype._insertTextIE=function(e){var t=this.getSelection(),n=t.startContainer,i=t.endContainer,o=t.startOffset,r=t.endOffset,a=t.commonAncestorContainer,s=dN(a.childNodes),c,l;if(fN(a)){var u=n.textContent;n.textContent=u.substring(0,o)+e+u.substring(r),c=n,l=o+e.length}else if(n===this.content&&i===this.content){var p=document.createTextNode(e);this.content.insertBefore(p,s[o]),c=p,l=p.textContent.length}else{var f=s.indexOf(n),d=s.indexOf(i);s.forEach(function(g,h){h===f?g.textContent=n.textContent.substring(0,o)+e+i.textContent.substring(r):h>f&&h<=d&&Zi(g)}),c=n,l=o+e.length}c&&l!==void 0&&setTimeout(function(){self.setSelection(c,l)})},Vi.prototype.autoResize=function(){var e=this.parent,t=this.content,n=parseInt(this.style.fontSize)||12;if(t.scrollHeight>e.offsetHeight||t.scrollHeight<e.offsetHeight-n){var i=e.getBoundingClientRect(),o=t.scrollHeight;e.style.height=o+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:o-i.height})}},Vi.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,i=parseInt(this.style.minWidth)||0,o=parseInt(this.style.minHeight)||0,r=parseInt(this.style.maxWidth)||1/0,a=parseInt(this.style.maxHeight)||1/0;if(!n){n=this.resizeHandle=jt('<div class="djs-direct-editing-resize-handle"></div>');var s,c,l,u,p=function(g){hg(g),fc(g),s=g.clientX,c=g.clientY;var h=t.getBoundingClientRect();l=h.width,u=h.height,Ve.bind(document,"mousemove",f),Ve.bind(document,"mouseup",d)},f=function(g){hg(g),fc(g);var h=lE(uE(l+g.clientX-s,i),r),m=lE(uE(u+g.clientY-c,o),a);t.style.width=h+"px",t.style.height=m+"px",e.resizeHandler({width:l,height:u,dx:g.clientX-s,dy:g.clientY-c})},d=function(g){hg(g),fc(g),Ve.unbind(document,"mousemove",f,!1),Ve.unbind(document,"mouseup",d,!1)};Ve.bind(n,"mousedown",p)}Y(n.style,{position:"absolute",bottom:"0px",right:"0px",cursor:"nwse-resize",width:"0",height:"0",borderTop:(parseInt(this.style.fontSize)/4||3)+"px solid transparent",borderRight:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderBottom:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderLeft:(parseInt(this.style.fontSize)/4||3)+"px solid transparent"}),t.appendChild(n)},Vi.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),Ve.unbind(t,"keydown",this.keyHandler),Ve.unbind(t,"mousedown",fc),Ve.unbind(t,"input",this.autoResize),Ve.unbind(t,"paste",this.handlePaste),Ve.unbind(t,"focusout",this.focusoutHandler),n&&(n.removeAttribute("style"),Zi(n)),Zi(e)},Vi.prototype.getValue=function(){return this.content.innerText.trim()},Vi.prototype.getSelection=function(){var e=window.getSelection(),t=e.getRangeAt(0);return t},Vi.prototype.setSelection=function(e,t){var n=document.createRange();e===null?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var i=window.getSelection();i.removeAllRanges(),i.addRange(n)};function hN(e){return e.replace(/\r\n|\r|\n/g,`
315
+ </svg>`},FB=900;function Ua(e,t,n,i){e.registerProvider(FB,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=i}Ua.$inject=["contextPad","popupMenu","translate","canvas"],Ua.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&Y(t,this._getEntries(e)),t},Ua.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")},Ua.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${D0.align}</div>`,action:{click:function(t,n){var i=e._getMenuPosition(n);Y(i,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",i)}}}}},Ua.prototype._getMenuPosition=function(e){var t=5,n=this._contextPad.getPad(e).html,i=n.getBoundingClientRect(),o={x:i.left,y:i.bottom+t};return o};var jB=["left","center","right","top","middle","bottom"];function lc(e,t,n,i){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",this)}lc.$inject=["popupMenu","alignElements","translate","rules"],lc.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&Y(t,this._getEntries(e)),t},lc.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})},lc.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,i=this._popupMenu,o={};return V(jB,function(r){o["align-elements-"+r]={group:"align",title:n("Align elements "+r),className:"bjs-align-elements-menu-entry",imageHtml:D0[r],action:function(){t.trigger(e,r),i.close()}}}),o};function Qu(e){Ci.call(this,e)}Qu.$inject=["eventBus"],Ne(Qu,Ci),Qu.prototype.init=function(){this.addRule("elements.align",function(e){var t=e.elements,n=ct(t,function(i){return!(i.waypoints||i.host||i.labelTarget)});return n=ml(n),n.length<2?!1:n})};const HB={__depends__:[QI,V_,rg],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",Ua],alignElementsMenuProvider:["type",lc],bpmnAlignElements:["type",Qu]};function qa(e,t,n){this._canvas=n,this._opts=Y({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},e);var i=this;t.on("drag.move",function(o){var r=i._toBorderPoint(o);i.startScroll(r)}),t.on(["drag.cleanup"],function(){i.stopScroll()})}qa.$inject=["config.autoScroll","eventBus","canvas"],qa.prototype.startScroll=function(e){var t=this._canvas,n=this._opts,i=this,o=t.getContainer().getBoundingClientRect(),r=[e.x,e.y,o.width-e.x,o.height-e.y];this.stopScroll();for(var a=0,s=0,c=0;c<4;c++)zB(r[c],n.scrollThresholdOut[c],n.scrollThresholdIn[c])&&(c===0?a=n.scrollStep:c==1?s=n.scrollStep:c==2?a=-n.scrollStep:c==3&&(s=-n.scrollStep));(a!==0||s!==0)&&(t.scroll({dx:a,dy:s}),this._scrolling=setTimeout(function(){i.startScroll(e)},n.scrollRepeatTimeout))};function zB(e,t,n){return t<e&&e<n}qa.prototype.stopScroll=function(){clearTimeout(this._scrolling)},qa.prototype.setOptions=function(e){this._opts=Y({},this._opts,e)},qa.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=Fr(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};const GB={__depends__:[So],__init__:["autoScroll"],autoScroll:["type",qa]};var L0="djs-bendpoint",I0="djs-segment-dragger";function VB(e,t){var n=Fr(t),i=e._container.getBoundingClientRect(),o;o={x:i.left,y:i.top};var r=e.viewbox();return{x:r.x+(n.x-o.x)/r.scale,y:r.y+(n.y-o.y)/r.scale}}function ag(e,t,n){var i=VB(e,n),o=xd(t,i);return o}function sg(e,t){var n=He("g");dt(n).add(L0),tt(e,n);var i=He("circle");Ie(i,{cx:0,cy:0,r:4}),dt(i).add("djs-visual"),tt(n,i);var o=He("circle");return Ie(o,{cx:0,cy:0,r:10}),dt(o).add("djs-hit"),tt(n,o),t&&dt(n).add(t),n}function WB(e,t,n,i){var o=He("g");tt(e,o);var r=18,a=6,s=11,c=qB(t,n,i),l=a+s,u=He("rect");Ie(u,{x:-r/2,y:-a/2,width:r,height:a}),dt(u).add("djs-visual"),tt(o,u);var p=He("rect");return Ie(p,{x:-c/2,y:-l/2,width:c,height:l}),dt(p).add("djs-hit"),tt(o,p),Uv(o,i==="v"?90:0),o}function B0(e,t,n){var i=He("g"),o=Kf(t,n),r=vo(t,n);return tt(e,i),WB(i,t,n,r),dt(i).add(I0),dt(i).add(r==="h"?"horizontal":"vertical"),Dn(i,o.x,o.y),i}function cg(e){return Math.abs(Math.round(e*2/3))}function UB(e,t){var n=YB(e,t);return Cd(e,n)}function qB(e,t,n){var i=t.x-e.x,o=t.y-e.y;return cg(n==="h"?i:o)}function YB(e,t){for(var n=t.waypoints,i=1/0,o,r=0;r<n.length-1;r++){var a=n[r],s=n[r+1],c=Ob(e,[a,s]);c<i&&(i=c,o=r)}return[n[o],n[o+1]]}function N0(e,t,n,i,o){function r(v,x,E){var A=v.index,I=v.point,P,k,H,F,G,ee;return A<=0||v.bendpoint?!1:(P=x[A-1],k=x[A],H=Kf(P,k),F=vo(P,k),G=Math.abs(I.x-H.x),ee=Math.abs(I.y-H.y),F&&G<=E&&ee<=E)}function a(v,x){var E=v.waypoints,A,I,P,k;return x.index<=0||x.bendpoint||(A={start:E[x.index-1],end:E[x.index]},I=vo(A.start,A.end),!I)?null:(I==="h"?P=A.end.x-A.start.x:P=A.end.y-A.start.y,k=cg(P)/2,k)}function s(v,x){var E=x.waypoints,A=ag(t,E,v),I;if(A){I=a(x,A);var P;if(r(A,E,I)?P=o.start(v,x,A.index):P=i.start(v,x,A.index,!A.bendpoint),P!==!1)return!0}}function c(v,x,E){Ve.bind(v,x,function(A){n.triggerMouseEvent(x,A,E),A.stopPropagation()})}function l(v,x){var E=t.getLayer("overlays"),A=Ct('.djs-bendpoints[data-element-id="'+Ur(v.id)+'"]',E);return!A&&x&&(A=He("g"),Ie(A,{"data-element-id":v.id}),dt(A).add("djs-bendpoints"),tt(E,A),c(A,"mousedown",v),c(A,"click",v),c(A,"dblclick",v)),A}function u(v,x){return Ct('.djs-segment-dragger[data-segment-idx="'+v+'"]',x)}function p(v,x){x.waypoints.forEach(function(E,A){var I=sg(v);tt(v,I),Dn(I,E.x,E.y)}),sg(v,"floating")}function f(v,x){for(var E=x.waypoints,A,I,P,k=1;k<E.length;k++)A=E[k-1],I=E[k],vo(A,I)&&(P=B0(v,A,I),Ie(P,{"data-segment-idx":k}),c(P,"mousemove",x))}function d(v){V(vs("."+L0,v),function(x){sn(x)})}function g(v){V(vs("."+I0,v),function(x){sn(x)})}function h(v){var x=l(v);return x||(x=l(v,!0),p(x,v),f(x,v)),x}function m(v){var x=l(v);x&&(g(x),d(x),f(x,v),p(x,v))}function w(v,x){var E=Ct(".floating",v),A=x.point;E&&(Dn(E,A.x,A.y),dt(E).add("positioned"))}function y(v,x,E){var A=u(x.index,v),I=E[x.index-1],P=E[x.index],k=x.point,H=Kf(I,P),F=vo(I,P),G,ee;A&&(G=KB(A),ee={x:k.x-H.x,y:k.y-H.y},F==="v"&&(ee={x:ee.y,y:ee.x}),Dn(G,ee.x,ee.y))}e.on("connection.changed",function(v){m(v.element)}),e.on("connection.remove",function(v){var x=l(v.element);x&&sn(x)}),e.on("element.marker.update",function(v){var x=v.element,E;x.waypoints&&(E=h(x),v.add?dt(E).add(v.marker):dt(E).remove(v.marker))}),e.on("element.mousemove",function(v){var x=v.element,E=x.waypoints,A,I;if(E){if(A=l(x,!0),I=ag(t,E,v.originalEvent),!I)return;w(A,I),I.bendpoint||y(A,I,E)}}),e.on("element.mousedown",function(v){if(tr(v)){var x=v.originalEvent,E=v.element;if(E.waypoints)return s(x,E)}}),e.on("selection.changed",function(v){var x=v.newSelection,E=x[0];E&&E.waypoints&&h(E)}),e.on("element.hover",function(v){var x=v.element;x.waypoints&&h(x)}),e.on("element.out",function(v){var x=v.element;if(x.waypoints){var E=l(x);if(E){var A=Ct(".floating",E);A&&dt(A).remove("positioned")}}}),e.on("element.updateId",function(v){var x=v.element,E=v.newId;if(x.waypoints){var A=l(x);A&&Ie(A,{"data-element-id":E})}}),this.addHandles=h,this.updateHandles=m,this.getBendpointsContainer=l,this.getSegmentDragger=u}N0.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];function KB(e){return Ct(".djs-visual",e)}var $0=Math.round,Kr="reconnectStart",Xr="reconnectEnd",uc="updateWaypoints";function lg(e,t,n,i,o,r){this._injector=e,this.start=function(a,s,c,l){var u=n.getGraphics(s),p=s.source,f=s.target,d=s.waypoints,g;!l&&c===0?g=Kr:!l&&c===d.length-1?g=Xr:g=uc;var h=g===uc?"connection.updateWaypoints":"connection.reconnect",m=o.allowed(h,{connection:s,source:p,target:f});if(m===!1&&(m=o.allowed(h,{connection:s,source:f,target:p})),m!==!1)return i.init(a,"bendpoint.move",{data:{connection:s,connectionGfx:u,context:{allowed:m,bendpointIndex:c,connection:s,source:p,target:f,insert:l,type:g}}})},t.on("bendpoint.move.hover",function(a){var s=a.context,c=s.connection,l=c.source,u=c.target,p=a.hover,f=s.type;s.hover=p;var d;if(p){var g=f===uc?"connection.updateWaypoints":"connection.reconnect";if(d=s.allowed=o.allowed(g,{connection:c,source:f===Kr?p:l,target:f===Xr?p:u}),d){s.source=f===Kr?p:l,s.target=f===Xr?p:u;return}d===!1&&(d=s.allowed=o.allowed(g,{connection:c,source:f===Xr?p:u,target:f===Kr?p:l})),d&&(s.source=f===Xr?p:u,s.target=f===Kr?p:l)}}),t.on(["bendpoint.move.out","bendpoint.move.cleanup"],function(a){var s=a.context,c=s.type;s.hover=null,s.source=null,s.target=null,c!==uc&&(s.allowed=!1)}),t.on("bendpoint.move.end",function(a){var s=a.context,c=s.allowed,l=s.bendpointIndex,u=s.connection,p=s.insert,f=u.waypoints.slice(),d=s.source,g=s.target,h=s.type,m=s.hints||{},w={x:$0(a.x),y:$0(a.y)};if(!c)return!1;h===uc?(p?f.splice(l,0,w):f[l]=w,m.bendpointMove={insert:p,bendpointIndex:l},f=this.cropWaypoints(u,f),r.updateWaypoints(u,tT(f),m)):(h===Kr?(m.docking="source",Ju(s)&&(m.docking="target",m.newWaypoints=f.reverse())):h===Xr&&(m.docking="target",Ju(s)&&(m.docking="source",m.newWaypoints=f.reverse())),r.reconnect(u,d,g,w,m))},this)}lg.$inject=["injector","eventBus","canvas","dragging","rules","modeling"],lg.prototype.cropWaypoints=function(e,t){var n=this._injector.get("connectionDocking",!1);if(!n)return t;var i=e.waypoints;return e.waypoints=t,e.waypoints=n.getCroppedWaypoints(e),t=e.waypoints,e.waypoints=i,t};function Ju(e){var t=e.hover,n=e.source,i=e.target,o=e.type;if(o===Kr)return t&&i&&t===i&&n!==i;if(o===Xr)return t&&n&&t===n&&n!==i}var XB="reconnectStart",ZB="reconnectEnd",F0="updateWaypoints",pc="connect-ok",ep="connect-not-ok",j0="connect-hover",H0="djs-updating",z0="djs-dragging",G0=1100;function V0(e,t,n,i){this._injector=t;var o=t.get("connectionPreview",!1);n.on("bendpoint.move.start",function(r){var a=r.context,s=a.bendpointIndex,c=a.connection,l=a.insert,u=c.waypoints,p=u.slice();a.waypoints=u,l&&p.splice(s,0,{x:r.x,y:r.y}),c.waypoints=p;var f=a.draggerGfx=sg(i.getLayer("overlays"));dt(f).add("djs-dragging"),i.addMarker(c,z0),i.addMarker(c,H0)}),n.on("bendpoint.move.hover",function(r){var a=r.context,s=a.allowed,c=a.hover,l=a.type;if(c){if(i.addMarker(c,j0),l===F0)return;s?(i.removeMarker(c,ep),i.addMarker(c,pc)):s===!1&&(i.removeMarker(c,pc),i.addMarker(c,ep))}}),n.on(["bendpoint.move.out","bendpoint.move.cleanup"],G0,function(r){var a=r.context,s=a.hover,c=a.target;s&&(i.removeMarker(s,j0),i.removeMarker(s,c?pc:ep))}),n.on("bendpoint.move.move",function(r){var a=r.context,s=a.allowed,c=a.bendpointIndex,l=a.draggerGfx,u=a.hover,p=a.type,f=a.connection,d=f.source,g=f.target,h=f.waypoints.slice(),m={x:r.x,y:r.y},w=a.hints||{},y={};o&&(w.connectionStart&&(y.connectionStart=w.connectionStart),w.connectionEnd&&(y.connectionEnd=w.connectionEnd),p===XB?Ju(a)?(y.connectionEnd=y.connectionEnd||m,y.source=g,y.target=u||d,h=h.reverse()):(y.connectionStart=y.connectionStart||m,y.source=u||d,y.target=g):p===ZB?Ju(a)?(y.connectionStart=y.connectionStart||m,y.source=u||g,y.target=d,h=h.reverse()):(y.connectionEnd=y.connectionEnd||m,y.source=d,y.target=u||g):(y.noCropping=!0,y.noLayout=!0,h[c]=m),p===F0&&(h=e.cropWaypoints(f,h)),y.waypoints=h,o.drawPreview(a,s,y)),Dn(l,r.x,r.y)},this),n.on(["bendpoint.move.end","bendpoint.move.cancel"],G0,function(r){var a=r.context,s=a.connection,c=a.draggerGfx,l=a.hover,u=a.target,p=a.waypoints;s.waypoints=p,sn(c),i.removeMarker(s,H0),i.removeMarker(s,z0),l&&(i.removeMarker(l,pc),i.removeMarker(l,u?pc:ep)),o&&o.cleanUp(a)})}V0.$inject=["bendpointMove","injector","eventBus","canvas"];var W0="connect-hover",U0="djs-updating";function q0(e,t,n){return ug(e,t,e[t]+n)}function ug(e,t,n){return{x:t==="x"?n:e.x,y:t==="y"?n:e.y}}function QB(e,t,n,i){var o=Math.max(t[i],n[i]),r=Math.min(t[i],n[i]),a=20,s=Math.min(Math.max(r+a,e[i]),o-a);return ug(t,i,s)}function Y0(e){return e==="x"?"y":"x"}function K0(e,t,n){var i,o;return e.original?e.original:(i=Je(t),o=Y0(n),ug(e,o,i[o]))}function X0(e,t,n,i,o,r){var a=e.get("connectionDocking",!1);this.start=function(p,f,d){var g,h=n.getGraphics(f),m=d-1,w=d,y=f.waypoints,v=y[m],x=y[w],E=ag(n,y,p),A,I,P;if(A=vo(v,x),!!A)return I=A==="v"?"x":"y",m===0&&(v=K0(v,f.source,I)),w===y.length-1&&(x=K0(x,f.target,I)),E?P=E.point:P={x:(v.x+x.x)/2,y:(v.y+x.y)/2},g={connection:f,segmentStartIndex:m,segmentEndIndex:w,segmentStart:v,segmentEnd:x,axis:I,dragPosition:P},i.init(p,P,"connectionSegment.move",{cursor:I==="x"?"resize-ew":"resize-ns",data:{connection:f,connectionGfx:h,context:g}})};function s(p,f){if(!a)return f;var d=p.waypoints,g;return p.waypoints=f,g=a.getCroppedWaypoints(p),p.waypoints=d,g}function c(p){o.update("connection",p.connection,p.connectionGfx)}function l(p,f,d){var g=p.newWaypoints,h=p.segmentStartIndex+f,m=g[h],w=p.segmentEndIndex+f,y=g[w],v=Y0(p.axis),x=QB(d,m,y,v);Dn(p.draggerGfx,x.x,x.y)}function u(p,f){var d=0,g=p.filter(function(h,m){return Yf(p[m-1],p[m+1],h)?(d=m<=f?d-1:d,!1):!0});return{waypoints:g,segmentOffset:d}}t.on("connectionSegment.move.start",function(p){var f=p.context,d=p.connection,g=n.getLayer("overlays");f.originalWaypoints=d.waypoints.slice(),f.draggerGfx=B0(g,f.segmentStart,f.segmentEnd),dt(f.draggerGfx).add("djs-dragging"),n.addMarker(d,U0)}),t.on("connectionSegment.move.move",function(p){var f=p.context,d=f.connection,g=f.segmentStartIndex,h=f.segmentEndIndex,m=f.segmentStart,w=f.segmentEnd,y=f.axis,v=f.originalWaypoints.slice(),x=q0(m,y,p["d"+y]),E=q0(w,y,p["d"+y]),A=v.length,I=0;v[g]=x,v[h]=E;var P,k;g<2&&(P=On(d.source,x),g===1?P==="intersect"&&(v.shift(),v[0]=x,I--):P!=="intersect"&&(v.unshift(m),I++)),h>A-3&&(k=On(d.target,E),h===A-2?k==="intersect"&&(v.pop(),v[v.length-1]=E):k!=="intersect"&&v.push(w)),f.newWaypoints=d.waypoints=s(d,v),l(f,I,p),f.newSegmentStartIndex=g+I,c(p)}),t.on("connectionSegment.move.hover",function(p){p.context.hover=p.hover,n.addMarker(p.hover,W0)}),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],function(p){var f=p.context.hover;f&&n.removeMarker(f,W0)}),t.on("connectionSegment.move.cleanup",function(p){var f=p.context,d=f.connection;f.draggerGfx&&sn(f.draggerGfx),n.removeMarker(d,U0)}),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],function(p){var f=p.context,d=f.connection;d.waypoints=f.originalWaypoints,c(p)}),t.on("connectionSegment.move.end",function(p){var f=p.context,d=f.connection,g=f.newWaypoints,h=f.newSegmentStartIndex;g=g.map(function(E){return{original:E.original,x:Math.round(E.x),y:Math.round(E.y)}});var m=u(g,h),w=m.waypoints,y=s(d,w),v=m.segmentOffset,x={segmentMove:{segmentStartIndex:f.segmentStartIndex,newSegmentStartIndex:h+v}};r.updateWaypoints(d,y,x)})}X0.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];var JB=Math.abs,Z0=Math.round;function eN(e,t,n){n=n===void 0?10:n;var i,o;for(i=0;i<t.length;i++)if(o=t[i],JB(o-e)<=n)return o}function Q0(e){return{x:e.x,y:e.y}}function J0(e){return{x:e.x+e.width,y:e.y+e.height}}function Ti(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:Z0(e.x+e.width/2),y:Z0(e.y+e.height/2)}}function Ya(e,t){var n=e.snapped;return n?typeof t=="string"?n[t]:n.x&&n.y:!1}function fn(e,t,n){if(typeof t!="string")throw new Error("axis must be in [x, y]");if(typeof n!="number"&&n!==!1)throw new Error("value must be Number or false");var i,o=e[t],r=e.snapped=e.snapped||{};return n===!1?r[t]=!1:(r[t]=!0,i=n-o,e[t]+=i,e["d"+t]+=i),o}function eE(e){return e.children||[]}var tN=Math.abs,tE=Math.round,pg=10;function nE(e){function t(r,a){if(Ze(r)){for(var s=r.length;s--;)if(tN(r[s]-a)<=pg)return r[s]}else{r=+r;var c=a%r;if(c<pg)return a-c;if(c>r-pg)return a-c+r}return a}function n(r,a){if(r.waypoints)return UB(a,r);if(r.width)return{x:tE(r.width/2+r.x),y:tE(r.height/2+r.y)}}function i(r){var a=r.context,s=a.snapPoints,c=a.connection,l=c.waypoints,u=a.segmentStart,p=a.segmentStartIndex,f=a.segmentEnd,d=a.segmentEndIndex,g=a.axis;if(s)return s;var h=[l[p-1],u,f,l[d+1]];return p<2&&h.unshift(n(c.source,r)),d>l.length-3&&h.unshift(n(c.target,r)),a.snapPoints=s={horizontal:[],vertical:[]},V(h,function(m){m&&(m=m.original||m,g==="y"&&s.horizontal.push(m.y),g==="x"&&s.vertical.push(m.x))}),s}e.on("connectionSegment.move.move",1500,function(r){var a=i(r),s=r.x,c=r.y,l,u;if(a){l=t(a.vertical,s),u=t(a.horizontal,c);var p=s-l,f=c-u;Y(r,{dx:r.dx-p,dy:r.dy-f,x:l,y:u}),(p||a.vertical.indexOf(s)!==-1)&&fn(r,"x",l),(f||a.horizontal.indexOf(c)!==-1)&&fn(r,"y",u)}});function o(r){var a=r.snapPoints,s=r.connection.waypoints,c=r.bendpointIndex;if(a)return a;var l=[s[c-1],s[c+1]];return r.snapPoints=a={horizontal:[],vertical:[]},V(l,function(u){u&&(u=u.original||u,a.horizontal.push(u.y),a.vertical.push(u.x))}),a}e.on(["connect.hover","connect.move","connect.end"],1500,function(r){var a=r.context,s=a.hover,c=s&&n(s,r);!Ot(s)||!c||!c.x||!c.y||(fn(r,"x",c.x),fn(r,"y",c.y))}),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,function(r){var a=r.context,s=o(a),c=a.hover,l=c&&n(c,r),u=r.x,p=r.y,f,d;if(s){f=t(l?s.vertical.concat([l.x]):s.vertical,u),d=t(l?s.horizontal.concat([l.y]):s.horizontal,p);var g=u-f,h=p-d;Y(r,{dx:r.dx-g,dy:r.dy-h,x:r.x-g,y:r.y-h}),(g||s.vertical.indexOf(u)!==-1)&&fn(r,"x",f),(h||s.horizontal.indexOf(p)!==-1)&&fn(r,"y",d)}})}nE.$inject=["eventBus"];const nN={__depends__:[So,io],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",N0],bendpointMove:["type",lg],bendpointMovePreview:["type",V0],connectionSegmentMove:["type",X0],bendpointSnapping:["type",nE]};function iE(e,t,n,i){function o(a,s){return i.allowed("connection.create",{source:a,target:s})}function r(a,s){return o(s,a)}e.on("connect.hover",function(a){var s=a.context,c=s.start,l=a.hover,u;if(s.hover=l,u=s.canExecute=o(c,l),!ra(u)){if(u!==!1){s.source=c,s.target=l;return}u=s.canExecute=r(c,l),!ra(u)&&u!==!1&&(s.source=l,s.target=c)}}),e.on(["connect.out","connect.cleanup"],function(a){var s=a.context;s.hover=null,s.source=null,s.target=null,s.canExecute=!1}),e.on("connect.end",function(a){var s=a.context,c=s.canExecute,l=s.connectionStart,u={x:a.x,y:a.y},p=s.source,f=s.target;if(!c)return!1;var d=null,g={connectionStart:fg(s)?u:l,connectionEnd:fg(s)?l:u};mn(c)&&(d=c),s.connection=n.connect(p,f,d,g)}),this.start=function(a,s,c,l){mn(c)||(l=c,c=Je(s)),t.init(a,"connect",{autoActivate:l,data:{shape:s,context:{start:s,connectionStart:c}}})}}iE.$inject=["eventBus","dragging","modeling","rules"];function fg(e){var t=e.hover,n=e.source,i=e.target;return t&&n&&t===n&&n!==i}var iN=1100,oN=900,oE="connect-ok",rE="connect-not-ok";function aE(e,t,n){var i=e.get("connectionPreview",!1);i&&t.on("connect.move",function(o){var r=o.context,a=r.canExecute,s=r.hover,c=r.source,l=r.start,u=r.startPosition,p=r.target,f=r.connectionStart||u,d=r.connectionEnd||{x:o.x,y:o.y},g=f,h=d;fg(r)&&(g=d,h=f),i.drawPreview(r,a,{source:c||l,target:p||s,connectionStart:g,connectionEnd:h})}),t.on("connect.hover",oN,function(o){var r=o.context,a=o.hover,s=r.canExecute;s!==null&&n.addMarker(a,s?oE:rE)}),t.on(["connect.out","connect.cleanup"],iN,function(o){var r=o.hover;r&&(n.removeMarker(r,oE),n.removeMarker(r,rE))}),i&&t.on("connect.cleanup",function(o){i.cleanUp(o.context)})}aE.$inject=["injector","eventBus","canvas"];const dg={__depends__:[Mi,io,So],__init__:["connectPreview"],connect:["type",iE],connectPreview:["type",aE]};var rN="djs-dragger";function ko(e,t,n,i){this._canvas=t,this._graphicsFactory=n,this._elementFactory=i,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}ko.$inject=["injector","canvas","graphicsFactory","elementFactory"],ko.prototype.drawPreview=function(e,t,n){n=n||{};var i=e.connectionPreviewGfx,o=e.getConnection,r=n.source,a=n.target,s=n.waypoints,c=n.connectionStart,l=n.connectionEnd,u=n.noLayout,p=n.noCropping,f=n.noNoop,d,g=this;if(i||(i=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),bs(i),o||(o=e.getConnection=aN(function(h,m,w){return g.getConnection(h,m,w)})),t&&(d=o(t,r,a)),!d){!f&&this.drawNoopPreview(i,n);return}d.waypoints=s||[],this._layouter&&!u&&(d.waypoints=this._layouter.layoutConnection(d,{source:r,target:a,connectionStart:c,connectionEnd:l,waypoints:n.waypoints||d.waypoints})),(!d.waypoints||!d.waypoints.length)&&(d.waypoints=[r?Je(r):c,a?Je(a):l]),this._connectionDocking&&(r||a)&&!p&&(d.waypoints=this._connectionDocking.getCroppedWaypoints(d,r,a)),this._graphicsFactory.drawConnection(i,d,{stroke:"var(--element-dragger-color)"})},ko.prototype.drawNoopPreview=function(e,t){var n=t.source,i=t.target,o=t.connectionStart||Je(n),r=t.connectionEnd||Je(i),a=this.cropWaypoints(o,r,n,i),s=this.createNoopConnection(a[0],a[1]);tt(e,s)},ko.prototype.cropWaypoints=function(e,t,n,i){var o=this._graphicsFactory,r=n&&o.getShapePath(n),a=i&&o.getShapePath(i),s=o.getConnectionPath({waypoints:[e,t]});return e=n&&Cs(r,s,!0)||e,t=i&&Cs(a,s,!1)||t,[e,t]},ko.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&sn(e.connectionPreviewGfx)},ko.prototype.getConnection=function(e){var t=sN(e);return this._elementFactory.createConnection(t)},ko.prototype.createConnectionPreviewGfx=function(){var e=He("g");return Ie(e,{pointerEvents:"none"}),dt(e).add(rN),tt(this._canvas.getActiveLayer(),e),e},ko.prototype.createNoopConnection=function(e,t){return _s([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};function aN(e){var t={};return function(n){var i=JSON.stringify(n),o=t[i];return o||(o=t[i]=e.apply(null,arguments)),o}}function sN(e){return mn(e)?e:{}}const cN={__init__:["connectionPreview"],connectionPreview:["type",ko]},tp="complex-preview";class sE{constructor(t,n,i){this._canvas=t,this._graphicsFactory=n,this._previewSupport=i,this._markers=[]}create(t){this.cleanUp();const{created:n=[],moved:i=[],removed:o=[],resized:r=[]}=t,a=this._canvas.getLayer(tp);n.filter(s=>!lN(s)).forEach(s=>{let c;Ot(s)?(c=this._graphicsFactory._createContainer("connection",He("g")),this._graphicsFactory.drawConnection(Ko(c),s)):(c=this._graphicsFactory._createContainer("shape",He("g")),this._graphicsFactory.drawShape(Ko(c),s),Dn(c,s.x,s.y)),this._previewSupport.addDragger(s,a,c)}),i.forEach(({element:s,delta:c})=>{this._previewSupport.addDragger(s,a,void 0,"djs-dragging"),this._canvas.addMarker(s,"djs-element-hidden"),this._markers.push([s,"djs-element-hidden"]);const l=this._previewSupport.addDragger(s,a);Ot(s)?Dn(l,c.x,c.y):Dn(l,s.x+c.x,s.y+c.y)}),o.forEach(s=>{this._previewSupport.addDragger(s,a,void 0,"djs-dragging"),this._canvas.addMarker(s,"djs-element-hidden"),this._markers.push([s,"djs-element-hidden"])}),r.forEach(({shape:s,bounds:c})=>{this._canvas.addMarker(s,"djs-hidden"),this._markers.push([s,"djs-hidden"]),this._previewSupport.addDragger(s,a,void 0,"djs-dragging");const l=this._graphicsFactory._createContainer("shape",He("g"));this._graphicsFactory.drawShape(Ko(l),s,{width:c.width,height:c.height}),Dn(l,c.x,c.y),this._previewSupport.addDragger(s,a,l)})}cleanUp(){bs(this._canvas.getLayer(tp)),this._markers.forEach(([t,n])=>this._canvas.removeMarker(t,n)),this._markers=[]}show(){this._canvas.showLayer(tp)}hide(){this._canvas.hideLayer(tp)}}sE.$inject=["canvas","graphicsFactory","previewSupport"];function lN(e){return e.hidden}const uN={__depends__:[Na],__init__:["complexPreview"],complexPreview:["type",sE]},cE=Math.round;function np(e,t,n,i,o,r){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=i,this._layouter=o,this._rules=r}np.prototype.create=function(e,t,n){const i=this._complexPreview,o=this._connectionDocking,r=this._elementFactory,a=this._eventBus,s=this._layouter,c=this._rules,l=r.createShape(Y({type:t},n)),u=a.fire("autoPlace",{source:e,shape:l});if(!u)return;Y(l,{x:u.x-cE(l.width/2),y:u.y-cE(l.height/2)});const p=c.allowed("connection.create",{source:e,target:l,hints:{targetParent:e.parent}});let f=null;p&&(f=r.createConnection(p),f.waypoints=s.layoutConnection(f,{source:e,target:l}),f.waypoints=o.getCroppedWaypoints(f,e,l)),i.create({created:[l,f].filter(d=>!ra(d))})},np.prototype.cleanUp=function(){this._complexPreview.cleanUp()},np.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];const pN={__depends__:[Cu,uN,Lh],__init__:["appendPreview"],appendPreview:["type",np]};var lE=Math.min,uE=Math.max;function hg(e){e.preventDefault()}function fc(e){e.stopPropagation()}function fN(e){return e.nodeType===Node.TEXT_NODE}function dN(e){return[].slice.call(e)}function Vi(e){this.container=e.container,this.parent=jt('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=Ct("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.focusoutHandler=e.focusoutHandler||function(){},this.autoResize=Kn(this.autoResize,this),this.handlePaste=Kn(this.handlePaste,this)}Vi.prototype.create=function(e,t,n,i){var o=this,r=this.parent,a=this.content,s=this.container;i=this.options=i||{},t=this.style=t||{};var c=Ni(t,["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);Y(r.style,{width:e.width+"px",height:e.height+"px",maxWidth:e.maxWidth+"px",maxHeight:e.maxHeight+"px",minWidth:e.minWidth+"px",minHeight:e.minHeight+"px",left:e.x+"px",top:e.y+"px",backgroundColor:"#ffffff",position:"absolute",overflow:"visible",border:"1px solid #ccc",boxSizing:"border-box",wordWrap:"normal",textAlign:"center",outline:"none"},c);var l=Ni(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return Y(a.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},l),i.centerVertically&&Y(a.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},l),a.innerText=n,Ve.bind(a,"keydown",this.keyHandler),Ve.bind(a,"mousedown",fc),Ve.bind(a,"paste",o.handlePaste),Ve.bind(a,"focusout",this.focusoutHandler),i.autoResize&&Ve.bind(a,"input",this.autoResize),i.resizable&&this.resizable(t),s.appendChild(r),this.setSelection(a.lastChild,a.lastChild&&a.lastChild.length),r},Vi.prototype.handlePaste=function(e){var t=this.options,n=this.style;e.preventDefault();var i;if(e.clipboardData?i=e.clipboardData.getData("text/plain"):i=window.clipboardData.getData("Text"),this.insertText(i),t.autoResize){var o=this.autoResize(n);o&&this.resizeHandler(o)}},Vi.prototype.insertText=function(e){e=hN(e);var t=document.execCommand("insertText",!1,e);t||this._insertTextIE(e)},Vi.prototype._insertTextIE=function(e){var t=this.getSelection(),n=t.startContainer,i=t.endContainer,o=t.startOffset,r=t.endOffset,a=t.commonAncestorContainer,s=dN(a.childNodes),c,l;if(fN(a)){var u=n.textContent;n.textContent=u.substring(0,o)+e+u.substring(r),c=n,l=o+e.length}else if(n===this.content&&i===this.content){var p=document.createTextNode(e);this.content.insertBefore(p,s[o]),c=p,l=p.textContent.length}else{var f=s.indexOf(n),d=s.indexOf(i);s.forEach(function(g,h){h===f?g.textContent=n.textContent.substring(0,o)+e+i.textContent.substring(r):h>f&&h<=d&&Zi(g)}),c=n,l=o+e.length}c&&l!==void 0&&setTimeout(function(){self.setSelection(c,l)})},Vi.prototype.autoResize=function(){var e=this.parent,t=this.content,n=parseInt(this.style.fontSize)||12;if(t.scrollHeight>e.offsetHeight||t.scrollHeight<e.offsetHeight-n){var i=e.getBoundingClientRect(),o=t.scrollHeight;e.style.height=o+"px",this.resizeHandler({width:i.width,height:i.height,dx:0,dy:o-i.height})}},Vi.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,i=parseInt(this.style.minWidth)||0,o=parseInt(this.style.minHeight)||0,r=parseInt(this.style.maxWidth)||1/0,a=parseInt(this.style.maxHeight)||1/0;if(!n){n=this.resizeHandle=jt('<div class="djs-direct-editing-resize-handle"></div>');var s,c,l,u,p=function(g){hg(g),fc(g),s=g.clientX,c=g.clientY;var h=t.getBoundingClientRect();l=h.width,u=h.height,Ve.bind(document,"mousemove",f),Ve.bind(document,"mouseup",d)},f=function(g){hg(g),fc(g);var h=lE(uE(l+g.clientX-s,i),r),m=lE(uE(u+g.clientY-c,o),a);t.style.width=h+"px",t.style.height=m+"px",e.resizeHandler({width:l,height:u,dx:g.clientX-s,dy:g.clientY-c})},d=function(g){hg(g),fc(g),Ve.unbind(document,"mousemove",f,!1),Ve.unbind(document,"mouseup",d,!1)};Ve.bind(n,"mousedown",p)}Y(n.style,{position:"absolute",bottom:"0px",right:"0px",cursor:"nwse-resize",width:"0",height:"0",borderTop:(parseInt(this.style.fontSize)/4||3)+"px solid transparent",borderRight:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderBottom:(parseInt(this.style.fontSize)/4||3)+"px solid #ccc",borderLeft:(parseInt(this.style.fontSize)/4||3)+"px solid transparent"}),t.appendChild(n)},Vi.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),Ve.unbind(t,"keydown",this.keyHandler),Ve.unbind(t,"mousedown",fc),Ve.unbind(t,"input",this.autoResize),Ve.unbind(t,"paste",this.handlePaste),Ve.unbind(t,"focusout",this.focusoutHandler),n&&(n.removeAttribute("style"),Zi(n)),Zi(e)},Vi.prototype.getValue=function(){return this.content.innerText.trim()},Vi.prototype.getSelection=function(){var e=window.getSelection(),t=e.getRangeAt(0);return t},Vi.prototype.setSelection=function(e,t){var n=document.createRange();e===null?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var i=window.getSelection();i.removeAllRanges(),i.addRange(n)};function hN(e){return e.replace(/\r\n|\r|\n/g,`
316
316
  `)}function ui(e,t){this._eventBus=e,this._canvas=t,this._providers=[],this._textbox=new Vi({container:t.getContainer(),keyHandler:Kn(this._handleKey,this),resizeHandler:Kn(this._handleResize,this),focusoutHandler:Kn(this._handleFocusout,this)}),e.on(["diagram.clear","diagram.destroy"],()=>this._cleanup())}ui.$inject=["eventBus","canvas"],ui.prototype.registerProvider=function(e){this._providers.push(e)},ui.prototype.isActive=function(e){return!!(this._active&&(!e||this._active.element===e))},ui.prototype.cancel=function(){this._active&&(this._fire("cancel"),this.close())},ui.prototype._fire=function(e,t){this._eventBus.fire("directEditing."+e,t||{active:this._active})},ui.prototype.close=function(){this._fire("deactivate"),this._cleanup(),this._canvas.restoreFocus&&this._canvas.restoreFocus()},ui.prototype._cleanup=function(){this._active&&(this._textbox.destroy(),this._active=null,this.resizable=void 0)},ui.prototype.complete=function(){var e=this._active;if(e){var t,n=e.context.bounds,i=this.$textbox.getBoundingClientRect(),o=this.getValue(),r=e.context.text;(o!==r||i.height!==n.height||i.width!==n.width)&&(t=this._textbox.container.getBoundingClientRect(),e.provider.update(e.element,o,e.context.text,{x:i.left-t.left,y:i.top-t.top,width:i.width,height:i.height})),this._fire("complete"),this.close()}},ui.prototype.getValue=function(){return this._textbox.getValue()},ui.prototype._handleKey=function(e){e.stopPropagation();var t=e.keyCode||e.charCode;if(t===27)return e.preventDefault(),this.cancel();if(t===13&&!e.shiftKey)return e.preventDefault(),this.complete()},ui.prototype._handleResize=function(e){this._fire("resize",e)},ui.prototype._handleFocusout=function(e){e.relatedTarget&&this._textbox.parent.contains(e.relatedTarget)||this.complete()},ui.prototype.activate=function(e){if(this.isActive()&&this.cancel(),this._eventBus.fire("directEditing.activate.allowed",{element:e})===!1)return!1;var t,n=It(this._providers,function(i){return(t=i.activate(e))?i:null});return t&&(this.$textbox=this._textbox.create(t.bounds,t.style,t.text,t.options),this._active={element:e,context:t,provider:n},t.options&&t.options.resizable&&(this.resizable=!0),this._fire("activate")),!!t};const pE={__depends__:[nu],__init__:["directEditing"],directEditing:["type",ui]};function gN(e){return function(t){var n=t.target,i=_e(e),o=i.eventDefinitions&&i.eventDefinitions[0],r=i.$type===n.type,a=(o&&o.$type)===n.eventDefinitionType,s=!!n.triggeredByEvent==!!i.triggeredByEvent,c=n.isExpanded===void 0||n.isExpanded===ht(e);return!r||!a||!s||!c}}const mN={task:{label:"Task",className:"bpmn-icon-task",target:{type:"bpmn:Task"}},"user-task":{label:"User task",className:"bpmn-icon-user",target:{type:"bpmn:UserTask"}},"service-task":{label:"Service task",className:"bpmn-icon-service",target:{type:"bpmn:ServiceTask"}},"send-task":{label:"Send task",className:"bpmn-icon-send",target:{type:"bpmn:SendTask"}},"receive-task":{label:"Receive task",className:"bpmn-icon-receive",target:{type:"bpmn:ReceiveTask"}},"manual-task":{label:"Manual task",className:"bpmn-icon-manual",target:{type:"bpmn:ManualTask"}},"rule-task":{label:"Business rule task",className:"bpmn-icon-business-rule",target:{type:"bpmn:BusinessRuleTask"}},"script-task":{label:"Script task",className:"bpmn-icon-script",target:{type:"bpmn:ScriptTask"}},"call-activity":{label:"Call activity",className:"bpmn-icon-call-activity",target:{type:"bpmn:CallActivity"}},transaction:{label:"Transaction",className:"bpmn-icon-transaction",target:{type:"bpmn:Transaction",isExpanded:!0}},"event-subprocess":{label:"Event sub-process",className:"bpmn-icon-event-subprocess-expanded",target:{type:"bpmn:SubProcess",triggeredByEvent:!0,isExpanded:!0}},"collapsed-subprocess":{label:"Sub-process (collapsed)",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:SubProcess",isExpanded:!1}},"expanded-subprocess":{label:"Sub-process (expanded)",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:SubProcess",isExpanded:!0}},"collapsed-ad-hoc-subprocess":{label:"Ad-hoc sub-process (collapsed)",className:"bpmn-icon-subprocess-collapsed",target:{type:"bpmn:AdHocSubProcess",isExpanded:!1}},"expanded-ad-hoc-subprocess":{label:"Ad-hoc sub-process (expanded)",className:"bpmn-icon-subprocess-expanded",target:{type:"bpmn:AdHocSubProcess",isExpanded:!0}},"exclusive-gateway":{label:"Exclusive gateway",className:"bpmn-icon-gateway-xor",target:{type:"bpmn:ExclusiveGateway"}},"parallel-gateway":{label:"Parallel gateway",className:"bpmn-icon-gateway-parallel",target:{type:"bpmn:ParallelGateway"}},"inclusive-gateway":{label:"Inclusive gateway",className:"bpmn-icon-gateway-or",target:{type:"bpmn:InclusiveGateway"}},"complex-gateway":{label:"Complex gateway",className:"bpmn-icon-gateway-complex",target:{type:"bpmn:ComplexGateway"}},"event-based-gateway":{label:"Event-based gateway",className:"bpmn-icon-gateway-eventbased",target:{type:"bpmn:EventBasedGateway",instantiate:!1,eventGatewayType:"Exclusive"}},"data-store-reference":{label:"Data store reference",className:"bpmn-icon-data-store",target:{type:"bpmn:DataStoreReference"}},"data-object-reference":{label:"Data object reference",className:"bpmn-icon-data-object",target:{type:"bpmn:DataObjectReference"}},"expanded-pool":{label:"Expanded pool/participant",className:"bpmn-icon-participant",target:{type:"bpmn:Participant",isExpanded:!0}},"collapsed-pool":{label:"Empty pool/participant",className:"bpmn-icon-lane",target:{type:"bpmn:Participant",isExpanded:!1}},"none-start-event":{label:"Start event",className:"bpmn-icon-start-event-none",target:{type:"bpmn:StartEvent"}},"none-intermediate-throwing":{label:"Intermediate throw event",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:IntermediateThrowEvent"}},"none-boundary-event":{label:"Boundary event",className:"bpmn-icon-intermediate-event-none",target:{type:"bpmn:BoundaryEvent"}},"none-end-event":{label:"End event",className:"bpmn-icon-end-event-none",target:{type:"bpmn:EndEvent"}},"message-start":{label:"Message start event",className:"bpmn-icon-start-event-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!0}},"timer-start":{label:"Timer start event",className:"bpmn-icon-start-event-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!0}},"conditional-start":{label:"Conditional start event",className:"bpmn-icon-start-event-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!0}},"signal-start":{label:"Signal start event",className:"bpmn-icon-start-event-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!0}},"error-start":{label:"Error start event",className:"bpmn-icon-start-event-error",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",isInterrupting:!0}},"escalation-start":{label:"Escalation start event",className:"bpmn-icon-start-event-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!0}},"compensation-start":{label:"Compensation start event",className:"bpmn-icon-start-event-compensation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",isInterrupting:!0}},"non-interrupting-message-start":{label:"Message start event (non-interrupting)",className:"bpmn-icon-start-event-non-interrupting-message",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:MessageEventDefinition",isInterrupting:!1}},"non-interrupting-timer-start":{label:"Timer start event (non-interrupting)",className:"bpmn-icon-start-event-non-interrupting-timer",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:TimerEventDefinition",isInterrupting:!1}},"non-interrupting-conditional-start":{label:"Conditional start event (non-interrupting)",className:"bpmn-icon-start-event-non-interrupting-condition",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",isInterrupting:!1}},"non-interrupting-signal-start":{label:"Signal start event (non-interrupting)",className:"bpmn-icon-start-event-non-interrupting-signal",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:SignalEventDefinition",isInterrupting:!1}},"non-interrupting-escalation-start":{label:"Escalation start event (non-interrupting)",className:"bpmn-icon-start-event-non-interrupting-escalation",target:{type:"bpmn:StartEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",isInterrupting:!1}},"message-intermediate-catch":{label:"Message intermediate catch event",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},"message-intermediate-throw":{label:"Message intermediate throw event",className:"bpmn-icon-intermediate-event-throw-message",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},"timer-intermediate-catch":{label:"Timer intermediate catch event",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:TimerEventDefinition"}},"escalation-intermediate-throw":{label:"Escalation intermediate throw event",className:"bpmn-icon-intermediate-event-throw-escalation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},"conditional-intermediate-catch":{label:"Conditional intermediate catch event",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition"}},"link-intermediate-catch":{label:"Link intermediate catch event",className:"bpmn-icon-intermediate-event-catch-link",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},"link-intermediate-throw":{label:"Link intermediate throw event",className:"bpmn-icon-intermediate-event-throw-link",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:LinkEventDefinition",eventDefinitionAttrs:{name:""}}},"compensation-intermediate-throw":{label:"Compensation intermediate throw event",className:"bpmn-icon-intermediate-event-throw-compensation",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},"signal-intermediate-catch":{label:"Signal intermediate catch event",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:IntermediateCatchEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},"signal-intermediate-throw":{label:"Signal intermediate throw event",className:"bpmn-icon-intermediate-event-throw-signal",target:{type:"bpmn:IntermediateThrowEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},"message-boundary":{label:"Message boundary event",className:"bpmn-icon-intermediate-event-catch-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!0}},"timer-boundary":{label:"Timer boundary event",className:"bpmn-icon-intermediate-event-catch-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!0}},"escalation-boundary":{label:"Escalation boundary event",className:"bpmn-icon-intermediate-event-catch-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!0}},"conditional-boundary":{label:"Conditional boundary event",className:"bpmn-icon-intermediate-event-catch-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!0}},"error-boundary":{label:"Error boundary event",className:"bpmn-icon-intermediate-event-catch-error",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ErrorEventDefinition",cancelActivity:!0}},"cancel-boundary":{label:"Cancel boundary event",className:"bpmn-icon-intermediate-event-catch-cancel",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CancelEventDefinition",cancelActivity:!0}},"signal-boundary":{label:"Signal boundary event",className:"bpmn-icon-intermediate-event-catch-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!0}},"compensation-boundary":{label:"Compensation boundary event",className:"bpmn-icon-intermediate-event-catch-compensation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:CompensateEventDefinition",cancelActivity:!0}},"non-interrupting-message-boundary":{label:"Message boundary event (non-interrupting)",className:"bpmn-icon-intermediate-event-catch-non-interrupting-message",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:MessageEventDefinition",cancelActivity:!1}},"non-interrupting-timer-boundary":{label:"Timer boundary event (non-interrupting)",className:"bpmn-icon-intermediate-event-catch-non-interrupting-timer",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:TimerEventDefinition",cancelActivity:!1}},"non-interrupting-escalation-boundary":{label:"Escalation boundary event (non-interrupting)",className:"bpmn-icon-intermediate-event-catch-non-interrupting-escalation",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:EscalationEventDefinition",cancelActivity:!1}},"non-interrupting-conditional-boundary":{label:"Conditional boundary event (non-interrupting)",className:"bpmn-icon-intermediate-event-catch-non-interrupting-condition",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:ConditionalEventDefinition",cancelActivity:!1}},"non-interrupting-signal-boundary":{label:"Signal boundary event (non-interrupting)",className:"bpmn-icon-intermediate-event-catch-non-interrupting-signal",target:{type:"bpmn:BoundaryEvent",eventDefinitionType:"bpmn:SignalEventDefinition",cancelActivity:!1}},"message-end":{label:"Message end event",className:"bpmn-icon-end-event-message",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:MessageEventDefinition"}},"escalation-end":{label:"Escalation end event",className:"bpmn-icon-end-event-escalation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:EscalationEventDefinition"}},"error-end":{label:"Error end event",className:"bpmn-icon-end-event-error",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:ErrorEventDefinition"}},"cancel-end":{label:"Cancel end event",className:"bpmn-icon-end-event-cancel",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CancelEventDefinition"}},"compensation-end":{label:"Compensation end event",className:"bpmn-icon-end-event-compensation",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:CompensateEventDefinition"}},"signal-end":{label:"Signal end event",className:"bpmn-icon-end-event-signal",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:SignalEventDefinition"}},"terminate-end":{label:"Terminate end event",className:"bpmn-icon-end-event-terminate",target:{type:"bpmn:EndEvent",eventDefinitionType:"bpmn:TerminateEventDefinition"}}};function xe(e,t={}){var n=mN[e];if(!n)throw new Error("unknown popup entry <"+e+">");return{...n,actionName:"replace-with-"+e,...t}}var yN=[xe("none-start-event",{actionName:"replace-with-none-start"}),xe("none-intermediate-throwing"),xe("none-end-event",{actionName:"replace-with-none-end"}),xe("message-start"),xe("timer-start"),xe("conditional-start"),xe("signal-start")],vN=[xe("none-start-event",{actionName:"replace-with-none-start"}),xe("none-intermediate-throwing"),xe("none-end-event",{actionName:"replace-with-none-end"})],bN=[xe("none-start-event",{actionName:"replace-with-none-start"}),xe("none-intermediate-throwing",{actionName:"replace-with-none-intermediate-throw"}),xe("none-end-event",{actionName:"replace-with-none-end"}),xe("message-intermediate-catch"),xe("message-intermediate-throw"),xe("timer-intermediate-catch"),xe("escalation-intermediate-throw"),xe("conditional-intermediate-catch"),xe("link-intermediate-catch"),xe("link-intermediate-throw"),xe("compensation-intermediate-throw"),xe("signal-intermediate-catch"),xe("signal-intermediate-throw")],xN=[xe("none-start-event",{actionName:"replace-with-none-start"}),xe("none-intermediate-throwing",{actionName:"replace-with-none-intermediate-throw"}),xe("none-end-event",{actionName:"replace-with-none-end"}),xe("message-end"),xe("escalation-end"),xe("error-end"),xe("cancel-end"),xe("compensation-end"),xe("signal-end"),xe("terminate-end")],wN=[xe("exclusive-gateway"),xe("parallel-gateway"),xe("inclusive-gateway"),xe("complex-gateway"),xe("event-based-gateway")],_N=[xe("transaction"),xe("event-subprocess"),xe("expanded-ad-hoc-subprocess",{actionName:"replace-with-ad-hoc-subprocess",label:"Ad-hoc sub-process"}),xe("collapsed-subprocess")],EN=[xe("expanded-subprocess",{actionName:"replace-with-subprocess",label:"Sub-process"}),xe("transaction"),xe("event-subprocess"),xe("collapsed-ad-hoc-subprocess")],fE=[xe("transaction"),xe("expanded-subprocess",{actionName:"replace-with-subprocess",label:"Sub-process"}),xe("expanded-ad-hoc-subprocess",{actionName:"replace-with-ad-hoc-subprocess",label:"Ad-hoc sub-process"}),xe("event-subprocess")],SN=fE,dE=[xe("task"),xe("user-task"),xe("service-task"),xe("send-task"),xe("receive-task"),xe("manual-task"),xe("rule-task"),xe("script-task"),xe("call-activity"),xe("collapsed-subprocess"),xe("expanded-subprocess"),xe("collapsed-ad-hoc-subprocess"),xe("expanded-ad-hoc-subprocess",{actionName:"replace-with-ad-hoc-subprocess"})],RN=[xe("data-store-reference")],CN=[xe("data-object-reference")],MN=[xe("message-boundary"),xe("timer-boundary"),xe("escalation-boundary"),xe("conditional-boundary"),xe("error-boundary"),xe("cancel-boundary"),xe("signal-boundary"),xe("compensation-boundary"),xe("non-interrupting-message-boundary"),xe("non-interrupting-timer-boundary"),xe("non-interrupting-escalation-boundary"),xe("non-interrupting-conditional-boundary"),xe("non-interrupting-signal-boundary")],AN=[xe("message-start"),xe("timer-start"),xe("conditional-start"),xe("signal-start"),xe("error-start"),xe("escalation-start"),xe("compensation-start"),xe("non-interrupting-message-start"),xe("non-interrupting-timer-start"),xe("non-interrupting-conditional-start"),xe("non-interrupting-signal-start"),xe("non-interrupting-escalation-start")],PN=[{label:"Sequence flow",actionName:"replace-with-sequence-flow",className:"bpmn-icon-connection"},{label:"Default flow",actionName:"replace-with-default-flow",className:"bpmn-icon-default-flow"},{label:"Conditional flow",actionName:"replace-with-conditional-flow",className:"bpmn-icon-conditional-flow"}],TN=[xe("expanded-pool"),xe("collapsed-pool",{label:function(e){var t="Empty pool/participant";return e.children&&e.children.length&&(t+=" (removes content)"),t}})],kN={"bpmn:MessageEventDefinition":[xe("message-start"),xe("message-intermediate-catch"),xe("message-intermediate-throw"),xe("message-end")],"bpmn:TimerEventDefinition":[xe("timer-start"),xe("timer-intermediate-catch")],"bpmn:ConditionalEventDefinition":[xe("conditional-start"),xe("conditional-intermediate-catch")],"bpmn:SignalEventDefinition":[xe("signal-start"),xe("signal-intermediate-catch"),xe("signal-intermediate-throw"),xe("signal-end")],"bpmn:ErrorEventDefinition":[xe("error-start"),xe("error-end")],"bpmn:EscalationEventDefinition":[xe("escalation-start"),xe("escalation-intermediate-throw"),xe("escalation-end")],"bpmn:CompensateEventDefinition":[xe("compensation-start"),xe("compensation-intermediate-throw"),xe("compensation-end")]};const hE={"start-event-non-interrupting":`
317
317
  <svg viewBox="0 0 2048 2048" xmlns="http://www.w3.org/2000/svg">
318
318
  <g transform="translate(0 995.64)">
@@ -324,7 +324,7 @@
324
324
  <circle cx="1024" cy="28.357" r="875" stroke-dasharray="418.310422, 361.2328165" stroke-width="100"/>
325
325
  <circle cx="1024" cy="28.357" r="685" stroke-dasharray="348.31044857,261.23283643" stroke-dashoffset="500" stroke-width="100"/>
326
326
  </g>
327
- </svg>`};function ki(e,t,n,i,o,r,a,s){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=o,this._rules=r,this._translate=a,this._moddleCopy=s,this._register()}ki.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate","moddleCopy"],ki.prototype._register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},ki.prototype.getPopupMenuEntries=function(e){var s;var t=e.businessObject,n=this._rules,i=[],o,r=[];if(Ze(e)||!n.allowed("shape.replace",{element:e}))return{};var a=gN(e);return M(t,"bpmn:DataObjectReference")?this._createEntries(e,RN):M(t,"bpmn:DataStoreReference")&&!M(e.parent,"bpmn:Collaboration")?this._createEntries(e,CN):(M(t,"bpmn:Event")&&!M(t,"bpmn:BoundaryEvent")&&(o=(s=t.get("eventDefinitions")[0])==null?void 0:s.$type,i=kN[o]||[],!Gn(t.$parent)&&M(t.$parent,"bpmn:SubProcess")&&(i=ct(i,function(c){return c.target.type!=="bpmn:StartEvent"}))),M(t,"bpmn:StartEvent")&&!M(t.$parent,"bpmn:SubProcess")?(r=ct(yN.concat(i),a),this._createEntries(e,r)):M(t,"bpmn:Participant")?(r=ct(TN,function(c){return ht(e)!==c.target.isExpanded}),this._createEntries(e,r)):M(t,"bpmn:StartEvent")&&Gn(t.$parent)?(r=ct(AN.concat(i),function(c){var l=c.target,u=l.isInterrupting!==!1,p=t.isInterrupting===u;return a(c)||!a(c)&&!p}),this._createEntries(e,r)):M(t,"bpmn:StartEvent")&&!Gn(t.$parent)&&M(t.$parent,"bpmn:SubProcess")?(r=ct(vN.concat(i),a),this._createEntries(e,r)):M(t,"bpmn:EndEvent")?(r=ct(xN.concat(i),function(c){var l=c.target;return l.eventDefinitionType=="bpmn:CancelEventDefinition"&&!M(t.$parent,"bpmn:Transaction")?!1:a(c)}),this._createEntries(e,r)):M(t,"bpmn:BoundaryEvent")?(r=ct(MN,function(c){var l=c.target;if(l.eventDefinitionType=="bpmn:CancelEventDefinition"&&!M(t.attachedToRef,"bpmn:Transaction"))return!1;var u=l.cancelActivity!==!1,p=t.cancelActivity==u;return a(c)||!a(c)&&!p}),this._createEntries(e,r)):M(t,"bpmn:IntermediateCatchEvent")||M(t,"bpmn:IntermediateThrowEvent")?(r=ct(bN.concat(i),a),this._createEntries(e,r)):M(t,"bpmn:Gateway")?(r=ct(wN,a),this._createEntries(e,r)):M(t,"bpmn:Transaction")?(r=ct(fE,a),this._createEntries(e,r)):Gn(t)&&ht(e)?(r=ct(SN,a),this._createEntries(e,r)):M(t,"bpmn:AdHocSubProcess")&&ht(e)?(r=ct(EN,a),this._createEntries(e,r)):M(t,"bpmn:SubProcess")&&ht(e)?(r=ct(_N,a),this._createEntries(e,r)):M(t,"bpmn:SubProcess")&&!ht(e)?(r=ct(dE,function(c){var l=c.target.type===e.type,u=c.target.isExpanded===!0;return l===u}),this._createEntries(e,r)):M(t,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,PN):M(t,"bpmn:FlowNode")?(r=ct(dE,a),this._createEntries(e,r)):{})},ki.prototype.getPopupMenuHeaderEntries=function(e){var t={};return M(e,"bpmn:Activity")&&!Gn(e)&&(t={...t,...this._getLoopCharacteristicsHeaderEntries(e)}),M(e,"bpmn:DataObjectReference")&&(t={...t,...this._getCollectionHeaderEntries(e)}),M(e,"bpmn:Participant")&&(t={...t,...this._getParticipantMultiplicityHeaderEntries(e)}),qb(e)&&(t={...t,...this._getNonInterruptingHeaderEntries(e)}),t},ki.prototype._createEntries=function(e,t){var n={},i=this;return V(t,function(o){n[o.actionName]=i._createEntry(o,e)}),n},ki.prototype._createSequenceFlowEntries=function(e,t){var n=_e(e),i={},o=this._modeling,r=this._moddle,a=this;return V(t,function(s){switch(s.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(M(n.sourceRef,"bpmn:ExclusiveGateway")||M(n.sourceRef,"bpmn:InclusiveGateway")||M(n.sourceRef,"bpmn:ComplexGateway")||M(n.sourceRef,"bpmn:Activity"))&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){o.updateProperties(e.source,{default:n})})});break;case"replace-with-conditional-flow":!n.conditionExpression&&M(n.sourceRef,"bpmn:Activity")&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){var c=r.create("bpmn:FormalExpression",{body:""});o.updateProperties(e,{conditionExpression:c})})});break;default:M(n.sourceRef,"bpmn:Activity")&&n.conditionExpression&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){o.updateProperties(e,{conditionExpression:void 0})})}),(M(n.sourceRef,"bpmn:ExclusiveGateway")||M(n.sourceRef,"bpmn:InclusiveGateway")||M(n.sourceRef,"bpmn:ComplexGateway")||M(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){o.updateProperties(e.source,{default:void 0})})})}}),i},ki.prototype._createEntry=function(e,t,n){var i=this._translate,o=this._bpmnReplace.replaceElement,r=function(){return o(t,e.target)},a=e.label;return a&&typeof a=="function"&&(a=a(t)),n=n||r,{label:i(a),className:e.className,action:n}},ki.prototype._getLoopCharacteristicsHeaderEntries=function(e){var t=this,n=this._translate;function i(l,u){if(u.active){t._modeling.updateProperties(e,{loopCharacteristics:void 0});return}var p=e.businessObject.get("loopCharacteristics");p&&M(p,u.options.loopCharacteristics)?t._modeling.updateModdleProperties(e,p,{isSequential:u.options.isSequential}):(p=t._moddle.create(u.options.loopCharacteristics,{isSequential:u.options.isSequential}),t._modeling.updateProperties(e,{loopCharacteristics:p}))}var o=_e(e),r=o.loopCharacteristics,a,s,c;return r&&(a=r.isSequential,s=r.isSequential===void 0,c=r.isSequential!==void 0&&!r.isSequential),{"toggle-parallel-mi":{className:"bpmn-icon-parallel-mi-marker",title:n("Parallel multi-instance"),active:c,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!1}},"toggle-sequential-mi":{className:"bpmn-icon-sequential-mi-marker",title:n("Sequential multi-instance"),active:a,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!0}},"toggle-loop":{className:"bpmn-icon-loop-marker",title:n("Loop"),active:s,action:i,options:{loopCharacteristics:"bpmn:StandardLoopCharacteristics"}}}},ki.prototype._getCollectionHeaderEntries=function(e){var t=this,n=this._translate,i=e.businessObject.dataObjectRef;if(!i)return{};function o(a,s){t._modeling.updateModdleProperties(e,i,{isCollection:!s.active})}var r=i.isCollection;return{"toggle-is-collection":{className:"bpmn-icon-parallel-mi-marker",title:n("Collection"),active:r,action:o}}},ki.prototype._getParticipantMultiplicityHeaderEntries=function(e){var t=this,n=this._bpmnFactory,i=this._translate;function o(a,s){var c=s.active,l;c||(l=n.create("bpmn:ParticipantMultiplicity")),t._modeling.updateProperties(e,{participantMultiplicity:l})}var r=e.businessObject.participantMultiplicity;return{"toggle-participant-multiplicity":{className:"bpmn-icon-parallel-mi-marker",title:i("Participant multiplicity"),active:!!r,action:o}}},ki.prototype._getNonInterruptingHeaderEntries=function(e){const t=this._translate,n=_e(e),i=this,o=Yb(e),r=M(e,"bpmn:BoundaryEvent")?hE["intermediate-event-non-interrupting"]:hE["start-event-non-interrupting"],a=!n[o];return{"toggle-non-interrupting":{imageHtml:r,title:t("Toggle non-interrupting"),active:a,action:function(){i._modeling.updateProperties(e,{[o]:!!a})}}}};const ON={__depends__:[rg,hw,Cu],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",ki]};function dc(e,t,n,i,o,r,a,s,c,l,u,p,f){e=e||{},i.registerProvider(this),this._contextPad=i,this._modeling=o,this._elementFactory=r,this._connect=a,this._create=s,this._popupMenu=c,this._canvas=l,this._rules=u,this._translate=p,this._eventBus=n,this._appendPreview=f,e.autoPlace!==!1&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,function(d){var g=d.context,h=g.shape;if(!(!Fs(d)||!i.isOpen(h))){var m=i.getEntries(h);m.replace&&m.replace.action.click(d,h)}}),n.on("contextPad.close",function(){f.cleanUp()})}dc.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate","appendPreview"],dc.prototype.getMultiElementContextPadEntries=function(e){var t=this._modeling,n={};return this._isDeleteAllowed(e)&&Y(n,{delete:{group:"edit",className:"bpmn-icon-trash",title:this._translate("Delete"),action:{click:function(i,o){t.removeElements(o.slice())}}}}),n},dc.prototype._isDeleteAllowed=function(e){var t=this._rules.allowed("elements.delete",{elements:e});return Ze(t)?Io(e,n=>t.includes(n)):t},dc.prototype.getContextPadEntries=function(e){var t=this._contextPad,n=this._modeling,i=this._elementFactory,o=this._connect,r=this._create,a=this._popupMenu,s=this._autoPlace,c=this._translate,l=this._appendPreview,u={};if(e.type==="label")return this._isDeleteAllowed([e])&&Y(u,g()),u;var p=e.businessObject;function f(v,x){o.start(v,x)}function d(v,x){n.removeElements([x])}function g(){return{delete:{group:"edit",className:"bpmn-icon-trash",title:c("Delete"),action:{click:d}}}}function h(v){var x=5,E=t.getPad(v).html,A=E.getBoundingClientRect(),B={x:A.left,y:A.bottom+x};return B}function m(v,x,E,A){function B(H,F){var G=i.createShape(Y({type:v},A));r.start(H,G,{source:F})}var P=s?function(H,F){var G=i.createShape(Y({type:v},A));s.append(F,G)}:B,k=s?function(H,F){return l.create(F,v,A),()=>{l.cleanUp()}}:null;return{group:"model",className:x,title:E,action:{dragstart:B,click:P,hover:k}}}function w(v){return function(x,E){n.splitLane(E,v),t.open(E,!0)}}if(st(p,["bpmn:Lane","bpmn:Participant"])&&ht(e)){var y=Jo(e);Y(u,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:c("Add lane above"),action:{click:function(v,x){n.addLane(x,"top")}}}}),y.length<2&&((En(e)?e.height>=120:e.width>=120)&&Y(u,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:c("Divide into two lanes"),action:{click:w(2)}}}),(En(e)?e.height>=180:e.width>=180)&&Y(u,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:c("Divide into three lanes"),action:{click:w(3)}}})),Y(u,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:c("Add lane below"),action:{click:function(v,x){n.addLane(x,"bottom")}}}})}return M(p,"bpmn:FlowNode")&&(M(p,"bpmn:EventBasedGateway")?Y(u,{"append.receive-task":m("bpmn:ReceiveTask","bpmn-icon-receive-task",c("Append receive task")),"append.message-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",c("Append message intermediate catch event"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",c("Append timer intermediate catch event"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",c("Append conditional intermediate catch event"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",c("Append signal intermediate catch event"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):gE(p,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?Y(u,{"append.compensation-activity":m("bpmn:Task","bpmn-icon-task",c("Append compensation activity"),{isForCompensation:!0})}):!M(p,"bpmn:EndEvent")&&!p.isForCompensation&&!gE(p,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")&&!Gn(p)&&Y(u,{"append.end-event":m("bpmn:EndEvent","bpmn-icon-end-event-none",c("Append end event")),"append.gateway":m("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",c("Append gateway")),"append.append-task":m("bpmn:Task","bpmn-icon-task",c("Append task")),"append.intermediate-event":m("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",c("Append intermediate/boundary event"))})),a.isEmpty(e,"bpmn-replace")||Y(u,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:c("Change element"),action:{click:function(v,x){var E=Y(h(x),{cursor:{x:v.x,y:v.y}});a.open(x,"bpmn-replace",E,{title:c("Change element"),width:"var(--bpmn-replace-popup-width, 300px)",search:!0})}}}}),M(p,"bpmn:SequenceFlow")&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),M(p,"bpmn:MessageFlow")&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),st(p,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation")),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect to other element"),action:{click:f,dragstart:f}}}),M(p,"bpmn:TextAnnotation")&&Y(u,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using association"),action:{click:f,dragstart:f}}}),st(p,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Y(u,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using data input association"),action:{click:f,dragstart:f}}}),M(p,"bpmn:Group")&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),this._isDeleteAllowed([e])&&Y(u,g()),u};function gE(e,t,n){var i=e.$instanceOf(t),o=!1,r=e.eventDefinitions||[];return V(r,function(a){a.$type===n&&(o=!0)}),i&&o}const DN={__depends__:[pN,pE,V_,Mi,dg,ou,ON],__init__:["contextPadProvider"],contextPadProvider:["type",dc]};var LN={horizontal:["x","width"],vertical:["y","height"]},mE=5;function Oo(e,t){this._modeling=e,this._filters=[],this.registerFilter(function(n){var i=t.allowed("elements.distribute",{elements:n});return Ze(i)?i:i?n:[]})}Oo.$inject=["modeling","rules"],Oo.prototype.registerFilter=function(e){if(typeof e!="function")throw new Error("the filter has to be a function");this._filters.push(e)},Oo.prototype.trigger=function(e,t){var n=this._modeling,i,o;if(!(e.length<3)&&(this._setOrientation(t),o=this._filterElements(e),i=this._createGroups(o),!(i.length<=2)))return n.distributeElements(i,this._axis,this._dimension),i},Oo.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,o=[].concat(e);return t.length?(V(t,function(r){o=r(o,n,i)}),o):e},Oo.prototype._createGroups=function(e){var t=[],n=this,i=this._axis,o=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');var r=qi(e,i);return V(r,function(a,s){var c=n._findRange(a,i,o),l,u=t[t.length-1];u&&n._hasIntersection(u.range,c)?t[t.length-1].elements.push(a):(l={range:c,elements:[a]},t.push(l))}),t},Oo.prototype._setOrientation=function(e){var t=LN[e];this._axis=t[0],this._dimension=t[1]},Oo.prototype._hasIntersection=function(e,t){return Math.max(e.min,e.max)>=Math.min(t.min,t.max)&&Math.min(e.min,e.max)<=Math.max(t.min,t.max)},Oo.prototype._findRange=function(e){var t=e[this._axis],n=e[this._dimension];return{min:t+mE,max:t+n-mE}};const IN={__init__:["distributeElements"],distributeElements:["type",Oo]};function ip(e){Ci.call(this,e)}ip.$inject=["eventBus"],Ne(ip,Ci),ip.prototype.init=function(){this.addRule("elements.distribute",function(e){var t=e.elements;return t=ct(t,function(n){var i=st(n,["bpmn:Association","bpmn:BoundaryEvent","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:Lane","bpmn:MessageFlow","bpmn:SequenceFlow","bpmn:TextAnnotation"]);return!(n.labelTarget||i)}),t=ml(t),t.length<3?!1:t})};var yE={horizontal:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
327
+ </svg>`};function ki(e,t,n,i,o,r,a,s){this._bpmnFactory=e,this._popupMenu=t,this._modeling=n,this._moddle=i,this._bpmnReplace=o,this._rules=r,this._translate=a,this._moddleCopy=s,this._register()}ki.$inject=["bpmnFactory","popupMenu","modeling","moddle","bpmnReplace","rules","translate","moddleCopy"],ki.prototype._register=function(){this._popupMenu.registerProvider("bpmn-replace",this)},ki.prototype.getPopupMenuEntries=function(e){var s;var t=e.businessObject,n=this._rules,i=[],o,r=[];if(Ze(e)||!n.allowed("shape.replace",{element:e}))return{};var a=gN(e);return M(t,"bpmn:DataObjectReference")?this._createEntries(e,RN):M(t,"bpmn:DataStoreReference")&&!M(e.parent,"bpmn:Collaboration")?this._createEntries(e,CN):(M(t,"bpmn:Event")&&!M(t,"bpmn:BoundaryEvent")&&(o=(s=t.get("eventDefinitions")[0])==null?void 0:s.$type,i=kN[o]||[],!Gn(t.$parent)&&M(t.$parent,"bpmn:SubProcess")&&(i=ct(i,function(c){return c.target.type!=="bpmn:StartEvent"}))),M(t,"bpmn:StartEvent")&&!M(t.$parent,"bpmn:SubProcess")?(r=ct(yN.concat(i),a),this._createEntries(e,r)):M(t,"bpmn:Participant")?(r=ct(TN,function(c){return ht(e)!==c.target.isExpanded}),this._createEntries(e,r)):M(t,"bpmn:StartEvent")&&Gn(t.$parent)?(r=ct(AN.concat(i),function(c){var l=c.target,u=l.isInterrupting!==!1,p=t.isInterrupting===u;return a(c)||!a(c)&&!p}),this._createEntries(e,r)):M(t,"bpmn:StartEvent")&&!Gn(t.$parent)&&M(t.$parent,"bpmn:SubProcess")?(r=ct(vN.concat(i),a),this._createEntries(e,r)):M(t,"bpmn:EndEvent")?(r=ct(xN.concat(i),function(c){var l=c.target;return l.eventDefinitionType=="bpmn:CancelEventDefinition"&&!M(t.$parent,"bpmn:Transaction")?!1:a(c)}),this._createEntries(e,r)):M(t,"bpmn:BoundaryEvent")?(r=ct(MN,function(c){var l=c.target;if(l.eventDefinitionType=="bpmn:CancelEventDefinition"&&!M(t.attachedToRef,"bpmn:Transaction"))return!1;var u=l.cancelActivity!==!1,p=t.cancelActivity==u;return a(c)||!a(c)&&!p}),this._createEntries(e,r)):M(t,"bpmn:IntermediateCatchEvent")||M(t,"bpmn:IntermediateThrowEvent")?(r=ct(bN.concat(i),a),this._createEntries(e,r)):M(t,"bpmn:Gateway")?(r=ct(wN,a),this._createEntries(e,r)):M(t,"bpmn:Transaction")?(r=ct(fE,a),this._createEntries(e,r)):Gn(t)&&ht(e)?(r=ct(SN,a),this._createEntries(e,r)):M(t,"bpmn:AdHocSubProcess")&&ht(e)?(r=ct(EN,a),this._createEntries(e,r)):M(t,"bpmn:SubProcess")&&ht(e)?(r=ct(_N,a),this._createEntries(e,r)):M(t,"bpmn:SubProcess")&&!ht(e)?(r=ct(dE,function(c){var l=c.target.type===e.type,u=c.target.isExpanded===!0;return l===u}),this._createEntries(e,r)):M(t,"bpmn:SequenceFlow")?this._createSequenceFlowEntries(e,PN):M(t,"bpmn:FlowNode")?(r=ct(dE,a),this._createEntries(e,r)):{})},ki.prototype.getPopupMenuHeaderEntries=function(e){var t={};return M(e,"bpmn:Activity")&&!Gn(e)&&(t={...t,...this._getLoopCharacteristicsHeaderEntries(e)}),M(e,"bpmn:DataObjectReference")&&(t={...t,...this._getCollectionHeaderEntries(e)}),M(e,"bpmn:Participant")&&(t={...t,...this._getParticipantMultiplicityHeaderEntries(e)}),qb(e)&&(t={...t,...this._getNonInterruptingHeaderEntries(e)}),t},ki.prototype._createEntries=function(e,t){var n={},i=this;return V(t,function(o){n[o.actionName]=i._createEntry(o,e)}),n},ki.prototype._createSequenceFlowEntries=function(e,t){var n=_e(e),i={},o=this._modeling,r=this._moddle,a=this;return V(t,function(s){switch(s.actionName){case"replace-with-default-flow":n.sourceRef.default!==n&&(M(n.sourceRef,"bpmn:ExclusiveGateway")||M(n.sourceRef,"bpmn:InclusiveGateway")||M(n.sourceRef,"bpmn:ComplexGateway")||M(n.sourceRef,"bpmn:Activity"))&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){o.updateProperties(e.source,{default:n})})});break;case"replace-with-conditional-flow":!n.conditionExpression&&M(n.sourceRef,"bpmn:Activity")&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){var c=r.create("bpmn:FormalExpression",{body:""});o.updateProperties(e,{conditionExpression:c})})});break;default:M(n.sourceRef,"bpmn:Activity")&&n.conditionExpression&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){o.updateProperties(e,{conditionExpression:void 0})})}),(M(n.sourceRef,"bpmn:ExclusiveGateway")||M(n.sourceRef,"bpmn:InclusiveGateway")||M(n.sourceRef,"bpmn:ComplexGateway")||M(n.sourceRef,"bpmn:Activity"))&&n.sourceRef.default===n&&(i={...i,[s.actionName]:a._createEntry(s,e,function(){o.updateProperties(e.source,{default:void 0})})})}}),i},ki.prototype._createEntry=function(e,t,n){var i=this._translate,o=this._bpmnReplace.replaceElement,r=function(){return o(t,e.target)},a=e.label;return a&&typeof a=="function"&&(a=a(t)),n=n||r,{label:i(a),className:e.className,action:n}},ki.prototype._getLoopCharacteristicsHeaderEntries=function(e){var t=this,n=this._translate;function i(l,u){if(u.active){t._modeling.updateProperties(e,{loopCharacteristics:void 0});return}var p=e.businessObject.get("loopCharacteristics");p&&M(p,u.options.loopCharacteristics)?t._modeling.updateModdleProperties(e,p,{isSequential:u.options.isSequential}):(p=t._moddle.create(u.options.loopCharacteristics,{isSequential:u.options.isSequential}),t._modeling.updateProperties(e,{loopCharacteristics:p}))}var o=_e(e),r=o.loopCharacteristics,a,s,c;return r&&(a=r.isSequential,s=r.isSequential===void 0,c=r.isSequential!==void 0&&!r.isSequential),{"toggle-parallel-mi":{className:"bpmn-icon-parallel-mi-marker",title:n("Parallel multi-instance"),active:c,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!1}},"toggle-sequential-mi":{className:"bpmn-icon-sequential-mi-marker",title:n("Sequential multi-instance"),active:a,action:i,options:{loopCharacteristics:"bpmn:MultiInstanceLoopCharacteristics",isSequential:!0}},"toggle-loop":{className:"bpmn-icon-loop-marker",title:n("Loop"),active:s,action:i,options:{loopCharacteristics:"bpmn:StandardLoopCharacteristics"}}}},ki.prototype._getCollectionHeaderEntries=function(e){var t=this,n=this._translate,i=e.businessObject.dataObjectRef;if(!i)return{};function o(a,s){t._modeling.updateModdleProperties(e,i,{isCollection:!s.active})}var r=i.isCollection;return{"toggle-is-collection":{className:"bpmn-icon-parallel-mi-marker",title:n("Collection"),active:r,action:o}}},ki.prototype._getParticipantMultiplicityHeaderEntries=function(e){var t=this,n=this._bpmnFactory,i=this._translate;function o(a,s){var c=s.active,l;c||(l=n.create("bpmn:ParticipantMultiplicity")),t._modeling.updateProperties(e,{participantMultiplicity:l})}var r=e.businessObject.participantMultiplicity;return{"toggle-participant-multiplicity":{className:"bpmn-icon-parallel-mi-marker",title:i("Participant multiplicity"),active:!!r,action:o}}},ki.prototype._getNonInterruptingHeaderEntries=function(e){const t=this._translate,n=_e(e),i=this,o=Yb(e),r=M(e,"bpmn:BoundaryEvent")?hE["intermediate-event-non-interrupting"]:hE["start-event-non-interrupting"],a=!n[o];return{"toggle-non-interrupting":{imageHtml:r,title:t("Toggle non-interrupting"),active:a,action:function(){i._modeling.updateProperties(e,{[o]:!!a})}}}};const ON={__depends__:[rg,hw,Cu],__init__:["replaceMenuProvider"],replaceMenuProvider:["type",ki]};function dc(e,t,n,i,o,r,a,s,c,l,u,p,f){e=e||{},i.registerProvider(this),this._contextPad=i,this._modeling=o,this._elementFactory=r,this._connect=a,this._create=s,this._popupMenu=c,this._canvas=l,this._rules=u,this._translate=p,this._eventBus=n,this._appendPreview=f,e.autoPlace!==!1&&(this._autoPlace=t.get("autoPlace",!1)),n.on("create.end",250,function(d){var g=d.context,h=g.shape;if(!(!Fs(d)||!i.isOpen(h))){var m=i.getEntries(h);m.replace&&m.replace.action.click(d,h)}}),n.on("contextPad.close",function(){f.cleanUp()})}dc.$inject=["config.contextPad","injector","eventBus","contextPad","modeling","elementFactory","connect","create","popupMenu","canvas","rules","translate","appendPreview"],dc.prototype.getMultiElementContextPadEntries=function(e){var t=this._modeling,n={};return this._isDeleteAllowed(e)&&Y(n,{delete:{group:"edit",className:"bpmn-icon-trash",title:this._translate("Delete"),action:{click:function(i,o){t.removeElements(o.slice())}}}}),n},dc.prototype._isDeleteAllowed=function(e){var t=this._rules.allowed("elements.delete",{elements:e});return Ze(t)?Io(e,n=>t.includes(n)):t},dc.prototype.getContextPadEntries=function(e){var t=this._contextPad,n=this._modeling,i=this._elementFactory,o=this._connect,r=this._create,a=this._popupMenu,s=this._autoPlace,c=this._translate,l=this._appendPreview,u={};if(e.type==="label")return this._isDeleteAllowed([e])&&Y(u,g()),u;var p=e.businessObject;function f(v,x){o.start(v,x)}function d(v,x){n.removeElements([x])}function g(){return{delete:{group:"edit",className:"bpmn-icon-trash",title:c("Delete"),action:{click:d}}}}function h(v){var x=5,E=t.getPad(v).html,A=E.getBoundingClientRect(),I={x:A.left,y:A.bottom+x};return I}function m(v,x,E,A){function I(H,F){var G=i.createShape(Y({type:v},A));r.start(H,G,{source:F})}var P=s?function(H,F){var G=i.createShape(Y({type:v},A));s.append(F,G)}:I,k=s?function(H,F){return l.create(F,v,A),()=>{l.cleanUp()}}:null;return{group:"model",className:x,title:E,action:{dragstart:I,click:P,hover:k}}}function w(v){return function(x,E){n.splitLane(E,v),t.open(E,!0)}}if(st(p,["bpmn:Lane","bpmn:Participant"])&&ht(e)){var y=Jo(e);Y(u,{"lane-insert-above":{group:"lane-insert-above",className:"bpmn-icon-lane-insert-above",title:c("Add lane above"),action:{click:function(v,x){n.addLane(x,"top")}}}}),y.length<2&&((En(e)?e.height>=120:e.width>=120)&&Y(u,{"lane-divide-two":{group:"lane-divide",className:"bpmn-icon-lane-divide-two",title:c("Divide into two lanes"),action:{click:w(2)}}}),(En(e)?e.height>=180:e.width>=180)&&Y(u,{"lane-divide-three":{group:"lane-divide",className:"bpmn-icon-lane-divide-three",title:c("Divide into three lanes"),action:{click:w(3)}}})),Y(u,{"lane-insert-below":{group:"lane-insert-below",className:"bpmn-icon-lane-insert-below",title:c("Add lane below"),action:{click:function(v,x){n.addLane(x,"bottom")}}}})}return M(p,"bpmn:FlowNode")&&(M(p,"bpmn:EventBasedGateway")?Y(u,{"append.receive-task":m("bpmn:ReceiveTask","bpmn-icon-receive-task",c("Append receive task")),"append.message-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-message",c("Append message intermediate catch event"),{eventDefinitionType:"bpmn:MessageEventDefinition"}),"append.timer-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-timer",c("Append timer intermediate catch event"),{eventDefinitionType:"bpmn:TimerEventDefinition"}),"append.condition-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-condition",c("Append conditional intermediate catch event"),{eventDefinitionType:"bpmn:ConditionalEventDefinition"}),"append.signal-intermediate-event":m("bpmn:IntermediateCatchEvent","bpmn-icon-intermediate-event-catch-signal",c("Append signal intermediate catch event"),{eventDefinitionType:"bpmn:SignalEventDefinition"})}):gE(p,"bpmn:BoundaryEvent","bpmn:CompensateEventDefinition")?Y(u,{"append.compensation-activity":m("bpmn:Task","bpmn-icon-task",c("Append compensation activity"),{isForCompensation:!0})}):!M(p,"bpmn:EndEvent")&&!p.isForCompensation&&!gE(p,"bpmn:IntermediateThrowEvent","bpmn:LinkEventDefinition")&&!Gn(p)&&Y(u,{"append.end-event":m("bpmn:EndEvent","bpmn-icon-end-event-none",c("Append end event")),"append.gateway":m("bpmn:ExclusiveGateway","bpmn-icon-gateway-none",c("Append gateway")),"append.append-task":m("bpmn:Task","bpmn-icon-task",c("Append task")),"append.intermediate-event":m("bpmn:IntermediateThrowEvent","bpmn-icon-intermediate-event-none",c("Append intermediate/boundary event"))})),a.isEmpty(e,"bpmn-replace")||Y(u,{replace:{group:"edit",className:"bpmn-icon-screw-wrench",title:c("Change element"),action:{click:function(v,x){var E=Y(h(x),{cursor:{x:v.x,y:v.y}});a.open(x,"bpmn-replace",E,{title:c("Change element"),width:"var(--bpmn-replace-popup-width, 300px)",search:!0})}}}}),M(p,"bpmn:SequenceFlow")&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),M(p,"bpmn:MessageFlow")&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),st(p,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation")),connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect to other element"),action:{click:f,dragstart:f}}}),M(p,"bpmn:TextAnnotation")&&Y(u,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using association"),action:{click:f,dragstart:f}}}),st(p,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&Y(u,{connect:{group:"connect",className:"bpmn-icon-connection-multi",title:c("Connect using data input association"),action:{click:f,dragstart:f}}}),M(p,"bpmn:Group")&&Y(u,{"append.text-annotation":m("bpmn:TextAnnotation","bpmn-icon-text-annotation",c("Add text annotation"))}),this._isDeleteAllowed([e])&&Y(u,g()),u};function gE(e,t,n){var i=e.$instanceOf(t),o=!1,r=e.eventDefinitions||[];return V(r,function(a){a.$type===n&&(o=!0)}),i&&o}const DN={__depends__:[pN,pE,V_,Mi,dg,ou,ON],__init__:["contextPadProvider"],contextPadProvider:["type",dc]};var LN={horizontal:["x","width"],vertical:["y","height"]},mE=5;function Oo(e,t){this._modeling=e,this._filters=[],this.registerFilter(function(n){var i=t.allowed("elements.distribute",{elements:n});return Ze(i)?i:i?n:[]})}Oo.$inject=["modeling","rules"],Oo.prototype.registerFilter=function(e){if(typeof e!="function")throw new Error("the filter has to be a function");this._filters.push(e)},Oo.prototype.trigger=function(e,t){var n=this._modeling,i,o;if(!(e.length<3)&&(this._setOrientation(t),o=this._filterElements(e),i=this._createGroups(o),!(i.length<=2)))return n.distributeElements(i,this._axis,this._dimension),i},Oo.prototype._filterElements=function(e){var t=this._filters,n=this._axis,i=this._dimension,o=[].concat(e);return t.length?(V(t,function(r){o=r(o,n,i)}),o):e},Oo.prototype._createGroups=function(e){var t=[],n=this,i=this._axis,o=this._dimension;if(!i)throw new Error('must have a defined "axis" and "dimension"');var r=qi(e,i);return V(r,function(a,s){var c=n._findRange(a,i,o),l,u=t[t.length-1];u&&n._hasIntersection(u.range,c)?t[t.length-1].elements.push(a):(l={range:c,elements:[a]},t.push(l))}),t},Oo.prototype._setOrientation=function(e){var t=LN[e];this._axis=t[0],this._dimension=t[1]},Oo.prototype._hasIntersection=function(e,t){return Math.max(e.min,e.max)>=Math.min(t.min,t.max)&&Math.min(e.min,e.max)<=Math.max(t.min,t.max)},Oo.prototype._findRange=function(e){var t=e[this._axis],n=e[this._dimension];return{min:t+mE,max:t+n-mE}};const IN={__init__:["distributeElements"],distributeElements:["type",Oo]};function ip(e){Ci.call(this,e)}ip.$inject=["eventBus"],Ne(ip,Ci),ip.prototype.init=function(){this.addRule("elements.distribute",function(e){var t=e.elements;return t=ct(t,function(n){var i=st(n,["bpmn:Association","bpmn:BoundaryEvent","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:Lane","bpmn:MessageFlow","bpmn:SequenceFlow","bpmn:TextAnnotation"]);return!(n.labelTarget||i)}),t=ml(t),t.length<3?!1:t})};var yE={horizontal:`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1800 1800">
328
328
  <polyline points="450 400 450 150 1350 150 1350 400" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>
329
329
  <rect x="150" y="450" width="600" height="1200" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
330
330
  <rect x="1050" y="450" width="600" height="800" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
@@ -332,7 +332,7 @@
332
332
  <polyline points="400 1350 150 1350 150 450 400 450" style="fill:none;stroke:currentColor;stroke-width:100;stroke-linejoin:round;"/>
333
333
  <rect x="450" y="150" width="1200" height="600" rx="1" style="fill:none;stroke:currentColor;stroke-width:100;"></rect>
334
334
  <rect x="450" y="1050" width="800" height="600" rx="1" style="fill:currentColor;stroke:currentColor;stroke-width:100;opacity:.5;"></rect>
335
- </svg>`},BN=900;function hc(e,t,n,i){this._distributeElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",BN,this)}hc.$inject=["popupMenu","distributeElements","translate","rules"],hc.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&Y(t,this._getEntries(e)),t},hc.prototype._isAllowed=function(e){return this._rules.allowed("elements.distribute",{elements:e})},hc.prototype._getEntries=function(e){var t=this._distributeElements,n=this._translate,i=this._popupMenu,o={"distribute-elements-horizontal":{group:"distribute",title:n("Distribute elements horizontally"),className:"bjs-align-elements-menu-entry",imageHtml:yE.horizontal,action:function(r,a){t.trigger(e,"horizontal"),i.close()}},"distribute-elements-vertical":{group:"distribute",title:n("Distribute elements vertically"),imageHtml:yE.vertical,action:function(r,a){t.trigger(e,"vertical"),i.close()}}};return o};const NN={__depends__:[rg,IN],__init__:["bpmnDistributeElements","distributeElementsMenuProvider"],bpmnDistributeElements:["type",ip],distributeElementsMenuProvider:["type",hc]};var vE="is not a registered action",$N="is already registered";function Oi(e,t){this._eventBus=e,this._actions={};var n=this;e.on("diagram.init",function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})})}Oi.$inject=["eventBus","injector"],Oi.prototype._registerDefaultActions=function(e){var t=e.get("commandStack",!1),n=e.get("modeling",!1),i=e.get("selection",!1),o=e.get("zoomScroll",!1),r=e.get("copyPaste",!1),a=e.get("canvas",!1),s=e.get("rules",!1),c=e.get("keyboardMove",!1),l=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",function(){t.undo()}),this.register("redo",function(){t.redo()})),r&&i&&this.register("copy",function(){var u=i.get();if(u.length)return r.copy(u)}),r&&i&&this.register("duplicate",function(){var u=i.get();if(u.length)return r.duplicate(u)}),r&&this.register("paste",function(){r.paste()}),r&&i&&s&&this.register("cut",function(){var u=i.get();if(u.length){var p=s.allowed("elements.delete",{elements:u});if(p!==!1){var f=Ze(p)?p:u;return r.cut(f.slice())}}}),o&&this.register("stepZoom",function(u){o.stepZoom(u.value)}),a&&this.register("zoom",function(u){a.zoom(u.value)}),n&&i&&s&&this.register("removeSelection",function(){var u=i.get();if(u.length){var p=s.allowed("elements.delete",{elements:u}),f;p!==!1&&(Ze(p)?f=p:f=u,f.length&&n.removeElements(f.slice()))}}),c&&this.register("moveCanvas",function(u){c.moveCanvas(u)}),l&&this.register("moveSelection",function(u){l.moveSelection(u.direction,u.accelerated)})},Oi.prototype.trigger=function(e,t){if(!this._actions[e])throw gg(e,vE);var n=this._eventBus.fire("editorActions.allowed",{action:e,opts:t});if(n!==!1)return this._actions[e](t)},Oi.prototype.register=function(e,t){var n=this;if(typeof e=="string")return this._registerAction(e,t);V(e,function(i,o){n._registerAction(o,i)})},Oi.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw gg(e,$N);this._actions[e]=t},Oi.prototype.unregister=function(e){if(!this.isRegistered(e))throw gg(e,vE);this._actions[e]=void 0},Oi.prototype.getActions=function(){return Object.keys(this._actions)},Oi.prototype.isRegistered=function(e){return!!this._actions[e]};function gg(e,t){return new Error(e+" "+t)}const FN={__init__:["editorActions"],editorActions:["type",Oi]};function op(e){e.invoke(Oi,this)}Ne(op,Oi),op.$inject=["injector"],op.prototype._registerDefaultActions=function(e){Oi.prototype._registerDefaultActions.call(this,e);var t=e.get("canvas",!1),n=e.get("elementRegistry",!1),i=e.get("selection",!1),o=e.get("spaceTool",!1),r=e.get("lassoTool",!1),a=e.get("handTool",!1),s=e.get("globalConnect",!1),c=e.get("distributeElements",!1),l=e.get("alignElements",!1),u=e.get("directEditing",!1),p=e.get("searchPad",!1),f=e.get("modeling",!1),d=e.get("contextPad",!1);t&&n&&i&&this._registerAction("selectElements",function(){var g=t.getRootElement(),h=n.filter(function(m){return m!==g});return i.select(h),h}),o&&this._registerAction("spaceTool",function(){o.toggle()}),r&&this._registerAction("lassoTool",function(){r.toggle()}),a&&this._registerAction("handTool",function(){a.toggle()}),s&&this._registerAction("globalConnectTool",function(){s.toggle()}),i&&c&&this._registerAction("distributeElements",function(g){var h=i.get(),m=g.type;h.length&&c.trigger(h,m)}),i&&l&&this._registerAction("alignElements",function(g){var h=i.get(),m=[],w=g.type;h.length&&(m=ct(h,function(y){return!M(y,"bpmn:Lane")}),l.trigger(m,w))}),i&&f&&this._registerAction("setColor",function(g){var h=i.get();h.length&&f.setColor(h,g)}),i&&u&&this._registerAction("directEditing",function(){var g=i.get();g.length&&u.activate(g[0])}),p&&this._registerAction("find",function(){p.toggle()}),t&&f&&this._registerAction("moveToOrigin",function(){var g=t.getRootElement(),h,m;M(g,"bpmn:Collaboration")?m=n.filter(function(w){return M(w.parent,"bpmn:Collaboration")}):m=n.filter(function(w){return w!==g&&!M(w.parent,"bpmn:SubProcess")}),h=cn(m),f.moveElements(m,{x:-h.x,y:-h.y},g)}),i&&d&&this._registerAction("replaceElement",function(g){d.triggerEntry("replace","click",g)})};const jN={__depends__:[FN],editorActions:["type",op]};function bE(e){e.on(["create.init","shape.move.init"],function(t){var n=t.context,i=t.shape;st(i,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(n.gridSnappingContext||(n.gridSnappingContext={}),n.gridSnappingContext.snapLocation="top-left")})}bE.$inject=["eventBus"];function Zr(e,t){we.call(this,e),this._gridSnapping=t;var n=this;this.preExecute("shape.resize",function(i){var o=i.context,r=o.hints||{},a=r.autoResize;if(a){var s=o.shape,c=o.newBounds;ei(a)?o.newBounds=n.snapComplex(c,a):o.newBounds=n.snapSimple(s,c)}})}Zr.$inject=["eventBus","gridSnapping","modeling"],Ne(Zr,we),Zr.prototype.snapSimple=function(e,t){var n=this._gridSnapping;return t.width=n.snapValue(t.width,{min:t.width}),t.height=n.snapValue(t.height,{min:t.height}),t.x=e.x+e.width/2-t.width/2,t.y=e.y+e.height/2-t.height/2,t},Zr.prototype.snapComplex=function(e,t){return/w|e/.test(t)&&(e=this.snapHorizontally(e,t)),/n|s/.test(t)&&(e=this.snapVertically(e,t)),e},Zr.prototype.snapHorizontally=function(e,t){var n=this._gridSnapping,i=/w/.test(t),o=/e/.test(t),r={};return r.width=n.snapValue(e.width,{min:e.width}),o&&(i?(r.x=n.snapValue(e.x,{max:e.x}),r.width+=n.snapValue(e.x-r.x,{min:e.x-r.x})):e.x=e.x+e.width-r.width),Y(e,r),e},Zr.prototype.snapVertically=function(e,t){var n=this._gridSnapping,i=/n/.test(t),o=/s/.test(t),r={};return r.height=n.snapValue(e.height,{min:e.height}),i&&(o?(r.y=n.snapValue(e.y,{max:e.y}),r.height+=n.snapValue(e.y-r.y,{min:e.y-r.y})):e.y=e.y+e.height-r.height),Y(e,r),e};var HN=2e3;function xE(e,t){e.on(["spaceTool.move","spaceTool.end"],HN,function(n){var i=n.context;if(i.initialized){var o=i.axis,r;o==="x"?(r=t.snapValue(n.dx),n.x=n.x+r-n.dx,n.dx=r):(r=t.snapValue(n.dy),n.y=n.y+r-n.dy,n.dy=r)}})}xE.$inject=["eventBus","gridSnapping"];const zN={__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Zr],gridSnappingSpaceToolBehavior:["type",xE]};var rp=10;function mg(e,t,n){return n||(n="round"),Math[n](e/t)*t}var GN=1200,VN=800;function fr(e,t,n){var i=!n||n.active!==!1;this._eventBus=t;var o=this;t.on("diagram.init",VN,function(){o.setActive(i)}),t.on(["create.move","create.end","bendpoint.move.move","bendpoint.move.end","connect.move","connect.end","connectionSegment.move.move","connectionSegment.move.end","resize.move","resize.end","shape.move.move","shape.move.end"],GN,function(r){var a=r.originalEvent;if(!(!o.active||a&&ai(a))){var s=r.context,c=s.gridSnappingContext;c||(c=s.gridSnappingContext={}),["x","y"].forEach(function(l){var u={},p=UN(r,l,e);p&&(u.offset=p);var f=WN(r,l);f&&Y(u,f),Ya(r,l)||o.snapEvent(r,l,u)})}})}fr.prototype.snapEvent=function(e,t,n){var i=this.snapValue(e[t],n);fn(e,t,i)},fr.prototype.getGridSpacing=function(){return rp},fr.prototype.snapValue=function(e,t){var n=0;t&&t.offset&&(n=t.offset),e+=n,e=mg(e,rp);var i,o;return t&&t.min&&(i=t.min,Qe(i)&&(i=mg(i+n,rp,"ceil"),e=Math.max(e,i))),t&&t.max&&(o=t.max,Qe(o)&&(o=mg(o+n,rp,"floor"),e=Math.min(e,o))),e-=n,e},fr.prototype.isActive=function(){return this.active},fr.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},fr.prototype.toggleActive=function(){this.setActive(!this.active)},fr.$inject=["elementRegistry","eventBus","config.gridSnapping"];function WN(e,t){var n=e.context,i=n.createConstraints,o=n.resizeConstraints||{},r=n.gridSnappingContext,a=r.snapConstraints;if(a&&a[t])return a[t];a||(a=r.snapConstraints={}),a[t]||(a[t]={});var s=n.direction;i&&(ap(t)?(a.x.min=i.left,a.x.max=i.right):(a.y.min=i.top,a.y.max=i.bottom));var c=o.min,l=o.max;return c&&(ap(t)?_E(s)?a.x.max=c.left:a.x.min=c.right:wE(s)?a.y.max=c.top:a.y.min=c.bottom),l&&(ap(t)?_E(s)?a.x.min=l.left:a.x.max=l.right:wE(s)?a.y.min=l.top:a.y.max=l.bottom),a[t]}function UN(e,t,n){var i=e.context,o=e.shape,r=i.gridSnappingContext,a=r.snapLocation,s=r.snapOffset;return s&&Qe(s[t])||(s||(s=r.snapOffset={}),Qe(s[t])||(s[t]=0),!o)||(n.get(o.id)||(ap(t)?s[t]+=o[t]+o.width/2:s[t]+=o[t]+o.height/2),!a)||(t==="x"?/left/.test(a)?s[t]-=o.width/2:/right/.test(a)&&(s[t]+=o.width/2):/top/.test(a)?s[t]-=o.height/2:/bottom/.test(a)&&(s[t]+=o.height/2)),s[t]}function ap(e){return e==="x"}function wE(e){return e.indexOf("n")!==-1}function _E(e){return e.indexOf("w")!==-1}const qN={__depends__:[zN],__init__:["gridSnapping"],gridSnapping:["type",fr]};var YN=2e3;function EE(e,t,n){e.on("autoPlace",YN,function(i){var o=i.source,r=Je(o),a=i.shape,s=a_(o,a,n);return["x","y"].forEach(function(c){var l={};s[c]!==r[c]&&(s[c]>r[c]?l.min=s[c]:l.max=s[c],M(a,"bpmn:TextAnnotation")&&(KN(c)?l.offset=-a.width/2:l.offset=-a.height/2),s[c]=t.snapValue(s[c],l))}),s})}EE.$inject=["eventBus","gridSnapping","elementRegistry"];function KN(e){return e==="x"}var XN=1750;function SE(e,t,n){t.on(["create.start","shape.move.start"],XN,function(i){var o=i.context,r=o.shape,a=e.getRootElement();if(!(!M(r,"bpmn:Participant")||!M(a,"bpmn:Process")||!a.children.length)){var s=o.createConstraints;s&&(r.width=n.snapValue(r.width,{min:r.width}),r.height=n.snapValue(r.height,{min:r.height}))}})}SE.$inject=["canvas","eventBus","gridSnapping"];var ZN=3e3;function sp(e,t,n){we.call(this,e),this._gridSnapping=t;var i=this;this.postExecuted(["connection.create","connection.layout"],ZN,function(o){var r=o.context,a=r.connection,s=r.hints||{},c=a.waypoints;s.connectionStart||s.connectionEnd||s.createElementsBehavior===!1||QN(c)&&n.updateWaypoints(a,i.snapMiddleSegments(c))})}sp.$inject=["eventBus","gridSnapping","modeling"],Ne(sp,we),sp.prototype.snapMiddleSegments=function(e){var t=this._gridSnapping,n;e=e.slice();for(var i=1;i<e.length-2;i++)n=t$(t,e[i],e[i+1]),e[i]=n[0],e[i+1]=n[1];return e};function QN(e){return e.length>3}function JN(e){return e==="h"}function e$(e){return e==="v"}function t$(e,t,n){var i=vo(t,n),o={};return JN(i)&&(o.y=e.snapValue(t.y)),e$(i)&&(o.x=e.snapValue(t.x)),("x"in o||"y"in o)&&(t=Y({},t,o),n=Y({},n,o)),[t,n]}const n$={__depends__:[qN,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",EE],gridSnappingParticipantBehavior:["type",SE],gridSnappingLayoutConnectionBehavior:["type",sp]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",bE]};var i$=30,RE=30;function gc(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],function(i){var o=i.element,r=i.gfx;if(M(o,"bpmn:Lane"))return n._createParticipantHit(o,r);if(M(o,"bpmn:Participant"))return ht(o)?n._createParticipantHit(o,r):n._createDefaultHit(o,r);if(M(o,"bpmn:SubProcess"))return ht(o)?n._createSubProcessHit(o,r):n._createDefaultHit(o,r)})}gc.$inject=["eventBus","interactionEvents"],gc.prototype._createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},gc.prototype._createParticipantHit=function(e,t){this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height});var n=En(e)?{width:i$,height:e.height}:{width:e.width,height:RE};return this._interactionEvents.createBoxHit(t,"all",n),!0},gc.prototype._createSubProcessHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:e.width,height:RE}),!0};const o$={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",gc]};function cp(e){e.invoke(Ha,this)}Ne(cp,Ha),cp.$inject=["injector"],cp.prototype.registerBindings=function(e,t){Ha.prototype.registerBindings.call(this,e,t);function n(i,o){t.isRegistered(i)&&e.addListener(o)}n("selectElements",function(i){var o=i.keyEvent;if(e.isKey(["a","A"],o)&&e.isCmd(o))return t.trigger("selectElements"),!0}),n("find",function(i){var o=i.keyEvent;if(e.isKey(["f","F"],o)&&e.isCmd(o))return t.trigger("find"),!0}),n("spaceTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["s","S"],o))return t.trigger("spaceTool"),!0}),n("lassoTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["l","L"],o))return t.trigger("lassoTool"),!0}),n("handTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["h","H"],o))return t.trigger("handTool"),!0}),n("globalConnectTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["c","C"],o))return t.trigger("globalConnectTool"),!0}),n("directEditing",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["e","E"],o))return t.trigger("directEditing"),!0}),n("replaceElement",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["r","R"],o))return t.trigger("replaceElement",o),!0})};const r$={__depends__:[Vh],__init__:["keyboardBindings"],keyboardBindings:["type",cp]};var a$={moveSpeed:1,moveSpeedAccelerated:10},s$=1500,CE="left",ME="up",AE="right",PE="down",c$={ArrowLeft:CE,Left:CE,ArrowUp:ME,Up:ME,ArrowRight:AE,Right:AE,ArrowDown:PE,Down:PE},l$={left:function(e){return{x:-e,y:0}},up:function(e){return{x:0,y:-e}},right:function(e){return{x:e,y:0}},down:function(e){return{x:0,y:e}}};function TE(e,t,n,i,o){var r=this;this._config=Y({},a$,e||{}),t.addListener(s$,function(a){var s=a.keyEvent,c=c$[s.key];if(c&&!t.isCmd(s)){var l=t.isShift(s);return r.moveSelection(c,l),!0}}),this.moveSelection=function(a,s){var c=o.get();if(c.length){var l=this._config[s?"moveSpeedAccelerated":"moveSpeed"],u=l$[a](l),p=i.allowed("elements.move",{shapes:c,hints:{keyboardMove:!0}});p&&n.moveElements(c,u)}}}TE.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];const u$={__depends__:[Vh,Mi],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",TE]};var kE=10;function mc(e,t,n,i){this._dragging=i,this._rules=t;var o=this;function r(c,l){var u=c.shape,p=c.direction,f=c.resizeConstraints,d;c.delta=l,d=K2(u,p,l),c.newBounds=Z2(d,f),c.canExecute=o.canResize(c)}function a(c){var l=c.resizeConstraints,u=c.minBounds;l===void 0&&(u===void 0&&(u=o.computeMinResizeBox(c)),c.resizeConstraints={min:qe(u)})}function s(c){var l=c.shape,u=c.canExecute,p=c.newBounds;if(u){if(p=Ov(p),!p$(l,p))return;n.resizeShape(l,p)}}e.on("resize.start",function(c){a(c.context)}),e.on("resize.move",function(c){var l={x:c.dx,y:c.dy};r(c.context,l)}),e.on("resize.end",function(c){s(c.context)})}mc.prototype.canResize=function(e){var t=this._rules,n=Ni(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},mc.prototype.activate=function(e,t,n){var i=this._dragging,o,r;if(typeof n=="string"&&(n={direction:n}),o=Y({shape:t},n),r=o.direction,!r)throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");i.init(e,OE(t,r),"resize",{autoActivate:!0,cursor:f$(r),data:{shape:t,context:o}})},mc.prototype.computeMinResizeBox=function(e){var t=e.shape,n=e.direction,i,o;return i=e.minDimensions||{width:kE,height:kE},o=bb(t,e.childrenBoxPadding),Q2(n,t,i,o)},mc.$inject=["eventBus","rules","modeling","dragging"];function p$(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function OE(e,t){var n=Je(e),i=qe(e),o={x:n.x,y:n.y};return t.indexOf("n")!==-1?o.y=i.top:t.indexOf("s")!==-1&&(o.y=i.bottom),t.indexOf("e")!==-1?o.x=i.right:t.indexOf("w")!==-1&&(o.x=i.left),o}function f$(e){var t="resize-";return e==="n"||e==="s"?t+"ns":e==="e"||e==="w"?t+"ew":e==="nw"||e==="se"?t+"nwse":t+"nesw"}var DE="djs-resizing",LE="resize-not-ok",d$=500;function IE(e,t,n){function i(r){var a=r.shape,s=r.newBounds,c=r.frame;c||(c=r.frame=n.addFrame(a,t.getActiveLayer()),t.addMarker(a,DE)),s.width>5&&Ie(c,{x:s.x,width:s.width}),s.height>5&&Ie(c,{y:s.y,height:s.height}),r.canExecute?dt(c).remove(LE):dt(c).add(LE)}function o(r){var a=r.shape,s=r.frame;s&&sn(r.frame),t.removeMarker(a,DE)}e.on("resize.move",d$,function(r){i(r.context)}),e.on("resize.cleanup",function(r){o(r.context)})}IE.$inject=["eventBus","canvas","previewSupport"];var lp=-6,up=8,pp=20,yc="djs-resizer",h$=["n","w","s","e","nw","ne","se","sw"];function dr(e,t,n,i){this._resize=i,this._canvas=t;var o=this;e.on("selection.changed",function(r){var a=r.newSelection;o.removeResizers(),a.length===1&&V(a,Kn(o.addResizer,o))}),e.on("shape.changed",function(r){var a=r.element;n.isSelected(a)&&(o.removeResizers(),o.addResizer(a))})}dr.prototype.makeDraggable=function(e,t,n){var i=this._resize;function o(r){tr(r)&&i.activate(r,e,n)}Ve.bind(t,"mousedown",o),Ve.bind(t,"touchstart",o)},dr.prototype._createResizer=function(e,t,n,i){var o=this._getResizersParent(),r=g$(i),a=He("g");dt(a).add(yc),dt(a).add(yc+"-"+e.id),dt(a).add(yc+"-"+i),tt(o,a);var s=He("rect");Ie(s,{x:-up/2+r.x,y:-up/2+r.y,width:up,height:up}),dt(s).add(yc+"-visual"),tt(a,s);var c=He("rect");return Ie(c,{x:-pp/2+r.x,y:-pp/2+r.y,width:pp,height:pp}),dt(c).add(yc+"-hit"),tt(a,c),_l(a,t,n),a},dr.prototype.createResizer=function(e,t){var n=OE(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},dr.prototype.addResizer=function(e){var t=this;Ot(e)||V(h$,function(n){t._resize.canResize({shape:e,direction:n})&&t.createResizer(e,n)})},dr.prototype.removeResizers=function(){var e=this._getResizersParent();bs(e)},dr.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},dr.$inject=["eventBus","canvas","selection","resize"];function g$(e){var t={x:0,y:0};return e.indexOf("e")!==-1?t.x=-lp:e.indexOf("w")!==-1&&(t.x=lp),e.indexOf("s")!==-1?t.y=-lp:e.indexOf("n")!==-1&&(t.y=lp),t}const BE={__depends__:[io,So,Na],__init__:["resize","resizePreview","resizeHandles"],resize:["type",mc],resizePreview:["type",IE],resizeHandles:["type",dr]};var m$=2e3;function vc(e,t,n,i,o,r,a){this._bpmnFactory=t,this._canvas=n,this._modeling=o,this._textRenderer=a,i.registerProvider(this),e.on("element.dblclick",function(c){s(c.element,!0)}),e.on(["autoPlace.start","canvas.viewbox.changing","drag.init","element.mousedown","popupMenu.open","root.set","selection.changed"],function(){i.isActive()&&i.complete()}),e.on(["shape.remove","connection.remove"],m$,function(c){i.isActive(c.element)&&i.cancel()}),e.on(["commandStack.changed"],function(c){i.isActive()&&i.cancel()}),e.on("directEditing.activate",function(c){r.removeResizers()}),e.on("create.end",500,function(c){var l=c.context,u=l.shape,p=c.context.canExecute,f=c.isTouch;f||p&&(l.hints&&l.hints.createElementsBehavior===!1||s(u))}),e.on("autoPlace.end",500,function(c){s(c.shape)});function s(c,l){(l||st(c,["bpmn:Activity","bpmn:Event","bpmn:TextAnnotation","bpmn:Participant"]))&&i.activate(c)}}vc.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],vc.prototype.activate=function(e){var t=vi(e);if(t!==void 0){var n={text:t},i=this.getEditingBBox(e);Y(n,i);var o={},r=n.style||{};return Y(r,{backgroundColor:null,border:null}),(st(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||NE(e))&&Y(o,{centerVertically:!0}),Zo(e)&&(Y(o,{resizable:!0,autoResize:!0}),Y(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),M(e,"bpmn:TextAnnotation")&&(Y(o,{resizable:!0,autoResize:!0}),Y(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),Y(n,{options:o,style:r}),n}},vc.prototype.getEditingBBox=function(e){var t=this._canvas,n=e.label||e,i=t.getAbsoluteBBox(n),o={x:i.x+i.width/2,y:i.y+i.height/2},r={x:i.x,y:i.y},a=t.zoom(),s=this._textRenderer.getDefaultStyle(),c=this._textRenderer.getExternalStyle(),l=c.fontSize*a,u=c.lineHeight,p=s.fontSize*a,f=s.lineHeight,d={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};if(M(e,"bpmn:Lane")||b$(e)){var g=En(e),h=g?{width:i.height,height:30*a,x:i.x-i.height/2+15*a,y:o.y-30*a/2}:{width:i.width,height:30*a};Y(r,h),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:g?"rotate(-90deg)":null})}if(v$(e)){var m=En(e),w=m?{width:i.width,height:i.height}:{width:i.height,height:i.width,x:o.x-i.height/2,y:o.y-i.width/2};Y(r,w),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:m?null:"rotate(-90deg)"})}(st(e,["bpmn:Task","bpmn:CallActivity"])||NE(e))&&(Y(r,{width:i.width,height:i.height}),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"})),y$(e)&&(Y(r,{width:i.width,x:i.x}),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"}));var y=1,v=i.width+2*y;if(n.labelTarget&&(Y(r,{width:v,height:i.height+2*y,x:i.x-y,y:i.y-y}),Y(d,{fontSize:l+"px",lineHeight:u})),Zo(n)&&!Rl(n)&&!at(n)){var x=Jf(e),E=t.getAbsoluteBBox({x:x.x,y:x.y,width:0,height:0}),A=l,B=Nr.width*a+2*y;Y(r,{width:B,height:A+2*y,x:E.x-B/2,y:E.y-A/2-y}),Y(d,{fontSize:l+"px",lineHeight:u})}return M(e,"bpmn:TextAnnotation")&&(Y(r,{width:i.width+2*y,height:i.height+2*y,x:i.x-y,y:i.y-y,minWidth:30*a,minHeight:10*a}),Y(d,{textAlign:"left",paddingTop:Ra*a+"px",paddingBottom:Ra*a+"px",paddingLeft:Ra*a+"px",paddingRight:Ra*a+"px",fontSize:p+"px",lineHeight:f})),{bounds:r,style:d}},vc.prototype.update=function(e,t,n,i){var o,r;M(e,"bpmn:TextAnnotation")&&(r=this._canvas.getAbsoluteBBox(e),o={x:e.x,y:e.y,width:e.width/r.width*i.width,height:e.height/r.height*i.height}),x$(t)&&(t=null),this._modeling.updateLabel(e,t,o)};function NE(e){return M(e,"bpmn:SubProcess")&&!ht(e)}function y$(e){return M(e,"bpmn:SubProcess")&&ht(e)}function v$(e){return M(e,"bpmn:Participant")&&!ht(e)}function b$(e){return M(e,"bpmn:Participant")&&ht(e)}function x$(e){return!e||!e.trim()}var $E="djs-element-hidden",FE="djs-label-hidden";function jE(e,t,n){var i=this,o=t.getDefaultLayer(),r,a,s;e.on("directEditing.activate",function(c){var l=c.active;if(r=l.element.label||l.element,M(r,"bpmn:TextAnnotation")){a=t.getAbsoluteBBox(r),s=He("g");var u=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:r.height,position:{mx:0,my:0}}),p=i.path=He("path");Ie(p,{d:u,strokeWidth:2,stroke:w$(r)}),tt(s,p),tt(o,s),Dn(s,r.x,r.y)}M(r,"bpmn:TextAnnotation")||r.labelTarget?t.addMarker(r,$E):(M(r,"bpmn:Task")||M(r,"bpmn:CallActivity")||M(r,"bpmn:SubProcess")||M(r,"bpmn:Participant")||M(r,"bpmn:Lane"))&&t.addMarker(r,FE)}),e.on("directEditing.resize",function(c){if(M(r,"bpmn:TextAnnotation")){var l=c.height,u=c.dy,p=Math.max(r.height/a.height*(l+u),0),f=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:p,position:{mx:0,my:0}});Ie(i.path,{d:f})}}),e.on(["directEditing.complete","directEditing.cancel"],function(c){var l=c.active;l&&(t.removeMarker(l.element.label||l.element,$E),t.removeMarker(r,FE)),r=void 0,a=void 0,s&&(sn(s),s=void 0)})}jE.$inject=["eventBus","canvas","pathMap"];function w$(e,t){var n=mt(e);return n.get("stroke")||t||"black"}const _$={__depends__:[yh,BE,pE],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",vc],labelEditingPreview:["type",jE]};var E$=500,S$=1e3;function ao(e,t,n){this._eventBus=e,this._elementRegistry=n,this._outlineOffset=5,this._outlineStyle=t.cls("djs-outline",["no-fill"]);var i=this;function o(r){ZP(r)||i.createOutline(r)}e.on("element.hover",function(r){o(r.element)}),e.on("selection.changed",function(r){V(r.newSelection,o)}),e.on(["shape.changed","connection.changed"],E$,function(r){var a=r.element,s=r.gfx,c=Ct(".djs-outline",s);c&&i.updateOutline(a,c)})}ao.prototype.createOutline=function(e){var t=this._elementRegistry.getGraphics(e);if(!t)throw new Error("cannot create outline for non-rendered element");var n=Ct(".djs-outline",t);return n||(n=this.getOutline(e)||this._createOutlineGfx(),tt(t,n),this.updateOutline(e,n)),n},ao.prototype._createOutlineGfx=function(){var e=He("rect");return Ie(e,Y({x:0,y:0,rx:4,width:100,height:100},this._outlineStyle)),e},ao.prototype.updateOutline=function(e,t){e.waypoints?this.updateConnectionOutline(t,e):this.updateShapeOutline(t,e)},ao.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&V(i,function(o){n=n||o.updateOutline(t,e)}),n||Ie(e,{x:-this._outlineOffset,y:-this._outlineOffset,width:t.width+this._outlineOffset*2,height:t.height+this._outlineOffset*2})},ao.prototype.updateConnectionOutline=function(e,t){var n=cn(t);Ie(e,{x:n.x-this._outlineOffset,y:n.y-this._outlineOffset,width:n.width+this._outlineOffset*2,height:n.height+this._outlineOffset*2})},ao.prototype.registerProvider=function(e,t){t||(t=e,e=S$),this._eventBus.on("outline.getProviders",e,function(n){n.providers.push(t)})},ao.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},ao.prototype.getOutline=function(e){var t,n=this._getProviders();return V(n,function(i){_n(i.getOutline)&&(t=t||i.getOutline(e))}),t},ao.$inject=["eventBus","styles","elementRegistry"];var fp=6;function yg(e,t,n){this._canvas=t;var i=this;e.on("element.changed",function(o){n.isSelected(o.element)&&i._updateMultiSelectionOutline(n.get())}),e.on("selection.changed",function(o){var r=o.newSelection;i._updateMultiSelectionOutline(r)})}yg.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");bs(t);var n=e.length>1,i=this._canvas.getContainer();if(dt(i)[n?"add":"remove"]("djs-multi-select"),!!n){var o=R$(cn(e)),r=He("rect");Ie(r,Y({rx:3},o)),dt(r).add("djs-selection-outline"),tt(t,r)}},yg.$inject=["eventBus","canvas","selection"];function R$(e){return{x:e.x-fp,y:e.y-fp,width:e.width+fp*2,height:e.height+fp*2}}const vg={__depends__:[Mi],__init__:["outline","multiSelectionOutline"],outline:["type",ao],multiSelectionOutline:["type",yg]},HE=["bpmn:Event","bpmn:SequenceFlow","bpmn:Gateway"],zE={class:"bjs-label-link",stroke:"var(--element-selected-outline-secondary-stroke-color)",strokeDasharray:"5, 5"},C$=15,dp=2;function GE(e,t,n,i,o){const r=t.getLayer("overlays");e.on(["selection.changed","shape.changed"],function(){s()}),e.on("selection.changed",function({newSelection:p}){var d;const f=p.filter(g=>st(g,HE));if(f.length===1){const g=f[0];at(g)?a(g,g.labelTarget):(d=g.labels)!=null&&d.length&&a(g.labels[0],g)}if(f.length===2){const g=f.find(at),h=f.find(m=>{var w;return(w=m.labels)==null?void 0:w.includes(g)});g&&h&&a(g,h)}}),e.on("shape.changed",function({element:p}){var f;!st(p,HE)||!u(p)||(at(p)?a(p,p.labelTarget):(f=p.labels)!=null&&f.length&&a(p.labels[0],p))});function a(p,f){const d=_s([Je(f),Je(p)],zE),g=d.getAttribute("d"),m=o.isSelected(p)?c(p):l(p),w=Cs(m,g);if(!w)return;const v=o.isSelected(f)?c(f):l(f),x=Cs(v,g)||Je(f);Bs(x,w)<C$||(Wf(d,[x,w]),tt(r,d))}function s(){vs(`.${zE.class}`,r).forEach(sn)}function c(p){const f=i.getOutline(p);if(!f)return l(p);if(f.x){const d={x:p.x+hr(f,"x")-dp,y:p.y+hr(f,"y")-dp,width:hr(f,"width")+dp*2,height:hr(f,"height")+dp*2};return td(d,hr(f,"rx"))}if(f.cx){const d=hr(f,"r"),g={x:p.x+hr(f,"cx")-d,y:p.y+hr(f,"cy")-d,width:d*2,height:d*2};return nb(g)}}function l(p){return n.getShapePath(p)}function u(p){return o.isSelected(p)}}GE.$inject=["eventBus","canvas","graphicsFactory","outline","selection"];function hr(e,t){return parseFloat(Ie(e,t)||0)}const M$={__depends__:[Mi,vg],__init__:["labelLink"],labelLink:["type",GE]};var A$=new zr("tt");function P$(e){var t=jt('<div class="djs-tooltip-container" />');return Un(t,{position:"absolute",width:"0",height:"0"}),e.insertBefore(t,e.firstChild),t}function T$(e,t,n){Un(e,{left:t+"px",top:n+"px"})}function bg(e,t){e.style.display=t===!1?"none":""}var VE="djs-tooltip",xg="."+VE;function Zn(e,t){this._eventBus=e,this._canvas=t,this._ids=A$,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=P$(t.getContainer());var n=this;ii.bind(this._tooltipRoot,xg,"mousedown",function(i){i.stopPropagation()}),ii.bind(this._tooltipRoot,xg,"mouseover",function(i){n.trigger("mouseover",i)}),ii.bind(this._tooltipRoot,xg,"mouseout",function(i){n.trigger("mouseout",i)}),this._init()}Zn.$inject=["eventBus","canvas"],Zn.prototype.add=function(e){if(!e.position)throw new Error("must specifiy tooltip position");if(!e.html)throw new Error("must specifiy tooltip html");var t=this._ids.next();return e=Y({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Zn.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(Cn(n,"data-tooltip-id"));i&&(e==="mouseover"&&i.timeout&&this.clearTimeout(i),e==="mouseout"&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Zn.prototype.get=function(e){return typeof e!="string"&&(e=e.id),this._tooltips[e]},Zn.prototype.clearTimeout=function(e){if(e=this.get(e),!!e){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Zn.prototype.setTimeout=function(e){if(e=this.get(e),!!e){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout(function(){t.remove(e)},e.timeout)}},Zn.prototype.remove=function(e){var t=this.get(e);t&&(Zi(t.html),Zi(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Zn.prototype.show=function(){bg(this._tooltipRoot)},Zn.prototype.hide=function(){bg(this._tooltipRoot,!1)},Zn.prototype._updateRoot=function(e){var t=e.scale||1,n=e.scale||1,i="matrix("+t+",0,0,"+n+","+-1*e.x*t+","+-1*e.y*n+")";this._tooltipRoot.style.transform=i,this._tooltipRoot.style["-ms-transform"]=i},Zn.prototype._addTooltip=function(e){var t=e.id,n=e.html,i,o=this._tooltipRoot;n.get&&n.constructor.prototype.jquery&&(n=n.get(0)),ei(n)&&(n=jt(n)),i=jt('<div data-tooltip-id="'+t+'" class="'+VE+'">'),Un(i,{position:"absolute"}),i.appendChild(n),e.type&&At(i).add("djs-tooltip-"+e.type),e.className&&At(i).add(e.className),e.htmlContainer=i,o.appendChild(i),this._tooltips[t]=e,this._updateTooltip(e)},Zn.prototype._updateTooltip=function(e){var t=e.position,n=e.htmlContainer;T$(n,t.x,t.y)},Zn.prototype._updateTooltipVisibilty=function(e){V(this._tooltips,function(t){var n=t.show,i=t.htmlContainer,o=!0;n&&((n.minZoom>e.scale||n.maxZoom<e.scale)&&(o=!1),bg(i,o))})},Zn.prototype._init=function(){var e=this;function t(n){e._updateRoot(n),e._updateTooltipVisibilty(n),e.show()}this._eventBus.on("canvas.viewbox.changing",function(n){e.hide()}),this._eventBus.on("canvas.viewbox.changed",function(n){t(n.viewbox)})};const k$={__init__:["tooltips"],tooltips:["type",Zn]};var O$="flow elements must be children of pools/participants",D$="Data object must be placed within a pool/participant.";function WE(e,t,n){function i(o,r,a){t.add({position:{x:o.x+5,y:o.y+5},type:"error",timeout:2e3,html:"<div>"+r+"</div>"})}e.on(["shape.move.rejected","create.rejected"],function(o){var r=o.context,a=r.shape,s=r.target;M(s,"bpmn:Collaboration")&&(M(a,"bpmn:FlowNode")?i(o,n(O$)):M(a,"bpmn:DataObjectReference")&&i(o,n(D$)))})}WE.$inject=["eventBus","tooltips","translate"];const L$={__depends__:[k$],__init__:["modelingFeedback"],modelingFeedback:["type",WE]};var I$=500,B$=1250,N$=1500,hp=Math.round;function $$(e){return{x:e.x+hp(e.width/2),y:e.y+hp(e.height/2)}}function UE(e,t,n,i,o){function r(s,c,l,u){return o.allowed("elements.move",{shapes:s,delta:c,position:l,target:u})}e.on("shape.move.start",N$,function(s){var c=s.context,l=s.shape,u=i.get().slice();u.indexOf(l)===-1&&(u=[l]),u=F$(u),Y(c,{shapes:u,validatedShapes:u,shape:l})}),e.on("shape.move.start",B$,function(s){var c=s.context,l=c.validatedShapes,u;if(u=c.canExecute=r(l),!u)return!1}),e.on("shape.move.move",I$,function(s){var c=s.context,l=c.validatedShapes,u=s.hover,p={x:s.dx,y:s.dy},f={x:s.x,y:s.y},d;if(d=r(l,p,f,u),c.delta=p,c.canExecute=d,d===null){c.target=null;return}c.target=u}),e.on("shape.move.end",function(s){var c=s.context,l=c.delta,u=c.canExecute,p=u==="attach",f=c.shapes;if(u===!1)return!1;l.x=hp(l.x),l.y=hp(l.y),!(l.x===0&&l.y===0)&&n.moveElements(f,l,c.target,{primaryShape:c.shape,attach:p})}),e.on("element.mousedown",function(s){if(tr(s)){var c=Da(s);if(!c)throw new Error("must supply DOM mousedown event");return a(c,s.element)}});function a(s,c,l,u){if(mn(l)&&(u=l,l=!1),!(c.waypoints||!c.parent)&&!dt(s.target).has("djs-hit-no-move")){var p=$$(c),f=t.init(s,p,"shape.move",{cursor:"grabbing",autoActivate:l,data:{shape:c,context:u||{}}});if(f!==!1)return!0}}this.start=a}UE.$inject=["eventBus","dragging","modeling","selection","rules"];function F$(e){var t=sa(e,"id");return ct(e,function(n){for(;n=n.parent;)if(t[n.id])return!1;return!0})}var qE=499,wg="djs-dragging",YE="drop-ok",KE="drop-not-ok",XE="new-parent",ZE="attach-ok";function QE(e,t,n,i){function o(c){var l=r(c),u=j$(l);return u}function r(c){var l=Es(c),u=l.flatMap(d=>(d.incoming||[]).concat(d.outgoing||[])),p=l.concat(u),f=[...new Set(p)];return f}function a(c,l){[ZE,YE,KE,XE].forEach(function(u){u===l?t.addMarker(c,u):t.removeMarker(c,u)})}function s(c,l,u){i.addDragger(l,c.dragGroup),u&&t.addMarker(l,wg),c.allDraggedElements?c.allDraggedElements.push(l):c.allDraggedElements=[l]}e.on("shape.move.start",qE,function(c){var l=c.context,u=l.shapes,p=l.allDraggedElements,f=o(u);if(!l.dragGroup){var d=He("g");Ie(d,n.cls("djs-drag-group",["no-events"]));var g=t.getActiveLayer();tt(g,d),l.dragGroup=d}f.forEach(function(h){i.addDragger(h,l.dragGroup)}),p?p=Ip([p,r(u)]):p=r(u),V(p,function(h){t.addMarker(h,wg)}),l.allDraggedElements=p,l.differentParents=H$(u)}),e.on("shape.move.move",qE,function(c){var l=c.context,u=l.dragGroup,p=l.target,f=l.shape.parent,d=l.canExecute;p&&(d==="attach"?a(p,ZE):l.canExecute&&f&&p.id!==f.id?a(p,XE):a(p,l.canExecute?YE:KE)),Dn(u,c.dx,c.dy)}),e.on(["shape.move.out","shape.move.cleanup"],function(c){var l=c.context,u=l.target;u&&a(u,null)}),e.on("shape.move.cleanup",function(c){var l=c.context,u=l.allDraggedElements,p=l.dragGroup;V(u,function(f){t.removeMarker(f,wg)}),p&&sn(p)}),this.makeDraggable=s}QE.$inject=["eventBus","canvas","styles","previewSupport"];function j$(e){var t=new Set;e.forEach(function(i){t.add(i.id)});var n=ct(e,function(i){return Ot(i)?t.has(i.source.id)&&t.has(i.target.id):!0});return n}function H$(e){return HS(sa(e,function(t){return t.parent&&t.parent.id}))!==1}const z$={__depends__:[nu,Mi,vg,io,So,Na],__init__:["move","movePreview"],move:["type",UE],movePreview:["type",QE]};var JE=".djs-palette-toggle",e1=".entry",G$=JE+", "+e1,_g="djs-palette-",V$="shown",Eg="open",t1="two-column",W$=1e3;function dn(e,t){this._eventBus=e,this._canvas=t;var n=this;e.on("tool-manager.update",function(i){var o=i.tool;n.updateToolHighlight(o)}),e.on("i18n.changed",function(){n._update()}),e.on("diagram.init",function(){n._diagramInitialized=!0,n._rebuild()})}dn.$inject=["eventBus","canvas"],dn.prototype.registerProvider=function(e,t){t||(t=e,e=W$),this._eventBus.on("palette.getProviders",e,function(n){n.providers.push(t)}),this._rebuild()},dn.prototype.getEntries=function(){var e=this._getProviders();return e.reduce(q$,{})},dn.prototype._rebuild=function(){if(this._diagramInitialized){var e=this._getProviders();e.length&&(this._container||this._init(),this._update())}},dn.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=jt(dn.HTML_MARKUP);n.appendChild(i),At(n).add(_g+V$),ii.bind(i,G$,"click",function(o){var r=o.delegateTarget;if(If(r,JE))return e.toggle();e.trigger("click",o)}),Ve.bind(i,"mousedown",function(o){o.stopPropagation()}),ii.bind(i,e1,"dragstart",function(o){e.trigger("dragstart",o)}),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},dn.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},dn.prototype._toggleState=function(e){e=e||{};var t=this._getParentContainer(),n=this._container,i=this._eventBus,o,r=At(n),a=At(t);"twoColumn"in e?o=e.twoColumn:o=this._needsCollapse(t.clientHeight,this._entries||{}),r.toggle(t1,o),a.toggle(_g+t1,o),"open"in e&&(r.toggle(Eg,e.open),a.toggle(_g+Eg,e.open)),i.fire("palette.changed",{twoColumn:o,open:this.isOpen()})},dn.prototype._update=function(){var e=Ct(".djs-palette-entries",this._container),t=this._entries=this.getEntries();fl(e),V(t,function(n,i){var o=n.group||"default",r=Ct("[data-group="+Ur(o)+"]",e);r||(r=jt('<div class="group"></div>'),Cn(r,"data-group",o),e.appendChild(r));var a=n.html||(n.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),s=jt(a);if(r.appendChild(s),!n.separator&&(Cn(s,"data-action",i),n.title&&Cn(s,"title",n.title),n.className&&U$(s,n.className),n.imageUrl)){var c=jt("<img>");Cn(c,"src",n.imageUrl),s.appendChild(c)}}),this.open()},dn.prototype.trigger=function(e,t,n){var i,o,r=t.delegateTarget||t.target;return r?(i=Cn(r,"data-action"),o=t.originalEvent||t,this.triggerEntry(i,e,o,n)):t.preventDefault()},dn.prototype.triggerEntry=function(e,t,n,i){var o=this._entries,r,a;if(r=o[e],!!r&&(a=r.action,this._eventBus.fire("palette.trigger",{entry:r,event:n})!==!1)){if(_n(a)){if(t==="click")return a(n,i)}else if(a[t])return a[t](n,i);n.preventDefault()}},dn.prototype._layoutChanged=function(){this._toggleState({})},dn.prototype._needsCollapse=function(e,t){var n=50,i=Object.keys(t).length*46;return e<i+n},dn.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},dn.prototype.open=function(){this._toggleState({open:!0})},dn.prototype.toggle=function(){this.isOpen()?this.close():this.open()},dn.prototype.isActiveTool=function(e){return e&&this._activeTool===e},dn.prototype.updateToolHighlight=function(e){var t,n;this._toolsContainer||(t=Ct(".djs-palette-entries",this._container),this._toolsContainer=Ct("[data-group=tools]",t)),n=this._toolsContainer,V(n.children,function(i){var o=i.getAttribute("data-action");if(o){var r=At(i);o=o.replace("-tool",""),r.contains("entry")&&o===e?r.add("highlighted-entry"):r.remove("highlighted-entry")}})},dn.prototype.isOpen=function(){return At(this._container).has(Eg)},dn.prototype._getParentContainer=function(){return this._canvas.getContainer()},dn.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';function U$(e,t){var n=At(e),i=Ze(t)?t:t.split(/\s+/g);i.forEach(function(o){n.add(o)})}function q$(e,t){var n=t.getPaletteEntries();return _n(n)?n(e):(V(n,function(i,o){e[o]=i}),e)}const Y$={__init__:["palette"],palette:["type",dn]};var n1="crosshair",i1="selected",K$="djs-dragging-active-lasso";function gr(e,t,n,i,o,r,a){this._selection=o,this._dragging=n,this._mouse=a;var s=this,c={create:function(p){var f=t.getActiveLayer(),d=p.frame=He("rect");Ie(d,{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),tt(f,d),l(!0),this.update(p)},update:function(p){var f=p.frame,d=p.bbox;f&&d&&Ie(f,{x:d.x,y:d.y,width:d.width,height:d.height});var g=p.marked,h=p.lastMarked;if(g&&h){for(const m of h)g.has(m)||t.removeMarker(m,i1);for(const m of g)h.has(m)||t.addMarker(m,i1)}},remove:function(p){this.update(p),p.frame&&sn(p.frame),l(!1)}};function l(p){dt(t.getContainer()).toggle(K$,p)}function u(p){var f=i.getAll();return new Set(aa(xa(f,p)))}r.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),e.on("lasso.selection.end",function(p){var f=p.originalEvent.target;!p.hover&&!(f instanceof SVGElement)||e.once("lasso.selection.ended",function(){s.activateLasso(p.originalEvent,!0)})}),e.on("lasso.end",0,function(p){var f=p.context;s._select(Array.from(f.marked))}),e.on("lasso.start",function(p){var f=p.context;f.bbox=o1(p),f.add=Kl(p),f.lastMarked=new Set(o.get()),f.add?f.marked=f.lastMarked:f.marked=new Set,f.initialMarked=f.marked,c.create(f)}),e.on("lasso.move",function(p){var f=p.context,d=f.bbox=o1(p),g=u(d),h=f.initialMarked.union(g);f.lastMarked=f.marked,f.marked=h,c.update(f)}),e.on("lasso.cleanup",function(p){var f=p.context;f.lastMarked=f.marked,f.marked=new Set(o.get()),c.remove(p.context)}),e.on("element.mousedown",1500,function(p){if(Kl(p))return s.activateLasso(p.originalEvent),!0})}gr.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],gr.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:n1,data:{context:{}},keepSelection:!0})},gr.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:n1,data:{context:{}},keepSelection:!0})},gr.prototype._select=function(e){this._selection.select(e)},gr.prototype.select=function(e,t,n=[]){var i=aa(xa(e,t));this._select([...n,...i])},gr.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},gr.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};function o1(e){var t={x:e.x-e.dx,y:e.y-e.dy},n={x:e.x,y:e.y},i;return t.x<=n.x&&t.y<n.y||t.x<n.x&&t.y<=n.y?i={x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}:t.x>=n.x&&t.y<n.y||t.x>n.x&&t.y<=n.y?i={x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}:t.x<=n.x&&t.y>n.y||t.x<n.x&&t.y>=n.y?i={x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y}:t.x>=n.x&&t.y>n.y||t.x>n.x&&t.y>=n.y?i={x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y}:i={x:n.x,y:n.y,width:0,height:0},i}const X$={__depends__:[au,zs],__init__:["lassoTool"],lassoTool:["type",gr]};var Sg=1500,r1="grab";function Ka(e,t,n,i,o,r){this._dragging=n,this._mouse=r;var a=this,s=i.get("keyboard",!1);o.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Sg,function(c){if(Fs(c))return a.activateMove(c.originalEvent,!0),!1}),s&&s.addListener(Sg,function(c){if(!(!a1(c.keyEvent)||a.isActive())){var l=a._mouse.getLastMoveEvent();a.activateMove(l,!!l)}},"keyboard.keydown"),s&&s.addListener(Sg,function(c){!a1(c.keyEvent)||!a.isActive()||a.toggle()},"keyboard.keyup"),e.on("hand.end",function(c){var l=c.originalEvent.target;if(!c.hover&&!(l instanceof SVGElement))return!1;e.once("hand.ended",function(){a.activateMove(c.originalEvent,{reactivate:!0})})}),e.on("hand.move.move",function(c){var l=t.viewbox().scale;t.scroll({dx:c.dx*l,dy:c.dy*l})}),e.on("hand.move.end",function(c){var l=c.context,u=l.reactivate;return!Fs(c)&&u&&e.once("hand.move.ended",function(p){a.activateHand(p.originalEvent,!0,!0)}),!1})}Ka.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Ka.prototype.activateMove=function(e,t,n){typeof t=="object"&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:r1,data:{context:n||{}}})},Ka.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:r1,data:{context:{reactivate:n}}})},Ka.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Ka.prototype.isActive=function(){var e=this._dragging.context();return e?/^(hand|hand\.move)$/.test(e.prefix):!1};function a1(e){return vn("Space",e)}const Z$={__depends__:[au,zs],__init__:["handTool"],handTool:["type",Ka]};var s1="connect-ok",c1="connect-not-ok";function Xa(e,t,n,i,o,r,a){var s=this;this._dragging=t,this._rules=r,this._mouse=a,o.registerTool("global-connect",{tool:"global-connect",dragging:"global-connect.drag"}),e.on("global-connect.hover",function(c){var l=c.context,u=c.hover,p=l.canStartConnect=s.canStartConnect(u);p!==null&&(l.startTarget=u,i.addMarker(u,p?s1:c1))}),e.on(["global-connect.out","global-connect.cleanup"],function(c){var l=c.context.startTarget,u=c.context.canStartConnect;l&&i.removeMarker(l,u?s1:c1)}),e.on(["global-connect.ended"],function(c){var l=c.context,u=l.startTarget,p={x:c.x,y:c.y},f=s.canStartConnect(u);if(f)return e.once("element.out",function(){e.once(["connect.ended","connect.canceled"],function(){e.fire("global-connect.drag.ended")}),n.start(null,u,p)}),!1})}Xa.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],Xa.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},Xa.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},Xa.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},Xa.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};const Q$={__depends__:[dg,io,So,au,zs],globalConnect:["type",Xa]};function Rg(e,t,n,i,o,r,a,s){this._palette=e,this._create=t,this._elementFactory=n,this._spaceTool=i,this._lassoTool=o,this._handTool=r,this._globalConnect=a,this._translate=s,e.registerProvider(this)}Rg.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],Rg.prototype.getPaletteEntries=function(){var e={},t=this._create,n=this._elementFactory,i=this._spaceTool,o=this._lassoTool,r=this._handTool,a=this._globalConnect,s=this._translate;function c(p,f,d,g,h){function m(w){var y=n.createShape(Y({type:p},h));t.start(w,y)}return{group:f,className:d,title:g,action:{dragstart:m,click:m}}}function l(p){var f=n.createShape({type:"bpmn:SubProcess",x:0,y:0,isExpanded:!0}),d=n.createShape({type:"bpmn:StartEvent",x:40,y:82,parent:f});t.start(p,[f,d],{hints:{autoSelect:[f]}})}function u(p){t.start(p,n.createParticipantShape())}return Y(e,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(p){r.activateHand(p)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(p){o.activateSelection(p)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:s("Activate create/remove space tool"),action:{click:function(p){i.activateSelection(p)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:s("Activate global connect tool"),action:{click:function(p){a.start(p)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":c("bpmn:StartEvent","event","bpmn-icon-start-event-none",s("Create start event")),"create.intermediate-event":c("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",s("Create intermediate/boundary event")),"create.end-event":c("bpmn:EndEvent","event","bpmn-icon-end-event-none",s("Create end event")),"create.exclusive-gateway":c("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",s("Create gateway")),"create.task":c("bpmn:Task","activity","bpmn-icon-task",s("Create task")),"create.data-object":c("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",s("Create data object reference")),"create.data-store":c("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",s("Create data store reference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:s("Create expanded sub-process"),action:{dragstart:l,click:l}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:s("Create pool/participant"),action:{dragstart:u,click:u}},"create.group":c("bpmn:Group","artifact","bpmn-icon-group",s("Create group"))}),e};const J$={__depends__:[Y$,ou,xw,X$,Z$,Q$,Os],__init__:["paletteProvider"],paletteProvider:["type",Rg]};var e5=250;function Cg(e,t,n,i,o){we.call(this,e);function r(s){var c=s.canExecute.replacements;V(c,function(l){var u=l.oldElementId,p={type:l.newElementType};if(!s.visualReplacements[u]){var f=t.get(u);Y(p,{x:f.x,y:f.y});var d=n.createShape(p);i.addShape(d,f.parent);var g=Ct('[data-element-id="'+Ur(f.id)+'"]',s.dragGroup);g&&Ie(g,{display:"none"});var h=o.addDragger(d,s.dragGroup);s.visualReplacements[u]=h,i.removeShape(d)}})}function a(s){var c=s.visualReplacements;V(c,function(l,u){var p=Ct('[data-element-id="'+Ur(u)+'"]',s.dragGroup);p&&Ie(p,{display:"inline"}),l.remove(),c[u]&&delete c[u]})}e.on("shape.move.move",e5,function(s){var c=s.context,l=c.canExecute;c.visualReplacements||(c.visualReplacements={}),l&&l.replacements?r(c):a(c)})}Cg.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],Ne(Cg,we);const t5={__depends__:[Na],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",Cg]};var n5=1250,Mg=40,i5=20,o5=10,l1=20,u1=["x","y"],r5=Math.abs;function p1(e){e.on(["connect.hover","connect.move","connect.end"],n5,function(t){var n=t.context,i=n.canExecute,o=n.start,r=n.hover,a=n.source,s=n.target;t.originalEvent&&ai(t.originalEvent)||(n.initialConnectionStart||(n.initialConnectionStart=n.connectionStart),i&&r&&a5(t,r,u5(r)),r&&l5(i,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(n.connectionStart=Ti(o),st(r,["bpmn:Event","bpmn:Gateway"])&&f1(t,Ti(r)),st(r,["bpmn:Task","bpmn:SubProcess"])&&s5(t,r),M(a,"bpmn:BoundaryEvent")&&s===a.host&&c5(t)):d1(i,"bpmn:MessageFlow")?(M(o,"bpmn:Event")&&(n.connectionStart=Ti(o)),M(r,"bpmn:Event")&&f1(t,Ti(r))):n.connectionStart=n.initialConnectionStart)})}p1.$inject=["eventBus"];function a5(e,t,n){u1.forEach(function(i){var o=h1(i,t);e[i]<t[i]+n?fn(e,i,t[i]+n):e[i]>t[i]+o-n&&fn(e,i,t[i]+o-n)})}function s5(e,t){var n=Ti(t);u1.forEach(function(i){p5(e,t,i)&&fn(e,i,n[i])})}function c5(e){var t=e.context,n=t.source,i=t.target;if(!f5(t)){var o=Ti(n),r=On(o,i,-10),a=[];/top|bottom/.test(r)&&a.push("x"),/left|right/.test(r)&&a.push("y"),a.forEach(function(s){var c=e[s],l;r5(c-o[s])<Mg&&(c>o[s]?l=o[s]+Mg:l=o[s]-Mg,fn(e,s,l))})}}function f1(e,t){fn(e,"x",t.x),fn(e,"y",t.y)}function d1(e,t){return e&&e.type===t}function l5(e,t){return Bo(t,function(n){return d1(e,n)})}function h1(e,t){return e==="x"?t.width:t.height}function u5(e){return M(e,"bpmn:Task")?o5:i5}function p5(e,t,n){return e[n]>t[n]+l1&&e[n]<t[n]+h1(n,t)-l1}function f5(e){var t=e.hover,n=e.source;return t&&n&&t===n}function mr(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}mr.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},mr.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,this._snapLocations.indexOf(e)===-1&&this._snapLocations.push(e)},mr.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},mr.prototype.getSnapLocations=function(){return this._snapLocations},mr.prototype.setSnapLocations=function(e){this._snapLocations=e},mr.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new gp,n.initDefaults(this._defaultSnaps)),n};function gp(){this._snapValues={}}gp.prototype.add=function(e,t){var n=this._snapValues[e];n||(n=this._snapValues[e]={x:[],y:[]}),n.x.indexOf(t.x)===-1&&n.x.push(t.x),n.y.indexOf(t.y)===-1&&n.y.push(t.y)},gp.prototype.snap=function(e,t,n,i){var o=this._snapValues[t];return o&&eN(e[n],o[n],i)},gp.prototype.initDefaults=function(e){var t=this;V(e||{},function(n,i){V(n,function(o){t.add(i,o)})})};var d5=1250;function so(e,t,n){var i=this;this._elementRegistry=e,t.on(["create.start","shape.move.start"],function(o){i.initSnap(o)}),t.on(["create.move","create.end","shape.move.move","shape.move.end"],d5,function(o){var r=o.context,a=r.shape,s=r.snapContext,c=r.target;if(!(o.originalEvent&&ai(o.originalEvent))&&!(Ya(o)||!c)){var l=s.pointsForTarget(c);l.initialized||(l=i.addSnapTargetPoints(l,a,c),l.initialized=!0),n.snap(o,l)}}),t.on(["create.cleanup","shape.move.cleanup"],function(){n.hide()})}so.$inject=["elementRegistry","eventBus","snapping"],so.prototype.initSnap=function(e){var t=this._elementRegistry,n=e.context,i=n.shape,o=n.snapContext;o||(o=n.snapContext=new mr);var r;t.get(i.id)?r=Ti(i,e):r={x:e.x+Ti(i).x,y:e.y+Ti(i).y};var a={x:r.x-i.width/2,y:r.y-i.height/2},s={x:r.x+i.width/2,y:r.y+i.height/2};return o.setSnapOrigin("mid",{x:r.x-e.x,y:r.y-e.y}),at(i)||(o.setSnapOrigin("top-left",{x:a.x-e.x,y:a.y-e.y}),o.setSnapOrigin("bottom-right",{x:s.x-e.x,y:s.y-e.y})),o},so.prototype.addSnapTargetPoints=function(e,t,n){var i=this.getSnapTargets(t,n);return V(i,function(o){if(at(o)){at(t)&&e.add("mid",Ti(o));return}if(Ot(o)){if(o.waypoints.length<3)return;var r=o.waypoints.slice(1,-1);V(r,function(a){e.add("mid",a)});return}e.add("mid",Ti(o))}),!Qe(t.x)||!Qe(t.y)||this._elementRegistry.get(t.id)&&e.add("mid",Ti(t)),e},so.prototype.getSnapTargets=function(e,t){return eE(t).filter(function(n){return!h5(n)})};function h5(e){return!!e.hidden}var g1=1500;function Za(e,t){t.invoke(so,this),e.on(["create.move","create.end"],g1,v5),e.on(["create.move","create.end","shape.move.move","shape.move.end"],g1,function(n){var i=n.context,o=i.canExecute,r=i.target,a=o&&(o==="attach"||o.attach);a&&!Ya(n)&&g5(n,r)})}Ne(Za,so),Za.$inject=["eventBus","injector"],Za.prototype.initSnap=function(e){var t=so.prototype.initSnap.call(this,e),n=e.shape,i=!!this._elementRegistry.get(n.id);return V(n.outgoing,function(o){var r=o.waypoints[0];r=r.original||r,t.setSnapOrigin(o.id+"-docking",y1(r,i,e))}),V(n.incoming,function(o){var r=o.waypoints[o.waypoints.length-1];r=r.original||r,t.setSnapOrigin(o.id+"-docking",y1(r,i,e))}),M(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},Za.prototype.addSnapTargetPoints=function(e,t,n){so.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);V(i,function(r){(y5(r)||m5([t,r],"bpmn:TextAnnotation"))&&(e.add("top-left",Q0(r)),e.add("bottom-right",J0(r)))});var o=this._elementRegistry;return V(t.incoming,function(r){if(o.get(t.id)){m1(i,r.source)||e.add("mid",Je(r.source));var a=r.waypoints[0];e.add(r.id+"-docking",a.original||a)}}),V(t.outgoing,function(r){if(o.get(t.id)){m1(i,r.target)||e.add("mid",Je(r.target));var a=r.waypoints[r.waypoints.length-1];e.add(r.id+"-docking",a.original||a)}}),M(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},Za.prototype.getSnapTargets=function(e,t){return so.prototype.getSnapTargets.call(this,e,t).filter(function(n){return!M(n,"bpmn:Lane")})};function g5(e,t){var n=qe(t),i=mx(e,t),o=e.context,r=o.shape,a;r.parent?a={x:0,y:0}:a=Je(r),/top/.test(i)?fn(e,"y",n.top-a.y):/bottom/.test(i)&&fn(e,"y",n.bottom-a.y),/left/.test(i)?fn(e,"x",n.left-a.x):/right/.test(i)&&fn(e,"x",n.right-a.x)}function m5(e,t){return e.every(function(n){return M(n,t)})}function y5(e){return M(e,"bpmn:SubProcess")&&ht(e)?!0:M(e,"bpmn:Participant")}function v5(e){var t=e.context,n=t.createConstraints;if(n){var i=n.top,o=n.right,r=n.bottom,a=n.left;(a&&a>=e.x||o&&o<=e.x)&&fn(e,"x",e.x),(i&&i>=e.y||r&&r<=e.y)&&fn(e,"y",e.y)}}function m1(e,t){return e.indexOf(t)!==-1}function y1(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}var b5=1250;function bc(e,t){var n=this;e.on(["resize.start"],function(i){n.initSnap(i)}),e.on(["resize.move","resize.end"],b5,function(i){var o=i.context,r=o.shape,a=r.parent,s=o.direction,c=o.snapContext;if(!(i.originalEvent&&ai(i.originalEvent))&&!Ya(i)){var l=c.pointsForTarget(a);l.initialized||(l=n.addSnapTargetPoints(l,r,a,s),l.initialized=!0),_5(s)&&fn(i,"x",i.x),E5(s)&&fn(i,"y",i.y),t.snap(i,l)}}),e.on(["resize.cleanup"],function(){t.hide()})}bc.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,o=t.snapContext;o||(o=t.snapContext=new mr);var r=v1(n,i);return o.setSnapOrigin("corner",{x:r.x-e.x,y:r.y-e.y}),o},bc.prototype.addSnapTargetPoints=function(e,t,n,i){var o=this.getSnapTargets(t,n);return V(o,function(r){e.add("corner",J0(r)),e.add("corner",Q0(r))}),e.add("corner",v1(t,i)),e},bc.$inject=["eventBus","snapping"],bc.prototype.getSnapTargets=function(e,t){return eE(t).filter(function(n){return!x5(n,e)&&!Ot(n)&&!w5(n)&&!at(n)})};function v1(e,t){var n=Je(e),i=qe(e),o={x:n.x,y:n.y};return t.indexOf("n")!==-1?o.y=i.top:t.indexOf("s")!==-1&&(o.y=i.bottom),t.indexOf("e")!==-1?o.x=i.right:t.indexOf("w")!==-1&&(o.x=i.left),o}function x5(e,t){return e.host===t}function w5(e){return!!e.hidden}function _5(e){return e==="n"||e==="s"}function E5(e){return e==="e"||e==="w"}var S5=7,R5=1e3;function yr(e){this._canvas=e,this._asyncHide=Np(Kn(this.hide,this),R5)}yr.$inject=["canvas"],yr.prototype.snap=function(e,t){var n=e.context,i=n.snapContext,o=i.getSnapLocations(),r={x:Ya(e,"x"),y:Ya(e,"y")};V(o,function(a){var s=i.getSnapOrigin(a),c={x:e.x+s.x,y:e.y+s.y};if(V(["x","y"],function(l){var u;r[l]||(u=t.snap(c,a,l,S5),u!==void 0&&(r[l]={value:u,originValue:u-s[l]}))}),r.x&&r.y)return!1}),this.showSnapLine("vertical",r.x&&r.x.value),this.showSnapLine("horizontal",r.y&&r.y.value),V(["x","y"],function(a){var s=r[a];mn(s)&&fn(e,a,s.originValue)})},yr.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=He("path");return Ie(n,{d:"M0,0 L0,0"}),dt(n).add("djs-snap-line"),tt(t,n),{update:function(i){Qe(i)?e==="horizontal"?Ie(n,{d:"M-100000,"+i+" L+100000,"+i,display:""}):Ie(n,{d:"M "+i+",-100000 L "+i+", +100000",display:""}):Ie(n,{display:"none"})}}},yr.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},yr.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},yr.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},yr.prototype.hide=function(){V(this._snapLines,function(e){e.update()})};const C5={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",so],resizeSnapping:["type",bc],snapping:["type",yr]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",p1],createMoveSnapping:["type",Za]};var b1=300;function ot(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=Ct(ot.INPUT_SELECTOR,this._container),this._resultsContainer=Ct(ot.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}ot.$inject=["canvas","eventBus","selection","translate"],ot.prototype._bindEvents=function(){var e=this;function t(n,i,o,r){e._eventMaps.push({el:n,type:o,listener:ii.bind(n,i,o,r)})}t(document,"html","click",function(n){e.close(!1)}),t(this._container,ot.INPUT_SELECTOR,"click",function(n){n.stopPropagation(),n.delegateTarget.focus()}),t(this._container,ot.RESULT_SELECTOR,"mouseover",function(n){n.stopPropagation(),e._scrollToNode(n.delegateTarget),e._preselect(n.delegateTarget)}),t(this._container,ot.RESULT_SELECTOR,"click",function(n){n.stopPropagation(),e._select(n.delegateTarget)}),t(this._container,ot.INPUT_SELECTOR,"keydown",function(n){vn("ArrowUp",n)&&n.preventDefault(),vn("ArrowDown",n)&&n.preventDefault()}),t(this._container,ot.INPUT_SELECTOR,"keyup",function(n){if(vn("Escape",n))return e.close();if(vn("Enter",n)){var i=e._getCurrentResult();return i?e._select(i):e.close(!1)}if(vn("ArrowUp",n))return e._scrollToDirection(!0);if(vn("ArrowDown",n))return e._scrollToDirection();vn(["ArrowLeft","ArrowRight"],n)||e._search(n.delegateTarget.value)})},ot.prototype._unbindEvents=function(){this._eventMaps.forEach(function(e){ii.unbind(e.el,e.type,e.listener)})},ot.prototype._search=function(e){var t=this;if(this._clearResults(),!!e.trim()){var n=this._searchProvider.find(e);if(n=n.filter(function(o){return!t._canvas.getRootElements().includes(o.element)}),!n.length){this._selection.select(null);return}n.forEach(function(o){var r=o.element.id,a=t._createResultNode(o,r);t._results[r]={element:o.element,node:a}});var i=Ct(ot.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}},ot.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},ot.prototype._scrollToNode=function(e){if(!(!e||e===this._getCurrentResult())){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},ot.prototype._clearResults=function(){fl(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},ot.prototype._getCurrentResult=function(){return Ct(ot.RESULT_SELECTED_SELECTOR,this._resultsContainer)},ot.prototype._createResultNode=function(e,t){var n=jt(ot.RESULT_HTML);return e.primaryTokens.length>0&&x1(n,e.primaryTokens,ot.RESULT_PRIMARY_HTML),x1(n,e.secondaryTokens,ot.RESULT_SECONDARY_HTML),Cn(n,ot.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},ot.prototype.registerProvider=function(e){this._searchProvider=e},ot.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._cachedRootElement=this._canvas.getRootElement(),this._cachedSelection=this._selection.get(),this._cachedViewbox=this._canvas.viewbox(),this._selection.select(null),this._bindEvents(),this._open=!0,At(this._canvas.getContainer()).add("djs-search-open"),At(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},ot.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,At(this._canvas.getContainer()).remove("djs-search-open"),At(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},ot.prototype.toggle=function(){this.isOpen()?this.close():this.open()},ot.prototype.isOpen=function(){return this._open},ot.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&At(t).remove(ot.RESULT_SELECTED_CLASS);var n=Cn(e,ot.RESULT_ID_ATTRIBUTE),i=this._results[n].element;At(e).add(ot.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:b1}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},ot.prototype._select=function(e){var t=Cn(e,ot.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:b1}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},ot.prototype._getBoxHtml=function(){const e=jt(ot.BOX_HTML),t=Ct(ot.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e};function x1(e,t,n){var i=M5(t),o=jt(n);o.innerHTML=i,e.appendChild(o)}function M5(e){var t="";return e.forEach(function(n){var i=A_(n.value||n.matched||n.normal),o=n.match||n.matched;o?t+='<b class="'+ot.RESULT_HIGHLIGHT_CLASS+'">'+i+"</b>":t+=i}),t!==""?t:null}ot.CONTAINER_SELECTOR=".djs-search-container",ot.INPUT_SELECTOR=".djs-search-input input",ot.RESULTS_CONTAINER_SELECTOR=".djs-search-results",ot.RESULT_SELECTOR=".djs-search-result",ot.RESULT_SELECTED_CLASS="djs-search-result-selected",ot.RESULT_SELECTED_SELECTOR="."+ot.RESULT_SELECTED_CLASS,ot.RESULT_ID_ATTRIBUTE="data-result-id",ot.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",ot.BOX_HTML=`<div class="djs-search-container djs-scrollable">
335
+ </svg>`},BN=900;function hc(e,t,n,i){this._distributeElements=t,this._translate=n,this._popupMenu=e,this._rules=i,e.registerProvider("align-elements",BN,this)}hc.$inject=["popupMenu","distributeElements","translate","rules"],hc.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&Y(t,this._getEntries(e)),t},hc.prototype._isAllowed=function(e){return this._rules.allowed("elements.distribute",{elements:e})},hc.prototype._getEntries=function(e){var t=this._distributeElements,n=this._translate,i=this._popupMenu,o={"distribute-elements-horizontal":{group:"distribute",title:n("Distribute elements horizontally"),className:"bjs-align-elements-menu-entry",imageHtml:yE.horizontal,action:function(r,a){t.trigger(e,"horizontal"),i.close()}},"distribute-elements-vertical":{group:"distribute",title:n("Distribute elements vertically"),imageHtml:yE.vertical,action:function(r,a){t.trigger(e,"vertical"),i.close()}}};return o};const NN={__depends__:[rg,IN],__init__:["bpmnDistributeElements","distributeElementsMenuProvider"],bpmnDistributeElements:["type",ip],distributeElementsMenuProvider:["type",hc]};var vE="is not a registered action",$N="is already registered";function Oi(e,t){this._eventBus=e,this._actions={};var n=this;e.on("diagram.init",function(){n._registerDefaultActions(t),e.fire("editorActions.init",{editorActions:n})})}Oi.$inject=["eventBus","injector"],Oi.prototype._registerDefaultActions=function(e){var t=e.get("commandStack",!1),n=e.get("modeling",!1),i=e.get("selection",!1),o=e.get("zoomScroll",!1),r=e.get("copyPaste",!1),a=e.get("canvas",!1),s=e.get("rules",!1),c=e.get("keyboardMove",!1),l=e.get("keyboardMoveSelection",!1);t&&(this.register("undo",function(){t.undo()}),this.register("redo",function(){t.redo()})),r&&i&&this.register("copy",function(){var u=i.get();if(u.length)return r.copy(u)}),r&&i&&this.register("duplicate",function(){var u=i.get();if(u.length)return r.duplicate(u)}),r&&this.register("paste",function(){r.paste()}),r&&i&&s&&this.register("cut",function(){var u=i.get();if(u.length){var p=s.allowed("elements.delete",{elements:u});if(p!==!1){var f=Ze(p)?p:u;return r.cut(f.slice())}}}),o&&this.register("stepZoom",function(u){o.stepZoom(u.value)}),a&&this.register("zoom",function(u){a.zoom(u.value)}),n&&i&&s&&this.register("removeSelection",function(){var u=i.get();if(u.length){var p=s.allowed("elements.delete",{elements:u}),f;p!==!1&&(Ze(p)?f=p:f=u,f.length&&n.removeElements(f.slice()))}}),c&&this.register("moveCanvas",function(u){c.moveCanvas(u)}),l&&this.register("moveSelection",function(u){l.moveSelection(u.direction,u.accelerated)})},Oi.prototype.trigger=function(e,t){if(!this._actions[e])throw gg(e,vE);var n=this._eventBus.fire("editorActions.allowed",{action:e,opts:t});if(n!==!1)return this._actions[e](t)},Oi.prototype.register=function(e,t){var n=this;if(typeof e=="string")return this._registerAction(e,t);V(e,function(i,o){n._registerAction(o,i)})},Oi.prototype._registerAction=function(e,t){if(this.isRegistered(e))throw gg(e,$N);this._actions[e]=t},Oi.prototype.unregister=function(e){if(!this.isRegistered(e))throw gg(e,vE);this._actions[e]=void 0},Oi.prototype.getActions=function(){return Object.keys(this._actions)},Oi.prototype.isRegistered=function(e){return!!this._actions[e]};function gg(e,t){return new Error(e+" "+t)}const FN={__init__:["editorActions"],editorActions:["type",Oi]};function op(e){e.invoke(Oi,this)}Ne(op,Oi),op.$inject=["injector"],op.prototype._registerDefaultActions=function(e){Oi.prototype._registerDefaultActions.call(this,e);var t=e.get("canvas",!1),n=e.get("elementRegistry",!1),i=e.get("selection",!1),o=e.get("spaceTool",!1),r=e.get("lassoTool",!1),a=e.get("handTool",!1),s=e.get("globalConnect",!1),c=e.get("distributeElements",!1),l=e.get("alignElements",!1),u=e.get("directEditing",!1),p=e.get("searchPad",!1),f=e.get("modeling",!1),d=e.get("contextPad",!1);t&&n&&i&&this._registerAction("selectElements",function(){var g=t.getRootElement(),h=n.filter(function(m){return m!==g});return i.select(h),h}),o&&this._registerAction("spaceTool",function(){o.toggle()}),r&&this._registerAction("lassoTool",function(){r.toggle()}),a&&this._registerAction("handTool",function(){a.toggle()}),s&&this._registerAction("globalConnectTool",function(){s.toggle()}),i&&c&&this._registerAction("distributeElements",function(g){var h=i.get(),m=g.type;h.length&&c.trigger(h,m)}),i&&l&&this._registerAction("alignElements",function(g){var h=i.get(),m=[],w=g.type;h.length&&(m=ct(h,function(y){return!M(y,"bpmn:Lane")}),l.trigger(m,w))}),i&&f&&this._registerAction("setColor",function(g){var h=i.get();h.length&&f.setColor(h,g)}),i&&u&&this._registerAction("directEditing",function(){var g=i.get();g.length&&u.activate(g[0])}),p&&this._registerAction("find",function(){p.toggle()}),t&&f&&this._registerAction("moveToOrigin",function(){var g=t.getRootElement(),h,m;M(g,"bpmn:Collaboration")?m=n.filter(function(w){return M(w.parent,"bpmn:Collaboration")}):m=n.filter(function(w){return w!==g&&!M(w.parent,"bpmn:SubProcess")}),h=cn(m),f.moveElements(m,{x:-h.x,y:-h.y},g)}),i&&d&&this._registerAction("replaceElement",function(g){d.triggerEntry("replace","click",g)})};const jN={__depends__:[FN],editorActions:["type",op]};function bE(e){e.on(["create.init","shape.move.init"],function(t){var n=t.context,i=t.shape;st(i,["bpmn:Participant","bpmn:SubProcess","bpmn:TextAnnotation"])&&(n.gridSnappingContext||(n.gridSnappingContext={}),n.gridSnappingContext.snapLocation="top-left")})}bE.$inject=["eventBus"];function Zr(e,t){we.call(this,e),this._gridSnapping=t;var n=this;this.preExecute("shape.resize",function(i){var o=i.context,r=o.hints||{},a=r.autoResize;if(a){var s=o.shape,c=o.newBounds;ei(a)?o.newBounds=n.snapComplex(c,a):o.newBounds=n.snapSimple(s,c)}})}Zr.$inject=["eventBus","gridSnapping","modeling"],Ne(Zr,we),Zr.prototype.snapSimple=function(e,t){var n=this._gridSnapping;return t.width=n.snapValue(t.width,{min:t.width}),t.height=n.snapValue(t.height,{min:t.height}),t.x=e.x+e.width/2-t.width/2,t.y=e.y+e.height/2-t.height/2,t},Zr.prototype.snapComplex=function(e,t){return/w|e/.test(t)&&(e=this.snapHorizontally(e,t)),/n|s/.test(t)&&(e=this.snapVertically(e,t)),e},Zr.prototype.snapHorizontally=function(e,t){var n=this._gridSnapping,i=/w/.test(t),o=/e/.test(t),r={};return r.width=n.snapValue(e.width,{min:e.width}),o&&(i?(r.x=n.snapValue(e.x,{max:e.x}),r.width+=n.snapValue(e.x-r.x,{min:e.x-r.x})):e.x=e.x+e.width-r.width),Y(e,r),e},Zr.prototype.snapVertically=function(e,t){var n=this._gridSnapping,i=/n/.test(t),o=/s/.test(t),r={};return r.height=n.snapValue(e.height,{min:e.height}),i&&(o?(r.y=n.snapValue(e.y,{max:e.y}),r.height+=n.snapValue(e.y-r.y,{min:e.y-r.y})):e.y=e.y+e.height-r.height),Y(e,r),e};var HN=2e3;function xE(e,t){e.on(["spaceTool.move","spaceTool.end"],HN,function(n){var i=n.context;if(i.initialized){var o=i.axis,r;o==="x"?(r=t.snapValue(n.dx),n.x=n.x+r-n.dx,n.dx=r):(r=t.snapValue(n.dy),n.y=n.y+r-n.dy,n.dy=r)}})}xE.$inject=["eventBus","gridSnapping"];const zN={__init__:["gridSnappingResizeBehavior","gridSnappingSpaceToolBehavior"],gridSnappingResizeBehavior:["type",Zr],gridSnappingSpaceToolBehavior:["type",xE]};var rp=10;function mg(e,t,n){return n||(n="round"),Math[n](e/t)*t}var GN=1200,VN=800;function fr(e,t,n){var i=!n||n.active!==!1;this._eventBus=t;var o=this;t.on("diagram.init",VN,function(){o.setActive(i)}),t.on(["create.move","create.end","bendpoint.move.move","bendpoint.move.end","connect.move","connect.end","connectionSegment.move.move","connectionSegment.move.end","resize.move","resize.end","shape.move.move","shape.move.end"],GN,function(r){var a=r.originalEvent;if(!(!o.active||a&&ai(a))){var s=r.context,c=s.gridSnappingContext;c||(c=s.gridSnappingContext={}),["x","y"].forEach(function(l){var u={},p=UN(r,l,e);p&&(u.offset=p);var f=WN(r,l);f&&Y(u,f),Ya(r,l)||o.snapEvent(r,l,u)})}})}fr.prototype.snapEvent=function(e,t,n){var i=this.snapValue(e[t],n);fn(e,t,i)},fr.prototype.getGridSpacing=function(){return rp},fr.prototype.snapValue=function(e,t){var n=0;t&&t.offset&&(n=t.offset),e+=n,e=mg(e,rp);var i,o;return t&&t.min&&(i=t.min,Qe(i)&&(i=mg(i+n,rp,"ceil"),e=Math.max(e,i))),t&&t.max&&(o=t.max,Qe(o)&&(o=mg(o+n,rp,"floor"),e=Math.min(e,o))),e-=n,e},fr.prototype.isActive=function(){return this.active},fr.prototype.setActive=function(e){this.active=e,this._eventBus.fire("gridSnapping.toggle",{active:e})},fr.prototype.toggleActive=function(){this.setActive(!this.active)},fr.$inject=["elementRegistry","eventBus","config.gridSnapping"];function WN(e,t){var n=e.context,i=n.createConstraints,o=n.resizeConstraints||{},r=n.gridSnappingContext,a=r.snapConstraints;if(a&&a[t])return a[t];a||(a=r.snapConstraints={}),a[t]||(a[t]={});var s=n.direction;i&&(ap(t)?(a.x.min=i.left,a.x.max=i.right):(a.y.min=i.top,a.y.max=i.bottom));var c=o.min,l=o.max;return c&&(ap(t)?_E(s)?a.x.max=c.left:a.x.min=c.right:wE(s)?a.y.max=c.top:a.y.min=c.bottom),l&&(ap(t)?_E(s)?a.x.min=l.left:a.x.max=l.right:wE(s)?a.y.min=l.top:a.y.max=l.bottom),a[t]}function UN(e,t,n){var i=e.context,o=e.shape,r=i.gridSnappingContext,a=r.snapLocation,s=r.snapOffset;return s&&Qe(s[t])||(s||(s=r.snapOffset={}),Qe(s[t])||(s[t]=0),!o)||(n.get(o.id)||(ap(t)?s[t]+=o[t]+o.width/2:s[t]+=o[t]+o.height/2),!a)||(t==="x"?/left/.test(a)?s[t]-=o.width/2:/right/.test(a)&&(s[t]+=o.width/2):/top/.test(a)?s[t]-=o.height/2:/bottom/.test(a)&&(s[t]+=o.height/2)),s[t]}function ap(e){return e==="x"}function wE(e){return e.indexOf("n")!==-1}function _E(e){return e.indexOf("w")!==-1}const qN={__depends__:[zN],__init__:["gridSnapping"],gridSnapping:["type",fr]};var YN=2e3;function EE(e,t,n){e.on("autoPlace",YN,function(i){var o=i.source,r=Je(o),a=i.shape,s=a_(o,a,n);return["x","y"].forEach(function(c){var l={};s[c]!==r[c]&&(s[c]>r[c]?l.min=s[c]:l.max=s[c],M(a,"bpmn:TextAnnotation")&&(KN(c)?l.offset=-a.width/2:l.offset=-a.height/2),s[c]=t.snapValue(s[c],l))}),s})}EE.$inject=["eventBus","gridSnapping","elementRegistry"];function KN(e){return e==="x"}var XN=1750;function SE(e,t,n){t.on(["create.start","shape.move.start"],XN,function(i){var o=i.context,r=o.shape,a=e.getRootElement();if(!(!M(r,"bpmn:Participant")||!M(a,"bpmn:Process")||!a.children.length)){var s=o.createConstraints;s&&(r.width=n.snapValue(r.width,{min:r.width}),r.height=n.snapValue(r.height,{min:r.height}))}})}SE.$inject=["canvas","eventBus","gridSnapping"];var ZN=3e3;function sp(e,t,n){we.call(this,e),this._gridSnapping=t;var i=this;this.postExecuted(["connection.create","connection.layout"],ZN,function(o){var r=o.context,a=r.connection,s=r.hints||{},c=a.waypoints;s.connectionStart||s.connectionEnd||s.createElementsBehavior===!1||QN(c)&&n.updateWaypoints(a,i.snapMiddleSegments(c))})}sp.$inject=["eventBus","gridSnapping","modeling"],Ne(sp,we),sp.prototype.snapMiddleSegments=function(e){var t=this._gridSnapping,n;e=e.slice();for(var i=1;i<e.length-2;i++)n=t$(t,e[i],e[i+1]),e[i]=n[0],e[i+1]=n[1];return e};function QN(e){return e.length>3}function JN(e){return e==="h"}function e$(e){return e==="v"}function t$(e,t,n){var i=vo(t,n),o={};return JN(i)&&(o.y=e.snapValue(t.y)),e$(i)&&(o.x=e.snapValue(t.x)),("x"in o||"y"in o)&&(t=Y({},t,o),n=Y({},n,o)),[t,n]}const n$={__depends__:[qN,{__init__:["gridSnappingAutoPlaceBehavior","gridSnappingParticipantBehavior","gridSnappingLayoutConnectionBehavior"],gridSnappingAutoPlaceBehavior:["type",EE],gridSnappingParticipantBehavior:["type",SE],gridSnappingLayoutConnectionBehavior:["type",sp]}],__init__:["bpmnGridSnapping"],bpmnGridSnapping:["type",bE]};var i$=30,RE=30;function gc(e,t){this._interactionEvents=t;var n=this;e.on(["interactionEvents.createHit","interactionEvents.updateHit"],function(i){var o=i.element,r=i.gfx;if(M(o,"bpmn:Lane"))return n._createParticipantHit(o,r);if(M(o,"bpmn:Participant"))return ht(o)?n._createParticipantHit(o,r):n._createDefaultHit(o,r);if(M(o,"bpmn:SubProcess"))return ht(o)?n._createSubProcessHit(o,r):n._createDefaultHit(o,r)})}gc.$inject=["eventBus","interactionEvents"],gc.prototype._createDefaultHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createDefaultHit(e,t),!0},gc.prototype._createParticipantHit=function(e,t){this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height});var n=En(e)?{width:i$,height:e.height}:{width:e.width,height:RE};return this._interactionEvents.createBoxHit(t,"all",n),!0},gc.prototype._createSubProcessHit=function(e,t){return this._interactionEvents.removeHits(t),this._interactionEvents.createBoxHit(t,"no-move",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"click-stroke",{width:e.width,height:e.height}),this._interactionEvents.createBoxHit(t,"all",{width:e.width,height:RE}),!0};const o$={__init__:["bpmnInteractionEvents"],bpmnInteractionEvents:["type",gc]};function cp(e){e.invoke(Ha,this)}Ne(cp,Ha),cp.$inject=["injector"],cp.prototype.registerBindings=function(e,t){Ha.prototype.registerBindings.call(this,e,t);function n(i,o){t.isRegistered(i)&&e.addListener(o)}n("selectElements",function(i){var o=i.keyEvent;if(e.isKey(["a","A"],o)&&e.isCmd(o))return t.trigger("selectElements"),!0}),n("find",function(i){var o=i.keyEvent;if(e.isKey(["f","F"],o)&&e.isCmd(o))return t.trigger("find"),!0}),n("spaceTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["s","S"],o))return t.trigger("spaceTool"),!0}),n("lassoTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["l","L"],o))return t.trigger("lassoTool"),!0}),n("handTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["h","H"],o))return t.trigger("handTool"),!0}),n("globalConnectTool",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["c","C"],o))return t.trigger("globalConnectTool"),!0}),n("directEditing",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["e","E"],o))return t.trigger("directEditing"),!0}),n("replaceElement",function(i){var o=i.keyEvent;if(!e.hasModifier(o)&&e.isKey(["r","R"],o))return t.trigger("replaceElement",o),!0})};const r$={__depends__:[Vh],__init__:["keyboardBindings"],keyboardBindings:["type",cp]};var a$={moveSpeed:1,moveSpeedAccelerated:10},s$=1500,CE="left",ME="up",AE="right",PE="down",c$={ArrowLeft:CE,Left:CE,ArrowUp:ME,Up:ME,ArrowRight:AE,Right:AE,ArrowDown:PE,Down:PE},l$={left:function(e){return{x:-e,y:0}},up:function(e){return{x:0,y:-e}},right:function(e){return{x:e,y:0}},down:function(e){return{x:0,y:e}}};function TE(e,t,n,i,o){var r=this;this._config=Y({},a$,e||{}),t.addListener(s$,function(a){var s=a.keyEvent,c=c$[s.key];if(c&&!t.isCmd(s)){var l=t.isShift(s);return r.moveSelection(c,l),!0}}),this.moveSelection=function(a,s){var c=o.get();if(c.length){var l=this._config[s?"moveSpeedAccelerated":"moveSpeed"],u=l$[a](l),p=i.allowed("elements.move",{shapes:c,hints:{keyboardMove:!0}});p&&n.moveElements(c,u)}}}TE.$inject=["config.keyboardMoveSelection","keyboard","modeling","rules","selection"];const u$={__depends__:[Vh,Mi],__init__:["keyboardMoveSelection"],keyboardMoveSelection:["type",TE]};var kE=10;function mc(e,t,n,i){this._dragging=i,this._rules=t;var o=this;function r(c,l){var u=c.shape,p=c.direction,f=c.resizeConstraints,d;c.delta=l,d=K2(u,p,l),c.newBounds=Z2(d,f),c.canExecute=o.canResize(c)}function a(c){var l=c.resizeConstraints,u=c.minBounds;l===void 0&&(u===void 0&&(u=o.computeMinResizeBox(c)),c.resizeConstraints={min:qe(u)})}function s(c){var l=c.shape,u=c.canExecute,p=c.newBounds;if(u){if(p=Ov(p),!p$(l,p))return;n.resizeShape(l,p)}}e.on("resize.start",function(c){a(c.context)}),e.on("resize.move",function(c){var l={x:c.dx,y:c.dy};r(c.context,l)}),e.on("resize.end",function(c){s(c.context)})}mc.prototype.canResize=function(e){var t=this._rules,n=Ni(e,["newBounds","shape","delta","direction"]);return t.allowed("shape.resize",n)},mc.prototype.activate=function(e,t,n){var i=this._dragging,o,r;if(typeof n=="string"&&(n={direction:n}),o=Y({shape:t},n),r=o.direction,!r)throw new Error("must provide a direction (n|w|s|e|nw|se|ne|sw)");i.init(e,OE(t,r),"resize",{autoActivate:!0,cursor:f$(r),data:{shape:t,context:o}})},mc.prototype.computeMinResizeBox=function(e){var t=e.shape,n=e.direction,i,o;return i=e.minDimensions||{width:kE,height:kE},o=bb(t,e.childrenBoxPadding),Q2(n,t,i,o)},mc.$inject=["eventBus","rules","modeling","dragging"];function p$(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function OE(e,t){var n=Je(e),i=qe(e),o={x:n.x,y:n.y};return t.indexOf("n")!==-1?o.y=i.top:t.indexOf("s")!==-1&&(o.y=i.bottom),t.indexOf("e")!==-1?o.x=i.right:t.indexOf("w")!==-1&&(o.x=i.left),o}function f$(e){var t="resize-";return e==="n"||e==="s"?t+"ns":e==="e"||e==="w"?t+"ew":e==="nw"||e==="se"?t+"nwse":t+"nesw"}var DE="djs-resizing",LE="resize-not-ok",d$=500;function IE(e,t,n){function i(r){var a=r.shape,s=r.newBounds,c=r.frame;c||(c=r.frame=n.addFrame(a,t.getActiveLayer()),t.addMarker(a,DE)),s.width>5&&Ie(c,{x:s.x,width:s.width}),s.height>5&&Ie(c,{y:s.y,height:s.height}),r.canExecute?dt(c).remove(LE):dt(c).add(LE)}function o(r){var a=r.shape,s=r.frame;s&&sn(r.frame),t.removeMarker(a,DE)}e.on("resize.move",d$,function(r){i(r.context)}),e.on("resize.cleanup",function(r){o(r.context)})}IE.$inject=["eventBus","canvas","previewSupport"];var lp=-6,up=8,pp=20,yc="djs-resizer",h$=["n","w","s","e","nw","ne","se","sw"];function dr(e,t,n,i){this._resize=i,this._canvas=t;var o=this;e.on("selection.changed",function(r){var a=r.newSelection;o.removeResizers(),a.length===1&&V(a,Kn(o.addResizer,o))}),e.on("shape.changed",function(r){var a=r.element;n.isSelected(a)&&(o.removeResizers(),o.addResizer(a))})}dr.prototype.makeDraggable=function(e,t,n){var i=this._resize;function o(r){tr(r)&&i.activate(r,e,n)}Ve.bind(t,"mousedown",o),Ve.bind(t,"touchstart",o)},dr.prototype._createResizer=function(e,t,n,i){var o=this._getResizersParent(),r=g$(i),a=He("g");dt(a).add(yc),dt(a).add(yc+"-"+e.id),dt(a).add(yc+"-"+i),tt(o,a);var s=He("rect");Ie(s,{x:-up/2+r.x,y:-up/2+r.y,width:up,height:up}),dt(s).add(yc+"-visual"),tt(a,s);var c=He("rect");return Ie(c,{x:-pp/2+r.x,y:-pp/2+r.y,width:pp,height:pp}),dt(c).add(yc+"-hit"),tt(a,c),_l(a,t,n),a},dr.prototype.createResizer=function(e,t){var n=OE(e,t),i=this._createResizer(e,n.x,n.y,t);this.makeDraggable(e,i,t)},dr.prototype.addResizer=function(e){var t=this;Ot(e)||V(h$,function(n){t._resize.canResize({shape:e,direction:n})&&t.createResizer(e,n)})},dr.prototype.removeResizers=function(){var e=this._getResizersParent();bs(e)},dr.prototype._getResizersParent=function(){return this._canvas.getLayer("resizers")},dr.$inject=["eventBus","canvas","selection","resize"];function g$(e){var t={x:0,y:0};return e.indexOf("e")!==-1?t.x=-lp:e.indexOf("w")!==-1&&(t.x=lp),e.indexOf("s")!==-1?t.y=-lp:e.indexOf("n")!==-1&&(t.y=lp),t}const BE={__depends__:[io,So,Na],__init__:["resize","resizePreview","resizeHandles"],resize:["type",mc],resizePreview:["type",IE],resizeHandles:["type",dr]};var m$=2e3;function vc(e,t,n,i,o,r,a){this._bpmnFactory=t,this._canvas=n,this._modeling=o,this._textRenderer=a,i.registerProvider(this),e.on("element.dblclick",function(c){s(c.element,!0)}),e.on(["autoPlace.start","canvas.viewbox.changing","drag.init","element.mousedown","popupMenu.open","root.set","selection.changed"],function(){i.isActive()&&i.complete()}),e.on(["shape.remove","connection.remove"],m$,function(c){i.isActive(c.element)&&i.cancel()}),e.on(["commandStack.changed"],function(c){i.isActive()&&i.cancel()}),e.on("directEditing.activate",function(c){r.removeResizers()}),e.on("create.end",500,function(c){var l=c.context,u=l.shape,p=c.context.canExecute,f=c.isTouch;f||p&&(l.hints&&l.hints.createElementsBehavior===!1||s(u))}),e.on("autoPlace.end",500,function(c){s(c.shape)});function s(c,l){(l||st(c,["bpmn:Activity","bpmn:Event","bpmn:TextAnnotation","bpmn:Participant"]))&&i.activate(c)}}vc.$inject=["eventBus","bpmnFactory","canvas","directEditing","modeling","resizeHandles","textRenderer"],vc.prototype.activate=function(e){var t=vi(e);if(t!==void 0){var n={text:t},i=this.getEditingBBox(e);Y(n,i);var o={},r=n.style||{};return Y(r,{backgroundColor:null,border:null}),(st(e,["bpmn:Task","bpmn:Participant","bpmn:Lane","bpmn:CallActivity"])||NE(e))&&Y(o,{centerVertically:!0}),Zo(e)&&(Y(o,{resizable:!0,autoResize:!0}),Y(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),M(e,"bpmn:TextAnnotation")&&(Y(o,{resizable:!0,autoResize:!0}),Y(r,{backgroundColor:"#ffffff",border:"1px solid #ccc"})),Y(n,{options:o,style:r}),n}},vc.prototype.getEditingBBox=function(e){var t=this._canvas,n=e.label||e,i=t.getAbsoluteBBox(n),o={x:i.x+i.width/2,y:i.y+i.height/2},r={x:i.x,y:i.y},a=t.zoom(),s=this._textRenderer.getDefaultStyle(),c=this._textRenderer.getExternalStyle(),l=c.fontSize*a,u=c.lineHeight,p=s.fontSize*a,f=s.lineHeight,d={fontFamily:this._textRenderer.getDefaultStyle().fontFamily,fontWeight:this._textRenderer.getDefaultStyle().fontWeight};if(M(e,"bpmn:Lane")||b$(e)){var g=En(e),h=g?{width:i.height,height:30*a,x:i.x-i.height/2+15*a,y:o.y-30*a/2}:{width:i.width,height:30*a};Y(r,h),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:g?"rotate(-90deg)":null})}if(v$(e)){var m=En(e),w=m?{width:i.width,height:i.height}:{width:i.height,height:i.width,x:o.x-i.height/2,y:o.y-i.width/2};Y(r,w),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px",transform:m?null:"rotate(-90deg)"})}(st(e,["bpmn:Task","bpmn:CallActivity"])||NE(e))&&(Y(r,{width:i.width,height:i.height}),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"})),y$(e)&&(Y(r,{width:i.width,x:i.x}),Y(d,{fontSize:p+"px",lineHeight:f,paddingTop:7*a+"px",paddingBottom:7*a+"px",paddingLeft:5*a+"px",paddingRight:5*a+"px"}));var y=1,v=i.width+2*y;if(n.labelTarget&&(Y(r,{width:v,height:i.height+2*y,x:i.x-y,y:i.y-y}),Y(d,{fontSize:l+"px",lineHeight:u})),Zo(n)&&!Rl(n)&&!at(n)){var x=Jf(e),E=t.getAbsoluteBBox({x:x.x,y:x.y,width:0,height:0}),A=l,I=Nr.width*a+2*y;Y(r,{width:I,height:A+2*y,x:E.x-I/2,y:E.y-A/2-y}),Y(d,{fontSize:l+"px",lineHeight:u})}return M(e,"bpmn:TextAnnotation")&&(Y(r,{width:i.width+2*y,height:i.height+2*y,x:i.x-y,y:i.y-y,minWidth:30*a,minHeight:10*a}),Y(d,{textAlign:"left",paddingTop:Ra*a+"px",paddingBottom:Ra*a+"px",paddingLeft:Ra*a+"px",paddingRight:Ra*a+"px",fontSize:p+"px",lineHeight:f})),{bounds:r,style:d}},vc.prototype.update=function(e,t,n,i){var o,r;M(e,"bpmn:TextAnnotation")&&(r=this._canvas.getAbsoluteBBox(e),o={x:e.x,y:e.y,width:e.width/r.width*i.width,height:e.height/r.height*i.height}),x$(t)&&(t=null),this._modeling.updateLabel(e,t,o)};function NE(e){return M(e,"bpmn:SubProcess")&&!ht(e)}function y$(e){return M(e,"bpmn:SubProcess")&&ht(e)}function v$(e){return M(e,"bpmn:Participant")&&!ht(e)}function b$(e){return M(e,"bpmn:Participant")&&ht(e)}function x$(e){return!e||!e.trim()}var $E="djs-element-hidden",FE="djs-label-hidden";function jE(e,t,n){var i=this,o=t.getDefaultLayer(),r,a,s;e.on("directEditing.activate",function(c){var l=c.active;if(r=l.element.label||l.element,M(r,"bpmn:TextAnnotation")){a=t.getAbsoluteBBox(r),s=He("g");var u=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:r.height,position:{mx:0,my:0}}),p=i.path=He("path");Ie(p,{d:u,strokeWidth:2,stroke:w$(r)}),tt(s,p),tt(o,s),Dn(s,r.x,r.y)}M(r,"bpmn:TextAnnotation")||r.labelTarget?t.addMarker(r,$E):(M(r,"bpmn:Task")||M(r,"bpmn:CallActivity")||M(r,"bpmn:SubProcess")||M(r,"bpmn:Participant")||M(r,"bpmn:Lane"))&&t.addMarker(r,FE)}),e.on("directEditing.resize",function(c){if(M(r,"bpmn:TextAnnotation")){var l=c.height,u=c.dy,p=Math.max(r.height/a.height*(l+u),0),f=n.getScaledPath("TEXT_ANNOTATION",{xScaleFactor:1,yScaleFactor:1,containerWidth:r.width,containerHeight:p,position:{mx:0,my:0}});Ie(i.path,{d:f})}}),e.on(["directEditing.complete","directEditing.cancel"],function(c){var l=c.active;l&&(t.removeMarker(l.element.label||l.element,$E),t.removeMarker(r,FE)),r=void 0,a=void 0,s&&(sn(s),s=void 0)})}jE.$inject=["eventBus","canvas","pathMap"];function w$(e,t){var n=mt(e);return n.get("stroke")||t||"black"}const _$={__depends__:[yh,BE,pE],__init__:["labelEditingProvider","labelEditingPreview"],labelEditingProvider:["type",vc],labelEditingPreview:["type",jE]};var E$=500,S$=1e3;function ao(e,t,n){this._eventBus=e,this._elementRegistry=n,this._outlineOffset=5,this._outlineStyle=t.cls("djs-outline",["no-fill"]);var i=this;function o(r){ZP(r)||i.createOutline(r)}e.on("element.hover",function(r){o(r.element)}),e.on("selection.changed",function(r){V(r.newSelection,o)}),e.on(["shape.changed","connection.changed"],E$,function(r){var a=r.element,s=r.gfx,c=Ct(".djs-outline",s);c&&i.updateOutline(a,c)})}ao.prototype.createOutline=function(e){var t=this._elementRegistry.getGraphics(e);if(!t)throw new Error("cannot create outline for non-rendered element");var n=Ct(".djs-outline",t);return n||(n=this.getOutline(e)||this._createOutlineGfx(),tt(t,n),this.updateOutline(e,n)),n},ao.prototype._createOutlineGfx=function(){var e=He("rect");return Ie(e,Y({x:0,y:0,rx:4,width:100,height:100},this._outlineStyle)),e},ao.prototype.updateOutline=function(e,t){e.waypoints?this.updateConnectionOutline(t,e):this.updateShapeOutline(t,e)},ao.prototype.updateShapeOutline=function(e,t){var n=!1,i=this._getProviders();i.length&&V(i,function(o){n=n||o.updateOutline(t,e)}),n||Ie(e,{x:-this._outlineOffset,y:-this._outlineOffset,width:t.width+this._outlineOffset*2,height:t.height+this._outlineOffset*2})},ao.prototype.updateConnectionOutline=function(e,t){var n=cn(t);Ie(e,{x:n.x-this._outlineOffset,y:n.y-this._outlineOffset,width:n.width+this._outlineOffset*2,height:n.height+this._outlineOffset*2})},ao.prototype.registerProvider=function(e,t){t||(t=e,e=S$),this._eventBus.on("outline.getProviders",e,function(n){n.providers.push(t)})},ao.prototype._getProviders=function(){var e=this._eventBus.createEvent({type:"outline.getProviders",providers:[]});return this._eventBus.fire(e),e.providers},ao.prototype.getOutline=function(e){var t,n=this._getProviders();return V(n,function(i){_n(i.getOutline)&&(t=t||i.getOutline(e))}),t},ao.$inject=["eventBus","styles","elementRegistry"];var fp=6;function yg(e,t,n){this._canvas=t;var i=this;e.on("element.changed",function(o){n.isSelected(o.element)&&i._updateMultiSelectionOutline(n.get())}),e.on("selection.changed",function(o){var r=o.newSelection;i._updateMultiSelectionOutline(r)})}yg.prototype._updateMultiSelectionOutline=function(e){var t=this._canvas.getLayer("selectionOutline");bs(t);var n=e.length>1,i=this._canvas.getContainer();if(dt(i)[n?"add":"remove"]("djs-multi-select"),!!n){var o=R$(cn(e)),r=He("rect");Ie(r,Y({rx:3},o)),dt(r).add("djs-selection-outline"),tt(t,r)}},yg.$inject=["eventBus","canvas","selection"];function R$(e){return{x:e.x-fp,y:e.y-fp,width:e.width+fp*2,height:e.height+fp*2}}const vg={__depends__:[Mi],__init__:["outline","multiSelectionOutline"],outline:["type",ao],multiSelectionOutline:["type",yg]},HE=["bpmn:Event","bpmn:SequenceFlow","bpmn:Gateway"],zE={class:"bjs-label-link",stroke:"var(--element-selected-outline-secondary-stroke-color)",strokeDasharray:"5, 5"},C$=15,dp=2;function GE(e,t,n,i,o){const r=t.getLayer("overlays");e.on(["selection.changed","shape.changed"],function(){s()}),e.on("selection.changed",function({newSelection:p}){var d;const f=p.filter(g=>st(g,HE));if(f.length===1){const g=f[0];at(g)?a(g,g.labelTarget):(d=g.labels)!=null&&d.length&&a(g.labels[0],g)}if(f.length===2){const g=f.find(at),h=f.find(m=>{var w;return(w=m.labels)==null?void 0:w.includes(g)});g&&h&&a(g,h)}}),e.on("shape.changed",function({element:p}){var f;!st(p,HE)||!u(p)||(at(p)?a(p,p.labelTarget):(f=p.labels)!=null&&f.length&&a(p.labels[0],p))});function a(p,f){const d=_s([Je(f),Je(p)],zE),g=d.getAttribute("d"),m=o.isSelected(p)?c(p):l(p),w=Cs(m,g);if(!w)return;const v=o.isSelected(f)?c(f):l(f),x=Cs(v,g)||Je(f);Bs(x,w)<C$||(Wf(d,[x,w]),tt(r,d))}function s(){vs(`.${zE.class}`,r).forEach(sn)}function c(p){const f=i.getOutline(p);if(!f)return l(p);if(f.x){const d={x:p.x+hr(f,"x")-dp,y:p.y+hr(f,"y")-dp,width:hr(f,"width")+dp*2,height:hr(f,"height")+dp*2};return td(d,hr(f,"rx"))}if(f.cx){const d=hr(f,"r"),g={x:p.x+hr(f,"cx")-d,y:p.y+hr(f,"cy")-d,width:d*2,height:d*2};return nb(g)}}function l(p){return n.getShapePath(p)}function u(p){return o.isSelected(p)}}GE.$inject=["eventBus","canvas","graphicsFactory","outline","selection"];function hr(e,t){return parseFloat(Ie(e,t)||0)}const M$={__depends__:[Mi,vg],__init__:["labelLink"],labelLink:["type",GE]};var A$=new zr("tt");function P$(e){var t=jt('<div class="djs-tooltip-container" />');return Un(t,{position:"absolute",width:"0",height:"0"}),e.insertBefore(t,e.firstChild),t}function T$(e,t,n){Un(e,{left:t+"px",top:n+"px"})}function bg(e,t){e.style.display=t===!1?"none":""}var VE="djs-tooltip",xg="."+VE;function Zn(e,t){this._eventBus=e,this._canvas=t,this._ids=A$,this._tooltipDefaults={show:{minZoom:.7,maxZoom:5}},this._tooltips={},this._tooltipRoot=P$(t.getContainer());var n=this;ii.bind(this._tooltipRoot,xg,"mousedown",function(i){i.stopPropagation()}),ii.bind(this._tooltipRoot,xg,"mouseover",function(i){n.trigger("mouseover",i)}),ii.bind(this._tooltipRoot,xg,"mouseout",function(i){n.trigger("mouseout",i)}),this._init()}Zn.$inject=["eventBus","canvas"],Zn.prototype.add=function(e){if(!e.position)throw new Error("must specifiy tooltip position");if(!e.html)throw new Error("must specifiy tooltip html");var t=this._ids.next();return e=Y({},this._tooltipDefaults,e,{id:t}),this._addTooltip(e),e.timeout&&this.setTimeout(e),t},Zn.prototype.trigger=function(e,t){var n=t.delegateTarget||t.target,i=this.get(Cn(n,"data-tooltip-id"));i&&(e==="mouseover"&&i.timeout&&this.clearTimeout(i),e==="mouseout"&&i.timeout&&(i.timeout=1e3,this.setTimeout(i)))},Zn.prototype.get=function(e){return typeof e!="string"&&(e=e.id),this._tooltips[e]},Zn.prototype.clearTimeout=function(e){if(e=this.get(e),!!e){var t=e.removeTimer;t&&(clearTimeout(t),e.removeTimer=null)}},Zn.prototype.setTimeout=function(e){if(e=this.get(e),!!e){this.clearTimeout(e);var t=this;e.removeTimer=setTimeout(function(){t.remove(e)},e.timeout)}},Zn.prototype.remove=function(e){var t=this.get(e);t&&(Zi(t.html),Zi(t.htmlContainer),delete t.htmlContainer,delete this._tooltips[t.id])},Zn.prototype.show=function(){bg(this._tooltipRoot)},Zn.prototype.hide=function(){bg(this._tooltipRoot,!1)},Zn.prototype._updateRoot=function(e){var t=e.scale||1,n=e.scale||1,i="matrix("+t+",0,0,"+n+","+-1*e.x*t+","+-1*e.y*n+")";this._tooltipRoot.style.transform=i,this._tooltipRoot.style["-ms-transform"]=i},Zn.prototype._addTooltip=function(e){var t=e.id,n=e.html,i,o=this._tooltipRoot;n.get&&n.constructor.prototype.jquery&&(n=n.get(0)),ei(n)&&(n=jt(n)),i=jt('<div data-tooltip-id="'+t+'" class="'+VE+'">'),Un(i,{position:"absolute"}),i.appendChild(n),e.type&&At(i).add("djs-tooltip-"+e.type),e.className&&At(i).add(e.className),e.htmlContainer=i,o.appendChild(i),this._tooltips[t]=e,this._updateTooltip(e)},Zn.prototype._updateTooltip=function(e){var t=e.position,n=e.htmlContainer;T$(n,t.x,t.y)},Zn.prototype._updateTooltipVisibilty=function(e){V(this._tooltips,function(t){var n=t.show,i=t.htmlContainer,o=!0;n&&((n.minZoom>e.scale||n.maxZoom<e.scale)&&(o=!1),bg(i,o))})},Zn.prototype._init=function(){var e=this;function t(n){e._updateRoot(n),e._updateTooltipVisibilty(n),e.show()}this._eventBus.on("canvas.viewbox.changing",function(n){e.hide()}),this._eventBus.on("canvas.viewbox.changed",function(n){t(n.viewbox)})};const k$={__init__:["tooltips"],tooltips:["type",Zn]};var O$="flow elements must be children of pools/participants",D$="Data object must be placed within a pool/participant.";function WE(e,t,n){function i(o,r,a){t.add({position:{x:o.x+5,y:o.y+5},type:"error",timeout:2e3,html:"<div>"+r+"</div>"})}e.on(["shape.move.rejected","create.rejected"],function(o){var r=o.context,a=r.shape,s=r.target;M(s,"bpmn:Collaboration")&&(M(a,"bpmn:FlowNode")?i(o,n(O$)):M(a,"bpmn:DataObjectReference")&&i(o,n(D$)))})}WE.$inject=["eventBus","tooltips","translate"];const L$={__depends__:[k$],__init__:["modelingFeedback"],modelingFeedback:["type",WE]};var I$=500,B$=1250,N$=1500,hp=Math.round;function $$(e){return{x:e.x+hp(e.width/2),y:e.y+hp(e.height/2)}}function UE(e,t,n,i,o){function r(s,c,l,u){return o.allowed("elements.move",{shapes:s,delta:c,position:l,target:u})}e.on("shape.move.start",N$,function(s){var c=s.context,l=s.shape,u=i.get().slice();u.indexOf(l)===-1&&(u=[l]),u=F$(u),Y(c,{shapes:u,validatedShapes:u,shape:l})}),e.on("shape.move.start",B$,function(s){var c=s.context,l=c.validatedShapes,u;if(u=c.canExecute=r(l),!u)return!1}),e.on("shape.move.move",I$,function(s){var c=s.context,l=c.validatedShapes,u=s.hover,p={x:s.dx,y:s.dy},f={x:s.x,y:s.y},d;if(d=r(l,p,f,u),c.delta=p,c.canExecute=d,d===null){c.target=null;return}c.target=u}),e.on("shape.move.end",function(s){var c=s.context,l=c.delta,u=c.canExecute,p=u==="attach",f=c.shapes;if(u===!1)return!1;l.x=hp(l.x),l.y=hp(l.y),!(l.x===0&&l.y===0)&&n.moveElements(f,l,c.target,{primaryShape:c.shape,attach:p})}),e.on("element.mousedown",function(s){if(tr(s)){var c=Da(s);if(!c)throw new Error("must supply DOM mousedown event");return a(c,s.element)}});function a(s,c,l,u){if(mn(l)&&(u=l,l=!1),!(c.waypoints||!c.parent)&&!dt(s.target).has("djs-hit-no-move")){var p=$$(c),f=t.init(s,p,"shape.move",{cursor:"grabbing",autoActivate:l,data:{shape:c,context:u||{}}});if(f!==!1)return!0}}this.start=a}UE.$inject=["eventBus","dragging","modeling","selection","rules"];function F$(e){var t=sa(e,"id");return ct(e,function(n){for(;n=n.parent;)if(t[n.id])return!1;return!0})}var qE=499,wg="djs-dragging",YE="drop-ok",KE="drop-not-ok",XE="new-parent",ZE="attach-ok";function QE(e,t,n,i){function o(c){var l=r(c),u=j$(l);return u}function r(c){var l=Es(c),u=l.flatMap(d=>(d.incoming||[]).concat(d.outgoing||[])),p=l.concat(u),f=[...new Set(p)];return f}function a(c,l){[ZE,YE,KE,XE].forEach(function(u){u===l?t.addMarker(c,u):t.removeMarker(c,u)})}function s(c,l,u){i.addDragger(l,c.dragGroup),u&&t.addMarker(l,wg),c.allDraggedElements?c.allDraggedElements.push(l):c.allDraggedElements=[l]}e.on("shape.move.start",qE,function(c){var l=c.context,u=l.shapes,p=l.allDraggedElements,f=o(u);if(!l.dragGroup){var d=He("g");Ie(d,n.cls("djs-drag-group",["no-events"]));var g=t.getActiveLayer();tt(g,d),l.dragGroup=d}f.forEach(function(h){i.addDragger(h,l.dragGroup)}),p?p=Ip([p,r(u)]):p=r(u),V(p,function(h){t.addMarker(h,wg)}),l.allDraggedElements=p,l.differentParents=H$(u)}),e.on("shape.move.move",qE,function(c){var l=c.context,u=l.dragGroup,p=l.target,f=l.shape.parent,d=l.canExecute;p&&(d==="attach"?a(p,ZE):l.canExecute&&f&&p.id!==f.id?a(p,XE):a(p,l.canExecute?YE:KE)),Dn(u,c.dx,c.dy)}),e.on(["shape.move.out","shape.move.cleanup"],function(c){var l=c.context,u=l.target;u&&a(u,null)}),e.on("shape.move.cleanup",function(c){var l=c.context,u=l.allDraggedElements,p=l.dragGroup;V(u,function(f){t.removeMarker(f,wg)}),p&&sn(p)}),this.makeDraggable=s}QE.$inject=["eventBus","canvas","styles","previewSupport"];function j$(e){var t=new Set;e.forEach(function(i){t.add(i.id)});var n=ct(e,function(i){return Ot(i)?t.has(i.source.id)&&t.has(i.target.id):!0});return n}function H$(e){return HS(sa(e,function(t){return t.parent&&t.parent.id}))!==1}const z$={__depends__:[nu,Mi,vg,io,So,Na],__init__:["move","movePreview"],move:["type",UE],movePreview:["type",QE]};var JE=".djs-palette-toggle",e1=".entry",G$=JE+", "+e1,_g="djs-palette-",V$="shown",Eg="open",t1="two-column",W$=1e3;function dn(e,t){this._eventBus=e,this._canvas=t;var n=this;e.on("tool-manager.update",function(i){var o=i.tool;n.updateToolHighlight(o)}),e.on("i18n.changed",function(){n._update()}),e.on("diagram.init",function(){n._diagramInitialized=!0,n._rebuild()})}dn.$inject=["eventBus","canvas"],dn.prototype.registerProvider=function(e,t){t||(t=e,e=W$),this._eventBus.on("palette.getProviders",e,function(n){n.providers.push(t)}),this._rebuild()},dn.prototype.getEntries=function(){var e=this._getProviders();return e.reduce(q$,{})},dn.prototype._rebuild=function(){if(this._diagramInitialized){var e=this._getProviders();e.length&&(this._container||this._init(),this._update())}},dn.prototype._init=function(){var e=this,t=this._eventBus,n=this._getParentContainer(),i=this._container=jt(dn.HTML_MARKUP);n.appendChild(i),At(n).add(_g+V$),ii.bind(i,G$,"click",function(o){var r=o.delegateTarget;if(If(r,JE))return e.toggle();e.trigger("click",o)}),Ve.bind(i,"mousedown",function(o){o.stopPropagation()}),ii.bind(i,e1,"dragstart",function(o){e.trigger("dragstart",o)}),t.on("canvas.resized",this._layoutChanged,this),t.fire("palette.create",{container:i})},dn.prototype._getProviders=function(e){var t=this._eventBus.createEvent({type:"palette.getProviders",providers:[]});return this._eventBus.fire(t),t.providers},dn.prototype._toggleState=function(e){e=e||{};var t=this._getParentContainer(),n=this._container,i=this._eventBus,o,r=At(n),a=At(t);"twoColumn"in e?o=e.twoColumn:o=this._needsCollapse(t.clientHeight,this._entries||{}),r.toggle(t1,o),a.toggle(_g+t1,o),"open"in e&&(r.toggle(Eg,e.open),a.toggle(_g+Eg,e.open)),i.fire("palette.changed",{twoColumn:o,open:this.isOpen()})},dn.prototype._update=function(){var e=Ct(".djs-palette-entries",this._container),t=this._entries=this.getEntries();fl(e),V(t,function(n,i){var o=n.group||"default",r=Ct("[data-group="+Ur(o)+"]",e);r||(r=jt('<div class="group"></div>'),Cn(r,"data-group",o),e.appendChild(r));var a=n.html||(n.separator?'<hr class="separator" />':'<div class="entry" draggable="true"></div>'),s=jt(a);if(r.appendChild(s),!n.separator&&(Cn(s,"data-action",i),n.title&&Cn(s,"title",n.title),n.className&&U$(s,n.className),n.imageUrl)){var c=jt("<img>");Cn(c,"src",n.imageUrl),s.appendChild(c)}}),this.open()},dn.prototype.trigger=function(e,t,n){var i,o,r=t.delegateTarget||t.target;return r?(i=Cn(r,"data-action"),o=t.originalEvent||t,this.triggerEntry(i,e,o,n)):t.preventDefault()},dn.prototype.triggerEntry=function(e,t,n,i){var o=this._entries,r,a;if(r=o[e],!!r&&(a=r.action,this._eventBus.fire("palette.trigger",{entry:r,event:n})!==!1)){if(_n(a)){if(t==="click")return a(n,i)}else if(a[t])return a[t](n,i);n.preventDefault()}},dn.prototype._layoutChanged=function(){this._toggleState({})},dn.prototype._needsCollapse=function(e,t){var n=50,i=Object.keys(t).length*46;return e<i+n},dn.prototype.close=function(){this._toggleState({open:!1,twoColumn:!1})},dn.prototype.open=function(){this._toggleState({open:!0})},dn.prototype.toggle=function(){this.isOpen()?this.close():this.open()},dn.prototype.isActiveTool=function(e){return e&&this._activeTool===e},dn.prototype.updateToolHighlight=function(e){var t,n;this._toolsContainer||(t=Ct(".djs-palette-entries",this._container),this._toolsContainer=Ct("[data-group=tools]",t)),n=this._toolsContainer,V(n.children,function(i){var o=i.getAttribute("data-action");if(o){var r=At(i);o=o.replace("-tool",""),r.contains("entry")&&o===e?r.add("highlighted-entry"):r.remove("highlighted-entry")}})},dn.prototype.isOpen=function(){return At(this._container).has(Eg)},dn.prototype._getParentContainer=function(){return this._canvas.getContainer()},dn.HTML_MARKUP='<div class="djs-palette"><div class="djs-palette-entries"></div><div class="djs-palette-toggle"></div></div>';function U$(e,t){var n=At(e),i=Ze(t)?t:t.split(/\s+/g);i.forEach(function(o){n.add(o)})}function q$(e,t){var n=t.getPaletteEntries();return _n(n)?n(e):(V(n,function(i,o){e[o]=i}),e)}const Y$={__init__:["palette"],palette:["type",dn]};var n1="crosshair",i1="selected",K$="djs-dragging-active-lasso";function gr(e,t,n,i,o,r,a){this._selection=o,this._dragging=n,this._mouse=a;var s=this,c={create:function(p){var f=t.getActiveLayer(),d=p.frame=He("rect");Ie(d,{class:"djs-lasso-overlay",width:1,height:1,x:0,y:0}),tt(f,d),l(!0),this.update(p)},update:function(p){var f=p.frame,d=p.bbox;f&&d&&Ie(f,{x:d.x,y:d.y,width:d.width,height:d.height});var g=p.marked,h=p.lastMarked;if(g&&h){for(const m of h)g.has(m)||t.removeMarker(m,i1);for(const m of g)h.has(m)||t.addMarker(m,i1)}},remove:function(p){this.update(p),p.frame&&sn(p.frame),l(!1)}};function l(p){dt(t.getContainer()).toggle(K$,p)}function u(p){var f=i.getAll();return new Set(aa(xa(f,p)))}r.registerTool("lasso",{tool:"lasso.selection",dragging:"lasso"}),e.on("lasso.selection.end",function(p){var f=p.originalEvent.target;!p.hover&&!(f instanceof SVGElement)||e.once("lasso.selection.ended",function(){s.activateLasso(p.originalEvent,!0)})}),e.on("lasso.end",0,function(p){var f=p.context;s._select(Array.from(f.marked))}),e.on("lasso.start",function(p){var f=p.context;f.bbox=o1(p),f.add=Kl(p),f.lastMarked=new Set(o.get()),f.add?f.marked=f.lastMarked:f.marked=new Set,f.initialMarked=f.marked,c.create(f)}),e.on("lasso.move",function(p){var f=p.context,d=f.bbox=o1(p),g=u(d),h=f.initialMarked.union(g);f.lastMarked=f.marked,f.marked=h,c.update(f)}),e.on("lasso.cleanup",function(p){var f=p.context;f.lastMarked=f.marked,f.marked=new Set(o.get()),c.remove(p.context)}),e.on("element.mousedown",1500,function(p){if(Kl(p))return s.activateLasso(p.originalEvent),!0})}gr.$inject=["eventBus","canvas","dragging","elementRegistry","selection","toolManager","mouse"],gr.prototype.activateLasso=function(e,t){this._dragging.init(e,"lasso",{autoActivate:t,cursor:n1,data:{context:{}},keepSelection:!0})},gr.prototype.activateSelection=function(e,t){this._dragging.init(e,"lasso.selection",{trapClick:!1,autoActivate:t,cursor:n1,data:{context:{}},keepSelection:!0})},gr.prototype._select=function(e){this._selection.select(e)},gr.prototype.select=function(e,t,n=[]){var i=aa(xa(e,t));this._select([...n,...i])},gr.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)},gr.prototype.isActive=function(){var e=this._dragging.context();return e&&/^lasso/.test(e.prefix)};function o1(e){var t={x:e.x-e.dx,y:e.y-e.dy},n={x:e.x,y:e.y},i;return t.x<=n.x&&t.y<n.y||t.x<n.x&&t.y<=n.y?i={x:t.x,y:t.y,width:n.x-t.x,height:n.y-t.y}:t.x>=n.x&&t.y<n.y||t.x>n.x&&t.y<=n.y?i={x:n.x,y:t.y,width:t.x-n.x,height:n.y-t.y}:t.x<=n.x&&t.y>n.y||t.x<n.x&&t.y>=n.y?i={x:t.x,y:n.y,width:n.x-t.x,height:t.y-n.y}:t.x>=n.x&&t.y>n.y||t.x>n.x&&t.y>=n.y?i={x:n.x,y:n.y,width:t.x-n.x,height:t.y-n.y}:i={x:n.x,y:n.y,width:0,height:0},i}const X$={__depends__:[au,zs],__init__:["lassoTool"],lassoTool:["type",gr]};var Sg=1500,r1="grab";function Ka(e,t,n,i,o,r){this._dragging=n,this._mouse=r;var a=this,s=i.get("keyboard",!1);o.registerTool("hand",{tool:"hand",dragging:"hand.move"}),e.on("element.mousedown",Sg,function(c){if(Fs(c))return a.activateMove(c.originalEvent,!0),!1}),s&&s.addListener(Sg,function(c){if(!(!a1(c.keyEvent)||a.isActive())){var l=a._mouse.getLastMoveEvent();a.activateMove(l,!!l)}},"keyboard.keydown"),s&&s.addListener(Sg,function(c){!a1(c.keyEvent)||!a.isActive()||a.toggle()},"keyboard.keyup"),e.on("hand.end",function(c){var l=c.originalEvent.target;if(!c.hover&&!(l instanceof SVGElement))return!1;e.once("hand.ended",function(){a.activateMove(c.originalEvent,{reactivate:!0})})}),e.on("hand.move.move",function(c){var l=t.viewbox().scale;t.scroll({dx:c.dx*l,dy:c.dy*l})}),e.on("hand.move.end",function(c){var l=c.context,u=l.reactivate;return!Fs(c)&&u&&e.once("hand.move.ended",function(p){a.activateHand(p.originalEvent,!0,!0)}),!1})}Ka.$inject=["eventBus","canvas","dragging","injector","toolManager","mouse"],Ka.prototype.activateMove=function(e,t,n){typeof t=="object"&&(n=t,t=!1),this._dragging.init(e,"hand.move",{autoActivate:t,cursor:r1,data:{context:n||{}}})},Ka.prototype.activateHand=function(e,t,n){this._dragging.init(e,"hand",{trapClick:!1,autoActivate:t,cursor:r1,data:{context:{reactivate:n}}})},Ka.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateHand(e,!!e)},Ka.prototype.isActive=function(){var e=this._dragging.context();return e?/^(hand|hand\.move)$/.test(e.prefix):!1};function a1(e){return vn("Space",e)}const Z$={__depends__:[au,zs],__init__:["handTool"],handTool:["type",Ka]};var s1="connect-ok",c1="connect-not-ok";function Xa(e,t,n,i,o,r,a){var s=this;this._dragging=t,this._rules=r,this._mouse=a,o.registerTool("global-connect",{tool:"global-connect",dragging:"global-connect.drag"}),e.on("global-connect.hover",function(c){var l=c.context,u=c.hover,p=l.canStartConnect=s.canStartConnect(u);p!==null&&(l.startTarget=u,i.addMarker(u,p?s1:c1))}),e.on(["global-connect.out","global-connect.cleanup"],function(c){var l=c.context.startTarget,u=c.context.canStartConnect;l&&i.removeMarker(l,u?s1:c1)}),e.on(["global-connect.ended"],function(c){var l=c.context,u=l.startTarget,p={x:c.x,y:c.y},f=s.canStartConnect(u);if(f)return e.once("element.out",function(){e.once(["connect.ended","connect.canceled"],function(){e.fire("global-connect.drag.ended")}),n.start(null,u,p)}),!1})}Xa.$inject=["eventBus","dragging","connect","canvas","toolManager","rules","mouse"],Xa.prototype.start=function(e,t){this._dragging.init(e,"global-connect",{autoActivate:t,trapClick:!1,data:{context:{}}})},Xa.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();return this.start(e,!!e)},Xa.prototype.isActive=function(){var e=this._dragging.context();return e&&/^global-connect/.test(e.prefix)},Xa.prototype.canStartConnect=function(e){return this._rules.allowed("connection.start",{source:e})};const Q$={__depends__:[dg,io,So,au,zs],globalConnect:["type",Xa]};function Rg(e,t,n,i,o,r,a,s){this._palette=e,this._create=t,this._elementFactory=n,this._spaceTool=i,this._lassoTool=o,this._handTool=r,this._globalConnect=a,this._translate=s,e.registerProvider(this)}Rg.$inject=["palette","create","elementFactory","spaceTool","lassoTool","handTool","globalConnect","translate"],Rg.prototype.getPaletteEntries=function(){var e={},t=this._create,n=this._elementFactory,i=this._spaceTool,o=this._lassoTool,r=this._handTool,a=this._globalConnect,s=this._translate;function c(p,f,d,g,h){function m(w){var y=n.createShape(Y({type:p},h));t.start(w,y)}return{group:f,className:d,title:g,action:{dragstart:m,click:m}}}function l(p){var f=n.createShape({type:"bpmn:SubProcess",x:0,y:0,isExpanded:!0}),d=n.createShape({type:"bpmn:StartEvent",x:40,y:82,parent:f});t.start(p,[f,d],{hints:{autoSelect:[f]}})}function u(p){t.start(p,n.createParticipantShape())}return Y(e,{"hand-tool":{group:"tools",className:"bpmn-icon-hand-tool",title:s("Activate hand tool"),action:{click:function(p){r.activateHand(p)}}},"lasso-tool":{group:"tools",className:"bpmn-icon-lasso-tool",title:s("Activate lasso tool"),action:{click:function(p){o.activateSelection(p)}}},"space-tool":{group:"tools",className:"bpmn-icon-space-tool",title:s("Activate create/remove space tool"),action:{click:function(p){i.activateSelection(p)}}},"global-connect-tool":{group:"tools",className:"bpmn-icon-connection-multi",title:s("Activate global connect tool"),action:{click:function(p){a.start(p)}}},"tool-separator":{group:"tools",separator:!0},"create.start-event":c("bpmn:StartEvent","event","bpmn-icon-start-event-none",s("Create start event")),"create.intermediate-event":c("bpmn:IntermediateThrowEvent","event","bpmn-icon-intermediate-event-none",s("Create intermediate/boundary event")),"create.end-event":c("bpmn:EndEvent","event","bpmn-icon-end-event-none",s("Create end event")),"create.exclusive-gateway":c("bpmn:ExclusiveGateway","gateway","bpmn-icon-gateway-none",s("Create gateway")),"create.task":c("bpmn:Task","activity","bpmn-icon-task",s("Create task")),"create.data-object":c("bpmn:DataObjectReference","data-object","bpmn-icon-data-object",s("Create data object reference")),"create.data-store":c("bpmn:DataStoreReference","data-store","bpmn-icon-data-store",s("Create data store reference")),"create.subprocess-expanded":{group:"activity",className:"bpmn-icon-subprocess-expanded",title:s("Create expanded sub-process"),action:{dragstart:l,click:l}},"create.participant-expanded":{group:"collaboration",className:"bpmn-icon-participant",title:s("Create pool/participant"),action:{dragstart:u,click:u}},"create.group":c("bpmn:Group","artifact","bpmn-icon-group",s("Create group"))}),e};const J$={__depends__:[Y$,ou,xw,X$,Z$,Q$,Os],__init__:["paletteProvider"],paletteProvider:["type",Rg]};var e5=250;function Cg(e,t,n,i,o){we.call(this,e);function r(s){var c=s.canExecute.replacements;V(c,function(l){var u=l.oldElementId,p={type:l.newElementType};if(!s.visualReplacements[u]){var f=t.get(u);Y(p,{x:f.x,y:f.y});var d=n.createShape(p);i.addShape(d,f.parent);var g=Ct('[data-element-id="'+Ur(f.id)+'"]',s.dragGroup);g&&Ie(g,{display:"none"});var h=o.addDragger(d,s.dragGroup);s.visualReplacements[u]=h,i.removeShape(d)}})}function a(s){var c=s.visualReplacements;V(c,function(l,u){var p=Ct('[data-element-id="'+Ur(u)+'"]',s.dragGroup);p&&Ie(p,{display:"inline"}),l.remove(),c[u]&&delete c[u]})}e.on("shape.move.move",e5,function(s){var c=s.context,l=c.canExecute;c.visualReplacements||(c.visualReplacements={}),l&&l.replacements?r(c):a(c)})}Cg.$inject=["eventBus","elementRegistry","elementFactory","canvas","previewSupport"],Ne(Cg,we);const t5={__depends__:[Na],__init__:["bpmnReplacePreview"],bpmnReplacePreview:["type",Cg]};var n5=1250,Mg=40,i5=20,o5=10,l1=20,u1=["x","y"],r5=Math.abs;function p1(e){e.on(["connect.hover","connect.move","connect.end"],n5,function(t){var n=t.context,i=n.canExecute,o=n.start,r=n.hover,a=n.source,s=n.target;t.originalEvent&&ai(t.originalEvent)||(n.initialConnectionStart||(n.initialConnectionStart=n.connectionStart),i&&r&&a5(t,r,u5(r)),r&&l5(i,["bpmn:Association","bpmn:DataInputAssociation","bpmn:DataOutputAssociation","bpmn:SequenceFlow"])?(n.connectionStart=Ti(o),st(r,["bpmn:Event","bpmn:Gateway"])&&f1(t,Ti(r)),st(r,["bpmn:Task","bpmn:SubProcess"])&&s5(t,r),M(a,"bpmn:BoundaryEvent")&&s===a.host&&c5(t)):d1(i,"bpmn:MessageFlow")?(M(o,"bpmn:Event")&&(n.connectionStart=Ti(o)),M(r,"bpmn:Event")&&f1(t,Ti(r))):n.connectionStart=n.initialConnectionStart)})}p1.$inject=["eventBus"];function a5(e,t,n){u1.forEach(function(i){var o=h1(i,t);e[i]<t[i]+n?fn(e,i,t[i]+n):e[i]>t[i]+o-n&&fn(e,i,t[i]+o-n)})}function s5(e,t){var n=Ti(t);u1.forEach(function(i){p5(e,t,i)&&fn(e,i,n[i])})}function c5(e){var t=e.context,n=t.source,i=t.target;if(!f5(t)){var o=Ti(n),r=On(o,i,-10),a=[];/top|bottom/.test(r)&&a.push("x"),/left|right/.test(r)&&a.push("y"),a.forEach(function(s){var c=e[s],l;r5(c-o[s])<Mg&&(c>o[s]?l=o[s]+Mg:l=o[s]-Mg,fn(e,s,l))})}}function f1(e,t){fn(e,"x",t.x),fn(e,"y",t.y)}function d1(e,t){return e&&e.type===t}function l5(e,t){return Bo(t,function(n){return d1(e,n)})}function h1(e,t){return e==="x"?t.width:t.height}function u5(e){return M(e,"bpmn:Task")?o5:i5}function p5(e,t,n){return e[n]>t[n]+l1&&e[n]<t[n]+h1(n,t)-l1}function f5(e){var t=e.hover,n=e.source;return t&&n&&t===n}function mr(){this._targets={},this._snapOrigins={},this._snapLocations=[],this._defaultSnaps={}}mr.prototype.getSnapOrigin=function(e){return this._snapOrigins[e]},mr.prototype.setSnapOrigin=function(e,t){this._snapOrigins[e]=t,this._snapLocations.indexOf(e)===-1&&this._snapLocations.push(e)},mr.prototype.addDefaultSnap=function(e,t){var n=this._defaultSnaps[e];n||(n=this._defaultSnaps[e]=[]),n.push(t)},mr.prototype.getSnapLocations=function(){return this._snapLocations},mr.prototype.setSnapLocations=function(e){this._snapLocations=e},mr.prototype.pointsForTarget=function(e){var t=e.id||e,n=this._targets[t];return n||(n=this._targets[t]=new gp,n.initDefaults(this._defaultSnaps)),n};function gp(){this._snapValues={}}gp.prototype.add=function(e,t){var n=this._snapValues[e];n||(n=this._snapValues[e]={x:[],y:[]}),n.x.indexOf(t.x)===-1&&n.x.push(t.x),n.y.indexOf(t.y)===-1&&n.y.push(t.y)},gp.prototype.snap=function(e,t,n,i){var o=this._snapValues[t];return o&&eN(e[n],o[n],i)},gp.prototype.initDefaults=function(e){var t=this;V(e||{},function(n,i){V(n,function(o){t.add(i,o)})})};var d5=1250;function so(e,t,n){var i=this;this._elementRegistry=e,t.on(["create.start","shape.move.start"],function(o){i.initSnap(o)}),t.on(["create.move","create.end","shape.move.move","shape.move.end"],d5,function(o){var r=o.context,a=r.shape,s=r.snapContext,c=r.target;if(!(o.originalEvent&&ai(o.originalEvent))&&!(Ya(o)||!c)){var l=s.pointsForTarget(c);l.initialized||(l=i.addSnapTargetPoints(l,a,c),l.initialized=!0),n.snap(o,l)}}),t.on(["create.cleanup","shape.move.cleanup"],function(){n.hide()})}so.$inject=["elementRegistry","eventBus","snapping"],so.prototype.initSnap=function(e){var t=this._elementRegistry,n=e.context,i=n.shape,o=n.snapContext;o||(o=n.snapContext=new mr);var r;t.get(i.id)?r=Ti(i,e):r={x:e.x+Ti(i).x,y:e.y+Ti(i).y};var a={x:r.x-i.width/2,y:r.y-i.height/2},s={x:r.x+i.width/2,y:r.y+i.height/2};return o.setSnapOrigin("mid",{x:r.x-e.x,y:r.y-e.y}),at(i)||(o.setSnapOrigin("top-left",{x:a.x-e.x,y:a.y-e.y}),o.setSnapOrigin("bottom-right",{x:s.x-e.x,y:s.y-e.y})),o},so.prototype.addSnapTargetPoints=function(e,t,n){var i=this.getSnapTargets(t,n);return V(i,function(o){if(at(o)){at(t)&&e.add("mid",Ti(o));return}if(Ot(o)){if(o.waypoints.length<3)return;var r=o.waypoints.slice(1,-1);V(r,function(a){e.add("mid",a)});return}e.add("mid",Ti(o))}),!Qe(t.x)||!Qe(t.y)||this._elementRegistry.get(t.id)&&e.add("mid",Ti(t)),e},so.prototype.getSnapTargets=function(e,t){return eE(t).filter(function(n){return!h5(n)})};function h5(e){return!!e.hidden}var g1=1500;function Za(e,t){t.invoke(so,this),e.on(["create.move","create.end"],g1,v5),e.on(["create.move","create.end","shape.move.move","shape.move.end"],g1,function(n){var i=n.context,o=i.canExecute,r=i.target,a=o&&(o==="attach"||o.attach);a&&!Ya(n)&&g5(n,r)})}Ne(Za,so),Za.$inject=["eventBus","injector"],Za.prototype.initSnap=function(e){var t=so.prototype.initSnap.call(this,e),n=e.shape,i=!!this._elementRegistry.get(n.id);return V(n.outgoing,function(o){var r=o.waypoints[0];r=r.original||r,t.setSnapOrigin(o.id+"-docking",y1(r,i,e))}),V(n.incoming,function(o){var r=o.waypoints[o.waypoints.length-1];r=r.original||r,t.setSnapOrigin(o.id+"-docking",y1(r,i,e))}),M(n,"bpmn:Participant")&&t.setSnapLocations(["top-left","bottom-right","mid"]),t},Za.prototype.addSnapTargetPoints=function(e,t,n){so.prototype.addSnapTargetPoints.call(this,e,t,n);var i=this.getSnapTargets(t,n);V(i,function(r){(y5(r)||m5([t,r],"bpmn:TextAnnotation"))&&(e.add("top-left",Q0(r)),e.add("bottom-right",J0(r)))});var o=this._elementRegistry;return V(t.incoming,function(r){if(o.get(t.id)){m1(i,r.source)||e.add("mid",Je(r.source));var a=r.waypoints[0];e.add(r.id+"-docking",a.original||a)}}),V(t.outgoing,function(r){if(o.get(t.id)){m1(i,r.target)||e.add("mid",Je(r.target));var a=r.waypoints[r.waypoints.length-1];e.add(r.id+"-docking",a.original||a)}}),M(n,"bpmn:SequenceFlow")&&(e=this.addSnapTargetPoints(e,t,n.parent)),e},Za.prototype.getSnapTargets=function(e,t){return so.prototype.getSnapTargets.call(this,e,t).filter(function(n){return!M(n,"bpmn:Lane")})};function g5(e,t){var n=qe(t),i=mx(e,t),o=e.context,r=o.shape,a;r.parent?a={x:0,y:0}:a=Je(r),/top/.test(i)?fn(e,"y",n.top-a.y):/bottom/.test(i)&&fn(e,"y",n.bottom-a.y),/left/.test(i)?fn(e,"x",n.left-a.x):/right/.test(i)&&fn(e,"x",n.right-a.x)}function m5(e,t){return e.every(function(n){return M(n,t)})}function y5(e){return M(e,"bpmn:SubProcess")&&ht(e)?!0:M(e,"bpmn:Participant")}function v5(e){var t=e.context,n=t.createConstraints;if(n){var i=n.top,o=n.right,r=n.bottom,a=n.left;(a&&a>=e.x||o&&o<=e.x)&&fn(e,"x",e.x),(i&&i>=e.y||r&&r<=e.y)&&fn(e,"y",e.y)}}function m1(e,t){return e.indexOf(t)!==-1}function y1(e,t,n){return t?{x:e.x-n.x,y:e.y-n.y}:{x:e.x,y:e.y}}var b5=1250;function bc(e,t){var n=this;e.on(["resize.start"],function(i){n.initSnap(i)}),e.on(["resize.move","resize.end"],b5,function(i){var o=i.context,r=o.shape,a=r.parent,s=o.direction,c=o.snapContext;if(!(i.originalEvent&&ai(i.originalEvent))&&!Ya(i)){var l=c.pointsForTarget(a);l.initialized||(l=n.addSnapTargetPoints(l,r,a,s),l.initialized=!0),_5(s)&&fn(i,"x",i.x),E5(s)&&fn(i,"y",i.y),t.snap(i,l)}}),e.on(["resize.cleanup"],function(){t.hide()})}bc.prototype.initSnap=function(e){var t=e.context,n=t.shape,i=t.direction,o=t.snapContext;o||(o=t.snapContext=new mr);var r=v1(n,i);return o.setSnapOrigin("corner",{x:r.x-e.x,y:r.y-e.y}),o},bc.prototype.addSnapTargetPoints=function(e,t,n,i){var o=this.getSnapTargets(t,n);return V(o,function(r){e.add("corner",J0(r)),e.add("corner",Q0(r))}),e.add("corner",v1(t,i)),e},bc.$inject=["eventBus","snapping"],bc.prototype.getSnapTargets=function(e,t){return eE(t).filter(function(n){return!x5(n,e)&&!Ot(n)&&!w5(n)&&!at(n)})};function v1(e,t){var n=Je(e),i=qe(e),o={x:n.x,y:n.y};return t.indexOf("n")!==-1?o.y=i.top:t.indexOf("s")!==-1&&(o.y=i.bottom),t.indexOf("e")!==-1?o.x=i.right:t.indexOf("w")!==-1&&(o.x=i.left),o}function x5(e,t){return e.host===t}function w5(e){return!!e.hidden}function _5(e){return e==="n"||e==="s"}function E5(e){return e==="e"||e==="w"}var S5=7,R5=1e3;function yr(e){this._canvas=e,this._asyncHide=Np(Kn(this.hide,this),R5)}yr.$inject=["canvas"],yr.prototype.snap=function(e,t){var n=e.context,i=n.snapContext,o=i.getSnapLocations(),r={x:Ya(e,"x"),y:Ya(e,"y")};V(o,function(a){var s=i.getSnapOrigin(a),c={x:e.x+s.x,y:e.y+s.y};if(V(["x","y"],function(l){var u;r[l]||(u=t.snap(c,a,l,S5),u!==void 0&&(r[l]={value:u,originValue:u-s[l]}))}),r.x&&r.y)return!1}),this.showSnapLine("vertical",r.x&&r.x.value),this.showSnapLine("horizontal",r.y&&r.y.value),V(["x","y"],function(a){var s=r[a];mn(s)&&fn(e,a,s.originValue)})},yr.prototype._createLine=function(e){var t=this._canvas.getLayer("snap"),n=He("path");return Ie(n,{d:"M0,0 L0,0"}),dt(n).add("djs-snap-line"),tt(t,n),{update:function(i){Qe(i)?e==="horizontal"?Ie(n,{d:"M-100000,"+i+" L+100000,"+i,display:""}):Ie(n,{d:"M "+i+",-100000 L "+i+", +100000",display:""}):Ie(n,{display:"none"})}}},yr.prototype._createSnapLines=function(){this._snapLines={horizontal:this._createLine("horizontal"),vertical:this._createLine("vertical")}},yr.prototype.showSnapLine=function(e,t){var n=this.getSnapLine(e);n&&n.update(t),this._asyncHide()},yr.prototype.getSnapLine=function(e){return this._snapLines||this._createSnapLines(),this._snapLines[e]},yr.prototype.hide=function(){V(this._snapLines,function(e){e.update()})};const C5={__depends__:[{__init__:["createMoveSnapping","resizeSnapping","snapping"],createMoveSnapping:["type",so],resizeSnapping:["type",bc],snapping:["type",yr]}],__init__:["connectSnapping","createMoveSnapping"],connectSnapping:["type",p1],createMoveSnapping:["type",Za]};var b1=300;function ot(e,t,n,i){this._open=!1,this._results={},this._eventMaps=[],this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._canvas=e,this._eventBus=t,this._selection=n,this._translate=i,this._container=this._getBoxHtml(),this._searchInput=Ct(ot.INPUT_SELECTOR,this._container),this._resultsContainer=Ct(ot.RESULTS_CONTAINER_SELECTOR,this._container),this._canvas.getContainer().appendChild(this._container),t.on(["canvas.destroy","diagram.destroy","drag.init","elements.changed"],this.close,this)}ot.$inject=["canvas","eventBus","selection","translate"],ot.prototype._bindEvents=function(){var e=this;function t(n,i,o,r){e._eventMaps.push({el:n,type:o,listener:ii.bind(n,i,o,r)})}t(document,"html","click",function(n){e.close(!1)}),t(this._container,ot.INPUT_SELECTOR,"click",function(n){n.stopPropagation(),n.delegateTarget.focus()}),t(this._container,ot.RESULT_SELECTOR,"mouseover",function(n){n.stopPropagation(),e._scrollToNode(n.delegateTarget),e._preselect(n.delegateTarget)}),t(this._container,ot.RESULT_SELECTOR,"click",function(n){n.stopPropagation(),e._select(n.delegateTarget)}),t(this._container,ot.INPUT_SELECTOR,"keydown",function(n){vn("ArrowUp",n)&&n.preventDefault(),vn("ArrowDown",n)&&n.preventDefault()}),t(this._container,ot.INPUT_SELECTOR,"keyup",function(n){if(vn("Escape",n))return e.close();if(vn("Enter",n)){var i=e._getCurrentResult();return i?e._select(i):e.close(!1)}if(vn("ArrowUp",n))return e._scrollToDirection(!0);if(vn("ArrowDown",n))return e._scrollToDirection();vn(["ArrowLeft","ArrowRight"],n)||e._search(n.delegateTarget.value)})},ot.prototype._unbindEvents=function(){this._eventMaps.forEach(function(e){ii.unbind(e.el,e.type,e.listener)})},ot.prototype._search=function(e){var t=this;if(this._clearResults(),!!e.trim()){var n=this._searchProvider.find(e);if(n=n.filter(function(o){return!t._canvas.getRootElements().includes(o.element)}),!n.length){this._selection.select(null);return}n.forEach(function(o){var r=o.element.id,a=t._createResultNode(o,r);t._results[r]={element:o.element,node:a}});var i=Ct(ot.RESULT_SELECTOR,this._resultsContainer);this._scrollToNode(i),this._preselect(i)}},ot.prototype._scrollToDirection=function(e){var t=this._getCurrentResult();if(t){var n=e?t.previousElementSibling:t.nextElementSibling;n&&(this._scrollToNode(n),this._preselect(n))}},ot.prototype._scrollToNode=function(e){if(!(!e||e===this._getCurrentResult())){var t=e.offsetTop,n=this._resultsContainer.scrollTop,i=t-this._resultsContainer.clientHeight+e.clientHeight;t<n?this._resultsContainer.scrollTop=t:n<i&&(this._resultsContainer.scrollTop=i)}},ot.prototype._clearResults=function(){fl(this._resultsContainer),this._results={},this._eventBus.fire("searchPad.cleared")},ot.prototype._getCurrentResult=function(){return Ct(ot.RESULT_SELECTED_SELECTOR,this._resultsContainer)},ot.prototype._createResultNode=function(e,t){var n=jt(ot.RESULT_HTML);return e.primaryTokens.length>0&&x1(n,e.primaryTokens,ot.RESULT_PRIMARY_HTML),x1(n,e.secondaryTokens,ot.RESULT_SECONDARY_HTML),Cn(n,ot.RESULT_ID_ATTRIBUTE,t),this._resultsContainer.appendChild(n),n},ot.prototype.registerProvider=function(e){this._searchProvider=e},ot.prototype.open=function(){if(!this._searchProvider)throw new Error("no search provider registered");this.isOpen()||(this._cachedRootElement=this._canvas.getRootElement(),this._cachedSelection=this._selection.get(),this._cachedViewbox=this._canvas.viewbox(),this._selection.select(null),this._bindEvents(),this._open=!0,At(this._canvas.getContainer()).add("djs-search-open"),At(this._container).add("open"),this._searchInput.focus(),this._eventBus.fire("searchPad.opened"))},ot.prototype.close=function(e=!0){this.isOpen()&&(e&&(this._cachedRootElement&&this._canvas.setRootElement(this._cachedRootElement),this._cachedSelection&&this._selection.select(this._cachedSelection),this._cachedViewbox&&this._canvas.viewbox(this._cachedViewbox),this._eventBus.fire("searchPad.restored")),this._cachedRootElement=null,this._cachedSelection=null,this._cachedViewbox=null,this._unbindEvents(),this._open=!1,At(this._canvas.getContainer()).remove("djs-search-open"),At(this._container).remove("open"),this._clearResults(),this._searchInput.value="",this._searchInput.blur(),this._eventBus.fire("searchPad.closed"),this._canvas.restoreFocus())},ot.prototype.toggle=function(){this.isOpen()?this.close():this.open()},ot.prototype.isOpen=function(){return this._open},ot.prototype._preselect=function(e){var t=this._getCurrentResult();if(e!==t){t&&At(t).remove(ot.RESULT_SELECTED_CLASS);var n=Cn(e,ot.RESULT_ID_ATTRIBUTE),i=this._results[n].element;At(e).add(ot.RESULT_SELECTED_CLASS),this._canvas.scrollToElement(i,{top:b1}),this._selection.select(i),this._eventBus.fire("searchPad.preselected",i)}},ot.prototype._select=function(e){var t=Cn(e,ot.RESULT_ID_ATTRIBUTE),n=this._results[t].element;this._cachedSelection=null,this._cachedViewbox=null,this.close(!1),this._canvas.scrollToElement(n,{top:b1}),this._selection.select(n),this._eventBus.fire("searchPad.selected",n)},ot.prototype._getBoxHtml=function(){const e=jt(ot.BOX_HTML),t=Ct(ot.INPUT_SELECTOR,e);return t&&t.setAttribute("aria-label",this._translate("Search in diagram")),e};function x1(e,t,n){var i=M5(t),o=jt(n);o.innerHTML=i,e.appendChild(o)}function M5(e){var t="";return e.forEach(function(n){var i=A_(n.value||n.matched||n.normal),o=n.match||n.matched;o?t+='<b class="'+ot.RESULT_HIGHLIGHT_CLASS+'">'+i+"</b>":t+=i}),t!==""?t:null}ot.CONTAINER_SELECTOR=".djs-search-container",ot.INPUT_SELECTOR=".djs-search-input input",ot.RESULTS_CONTAINER_SELECTOR=".djs-search-results",ot.RESULT_SELECTOR=".djs-search-result",ot.RESULT_SELECTED_CLASS="djs-search-result-selected",ot.RESULT_SELECTED_SELECTOR="."+ot.RESULT_SELECTED_CLASS,ot.RESULT_ID_ATTRIBUTE="data-result-id",ot.RESULT_HIGHLIGHT_CLASS="djs-search-highlight",ot.BOX_HTML=`<div class="djs-search-container djs-scrollable">
336
336
  <div class="djs-search-input">
337
337
  <svg class="djs-search-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
338
338
  <path fill-rule="evenodd" clip-rule="evenodd" d="M9.0325 8.5H9.625L13.3675 12.25L12.25 13.3675L8.5 9.625V9.0325L8.2975 8.8225C7.4425 9.5575 6.3325 10 5.125 10C2.4325 10 0.25 7.8175 0.25 5.125C0.25 2.4325 2.4325 0.25 5.125 0.25C7.8175 0.25 10 2.4325 10 5.125C10 6.3325 9.5575 7.4425 8.8225 8.2975L9.0325 8.5ZM1.75 5.125C1.75 6.9925 3.2575 8.5 5.125 8.5C6.9925 8.5 8.5 6.9925 8.5 5.125C8.5 3.2575 6.9925 1.75 5.125 1.75C3.2575 1.75 1.75 3.2575 1.75 5.125Z" fill="#22242A"/>