HomeDashboard/.venv/lib/python3.12/site-packages/nicegui/elements/mermaid/dist/diagram-N7FPYD76-VtQ5TULk.js
2026-01-03 14:54:18 +01:00

3 lines
4.0 KiB
JavaScript

import{c as t}from"./chunk-4KE642ED-DMtXVwOD.js";import{p as e}from"./treemap-75Q7IDZK-HKTH2UG6-CtK1P-cI.js";import{m as a,Z as r,K as l,J as o,Q as n,j as i,X as s,L as d,a6 as c,Y as b,l as p,O as k,u as h,t as g}from"./index-Bd_j0xvv.js";import"./chunk-5ZJXQJOJ-BQpwB-Bn.js";var f={packet:[]},u=structuredClone(f),w=h.packet,x=a(()=>{let t=d({...w,...k().packet});return t.showBits&&(t.paddingY+=10),t},"getConfig"),m=a(()=>u.packet,"getPacket"),$={pushWord:a(t=>{t.length>0&&u.packet.push(t)},"pushWord"),getPacket:m,getConfig:x,clear:a(()=>{p(),u=structuredClone(f)},"clear"),setAccTitle:s,getAccTitle:i,setDiagramTitle:n,getDiagramTitle:o,getAccDescription:l,setAccDescription:r},y=a(e=>{t(e,$);let a=-1,r=[],l=1,{bitsPerRow:o}=$.getConfig();for(let{start:t,end:n,bits:i,label:s}of e.blocks){if(void 0!==t&&void 0!==n&&n<t)throw new Error(`Packet block ${t} - ${n} is invalid. End must be greater than start.`);if(t??=a+1,t!==a+1)throw new Error(`Packet block ${t} - ${n??t} is not contiguous. It should start from ${a+1}.`);if(0===i)throw new Error(`Packet block ${t} is invalid. Cannot have a zero bit field.`);for(n??=t+(i??1)-1,i??=n-t+1,a=n,g.debug(`Packet block ${t} - ${a} with label ${s}`);r.length<=o+1&&$.getPacket().length<1e4;){let[e,a]=C({start:t,end:n,bits:i,label:s},l,o);if(r.push(e),e.end+1===l*o&&($.pushWord(r),r=[],l++),!a)break;({start:t,end:n,bits:i,label:s}=a)}}$.pushWord(r)},"populate"),C=a((t,e,a)=>{if(void 0===t.start)throw new Error("start should have been set during first phase");if(void 0===t.end)throw new Error("end should have been set during first phase");if(t.start>t.end)throw new Error(`Block start ${t.start} is greater than block end ${t.end}.`);if(t.end+1<=e*a)return[t,void 0];let r=e*a-1,l=e*a;return[{start:t.start,end:r,label:t.label,bits:r-t.start},{start:l,end:t.end,label:t.label,bits:t.end-l}]},"getNextFittingBlock"),B={parse:a(async t=>{let a=await e("packet",t);g.debug(a),y(a)},"parse")},v=a((t,e,a,r)=>{let l=r.db,o=l.getConfig(),{rowHeight:n,paddingY:i,bitWidth:s,bitsPerRow:d}=o,p=l.getPacket(),k=l.getDiagramTitle(),h=n+i,g=h*(p.length+1)-(k?0:n),f=s*d+2,u=c(e);u.attr("viewbox",`0 0 ${f} ${g}`),b(u,g,f,o.useMaxWidth);for(let[t,e]of p.entries())P(u,e,t,o);u.append("text").text(k).attr("x",f/2).attr("y",g-h/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")},"draw"),P=a((t,e,a,{rowHeight:r,paddingX:l,paddingY:o,bitWidth:n,bitsPerRow:i,showBits:s})=>{let d=t.append("g"),c=a*(r+o)+o;for(let t of e){let e=t.start%i*n+1,a=(t.end-t.start+1)*n-l;if(d.append("rect").attr("x",e).attr("y",c).attr("width",a).attr("height",r).attr("class","packetBlock"),d.append("text").attr("x",e+a/2).attr("y",c+r/2).attr("class","packetLabel").attr("dominant-baseline","middle").attr("text-anchor","middle").text(t.label),!s)continue;let o=t.end===t.start,b=c-2;d.append("text").attr("x",e+(o?a/2:0)).attr("y",b).attr("class","packetByte start").attr("dominant-baseline","auto").attr("text-anchor",o?"middle":"start").text(t.start),o||d.append("text").attr("x",e+a).attr("y",b).attr("class","packetByte end").attr("dominant-baseline","auto").attr("text-anchor","end").text(t.end)}},"drawWord"),z={draw:v},S={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},W=a(({packet:t}={})=>{let e=d(S,t);return`\n\t.packetByte {\n\t\tfont-size: ${e.byteFontSize};\n\t}\n\t.packetByte.start {\n\t\tfill: ${e.startByteColor};\n\t}\n\t.packetByte.end {\n\t\tfill: ${e.endByteColor};\n\t}\n\t.packetLabel {\n\t\tfill: ${e.labelColor};\n\t\tfont-size: ${e.labelFontSize};\n\t}\n\t.packetTitle {\n\t\tfill: ${e.titleColor};\n\t\tfont-size: ${e.titleFontSize};\n\t}\n\t.packetBlock {\n\t\tstroke: ${e.blockStrokeColor};\n\t\tstroke-width: ${e.blockStrokeWidth};\n\t\tfill: ${e.blockFillColor};\n\t}\n\t`},"styles"),E={parser:B,db:$,renderer:z,styles:W};export{E as diagram};
//# sourceMappingURL=diagram-N7FPYD76-VtQ5TULk.js.map