Files
mermaid-live-editor/docs/_app/chunks/util-bc8a8da5.js
T
2021-05-23 06:13:49 +00:00

2 lines
3.3 KiB
JavaScript

var e=Object.defineProperty,a=Object.defineProperties,t=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,s=(a,t,n)=>t in a?e(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n,i=(e,a)=>{for(var t in a||(a={}))o.call(a,t)&&s(e,t,a[t]);if(n)for(var t of n(a))r.call(a,t)&&s(e,t,a[t]);return e},c=(e,n)=>a(e,t(n));import{a2 as l,a3 as d,C as u,a4 as p,a0 as f,a6 as h,a9 as m,S as y,i as g,s as v,e as b,c as O,a as w,d as S,b as E,O as x,f as D,F as j,G as C,a7 as T,z as P,a8 as J,J as N}from"./vendor-05ca1e79.js";const I=l(u({code:"graph TD\n A[Christmas] --\x3e|Get money| B(Go shopping)\n B --\x3e C{Let me think}\n C --\x3e|One| D[Laptop]\n C --\x3e|Two| E[iPhone]\n C --\x3e|Three| F[fa:fa-car Car]\n ",mermaid:JSON.stringify({theme:"default"},null,2),updateEditor:!1,autoSync:!0,updateDiagram:!0}),d(),"codeStore"),L=p([I],(([e],a)=>{a(f(JSON.stringify(e),!0))})),G=e=>{I.update((a=>i(i({},a),e)))};let V=!1;const k=(e,a,t=!1)=>{if((e.match(/\n/g)||"").length+1>50&&!V&&h(I).autoSync){const e=confirm("Long diagram deteced. Turn off Auto Sync? Click the sync logo to manually sync.");V=!0,e&&G({autoSync:!1})}I.update((n=>c(i({},n),{code:e,updateEditor:a,updateDiagram:t})))},z=(e,a)=>{I.update((t=>c(i({},t),{mermaid:e,updateEditor:a})))},A=()=>JSON.stringify(h(I)),B=u(void 0);function F(e){let a,t;return{c(){a=b("div"),t=b("div"),this.h()},l(e){a=O(e,"DIV",{id:!0,class:!0});var n=w(a);t=O(n,"DIV",{id:!0,class:!0}),w(t).forEach(S),n.forEach(S),this.h()},h(){E(t,"id","container"),E(t,"class","flex-1 overflow-auto"),E(a,"id","view"),E(a,"class","p-2 svelte-7vvt6c"),x(a,"error",e[1]),x(a,"outOfSync",e[2])},m(n,o){D(n,a,o),j(a,t),e[3](t)},p(e,[t]){2&t&&x(a,"error",e[1]),4&t&&x(a,"outOfSync",e[2])},i:C,o:C,d(t){t&&S(a),e[3](null)}}}function _(e,a,t){let n;T(e,I,(e=>t(6,n=e)));var o=this&&this.__awaiter||function(e,a,t,n){return new(t||(t=Promise))((function(o,r){function s(e){try{c(n.next(e))}catch(a){r(a)}}function i(e){try{c(n.throw(e))}catch(a){r(a)}}function c(e){var a;e.done?o(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(s,i)}c((n=n.apply(e,a||[])).next())}))};const r=window.mermaid;let s,i="",c=!1,l=!1,d=!0;P((()=>o(void 0,void 0,void 0,(function*(){I.subscribe((e=>{try{if(s&&e&&(e.updateDiagram||e.autoSync)){e.autoSync||J(I,n.updateDiagram=!1,n),t(2,l=!1),d=!0,i=e.code;const a=s.parentElement.parentElement.parentElement.scrollTop;t(0,s.innerHTML=i,s),delete s.dataset.processed,r.initialize(Object.assign({},JSON.parse(e.mermaid))),r.init(s),r.render("graph-div",i,u),t(0,s.parentElement.parentElement.parentElement.scrollTop=a,s)}else d?d=!1:t(2,l=!0)}catch(a){console.log("view fail",a),t(1,c=!0)}})),B.subscribe((e=>{void 0===e?t(1,c=!1):(t(1,c=!0),console.log("Error: ",e))}))}))));const u=(e,a)=>{};return[s,c,l,function(e){N[e?"unshift":"push"]((()=>{s=e,t(0,s)}))}]}class H extends y{constructor(e){super(),g(this,e,_,F,v,{})}}const M=()=>{(e=>{let a;try{const t=m(e);console.log(`Tring to load state: ${t}`),a=JSON.parse(t)}catch(t){e&&console.error("Init error",t),a=h(I),console.log(a)}G(c(i({},a),{updateEditor:!0}))})(window.location.hash.slice(1))},$=()=>{G({updateDiagram:!0})},q=()=>{M(),$(),L.subscribe((e=>{window.location.hash=e}))};export{H as V,z as a,L as b,I as c,B as e,A as g,q as i,$ as s,k as u};