UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

2 lines (1 loc) 6.26 kB
import{A as G,t as P}from"./chunk-QJSWEUOL.mjs";import{b as h}from"./chunk-H7VHZCWX.mjs";import{a as s}from"./chunk-AQ6EADP3.mjs";var H=Object.freeze({left:0,top:0,width:16,height:16}),g=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),y=Object.freeze({...H,...g}),M=Object.freeze({...y,body:"",hidden:!1});var B=Object.freeze({width:null,height:null}),L=Object.freeze({...B,...g});var T=s((t,e,n,r="")=>{let o=t.split(":");if(t.slice(0,1)==="@"){if(o.length<2||o.length>3)return null;r=o.shift().slice(1)}if(o.length>3||!o.length)return null;if(o.length>1){let f=o.pop(),m=o.pop(),p={provider:o.length>0?o[0]:r,prefix:m,name:f};return e&&!x(p)?null:p}let c=o[0],i=c.split("-");if(i.length>1){let f={provider:r,prefix:i.shift(),name:i.join("-")};return e&&!x(f)?null:f}if(n&&r===""){let f={provider:r,prefix:"",name:c};return e&&!x(f,n)?null:f}return null},"stringToIcon"),x=s((t,e)=>t?!!((e&&t.prefix===""||t.prefix)&&t.name):!1,"validateIconName");function z(t,e){let n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);let r=((t.rotate||0)+(e.rotate||0))%4;return r&&(n.rotate=r),n}s(z,"mergeIconTransformations");function E(t,e){let n=z(t,e);for(let r in M)r in g?r in t&&!(r in n)&&(n[r]=g[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}s(E,"mergeIconData");function A(t,e){let n=t.icons,r=t.aliases||Object.create(null),o=Object.create(null);function c(i){if(n[i])return o[i]=[];if(!(i in o)){o[i]=null;let f=r[i]&&r[i].parent,m=f&&c(f);m&&(o[i]=[f].concat(m))}return o[i]}return s(c,"resolve"),(e||Object.keys(n).concat(Object.keys(r))).forEach(c),o}s(A,"getIconsTree");function U(t,e,n){let r=t.icons,o=t.aliases||Object.create(null),c={};function i(f){c=E(r[f]||o[f],c)}return s(i,"parse"),i(e),n.forEach(i),E(t,c)}s(U,"internalGetIconData");function b(t,e){if(t.icons[e])return U(t,e,[]);let n=A(t,[e])[e];return n?U(t,e,n):null}s(b,"getIconData");var J=/(-?[0-9.]*[0-9]+[0-9.]*)/g,K=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function j(t,e,n){if(e===1)return t;if(n=n||100,typeof t=="number")return Math.ceil(t*e*n)/n;if(typeof t!="string")return t;let r=t.split(J);if(r===null||!r.length)return t;let o=[],c=r.shift(),i=K.test(c);for(;;){if(i){let f=parseFloat(c);isNaN(f)?o.push(c):o.push(Math.ceil(f*e*n)/n)}else o.push(c);if(c=r.shift(),c===void 0)return o.join("");i=!i}}s(j,"calculateSize");function W(t,e="defs"){let n="",r=t.indexOf("<"+e);for(;r>=0;){let o=t.indexOf(">",r),c=t.indexOf("</"+e);if(o===-1||c===-1)break;let i=t.indexOf(">",c);if(i===-1)break;n+=t.slice(o+1,c).trim(),t=t.slice(0,r).trim()+t.slice(i+1)}return{defs:n,content:t}}s(W,"splitSVGDefs");function Q(t,e){return t?"<defs>"+t+"</defs>"+e:e}s(Q,"mergeDefsAndContent");function $(t,e,n){let r=W(t);return Q(r.defs,e+r.content+n)}s($,"wrapSVGContent");var X=s(t=>t==="unset"||t==="undefined"||t==="none","isUnsetKeyword");function F(t,e){let n={...y,...t},r={...L,...e},o={left:n.left,top:n.top,width:n.width,height:n.height},c=n.body;[n,r].forEach(d=>{let a=[],R=d.hFlip,V=d.vFlip,u=d.rotate;R?V?u+=2:(a.push("translate("+(o.width+o.left).toString()+" "+(0-o.top).toString()+")"),a.push("scale(-1 1)"),o.top=o.left=0):V&&(a.push("translate("+(0-o.left).toString()+" "+(o.height+o.top).toString()+")"),a.push("scale(1 -1)"),o.top=o.left=0);let l;switch(u<0&&(u-=Math.floor(u/4)*4),u=u%4,u){case 1:l=o.height/2+o.top,a.unshift("rotate(90 "+l.toString()+" "+l.toString()+")");break;case 2:a.unshift("rotate(180 "+(o.width/2+o.left).toString()+" "+(o.height/2+o.top).toString()+")");break;case 3:l=o.width/2+o.left,a.unshift("rotate(-90 "+l.toString()+" "+l.toString()+")");break}u%2===1&&(o.left!==o.top&&(l=o.left,o.left=o.top,o.top=l),o.width!==o.height&&(l=o.width,o.width=o.height,o.height=l)),a.length&&(c=$(c,'<g transform="'+a.join(" ")+'">',"</g>"))});let i=r.width,f=r.height,m=o.width,p=o.height,I,S;i===null?(S=f===null?"1em":f==="auto"?p:f,I=j(S,m/p)):(I=i==="auto"?m:i,S=f===null?j(I,p/m):f==="auto"?p:f);let w={},O=s((d,a)=>{X(a)||(w[d]=a.toString())},"setAttr");O("width",I),O("height",S);let k=[o.left,o.top,m,p];return w.viewBox=k.join(" "),{attributes:w,viewBox:k,body:c}}s(F,"iconToSVG");var Y=/\sid="(\S+)"/g,Z="IconifyId"+Date.now().toString(16)+(Math.random()*16777216|0).toString(16),_=0;function C(t,e=Z){let n=[],r;for(;r=Y.exec(t);)n.push(r[1]);if(!n.length)return t;let o="suffix"+(Math.random()*16777216|Date.now()).toString(16);return n.forEach(c=>{let i=typeof e=="function"?e(c):e+(_++).toString(),f=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+f+')([")]|\\.[a-z])',"g"),"$1"+i+o+"$3")}),t=t.replace(new RegExp(o,"g"),""),t}s(C,"replaceIDs");function v(t,e){let n=t.indexOf("xlink:")===-1?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(let r in e)n+=" "+r+'="'+e[r]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}s(v,"iconToHTML");var tt={body:'<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/><text transform="translate(21.16 64.67)" style="fill: #fff; font-family: ArialMT, Arial; font-size: 67.75px;"><tspan x="0" y="0">?</tspan></text></g>',height:80,width:80},D=new Map,q=new Map,Rt=s(t=>{for(let e of t){if(!e.name)throw new Error('Invalid icon loader. Must have a "name" property with non-empty string value.');if(h.debug("Registering icon pack:",e.name),"loader"in e)q.set(e.name,e.loader);else if("icons"in e)D.set(e.name,e.icons);else throw h.error("Invalid icon loader:",e),new Error('Invalid icon loader. Must have either "icons" or "loader" property.')}},"registerIconPacks"),N=s(async(t,e)=>{let n=T(t,!0,e!==void 0);if(!n)throw new Error(`Invalid icon name: ${t}`);let r=n.prefix||e;if(!r)throw new Error(`Icon name must contain a prefix: ${t}`);let o=D.get(r);if(!o){let i=q.get(r);if(!i)throw new Error(`Icon set not found: ${n.prefix}`);try{o={...await i(),prefix:r},D.set(r,o)}catch(f){throw h.error(f),new Error(`Failed to load icon set: ${n.prefix}`)}}let c=b(o,n.name);if(!c)throw new Error(`Icon not found: ${t}`);return c},"getRegisteredIconData"),Ht=s(async t=>{try{return await N(t),!0}catch{return!1}},"isIconAvailable"),Bt=s(async(t,e,n)=>{let r;try{r=await N(t,e?.fallbackPrefix)}catch(i){h.error(i),r=tt}let o=F(r,e),c=v(C(o.body),{...o.attributes,...n});return G(c,P())},"getIconSVG");export{tt as a,Rt as b,Ht as c,Bt as d};