Home
last modified time | relevance | path

Searched refs:vP (Results 1 – 6 of 6) sorted by relevance

/plugin/zwidoku/files/
H A Dcommon.css1vP///yH5BAEKAA8ALAAAAAAQABAAAARe8Mk53XGO6srY2c8hWgeziNuhdJ2lfJoqzEXdwFQpEHX9pooBYUgY/GJBYlGB2CBY0E…
/plugin/bpmnio/vendor/dmn-js/dist/
H A Ddmn-modeler.production.min.js284 `))};if((z.mac||z.android)&&f.from==s-1&&/^\. ?$/.test(i.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(f={from:a,to:l,insert:be.of([i.text.replace("."," ")])}),this.pendingContextChange=f,!e.state.readOnly){let h=this.to-this.from+(f.to-f.from+f.insert.length);Tb(e,f,$.single(this.toEditorPos(i.selectionStart,h),this.toEditorPos(i.selectionEnd,h)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),f.from<f.to&&!f.insert.length&&e.inputState.composing>=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,i.updateRangeStart-1),Math.min(t.text.length,i.updateRangeStart+1)))&&this.handlers.compositionend(i)},this.handlers.characterboundsupdate=i=>{let r=[],o=null;for(let s=this.toEditorPos(i.rangeStart),a=this.toEditorPos(i.rangeEnd);s<a;s++){let l=e.coordsForChar(s);o=l&&new DOMRect(l.left,l.top,l.right-l.left,l.bottom-l.top)||o||new DOMRect,r.push(o)}t.updateCharacterBounds(i.rangeStart,r)},this.handlers.textformatupdate=i=>{let r=[];for(let o of i.getTextFormats()){let s=o.underlineStyle,a=o.underlineThickness;if(!/none/i.test(s)&&!/none/i.test(a)){let l=this.toEditorPos(o.rangeStart),c=this.toEditorPos(o.rangeEnd);if(l<c){let u=`text-decoration: underline ${/^[a-z]/.test(s)?s+" ":s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${/thin/i.test(a)?1:2}px`;r.push(he.mark({attributes:{style:u}}).range(l,c))}}}e.dispatch({effects:fA.of(he.set(r))})},this.handlers.compositionstart=()=>{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:i}=this.composing;this.composing=null,i&&this.reset(e.state)}};for(let i in this.handlers)t.addEventListener(i,this.handlers[i]);this.measureReq={read:i=>{this.editContext.updateControlBounds(i.contentDOM.getBoundingClientRect());let r=Th(i.root);r&&r.rangeCount&&this.editContext.updateSelectionBounds(r.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,i=!1,r=this.pendingContextChange;return e.changes.iterChanges((o,s,a,l,c)=>{if(i)return;let u=c.length-(s-o);if(r&&s>=r.to)if(r.from==o&&r.to==s&&r.insert.eq(c)){r=this.pendingContextChange=null,t+=u,this.to+=u;return}else r=null,this.revertPending(e.state);if(o+=t,s+=t,s<=this.from)this.from+=u,this.to+=u;else if(o<this.to){if(o<this.from||s>this.to||this.to-this.from+c.length>3e4){i=!0;return}this.editContext.updateText(this.toContextPos(o),this.toContextPos(s),c.toString()),this.to+=u}t+=u}),r&&!i&&this.revertPending(e.state),!i}update(e){let t=this.pendingContextChange,i=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(i.from,i.to)&&e.transactions.some(r=>!r.isUserEvent("input.type")&&r.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,i=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),r=this.toContextPos(t.head);(this.editContext.selectionStart!=i||this.editContext.selectionEnd!=r)&&this.editContext.updateSelection(i,r)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to<e.doc.length&&this.to-t<500||this.to-this.from>1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let i=this.composing;return i&&i.drifted?i.editorBase+(e-i.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}},U=class n{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:i}=e;this.dispatchTransactions=e.dispatchTransactions||i&&(r=>r.forEach(o=>i(o,this)))||(r=>this.update(r)),this.dispatch=this.dispatch.bind(this),this._root=e.root||vq(e.parent)||document,this.viewState=new Qg(this,e.state||Ze.create(e)),e.scrollTo&&e.scrollTo.is(Og)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Xl).map(r=>new Ch(r));for(let r of this.plugins)r.update(this);this.observer=new gb(this),this.inputState=new ib(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Vg(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let t=e.length==1&&e[0]instanceof Ft?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,r,o=this.state;for(let h of e){if(h.startState!=o)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");o=h.state}if(this.destroyed){this.viewState.state=o;return}let s=this.hasFocus,a=0,l=null;e.some(h=>h.annotation(kA))?(this.inputState.notifiedFocused=s,a=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=RA(o,s),l||(a=1));let c=this.observer.delayedAndroidKey,u=null;if(c?(this.observer.clearDelayedAndroidKey(),u=this.observer.readChange(),(u&&!this.state.doc.eq(o.doc)||!this.state.selection.eq(o.selection))&&(u=null)):this.observer.clear(),o.facet(Ze.phrases)!=this.state.facet(Ze.phrases))return this.setState(o);r=Fg.create(this,o,e),r.flags|=a;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection,{x:p,y:m}=this.state.facet(n.cursorScrollMargin);f=new wh(d.empty?d:$.cursor(d.head,d.head>d.anchor?-1:1),"nearest","nearest",m,p)}for(let d of h.effects)d.is(Og)&&(f=d.value.clip(this.state))}this.viewState.update(r,f),this.bidiCache=Kg.update(this.bidiCache,r.changes),r.empty||(this.updatePlugins(r),this.inputState.update(r)),t=this.docView.update(r),this.state.facet(yh)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(r.startState.facet(Mg)!=r.state.facet(Mg)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!r.empty)for(let h of this.state.facet(z0))try{h(r)}catch(d){It(this.state,d,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!bA(this,u)&&c.force&&ec(this.contentDOM,c.key,c.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new Qg(this,e),this.plugins=e.facet(Xl).map(i=>new Ch(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView.destroy(),this.docView=new Vg(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Xl),i=e.state.facet(Xl);if(t!=i){let r=[];for(let o of i){let s=t.indexOf(o);if(s<0)r.push(new Ch(o));else{let a=this.plugins[s];a.mustUpdate=e,r.push(a)}}for(let o of this.plugins)o.mustUpdate!=e&&o.destroy(this);this.plugins=r,this.pluginMap.clear()}else for(let r of this.plugins)r.mustUpdate=e;for(let r=0;r<this.plugins.length;r++)this.plugins[r].update(this);t!=i&&this.inputState.ensureHandlers(this.plugins)}docViewUpdate(){for(let e of this.plugins){let t=e.value;if(t&&t.docViewUpdate)try{t.docViewUpdate(this)}catch(i){It(this.state,i,"doc view update listener")}}}measure(e=!0){if(this.destroyed)return;if(this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.viewState.scrollParent,r=this.viewState.getScrollOffset(),{scrollAnchorPos:o,scrollAnchorHeight:s}=this.viewState;Math.abs(r-this.viewState.scrollOffset)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let a=0;;a++){if(s<0)if(GT(i||this.win))o=-1,s=this.viewState.heightMap.height;else{let d=this.viewState.scrollAnchorAt(r);o=d.from,s=d.top}this.updateState=1;let l=this.viewState.measure();if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(a>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let c=[];l&4||([this.measureRequests,c]=[c,this.measureRequests]);let u=c.map(d=>{try{return d.read(this)}catch(p){return It(this.state,p),NT}}),f=Fg.create(this,this.state,[]),h=!1;f.flags|=l,t?t.flags|=l:t=f,this.updateState=2,f.empty||(this.updatePlugins(f),this.inputState.update(f),this.updateAttrs(),h=this.docView.update(f),h&&this.docViewUpdate());for(let d=0;d<c.length;d++)if(u[d]!=NT)try{let p=c[d];p.write&&p.write(u[d],this)}catch(p){It(this.state,p)}if(h&&this.docView.updateSelection(!0),!f.viewportChanged&&this.measureRequests.length==0){if(this.viewState.editorHeight)if(this.viewState.scrollTarget){this.docView.scrollIntoView(this.viewState.scrollTarget),this.viewState.scrollTarget=null,s=-1;continue}else{let p=((o<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(o).top)-s)/this.scaleY;if((p>1||p<-1)&&(i==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){r=r+p,i?i.scrollTop+=p:this.win.scrollBy(0,p),s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let a of this.state.facet(z0))a(t)}get themeClasses(){return pb+" "+(this.state.facet(db)?MA:AA)+" "+this.state.facet(Mg)}updateAttrs(){let e=$T(this,hA,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Fr)?"true":"false",class:"cm-content",style:`${z.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),$T(this,Ob,t);let i=this.observer.ignore(()=>{let r=gT(this.contentDOM,this.contentAttrs,t),o=gT(this.dom,this.editorAttrs,e);return r||o});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let r of i.effects)if(r.is(n.announce)){t&&(this.announceDOM.textContent=""),t=!1;let o=this.announceDOM.appendChild(document.createElement("div"));o.textContent=r.value}}mountStyles(){this.styleModules=this.state.facet(yh);let e=this.state.facet(n.cspNonce);ni.mount(this.root,this.styleModules.concat(EV).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;t<this.measureRequests.length;t++)if(this.measureRequests[t].key===e.key){this.measureRequests[t]=e;return}}this.measureRequests.push(e)}}plugin(e){let t=this.pluginMap.get(e);return(t===void 0||t&&t.plugin!=e)&&this.pluginMap.set(e,t=this.plugins.find(i=>i.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return D0(this,e,wT(this,e,t,i))}moveByGroup(e,t){return D0(this,e,wT(this,e,t,i=>Gq(this,e.head,i)))}visualLineSide(e,t){let i=this.bidiSpans(e),r=this.textDirectionAt(e.from),o=i[t?i.length-1:0];return $.cursor(o.side(t,r)+e.from,o.forward(!t,r)?1:-1)}moveToLineBoundary(e,t,i=!0){return Kq(this,e,t,i)}moveVertically(e,t,i){return D0(this,e,Xq(this,e,t,i))}domAtPos(e,t=1){return this.docView.domAtPos(e,t)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){this.readMeasured();let i=J0(this,e,t);return i&&i.pos}posAndSideAtCoords(e,t=!0){return this.readMeasured(),J0(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let r=this.state.doc.lineAt(e),o=this.bidiSpans(r),s=o[oi.find(o,e-r.from,-1,t)];return Ah(i,s.dir==We.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(cA)||e<this.viewport.from||e>this.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>kV)return tA(e.length);let t=this.textDirectionAt(e.from),i;for(let o of this.bidiCache)if(o.from==e.from&&o.dir==t&&(o.fresh||eA(o.isolates,i=xT(this,e))))return o.order;i||(i=xT(this,e));let r=Oq(e.text,t,i);return this.bidiCache.push(new Kg(e.from,e.to,t,i,!0,r)),r}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||z.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{KT(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){var i,r,o,s;return Og.of(new wh(typeof e=="number"?$.cursor(e):e,(i=t.y)!==null&&i!==void 0?i:"nearest",(r=t.x)!==null&&r!==void 0?r:"nearest",(o=t.yMargin)!==null&&o!==void 0?o:5,(s=t.xMargin)!==null&&s!==void 0?s:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,i=this.viewState.scrollAnchorAt(e);return Og.of(new wh($.cursor(i.from),"start","start",i.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return Yt.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return Yt.define(()=>({}),{eventObservers:e})}static theme(e,t){let i=ni.newName(),r=[Mg.of(i),yh.of(mb(`.${i}`,e))];return t&&t.dark&&r.push(db.of(!0)),r}static baseTheme(e){return $r.lowest(yh.of(mb("."+pb,e,PA)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),r=i&&it.get(i)||it.get(e);return((t=r==null?void 0:r.root)===null||t===void 0?void 0:t.view)||null}};U.styleModule=yh;U.inputHandler=aA;U.clipboardInputFilter=Eb;U.clipboardOutputFilter=Sb;U.scrollHandler=uA;U.focusChangeEffect=lA;U.perLineTextDirection=cA;U.exceptionSink=sA;U.updateListener=z0;U.editable=Fr;U.mouseSelectionStyle=oA;U.dragMovesSelection=rA;U.clickAddsSelectionRange=iA;U.decorations=ey;U.blockWrappers=dA;U.outerDecorations=kb;U.atomicRanges=Ph;U.bidiIsolatedRanges=pA;U.cursorScrollMargin=H.define({combine:n=>{let e=5,t=5;for(let i of n)typeof i=="number"?e=t=i:{x:e,y:t}=i;return{x:e,y:t}}});U.scrollMargins=mA;U.darkTheme=db;U.cspNonce=H.define({combine:n=>n.length?n[0]:""});U.contentAttributes=Ob;U.editorAttributes=hA;U.lineWrapping=U.contentAttributes.of({class:"cm-lineWrapping"});U.announce=de.define();var kV=4096,NT={},Kg=class n{constructor(e,t,i,r,o,s){this.from=e,this.to=t,this.dir=i,this.isolates=r,this.fresh=o,this.order=s}static update(e,t){if(t.empty&&!e.some(o=>o.fresh))return e;let i=[],r=e.length?e[e.length-1].dir:We.LTR;for(let o=Math.max(0,e.length-10);o<e.length;o++){let s=e[o];s.dir==r&&!t.touchesRange(s.from,s.to)&&i.push(new n(t.mapPos(s.from,1),t.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return i}};function $T(n,e,t){for(let i=n.state.facet(e),r=i.length-1;r>=0;r--){let o=i[r],s=typeof o=="function"?o(n):o;s&&_b(s,t)}return t}var RV=z.mac?"mac":z.windows?"win":z.linux?"linux":"key";function TV(n,e){let t=n.split(/-(?!$)/),i=t[t.length-1];i=="Space"&&(i=" ");let r,o,s,a;for(let l=0;l<t.length-1;++l){let c=t[l];if(/^(cmd|meta|m)$/i.test(c))a=!0;else if(/^a(lt)?$/i.test(c))r=!0;else if(/^(c|ctrl|control)$/i.test(c))o=!0;else if(/^s(hift)?$/i.test(c))s=!0;else if(/^mod$/i.test(c))e=="mac"?a=!0:o=!0;else throw new Error("Unrecognized modifier name: "+c)}return r&&(i="Alt-"+i),o&&(i="Ctrl-"+i),a&&(i="Meta-"+i),s&&(i="Shift-"+i),i}function Pg(n,e,t){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t!==!1&&e.shiftKey&&(n="Shift-"+n),n}var AV=$r.default(U.domEventHandlers({keydown(n,e){return IV(MV(e.state),n,e,"editor")}})),sc=H.define({enables:AV}),jT=new WeakMap;function MV(n){let e=n.facet(sc),t=jT.get(e);return t||jT.set(e,t=DV(e.reduce((i,r)=>i.concat(r),[]))),t}var Lo=null,PV=4e3;function DV(n,e=RV){let t=Object.create(null),i=Object.create(null),r=(s,a)=>{let l=i[s];if(l==null)i[s]=a;else if(l!=a)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},o=(s,a,l,c,u)=>{var f,h;let d=t[s]||(t[s]=Object.create(null)),p=a.split(/ (?!$)/).map(b=>TV(b,e));for(let b=1;b<p.length;b++){let _=p.slice(0,b).join(" ");r(_,!0),d[_]||(d[_]={preventDefault:!0,stopPropagation:!1,run:[v=>{let x=Lo={view:v,prefix:_,scope:s};return setTimeout(()=>{Lo==x&&(Lo=null)},PV),!0}]})}let m=p.join(" ");r(m,!1);let g=d[m]||(d[m]={preventDefault:!1,stopPropagation:!1,run:((h=(f=d._any)===null||f===void 0?void 0:f.run)===null||h===void 0?void 0:h.slice())||[]});l&&g.run.push(l),c&&(g.preventDefault=!0),u&&(g.stopPropagation=!0)};for(let s of n){let a=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of a){let u=t[c]||(t[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:f}=s;for(let h in u)u[h].run.push(d=>f(d,vb))}let l=s[e]||s.key;if(l)for(let c of a)o(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&o(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return t}var vb=null;function IV(n,e,t,i){vb=e;let r=fT(e),o=ti(r,0),s=Yi(o)==r.length&&r!=" ",a="",l=!1,c=!1,u=!1;Lo&&Lo.view==t&&Lo.scope==i&&(a=Lo.prefix+" ",CA.indexOf(e.keyCode)<0&&(c=!0,Lo=null));let f=new Set,h=g=>{if(g){for(let b of g.run)if(!f.has(b)&&(f.add(b),b(t)))return g.stopPropagation&&(u=!0),!0;g.preventDefault&&(g.stopPropagation&&(u=!0),c=!0)}return!1},d=n[i],p,m;return d&&(h(d[a+Pg(r,e,!s)])?l=!0:s&&(e.altKey||e.metaKey||e.ctrlKey)&&!(z.windows&&e.ctrlKey&&e.altKey)&&!(z.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(p=jr[e.keyCode])&&p!=r?(h(d[a+Pg(p,e,!0)])||e.shiftKey&&(m=Kl[e.keyCode])!=r&&m!=p&&h(d[a+Pg(m,e,!1)]))&&(l=!0):s&&e.shiftKey&&h(d[a+Pg(r,e,!0)])&&(l=!0),!l&&h(d._any)&&(l=!0)),c&&(l=!0),l&&u&&e.stopPropagation(),vb=null,l}var pge=/x/.unicode!=null?"gu":"g";var xb=class extends ai{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?bh(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),r=Ah(t[0],i.direction!="rtl"),o=parseInt(i.lineHeight);return r.bottom-r.top>o*1.5?{left:r.left,right:r.right,top:r.top,bottom:r.top+o}:r}ignoreEvent(){return!1}};function Ab(n){let e=Yt.fromClass(class{constructor(t){this.view=t,this.placeholder=n?he.set([he.widget({widget:new xb(n),side:1}).range(0)]):he.none}get decorations(){return this.view.state.doc.length?he.none:this.placeholder}},{decorations:t=>t.decorations});return typeof n=="string"?[e,U.contentAttributes.of({"aria-placeholder":n})]:e}var Dg="-10000px",Gg=class{constructor(e,t,i,r){this.facet=t,this.createTooltipView=i,this.removeTooltipView=r,this.input=e.state.facet(t),this.tooltips=this.input.filter(s=>s);let o=null;this.tooltipViews=this.tooltips.map(s=>o=i(s,o))}update(e,t){var i;let r=e.state.facet(this.facet),o=r.filter(l=>l);if(r===this.input){for(let l of this.tooltipViews)l.update&&l.update(e);return!1}let s=[],a=t?[]:null;for(let l=0;l<o.length;l++){let c=o[l],u=-1;if(c){for(let f=0;f<this.tooltips.length;f++){let h=this.tooltips[f];h&&h.create==c.create&&(u=f)}if(u<0)s[l]=this.createTooltipView(c,l?s[l-1]:null),a&&(a[l]=!!c.above);else{let f=s[l]=this.tooltipViews[u];a&&(a[l]=t[u]),f.update&&f.update(e)}}}for(let l of this.tooltipViews)s.indexOf(l)<0&&(this.removeTooltipView(l),(i=l.destroy)===null||i===void 0||i.call(l));return t&&(a.forEach((l,c)=>t[c]=l),t.length=a.length),this.input=r,this.tooltips=o,this.tooltipViews=s,!0}};function DA(n={}){return Bg.of(n)}function LV(n){let e=n.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}var Bg=H.define({combine:n=>{var e,t,i;return{position:z.ios?"absolute":((e=n.find(r=>r.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(r=>r.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(r=>r.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||LV}}}),FT=new WeakMap,Mb=Yt.fromClass(class{constructor(n){this.view=n,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Bg);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new Gg(n,Dh,(t,i)=>this.createTooltip(t,i),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n,this.above);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Bg);if(i.position!=this.position&&!this.madeAbsolute){this.position=i.position;for(let r of this.manager.tooltipViews)r.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let r of this.manager.tooltipViews)this.container.appendChild(r.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n,e){let t=n.create(this.view),i=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),n.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let r=document.createElement("div");r.className="cm-tooltip-arrow",t.dom.appendChild(r)}return t.dom.style.position=this.position,t.dom.style.top=Dg,t.dom.style.left="0px",this.container.insertBefore(t.dom,i),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var n,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let i of this.manager.tooltipViews)i.dom.remove(),(n=i.destroy)===null||n===void 0||n.call(i);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:o}=this.manager.tooltipViews[0];if(z.safari){let s=o.getBoundingClientRect();t=Math.abs(s.top+1e4)>1||Math.abs(s.left)>1}else t=!!o.offsetParent&&o.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let o=this.parent.getBoundingClientRect();o.width&&o.height&&(n=o.width/this.parent.offsetWidth,e=o.height/this.parent.offsetHeight)}else({scaleX:n,scaleY:e}=this.view.viewState);let i=this.view.scrollDOM.getBoundingClientRect(),r=Rb(this.view);return{visible:{left:i.left+r.left,top:i.top+r.top,right:i.right-r.right,bottom:i.bottom-r.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((o,s)=>{let a=this.manager.tooltipViews[s];return a.getCoords?a.getCoords(o.pos):this.view.coordsAtPos(o.pos)}),size:this.manager.tooltipViews.map(({dom:o})=>o.getBoundingClientRect()),space:this.view.state.facet(Bg).tooltipSpace(this.view),scaleX:n,scaleY:e,makeAbsolute:t}}writeMeasure(n){var e;if(n.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let a of this.manager.tooltipViews)a.dom.style.position="absolute"}let{visible:t,space:i,scaleX:r,scaleY:o}=n,s=[];for(let a=0;a<this.manager.tooltips.length;a++){let l=this.manager.tooltips[a],c=this.manager.tooltipViews[a],{dom:u}=c,f=n.pos[a],h=n.size[a];if(!f||l.clip!==!1&&(f.bottom<=Math.max(t.top,i.top)||f.top>=Math.min(t.bottom,i.bottom)||f.right<Math.max(t.left,i.left)-.1||f.left>Math.min(t.right,i.right)+.1)){u.style.top=Dg;continue}let d=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,p=d?7:0,m=h.right-h.left,g=(e=FT.get(c))!==null&&e!==void 0?e:h.bottom-h.top,b=c.offset||NV,_=this.view.textDirection==We.LTR,v=h.width>i.right-i.left?_?i.left:i.right-h.width:_?Math.max(i.left,Math.min(f.left-(d?14:0)+b.x,i.right-m)):Math.min(Math.max(i.left,f.left-m+(d?14:0)-b.x),i.right-m),x=this.above[a];!l.strictSide&&(x?f.top-g-p-b.y<i.top:f.bottom+g+p+b.y>i.bottom)&&x==i.bottom-f.bottom>f.top-i.top&&(x=this.above[a]=!x);let C=(x?f.top-i.top:i.bottom-f.bottom)-p;if(C<g&&c.resize!==!1){if(C<this.view.defaultLineHeight){u.style.top=Dg;continue}FT.set(c,g),u.style.height=(g=C)/o+"px"}else u.style.height&&(u.style.height="");let E=x?f.top-g-p-b.y:f.bottom+p+b.y,S=v+m;if(c.overlap!==!0)for(let w of s)w.left<S&&w.right>v&&w.top<E+g&&w.bottom>E&&(E=x?w.top-g-2-p:w.bottom+p+2);if(this.position=="absolute"?(u.style.top=(E-n.parent.top)/o+"px",qT(u,(v-n.parent.left)/r)):(u.style.top=E/o+"px",qT(u,v/r)),d){let w=f.left+(_?b.x:-b.x)-(v+14-7);d.style.left=w/r+"px"}c.overlap!==!0&&s.push({left:v,top:E,right:S,bottom:E+g}),u.classList.toggle("cm-tooltip-above",x),u.classList.toggle("cm-tooltip-below",!x),c.positioned&&c.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Dg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function qT(n,e){let t=parseInt(n.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(n.style.left=e+"px")}var BV=U.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),NV={x:0,y:0},Dh=H.define({enables:[Mb,BV]}),Xg=H.define({combine:n=>n.reduce((e,t)=>e.concat(t),[])}),Yg=class n{static create(e){return new n(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Gg(e,Xg,(t,i)=>this.createHostedView(t,i),t=>t.dom.remove())}createHostedView(e,t){let i=e.create(this.view);return i.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(i.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&i.mount&&i.mount(this.view),i}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let i of this.manager.tooltipViews){let r=i[e];if(r!==void 0){if(t===void 0)t=r;else if(t!==r)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}},$V=Dh.compute([Xg],n=>{let e=n.facet(Xg);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var i;return(i=t.end)!==null&&i!==void 0?i:t.pos})),create:Yg.create,above:e[0].above,arrow:e.some(t=>t.arrow)}}),jV=H.define(),bb=class{constructor(e,t,i,r,o,s){this.view=e,this.source=t,this.field=i,this.locked=r,this.setHover=o,this.hoverTime=s,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(e){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;e<this.hoverTime?this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime-e):this.startHover()}startHover(){clearTimeout(this.restartTimeout);let{view:e,lastMove:t}=this,i=e.docView.tile.nearest(t.target);if(!i)return;let r,o=1;if(i.isWidget())r=i.posAtStart;else{if(r=e.posAtCoords(t),r==null)return;let s=e.coordsAtPos(r);if(!s||t.y<s.top||t.y>s.bottom||t.x<s.left-e.defaultCharacterWidth||t.x>s.right+e.defaultCharacterWidth)return;let a=e.bidiSpans(e.state.doc.lineAt(r)).find(c=>c.from<=r&&c.to>=r),l=a&&a.dir==We.RTL?-1:1;o=t.x<s.left?-l:l}this.activateHover(e,r,o)}activateHover(e,t,i,r){let o=this.source(e,t,i),s=a=>{if(a&&!(Array.isArray(a)&&!a.length)){let l=Array.isArray(a)?a:[a];r&&this.locked.set(l,r),e.dispatch({effects:this.setHover.of(l)})}};if(o&&"then"in o){let a=this.pending={pos:t};o.then(l=>{this.pending==a&&(this.pending=null,s(l))},l=>It(e.state,l,"hover tooltip"))}else s(o)}get tooltip(){let e=this.view.plugin(Mb),t=e?e.manager.tooltips.findIndex(i=>i.create==Yg.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,i;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:r,tooltip:o}=this;if(r.length&&!this.locked.has(r)&&o&&!FV(o.dom,e)||this.pending){let{pos:s}=r[0]||this.pending,a=(i=(t=r[0])===null||t===void 0?void 0:t.end)!==null&&i!==void 0?i:s;(s==a?this.view.posAtCoords(this.lastMove)!=s:!qV(this.view,s,a,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length&&!this.locked.has(t)){let{tooltip:i}=this;i&&i.dom.contains(e.relatedTarget)?this.watchTooltipLeave(i.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=i=>{e.removeEventListener("mouseleave",t);let{active:r}=this;r.length&&!this.locked.has(r)&&!this.view.dom.contains(i.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),clearTimeout(this.restartTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}},Ig=4;function FV(n,e){let{left:t,right:i,top:r,bottom:o}=n.getBoundingClientRect(),s;if(s=n.querySelector(".cm-tooltip-arrow")){let a=s.getBoundingClientRect();r=Math.min(a.top,r),o=Math.max(a.bottom,o)}return e.clientX>=t-Ig&&e.clientX<=i+Ig&&e.clientY>=r-Ig&&e.clientY<=o+Ig}function qV(n,e,t,i,r,o){let s=n.scrollDOM.getBoundingClientRect(),a=n.documentTop+n.documentPadding.top+n.contentHeight;if(s.left>i||s.right<i||s.top>r||Math.min(s.bottom,a)<r)return!1;let l=n.posAtCoords({x:i,y:r},!1);return l>=e&&l<=t}function IA(n,e={}){let t=de.define(),i=new WeakMap,r=qt.define({create(){return[]},update(s,a){let l=i.get(s);if(s.length&&(e.hideOnChange&&(a.docChanged||a.selection)?s=[]:l&&l(a)?s=[]:e.hideOn&&(s=s.filter(c=>!e.hideOn(a,c)))),a.docChanged&&s.length){let c=[];for(let u of s){let f=a.changes.mapPos(u.pos,-1,Ot.TrackDel);if(f!=null){let h=Object.assign(Object.create(null),u);h.pos=f,h.end!=null&&(h.end=a.changes.mapPos(h.end)),c.push(h)}}s=c}for(let c of a.effects)c.is(t)&&(s=c.value,l=void 0),(c.is(VV)&&!c.value||c.value==r)&&(s=[]);return s.length&&l&&i.set(s,l),s},provide:s=>Xg.from(s)}),o=Yt.define(s=>new bb(s,n,r,i,t,e.hoverTime||300));return{active:r,extension:[r,o,jV.of(o),$V]}}function Pb(n,e){let t=n.plugin(Mb);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}var VV=de.define();var VT=H.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});var HV=Yt.fromClass(class{constructor(n){this.input=n.state.facet(Zg),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(VT);this.top=new Zl(n,!0,e.topContainer),this.bottom=new Zl(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(VT);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Zl(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Zl(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Zg);if(t!=this.input){let i=t.filter(l=>l),r=[],o=[],s=[],a=[];for(let l of i){let c=this.specs.indexOf(l),u;c<0?(u=l(n.view),a.push(u)):(u=this.panels[c],u.update&&u.update(n)),r.push(u),(u.top?o:s).push(u)}this.specs=i,this.panels=r,this.top.sync(o),this.bottom.sync(s);for(let l of a)l.dom.classList.add("cm-panel"),l.mount&&l.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>U.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})}),Zl=class{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=HT(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=HT(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}};function HT(n){let e=n.nextSibling;return n.remove(),e}var Zg=H.define({enables:HV});var er=class extends ei{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}};er.prototype.elementClass="";er.prototype.toDOM=void 0;er.prototype.mapMode=Ot.TrackBefore;er.prototype.startSide=er.prototype.endSide=-1;er.prototype.point=!0;var zV=0,Ih=class{constructor(e,t){this.from=e,this.to=t}},ce=class{constructor(e={}){this.id=zV++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Zt.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}};ce.closedBy=new ce({deserialize:n=>n.split(" ")});ce.openedBy=new ce({deserialize:n=>n.split(" ")});ce.group=new ce({deserialize:n=>n.split(" ")});ce.isolate=new ce({deserialize:n=>{if(n&&n!="rtl"&&n!="ltr"&&n!="auto")throw new RangeError("Invalid value for isolate: "+n);return n||"auto"}});ce.contextHash=new ce({perNode:!0});ce.lookAhead=new ce({perNode:!0});ce.mounted=new ce({perNode:!0});var zs=class{constructor(e,t,i,r=!1){this.tree=e,this.overlay=t,this.parser=i,this.bracketed=r}static get(e){return e&&e.props&&e.props[ce.mounted.id]}},WV=Object.create(null),Zt=class n{constructor(e,t,i,r=0){this.name=e,this.props=t,this.id=i,this.flags=r}static define(e){let t=e.props&&e.props.length?Object.create(null):WV,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),r=new n(e.name||"",t,e.id,i);if(e.props){for(let o of e.props)if(Array.isArray(o)||(o=o(r)),o){if(o[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[o[0].id]=o[1]}}return r}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(ce.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let r of i.split(" "))t[r]=e[i];return i=>{for(let r=i.prop(ce.group),o=-1;o<(r?r.length:0);o++){let s=t[o<0?i.name:r[o]];if(s)return s}}}};Zt.none=new Zt("",Object.create(null),0,8);var Lh=class n{constructor(e){this.types=e;for(let t=0;t<e.length;t++)if(e[t].id!=t)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let t=[];for(let i of this.types){let r=null;for(let o of e){let s=o(i);if(s){r||(r=Object.assign({},i.props));let a=s[1],l=s[0];l.combine&&l.id in r&&(a=l.combine(r[l.id],a)),r[l.id]=a}}t.push(r?new Zt(i.name,r,i.id,i.flags):i)}return new n(t)}},ny=new WeakMap,LA=new WeakMap,rt;(function(n){n[n.ExcludeBuffers=1]="ExcludeBuffers",n[n.IncludeAnonymous=2]="IncludeAnonymous",n[n.IgnoreMounts=4]="IgnoreMounts",n[n.IgnoreOverlays=8]="IgnoreOverlays",n[n.EnterBracketed=16]="EnterBracketed"})(rt||(rt={}));var gt=class n{constructor(e,t,i,r,o){if(this.type=e,this.children=t,this.positions=i,this.length=r,this.props=null,o&&o.length){this.props=Object.create(null);for(let[s,a]of o)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=zs.get(this);if(e&&!e.overlay)return e.tree.toString();let t="";for(let i of this.children){let r=i.toString();r&&(t&&(t+=","),t+=r)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(t.length?"("+t+")":""):t}cursor(e=0){return new $h(this.topNode,e)}cursorAt(e,t=0,i=0){let r=ny.get(this)||this.topNode,o=new $h(r);return o.moveTo(e,t),ny.set(this,o._tree),o}get topNode(){return new tr(this,0,0,null)}resolve(e,t=0){let i=Bh(ny.get(this)||this.topNode,e,t,!1);return ny.set(this,i),i}resolveInner(e,t=0){let i=Bh(LA.get(this)||this.topNode,e,t,!0);return LA.set(this,i),i}resolveStack(e,t=0){return UV(this,e,t)}iterate(e){let{enter:t,leave:i,from:r=0,to:o=this.length}=e,s=e.mode||0,a=(s&rt.IncludeAnonymous)>0;for(let l=this.cursor(s|rt.IncludeAnonymous);;){let c=!1;if(l.from<=o&&l.to>=r&&(!a&&l.type.isAnonymous||t(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&i&&(a||!l.type.isAnonymous)&&i(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:jb(Zt.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,r)=>new n(this.type,t,i,r,this.propValues),e.makeTree||((t,i,r)=>new n(Zt.none,t,i,r)))}static build(e){return QV(e)}};gt.empty=new gt(Zt.none,[],[],0);var Db=class n{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new n(this.buffer,this.index)}},jo=class n{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return Zt.none}toString(){let e=[];for(let t=0;t<this.buffer.length;)e.push(this.childString(t)),t=this.buffer[t+3];return e.join(",")}childString(e){let t=this.buffer[e],i=this.buffer[e+3],r=this.set.types[t],o=r.name;if(/\W/.test(o)&&!r.isError&&(o=JSON.stringify(o)),e+=4,i==e)return o;let s=[];for(;e<i;)s.push(this.childString(e)),e=this.buffer[e+3];return o+"("+s.join(",")+")"}findChild(e,t,i,r,o){let{buffer:s}=this,a=-1;for(let l=e;l!=t&&!($A(o,r,s[l+1],s[l+2])&&(a=l,i>0));l=s[l+3]);return a}slice(e,t,i){let r=this.buffer,o=new Uint16Array(t-e),s=0;for(let a=e,l=0;a<t;){o[l++]=r[a++],o[l++]=r[a++]-i;let c=o[l++]=r[a++]-i;o[l++]=r[a++]-e,s=Math.max(s,c)}return new n(o,s,this.set)}};function $A(n,e,t,i){switch(n){case-2:return t<e;case-1:return i>=e&&t<e;case 0:return t<e&&i>e;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function Bh(n,e,t,i){for(var r;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to<e);){let s=!i&&n instanceof tr&&n.index<0?null:n.parent;if(!s)return n;n=s}let o=i?0:rt.IgnoreOverlays;if(i)for(let s=n,a=s.parent;a;s=a,a=s.parent)s instanceof tr&&s.index<0&&((r=a.enter(e,t,o))===null||r===void 0?void 0:r.from)!=s.from&&(n=a);for(;;){let s=n.enter(e,t,o);if(!s)return n;n=s}}var ry=class{cursor(e=0){return new $h(this,e)}getChild(e,t=null,i=null){let r=BA(this,e,t,i);return r.length?r[0]:null}getChildren(e,t=null,i=null){return BA(this,e,t,i)}resolve(e,t=0){return Bh(this,e,t,!1)}resolveInner(e,t=0){return Bh(this,e,t,!0)}matchContext(e){return Ib(this.parent,e)}enterUnfinishedNodesBefore(e){let t=this.childBefore(e),i=this;for(;t;){let r=t.lastChild;if(!r||r.to!=t.to)break;r.type.isError&&r.from==r.to?(i=t,t=r.prevSibling):t=r}return i}get node(){return this}get next(){return this.parent}},tr=class n extends ry{constructor(e,t,i,r){super(),this._tree=e,this.from=t,this.index=i,this._parent=r}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,t,i,r,o=0){for(let s=this;;){for(let{children:a,positions:l}=s._tree,c=t>0?a.length:-1;e!=c;e+=t){let u=a[e],f=l[e]+s.from,h;if(!(!(o&rt.EnterBracketed&&u instanceof gt&&(h=zs.get(u))&&!h.overlay&&h.bracketed&&i>=f&&i<=f+u.length)&&!$A(r,i,f,f+u.length))){if(u instanceof jo){if(o&rt.ExcludeBuffers)continue;let d=u.findChild(0,u.buffer.length,t,i-f,r);if(d>-1)return new Nh(new Lb(s,u,e,f),null,d)}else if(o&rt.IncludeAnonymous||!u.type.isAnonymous||$b(u)){let d;if(!(o&rt.IgnoreMounts)&&(d=zs.get(u))&&!d.overlay)return new n(d.tree,f,e,s);let p=new n(u,f,e,s);return o&rt.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(t<0?u.children.length-1:0,t,i,r,o)}}}if(o&rt.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?e=s.index+t:e=t<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,i=0){let r;if(!(i&rt.IgnoreOverlays)&&(r=zs.get(this._tree))&&r.overlay){let o=e-this.from,s=i&rt.EnterBracketed&&r.bracketed;for(let{from:a,to:l}of r.overlay)if((t>0||s?a<=o:a<o)&&(t<0||s?l>=o:l>o))return new n(r.tree,r.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}};function BA(n,e,t,i){let r=n.cursor(),o=[];if(!r.firstChild())return o;if(t!=null){for(let s=!1;!s;)if(s=r.type.is(t),!r.nextSibling())return o}for(;;){if(i!=null&&r.type.is(i))return o;if(r.type.is(e)&&o.push(r.node),!r.nextSibling())return i==null?o:[]}}function Ib(n,e,t=e.length-1){for(let i=n;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}var Lb=class{constructor(e,t,i,r){this.parent=e,this.buffer=t,this.index=i,this.start=r}},Nh=class n extends ry{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){super(),this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.context.start,i);return o<0?null:new n(this.context,this,o)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,i=0){if(i&rt.ExcludeBuffers)return null;let{buffer:r}=this.context,o=r.findChild(this.index+4,r.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return o<0?null:new n(this.context,this,o)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new n(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new n(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,r=this.index+4,o=i.buffer[this.index+3];if(o>r){let s=i.buffer[this.index+1];e.push(i.slice(r,o,s)),t.push(0)}return new gt(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}};function jA(n){if(!n.length)return null;let e=0,t=n[0];for(let o=1;o<n.length;o++){let s=n[o];(s.from>t.from||s.to<t.to)&&(t=s,e=o)}let i=t instanceof tr&&t.index<0?null:t.parent,r=n.slice();return i?r[e]=i:r.splice(e,1),new Bb(r,t)}var Bb=class{constructor(e,t){this.heads=e,this.node=t}get next(){return jA(this.heads)}};function UV(n,e,t){let i=n.resolveInner(e,t),r=null;for(let o=i instanceof tr?i:i.context.parent;o;o=o.parent)if(o.index<0){let s=o.parent;(r||(r=[i])).push(s.resolve(e,t)),o=s}else{let s=zs.get(o.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new tr(s.tree,s.overlay[0].from+o.from,-1,o);(r||(r=[i])).push(Bh(a,e,t,!1))}}return r?jA(r):i}var $h=class{get name(){return this.type.name}constructor(e,t=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=t&~rt.EnterBracketed,e instanceof tr)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:r}=this.buffer;return this.type=t||r.set.types[r.buffer[e]],this.from=i+r.buffer[e+1],this.to=i+r.buffer[e+2],!0}yield(e){return e?e instanceof tr?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:r}=this.buffer,o=r.findChild(this.index+4,r.buffer[this.index+3],e,t-this.buffer.start,i);return o<0?!1:(this.stack.push(this.index),this.yieldBuf(o))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&rt.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&rt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&rt.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let r=i<0?0:this.stack[i]+4;if(this.index!=r)return this.yieldBuf(t.findChild(r,this.index,-1,0,4))}else{let r=t.buffer[this.index+3];if(r<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(r)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:r}=this;if(r){if(e>0){if(this.index<r.buffer.buffer.length)return!1}else for(let o=0;o<this.index;o++)if(r.buffer.buffer[o+3]<this.index)return!1;({index:t,parent:i}=r)}else({index:t,_parent:i}=this._tree);for(;i;{index:t,_parent:i}=i)if(t>-1)for(let o=t+e,s=e<0?-1:i._tree.children.length;o!=s;o+=e){let a=i._tree.children[o];if(this.mode&rt.IncludeAnonymous||a instanceof jo||!a.type.isAnonymous||$b(a))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,t););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,t=null,i=0;if(e&&e.context==this.buffer)e:for(let r=this.index,o=this.stack.length;o>=0;){for(let s=e;s;s=s._parent)if(s.index==r){if(r==this.index)return s;t=s,i=o+1;break e}r=this.stack[--o]}for(let r=i;r<this.stack.length;r++)t=new Nh(this.buffer,t,this.stack[r]);return this.bufferNode=new Nh(this.buffer,t,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,t){for(let i=0;;){let r=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){i++;continue}this.type.isAnonymous||(r=!0)}for(;;){if(r&&t&&t(this),r=this.type.isAnonymous,!i)return;if(this.nextSibling())break;this.parent(),i--,r=!0}}}matchContext(e){if(!this.buffer)return Ib(this.node.parent,e);let{buffer:t}=this.buffer,{types:i}=t.set;for(let r=e.length-1,o=this.stack.length-1;r>=0;o--){if(o<0)return Ib(this._tree,e,r);let s=i[t.buffer[this.stack[o]]];if(!s.isAnonymous){if(e[r]&&e[r]!=s.name)return!1;r--}}return!0}};function $b(n){return n.children.some(e=>e instanceof jo||!e.type.isAnonymous||$b(e))}function QV(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:r=1024,reused:o=[],minRepeatType:s=i.types.length}=n,a=Array.isArray(t)?new Db(t,t.length):t,l=i.types,c=0,u=0;function f(C,E,S,w,R,A){let{id:I,start:D,end:N,size:W}=a,Re=u,_e=c;if(W<0)if(a.next(),W==-1){let $e=o[I];S.push($e),w.push(D-C);return}else if(W==-3){c=I;return}else if(W==-4){u=I;return}else throw new RangeError(`Unrecognized record size: ${W}`);let ue=l[I],re,me,Ue=D-C;if(N-D<=r&&(me=g(a.pos-E,R))){let $e=new Uint16Array(me.size-me.skip),Ct=a.pos-me.size,Nt=$e.length;for(;a.pos>Ct;)Nt=b(me.start,$e,Nt);re=new jo($e,N-me.start,i),Ue=me.start-C}else{let $e=a.pos-W;a.next();let Ct=[],Nt=[],fn=I>=s?I:-1,ct=0,Ti=N;for(;a.pos>$e;)fn>=0&&a.id==fn&&a.size>=0?(a.end<=Ti-r&&(p(Ct,Nt,D,ct,a.end,Ti,fn,Re,_e),ct=Ct.length,Ti=a.end),a.next()):A>2500?h(D,$e,Ct,Nt):f(D,$e,Ct,Nt,fn,A+1);if(fn>=0&&ct>0&&ct<Ct.length&&p(Ct,Nt,D,ct,D,Ti,fn,Re,_e),Ct.reverse(),Nt.reverse(),fn>-1&&ct>0){let Zo=d(ue,_e);re=jb(ue,Ct,Nt,0,Ct.length,0,N-D,Zo,Zo)}else re=m(ue,Ct,Nt,N-D,Re-N,_e)}S.push(re),w.push(Ue)}function h(C,E,S,w){let R=[],A=0,I=-1;for(;a.pos>E;){let{id:D,start:N,end:W,size:Re}=a;if(Re>4)a.next();else{if(I>-1&&N<I)break;I<0&&(I=W-r),R.push(D,N,W),A++,a.next()}}if(A){let D=new Uint16Array(A*4),N=R[R.length-2];for(let W=R.length-3,Re=0;W>=0;W-=3)D[Re++]=R[W],D[Re++]=R[W+1]-N,D[Re++]=R[W+2]-N,D[Re++]=Re;S.push(new jo(D,R[2]-N,i)),w.push(N-C)}}function d(C,E){return(S,w,R)=>{let A=0,I=S.length-1,D,N;if(I>=0&&(D=S[I])instanceof gt){if(!I&&D.type==C&&D.length==R)return D;(N=D.prop(ce.lookAhead))&&(A=w[I]+D.length+N)}return m(C,S,w,R,A,E)}}function p(C,E,S,w,R,A,I,D,N){let W=[],Re=[];for(;C.length>w;)W.push(C.pop()),Re.push(E.pop()+S-R);C.push(m(i.types[I],W,Re,A-R,D-A,N)),E.push(R-S)}function m(C,E,S,w,R,A,I){if(A){let D=[ce.contextHash,A];I=I?[D].concat(I):[D]}if(R>25){let D=[ce.lookAhead,R];I=I?[D].concat(I):[D]}return new gt(C,E,S,w,I)}function g(C,E){let S=a.fork(),w=0,R=0,A=0,I=S.end-r,D={size:0,start:0,skip:0};e:for(let N=S.pos-C;S.pos>N;){let W=S.size;if(S.id==E&&W>=0){D.size=w,D.start=R,D.skip=A,A+=4,w+=4,S.next();continue}let Re=S.pos-W;if(W<0||Re<N||S.start<I)break;let _e=S.id>=s?4:0,ue=S.start;for(S.next();S.pos>Re;){if(S.size<0)if(S.size==-3||S.size==-4)_e+=4;else break e;else S.id>=s&&(_e+=4);S.next()}R=ue,w+=W,A+=_e}return(E<0||w==C)&&(D.size=w,D.start=R,D.skip=A),D.size>4?D:void 0}function b(C,E,S){let{id:w,start:R,end:A,size:I}=a;if(a.next(),I>=0&&w<s){let D=S;if(I>4){let N=a.pos-(I-4);for(;a.pos>N;)S=b(C,E,S)}E[--S]=D,E[--S]=A-C,E[--S]=R-C,E[--S]=w}else I==-3?c=w:I==-4&&(u=w);return S}let _=[],v=[];for(;a.pos>0;)f(n.start||0,n.bufferStart||0,_,v,-1,0);let x=(e=n.length)!==null&&e!==void 0?e:_.length?v[0]+_[0].length:0;return new gt(l[n.topID],_.reverse(),v.reverse(),x)}var NA=new WeakMap;function iy(n,e){if(!n.isAnonymous||e instanceof jo||e.type!=n)return 1;let t=NA.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof gt)){t=1;break}t+=iy(n,i)}NA.set(e,t)}return t}function jb(n,e,t,i,r,o,s,a,l){let c=0;for(let p=i;p<r;p++)c+=iy(n,e[p]);let u=Math.ceil(c*1.5/8),f=[],h=[];function d(p,m,g,b,_){for(let v=g;v<b;){let x=v,C=m[v],E=iy(n,p[v]);for(v++;v<b;v++){let S=iy(n,p[v]);if(E+S>=u)break;E+=S}if(v==x+1){if(E>u){let S=p[x];d(S.children,S.positions,0,S.children.length,m[x]+_);continue}f.push(p[x])}else{let S=m[v-1]+p[v-1].length-C;f.push(jb(n,p,m,x,v,C,S,null,l))}h.push(C+_-o)}}return d(e,t,i,r,0),(a||l)(f,h,s)}var Ws=class n{constructor(e,t,i,r,o=!1,s=!1){this.from=e,this.to=t,this.tree=i,this.offset=r,this.open=(o?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let r=[new n(0,e.length,e,0,!1,i)];for(let o of t)o.to>e.length&&r.push(o);return r}static applyChanges(e,t,i=128){if(!t.length)return e;let r=[],o=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<t.length?t[a]:null,f=u?u.fromA:1e9;if(f-l>=i)for(;s&&s.from<f;){let h=s;if(l>=h.from||f<=h.to||c){let d=Math.max(h.from,l)-c,p=Math.min(h.to,f)-c;h=d>=p?null:new n(d,p,h.tree,h.offset+c,a>0,!!u)}if(h&&r.push(h),s.to>f)break;s=o<e.length?e[o++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return r}},ac=class{startParse(e,t,i){return typeof e=="string"&&(e=new Nb(e)),i=i?i.length?i.map(r=>new Ih(r.from,r.to)):[new Ih(0,0)]:[new Ih(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let r=this.startParse(e,t,i);for(;;){let o=r.advance();if(o)return o}}},Nb=class{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}};var bge=new ce({perNode:!0});var KV=0,Ci=class n{constructor(e,t,i,r){this.name=e,this.set=t,this.base=i,this.modified=r,this.id=KV++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let i=typeof e=="string"?e:"?";if(e instanceof n&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let r=new n(i,[],null,[]);if(r.set.push(r),t)for(let o of t.set)r.set.push(o);return r}static defineModifier(e){let t=new ly(e);return i=>i.modified.indexOf(t)>-1?i:ly.get(i.base||i,i.modified.concat(t).sort((r,o)=>r.id-o.id))}},GV=0,ly=class n{constructor(e){this.name=e,this.instances=[],this.id=GV++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(a=>a.base==e&&XV(t,a.modified));if(i)return i;let r=[],o=new Ci(e.name,r,e,t);for(let a of t)a.instances.push(o);let s=YV(t);for(let a of e.set)if(!a.modified.length)for(let l of s)r.push(n.get(a,l));return o}};function XV(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function YV(n){let e=[[]];for(let t=0;t<n.length;t++)for(let i=0,r=e.length;i<r;i++)e.push(e[i].concat(n[t]));return e.sort((t,i)=>i.length-t.length)}function cy(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let r of t.split(" "))if(r){let o=[],s=2,a=r;for(let f=0;;){if(a=="..."&&f>0&&f+3==r.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+r);if(o.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==r.length)break;let d=r[f++];if(f==r.length&&d=="!"){s=0;break}if(d!="/")throw new RangeError("Invalid path: "+r);a=r.slice(f)}let l=o.length-1,c=o[l];if(!c)throw new RangeError("Invalid path: "+r);let u=new Qs(i,s,l>0?o.slice(0,l):null);e[c]=u.sort(e[c])}}return VA.add(e)}var VA=new ce({combine(n,e){let t,i,r;for(;n||e;){if(!n||e&&n.depth>=e.depth?(r=e,e=e.next):(r=n,n=n.next),t&&t.mode==r.mode&&!r.context&&!t.context)continue;let o=new Qs(r.tags,r.mode,r.context);t?t.next=o:i=o,t=o}return i}}),Qs=class{constructor(e,t,i,r){this.tags=e,this.mode=t,this.context=i,this.next=r}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}};Qs.empty=new Qs([],2,null);function Hb(n,e){let t=Object.create(null);for(let o of n)if(!Array.isArray(o.tag))t[o.tag.id]=o.class;else for(let s of o.tag)t[s.id]=o.class;let{scope:i,all:r=null}=e||{};return{style:o=>{let s=r;for(let a of o)for(let l of a.set){let c=t[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:i}}function ZV(n,e){let t=null;for(let i of n){let r=i.style(e);r&&(t=t?t+" "+r:r)}return t}function HA(n,e,t,i=0,r=n.length){let o=new qb(i,Array.isArray(e)?e:[e],t);o.highlightRange(n.cursor(),i,r,"",o.highlighters),o.flush(r)}var qb=class{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,r,o){let{type:s,from:a,to:l}=e;if(a>=i||l<=t)return;s.isTop&&(o=this.highlighters.filter(d=>!d.scope||d.scope(s)));let c=r,u=JV(e)||Qs.empty,f=ZV(o,u.tags);if(f&&(c&&(c+=" "),c+=f,u.mode==1&&(r+=(r?" ":"")+f)),this.startSpan(Math.max(t,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(ce.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+a,1),p=this.highlighters.filter(g=>!g.scope||g.scope(h.tree.type)),m=e.firstChild();for(let g=0,b=a;;g++){let _=g<h.overlay.length?h.overlay[g]:null,v=_?_.from+a:l,x=Math.max(t,b),C=Math.min(i,v);if(x<C&&m)for(;e.from<C&&(this.highlightRange(e,x,C,r,o),this.startSpan(Math.min(C,e.to),c),!(e.to>=v||!e.nextSibling())););if(!_||v>i)break;b=_.to+a,b>t&&(this.highlightRange(d.cursor(),Math.max(t,_.from+a),Math.min(i,b),"",p),this.startSpan(Math.min(i,b),c))}m&&e.parent()}else if(e.firstChild()){h&&(r="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,r,o),this.startSpan(Math.min(i,e.to),c)}while(e.nextSibling());e.parent()}}};function JV(n){let e=n.type.prop(VA);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}var V=Ci.define,oy=V(),Fo=V(),FA=V(Fo),qA=V(Fo),qo=V(),sy=V(qo),Fb=V(qo),rr=V(),Us=V(rr),nr=V(),ir=V(),Vb=V(),jh=V(Vb),ay=V(),B={comment:oy,lineComment:V(oy),blockComment:V(oy),docComment:V(oy),name:Fo,variableName:V(Fo),typeName:FA,tagName:V(FA),propertyName:qA,attributeName:V(qA),className:V(Fo),labelName:V(Fo),namespace:V(Fo),macroName:V(Fo),literal:qo,string:sy,docString:V(sy),character:V(sy),attributeValue:V(sy),number:Fb,integer:V(Fb),float:V(Fb),bool:V(qo),regexp:V(qo),escape:V(qo),color:V(qo),url:V(qo),keyword:nr,self:V(nr),null:V(nr),atom:V(nr),unit:V(nr),modifier:V(nr),operatorKeyword:V(nr),controlKeyword:V(nr),definitionKeyword:V(nr),moduleKeyword:V(nr),operator:ir,derefOperator:V(ir),arithmeticOperator:V(ir),logicOperator:V(ir),bitwiseOperator:V(ir),compareOperator:V(ir),updateOperator:V(ir),definitionOperator:V(ir),typeOperator:V(ir),controlOperator:V(ir),punctuation:Vb,separator:V(Vb),bracket:jh,angleBracket:V(jh),squareBracket:V(jh),paren:V(jh),brace:V(jh),content:rr,heading:Us,heading1:V(Us),heading2:V(Us),heading3:V(Us),heading4:V(Us),heading5:V(Us),heading6:V(Us),contentSeparator:V(rr),list:V(rr),quote:V(rr),emphasis:V(rr),strong:V(rr),link:V(rr),monospace:V(rr),strikethrough:V(rr),inserted:V(),deleted:V(),changed:V(),invalid:V(),meta:ay,documentMeta:V(ay),annotation:V(ay),processingInstruction:V(ay),definition:Ci.defineModifier("definition"),constant:Ci.defineModifier("constant"),function:Ci.defineModifier("function"),standard:Ci.defineModifier("standard"),local:Ci.defineModifier("local"),special:Ci.defineModifier("special")};for(let n in B){let e=B[n];e instanceof Ci&&(e.name=n)}var Cge=Hb([{tag:B.link,class:"tok-link"},{tag:B.heading,class:"tok-heading"},{tag:B.emphasis,class:"tok-emphasis"},{tag:B.strong,class:"tok-strong"},{tag:B.keyword,class:"tok-keyword"},{tag:B.atom,class:"tok-atom"},{tag:B.bool,class:"tok-bool"},{tag:B.url,class:"tok-url"},{tag:B.labelName,class:"tok-labelName"},{tag:B.inserted,class:"tok-inserted"},{tag:B.deleted,class:"tok-deleted"},{tag:B.literal,class:"tok-literal"},{tag:B.string,class:"tok-string"},{tag:B.number,class:"tok-number"},{tag:[B.regexp,B.escape,B.special(B.string)],class:"tok-string2"},{tag:B.variableName,class:"tok-variableName"},{tag:B.local(B.variableName),class:"tok-variableName tok-local"},{tag:B.definition(B.variableName),class:"tok-variableName tok-definition"},{tag:B.special(B.variableName),class:"tok-variableName2"},{tag:B.definition(B.propertyName),class:"tok-propertyName tok-definition"},{tag:B.typeName,class:"tok-typeName"},{tag:B.namespace,class:"tok-namespace"},{tag:B.className,class:"tok-className"},{tag:B.macroName,class:"tok-macroName"},{tag:B.propertyName,class:"tok-propertyName"},{tag:B.operator,class:"tok-operator"},{tag:B.comment,class:"tok-comment"},{tag:B.meta,class:"tok-meta"},{tag:B.invalid,class:"tok-invalid"},{tag:B.punctuation,class:"tok-punctuation"}]);var zb,lc=new ce;function t4(n){return H.define({combine:n?e=>e.concat(n):void 0})}var n4=new ce,In=class{constructor(e,t,i=[],r=""){this.data=e,this.name=r,Ze.prototype.hasOwnProperty("tree")||Object.defineProperty(Ze.prototype,"tree",{get(){return lt(this)}}),this.parser=t,this.extension=[cc.of(this),Ze.languageData.of((o,s,a)=>{let l=zA(o,s,a),c=l.type.prop(lc);if(!c)return[];let u=o.facet(c),f=l.type.prop(n4);if(f){let h=l.resolve(s-l.from,a);for(let d of f)if(d.test(h,o)){let p=o.facet(d.facet);return d.type=="replace"?p:p.concat(u)}}return u})].concat(i)}isActiveAt(e,t,i=-1){return zA(e,t,i).type.prop(lc)==this.data}findRegions(e){let t=e.facet(cc);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],r=(o,s)=>{if(o.prop(lc)==this.data){i.push({from:s,to:s+o.length});return}let a=o.prop(ce.mounted);if(a){if(a.tree.prop(lc)==this.data){if(a.overlay)for(let l of a.overlay)i.push({from:l.from+s,to:l.to+s});else i.push({from:s,to:s+o.length});return}else if(a.overlay){let l=i.length;if(r(a.tree,a.overlay[0].from+s),i.length>l)return}}for(let l=0;l<o.children.length;l++){let c=o.children[l];c instanceof gt&&r(c,o.positions[l]+s)}};return r(lt(e),0),i}get allowsNesting(){return!0}};In.setState=de.define();function zA(n,e,t){let i=n.facet(cc),r=lt(n).topNode;if(!i||i.allowsNesting)for(let o=r;o;o=o.enter(e,t,rt.ExcludeBuffers|rt.EnterBracketed))o.type.isTop&&(r=o);return r}var uy=class n extends In{constructor(e,t,i){super(e,t,[],i),this.parser=t}static define(e){let t=t4(e.languageData);return new n(t,e.parser.configure({props:[lc.add(i=>i.isTop?t:void 0)]}),e.name)}configure(e,t){return new n(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}};function lt(n){let e=n.field(In.state,!1);return e?e.tree:gt.empty}var Kb=class{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e<i||t>=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}},Fh=null,Gb=class n{constructor(e,t,i=[],r,o,s,a,l){this.parser=e,this.state=t,this.fragments=i,this.tree=r,this.treeLen=o,this.viewport=s,this.skipped=a,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new n(e,t,[],gt.empty,0,i,[],null)}startParse(){return this.parser.startParse(new Kb(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=gt.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let r=Date.now()+e;e=()=>Date.now()>r}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t<this.state.doc.length&&this.parse.stopAt(t);;){let r=this.parse.advance();if(r)if(this.fragments=this.withoutTempSkipped(Ws.addTree(r,this.fragments,this.parse.stoppedAt!=null)),this.treeLen=(i=this.parse.stoppedAt)!==null&&i!==void 0?i:this.state.doc.length,this.tree=r,this.parse=null,this.treeLen<(t!=null?t:this.state.doc.length))this.parse=this.startParse();else return!0;if(e())return!1}})}takeTree(){let e,t;this.parse&&(e=this.parse.parsedPos)>=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Ws.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=Fh;Fh=this;try{return e()}finally{Fh=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=WA(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:r,treeLen:o,viewport:s,skipped:a}=this;if(this.takeTree(),!e.empty){let l=[];if(e.iterChangedRanges((c,u,f,h)=>l.push({fromA:c,toA:u,fromB:f,toB:h})),i=Ws.applyChanges(i,l),r=gt.empty,o=0,s={from:e.mapPos(s.from,-1),to:e.mapPos(s.to,1)},this.skipped.length){a=[];for(let c of this.skipped){let u=e.mapPos(c.from,1),f=e.mapPos(c.to,-1);u<f&&a.push({from:u,to:f})}}}return new n(this.parser,t,i,r,o,s,a,this.scheduleOn)}updateViewport(e){if(this.viewport.from==e.from&&this.viewport.to==e.to)return!1;this.viewport=e;let t=this.skipped.length;for(let i=0;i<this.skipped.length;i++){let{from:r,to:o}=this.skipped[i];r<e.to&&o>e.from&&(this.fragments=WA(this.fragments,r,o),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends ac{createParse(t,i,r){let o=r[0].from,s=r[r.length-1].to;return{parsedPos:o,advance(){let l=Fh;if(l){for(let c of r)l.tempSkipped.push(c);e&&(l.scheduleOn=l.scheduleOn?Promise.all([l.scheduleOn,e]):e)}return this.parsedPos=s,new gt(Zt.none,[],[],s-o)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return Fh}};function WA(n,e,t){return Ws.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}var qh=class n{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new n(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=Gb.create(e.facet(cc).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new n(i)}};In.state=qt.define({create:qh.init,update(n,e){for(let t of e.effects)if(t.is(In.setState))return t.value;return e.startState.facet(cc)!=e.state.facet(cc)?qh.init(e.state):n.apply(e)}});var XA=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(XA=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});var Wb=typeof navigator!="undefined"&&(!((zb=navigator.scheduling)===null||zb===void 0)&&zb.isInputPending)?()=>navigator.scheduling.isInputPending():null,i4=Yt.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(In.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(In.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=XA(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnd<t&&(this.chunkEnd<0||this.view.hasFocus)&&(this.chunkEnd=t+3e4,this.chunkBudget=3e3),this.chunkBudget<=0)return;let{state:i,viewport:{to:r}}=this.view,o=i.field(In.state);if(o.tree==o.context.tree&&o.context.isDone(r+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,e&&!Wb?Math.max(25,e.timeRemaining()-5):1e9),a=o.context.treeLen<r&&i.doc.length>r+1e3,l=o.context.work(()=>Wb&&Wb()||Date.now()>s,r+(a?0:1e5));this.chunkBudget-=Date.now()-t,(l||this.chunkBudget<=0)&&(o.context.takeTree(),this.view.dispatch({effects:In.setState.of(new qh(o.context))})),this.chunkBudget>0&&!(l&&!a)&&this.scheduleWork(),this.checkAsyncSchedule(o.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>It(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),cc=H.define({combine(n){return n.length?n[0]:null},enables:n=>[In.state,i4,U.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]}),fy=class{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}};var r4=H.define(),fc=H.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function Vh(n){let e=n.facet(fc);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function hc(n,e){let t="",i=n.tabSize,r=n.facet(fc)[0];if(r==" "){for(;e>=i;)t+=" ",e-=i;r=" "}for(let o=0;o<e;o++)t+=r;return t}function hy(n,e){n instanceof Ze&&(n=new Ks(n));for(let i of n.state.facet(r4)){let r=i(n,e);if(r!==void 0)return r}let t=lt(n.state);return t.length>=e?o4(n,t,e):null}var Ks=class{constructor(e,t={}){this.state=e,this.options=t,this.unit=Vh(e)}lineAt(e,t=1){let i=this.state.doc.lineAt(e),{simulateBreak:r,simulateDoubleBreak:o}=this.options;return r!=null&&r>=i.from&&r<=i.to?o&&r==e?{text:"",from:e}:(t<0?r<e:r<=e)?{text:i.text.slice(r-i.from),from:r}:{text:i.text.slice(0,r-i.from),from:i.from}:i}textAfterPos(e,t=1){if(this.options.simulateDoubleBreak&&e==this.options.simulateBreak)return"";let{text:i,from:r}=this.lineAt(e,t);return i.slice(e-r,Math.min(i.length,e+100-r))}column(e,t=1){let{text:i,from:r}=this.lineAt(e,t),o=this.countColumn(i,e-r),s=this.options.overrideIndentation?this.options.overrideIndentation(r):-1;return s>-1&&(o+=s-this.countColumn(i,i.search(/\S|$/))),o}countColumn(e,t=e.length){return $s(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:r}=this.lineAt(e,t),o=this.options.overrideIndentation;if(o){let s=o(r);if(s>-1)return s}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}},t_=new ce;function o4(n,e,t){let i=e.resolveStack(t),r=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(r!=i.node){let o=[];for(let s=r;s&&!(s.from<i.node.from||s.to>i.node.to||s.from==i.node.from&&s.type==i.node.type);s=s.parent)o.push(s);for(let s=o.length-1;s>=0;s--)i={node:o[s],next:i}}return YA(i,n,t)}function YA(n,e,t){for(let i=n;i;i=i.next){let r=a4(i.node);if(r)return r(Xb.create(e,t,i))}return 0}function s4(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function a4(n){let e=n.type.prop(t_);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(ce.closedBy))){let r=n.lastChild,o=r&&i.indexOf(r.name)>-1;return s=>ZA(s,!0,1,void 0,o&&!s4(s)?r.from:void 0)}return n.parent==null?l4:null}function l4(){return 0}var Xb=class n extends Ks{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.context=i}get node(){return this.context.node}static create(e,t,i){return new n(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(c4(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){return YA(this.context.next,this.base,this.pos)}};function c4(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function u4(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let r=n.options.simulateBreak,o=n.state.doc.lineAt(t.from),s=r==null||r<=o.from?o.to:Math.min(o.to,r);for(let a=t.to;;){let l=e.childAfter(a);if(!l||l==i)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let c=/^ */.exec(o.text.slice(t.to-o.from))[0].length;return{from:t.from,to:t.to+c}}a=l.to}}function n_({closing:n,align:e=!0,units:t=1}){return i=>ZA(i,e,t,n)}function ZA(n,e,t,i,r){let o=n.textAfter,s=o.match(/^\s*/)[0].length,a=i&&o.slice(s,s+i.length)==i||r==n.pos+s,l=e?u4(n):null;return l?a?n.column(l.from):n.column(l.to):n.baseIndent+(a?0:n.unit*t)}function dy({except:n,units:e=1}={}){return t=>{let i=n&&n.test(t.textAfter);return t.baseIndent+(i?0:e*t.unit)}}var f4=200;function JA(){return Ze.transactionFilter.of(n=>{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,r=t.lineAt(i);if(i>r.from+f4)return n;let o=t.sliceString(r.from,i);if(!e.some(c=>c.test(o)))return n;let{state:s}=n,a=-1,l=[];for(let{head:c}of s.selection.ranges){let u=s.doc.lineAt(c);if(u.from==a)continue;a=u.from;let f=hy(s,u.from);if(f==null)continue;let h=/^\s*/.exec(u.text)[0],d=hc(s,f);h!=d&&l.push({from:u.from,to:u.from+h.length,insert:d})}return l.length?[n,{changes:l,sequential:!0}]:n})}var eM=new ce;function py(n){let e=n.firstChild,t=n.lastChild;return e&&e.to<t.from?{from:e.to,to:t.type.isError?n.to:t.from}:null}var uc=class n{constructor(e,t){this.specs=e;let i;function r(a){let l=ni.newName();return(i||(i=Object.create(null)))["."+l]=a,l}let o=typeof t.all=="string"?t.all:t.all?r(t.all):void 0,s=t.scope;this.scope=s instanceof In?a=>a.prop(lc)==s.data:s?a=>a==s:void 0,this.style=Hb(e.map(a=>({tag:a.tag,class:a.class||r(Object.assign({},a,{tag:null}))})),{all:o}).style,this.module=i?new ni(i):null,this.themeType=t.themeType}static define(e,t){return new n(e,t||{})}},Yb=H.define(),tM=H.define({combine(n){return n.length?[n[0]]:null}});function Ub(n){let e=n.facet(Yb);return e.length?e:n.facet(tM)}function nM(n,e){let t=[h4],i;return n instanceof uc&&(n.module&&t.push(U.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(tM.of(n)):i?t.push(Yb.computeN([U.darkTheme],r=>r.facet(U.darkTheme)==(i=="dark")?[n]:[])):t.push(Yb.of(n)),t}var Zb=class{constructor(e){this.markCache=Object.create(null),this.tree=lt(e.state),this.decorations=this.buildDeco(e,Ub(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=lt(e.state),i=Ub(e.state),r=i!=Ub(e.startState),{viewport:o}=e.view,s=e.changes.mapPos(this.decoratedTo,1);t.length<o.to&&!r&&t.type==this.tree.type&&s>=o.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=s):(t!=this.tree||e.viewportChanged||r)&&(this.tree=t,this.decorations=this.buildDeco(e.view,i),this.decoratedTo=o.to)}buildDeco(e,t){if(!t||!this.tree.length)return he.none;let i=new Nr;for(let{from:r,to:o}of e.visibleRanges)HA(this.tree,t,(s,a,l)=>{i.add(s,a,this.markCache[l]||(this.markCache[l]=he.mark({class:l})))},r,o);return i.finish()}},h4=$r.high(Yt.fromClass(Zb,{decorations:n=>n.decorations})),Mge=uc.define([{tag:B.meta,color:"#404740"},{tag:B.link,textDecoration:"underline"},{tag:B.heading,textDecoration:"underline",fontWeight:"bold"},{tag:B.emphasis,fontStyle:"italic"},{tag:B.strong,fontWeight:"bold"},{tag:B.strikethrough,textDecoration:"line-through"},{tag:B.keyword,color:"#708"},{tag:[B.atom,B.bool,B.url,B.contentSeparator,B.labelName],color:"#219"},{tag:[B.literal,B.inserted],color:"#164"},{tag:[B.string,B.deleted],color:"#a11"},{tag:[B.regexp,B.escape,B.special(B.string)],color:"#e40"},{tag:B.definition(B.variableName),color:"#00f"},{tag:B.local(B.variableName),color:"#30a"},{tag:[B.typeName,B.namespace],color:"#085"},{tag:B.className,color:"#167"},{tag:[B.special(B.variableName),B.macroName],color:"#256"},{tag:B.definition(B.propertyName),color:"#00c"},{tag:B.comment,color:"#940"},{tag:B.invalid,color:"#f00"}]),d4=U.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),iM=1e4,rM="()[]{}",oM=H.define({combine(n){return Io(n,{afterCursor:!0,brackets:rM,maxScanDistance:iM,renderMatch:g4})}}),p4=he.mark({class:"cm-matchingBracket"}),m4=he.mark({class:"cm-nonmatchingBracket"});function g4(n){let e=[],t=n.matched?p4:m4;return e.push(t.range(n.start.from,n.start.to)),n.end&&e.push(t.range(n.end.from,n.end.to)),e}function UA(n){let e=[],t=n.facet(oM);for(let i of n.selection.ranges){if(!i.empty)continue;let r=Ei(n,i.head,-1,t)||i.head>0&&Ei(n,i.head-1,1,t)||t.afterCursor&&(Ei(n,i.head,1,t)||i.head<n.doc.length&&Ei(n,i.head+1,-1,t));r&&(e=e.concat(t.renderMatch(r,n)))}return he.set(e,!0)}var y4=Yt.fromClass(class{constructor(n){this.paused=!1,this.decorations=UA(n.state)}update(n){(n.docChanged||n.selectionSet||this.paused)&&(n.view.composing?(this.decorations=this.decorations.map(n.changes),this.paused=!0):(this.decorations=UA(n.state),this.paused=!1))}},{decorations:n=>n.decorations}),v4=[y4,d4];function sM(n={}){return[oM.of(n),v4]}var x4=new ce;function Jb(n,e,t){let i=n.prop(e<0?ce.openedBy:ce.closedBy);if(i)return i;if(n.name.length==1){let r=t.indexOf(n.name);if(r>-1&&r%2==(e<0?1:0))return[t[r+e]]}return null}function e_(n){let e=n.type.prop(x4);return e?e(n.node):n}function Ei(n,e,t,i={}){let r=i.maxScanDistance||iM,o=i.brackets||rM,s=lt(n),a=s.resolveInner(e,t);for(let l=a;l;l=l.parent){let c=Jb(l.type,t,o);if(c&&l.from<l.to){let u=e_(l);if(u&&(t>0?e>=u.from&&e<u.to:e>u.from&&e<=u.to))return b4(n,e,t,l,u,c,o)}}return _4(n,e,t,s,a.type,r,o)}function b4(n,e,t,i,r,o,s){let a=i.parent,l={from:r.from,to:r.to},c=0,u=a==null?void 0:a.cursor();if(u&&(t<0?u.childBefore(i.from):u.childAfter(i.to)))do if(t<0?u.to<=i.from:u.from>=i.to){if(c==0&&o.indexOf(u.type.name)>-1&&u.from<u.to){let f=e_(u);return{start:l,end:f?{from:f.from,to:f.to}:void 0,matched:!0}}else if(Jb(u.type,t,s))c++;else if(Jb(u.type,-t,s)){if(c==0){let f=e_(u);return{start:l,end:f&&f.from<f.to?{from:f.from,to:f.to}:void 0,matched:!1}}c--}}while(t<0?u.prevSibling():u.nextSibling());return{start:l,matched:!1}}function _4(n,e,t,i,r,o,s){if(t<0?!e:e==n.doc.length)return null;let a=t<0?n.sliceDoc(e-1,e):n.sliceDoc(e,e+1),l=s.indexOf(a);if(l<0||l%2==0!=t>0)return null;let c={from:t<0?e-1:e,to:t>0?e+1:e},u=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let h=0;!u.next().done&&h<=o;){let d=u.value;t<0&&(h+=d.length);let p=e+h*t;for(let m=t>0?0:d.length-1,g=t>0?d.length:-1;m!=g;m+=t){let b=s.indexOf(d[m]);if(!(b<0||i.resolveInner(p+m,1).type!=r))if(b%2==0==t>0)f++;else{if(f==1)return{start:c,end:{from:p+m,to:p+m+1},matched:b>>1==l>>1};f--}}t>0&&(h+=d.length)}return u.done?{start:c,matched:!1}:null}var w4=Object.create(null),QA=[Zt.none];var KA=[],GA=Object.create(null),C4=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])C4[n]=E4(w4,e);function Qb(n,e){KA.indexOf(n)>-1||(KA.push(n),console.warn(e))}function E4(n,e){let t=[];for(let a of e.split(" ")){let l=[];for(let c of a.split(".")){let u=n[c]||B[c];u?typeof u=="function"?l.length?l=l.map(u):Qb(c,`Modifier ${c} used at start of tag`):l.length?Qb(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:Qb(c,`Unknown highlighting tag ${c}`)}for(let c of l)t.push(c)}if(!t.length)return 0;let i=e.replace(/ /g,"_"),r=i+" "+t.map(a=>a.id),o=GA[r];if(o)return o.id;let s=GA[r]=Zt.define({id:QA.length,name:i,props:[cy({[i]:t})]});return QA.push(s),s.id}var Pge={rtl:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"rtl"},bidiIsolate:We.RTL}),ltr:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"ltr"},bidiIsolate:We.LTR}),auto:he.mark({class:"cm-iso",inclusive:!0,attributes:{dir:"auto"},bidiIsolate:null})};var gy=class{constructor(e,t,i,r){this.state=e,this.pos=t,this.explicit=i,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=lt(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),r=t.text.slice(i-t.from,this.pos-t.from),o=r.search(mM(e,!1));return o<0?null:{from:i+o,to:this.pos,text:r.slice(o)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,i){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),i&&i.onDocChange&&(this.abortOnDocChange=!0))}};function aM(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function S4(n){let e=Object.create(null),t=Object.create(null);for(let{label:r}of n){e[r[0]]=!0;for(let o=1;o<r.length;o++)t[r[o]]=!0}let i=aM(e)+aM(t)+"*$";return[new RegExp("^"+i),new RegExp(i)]}function pc(n){let e=n.map(r=>typeof r=="string"?{label:r}:r),[t,i]=e.every(r=>/^\w+$/.test(r.label))?[/\w*$/,/\w+$/]:S4(e);return r=>{let o=r.matchBefore(i);return o||r.explicit?{from:o?o.from:r.pos,options:e,validFor:t}:null}}var yy=class{constructor(e,t,i,r){this.completion=e,this.source=t,this.match=i,this.score=r}};function Xs(n){return n.selection.main.from}function mM(n,e){var t;let{source:i}=n,r=e&&i[0]!="^",o=i[i.length-1]!="$";return!r&&!o?n:new RegExp(`${r?"^":""}(?:${i})${o?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}var m_=Mn.define();function O4(n,e,t,i){let{main:r}=n.selection,o=t-r.from,s=i-r.from;return{...n.changeByRange(a=>{if(a!=r&&t!=i&&n.sliceDoc(a.from+o,a.from+s)!=n.sliceDoc(t,i))return{range:a};let l=n.toText(e);return{changes:{from:a.from+o,to:i==r.from?a.to:a.from+s,insert:l},range:$.cursor(a.from+o+l.length)}}),scrollIntoView:!0,userEvent:"input.complete"}}var lM=new WeakMap;function k4(n){if(!Array.isArray(n))return n;let e=lM.get(n);return e||lM.set(n,e=pc(n)),e}var vy=de.define(),Hh=de.define(),s_=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let i=ti(e,t),r=Yi(i);this.chars.push(i);let o=e.slice(t,t+r),s=o.toUpperCase();this.folded.push(ti(s==o?o.toLowerCase():s,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:i,any:r,precise:o,byWord:s}=this;if(t.length==1){let _=ti(e,0),v=Yi(_),x=v==e.length?0:-100;if(_!=t[0])if(_==i[0])x+=-200;else return null;return this.ret(x,[0,v])}let a=e.indexOf(this.pattern);if(a==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=t.length,c=0;if(a<0){for(let _=0,v=Math.min(e.length,200);_<v&&c<l;){let x=ti(e,_);(x==t[c]||x==i[c])&&(r[c++]=_),_+=Yi(x)}if(c<l)return null}let u=0,f=0,h=!1,d=0,p=-1,m=-1,g=/[a-z]/.test(e),b=!0;for(let _=0,v=Math.min(e.length,200),x=0;_<v&&f<l;){let C=ti(e,_);a<0&&(u<l&&C==t[u]&&(o[u++]=_),d<l&&(C==t[d]||C==i[d]?(d==0&&(p=_),m=_+1,d++):d=0));let E,S=C<255?C>=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(E=E0(C))!=E.toLowerCase()?1:E!=E.toUpperCase()?2:0;(!_||S==1&&g||x==0&&S!=0)&&(t[f]==C||i[f]==C&&(h=!0)?s[f++]=_:s.length&&(b=!1)),x=S,_+=Yi(C)}return f==l&&s[0]==0&&b?this.result(-100+(h?-200:0),s,e):d==l&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):a>-1?this.ret(-700-e.length,[a,a+this.pattern.length]):d==l?this.ret(-900-e.length,[p,m]):f==l?this.result(-100+(h?-200:0)+-700+(b?0:-1100),s,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,i){let r=[],o=0;for(let s of t){let a=s+(this.astral?Yi(ti(i,s)):1);o&&r[o-1]==s?r[o-1]=a:(r[o++]=s,r[o++]=a)}return this.ret(e-i.length,r)}},a_=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),i=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return i==null?null:(this.matched=[0,t.length],this.score=i+(e.length==this.pattern.length?0:-100),this)}},Lt=H.define({combine(n){return Io(n,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:R4,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>cM(e(i),t(i)),optionClass:(e,t)=>i=>cM(e(i),t(i)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function cM(n,e){return n?e?n+" "+e:n:e}function R4(n,e,t,i,r,o){let s=n.textDirection==We.RTL,a=s,l=!1,c="top",u,f,h=e.left-r.left,d=r.right-e.right,p=i.right-i.left,m=i.bottom-i.top;if(a&&h<Math.min(p,d)?a=!1:!a&&d<Math.min(p,h)&&(a=!0),p<=(a?h:d))u=Math.max(r.top,Math.min(t.top,r.bottom-m))-e.top,f=Math.min(400,a?h:d);else{l=!0,f=Math.min(400,(s?e.right:r.right-e.left)-30);let _=r.bottom-e.bottom;_>=m||_>e.top?u=t.bottom-e.top:(c="bottom",u=e.bottom-t.top)}let g=(e.bottom-e.top)/o.offsetHeight,b=(e.right-e.left)/o.offsetWidth;return{style:`${c}: ${u/g}px; max-width: ${f/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":a?"left":"right")}}var g_=de.define();function T4(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(r=>"cm-completionIcon-"+r)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,r,o){let s=document.createElement("span");s.className="cm-completionLabel";let a=t.displayLabel||t.label,l=0;for(let c=0;c<o.length;){let u=o[c++],f=o[c++];u>l&&s.appendChild(document.createTextNode(a.slice(l,u)));let h=s.appendChild(document.createElement("span"));h.appendChild(document.createTextNode(a.slice(u,f))),h.className="cm-completionMatchedText",l=f}return l<a.length&&s.appendChild(document.createTextNode(a.slice(l))),s},position:50},{render(t){if(!t.detail)return null;let i=document.createElement("span");return i.className="cm-completionDetail",i.textContent=t.detail,i},position:80}),e.sort((t,i)=>t.position-i.position).map(t=>t.render)}function i_(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let r=Math.floor(e/t);return{from:r*t,to:(r+1)*t}}let i=Math.ceil((n-e)/t);return{from:n-i*t,to:n-(i-1)*t}}var l_=class{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:l=>this.placeInfo(l),key:this},this.space=null,this.currentClass="";let r=e.state.field(t),{options:o,selected:s}=r.open,a=e.state.facet(Lt);this.optionContent=T4(a),this.optionClass=a.optionClass,this.tooltipClass=a.tooltipClass,this.range=i_(o.length,s,a.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",l=>{let{options:c}=e.state.field(t).open;for(let u=l.target,f;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(f=/-(\d+)$/.exec(u.id))&&+f[1]<c.length){this.applyCompletion(e,c[+f[1]]),l.preventDefault();return}if(l.target==this.list){let u=this.list.classList.contains("cm-completionListIncompleteTop")&&l.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains("cm-completionListIncompleteBottom")&&l.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;u!=null&&(e.dispatch({effects:g_.of(u)}),l.preventDefault())}}),this.dom.addEventListener("focusout",l=>{let c=e.state.field(this.stateField,!1);c&&c.tooltip&&e.state.facet(Lt).closeOnBlur&&l.relatedTarget!=e.contentDOM&&e.dispatch({effects:Hh.of(null)})}),this.showOptions(o,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let i=e.state.field(this.stateField),r=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),i!=r){let{options:o,selected:s,disabled:a}=i.open;(!r.open||r.open.options!=o)&&(this.range=i_(o.length,s,e.state.facet(Lt).maxRenderedOptions),this.showOptions(o,i.id)),this.updateSel(),a!=((t=r.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=i_(t.options.length,t.selected,this.view.state.facet(Lt).maxRenderedOptions),this.showOptions(t.options,e.id));let i=this.updateSelectedOption(t.selected);if(i){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:o}=r;if(!o)return;let s=typeof o=="string"?document.createTextNode(o):o(r);if(!s)return;"then"in s?s.then(a=>{a&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(a,r)}).catch(a=>It(this.view.state,a,"completion info")):(this.addInfoPane(s,r),i.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",i.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:r,destroy:o}=e;i.appendChild(r),this.infoDestroy=o||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,r=this.range.from;i;i=i.nextSibling,r++)i.nodeName!="LI"||!i.id?r--:r==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&(i.removeAttribute("aria-selected"),i.removeAttribute("aria-describedby"));return t&&M4(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),o=this.space;if(!o){let s=this.dom.ownerDocument.documentElement;o={left:0,top:0,right:s.clientWidth,bottom:s.clientHeight}}return r.top>Math.min(o.bottom,t.bottom)-10||r.bottom<Math.max(o.top,t.top)+10?null:this.view.state.facet(Lt).positionInfo(this.view,t,r,i,o,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className="cm-tooltip cm-completionInfo "+(e.class||"")):this.info.style.cssText="top: -1e6px")}createListBox(e,t,i){let r=document.createElement("ul");r.id=t,r.setAttribute("role","listbox"),r.setAttribute("aria-expanded","true"),r.setAttribute("aria-label",this.view.state.phrase("Completions")),r.addEventListener("mousedown",s=>{s.target==r&&s.preventDefault()});let o=null;for(let s=i.from;s<i.to;s++){let{completion:a,match:l}=e[s],{section:c}=a;if(c){let h=typeof c=="string"?c:c.name;if(h!=o&&(s>i.from||i.from==0))if(o=h,typeof c!="string"&&c.header)r.appendChild(c.header(c));else{let d=r.appendChild(document.createElement("completion-section"));d.textContent=h}}let u=r.appendChild(document.createElement("li"));u.id=t+"-"+s,u.setAttribute("role","option");let f=this.optionClass(a);f&&(u.className=f);for(let h of this.optionContent){let d=h(a,this.view.state,this.view,l);d&&u.appendChild(d)}}return i.from&&r.classList.add("cm-completionListIncompleteTop"),i.to<e.length&&r.classList.add("cm-completionListIncompleteBottom"),r}destroyInfo(){this.info&&(this.infoDestroy&&this.infoDestroy(),this.info.remove(),this.info=null)}destroy(){this.destroyInfo()}};function A4(n,e){return t=>new l_(t,n,e)}function M4(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect(),r=t.height/n.offsetHeight;i.top<t.top?n.scrollTop-=(t.top-i.top)/r:i.bottom>t.bottom&&(n.scrollTop+=(i.bottom-t.bottom)/r)}function uM(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function P4(n,e){let t=[],i=null,r=null,o=u=>{t.push(u);let{section:f}=u.completion;if(f){i||(i=[]);let h=typeof f=="string"?f:f.name;i.some(d=>d.name==h)||i.push(typeof f=="string"?{name:h}:f)}},s=e.facet(Lt);for(let u of n)if(u.hasResult()){let f=u.result.getMatch;if(u.result.filter===!1)for(let h of u.result.options)o(new yy(h,u.source,f?f(h):[],1e9-t.length));else{let h=e.sliceDoc(u.from,u.to),d,p=s.filterStrict?new a_(h):new s_(h);for(let m of u.result.options)if(d=p.match(m.label)){let g=m.displayLabel?f?f(m,d.matched):[]:d.matched,b=d.score+(m.boost||0);if(o(new yy(m,u.source,g,b)),typeof m.section=="object"&&m.section.rank==="dynamic"){let{name:_}=m.section;r||(r=Object.create(null)),r[_]=Math.max(b,r[_]||-1e9)}}}}if(i){let u=Object.create(null),f=0,h=(d,p)=>(d.rank==="dynamic"&&p.rank==="dynamic"?r[p.name]-r[d.name]:0)||(typeof d.rank=="number"?d.rank:1e9)-(typeof p.rank=="number"?p.rank:1e9)||(d.name<p.name?-1:1);for(let d of i.sort(h))f-=1e5,u[d.name]=f;for(let d of t){let{section:p}=d.completion;p&&(d.score+=u[typeof p=="string"?p:p.name])}}let a=[],l=null,c=s.compareCompletions;for(let u of t.sort((f,h)=>h.score-f.score||c(f.completion,h.completion))){let f=u.completion;!l||l.label!=f.label||l.detail!=f.detail||l.type!=null&&f.type!=null&&l.type!=f.type||l.apply!=f.apply||l.boost!=f.boost?a.push(u):uM(u.completion)>uM(l)&&(a[a.length-1]=u),l=u.completion}return a}var c_=class n{constructor(e,t,i,r,o,s){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=r,this.selected=o,this.disabled=s}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new n(this.options,fM(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,r,o,s){if(r&&!s&&e.some(c=>c.isPending))return r.setDisabled();let a=P4(e,t);if(!a.length)return r&&e.some(c=>c.isPending)?r.setDisabled():null;let l=t.facet(Lt).selectOnOpen?0:-1;if(r&&r.selected!=l&&r.selected!=-1){let c=r.options[r.selected].completion;for(let u=0;u<a.length;u++)if(a[u].completion==c){l=u;break}}return new n(a,fM(i,l),{pos:e.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:$4,above:o.aboveCursor},r?r.timestamp:Date.now(),l,!1)}map(e){return new n(this.options,this.attrs,{...this.tooltip,pos:e.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new n(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},u_=class n{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new n(B4,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(Lt),o=(i.override||t.languageDataAt("autocomplete",Xs(t)).map(k4)).map(l=>(this.active.find(u=>u.source==l)||new Hr(l,this.active.some(u=>u.state!=0)?1:0)).update(e,i));o.length==this.active.length&&o.every((l,c)=>l==this.active[c])&&(o=this.active);let s=this.open,a=e.effects.some(l=>l.is(y_));s&&e.docChanged&&(s=s.map(e.changes)),e.selection||o.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!D4(o,this.active)||a?s=c_.build(o,t,this.id,s,i,a):s&&s.disabled&&!o.some(l=>l.isPending)&&(s=null),!s&&o.every(l=>!l.isPending)&&o.some(l=>l.hasResult())&&(o=o.map(l=>l.hasResult()?new Hr(l.source,0):l));for(let l of e.effects)l.is(g_)&&(s=s&&s.setSelected(l.value,this.id));return o==this.active&&s==this.open?this:new n(o,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?I4:L4}};function D4(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t<n.length&&!n[t].hasResult();)t++;for(;i<e.length&&!e[i].hasResult();)i++;let r=t==n.length,o=i==e.length;if(r||o)return r==o;if(n[t++].result!=e[i++].result)return!1}}var I4={"aria-autocomplete":"list"},L4={};function fM(n,e){let t={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":n};return e>-1&&(t["aria-activedescendant"]=n+"-"+e),t}var B4=[];function gM(n,e){if(n.isUserEvent("input.complete")){let i=n.annotation(m_);if(i&&e.activateOnCompletion(i))return 12}let t=n.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:n.isUserEvent("delete.backward")?2:n.selection?8:n.docChanged?16:0}var Hr=class n{constructor(e,t,i=!1){this.source=e,this.state=t,this.explicit=i}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let i=gM(e,t),r=this;(i&8||i&16&&this.touches(e))&&(r=new n(r.source,0)),i&4&&r.state==0&&(r=new n(this.source,1)),r=r.updateFor(e,i);for(let o of e.effects)if(o.is(vy))r=new n(r.source,1,o.value);else if(o.is(Hh))r=new n(r.source,0);else if(o.is(y_))for(let s of o.value)s.source==r.source&&(r=s);return r}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Xs(e.state))}},xy=class n extends Hr{constructor(e,t,i,r,o,s){super(e,3,t),this.limit=i,this.result=r,this.from=o,this.to=s}hasResult(){return!0}updateFor(e,t){var i;if(!(t&3))return this.map(e.changes);let r=this.result;r.map&&!e.changes.empty&&(r=r.map(r,e.changes));let o=e.changes.mapPos(this.from),s=e.changes.mapPos(this.to,1),a=Xs(e.state);if(a>s||!r||t&2&&(Xs(e.startState)==this.from||a<this.limit))return new Hr(this.source,t&4?1:0);let l=e.changes.mapPos(this.limit);return N4(r.validFor,e.state,o,s)?new n(this.source,this.explicit,l,r,o,s):r.update&&(r=r.update(r,o,s,new gy(e.state,a,!1)))?new n(this.source,this.explicit,l,r,r.from,(i=r.to)!==null&&i!==void 0?i:Xs(e.state)):new Hr(this.source,1,this.explicit)}map(e){if(e.empty)return this;let t=this.result.map?this.result.map(this.result,e):this.result;return t?new n(this.source,this.explicit,e.mapPos(this.limit),t,e.mapPos(this.from),e.mapPos(this.to,1)):new Hr(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function N4(n,e,t,i){if(!n)return!1;let r=e.sliceDoc(t,i);return typeof n=="function"?n(r,t,i,e):mM(n,!0).test(r)}var y_=de.define({map(n,e){return n.map(t=>t.map(e))}}),wn=qt.define({create(){return u_.start()},update(n,e){return n.update(e)},provide:n=>[Dh.from(n,e=>e.tooltip),U.contentAttributes.from(n,e=>e.attrs)]});function v_(n,e){let t=e.completion.apply||e.completion.label,i=n.state.field(wn).active.find(r=>r.source==e.source);return i instanceof xy?(typeof t=="string"?n.dispatch({...O4(n.state,t,i.from,i.to),annotations:m_.of(e.completion)}):t(n,e.completion,i.from,i.to),!0):!1}var $4=A4(wn,v_);function my(n,e="option"){return t=>{let i=t.state.field(wn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp<t.state.facet(Lt).interactionDelay)return!1;let r=1,o;e=="page"&&(o=Pb(t,i.open.tooltip))&&(r=Math.max(2,Math.floor(o.dom.offsetHeight/o.dom.querySelector("li").offsetHeight)-1));let{length:s}=i.open.options,a=i.open.selected>-1?i.open.selected+r*(n?1:-1):n?0:s-1;return a<0?a=e=="page"?0:s-1:a>=s&&(a=e=="page"?s-1:0),t.dispatch({effects:g_.of(a)}),!0}}var j4=n=>{let e=n.state.field(wn,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestamp<n.state.facet(Lt).interactionDelay?!1:v_(n,e.open.options[e.open.selected])},r_=n=>n.state.field(wn,!1)?(n.dispatch({effects:vy.of(!0)}),!0):!1,F4=n=>{let e=n.state.field(wn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:Hh.of(null)}),!0)},f_=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},q4=50,V4=1e3,H4=Yt.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of n.state.field(wn).active)e.isPending&&this.startQuery(e)}update(n){let e=n.state.field(wn),t=n.state.facet(Lt);if(!n.selectionSet&&!n.docChanged&&n.startState.field(wn)==e)return;let i=n.transactions.some(o=>{let s=gM(o,t);return s&8||(o.selection||o.docChanged)&&!(s&3)});for(let o=0;o<this.running.length;o++){let s=this.running[o];if(i||s.context.abortOnDocChange&&n.docChanged||s.updates.length+n.transactions.length>q4&&Date.now()-s.time>V4){for(let a of s.context.abortListeners)try{a()}catch(l){It(this.view.state,l)}s.context.abortListeners=null,this.running.splice(o--,1)}else s.updates.push(...n.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),n.transactions.some(o=>o.effects.some(s=>s.is(vy)))&&(this.pendingStart=!0);let r=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(o=>o.isPending&&!this.running.some(s=>s.active.source==o.source))?setTimeout(()=>this.startUpdate(),r):-1,this.composing!=0)for(let o of n.transactions)o.isUserEvent("input.type")?this.composing=2:this.composing==2&&o.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:n}=this.view,e=n.field(wn);for(let t of e.active)t.isPending&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Lt).updateSyncTime))}startQuery(n){let{state:e}=this.view,t=Xs(e),i=new gy(e,t,n.explicit,this.view),r=new f_(n,i);this.running.push(r),Promise.resolve(n.source(i)).then(o=>{r.context.aborted||(r.done=o||null,this.scheduleAccept())},o=>{this.view.dispatch({effects:Hh.of(null)}),It(this.view.state,o)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Lt).updateSyncTime))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Lt),i=this.view.state.field(wn);for(let r=0;r<this.running.length;r++){let o=this.running[r];if(o.done===void 0)continue;if(this.running.splice(r--,1),o.done){let a=Xs(o.updates.length?o.updates[0].startState:this.view.state),l=Math.min(a,o.done.from+(o.active.explicit?0:1)),c=new xy(o.active.source,o.active.explicit,l,o.done,o.done.from,(n=o.done.to)!==null&&n!==void 0?n:a);for(let u of o.updates)c=c.update(u,t);if(c.hasResult()){e.push(c);continue}}let s=i.active.find(a=>a.source==o.active.source);if(s&&s.isPending)if(o.done==null){let a=new Hr(o.active.source,0);for(let l of o.updates)a=a.update(l,t);a.isPending||e.push(a)}else this.startQuery(s)}(e.length||i.open&&i.open.disabled)&&this.view.dispatch({effects:y_.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(wn,!1);if(e&&e.tooltip&&this.view.state.facet(Lt).closeOnBlur){let t=e.open&&Pb(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Hh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:vy.of(!1)}),20),this.composing=0}}}),z4=typeof navigator=="object"&&/Win/.test(navigator.platform),W4=$r.highest(U.domEventHandlers({keydown(n,e){let t=e.state.field(wn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||n.key.length>1||n.ctrlKey&&!(z4&&n.altKey)||n.metaKey)return!1;let i=t.open.options[t.open.selected],r=t.active.find(s=>s.source==i.source),o=i.completion.commitCharacters||r.result.commitCharacters;return o&&o.indexOf(n.key)>-1&&v_(e,i),!1}})),yM=U.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"\xB7\xB7\xB7"',opacity:.5,display:"block",textAlign:"center",cursor:"pointer"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'\u0192'"}},".cm-completionIcon-class":{"&:after":{content:"'\u25CB'"}},".cm-completionIcon-interface":{"&:after":{content:"'\u25CC'"}},".cm-completionIcon-variable":{"&:after":{content:"'\u{1D465}'"}},".cm-completionIcon-constant":{"&:after":{content:"'\u{1D436}'"}},".cm-completionIcon-type":{"&:after":{content:"'\u{1D461}'"}},".cm-completionIcon-enum":{"&:after":{content:"'\u222A'"}},".cm-completionIcon-property":{"&:after":{content:"'\u25A1'"}},".cm-completionIcon-keyword":{"&:after":{content:"'\u{1F511}\uFE0E'"}},".cm-completionIcon-namespace":{"&:after":{content:"'\u25A2'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),h_=class{constructor(e,t,i,r){this.field=e,this.line=t,this.from=i,this.to=r}},d_=class n{constructor(e,t,i){this.field=e,this.from=t,this.to=i}map(e){let t=e.mapPos(this.from,-1,Ot.TrackDel),i=e.mapPos(this.to,1,Ot.TrackDel);return t==null||i==null?null:new n(this.field,t,i)}},p_=class n{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let i=[],r=[t],o=e.doc.lineAt(t),s=/^\s*/.exec(o.text)[0];for(let l of this.lines){if(i.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let f=0;f<u;f++)c+=e.facet(fc);r.push(t+c.length-u),l=c+l.slice(u)}i.push(l),t+=l.length+1}let a=this.fieldPositions.map(l=>new d_(l.field,r[l.line]+l.from,r[l.line]+l.to));return{text:i,ranges:a}}static parse(e){let t=[],i=[],r=[],o;for(let s of e.split(/\r\n?|\n/)){for(;o=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(s);){let a=o[1]?+o[1]:null,l=o[2]||o[3]||"",c=-1;a===0&&(a=1e9);let u=l.replace(/\\[{}]/g,f=>f[1]);for(let f=0;f<t.length;f++)(a!=null?t[f].seq==a:u&&t[f].name==u)&&(c=f);if(c<0){let f=0;for(;f<t.length&&(a==null||t[f].seq!=null&&t[f].seq<a);)f++;t.splice(f,0,{seq:a,name:u}),c=f;for(let h of r)h.field>=c&&h.field++}for(let f of r)if(f.line==i.length&&f.from>o.index){let h=o[2]?3+(o[1]||"").length:2;f.from-=h,f.to-=h}r.push(new h_(c,i.length,o.index,o.index+u.length)),s=s.slice(0,o.index)+l+s.slice(o.index+o[0].length)}s=s.replace(/\\([{}])/g,(a,l,c)=>{for(let u of r)u.line==i.length&&u.from>c&&(u.from--,u.to--);return l}),i.push(s)}return new n(i,r)}},U4=he.widget({widget:new class extends ai{toDOM(){let n=document.createElement("span");return n.className="cm-snippetFieldPosition",n}ignoreEvent(){return!1}}}),Q4=he.mark({class:"cm-snippetField"}),dc=class n{constructor(e,t){this.ranges=e,this.active=t,this.deco=he.set(e.map(i=>(i.from==i.to?U4:Q4).range(i.from,i.to)),!0)}map(e){let t=[];for(let i of this.ranges){let r=i.map(e);if(!r)return null;t.push(r)}return new n(t,this.active)}selectionInsideField(e){return e.ranges.every(t=>this.ranges.some(i=>i.field==this.active&&i.from<=t.from&&i.to>=t.to))}},Wh=de.define({map(n,e){return n&&n.map(e)}}),K4=de.define(),zh=qt.define({create(){return null},update(n,e){for(let t of e.effects){if(t.is(Wh))return t.value;if(t.is(K4)&&n)return new dc(n.ranges,t.value)}return n&&e.docChanged&&(n=n.map(e.changes)),n&&e.selection&&!n.selectionInsideField(e.selection)&&(n=null),n},provide:n=>U.decorations.from(n,e=>e?e.deco:he.none)});function x_(n,e){return $.create(n.filter(t=>t.field==e).map(t=>$.range(t.from,t.to)))}function G4(n){let e=p_.parse(n);return(t,i,r,o)=>{let{text:s,ranges:a}=e.instantiate(t.state,r),{main:l}=t.state.selection,c={changes:{from:r,to:o==l.from?l.to:o,insert:be.of(s)},scrollIntoView:!0,annotations:i?[m_.of(i),Ft.userEvent.of("input.complete")]:void 0};if(a.length&&(c.selection=x_(a,0)),a.some(u=>u.field>0)){let u=new dc(a,0),f=c.effects=[Wh.of(u)];t.state.field(zh,!1)===void 0&&f.push(de.appendConfig.of([zh,eH,tH,yM]))}t.dispatch(t.state.update(c))}}function vM(n){return({state:e,dispatch:t})=>{let i=e.field(zh,!1);if(!i||n<0&&i.active==0)return!1;let r=i.active+n,o=n>0&&!i.ranges.some(s=>s.field==r+n);return t(e.update({selection:x_(i.ranges,r),effects:Wh.of(o?null:new dc(i.ranges,r)),scrollIntoView:!0})),!0}}var X4=({state:n,dispatch:e})=>n.field(zh,!1)?(e(n.update({effects:Wh.of(null)})),!0):!1,Y4=vM(1),Z4=vM(-1);var J4=[{key:"Tab",run:Y4,shift:Z4},{key:"Escape",run:X4}],hM=H.define({combine(n){return n.length?n[0]:J4}}),eH=$r.highest(sc.compute([hM],n=>n.facet(hM)));function li(n,e){return{...e,apply:G4(n)}}var tH=U.domEventHandlers({mousedown(n,e){let t=e.state.field(zh,!1),i;if(!t||(i=e.posAtCoords({x:n.clientX,y:n.clientY}))==null)return!1;let r=t.ranges.find(o=>o.from<=i&&o.to>=i);return!r||r.field==t.active?!1:(e.dispatch({selection:x_(t.ranges,r.field),effects:Wh.of(t.ranges.some(o=>o.field>r.field)?new dc(t.ranges,r.field):null),scrollIntoView:!0}),!0)}});var by={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Gs=de.define({map(n,e){let t=e.mapPos(n,-1,Ot.TrackAfter);return t==null?void 0:t}}),b_=new class extends ei{};b_.startSide=1;b_.endSide=-1;var xM=qt.define({create(){return Be.empty},update(n,e){if(n=n.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);n=n.update({filter:i=>i>=t.from&&i<=t.to})}for(let t of e.effects)t.is(Gs)&&(n=n.update({add:[b_.range(t.value,t.value+1)]}));return n}});function bM(){return[oH,xM]}var o_="()[]{}<>\xAB\xBB\xBB\xAB\uFF3B\uFF3D\uFF5B\uFF5D";function nH(n){for(let e=0;e<o_.length;e+=2)if(o_.charCodeAt(e)==n)return o_.charAt(e+1);return E0(n<128?n:n+1)}function iH(n,e){return n.languageDataAt("closeBrackets",e)[0]||by}var rH=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),oH=U.inputHandler.of((n,e,t,i)=>{if((rH?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let r=n.state.selection.main;if(i.length>2||i.length==2&&Yi(ti(i,0))==1||e!=r.from||t!=r.to)return!1;let o=sH(n.state,i);return o?(n.dispatch(o),!0):!1});function sH(n,e){let t=iH(n,n.selection.main.head),i=t.brackets||by.brackets;for(let r of i){let o=nH(ti(r,0));if(e==r)return o==r?cH(n,r,i.indexOf(r+r+r)>-1,t):aH(n,r,o,t.before||by.before);if(e==o&&_M(n,n.selection.main.from))return lH(n,r,o)}return null}function _M(n,e){let t=!1;return n.field(xM).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function __(n,e){let t=n.sliceString(e,e+2);return t.slice(0,Yi(ti(t,0)))}function aH(n,e,t,i){let r=null,o=n.changeByRange(s=>{if(!s.empty)return{changes:[{insert:e,from:s.from},{insert:t,from:s.to}],effects:Gs.of(s.to+e.length),range:$.range(s.anchor+e.length,s.head+e.length)};let a=__(n.doc,s.head);return!a||/\s/.test(a)||i.indexOf(a)>-1?{changes:{insert:e+t,from:s.head},effects:Gs.of(s.head+e.length),range:$.cursor(s.head+e.length)}:{range:r=s}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function lH(n,e,t){let i=null,r=n.changeByRange(o=>o.empty&&__(n.doc,o.head)==t?{changes:{from:o.head,to:o.head+t.length,insert:t},range:$.cursor(o.head+t.length)}:i={range:o});return i?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function cH(n,e,t,i){let r=i.stringPrefixes||by.stringPrefixes,o=null,s=n.changeByRange(a=>{if(!a.empty)return{changes:[{insert:e,from:a.from},{insert:e,from:a.to}],effects:Gs.of(a.to+e.length),range:$.range(a.anchor+e.length,a.head+e.length)};let l=a.head,c=__(n.doc,l),u;if(c==e){if(dM(n,l))return{changes:{insert:e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)};if(_M(n,l)){let h=t&&n.sliceDoc(l,l+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:l,to:l+h.length,insert:h},range:$.cursor(l+h.length)}}}else{if(t&&n.sliceDoc(l-2*e.length,l)==e+e&&(u=pM(n,l-2*e.length,r))>-1&&dM(n,u))return{changes:{insert:e+e+e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)};if(n.charCategorizer(l)(c)!=ln.Word&&pM(n,l,r)>-1&&!uH(n,l,e,r))return{changes:{insert:e+e,from:l},effects:Gs.of(l+e.length),range:$.cursor(l+e.length)}}return{range:o=a}});return o?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function dM(n,e){let t=lt(n).resolveInner(e+1);return t.parent&&t.from==e}function uH(n,e,t,i){let r=lt(n).resolveInner(e,-1),o=i.reduce((s,a)=>Math.max(s,a.length),0);for(let s=0;s<5;s++){let a=n.sliceDoc(r.from,Math.min(r.to,r.from+t.length+o)),l=a.indexOf(t);if(!l||l>-1&&i.indexOf(a.slice(0,l))>-1){let u=r.firstChild;for(;u&&u.from==r.from&&u.to-u.from>t.length+l;){if(n.sliceDoc(u.to-t.length,u.to)==t)return!1;u=u.firstChild}return!0}let c=r.to==e&&r.parent;if(!c)break;r=c}return!1}function pM(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=ln.Word)return e;for(let r of t){let o=e-r.length;if(n.sliceDoc(o,e)==r&&i(n.sliceDoc(o-1,o))!=ln.Word)return o}return-1}function wM(n={}){return[W4,wn,Lt.of(n),H4,hH,yM]}var fH=[{key:"Ctrl-Space",run:r_},{mac:"Alt-`",run:r_},{mac:"Alt-i",run:r_},{key:"Escape",run:F4},{key:"ArrowDown",run:my(!0)},{key:"ArrowUp",run:my(!1)},{key:"PageDown",run:my(!0,"page")},{key:"PageUp",run:my(!1,"page")},{key:"Enter",run:j4}],hH=$r.highest(sc.computeN([Lt],n=>n.facet(Lt).defaultKeymap?[fH]:[]));var dH=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=k_(n.state,t.from);return i.line?pH(n):i.block?gH(n):!1};function O_(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let r=n(e,t);return r?(i(t.update(r)),!0):!1}}var pH=O_(xH,0);var mH=O_(PM,0);var gH=O_((n,e)=>PM(n,e,vH(e)),0);function k_(n,e){let t=n.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}var Uh=50;function yH(n,{open:e,close:t},i,r){let o=n.sliceDoc(i-Uh,i),s=n.sliceDoc(r,r+Uh),a=/\s*$/.exec(o)[0].length,l=/^\s*/.exec(s)[0].length,c=o.length-a;if(o.slice(c-e.length,c)==e&&s.slice(l,l+t.length)==t)return{open:{pos:i-a,margin:a&&1},close:{pos:r+l,margin:l&&1}};let u,f;r-i<=2*Uh?u=f=n.sliceDoc(i,r):(u=n.sliceDoc(i,i+Uh),f=n.sliceDoc(r-Uh,r));let h=/^\s*/.exec(u)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return u.slice(h,h+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+h+e.length,margin:/\s/.test(u.charAt(h+e.length))?1:0},close:{pos:r-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function vH(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),r=t.to<=i.to?i:n.doc.lineAt(t.to);r.from>i.from&&r.from==t.to&&(r=t.to==i.to+1?i:n.doc.lineAt(t.to-1));let o=e.length-1;o>=0&&e[o].to>i.from?e[o].to=r.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:r.to})}return e}function PM(n,e,t=e.selection.ranges){let i=t.map(o=>k_(e,o.from).block);if(!i.every(o=>o))return null;let r=t.map((o,s)=>yH(e,i[s],o.from,o.to));if(n!=2&&!r.every(o=>o))return{changes:e.changes(t.map((o,s)=>r[s]?[]:[{from:o.from,insert:i[s].open+" "},{from:o.to,insert:" "+i[s].close}]))};if(n!=1&&r.some(o=>o)){let o=[];for(let s=0,a;s<r.length;s++)if(a=r[s]){let l=i[s],{open:c,close:u}=a;o.push({from:c.pos-l.open.length,to:c.pos+c.margin},{from:u.pos-u.margin,to:u.pos+l.close.length})}return{changes:o}}return null}function xH(n,e,t=e.selection.ranges){let i=[],r=-1;e:for(let{from:o,to:s}of t){let a=i.length,l=1e9,c;for(let u=o;u<=s;){let f=e.doc.lineAt(u);if(c==null&&(c=k_(e,f.from).line,!c))continue e;if(f.from>r&&(o==s||s>f.from)){r=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+c.length)==c?h:-1;h<f.text.length&&h<l&&(l=h),i.push({line:f,comment:p,token:c,indent:h,empty:d,single:!1})}u=f.to+1}if(l<1e9)for(let u=a;u<i.length;u++)i[u].indent<i[u].line.text.length&&(i[u].indent=l);i.length==a+1&&(i[a].single=!0)}if(n!=2&&i.some(o=>o.comment<0&&(!o.empty||o.single))){let o=[];for(let{line:a,token:l,indent:c,empty:u,single:f}of i)(f||!u)&&o.push({from:a.from+c,insert:l+" "});let s=e.changes(o);return{changes:s,selection:e.selection.map(s,1)}}else if(n!=1&&i.some(o=>o.comment>=0)){let o=[];for(let{line:s,comment:a,token:l}of i)if(a>=0){let c=s.from+a,u=c+l.length;s.text[u-s.from]==" "&&u++,o.push({from:c,to:u})}return{changes:o}}return null}var CM=Mn.define();var bH=H.define();var Ys=class n{constructor(e,t,i,r,o){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=r,this.selectionsAfter=o}setSelAfter(e){return new n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(r=>r.toJSON())}}static fromJSON(e){return new n(e.changes&&cn.fromJSON(e.changes),[],e.mapped&&Br.fromJSON(e.mapped),e.startSelection&&$.fromJSON(e.startSelection),e.selectionsAfter.map($.fromJSON))}static fromTransaction(e,t){let i=ci;for(let r of e.startState.facet(bH)){let o=r(e);o.length&&(i=i.concat(o))}return!i.length&&e.changes.empty?null:new n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,ci)}static selection(e){return new n(void 0,ci,void 0,void 0,e)}};function C_(n,e,t,i){let r=e+1>t+20?e-t-1:0,o=n.slice(r,e);return o.push(i),o}function _H(n,e){let t=[],i=!1;return n.iterChangedRanges((r,o)=>t.push(r,o)),e.iterChangedRanges((r,o,s,a)=>{for(let l=0;l<t.length;){let c=t[l++],u=t[l++];a>=c&&s<=u&&(i=!0)}}),i}function wH(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function DM(n,e){return n.length?e.length?n.concat(e):n:e}var ci=[],CH=200;function EH(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-CH));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),C_(n,n.length-1,1e9,t.setSelAfter(i)))}else return[Ys.selection([e])]}function SH(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function w_(n,e){if(!n.length)return n;let t=n.length,i=ci;for(;t;){let r=OH(n[t-1],e,i);if(r.changes&&!r.changes.empty||r.effects.length){let o=n.slice(0,t);return o[t-1]=r,o}else e=r.mapped,t--,i=r.selectionsAfter}return i.length?[Ys.selection(i)]:ci}function OH(n,e,t){let i=DM(n.selectionsAfter.length?n.selectionsAfter.map(a=>a.map(e)):ci,t);if(!n.changes)return Ys.selection(i);let r=n.changes.map(e),o=e.mapDesc(n.changes,!0),s=n.mapped?n.mapped.composeDesc(o):o;return new Ys(r,de.mapEffects(n.effects,e),s,n.startSelection.map(o),i)}var kH=/^(input\.type|delete)($|\.)/,wy=class n{constructor(e,t,i=0,r=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=r}isolate(){return this.prevTime?new n(this.done,this.undone):this}addChanges(e,t,i,r,o){let s=this.done,a=s[s.length-1];return a&&a.changes&&!a.changes.empty&&e.changes&&(!i||kH.test(i))&&(!a.selectionsAfter.length&&t-this.prevTime<r.newGroupDelay&&r.joinToEvent(o,_H(a.changes,e.changes))||i=="input.type.compose")?s=C_(s,s.length-1,r.minDepth,new Ys(e.changes.compose(a.changes),DM(de.mapEffects(e.effects,a.changes),a.effects),a.mapped,a.startSelection,ci)):s=C_(s,s.length,r.minDepth,e),new n(s,ci,t,i)}addSelection(e,t,i,r){let o=this.done.length?this.done[this.done.length-1].selectionsAfter:ci;return o.length>0&&t-this.prevTime<r&&i==this.prevUserEvent&&i&&/^select($|\.)/.test(i)&&wH(o[o.length-1],e)?this:new n(EH(this.done,e),this.undone,t,i)}addMapping(e){return new n(w_(this.done,e),w_(this.undone,e),this.prevTime,this.prevUserEvent)}pop(e,t,i){let r=e==0?this.done:this.undone;if(r.length==0)return null;let o=r[r.length-1],s=o.selectionsAfter[0]||(o.startSelection?o.startSelection.map(o.changes.invertedDesc,1):t.selection);if(i&&o.selectionsAfter.length)return t.update({selection:o.selectionsAfter[o.selectionsAfter.length-1],annotations:CM.of({side:e,rest:SH(r),selection:s}),userEvent:e==0?"select.undo":"select.redo",scrollIntoView:!0});if(o.changes){let a=r.length==1?ci:r.slice(0,r.length-1);return o.mapped&&(a=w_(a,o.mapped)),t.update({changes:o.changes,selection:o.startSelection,effects:o.effects,annotations:CM.of({side:e,rest:a,selection:s}),filter:!1,userEvent:e==0?"undo":"redo",scrollIntoView:!0})}else return null}};wy.empty=new wy(ci,ci);function mc(n,e){return $.create(n.ranges.map(e),n.mainIndex)}function Si(n,e){return n.update({selection:e,scrollIntoView:!0,userEvent:"select"})}function Oi({state:n,dispatch:e},t){let i=mc(n.selection,t);return i.eq(n.selection,!0)?!1:(e(Si(n,i)),!0)}function Cy(n,e){return $.cursor(e?n.to:n.from)}function IM(n,e){return Oi(n,t=>t.empty?n.moveByChar(t,e):Cy(t,e))}function Jt(n){return n.textDirectionAt(n.state.selection.main.head)==We.LTR}var LM=n=>IM(n,!Jt(n)),BM=n=>IM(n,Jt(n));function NM(n,e){return Oi(n,t=>t.empty?n.moveByGroup(t,e):Cy(t,e))}var RH=n=>NM(n,!Jt(n)),TH=n=>NM(n,Jt(n));var Qge=typeof Intl!="undefined"&&Intl.Segmenter?new Intl.Segmenter(void 0,{granularity:"word"}):null;function AH(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function Ey(n,e,t){let i=lt(n).resolveInner(e.head),r=t?ce.closedBy:ce.openedBy;for(let l=e.head;;){let c=t?i.childAfter(l):i.childBefore(l);if(!c)break;AH(n,c,r)?i=c:l=t?c.to:c.from}let o=i.type.prop(r),s,a;return o&&(s=t?Ei(n,i.from,1):Ei(n,i.to,-1))&&s.matched?a=t?s.end.to:s.end.from:a=t?i.to:i.from,$.cursor(a,t?-1:1)}var MH=n=>Oi(n,e=>Ey(n.state,e,!Jt(n))),PH=n=>Oi(n,e=>Ey(n.state,e,Jt(n)));function $M(n,e){return Oi(n,t=>{if(!t.empty)return Cy(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}var jM=n=>$M(n,!1),FM=n=>$M(n,!0);function qM(n){let e=n.scrollDOM.clientHeight<n.scrollDOM.scrollHeight-2,t=0,i=0,r;if(e){for(let o of n.state.facet(U.scrollMargins)){let s=o(n);s!=null&&s.top&&(t=Math.max(s==null?void 0:s.top,t)),s!=null&&s.bottom&&(i=Math.max(s==null?void 0:s.bottom,i))}r=n.scrollDOM.clientHeight-t-i}else r=(n.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:t,marginBottom:i,selfScroll:e,height:Math.max(n.defaultLineHeight,r-5)}}function VM(n,e){let t=qM(n),{state:i}=n,r=mc(i.selection,s=>s.empty?n.moveVertically(s,e,t.height):Cy(s,e));if(r.eq(i.selection))return!1;let o;if(t.selfScroll){let s=n.coordsAtPos(i.selection.main.head),a=n.scrollDOM.getBoundingClientRect(),l=a.top+t.marginTop,c=a.bottom-t.marginBottom;s&&s.top>l&&s.bottom<c&&(o=U.scrollIntoView(r.main.head,{y:"start",yMargin:s.top-l}))}return n.dispatch(Si(i,r),{effects:o}),!0}var EM=n=>VM(n,!1),E_=n=>VM(n,!0);function Vo(n,e,t){let i=n.lineBlockAt(e.head),r=n.moveToLineBoundary(e,t);if(r.head==e.head&&r.head!=(t?i.to:i.from)&&(r=n.moveToLineBoundary(e,t,!1)),!t&&r.head==i.from&&i.length){let o=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;o&&e.head!=i.from+o&&(r=$.cursor(i.from+o))}return r}var DH=n=>Oi(n,e=>Vo(n,e,!0)),IH=n=>Oi(n,e=>Vo(n,e,!1)),LH=n=>Oi(n,e=>Vo(n,e,!Jt(n))),BH=n=>Oi(n,e=>Vo(n,e,Jt(n))),NH=n=>Oi(n,e=>$.cursor(n.lineBlockAt(e.head).from,1)),$H=n=>Oi(n,e=>$.cursor(n.lineBlockAt(e.head).to,-1));function jH(n,e,t){let i=!1,r=mc(n.selection,o=>{let s=Ei(n,o.head,-1)||Ei(n,o.head,1)||o.head>0&&Ei(n,o.head-1,1)||o.head<n.doc.length&&Ei(n,o.head+1,-1);if(!s||!s.end)return o;i=!0;let a=s.start.from==o.head?s.end.to:s.end.from;return t?$.range(o.anchor,a):$.cursor(a)});return i?(e(Si(n,r)),!0):!1}var FH=({state:n,dispatch:e})=>jH(n,e,!1);function ui(n,e){let t=mc(n.state.selection,i=>{let r=e(i);return $.range(i.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return t.eq(n.state.selection)?!1:(n.dispatch(Si(n.state,t)),!0)}function HM(n,e){return ui(n,t=>n.moveByChar(t,e))}var zM=n=>HM(n,!Jt(n)),WM=n=>HM(n,Jt(n));function UM(n,e){return ui(n,t=>n.moveByGroup(t,e))}var qH=n=>UM(n,!Jt(n)),VH=n=>UM(n,Jt(n));var HH=n=>ui(n,e=>Ey(n.state,e,!Jt(n))),zH=n=>ui(n,e=>Ey(n.state,e,Jt(n)));function QM(n,e){return ui(n,t=>n.moveVertically(t,e))}var KM=n=>QM(n,!1),GM=n=>QM(n,!0);function XM(n,e){return ui(n,t=>n.moveVertically(t,e,qM(n).height))}var SM=n=>XM(n,!1),OM=n=>XM(n,!0),WH=n=>ui(n,e=>Vo(n,e,!0)),UH=n=>ui(n,e=>Vo(n,e,!1)),QH=n=>ui(n,e=>Vo(n,e,!Jt(n))),KH=n=>ui(n,e=>Vo(n,e,Jt(n))),GH=n=>ui(n,e=>$.cursor(n.lineBlockAt(e.head).from)),XH=n=>ui(n,e=>$.cursor(n.lineBlockAt(e.head).to)),kM=({state:n,dispatch:e})=>(e(Si(n,{anchor:0})),!0),RM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.doc.length})),!0),TM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.selection.main.anchor,head:0})),!0),AM=({state:n,dispatch:e})=>(e(Si(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),YH=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),ZH=({state:n,dispatch:e})=>{let t=Sy(n).map(({from:i,to:r})=>$.range(i,Math.min(r+1,n.doc.length)));return e(n.update({selection:$.create(t),userEvent:"select"})),!0},JH=({state:n,dispatch:e})=>{let t=mc(n.selection,i=>{let r=lt(n),o=r.resolveStack(i.from,1);if(i.empty){let s=r.resolveStack(i.from,-1);s.node.from>=o.node.from&&s.node.to<=o.node.to&&(o=s)}for(let s=o;s;s=s.next){let{node:a}=s;if((a.from<i.from&&a.to>=i.to||a.to>i.to&&a.from<=i.from)&&s.next)return $.range(a.to,a.from)}return i});return t.eq(n.selection)?!1:(e(Si(n,t)),!0)};function YM(n,e){let{state:t}=n,i=t.selection,r=t.selection.ranges.slice();for(let o of t.selection.ranges){let s=t.doc.lineAt(o.head);if(e?s.to<n.state.doc.length:s.from>0)for(let a=o;;){let l=n.moveVertically(a,e);if(l.head<s.from||l.head>s.to){r.some(c=>c.head==l.head)||r.push(l);break}else{if(l.head==a.head)break;a=l}}}return r.length==i.ranges.length?!1:(n.dispatch(Si(t,$.create(r,r.length-1))),!0)}var e6=n=>YM(n,!1),t6=n=>YM(n,!0),n6=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=$.create([t.main]):t.main.empty||(i=$.create([$.cursor(t.main.head)])),i?(e(Si(n,i)),!0):!1};function Qh(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,r=i.changeByRange(o=>{let{from:s,to:a}=o;if(s==a){let l=e(o);l<s?(t="delete.backward",l=_y(n,l,!1)):l>s&&(t="delete.forward",l=_y(n,l,!0)),s=Math.min(s,l),a=Math.max(a,l)}else s=_y(n,s,!1),a=_y(n,a,!0);return s==a?{range:o}:{changes:{from:s,to:a},range:$.cursor(s,s<o.head?-1:1)}});return r.changes.empty?!1:(n.dispatch(i.update(r,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?U.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function _y(n,e,t){if(n instanceof U)for(let i of n.state.facet(U.atomicRanges).map(r=>r(n)))i.between(e,e,(r,o)=>{r<e&&o>e&&(e=t?o:r)});return e}var ZM=(n,e,t)=>Qh(n,i=>{let r=i.from,{state:o}=n,s=o.doc.lineAt(r),a,l;if(t&&!e&&r>s.from&&r<s.from+200&&!/[^ \t]/.test(a=s.text.slice(0,r-s.from))){if(a[a.length-1]==" ")return r-1;let c=$s(a,o.tabSize),u=c%Vh(o)||Vh(o);for(let f=0;f<u&&a[a.length-1-f]==" ";f++)r--;l=r}else l=Dt(s.text,r-s.from,e,e)+s.from,l==r&&s.number!=(e?o.doc.lines:1)?l+=e?1:-1:!e&&/[\ufe00-\ufe0f]/.test(s.text.slice(l-s.from,r-s.from))&&(l=Dt(s.text,l-s.from,!1,!1)+s.from);return l}),S_=n=>ZM(n,!1,!0);var JM=n=>ZM(n,!0,!1),eP=(n,e)=>Qh(n,t=>{let i=t.head,{state:r}=n,o=r.doc.lineAt(i),s=r.charCategorizer(i);for(let a=null;;){if(i==(e?o.to:o.from)){i==t.head&&o.number!=(e?r.doc.lines:1)&&(i+=e?1:-1);break}let l=Dt(o.text,i-o.from,e)+o.from,c=o.text.slice(Math.min(i,l)-o.from,Math.max(i,l)-o.from),u=s(c);if(a!=null&&u!=a)break;(c!=" "||i!=t.head)&&(a=u),i=l}return i}),tP=n=>eP(n,!1),i6=n=>eP(n,!0);var r6=n=>Qh(n,e=>{let t=n.lineBlockAt(e.head).to;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var o6=n=>Qh(n,e=>{let t=n.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),s6=n=>Qh(n,e=>{let t=n.moveToLineBoundary(e,!0).head;return e.head<t?t:Math.min(n.state.doc.length,e.head+1)});var a6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:be.of(["",""])},range:$.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},l6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let r=i.from,o=n.doc.lineAt(r),s=r==o.from?r-1:Dt(o.text,r-o.from,!1)+o.from,a=r==o.to?r+1:Dt(o.text,r-o.from,!0)+o.from;return{changes:{from:s,to:a,insert:n.doc.slice(r,a).append(n.doc.slice(s,r))},range:$.cursor(a)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Sy(n){let e=[],t=-1;for(let i of n.selection.ranges){let r=n.doc.lineAt(i.from),o=n.doc.lineAt(i.to);if(!i.empty&&i.to==o.from&&(o=n.doc.lineAt(i.to-1)),t>=r.number){let s=e[e.length-1];s.to=o.to,s.ranges.push(i)}else e.push({from:r.from,to:o.to,ranges:[i]});t=o.number+1}return e}function nP(n,e,t){if(n.readOnly)return!1;let i=[],r=[];for(let o of Sy(n)){if(t?o.to==n.doc.length:o.from==0)continue;let s=n.doc.lineAt(t?o.to+1:o.from-1),a=s.length+1;if(t){i.push({from:o.to,to:s.to},{from:o.from,insert:s.text+n.lineBreak});for(let l of o.ranges)r.push($.range(Math.min(n.doc.length,l.anchor+a),Math.min(n.doc.length,l.head+a)))}else{i.push({from:s.from,to:o.from},{from:o.to,insert:n.lineBreak+s.text});for(let l of o.ranges)r.push($.range(l.anchor-a,l.head-a))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:$.create(r,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}var c6=({state:n,dispatch:e})=>nP(n,e,!1),u6=({state:n,dispatch:e})=>nP(n,e,!0);function iP(n,e,t){if(n.readOnly)return!1;let i=[];for(let o of Sy(n))t?i.push({from:o.from,insert:n.doc.slice(o.from,o.to)+n.lineBreak}):i.push({from:o.to,insert:n.lineBreak+n.doc.slice(o.from,o.to)});let r=n.changes(i);return e(n.update({changes:r,selection:n.selection.map(r,t?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}var f6=({state:n,dispatch:e})=>iP(n,e,!1),h6=({state:n,dispatch:e})=>iP(n,e,!0),d6=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(Sy(e).map(({from:r,to:o})=>(r>0?r--:o<e.doc.length&&o++,{from:r,to:o}))),i=mc(e.selection,r=>{let o;if(n.lineWrapping){let s=n.lineBlockAt(r.head),a=n.coordsAtPos(r.head,r.assoc||1);a&&(o=s.bottom+n.documentTop-a.bottom+n.defaultLineHeight/2)}return n.moveVertically(r,!0,o)}).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function p6(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=lt(n).resolveInner(e),i=t.childBefore(e),r=t.childAfter(e),o;return i&&r&&i.to<=e&&r.from>=e&&(o=i.type.prop(ce.closedBy))&&o.indexOf(r.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(r.from).from&&!/\S/.test(n.sliceDoc(i.to,r.from))?{from:i.to,to:r.from}:null}var MM=rP(!1),m6=rP(!0);function rP(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(r=>{let{from:o,to:s}=r,a=e.doc.lineAt(o),l=!n&&o==s&&p6(e,o);n&&(o=s=(s<=a.to?a:e.doc.lineAt(s)).to);let c=new Ks(e,{simulateBreak:o,simulateDoubleBreak:!!l}),u=hy(c,o);for(u==null&&(u=$s(/^\s*/.exec(e.doc.lineAt(o).text)[0],e.tabSize));s<a.to&&/\s/.test(a.text[s-a.from]);)s++;l?{from:o,to:s}=l:o>a.from&&o<a.from+100&&!/\S/.test(a.text.slice(0,o))&&(o=a.from);let f=["",hc(e,u)];return l&&f.push(hc(e,c.lineIndent(a.from,-1))),{changes:{from:o,to:s,insert:be.of(f)},range:$.cursor(o+1+f[1].length)}});return t(e.update(i,{scrollIntoView:!0,userEvent:"input"})),!0}}function R_(n,e){let t=-1;return n.changeByRange(i=>{let r=[];for(let s=i.from;s<=i.to;){let a=n.doc.lineAt(s);a.number>t&&(i.empty||i.to>a.from)&&(e(a,r,i),t=a.number),s=a.to+1}let o=n.changes(r);return{changes:r,range:$.range(o.mapPos(i.anchor,1),o.mapPos(i.head,1))}})}var g6=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new Ks(n,{overrideIndentation:o=>{let s=t[o];return s==null?-1:s}}),r=R_(n,(o,s,a)=>{let l=hy(i,o.from);if(l==null)return;/\S/.test(o.text)||(l=0);let c=/^\s*/.exec(o.text)[0],u=hc(n,l);(c!=u||a.from<o.from+c.length)&&(t[o.from]=l,s.push({from:o.from,to:o.from+c.length,insert:u}))});return r.changes.empty||e(n.update(r,{userEvent:"indent"})),!0},y6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(R_(n,(t,i)=>{i.push({from:t.from,insert:n.facet(fc)})}),{userEvent:"input.indent"})),!0),v6=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(R_(n,(t,i)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let o=$s(r,n.tabSize),s=0,a=hc(n,Math.max(0,o-Vh(n)));for(;s<r.length&&s<a.length&&r.charCodeAt(s)==a.charCodeAt(s);)s++;i.push({from:t.from+s,to:t.from+r.length,insert:a.slice(s)})}),{userEvent:"delete.dedent"})),!0),x6=n=>(n.setTabFocusMode(),!0);var b6=[{key:"Ctrl-b",run:LM,shift:zM,preventDefault:!0},{key:"Ctrl-f",run:BM,shift:WM},{key:"Ctrl-p",run:jM,shift:KM},{key:"Ctrl-n",run:FM,shift:GM},{key:"Ctrl-a",run:NH,shift:GH},{key:"Ctrl-e",run:$H,shift:XH},{key:"Ctrl-d",run:JM},{key:"Ctrl-h",run:S_},{key:"Ctrl-k",run:r6},{key:"Ctrl-Alt-h",run:tP},{key:"Ctrl-o",run:a6},{key:"Ctrl-t",run:l6},{key:"Ctrl-v",run:E_}],_6=[{key:"ArrowLeft",run:LM,shift:zM,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:RH,shift:qH,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:LH,shift:QH,preventDefault:!0},{key:"ArrowRight",run:BM,shift:WM,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:TH,shift:VH,preventDefault:!0},{mac:"Cmd-ArrowRight",run:BH,shift:KH,preventDefault:!0},{key:"ArrowUp",run:jM,shift:KM,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kM,shift:TM},{mac:"Ctrl-ArrowUp",run:EM,shift:SM},{key:"ArrowDown",run:FM,shift:GM,preventDefault:!0},{mac:"Cmd-ArrowDown",run:RM,shift:AM},{mac:"Ctrl-ArrowDown",run:E_,shift:OM},{key:"PageUp",run:EM,shift:SM},{key:"PageDown",run:E_,shift:OM},{key:"Home",run:IH,shift:UH,preventDefault:!0},{key:"Mod-Home",run:kM,shift:TM},{key:"End",run:DH,shift:WH,preventDefault:!0},{key:"Mod-End",run:RM,shift:AM},{key:"Enter",run:MM,shift:MM},{key:"Mod-a",run:YH},{key:"Backspace",run:S_,shift:S_,preventDefault:!0},{key:"Delete",run:JM,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:tP,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:i6,preventDefault:!0},{mac:"Mod-Backspace",run:o6,preventDefault:!0},{mac:"Mod-Delete",run:s6,preventDefault:!0}].concat(b6.map(n=>({mac:n.key,run:n.run,shift:n.shift}))),oP=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:MH,shift:HH},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:PH,shift:zH},{key:"Alt-ArrowUp",run:c6},{key:"Shift-Alt-ArrowUp",run:f6},{key:"Alt-ArrowDown",run:u6},{key:"Shift-Alt-ArrowDown",run:h6},{key:"Mod-Alt-ArrowUp",run:e6},{key:"Mod-Alt-ArrowDown",run:t6},{key:"Escape",run:n6},{key:"Mod-Enter",run:m6},{key:"Alt-l",mac:"Ctrl-l",run:ZH},{key:"Mod-i",run:JH,preventDefault:!0},{key:"Mod-[",run:v6},{key:"Mod-]",run:y6},{key:"Mod-Alt-\\",run:g6},{key:"Shift-Mod-k",run:d6},{key:"Shift-Mod-\\",run:FH},{key:"Mod-/",run:dH},{key:"Alt-A",run:mH},{key:"Ctrl-m",mac:"Shift-Alt-m",run:x6}].concat(_6);var ky=class{constructor(e,t,i){this.from=e,this.to=t,this.diagnostic=i}},Zs=class n{constructor(e,t,i){this.diagnostics=e,this.panel=t,this.selected=i}static init(e,t,i){let r=i.facet(or).markerFilter;r&&(e=r(e,i));let o=e.slice().sort((d,p)=>d.from-p.from||d.to-p.to),s=new Nr,a=[],l=0,c=i.doc.iter(),u=0,f=i.doc.length;for(let d=0;;){let p=d==o.length?null:o[d];if(!p&&!a.length)break;let m,g;if(a.length)m=l,g=a.reduce((v,x)=>Math.min(v,x.to),p&&p.from>m?p.from:1e8);else{if(m=p.from,m>f)break;g=p.to,a.push(p),d++}for(;d<o.length;){let v=o[d];if(v.from==m&&(v.to>v.from||v.to==m))a.push(v),d++,g=Math.min(v.to,g);else{g=Math.min(v.from,g);break}}g=Math.min(g,f);let b=!1;if(a.some(v=>v.from==m&&(v.to==g||g==f))&&(b=m==g,!b&&g-m<10)){let v=m-(u+c.value.length);v>0&&(c.next(v),u=m);for(let x=m;;){if(x>=g){b=!0;break}if(!c.lineBreak&&u+c.value.length>x)break;x=u+c.value.length,u+=c.value.length,c.next()}}let _=D6(a);if(b)s.add(m,m,he.widget({widget:new T_(_),diagnostics:a.slice()}));else{let v=a.reduce((x,C)=>C.markClass?x+" "+C.markClass:x,"");s.add(m,g,he.mark({class:"cm-lintRange cm-lintRange-"+_+v,diagnostics:a.slice(),inclusiveEnd:a.some(x=>x.to>g)}))}if(l=g,l==f)break;for(let v=0;v<a.length;v++)a[v].to<=l&&a.splice(v--,1)}let h=s.finish();return new n(h,t,gc(h))}};function gc(n,e=null,t=0){let i=null;return n.between(t,1e9,(r,o,{spec:s})=>{if(!(e&&s.diagnostics.indexOf(e)<0))if(!i)i=new ky(r,o,e||s.diagnostics[0]);else{if(s.diagnostics.indexOf(i.diagnostic)<0)return!1;i=new ky(i.from,o,i.diagnostic)}}),i}function w6(n,e){let t=e.pos,i=e.end||t,r=n.state.facet(or).hideOn(n,t,i);if(r!=null)return r;let o=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(s=>s.is(Kh))||n.changes.touchesRange(o.from,Math.max(o.to,i)))}function C6(n,e){return n.field(ki,!1)?e:e.concat(de.appendConfig.of(dP))}function E6(n,e){return{effects:C6(n,[Kh.of(e)])}}var Kh=de.define(),lP=de.define(),cP=de.define(),ki=qt.define({create(){return new Zs(he.none,null,null)},update(n,e){if(e.docChanged&&n.diagnostics.size){let t=n.diagnostics.map(e.changes),i=null,r=n.panel;if(n.selected){let o=e.changes.mapPos(n.selected.from,1);i=gc(t,n.selected.diagnostic,o)||gc(t,null,o)}!t.size&&r&&e.state.facet(or).autoPanel&&(r=null),n=new Zs(t,r,i)}for(let t of e.effects)if(t.is(Kh)){let i=e.state.facet(or).autoPanel?t.value.length?Ty.open:null:n.panel;n=Zs.init(t.value,i,e.state)}else t.is(lP)?n=new Zs(n.diagnostics,t.value?Ty.open:null,n.selected):t.is(cP)&&(n=new Zs(n.diagnostics,n.panel,t.value));return n},provide:n=>[Zg.from(n,e=>e.panel),U.decorations.from(n,e=>e.diagnostics)]});var S6=he.mark({class:"cm-lintRange cm-lintRange-active"});function O6(n,e,t){let{diagnostics:i}=n.state.field(ki),r,o=-1,s=-1;i.between(e-(t<0?1:0),e+(t>0?1:0),(l,c,{spec:u})=>{if(e>=l&&e<=c&&(l==c||(e>l||t>0)&&(e<c||t<0)))return r=u.diagnostics,o=l,s=c,!1});let a=n.state.facet(or).tooltipFilter;return r&&a&&(r=a(r,n.state)),r?{pos:o,end:s,above:!0,create(){return{dom:k6(n,r)}}}:null}function k6(n,e){return Pn("ul",{class:"cm-tooltip-lint"},e.map(t=>hP(n,t,!1)))}var sP=n=>{let e=n.state.field(ki,!1);return!e||!e.panel?!1:(n.dispatch({effects:lP.of(!1)}),!0)};var R6=Yt.fromClass(class{constructor(n){this.view=n,this.timeout=-1,this.set=!0;let{delay:e}=n.state.facet(or);this.lintTime=Date.now()+e,this.run=this.run.bind(this),this.timeout=setTimeout(this.run,e)}run(){clearTimeout(this.timeout);let n=Date.now();if(n<this.lintTime-10)this.timeout=setTimeout(this.run,this.lintTime-n);else{this.set=!1;let{state:e}=this.view,{sources:t}=e.facet(or);t.length&&T6(t.map(i=>Promise.resolve(i(this.view))),i=>{this.view.state.doc==e.doc&&this.view.dispatch(E6(this.view.state,i.reduce((r,o)=>r.concat(o))))},i=>{It(this.view.state,i)})}}update(n){let e=n.state.facet(or);(n.docChanged||e!=n.startState.facet(or)||e.needsRefresh&&e.needsRefresh(n))&&(this.lintTime=Date.now()+e.delay,this.set||(this.set=!0,this.timeout=setTimeout(this.run,e.delay)))}force(){this.set&&(this.lintTime=Date.now(),this.run())}destroy(){clearTimeout(this.timeout)}});function T6(n,e,t){let i=[],r=-1;for(let o of n)o.then(s=>{i.push(s),clearTimeout(r),i.length==n.length?e(i):r=setTimeout(()=>e(i),200)},t)}var or=H.define({combine(n){return{sources:n.map(e=>e.source).filter(e=>e!=null),...Io(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:aP,tooltipFilter:aP,needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t,hideOn:(e,t)=>e?t?(i,r,o)=>e(i,r,o)||t(i,r,o):e:t,autoPanel:(e,t)=>e||t})}}});function aP(n,e){return n?e?(t,i)=>e(n(t,i),i):n:e}function uP(n,e={}){return[or.of({source:n,config:e}),R6,dP]}function fP(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;i<t.length;i++){let r=t[i];if(/[a-zA-Z]/.test(r)&&!e.some(o=>o.toLowerCase()==r.toLowerCase())){e.push(r);continue e}}e.push("")}return e}function hP(n,e,t){var i;let r=t?fP(e.actions):[];return Pn("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Pn("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(n):e.message),(i=e.actions)===null||i===void 0?void 0:i.map((o,s)=>{let a=!1,l=d=>{if(d.preventDefault(),a)return;a=!0;let p=gc(n.state.field(ki).diagnostics,e);p&&o.apply(n,p.from,p.to)},{name:c}=o,u=r[s]?c.indexOf(r[s]):-1,f=u<0?c:[c.slice(0,u),Pn("u",c.slice(u,u+1)),c.slice(u+1)],h=o.markClass?" "+o.markClass:"";return Pn("button",{type:"button",class:"cm-diagnosticAction"+h,onclick:l,onmousedown:l,"aria-label":` Action: ${c}${u<0?"":` (access key "${r[s]})"`}.`},f)}),e.source&&Pn("div",{class:"cm-diagnosticSource"},e.source))}var T_=class extends ai{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Pn("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}},Ry=class{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=hP(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}},Ty=class n{constructor(e){this.view=e,this.items=[];let t=r=>{if(!(r.ctrlKey||r.altKey||r.metaKey)){if(r.keyCode==27)sP(this.view),this.view.focus();else if(r.keyCode==38||r.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(r.keyCode==40||r.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(r.keyCode==36)this.moveSelection(0);else if(r.keyCode==35)this.moveSelection(this.items.length-1);else if(r.keyCode==13)this.view.focus();else if(r.keyCode>=65&&r.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:o}=this.items[this.selectedIndex],s=fP(o.actions);for(let a=0;a<s.length;a++)if(s[a].toUpperCase().charCodeAt(0)==r.keyCode){let l=gc(this.view.state.field(ki).diagnostics,o);l&&o.actions[a].apply(e,l.from,l.to)}}else return;r.preventDefault()}},i=r=>{for(let o=0;o<this.items.length;o++)this.items[o].dom.contains(r.target)&&this.moveSelection(o)};this.list=Pn("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:t,onclick:i}),this.dom=Pn("div",{class:"cm-panel-lint"},this.list,Pn("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>sP(this.view)},"\xD7")),this.update()}get selectedIndex(){let e=this.view.state.field(ki).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(ki),i=0,r=!1,o=null,s=new Set;for(e.between(0,this.view.state.doc.length,(a,l,{spec:c})=>{for(let u of c.diagnostics){if(s.has(u))continue;s.add(u);let f=-1,h;for(let d=i;d<this.items.length;d++)if(this.items[d].diagnostic==u){f=d;break}f<0?(h=new Ry(this.view,u),this.items.splice(i,0,h),r=!0):(h=this.items[f],f>i&&(this.items.splice(i,f-i),r=!0)),t&&h.diagnostic==t.diagnostic?h.dom.hasAttribute("aria-selected")||(h.dom.setAttribute("aria-selected","true"),o=h):h.dom.hasAttribute("aria-selected")&&h.dom.removeAttribute("aria-selected"),i++}});i<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Ry(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),r=!0),o?(this.list.setAttribute("aria-activedescendant",o.id),this.view.requestMeasure({key:this,read:()=>({sel:o.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:a,panel:l})=>{let c=l.height/this.list.offsetHeight;a.top<l.top?this.list.scrollTop-=(l.top-a.top)/c:a.bottom>l.bottom&&(this.list.scrollTop+=(a.bottom-l.bottom)/c)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(ki),i=gc(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:cP.of(i)})}static open(e){return new n(e)}};function A6(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${e}>${encodeURIComponent(n)}</svg>')`}function Oy(n){return A6(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${n}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}var M6=U.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:Oy("#f11")},".cm-lintRange-warning":{backgroundImage:Oy("orange")},".cm-lintRange-info":{backgroundImage:Oy("#999")},".cm-lintRange-hint":{backgroundImage:Oy("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:"#86714a80"},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:"#2e343e"}}});function P6(n){return n=="error"?4:n=="warning"?3:n=="info"?2:1}function D6(n){let e="hint",t=1;for(let i of n){let r=P6(i.severity);r>t&&(t=r,e=i.severity)}return e}var I6=IA(O6,{hideOn:w6}),dP=[ki,U.decorations.compute([ki],n=>{let{selected:e,panel:t}=n.field(ki);return!e||!t||e.from==e.to?he.none:he.set([S6.range(e.from,e.to)])}),I6,M6];function pP(n){return{all:n=n||new Map,on:function(e,t){var i=n.get(e);i?i.push(t):n.set(e,[t])},off:function(e,t){var i=n.get(e);i&&(t?i.splice(i.indexOf(t)>>>0,1):n.set(e,[]))},emit:function(e,t){var i=n.get(e);i&&i.slice().map(function(r){r(t)}),(i=n.get("*"))&&i.slice().map(function(r){r(e,t)})}}}var P_=class n{constructor(e,t,i,r,o,s,a,l,c,u=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=r,this.pos=o,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let r=e.parser.context;return new n(e,[],t,i,i,0,[],0,r?new Ay(r,r.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,r=e&65535,{parser:o}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=o.dynamicPrecedence(r);if(a&&(this.score+=a),i==0){r<o.minRepeatTerm&&this.reducePos<this.pos&&(this.reducePos=this.pos),this.pushState(o.getGoto(this.state,r,!0),this.reducePos),r<o.minRepeatTerm&&this.storeNode(r,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(r,this.reducePos);return}let l=this.stack.length-(i-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from;r<o.minRepeatTerm&&c==this.reducePos&&this.reducePos<this.pos&&(this.reducePos=this.pos);let u=this.reducePos-c;u>=2e3&&!(!((t=this.p.parser.nodeSet.types[r])===null||t===void 0)&&t.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let f=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-f;if(r<o.minRepeatTerm||e&131072){let d=o.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(r,c,d,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let d=this.stack[l-3];this.state=o.getGoto(d,r,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(r,c)}storeNode(e,t,i,r=4,o=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this.buffer.length;if(s>0&&this.buffer[s-4]==0&&this.buffer[s-1]>-1){if(t==i)return;if(this.buffer[s-2]>=t){this.buffer[s-2]=i;return}}}if(!o||this.pos==i)this.buffer.push(e,t,i,r);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>i;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>i;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,r>4&&(r-=4)}this.buffer[s]=e,this.buffer[s+1]=t,this.buffer[s+2]=i,this.buffer[s+3]=r}}shift(e,t,i,r){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let o=e,{parser:s}=this.p;this.pos=r;let a=s.stateFlag(o,1);!a&&(r>i||t<=s.maxNode)&&(this.reducePos=r),this.pushState(o,a?i:Math.min(i,this.reducePos)),this.shiftContext(t,i),t<=s.maxNode&&this.buffer.push(t,i,r,4)}else this.pos=r,this.shiftContext(t,i),t<=this.p.parser.maxNode&&this.buffer.push(t,i,r,4)}apply(e,t,i,r){e&65536?this.reduce(e):this.shift(e,t,i,r)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let r=this.pos;this.reducePos=this.pos=r+e.length,this.pushState(t,r),this.buffer.push(i,r,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(t&&e.buffer[t-4]==0&&(t-=4);t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),r=e.bufferBase+t;for(;e&&r==e.bufferBase;)e=e.parent;return new n(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,r,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new D_(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if((i&65536)==0)return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let r=[];for(let o=0,s;o<t.length;o+=2)(s=t[o+1])!=this.state&&this.p.parser.hasAction(s,e)&&r.push(t[o],s);if(this.stack.length<120)for(let o=0;r.length<8&&o<t.length;o+=2){let s=t[o+1];r.some((a,l)=>l&1&&a==s)||r.push(t[o],s)}t=r}let i=[];for(let r=0;r<t.length&&i.length<4;r+=2){let o=t[r+1];if(o==this.state)continue;let s=this.split();s.pushState(o,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(t[r],this.pos),s.reducePos=this.pos,s.score-=200,i.push(s)}return i}forceReduce(){let{parser:e}=this.p,t=e.stateSlot(this.state,5);if((t&65536)==0)return!1;if(!e.validAction(this.state,t)){let i=t>>19,r=t&65535,o=this.stack.length-i*3;if(o<0||e.getGoto(this.stack[o],r,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;t=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(r,o)=>{if(!t.includes(r))return t.push(r),e.allActions(r,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-o;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=i(s,o+1);if(a!=null)return a}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t<this.stack.length;t+=3)if(this.stack[t]!=e.stack[t])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(t)))}reduceContext(e,t){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(t)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let t=new Ay(this.curContext.tracker,e);t.hash!=this.curContext.hash&&this.emitContext(),this.curContext=t}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}},Ay=class{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}},D_=class{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let r=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=r}},I_=class n{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new n(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new n(this.stack,this.pos,this.index)}};function Gh(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,r=0;i<n.length;){let o=0;for(;;){let s=n.charCodeAt(i++),a=!1;if(s==126){o=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),o+=l,a)break;o*=46}t?t[r++]=o:t=new e(o)}return t}var yc=class{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}},mP=new yc,L_=class{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=mP,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,r=this.rangeIndex,o=this.pos+e;for(;o<i.from;){if(!r)return null;let s=this.ranges[--r];o-=i.from-s.to,i=s}for(;t<0?o>i.to:o>=i.to;){if(r==this.ranges.length-1)return null;let s=this.ranges[++r];o+=s.from-i.to,i=s}return o}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let t of this.ranges)if(t.to>e)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,r;if(t>=0&&t<this.chunk.length)i=this.pos+e,r=this.chunk.charCodeAt(t);else{let o=this.resolveOffset(e,1);if(o==null)return-1;if(i=o,i>=this.chunk2Pos&&i<this.chunk2Pos+this.chunk2.length)r=this.chunk2.charCodeAt(i-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=i;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=i),i+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-i)),r=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),r}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=i}acceptTokenTo(e,t){this.token.value=e,this.token.end=t}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:t}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=t,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),t=this.pos+e.length;this.chunk=t>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=mP,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,t){if(e>=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let r of this.ranges){if(r.from>=t)break;r.to>e&&(i+=this.input.read(Math.max(r.from,e),Math.min(r.to,t)))}return i}},Ho=class{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;bP(this.data,e,t,this.id,i.data,i.tokenPrecTable)}};Ho.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var B_=class{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?Gh(e):e}token(e,t){let i=e.pos,r=0;for(;;){let o=e.next<0,s=e.resolveOffset(1,1);if(bP(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(o||r++,s==null)break;e.reset(s,e.token)}r&&(e.reset(i,e.token),e.acceptToken(this.elseToken,r))}};B_.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;var vc=class{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}};function bP(n,e,t,i,r,o){let s=0,a=1<<i,{dialect:l}=t.p.parser;e:for(;(a&n[s])!=0;){let c=n[s+1];for(let d=s+3;d<c;d+=2)if((n[d+1]&a)>0){let p=n[d];if(l.allows(p)&&(e.token.value==-1||e.token.value==p||B6(p,e.token.value,r,o))){e.acceptToken(p);break}}let u=e.next,f=0,h=n[s+2];if(e.next<0&&h>f&&n[c+h*3-3]==65535){s=n[c+h*3-1];continue e}for(;f<h;){let d=f+h>>1,p=c+d+(d<<1),m=n[p],g=n[p+1]||65536;if(u<m)h=d;else if(u>=g)f=d+1;else{s=n[p+2],e.advance();continue e}}break}}function gP(n,e,t){for(let i=e,r;(r=n[i])!=65535;i++)if(r==t)return i-e;return-1}function B6(n,e,t,i){let r=gP(t,i,e);return r<0||gP(t,i,n)<r}var Ln=typeof process!="undefined"&&process.env&&/\bparse\b/.test(process.env.LOG),A_=null;function yP(n,e,t){let i=n.cursor(rt.IncludeAnonymous);for(i.moveTo(e);;)if(!(t<0?i.childBefore(e):i.childAfter(e)))for(;;){if((t<0?i.to<e:i.from>e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}var N_=class{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?yP(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?yP(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let t=this.trees.length-1;if(t<0)return this.nextFragment(),null;let i=this.trees[t],r=this.index[t];if(r==i.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let o=i.children[r],s=this.start[t]+i.positions[r];if(s>e)return this.nextStart=s,null;if(o instanceof gt){if(s==e){if(s<this.safeFrom)return null;let a=s+o.length;if(a<=this.safeTo){let l=o.prop(ce.lookAhead);if(!l||a+l<this.fragment.to)return o}}this.index[t]++,s+o.length>=Math.max(this.safeFrom,e)&&(this.trees.push(o),this.start.push(s),this.index.push(0))}else this.index[t]++,this.nextStart=s+o.length}}},$_=class{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new yc)}getActions(e){let t=0,i=null,{parser:r}=e.p,{tokenizers:o}=r,s=r.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<o.length;c++){if((1<<c&s)==0)continue;let u=o[c],f=this.tokens[c];if(!(i&&!u.fallback)&&((u.contextual||f.start!=e.pos||f.mask!=s||f.context!=a)&&(this.updateCachedToken(f,u,e),f.mask=s,f.context=a),f.lookAhead>f.end+25&&(l=Math.max(f.lookAhead,l)),f.value!=0)){let h=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!u.extend&&(i=f,t>h))break}}for(;this.actions.length>t;)this.actions.pop();return l&&e.setLookAhead(l),!i&&e.pos==this.stream.end&&(i=new yc,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new yc,{pos:i,p:r}=e;return t.start=i,t.end=Math.min(i+1,r.stream.end),t.value=i==r.stream.end?r.parser.eofTerm:0,t}updateCachedToken(e,t,i){let r=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(r,e),i),e.value>-1){let{parser:o}=i.p;for(let s=0;s<o.specialized.length;s++)if(o.specialized[s]==e.value){let a=o.specializers[s](this.stream.read(e.start,e.end),i);if(a>=0&&i.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(r+1)}putAction(e,t,i,r){for(let o=0;o<r;o+=3)if(this.actions[o]==e)return r;return this.actions[r++]=e,this.actions[r++]=t,this.actions[r++]=i,r}addActions(e,t,i,r){let{state:o}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(o,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=zr(a,c+2);else{r==0&&a[c+1]==2&&(r=this.putAction(zr(a,c+2),t,i,r));break}a[c]==t&&(r=this.putAction(zr(a,c+1),t,i,r))}return r}},j_=class{constructor(e,t,i,r){this.parser=e,this.input=t,this.ranges=r,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new L_(t,r),this.tokens=new $_(e,this.stream),this.topTerm=e.top[1];let{from:o}=r[0];this.stacks=[P_.start(this,e.top[0],o)],this.fragments=i.length&&this.stream.end-o>e.bufferLength*4?new N_(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],r,o;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>t)i.push(a);else{if(this.advanceStack(a,i,e))continue;{r||(r=[],o=[]),r.push(a);let l=this.tokens.getMainToken(a);o.push(l.value,l.end)}}break}}if(!i.length){let s=r&&N6(r);if(s)return Ln&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Ln&&r&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&r){let s=this.stoppedAt!=null&&r[0].pos>this.stoppedAt?r[0]:this.runRecovery(r,o,i);if(s)return Ln&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(i.length>s)for(i.sort((a,l)=>l.score-a.score);i.length>s;)i.pop();i.some(a=>a.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let s=0;s<i.length-1;s++){let a=i[s];for(let l=s+1;l<i.length;l++){let c=i[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)i.splice(l--,1);else{i.splice(s--,1);continue e}}}i.length>12&&(i.sort((s,a)=>a.score-s.score),i.splice(12,i.length-12))}this.minStackPos=i[0].pos;for(let s=1;s<i.length;s++)i[s].pos<this.minStackPos&&(this.minStackPos=i[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,t,i){let r=e.pos,{parser:o}=this,s=Ln?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&r>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let f=this.fragments.nodeAt(r);f;){let h=this.parser.nodeSet.types[f.type.id]==f.type?o.getGoto(e.state,f.type.id):-1;if(h>-1&&f.length&&(!c||(f.prop(ce.contextHash)||0)==u))return e.useNode(f,h),Ln&&console.log(s+this.stackID(e)+` (via reuse of ${o.getName(f.type.id)})`),!0;if(!(f instanceof gt)||f.children.length==0||f.positions[0]>0)break;let d=f.children[0];if(d instanceof gt&&f.positions[0]==0)f=d;else break}}let a=o.stateSlot(e.state,4);if(a>0)return e.reduce(a),Ln&&console.log(s+this.stackID(e)+` (via always-reduce ${o.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],f=l[c++],h=l[c++],d=c==l.length||!i,p=d?e:e.split(),m=this.tokens.mainToken;if(p.apply(u,f,m?m.start:p.pos,h),Ln&&console.log(s+this.stackID(p)+` (via ${(u&65536)==0?"shift":`reduce of ${o.getName(u&65535)}`} for ${o.getName(f)} @ ${r}${p==e?"":", split"})`),d)return!0;p.pos>r?t.push(p):i.push(p)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return vP(e,t),!0}}runRecovery(e,t,i){let r=null,o=!1;for(let s=0;s<e.length;s++){let a=e[s],l=t[s<<1],c=t[(s<<1)+1],u=Ln?this.stackID(a)+" -> ":"";if(a.deadEnd&&(o||(o=!0,a.restart(),Ln&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,i))))continue;let f=a.split(),h=u;for(let d=0;d<10&&f.forceReduce()&&(Ln&&console.log(h+this.stackID(f)+" (via force-reduce)"),!this.advanceFully(f,i));d++)Ln&&(h=this.stackID(f)+" -> ");for(let d of a.recoverByInsert(l))Ln&&console.log(u+this.stackID(d)+" (via recover-insert)"),this.advanceFully(d,i);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Ln&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),vP(a,i)):(!r||r.score<f.score)&&(r=f)}return r}stackToTree(e){return e.close(),gt.build({buffer:I_.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let t=(A_||(A_=new WeakMap)).get(e);return t||A_.set(e,t=String.fromCodePoint(this.nextStackID++)),t+e}};function vP(n,e){for(let t=0;t<e.length;t++){let i=e[t];if(i.pos==n.pos&&i.sameState(n)){e[t].score<n.score&&(e[t]=n);return}}e.push(n)}var F_=class{constructor(e,t,i){this.source=e,this.flags=t,this.disabled=i}allows(e){return!this.disabled||this.disabled[e]==0}},M_=n=>n,My=class{constructor(e){this.start=e.start,this.shift=e.shift||M_,this.reduce=e.reduce||M_,this.reuse=e.reuse||M_,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}},Py=class n extends ac{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let a=0;a<e.repeatNodeCount;a++)t.push("");let i=Object.keys(e.topRules).map(a=>e.topRules[a][1]),r=[];for(let a=0;a<t.length;a++)r.push([]);function o(a,l,c){r[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=ce[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)o(u,l,a[c++]);else{let f=a[c+-u];for(let h=-u;h>0;h--)o(a[c++],l,f);c++}}}this.nodeSet=new Lh(t.map((a,l)=>Zt.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:r[l],top:i.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=1024;let s=Gh(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(xP),this.states=Gh(e.states,Uint32Array),this.data=Gh(e.stateData),this.goto=Gh(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Ho(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let r=new j_(this,e,t,i);for(let o of this.wrappers)r=o(r,e,t,i);return r}getGoto(e,t,i=!1){let r=this.goto;if(t>=r[0])return-1;for(let o=r[t+1];;){let s=r[o++],a=s&1,l=r[o++];if(a&&i)return l;for(let c=o+(s>>1);o<c;o++)if(r[o]==e)return l;if(a)return-1}}hasAction(e,t){let i=this.data;for(let r=0;r<2;r++)for(let o=this.stateSlot(e,r?2:1),s;;o+=3){if((s=i[o])==65535)if(i[o+1]==1)s=i[o=zr(i,o+2)];else{if(i[o+1]==2)return zr(i,o+2);break}if(s==t||s==0)return zr(i,o+1)}return 0}stateSlot(e,t){return this.states[e*6+t]}stateFlag(e,t){return(this.stateSlot(e,0)&t)>0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),r=i?t(i):void 0;for(let o=this.stateSlot(e,1);r==null;o+=3){if(this.data[o]==65535)if(this.data[o+1]==1)o=zr(this.data,o+2);else break;r=t(zr(this.data,o+1))}return r}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=zr(this.data,i+2);else break;if((this.data[i+2]&1)==0){let r=this.data[i+1];t.some((o,s)=>s&1&&o==r)||t.push(this.data[i],r)}}return t}configure(e){let t=Object.assign(Object.create(n.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let r=e.tokenizers.find(o=>o.from==i);return r?r.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,r)=>{let o=e.specializers.find(a=>a.from==i.external);if(!o)return i;let s=Object.assign(Object.assign({},i),{external:o.to});return t.specializers[r]=xP(s),s})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let o of e.split(" ")){let s=t.indexOf(o);s>=0&&(i[s]=!0)}let r=null;for(let o=0;o<t.length;o++)if(!i[o])for(let s=this.dialects[t[o]],a;(a=this.data[s++])!=65535;)(r||(r=new Uint8Array(this.maxTerm+1)))[a]=1;return new F_(e,i,r)}static deserialize(e){return new n(e)}};function zr(n,e){return n[e]|n[e+1]<<16}function N6(n){let e=null;for(let t of n){let i=t.p.stoppedAt;(t.pos==t.p.stream.end||i!=null&&t.pos>i)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.score<t.score)&&(e=t)}return e}function xP(n){if(n.external){let e=n.extend?1:0;return(t,i)=>n.external(t,i)<<1|e}return n.get}var $6=121,H_=122,kP=123,j6=124,_P=128,F6=4,q6=131,V6=7,H6=8,z6=9,W6=10,U6=139,RP=19,Q6=140,K6=23,G6=141,X6=27,Y6=37,Z6=41,J6=144,ez=145,tz=146,nz=147,iz=47,rz=68,TP=153,AP=70,MP=154,PP=72,oz=155,sz=76,az=160,lz=79,cz=80,uz=81,fz=167,DP=89,hz=90,dz=169,pz=97,mz=171,gz=98,yz=100,vz=101,z_=typeof process!="undefined"&&process.env&&/\bfparse(:dbg)?\b/.test(process.env.LOG),W_=typeof process!="undefined"&&process.env&&/\bfparse:dbg\b/.test(process.env.LOG),Wr=typeof process!="undefined"&&process.env&&/\bcontext\b/.test(process.env.LOG),IP=[9,11,12,32,133,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288],xz=LP(`
288 %s`,this.path,this.context,CP(e," ")),this)}token(e){return Wr&&console.log("[%s] token <%s> + <%s>",this.path,this.tokens.join(" "),e),this.assign({tokens:[...this.tokens,e]})}literal(e){return Wr&&console.log("[%s] literal %o",this.path,e),this.pushChild(this.of({name:"Literal",value:e}))}computedValue(){for(let e=this;;e=xc(e.children)){if(!e)return null;if(!Yr(e.value))return e.value}}contextCache(){let e=this.cache.get(this.context);return e||(e=SP(this.context),this.cache.set(this.context,e)),e}get path(){var e,t;return((t=(e=this.parent)==null?void 0:e.path)==null?void 0:t.concat(" > ",this.name))||this.name}get(e){let t=e&&U_(e),i=this.contextCache().originalMap.get(t);if(typeof i=="undefined")return;let r=this.context.get(i);return r instanceof bc?r.get(this):r}resolveName(){let e=this.tokens.join(" "),t=[],i=this.assign({tokens:t}),r=this.of({name:"VariableName",parent:i,value:this.get(e),raw:e});return Wr&&console.log("[%s] resolve name <%s=%s>",r.path,e,this.get(e)),i.pushChild(r)}pushChild(e){if(!e)return this;let t=this.assign({children:[...this.children,e]});return e.parent=t,t}pushChildren(e){let t=this;for(let i of e)t=t.pushChild(i);return t}declareName(){if(this.tokens.length===0)throw Error("no tokens to declare name");let e=this.tokens.join(" ");return Wr&&console.log("[%s] declareName <%s>",this.path,e),this.assign({tokens:[]}).pushChild(this.of({name:"Name",value:e}))}define(e,t){if(typeof e!="string")return Wr&&console.log("[%s] no define <%s=%s>",this.path,e,t),this;Wr&&console.log("[%s] define <%s=%s>",this.path,e,t);let i=this.context,r=i.set(e,t),o=this.cache.get(i)||SP(i),s=NP(e,$P(o));return this.cache.set(r,s),this.assign({context:r})}assign(e={}){return n.of({...this,...e})}of(e={}){let t={context:this.context,parent:this.parent};return n.of({...t,...e})}static of(e){let{name:t,tokens:i=[],children:r=[],parent:o=null,context:s,value:a,raw:l,__cache:c}=e;if(!s)throw new Error("must provide <context>");return new n({name:t,tokens:[...i],children:[...r],context:s,parent:o,value:a,raw:l,__cache:c})}};function U_(n){return n.replace(/\s*([./\-'+]|\*\*?)\s*/g," $1 ").replace(/\s{2,}/g," ").trim()}function OP(n,e,t){var c;let i=n.children.filter(u=>u.name!==e),r=n.children.filter(u=>u.name===e),o=i[0],s=i[Math.max(1,i.length-1)],a=o==null?void 0:o.computedValue(),l=(c=s==null?void 0:s.computedValue())!=null?c:null;return n.assign({children:r}).enterScope(e).pushChildren(i).exitScope(t).define(a,l)}function Q_(n={},e=q_){let t=V_.of({context:e.of(n)});return new My({start:t,reduce(i,r,o,s){if(r===RP){let[f,h]=i.children.slice(-2);i=i.assign({value:e.of(f==null?void 0:f.computedValue(),h==null?void 0:h.computedValue())})}if(r===DP&&(i=i.assign({value:e.of(...i.children.map(f=>f==null?void 0:f.computedValue()))})),r===AP){let[f,h]=i.children.slice(-2);i=i.assign({value:f==null?void 0:f.computedValue()})}if(r===PP){let[f,...h]=i.children;(f==null?void 0:f.raw)==="get value"?i=Nz(i,h):i=i.assign({value:(f==null?void 0:f.computedValue())||e.of(void 0)})}let a=Pz[r];if(a)return i.enterScope(a);let l=Mz[r];if(l){let{children:f,context:h}=i,d=f.slice(0,-1),p=xc(f),m=null;return r===TP&&(m=e.of(p==null?void 0:p.computedValue())),r===MP&&(m=e.of(h,p==null?void 0:p.computedValue()).set("item",p==null?void 0:p.computedValue())),i.assign({children:d}).enterScope(l).pushChild(p).assign({context:m||h})}let c=s.read(s.pos,o.pos);if(Dz[r])return i.exitScope(c);if(r===gz){let f=i.children.filter(p=>p.name!=="ContextEntry"),h=f[0],d=xc(f);return OP(i,"ContextEntry",c).assign({value:e.of(i.value).set(h==null?void 0:h.computedValue(),d==null?void 0:d.computedValue())})}if(r===V6||r===X6)return OP(i,"InExpression",c);if(r===U6)return i.define("partial",bc.of(f=>{var h;return(h=xc(f.children))==null?void 0:h.computedValue()}));if(r===sz){let f=xc(i.children).computedValue();return i.define(f,1)}if(r===J6||r===ez||r===tz){let f=i.children.slice(0,-1),h=xc(i.children);return i.assign({children:f}).enterScope("ArithmeticExpression").pushChild(h)}if(r===nz)return i.enterScope("ArithmeticExpression");if(r===z6||r===W6||r===vz)return i.token(c);if(r===cz)return i.literal(c.replace(/^"|"$/g,"").replace(/\\(["\\])/g,"$1"));if(r===uz)return i.literal(c==="true");if(r===lz)return i.literal(parseFloat(c));if(r===az)return i.literal(null);if(r===iz)return i.resolveName();if(r===H6||r===yz)return i.declareName();if((r===_P||r===Y6)&&i.tokens.length>0)throw new Error("uncleared name");if(r===_P){let f=i;for(;f.parent;)f=f.exitScope(c);return f}return i}})}var Bz=Q_({});function Nz(n,e){if(!e.length)return n.assign({value:null});if(e[0].name==="Name"&&(e=$z(e,["m","key"])),e.length!==2)return n.assign({value:null});let[t,i]=e,r=i==null?void 0:i.computedValue(),o=t==null?void 0:t.computedValue();return!o||typeof o!="object"||typeof r!="string"?n.assign({value:null}):n.assign({value:[U_(r),r].reduce((s,a)=>o.get(a)||s,null)})}function $z(n,e){let t={};for(let i=0;i<n.length;i+=2){let[r,o]=n.slice(i,i+2);t[r.value]=o}return e.map(i=>t[i])}function xc(n){return n[n.length-1]}var jz=cy({StringLiteral:B.string,NumericLiteral:B.number,BooleanLiteral:B.bool,"AtLiteral!":B.special(B.string),CompareOp:B.compareOperator,ArithOp:B.arithmeticOperator,"for if then else some every return":B.controlKeyword,"in instance of and or satisfies between as":B.operatorKeyword,function:B.definitionKeyword,"Type/...":B.typeName,"Wildcard!":B.modifier,null:B.null,LineComment:B.lineComment,BlockComment:B.blockComment,"VariableName!":B.variableName,'"?"':B.special(B.variableName),"DateTimeConstructor! SpecialFunctionName!":B.standard(B.function(B.variableName)),"FunctionInvocation/VariableName!":B.function(B.variableName),"Name!":B.definition(B.variableName),"Key/Name! ContextEntryType/Name!":B.definition(B.propertyName),"PathExpression/VariableName!":B.propertyName,"FormalParameter/ParameterName!":B.function(B.definition(B.variableName)),"( )":B.paren,"[ ]":B.squareBracket,"{ }":B.brace,".":B.derefOperator,", ;":B.separator,"..":B.punctuation}),Fz={__proto__:null,for:10,in:32,return:36,if:40,then:42,else:44,some:48,every:50,satisfies:56,or:60,and:64,between:72,instance:86,of:89,days:101,time:103,duration:105,years:107,months:109,date:111,list:117,context:123,function:130,null:156,true:330,false:330,"?":170,external:186,not:211},jP=Py.deserialize({version:14,states:"CjO`QYOOO`QYOOO$yQYOOOOQU'#Ce'#CeO%TQYO'#C`O&^QYO'#FQOOQQ'#Fe'#FeO&hQYO'#FeO`QYO'#DVOOQU'#En'#EnO(_Q^O'#D]OOQU'#D^'#D^OOQU'#D]'#D]OOQO'#Fm'#FmO*[QWO'#DvOOQQ'#D}'#D}OOQQ'#EO'#EOOOQQ'#EP'#EPO*aOWO'#ESO*[QWO'#EQOOQQ'#EQ'#EQOOQQ'#Fs'#FsOOQQ'#Fq'#FqOOQQ'#Fy'#FyOOQQ'#EU'#EUO`QYO'#EWOOQQ'#FS'#FSO*iQ^O'#FSO,`QYO'#EXO,gQWO'#EYOOQP'#F}'#F}O,lQXO'#EaOOQQ'#Fz'#FzOOQQ'#FR'#FRQOQWOOOOQQ'#FT'#FTOOQQ'#F^'#F^O`QYO'#CoOOQQ'#F_'#F_O%TQYO'#CsO,zQYO'#DwOOQQ'#Fr'#FrO-PQYO'#EROOQO'#ER'#ERO`QYO'#EVO`QYO'#EUOOQO'#F{'#F{Q-XQWOOO-^QYO'#DRO.TQWO'#FaOOQO'#DT'#DTO.`QYO'#FeO.gQWOOO/^QYO'#CdO/kQYO'#FVOOQQ'#Cc'#CcO/pQYO'#FUOOQQ'#Cb'#CbO/xQYO,58zO`QYO,59iOOQQ'#Fb'#FbOOQQ'#Fc'#FcOOQQ'#Fd'#FdO`QYO,59qO`QYO,59qO`QYO,59qOOQQ'#Fk'#FkO/}QYO,5:^OOQQ'#Fl'#FlO`QYO,5:`O`QYO,59eO`QYO,59gO`QYO,59iO1|QYO,59iO2TQYO,59rOOQQ,5:i,5:iO2YQYO,59qOOQU-E8l-E8lO3|QYO'#FnOOQQ,5:b,5:bOOQQ,5:n,5:nOOQQ,5:l,5:lO4TQYO,5:rOOQQ,5;n,5;nO4_QYO,5:qO4lQWO,5:sO4qQYO,5:tOOQP'#Ee'#EeO5hQXO'#EdOOQO'#Ec'#EcO5oQWO'#EbO5tQWO'#GOO5|QWO,5:{O6RQYO,59ZOOQQ'#Cw'#CwO6YQYO'#F`OOQQ'#Cv'#CvO6bQYO,59_O6gQYO,5:cO6lQYO,5:mO4WQYO,5:qO6qQYO,5:pO`QYO'#EwQ-XQWOOO`QYO'#EmO7hQWO,5;{O`QYOOOOQR'#Cf'#CfOOQQ'#Ej'#EjO8bQYO,59OO`QYO,5;qOOQQ'#FY'#FYO%TQYO'#EkO8rQYO,5;pO`QYO1G.fOOQQ'#F]'#F]O9iQYO1G/TO<`QYO1G/]O<jQYO1G/]O<tQYO1G/]OOQQ1G/x1G/xO>hQYO1G/zO>oQYO1G/PO?xQYO1G/ROARQYO1G/TO`QYO1G/TOOQQ1G/T1G/TOAiQYO1G/^OBWQ^O'#CdOCjQYO'#FpOOQO'#Dz'#DzOCtQWO'#DyOCyQWO'#FoOOQO'#Dx'#DxOOQO'#D{'#D{ODRQWO,5<YOOQQ1G0^1G0^O`QYO1G0]O`QYO'#EsODWQWO,5<[OOQQ1G0_1G0_ODcQWO'#E[ODnQWO'#F|OOQO'#EZ'#EZODvQWO1G0`OOQP'#Eu'#EuOD{QXO,5;OO`QYO,5:|OESQXO'#EvOE_QWO,5<jOOQQ1G0g1G0gO`QYO1G.uO%TQYO'#ElOEgQYO,5;zO`QYO1G.yOEoQYO1G/}OOQO1G0X1G0XOOQO,5;c,5;cOOQO-E8u-E8uOOQO,5;X,5;XOOQO-E8k-E8kOEtQWOOOOQQ-E8h-E8hOEyQYO'#CmOOQQ1G1]1G1]OOQQ,5;V,5;VOOQQ-E8i-E8iOFZQYO7+$QOOQQ7+%f7+%fO`QYO7+$oOGQQYO,5:rOG_QWO7+$oOGdQYO'#D[OOQQ'#DZ'#DZOIWQYO'#D_OI]QYO'#D_OIbQYO'#D_OIgQ`O'#DgOIlQ`O'#DjOIqQ`O'#DnOOQQ7+$x7+$xO`QYO,5:eO%TQYO'#ErOIvQWO,5<ZOOQQ1G1t1G1tOJ|QYO7+%wOKZQYO,5;_OOQO-E8q-E8qOAiQYO,5:vO%TQYO'#EtOKhQWO,5<hOKpQYO7+%zOOQP-E8s-E8sOKwQYO1G0hOOQO,5;b,5;bOOQO-E8t-E8tOLRQYO7+$aOOQQ,5;W,5;WOOQQ-E8j-E8jOLYQYO7+$eOOQO7+%i7+%iO`QYO,59XOMPQYO<<HZOOQQ<<HZ<<HZO/}QYO'#EoONYQYO,59vO! |QYO,59yO!!RQYO,59yO!!WQYO,59yO!!]QYO,5:RO%TQYO,5:UO!!zQbO,5:YO!#RQYO1G0POOQO,5;^,5;^OOQO-E8p-E8pO!#]QYO<<IcOOQQ<<Ic<<IcOOQO1G0b1G0bOOQO,5;`,5;`OOQO-E8r-E8rO!&_QYO'#E^OOQQ<<If<<IfO`QYO<<IfO`QYO<<G{O!'UQYO1G.sOOQQ,5;Z,5;ZOOQQ-E8m-E8mO!'cQYO1G/eOOQQ1G/e1G/eO!'hQbO'#D]O!'yQ`O'#D[O!(UQ`O1G/mO!(ZQWO'#DmO!(`Q`O'#FgOOQO'#Dl'#DlO!(hQ`O1G/pOOQO'#Dq'#DqO!(mQ`O'#FiOOQO'#Dp'#DpO!(uQ`O1G/tOOQQAN?QAN?QO!(zQYOAN=gOOQQ7+%P7+%PO!)qQ`O,59vOOQQ7+%X7+%XO!!]QYO,5:XO%TQYO'#EpO!)|Q`O,5<ROOQQ7+%[7+%[O!!]QYO'#EqO!*UQ`O,5<TO!*^Q`O7+%`OOQO1G/s1G/sOOQO,5;[,5;[OOQO-E8n-E8nOOQO,5;],5;]OOQO-E8o-E8oOAiQYO<<HzOOQQAN>fAN>fO/}QYO'#EoO!!]QYO<<HzO!*cQ`O7+%`O!*hQ`O1G/tO!!zQbO,5:YO!*mQ`O'#Dn",stateData:"!+Q~O#rOS#sOSPOSQOS~OTsOZVO[UOdtOhvOivOr}Os}OviO!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$YZO$h_O$i`O$j`O$kaO$lbO~OTsO[UOdtOhvOivOr}Os}OviO!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$YZO$h_O$i`O$j`O$kaO$lbO~OZ!TO#]!UO~P#VO#nRO#oRO~OZ!^O[!^O]!_O^!_O_!`O`!kOn!hOp!iOr!]Os!]Ot!jO{!lO!i!fO#z!dOv$aX~O#l#tX$s#tX~P%]O$h!mOT$XXZ$XX[$XXd$XXh$XXi$XXr$XXs$XXv$XX!T$XX!U$XX!V$XX!X$XX!c$XX!g$XX!i$XX!p$XX!w$XX#S$XX#n$XX#o$XX$Y$XX$i$XX$j$XX$k$XX$l$XX~O#nRO#oROZ!PX[!PX]!PX^!PX_!PX`!PXn!PXp!PXr!PXs!PXt!PXv!PX{!PX!i!PX#l!PX#p!PX#z!PX$s!PX$O!PXx!PX#}!PX!g!PXe!PXb!PX#R!PXf!PXl!PX~Ov!pO~O$i`O$j`O~O#p!uOZ#vX[#vX]#vX^#vX_#vX`#vXn#vXp#vXr#vXs#vXt#vXv#vX{#vX!i#vX#l#vX#z#vX$s#vX$O#vXx#vX#}#vX!g#vXe#vXb#vX#R#vXf#vXl#vX~O!g$dP~P`Ov!xO~O#m!yO$i`O$j`O#R$rP~Op#UO~Op#VOv!uX~O$s#YO~O#luX$OuX$suXxuX#}uX!guXeuXbuX#RuXfuXluX~P%]O$O#[O#l$TXx$TX~O#l#[X~P&hOv#^O~OZ#_O[#_O]#_O^#_O_#_O#nRO#oRO#z#_O#{#_O$[WX~O`WXxWX$OWX~P.lO`#cO~O$O#dOb#xX~Ob#gO~O#nRO#oRO$YZO~OTsOZVO[UOdtOhvOivOr}Os}O!T{O!U{O!VxO!XzO!c!OO!g|O!igO!pyO!wjO#SnO#nRO#oRO$YZO$h_O$i`O$j`O$kaO$lbO~Ov#qO~P0YO|#sO~O{!lO!i!fO#z!dOZya[ya]ya^ya_ya`yanyapyaryasyatyav$aX#lya$sya$Oyaxya#}ya!gyaeyabya#Ryafyalya~Ox$dP~P`Ox#|O#}#}O~P%]O#}#}O$O$OO!g$dX~P%]O!g$QO~O#nRO#oROx$pP~OZ#_O[#_O]#_O^#_O_#_O#m!yO#z#_O#{#_O~O$[#WX~P4|O$[$XO~O$O$YO#R$rX~O#R$[O~Oe$]O~P%]O$O$^Ol$SX~Ol$`O~O!W$aO~O!T$bO~O#l!xa$s!xa$O!xax!xa#}!xa!g!xae!xab!xa#R!xaf!xal!xa~P%]O$O#[O#l$Tax$Ta~OZ#_O[#_O]#_O^#_O_#_O#nRO#oRO#z#_O#{#_O~O`Wa$[WaxWa$OWa~P7sO$O#dOb#xa~OZ!^O[!^O]!_O^!_O_!`O{!lO!i!fO#z!dOv$aX~O`qinqipqirqisqitqi#lqi$sqi$Oqixqi#}qi!gqieqibqi#Rqifqilqi~P8zO_!`O{!lO!i!fO#z!dOZyi[yi`yinyipyiryisyityiv$aX#lyi$syi$Oyixyi#}yi!gyieyibyi#Ryifyilyi~O]!_O^!_O~P:rO]yi^yi~P:rO{!lO!i!fO#z!dOZyi[yi]yi^yi_yi`yinyipyiryisyityiv$aX#lyi$syi$Oyixyi#}yi!gyieyibyi#Ryifyilyi~O!g$nO~P%]O`!kOp!iOr!]Os!]Ot!jOnmi#lmi$smi$Omixmi#}mi!gmiemibmi#Rmifmilmi~P8zO`!kOr!]Os!]Ot!jOnoipoi#loi$soi$Ooixoi#}oi!goieoiboi#Roifoiloi~P8zO`!kOn!hOp$oOr!]Os!]Ot!jO~P8zO!S$tO!V$uO!X$vO![$wO!_$xO!c$yO#nRO#oRO$YZO~OZ#bX[#bX]#bX^#bX_#bX`#bXn#bXp#bXr#bXs#bXt#bXv#bXx#bX{#bX!i#bX#n#bX#o#bX#p#bX#z#bX$O#bX~P.lO$O$OOx$dX~P%]O$[${O~O$O$|Ox$cX~Ox%OO~O$O$OO!g$dax$da~O$[%SOx#OX$O#OX~O$O%TOx$pX~Ox%VO~O$[#Wa~P4|O#m!yO$i`O$j`O~O$O$YO#R$ra~O$O$^Ol$Sa~O!U%`O~OxrO~O#}%aObaX$OaXlaX~P%]O#lSq$sSq$OSqxSq#}Sq!gSqeSqbSq#RSqfSqlSq~P%]Ox#|O#}#}O$OuX~P%]Ox%cO~O#z%dOZ!OX[!OX]!OX^!OX_!OX`!OXn!OXp!OXr!OXs!OXt!OXv!OX{!OX!i!OX#l!OX$s!OX$O!OXx!OX#}!OX!g!OXe!OXb!OX#R!OXf!OXl!OX~Op%fO~Op%gO~Op%hO~O!]%iO~O!]%jO~O!]%kO~O$O$|Ox$ca~OZ!^O[!^O]!_O^!_O_!`O`!kOn!hOp!iOr!]Os!]Ot!jO{!lO#z!dOv$aX~Ox%pO!g%pO!i%oO~PJOO!g#ga$O#gax#ga~P%]O$O%TOx$pa~O#P%vO~P`O#R#Ui$O#Ui~P%]Of%wO~P%]O#lgq$sgq$Ogqxgq#}gq!ggqegqbgq#Rgqfgqlgq~P%]O`qynqypqyrqysqytqy#lqy$sqy$Oqyxqy#}qy!gqyeqybqy#Rqyfqylqy~P8zO#z%dOZ!Oa[!Oa]!Oa^!Oa_!Oa`!Oan!Oap!Oar!Oas!Oat!Oav!Oa{!Oa!i!Oa#l!Oa$s!Oa$O!Oax!Oa#}!Oa!g!Oae!Oab!Oa#R!Oaf!Oal!Oa~O!T%{O~O!W%{O~O!T%|O~O!S$tO!V$uO!X$vO![$wO!_$xO!c&rO#nRO#oRO$YZO~O!Y$]P~P!!]Ox!mi$O!mi~P%]OT$`XZ$`X[$`X]!yy^!yy_!yy`!yyd$`Xh$`Xi$`Xn!yyp!yyr$`Xs$`Xt!yyv$`X{!yy!T$`X!U$`X!V$`X!X$`X!c$`X!g$`X!i$`X!p$`X!w$`X#S$`X#l!yy#n$`X#o$`X#z!yy$Y$`X$h$`X$i$`X$j$`X$k$`X$l$`X$s!yy$O!yyx!yy#}!yye!yyb!yy#R!yyf!yyl!yy~O#l#QX$s#QX$O#QXx#QX#}#QX!g#QXe#QXb#QX#R#QXf#QXl#QX~P%]Obai$Oailai~P%]O!U&[O~O#nRO#oRO!Y!PX#z!PX$O!PX~O#z&mO!Y!OX$O!OX~O!Y&^O~O$[&_O~O$O&`O!Y$ZX~O!Y&bO~O$O&cO!Y$]X~O!Y&eO~O#lc!R$sc!R$Oc!Rxc!R#}c!R!gc!Rec!Rbc!R#Rc!Rfc!Rlc!R~P%]O#z&mO!Y!Oa$O!Oa~O$O&`O!Y$Za~O$O&cO!Y$]a~O$^&kO~O$^&nO~O!Y&oO~O!]&qO~O$Y$i~$i$j_^$h#zQP]Q~",goto:"EX$sPPPP$tP%l%o%u&V'oPPPPPP'xP$tPPP$tPP'{(OP$tP$tP$tPPP(UP(aP$t$tPP(j)P)[*h)PPPPPPPP)PPP)PP+l+o)PP+u+{$tP$tP$t,S,z,}-T,zP-].T-]-]/S/zP$t0r$t1j1j2b2eP2kPP1j2q2w/O2{PP3TP3W3_3e3k3q4{5V5]5c5i5p5v5|6SPPPPPPPP6Y6c8g9_:V:YPP:bPP:e:h;`<W<Z<`<|=k>ZP?RP?UP?Y?z@lAdAjAm$tAsAsPPPPPBk8gCcDZD^EU!kjOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR![SQ!YSR$k#dW!WSw#d$^W#v!p!x$|%TT&Q%j&`#UXOPQWYilu|}!]!a!b!c!e!g!h!i!j!k#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%i%k%v%w%}&_&c&k&m&n&qb!VSw!x#d$^$|%T%j&`U#`!V#a#tR#t!pU#`!V#a#tT$V!z$WR$j#bR#TwQ#RwR%]$^U!RQ#^#qQ#r!kR$e#[QrQQ$g#^R$q#qQ$z#sQ%q%SQ&P%iU&U%k&c&qQ&f&_T&l&k&nc$s#s%S%i%k&_&c&k&n&q!jkOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ#l!eU$r#s%S&kS%y%d&m]&O%i%k&_&c&n&q#T[OPQWilu|}!]!a!b!c!e!g!h!i!j!k!p#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%i%k%v%w&_&c&k&m&n&qR&T%jQ&R%jR&g&`Q&X%kR&p&qS&V%k&qR&i&c!k]OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#{!pQ#x!pR%m$|S#w!p$|T$R!x%T!keOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!jeOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ!rbT!{o$Y!kcOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kdOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!khOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kpOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR$U!xQ$S!xR%r%TQ%u%VR&Y%vQ!}oR%Y$YT!|o$YS!zo$YT$V!z$WRrQS#a!V#tR$h#aQ#e!YR$l#eQ$_#RR%^$_Q#]!RR$f#]!tYOPQWilu|}!]!a!b!c!e!g!h!i!j!k!p#Y#[#^#b#f#q#s#}$O$X$]$`$o${%S%V%a%d%v%w&kS!oY%}_%}%i%k&_&c&m&n&qQ%e$rS%z%e&]R&]&OQ&a&RR&h&aQ&d&VR&j&dQ$}#xR%n$}S$P!v#uR%R$PQ%U$SR%s%UQ$W!zR%W$WQ$Z!}R%Z$ZQ#Z!PR$d#ZQrOQ!PPR$c#YUTOP#YW!QQ!k#[#^Q!nWQ!tiQ!vlQ#PuQ#W|Q#X}Q#h!]Q#i!aQ#j!bQ#k!cQ#m!gQ#n!hQ#o!iQ#p!jQ#u!pQ$i#bQ$m#fQ$p#qQ%P#}Q%Q$OQ%X$XQ%[$]Q%_$`Q%b$oQ%l${S%t%V%vQ%x%aR&Z%w!kqOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kSOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR!ZSS!XS#dT#Qw$^R#b!WR#f![!kuOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kwOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#SwV!SQ#^#q!V!aT!Q!t!v#P#W#X#h#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!X!bT!Q!t!v#P#W#X#h#i#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!Z!cT!Q!t!v#P#W#X#h#i#j#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!kWOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR&S%jT&W%k&q!_!eT!Q!n!t!v#P#W#X#h#i#j#k#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!_!gT!Q!n!t!v#P#W#X#h#i#j#k#m#n#o#p#u$i$m$p%P%Q%X%[%_%b%l%t%x&Z!k^OPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wQ!q^R!scR#y!pQ!wlR#z!p!kfOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!klOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%w!kmOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR$T!x!koOPQWilu|}!]!a!b!c!g!h!i!j!k!p#Y#[#^#b#f#q#}$O$X$]$`$o${%V%a%v%wR#Oo",nodeNames:"\u26A0 LineComment BlockComment Expression ForExpression for InExpressions InExpression Name Identifier Identifier ArithOp ArithOp ArithOp ArithOp ArithOp in IterationContext return IfExpression if then else QuantifiedExpression some every InExpressions InExpression satisfies Disjunction or Conjunction and Comparison CompareOp CompareOp between PositiveUnaryTest ( PositiveUnaryTests ) ArithmeticExpression InstanceOfExpression instance of Type QualifiedName VariableName BacktickIdentifier SpecialType days time duration years months date > ListType list < ContextType context ContextEntryTypes ContextEntryType FunctionType function ArgumentTypes ArgumentType PathExpression ] FilterExpression [ FunctionInvocation SpecialFunctionName NamedParameters NamedParameter ParameterName PositionalParameters null NumericLiteral StringLiteral BooleanLiteral DateTimeLiteral DateTimeConstructor AtLiteral ? SimplePositiveUnaryTest Interval ParenthesizedExpression List FunctionDefinition FormalParameters FormalParameter external FunctionBody } { Context ContextEntry Key Name Identifier Expressions UnaryTests Wildcard not",maxTerm:173,context:Bz,nodeProps:[["group",-17,4,19,23,29,31,33,41,42,68,70,72,85,86,88,89,90,97,"Expr",47,"Expr Expr",-5,78,79,80,81,82,"Expr Literal"],["closedBy",38,")",71,"]",96,"}"],["openedBy",40,"(",69,"[",95,"{"]],propSources:[jz],skippedNodes:[0,1,2],repeatNodeCount:14,tokenData:".v~RvXY#iYZ$^Z[#i]^$^pq#iqr$crs$nwx(Wxy(]yz(bz{(g{|(t|}(y}!O)O!O!P)]!P!Q*g!Q![,b![!],y!]!^-O!^!_-T!_!`$i!`!a-d!b!c-n!}#O-s#P#Q-x#Q#R(o#S#T-}#o#p.l#q#r.q$f$g#i#BY#BZ#i$IS$I_#i$I|$I}$^$I}$JO$^$JT$JU#i$KV$KW#i&FU&FV#i?HT?HU#i~#nY#r~XY#iZ[#ipq#i$f$g#i#BY#BZ#i$IS$I_#i$JT$JU#i$KV$KW#i&FU&FV#i?HT?HU#i~$cO#s~~$fP!_!`$i~$nOr~~$qXOY$nYZ%^Zr$nrs&zs#O$n#O#P'R#P;'S$n;'S;=`(Q<%lO$n~%aVOr%^rs%vs#O%^#O#P%{#P;'S%^;'S;=`&t<%lO%^~%{O$i~~&ORO;'S%^;'S;=`&X;=`O%^~&[WOr%^rs%vs#O%^#O#P%{#P;'S%^;'S;=`&t;=`<%l%^<%lO%^~&wP;=`<%l%^~'RO$i~$j~~'URO;'S$n;'S;=`'_;=`O$n~'bYOY$nYZ%^Zr$nrs&zs#O$n#O#P'R#P;'S$n;'S;=`(Q;=`<%l$n<%lO$n~(TP;=`<%l$n~(]O#{~~(bOv~~(gOx~~(lP^~z{(o~(tO_~~(yO[~~)OO$O~R)TPZP!`!a)WQ)]O$^Q~)bQ#z~!O!P)h!Q![)m~)mO#}~~)rR$h~!Q![)m!g!h){#X#Y){~*OR{|*X}!O*X!Q![*_~*[P!Q![*_~*dP$h~!Q![*_~*lQ]~z{*r!P!Q+y~*uTOz*rz{+U{;'S*r;'S;=`+s<%lO*r~+XVOz*rz{+U{!P*r!P!Q+n!Q;'S*r;'S;=`+s<%lO*r~+sOQ~~+vP;=`<%l*r~,OSP~OY+yZ;'S+y;'S;=`,[<%lO+y~,_P;=`<%l+y~,gS$h~!O!P,s!Q![,b!g!h){#X#Y){~,vP!Q![)m~-OO$[~~-TO$s~R-[P!]QsP!_!`-_P-dOsPR-kP!YQsP!_!`-_~-sO$l~~-xO!i~~-}O!g~~.QTO#S-}#S#T.a#T;'S-};'S;=`.f<%lO-}~.fO$Y~~.iP;=`<%l-}~.qO#S~~.vO#R~",tokenizers:[Tz,Rz,Az,0,1],topRules:{Expression:[0,3],Expressions:[1,102],UnaryTests:[2,103]},dialects:{camunda:2564},dynamicPrecedences:{31:-1,68:1,72:-1,74:-1},specialized:[{term:122,get:n=>Fz[n]||-1}],tokenPrec:2567});function qz(n){let e=[];return n.iterate({enter:t=>{let i=t.node;if(!i.type.isError)return;let r=i.parent,o=qP(i),s={from:i.from,to:i.to,severity:"error",type:"Syntax Error"};if(i.from!==i.to)s.message=`Unrecognized token in <${r.name}>`;else if(o)s.message=`Unrecognized token <${o.name}> in <${r.name}>`,s.to=o.to;else{let a=r.enterUnfinishedNodesBefore(i.to);s.message=`Incomplete <${(a||r).name}>`}e.push(s)}}),e}function qP(n){return n?n.nextSibling||qP(n.parent):null}var Vz="first-item",Hz={create(n){return{enter(e){if(e.name!=="FilterExpression")return;let t=n.readContent(e.from,e.to);if(FP().test(t)){let{from:i,to:r}=e;n.report({from:i,to:r,message:"First item is accessed via [1]",severity:"warning",type:Vz,actions:[{name:"fix",apply(o,s=i,a=r){n.updateContent(s,a,t.replace(FP(),"[1]"))}}]})}}}}};function FP(){return/\[\s*0\s*\]$/}var zz=[Hz];function Wz(n){let{readContent:e,syntaxTree:t,updateContent:i}=n,r=[],o={readContent:e,report:a=>{r.push(a)},updateContent:i},s=zz.map(a=>a.create(o));return t.iterate({enter:a=>{for(let l of s)l.enter&&l.enter(a)},leave:a=>{for(let l of s)l.leave&&l.leave(a)}}),r}function Uz(n){return[...qz(n.syntaxTree),...Wz(n)]}var VP=()=>n=>{if(n.state.doc.length===0)return[];let e=lt(n.state);return Uz({syntaxTree:e,readContent:(i,r)=>n.state.sliceDoc(i,r),updateContent:(i,r,o)=>n.dispatch({changes:{from:i,to:r,insert:o}})}).map(i=>({...i,source:i.type}))};var G_=[li("function(${params}) ${body}",{label:"function",detail:"definition",type:"keyword"}),li("for ${var} in ${collection} return ${value}",{label:"for",detail:"expression",type:"keyword"}),li("every ${var} in ${collection} satisfies ${condition}",{label:"every",detail:"quantified expression",type:"keyword"}),li("some ${var} in ${collection} satisfies ${condition}",{label:"some",detail:"quantified expression",type:"keyword"}),li("if ${condition} then ${value} else ${other value}",{label:"if",detail:"block",type:"keyword"}),li("{ ${key}: ${value} }",{label:"context",detail:"block",type:"keyword"}),li("null",{label:"null",detail:"literal",type:"keyword"}),li("true",{label:"true",detail:"literal",type:"keyword"}),li("false",{label:"false",detail:"literal",type:"keyword"})];function K_(){return K_=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(n[i]=t[i])}return n},K_.apply(null,arguments)}function Xh(n){let{context:e,after:t,before:i,keyword:r}=n;return Yz({nodes:e,before:i,after:t,keyword:r},pc([{label:r,type:"keyword",boost:10}]))}var X_=[Xh({context:"InExpression",keyword:"in"}),Xh({context:"IfExpression",keyword:"then",after:"if",before:"else"}),Xh({context:"IfExpression",keyword:"else",after:"then"}),Xh({context:"QuantifiedExpression",keyword:"satisfies"}),Xh({context:"ForExpression",after:"InExpressions",keyword:"return"})],HP=["StringLiteral","Identifier","LineComment","BlockComment","PathExpression","Context","Key","ParameterName"],Qz=["Expr","ContextEntry"];function Kz(n){let e=[...HP,...Qz];return t=>{let{state:i,pos:r}=t,o=UP(lt(i).resolveInner(r,-1),e);if(o){let[s,a]=o;if(HP.includes(a))return null}return n(t)}}function Gz(n){return Kz(pc(n.map(e=>K_({},e,{type:"text"}))))}function zP(n,e,t){return WP(n,e,t,-1)}function Xz(n,e,t){return WP(n,e,t,1)}function WP(n,e,t,i){let r=n[i>0?"childAfter":"childBefore"](e);for(;r;){if(t.includes(r.name))return r;if(r.type.isError&&r.firstChild&&t.includes(r.firstChild.name))return r.firstChild;r=r[i>0?"nextSibling":"prevSibling"]}return null}function UP(n,e){for(Array.isArray(e)||(e=[e]);n;n=n.parent){let t=n.type,i=e.find(r=>r&&t.is(r));if(i)return[n,i];if(t.isTop)break}return null}function Yz(n,e){let{nodes:t,before:i,after:r,keyword:o}=n;return s=>{let{state:a,pos:l}=s,c=UP(lt(a).resolveInner(l,-1),t);if(!c)return null;let[u]=c;return zP(u,l,[o,i])||Xz(u,l,[o,r])||r&&!zP(u,l,[r])?null:e(s)}}var QP=uy.define({parser:jP.configure({props:[t_.add({Context:n_({closing:"}"}),"List FilterExpression":n_({closing:"]"}),"ParenthesizedExpression FunctionInvocation":dy({except:/^\s*\)/}),"ForExpression QuantifiedExpression IfExpression":dy({except:/^\s*(then|else|return|satisfies)\b/}),FunctionDefinition:dy({except:/^\s*(\(|\))/})}),eM.add({Context:py,List:py,ParenthesizedExpression:py,FunctionDefinition(n){let e=n.getChild(")");return e?{from:e.to,to:n.to}:null}})]}),languageData:{indentOnInput:/^\s*(\)|\}|\]|then|else|return|satisfies)$/,commentTokens:{line:"//",block:{open:"/*",close:"*/"}}}}),Zz=QP.configure({top:"UnaryTests"},"FEEL unary tests"),Jz=QP.configure({top:"Expression"},"FEEL expression");function KP(n={}){let e=n.dialect==="unaryTests"?Zz:Jz,t=n.parserDialect,i=Q_(n.context),r=e.configure({contextTracker:i,dialect:t}),o=n.completions||[Gz(G_),X_].flat();return new fy(r,[...o.map(s=>r.data.of({autocomplete:s}))])}var eW=[{name:"not",type:"function",params:[{name:"negand"}],info:`<p>Returns the logical negation of the given value.</p>
[all...]
/plugin/bpmnio/vendor/bpmn-js/dist/
H A Dbpmn-modeler.production.min.js262 </svg>`},Eu=HC;var $C=900;function oi(e,t,n,r){e.registerProvider($C,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=r}oi.$inject=["contextPad","popupMenu","translate","canvas"];oi.prototype.getMultiElementContextPadEntries=function(e){var t={};return this._isAllowed(e)&&C(t,this._getEntries(e)),t};oi.prototype._isAllowed=function(e){return!this._popupMenu.isEmpty(e,"align-elements")};oi.prototype._getEntries=function(){var e=this;return{"align-elements":{group:"align-elements",title:e._translate("Align elements"),html:`<div class="entry">${Eu.align}</div>`,action:{click:function(t,n){var r=e._getMenuPosition(n);C(r,{cursor:{x:t.x,y:t.y}}),e._popupMenu.open(n,"align-elements",r)}}}}};oi.prototype._getMenuPosition=function(e){var t=5,n=this._contextPad.getPad(e).html,r=n.getBoundingClientRect(),i={x:r.left,y:r.bottom+t};return i};N();var zC=["left","center","right","top","middle","bottom"];function Oi(e,t,n,r){this._alignElements=t,this._translate=n,this._popupMenu=e,this._rules=r,e.registerProvider("align-elements",this)}Oi.$inject=["popupMenu","alignElements","translate","rules"];Oi.prototype.getPopupMenuEntries=function(e){var t={};return this._isAllowed(e)&&C(t,this._getEntries(e)),t};Oi.prototype._isAllowed=function(e){return this._rules.allowed("elements.align",{elements:e})};Oi.prototype._getEntries=function(e){var t=this._alignElements,n=this._translate,r=this._popupMenu,i={};return E(zC,function(o){i["align-elements-"+o]={group:"align",title:n("Align elements "+o),className:"bjs-align-elements-menu-entry",imageHtml:Eu[o],action:function(){t.trigger(e,o),r.close()}}}),i};function Ot(e){k.call(this,e),this.init()}Ot.$inject=["eventBus"];B(Ot,k);Ot.prototype.addRule=function(e,t,n){var r=this;typeof e=="string"&&(e=[e]),e.forEach(function(i){r.canExecute(i,t,function(o,a,s){return n(o)},!0)})};Ot.prototype.init=function(){};N();function ko(e){Ot.call(this,e)}ko.$inject=["eventBus"];B(ko,Ot);ko.prototype.init=function(){this.addRule("elements.align",function(e){var t=e.elements,n=Q(t,function(r){return!(r.waypoints||r.host||r.labelTarget)});return n=zr(n),n.length<2?!1:n})};var Yv={__depends__:[uv,su,Do],__init__:["alignElementsContextPadProvider","alignElementsMenuProvider","bpmnAlignElements"],alignElementsContextPadProvider:["type",oi],alignElementsMenuProvider:["type",Oi],bpmnAlignElements:["type",ko]};N();var GC=10,Pf=50,VC=250;function wu(e,t,n,r){for(var i;i=WC(e,n,t);)n=r(t,n,i);return n}function Su(e){return function(t,n,r){var i={x:n.x,y:n.y};return["x","y"].forEach(function(o){var a=e[o];if(a){var s=o==="x"?"width":"height",c=a.margin,u=a.minDistance;c<0?i[o]=Math.min(r[o]+c-t[s]/2,n[o]-u+c):i[o]=Math.max(r[o]+r[s]+c+t[s]/2,n[o]+u+c)}}),i}}function WC(e,t,n){var r={x:t.x-n.width/2,y:t.y-n.height/2,width:n.width,height:n.height},i=UC(e);return re(i,function(o){if(o===n)return!1;var a=He(o,r,GC);return a==="intersect"})}function Xv(e,t){t||(t={});function n(m){return m.source===e?1:-1}var r=t.defaultDistance||Pf,i=t.direction||"e",o=t.filter,a=t.getWeight||n,s=t.maxDistance||VC,c=t.reference||"start";o||(o=YC);function u(m,g){return i==="n"?c==="start"?Z(m).top-Z(g).bottom:c==="center"?Z(m).top-X(g).y:Z(m).top-Z(g).top:i==="w"?c==="start"?Z(m).left-Z(g).right:c==="center"?Z(m).left-X(g).x:Z(m).left-Z(g).left:i==="s"?c==="start"?Z(g).top-Z(m).bottom:c==="center"?X(g).y-Z(m).bottom:Z(g).bottom-Z(m).bottom:c==="start"?Z(g).left-Z(m).right:c==="center"?X(g).x-Z(m).right:Z(g).right-Z(m).right}var p=e.incoming.filter(o).map(function(m){var g=a(m),v=g<0?u(m.source,e):u(e,m.source);return{id:m.source.id,distance:v,weight:g}}),l=e.outgoing.filter(o).map(function(m){var g=a(m),v=g>0?u(e,m.target):u(m.target,e);return{id:m.target.id,distance:v,weight:g}}),f=p.concat(l).reduce(function(m,g){return m[g.id+"__weight_"+g.weight]=g,m},{}),d=Ge(f,function(m,g){var v=g.distance,w=g.weight;return v<0||v>s||(m[String(v)]||(m[String(v)]=0),m[String(v)]+=1*w,(!m.distance||m[m.distance]<m[String(v)])&&(m.distance=v)),m},{});return d.distance||r}function UC(e){var t=Rf(e);return e.host&&(t=t.concat(Rf(e.host))),e.attachers&&(t=t.concat(e.attachers.reduce(function(n,r){return n.concat(Rf(r))},[]))),t}function Rf(e){return KC(e).concat(qC(e))}function qC(e){return e.incoming.map(function(t){return t.source})}function KC(e){return e.outgoing.map(function(t){return t.target})}function YC(){return!0}var XC=100;function Cu(e,t,n){e.on("autoPlace",XC,function(r){var i=r.shape,o=r.source;return ZC(o,i)}),e.on("autoPlace.end",function(r){n.scrollToElement(r.shape)}),this.append=function(r,i,o){e.fire("autoPlace.start",{source:r,shape:i});var a=e.fire("autoPlace",{source:r,shape:i}),s=t.appendShape(r,i,a,r.parent,o);return e.fire("autoPlace.end",{source:r,shape:s}),s}}Cu.$inject=["eventBus","modeling","canvas"];function ZC(e,t,n){n||(n={});var r=n.defaultDistance||Pf,i=X(e),o=Z(e);return{x:o.right+r+t.width/2,y:i.y}}function Ru(e,t){e.on("autoPlace.end",500,function(n){t.select(n.shape)})}Ru.$inject=["eventBus","selection"];var Zv={__init__:["autoPlaceSelectionBehavior"],autoPlace:["type",Cu],autoPlaceSelectionBehavior:["type",Ru]};N();function kr(e,t){for(st(t)&&(t=[t]);e=e.parent;)if(te(e,t))return e;return null}function Pu(e,t){var n=kr(e,"bpmn:Process");if(n)return!0;var r=["bpmn:Participant","bpmn:Lane"];if(n=kr(e,r),n)return Me(n);if(te(e,r))return Me(e);var i;for(i=j(e);i&&!h(i,"bpmn:Process");i=i.$parent);if(!t)return!0;var o=t.find(function(a){var s=j(a);return s&&s.get("processRef")===i});return o?Me(o):!0}function Au(e,t,n){var r=Pu(e,n);if(h(t,"bpmn:TextAnnotation"))return JC(e,t,r);if(te(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"]))return eR(e,t,r);if(h(t,"bpmn:FlowNode"))return QC(e,t,r)}function QC(e,t,n){var r=Z(e),i=X(e),o=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=Xv(e,{filter:function(d){return h(d,"bpmn:SequenceFlow")},direction:o.directionHint}),s=30,c=o.minDistance,u=o.baseOrientation;h(e,"bpmn:BoundaryEvent")&&(u=He(e,e.host,-25),u.indexOf(o.boundaryOrientation)!==-1&&(s*=-1));var p=n?{x:r.right+a+t.width/2,y:i.y+Qv(u,c,o)}:{x:i.x+Qv(u,c,o),y:r.bottom+a+t.height/2},l={margin:s,minDistance:c},f=n?{y:l}:{x:l};return wu(e,t,p,Su(f))}function Qv(e,t,n){return e.includes(n.start)?-1*t:e.includes(n.end)?t:0}function JC(e,t,n){var r=Z(e),i=n?{x:r.right+t.width/2,y:r.top-50-t.height/2}:{x:r.right+50+t.width/2,y:r.bottom+t.height/2};de(e)&&(i=X(e),n?(i.x+=100,i.y-=50):(i.x+=100,i.y+=50));var o={margin:n?-30:30,minDistance:20},a=n?{y:o}:{x:o};return wu(e,t,i,Su(a))}function eR(e,t,n){var r=Z(e),i=n?{x:r.right-10+t.width/2,y:r.bottom+40+t.width/2}:{x:r.left-40-t.width/2,y:r.bottom-10+t.height/2},o={margin:30,minDistance:30},a=n?{x:o}:{y:o};return wu(e,t,i,Su(a))}function Tu(e,t){e.on("autoPlace",function(n){var r=n.shape,i=n.source;return Au(i,r,t)})}Tu.$inject=["eventBus","elementRegistry"];var No={__depends__:[Zv],__init__:["bpmnAutoPlace"],bpmnAutoPlace:["type",Tu]};N();function $n(e,t,n,r){k.call(this,e),this._elementRegistry=t,this._modeling=n,this._rules=r;var i=this;this.postExecuted(["shape.create"],function(o){var a=o.context,s=a.hints||{},c=a.shape,u=a.parent||a.newParent;s.autoResize!==!1&&i._expand([c],u)}),this.postExecuted(["elements.move"],function(o){var a=o.context,s=_i(Sn(a.closure.topLevel)),c=a.hints,u=c?c.autoResize:!0;if(u!==!1){var p=Vt(s,function(l){return l.parent.id});E(p,function(l,f){q(u)&&(l=l.filter(function(d){return re(u,Ct({id:d.id}))})),i._expand(l,f)})}}),this.postExecuted(["shape.toggleCollapse"],function(o){var a=o.context,s=a.hints,c=a.shape;s&&s.autoResize===!1||c.collapsed||i._expand(c.children||[],c)}),this.postExecuted(["shape.resize"],function(o){var a=o.context,s=a.hints,c=a.shape,u=c.parent;s&&s.autoResize===!1||u&&i._expand([c],u)})}$n.$inject=["eventBus","elementRegistry","modeling","rules"];B($n,k);$n.prototype._getOptimalBounds=function(e,t){var n=this.getOffset(t),r=this.getPadding(t),i=Z(Ce(e)),o=Z(t),a={};return i.top-o.top<r.top&&(a.top=i.top-n.top),i.left-o.left<r.left&&(a.left=i.left-n.left),o.right-i.right<r.right&&(a.right=i.right+n.right),o.bottom-i.bottom<r.bottom&&(a.bottom=i.bottom+n.bottom),Si(C({},o,a))};$n.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 r=this._getOptimalBounds(e,t);if(tR(r,t)){var i=nR(mt(t,["x","y","width","height"]),r);this.resize(t,r,{autoResize:i});var o=t.parent;o&&this._expand([t],o)}}};$n.prototype.getOffset=function(e){return{top:60,bottom:60,left:100,right:100}};$n.prototype.getPadding=function(e){return{top:2,bottom:2,left:15,right:15}};$n.prototype.resize=function(e,t,n){this._modeling.resizeShape(e,t,null,n)};function tR(e,t){return e.x!==t.x||e.y!==t.y||e.width!==t.width||e.height!==t.height}function nR(e,t){var n="";return e=Z(e),t=Z(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 Oo(e){e.invoke($n,this)}Oo.$inject=["injector"];B(Oo,$n);Oo.prototype.resize=function(e,t,n){h(e,"bpmn:Participant")?this._modeling.resizeLane(e,t,null,n):this._modeling.resizeShape(e,t,null,n)};N();function Bi(e){Ot.call(this,e);var t=this;this.addRule("element.autoResize",function(n){return t.canResize(n.elements,n.target)})}Bi.$inject=["eventBus"];B(Bi,Ot);Bi.prototype.canResize=function(e,t){return!1};function Bo(e,t){Bi.call(this,e),this._modeling=t}B(Bo,Bi);Bo.$inject=["eventBus","modeling"];Bo.prototype.canResize=function(e,t){if(h(t.di,"bpmndi:BPMNPlane")||!h(t,"bpmn:Participant")&&!h(t,"bpmn:Lane")&&!h(t,"bpmn:SubProcess"))return!1;var n=!0;return E(e,function(r){if(h(r,"bpmn:Lane")||ee(r)){n=!1;return}}),n};var Jv={__init__:["bpmnAutoResize","bpmnAutoResizeProvider"],bpmnAutoResize:["type",Oo],bpmnAutoResizeProvider:["type",Bo]};var eg=1500;function Mu(e,t,n){var r=this,i=n.get("dragging",!1);function o(a){if(!a.hover){var s=a.originalEvent,c=r._findTargetGfx(s),u=c&&e.get(c);c&&u&&(a.stopPropagation(),i.hover({element:u,gfx:c}),i.move(s))}}i&&t.on("drag.start",function(a){t.once("drag.move",eg,function(s){o(s)})}),(function(){var a,s;t.on("element.hover",function(c){a=c.gfx,s=c.element}),t.on("element.hover",eg,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=An(a),c=document.elementFromPoint(s.x,s.y),rR(c)}}Mu.$inject=["elementRegistry","eventBus","injector"];function rR(e){return Bn(e,"svg, .djs-element",!0)}var tg={__init__:["hoverFix"],hoverFix:["type",Mu]};N();var Io=Math.round,ng="djs-drag-active";function Ii(e){e.preventDefault()}function iR(e){return typeof TouchEvent!="undefined"&&e instanceof TouchEvent}function oR(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Du(e,t,n,r){var i={threshold:5,trapClick:!0},o;function a(x){var b=t.viewbox(),R=t._container.getBoundingClientRect();return{x:b.x+(x.x-R.left)/b.scale,y:b.y+(x.y-R.top)/b.scale}}function s(x,b){b=b||o;var R=e.createEvent(C({},b.payload,b.data,{isTouch:b.isTouch}));return e.fire("drag."+x,R)===!1?!1:e.fire(b.prefix+"."+x,R)}function c(x){var b=x.filter(function(R){return r.get(R.id)});b.length&&n.select(b)}function u(x,b){var R=o.payload,A=o.displacement,O=o.globalStart,T=An(x),I=Dt(T,O),L=o.localStart,W=a(T),z=Dt(W,L);if(!o.active&&(b||oR(I)>o.threshold)){if(C(R,{x:Io(L.x+A.x),y:Io(L.y+A.y),dx:0,dy:0},{originalEvent:x}),s("start")===!1)return v();o.active=!0,o.keepSelection||(R.previousSelection=n.get(),n.select(null)),o.cursor&&Di(o.cursor),t.addMarker(t.getRootElement(),ng)}Wc(x),o.active&&(C(R,{x:Io(W.x+A.x),y:Io(W.y+A.y),dx:Io(z.x),dy:Io(z.y)},{originalEvent:x}),s("move"))}function p(x){var b,R=!0;o.active&&(x&&(o.payload.originalEvent=x,Wc(x)),R=s("end")),R===!1&&s("rejected"),b=w(R!==!0),s("ended",b)}function l(x){Ke("Escape",x)&&(Ii(x),v())}function f(x){var b;o.active&&(b=nu(e),setTimeout(b,400),Ii(x)),p(x)}function d(x){u(x)}function m(x){var b=o.payload;b.hoverGfx=x.gfx,b.hover=x.element,s("hover")}function g(x){s("out");var b=o.payload;b.hoverGfx=null,b.hover=null}function v(x){var b;if(o){var R=o.active;R&&s("cancel"),b=w(x),R&&s("canceled",b)}}function w(x){var b,R;s("cleanup"),tu(),o.trapClick?R=f:R=p,se.unbind(document,"mousemove",u),se.unbind(document,"dragstart",Ii),se.unbind(document,"selectstart",Ii),se.unbind(document,"mousedown",R,!0),se.unbind(document,"mouseup",R,!0),se.unbind(document,"keyup",l),se.unbind(document,"touchstart",d,!0),se.unbind(document,"touchcancel",v,!0),se.unbind(document,"touchmove",u,!0),se.unbind(document,"touchend",p,!0),e.off("element.hover",m),e.off("element.out",g),t.removeMarker(t.getRootElement(),ng);var A=o.payload.previousSelection;return x!==!1&&A&&!n.get().length&&c(A),b=o,o=null,b}function S(x,b,R,A){o&&v(!1),typeof b=="string"&&(A=R,R=b,b=null),A=C({},i,A||{});var O=A.data||{},T,I,L,W,z;if(A.trapClick?W=f:W=p,x?(T=Ar(x)||x,I=An(x),Wc(x),T.type==="dragstart"&&Ii(T)):(T=null,I={x:0,y:0}),L=a(I),b||(b=L),z=iR(T),o=C({prefix:R,data:O,payload:{},globalStart:I,displacement:Dt(b,L),localStart:L,isTouch:z},A),A.manual||(z?(se.bind(document,"touchstart",d,!0),se.bind(document,"touchcancel",v,!0),se.bind(document,"touchmove",u,!0),se.bind(document,"touchend",p,!0)):(se.bind(document,"mousemove",u),se.bind(document,"dragstart",Ii),se.bind(document,"selectstart",Ii),se.bind(document,"mousedown",W,!0),se.bind(document,"mouseup",W,!0)),se.bind(document,"keyup",l),e.on("element.hover",m),e.on("element.out",g)),s("init")===!1)return v(),!1;A.autoActivate&&u(x,!0)}e.on("diagram.destroy",v),this.init=S,this.move=u,this.hover=m,this.out=g,this.end=p,this.cancel=v,this.context=function(){return o},this.setOptions=function(x){C(i,x)}}Du.$inject=["eventBus","canvas","selection","elementRegistry"];var kt={__depends__:[tg,rt],dragging:["type",Du]};N();function ai(e,t,n){this._canvas=n,this._opts=C({scrollThresholdIn:[20,20,20,20],scrollThresholdOut:[0,0,0,0],scrollRepeatTimeout:15,scrollStep:10},e);var r=this;t.on("drag.move",function(i){var o=r._toBorderPoint(i);r.startScroll(o)}),t.on(["drag.cleanup"],function(){r.stopScroll()})}ai.$inject=["config.autoScroll","eventBus","canvas"];ai.prototype.startScroll=function(e){var t=this._canvas,n=this._opts,r=this,i=t.getContainer().getBoundingClientRect(),o=[e.x,e.y,i.width-e.x,i.height-e.y];this.stopScroll();for(var a=0,s=0,c=0;c<4;c++)aR(o[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(){r.startScroll(e)},n.scrollRepeatTimeout))};function aR(e,t,n){return t<e&&e<n}ai.prototype.stopScroll=function(){clearTimeout(this._scrolling)};ai.prototype.setOptions=function(e){this._opts=C({},this._opts,e)};ai.prototype._toBorderPoint=function(e){var t=this._canvas._container.getBoundingClientRect(),n=An(e.originalEvent);return{x:n.x-t.left,y:n.y-t.top}};var rg={__depends__:[kt],__init__:["autoScroll"],autoScroll:["type",ai]};function Wa(e){this._commandStack=e.get("commandStack",!1)}Wa.$inject=["injector"];Wa.prototype.allowed=function(e,t){var n=!0,r=this._commandStack;return r&&(n=r.canExecute(e,t)),n===void 0?!0:n};var Et={__init__:["rules"],rules:["type",Wa]};N();var ku=Math.round,sR=Math.max;function cR(e,t){var n=e.x,r=e.y;return[["M",n,r],["m",0,-t],["a",t,t,0,1,1,0,2*t],["a",t,t,0,1,1,0,-2*t],["z"]]}function uR(e){var t=[];return e.forEach(function(n,r){t.push([r===0?"M":"L",n.x,n.y])}),t}var ig=10;function pR(e,t){var n,r;for(n=0;r=e[n];n++)if(Gr(r,t)<=ig)return{point:e[n],bendpoint:!0,index:n};return null}function lR(e,t){var n=Da(cR(t,ig),uR(e)),r=n[0],i=n[n.length-1],o;return r?r!==i?r.segment2!==i.segment2?(o=sR(r.segment2,i.segment2)-1,{point:e[o],bendpoint:!0,index:o}):{point:{x:ku(r.x+i.x)/2,y:ku(r.y+i.y)/2},index:r.segment2}:{point:{x:ku(r.x),y:ku(r.y)},index:r.segment2}:null}function Ua(e,t){return pR(e,t)||lR(e,t)}function og(e){return Math.sqrt(Math.pow(e.x,2)+Math.pow(e.y,2))}function Af(e){return Math.atan((e[1].y-e[0].y)/(e[1].x-e[0].x))}function ag(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 fR(e,t,n){var r=[{n:e[0]-n[0],lambda:t[0]},{n:e[1]-n[1],lambda:t[1]}],i=r[0].n*t[0]+r[1].n*t[1],o=r[0].lambda*t[0]+r[1].lambda*t[1];return-i/o}function qa(e,t){var n=t[0],r=t[1],i={x:r.x-n.x,y:r.y-n.y},o=fR([n.x,n.y],[i.x,i.y],[e.x,e.y]);return{x:n.x+o*i.x,y:n.y+o*i.y}}function Nu(e,t){var n=qa(e,t),r={x:n.x-e.x,y:n.y-e.y};return og(r)}function Li(e,t){return og({x:e.x-t.x,y:e.y-t.y})}var Tf="djs-bendpoint",Mf="djs-segment-dragger";function dR(e,t){var n=An(t),r=e._container.getBoundingClientRect(),i;i={x:r.left,y:r.top};var o=e.viewbox();return{x:o.x+(n.x-i.x)/o.scale,y:o.y+(n.y-i.y)/o.scale}}function Ka(e,t,n){var r=dR(e,n),i=Ua(t,r);return i}function Ya(e,t){var n=U("g");pe(n).add(Tf),J(e,n);var r=U("circle");$(r,{cx:0,cy:0,r:4}),pe(r).add("djs-visual"),J(n,r);var i=U("circle");return $(i,{cx:0,cy:0,r:10}),pe(i).add("djs-hit"),J(n,i),t&&pe(n).add(t),n}function mR(e,t,n,r){var i=U("g");J(e,i);var o=18,a=6,s=11,c=hR(t,n,r),u=a+s,p=U("rect");$(p,{x:-o/2,y:-a/2,width:o,height:a}),pe(p).add("djs-visual"),J(i,p);var l=U("rect");return $(l,{x:-c/2,y:-u/2,width:c,height:u}),pe(l).add("djs-hit"),J(i,l),Rc(i,r==="v"?90:0,0,0),i}function Bu(e,t,n){var r=U("g"),i=Ma(t,n),o=en(t,n);return J(e,r),mR(r,t,n,o),pe(r).add(Mf),pe(r).add(o==="h"?"horizontal":"vertical"),Fe(r,i.x,i.y),r}function Ou(e){return Math.abs(Math.round(e*2/3))}function sg(e,t){var n=vR(e,t);return qa(e,n)}function hR(e,t,n){var r=t.x-e.x,i=t.y-e.y;return Ou(n==="h"?r:i)}function vR(e,t){for(var n=t.waypoints,r=1/0,i,o=0;o<n.length-1;o++){var a=n[o],s=n[o+1],c=Nu(e,[a,s]);c<r&&(r=c,i=o)}return[n[i],n[i+1]]}function Iu(e,t,n,r,i){function o(x,b,R){var A=x.index,O=x.point,T,I,L,W,z,K;return A<=0||x.bendpoint?!1:(T=b[A-1],I=b[A],L=Ma(T,I),W=en(T,I),z=Math.abs(O.x-L.x),K=Math.abs(O.y-L.y),W&&z<=R&&K<=R)}function a(x,b){var R=x.waypoints,A,O,T,I;return b.index<=0||b.bendpoint||(A={start:R[b.index-1],end:R[b.index]},O=en(A.start,A.end),!O)?null:(O==="h"?T=A.end.x-A.start.x:T=A.end.y-A.start.y,I=Ou(T)/2,I)}function s(x,b){var R=b.waypoints,A=Ka(t,R,x),O;if(A){O=a(b,A);var T;if(o(A,R,O)?T=i.start(x,b,A.index):T=r.start(x,b,A.index,!A.bendpoint),T!==!1)return!0}}function c(x,b,R){se.bind(x,b,function(A){n.triggerMouseEvent(b,A,R),A.stopPropagation()})}function u(x,b){var R=t.getLayer("overlays"),A=_e('.djs-bendpoints[data-element-id="'+Rr(x.id)+'"]',R);return!A&&b&&(A=U("g"),$(A,{"data-element-id":x.id}),pe(A).add("djs-bendpoints"),J(R,A),c(A,"mousedown",x),c(A,"click",x),c(A,"dblclick",x)),A}function p(x,b){return _e('.djs-segment-dragger[data-segment-idx="'+x+'"]',b)}function l(x,b){b.waypoints.forEach(function(R,A){var O=Ya(x);J(x,O),Fe(O,R.x,R.y)}),Ya(x,"floating")}function f(x,b){for(var R=b.waypoints,A,O,T,I=1;I<R.length;I++)A=R[I-1],O=R[I],en(A,O)&&(T=Bu(x,A,O),$(T,{"data-segment-idx":I}),c(T,"mousemove",b))}function d(x){E(xi("."+Tf,x),function(b){Pe(b)})}function m(x){E(xi("."+Mf,x),function(b){Pe(b)})}function g(x){var b=u(x);return b||(b=u(x,!0),l(b,x),f(b,x)),b}function v(x){var b=u(x);b&&(m(b),d(b),f(b,x),l(b,x))}function w(x,b){var R=_e(".floating",x),A=b.point;R&&Fe(R,A.x,A.y)}function S(x,b,R){var A=p(b.index,x),O=R[b.index-1],T=R[b.index],I=b.point,L=Ma(O,T),W=en(O,T),z,K;A&&(z=gR(A),K={x:I.x-L.x,y:I.y-L.y},W==="v"&&(K={x:K.y,y:K.x}),Fe(z,K.x,K.y))}e.on("connection.changed",function(x){v(x.element)}),e.on("connection.remove",function(x){var b=u(x.element);b&&Pe(b)}),e.on("element.marker.update",function(x){var b=x.element,R;b.waypoints&&(R=g(b),x.add?pe(R).add(x.marker):pe(R).remove(x.marker))}),e.on("element.mousemove",function(x){var b=x.element,R=b.waypoints,A,O;if(R){if(A=u(b,!0),O=Ka(t,R,x.originalEvent),!O)return;w(A,O),O.bendpoint||S(A,O,R)}}),e.on("element.mousedown",function(x){if(gn(x)){var b=x.originalEvent,R=x.element;if(R.waypoints)return s(b,R)}}),e.on("selection.changed",function(x){var b=x.newSelection,R=b[0];R&&R.waypoints&&g(R)}),e.on("element.hover",function(x){var b=x.element;b.waypoints&&g(b)}),e.on("element.updateId",function(x){var b=x.element,R=x.newId;if(b.waypoints){var A=u(b);A&&$(A,{"data-element-id":R})}}),this.addHandles=g,this.updateHandles=v,this.getBendpointsContainer=u,this.getSegmentDragger=p}Iu.$inject=["eventBus","canvas","interactionEvents","bendpointMove","connectionSegmentMove"];function gR(e){return _e(".djs-visual",e)}var cg=Math.round,ji="reconnectStart",Fi="reconnectEnd",Xa="updateWaypoints";function Qa(e,t,n,r,i,o){this._injector=e,this.start=function(a,s,c,u){var p=n.getGraphics(s),l=s.source,f=s.target,d=s.waypoints,m;!u&&c===0?m=ji:!u&&c===d.length-1?m=Fi:m=Xa;var g=m===Xa?"connection.updateWaypoints":"connection.reconnect",v=i.allowed(g,{connection:s,source:l,target:f});if(v===!1&&(v=i.allowed(g,{connection:s,source:f,target:l})),v!==!1)return r.init(a,"bendpoint.move",{data:{connection:s,connectionGfx:p,context:{allowed:v,bendpointIndex:c,connection:s,source:l,target:f,insert:u,type:m}}})},t.on("bendpoint.move.hover",function(a){var s=a.context,c=s.connection,u=c.source,p=c.target,l=a.hover,f=s.type;s.hover=l;var d;if(l){var m=f===Xa?"connection.updateWaypoints":"connection.reconnect";if(d=s.allowed=i.allowed(m,{connection:c,source:f===ji?l:u,target:f===Fi?l:p}),d){s.source=f===ji?l:u,s.target=f===Fi?l:p;return}d===!1&&(d=s.allowed=i.allowed(m,{connection:c,source:f===Fi?l:p,target:f===ji?l:u})),d&&(s.source=f===Fi?l:p,s.target=f===ji?l:u)}}),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!==Xa&&(s.allowed=!1)}),t.on("bendpoint.move.end",function(a){var s=a.context,c=s.allowed,u=s.bendpointIndex,p=s.connection,l=s.insert,f=p.waypoints.slice(),d=s.source,m=s.target,g=s.type,v=s.hints||{},w={x:cg(a.x),y:cg(a.y)};if(!c)return!1;g===Xa?(l?f.splice(u,0,w):f[u]=w,v.bendpointMove={insert:l,bendpointIndex:u},f=this.cropWaypoints(p,f),o.updateWaypoints(p,Am(f),v)):(g===ji?(v.docking="source",Za(s)&&(v.docking="target",v.newWaypoints=f.reverse())):g===Fi&&(v.docking="target",Za(s)&&(v.docking="source",v.newWaypoints=f.reverse())),o.reconnect(p,d,m,w,v))},this)}Qa.$inject=["injector","eventBus","canvas","dragging","rules","modeling"];Qa.prototype.cropWaypoints=function(e,t){var n=this._injector.get("connectionDocking",!1);if(!n)return t;var r=e.waypoints;return e.waypoints=t,e.waypoints=n.getCroppedWaypoints(e),t=e.waypoints,e.waypoints=r,t};function Za(e){var t=e.hover,n=e.source,r=e.target,i=e.type;if(i===ji)return t&&r&&t===r&&n!==r;if(i===Fi)return t&&n&&t===n&&n!==r}var yR="reconnectStart",_R="reconnectEnd",ug="updateWaypoints",Ja="connect-ok",Lu="connect-not-ok",pg="connect-hover",lg="djs-updating",fg="djs-dragging",dg=1100;function ju(e,t,n,r){this._injector=t;var i=t.get("connectionPreview",!1);n.on("bendpoint.move.start",function(o){var a=o.context,s=a.bendpointIndex,c=a.connection,u=a.insert,p=c.waypoints,l=p.slice();a.waypoints=p,u&&l.splice(s,0,{x:o.x,y:o.y}),c.waypoints=l;var f=a.draggerGfx=Ya(r.getLayer("overlays"));pe(f).add("djs-dragging"),r.addMarker(c,fg),r.addMarker(c,lg)}),n.on("bendpoint.move.hover",function(o){var a=o.context,s=a.allowed,c=a.hover,u=a.type;if(c){if(r.addMarker(c,pg),u===ug)return;s?(r.removeMarker(c,Lu),r.addMarker(c,Ja)):s===!1&&(r.removeMarker(c,Ja),r.addMarker(c,Lu))}}),n.on(["bendpoint.move.out","bendpoint.move.cleanup"],dg,function(o){var a=o.context,s=a.hover,c=a.target;s&&(r.removeMarker(s,pg),r.removeMarker(s,c?Ja:Lu))}),n.on("bendpoint.move.move",function(o){var a=o.context,s=a.allowed,c=a.bendpointIndex,u=a.draggerGfx,p=a.hover,l=a.type,f=a.connection,d=f.source,m=f.target,g=f.waypoints.slice(),v={x:o.x,y:o.y},w=a.hints||{},S={};i&&(w.connectionStart&&(S.connectionStart=w.connectionStart),w.connectionEnd&&(S.connectionEnd=w.connectionEnd),l===yR?Za(a)?(S.connectionEnd=S.connectionEnd||v,S.source=m,S.target=p||d,g=g.reverse()):(S.connectionStart=S.connectionStart||v,S.source=p||d,S.target=m):l===_R?Za(a)?(S.connectionStart=S.connectionStart||v,S.source=p||m,S.target=d,g=g.reverse()):(S.connectionEnd=S.connectionEnd||v,S.source=d,S.target=p||m):(S.noCropping=!0,S.noLayout=!0,g[c]=v),l===ug&&(g=e.cropWaypoints(f,g)),S.waypoints=g,i.drawPreview(a,s,S)),Fe(u,o.x,o.y)},this),n.on(["bendpoint.move.end","bendpoint.move.cancel"],dg,function(o){var a=o.context,s=a.connection,c=a.draggerGfx,u=a.hover,p=a.target,l=a.waypoints;s.waypoints=l,Pe(c),r.removeMarker(s,lg),r.removeMarker(s,fg),u&&(r.removeMarker(u,Ja),r.removeMarker(u,p?Ja:Lu)),i&&i.cleanUp(a)})}ju.$inject=["bendpointMove","injector","eventBus","canvas"];var mg="connect-hover",hg="djs-updating";function vg(e,t,n){return Df(e,t,e[t]+n)}function Df(e,t,n){return{x:t==="x"?n:e.x,y:t==="y"?n:e.y}}function bR(e,t,n,r){var i=Math.max(t[r],n[r]),o=Math.min(t[r],n[r]),a=20,s=Math.min(Math.max(o+a,e[r]),i-a);return Df(t,r,s)}function yg(e){return e==="x"?"y":"x"}function gg(e,t,n){var r,i;return e.original?e.original:(r=X(t),i=yg(n),Df(e,i,r[i]))}function Fu(e,t,n,r,i,o){var a=e.get("connectionDocking",!1);this.start=function(l,f,d){var m,g=n.getGraphics(f),v=d-1,w=d,S=f.waypoints,x=S[v],b=S[w],R=Ka(n,S,l),A,O,T;if(A=en(x,b),!!A)return O=A==="v"?"x":"y",v===0&&(x=gg(x,f.source,O)),w===S.length-1&&(b=gg(b,f.target,O)),R?T=R.point:T={x:(x.x+b.x)/2,y:(x.y+b.y)/2},m={connection:f,segmentStartIndex:v,segmentEndIndex:w,segmentStart:x,segmentEnd:b,axis:O,dragPosition:T},r.init(l,T,"connectionSegment.move",{cursor:O==="x"?"resize-ew":"resize-ns",data:{connection:f,connectionGfx:g,context:m}})};function s(l,f){if(!a)return f;var d=l.waypoints,m;return l.waypoints=f,m=a.getCroppedWaypoints(l),l.waypoints=d,m}function c(l){i.update("connection",l.connection,l.connectionGfx)}function u(l,f,d){var m=l.newWaypoints,g=l.segmentStartIndex+f,v=m[g],w=l.segmentEndIndex+f,S=m[w],x=yg(l.axis),b=bR(d,v,S,x);Fe(l.draggerGfx,b.x,b.y)}function p(l,f){var d=0,m=l.filter(function(g,v){return uo(l[v-1],l[v+1],g)?(d=v<=f?d-1:d,!1):!0});return{waypoints:m,segmentOffset:d}}t.on("connectionSegment.move.start",function(l){var f=l.context,d=l.connection,m=n.getLayer("overlays");f.originalWaypoints=d.waypoints.slice(),f.draggerGfx=Bu(m,f.segmentStart,f.segmentEnd),pe(f.draggerGfx).add("djs-dragging"),n.addMarker(d,hg)}),t.on("connectionSegment.move.move",function(l){var f=l.context,d=f.connection,m=f.segmentStartIndex,g=f.segmentEndIndex,v=f.segmentStart,w=f.segmentEnd,S=f.axis,x=f.originalWaypoints.slice(),b=vg(v,S,l["d"+S]),R=vg(w,S,l["d"+S]),A=x.length,O=0;x[m]=b,x[g]=R;var T,I;m<2&&(T=He(d.source,b),m===1?T==="intersect"&&(x.shift(),x[0]=b,O--):T!=="intersect"&&(x.unshift(v),O++)),g>A-3&&(I=He(d.target,R),g===A-2?I==="intersect"&&(x.pop(),x[x.length-1]=R):I!=="intersect"&&x.push(w)),f.newWaypoints=d.waypoints=s(d,x),u(f,O,l),f.newSegmentStartIndex=m+O,c(l)}),t.on("connectionSegment.move.hover",function(l){l.context.hover=l.hover,n.addMarker(l.hover,mg)}),t.on(["connectionSegment.move.out","connectionSegment.move.cleanup"],function(l){var f=l.context.hover;f&&n.removeMarker(f,mg)}),t.on("connectionSegment.move.cleanup",function(l){var f=l.context,d=f.connection;f.draggerGfx&&Pe(f.draggerGfx),n.removeMarker(d,hg)}),t.on(["connectionSegment.move.cancel","connectionSegment.move.end"],function(l){var f=l.context,d=f.connection;d.waypoints=f.originalWaypoints,c(l)}),t.on("connectionSegment.move.end",function(l){var f=l.context,d=f.connection,m=f.newWaypoints,g=f.newSegmentStartIndex;m=m.map(function(R){return{original:R.original,x:Math.round(R.x),y:Math.round(R.y)}});var v=p(m,g),w=v.waypoints,S=s(d,w),x=v.segmentOffset,b={segmentMove:{segmentStartIndex:f.segmentStartIndex,newSegmentStartIndex:g+x}};o.updateWaypoints(d,S,b)})}Fu.$inject=["injector","eventBus","canvas","dragging","graphicsFactory","modeling"];N();var xR=Math.abs,_g=Math.round;function bg(e,t,n){n=n===void 0?10:n;var r,i;for(r=0;r<t.length;r++)if(i=t[r],xR(i-e)<=n)return i}function Hu(e){return{x:e.x,y:e.y}}function $u(e){return{x:e.x+e.width,y:e.y+e.height}}function rn(e,t){return!e||isNaN(e.x)||isNaN(e.y)?t:{x:_g(e.x+e.width/2),y:_g(e.y+e.height/2)}}function zn(e,t){var n=e.snapped;return n?typeof t=="string"?n[t]:n.x&&n.y:!1}function ze(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 r,i=e[t],o=e.snapped=e.snapped||{};return n===!1?o[t]=!1:(o[t]=!0,r=n-i,e[t]+=r,e["d"+t]+=r),i}function zu(e){return e.children||[]}var ER=Math.abs,xg=Math.round,kf=10;function Gu(e){function t(o,a){if(q(o)){for(var s=o.length;s--;)if(ER(o[s]-a)<=kf)return o[s]}else{o=+o;var c=a%o;if(c<kf)return a-c;if(c>o-kf)return a-c+o}return a}function n(o,a){if(o.waypoints)return sg(a,o);if(o.width)return{x:xg(o.width/2+o.x),y:xg(o.height/2+o.y)}}function r(o){var a=o.context,s=a.snapPoints,c=a.connection,u=c.waypoints,p=a.segmentStart,l=a.segmentStartIndex,f=a.segmentEnd,d=a.segmentEndIndex,m=a.axis;if(s)return s;var g=[u[l-1],p,f,u[d+1]];return l<2&&g.unshift(n(c.source,o)),d>u.length-3&&g.unshift(n(c.target,o)),a.snapPoints=s={horizontal:[],vertical:[]},E(g,function(v){v&&(v=v.original||v,m==="y"&&s.horizontal.push(v.y),m==="x"&&s.vertical.push(v.x))}),s}e.on("connectionSegment.move.move",1500,function(o){var a=r(o),s=o.x,c=o.y,u,p;if(a){u=t(a.vertical,s),p=t(a.horizontal,c);var l=s-u,f=c-p;C(o,{dx:o.dx-l,dy:o.dy-f,x:u,y:p}),(l||a.vertical.indexOf(s)!==-1)&&ze(o,"x",u),(f||a.horizontal.indexOf(c)!==-1)&&ze(o,"y",p)}});function i(o){var a=o.snapPoints,s=o.connection.waypoints,c=o.bendpointIndex;if(a)return a;var u=[s[c-1],s[c+1]];return o.snapPoints=a={horizontal:[],vertical:[]},E(u,function(p){p&&(p=p.original||p,a.horizontal.push(p.y),a.vertical.push(p.x))}),a}e.on(["connect.hover","connect.move","connect.end"],1500,function(o){var a=o.context,s=a.hover,c=s&&n(s,o);!de(s)||!c||!c.x||!c.y||(ze(o,"x",c.x),ze(o,"y",c.y))}),e.on(["bendpoint.move.move","bendpoint.move.end"],1500,function(o){var a=o.context,s=i(a),c=a.hover,u=c&&n(c,o),p=o.x,l=o.y,f,d;if(s){f=t(u?s.vertical.concat([u.x]):s.vertical,p),d=t(u?s.horizontal.concat([u.y]):s.horizontal,l);var m=p-f,g=l-d;C(o,{dx:o.dx-m,dy:o.dy-g,x:o.x-m,y:o.y-g}),(m||s.vertical.indexOf(p)!==-1)&&ze(o,"x",f),(g||s.horizontal.indexOf(l)!==-1)&&ze(o,"y",d)}})}Gu.$inject=["eventBus"];var Eg={__depends__:[kt,Et],__init__:["bendpoints","bendpointSnapping","bendpointMovePreview"],bendpoints:["type",Iu],bendpointMove:["type",Qa],bendpointMovePreview:["type",ju],connectionSegmentMove:["type",Fu],bendpointSnapping:["type",Gu]};N();function Wu(e,t,n,r){function i(a,s){return r.allowed("connection.create",{source:a,target:s})}function o(a,s){return i(s,a)}e.on("connect.hover",function(a){var s=a.context,c=s.start,u=a.hover,p;if(s.hover=u,p=s.canExecute=i(c,u),!Yn(p)){if(p!==!1){s.source=c,s.target=u;return}p=s.canExecute=o(c,u),!Yn(p)&&p!==!1&&(s.source=u,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,u=s.connectionStart,p={x:a.x,y:a.y},l=s.source,f=s.target;if(!c)return!1;var d=null,m={connectionStart:Vu(s)?p:u,connectionEnd:Vu(s)?u:p};Se(c)&&(d=c),s.connection=n.connect(l,f,d,m)}),this.start=function(a,s,c,u){Se(c)||(u=c,c=X(s)),t.init(a,"connect",{autoActivate:u,data:{shape:s,context:{start:s,connectionStart:c}}})}}Wu.$inject=["eventBus","dragging","modeling","rules"];function Vu(e){var t=e.hover,n=e.source,r=e.target;return t&&n&&t===n&&n!==r}var wR=1100,SR=900,wg="connect-ok",Sg="connect-not-ok";function Uu(e,t,n){var r=e.get("connectionPreview",!1);r&&t.on("connect.move",function(i){var o=i.context,a=o.canExecute,s=o.hover,c=o.source,u=o.start,p=o.startPosition,l=o.target,f=o.connectionStart||p,d=o.connectionEnd||{x:i.x,y:i.y},m=f,g=d;Vu(o)&&(m=d,g=f),r.drawPreview(o,a,{source:c||u,target:l||s,connectionStart:m,connectionEnd:g})}),t.on("connect.hover",SR,function(i){var o=i.context,a=i.hover,s=o.canExecute;s!==null&&n.addMarker(a,s?wg:Sg)}),t.on(["connect.out","connect.cleanup"],wR,function(i){var o=i.hover;o&&(n.removeMarker(o,wg),n.removeMarker(o,Sg))}),r&&t.on("connect.cleanup",function(i){r.cleanUp(i.context)})}Uu.$inject=["injector","eventBus","canvas"];var Lo={__depends__:[rt,Et,kt],__init__:["connectPreview"],connect:["type",Wu],connectPreview:["type",Uu]};N();var CR="djs-dragger";function Gn(e,t,n,r){this._canvas=t,this._graphicsFactory=n,this._elementFactory=r,this._connectionDocking=e.get("connectionDocking",!1),this._layouter=e.get("layouter",!1)}Gn.$inject=["injector","canvas","graphicsFactory","elementFactory"];Gn.prototype.drawPreview=function(e,t,n){n=n||{};var r=e.connectionPreviewGfx,i=e.getConnection,o=n.source,a=n.target,s=n.waypoints,c=n.connectionStart,u=n.connectionEnd,p=n.noLayout,l=n.noCropping,f=n.noNoop,d,m=this;if(r||(r=e.connectionPreviewGfx=this.createConnectionPreviewGfx()),_r(r),i||(i=e.getConnection=RR(function(g,v,w){return m.getConnection(g,v,w)})),t&&(d=i(t,o,a)),!d){!f&&this.drawNoopPreview(r,n);return}d.waypoints=s||[],this._layouter&&!p&&(d.waypoints=this._layouter.layoutConnection(d,{source:o,target:a,connectionStart:c,connectionEnd:u,waypoints:n.waypoints||d.waypoints})),(!d.waypoints||!d.waypoints.length)&&(d.waypoints=[o?X(o):c,a?X(a):u]),this._connectionDocking&&(o||a)&&!l&&(d.waypoints=this._connectionDocking.getCroppedWaypoints(d,o,a)),this._graphicsFactory.drawConnection(r,d,{stroke:"var(--element-dragger-color)"})};Gn.prototype.drawNoopPreview=function(e,t){var n=t.source,r=t.target,i=t.connectionStart||X(n),o=t.connectionEnd||X(r),a=this.cropWaypoints(i,o,n,r),s=this.createNoopConnection(a[0],a[1]);J(e,s)};Gn.prototype.cropWaypoints=function(e,t,n,r){var i=this._graphicsFactory,o=n&&i.getShapePath(n),a=r&&i.getShapePath(r),s=i.getConnectionPath({waypoints:[e,t]});return e=n&&qr(o,s,!0)||e,t=r&&qr(a,s,!1)||t,[e,t]};Gn.prototype.cleanUp=function(e){e&&e.connectionPreviewGfx&&Pe(e.connectionPreviewGfx)};Gn.prototype.getConnection=function(e){var t=PR(e);return this._elementFactory.createConnection(t)};Gn.prototype.createConnectionPreviewGfx=function(){var e=U("g");return $(e,{pointerEvents:"none"}),pe(e).add(CR),J(this._canvas.getActiveLayer(),e),e};Gn.prototype.createNoopConnection=function(e,t){return Xn([e,t],{stroke:"#333",strokeDasharray:[1],strokeWidth:2,"pointer-events":"none"})};function RR(e){var t={};return function(n){var r=JSON.stringify(n),i=t[r];return i||(i=t[r]=e.apply(null,arguments)),i}}function PR(e){return Se(e)?e:{}}var Cg={__init__:["connectionPreview"],connectionPreview:["type",Gn]};var AR=new or("ps"),TR=["marker-start","marker-mid","marker-end"],MR=["circle","ellipse","line","path","polygon","polyline","path","rect"];function cr(e,t,n,r){this._elementRegistry=e,this._canvas=n,this._styles=r}cr.$inject=["elementRegistry","eventBus","canvas","styles"];cr.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")};cr.prototype.getGfx=function(e){return this._elementRegistry.getGraphics(e)};cr.prototype.addDragger=function(e,t,n,r="djs-dragger"){n=n||this.getGfx(e);var i=Sl(n),o=n.getBoundingClientRect();return this._cloneMarkers(Ln(i),r),$(i,this._styles.cls(r,[],{x:o.top,y:o.left})),J(t,i),$(i,"data-preview-support-element-id",e.id),i};cr.prototype.addFrame=function(e,t){var n=U("rect",{class:"djs-resize-overlay",width:e.width,height:e.height,x:e.x,y:e.y});return J(t,n),$(n,"data-preview-support-element-id",e.id),n};cr.prototype._cloneMarkers=function(e,t="djs-dragger",n=e){var r=this;e.childNodes&&e.childNodes.forEach(i=>{r._cloneMarkers(i,t,n)}),OR(e)&&TR.forEach(function(i){if($(e,i)){var o=DR(e,i,r._canvas.getContainer());o&&r._cloneMarker(n,e,o,i,t)}})};cr.prototype._cloneMarker=function(e,t,n,r,i="djs-dragger"){var o=[n.id,i,AR.next()].join("-"),a=_e("marker#"+n.id,e);e=e||this._canvas._svg;var s=a||Sl(n);s.id=o,pe(s).add(i);var c=_e(":scope > defs",e);c||(c=U("defs"),J(e,c)),J(c,s);var u=NR(s.id);$(t,r,u)};function DR(e,t,n){var r=kR($(e,t));return _e("marker#"+r,n||document)}function kR(e){return e.match(/url\(['"]?#([^'"]*)['"]?\)/)[1]}function NR(e){return"url(#"+e+")"}function OR(e){return MR.indexOf(e.nodeName)!==-1}var Dn={__init__:["previewSupport"],previewSupport:["type",cr]};var qu="complex-preview",jo=class{constructor(t,n,r){this._canvas=t,this._graphicsFactory=n,this._previewSupport=r,this._markers=[]}create(t){this.cleanUp();let{created:n=[],moved:r=[],removed:i=[],resized:o=[]}=t,a=this._canvas.getLayer(qu);n.filter(s=>!BR(s)).forEach(s=>{let c;de(s)?(c=this._graphicsFactory._createContainer("connection",U("g")),this._graphicsFactory.drawConnection(Ln(c),s)):(c=this._graphicsFactory._createContainer("shape",U("g")),this._graphicsFactory.drawShape(Ln(c),s),Fe(c,s.x,s.y)),this._previewSupport.addDragger(s,a,c)}),r.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"]);let u=this._previewSupport.addDragger(s,a);de(s)?Fe(u,c.x,c.y):Fe(u,s.x+c.x,s.y+c.y)}),i.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"])}),o.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");let u=this._graphicsFactory._createContainer("shape",U("g"));this._graphicsFactory.drawShape(Ln(u),s,{width:c.width,height:c.height}),Fe(u,c.x,c.y),this._previewSupport.addDragger(s,a,u)})}cleanUp(){_r(this._canvas.getLayer(qu)),this._markers.forEach(([t,n])=>this._canvas.removeMarker(t,n)),this._markers=[]}show(){this._canvas.showLayer(qu)}hide(){this._canvas.hideLayer(qu)}};jo.$inject=["canvas","graphicsFactory","previewSupport"];function BR(e){return e.hidden}var Rg={__depends__:[Dn],__init__:["complexPreview"],complexPreview:["type",jo]};var Nf=["top","bottom","left","right"],Ku=10;function es(e,t){k.call(this,e),this.postExecuted(["connection.create","connection.layout","connection.updateWaypoints"],function(i){var o=i.context,a=o.connection,s=a.source,c=a.target,u=o.hints||{};u.createElementsBehavior!==!1&&(n(s),n(c))}),this.postExecuted(["label.create"],function(i){var o=i.context,a=o.shape,s=o.hints||{};s.createElementsBehavior!==!1&&n(a.labelTarget)}),this.postExecuted(["elements.create"],function(i){var o=i.context,a=o.elements,s=o.hints||{};s.createElementsBehavior!==!1&&a.forEach(function(c){n(c)})});function n(i){if(Xr(i)&&!de(i)){var o=jR(i);o&&r(i,o)}}function r(i,o){var a=X(i),s=i.label,c=X(s);if(s.parent){var u=Z(i),p;switch(o){case"top":p={x:a.x,y:u.top-Ku-s.height/2};break;case"left":p={x:u.left-Ku-s.width/2,y:a.y};break;case"bottom":p={x:a.x,y:u.bottom+Ku+s.height/2};break;case"right":p={x:u.right+Ku+s.width/2,y:a.y};break}var l=Dt(p,c);t.moveShape(s,l)}}}B(es,k);es.$inject=["eventBus","modeling"];function IR(e){var t=e.host,n=X(e),r=He(n,t),i;r.indexOf("-")>=0?i=r.split("-"):i=[r];var o=Nf.filter(function(a){return i.indexOf(a)===-1});return o}function LR(e){var t=X(e),n=[].concat(e.incoming.map(function(r){return r.waypoints[r.waypoints.length-2]}),e.outgoing.map(function(r){return r.waypoints[1]})).map(function(r){return Pg(t,r)});return n}function jR(e){var t=X(e.label),n=X(e),r=Pg(n,t);if(FR(r)){var i=LR(e);if(e.host){var o=IR(e);i=i.concat(o)}var a=Nf.filter(function(s){return i.indexOf(s)===-1});return a.indexOf(r)!==-1?He(e.label,e)!=="intersect"?void 0:r:a[0]}}function Pg(e,t){return He(t,e,5)}function FR(e){return Nf.indexOf(e)!==-1}function ts(e){k.call(this,e),this.preExecute("shape.append",function(t){var n=t.source,r=t.shape;t.position||(h(r,"bpmn:TextAnnotation")?t.position={x:n.x+n.width/2+75,y:n.y-50-r.height/2}:t.position={x:n.x+n.width+80+r.width/2,y:n.y+n.height/2})},!0)}B(ts,k);ts.$inject=["eventBus"];N();var HR=1500;function ns(e,t,n){e.invoke(k,this),this.preExecute("elements.delete",HR,function(i){var o=i.context,a=o.elements,s=r(a);s.length&&(o.elements=a.concat(s))}),t.on("shape.move.start",function(i){var o=i.context.shapes,a=r(o);a.length&&(i.context.shapes=o.concat(a))});function r(i){var o=Q(i,u=>h(u,"bpmn:Participant")||h(u,"bpmn:SubProcess"));if(!o.length)return[];var a=n.getRootElement(),s=new Set(a.children.filter(u=>h(u,"bpmn:Artifact"))),c=new Set;return E(o,u=>{let p=new Set(Sn(wi(Array.from(s),Ce(u))));c=c.union(p),s=s.difference(p)}),Array.from(c)}}B(ns,k);ns.$inject=["injector","eventBus","canvas"];N();function rs(e,t){e.invoke(k,this),this.postExecute("shape.move",function(n){var r=n.newParent,i=n.shape,o=Q(i.incoming.concat(i.outgoing),function(a){return h(a,"bpmn:Association")});E(o,function(a){t.moveConnection(a,{x:0,y:0},r)})},!0)}B(rs,k);rs.$inject=["injector","modeling"];var Ag=500;function Fo(e,t){t.invoke(k,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",Ag,function(r){var i=r.elements;i=i.filter(function(o){var a=o.host;return Tg(o,a)}),i.length===1&&i.map(function(o){return i.indexOf(o)}).forEach(function(o){var a=i[o];r.elements[o]=n._replaceShape(i[o],a)})},!0),this.preExecute("elements.move",Ag,function(r){var i=r.shapes,o=r.newHost;if(i.length===1){var a=i[0];Tg(a,o)&&(r.shapes=[n._replaceShape(a,o)])}},!0)}Fo.$inject=["bpmnReplace","injector"];B(Fo,k);Fo.prototype._replaceShape=function(e,t){var n=$R(e),r={type:"bpmn:BoundaryEvent",host:t};return n&&(r.eventDefinitionType=n.$type),this._bpmnReplace.replaceElement(e,r,{layoutConnection:!1})};function $R(e){var t=j(e),n=t.eventDefinitions;return n&&n[0]}function Tg(e,t){return!ee(e)&&te(e,["bpmn:IntermediateThrowEvent","bpmn:IntermediateCatchEvent"])&&!!t}N();function is(e,t){k.call(this,e);function n(r){return Q(r.attachers,function(i){return h(i,"bpmn:BoundaryEvent")})}this.postExecute("connection.create",function(r){var i=r.context.source,o=r.context.target,a=n(o);h(i,"bpmn:EventBasedGateway")&&h(o,"bpmn:ReceiveTask")&&a.length>0&&t.removeElements(a)}),this.postExecute("connection.reconnect",function(r){var i=r.context.oldSource,o=r.context.newSource;h(i,"bpmn:Gateway")&&h(o,"bpmn:EventBasedGateway")&&E(o.outgoing,function(a){var s=a.target,c=n(s);h(s,"bpmn:ReceiveTask")&&c.length>0&&t.removeElements(c)})})}is.$inject=["eventBus","modeling"];B(is,k);function as(e,t,n){k.call(this,e),this.preExecute("shape.replace",s,!0),this.postExecuted("shape.replace",c,!0),this.preExecute("connection.create",i,!0),this.postExecuted("connection.delete",r,!0),this.postExecuted("connection.reconnect",o,!0),this.postExecuted("element.updateProperties",a,!0);function r(v){let w=v.source,S=v.target;Ho(w)&&os(S)&&p(S)}function i(v){let w=v.connection,S=v.source,x=v.target;Ho(S)&&Yu(x)&&(u(x),f(S,[w]))}function o(v){let w=v.newTarget,S=v.oldSource,x=v.oldTarget;if(x!==w){let b=S;os(x)&&p(x),Ho(b)&&Yu(w)&&u(w)}}function a(v){let{element:w}=v;os(w)?(l(w),d(w)):Yu(w)&&m(w)}function s(v){let{newData:w,oldShape:S}=v;if(Ho(v.oldShape)&&w.eventDefinitionType!=="bpmn:CompensateEventDefinition"||w.type!=="bpmn:BoundaryEvent"){let x=S.outgoing.find(({target:b})=>os(b));x&&x.target&&(v._connectionTarget=x.target)}else if(!Ho(v.oldShape)&&w.eventDefinitionType==="bpmn:CompensateEventDefinition"&&w.type==="bpmn:BoundaryEvent"){let x=S.outgoing.find(({target:b})=>Yu(b));x&&x.target&&(v._connectionTarget=x.target),g(S)}}function c(v){let{_connectionTarget:w,newShape:S}=v;w&&t.connect(S,w)}function u(v){t.updateProperties(v,{isForCompensation:!0})}function p(v){t.updateProperties(v,{isForCompensation:void 0})}function l(v){for(let w of v.incoming)n.canConnect(w.source,v)||t.removeConnection(w);for(let w of v.outgoing)n.canConnect(v,w.target)||t.removeConnection(w)}function f(v,w){v.outgoing.filter(b=>h(b,"bpmn:Association")).filter(b=>os(b.target)&&!w.includes(b)).forEach(b=>t.removeConnection(b))}function d(v){let w=v.attachers.slice();w.length&&t.removeElements(w)}function m(v){let w=v.incoming.filter(S=>Ho(S.source));t.removeElements(w)}function g(v){let w=v.outgoing.filter(S=>h(S,"bpmn:SequenceFlow"));t.removeElements(w)}}B(as,k);as.$inject=["eventBus","modeling","bpmnRules"];function os(e){let t=j(e);return t&&t.get("isForCompensation")}function Ho(e){return e&&h(e,"bpmn:BoundaryEvent")&&Er(e,"bpmn:CompensateEventDefinition")}function Yu(e){return e&&h(e,"bpmn:Activity")&&!Qe(e)}function ss(e){e.invoke(k,this),this.preExecute("shape.create",1500,function(t){var n=t.context,r=n.parent,i=n.shape;h(r,"bpmn:Lane")&&!h(i,"bpmn:Lane")&&(n.parent=kr(r,"bpmn:Participant"))})}ss.$inject=["injector"];B(ss,k);function cs(e,t){k.call(this,e),this.preExecute("shape.create",function(n){var a;var r=n.context,i=r.shape;if(h(i,"bpmn:DataObjectReference")&&i.type!=="label"){var o=t.create("bpmn:DataObject");o.isCollection=((a=i.businessObject.dataObjectRef)==null?void 0:a.isCollection)||!1,i.businessObject.dataObjectRef=o}})}cs.$inject=["eventBus","bpmnFactory"];B(cs,k);N();var Of=20,Bf=20,Mg=30,Xu=2e3;function us(e,t,n){k.call(this,t),t.on(["create.start","shape.move.start"],Xu,function(i){var o=i.context,a=o.shape,s=e.getRootElement();if(!(!h(a,"bpmn:Participant")||!h(s,"bpmn:Process")||!s.children.length)){var c=s.children.filter(function(l){return!h(l,"bpmn:Group")&&!ee(l)&&!de(l)});if(c.length){var u=Ce(c),p=zR(a,u);C(a,p),o.createConstraints=GR(a,u)}}}),t.on("create.start",Xu,function(i){var o=i.context,a=o.shape,s=e.getRootElement(),c=e.getGraphics(s);function u(p){p.element=s,p.gfx=c}h(a,"bpmn:Participant")&&h(s,"bpmn:Process")&&(t.on("element.hover",Xu,u),t.once("create.cleanup",function(){t.off("element.hover",u)}))});function r(){var i=e.getRootElement();return h(i,"bpmn:Collaboration")?i:n.makeCollaboration()}this.preExecute("elements.create",Xu,function(i){var o=i.elements,a=i.parent,s=VR(o),c;s&&h(a,"bpmn:Process")&&(i.parent=r(),c=i.hints=i.hints||{},c.participant=s,c.process=a,c.processRef=j(s).get("processRef"))},!0),this.preExecute("shape.create",function(i){var o=i.parent,a=i.shape;h(a,"bpmn:Participant")&&h(o,"bpmn:Process")&&(i.parent=r(),i.process=o,i.processRef=j(a).get("processRef"))},!0),this.execute("shape.create",function(i){var o=i.hints||{},a=i.process||o.process,s=i.shape,c=o.participant;a&&(!c||s===c)&&j(s).set("processRef",j(a))},!0),this.revert("shape.create",function(i){var o=i.hints||{},a=i.process||o.process,s=i.processRef||o.processRef,c=i.shape,u=o.participant;a&&(!u||c===u)&&j(c).set("processRef",s)},!0),this.postExecute("shape.create",function(i){var o=i.hints||{},a=i.process||i.hints.process,s=i.shape,c=o.participant;if(a){var u=a.children.slice();c?s===c&&n.moveElements(u,{x:0,y:0},c):n.moveElements(u,{x:0,y:0},s)}},!0)}us.$inject=["canvas","eventBus","modeling"];B(us,k);function zR(e,t){t={width:t.width+Of*2+Mg,height:t.height+Bf*2};var n=Math.max(e.width,t.width),r=Math.max(e.height,t.height);return{x:-n/2,y:-r/2,width:n,height:r}}function GR(e,t){return t=Z(t),{bottom:t.top+e.height/2-Bf,left:t.right-e.width/2+Of,top:t.bottom-e.height/2+Bf,right:t.left+e.width/2-Of-Mg}}function VR(e){return re(e,function(t){return h(t,"bpmn:Participant")})}N();var Dg="__targetRef_placeholder";function ps(e,t){k.call(this,e),this.executed(["connection.create","connection.delete","connection.move","connection.reconnect"],kg(o)),this.reverted(["connection.create","connection.delete","connection.move","connection.reconnect"],kg(o));function n(a,s,c){var u=a.get("dataInputAssociations");return re(u,function(p){return p!==c&&p.targetRef===s})}function r(a,s){var c=a.get("properties"),u=re(c,function(p){return p.name===Dg});return!u&&s&&(u=t.create("bpmn:Property",{name:Dg}),Ae(c,u)),u}function i(a,s){var c=r(a);c&&(n(a,c,s)||Oe(a.get("properties"),c))}function o(a){var s=a.context,c=s.connection,u=c.businessObject,p=c.target,l=p&&p.businessObject,f=s.newTarget,d=f&&f.businessObject,m=s.oldTarget||s.target,g=m&&m.businessObject,v=c.businessObject,w;g&&g!==l&&i(g,u),d&&d!==l&&i(d,u),l?(w=r(l,!0),v.targetRef=w):v.targetRef=null}}ps.$inject=["eventBus","bpmnFactory"];B(ps,k);function kg(e){return function(t){var n=t.context,r=n.connection;if(h(r,"bpmn:DataInputAssociation"))return e(t)}}function $o(e){this._bpmnUpdater=e}$o.$inject=["bpmnUpdater"];$o.prototype.execute=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,r=e.newSemanticParent,i=e.newDiParent;return e.oldSemanticParent=t.$parent,e.oldDiParent=n.$parent,this._bpmnUpdater.updateSemanticParent(t,r),this._bpmnUpdater.updateDiParent(n,i),[]};$o.prototype.revert=function(e){var t=e.dataStoreBo,n=e.dataStoreDi,r=e.oldSemanticParent,i=e.oldDiParent;return this._bpmnUpdater.updateSemanticParent(t,r),this._bpmnUpdater.updateDiParent(n,i),[]};function ls(e,t,n,r){k.call(this,r),t.registerHandler("dataStore.updateContainment",$o);function i(){return n.filter(function(s){return h(s,"bpmn:Participant")&&j(s).processRef})[0]}function o(s){return s.children.filter(function(c){return h(c,"bpmn:DataStoreReference")&&!c.labelTarget})}function a(s,c){var u=s.businessObject||s;if(c=c||i(),c){var p=c.businessObject||c;t.execute("dataStore.updateContainment",{dataStoreBo:u,dataStoreDi:ce(s),newSemanticParent:p.processRef||p,newDiParent:ce(c)})}}this.preExecute("shape.create",function(s){var c=s.context,u=c.shape;h(u,"bpmn:DataStoreReference")&&u.type!=="label"&&(c.hints||(c.hints={}),c.hints.autoResize=!1)}),this.preExecute("elements.move",function(s){var c=s.context,u=c.shapes,p=u.filter(function(l){return h(l,"bpmn:DataStoreReference")});p.length&&(c.hints||(c.hints={}),c.hints.autoResize=u.filter(function(l){return!h(l,"bpmn:DataStoreReference")}))}),this.postExecute("shape.create",function(s){var c=s.context,u=c.shape,p=u.parent;h(u,"bpmn:DataStoreReference")&&u.type!=="label"&&h(p,"bpmn:Collaboration")&&a(u)}),this.postExecute("shape.move",function(s){var c=s.context,u=c.shape,p=c.oldParent,l=u.parent;if(!h(p,"bpmn:Collaboration")&&h(u,"bpmn:DataStoreReference")&&u.type!=="label"&&h(l,"bpmn:Collaboration")){var f=h(p,"bpmn:Participant")?p:UR(p,"bpmn:Participant");a(u,f)}}),this.postExecute("shape.delete",function(s){var c=s.context,u=c.shape,p=e.getRootElement();te(u,["bpmn:Participant","bpmn:SubProcess"])&&h(p,"bpmn:Collaboration")&&o(p).filter(function(l){return WR(l,u)}).forEach(function(l){a(l)})}),this.postExecute("canvas.updateRoot",function(s){var c=s.context,u=c.oldRoot,p=c.newRoot,l=o(u);l.forEach(function(f){h(p,"bpmn:Process")&&a(f,p)})})}ls.$inject=["canvas","commandStack","elementRegistry","eventBus"];B(ls,k);function WR(e,t){for(var n=e.businessObject||e,r=t.businessObject||t;n.$parent;){if(n.$parent===r.processRef||r)return!0;n=n.$parent}return!1}function UR(e,t){for(;e.parent;){if(h(e.parent,t))return e.parent;e=e.parent}}N();var Qu=Math.max,Ju=Math.min,qR=20;function ep(e,t){return{top:e.top-t.top,right:e.right-t.right,bottom:e.bottom-t.bottom,left:e.left-t.left}}function Ng(e,t,n){var r=n.x,i=n.y,o={x:e.x,y:e.y,width:e.width,height:e.height};return t.indexOf("n")!==-1?(o.y=e.y+i,o.height=e.height-i):t.indexOf("s")!==-1&&(o.height=e.height+i),t.indexOf("e")!==-1?o.width=e.width+r:t.indexOf("w")!==-1&&(o.x=e.x+r,o.width=e.width-r),o}function Og(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 Zu(e,t,n){var r=t[e],i=n.min&&n.min[e],o=n.max&&n.max[e];return ne(i)&&(r=(/top|left/.test(e)?Ju:Qu)(r,i)),ne(o)&&(r=(/top|left/.test(e)?Qu:Ju)(r,o)),r}function Bg(e,t){if(!t)return e;var n=Z(e);return Si({top:Zu("top",n,t),right:Zu("right",n,t),bottom:Zu("bottom",n,t),left:Zu("left",n,t)})}function Ig(e,t,n,r){var i=Z(t),o={top:/n/.test(e)?i.bottom-n.height:i.top,left:/w/.test(e)?i.right-n.width:i.left,bottom:/s/.test(e)?i.top+n.height:i.bottom,right:/e/.test(e)?i.left+n.width:i.right},a=r?Z(r):o,s={top:Ju(o.top,a.top),left:Ju(o.left,a.left),bottom:Qu(o.bottom,a.bottom),right:Qu(o.right,a.right)};return Si(s)}function fs(e,t){return typeof e!="undefined"?e:qR}function KR(e,t){var n,r,i,o;return typeof t=="object"?(n=fs(t.left),r=fs(t.right),i=fs(t.top),o=fs(t.bottom)):n=r=i=o=fs(t),{x:e.x-n,y:e.y-i,width:e.width+n+r,height:e.height+i+o}}function YR(e){return!(e.waypoints||e.type==="label")}function tp(e,t){var n;if(e.length===void 0?n=Q(e.children,YR):n=e,n.length)return KR(Ce(n),t)}var si=Math.abs;function XR(e,t){return ep(Z(t),Z(e))}var ZR=["bpmn:Participant","bpmn:Process","bpmn:SubProcess"],on=30;function zo(e,t){return t=t||[],e.children.filter(function(n){h(n,"bpmn:Lane")&&(zo(n,t),t.push(n))}),t}function yn(e){return e.children.filter(function(t){return h(t,"bpmn:Lane")})}function Bt(e){return kr(e,ZR)||e}function Lg(e,t){var n=Bt(e),r=h(n,"bpmn:Process")?[]:[n],i=zo(n,r),o=Z(e),a=Z(t),s=XR(e,t),c=[],u=Me(e);return i.forEach(function(p){if(p!==e){var l=u?0:s.top,f=u?s.right:0,d=u?0:s.bottom,m=u?s.left:0,g=Z(p);s.top&&(si(g.bottom-o.top)<10&&(d=a.top-g.bottom),si(g.top-o.top)<5&&(l=a.top-g.top)),s.left&&(si(g.right-o.left)<10&&(f=a.left-g.right),si(g.left-o.left)<5&&(m=a.left-g.left)),s.bottom&&(si(g.top-o.bottom)<10&&(l=a.bottom-g.top),si(g.bottom-o.bottom)<5&&(d=a.bottom-g.bottom)),s.right&&(si(g.left-o.right)<10&&(m=a.right-g.left),si(g.right-o.right)<5&&(f=a.right-g.right)),(l||f||d||m)&&c.push({shape:p,newBounds:Og(p,{top:l,right:f,bottom:d,left:m})})}}),c}var QR=500;function ds(e,t){k.call(this,e);function n(r,i){var o=Me(r),a=yn(i),s=[],c=[],u=[],p=[];if(In(a,function(v){return o?v.y>r.y?c.push(v):s.push(v):v.x>r.x?p.push(v):u.push(v),v.children}),!!a.length){var l;o?c.length&&s.length?l=r.height/2:l=r.height:p.length&&u.length?l=r.width/2:l=r.width;var f,d,m,g;s.length&&(f=t.calculateAdjustments(s,"y",l,r.y-10),t.makeSpace(f.movingShapes,f.resizingShapes,{x:0,y:l},"s")),c.length&&(d=t.calculateAdjustments(c,"y",-l,r.y+r.height+10),t.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:-l},"n")),u.length&&(m=t.calculateAdjustments(u,"x",l,r.x-10),t.makeSpace(m.movingShapes,m.resizingShapes,{x:l,y:0},"e")),p.length&&(g=t.calculateAdjustments(p,"x",-l,r.x+r.width+10),t.makeSpace(g.movingShapes,g.resizingShapes,{x:-l,y:0},"w"))}}this.postExecuted("shape.delete",QR,function(r){var i=r.context,o=i.hints,a=i.shape,s=i.oldParent;h(a,"bpmn:Lane")&&(o&&o.nested||n(a,s))})}ds.$inject=["eventBus","spaceTool"];B(ds,k);var jg=500;function Go(e,t){t.invoke(k,this),this._bpmnReplace=e;var n=this;this.postExecuted("elements.create",jg,function(r){var i=r.elements;i.filter(function(o){var a=o.host;return Fg(o,a)}).map(function(o){return i.indexOf(o)}).forEach(function(o){r.elements[o]=n._replaceShape(i[o])})},!0),this.preExecute("elements.move",jg,function(r){var i=r.shapes,o=r.newHost;i.forEach(function(a,s){var c=a.host;Fg(a,eP(i,c)?c:o)&&(i[s]=n._replaceShape(a))})},!0)}Go.$inject=["bpmnReplace","injector"];B(Go,k);Go.prototype._replaceShape=function(e){var t=JR(e),n;return t?n={type:"bpmn:IntermediateCatchEvent",eventDefinitionType:t.$type}:n={type:"bpmn:IntermediateThrowEvent"},this._bpmnReplace.replaceElement(e,n,{layoutConnection:!1})};function JR(e){var t=j(e),n=t.eventDefinitions;return n&&n[0]}function Fg(e,t){return!ee(e)&&h(e,"bpmn:BoundaryEvent")&&!t}function eP(e,t){return e.indexOf(t)!==-1}N();function ms(e,t,n){k.call(this,e);function r(i,o,a){var s=o.waypoints,c,u,p,l,f,d,m,g=i.outgoing.slice(),v=i.incoming.slice(),w;ne(a.width)?w=X(a):w=a;var S=Ua(s,w);if(S){if(c=s.slice(0,S.index),u=s.slice(S.index+(S.bendpoint?1:0)),!c.length||!u.length)return;p=S.bendpoint?s[S.index]:w,(c.length===1||!Hg(i,c[c.length-1]))&&c.push($g(p)),(u.length===1||!Hg(i,u[0]))&&u.unshift($g(p))}l=o.source,f=o.target,t.canConnect(l,i,o)&&(n.reconnectEnd(o,i,c||w),d=o),t.canConnect(i,f,o)&&(d?m=n.connect(i,f,{type:o.type,waypoints:u}):(n.reconnectStart(o,i,u||w),m=o));var x=[].concat(d&&Q(v,function(b){return b.source===d.source})||[],m&&Q(g,function(b){return b.target===m.target})||[]);x.length&&n.removeElements(x)}this.preExecute("elements.move",function(i){var o=i.newParent,a=i.shapes,s=i.delta,c=a[0];if(!(!c||!o)){o&&o.waypoints&&(i.newParent=o=o.parent);var u=X(c),p={x:u.x+s.x,y:u.y+s.y},l=re(o.children,function(f){var d=t.canInsert(a,f);return d&&Ua(f.waypoints,p)});l&&(i.targetFlow=l,i.position=p)}},!0),this.postExecuted("elements.move",function(i){var o=i.shapes,a=i.targetFlow,s=i.position;a&&r(o[0],a,s)},!0),this.preExecute("shape.create",function(i){var o=i.parent,a=i.shape;t.canInsert(a,o)&&(i.targetFlow=o,i.parent=o.parent)},!0),this.postExecuted("shape.create",function(i){var o=i.shape,a=i.targetFlow,s=i.position;a&&r(o,a,s)},!0)}B(ms,k);ms.$inject=["eventBus","bpmnRules","modeling"];function Hg(e,t){var n=t.x,r=t.y;return n>=e.x&&n<=e.x+e.width&&r>=e.y&&r<=e.y+e.height}function $g(e){return C({},e)}function hs(e,t){k.call(this,e),this.preExecuted("connection.create",function(n){var r=n.context,i=r.connection,o=r.source,a=r.target,s=r.hints;if(!(s&&s.createElementsBehavior===!1)&&Vo(i)){var c=[];h(o,"bpmn:EventBasedGateway")?c=a.incoming.filter(u=>u!==i&&Vo(u)):c=a.incoming.filter(u=>u!==i&&Vo(u)&&h(u.source,"bpmn:EventBasedGateway")),c.forEach(function(u){t.removeConnection(u)})}}),this.preExecuted("shape.replace",function(n){var r=n.context,i=r.newShape;if(h(i,"bpmn:EventBasedGateway")){var o=i.outgoing.filter(Vo).reduce(function(a,s){return a.includes(s.target)?a:a.concat(s.target)},[]);o.forEach(function(a){a.incoming.filter(Vo).forEach(function(s){let c=a.incoming.filter(Vo).filter(function(u){return u.source===i});(s.source!==i||c.length>1)&&t.removeConnection(s)})})}})}hs.$inject=["eventBus","modeling"];B(hs,k);function Vo(e){return h(e,"bpmn:SequenceFlow")}var np=1500,zg=2e3;function rp(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"],np,function(r){var i=r.context,o=i.shape||r.shape,a=r.hover;h(a,"bpmn:Lane")&&!te(o,["bpmn:Lane","bpmn:Participant"])&&(r.hover=Bt(a),r.hoverGfx=e.getGraphics(r.hover));var s=n.getRootElement();a!==s&&(o.labelTarget||te(o,["bpmn:Group","bpmn:TextAnnotation"]))&&(r.hover=s,r.hoverGfx=e.getGraphics(r.hover))}),t.on(["connect.hover","connect.out","connect.end","connect.cleanup","global-connect.hover","global-connect.out","global-connect.end","global-connect.cleanup"],np,function(r){var i=r.hover;h(i,"bpmn:Lane")&&(r.hover=Bt(i)||i,r.hoverGfx=e.getGraphics(r.hover))}),t.on(["bendpoint.move.hover"],np,function(r){var i=r.context,o=r.hover,a=i.type;h(o,"bpmn:Lane")&&/reconnect/.test(a)&&(r.hover=Bt(o)||o,r.hoverGfx=e.getGraphics(r.hover))}),t.on(["connect.start"],np,function(r){var i=r.context,o=i.start;h(o,"bpmn:Lane")&&(i.start=Bt(o)||o)}),t.on("shape.move.start",zg,function(r){var i=r.shape;h(i,"bpmn:Lane")&&(r.shape=Bt(i)||i)}),t.on("spaceTool.move",zg,function(r){var i=r.hover;i&&h(i,"bpmn:Lane")&&(r.hover=Bt(i))})}rp.$inject=["elementRegistry","eventBus","canvas"];function Gg(e){return e.create("bpmn:Category")}function Vg(e){return e.create("bpmn:CategoryValue")}function Wg(e,t,n){return Ae(t.get("categoryValue"),e),e.$parent=t,Ae(n.get("rootElements"),t),t.$parent=n,e}function Ug(e){var t=e.$parent;return t&&(Oe(t.get("categoryValue"),e),e.$parent=null),e}function qg(e){var t=e.$parent;return t&&(Oe(t.get("rootElements"),e),e.$parent=null),e}var Kg=770;function vs(e,t,n,r,i,o){i.invoke(k,this);function a(){return n.filter(function(m){return h(m,"bpmn:Group")})}function s(m,g){return m.some(function(v){var w=j(v),S=w.categoryValueRef&&w.categoryValueRef.$parent;return S===g})}function c(m,g){return m.some(function(v){var w=j(v);return w.categoryValueRef===g})}function u(m,g,v){var w=a().filter(function(S){return S.businessObject!==v});g&&!s(w,g)&&qg(g),m&&!c(w,m)&&Ug(m)}function p(m,g){return Wg(m,g,t.getDefinitions())}function l(m,g){var v=j(m),w=v.categoryValueRef;w||(w=v.categoryValueRef=g.categoryValue=g.categoryValue||Vg(e));var S=w.$parent;S||(S=w.$parent=g.category=g.category||Gg(e)),p(w,S,t.getDefinitions())}function f(m,g){var v=g.category,w=g.categoryValue,S=j(m);w?(S.categoryValueRef=null,u(w,v,S)):u(null,S.categoryValueRef.$parent,S)}this.execute("label.create",function(m){var g=m.context,v=g.labelTarget;h(v,"bpmn:Group")&&l(v,g)}),this.revert("label.create",function(m){var g=m.context,v=g.labelTarget;h(v,"bpmn:Group")&&f(v,g)}),this.execute("shape.delete",function(m){var g=m.context,v=g.shape,w=j(v);if(!(!h(v,"bpmn:Group")||v.labelTarget)){var S=g.categoryValue=w.categoryValueRef,x;S&&(x=g.category=S.$parent,u(S,x,w),w.categoryValueRef=null)}}),this.reverted("shape.delete",function(m){var g=m.context,v=g.shape;if(!(!h(v,"bpmn:Group")||v.labelTarget)){var w=g.category,S=g.categoryValue,x=j(v);S&&(x.categoryValueRef=S,p(S,w))}}),this.execute("shape.create",function(m){var g=m.context,v=g.shape;!h(v,"bpmn:Group")||v.labelTarget||j(v).categoryValueRef&&l(v,g)}),this.reverted("shape.create",function(m){var g=m.context,v=g.shape;!h(v,"bpmn:Group")||v.labelTarget||j(v).categoryValueRef&&f(v,g)});function d(m,g){var v=e.create(m.$type);return o.copyElement(m,v,null,g)}r.on("copyPaste.copyElement",Kg,function(m){var g=m.descriptor,v=m.element;if(!(!h(v,"bpmn:Group")||v.labelTarget)){var w=j(v);if(w.categoryValueRef){var S=w.categoryValueRef;g.categoryValue=d(S,!0),S.$parent&&(g.category=d(S.$parent,!0))}}}),r.on("copyPaste.pasteElement",Kg,function(m){var g=m.descriptor,v=g.businessObject,w=g.categoryValue,S=g.category;w&&(w=v.categoryValueRef=d(w)),S&&(w.$parent=d(S)),delete g.category,delete g.categoryValue})}vs.$inject=["bpmnFactory","bpmnjs","elementRegistry","eventBus","injector","moddleCopy"];B(vs,k);function Wo(e,t,n,r){var i,o,a,s,c;return i=(r.y-n.y)*(t.x-e.x)-(r.x-n.x)*(t.y-e.y),i==0?null:(o=e.y-n.y,a=e.x-n.x,c=(r.x-n.x)*o-(r.y-n.y)*a,s=c/i,{x:Math.round(e.x+s*(t.x-e.x)),y:Math.round(e.y+s*(t.y-e.y))})}function ip(e){function t(r,i,o){var a={x:o.x,y:o.y-50},s={x:o.x-50,y:o.y},c=Wo(r,i,o,a),u=Wo(r,i,o,s),p;c&&u?Yg(c,o)>Yg(u,o)?p=u:p=c:p=c||u,r.original=p}function n(r){var i=r.waypoints;t(i[0],i[1],X(r.source)),t(i[i.length-1],i[i.length-2],X(r.target))}e.on("bpmnElement.added",function(r){var i=r.element;i.waypoints&&n(i)})}ip.$inject=["eventBus"];function Yg(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function gs(e){k.call(this,e);var t=["bpmn:Participant","bpmn:Lane"];this.executed(["shape.move","shape.create","shape.resize"],function(n){var r=n.context.shape,i=j(r),o=ce(r);if(te(i,t)){var a=o.get("isHorizontal");a===void 0&&(a=!0),o.set("isHorizontal",a)}})}gs.$inject=["eventBus"];B(gs,k);N();var ey=Math.sqrt,ty=Math.min,tP=Math.max,Xg=Math.abs;function Zg(e){return Math.pow(e,2)}function ys(e,t){return ey(Zg(e.x-t.x)+Zg(e.y-t.y))}function ny(e,t){var n=0,r,i,o,a,s,c,u,p,l,f,d;for(n=0;n<t.length-1;n++){if(r=t[n],i=t[n+1],Jg(r,i)?u=[r]:(o=ys(e,r),a=ys(e,i),c=ty(o,a),u=nP(r,i,e,c)),u.length<1)throw new Error("expected between [1, 2] circle -> line intersections");u.length===1&&(p={type:"bendpoint",position:u[0],segmentIndex:n,bendpointIndex:Jg(r,u[0])?n:n+1}),u.length===2&&(s=iP(u[0],u[1]),p={type:"segment",position:s,segmentIndex:n,relativeLocation:ys(r,s)/ys(r,i)}),l=ys(p.position,e),(!d||f>l)&&(d=p,f=l)}return d}function nP(e,t,n,r){var i=t.x-e.x,o=t.y-e.y,a=n.x-e.x,s=n.y-e.y,c=i*i+o*o,u=i*a+o*s,p=a*a+s*s-r*r,l=u/c,f=p/c,d=l*l-f;if(d<0&&d>-1e-6&&(d=0),d<0)return[];var m=ey(d),g=-l+m,v=-l-m,w={x:e.x-i*g,y:e.y-o*g};if(d===0)return[w];var S={x:e.x-i*v,y:e.y-o*v};return[w,S].filter(function(x){return rP(x,e,t)})}function rP(e,t,n){return Qg(e.x,t.x,n.x)&&Qg(e.y,t.y,n.y)}function Qg(e,t,n){return e>=ty(t,n)-op&&e<=tP(t,n)+op}function iP(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}var op=.1;function Jg(e,t){return Xg(e.x-t.x)<=op&&Xg(e.y-t.y)<=op}function iy(e,t,n,r){var i=n.segmentIndex,o=t.length-e.length;if(r.segmentMove){var a=r.segmentMove.segmentStartIndex,s=r.segmentMove.newSegmentStartIndex;return i===a?s:i>=s?i+o<s?s:i+o:i}if(r.bendpointMove){var c=r.bendpointMove.insert,u=r.bendpointMove.bendpointIndex,p;if(o===0)return i;if(i>=u&&(p=c?i+1:i-1),i<u&&(p=i,c&&n.type!=="bendpoint"&&u-1===i)){var l=oy(t,u);l<n.relativeLocation&&p++}return p}return o===0?i:r.connectionStart&&i===0?0:r.connectionEnd&&i===e.length-2?t.length-2:Math.floor((t.length-2)/2)}function ap(e,t,n,r){var i=0,o=0,a={point:e,delta:{x:0,y:0}},s=ny(e,n),c=s.segmentIndex,u=iy(n,t,s,r);if(u<0||u>t.length-2||u===null)return a;var p=ry(n,c),l=ry(t,u),f=s.position,d=aP(p,f),m=oP(p,l);if(s.type==="bendpoint"){var g=t.length-n.length,v=s.bendpointIndex,w=n[v];if(t.indexOf(w)!==-1)return a;if(g===0){var S=t[v];return i=S.x-s.position.x,o=S.y-s.position.y,{delta:{x:i,y:o},point:{x:e.x+i,y:e.y+o}}}g<0&&v!==0&&v<n.length-1&&(d=oy(n,v))}var x={x:(l[1].x-l[0].x)*d+l[0].x,y:(l[1].y-l[0].y)*d+l[0].y},b=ag({x:e.x-f.x,y:e.y-f.y},m);return i=x.x+b.x-e.x,o=x.y+b.y-e.y,{point:Rn(x),delta:Rn({x:i,y:o})}}function oy(e,t){var n=Li(e[t-1],e[t]),r=Li(e[t],e[t+1]),i=n/(n+r);return i}function oP(e,t){var n=Af(e),r=Af(t);return r-n}function ry(e,t){return[e[t],e[t+1]]}function aP(e,t){var n=Li(e[0],e[1]),r=Li(e[0],t);return n===0?0:r/n}function ay(e,t,n,r){var i=X(e);return ap(i,t,n,r).delta}function Hi(e,t,n){var r=So(t),i=So(n),o=Dt(e,r),a={x:o.x*(n.width/t.width),y:o.y*(n.height/t.height)};return Rn({x:i.x+a.x,y:i.y+a.y})}function If(e,t,n){var r=So(e),i=So(t),o=So(n),a=Dt(e,r),s=Dt(r,i),c=sP(r,t,n);if(c)return c;var u={x:s.x*(n.width/t.width),y:s.y*(n.height/t.height)},p={x:o.x+u.x,y:o.y+u.y};return Rn({x:p.x+a.x-e.x,y:p.y+a.y-e.y})}function sP(e,t,n){var r=Z(t),i=Z(n);if(cP(r,i))return null;var o=He(t,e),a,s,c;if(o==="top")a={x:0,y:i.bottom-r.bottom};else if(o==="bottom")a={x:0,y:i.top-r.top};else if(o==="right")a={x:i.left-r.left,y:0};else if(o==="left")a={x:i.right-r.right,y:0};else return null;return s={x:e.x+a.x,y:e.y+a.y},c=He(n,s),c!==o?null:a}function cP(e,t){return uP(e,t)||pP(e,t)}function uP(e,t){return e.right!==t.right&&e.left!==t.left}function pP(e,t){return e.top!==t.top&&e.bottom!==t.bottom}N();var sy="name",cy="text";function _s(e,t,n,r){k.call(this,e),this.postExecute("element.updateProperties",i),this.postExecute("element.updateModdleProperties",a=>{j(a.context.element)===a.context.moddleElement&&i(a)});function i(a){var s=a.context,c=s.element,u=s.properties;if(sy in u&&t.updateLabel(c,u[sy]),cy in u&&h(c,"bpmn:TextAnnotation")){var p=r.getTextAnnotationBounds({x:c.x,y:c.y,width:c.width,height:c.height},u[cy]||"");t.updateLabel(c,u.text,p)}}this.postExecute(["shape.create","connection.create"],function(a){var s=a.context,c=s.hints||{};if(c.createElementsBehavior!==!1){var u=s.shape||s.connection;ee(u)||!mn(u)||gt(u)&&t.updateLabel(u,gt(u))}}),this.postExecute("shape.delete",function(a){var s=a.context,c=s.labelTarget,u=s.hints||{};c&&u.unsetLabel!==!1&&t.updateLabel(c,null,null,{removeShape:!1})});function o(a){var s=a.context,c=s.connection,u=c.label,p=C({},s.hints),l=s.newWaypoints||c.waypoints,f=s.oldWaypoints;return typeof p.startChanged=="undefined"&&(p.startChanged=!!p.connectionStart),typeof p.endChanged=="undefined"&&(p.endChanged=!!p.connectionEnd),ay(u,l,f,p)}this.postExecute(["connection.layout","connection.updateWaypoints"],function(a){var s=a.context,c=s.hints||{};if(c.labelBehavior!==!1){var u=s.connection,p=u.label,l;!p||!p.parent||(l=o(a),t.moveShape(p,l))}}),this.postExecute(["shape.replace"],function(a){var s=a.context,c=s.newShape,u=s.oldShape,p=j(c);p&&mn(p)&&u.label&&c.label&&(c.label.x=u.label.x,c.label.y=u.label.y)}),this.preExecute("shape.resize",function(a){var s=a.context,c=s.shape,u=s.hints||{};if(!(!ee(c)||u.autoResize)){var p=s.newBounds,l=r.getDimensions(gt(c)||"",{box:p,style:r.getExternalStyle()}),f=Math.ceil(l.height),d=p.y!==c.y,m=c.y+c.height;s.newBounds={width:p.width,height:f,x:p.x,y:d?m-f:p.y}}}),this.postExecute("shape.resize",function(a){var s=a.context,c=s.shape,u=s.newBounds,p=s.oldBounds;if(Xr(c)){var l=c.label,f=X(l),d=dP(p),m=fP(f,d),g=lP(m,p,u);t.moveShape(l,g)}})}B(_s,k);_s.$inject=["eventBus","modeling","bpmnFactory","textRenderer"];function lP(e,t,n){var r=Hi(e,t,n);return Rn(Dt(r,e))}function fP(e,t){if(t.length){var n=mP(e,t);return qa(e,n)}}function dP(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 mP(e,t){var n=t.map(function(i){return{line:i,distance:Nu(e,i)}}),r=At(n,"distance");return r[0].line}N();function uy(e,t,n,r){return ap(e,t,n,r).point}function bs(e,t){k.call(this,e);function n(r,i){var o=r.context,a=o.connection,s=C({},o.hints),c=o.newWaypoints||a.waypoints,u=o.oldWaypoints;return typeof s.startChanged=="undefined"&&(s.startChanged=!!s.connectionStart),typeof s.endChanged=="undefined"&&(s.endChanged=!!s.connectionEnd),uy(i,c,u,s)}this.postExecute(["connection.layout","connection.updateWaypoints"],function(r){var i=r.context,o=i.connection,a=o.outgoing,s=o.incoming;s.forEach(function(c){var u=c.waypoints[c.waypoints.length-1],p=n(r,u),l=[].concat(c.waypoints.slice(0,-1),[p]);t.updateWaypoints(c,l)}),a.forEach(function(c){var u=c.waypoints[0],p=n(r,u),l=[].concat([p],c.waypoints.slice(1));t.updateWaypoints(c,l)})}),this.postExecute(["connection.move"],function(r){var i=r.context,o=i.connection,a=o.outgoing,s=o.incoming,c=i.delta;s.forEach(function(u){var p=u.waypoints[u.waypoints.length-1],l={x:p.x+c.x,y:p.y+c.y},f=[].concat(u.waypoints.slice(0,-1),[l]);t.updateWaypoints(u,f)}),a.forEach(function(u){var p=u.waypoints[0],l={x:p.x+c.x,y:p.y+c.y},f=[].concat([l],u.waypoints.slice(1));t.updateWaypoints(u,f)})})}B(bs,k);bs.$inject=["eventBus","modeling"];N();function ci(e,t,n){var r=sp(e),i=ly(r,t),o=r[0];return i.length?i[i.length-1]:Hi(o.original||o,n,t)}function ui(e,t,n){var r=sp(e),i=ly(r,t),o=r[r.length-1];return i.length?i[0]:Hi(o.original||o,n,t)}function Uo(e,t,n){var r=sp(e),i=py(t,n),o=r[0];return Hi(o.original||o,i,t)}function qo(e,t,n){var r=sp(e),i=py(t,n),o=r[r.length-1];return Hi(o.original||o,i,t)}function py(e,t){return{x:e.x-t.x,y:e.y-t.y,width:e.width,height:e.height}}function sp(e){var t=e.waypoints;if(!t.length)throw new Error("connection#"+e.id+": no waypoints");return t}function ly(e,t){var n=je(e,vP);return Q(n,function(r){return hP(r,t)})}function hP(e,t){return He(t,e,1)==="intersect"}function vP(e){return e.original||e}function xs(e,t){k.call(this,e),this.postExecute("shape.replace",function(n){var r=n.oldShape,i=n.newShape;if(gP(r,i)){var o=yP(r);o.incoming.forEach(function(a){var s=ui(a,i,r);t.reconnectEnd(a,i,s)}),o.outgoing.forEach(function(a){var s=ci(a,i,r);t.reconnectStart(a,i,s)})}},!0)}xs.$inject=["eventBus","modeling"];B(xs,k);function gP(e,t){return h(e,"bpmn:Participant")&&ie(e)&&h(t,"bpmn:Participant")&&!ie(t)}function yP(e){var t=Zn([e],!1),n=[],r=[];return t.forEach(function(i){i!==e&&(i.incoming.forEach(function(o){h(o,"bpmn:MessageFlow")&&n.push(o)}),i.outgoing.forEach(function(o){h(o,"bpmn:MessageFlow")&&r.push(o)}))},[]),{incoming:n,outgoing:r}}var _P=["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:EscalationEventDefinition","bpmn:ConditionalEventDefinition","bpmn:SignalEventDefinition"];function cp(e){let t=j(e);if(!h(t,"bpmn:BoundaryEvent")&&!(h(t,"bpmn:StartEvent")&&Qe(t.$parent)))return!1;let n=t.get("eventDefinitions");return!n||!n.length?!1:_P.some(r=>h(n[0],r))}function up(e){return h(e,"bpmn:BoundaryEvent")?"cancelActivity":"isInterrupting"}function Es(e,t){e.invoke(k,this),this.postExecuted("shape.replace",function(n){let r=n.context.oldShape,i=n.context.newShape,o=n.context.hints;if(!cp(i))return;let a=up(i);if(o.targetElement&&o.targetElement[a]!==void 0)return;let c=j(r).get(a),u=j(i).get(a);c!==u&&t.updateProperties(i,{[a]:c})})}Es.$inject=["injector","modeling"];B(Es,k);function ws(e,t){k.call(this,e),this.preExecute("shape.resize",function(n){var r=n.shape,i=ce(r),o=i&&i.get("label"),a=o&&o.get("bounds");a&&t.updateModdleProperties(r,o,{bounds:void 0})},!0)}B(ws,k);ws.$inject=["eventBus","modeling"];function Ss(e,t,n){k.call(this,e),this.preExecute("shape.delete",function(r){var i=r.context.shape;if(!(i.incoming.length!==1||i.outgoing.length!==1)){var o=i.incoming[0],a=i.outgoing[0];if(!(!h(o,"bpmn:SequenceFlow")||!h(a,"bpmn:SequenceFlow"))&&t.canConnect(o.source,a.target,o)){var s=bP(o.waypoints,a.waypoints);n.reconnectEnd(o,a.target,s)}}})}B(Ss,k);Ss.$inject=["eventBus","bpmnRules","modeling"];function Ko(e){return e.original||e}function bP(e,t){var n=Wo(Ko(e[e.length-2]),Ko(e[e.length-1]),Ko(t[1]),Ko(t[0]));return n?[].concat(e.slice(0,e.length-1),[n],t.slice(1)):[Ko(e[0]),Ko(t[t.length-1])]}function Cs(e,t){k.call(this,e),this.preExecute("shape.delete",function(n){var r=n.shape,i=r.parent;h(r,"bpmn:Participant")&&(n.collaborationRoot=i)},!0),this.postExecute("shape.delete",function(n){var r=n.collaborationRoot;if(r&&!r.businessObject.participants.length){var i=t.makeProcess(),o=r.children.slice();t.moveElements(o,{x:0,y:0},i)}},!0)}Cs.$inject=["eventBus","modeling"];B(Cs,k);N();function Rs(e,t,n,r){k.call(this,e);var i=r.get("dragging",!1);function o(c){var u=c.source,p=c.target,l=c.parent;if(l){var f,d;h(c,"bpmn:SequenceFlow")&&(n.canConnectSequenceFlow(u,p)||(d=!0),n.canConnectMessageFlow(u,p)&&(f="bpmn:MessageFlow")),h(c,"bpmn:MessageFlow")&&(n.canConnectMessageFlow(u,p)||(d=!0),n.canConnectSequenceFlow(u,p)&&(f="bpmn:SequenceFlow")),d&&t.removeConnection(c),f&&t.connect(u,p,{type:f,waypoints:c.waypoints.slice()})}}function a(c){var u=c.context,p=u.connection,l=u.newSource||p.source,f=u.newTarget||p.target,d,m;d=n.canConnect(l,f),!(!d||d.type===p.type)&&(m=t.connect(l,f,{type:d.type,associationDirection:d.associationDirection,waypoints:p.waypoints.slice()}),p.parent&&t.removeConnection(p),u.connection=m,i&&s(p,m))}function s(c,u){var p=i.context(),l=p&&p.payload.previousSelection,f;!l||!l.length||(f=l.indexOf(c),f!==-1&&l.splice(f,1,u))}this.postExecuted("elements.move",function(c){var u=c.closure,p=u.allConnections;E(p,o)},!0),this.preExecute("connection.reconnect",a),this.postExecuted("element.updateProperties",function(c){var u=c.context,p=u.properties,l=u.element,f=l.businessObject,d;p.default&&(d=re(l.outgoing,Ct({id:l.businessObject.default.id})),d&&t.updateProperties(d,{conditionExpression:void 0})),p.conditionExpression&&f.sourceRef.default===f&&t.updateProperties(l.source,{default:void 0})})}B(Rs,k);Rs.$inject=["eventBus","modeling","bpmnRules","injector"];N();function Yo(e,t,n,r,i,o){r.invoke(k,this),this._bpmnReplace=e,this._elementRegistry=n,this._selection=o,this.postExecuted(["elements.create"],500,function(a){var s=a.context,c=s.parent,u=s.elements,p=Ge(u,function(l,f){var d=t.canReplace([f],f.host||f.parent||c);return d?l.concat(d.replacements):l},[]);p.length&&this._replaceElements(u,p)},this),this.postExecuted(["elements.move"],500,function(a){var s=a.context,c=s.newParent,u=s.newHost,p=[];E(s.closure.topLevel,function(f){Qe(f)?p=p.concat(f.children):p=p.concat(f)}),p.length===1&&u&&(c=u);var l=t.canReplace(p,c);l&&this._replaceElements(p,l.replacements,u)},this),this.postExecute(["shape.replace"],1500,function(a){var s=a.context,c=s.oldShape,u=s.newShape,p=c.attachers,l;p&&p.length&&(l=t.canReplace(p,u),this._replaceElements(p,l.replacements))},this),this.postExecuted(["shape.replace"],1500,function(a){var s=a.context,c=s.oldShape,u=s.newShape;i.unclaimId(c.businessObject.id,c.businessObject),i.updateProperties(u,{id:c.id})})}B(Yo,k);Yo.prototype._replaceElements=function(e,t){var n=this._elementRegistry,r=this._bpmnReplace,i=this._selection;E(t,function(o){var a={type:o.newElementType},s=n.get(o.oldElementId),c=e.indexOf(s);e[c]=r.replaceElement(s,a,{select:!1})}),t&&i.select(e)};Yo.$inject=["bpmnReplace","bpmnRules","elementRegistry","injector","modeling","selection"];var xP=1500,fy={width:140,height:120},pp={width:300,height:60},lp={width:60,height:300},Ps={width:300,height:150},As={width:150,height:300},Lf={width:140,height:120},jf={width:100,height:40};function fp(e){e.on("resize.start",xP,function(t){var n=t.context,r=n.shape,i=n.direction,o=n.balanced;(h(r,"bpmn:Lane")||h(r,"bpmn:Participant"))&&(n.resizeConstraints=RP(r,i,o)),h(r,"bpmn:SubProcess")&&ie(r)&&(n.minDimensions=Lf),h(r,"bpmn:TextAnnotation")&&(n.minDimensions=jf)})}fp.$inject=["eventBus"];var pi=Math.abs,EP=Math.min,wP=Math.max;function dy(e,t,n,r){var i=e[t];e[t]=i===void 0?n:r(n,i)}function Xo(e,t,n){return dy(e,t,n,EP)}function Zo(e,t,n){return dy(e,t,n,wP)}var SP={top:20,left:50,right:20,bottom:20},CP={top:50,left:20,right:20,bottom:20};function RP(e,t,n){var r=Bt(e),i=!0,o=!0,a=zo(r,[r]),s=Z(e),c={},u={},p=Me(e),l=p?pp:lp;/n/.test(t)?u.top=s.bottom-l.height:/e/.test(t)?u.right=s.left+l.width:/s/.test(t)?u.bottom=s.top+l.height:/w/.test(t)&&(u.left=s.right-l.width),a.forEach(function(m){var g=Z(m);p?(g.top<s.top-10&&(i=!1),g.bottom>s.bottom+10&&(o=!1)):(g.left<s.left-10&&(i=!1),g.right>s.right+10&&(o=!1)),/n/.test(t)&&(n&&pi(s.top-g.bottom)<10&&Zo(c,"top",g.top+l.height),pi(s.top-g.top)<5&&Xo(u,"top",g.bottom-l.height)),/e/.test(t)&&(n&&pi(s.right-g.left)<10&&Xo(c,"right",g.right-l.width),pi(s.right-g.right)<5&&Zo(u,"right",g.left+l.width)),/s/.test(t)&&(n&&pi(s.bottom-g.top)<10&&Xo(c,"bottom",g.bottom-l.height),pi(s.bottom-g.bottom)<5&&Zo(u,"bottom",g.top+l.height)),/w/.test(t)&&(n&&pi(s.left-g.right)<10&&Zo(c,"left",g.left+l.width),pi(s.left-g.left)<5&&Xo(u,"left",g.right-l.width))});var f=r.children.filter(function(m){return!m.hidden&&!m.waypoints&&(h(m,"bpmn:FlowElement")||h(m,"bpmn:Artifact"))}),d=p?SP:CP;return f.forEach(function(m){var g=Z(m);/n/.test(t)&&(!p||i)&&Xo(u,"top",g.top-d.top),/e/.test(t)&&(p||o)&&Zo(u,"right",g.right+d.right),/s/.test(t)&&(!p||o)&&Zo(u,"bottom",g.bottom+d.bottom),/w/.test(t)&&(p||i)&&Xo(u,"left",g.left-d.left)}),{min:u,max:c}}var my=1001;function dp(e,t){e.on("resize.start",my+500,function(n){var r=n.context,i=r.shape;(h(i,"bpmn:Lane")||h(i,"bpmn:Participant"))&&(r.balanced=!Tr(n))}),e.on("resize.end",my,function(n){var r=n.context,i=r.shape,o=r.canExecute,a=r.newBounds;if(h(i,"bpmn:Lane")||h(i,"bpmn:Participant"))return o&&(a=wc(a),t.resizeLane(i,a,r.balanced)),!1})}dp.$inject=["eventBus","modeling"];N();var PP=500;function Ts(e,t,n,r,i){n.invoke(k,this);function o(p){return te(p,["bpmn:ReceiveTask","bpmn:SendTask"])||AP(p,["bpmn:ErrorEventDefinition","bpmn:EscalationEventDefinition","bpmn:MessageEventDefinition","bpmn:SignalEventDefinition"])}function a(p){var l=e.getDefinitions(),f=l.get("rootElements");return!!re(f,Ct({id:p.id}))}function s(p){if(h(p,"bpmn:ErrorEventDefinition"))return"errorRef";if(h(p,"bpmn:EscalationEventDefinition"))return"escalationRef";if(h(p,"bpmn:MessageEventDefinition"))return"messageRef";if(h(p,"bpmn:SignalEventDefinition"))return"signalRef"}function c(p){if(te(p,["bpmn:ReceiveTask","bpmn:SendTask"]))return p.get("messageRef");var l=p.get("eventDefinitions"),f=l[0];return f.get(s(f))}function u(p,l){if(te(p,["bpmn:ReceiveTask","bpmn:SendTask"]))return p.set("messageRef",l);var f=p.get("eventDefinitions"),d=f[0];return d.set(s(d),l)}this.executed(["shape.create","element.updateProperties","element.updateModdleProperties"],function(p){var l=p.shape||p.element;if(o(l)){var f=j(l),d=c(f),m;d&&!a(d)&&(m=e.getDefinitions().get("rootElements"),Ae(m,d),p.addedRootElement=d)}},!0),this.reverted(["shape.create","element.updateProperties","element.updateModdleProperties"],function(p){var l=p.addedRootElement;if(l){var f=e.getDefinitions().get("rootElements");Oe(f,l)}},!0),t.on("copyPaste.copyElement",function(p){var l=p.descriptor,f=p.element;if(!(f.labelTarget||!o(f))){var d=j(f),m=c(d);m&&(l.referencedRootElement=m)}}),t.on("copyPaste.pasteElement",PP,function(p){var l=p.descriptor,f=l.businessObject,d=l.referencedRootElement;d&&(a(d)||(d=r.copyElement(d,i.create(d.$type))),u(f,d),delete l.referencedRootElement)})}Ts.$inject=["bpmnjs","eventBus","injector","moddleCopy","bpmnFactory"];B(Ts,k);function AP(e,t){return q(t)||(t=[t]),Lt(t,function(n){return Er(e,n)})}N();var hy=Math.max;function mp(e){e.on("spaceTool.getMinDimensions",function(t){var n=t.shapes,r=t.axis,i=t.start,o={};return E(n,function(a){var s=a.id;h(a,"bpmn:Participant")&&(o[s]=MP(a,r,i)),h(a,"bpmn:Lane")&&(o[s]=Me(a)?pp:lp),h(a,"bpmn:SubProcess")&&ie(a)&&(o[s]=Lf),h(a,"bpmn:TextAnnotation")&&(o[s]=jf),h(a,"bpmn:Group")&&(o[s]=fy)}),o})}mp.$inject=["eventBus"];function TP(e){return e==="x"}function MP(e,t,n){var r=Me(e);if(!NP(e))return r?Ps:As;var i=TP(t),o={};return i?r?o=Ps:o={width:kP(e,n,i),height:As.height}:r?o={width:Ps.width,height:DP(e,n,i)}:o=As,o}function DP(e,t,n){var r;return r=OP(e,t,n),hy(Ps.height,r)}function kP(e,t,n){var r;return r=BP(e,t,n),hy(As.width,r)}function NP(e){return!!yn(e).length}function OP(e,t,n){var r=yn(e),i;return i=Ff(r,t,n),e.height-i.height+pp.height}function BP(e,t,n){var r=yn(e),i;return i=Ff(r,t,n),e.width-i.width+lp.width}function Ff(e,t,n){var r,i,o;for(r=0;r<e.length;r++)if(i=e[r],!n&&t>=i.y&&t<=i.y+i.height||n&&t>=i.x&&t<=i.x+i.width)return o=yn(i),o.length?Ff(o,t,n):i}N();var vy=400,IP=600,gy={x:180,y:160};function Vn(e,t,n,r,i,o,a){k.call(this,t),this._canvas=e,this._eventBus=t,this._modeling=n,this._elementFactory=r,this._bpmnFactory=i,this._bpmnjs=o,this._elementRegistry=a;var s=this;function c(l){return h(l,"bpmn:SubProcess")&&!ie(l)}function u(l){var f=l.shape,d=l.newRootElement,m=j(f);d=s._addDiagram(d||m),l.newRootElement=e.addRootElement(d)}function p(l){var f=l.shape,d=j(f);s._removeDiagram(d);var m=l.newRootElement=a.get(vn(d));e.removeRootElement(m)}this.executed("shape.create",function(l){var f=l.shape;c(f)&&u(l)},!0),this.postExecuted("elements.create",function(l){var f=l.elements;E(f,function(d){if(c(d)){var m=a.get(vn(d));if(!(!m||!d.children||!d.children.length)){var g=yy(d);s._showRecursively(g),s._moveChildrenToShape(g,m)}}})},!0),this.reverted("shape.create",function(l){var f=l.shape;c(f)&&p(l)},!0),this.preExecute("shape.delete",function(l){var f=l.shape;!h(f,"bpmn:SubProcess")||!ie(f)||E(Ti([f]),d=>{n.removeShape(d.annotation)})},!0),this.preExecuted("shape.delete",function(l){var f=l.shape;if(c(f)){var d=a.get(vn(f));d&&n.removeElements(d.children.slice())}},!0),this.executed("shape.delete",function(l){var f=l.shape;c(f)&&p(l)},!0),this.reverted("shape.delete",function(l){var f=l.shape;c(f)&&u(l)},!0),this.preExecuted("shape.replace",function(l){var f=l.oldShape,d=l.newShape;!c(f)||!c(d)||(l.oldRoot=e.removeRootElement(vn(f)))},!0),this.postExecuted("shape.replace",function(l){var f=l.newShape,d=l.oldRoot,m=e.findRoot(vn(f));if(!(!d||!m)){var g=d.children;n.moveElements(g,{x:0,y:0},m)}},!0),this.executed("element.updateProperties",function(l){var f=l.element;if(h(f,"bpmn:SubProcess")){var d=l.properties,m=l.oldProperties,g=m.id,v=d.id;if(g!==v){if(Eo(f)){a.updateId(f,Jr(v)),a.updateId(g,v);return}var w=a.get(Jr(g));w&&a.updateId(Jr(g),Jr(v))}}},!0),this.reverted("element.updateProperties",function(l){var f=l.element;if(h(f,"bpmn:SubProcess")){var d=l.properties,m=l.oldProperties,g=m.id,v=d.id;if(g!==v){if(Eo(f)){a.updateId(f,Jr(g)),a.updateId(v,g);return}var w=a.get(Jr(v));w&&a.updateId(w,Jr(g))}}},!0),t.on("element.changed",function(l){var f=l.element;if(Eo(f)){var d=f,m=a.get(rf(d));!m||m===d||t.fire("element.changed",{element:m})}}),this.executed("shape.toggleCollapse",vy,function(l){var f=l.shape;h(f,"bpmn:SubProcess")&&(ie(f)?p(l):(u(l),s._showRecursively(f.children)))},!0),this.reverted("shape.toggleCollapse",vy,function(l){var f=l.shape;h(f,"bpmn:SubProcess")&&(ie(f)?p(l):(u(l),s._showRecursively(f.children)))},!0),this.postExecuted("shape.toggleCollapse",IP,function(l){var f=l.shape;if(h(f,"bpmn:SubProcess")){var d=l.newRootElement;if(d)if(ie(f))s._moveChildrenToShape(d.children.slice(),f),E(Ti(f.children),g=>{n.moveShape(g.annotation,{x:0,y:0},f.parent),E(g.associations,v=>{n.moveConnection(v,{x:0,y:0},f.parent)})});else{s._disconnectSharedAnnotations(f);var m=yy(f);s._moveChildrenToShape(m,d)}}},!0),t.on("copyPaste.createTree",function(l){var f=l.element,d=l.children;if(c(f)){var m=vn(f),g=a.get(m);g&&d.push.apply(d,g.children)}}),t.on("copyPaste.copyElement",function(l){var f=l.descriptor,d=l.element,m=l.elements,g=d.parent,v=h(ce(g),"bpmndi:BPMNPlane");if(v){var w=rf(g),S=re(m,function(x){return x.id===w});S&&(f.parent=S.id)}}),t.on("copyPaste.pasteElement",function(l){var f=l.descriptor;f.parent&&(c(f.parent)||f.parent.hidden)&&(f.hidden=!0)})}B(Vn,k);Vn.prototype._moveChildrenToShape=function(e,t){var n=this._modeling;if(e.length){var r=e.filter(function(c){return!c.hidden});if(!r.length){n.moveElements(e,{x:0,y:0},t,{autoResize:!1});return}var i=Ce(r),o;if(!t.x)o={x:gy.x-i.x,y:gy.y-i.y};else{var a=X(t),s=X(i);o={x:a.x-s.x,y:a.y-s.y}}n.moveElements(e,o,t,{autoResize:!1})}};Vn.prototype._disconnectSharedAnnotations=function(e){var t=this._modeling,n=new Set(Jl(e).map(r=>r.annotation));n.size&&E(Ti(e.children),r=>{n.has(r.annotation)&&E(r.associations,i=>{t.removeConnection(i)})})};Vn.prototype._showRecursively=function(e,t){var n=this,r=[];return e.forEach(function(i){i.hidden=!!t,r=r.concat(i),i.children&&(r=r.concat(n._showRecursively(i.children,i.collapsed||t)))}),r};Vn.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};Vn.prototype._createNewDiagram=function(e){var t=this._bpmnFactory,n=this._elementFactory,r=t.create("bpmndi:BPMNPlane",{bpmnElement:e}),i=t.create("bpmndi:BPMNDiagram",{plane:r});r.$parent=i;var o=n.createRoot({id:vn(e),type:e.$type,di:r,businessObject:e,collapsed:!0});return o};Vn.prototype._removeDiagram=function(e){var t=this._bpmnjs,n=t.getDefinitions().diagrams,r=re(n,function(i){return i.plane.bpmnElement.id===e.id});return n.splice(n.indexOf(r),1),r};Vn.$inject=["canvas","eventBus","modeling","elementFactory","bpmnFactory","bpmnjs","elementRegistry"];function LP(e){var t=[];return E(Ti(e),n=>{t.push(n.annotation),t.push.apply(t,n.associations)}),t}function yy(e){return e.children.slice().concat(LP(e.children)).concat(jP(e))}function jP(e){return Ta(e.children||[],!0,-1).reduce(function(t,n){return n.label&&n.label.parent!==e&&t.push(n.label),t},[])}function Ms(e,t){e.invoke(k,this),this.postExecuted("shape.replace",function(n){var r=n.context.oldShape,i=n.context.newShape;if(!(!h(i,"bpmn:SubProcess")||h(i,"bpmn:AdHocSubProcess")||!(h(r,"bpmn:Task")||h(r,"bpmn:CallActivity"))||!ie(i))){var o=FP(i);t.createShape({type:"bpmn:StartEvent"},o,i)}})}Ms.$inject=["injector","modeling"];B(Ms,k);function FP(e){return{x:e.x+e.width/6,y:e.y+e.height/2}}function Ds(e,t){k.call(this,e),this.preExecute("connection.create",function(n){let{target:r}=n;h(r,"bpmn:TextAnnotation")&&(n.parent=r.parent)},!0),this.preExecute(["shape.create","shape.resize","elements.move"],function(n){let r=n.shapes||[n.shape];r.length===1&&h(r[0],"bpmn:TextAnnotation")&&(n.hints=n.hints||{},n.hints.autoResize=!1)},!0),this.preExecute("shape.resize",function(n){var r=n.context,i=r.shape,o=r.hints||{};if(!(!h(i,"bpmn:TextAnnotation")||o.autoResize)){var a=r.newBounds,s=t.getTextAnnotationBounds(a,gt(i)||""),c=a.y!==i.y&&Math.abs(a.y+a.height-(i.y+i.height))<=1,u=i.y+i.height;r.newBounds={width:a.width,height:s.height,x:a.x,y:c?u-s.height:a.y}}})}B(Ds,k);Ds.$inject=["eventBus","textRenderer"];N();function ks(e,t){k.call(this,e),this.postExecuted("shape.toggleCollapse",1500,function(n){var r=n.shape;if(ie(r))return;var i=Zn(r);i.forEach(function(a){var s=a.incoming.slice(),c=a.outgoing.slice();E(s,function(u){o(u,!0)}),E(c,function(u){o(u,!1)})});function o(a,s){i.indexOf(a.source)!==-1&&i.indexOf(a.target)!==-1||h(a,"bpmn:Association")&&(h(a.source,"bpmn:TextAnnotation")||h(a.target,"bpmn:TextAnnotation"))||(s?t.reconnectEnd(a,r,X(r)):t.reconnectStart(a,r,X(r)))}},!0)}B(ks,k);ks.$inject=["eventBus","modeling"];var Hf=500;function Ns(e,t,n){k.call(this,e);function r(a){a.length&&a.forEach(function(s){s.type==="label"&&!s.businessObject.name&&(s.hidden=!0)})}function i(a,s){var c=a.children,u=s,p,l;return p=HP(c).concat([a]),l=tp(p),l?(u.width=Math.max(l.width,u.width),u.height=Math.max(l.height,u.height),u.x=l.x+(l.width-u.width)/2,u.y=l.y+(l.height-u.height)/2):(u.x=a.x+(a.width-u.width)/2,u.y=a.y+(a.height-u.height)/2),u}function o(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"],Hf,function(a){var s=a.context,c=s.shape;h(c,"bpmn:SubProcess")&&(c.collapsed?ce(c).isExpanded=!1:(r(c.children),ce(c).isExpanded=!0))}),this.reverted(["shape.toggleCollapse"],Hf,function(a){var s=a.context,c=s.shape;c.collapsed?ce(c).isExpanded=!1:ce(c).isExpanded=!0}),this.postExecuted(["shape.toggleCollapse"],Hf,function(a){var s=a.context.shape,c=t.getDefaultSize(s),u;s.collapsed?u=o(s,c):u=i(s,c),n.resizeShape(s,u,null,{autoResize:s.collapsed?!1:"nwse"})})}B(Ns,k);Ns.$inject=["eventBus","elementFactory","modeling"];function HP(e){return e.filter(function(t){return!t.hidden})}function Os(e,t,n,r){t.invoke(k,this),this.preExecute("shape.delete",function(i){var o=i.context,a=o.shape,s=a.businessObject;ee(a)||(h(a,"bpmn:Participant")&&ie(a)&&n.ids.unclaim(s.processRef.id),r.unclaimId(s.id,s))}),this.preExecute("connection.delete",function(i){var o=i.context,a=o.connection,s=a.businessObject;r.unclaimId(s.id,s)}),this.preExecute("canvas.updateRoot",function(){var i=e.getRootElement(),o=i.businessObject;h(i,"bpmn:Collaboration")&&n.ids.unclaim(o.id)})}B(Os,k);Os.$inject=["canvas","injector","moddle","modeling"];function Bs(e,t){k.call(this,e),this.preExecute("connection.delete",function(n){var r=n.context,i=r.connection,o=i.source;$P(i,o)&&t.updateProperties(o,{default:null})})}B(Bs,k);Bs.$inject=["eventBus","modeling"];function $P(e,t){if(!h(e,"bpmn:SequenceFlow"))return!1;var n=j(t),r=j(e);return n.get("default")===r}var zP=500,GP=5e3;function Is(e,t){k.call(this,e);var n;function r(){return n=n||new VP,n.enter(),n}function i(){if(!n)throw new Error("out of bounds release");return n}function o(){if(!n)throw new Error("out of bounds release");var s=n.leave();return s&&(t.updateLaneRefs(n.flowNodes,n.lanes),n=null),s}var a=["spaceTool","lane.add","lane.resize","lane.split","elements.create","elements.delete","elements.move","shape.create","shape.delete","shape.move","shape.resize"];this.preExecute(a,GP,function(s){r()}),this.postExecuted(a,zP,function(s){o()}),this.preExecute(["shape.create","shape.move","shape.delete","shape.resize"],function(s){var c=s.context,u=c.shape,p=i();u.labelTarget||(h(u,"bpmn:Lane")&&p.addLane(u),h(u,"bpmn:FlowNode")&&p.addFlowNode(u))})}Is.$inject=["eventBus","modeling"];B(Is,k);function VP(){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}}function Ls(e,t){k.call(this,e),this.postExecuted("elements.create",function(n){let r=n.context,i=r.elements;for(let o of i)WP(o)&&!qP(o)&&t.updateProperties(o,{isForCompensation:void 0})})}B(Ls,k);Ls.$inject=["eventBus","modeling"];function WP(e){let t=j(e);return t&&t.isForCompensation}function UP(e){return e&&h(e,"bpmn:BoundaryEvent")&&Er(e,"bpmn:CompensateEventDefinition")}function qP(e){return e.incoming.filter(n=>UP(n.source)).length>0}var _y={__init__:["adaptiveLabelPositioningBehavior","appendBehavior","artifactBehavior","associationBehavior","attachEventBehavior","boundaryEventBehavior","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","unsetDefaultFlowBehavior","setCompensationActivityAfterPasteBehavior"],adaptiveLabelPositioningBehavior:["type",es],appendBehavior:["type",ts],associationBehavior:["type",rs],attachEventBehavior:["type",Fo],artifactBehavior:["type",ns],boundaryEventBehavior:["type",is],compensateBoundaryEventBehaviour:["type",as],createBehavior:["type",ss],createDataObjectBehavior:["type",cs],createParticipantBehavior:["type",us],dataInputAssociationBehavior:["type",ps],dataStoreBehavior:["type",ls],deleteLaneBehavior:["type",ds],detachEventBehavior:["type",Go],dropOnFlowBehavior:["type",ms],eventBasedGatewayBehavior:["type",hs],fixHoverBehavior:["type",rp],groupBehavior:["type",vs],importDockingFix:["type",ip],isHorizontalFix:["type",gs],labelBehavior:["type",_s],layoutConnectionBehavior:["type",bs],messageFlowBehavior:["type",xs],nonInterruptingBehavior:["type",Es],removeElementBehavior:["type",Ss],removeEmbeddedLabelBoundsBehavior:["type",ws],removeParticipantBehavior:["type",Cs],replaceConnectionBehavior:["type",Rs],replaceElementBehaviour:["type",Yo],resizeBehavior:["type",fp],resizeLaneBehavior:["type",dp],rootElementReferenceBehavior:["type",Ts],spaceToolBehavior:["type",mp],subProcessPlaneBehavior:["type",Vn],subProcessStartEventBehavior:["type",Ms],textAnnotationBehavior:["type",Ds],toggleCollapseConnectionBehaviour:["type",ks],toggleElementCollapseBehaviour:["type",Ns],unclaimIdBehavior:["type",Os],unsetDefaultFlowBehavior:["type",Bs],updateFlowNodeRefsBehavior:["type",Is],setCompensationActivityAfterPasteBehavior:["type",Ls]};N();function hp(e,t){var n=He(e,t,-15);return n!=="intersect"?n:null}function wt(e){Ot.call(this,e)}B(wt,Ot);wt.$inject=["eventBus"];wt.prototype.init=function(){this.addRule("connection.start",function(e){var t=e.source;return KP(t)}),this.addRule("connection.create",function(e){var t=e.source,n=e.target,r=e.hints||{},i=r.targetParent,o=r.targetAttach;if(o)return!1;i&&(n.parent=i);try{return vp(t,n)}finally{i&&(n.parent=null)}}),this.addRule("connection.reconnect",function(e){var t=e.connection,n=e.source,r=e.target;return vp(n,r,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,r=e.direction;return Ny(t,n,r)}),this.addRule("elements.create",function(e){var t=e.elements,n=e.position,r=e.target;return de(r)&&!gp(t,r,n)?!1:ln(t,function(i){return de(i)?vp(i.source,i.target,i):i.host?js(i,i.host,null,n):Gf(i,r,null,n)})}),this.addRule("elements.move",function(e){var t=e.target,n=e.shapes,r=e.position,i=e.hints;return i!=null&&i.keyboardMove&&n.some(function(a){return Py(a)&&!n.includes(a.host)})?!1:js(n,t,null,r)||Dy(n,t,r)||ky(n,t,r)||gp(n,t,r)}),this.addRule("shape.create",function(e){return Gf(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 jy(n,t)})};wt.prototype.canConnectMessageFlow=Iy;wt.prototype.canConnectSequenceFlow=Ly;wt.prototype.canConnectDataAssociation=Wf;wt.prototype.canConnectAssociation=Oy;wt.prototype.canConnectCompensationAssociation=By;wt.prototype.canMove=ky;wt.prototype.canAttach=js;wt.prototype.canReplace=Dy;wt.prototype.canDrop=Qo;wt.prototype.canInsert=gp;wt.prototype.canCreate=Gf;wt.prototype.canConnect=vp;wt.prototype.canResize=Ny;wt.prototype.canCopy=jy;function KP(e){return $f(e)?null:te(e,["bpmn:FlowNode","bpmn:InteractionNode","bpmn:DataObjectReference","bpmn:DataStoreReference","bpmn:Group","bpmn:TextAnnotation"])}function $f(e){return!e||ee(e)}function by(e){do{if(h(e,"bpmn:Process"))return j(e);if(h(e,"bpmn:Participant"))return j(e).processRef||j(e)}while(e=e.parent)}function zf(e){return h(e,"bpmn:TextAnnotation")}function Vf(e){return h(e,"bpmn:Group")&&!e.labelTarget}function Sy(e){return h(e,"bpmn:BoundaryEvent")&&ur(e,"bpmn:CompensateEventDefinition")}function yp(e){return j(e).isForCompensation}function YP(e,t){var n=by(e),r=by(t);return n===r}function XP(e){return h(e,"bpmn:InteractionNode")&&!h(e,"bpmn:BoundaryEvent")&&(!h(e,"bpmn:Event")||h(e,"bpmn:ThrowEvent")&&Ry(e,"bpmn:MessageEventDefinition"))}function ZP(e){return h(e,"bpmn:InteractionNode")&&!yp(e)&&(!h(e,"bpmn:Event")||h(e,"bpmn:CatchEvent")&&Ry(e,"bpmn:MessageEventDefinition"))&&!(h(e,"bpmn:BoundaryEvent")&&!ur(e,"bpmn:MessageEventDefinition"))}function xy(e){for(var t=e;t=t.parent;){if(h(t,"bpmn:FlowElementsContainer"))return j(t);if(h(t,"bpmn:Participant"))return j(t).processRef}return null}function Cy(e,t){var n=xy(e),r=xy(t);return n===r}function ur(e,t){var n=j(e);return!!re(n.eventDefinitions||[],function(r){return h(r,t)})}function Ry(e,t){var n=j(e);return(n.eventDefinitions||[]).every(function(r){return h(r,t)})}function QP(e){return h(e,"bpmn:FlowNode")&&!h(e,"bpmn:EndEvent")&&!Qe(e)&&!(h(e,"bpmn:IntermediateThrowEvent")&&ur(e,"bpmn:LinkEventDefinition"))&&!Sy(e)&&!yp(e)}function JP(e){return h(e,"bpmn:FlowNode")&&!h(e,"bpmn:StartEvent")&&!h(e,"bpmn:BoundaryEvent")&&!Qe(e)&&!(h(e,"bpmn:IntermediateCatchEvent")&&ur(e,"bpmn:LinkEventDefinition"))&&!yp(e)}function eA(e){return h(e,"bpmn:ReceiveTask")||h(e,"bpmn:IntermediateCatchEvent")&&(ur(e,"bpmn:MessageEventDefinition")||ur(e,"bpmn:TimerEventDefinition")||ur(e,"bpmn:ConditionalEventDefinition")||ur(e,"bpmn:SignalEventDefinition"))}function tA(e){for(var t=[];e;)e=e.parent,e&&t.push(e);return t}function Ey(e,t){var n=tA(t);return n.indexOf(e)!==-1}function vp(e,t,n){if($f(e)||$f(t))return null;if(!h(n,"bpmn:DataAssociation")){if(Iy(e,t))return{type:"bpmn:MessageFlow"};if(Ly(e,t))return{type:"bpmn:SequenceFlow"}}var r=Wf(e,t);return r||(By(e,t)?{type:"bpmn:Association",associationDirection:"One"}:Oy(e,t)?{type:"bpmn:Association",associationDirection:"None"}:!1)}function Qo(e,t){return ee(e)||Vf(e)?!0:h(t,"bpmn:Participant")&&!ie(t)?!1:h(e,"bpmn:Participant")?h(t,"bpmn:Process")||h(t,"bpmn:Collaboration"):te(e,["bpmn:DataInput","bpmn:DataOutput"])&&e.parent?t===e.parent:h(e,"bpmn:Lane")?h(t,"bpmn:Participant")||h(t,"bpmn:Lane"):h(e,"bpmn:BoundaryEvent")&&!nA(e)?!1:h(e,"bpmn:FlowElement")&&!h(e,"bpmn:DataStoreReference")?h(t,"bpmn:FlowElementsContainer")?ie(t):te(t,["bpmn:Participant","bpmn:Lane"]):h(e,"bpmn:DataStoreReference")&&h(t,"bpmn:Collaboration")?Lt(j(t).get("participants"),function(n){return!!n.get("processRef")}):te(e,["bpmn:Artifact","bpmn:DataAssociation","bpmn:DataStoreReference"])?te(t,["bpmn:Collaboration","bpmn:Lane","bpmn:Participant","bpmn:Process","bpmn:SubProcess"]):h(e,"bpmn:MessageFlow")?h(t,"bpmn:Collaboration")||e.source.parent==t||e.target.parent==t:!1}function nA(e){return j(e).cancelActivity&&(Ay(e)||Ty(e))}function Py(e){return!ee(e)&&h(e,"bpmn:BoundaryEvent")}function rA(e){return h(e,"bpmn:Lane")}function iA(e){return Py(e)||h(e,"bpmn:IntermediateThrowEvent")&&Ay(e)?!0:h(e,"bpmn:IntermediateCatchEvent")&&Ty(e)}function Ay(e){var t=j(e);return t&&!(t.eventDefinitions&&t.eventDefinitions.length)}function Ty(e){return My(e,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])}function My(e,t){return t.some(function(n){return ur(e,n)})}function oA(e){return h(e,"bpmn:ReceiveTask")&&re(e.incoming,function(t){return h(t.source,"bpmn:EventBasedGateway")})}function js(e,t,n,r){if(Array.isArray(e)||(e=[e]),e.length!==1)return!1;var i=e[0];return ee(i)||!iA(i)||Qe(t)||!h(t,"bpmn:Activity")||yp(t)||r&&!hp(r,t)||oA(t)?!1:"attach"}function Dy(e,t,n){if(!t)return!1;var r={replacements:[]};return E(e,function(i){Qe(t)||h(i,"bpmn:StartEvent")&&i.type!=="label"&&Qo(i,t)&&(hh(i)||r.replacements.push({oldElementId:i.id,newElementType:"bpmn:StartEvent"}),(vh(i)||gh(i)||yh(i))&&r.replacements.push({oldElementId:i.id,newElementType:"bpmn:StartEvent"}),My(i,["bpmn:MessageEventDefinition","bpmn:TimerEventDefinition","bpmn:SignalEventDefinition","bpmn:ConditionalEventDefinition"])&&h(t,"bpmn:SubProcess")&&r.replacements.push({oldElementId:i.id,newElementType:"bpmn:StartEvent"})),h(t,"bpmn:Transaction")||ur(i,"bpmn:CancelEventDefinition")&&i.type!=="label"&&(h(i,"bpmn:EndEvent")&&Qo(i,t)&&r.replacements.push({oldElementId:i.id,newElementType:"bpmn:EndEvent"}),h(i,"bpmn:BoundaryEvent")&&js(i,t,null,n)&&r.replacements.push({oldElementId:i.id,newElementType:"bpmn:BoundaryEvent"}))}),r.replacements.length?r:!1}function ky(e,t){return Lt(e,rA)?!1:t?e.every(function(n){return Qo(n,t)}):!0}function Gf(e,t,n,r){return t?ee(e)||Vf(e)?!0:Qo(e,t,r)||gp(e,t,r):!1}function Ny(e,t,n){return h(e,"bpmn:SubProcess")?ie(e)&&(!t||t.width>=100&&t.height>=80):h(e,"bpmn:Lane")||h(e,"bpmn:Participant")?!0:zf(e)?n?n==="e"||n==="w":!0:Vf(e)?!0:ee(e)?n?n==="e"||n==="w":!0:!1}function aA(e,t){var n=zf(e),r=zf(t);return(n||r)&&n!==r}function Oy(e,t){return Ey(t,e)||Ey(e,t)?!1:aA(e,t)?!0:!!Wf(e,t)}function By(e,t){return Cy(e,t)&&Sy(e)&&h(t,"bpmn:Activity")&&!cA(t,e)&&!Qe(t)}function Iy(e,t){return wy(e)&&!wy(t)?!1:XP(e)&&ZP(t)&&!YP(e,t)}function Ly(e,t){return QP(e)&&JP(t)&&Cy(e,t)&&!(h(e,"bpmn:EventBasedGateway")&&!eA(t))}function Wf(e,t){return te(e,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&te(t,["bpmn:Activity","bpmn:ThrowEvent"])?{type:"bpmn:DataInputAssociation"}:te(t,["bpmn:DataObjectReference","bpmn:DataStoreReference"])&&te(e,["bpmn:Activity","bpmn:CatchEvent"])?{type:"bpmn:DataOutputAssociation"}:!1}function gp(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:te(t,["bpmn:SequenceFlow","bpmn:MessageFlow"])&&!ee(t)&&h(e,"bpmn:FlowNode")&&!h(e,"bpmn:BoundaryEvent")&&Qo(e,t.parent,n)}function sA(e,t){return e&&t&&e.indexOf(t)!==-1}function jy(e,t){return ee(t)?!0:!(h(t,"bpmn:Lane")&&!sA(e,t.parent))}function wy(e){return kr(e,"bpmn:Process")||kr(e,"bpmn:Collaboration")}function cA(e,t){return e.attachers.includes(t)}var Fy={__depends__:[Et],__init__:["bpmnRules"],bpmnRules:["type",wt]};N();var uA=2e3;function _p(e,t){e.on("saveXML.start",uA,n);function n(){var r=t.getRootElements();E(r,function(i){var o=ce(i),a,s;a=Zn([i],!1),a=Q(a,function(c){return c!==i&&!c.labelTarget}),s=je(a,ce),o.set("planeElement",s)})}}_p.$inject=["eventBus","canvas"];var Hy={__init__:["bpmnDiOrdering"],bpmnDiOrdering:["type",_p]};function Jo(e){k.call(this,e);var t=this;this.preExecute(["shape.create","connection.create"],function(n){var r=n.context,i=r.shape||r.connection,o=r.parent,a=t.getOrdering(i,o);a&&(a.parent!==void 0&&(r.parent=a.parent),r.parentIndex=a.index)}),this.preExecute(["shape.move","connection.move"],function(n){var r=n.context,i=r.shape||r.connection,o=r.newParent||i.parent,a=t.getOrdering(i,o);a&&(a.parent!==void 0&&(r.newParent=a.parent),r.newParentIndex=a.index)})}Jo.prototype.getOrdering=function(e,t){return null};B(Jo,k);N();function Fs(e,t){Jo.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 r(a){if(a.labelTarget)return{level:10};var s=re(n,function(c){return te(a,[c.type])});return s&&s.order||{level:1}}function i(a){var s=a.order;if(s||(a.order=s=r(a)),!s)throw new Error(`no order for <${a.id}>`);return s}function o(a,s,c){for(var u=s;u&&!te(u,c);)u=u.parent;if(!u)throw new Error(`no parent for <${a.id}> in <${s&&s.id}>`);return u}this.getOrdering=function(a,s){if(a.labelTarget||h(a,"bpmn:TextAnnotation"))return{parent:t.findRoot(s)||t.getRootElement(),index:-1};var c=i(a);c.containers&&(s=o(a,s,c.containers));var u=s.children.indexOf(a),p=Sa(s.children,function(l){return!a.labelTarget&&l.labelTarget?!1:c.level<i(l).level});return p!==-1&&u!==-1&&u<p&&(p-=1),{index:p,parent:s}}}Fs.$inject=["eventBus","canvas"];B(Fs,Jo);var $y={__init__:["bpmnOrderingProvider"],bpmnOrderingProvider:["type",Fs]};function $i(){}$i.prototype.get=function(){return this._data};$i.prototype.set=function(e){this._data=e};$i.prototype.clear=function(){var e=this._data;return delete this._data,e};$i.prototype.isEmpty=function(){return!this._data};var zy={clipboard:["type",$i]};N();var pA="drop-ok",Gy="drop-not-ok",Vy="attach-ok",Wy="new-parent",Uy="create",lA=2e3;function bp(e,t,n,r,i){function o(c,u,p,l,f){if(!u)return!1;c=Q(c,function(S){var x=S.labelTarget;return!S.parent&&!(ee(S)&&c.indexOf(x)!==-1)});var d=re(c,function(S){return!de(S)}),m=!1,g=!1,v=!1;Ky(c)&&(m=i.allowed("shape.attach",{position:p,shape:d,target:u})),m||(Ky(c)?v=i.allowed("shape.create",{position:p,shape:d,source:l,target:u}):v=i.allowed("elements.create",{elements:c,position:p,target:u}));var w=f.connectionTarget;return v||m?(d&&l&&(g=i.allowed("connection.create",{source:w===l?d:l,target:w===l?l:d,hints:{targetParent:u,targetAttach:m}})),{attach:m,connect:g}):v===null||m===null?null:!1}function a(c,u){[Vy,pA,Gy,Wy].forEach(function(p){p===u?e.addMarker(c,p):e.removeMarker(c,p)})}n.on(["create.move","create.hover"],function(c){var u=c.context,p=u.elements,l=c.hover,f=u.source,d=u.hints||{};if(!l){u.canExecute=!1,u.target=null;return}qy(c);var m={x:c.x,y:c.y},g=u.canExecute=l&&o(p,l,m,f,d);l&&g!==null&&(u.target=l,g&&g.attach?a(l,Vy):a(l,g?Wy:Gy))}),n.on(["create.end","create.out","create.cleanup"],function(c){var u=c.hover;u&&a(u,null)}),n.on("create.end",function(c){var u=c.context,p=u.source,l=u.shape,f=u.elements,d=u.target,m=u.canExecute,g=m&&m.attach,v=m&&m.connect,w=u.hints||{};if(m===!1||!d)return!1;qy(c);var S={x:c.x,y:c.y};v?l=r.appendShape(p,l,S,d,{attach:g,connection:v===!0?{}:v,connectionTarget:w.connectionTarget}):(f=r.createElements(f,S,d,C({},w,{attach:g})),l=re(f,function(x){return!de(x)})),C(u,{elements:f,shape:l}),C(c,{elements:f,shape:l})});function s(){var c=t.context();c&&c.prefix===Uy&&t.cancel()}n.on("create.init",function(){n.on("elements.changed",s),n.once(["create.cancel","create.end"],lA,function(){n.off("elements.changed",s)})}),this.start=function(c,u,p){q(u)||(u=[u]);var l=re(u,function(m){return!de(m)});if(l){p=C({elements:u,hints:{},shape:l},p||{}),E(u,function(m){ne(m.x)||(m.x=0),ne(m.y)||(m.y=0)});var f=Q(u,function(m){return!m.hidden}),d=Ce(f);E(u,function(m){de(m)&&(m.waypoints=je(m.waypoints,function(g){return{x:g.x-d.x-d.width/2,y:g.y-d.y-d.height/2}})),C(m,{x:m.x-d.x-d.width/2,y:m.y-d.y-d.height/2})}),t.init(c,Uy,{cursor:"grabbing",autoActivate:!0,data:{shape:l,elements:u,context:p}})}}}bp.$inject=["canvas","dragging","eventBus","modeling","rules"];function qy(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 Ky(e){return e&&e.length===1&&!de(e[0])}var fA=750;function xp(e,t,n,r,i){function o(a){var s=U("g");$(s,i.cls("djs-drag-group",["no-events"]));var c=U("g");return a.forEach(function(u){var p;u.hidden||(u.waypoints?(p=n._createContainer("connection",c),n.drawConnection(Ln(p),u)):(p=n._createContainer("shape",c),n.drawShape(Ln(p),u),Fe(p,u.x,u.y)),r.addDragger(u,s,p))}),s}t.on("create.move",fA,function(a){var s=a.hover,c=a.context,u=c.elements,p=c.dragGroup;p||(p=c.dragGroup=o(u));var l;s?(p.parentNode||(l=e.getActiveLayer(),J(l,p)),Fe(p,a.x,a.y)):Pe(p)}),t.on("create.cleanup",function(a){var s=a.context,c=s.dragGroup;c&&Pe(c)})}xp.$inject=["canvas","eventBus","graphicsFactory","previewSupport","styles"];var li={__depends__:[kt,Dn,Et,rt],__init__:["create","createPreview"],create:["type",bp],createPreview:["type",xp]};function Hs(e){var t=this;this._lastMoveEvent=null;function n(r){t._lastMoveEvent=r}e.on("canvas.init",function(r){var i=t._svg=r.svg;i.addEventListener("mousemove",n)}),e.on("canvas.destroy",function(){t._lastMouseEvent=null,t._svg.removeEventListener("mousemove",n)})}Hs.$inject=["eventBus"];Hs.prototype.getLastMoveEvent=function(){return this._lastMoveEvent||dA(0,0)};function dA(e,t){var n=document.createEvent("MouseEvent"),r=e,i=t,o=e,a=t;return n.initMouseEvent&&n.initMouseEvent("mousemove",!0,!0,window,0,r,i,o,a,!1,!1,!1,!1,0,null),n}var pr={__init__:["mouse"],mouse:["type",Hs]};N();var Yy=2e3;function Ht(e,t,n,r,i,o,a,s){this._canvas=e,this._create=t,this._elementFactory=r,this._eventBus=i,this._modeling=o,this._mouse=a,this._rules=s,i.on("copyPaste.copyElement",function(c){var u=c.descriptor,p=c.element,l=c.elements;u.priority=1,u.id=p.id;var f=re(l,function(d){return d===p.parent});f&&(u.parent=p.parent.id),mA(p)&&(u.priority=2,u.host=p.host.id),de(p)&&(u.priority=3,u.source=p.source.id,u.target=p.target.id,u.waypoints=hA(p)),ee(p)&&(u.priority=4,u.labelTarget=p.labelTarget.id),E(["x","y","width","height"],function(d){ne(p[d])&&(u[d]=p[d])}),u.hidden=p.hidden,u.collapsed=p.collapsed}),i.on("copyPaste.elementsCopied",Yy,function(c){var u;((u=c.hints)==null?void 0:u.clip)!==!1&&n.set(c.tree)}),i.on("copyPaste.pasteElements",Yy,function(c){c.tree||(c.tree=n.get())}),i.on("copyPaste.pasteElements",function(c){var u=c.hints;C(u,{createElementsBehavior:!1})})}Ht.$inject=["canvas","create","clipboard","elementFactory","eventBus","modeling","mouse","rules"];Ht.prototype.copy=function(e,t={}){var n,r;return q(e)||(e=e?[e]:[]),n=this._eventBus.fire("copyPaste.canCopyElements",{elements:e}),n===!1?r={}:r=this.createTree(q(n)?n:e),this._eventBus.fire("copyPaste.elementsCopied",{elements:e,tree:r,hints:t}),r};Ht.prototype.paste=function(e={}){var t=this._eventBus.createEvent({type:"copyPaste.pasteElements",hints:{},...e}),n=this._eventBus.fire(t);if(n!==!1){var r=t.tree;if(r){var i=t.hints,o=this._createElements(r);if(t.element&&t.point)return this._paste(o,t.element,t.point,i);this._create.start(this._mouse.getLastMoveEvent(),o,{hints:i})}}};Ht.prototype.duplicate=function(e,t={}){var n=this.copy(e,{clip:!1});return this.paste({...t,tree:n})};Ht.prototype.cut=function(e){var t=this.copy(e),n=this._getElementIdsFromTree(t),r=e.filter(function(i){return n[i.id]});return r.length>0&&this._modeling.removeElements(r),t};Ht.prototype._getElementIdsFromTree=function(e){var t={};return E(e,function(n){E(n,function(r){r.id&&(t[r.id]=!0)})}),t};Ht.prototype._paste=function(e,t,n,r){E(e,function(o){ne(o.x)||(o.x=0),ne(o.y)||(o.y=0)});var i=Ce(e);return E(e,function(o){de(o)&&(o.waypoints=je(o.waypoints,function(a){return{x:a.x-i.x-i.width/2,y:a.y-i.y-i.height/2}})),C(o,{x:o.x-i.x-i.width/2,y:o.y-i.y-i.height/2})}),this._modeling.createElements(e,n,t,C({},r))};Ht.prototype._createElements=function(e){var t=this,n=this._eventBus,r={},i=[];return E(e,function(o,a){a=parseInt(a,10),o=At(o,"priority"),E(o,function(s){var c=C({},Nt(s,["priority"]));r[s.parent]?c.parent=r[s.parent]:delete c.parent,n.fire("copyPaste.pasteElement",{cache:r,descriptor:c});var u;if(de(c)){c.source=r[s.source],c.target=r[s.target],u=r[s.id]=t.createConnection(c),i.push(u);return}if(ee(c)){c.labelTarget=r[c.labelTarget],u=r[s.id]=t.createLabel(c),i.push(u);return}c.host&&(c.host=r[c.host]),u=r[s.id]=t.createShape(c),i.push(u)})}),i};Ht.prototype.createConnection=function(e){var t=this._elementFactory.createConnection(Nt(e,["id"]));return t};Ht.prototype.createLabel=function(e){var t=this._elementFactory.createLabel(Nt(e,["id"]));return t};Ht.prototype.createShape=function(e){var t=this._elementFactory.createShape(Nt(e,["id"]));return t};Ht.prototype.hasRelations=function(e,t){var n,r,i;return!(de(e)&&(r=re(t,Ct({id:e.source.id})),i=re(t,Ct({id:e.target.id})),!r||!i)||ee(e)&&(n=re(t,Ct({id:e.labelTarget.id})),!n))};Ht.prototype.createTree=function(e){var t=this._rules,n=this,r={},i=[],o=zr(e);function a(u,p){return t.allowed("element.copy",{element:u,elements:p})}function s(u,p){var l=re(i,function(f){return u===f.element});if(!l){i.push({element:u,depth:p});return}l.depth<p&&(i=c(l,i),i.push({element:l.element,depth:p}))}function c(u,p){var l=p.indexOf(u);return l!==-1&&p.splice(l,1),p}return In(o,function(u,p,l){if(ee(u))return;E(u.labels,function(m){s(m,l)});function f(m){m&&m.length&&E(m,function(g){E(g.labels,function(v){s(v,l)}),s(g,l)})}E([u.attachers,u.incoming,u.outgoing],f),s(u,l);var d=[];return u.children&&(d=u.children.slice()),n._eventBus.fire("copyPaste.createTree",{element:u,children:d}),d}),e=je(i,function(u){return u.element}),i=je(i,function(u){return u.descriptor={},n._eventBus.fire("copyPaste.copyElement",{descriptor:u.descriptor,element:u.element,elements:e}),u}),i=At(i,function(u){return u.descriptor.priority}),e=je(i,function(u){return u.element}),E(i,function(u){var p=u.depth;if(!n.hasRelations(u.element,e)){Zy(u.element,e);return}if(!a(u.element,e)){Zy(u.element,e);return}r[p]||(r[p]=[]),r[p].push(u.descriptor)}),r};function mA(e){return!!e.host}function hA(e){return je(e.waypoints,function(t){return t=Xy(t),t.original&&(t.original=Xy(t.original)),t})}function Xy(e){return C({},e)}function Zy(e,t){var n=t.indexOf(e);return n===-1?t:t.splice(n,1)}var Qy={__depends__:[zy,li,pr,Et],__init__:["copyPaste"],copyPaste:["type",Ht]};N();function Uf(e,t,n){q(n)||(n=[n]),E(n,function(r){wn(e[r])||(t[r]=e[r])})}var qf=750;function Ep(e,t,n){function r(c,u){var p=e.create(c.$type);return n.copyElement(c,p,null,u)}t.on("copyPaste.copyElement",qf,function(c){var u=c.descriptor,p=c.element,l=j(p);if(ee(p))return u;var f=u.businessObject=r(l,!0),d=u.di=r(ce(p),!0);d.bpmnElement=f,Uf(f,u,"name"),Uf(d,u,"isExpanded"),l.default&&(u.default=l.default.id)});var i="-bpmn-js-refs";function o(c){return c[i]=c[i]||{}}function a(c,u){c[i]=u}function s(c,u,p){var l=j(c);return c.default&&(p[c.default]={element:l,property:"default"}),c.host&&(j(c).attachedToRef=j(u[c.host])),Nt(p,Ge(p,function(f,d,m){var g=d.element,v=d.property;return m===c.id&&(g.set(v,l),f.push(c.id)),f},[]))}t.on("copyPaste.pasteElement",function(c){var u=c.cache,p=c.descriptor,l=p.businessObject,f=p.di;if(ee(p)){p.businessObject=j(u[p.labelTarget]),p.di=ce(u[p.labelTarget]);return}l=p.businessObject=r(l),f=p.di=r(f),f.bpmnElement=l,Uf(p,l,["isExpanded","name"]),p.type=l.$type}),t.on("copyPaste.copyElement",qf,function(c){var u=c.descriptor,p=c.element;if(h(p,"bpmn:Participant")){var l=j(p);l.processRef&&(u.processRef=r(l.processRef,!0))}}),t.on("copyPaste.pasteElement",function(c){var u=c.descriptor,p=u.processRef;p&&(u.processRef=r(p))}),t.on("copyPaste.createTree",function(c){var u=c.element,p=c.children;h(u,"bpmn:SubProcess")&&E(Ti(p),l=>{p.push(l.annotation)})}),t.on("copyPaste.pasteElement",qf,function(c){var u=c.cache,p=c.descriptor;a(u,s(p,u,o(u)))})}Ep.$inject=["bpmnFactory","eventBus","moddleCopy"];N();var vA=["artifacts","dataInputAssociations","dataOutputAssociations","default","flowElements","lanes","incoming","outgoing","categoryValue"],gA=["errorRef","escalationRef","messageRef","signalRef","dataObjectRef"];function zi(e,t,n){this._bpmnFactory=t,this._eventBus=e,this._moddle=n,e.on("moddleCopy.canCopyProperties",r=>{let{propertyNames:i}=r;if(!(!i||!i.length))return At(i,o=>o==="extensionElements")}),e.on("moddleCopy.canCopyProperty",r=>{let{parent:i,property:o,propertyName:a}=r,s=Se(i)&&i.$descriptor;if(a&&gA.includes(a))return o;if(a&&vA.includes(a)||a&&s&&!re(s.properties,Ct({name:a})))return!1}),e.on("moddleCopy.canSetCopiedProperty",r=>{let{property:i}=r;if(h(i,"bpmn:ExtensionElements")&&(!i.values||!i.values.length))return!1})}zi.$inject=["eventBus","bpmnFactory","moddle"];zi.prototype.copyElement=function(e,t,n,r=!1){n&&!q(n)&&(n=[n]),n=n||wp(e.$descriptor);let i=this._eventBus.fire("moddleCopy.canCopyProperties",{propertyNames:n,sourceElement:e,targetElement:t,clone:r});return i===!1||(q(i)&&(n=i),E(n,o=>{let a;dt(e,o)&&(a=e.get(o));let s=this.copyProperty(a,t,o,r);!Ue(s)||this._eventBus.fire("moddleCopy.canSetCopiedProperty",{parent:t,property:s,propertyName:o})===!1||t.set(o,s)})),t};zi.prototype.copyProperty=function(e,t,n,r=!1){let i=this._eventBus.fire("moddleCopy.canCopyProperty",{parent:t,property:e,propertyName:n,clone:r});if(i===!1)return;if(i)return Se(i)&&i.$type&&!i.$parent&&(i.$parent=t),i;let o=this._moddle.getPropertyDescriptor(t,n);if(!o.isReference)return o.isId?e&&this._copyId(e,t,r):q(e)?Ge(e,(a,s)=>{let c=this.copyProperty(s,t,n,r);return c?a.concat(c):a},[]):Se(e)&&e.$type?this._moddle.getElementDescriptor(e).isGeneric?void 0:(i=this._bpmnFactory.create(e.$type),i.$parent=t,i=this.copyElement(e,i,null,r),i):e};zi.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 wp(e,t){return Ge(e.properties,(n,r)=>t&&r.default?n:n.concat(r.name),[])}var Sp={__depends__:[Qy],__init__:["bpmnCopyPaste","moddleCopy"],bpmnCopyPaste:["type",Ep],moddleCopy:["type",zi]};N();var Jy=Math.round;function $s(e,t){this._modeling=e,this._eventBus=t}$s.$inject=["modeling","eventBus"];$s.prototype.replaceElement=function(e,t,n){if(e.waypoints)return null;var r=this._modeling,i=this._eventBus;i.fire("replace.start",{element:e,attrs:t,hints:n});var o=t.width||e.width,a=t.height||e.height,s=t.x||e.x,c=t.y||e.y,u=Jy(s+o/2),p=Jy(c+a/2),l=r.replaceShape(e,C({},t,{x:u,y:p,width:o,height:a}),n);return i.fire("replace.end",{element:e,newElement:l,hints:n}),l};function Cp(e,t){t.on("replace.end",500,function(n){let{newElement:r,hints:i={}}=n;i.select!==!1&&e.select(r)})}Cp.$inject=["selection","eventBus"];var e_={__init__:["replace","replaceSelectionBehavior"],replaceSelectionBehavior:["type",Cp],replace:["type",$s]};N();function yA(e,t,n){q(n)||(n=[n]),E(n,function(r){wn(e[r])||(t[r]=e[r])})}var _A=["cancelActivity","instantiate","eventGatewayType","triggeredByEvent","isInterrupting"];function bA(e,t){var n=e&&dt(e,"collapsed")?e.collapsed:!ie(e),r;return t&&(dt(t,"collapsed")||dt(t,"isExpanded"))?r=dt(t,"collapsed")?t.collapsed:!t.isExpanded:r=n,n!==r}function Pp(e,t,n,r,i,o){function a(s,c,u){u=u||{};var p=c.type,l=s.businessObject;if(Rp(l)&&(p==="bpmn:SubProcess"||p==="bpmn:AdHocSubProcess")&&bA(s,c))return r.toggleCollapse(s),s;var f=e.create(p),d={type:p,businessObject:f};d.di={},p==="bpmn:ExclusiveGateway"&&(d.di.isMarkerVisible=!0),yA(s.di,d.di,["fill","stroke","background-color","border-color","color"]);var m=wp(l.$descriptor),g=wp(f.$descriptor,!0),v=xA(m,g);C(f,mt(c,_A));var w=Q(v,function(b){return b==="eventDefinitions"?t_(s,c.eventDefinitionType):b==="loopCharacteristics"?!Qe(f):dt(f,b)||b==="processRef"&&c.isExpanded===!1||b==="triggeredByEvent"?!1:b==="isForCompensation"?!Qe(f):!0});if(f=n.copyElement(l,f,w),c.eventDefinitionType&&(t_(f,c.eventDefinitionType)||(d.eventDefinitionType=c.eventDefinitionType,d.eventDefinitionAttrs=c.eventDefinitionAttrs)),h(l,"bpmn:Activity")){if(Rp(l))d.isExpanded=ie(s);else if(c&&dt(c,"isExpanded")){d.isExpanded=c.isExpanded;var S=t.getDefaultSize(f,{isExpanded:d.isExpanded});d.width=S.width,d.height=S.height,d.x=s.x-(d.width-s.width)/2,d.y=s.y-(d.height-s.height)/2}ie(s)&&!h(l,"bpmn:Task")&&d.isExpanded&&(d.width=s.width,d.height=s.height)}if(Rp(l)&&!Rp(f)&&(u.moveChildren=!1),h(l,"bpmn:Participant")){c.isExpanded===!0?f.processRef=e.create("bpmn:Process"):u.moveChildren=!1;var x=Me(s);ce(s).isHorizontal||(ce(d).isHorizontal=x),d.width=x?s.width:t.getDefaultSize(d).width,d.height=x?t.getDefaultSize(d).height:s.height}return o.allowed("shape.resize",{shape:f})||(d.height=t.getDefaultSize(d).height,d.width=t.getDefaultSize(d).width),f.name=l.name,te(l,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&te(f,["bpmn:ExclusiveGateway","bpmn:InclusiveGateway","bpmn:Activity"])&&(f.default=l.default),c.host&&!h(l,"bpmn:BoundaryEvent")&&h(f,"bpmn:BoundaryEvent")&&(d.host=c.host),(d.type==="bpmn:DataStoreReference"||d.type==="bpmn:DataObjectReference")&&(d.x=s.x+(s.width-d.width)/2),i.replaceElement(s,d,{...u,targetElement:c})}this.replaceElement=a}Pp.$inject=["bpmnFactory","elementFactory","moddleCopy","modeling","replace","rules"];function Rp(e){return h(e,"bpmn:SubProcess")}function t_(e,t){var n=j(e);return t&&n.get("eventDefinitions").some(function(r){return h(r,t)})}function xA(e,t){return e.filter(function(n){return t.includes(n)})}var Ap={__depends__:[Sp,e_,rt],bpmnReplace:["type",Pp]};N();var EA=250;function Nr(e){this._eventBus=e,this._tools=[],this._active=null}Nr.$inject=["eventBus"];Nr.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)};Nr.prototype.isActive=function(e){return e&&this._active===e};Nr.prototype.length=function(e){return this._tools.length};Nr.prototype.setActive=function(e){var t=this._eventBus;this._active!==e&&(this._active=e,t.fire("tool-manager.update",{tool:e}))};Nr.prototype.bindEvents=function(e,t){var n=this._eventBus,r=[];n.on(t.tool+".init",function(i){var o=i.context;if(!o.reactivate&&this.isActive(e)){this.setActive(null);return}this.setActive(e)},this),E(t,function(i){r.push(i+".ended"),r.push(i+".canceled")}),n.on(r,EA,function(i){this._active&&(wA(i)||this.setActive(null))},this)};function wA(e){var t=e.originalEvent&&e.originalEvent.target;return t&&Bn(t,'.group[data-group="tools"]')}var fi={__depends__:[kt],__init__:["toolManager"],toolManager:["type",Nr]};N();N();function n_(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 r_(e,t){var n=[];return E(e.concat(t),function(r){var i=r.incoming,o=r.outgoing;E(i.concat(o),function(a){var s=a.source,c=a.target;(zs(e,s)||zs(e,c)||zs(t,s)||zs(t,c))&&(zs(n,a)||n.push(a))})}),n}function zs(e,t){return e.indexOf(t)!==-1}function i_(e,t,n){var r=e.x,i=e.y,o=e.width,a=e.height,s=n.x,c=n.y;switch(t){case"n":return{x:r,y:i+c,width:o,height:a-c};case"s":return{x:r,y:i,width:o,height:a+c};case"w":return{x:r+s,y:i,width:o-s,height:a};case"e":return{x:r,y:i,width:o+s,height:a};default:throw new Error("unknown direction: "+t)}}var Kf=Math.abs,SA=Math.round,Or={x:"width",y:"height"},s_="crosshair",di={n:"top",w:"left",s:"bottom",e:"right"},CA=1500,Tp={n:"s",w:"e",s:"n",e:"w"},Mp=20;function Xt(e,t,n,r,i,o,a){this._canvas=e,this._dragging=t,this._eventBus=n,this._modeling=r,this._rules=i,this._toolManager=o,this._mouse=a;var s=this;o.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",CA,function(c){var u=c.context,p=u.initialized;p||(p=u.initialized=s.init(c,u)),p&&a_(c)}),n.on("spaceTool.end",function(c){var u=c.context,p=u.axis,l=u.direction,f=u.movingShapes,d=u.resizingShapes,m=u.start;if(u.initialized){a_(c);var g={x:0,y:0};g[p]=SA(c["d"+p]),s.makeSpace(f,d,g,l,m),n.once("spaceTool.ended",function(v){s.activateSelection(v.originalEvent,!0,!0)})}})}Xt.$inject=["canvas","dragging","eventBus","modeling","rules","toolManager","mouse"];Xt.prototype.activateSelection=function(e,t,n){this._dragging.init(e,"spaceTool.selection",{autoActivate:t,cursor:s_,data:{context:{reactivate:n}},trapClick:!1})};Xt.prototype.activateMakeSpace=function(e){this._dragging.init(e,"spaceTool",{autoActivate:!0,cursor:s_,data:{context:{}}})};Xt.prototype.makeSpace=function(e,t,n,r,i){return this._modeling.createSpace(e,t,n,r,i)};Xt.prototype.init=function(e,t){var n=Kf(e.dx)>Kf(e.dy)?"x":"y",r=e["d"+n],i=e[n]-r;if(Kf(r)<5)return!1;r<0&&(r*=-1),Tr(e)&&(r*=-1);var o=n_(n,r),a=this._canvas.getRootElement();!Mi(e)&&e.hover&&(a=e.hover);var s=[...Zn(a,!0),...a.attachers||[]],c=this.calculateAdjustments(s,n,r,i),u=this._eventBus.fire("spaceTool.getMinDimensions",{axis:n,direction:o,shapes:c.resizingShapes,start:i}),p=RA(c,n,o,i,u);return C(t,c,{axis:n,direction:o,spaceToolConstraints:p,start:i}),Di("resize-"+(n==="x"?"ew":"ns")),!0};Xt.prototype.calculateAdjustments=function(e,t,n,r){var i=this._rules,o=[],a=[],s=[],c=[];function u(f){o.includes(f)||o.push(f);var d=f.label;d&&!o.includes(d)&&o.push(d)}function p(f){a.includes(f)||a.push(f)}E(e,function(f){if(!(!f.parent||ee(f))){if(de(f)){c.push(f);return}var d=f[t],m=d+f[Or[t]];if(PA(f)&&(n>0&&X(f)[t]>r||n<0&&X(f)[t]<r)){s.push(f);return}if(n>0&&d>r||n<0&&m<r){u(f);return}if(d<r&&m>r&&i.allowed("shape.resize",{shape:f})){p(f);return}}}),E(o,function(f){var d=f.attachers;d&&E(d,function(m){u(m)})});var l=o.concat(a);return E(s,function(f){var d=f.host;Gi(l,d)&&u(f)}),l=o.concat(a),E(c,function(f){var d=f.source,m=f.target,g=f.label;Gi(l,d)&&Gi(l,m)&&g&&u(g)}),{movingShapes:o,resizingShapes:a}};Xt.prototype.toggle=function(){if(this.isActive())return this._dragging.cancel();var e=this._mouse.getLastMoveEvent();this.activateSelection(e,!!e)};Xt.prototype.isActive=function(){var e=this._dragging.context();return e?/^spaceTool/.test(e.prefix):!1};function o_(e){return{top:e.top-Mp,right:e.right+Mp,bottom:e.bottom+Mp,left:e.left-Mp}}function a_(e){var t=e.context,n=t.spaceToolConstraints;if(n){var r,i;ne(n.left)&&(r=Math.max(e.x,n.left),e.dx=e.dx+r-e.x,e.x=r),ne(n.right)&&(r=Math.min(e.x,n.right),e.dx=e.dx+r-e.x,e.x=r),ne(n.top)&&(i=Math.max(e.y,n.top),e.dy=e.dy+i-e.y,e.y=i),ne(n.bottom)&&(i=Math.min(e.y,n.bottom),e.dy=e.dy+i-e.y,e.y=i)}}function RA(e,t,n,r,i){var o=e.movingShapes,a=e.resizingShapes;if(a.length){var s={},c,u;return E(a,function(p){var l=p.attachers,f=p.children,d=Z(p),m=Q(f,function(L){return!de(L)&&!ee(L)&&!Gi(o,L)&&!Gi(a,L)}),g=Q(f,function(L){return!de(L)&&!ee(L)&&Gi(o,L)}),v,w,S,x=[],b=[],R,A,O,T;m.length&&(w=o_(Z(Ce(m))),v=r-d[di[n]]+w[di[n]],n==="n"?s.bottom=u=ne(u)?Math.min(u,v):v:n==="w"?s.right=u=ne(u)?Math.min(u,v):v:n==="s"?s.top=c=ne(c)?Math.max(c,v):v:n==="e"&&(s.left=c=ne(c)?Math.max(c,v):v)),g.length&&(S=o_(Z(Ce(g))),v=r-S[di[Tp[n]]]+d[di[Tp[n]]],n==="n"?s.bottom=u=ne(u)?Math.min(u,v):v:n==="w"?s.right=u=ne(u)?Math.min(u,v):v:n==="s"?s.top=c=ne(c)?Math.max(c,v):v:n==="e"&&(s.left=c=ne(c)?Math.max(c,v):v)),l&&l.length&&(l.forEach(function(L){Gi(o,L)?x.push(L):b.push(L)}),x.length&&(R=Z(Ce(x.map(X))),A=d[di[Tp[n]]]-(R[di[Tp[n]]]-r)),b.length&&(O=Z(Ce(b.map(X))),T=O[di[n]]-(d[di[n]]-r)),n==="n"?(v=Math.min(A||1/0,T||1/0),s.bottom=u=ne(u)?Math.min(u,v):v):n==="w"?(v=Math.min(A||1/0,T||1/0),s.right=u=ne(u)?Math.min(u,v):v):n==="s"?(v=Math.max(A||-1/0,T||-1/0),s.top=c=ne(c)?Math.max(c,v):v):n==="e"&&(v=Math.max(A||-1/0,T||-1/0),s.left=c=ne(c)?Math.max(c,v):v));var I=i&&i[p.id];I&&(n==="n"?(v=r+p[Or[t]]-I[Or[t]],s.bottom=u=ne(u)?Math.min(u,v):v):n==="w"?(v=r+p[Or[t]]-I[Or[t]],s.right=u=ne(u)?Math.min(u,v):v):n==="s"?(v=r-p[Or[t]]+I[Or[t]],s.top=c=ne(c)?Math.max(c,v):v):n==="e"&&(v=r-p[Or[t]]+I[Or[t]],s.left=c=ne(c)?Math.max(c,v):v))}),s}}function Gi(e,t){return e.indexOf(t)!==-1}function PA(e){return!!e.host}N();var Yf="djs-dragging",c_="djs-resizing",AA=250,Dp=Math.max;function kp(e,t,n,r,i){function o(a,s){E(a,function(c){i.addDragger(c,s),n.addMarker(c,Yf)})}e.on("spaceTool.selection.start",function(a){var s=n.getLayer("space"),c=a.context,u={x:"M 0,-10000 L 0,10000",y:"M -10000,0 L 10000,0"},p=U("g");$(p,r.cls("djs-crosshair-group",["no-events"])),J(s,p);var l=U("path");$(l,"d",u.x),pe(l).add("djs-crosshair"),J(p,l);var f=U("path");$(f,"d",u.y),pe(f).add("djs-crosshair"),J(p,f),c.crosshairGroup=p}),e.on("spaceTool.selection.move",function(a){var s=a.context.crosshairGroup;Fe(s,a.x,a.y)}),e.on("spaceTool.selection.cleanup",function(a){var s=a.context,c=s.crosshairGroup;c&&Pe(c)}),e.on("spaceTool.move",AA,function(a){var s=a.context,c=s.line,u=s.axis,p=s.movingShapes,l=s.resizingShapes;if(s.initialized){if(!s.dragGroup){var f=n.getLayer("space");c=U("path"),$(c,"d","M0,0 L0,0"),pe(c).add("djs-crosshair"),J(f,c),s.line=c;var d=U("g");$(d,r.cls("djs-drag-group",["no-events"])),J(n.getActiveLayer(),d),o(p,d);var m=s.movingConnections=t.filter(function(b){var R=!1;E(p,function(I){E(I.outgoing,function(L){b===L&&(R=!0)})});var A=!1;E(p,function(I){E(I.incoming,function(L){b===L&&(A=!0)})});var O=!1;E(l,function(I){E(I.outgoing,function(L){b===L&&(O=!0)})});var T=!1;return E(l,function(I){E(I.incoming,function(L){b===L&&(T=!0)})}),de(b)&&(R||O)&&(A||T)});o(m,d),s.dragGroup=d}if(!s.frameGroup){var g=U("g");$(g,r.cls("djs-frame-group",["no-events"])),J(n.getActiveLayer(),g);var v=[];E(l,function(b){var R=i.addFrame(b,g),A=R.getBBox();v.push({element:R,initialBounds:A}),n.addMarker(b,c_)}),s.frameGroup=g,s.frames=v}var w={x:"M"+a.x+", -10000 L"+a.x+", 10000",y:"M -10000, "+a.y+" L 10000, "+a.y};$(c,{d:w[u]});var S={x:"y",y:"x"},x={x:a.dx,y:a.dy};x[S[s.axis]]=0,Fe(s.dragGroup,x.x,x.y),E(s.frames,function(b){var R=b.element,A=b.initialBounds,O,T;s.direction==="e"?$(R,{width:Dp(A.width+x.x,5)}):(O=Dp(A.width-x.x,5),$(R,{width:O,x:A.x+A.width-O})),s.direction==="s"?$(R,{height:Dp(A.height+x.y,5)}):(T=Dp(A.height-x.y,5),$(R,{height:T,y:A.y+A.height-T}))})}}),e.on("spaceTool.cleanup",function(a){var s=a.context,c=s.movingShapes,u=s.movingConnections,p=s.resizingShapes,l=s.line,f=s.dragGroup,d=s.frameGroup;E(c,function(m){n.removeMarker(m,Yf)}),E(u,function(m){n.removeMarker(m,Yf)}),f&&(Pe(l),Pe(f)),E(p,function(m){n.removeMarker(m,c_)}),d&&Pe(d)})}kp.$inject=["eventBus","elementRegistry","canvas","styles","previewSupport"];var u_={__init__:["spaceToolPreview"],__depends__:[kt,Et,fi,Dn,pr],spaceTool:["type",Xt],spaceToolPreview:["type",kp]};N();function ea(e,t){e.invoke(Xt,this),this._canvas=t}ea.$inject=["injector","canvas"];B(ea,Xt);ea.prototype.calculateAdjustments=function(e,t,n,r){var i=this._canvas.getRootElement(),o=e[0]===i?null:e[0],a=[];o&&(a=Sn(wi(i.children.filter(u=>h(u,"bpmn:Artifact")),Ce(o))));let s=[...e,...a];var c=Xt.prototype.calculateAdjustments.call(this,s,t,n,r);return c.resizingShapes=c.resizingShapes.filter(function(u){return!(h(u,"bpmn:TextAnnotation")||TA(u)&&(t==="y"&&Me(u)||t==="x"&&!Me(u)))}),c};function TA(e){return h(e,"bpmn:Participant")&&!j(e).processRef}var Np={__depends__:[u_],spaceTool:["type",ea]};N();function We(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)}We.$inject=["eventBus","injector"];We.prototype.execute=function(e,t){if(!e)throw new Error("command required");this._currentExecution.trigger="execute";let n={command:e,context:t};this._pushAction(n),this._internalExecute(n),this._popAction()};We.prototype.canExecute=function(e,t){let n={command:e,context:t},r=this._getHandler(e),i=this._fire(e,"canExecute",n);if(i===void 0){if(!r)return!1;r.canExecute&&(i=r.canExecute(t))}return i};We.prototype.clear=function(e){this._stack.length=0,this._stackIdx=-1,e!==!1&&this._fire("changed",{trigger:"clear"})};We.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()}};We.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()}};We.prototype.register=function(e,t){this._setHandler(e,t)};We.prototype.registerHandler=function(e,t){if(!e||!t)throw new Error("command and handlerCls must be defined");let n=this._injector.instantiate(t);this.register(e,n)};We.prototype.canUndo=function(){return!!this._getUndoAction()};We.prototype.canRedo=function(){return!!this._getRedoAction()};We.prototype._getRedoAction=function(){return this._stack[this._stackIdx+1]};We.prototype._getUndoAction=function(){return this._stack[this._stackIdx]};We.prototype._internalUndo=function(e){let t=e.command,n=e.context,r=this._getHandler(t);this._atomicDo(()=>{this._fire(t,"revert",e),r.revert&&this._markDirty(r.revert(n)),this._revertedAction(e),this._fire(t,"reverted",e)})};We.prototype._fire=function(e,t,n){arguments.length<3&&(n=t,t=null);let r=t?[e+"."+t,t]:[e],i;n=this._eventBus.createEvent(n);for(let o of r)if(i=this._eventBus.fire("commandStack."+o,n),n.cancelBubble)break;return i};We.prototype._createId=function(){return this._uid++};We.prototype._atomicDo=function(e){let t=this._currentExecution;t.atomic=!0;try{e()}finally{t.atomic=!1}};We.prototype._internalExecute=function(e,t){let n=e.command,r=e.context,i=this._getHandler(n);if(!i)throw new Error("no command handler registered for <"+n+">");this._pushAction(e),t||(this._fire(n,"preExecute",e),i.preExecute&&i.preExecute(r),this._fire(n,"preExecuted",e)),this._atomicDo(()=>{this._fire(n,"execute",e),i.execute&&this._markDirty(i.execute(r)),this._executedAction(e,t),this._fire(n,"executed",e)}),t||(this._fire(n,"postExecute",e),i.postExecute&&i.postExecute(r),this._fire(n,"postExecuted",e)),this._popAction()};We.prototype._pushAction=function(e){let t=this._currentExecution,n=t.actions,r=n[0];if(t.atomic)throw new Error("illegal invocation in <execute> or <revert> phase (action: "+e.command+")");e.id||(e.id=r&&r.id||this._createId()),n.push(e)};We.prototype._popAction=function(){let e=this._currentExecution,t=e.trigger,n=e.actions,r=e.dirty;n.pop(),n.length||(this._eventBus.fire("elements.changed",{elements:mc("id",r.reverse())}),r.length=0,this._fire("changed",{trigger:t}),e.trigger=null)};We.prototype._markDirty=function(e){let t=this._currentExecution;e&&(e=q(e)?e:[e],t.dirty=t.dirty.concat(e))};We.prototype._executedAction=function(e,t){let n=++this._stackIdx;t||this._stack.splice(n,this._stack.length,e)};We.prototype._revertedAction=function(e){this._stackIdx--};We.prototype._getHandler=function(e){return this._handlerMap[e]};We.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};var p_={commandStack:["type",We]};N();function kn(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 MA=250,l_=1400;function Gs(e,t,n){k.call(this,t);var r=e.get("movePreview",!1);t.on("shape.move.start",l_,function(i){var o=i.context,a=o.shapes,s=o.validatedShapes;o.shapes=f_(a),o.validatedShapes=f_(s)}),r&&t.on("shape.move.start",MA,function(i){var o=i.context,a=o.shapes,s=[];E(a,function(c){E(c.labels,function(u){!u.hidden&&o.shapes.indexOf(u)===-1&&s.push(u),c.labelTarget&&s.push(c)})}),E(s,function(c){r.makeDraggable(o,c,!0)})}),this.preExecuted("elements.move",l_,function(i){var o=i.context,a=o.closure,s=a.enclosedElements,c=[];E(s,function(u){E(u.labels,function(p){s[p.id]||c.push(p)})}),a.addAll(c)}),this.preExecute(["connection.delete","shape.delete"],function(i){var o=i.context,a=o.connection||o.shape;kn(a.labels,function(s){n.removeShape(s,{nested:!0})})}),this.execute("shape.delete",function(i){var o=i.context,a=o.shape,s=a.labelTarget;s&&(o.labelTargetIndex=co(s.labels,a),o.labelTarget=s,a.labelTarget=null)}),this.revert("shape.delete",function(i){var o=i.context,a=o.shape,s=o.labelTarget,c=o.labelTargetIndex;s&&(Ae(s.labels,a,c),a.labelTarget=s)})}B(Gs,k);Gs.$inject=["injector","eventBus","modeling"];function f_(e){return Q(e,function(t){return e.indexOf(t.labelTarget)===-1})}var d_={__init__:["labelSupport"],labelSupport:["type",Gs]};N();var DA=251,m_=1401,h_="attach-ok";function Vs(e,t,n,r,i){k.call(this,t);var o=e.get("movePreview",!1);t.on("shape.move.start",m_,function(a){var s=a.context,c=s.shapes,u=s.validatedShapes;s.shapes=kA(c),s.validatedShapes=NA(u)}),o&&t.on("shape.move.start",DA,function(a){var s=a.context,c=s.shapes,u=Xf(c);E(u,function(p){o.makeDraggable(s,p,!0),E(p.labels,function(l){o.makeDraggable(s,l,!0)})})}),o&&t.on("shape.move.start",function(a){var s=a.context,c=s.shapes;if(c.length===1){var u=c[0],p=u.host;p&&(n.addMarker(p,h_),t.once(["shape.move.out","shape.move.cleanup"],function(){n.removeMarker(p,h_)}))}}),this.preExecuted("elements.move",m_,function(a){var s=a.context,c=s.closure,u=s.shapes,p=Xf(u);E(p,function(l){c.add(l,c.topLevel[l.host.id])})}),this.postExecuted("elements.move",function(a){var s=a.context,c=s.shapes,u=s.newHost,p;u&&c.length!==1||(u?p=c:p=Q(c,function(l){var f=l.host;return OA(l)&&!BA(c,f)}),E(p,function(l){i.updateAttachment(l,u)}))}),this.postExecuted("elements.move",function(a){var s=a.context.shapes;E(s,function(c){E(c.attachers,function(u){E(u.outgoing.slice(),function(p){var l=r.allowed("connection.reconnect",{connection:p,source:p.source,target:p.target});l||i.removeConnection(p)}),E(u.incoming.slice(),function(p){var l=r.allowed("connection.reconnect",{connection:p,source:p.source,target:p.target});l||i.removeConnection(p)})})})}),this.postExecute("shape.create",function(a){var s=a.context,c=s.shape,u=s.host;u&&i.updateAttachment(c,u)}),this.postExecute("shape.replace",function(a){var s=a.context,c=s.oldShape,u=s.newShape;kn(c.attachers,function(p){var l=r.allowed("elements.move",{target:u,shapes:[p]});l==="attach"?i.updateAttachment(p,u):i.removeShape(p)}),u.attachers.length&&E(u.attachers,function(p){var l=If(p,c,u);i.moveShape(p,l,p.parent)})}),this.postExecute("shape.resize",function(a){var s=a.context,c=s.shape,u=s.oldBounds,p=s.newBounds,l=c.attachers,f=s.hints||{};f.attachSupport!==!1&&E(l,function(d){var m=If(d,u,p);i.moveShape(d,m,d.parent),E(d.labels,function(g){i.moveShape(g,m,g.parent)})})}),this.preExecute("shape.delete",function(a){var s=a.context.shape;kn(s.attachers,function(c){i.removeShape(c)}),s.host&&i.updateAttachment(s,null)})}B(Vs,k);Vs.$inject=["injector","eventBus","canvas","rules","modeling"];function Xf(e){return _i(je(e,function(t){return t.attachers||[]}))}function kA(e){var t=Xf(e);return gl("id",e,t)}function NA(e){var t=Vt(e,"id");return Q(e,function(n){for(;n;){if(n.host&&t[n.host.id])return!1;n=n.parent}return!0})}function OA(e){return!!e.host}function BA(e,t){return e.indexOf(t)!==-1}var v_={__depends__:[Et],__init__:["attachSupport"],attachSupport:["type",Vs]};N();function an(e){this._model=e}an.$inject=["moddle"];an.prototype._needsId=function(e){return te(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"])};an.prototype._ensureId=function(e){if(e.id){this._model.ids.claim(e.id,e);return}var t;h(e,"bpmn:Activity")?t="Activity":h(e,"bpmn:Event")?t="Event":h(e,"bpmn:Gateway")?t="Gateway":te(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))};an.prototype.create=function(e,t){var n=this._model.create(e,t||{});return this._ensureId(n),n};an.prototype.createDiLabel=function(){return this.create("bpmndi:BPMNLabel",{bounds:this.createDiBounds()})};an.prototype.createDiShape=function(e,t){return this.create("bpmndi:BPMNShape",C({bpmnElement:e,bounds:this.createDiBounds()},t))};an.prototype.createDiBounds=function(e){return this.create("dc:Bounds",e)};an.prototype.createDiWaypoints=function(e){var t=this;return je(e,function(n){return t.createDiWaypoint(n)})};an.prototype.createDiWaypoint=function(e){return this.create("dc:Point",mt(e,["x","y"]))};an.prototype.createDiEdge=function(e,t){return this.create("bpmndi:BPMNEdge",C({bpmnElement:e,waypoint:this.createDiWaypoints([])},t))};an.prototype.createDiPlane=function(e,t){return this.create("bpmndi:BPMNPlane",C({bpmnElement:e},t))};N();function $t(e,t,n){k.call(this,e),this._bpmnFactory=t;var r=this;function i(d){var m=d.context,g=m.hints||{},v;!m.cropped&&g.createElementsBehavior!==!1&&(v=m.connection,v.waypoints=n.getCroppedWaypoints(v),m.cropped=!0)}this.executed(["connection.layout","connection.create"],i),this.reverted(["connection.layout"],function(d){delete d.context.cropped});function o(d){var m=d.context;r.updateParent(m.shape||m.connection,m.oldParent)}function a(d){var m=d.context,g=m.shape||m.connection,v=m.parent||m.newParent;r.updateParent(g,v)}this.executed(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],sn(o)),this.reverted(["shape.move","shape.create","shape.delete","connection.create","connection.move","connection.delete"],sn(a));function s(d){var m=d.context,g=m.oldRoot,v=g.children;E(v,function(w){h(w,"bpmn:BaseElement")&&r.updateParent(w)})}this.executed(["canvas.updateRoot"],s),this.reverted(["canvas.updateRoot"],s);function c(d){var m=d.context.shape;h(m,"bpmn:BaseElement")&&r.updateBounds(m)}this.executed(["shape.move","shape.create","shape.resize"],sn(function(d){d.context.shape.type!=="label"&&c(d)})),this.reverted(["shape.move","shape.create","shape.resize"],sn(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 u(d){r.updateConnection(d.context)}this.executed(["connection.create","connection.move","connection.delete","connection.reconnect"],sn(u)),this.reverted(["connection.create","connection.move","connection.delete","connection.reconnect"],sn(u));function p(d){r.updateConnectionWaypoints(d.context.connection)}this.executed(["connection.layout","connection.move","connection.updateWaypoints"],sn(p)),this.reverted(["connection.layout","connection.move","connection.updateWaypoints"],sn(p)),this.executed("connection.reconnect",sn(function(d){var m=d.context,g=m.connection,v=m.oldSource,w=m.newSource,S=j(g),x=j(v),b=j(w);S.conditionExpression&&!te(b,["bpmn:Activity","bpmn:ExclusiveGateway","bpmn:InclusiveGateway"])&&(m.oldConditionExpression=S.conditionExpression,delete S.conditionExpression),v!==w&&x.default===S&&(m.oldDefault=x.default,delete x.default)})),this.reverted("connection.reconnect",sn(function(d){var m=d.context,g=m.connection,v=m.oldSource,w=m.newSource,S=j(g),x=j(v),b=j(w);m.oldConditionExpression&&(S.conditionExpression=m.oldConditionExpression),m.oldDefault&&(x.default=m.oldDefault,delete b.default)}));function l(d){r.updateAttachment(d.context)}this.executed(["element.updateAttachment"],sn(l)),this.reverted(["element.updateAttachment"],sn(l)),this.executed("element.updateLabel",sn(f)),this.reverted("element.updateLabel",sn(f));function f(d){let{element:m}=d.context,g=gt(m),v=ce(m),w=v&&v.get("label");mn(m)||Eo(m)||(g&&!w?v.set("label",t.create("bpmndi:BPMNLabel")):!g&&w&&v.set("label",void 0))}}B($t,k);$t.$inject=["eventBus","bpmnFactory","connectionDocking"];$t.prototype.updateAttachment=function(e){var t=e.shape,n=t.businessObject,r=t.host;n.attachedToRef=r&&r.businessObject};$t.prototype.updateParent=function(e,t){if(!ee(e)&&!(h(e,"bpmn:DataStoreReference")&&e.parent&&h(e.parent,"bpmn:Collaboration"))){var n=e.parent,r=e.businessObject,i=ce(e),o=n&&n.businessObject,a=ce(n);h(e,"bpmn:FlowNode")&&this.updateFlowNodeRefs(r,o,t&&t.businessObject),h(e,"bpmn:DataOutputAssociation")&&(e.source?o=e.source.businessObject:o=null),h(e,"bpmn:DataInputAssociation")&&(e.target?o=e.target.businessObject:o=null),this.updateSemanticParent(r,o),h(e,"bpmn:DataObjectReference")&&r.dataObjectRef&&this.updateSemanticParent(r.dataObjectRef,o),this.updateDiParent(i,a)}};$t.prototype.updateBounds=function(e){var t=ce(e),n=LA(e);if(n){var r=Dt(n,t.get("bounds"));C(n,{x:e.x+r.x,y:e.y+r.y})}var i=ee(e)?this._getLabel(t):t,o=i.bounds;o||(o=this._bpmnFactory.createDiBounds(),i.set("bounds",o)),C(o,{x:e.x,y:e.y,width:e.width,height:e.height})};$t.prototype.updateFlowNodeRefs=function(e,t,n){if(n!==t){var r,i;h(n,"bpmn:Lane")&&(r=n.get("flowNodeRef"),Oe(r,e)),h(t,"bpmn:Lane")&&(i=t.get("flowNodeRef"),Ae(i,e))}};$t.prototype.updateDiConnection=function(e,t,n){var r=ce(e),i=ce(t),o=ce(n);r.sourceElement&&r.sourceElement.bpmnElement!==j(t)&&(r.sourceElement=t&&i),r.targetElement&&r.targetElement.bpmnElement!==j(n)&&(r.targetElement=n&&o)};$t.prototype.updateDiParent=function(e,t){if(t&&!h(t,"bpmndi:BPMNPlane")&&(t=t.$parent),e.$parent!==t){var n=(t||e.$parent).get("planeElement");t?(n.push(e),e.$parent=t):(Oe(n,e),e.$parent=null)}};function IA(e){for(;e&&!h(e,"bpmn:Definitions");)e=e.$parent;return e}$t.prototype.getLaneSet=function(e){var t,n;return h(e,"bpmn:Lane")?(t=e.childLaneSet,t||(t=this._bpmnFactory.create("bpmn:LaneSet"),e.childLaneSet=t,t.$parent=e),t):(h(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)};$t.prototype.updateSemanticParent=function(e,t,n){var r;if(e.$parent!==t&&!((h(e,"bpmn:DataInput")||h(e,"bpmn:DataOutput"))&&(h(t,"bpmn:Participant")&&"processRef"in t&&(t=t.processRef),"ioSpecification"in t&&t.ioSpecification===e.$parent))){if(h(e,"bpmn:Lane"))t&&(t=this.getLaneSet(t)),r="lanes";else if(h(e,"bpmn:FlowElement")){if(t){if(h(t,"bpmn:Participant"))t=t.processRef;else if(h(t,"bpmn:Lane"))do t=t.$parent.$parent;while(h(t,"bpmn:Lane"))}r="flowElements"}else if(h(e,"bpmn:Artifact")){for(;t&&!h(t,"bpmn:Process")&&!h(t,"bpmn:SubProcess")&&!h(t,"bpmn:Collaboration");)if(h(t,"bpmn:Participant")){t=t.processRef;break}else t=t.$parent;r="artifacts"}else if(h(e,"bpmn:MessageFlow"))r="messageFlows";else if(h(e,"bpmn:Participant")){r="participants";var i=e.processRef,o;i&&(o=IA(e.$parent||t),e.$parent&&(Oe(o.get("rootElements"),i),i.$parent=null),t&&(Ae(o.get("rootElements"),i),i.$parent=o))}else h(e,"bpmn:DataOutputAssociation")?r="dataOutputAssociations":h(e,"bpmn:DataInputAssociation")&&(r="dataInputAssociations");if(!r)throw new Error(`no parent for <${e.id}> in <${t.id}>`);var a;if(e.$parent&&(a=e.$parent.get(r),Oe(a,e)),t?(a=t.get(r),a.push(e),e.$parent=t):e.$parent=null,n){var s=n.get(r);Oe(a,e),t&&(s||(s=[],t.set(r,s)),s.push(e))}}};$t.prototype.updateConnectionWaypoints=function(e){var t=ce(e);t.set("waypoint",this._bpmnFactory.createDiWaypoints(e.waypoints))};$t.prototype.updateConnection=function(e){var t=e.connection,n=j(t),r=t.source,i=j(r),o=t.target,a=j(t.target),s;if(h(n,"bpmn:DataAssociation"))h(n,"bpmn:DataInputAssociation")?(n.get("sourceRef")[0]=i,s=e.parent||e.newParent||a,this.updateSemanticParent(n,a,s)):h(n,"bpmn:DataOutputAssociation")&&(s=e.parent||e.newParent||i,this.updateSemanticParent(n,i,s),n.targetRef=a);else{var c=h(n,"bpmn:SequenceFlow");n.sourceRef!==i&&(c&&(Oe(n.sourceRef&&n.sourceRef.get("outgoing"),n),i&&i.get("outgoing")&&i.get("outgoing").push(n)),n.sourceRef=i),n.targetRef!==a&&(c&&(Oe(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,r,o)};$t.prototype._getLabel=function(e){return e.label||(e.label=this._bpmnFactory.createDiLabel()),e.label};function sn(e){return function(t){var n=t.context,r=n.shape||n.connection||n.element;h(r,"bpmn:BaseElement")&&e(t)}}function LA(e){if(h(e,"bpmn:Activity")){var t=ce(e);if(t){var n=t.get("label");if(n)return n.get("bounds")}}}N();function lr(e,t){Pn.call(this),this._bpmnFactory=e,this._moddle=t}B(lr,Pn);lr.$inject=["bpmnFactory","moddle"];lr.prototype._baseCreate=Pn.prototype.create;lr.prototype.create=function(e,t){if(e==="label"){var n=t.di||this._bpmnFactory.createDiLabel();return this._baseCreate(e,C({type:"label",di:n},ir,t))}return this.createElement(e,t)};lr.prototype.createElement=function(e,t){t=C({},t||{});var n,r=t.businessObject,i=t.di;if(!r){if(!t.type)throw new Error("no shape type specified");r=this._bpmnFactory.create(t.type)}if(!FA(i)){var o=C({},i||{},{id:r.id+"_di"});e==="root"?i=this._bpmnFactory.createDiPlane(r,o):e==="connection"?i=this._bpmnFactory.createDiEdge(r,o):i=this._bpmnFactory.createDiShape(r,o)}h(r,"bpmn:Group")&&(t=C({isFrame:!0},t)),t=jA(r,t,["processRef","isInterrupting","associationDirection","isForCompensation"]),t.isExpanded&&(t=Zf(i,t,"isExpanded")),te(r,["bpmn:Lane","bpmn:Participant"])&&(t=Zf(i,t,"isHorizontal")),h(r,"bpmn:SubProcess")&&(t.collapsed=!ie(r,i)),h(r,"bpmn:ExclusiveGateway")&&(dt(i,"isMarkerVisible")?i.isMarkerVisible===void 0&&(i.isMarkerVisible=!1):i.isMarkerVisible=!0),Ue(t.triggeredByEvent)&&(r.triggeredByEvent=t.triggeredByEvent,delete t.triggeredByEvent),Ue(t.cancelActivity)&&(r.cancelActivity=t.cancelActivity,delete t.cancelActivity);var a,s;return t.eventDefinitionType&&(a=r.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=r,r.eventDefinitions=a,delete t.eventDefinitionType),n=this.getDefaultSize(r,i),t=C({id:r.id},n,t,{businessObject:r,di:i}),this._baseCreate(e,t)};lr.prototype.getDefaultSize=function(e,t){var n=j(e);if(t=t||ce(e),h(n,"bpmn:SubProcess"))return ie(n,t)?{width:350,height:200}:{width:100,height:80};if(h(n,"bpmn:Task"))return{width:100,height:80};if(h(n,"bpmn:Gateway"))return{width:50,height:50};if(h(n,"bpmn:Event"))return{width:36,height:36};if(h(n,"bpmn:Participant")){var r=t.isHorizontal===void 0||t.isHorizontal===!0;return ie(n,t)?r?{width:600,height:250}:{width:250,height:600}:r?{width:400,height:60}:{width:60,height:400}}return h(n,"bpmn:Lane")?{width:400,height:100}:h(n,"bpmn:DataObjectReference")?{width:36,height:50}:h(n,"bpmn:DataStoreReference")?{width:50,height:50}:h(n,"bpmn:TextAnnotation")?{width:100,height:40}:h(n,"bpmn:Group")?{width:300,height:300}:{width:100,height:80}};lr.prototype.createParticipantShape=function(e){return Se(e)||(e={isExpanded:e}),e=C({type:"bpmn:Participant"},e||{}),e.isExpanded!==!1&&(e.processRef=this._bpmnFactory.create("bpmn:Process")),this.createShape(e)};function jA(e,t,n){return E(n,function(r){t=Zf(e,t,r)}),t}function Zf(e,t,n){return t[n]===void 0?t:(e[n]=t[n],Nt(t,[n]))}function FA(e){return te(e,["bpmndi:BPMNShape","bpmndi:BPMNEdge","bpmndi:BPMNDiagram","bpmndi:BPMNPlane"])}N();N();function ta(e,t){this._modeling=e,this._canvas=t}ta.$inject=["modeling","canvas"];ta.prototype.preExecute=function(e){var t=this._modeling,n=e.elements,r=e.alignment;E(n,function(i){var o={x:0,y:0};Ue(r.left)?o.x=r.left-i.x:Ue(r.right)?o.x=r.right-i.width-i.x:Ue(r.center)?o.x=r.center-Math.round(i.width/2)-i.x:Ue(r.top)?o.y=r.top-i.y:Ue(r.bottom)?o.y=r.bottom-i.height-i.y:Ue(r.middle)&&(o.y=r.middle-Math.round(i.height/2)-i.y),t.moveElements([i],o,i.parent)})};ta.prototype.postExecute=function(e){};N();function na(e){this._modeling=e}na.$inject=["modeling"];na.prototype.preExecute=function(e){var t=e.source;if(!t)throw new Error("source required");var n=e.target||t.parent,r=e.shape,i=e.hints||{};r=e.shape=this._modeling.createShape(r,e.position,n,{attach:i.attach}),e.shape=r};na.prototype.postExecute=function(e){var t=e.hints||{};HA(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 HA(e,t){return Lt(e.outgoing,function(n){return n.target===t})}function ra(e,t){this._canvas=e,this._layouter=t}ra.$inject=["canvas","layouter"];ra.prototype.execute=function(e){var t=e.connection,n=e.source,r=e.target,i=e.parent,o=e.parentIndex,a=e.hints;if(!n||!r)throw new Error("source and target required");if(!i)throw new Error("parent required");return t.source=n,t.target=r,t.waypoints||(t.waypoints=this._layouter.layoutConnection(t,a)),this._canvas.addConnection(t,i,o),t};ra.prototype.revert=function(e){var t=e.connection;return this._canvas.removeConnection(t),t.source=null,t.target=null,t};N();var Op=Math.round;function Ws(e){this._modeling=e}Ws.$inject=["modeling"];Ws.prototype.preExecute=function(e){var t=e.elements,n=e.parent,r=e.parentIndex,i=e.position,o=e.hints,a=this._modeling;E(t,function(l){ne(l.x)||(l.x=0),ne(l.y)||(l.y=0)});var s=Q(t,function(l){return!l.hidden}),c=Ce(s);E(t,function(l){de(l)&&(l.waypoints=je(l.waypoints,function(f){return{x:Op(f.x-c.x-c.width/2+i.x),y:Op(f.y-c.y-c.height/2+i.y)}})),C(l,{x:Op(l.x-c.x-c.width/2+i.x),y:Op(l.y-c.y-c.height/2+i.y)})});var u=zr(t),p={};E(t,function(l){if(de(l)){p[l.id]=ne(r)?a.createConnection(p[l.source.id],p[l.target.id],r,l,l.parent||n,o):a.createConnection(p[l.source.id],p[l.target.id],l,l.parent||n,o);return}var f=C({},o);u.indexOf(l)===-1&&(f.autoResize=!1),ee(l)&&(f=Nt(f,["attach"])),p[l.id]=ne(r)?a.createShape(l,mt(l,["x","y","width","height"]),l.parent||n,r,f):a.createShape(l,mt(l,["x","y","width","height"]),l.parent||n,f)}),e.elements=Sn(p)};N();var g_=Math.round;function Wn(e){this._canvas=e}Wn.$inject=["canvas"];Wn.prototype.execute=function(e){var t=e.shape,n=e.position,r=e.parent,i=e.parentIndex;if(!r)throw new Error("parent required");if(!n)throw new Error("position required");return n.width!==void 0?C(t,n):C(t,{x:n.x-g_(t.width/2),y:n.y-g_(t.height/2)}),this._canvas.addShape(t,r,i),t};Wn.prototype.revert=function(e){var t=e.shape;return this._canvas.removeShape(t),t};function Vi(e){Wn.call(this,e)}B(Vi,Wn);Vi.$inject=["canvas"];var $A=Wn.prototype.execute;Vi.prototype.execute=function(e){var t=e.shape;return GA(t),t.labelTarget=e.labelTarget,$A.call(this,e)};var zA=Wn.prototype.revert;Vi.prototype.revert=function(e){return e.shape.labelTarget=null,zA.call(this,e)};function GA(e){["width","height"].forEach(function(t){typeof e[t]=="undefined"&&(e[t]=0)})}function Wi(e,t){this._canvas=e,this._modeling=t}Wi.$inject=["canvas","modeling"];Wi.prototype.preExecute=function(e){var t=this._modeling,n=e.connection;kn(n.incoming,function(r){t.removeConnection(r,{nested:!0})}),kn(n.outgoing,function(r){t.removeConnection(r,{nested:!0})})};Wi.prototype.execute=function(e){var t=e.connection,n=t.parent;return e.parent=n,e.parentIndex=co(n.children,t),e.source=t.source,e.target=t.target,this._canvas.removeConnection(t),t.source=null,t.target=null,t};Wi.prototype.revert=function(e){var t=e.connection,n=e.parent,r=e.parentIndex;return t.source=e.source,t.target=e.target,Ae(n.children,t,r),this._canvas.addConnection(t,n),t};N();function Us(e,t){this._modeling=e,this._elementRegistry=t}Us.$inject=["modeling","elementRegistry"];Us.prototype.postExecute=function(e){var t=this._modeling,n=this._elementRegistry,r=e.elements;E(r,function(i){n.get(i.id)&&(i.waypoints?t.removeConnection(i):t.removeShape(i))})};function Ui(e,t){this._canvas=e,this._modeling=t}Ui.$inject=["canvas","modeling"];Ui.prototype.preExecute=function(e){var t=this._modeling,n=e.shape;kn(n.incoming,function(r){t.removeConnection(r,{nested:!0})}),kn(n.outgoing,function(r){t.removeConnection(r,{nested:!0})}),kn(n.children,function(r){de(r)?t.removeConnection(r,{nested:!0}):t.removeShape(r,{nested:!0})})};Ui.prototype.execute=function(e){var t=this._canvas,n=e.shape,r=n.parent;return e.oldParent=r,e.oldParentIndex=co(r.children,n),t.removeShape(n),n};Ui.prototype.revert=function(e){var t=this._canvas,n=e.shape,r=e.oldParent,i=e.oldParentIndex;return Ae(r.children,n,i),t.addShape(n,r),n};N();function ia(e){this._modeling=e}ia.$inject=["modeling"];var y_={x:"y",y:"x"};ia.prototype.preExecute=function(e){var t=this._modeling,n=e.groups,r=e.axis,i=e.dimension;function o(v,w){v.range.min=Math.min(w[r],v.range.min),v.range.max=Math.max(w[r]+w[i],v.range.max)}function a(v){return v[r]+v[i]/2}function s(v){return v.length-1}function c(v){return v.max-v.min}function u(v,w){var S={y:0};S[r]=v-a(w),S[r]&&(S[y_[r]]=0,t.moveElements([w],S,w.parent))}var p=n[0],l=s(n),f=n[l],d,m,g=0;E(n,function(v,w){var S,x,b;if(v.elements.length<2){w&&w!==n.length-1&&(o(v,v.elements[0]),g+=c(v.range));return}S=At(v.elements,r),x=S[0],w===l&&(x=S[s(S)]),b=a(x),v.range=null,E(S,function(R){if(u(b,R),v.range===null){v.range={min:R[r],max:R[r]+R[i]};return}o(v,R)}),w&&w!==n.length-1&&(g+=c(v.range))}),m=Math.abs(f.range.min-p.range.max),d=Math.round((m-g)/(n.length-1)),!(d<n.length-1)&&E(n,function(v,w){var S={},x;v===p||v===f||(x=n[w-1],v.range.max=0,E(v.elements,function(b,R){S[y_[r]]=0,S[r]=x.range.max-b[r]+d,v.range.min!==b[r]&&(S[r]+=b[r]-v.range.min),S[r]&&t.moveElements([b],S,b.parent),v.range.max=Math.max(b[r]+b[i],R?v.range.max:0)}))})};ia.prototype.postExecute=function(e){};N();function oa(e,t){this._layouter=e,this._canvas=t}oa.$inject=["layouter","canvas"];oa.prototype.execute=function(e){var t=e.connection,n=t.waypoints;return C(e,{oldWaypoints:n}),t.waypoints=this._layouter.layoutConnection(t,e.hints),t};oa.prototype.revert=function(e){var t=e.connection;return t.waypoints=e.oldWaypoints,t};N();function qs(){}qs.prototype.execute=function(e){var t=e.connection,n=e.delta,r=e.newParent||t.parent,i=e.newParentIndex,o=t.parent;return e.oldParent=o,e.oldParentIndex=Oe(o.children,t),Ae(r.children,t,i),t.parent=r,E(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};qs.prototype.revert=function(e){var t=e.connection,n=t.parent,r=e.oldParent,i=e.oldParentIndex,o=e.delta;return Oe(n.children,t),Ae(r.children,t,i),t.parent=r,E(t.waypoints,function(a){a.x-=o.x,a.y-=o.y,a.original&&(a.original.x-=o.x,a.original.y-=o.y)}),t};N();N();function Ks(){this.allShapes={},this.allConnections={},this.enclosedElements={},this.enclosedConnections={},this.topLevel={}}Ks.prototype.add=function(e,t){return this.addAll([e],t)};Ks.prototype.addAll=function(e,t){var n=hm(e,!!t,this);return C(this,n),this};function mi(e){this._modeling=e}mi.prototype.moveRecursive=function(e,t,n){return e?this.moveClosure(this.getClosure(e),t,n):[]};mi.prototype.moveClosure=function(e,t,n,r,i){var o=this._modeling,a=e.allShapes,s=e.allConnections,c=e.enclosedConnections,u=e.topLevel,p=!1;i&&i.parent===n&&(p=!0),E(a,function(l){o.moveShape(l,t,u[l.id]&&!p&&n,{recurse:!1,layout:!1})}),E(s,function(l){var f=!!a[l.source.id],d=!!a[l.target.id];c[l.id]&&f&&d?o.moveConnection(l,t,u[l.id]&&!p&&n):o.layoutConnection(l,{connectionStart:f&&Uo(l,l.source,t),connectionEnd:d&&qo(l,l.target,t)})})};mi.prototype.getClosure=function(e){return new Ks().addAll(e,!0)};function aa(e){this._helper=new mi(e)}aa.$inject=["modeling"];aa.prototype.preExecute=function(e){e.closure=this._helper.getClosure(e.shapes)};aa.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)};N();function Br(e){this._modeling=e,this._helper=new mi(e)}Br.$inject=["modeling"];Br.prototype.execute=function(e){var t=e.shape,n=e.delta,r=e.newParent||t.parent,i=e.newParentIndex,o=t.parent;return e.oldBounds=mt(t,["x","y","width","height"]),e.oldParent=o,e.oldParentIndex=Oe(o.children,t),Ae(r.children,t,i),C(t,{parent:r,x:t.x+n.x,y:t.y+n.y}),t};Br.prototype.postExecute=function(e){var t=e.shape,n=e.delta,r=e.hints,i=this._modeling;r.layout!==!1&&(E(t.incoming,function(o){i.layoutConnection(o,{connectionEnd:qo(o,t,n)})}),E(t.outgoing,function(o){i.layoutConnection(o,{connectionStart:Uo(o,t,n)})})),r.recurse!==!1&&this.moveChildren(e)};Br.prototype.revert=function(e){var t=e.shape,n=e.oldParent,r=e.oldParentIndex,i=e.delta;return Ae(n.children,t,r),C(t,{parent:n,x:t.x-i.x,y:t.y-i.y}),t};Br.prototype.moveChildren=function(e){var t=e.delta,n=e.shape;this._helper.moveRecursive(n.children,t,null)};Br.prototype.getNewParent=function(e){return e.newParent||e.shape.parent};N();function qi(e){this._modeling=e}qi.$inject=["modeling"];qi.prototype.execute=function(e){var t=e.newSource,n=e.newTarget,r=e.connection,i=e.dockingOrPoints;if(!t&&!n)throw new Error("newSource or newTarget required");return q(i)&&(e.oldWaypoints=r.waypoints,r.waypoints=i),t&&(e.oldSource=r.source,r.source=t),n&&(e.oldTarget=r.target,r.target=n),r};qi.prototype.postExecute=function(e){var t=e.connection,n=e.newSource,r=e.newTarget,i=e.dockingOrPoints,o=e.hints||{},a={};o.connectionStart&&(a.connectionStart=o.connectionStart),o.connectionEnd&&(a.connectionEnd=o.connectionEnd),o.layoutConnection!==!1&&(n&&(!r||o.docking==="source")&&(a.connectionStart=a.connectionStart||__(q(i)?i[0]:i)),r&&(!n||o.docking==="target")&&(a.connectionEnd=a.connectionEnd||__(q(i)?i[i.length-1]:i)),o.newWaypoints&&(a.waypoints=o.newWaypoints),this._modeling.layoutConnection(t,a))};qi.prototype.revert=function(e){var t=e.oldSource,n=e.oldTarget,r=e.oldWaypoints,i=e.connection;return t&&(i.source=t),n&&(i.target=n),r&&(i.waypoints=r),i};function __(e){return e.original||e}N();function Un(e,t){this._modeling=e,this._rules=t}Un.$inject=["modeling","rules"];Un.prototype.preExecute=function(e){var t=this,n=this._modeling,r=this._rules,i=e.oldShape,o=e.newData,a=e.hints||{},s;function c(m,g,v){return r.allowed("connection.reconnect",{connection:v,source:m,target:g})}var u={x:o.x,y:o.y},p={x:i.x,y:i.y,width:i.width,height:i.height};s=e.newShape=e.newShape||t.createShape(o,u,i.parent,a),i.host&&n.updateAttachment(s,i.host);var l;a.moveChildren!==!1&&(l=i.children.slice(),n.moveElements(l,{x:0,y:0},s,a));var f=i.incoming.slice(),d=i.outgoing.slice();E(f,function(m){var g=m.source,v=c(g,s,m);v&&t.reconnectEnd(m,s,ui(m,s,p),a)}),E(d,function(m){var g=m.target,v=c(s,g,m);v&&t.reconnectStart(m,s,ci(m,s,p),a)})};Un.prototype.postExecute=function(e){var t=e.oldShape;this._modeling.removeShape(t)};Un.prototype.execute=function(e){};Un.prototype.revert=function(e){};Un.prototype.createShape=function(e,t,n,r){return this._modeling.createShape(e,t,n,r)};Un.prototype.reconnectStart=function(e,t,n,r){this._modeling.reconnectStart(e,t,n,r)};Un.prototype.reconnectEnd=function(e,t,n,r){this._modeling.reconnectEnd(e,t,n,r)};N();function Ki(e){this._modeling=e}Ki.$inject=["modeling"];Ki.prototype.execute=function(e){var t=e.shape,n=e.newBounds,r=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(r&&(n.width<r.width||n.height<r.height))throw new Error("width and height cannot be less than minimum height and width");if(!r&&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},C(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t};Ki.prototype.postExecute=function(e){var t=this._modeling,n=e.shape,r=e.oldBounds,i=e.hints||{};i.layout!==!1&&(E(n.incoming,function(o){t.layoutConnection(o,{connectionEnd:ui(o,n,r)})}),E(n.outgoing,function(o){t.layoutConnection(o,{connectionStart:ci(o,n,r)})}))};Ki.prototype.revert=function(e){var t=e.shape,n=e.oldBounds;return C(t,{width:n.width,height:n.height,x:n.x,y:n.y}),t};N();function fr(e){this._modeling=e}fr.$inject=["modeling"];fr.prototype.preExecute=function(e){var t=e.delta,n=e.direction,r=e.movingShapes,i=e.resizingShapes,o=e.start,a={};this.moveShapes(r,t),E(i,function(s){a[s.id]=WA(s)}),this.resizeShapes(i,t,n),this.updateConnectionWaypoints(r_(r,i),t,n,o,r,i,a)};fr.prototype.execute=function(){};fr.prototype.revert=function(){};fr.prototype.moveShapes=function(e,t){var n=this;E(e,function(r){n._modeling.moveShape(r,t,null,{autoResize:!1,layout:!1,recurse:!1})})};fr.prototype.resizeShapes=function(e,t,n){var r=this;E(e,function(i){var o=i_(i,n,t);r._modeling.resizeShape(i,o,null,{attachSupport:!1,autoResize:!1,layout:!1})})};fr.prototype.updateConnectionWaypoints=function(e,t,n,r,i,o,a){var s=this,c=i.concat(o);E(e,function(u){var p=u.source,l=u.target,f=VA(u),d=E_(n),m={};hi(c,p)&&hi(c,l)?(f=je(f,function(g){return x_(g,r,n)&&(g[d]=g[d]+t[d]),g.original&&x_(g.original,r,n)&&(g.original[d]=g.original[d]+t[d]),g}),s._modeling.updateWaypoints(u,f,{labelBehavior:!1})):(hi(c,p)||hi(c,l))&&(hi(i,p)?m.connectionStart=Uo(u,p,t):hi(i,l)?m.connectionEnd=qo(u,l,t):hi(o,p)?m.connectionStart=ci(u,p,a[p.id]):hi(o,l)&&(m.connectionEnd=ui(u,l,a[l.id])),s._modeling.layoutConnection(u,m))})};function b_(e){return C({},e)}function VA(e){return je(e.waypoints,function(t){return t=b_(t),t.original&&(t.original=b_(t.original)),t})}function E_(e){switch(e){case"n":return"y";case"w":return"x";case"s":return"y";case"e":return"x"}}function x_(e,t,n){var r=E_(n);if(/e|s/.test(n))return e[r]>t;if(/n|w/.test(n))return e[r]<t}function hi(e,t){return e.indexOf(t)!==-1}function WA(e){return{x:e.x,y:e.y,height:e.height,width:e.width}}N();function sa(e){this._modeling=e}sa.$inject=["modeling"];sa.prototype.execute=function(e){var t=e.shape,n=t.children;e.oldChildrenVisibility=w_(n),t.collapsed=!t.collapsed;var r=S_(n,t.collapsed);return[t].concat(r)};sa.prototype.revert=function(e){var t=e.shape,n=e.oldChildrenVisibility,r=t.children,i=C_(r,n);return t.collapsed=!t.collapsed,[t].concat(i)};function w_(e){var t={};return E(e,function(n){t[n.id]=n.hidden,n.children&&(t=C({},t,w_(n.children)))}),t}function S_(e,t){var n=[];return E(e,function(r){r.hidden=t,n=n.concat(r),r.children&&(n=n.concat(S_(r.children,r.collapsed||t)))}),n}function C_(e,t){var n=[];return E(e,function(r){r.hidden=t[r.id],n=n.concat(r),r.children&&(n=n.concat(C_(r.children,t)))}),n}function ca(e){this._modeling=e}ca.$inject=["modeling"];ca.prototype.execute=function(e){var t=e.shape,n=e.newHost,r=t.host;return e.oldHost=r,e.attacherIdx=R_(r,t),P_(n,t),t.host=n,t};ca.prototype.revert=function(e){var t=e.shape,n=e.newHost,r=e.oldHost,i=e.attacherIdx;return t.host=r,R_(n,t),P_(r,t,i),t};function R_(e,t){return Oe(e&&e.attachers,t)}function P_(e,t,n){if(e){var r=e.attachers;r||(e.attachers=r=[]),Ae(r,t,n)}}function Ys(){}Ys.prototype.execute=function(e){var t=e.connection,n=e.newWaypoints;return e.oldWaypoints=t.waypoints,t.waypoints=n,t};Ys.prototype.revert=function(e){var t=e.connection,n=e.oldWaypoints;return t.waypoints=n,t};function De(e,t,n){this._eventBus=e,this._elementFactory=t,this._commandStack=n;var r=this;e.on("diagram.init",function(){r.registerHandlers(n)})}De.$inject=["eventBus","elementFactory","commandStack"];De.prototype.getHandlers=function(){return{"shape.append":na,"shape.create":Wn,"shape.delete":Ui,"shape.move":Br,"shape.resize":Ki,"shape.replace":Un,"shape.toggleCollapse":sa,spaceTool:fr,"label.create":Vi,"connection.create":ra,"connection.delete":Wi,"connection.move":qs,"connection.layout":oa,"connection.updateWaypoints":Ys,"connection.reconnect":qi,"elements.create":Ws,"elements.move":aa,"elements.delete":Us,"elements.distribute":ia,"elements.align":ta,"element.updateAttachment":ca}};De.prototype.registerHandlers=function(e){E(this.getHandlers(),function(t,n){e.registerHandler(n,t)})};De.prototype.moveShape=function(e,t,n,r,i){typeof r=="object"&&(i=r,r=null);var o={shape:e,delta:t,newParent:n,newParentIndex:r,hints:i||{}};this._commandStack.execute("shape.move",o)};De.prototype.updateAttachment=function(e,t){var n={shape:e,newHost:t};this._commandStack.execute("element.updateAttachment",n)};De.prototype.moveElements=function(e,t,n,r){r=r||{};var i=r.attach,o=n,a;i===!0?(a=n,o=n.parent):i===!1&&(a=null);var s={shapes:e,delta:t,newParent:o,newHost:a,hints:r};this._commandStack.execute("elements.move",s)};De.prototype.moveConnection=function(e,t,n,r,i){typeof r=="object"&&(i=r,r=void 0);var o={connection:e,delta:t,newParent:n,newParentIndex:r,hints:i||{}};this._commandStack.execute("connection.move",o)};De.prototype.layoutConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.layout",n)};De.prototype.createConnection=function(e,t,n,r,i,o){typeof n=="object"&&(o=i,i=r,r=n,n=void 0),r=this._create("connection",r);var a={source:e,target:t,parent:i,parentIndex:n,connection:r,hints:o};return this._commandStack.execute("connection.create",a),a.connection};De.prototype.createShape=function(e,t,n,r,i){typeof r!="number"&&(i=r,r=void 0),i=i||{};var o=i.attach,a,s;e=this._create("shape",e),o?(a=n.parent,s=n):a=n;var c={position:t,shape:e,parent:a,parentIndex:r,host:s,hints:i};return this._commandStack.execute("shape.create",c),c.shape};De.prototype.createElements=function(e,t,n,r,i){q(e)||(e=[e]),typeof r!="number"&&(i=r,r=void 0),i=i||{};var o={position:t,elements:e,parent:n,parentIndex:r,hints:i};return this._commandStack.execute("elements.create",o),o.elements};De.prototype.createLabel=function(e,t,n,r){n=this._create("label",n);var i={labelTarget:e,position:t,parent:r||e.parent,shape:n};return this._commandStack.execute("label.create",i),i.shape};De.prototype.appendShape=function(e,t,n,r,i){i=i||{},t=this._create("shape",t);var o={source:e,position:n,target:r,shape:t,connection:i.connection,connectionParent:i.connectionParent,hints:i};return this._commandStack.execute("shape.append",o),o.shape};De.prototype.removeElements=function(e){var t={elements:e};this._commandStack.execute("elements.delete",t)};De.prototype.distributeElements=function(e,t,n){var r={groups:e,axis:t,dimension:n};this._commandStack.execute("elements.distribute",r)};De.prototype.removeShape=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.delete",n)};De.prototype.removeConnection=function(e,t){var n={connection:e,hints:t||{}};this._commandStack.execute("connection.delete",n)};De.prototype.replaceShape=function(e,t,n){var r={oldShape:e,newData:t,hints:n||{}};return this._commandStack.execute("shape.replace",r),r.newShape};De.prototype.alignElements=function(e,t){var n={elements:e,alignment:t};this._commandStack.execute("elements.align",n)};De.prototype.resizeShape=function(e,t,n,r){var i={shape:e,newBounds:t,minBounds:n,hints:r};this._commandStack.execute("shape.resize",i)};De.prototype.createSpace=function(e,t,n,r,i){var o={delta:n,direction:r,movingShapes:e,resizingShapes:t,start:i};this._commandStack.execute("spaceTool",o)};De.prototype.updateWaypoints=function(e,t,n){var r={connection:e,newWaypoints:t,hints:n||{}};this._commandStack.execute("connection.updateWaypoints",r)};De.prototype.reconnect=function(e,t,n,r,i){var o={connection:e,newSource:t,newTarget:n,dockingOrPoints:r,hints:i||{}};this._commandStack.execute("connection.reconnect",o)};De.prototype.reconnectStart=function(e,t,n,r){r||(r={}),this.reconnect(e,t,e.target,n,C(r,{docking:"source"}))};De.prototype.reconnectEnd=function(e,t,n,r){r||(r={}),this.reconnect(e,e.source,t,n,C(r,{docking:"target"}))};De.prototype.connect=function(e,t,n,r){return this.createConnection(e,t,n||{},e.parent,r)};De.prototype._create=function(e,t){return zm(t)?t:this._elementFactory.create(e,t)};De.prototype.toggleCollapse=function(e,t){var n={shape:e,hints:t||{}};this._commandStack.execute("shape.toggleCollapse",n)};N();function Yi(e){this._elementRegistry=e}Yi.$inject=["elementRegistry"];Yi.prototype.execute=function(e){var t=e.element,n=e.moddleElement,r=e.properties;if(!n)throw new Error("<moddleElement> required");var i=e.changed||this._getVisualReferences(n).concat(t),o=e.oldProperties||UA(n,bi(r));return A_(n,r),e.oldProperties=o,e.changed=i,i};Yi.prototype.revert=function(e){var t=e.oldProperties,n=e.moddleElement,r=e.changed;return A_(n,t),r};Yi.prototype._getVisualReferences=function(e){var t=this._elementRegistry;return h(e,"bpmn:DataObject")?qA(e,t):[]};function UA(e,t){return Ge(t,function(n,r){return n[r]=e.get(r),n},{})}function A_(e,t){E(t,function(n,r){e.set(r,n)})}function qA(e,t){return t.filter(function(n){return h(n,"bpmn:DataObjectReference")&&j(n).dataObjectRef===e})}N();var Xs="default",Ir="id",T_="di",KA={width:0,height:0};function Xi(e,t,n,r){this._elementRegistry=e,this._moddle=t,this._modeling=n,this._textRenderer=r}Xi.$inject=["elementRegistry","moddle","modeling","textRenderer"];Xi.prototype.execute=function(e){var t=e.element,n=[t];if(!t)throw new Error("element required");var r=this._elementRegistry,i=this._moddle.ids,o=t.businessObject,a=JA(e.properties),s=e.oldProperties||YA(t,a);return M_(a,o)&&(i.unclaim(o[Ir]),r.updateId(t,a[Ir]),i.claim(a[Ir],o)),Xs in a&&(a[Xs]&&n.push(r.get(a[Xs].id)),o[Xs]&&n.push(r.get(o[Xs].id))),D_(t,a),e.oldProperties=s,e.changed=n,n};Xi.prototype.postExecute=function(e){var t=e.element,n=t.label,r=n&&j(n).name;if(r){var i=this._textRenderer.getExternalLabelBounds(n,r);this._modeling.resizeShape(n,i,KA)}};Xi.prototype.revert=function(e){var t=e.element,n=e.properties,r=e.oldProperties,i=t.businessObject,o=this._elementRegistry,a=this._moddle.ids;return D_(t,r),M_(n,i)&&(a.unclaim(n[Ir]),o.updateId(t,r[Ir]),a.claim(r[Ir],i)),e.changed};function M_(e,t){return Ir in e&&e[Ir]!==t[Ir]}function YA(e,t){var n=bi(t),r=e.businessObject,i=ce(e);return Ge(n,function(o,a){return a!==T_?o[a]=r.get(a):o[a]=XA(i,bi(t.di)),o},{})}function XA(e,t){return Ge(t,function(n,r){return n[r]=e&&e.get(r),n},{})}function D_(e,t){var n=e.businessObject,r=ce(e);E(t,function(i,o){o!==T_?n.set(o,i):r&&ZA(r,i)})}function ZA(e,t){E(t,function(n,r){e.set(r,n)})}var QA=["default"];function JA(e){var t=C({},e);return QA.forEach(function(n){n in e&&(t[n]=j(t[n]))}),t}function ua(e,t){this._canvas=e,this._modeling=t}ua.$inject=["canvas","modeling"];ua.prototype.execute=function(e){var t=this._canvas,n=e.newRoot,r=n.businessObject,i=t.getRootElement(),o=i.businessObject,a=o.$parent,s=ce(i);return t.setRootElement(n),t.removeRootElement(i),Ae(a.rootElements,r),r.$parent=a,Oe(a.rootElements,o),o.$parent=null,i.di=null,s.bpmnElement=r,n.di=s,e.oldRoot=i,[]};ua.prototype.revert=function(e){var t=this._canvas,n=e.newRoot,r=n.businessObject,i=e.oldRoot,o=i.businessObject,a=r.$parent,s=ce(n);return t.setRootElement(i),t.removeRootElement(n),Oe(a.rootElements,r),r.$parent=null,Ae(a.rootElements,o),o.$parent=a,n.di=null,s.bpmnElement=o,i.di=s,[]};N();function Zs(e,t){this._modeling=e,this._spaceTool=t}Zs.$inject=["modeling","spaceTool"];Zs.prototype.preExecute=function(e){var t=this._spaceTool,n=this._modeling,r=e.shape,i=e.location,o=Bt(r),a=o===r,s=a?r:r.parent,c=yn(s),u=Me(r);if(u?i==="left"?i="top":i==="right"&&(i="bottom"):i==="top"?i="left":i==="bottom"&&(i="right"),!c.length){var p=u?{x:r.x+on,y:r.y,width:r.width-on,height:r.height}:{x:r.x,y:r.y+on,width:r.width,height:r.height-on};n.createShape({type:"bpmn:Lane",isHorizontal:u},p,s)}var l=[];In(o,function(b){return l.push(b),b.label&&l.push(b.label),b===r?[]:Q(b.children,function(R){return R!==r})});var f,d,m,g,v;i==="top"?(f=-120,d=r.y,m=d+10,g="n",v="y"):i==="left"?(f=-120,d=r.x,m=d+10,g="w",v="x"):i==="bottom"?(f=120,d=r.y+r.height,m=d-10,g="s",v="y"):i==="right"&&(f=120,d=r.x+r.width,m=d-10,g="e",v="x");var w=t.calculateAdjustments(l,v,f,m),S=u?{x:0,y:f}:{x:f,y:0};t.makeSpace(w.movingShapes,w.resizingShapes,S,g,m);var x=u?{x:r.x+(a?on:0),y:d-(i==="top"?120:0),width:r.width-(a?on:0),height:120}:{x:d-(i==="left"?120:0),y:r.y+(a?on:0),width:120,height:r.height-(a?on:0)};e.newLane=n.createShape({type:"bpmn:Lane",isHorizontal:u},x,s)};function Qs(e){this._modeling=e}Qs.$inject=["modeling"];Qs.prototype.preExecute=function(e){var t=this._modeling,n=e.shape,r=e.count,i=yn(n),o=i.length;if(o>r)throw new Error(`more than <${r}> child lanes`);var a=Me(n),s=a?n.height:n.width,c=Math.round(s/r),u,p,l,f;for(f=0;f<r;f++)f===r-1?u=s-c*f:u=c,p=a?{x:n.x+on,y:n.y+f*c,width:n.width-on,height:u}:{x:n.x+f*c,y:n.y+on,width:u,height:n.height-on},f<o?t.resizeShape(i[f],p):(l={type:"bpmn:Lane",isHorizontal:a},t.createShape(l,p,n))};function Zi(e,t){this._modeling=e,this._spaceTool=t}Zi.$inject=["modeling","spaceTool"];Zi.prototype.preExecute=function(e){var t=e.shape,n=e.newBounds,r=e.balanced;r!==!1?this.resizeBalanced(t,n):this.resizeSpace(t,n)};Zi.prototype.resizeBalanced=function(e,t){var n=this._modeling,r=Lg(e,t);n.resizeShape(e,t),r.forEach(function(i){n.resizeShape(i.shape,i.newBounds)})};Zi.prototype.resizeSpace=function(e,t){var n=this._spaceTool,r=Z(e),i=Z(t),o=ep(i,r),a=Bt(e),s=[],c=[];In(a,function(m){return s.push(m),(h(m,"bpmn:Lane")||h(m,"bpmn:Participant"))&&c.push(m),m.children});var u,p,l,f,d;(o.bottom||o.top)&&(u=o.bottom||o.top,p=e.y+(o.bottom?e.height:0)+(o.bottom?-10:10),l=o.bottom?"s":"n",f=o.top>0||o.bottom<0?-u:u,d=n.calculateAdjustments(s,"y",f,p),n.makeSpace(d.movingShapes,d.resizingShapes,{x:0,y:u},l)),(o.left||o.right)&&(u=o.right||o.left,p=e.x+(o.right?e.width:0)+(o.right?-10:100),l=o.right?"e":"w",f=o.left>0||o.right<0?-u:u,d=n.calculateAdjustments(c,"x",f,p),n.makeSpace(d.movingShapes,d.resizingShapes,{x:u,y:0},l))};var Js="flowNodeRef",Qf="lanes";function Qi(e){this._elementRegistry=e}Qi.$inject=["elementRegistry"];Qi.prototype._computeUpdates=function(e,t){var n=[],r=[],i={},o=[];function a(p,l){var f=Z(l),d={x:p.x+p.width/2,y:p.y+p.height/2};return d.x>f.left&&d.x<f.right&&d.y>f.top&&d.y<f.bottom}function s(p){n.indexOf(p)===-1&&(o.push(p),n.push(p))}function c(p){var l=Bt(p);return i[l.id]||(i[l.id]=zo(l)),i[l.id]}function u(p){if(!p.parent)return[];var l=c(p);return l.filter(function(f){return a(p,f)}).map(function(f){return f.businessObject})}return t.forEach(function(p){var l=Bt(p);if(!(!l||n.indexOf(l)!==-1)){var f=l.children.filter(function(d){return h(d,"bpmn:FlowNode")});f.forEach(s),n.push(l)}}),e.forEach(s),o.forEach(function(p){var l=p.businessObject,f=l.get(Qf),d=f.slice(),m=u(p);r.push({flowNode:l,remove:d,add:m})}),t.forEach(function(p){var l=p.businessObject;p.parent||l.get(Js).forEach(function(f){r.push({flowNode:f,remove:[l],add:[]})})}),r};Qi.prototype.execute=function(e){var t=e.updates;return t||(t=e.updates=this._computeUpdates(e.flowNodeShapes,e.laneShapes)),t.forEach(function(n){var r=n.flowNode,i=r.get(Qf);n.remove.forEach(function(o){Oe(i,o),Oe(o.get(Js),r)}),n.add.forEach(function(o){Ae(i,o),Ae(o.get(Js),r)})}),[]};Qi.prototype.revert=function(e){var t=e.updates;return t.forEach(function(n){var r=n.flowNode,i=r.get(Qf);n.add.forEach(function(o){Oe(i,o),Oe(o.get(Js),r)}),n.remove.forEach(function(o){Ae(i,o),Ae(o.get(Js),r)})}),[]};function pa(e){this._moddle=e}pa.$inject=["moddle"];pa.prototype.execute=function(e){var t=this._moddle.ids,n=e.id,r=e.element,i=e.claiming;return i?t.claim(n,r):t.unclaim(n),[]};pa.prototype.revert=function(e){var t=this._moddle.ids,n=e.id,r=e.element,i=e.claiming;return i?t.unclaim(n):t.claim(n,r),[]};N();var eT={fill:void 0,stroke:void 0};function ec(e){this._commandStack=e,this._normalizeColor=function(t){if(t){if(st(t)){var n=tT(t);if(n)return n}throw new Error(`invalid color value: ${t}`)}}}ec.$inject=["commandStack"];ec.prototype.postExecute=function(e){var t=e.elements,n=e.colors||eT,r=this,i={};"fill"in n&&C(i,{"background-color":this._normalizeColor(n.fill)}),"stroke"in n&&C(i,{"border-color":this._normalizeColor(n.stroke)}),E(t,function(o){var a=de(o)?mt(i,["border-color"]):i,s=ce(o);if(nT(a),ee(o)){if(!s||!h(s.label,"bpmndi:BPMNLabel"))return;r._commandStack.execute("element.updateModdleProperties",{element:o,moddleElement:s.label,properties:{color:i["border-color"]}})}else{if(!te(s,["bpmndi:BPMNEdge","bpmndi:BPMNShape"]))return;r._commandStack.execute("element.updateProperties",{element:o,properties:{di:a}})}})};function tT(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 nT(e){"border-color"in e&&(e.stroke=e["border-color"]),"background-color"in e&&(e.fill=e["background-color"])}var rT={width:0,height:0};function Bp(e,t,n){function r(c,u){var p=c.label||c,l=c.labelTarget||c;return Eh(p,u,l!==p),[p,l]}function i(c){var u=c.element,p=u.businessObject,l=c.newLabel;if(!ee(u)&&mn(u)&&!Xr(u)&&!k_(l)){var f=7,d=La(u);d={x:d.x,y:d.y+f},e.createLabel(u,d,{id:p.id+"_label",businessObject:p,di:u.di})}}function o(c){return c.oldLabel=gt(c.element),r(c.element,c.newLabel)}function a(c){return r(c.element,c.oldLabel)}function s(c){var u=c.element,p=u.label||u,l=c.newLabel,f=c.newBounds,d=c.hints||{};if(!(!ee(p)&&!h(p,"bpmn:TextAnnotation"))){if(ee(p)&&k_(l)){d.removeShape!==!1&&e.removeShape(p,{unsetLabel:!1});return}var m=gt(u);typeof f=="undefined"&&(f=t.getExternalLabelBounds(p,m)),f&&e.resizeShape(p,f,rT)}}this.preExecute=i,this.execute=o,this.revert=a,this.postExecute=s}Bp.$inject=["modeling","textRenderer","bpmnFactory"];function k_(e){return!e||!e.trim()}function Pt(e,t,n,r){De.call(this,e,t,n),this._bpmnRules=r}B(Pt,De);Pt.$inject=["eventBus","elementFactory","commandStack","bpmnRules"];Pt.prototype.getHandlers=function(){var e=De.prototype.getHandlers.call(this);return e["element.updateModdleProperties"]=Yi,e["element.updateProperties"]=Xi,e["canvas.updateRoot"]=ua,e["lane.add"]=Zs,e["lane.resize"]=Zi,e["lane.split"]=Qs,e["lane.updateRefs"]=Qi,e["id.updateClaim"]=pa,e["element.setColor"]=ec,e["element.updateLabel"]=Bp,e};Pt.prototype.updateLabel=function(e,t,n,r){this._commandStack.execute("element.updateLabel",{element:e,newLabel:t,newBounds:n,hints:r||{}})};Pt.prototype.connect=function(e,t,n,r){var i=this._bpmnRules;if(n||(n=i.canConnect(e,t)),!!n)return this.createConnection(e,t,n,e.parent,r)};Pt.prototype.updateModdleProperties=function(e,t,n){this._commandStack.execute("element.updateModdleProperties",{element:e,moddleElement:t,properties:n})};Pt.prototype.updateProperties=function(e,t){this._commandStack.execute("element.updateProperties",{element:e,properties:t})};Pt.prototype.resizeLane=function(e,t,n){this._commandStack.execute("lane.resize",{shape:e,newBounds:t,balanced:n})};Pt.prototype.addLane=function(e,t){var n={shape:e,location:t};return this._commandStack.execute("lane.add",n),n.newLane};Pt.prototype.splitLane=function(e,t){this._commandStack.execute("lane.split",{shape:e,count:t})};Pt.prototype.makeCollaboration=function(){var e=this._create("root",{type:"bpmn:Collaboration"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e};Pt.prototype.makeProcess=function(){var e=this._create("root",{type:"bpmn:Process"}),t={newRoot:e};return this._commandStack.execute("canvas.updateRoot",t),e};Pt.prototype.updateLaneRefs=function(e,t){this._commandStack.execute("lane.updateRefs",{flowNodeShapes:e,laneShapes:t})};Pt.prototype.claimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t,claiming:!0})};Pt.prototype.unclaimId=function(e,t){this._commandStack.execute("id.updateClaim",{id:e,element:t})};Pt.prototype.setColor=function(e,t){e.length||(e=[e]),this._commandStack.execute("element.setColor",{elements:e,colors:t})};N();function Ip(){}Ip.prototype.layoutConnection=function(e,t){return t=t||{},[t.connectionStart||X(t.source||e.source),t.connectionEnd||X(t.target||e.target)]};N();var Lp=20,iT=5,jp=Math.round,N_=20,oT={"h:h":20,"v:v":20,"h:v":-10,"v:h":-10};function aT(e,t){return!{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/./,v:/./}[t].test(e)}function sT(e,t){return{t:/top/,r:/right/,b:/bottom/,l:/left/,h:/left|right/,v:/top|bottom/}[e].test(t)}function L_(e,t,n){var r=He(t,e,iT),i=n.split(":")[0],o=jp((t.x-e.x)/2+e.x),a=jp((t.y-e.y)/2+e.y),s,c,u=sT(i,r),p=/h|r|l/.test(i),l=!1,f=!1;return u?(s=p?{x:o,y:e.y}:{x:e.x,y:a},c=p?"h:h":"v:v"):(l=aT(r,i),c=p?"h:v":"v:h",l?p?(f=a===e.y,s={x:e.x+Lp*(/l/.test(i)?-1:1),y:f?a+Lp:a}):(f=o===e.x,s={x:f?o+Lp:o,y:e.y+Lp*(/t/.test(i)?-1:1)}):s={x:o,y:a}),{waypoints:Jf(e,s,c).concat(s),directions:c,turnNextDirections:f}}function cT(e,t,n){return L_(e,t,n)}function uT(e,t,n){var r=L_(t,e,O_(n));return{waypoints:r.waypoints.slice().reverse(),directions:O_(r.directions),turnNextDirections:r.turnNextDirections}}function pT(e,t){var n=e.directions.split(":")[1],r=t.directions.split(":")[0];e.turnNextDirections&&(n=n=="h"?"v":"h"),t.turnNextDirections&&(r=r=="h"?"v":"h");var i=n+":"+r,o=Jf(e.waypoints[e.waypoints.length-1],t.waypoints[0],i);return{waypoints:o,directions:i}}function O_(e){return e.split(":").reverse().join(":")}function lT(e,t,n){var r=jp((t.x-e.x)/2+e.x),i=jp((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:r,y:e.y},{x:r,y:t.y}];if(n==="v:v")return[{x:e.x,y:i},{x:t.x,y:i}];throw new Error("invalid directions: can only handle varians of [hv]:[hv]")}function Jf(e,t,n){if(n=n||"h:h",!_T(n))throw new Error("unknown directions: <"+n+">: must be specified as <start>:<end> with start/end in { h,v,t,r,b,l }");if(F_(n)){var r=cT(e,t,n),i=uT(e,t,n),o=pT(r,i);return[].concat(r.waypoints,o.waypoints,i.waypoints)}return lT(e,t,n)}function fT(e,t,n){var r=Jf(e,t,n);return r.unshift(e),r.push(t),td(r)}function dT(e,t,n,r,i){var o=i&&i.preferredLayouts||[],a=hl(o,"straight")[0]||"h:h",s=oT[a]||0,c=He(e,t,s),u=yT(c,a);n=n||X(e),r=r||X(t);var p=u.split(":"),l=I_(n,e,p[0],bT(c)),f=I_(r,t,p[1],c);return fT(l,f,u)}function j_(e,t,n,r,i,o){q(n)&&(i=n,o=r,n=X(e),r=X(t)),o=C({preferredLayouts:[]},o),i=i||[];var a=o.preferredLayouts,s=a.indexOf("straight")!==-1,c;return c=s&&hT(e,t,n,r,o),c||(c=o.connectionEnd&&gT(t,e,r,i),c)||(c=o.connectionStart&&vT(e,t,n,i),c)?c:!o.connectionStart&&!o.connectionEnd&&i&&i.length?i:dT(e,t,n,r,o)}function mT(e,t,n){return e>=t&&e<=n}function B_(e,t,n){var r={x:"width",y:"height"};return mT(t[e],n[e],n[e]+n[r[e]])}function hT(e,t,n,r,i){var o={},a,s;return s=He(e,t),/^(top|bottom|left|right)$/.test(s)?(/top|bottom/.test(s)&&(a="x"),/left|right/.test(s)&&(a="y"),i.preserveDocking==="target"?B_(a,r,e)?(o[a]=r[a],[{x:o.x!==void 0?o.x:n.x,y:o.y!==void 0?o.y:n.y,original:{x:o.x!==void 0?o.x:n.x,y:o.y!==void 0?o.y:n.y}},{x:r.x,y:r.y}]):null:B_(a,n,t)?(o[a]=n[a],[{x:n.x,y:n.y},{x:o.x!==void 0?o.x:r.x,y:o.y!==void 0?o.y:r.y,original:{x:o.x!==void 0?o.x:r.x,y:o.y!==void 0?o.y:r.y}}]):null):null}function vT(e,t,n,r){return ed(e,t,n,r)}function gT(e,t,n,r){var i=r.slice().reverse();return i=ed(e,t,n,i),i?i.reverse():null}function ed(e,t,n,r){function i(p){return p.length<3?!0:p.length>4?!1:!!re(p,function(l,f){var d=p[f-1];return d&&Gr(l,d)<3})}function o(p,l,f){var d=en(l,p);switch(d){case"v":return{x:f.x,y:p.y};case"h":return{x:p.x,y:f.y}}return{x:p.x,y:p.y}}function a(p,l,f){var d;for(d=p.length-2;d!==0;d--)if(Nl(p[d],l,N_)||Nl(p[d],f,N_))return p.slice(d);return p}if(i(r))return null;var s=r[0],c=r.slice(),u;return c[0]=n,c[1]=o(c[1],s,n),u=a(c,e,t),u!==c&&(c=ed(e,t,n,u)),c&&en(c)?null:c}function yT(e,t){if(F_(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 _T(e){return e&&/^h|v|t|r|b|l:h|v|t|r|b|l$/.test(e)}function F_(e){return e&&/t|r|b|l/.test(e)}function bT(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 I_(e,t,n,r){if(n==="h"&&(n=/left/.test(r)?"l":"r"),n==="v"&&(n=/top/.test(r)?"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 td(e){return e.reduce(function(t,n,r){var i=t[t.length-1],o=e[r+1];return uo(i,o,n,0)||t.push(n),t},[])}var xT=-10,ET=40,wT={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},ST={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},rd={top:"bottom","top-right":"bottom-left","top-left":"bottom-right",right:"left",bottom:"top","bottom-right":"top-left","bottom-left":"top-right",left:"right"},tc={top:"t",right:"r",bottom:"b",left:"l"};function da(e){this._elementRegistry=e}B(da,Ip);da.prototype.layoutConnection=function(e,t){t||(t={});var n=t.source||e.source,r=t.target||e.target,i=t.waypoints||e.waypoints,o=t.connectionStart,a=t.connectionEnd,s=this._elementRegistry,c,u;if(o||(o=H_(i&&i[0],n)),a||(a=H_(i&&i[i.length-1],r)),(h(e,"bpmn:Association")||h(e,"bpmn:DataAssociation"))&&i&&!$_(n,r))return[].concat([o],i.slice(1,-1),[a]);var p=Pu(n,s)?wT:ST;return h(e,"bpmn:MessageFlow")?c=RT(n,r,p):(h(e,"bpmn:SequenceFlow")||$_(n,r))&&(n===r?c={preferredLayouts:kT(n,e,p)}:h(n,"bpmn:BoundaryEvent")?c={preferredLayouts:NT(n,r,a,p)}:nc(n)||nc(r)?c={preferredLayouts:p.subProcess,preserveDocking:AT(n)}:h(n,"bpmn:Gateway")?c={preferredLayouts:p.fromGateway}:h(r,"bpmn:Gateway")?c={preferredLayouts:p.toGateway}:c={preferredLayouts:p.default}),c&&(c=C(c,t),u=td(j_(n,r,o,a,i,c))),u||[o,a]};function CT(e){var t=e.host;return He(X(e),t,xT)}function RT(e,t,n){return{preferredLayouts:n.messageFlow,preserveDocking:PT(e,t)}}function PT(e,t){return h(t,"bpmn:Participant")?"source":h(e,"bpmn:Participant")?"target":nc(t)?"source":nc(e)||h(t,"bpmn:Event")?"target":h(e,"bpmn:Event")?"source":null}function AT(e){return nc(e)?"target":"source"}function H_(e,t){return e?e.original||e:X(t)}function $_(e,t){return h(t,"bpmn:Activity")&&h(e,"bpmn:BoundaryEvent")&&t.businessObject.isForCompensation}function nc(e){return h(e,"bpmn:SubProcess")&&ie(e)}function Ji(e,t){return e===t}function TT(e,t){return t.indexOf(e)!==-1}function la(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 z_(e,t){return rd[e]===t}function MT(e,t){var n=la(e),r=rd[n];return t.indexOf(r)!==-1}function DT(e,t){var n=fa(e),r=rd[n];return t.indexOf(r)!==-1}function V_(e){return e==="right"||e==="left"}function kT(e,t,n){var r=t.waypoints,i=r&&r.length&&He(r[0],e);return i==="top"?n.loop.fromTop:i==="right"?n.loop.fromRight:i==="left"?n.loop.fromLeft:n.loop.fromBottom}function NT(e,t,n,r){var i=X(e),o=X(t),a=CT(e),s,c,u=Ji(e.host,t),p=TT(a,["top","right","bottom","left"]),l=He(o,i,{x:e.width/2+t.width/2,y:e.height/2+t.height/2});return u?OT(a,p,e,t,n,r):(s=BT(a,l,p,r.isHorizontal),c=IT(a,l,p,r.isHorizontal),[s+":"+c])}function OT(e,t,n,r,i,o){var a=t?e:o.isHorizontal?fa(e):la(e),s=tc[a],c;return t?V_(e)?c=G_("y",n,r,i)?"h":o.boundaryLoop.alternateHorizontalSide:c=G_("x",n,r,i)?"v":o.boundaryLoop.alternateVerticalSide:c=o.boundaryLoop.default,[s+":"+c]}function G_(e,t,n,r){var i=ET;return!(nd(e,r,n,i)||nd(e,r,{x:n.x+n.width,y:n.y+n.height},i)||nd(e,r,X(t),i))}function nd(e,t,n,r){return Math.abs(t[e]-n[e])<r}function BT(e,t,n,r){if(n)return tc[e];var i=fa(e),o=la(e),a=fa(t),s=la(t);if(r){if(Ji(i,a)||z_(o,s))return tc[i]}else if(Ji(o,s)||z_(i,a))return tc[o];return tc[r?o:i]}function IT(e,t,n,r){if(n)return V_(e)?MT(e,t)||Ji(e,t)?"h":"v":DT(e,t)||Ji(e,t)?"v":"h";var i=fa(e),o=la(e),a=fa(t),s=la(t);return a&&!s?"v":s&&!a?"h":r?Ji(i,a)?"h":"v":Ji(o,s)?"v":"h"}da.$inject=["elementRegistry"];N();function W_(e){return C({original:e.point.original||e.point},e.actual)}function dr(e,t){this._elementRegistry=e,this._graphicsFactory=t}dr.$inject=["elementRegistry","graphicsFactory"];dr.prototype.getCroppedWaypoints=function(e,t,n){t=t||e.source,n=n||e.target;var r=this.getDockingPoint(e,t,!0),i=this.getDockingPoint(e,n),o=e.waypoints.slice(r.idx+1,i.idx);return o.unshift(W_(r)),o.push(W_(i)),o};dr.prototype.getDockingPoint=function(e,t,n){var r=e.waypoints,i,o,a;return i=n?0:r.length-1,o=r[i],a=this._getIntersection(t,e,n),{point:o,actual:a||o,idx:i}};dr.prototype._getIntersection=function(e,t,n){var r=this._getShapePath(e),i=this._getConnectionPath(t);return qr(r,i,n)};dr.prototype._getConnectionPath=function(e){return this._graphicsFactory.getConnectionPath(e)};dr.prototype._getShapePath=function(e){return this._graphicsFactory.getShapePath(e)};dr.prototype._getGfx=function(e){return this._elementRegistry.getGraphics(e)};var Fp={__init__:["modeling","bpmnUpdater"],__depends__:[_y,Fy,Hy,$y,Ap,p_,d_,v_,rt,xo,Np],bpmnFactory:["type",an],bpmnUpdater:["type",$t],elementFactory:["type",lr],modeling:["type",Pt],layouter:["type",da],connectionDocking:["type",dr]};N();var U_=Math.round;function ma(e,t,n,r,i,o){this._complexPreview=e,this._connectionDocking=t,this._elementFactory=n,this._eventBus=r,this._layouter=i,this._rules=o}ma.prototype.create=function(e,t,n){let r=this._complexPreview,i=this._connectionDocking,o=this._elementFactory,a=this._eventBus,s=this._layouter,c=this._rules,u=o.createShape(C({type:t},n)),p=a.fire("autoPlace",{source:e,shape:u});if(!p)return;C(u,{x:p.x-U_(u.width/2),y:p.y-U_(u.height/2)});let l=c.allowed("connection.create",{source:e,target:u,hints:{targetParent:e.parent}}),f=null;l&&(f=o.createConnection(l),f.waypoints=s.layoutConnection(f,{source:e,target:u}),f.waypoints=i.getCroppedWaypoints(f,e,u)),r.create({created:[u,f].filter(d=>!Yn(d))})};ma.prototype.cleanUp=function(){this._complexPreview.cleanUp()};ma.$inject=["complexPreview","connectionDocking","elementFactory","eventBus","layouter","rules"];var q_={__depends__:[No,Rg,Fp],__init__:["appendPreview"],appendPreview:["type",ma]};N();N();var K_=Math.min,Y_=Math.max;function id(e){e.preventDefault()}function rc(e){e.stopPropagation()}function LT(e){return e.nodeType===Node.TEXT_NODE}function jT(e){return[].slice.call(e)}function _n(e){this.container=e.container,this.parent=ue('<div class="djs-direct-editing-parent"><div class="djs-direct-editing-content" contenteditable="true"></div></div>'),this.content=_e("[contenteditable]",this.parent),this.keyHandler=e.keyHandler||function(){},this.resizeHandler=e.resizeHandler||function(){},this.autoResize=tt(this.autoResize,this),this.handlePaste=tt(this.handlePaste,this)}_n.prototype.create=function(e,t,n,r){var i=this,o=this.parent,a=this.content,s=this.container;r=this.options=r||{},t=this.style=t||{};var c=mt(t,["width","height","maxWidth","maxHeight","minWidth","minHeight","left","top","backgroundColor","position","overflow","border","wordWrap","textAlign","outline","transform"]);C(o.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 u=mt(t,["fontFamily","fontSize","fontWeight","lineHeight","padding","paddingTop","paddingRight","paddingBottom","paddingLeft"]);return C(a.style,{boxSizing:"border-box",width:"100%",outline:"none",wordWrap:"break-word"},u),r.centerVertically&&C(a.style,{position:"absolute",top:"50%",transform:"translate(0, -50%)"},u),a.innerText=n,se.bind(a,"keydown",this.keyHandler),se.bind(a,"mousedown",rc),se.bind(a,"paste",i.handlePaste),r.autoResize&&se.bind(a,"input",this.autoResize),r.resizable&&this.resizable(t),s.appendChild(o),this.setSelection(a.lastChild,a.lastChild&&a.lastChild.length),o};_n.prototype.handlePaste=function(e){var t=this.options,n=this.style;e.preventDefault();var r;if(e.clipboardData?r=e.clipboardData.getData("text/plain"):r=window.clipboardData.getData("Text"),this.insertText(r),t.autoResize){var i=this.autoResize(n);i&&this.resizeHandler(i)}};_n.prototype.insertText=function(e){e=FT(e);var t=document.execCommand("insertText",!1,e);t||this._insertTextIE(e)};_n.prototype._insertTextIE=function(e){var t=this.getSelection(),n=t.startContainer,r=t.endContainer,i=t.startOffset,o=t.endOffset,a=t.commonAncestorContainer,s=jT(a.childNodes),c,u;if(LT(a)){var p=n.textContent;n.textContent=p.substring(0,i)+e+p.substring(o),c=n,u=i+e.length}else if(n===this.content&&r===this.content){var l=document.createTextNode(e);this.content.insertBefore(l,s[i]),c=l,u=l.textContent.length}else{var f=s.indexOf(n),d=s.indexOf(r);s.forEach(function(m,g){g===f?m.textContent=n.textContent.substring(0,i)+e+r.textContent.substring(o):g>f&&g<=d&&Wt(m)}),c=n,u=i+e.length}c&&u!==void 0&&setTimeout(function(){self.setSelection(c,u)})};_n.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 r=e.getBoundingClientRect(),i=t.scrollHeight;e.style.height=i+"px",this.resizeHandler({width:r.width,height:r.height,dx:0,dy:i-r.height})}};_n.prototype.resizable=function(){var e=this,t=this.parent,n=this.resizeHandle,r=parseInt(this.style.minWidth)||0,i=parseInt(this.style.minHeight)||0,o=parseInt(this.style.maxWidth)||1/0,a=parseInt(this.style.maxHeight)||1/0;if(!n){n=this.resizeHandle=ue('<div class="djs-direct-editing-resize-handle"></div>');var s,c,u,p,l=function(m){id(m),rc(m),s=m.clientX,c=m.clientY;var g=t.getBoundingClientRect();u=g.width,p=g.height,se.bind(document,"mousemove",f),se.bind(document,"mouseup",d)},f=function(m){id(m),rc(m);var g=K_(Y_(u+m.clientX-s,r),o),v=K_(Y_(p+m.clientY-c,i),a);t.style.width=g+"px",t.style.height=v+"px",e.resizeHandler({width:u,height:p,dx:m.clientX-s,dy:m.clientY-c})},d=function(m){id(m),rc(m),se.unbind(document,"mousemove",f,!1),se.unbind(document,"mouseup",d,!1)};se.bind(n,"mousedown",l)}C(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)};_n.prototype.destroy=function(){var e=this.parent,t=this.content,n=this.resizeHandle;t.innerText="",e.removeAttribute("style"),t.removeAttribute("style"),se.unbind(t,"keydown",this.keyHandler),se.unbind(t,"mousedown",rc),se.unbind(t,"input",this.autoResize),se.unbind(t,"paste",this.handlePaste),n&&(n.removeAttribute("style"),Wt(n)),Wt(e)};_n.prototype.getValue=function(){return this.content.innerText.trim()};_n.prototype.getSelection=function(){var e=window.getSelection(),t=e.getRangeAt(0);return t};_n.prototype.setSelection=function(e,t){var n=document.createRange();e===null?n.selectNodeContents(this.content):(n.setStart(e,t),n.setEnd(e,t));var r=window.getSelection();r.removeAllRanges(),r.addRange(n)};function FT(e){return e.replace(/\r\n|\r|\n/g,`
211 </svg>`},sp=ES;var wS=900;function Yr(e,t,n,r){e.registerProvider(wS,this),this._contextPad=e,this._popupMenu=t,this._translate=n,this._canvas=r}Yr.$inject=["contextPad" global() function in Vo.Ps.On.Oi
/plugin/mizarverifiabledocs/dist/
H A Dscript.js.map1vP#g#h7y~7|P#]#^8P~8SP#c#d8V~8YP#b#c1d~8`R#c#d8i#f#g8o#i#j3v~8lP#f#g!|~8rP#c#d8u~8xP#a#b(}~9OP#]#^…
/plugin/mizarproofchecker/dist/
Dscript.js.map1vP#g#h7y~7|P#]#^8P~8SP#c#d8V~8YP#b#c1d~8`R#c#d8i#f#g8o#i#j3v~8lP#f#g!|~8rP#c#d8u~8xP#a#b(}~9OP#]#^…
/plugin/mizarveifiabledocs/dist/
Dscript.js.map1vP#g#h7y~7|P#]#^8P~8SP#c#d8V~8YP#b#c1d~8`R#c#d8i#f#g8o#i#j3v~8lP#f#g!|~8rP#c#d8u~8xP#a#b(}~9OP#]#^…