import{S as et,i as ot,s as it,a as nt,l as D,c as st,m as T,n as V,h as P,p as A,Z as C,b as O,N as Y,E as q,M as W,o as rt,a5 as at,r as lt,u as ut,v as ht,Q as U}from"./index-1530a265.js";import{x as R,s as G,g as X,y as F,z as ct,b as pt}from"./state-e537f134.js";var ft=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 r(c,a){var d=function(p){!p&&(p=window.event);var v={originalEvent:p,target:p.target||p.srcElement,type:"wheel",deltaMode:p.type=="MozMousePixelScroll"?0:1,deltaX:0,delatZ:0,preventDefault:function(){p.preventDefault?p.preventDefault():p.returnValue=!1}};return i=="mousewheel"?(v.deltaY=-.025*p.wheelDelta,p.wheelDeltaX&&(v.deltaX=-.025*p.wheelDeltaX)):v.deltaY=p.detail,a(v)};return s.push({element:c,fn:d}),d}function h(c){for(var a=0;ae?(clearTimeout(h),h=null,m=y,r=t.apply(s,n),h||(s=n=null)):!h&&o.trailing!==!1&&(h=setTimeout(w,x)),r}},createRequestAnimationFrame:function(t){var e=null;return t!=="auto"&&t<60&&t>1&&(e=Math.floor(1e3/t)),e===null?window.requestAnimationFrame||H(33):H(e)}};function H(t){return function(e){window.setTimeout(e,t)}}var I=_,J="unknown";document.documentMode&&(J="ie");var k={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(I.isElement(e)?o=e:o=t.querySelector(e),!o){var i=Array.prototype.slice.call(t.childNodes||t.children).filter(function(m){return m.nodeName!=="defs"&&m.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 r=n.length;r>0;r--)n[n.length-r].nodeName!=="defs"&&o.appendChild(n[n.length-r]);t.appendChild(o)}var h=[];return o.getAttribute("class")&&(h=o.getAttribute("class").split(" ")),~h.indexOf("svg-pan-zoom_viewport")||(h.push("svg-pan-zoom_viewport"),o.setAttribute("class",h.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:I.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:Q);this.options.mouseWheelZoomEnabled&&(this.options.mouseWheelZoomEnabled=!1,this.enableMouseWheelZoom())};u.prototype.enableMouseWheelZoom=function(){if(!this.options.mouseWheelZoomEnabled){var t=this;this.wheelListener=function(o){return t.handleMouseWheel(o)};var e=!this.options.preventMouseEventsDefault;K.on(this.options.eventsListenerElement||this.svg,this.wheelListener,e),this.options.mouseWheelZoomEnabled=!0}};u.prototype.disableMouseWheelZoom=function(){if(this.options.mouseWheelZoomEnabled){var t=!this.options.preventMouseEventsDefault;K.off(this.options.eventsListenerElement||this.svg,this.wheelListener,t),this.options.mouseWheelZoomEnabled=!1}};u.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=S.getEventPoint(t,this.svg).matrixTransform(s),r=Math.pow(1+this.options.zoomScaleSensitivity,-1*e);this.zoomAtPoint(r,n)}};u.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()),r=this.svg.createSVGMatrix().translate(n.x,n.y).scale(t).translate(-n.x,-n.y),h=s.multiply(r);h.a!==s.a&&this.viewport.setCTM(h)};u.prototype.zoom=function(t,e){this.zoomAtPoint(t,S.getSvgCenterPoint(this.svg,this.width,this.height),e)};u.prototype.publicZoom=function(t,e){e&&(t=this.computeFromRelativeZoom(t)),this.zoom(t,e)};u.prototype.publicZoomAtPoint=function(t,e,o){if(o&&(t=this.computeFromRelativeZoom(t)),b.getType(e)!=="SVGPoint")if("x"in e&&"y"in e)e=S.createSVGPoint(this.svg,e.x,e.y);else throw new Error("Given point is invalid");this.zoomAtPoint(t,e,o)};u.prototype.getZoom=function(){return this.viewport.getZoom()};u.prototype.getRelativeZoom=function(){return this.viewport.getRelativeZoom()};u.prototype.computeFromRelativeZoom=function(t){return t*this.viewport.getOriginalState().zoom};u.prototype.resetZoom=function(){var t=this.viewport.getOriginalState();this.zoom(t.zoom,!0)};u.prototype.resetPan=function(){this.pan(this.viewport.getOriginalState())};u.prototype.reset=function(){this.resetZoom(),this.resetPan()};u.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=S.getEventPoint(t,this.svg).matrixTransform(this.svg.getScreenCTM().inverse());this.zoomAtPoint(o,i)};u.prototype.handleMouseDown=function(t,e){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),b.mouseAndTouchNormalize(t,this.svg),this.options.dblClickZoomEnabled&&b.isDblClick(t,e)?this.handleDblClick(t):(this.state="pan",this.firstEventCTM=this.viewport.getCTM(),this.stateOrigin=S.getEventPoint(t,this.svg).matrixTransform(this.firstEventCTM.inverse()))};u.prototype.handleMouseMove=function(t){if(this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&this.options.panEnabled){var e=S.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)}};u.prototype.handleMouseUp=function(t){this.options.preventMouseEventsDefault&&(t.preventDefault?t.preventDefault():t.returnValue=!1),this.state==="pan"&&(this.state="none")};u.prototype.fit=function(){var t=this.viewport.getViewBox(),e=Math.min(this.width/t.width,this.height/t.height);this.zoom(e,!0)};u.prototype.contain=function(){var t=this.viewport.getViewBox(),e=Math.max(this.width/t.width,this.height/t.height);this.zoom(e,!0)};u.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})};u.prototype.updateBBox=function(){this.viewport.simpleViewBoxCache()};u.prototype.pan=function(t){var e=this.viewport.getCTM();e.e=t.x,e.f=t.y,this.viewport.setCTM(e)};u.prototype.panBy=function(t){var e=this.viewport.getCTM();e.e+=t.x,e.f+=t.y,this.viewport.setCTM(e)};u.prototype.getPan=function(){var t=this.viewport.getState();return{x:t.x,y:t.y}};u.prototype.resize=function(){var t=S.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())};u.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:Q);this.disableMouseWheelZoom(),this.getPublicInstance().disableControlIcons(),this.reset(),E=E.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}};u.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:b.proxy(e,t.publicInstance),t.pi},setOnPan:function(e){return t.options.onPan=e===null?null:b.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,L.enable(t)),t.pi},disableControlIcons:function(){return t.options.controlIconsEnabled&&(t.options.controlIconsEnabled=!1,L.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:b.proxy(e,t.publicInstance),t.pi},setOnZoom:function(e){return t.options.onZoom=e===null?null:b.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:b.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 E=[],wt=function(t,e){var o=b.getSvg(t);if(o===null)return null;for(var i=E.length-1;i>=0;i--)if(E[i].svg===o)return E[i].instance.getPublicInstance();return E.push({svg:o,instance:new u(o,e)}),E[E.length-1].instance.getPublicInstance()},yt=wt;function j(t){let e,o=t[5].error+"",i;return{c(){e=D("div"),i=lt(o),this.h()},l(s){e=T(s,"DIV",{class:!0,id:!0});var n=V(e);i=ut(n,o),n.forEach(P),this.h()},h(){A(e,"class","p-2 text-red-600"),A(e,"id","errorContainer")},m(s,n){O(s,e,n),Y(e,i)},p(s,n){n&32&&o!==(o=s[5].error+"")&&ht(i,o)},d(s){s&&P(e)}}}function St(t){let e,o,i,s=t[2]&&t[5].error instanceof Error&&j(t);return{c(){s&&s.c(),e=nt(),o=D("div"),i=D("div"),this.h()},l(n){s&&s.l(n),e=st(n),o=T(n,"DIV",{id:!0,class:!0});var r=V(o);i=T(r,"DIV",{id:!0,class:!0}),V(i).forEach(P),r.forEach(P),this.h()},h(){A(i,"id","container"),A(i,"class","h-full overflow-auto svelte-1ewr4tw"),C(i,"hide",t[4]),A(o,"id","view"),A(o,"class","p-2 h-full svelte-1ewr4tw"),C(o,"error",t[2]),C(o,"outOfSync",t[3])},m(n,r){s&&s.m(n,r),O(n,e,r),O(n,o,r),Y(o,i),t[6](i),t[7](o)},p(n,[r]){n[2]&&n[5].error instanceof Error?s?s.p(n,r):(s=j(n),s.c(),s.m(e.parentNode,e)):s&&(s.d(1),s=null),r&16&&C(i,"hide",n[4]),r&4&&C(o,"error",n[2]),r&8&&C(o,"outOfSync",n[3])},i:q,o:q,d(n){s&&s.d(n),n&&P(e),n&&P(o),t[6](null),t[7](null)}}}function xt(t,e,o){let i,s;W(t,G,l=>o(5,i=l)),W(t,X,l=>o(14,s=l));let n="",r="",h,m,w=!1,y=!1,x=!1,N=!0,c=i.panZoom,a,d;const p=()=>{const l=a.getPan(),Z=a.getZoom();clearTimeout(d),d=window.setTimeout(()=>{ct({pan:l,zoom:Z}),pt("panZoom")},200)},v=l=>{!l.panZoom||(o(4,x=!0),a==null||a.destroy(),a=void 0,Promise.resolve().then(()=>{const Z=document.getElementById("graph-div");a=yt(Z,{onPan:p,onZoom:p,controlIconsEnabled:!0,fit:!0,center:!0});const{pan:B,zoom:z}=l;B!==void 0&&z!==void 0&&Number.isFinite(z)&&(a.zoom(z),a.pan(B)),o(4,x=!1)}))};rt(()=>{G.subscribe(l=>{if(l.error!==void 0){o(2,w=!0);return}o(2,w=!1);try{if(h&&l&&(l.updateDiagram||l.autoSync)){if(l.autoSync||at(X,s.updateDiagram=!1,s),o(3,y=!1),N=!0,n===l.code&&r===l.mermaid&&c===l.panZoom)return;n=l.code,r=l.mermaid,c=l.panZoom;const Z=m.parentElement.scrollTop;delete h.dataset.processed,F.initialize(Object.assign({},JSON.parse(l.mermaid))),F.render("graph-div",n,B=>{if(B.length>0){v(l),o(0,h.innerHTML=B,h);const z=document.getElementById("graph-div");z.setAttribute("height","100%"),z.style.maxWidth="100%"}}),o(1,m.parentElement.scrollTop=Z,m),o(2,w=!1)}else N?N=!1:(n!==l.code||r!==l.mermaid)&&o(3,y=!0)}catch(Z){console.log("view fail",Z),o(2,w=!0)}}),window.addEventListener("resize",()=>{i.panZoom&&a&&a.resize()})});function $(l){U[l?"unshift":"push"](()=>{h=l,o(0,h)})}function tt(l){U[l?"unshift":"push"](()=>{m=l,o(1,m)})}return[h,m,w,y,x,i,$,tt]}class Zt extends et{constructor(e){super(),ot(this,e,xt,St,it,{})}}export{Zt as V};