Files
mermaid-live-editor/_app/chunks/state-b8864def.js
T
2022-03-14 12:23:56 +00:00

19 lines
4.0 KiB
JavaScript

var b=Object.defineProperty,k=Object.defineProperties;var v=Object.getOwnPropertyDescriptors;var u=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var m=(e,t,s)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,a=(e,t)=>{for(var s in t||(t={}))L.call(t,s)&&m(e,s,t[s]);if(u)for(var s of u(t))_.call(t,s)&&m(e,s,t[s]);return e},o=(e,t)=>k(e,v(t));import{D as h,L as C,M as T,N as O,O as D,P as N,Q as w,R as A,T as E,U as z,V as d}from"./vendor-5dd41a27.js";import{_ as f}from"./preload-helper-1db36302.js";const J={loading:!1},p=h(J),H=async(e,t)=>{p.set({loading:!0,message:e});const s=await t;return p.set({loading:!1}),s};let l;const M=async()=>{if(!l)try{const{Analytics:e}=await f(()=>import("./analytics.browser.es-6fbc7285.js"),[]),t=await f(()=>import("./analytics-plugin-ga.browser.es-1cdb0512.js"),[]);l=e({app:"mermaid-live-editor",plugins:[t.init({trackingId:"UA-153180559-1"})]})}catch{console.info("Analytics blocked ;)")}},R=e=>e.replace(/^\s*%%.*\n/g,`
`).trimStart().split(" ")[0];let g;const P=e=>{l&&(clearTimeout(g),g=setTimeout(function(){const t=R(e);console.debug("ga:","send","event","render",t),l.track("render",{graphType:t})},5e3))},U={serialize:e=>N(e,!0),deserialize:e=>w(e)},I={serialize:e=>{const t=new TextEncoder().encode(e),s=T(t,{level:9});return C(s,!0)},deserialize:e=>{const t=O(e);return D(t,{to:"string"})}},c={base64:U,pako:I},B=e=>{const t=JSON.stringify(e),s="pako",n=c[s].serialize(t);return`${s}:${n}`},G=e=>{let t,s;if(e.includes(":")){let r;if([r,s]=e.split(":"),r in c)t=r;else throw new Error(`Unknown serde type: ${r}`)}else t="base64",s=e;const n=c[t].deserialize(s);return JSON.parse(n)},$={code:`graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
`,mermaid:JSON.stringify({theme:"default"},null,2),updateEditor:!1,autoSync:!0,updateDiagram:!0},j=`graph TD
A[Loading URL failed. We can try to figure out why.] -->|Decode JSON| B(Please check the console to see the JSON and error details.)
B --> C{Is the JSON correct?}
C -->|Yes| D(Please Click here to Raise an issue in github.<br/>Including the broken link in the issue <br/> will speed up the fix.)
C -->|No| E{Did someone <br/>send you this link?}
E -->|Yes| F[Ask them to send <br/>you the complete link]
E -->|No| G{Did you copy <br/> the complete URL?}
G --> |Yes| D
G --> |"No :("| H(Try using the Timeline tab in History <br/>from same browser you used to create the diagram.)
click D href "https://github.com/mermaid-js/mermaid-live-editor/issues/new?assignees=&labels=bug&template=bug_report.md&title=Broken%20link" "Raise issue"`,i=A(h($),E(),"codeStore"),x=z([i],([e],t)=>{t(B(e))}),Q=e=>{let t;console.log("Loading",e);try{t=G(e);const s=typeof t.mermaid=="string"?JSON.parse(t.mermaid):t.mermaid;s.securityLevel&&s.securityLevel!=="strict"&&confirm(`Removing "securityLevel":"${s.securityLevel}" from the config for safety.
Click Cancel if you trust the source of this Diagram.`)&&delete s.securityLevel,t.mermaid=JSON.stringify(s,null,2)}catch(s){t=d(i),e&&(console.error("Init error",s),t.code=j)}S(o(a({},t),{updateEditor:!0}))},S=e=>{i.update(t=>a(a({},t),e))};let y=!1;const W=(e,t,s=!1)=>{if(P(e),(e.match(/\n/g)||"").length+1>50&&!y&&d(i).autoSync){const r=confirm("Long diagram detected. Turn off Auto Sync? Click the sync logo to manually sync.");y=!0,r&&S({autoSync:!1})}i.update(r=>o(a({},r),{code:e,updateEditor:t,updateDiagram:s}))},q=(e,t)=>{i.update(s=>o(a({},s),{mermaid:e,updateEditor:t}))},K=e=>{i.update(t=>{const s=JSON.parse(t.mermaid);return(!s.theme||["dark","default"].includes(s.theme))&&(s.theme=e?"dark":"default"),o(a({},t),{mermaid:JSON.stringify(s,null,2),updateEditor:!0})})},X=()=>{x.subscribe(e=>{history.replaceState(void 0,void 0,`#${e}`)})},Z=()=>JSON.stringify(d(i));export{l as a,q as b,i as c,$ as d,S as e,X as f,Z as g,M as h,H as i,Q as j,p as l,I as p,x as s,K as t,W as u};