import{S as at,i as lt,s as ut,a as G,k as D,c as X,l as I,m as _,h as E,n as C,V,b as O,H as x,K as q,G as H,o as ht,q as B,r as N,u as ct,a2 as pt,L as F}from"./index-55f02416.js";import{y as j,s as Y,h as K,x as J,z as Q,w as ft,b as mt}from"./state-8239c202.js";var dt=function(){var t="",e,o,i,s=[],n={passive:!0};window.addEventListener?(e="addEventListener",o="removeEventListener"):(e="attachEvent",o="detachEvent",t="on"),i="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";function a(p,u){var v=function(m){!m&&(m=window.event);var y={originalEvent:m,target:m.target||m.srcElement,type:"wheel",deltaMode:m.type=="MozMousePixelScroll"?0:1,deltaX:0,delatZ:0,preventDefault:function(){m.preventDefault?m.preventDefault():m.returnValue=!1}};return i=="mousewheel"?(y.deltaY=-.025*m.wheelDelta,m.wheelDeltaX&&(y.deltaX=-.025*m.wheelDeltaX)):y.deltaY=m.detail,u(y)};return s.push({element:p,fn:v}),v}function r(p){for(var u=0;ue?(clearTimeout(r),r=null,l=w,a=t.apply(s,n),r||(s=n=null)):!r&&o.trailing!==!1&&(r=setTimeout(b,g)),a}},createRequestAnimationFrame:function(t){var e=null;return t!=="auto"&&t<60&&t>1&&(e=Math.floor(1e3/t)),e===null?window.requestAnimationFrame||$(33):$(e)}};function $(t){return function(e){window.setTimeout(e,t)}}var k=R,ot="unknown";document.documentMode&&(ot="ie");var U={svgNS:"http://www.w3.org/2000/svg",xmlNS:"http://www.w3.org/XML/1998/namespace",xmlnsNS:"http://www.w3.org/2000/xmlns/",xlinkNS:"http://www.w3.org/1999/xlink",evNS:"http://www.w3.org/2001/xml-events",getBoundingClientRectNormalized:function(t){if(t.clientWidth&&t.clientHeight)return{width:t.clientWidth,height:t.clientHeight};if(t.getBoundingClientRect())return t.getBoundingClientRect();throw new Error("Cannot get BoundingClientRect for SVG.")},getOrCreateViewport:function(t,e){var o=null;if(k.isElement(e)?o=e:o=t.querySelector(e),!o){var i=Array.prototype.slice.call(t.childNodes||t.children).filter(function(l){return l.nodeName!=="defs"&&l.nodeName!=="#text"});i.length===1&&i[0].nodeName==="g"&&i[0].getAttribute("transform")===null&&(o=i[0])}if(!o){var s="viewport-"+new Date().toISOString().replace(/\D/g,"");o=document.createElementNS(this.svgNS,"g"),o.setAttribute("id",s);var n=t.childNodes||t.children;if(!!n&&n.length>0)for(var a=n.length;a>0;a--)n[n.length-a].nodeName!=="defs"&&o.appendChild(n[n.length-a]);t.appendChild(o)}var r=[];return o.getAttribute("class")&&(r=o.getAttribute("class").split(" ")),~r.indexOf("svg-pan-zoom_viewport")||(r.push("svg-pan-zoom_viewport"),o.setAttribute("class",r.join(" "))),o},setupSvgAttributes:function(t){if(t.setAttribute("xmlns",this.svgNS),t.setAttributeNS(this.xmlnsNS,"xmlns:xlink",this.xlinkNS),t.setAttributeNS(this.xmlnsNS,"xmlns:ev",this.evNS),t.parentNode!==null){var e=t.getAttribute("style")||"";e.toLowerCase().indexOf("overflow")===-1&&t.setAttribute("style","overflow: hidden; "+e)}},internetExplorerRedisplayInterval:300,refreshDefsGlobal:k.throttle(function(){for(var t=document.querySelectorAll("defs"),e=t.length,o=0;o=0;i--)this.eventListeners.hasOwnProperty(o[i])&&delete this.eventListeners[o[i]]}for(var s in this.eventListeners)(this.options.eventsListenerElement||this.svg).addEventListener(s,this.eventListeners[s],this.options.preventMouseEventsDefault?!1:nt);this.options.mouseWheelZoomEnabled&&(this.options.mouseWheelZoomEnabled=!1,this.enableMouseWheelZoom())};c.prototype.enableMouseWheelZoom=function(){if(!this.options.mouseWheelZoomEnabled){var t=this;this.wheelListener=function(o){return t.handleMouseWheel(o)};var e=!this.options.preventMouseEventsDefault;it.on(this.options.eventsListenerElement||this.svg,this.wheelListener,e),this.options.mouseWheelZoomEnabled=!0}};c.prototype.disableMouseWheelZoom=function(){if(this.options.mouseWheelZoomEnabled){var t=!this.options.preventMouseEventsDefault;it.off(this.options.eventsListenerElement||this.svg,this.wheelListener,t),this.options.mouseWheelZoomEnabled=!1}};c.prototype.handleMouseWheel=function(t){if(!(!this.options.zoomEnabled||this.state!=="none")){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1);var e=t.deltaY||1,o=Date.now()-this.lastMouseWheelEventTime,i=3+Math.max(0,30-o);this.lastMouseWheelEventTime=Date.now(),"deltaMode"in t&&t.deltaMode===0&&t.wheelDelta&&(e=t.deltaY===0?0:Math.abs(t.wheelDelta)/t.deltaY),e=-.30?1:-1)*Math.log(Math.abs(e)+10)/i;var s=this.svg.getScreenCTM().inverse(),n=Z.getEventPoint(t,this.svg).matrixTransform(s),a=Math.pow(1+this.options.zoomScaleSensitivity,-1*e);this.zoomAtPoint(a,n)}};c.prototype.zoomAtPoint=function(t,e,o){var i=this.viewport.getOriginalState();o?(t=Math.max(this.options.minZoom*i.zoom,Math.min(this.options.maxZoom*i.zoom,t)),t=t/this.getZoom()):this.getZoom()*tthis.options.maxZoom*i.zoom&&(t=this.options.maxZoom*i.zoom/this.getZoom());var s=this.viewport.getCTM(),n=e.matrixTransform(s.inverse()),a=this.svg.createSVGMatrix().translate(n.x,n.y).scale(t).translate(-n.x,-n.y),r=s.multiply(a);r.a!==s.a&&this.viewport.setCTM(r)};c.prototype.zoom=function(t,e){this.zoomAtPoint(t,Z.getSvgCenterPoint(this.svg,this.width,this.height),e)};c.prototype.publicZoom=function(t,e){e&&(t=this.computeFromRelativeZoom(t)),this.zoom(t,e)};c.prototype.publicZoomAtPoint=function(t,e,o){if(o&&(t=this.computeFromRelativeZoom(t)),M.getType(e)!=="SVGPoint")if("x"in e&&"y"in e)e=Z.createSVGPoint(this.svg,e.x,e.y);else throw new Error("Given point is invalid");this.zoomAtPoint(t,e,o)};c.prototype.getZoom=function(){return this.viewport.getZoom()};c.prototype.getRelativeZoom=function(){return this.viewport.getRelativeZoom()};c.prototype.computeFromRelativeZoom=function(t){return t*this.viewport.getOriginalState().zoom};c.prototype.resetZoom=function(){var t=this.viewport.getOriginalState();this.zoom(t.zoom,!0)};c.prototype.resetPan=function(){this.pan(this.viewport.getOriginalState())};c.prototype.reset=function(){this.resetZoom(),this.resetPan()};c.prototype.handleDblClick=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.options.controlIconsEnabled){var e=t.target.getAttribute("class")||"";if(e.indexOf("svg-pan-zoom-control")>-1)return!1}var o;t.shiftKey?o=1/((1+this.options.zoomScaleSensitivity)*2):o=(1+this.options.zoomScaleSensitivity)*2;var i=Z.getEventPoint(t,this.svg).matrixTransform(this.svg.getScreenCTM().inverse());this.zoomAtPoint(o,i)};c.prototype.handleMouseDown=function(t,e){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),M.mouseAndTouchNormalize(t,this.svg),this.options.dblClickZoomEnabled&&M.isDblClick(t,e)?this.handleDblClick(t):(this.state="pan",this.firstEventCTM=this.viewport.getCTM(),this.stateOrigin=Z.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()))};c.prototype.handleMouseMove=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&this.options.panEnabled){var e=Z.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()),o=this.firstEventCTM.translate(e.x-this.stateOrigin.x,e.y-this.stateOrigin.y);this.viewport.setCTM(o)}};c.prototype.handleMouseUp=function(t){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&(this.state="none")};c.prototype.fit=function(){var t=this.viewport.getViewBox(),e=Math.min(this.width/t.width,this.height/t.height);this.zoom(e,!0)};c.prototype.contain=function(){var t=this.viewport.getViewBox(),e=Math.max(this.width/t.width,this.height/t.height);this.zoom(e,!0)};c.prototype.center=function(){var t=this.viewport.getViewBox(),e=(this.width-(t.width+t.x*2)*this.getZoom())*.5,o=(this.height-(t.height+t.y*2)*this.getZoom())*.5;this.getPublicInstance().pan({x:e,y:o})};c.prototype.updateBBox=function(){this.viewport.simpleViewBoxCache()};c.prototype.pan=function(t){var e=this.viewport.getCTM();e.e=t.x,e.f=t.y,this.viewport.setCTM(e)};c.prototype.panBy=function(t){var e=this.viewport.getCTM();e.e+=t.x,e.f+=t.y,this.viewport.setCTM(e)};c.prototype.getPan=function(){var t=this.viewport.getState();return{x:t.x,y:t.y}};c.prototype.resize=function(){var t=Z.getBoundingClientRectNormalized(this.svg);this.width=t.width,this.height=t.height;var e=this.viewport;e.options.width=this.width,e.options.height=this.height,e.processCTM(),this.options.controlIconsEnabled&&(this.getPublicInstance().disableControlIcons(),this.getPublicInstance().enableControlIcons())};c.prototype.destroy=function(){var t=this;this.beforeZoom=null,this.onZoom=null,this.beforePan=null,this.onPan=null,this.onUpdatedCTM=null,this.options.customEventsHandler!=null&&this.options.customEventsHandler.destroy({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});for(var e in this.eventListeners)(this.options.eventsListenerElement||this.svg).removeEventListener(e,this.eventListeners[e],this.options.preventMouseEventsDefault?!1:nt);this.disableMouseWheelZoom(),this.getPublicInstance().disableControlIcons(),this.reset(),z=z.filter(function(o){return o.svg!==t.svg}),delete this.options,delete this.viewport,delete this.publicInstance,delete this.pi,this.getPublicInstance=function(){return null}};c.prototype.getPublicInstance=function(){var t=this;return this.publicInstance||(this.publicInstance=this.pi={enablePan:function(){return t.options.panEnabled=!0,t.pi},disablePan:function(){return t.options.panEnabled=!1,t.pi},isPanEnabled:function(){return!!t.options.panEnabled},pan:function(e){return t.pan(e),t.pi},panBy:function(e){return t.panBy(e),t.pi},getPan:function(){return t.getPan()},setBeforePan:function(e){return t.options.beforePan=e===null?null:M.proxy(e,t.publicInstance),t.pi},setOnPan:function(e){return t.options.onPan=e===null?null:M.proxy(e,t.publicInstance),t.pi},enableZoom:function(){return t.options.zoomEnabled=!0,t.pi},disableZoom:function(){return t.options.zoomEnabled=!1,t.pi},isZoomEnabled:function(){return!!t.options.zoomEnabled},enableControlIcons:function(){return t.options.controlIconsEnabled||(t.options.controlIconsEnabled=!0,W.enable(t)),t.pi},disableControlIcons:function(){return t.options.controlIconsEnabled&&(t.options.controlIconsEnabled=!1,W.disable(t)),t.pi},isControlIconsEnabled:function(){return!!t.options.controlIconsEnabled},enableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!0,t.pi},disableDblClickZoom:function(){return t.options.dblClickZoomEnabled=!1,t.pi},isDblClickZoomEnabled:function(){return!!t.options.dblClickZoomEnabled},enableMouseWheelZoom:function(){return t.enableMouseWheelZoom(),t.pi},disableMouseWheelZoom:function(){return t.disableMouseWheelZoom(),t.pi},isMouseWheelZoomEnabled:function(){return!!t.options.mouseWheelZoomEnabled},setZoomScaleSensitivity:function(e){return t.options.zoomScaleSensitivity=e,t.pi},setMinZoom:function(e){return t.options.minZoom=e,t.pi},setMaxZoom:function(e){return t.options.maxZoom=e,t.pi},setBeforeZoom:function(e){return t.options.beforeZoom=e===null?null:M.proxy(e,t.publicInstance),t.pi},setOnZoom:function(e){return t.options.onZoom=e===null?null:M.proxy(e,t.publicInstance),t.pi},zoom:function(e){return t.publicZoom(e,!0),t.pi},zoomBy:function(e){return t.publicZoom(e,!1),t.pi},zoomAtPoint:function(e,o){return t.publicZoomAtPoint(e,o,!0),t.pi},zoomAtPointBy:function(e,o){return t.publicZoomAtPoint(e,o,!1),t.pi},zoomIn:function(){return this.zoomBy(1+t.options.zoomScaleSensitivity),t.pi},zoomOut:function(){return this.zoomBy(1/(1+t.options.zoomScaleSensitivity)),t.pi},getZoom:function(){return t.getRelativeZoom()},setOnUpdatedCTM:function(e){return t.options.onUpdatedCTM=e===null?null:M.proxy(e,t.publicInstance),t.pi},resetZoom:function(){return t.resetZoom(),t.pi},resetPan:function(){return t.resetPan(),t.pi},reset:function(){return t.reset(),t.pi},fit:function(){return t.fit(),t.pi},contain:function(){return t.contain(),t.pi},center:function(){return t.center(),t.pi},updateBBox:function(){return t.updateBBox(),t.pi},resize:function(){return t.resize(),t.pi},getSizes:function(){return{width:t.width,height:t.height,realZoom:t.getZoom(),viewBox:t.viewport.getViewBox()}},destroy:function(){return t.destroy(),t.pi}}),this.publicInstance};var z=[],St=function(t,e){var o=M.getSvg(t);if(o===null)return null;for(var i=z.length-1;i>=0;i--)if(z[i].svg===o)return z[i].instance.getPublicInstance();return z.push({svg:o,instance:new c(o,e)}),z[z.length-1].instance.getPublicInstance()},xt=St;function tt(t){let e,o=t[5].error+"",i;return{c(){e=D("div"),i=B(o),this.h()},l(s){e=I(s,"DIV",{class:!0,id:!0});var n=_(e);i=N(n,o),n.forEach(E),this.h()},h(){C(e,"class","p-2 text-red-600"),C(e,"id","errorContainer")},m(s,n){O(s,e,n),x(e,i)},p(s,n){n&32&&o!==(o=s[5].error+"")&&ct(i,o)},d(s){s&&E(e)}}}function et(t){let e,o,i,s,n,a,r,l,b,w;return{c(){e=D("div"),o=B("Diagram out of sync. "),i=D("br"),s=B(` Press `),n=D("i"),a=B(" (Sync button) or "),r=D("kbd"),l=B(J),b=B(" + Enter"),w=B(" to sync."),this.h()},l(g){e=I(g,"DIV",{class:!0});var d=_(e);o=N(d,"Diagram out of sync. "),i=I(d,"BR",{}),s=N(d,` Press `),n=I(d,"I",{class:!0}),_(n).forEach(E),a=N(d," (Sync button) or "),r=I(d,"KBD",{});var p=_(r);l=N(p,J),b=N(p," + Enter"),p.forEach(E),w=N(d," to sync."),d.forEach(E),this.h()},h(){C(n,"class","fas fa-sync"),C(e,"class","absolute w-full p-2 z-10 text-yellow-600 bg-base-100 bg-opacity-80 text-center")},m(g,d){O(g,e,d),x(e,o),x(e,i),x(e,s),x(e,n),x(e,a),x(e,r),x(r,l),x(r,b),x(e,w)},p:q,d(g){g&&E(e)}}}function Et(t){let e,o,i,s,n=t[2]&&t[5].error instanceof Error&&tt(t),a=t[3]&&et();return{c(){n&&n.c(),e=G(),a&&a.c(),o=G(),i=D("div"),s=D("div"),this.h()},l(r){n&&n.l(r),e=X(r),a&&a.l(r),o=X(r),i=I(r,"DIV",{id:!0,class:!0});var l=_(i);s=I(l,"DIV",{id:!0,class:!0}),_(s).forEach(E),l.forEach(E),this.h()},h(){C(s,"id","container"),C(s,"class","h-full overflow-auto svelte-1ewr4tw"),V(s,"hide",t[4]),C(i,"id","view"),C(i,"class","p-2 h-full svelte-1ewr4tw"),V(i,"error",t[2]),V(i,"outOfSync",t[3])},m(r,l){n&&n.m(r,l),O(r,e,l),a&&a.m(r,l),O(r,o,l),O(r,i,l),x(i,s),t[6](s),t[7](i)},p(r,[l]){r[2]&&r[5].error instanceof Error?n?n.p(r,l):(n=tt(r),n.c(),n.m(e.parentNode,e)):n&&(n.d(1),n=null),r[3]?a?a.p(r,l):(a=et(),a.c(),a.m(o.parentNode,o)):a&&(a.d(1),a=null),l&16&&V(s,"hide",r[4]),l&4&&V(i,"error",r[2]),l&8&&V(i,"outOfSync",r[3])},i:q,o:q,d(r){n&&n.d(r),r&&E(e),a&&a.d(r),r&&E(o),r&&E(i),t[6](null),t[7](null)}}}function Mt(t,e,o){let i,s;H(t,Y,h=>o(5,i=h)),H(t,K,h=>o(13,s=h));let n="",a="",r,l,b=!1,w=!1,g=!1,d=!0,p=i.panZoom,u;const v=()=>{const h=u.getPan(),A=u.getZoom();ft({pan:h,zoom:A}),mt("panZoom")},m=h=>{!h.panZoom||(o(4,g=!0),u==null||u.destroy(),u=void 0,Promise.resolve().then(()=>{const A=document.getElementById("graph-div");u=xt(A,{onPan:v,onZoom:v,controlIconsEnabled:!0,fit:!0,center:!0});const{pan:L,zoom:T}=h;L!==void 0&&T!==void 0&&Number.isFinite(T)&&(u.zoom(T),u.pan(L)),o(4,g=!1)}))},y=h=>{if(h.error!==void 0){o(2,b=!0);return}o(2,b=!1);try{if(r&&h&&(h.updateDiagram||h.autoSync)){if(h.autoSync||pt(K,s.updateDiagram=!1,s),o(3,w=!1),d=!0,n===h.code&&a===h.mermaid&&p===h.panZoom)return;n=h.code,a=h.mermaid,p=h.panZoom;const A=l.parentElement.scrollTop;delete r.dataset.processed,Q.initialize(Object.assign({},JSON.parse(h.mermaid))),Q.render("graph-div",n,L=>{if(L.length>0){m(h),o(0,r.innerHTML=L,r);const T=document.getElementById("graph-div");T.setAttribute("height","100%"),T.style.maxWidth="100%"}}),o(1,l.parentElement.scrollTop=A,l),o(2,b=!1)}else d?d=!1:(n!==h.code||a!==h.mermaid)&&o(3,w=!0)}catch(A){console.error("view fail",A),o(2,b=!0)}};ht(()=>{Y.subscribe(h=>{y(h)}),window.addEventListener("resize",()=>{i.panZoom&&u&&u.resize()})});function st(h){F[h?"unshift":"push"](()=>{r=h,o(0,r)})}function rt(h){F[h?"unshift":"push"](()=>{l=h,o(1,l)})}return[r,l,b,w,g,i,st,rt]}class Ct extends at{constructor(e){super(),lt(this,e,Mt,Et,ut,{})}}export{Ct as V};