Files
mermaid-live-editor/_app/immutable/chunks/view-8b5fc4cf.js
T
2022-08-12 09:56:41 +00:00

2 lines
2.0 KiB
JavaScript

import{S as z,i as j,s as q,a as H,l as b,c as J,m as v,n as g,h as c,p as u,Z as d,b as y,N as M,E,M as w,o as L,a5 as Q,r as U,u as Z,v as A,Q as D}from"./index-1530a265.js";import{i as O,s as V,v as k}from"./state-7916fb32.js";function I(l){let o,e=l[4].error+"",i;return{c(){o=b("div"),i=U(e),this.h()},l(s){o=v(s,"DIV",{class:!0,id:!0});var r=g(o);i=Z(r,e),r.forEach(c),this.h()},h(){u(o,"class","p-2 text-red-600"),u(o,"id","errorContainer")},m(s,r){y(s,o,r),M(o,i)},p(s,r){r&16&&e!==(e=s[4].error+"")&&A(i,e)},d(s){s&&c(o)}}}function B(l){let o,e,i,s=l[2]&&l[4].error instanceof Error&&I(l);return{c(){s&&s.c(),o=H(),e=b("div"),i=b("div"),this.h()},l(r){s&&s.l(r),o=J(r),e=v(r,"DIV",{id:!0,class:!0});var n=g(e);i=v(n,"DIV",{id:!0,class:!0}),g(i).forEach(c),n.forEach(c),this.h()},h(){u(i,"id","container"),u(i,"class","flex-1 overflow-auto"),u(e,"id","view"),u(e,"class","p-2 svelte-1blxohz"),d(e,"error",l[2]),d(e,"outOfSync",l[3])},m(r,n){s&&s.m(r,n),y(r,o,n),y(r,e,n),M(e,i),l[5](i),l[6](e)},p(r,[n]){r[2]&&r[4].error instanceof Error?s?s.p(r,n):(s=I(r),s.c(),s.m(o.parentNode,o)):s&&(s.d(1),s=null),n&4&&d(e,"error",r[2]),n&8&&d(e,"outOfSync",r[3])},i:E,o:E,d(r){s&&s.d(r),r&&c(o),r&&c(e),l[5](null),l[6](null)}}}function C(l,o,e){let i,s;w(l,O,t=>e(10,i=t)),w(l,V,t=>e(4,s=t));let r="",n="",a,f,p=!1,m=!1,_=!0;L(()=>{V.subscribe(t=>{if(t.error!==void 0){e(2,p=!0);return}e(2,p=!1);try{if(a&&t&&(t.updateDiagram||t.autoSync)){if(t.autoSync||Q(O,i.updateDiagram=!1,i),e(3,m=!1),_=!0,r===t.code&&n===t.mermaid)return;r=t.code,n=t.mermaid;const h=f.parentElement.scrollTop;delete a.dataset.processed,k.initialize(Object.assign({},JSON.parse(t.mermaid))),k.render("graph-div",r,S=>{S.length>0&&(console.log(S),e(0,a.innerHTML=S,a))}),e(1,f.parentElement.scrollTop=h,f),e(2,p=!1)}else _?_=!1:e(3,m=!0)}catch(h){console.log("view fail",h),e(2,p=!0)}})});function N(t){D[t?"unshift":"push"](()=>{a=t,e(0,a)})}function T(t){D[t?"unshift":"push"](()=>{f=t,e(1,f)})}return[a,f,p,m,s,N,T]}class K extends z{constructor(o){super(),j(this,o,C,B,q,{})}}export{K as V};