@shibayama/pdgkit 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,247 @@
1
+ "use strict";var pdgkit=(()=>{var lt=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var ye=Object.prototype.hasOwnProperty;var Se=(t,e)=>{for(var n in e)lt(t,n,{get:e[n],enumerable:!0})},we=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of be(e))!ye.call(t,o)&&o!==n&&lt(t,o,{get:()=>e[o],enumerable:!(r=xe(e,o))||r.enumerable});return t};var Ee=t=>we(lt({},"__esModule",{value:!0}),t);var Kn={};Se(Kn,{PATTERN_SOURCE:()=>Lt,SAMPLES:()=>Bt,SAMPLE_ORDER:()=>Pt,VERSION:()=>Hn,buildSvgModel:()=>Et,computeContentBox:()=>at,layout:()=>z,parse:()=>F,refsToCsv:()=>Ot,refsToMarkdown:()=>Mt,render:()=>q,renderToSvg:()=>ut,serializeSvg:()=>J,svgDisplayDimensions:()=>ct,toSvgString:()=>Wn,validate:()=>me});var K=/[A-Za-z0-9_*]+/.source,vt=[{lit:"<->",kind:"bidir"},{lit:"=>",kind:"thick"},{lit:"->",kind:"arrow"},{lit:"<-",kind:"arrow",reverse:!0},{lit:".>",kind:"dashed-arrow"},{lit:"..",kind:"dashed"},{lit:"-",kind:"line"}],Ae=new RegExp(`^(${K})\\s*=(?!>)\\s*(.*)$`),Me=new RegExp(`^(${K})\\s+(<->|=>|->|<-|\\.>|\\.\\.|-)\\s+(${K})\\s*(?::\\s*(.*))?$`),Oe=new RegExp(`^(${K})\\s*:\\s*(.+)$`);function F(t){let e={nodes:new Map,containments:[],edges:[],diagnostics:[],kind:"block"},n=t.split(/\r?\n/);for(let r=0;r<n.length;r++){let s=Tt(n[r]).trim();s&&(Pe(s,r+1,e)||Be(s,r+1,e)||Le(s,r+1,e)||e.diagnostics.push({severity:"error",line:r+1,col:1,message:`\u69CB\u6587\u4E0D\u660E: "${s}"`}))}return e.kind=_e(e),e}function Pe(t,e,n){let r=t.match(Ae);if(!r)return!1;let o=r[1],s=r[2],i=ht(s);return n.nodes.get(o)&&n.diagnostics.push({severity:"warning",line:e,col:1,message:`\u7B26\u53F7 "${o}" \u306F\u518D\u5B9A\u7FA9\u3055\u308C\u307E\u3057\u305F`}),n.nodes.set(o,{id:o,label:i,implicit:!1}),!0}function Be(t,e,n){let r=t.match(Me);if(!r)return!1;let o=r[2],s=vt.find(u=>u.lit===o),i=s.reverse?r[3]:r[1],a=s.reverse?r[1]:r[3],c=r[4]??"",l={from:i,to:a,op:s.kind,label:c.trim()?ht(c):void 0,line:e};return n.edges.push(l),Q(n,i),Q(n,a),!0}function Le(t,e,n){let r=t.match(Oe);if(!r)return!1;let o=r[1],i=r[2].trim().split(/\s+/).filter(Boolean),a=new RegExp(`^${K}$`);for(let c of i)if(!a.test(c))return n.diagnostics.push({severity:"error",line:e,col:1,message:`\u5305\u542B\u306E\u5B50\u3068\u3057\u3066\u4E0D\u6B63\u306A\u30C8\u30FC\u30AF\u30F3: "${c}"`}),!0;n.containments.push({parent:o,children:i,line:e}),Q(n,o);for(let c of i)Q(n,c);return!0}function Q(t,e){let n=t.nodes.get(e);return n||(n={id:e,label:{},implicit:!0},t.nodes.set(e,n),n)}function Tt(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];if(r==='"')e=!e;else if(!e&&r==="#")return t.slice(0,n)}return t}function ht(t){let e=t.trim();if(!e)return{};let n=Re(e);return n===-1?{ja:ft(e)}:{ja:ft(e.slice(0,n).trim()),en:ft(e.slice(n+1).trim())}}function Re(t){let e=!1;for(let n=0;n<t.length;n++){if(t[n]==='"'){e=!e;continue}if(!e&&t[n]==="/"&&Nt(t[n-1])&&Nt(t[n+1]))return n}return-1}function Nt(t){return t===" "||t===" "}function ft(t){return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function _e(t){if(t.containments.length>0)return"block";for(let n of t.nodes.values()){let r=n.label.ja??"",o=n.label.en??"";if(r.endsWith("?")||o.endsWith("?"))return"flow"}if(t.nodes.has("*"))return"state";let e=new Set;for(let n of t.edges){if(n.op==="bidir")return"seq";let r=`${n.from}|${n.to}`,o=`${n.to}|${n.from}`;if(e.has(o))return"seq";e.add(r)}return"flow"}function z(t){switch(t.kind){case"block":return Ne(t);case"flow":return ve(t);case"state":return Te(t);case"seq":return ke(t)}}function Ne(t){let e=new Map;for(let h of t.containments)e.set(h.parent,h.children);let n=new Map;for(let h of t.containments)for(let g of h.children)n.set(g,h.parent);let r=new Set;for(let h of e.values())for(let g of h)r.add(g);let s=[...t.nodes.keys()].filter(h=>!r.has(h)),i=[],a=new Map;function c(h){let g=e.get(h);if(!g||g.length===0)return{w:36,h:14};let E=g.map(c);if(l(h)==="grid"){let w=u(h,g),B=Math.max(...E.map(M=>M.w)),P=m(E,w);return{w:w*B+16+(w-1)*24,h:f(h)+P.reduce((M,R)=>M+R,0)+16+Math.max(0,P.length-1)*24}}let O=Math.max(...E.map(w=>w.w)),A=E.reduce((w,B)=>w+B.h,0);return{w:O+16,h:f(h)+A+16+(g.length-1)*24}}function l(h){let g=e.get(h);return!g||g.length<=2?"stack":d(h,g)?"grid":De(g,t.edges,e)?"stack":"grid"}function u(h,g){return d(h,g)?Math.min(g.length,4):g.length>=7?4:g.length>=5?3:2}function m(h,g){let E=Math.ceil(h.length/g),O=[];for(let A=0;A<E;A++){let w=h.slice(A*g,A*g+g);O.push(Math.max(...w.map(B=>B.h)))}return O}function f(h){let g=e.get(h);return g&&d(h,g)?19:5}function d(h,g){return t.edges.some(E=>E.from===h&&g.some(O=>O===E.to||gt(O,E.to,e)))}function y(h,g,E){let O=c(h);a.set(h,{x:g,y:E,w:O.w,h:O.h});let A=t.nodes.get(h),w=e.get(h);if(!w||w.length===0){i.push({id:h,x:g,y:E,w:O.w,h:O.h,label:A?.label??{},shape:"box",isContainer:!1});return}let B=w.map(c);if(l(h)==="grid"){let P=u(h,w),M=Math.max(...B.map(v=>v.w)),R=m(B,P),W=[],Rt=E+f(h)+8;for(let v=0;v<R.length;v++)W[v]=Rt,Rt+=R[v]+24;for(let v=0;v<w.length;v++){let _t=Math.floor(v/P),de=v%P,ge=g+8+de*(M+24)+(M-B[v].w)/2,pe=W[_t]+(R[_t]-B[v].h)/2;y(w[v],ge,pe)}Ce(w,B,R,W,P,e,t.edges,a,i)}else{let P=Math.max(...B.map(R=>R.w)),M=E+f(h)+8;for(let R=0;R<w.length;R++){let W=g+8+(P-B[R].w)/2;y(w[R],W,M),M+=B[R].h+24}}i.push({id:h,x:g,y:E,w:O.w,h:O.h,label:A?.label??{},shape:"box",isContainer:!0})}let S=8;for(let h of s){let g=new Set(a.keys());y(h,S,8);let E=tt(h,e),O=Ie(h,E,g,t.edges,a);Math.abs(O)>=.001&&qt(E,O,a,i);let A=c(h);S+=A.w+32}let b=Ge(t.edges,a,i,n);i.sort((h,g)=>{if(h.isContainer!==g.isContainer)return h.isContainer?-1:1;if(h.isContainer&&g.isContainer){let E=Gt(h.id,n)-Gt(g.id,n);return E!==0?E:g.w*g.h-h.w*h.h}return h.y-g.y||h.x-g.x});let x=[...a.values()],p=b.flatMap(h=>h.points),L=x.length?Math.max(...x.map(h=>h.x+h.w)):8,k=x.length?Math.max(...x.map(h=>h.y+h.h)):8,_=p.length?Math.max(...p.map(([h])=>h)):8,D=p.length?Math.max(...p.map(([,h])=>h)):8,V=Math.max(L,_)+8,C=Math.max(k,D)+8;return{nodes:i,edges:b,width:V,height:C,kind:"block"}}function ve(t){let e=[...t.nodes.keys()],{byRank:n}=Ut(t);function r(f){let d=t.nodes.get(f),y=d?.label.ja??"",S=d?.label.en??"";if(y.endsWith("?")||S.endsWith("?"))return"diamond";let b=t.edges.filter(p=>p.to===f).length,x=t.edges.filter(p=>p.from===f).length;return b===0||x===0?"round":"box"}let o=14,s=10,i=new Map,a=[...n.keys()].sort((f,d)=>f-d),c=8,l=0;for(let f of a){let d=n.get(f),y=d.map(p=>r(p)==="diamond"?36*1.2:36),S=y.reduce((p,L)=>p+L,0)+(d.length-1)*s,b=8;b=(Math.max(S+16,200)-S)/2;for(let p=0;p<d.length;p++)i.set(d[p],{x:b,y:c,w:y[p],h:14}),b+=y[p]+s;b>l&&(l=b),c+=14+o}for(let f of e)i.has(f)||(i.set(f,{x:8,y:c,w:36,h:14}),c+=14+o);let u=[];for(let[f,d]of i)u.push({id:f,...d,label:t.nodes.get(f)?.label??{},shape:r(f),isContainer:!1});let m=zt(t.edges,i);return{nodes:u,edges:m,width:l+8,height:c+8,kind:"flow"}}function Te(t){let{byRank:e}=Ut(t);function n(m){return m==="*"?"circle":"round"}let r=14,o=10,s=new Map,i=[...e.keys()].sort((m,f)=>m-f),a=8,c=0;for(let m of i){let f=e.get(m),d=f.map(p=>n(p)==="circle"?6:36),y=f.map(p=>n(p)==="circle"?6:14),S=d.reduce((p,L)=>p+L,0)+(f.length-1)*o,x=(Math.max(S+16,200)-S)/2;for(let p=0;p<f.length;p++)s.set(f[p],{x,y:a+(14-y[p])/2,w:d[p],h:y[p]}),x+=d[p]+o;x>c&&(c=x),a+=14+r}for(let m of t.nodes.keys())s.has(m)||(s.set(m,{x:8,y:a,w:36,h:14}),a+=14+r);let l=[];for(let[m,f]of s)l.push({id:m,...f,label:t.nodes.get(m)?.label??{},shape:n(m),isContainer:!1});let u=zt(t.edges,s);return{nodes:l,edges:u,width:c+8,height:a+8,kind:"state"}}function ke(t){let e=new Set,n=[];for(let d of t.edges)for(let y of[d.from,d.to])e.has(y)||(e.add(y),n.push(y));for(let d of t.nodes.keys())e.has(d)||(e.add(d),n.push(d));let r=40,o=12,s=28,i=12,a=new Map,c=[],l=8;for(let d of n)a.set(d,l+r/2),c.push({id:d,x:l,y:8,w:r,h:o,label:t.nodes.get(d)?.label??{},shape:"actor",isContainer:!1}),l+=r+s;let u=8+o+i,m=[];for(let d of t.edges){let y=a.get(d.from),S=a.get(d.to);y===void 0||S===void 0||(m.push({from:d.from,to:d.to,points:[[y,u],[S,u]],label:d.label,op:d.op}),u+=i)}let f=n.map(d=>({from:d,to:d,points:[[a.get(d),8+o],[a.get(d),u+i]],op:"dashed",isLifeline:!0}));return{nodes:c,edges:[...f,...m],width:l,height:u+16,kind:"seq"}}function Ut(t){let e=[...t.nodes.keys()],n=new Map;for(let u of e)n.set(u,0);for(let u of t.edges)n.set(u.to,(n.get(u.to)??0)+1);let r=new Map;for(let u of t.edges)r.has(u.from)||r.set(u.from,[]),r.get(u.from).push(u.to);let o=e.filter(u=>n.get(u)===0);o.length===0&&(o=e.includes("*")?["*"]:e.length?[e[0]]:[]);let s=new Map,i=new Set;for(let u of o)s.set(u,0),i.add(u);let a=[...o];for(;a.length;){let u=[];for(let m of a){let f=s.get(m);for(let d of r.get(m)??[])i.has(d)||(s.set(d,f+1),i.add(d),u.push(d))}a=u}let c=0;for(let u of s.values())u>c&&(c=u);for(let u of e)i.has(u)||(c++,s.set(u,c),i.add(u));let l=new Map;for(let[u,m]of s)l.has(m)||l.set(m,[]),l.get(m).push(u);return{byRank:l}}function zt(t,e){return t.map(n=>{let r=e.get(n.from),o=e.get(n.to);return!r||!o?{from:n.from,to:n.to,points:[],label:n.label,op:n.op}:{from:n.from,to:n.to,points:dt(r,o),label:n.label,op:n.op}})}function De(t,e,n){let r=new Set(t),o=new Set,s=new Map,i=new Map;for(let l of t)s.set(l,0),i.set(l,0);for(let l of e){let u=kt(l.from,r,n),m=kt(l.to,r,n);if(!u||!m||u===m)continue;let f=`${u}|${m}`;o.has(f)||(o.add(f),i.set(u,(i.get(u)??0)+1),s.set(m,(s.get(m)??0)+1))}if(o.size<t.length-1)return!1;let a=0,c=0;for(let l of t){let u=s.get(l)??0,m=i.get(l)??0;if(u>1||m>1)return!1;u===0&&m===1&&a++,u===1&&m===0&&c++}return a===1&&c===1}function kt(t,e,n){if(e.has(t))return t;for(let r of e)if(gt(r,t,n))return r}function gt(t,e,n){let r=n.get(t);if(!r)return!1;for(let o of r)if(o===e||gt(o,e,n))return!0;return!1}function tt(t,e){let n=new Set([t]);for(let r of e.get(t)??[])for(let o of tt(r,e))n.add(o);return n}function Ce(t,e,n,r,o,s,i,a,c){let l=Math.ceil(t.length/o);for(let u=0;u<l;u++){let m=t.slice(u*o,u*o+o),f=r[u],d=n[u];if(!(f===void 0||d===void 0))for(let y of m){let S=t.indexOf(y),b=e[S];if(!b||b.h>=d-.001)continue;let x=tt(y,s),p=new Set;for(let h of m)if(h!==y)for(let g of tt(h,s))p.add(g);let L=[];for(let h of i){let g=x.has(h.from),E=x.has(h.to);g&&p.has(h.to)?et(L,G(a.get(h.to))-G(a.get(h.from)),nt(h,!1)):E&&p.has(h.from)&&et(L,G(a.get(h.from))-G(a.get(h.to)),nt(h,!0))}if(L.length===0)continue;L.sort((h,g)=>h-g);let k=L[Math.floor(L.length/2)],_=a.get(y);if(!_)continue;let D=f-_.y,V=f+d-b.h-_.y,C=Math.min(V,Math.max(D,k));Math.abs(C)>=.001&&qt(x,C,a,c)}}}function Ie(t,e,n,r,o){let s=[];for(let c of r){let l=e.has(c.from),u=e.has(c.to),m=n.has(c.from),f=n.has(c.to);l&&f?et(s,G(o.get(c.to))-G(o.get(c.from)),nt(c,!1)):u&&m&&et(s,G(o.get(c.from))-G(o.get(c.to)),nt(c,!0))}if(s.length===0)return 0;s.sort((c,l)=>c-l);let i=s[Math.floor(s.length/2)],a=o.get(t);return a?Math.max(8-a.y,i):i}function et(t,e,n){if(Number.isFinite(e))for(let r=0;r<n;r++)t.push(e)}function nt(t,e){return(t.op==="dashed"||t.op==="dashed-arrow"?1:3)+(e?1:0)}function G(t){return t?t.y+t.h/2:Number.NaN}function qt(t,e,n,r){for(let o of t){let s=n.get(o);s&&(s.y+=e)}for(let o of r)t.has(o.id)&&(o.y+=e)}function Ge(t,e,n,r){let o=new Set(n.filter(i=>i.isContainer).map(i=>i.id)),s=t.map((i,a)=>{let c=e.get(i.from),l=e.get(i.to);if(!c||!l)return{edge:i,index:a,endpointBoundaries:[],endpointInteriorBarriers:[]};let u=Ct(i.from,i.to,e,r,o)??c,m=Ct(i.to,i.from,e,r,o)??l,f=[...u===c?[]:[c],...m===l?[]:[l]],d=[...It(i.from,i.to,r,o)?[c]:[],...It(i.to,i.from,r,o)?[l]:[]];return{edge:i,index:a,routeA:u,routeB:m,endpointBoundaries:f,endpointInteriorBarriers:d,bounds:en(i.from,i.to,r,e)}});return $e(s,n,r)}function $e(t,e,n){let r=[];for(let o of t){let s=We(o),i=r.flatMap((u,m)=>Ye(u,m)),a=r.flatMap((u,m)=>Ve(u,m)),c=i.filter(u=>u.edgeIndex!==o.index&&!je(u,o.edge)&&(!s||Jt(s,u))),l=a.filter(u=>He(u,o,s));r.push(Fe(o,[...e,...c,...l],n))}return r}function Fe(t,e,n){let{edge:r,routeA:o,routeB:s}=t;return!o||!s?{from:r.from,to:r.to,points:[],label:r.label,op:r.op}:{from:r.from,to:r.to,points:Qt(o,s,r.from,r.to,e,n,t.bounds,t.endpointBoundaries,t.endpointInteriorBarriers,r.op),label:r.label,op:r.op}}function Ye(t,e){if(t.isLifeline||t.points.length<2)return[];let n=[];return Xe(t.op)&&n.push(Dt(t,e,t.points[t.points.length-1],"end")),t.op==="bidir"&&n.push(Dt(t,e,t.points[0],"start")),n}function Xe(t){return t!=="line"&&t!=="dashed"}function Dt(t,e,n,r){let o=t.op==="thick"?5:4.2;return{id:`__arrow_guard_${e}_${r}`,x:n[0]-o,y:n[1]-o,w:o*2,h:o*2,isContainer:!1,edgeIndex:e,edgeFrom:t.from,edgeTo:t.to}}function je(t,e){return t.edgeFrom===e.from||t.edgeFrom===e.to||t.edgeTo===e.from||t.edgeTo===e.to}function Ve(t,e){if(t.points.length<2)return[];let n=[],r=2.2,o=1.2;for(let s=0;s<t.points.length-1;s++){let i=t.points[s],a=t.points[s+1];if(!(pt(i,a)<=o*2)){if(Math.abs(i[0]-a[0])<.001){let l=Math.min(i[1],a[1])+o,u=Math.max(i[1],a[1])-o;n.push({id:`__edge_guard_${e}_${s}`,x:i[0]-r,y:l,w:r*2,h:u-l,isContainer:!1,edgeIndex:e,edgeOp:t.op,orientation:"vertical"})}else if(Math.abs(i[1]-a[1])<.001){let l=Math.min(i[0],a[0])+o,u=Math.max(i[0],a[0])-o;n.push({id:`__edge_guard_${e}_${s}`,x:l,y:i[1]-r,w:u-l,h:r*2,isContainer:!1,edgeIndex:e,edgeOp:t.op,orientation:"horizontal"})}}}return n}function He(t,e,n){return t.edgeIndex===e.index?!1:!n||Jt(n,t)}function We(t){if(!t.routeA||!t.routeB)return;let e=Math.min(t.routeA.x,t.routeB.x),n=Math.min(t.routeA.y,t.routeB.y),r=Math.max(t.routeA.x+t.routeA.w,t.routeB.x+t.routeB.w),o=Math.max(t.routeA.y+t.routeA.h,t.routeB.y+t.routeB.h),s=48,i={x:e-s,y:n-s,w:r-e+s*2,h:o-n+s*2};return t.bounds?{x:Math.max(i.x,t.bounds.x),y:Math.max(i.y,t.bounds.y),w:Math.min(i.x+i.w,t.bounds.x+t.bounds.w)-Math.max(i.x,t.bounds.x),h:Math.min(i.y+i.h,t.bounds.y+t.bounds.h)-Math.max(i.y,t.bounds.y)}:i}function Jt(t,e){return t.x<e.x+e.w&&t.x+t.w>e.x&&t.y<e.y+e.h&&t.y+t.h>e.y}function Ct(t,e,n,r,o){let s=n.get(t),i=n.get(e);if(!s||!i)return;if(!rt(t,e,r))return o.has(t)?s:void 0;let a=s.x+8,c=s.x+s.w-8,l=s.y+5+8/2;return{x:Math.min(c,Math.max(a,i.x+i.w/2))-.1,y:l-.1,w:.2,h:.2}}function It(t,e,n,r){return r.has(t)&&!rt(t,e,n)}function rt(t,e,n){let r=e,o=new Set;for(;n.has(r)&&!o.has(r);)if(o.add(r),r=n.get(r),r===t)return!0;return!1}function Gt(t,e){let n=0,r=t,o=new Set;for(;e.has(r)&&!o.has(r);)o.add(r),r=e.get(r),n++;return n}function Qt(t,e,n,r,o,s,i,a=[],c=[],l="line",u=!0){let m=o.filter(h=>h.id!==n&&h.id!==r),f=m.filter(h=>!h.isContainer),d=f.filter(h=>h.id.startsWith("__arrow_guard_")),y=ze(n,r,s),S=m.filter(h=>h.isContainer&&y.has(h.id)),b=m.filter(h=>h.isContainer&&!y.has(h.id)),x=S.filter(h=>rt(h.id,n,s)!==rt(h.id,r,s)),p=a.map((h,g)=>({...h,id:`__endpoint_boundary_${g}`,isContainer:!0})),L=f.filter(h=>!h.id.startsWith("__")),k=f.filter(Zt),_=Ke(t,e);if(_&&$t(_,l)&&(!i||Wt(_,i))&&!I(_,L,.8)&&!I(_,d,.8)&&(!u||!Xt(_,k))&&!I(_,b,.8)&&!I(_,c,0)&&!mt(_,[...a,...S,...b],4))return _;let D=tn(t,e,[...m,...p],i),V=dt(t,e),C=Number.POSITIVE_INFINITY;for(let h of jt(t))for(let g of jt(e)){let E=h.point,O=g.point,A=Vt(h),w=Vt(g),B=[[E,A,[w[0],A[1]],w,O],[E,A,[A[0],w[1]],w,O]];(Math.abs(A[0]-w[0])<.001||Math.abs(A[1]-w[1])<.001)&&B.push([E,A,w,O]);for(let P of D.xs)B.push([E,A,[P,A[1]],[P,w[1]],w,O]);for(let P of D.ys)B.push([E,A,[A[0],P],[w[0],P],w,O]);for(let P of D.xs)for(let M of D.ys)B.push([E,A,[P,A[1]],[P,M],[w[0],M],w,O]),B.push([E,A,[A[0],M],[P,M],[P,w[1]],w,O]);for(let P of B){let M=rn(P);if(!on(M)||!$t(M,l)||i&&!Wt(M,i)||mt(M,[t,e],0)||I(M,c,0)||I(M,L,.8)||I(M,d,.8)||u&&Xt(M,k)||I(M,b,.8)||mt(M,[...a,...S,...b],4))continue;let R=sn(M,t,e,f,b,S,x,a)+qe(t,e,h.side,g.side,l)+h.offsetPenalty+g.offsetPenalty;R<C&&(V=M,C=R)}}return C===Number.POSITIVE_INFINITY?u&&k.length>0?Qt(t,e,n,r,o,s,i,a,c,l,!1):dt(t,e):V}function Ke(t,e){let n=t.x+t.w/2,r=t.y+t.h/2,o=e.x+e.w/2,s=e.y+e.h/2;if(Math.abs(r-s)<.001){if(t.x+t.w<=e.x)return[[t.x+t.w,r],[e.x,s]];if(e.x+e.w<=t.x)return[[t.x,r],[e.x+e.w,s]]}if(Math.abs(n-o)<.001){if(t.y+t.h<=e.y)return[[n,t.y+t.h],[o,e.y]];if(e.y+e.h<=t.y)return[[n,t.y],[o,e.y+e.h]]}}function $t(t,e){return!(t.length<2||e!=="line"&&e!=="dashed"&&Ft(t,!1)<Yt(e)||e==="bidir"&&Ft(t,!0)<Yt(e))}function Ft(t,e){if(t.length<2)return 0;let n=e?t[0]:t[t.length-1],r=e?t[1]:t[t.length-2];return pt(n,r)}function Yt(t){return t==="thick"?5.4:4.6}function I(t,e,n){for(let r=0;r<t.length-1;r++)for(let o of e)if(Y(t[r],t[r+1],o,n)>.001)return!0;return!1}function mt(t,e,n){for(let r=0;r<t.length-1;r++)for(let o of e)if(te(t[r],t[r+1],o,n)>.001)return!0;return!1}function Xt(t,e){for(let n=0;n<t.length-1;n++)for(let r of e)if(Ue(t[n],t[n+1],r))return!0;return!1}function Ue(t,e,n){let r=Math.abs(t[0]-e[0])<.001,o=Math.abs(t[1]-e[1])<.001;if(r&&n.orientation==="vertical"){let s=n.x+n.w/2;return Math.abs(t[0]-s)>n.w/2+.001?!1:H(t[1],e[1],n.y,n.y+n.h)>.001}if(o&&n.orientation==="horizontal"){let s=n.y+n.h/2;return Math.abs(t[1]-s)>n.h/2+.001?!1:H(t[0],e[0],n.x,n.x+n.w)>.001}return!1}function ze(t,e,n){return new Set([t,e,...ot(t,n),...ot(e,n)])}function jt(t){let e=t.x+t.w/2,n=t.y+t.h/2,r=Math.min(t.w*.25,Math.max(3,t.w/2-4)),o=Math.min(t.h*.25,Math.max(2,t.h/2-3)),s=9;return[{point:[t.x+t.w,n],side:"right",offsetPenalty:0},{point:[t.x,n],side:"left",offsetPenalty:0},{point:[e,t.y+t.h],side:"bottom",offsetPenalty:0},{point:[e,t.y],side:"top",offsetPenalty:0},{point:[t.x+t.w,n-o],side:"right",offsetPenalty:s},{point:[t.x+t.w,n+o],side:"right",offsetPenalty:s},{point:[t.x,n-o],side:"left",offsetPenalty:s},{point:[t.x,n+o],side:"left",offsetPenalty:s},{point:[e-r,t.y+t.h],side:"bottom",offsetPenalty:s},{point:[e+r,t.y+t.h],side:"bottom",offsetPenalty:s},{point:[e-r,t.y],side:"top",offsetPenalty:s},{point:[e+r,t.y],side:"top",offsetPenalty:s}]}function Vt(t){let[e,n]=t.point;switch(t.side){case"right":return[e+6,n];case"left":return[e-6,n];case"bottom":return[e,n+6];case"top":return[e,n-6]}}function qe(t,e,n,r,o){let s=t.x+t.w/2,i=t.y+t.h/2,a=e.x+e.w/2,c=e.y+e.h/2,l=a-s,u=c-i;return o==="dashed"?Je(n,r,l,u,t,e):Qe(n,l,u,t)+Ze(r,l,u,e)}function Je(t,e,n,r,o,s){if(Math.abs(r)>Math.min(o.h,s.h)*.8){let i=r>0?"bottom":"top",a=r>0?"top":"bottom";return Z(t,i)+Z(e,a)}if(Math.abs(n)>Math.min(o.w,s.w)*.8){let i=n>0?"right":"left",a=n>0?"left":"right";return Z(t,i)+Z(e,a)}return 0}function Z(t,e){return t===e?0:t===X(e)?1400:450}function Qe(t,e,n,r){if(Math.abs(n)>r.h*.8&&Math.abs(n)>=Math.abs(e)*.25){let o=n>0?"bottom":"top";return t===o?0:t===X(o)?800:180}if(Math.abs(e)>r.w*.5){let o=e>0?"right":"left";return t===o?0:t===X(o)?900:90}if(Math.abs(n)>r.h*.8){let o=n>0?"bottom":"top";return t===o?0:t===X(o)?600:120}return 0}function Ze(t,e,n,r){if(Math.abs(n)>r.h*.8&&Math.abs(n)>=Math.abs(e)*.25){let o=n>0?"top":"bottom";return t===o?0:t===X(o)?1400:360}if(Math.abs(e)>r.w*.5&&Math.abs(e)>=Math.abs(n)*1.2){let o=e>0?"left":"right";return t===o?0:t===X(o)?1200:220}if(Math.abs(n)>r.h*.35){let o=n>0?"top":"bottom";return t===o?0:t==="left"||t==="right"?9e3:1200}if(Math.abs(e)>r.w*.5){let o=e>0?"left":"right";return t===o?0:t===X(o)?1e3:160}return 0}function X(t){switch(t){case"right":return"left";case"left":return"right";case"bottom":return"top";case"top":return"bottom"}}function tn(t,e,n,r){let o=[t,e,...n],s=24,i=r?r.x:Math.max(8,Math.min(...o.map(f=>f.x))-s),a=r?r.x+r.w:Math.max(...o.map(f=>f.x+f.w))+s,c=r?r.y:Math.max(8,Math.min(...o.map(f=>f.y))-s),l=r?r.y+r.h:Math.max(...o.map(f=>f.y+f.h))+s,u=[(t.x+t.w/2+e.x+e.w/2)/2],m=[(t.y+t.h/2+e.y+e.h/2)/2];for(let f of o)for(let d of[12,12*1.5,24])u.push(f.x-d,f.x+f.w+d),m.push(f.y-d,f.y+f.h+d);return r&&(u.push(r.x,r.x+r.w),m.push(r.y,r.y+r.h)),{xs:Ht(Kt(u.filter(f=>f>=i&&f<=a)),(t.x+t.w/2+e.x+e.w/2)/2),ys:Ht(Kt(m.filter(f=>f>=c&&f<=l)),(t.y+t.h/2+e.y+e.h/2)/2)}}function Ht(t,e){if(t.length<=18)return t;let n=new Set([t[0],t[t.length-1]]);for(let r of[...t].sort((o,s)=>Math.abs(o-e)-Math.abs(s-e)))if(n.add(r),n.size>=18)break;return[...n].sort((r,o)=>r-o)}function en(t,e,n,r){let o=nn(t,e,n);if(!o)return;let s=r.get(o);if(!s)return;let i=12/2,a=s.y+5+8/2,c=s.y+s.h-i;return{x:s.x+i,y:a,w:Math.max(0,s.w-i*2),h:Math.max(0,c-a)}}function nn(t,e,n){let r=new Set(ot(e,n));return ot(t,n).find(o=>r.has(o))}function ot(t,e){let n=[],r=t,o=new Set;for(;e.has(r)&&!o.has(r);)o.add(r),r=e.get(r),n.push(r);return n}function Wt(t,e){let n=e.x+e.w,r=e.y+e.h;return t.every(([o,s])=>o>=e.x-.001&&o<=n+.001&&s>=e.y-.001&&s<=r+.001)}function Kt(t){let e=new Set,n=[];for(let r of t){let o=Math.round(r*1e3)/1e3,s=o.toFixed(3);e.has(s)||(e.add(s),n.push(o))}return n.sort((r,o)=>r-o)}function rn(t){let e=[];for(let r of t){let o=e[e.length-1];(!o||Math.abs(o[0]-r[0])>=.001||Math.abs(o[1]-r[1])>=.001)&&e.push(r)}let n=[];for(let r of e)for(n.push(r);n.length>=3;){let o=n[n.length-3],s=n[n.length-2],i=n[n.length-1],a=Math.abs(o[0]-s[0])<.001&&Math.abs(s[0]-i[0])<.001,c=Math.abs(o[1]-s[1])<.001&&Math.abs(s[1]-i[1])<.001;if(!a&&!c)break;n.splice(n.length-2,1)}return n}function on(t){if(t.length<2)return!1;for(let e=0;e<t.length-1;e++){let n=t[e],r=t[e+1];if(Math.abs(n[0]-r[0])>=.001&&Math.abs(n[1]-r[1])>=.001)return!1}return!0}function sn(t,e,n,r,o,s,i,a){let c=0;for(let l=0;l<t.length-1;l++){let u=t[l],m=t[l+1];c+=pt(u,m);let f=Y(u,m,e,0);f>0&&(c+=22e4+f*1500);let d=Y(u,m,n,0);d>0&&(c+=22e4+d*1500);let y=U(u,m,e);y>0&&(c+=8e3+y*120);let S=U(u,m,n);S>0&&(c+=8e3+S*120);for(let b of a){let x=U(u,m,b);x>0&&(c+=12e3+x*160)}for(let b of r){let x=Y(u,m,b,.8);x>0&&(c+=cn(b,u,m,x))}for(let b of o){let x=Y(u,m,b,.8);x>0&&(c+=18e4+x*1200);let p=U(u,m,b);p>0&&(c+=18e3+p*300)}for(let b of s){let x=Y(u,m,ln(b),.8);x>0&&(c+=14e3+x*120);let p=U(u,m,b);p>0&&(c+=6e3+p*120)}for(let b of i){let x=Y(u,m,b,0);x>0&&(c+=x*40)}}return c+=Math.max(0,t.length-2)*3,c+=an(t,e,n),c}function an(t,e,n){let o=Math.min(e.x,n.x)-60,s=Math.min(e.y,n.y)-60,i=Math.max(e.x+e.w,n.x+n.w)+60,a=Math.max(e.y+e.h,n.y+n.h)+60,c=0;for(let[l,u]of t)l<o&&(c+=(o-l)*90),l>i&&(c+=(l-i)*90),u<s&&(c+=(s-u)*90),u>a&&(c+=(u-a)*90);return c}function cn(t,e,n,r){return t.id.startsWith("__arrow_guard_")?7e4+r*700:Zt(t)?un(t,e,n,r):16e4+r*1200}function un(t,e,n,r){let o=Math.abs(e[0]-n[0])<.001,s=t.orientation==="vertical";return o===s?85e3+r*1200:500+r*160}function Zt(t){return t.id.startsWith("__edge_guard_")&&"orientation"in t&&(t.orientation==="vertical"||t.orientation==="horizontal")}function ln(t){return{x:t.x,y:t.y,w:t.w,h:13}}function pt(t,e){return Math.abs(t[0]-e[0])+Math.abs(t[1]-e[1])}function Y(t,e,n,r){let o=n.x-r,s=n.x+n.w+r,i=n.y-r,a=n.y+n.h+r;if(Math.abs(t[0]-e[0])<.001){let c=t[0];return c<=o||c>=s?0:H(t[1],e[1],i,a)}if(Math.abs(t[1]-e[1])<.001){let c=t[1];return c<=i||c>=a?0:H(t[0],e[0],o,s)}return 0}function U(t,e,n){return te(t,e,n,0)}function te(t,e,n,r){if(Math.abs(t[0]-e[0])<.001){let o=t[0];return Math.abs(o-n.x)>r+.001&&Math.abs(o-(n.x+n.w))>r+.001?0:H(t[1],e[1],n.y,n.y+n.h)}if(Math.abs(t[1]-e[1])<.001){let o=t[1];return Math.abs(o-n.y)>r+.001&&Math.abs(o-(n.y+n.h))>r+.001?0:H(t[0],e[0],n.x,n.x+n.w)}return 0}function H(t,e,n,r){let o=Math.min(t,e),s=Math.max(t,e),i=Math.min(n,r),a=Math.max(n,r);return Math.max(0,Math.min(s,a)-Math.max(o,i))}function dt(t,e){let n={x:t.x+t.w/2,y:t.y+t.h/2},r={x:e.x+e.w/2,y:e.y+e.h/2},o=r.x-n.x,s=r.y-n.y,i,a,c=t.x+t.w<=e.x||e.x+e.w<=t.x,l=t.y+t.h<=e.y||e.y+e.h<=t.y;if(c?!0:l?!1:Math.abs(o)>Math.abs(s)){if(i=[o>0?t.x+t.w:t.x,n.y],a=[o>0?e.x:e.x+e.w,r.y],Math.abs(i[1]-a[1])<.5)return[i,a];let m=(i[0]+a[0])/2;return[i,[m,i[1]],[m,a[1]],a]}else{if(i=[n.x,s>0?t.y+t.h:t.y],a=[r.x,s>0?e.y:e.y+e.h],Math.abs(i[0]-a[0])<.5)return[i,a];let m=(i[1]+a[1])/2;return[i,[i[0],m],[a[0],m],a]}}var se="http://www.w3.org/2000/svg",fn='"Hiragino Sans", "Yu Gothic", "Noto Sans CJK JP", sans-serif';var hn=[0,3.2,6.4],j=.001;function q(t,e={}){let n=e.lang??"ja",r=N("svg",{xmlns:se,viewBox:`0 0 ${t.width} ${t.height}`,"font-family":fn,"shape-rendering":"geometricPrecision"}),o=t.nodes.filter(a=>a.isContainer),s=t.nodes.filter(a=>!a.isContainer),i=[];for(let a of o)r.appendChild(mn(a,n));for(let a of t.edges)r.appendChild(pn(a,n,t,i));for(let a of t.edges)r.appendChild(xn(a));for(let a of s)r.appendChild(dn(a,n));return r}function mn(t,e){let n=N("g");n.appendChild(N("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:"white",stroke:"#000","stroke-width":.3}));let r=St(t.label,e);if(r.length||t.id){let o=N("text",{x:t.x+2,y:t.y+3.5,"font-size":2.6,fill:"#000"});o.textContent=(t.id?t.id+" ":"")+(r[0]??""),n.appendChild(o)}return n}function dn(t,e){let n=N("g");n.appendChild(gn(t));let r=[];t.id&&t.id!=="*"&&r.push(t.id);let o=St(t.label,e);for(let l of o)r.push(l);if(r.length===0)return n;let s=2.8,i=s*1.2,a=r.length*i,c=t.y+t.h/2-a/2+i*.8;for(let l=0;l<r.length;l++){let u=N("text",{x:t.x+t.w/2,y:c+l*i,"font-size":s,fill:"#000","text-anchor":"middle"});u.textContent=r[l],n.appendChild(u)}return n}function gn(t){let e="#000",n="white";switch(t.shape){case"round":return N("rect",{x:t.x,y:t.y,width:t.w,height:t.h,rx:Math.min(t.w,t.h)/2,ry:Math.min(t.w,t.h)/2,fill:n,stroke:e,"stroke-width":.4});case"circle":{let o=Math.min(t.w,t.h)/2;return N("circle",{cx:t.x+t.w/2,cy:t.y+t.h/2,r:o,fill:"#000",stroke:e})}case"diamond":{let o=t.x+t.w/2,s=t.y+t.h/2,i=[[o,t.y],[t.x+t.w,s],[o,t.y+t.h],[t.x,s]].map(a=>a.join(",")).join(" ");return N("polygon",{points:i,fill:n,stroke:e,"stroke-width":.4})}default:return N("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:n,stroke:e,"stroke-width":.4})}}function pn(t,e,n,r){let o=N("g");if(t.points.length<2)return o;let s=Sn(t);if(s.length<2)return o;let i=s.map((u,m)=>m===0?`M ${u[0]} ${u[1]}`:`L ${u[0]} ${u[1]}`).join(" "),a=N("path",{d:i,fill:"none",stroke:"#000","stroke-width":bn(t.op),"stroke-linecap":"butt","stroke-linejoin":"miter"}),c=yn(t.op);c&&a.setAttribute("stroke-dasharray",c),o.appendChild(a);let l=St(t.label,e);if(l.length){let u=l[0],m=l[1],f=ie(t,l,n,r);r.push(yt(f.box,.8));let d=(y,S,b,x,p,L)=>{let k=N("text",{x:S,y:b,"font-size":x,fill:"#000","text-anchor":p,"dominant-baseline":L});k.textContent=y,o.appendChild(k)};d(u,f.ja.x,f.ja.y,2.4,f.anchor,f.ja.baseline),m&&f.en&&d(m,f.en.x,f.en.y,2.1,f.anchor,f.en.baseline)}return o}function xn(t){let e=N("g");if(t.isLifeline)return e;let n=re(t,!1),r=re(t,!0);return n&&e.appendChild(n),r&&e.appendChild(r),e}function bn(t){return t==="thick"?.7:.4}function yn(t){return t==="dashed"||t==="dashed-arrow"?"1.4 1.2":null}function Sn(t){let e=t.points.map(n=>[n[0],n[1]]);return t.op!=="line"&&t.op!=="dashed"&&(e=ee(e,!1,ne(t.op))),t.op==="bidir"&&(e=ee(e,!0,ne(t.op))),e}function ee(t,e,n){if(t.length<2||n<=0)return t;let r=e?[...t].reverse():[...t],o=n;for(;r.length>=2&&o>0;){let s=r[r.length-1],i=r[r.length-2],a=i[0]-s[0],c=i[1]-s[1],l=Math.hypot(a,c);if(l<j){r.pop();continue}l>o?(r[r.length-1]=[s[0]+a/l*o,s[1]+c/l*o],o=0):(r.pop(),o-=l)}return e?r.reverse():r}function ne(t){return t==="thick"?3.4:2.8}function re(t,e){if(t.points.length<2||e&&t.op!=="bidir"||!e&&(t.op==="line"||t.op==="dashed"))return null;let n=e?t.points:[...t.points].reverse();return wn(n[0],n[1],t.op==="thick")}function wn(t,e,n){let r=e[0]-t[0],o=e[1]-t[1],s=Math.hypot(r,o);if(s<.001)return null;let i=r/s,a=o/s,c=n?3.4:2.8,l=n?1.6:1.25,u=t[0]+i*c,m=t[1]+a*c,f=-a,d=i,y=[t,[u+f*l,m+d*l],[u-f*l,m-d*l]].map(S=>S.join(",")).join(" ");return N("polygon",{points:y,fill:"#000",stroke:"#000","stroke-width":0})}function N(t,e={}){let n=document.createElementNS(se,t);for(let[r,o]of Object.entries(e))n.setAttribute(r,String(o));return n}function St(t,e){if(!t)return[];if(e==="ja")return t.ja?[t.ja]:t.en?[t.en]:[];if(e==="en")return t.en?[t.en]:t.ja?[t.ja]:[];let n=[];return t.ja&&n.push(t.ja),t.en&&n.push(t.en),n}function ie(t,e,n,r=[]){let o=[],s=Math.max(...e.map((a,c)=>st(a,c===0?2.4:2.1))),i=e.length>1?2.4+2.1+.6:2.4;for(let a=0;a<t.points.length-1;a++){let c=t.points[a],l=t.points[a+1],u=l[0]-c[0],m=l[1]-c[1];if(!(Math.abs(u)+Math.abs(m)<8))for(let d of[.5,.35,.65,.22,.78]){let y=c[0]+u*d,S=c[1]+m*d;for(let b of hn){let x=4+b,p=b*9;Math.abs(m)<j?(o.push(xt(t,n,r,e,s,i,c,l,y,S,"above",x,p)),o.push(xt(t,n,r,e,s,i,c,l,y,S,"below",x,p))):Math.abs(u)<j&&(o.push(bt(t,n,r,e,s,i,c,l,y,S,"right",x,p)),o.push(bt(t,n,r,e,s,i,c,l,y,S,"left",x,p)))}}}if(o.length===0){let[a,c]=En(t.points),l=(a[0]+c[0])/2,u=(a[1]+c[1])/2;return Math.abs(c[1]-a[1])>=Math.abs(c[0]-a[0])?bt(t,n,r,e,s,i,a,c,l,u,"right",4,0):xt(t,n,r,e,s,i,a,c,l,u,"above",4,0)}return o.sort((a,c)=>a.score-c.score),o[0]}function xt(t,e,n,r,o,s,i,a,c,l,u,m,f){let d=u==="above"?l-m-s:l+m,y={x:c-o/2,y:d,w:o,h:s},S,b;r.length>1?(S=d+2.4,b=S+.6+2.1):S=d+2.4;let x={box:y,lineA:i,lineB:a,score:0,vertical:!1,anchor:"middle",ja:{x:c,y:S,baseline:"alphabetic"},en:b===void 0?void 0:{x:c,y:b,baseline:"alphabetic"}};return x.score=ae(x,t,e,n)+(u==="above"?0:8)+f,x}function bt(t,e,n,r,o,s,i,a,c,l,u,m,f){let d=u==="right"?c+m:c-m,y={x:u==="right"?d:d-o,y:l-s/2,w:o,h:s},S=u==="right"?"start":"end",b=r.length>1?l-2.4/2-.6/2:l,x=r.length>1?l+2.1/2+.6/2:void 0,p={box:y,lineA:i,lineB:a,score:0,vertical:!0,anchor:S,ja:{x:d,y:b,baseline:"middle"},en:x===void 0?void 0:{x:d,y:x,baseline:"middle"}};return p.score=ae(p,t,e,n)+(u==="right"?0:8)+f,p}function ae(t,e,n,r){let o=t.vertical?5:0,s=t.box;s.x<0&&(o+=Math.abs(s.x)*300),s.y<0&&(o+=Math.abs(s.y)*300),s.x+s.w>n.width&&(o+=(s.x+s.w-n.width)*300),s.y+s.h>n.height&&(o+=(s.y+s.h-n.height)*300);for(let f of n.nodes)if(f.isContainer){let d={x:f.x,y:f.y,w:f.w,h:6};o+=$(s,d)*900,o+=An(s,f)*1800,o+=Mn(s,f,1.8)*9e3}else{let d=$(s,f);d>0&&(o+=1e6+d*5e4),o+=$(s,yt(f,1.8))*5200}for(let f of n.edges)for(let d=0;d<f.points.length-1;d++){let y=f.points[d],S=f.points[d+1];On(y,S,yt(s,.8))&&(o+=f===e?35:380)}for(let f of r)o+=$(s,f)*18e3;let i=Math.abs(t.lineA[0]-t.lineB[0])+Math.abs(t.lineA[1]-t.lineB[1]),a=t.vertical?s.h:s.w;o+=Math.max(0,Math.max(36,a*2.4)-i)*80;let c=t.vertical?s.y+s.h/2:s.x+s.w/2,l=t.vertical?t.lineA[1]:t.lineA[0],u=t.vertical?t.lineB[1]:t.lineB[0],m=Math.min(Math.abs(c-l),Math.abs(c-u));return o+=Math.max(0,12-m)*80,o}function st(t,e){let n=0;for(let r of t)r===" "?n+=e*.35:r.charCodeAt(0)<=127?n+=e*.58:n+=e;return Math.max(e*2,n)}function En(t){let e=0,n=-1;for(let s=0;s<t.length-1;s++){let i=t[s+1][0]-t[s][0],a=t[s+1][1]-t[s][1],c=i*i+a*a;c>n&&(n=c,e=s)}let r=t[e],o=t[e+1];return[r,o]}function yt(t,e){return{x:t.x-e,y:t.y-e,w:t.w+e*2,h:t.h+e*2}}function $(t,e){let n=Math.max(0,Math.min(t.x+t.w,e.x+e.w)-Math.max(t.x,e.x)),r=Math.max(0,Math.min(t.y+t.h,e.y+e.h)-Math.max(t.y,e.y));return n*r}function An(t,e){let n=Math.abs(t.x-e.x)<1||Math.abs(t.x+t.w-e.x)<1,r=Math.abs(t.x-(e.x+e.w))<1||Math.abs(t.x+t.w-(e.x+e.w))<1,o=Math.abs(t.y-e.y)<1||Math.abs(t.y+t.h-e.y)<1,s=Math.abs(t.y-(e.y+e.h))<1||Math.abs(t.y+t.h-(e.y+e.h))<1;return Number(n||r||o||s)}function Mn(t,e,n){return $(t,{x:e.x-n,y:e.y-n,w:n*2,h:e.h+n*2})+$(t,{x:e.x+e.w-n,y:e.y-n,w:n*2,h:e.h+n*2})+$(t,{x:e.x-n,y:e.y-n,w:e.w+n*2,h:n*2})+$(t,{x:e.x-n,y:e.y+e.h-n,w:e.w+n*2,h:n*2})}function On(t,e,n){let r=n.x,o=n.x+n.w,s=n.y,i=n.y+n.h;if(Math.abs(t[0]-e[0])<j){let a=t[0];return a<=r||a>=o?!1:oe(t[1],e[1],s,i)>j}if(Math.abs(t[1]-e[1])<j){let a=t[1];return a<=s||a>=i?!1:oe(t[0],e[0],r,o)>j}return!1}function oe(t,e,n,r){let o=Math.min(t,e),s=Math.max(t,e),i=Math.min(n,r),a=Math.max(n,r);return Math.max(0,Math.min(s,a)-Math.max(o,i))}var Pn="http://www.w3.org/2000/svg",it=class{constructor(e,n){this.namespaceURI=e;this.tagName=n}namespaceURI;tagName;nodeType="element";attrs=new Map;children=[];text=null;setAttribute(e,n){this.attrs.set(e,String(n))}getAttribute(e){return this.attrs.has(e)?this.attrs.get(e):null}removeAttribute(e){this.attrs.delete(e)}appendChild(e){return this.text=null,this.children.push(e),e}set textContent(e){this.text=e==null?"":String(e),this.children=[]}get textContent(){return this.text!=null?this.text:this.children.map(e=>e.textContent).join("")}},Bn={createElementNS(t,e){return new it(t,e)},createElement(t){return new it(Pn,t)}};function ce(t){let e=globalThis,n=e.document;e.document=Bn;try{return t()}finally{e.document=n}}function Ln(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Rn(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function J(t){let e=[...t.attrs].map(([r,o])=>` ${r}="${Ln(o)}"`).join("");if(t.text!=null)return`<${t.tagName}${e}>${Rn(t.text)}</${t.tagName}>`;if(t.children.length===0)return`<${t.tagName}${e}/>`;let n=t.children.map(J).join("");return`<${t.tagName}${e}>${n}</${t.tagName}>`}var _n=3;function T(t,e,n=0){let r=t.getAttribute(e);if(r==null)return n;let o=Number.parseFloat(r);return Number.isFinite(o)?o:n}function wt(t){let e=[],n=/-?\d*\.?\d+(?:e[-+]?\d+)?/gi,r;for(;(r=n.exec(t))!==null;)e.push(Number.parseFloat(r[0]));return e}function Nn(t){switch(t.tagName){case"rect":{let e=T(t,"x"),n=T(t,"y"),r=T(t,"width"),o=T(t,"height");return r<=0&&o<=0?null:{minX:e,minY:n,maxX:e+r,maxY:n+o}}case"circle":{let e=T(t,"cx"),n=T(t,"cy"),r=T(t,"r");return r<=0?null:{minX:e-r,minY:n-r,maxX:e+r,maxY:n+r}}case"line":{let e=T(t,"x1"),n=T(t,"y1"),r=T(t,"x2"),o=T(t,"y2");return{minX:Math.min(e,r),minY:Math.min(n,o),maxX:Math.max(e,r),maxY:Math.max(n,o)}}case"polygon":case"polyline":{let e=wt(t.getAttribute("points")??"");return ue(e)}case"path":{let e=wt(t.getAttribute("d")??"");return ue(e)}case"text":return vn(t);default:return null}}function ue(t){if(t.length<2)return null;let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let s=0;s+1<t.length;s+=2){let i=t[s],a=t[s+1];i<e&&(e=i),a<n&&(n=a),i>r&&(r=i),a>o&&(o=a)}return Number.isFinite(e)?{minX:e,minY:n,maxX:r,maxY:o}:null}function vn(t){let e=t.textContent;if(!e)return null;let n=T(t,"x"),r=T(t,"y"),o=T(t,"font-size",2.8),s=st(e,o),i=t.getAttribute("text-anchor")??"start",a;i==="middle"?a=n-s/2:i==="end"?a=n-s:a=n;let c=a+s,l=t.getAttribute("dominant-baseline")??"alphabetic",u,m;return l==="middle"||l==="central"?(u=r-o*.6,m=r+o*.6):(u=r-o*.8,m=r+o*.25),{minX:a,minY:u,maxX:c,maxY:m}}function le(t,e){let n=Nn(t);n&&e.push(n);for(let r of t.children)le(r,e)}function Tn(t){if(t.length===0)return null;let e=1/0,n=1/0,r=-1/0,o=-1/0;for(let s of t)s.minX<e&&(e=s.minX),s.minY<n&&(n=s.minY),s.maxX>r&&(r=s.maxX),s.maxY>o&&(o=s.maxY);return{minX:e,minY:n,maxX:r,maxY:o}}function kn(t){let e=wt(t.getAttribute("viewBox")??"");return e.length===4&&e[2]>0&&e[3]>0?{minX:e[0],minY:e[1],width:e[2],height:e[3]}:{minX:0,minY:0,width:210,height:297}}function at(t,e=_n){let n=[];le(t,n);let r=Tn(n);if(!r)return kn(t);let o=Math.max(0,e);return{minX:r.minX-o,minY:r.minY-o,width:Math.max(1,r.maxX-r.minX+o*2),height:Math.max(1,r.maxY-r.minY+o*2)}}function ct(t,e=1600){let n=Math.max(t.width,t.height,1),r=Math.max(1,e/n);return{width:Math.max(1,Math.ceil(t.width*r)),height:Math.max(1,Math.ceil(t.height*r)),scale:r}}var Dn="http://www.w3.org/2000/svg",Cn=3,In=1600;function Et(t,e={}){let{lang:n="ja",crop:r=!0,bleed:o=Cn,targetSide:s=In}=e,i=F(t),a=z(i),c=ce(()=>q(a,{lang:n})),l=r?at(c,o):{minX:0,minY:0,width:a.width,height:a.height},u=ct(l,s);return c.setAttribute("xmlns",Dn),c.setAttribute("version","1.1"),c.setAttribute("viewBox",`${l.minX} ${l.minY} ${l.width} ${l.height}`),c.setAttribute("width",String(u.width)),c.setAttribute("height",String(u.height)),c.setAttribute("preserveAspectRatio","xMidYMid meet"),{el:c,kind:i.kind,viewBox:l,width:u.width,height:u.height}}function ut(t,e={}){let n=Et(t,e),r=J(n.el);return{svg:e.xmlDeclaration??!0?`<?xml version="1.0" encoding="UTF-8"?>
2
+ ${r}`:r,kind:n.kind,viewBox:n.viewBox,width:n.width,height:n.height}}function Mt(t){let e=fe(t),n=[];n.push("## \u7B26\u53F7\u306E\u8AAC\u660E / Reference Signs"),n.push(""),n.push("| \u7B26\u53F7 | \u540D\u79F0(\u65E5\u672C\u8A9E) | Name (English) |"),n.push("|------|---------------|----------------|");for(let r of e){let o=t.nodes.get(r);n.push(`| ${r} | ${o.label.ja??""} | ${o.label.en??""} |`)}return n.join(`
3
+ `)}function Ot(t){let e=fe(t),n=["id,ja,en"];for(let r of e){let o=t.nodes.get(r);n.push(`${At(r)},${At(o.label.ja??"")},${At(o.label.en??"")}`)}return n.join(`
4
+ `)}function At(t){return/[",\n]/.test(t)?'"'+t.replace(/"/g,'""')+'"':t}function fe(t){return[...t.nodes.keys()].filter(n=>n!=="*").sort((n,r)=>{let o=parseInt(n,10),s=parseInt(r,10);return!isNaN(o)&&!isNaN(s)?o-s:n.localeCompare(r)})}var Pt=["block","system","iot","imagePipeline","controlLoop","flow","state","seq","handshake"],Bt={block:{label:"\u30D6\u30ED\u30C3\u30AF\u56F3",hint:"\u300C:\u300D\u3092\u4F7F\u3046\u3068\u30D6\u30ED\u30C3\u30AF\u56F3\u306B\u306A\u308B",source:`# \u30D6\u30ED\u30C3\u30AF\u56F3(\u88C5\u7F6E\u30AF\u30EC\u30FC\u30E0\u7528)
5
+ # \u30D2\u30F3\u30C8:\u300C:\u300D\u3067\u5305\u542B\u95A2\u4FC2\u3092\u66F8\u304F \u2192 \u30D6\u30ED\u30C3\u30AF\u56F3\u3068\u5224\u5B9A\u3055\u308C\u308B
6
+
7
+ 10 = \u5236\u5FA1\u88C5\u7F6E / control device
8
+ 11 = CPU
9
+ 12 = \u30E1\u30E2\u30EA / memory
10
+ 13 = "I/O \u30A4\u30F3\u30BF\u30FC\u30D5\u30A7\u30FC\u30B9" / "I/O interface"
11
+ 20 = \u5916\u90E8\u6A5F\u5668 / external device
12
+
13
+ 10 : 11 12 13
14
+
15
+ 11 - 12
16
+ 11 - 13
17
+ 13 -> 20 : \u4FE1\u53F7 / signal
18
+ `},system:{label:"\u30B7\u30B9\u30C6\u30E0\u5168\u4F53",hint:"\u968E\u5C64\u69CB\u6210 + \u5916\u90E8\u63A5\u7D9A",source:`# \u30B7\u30B9\u30C6\u30E0\u5168\u4F53(\u968E\u5C64+\u5916\u90E8\u63A5\u7D9A)
19
+ # \u30D2\u30F3\u30C8: \u5185\u90E8\u30D6\u30ED\u30C3\u30AF\u3068\u5916\u90E8\u88C5\u7F6E\u3092\u5206\u3051\u3066\u66F8\u304F\u3068\u3001\u7279\u8A31\u56F3\u9762\u3089\u3057\u3044\u69CB\u6210\u306B\u306A\u308B
20
+
21
+ 100 = \u30B7\u30B9\u30C6\u30E0\u672C\u4F53 / Main system
22
+ 10 = \u5236\u5FA1\u90E8 / Control
23
+ 20 = \u901A\u4FE1\u90E8 / Comm
24
+ 11 = CPU
25
+ 12 = \u30E1\u30E2\u30EA / memory
26
+ 21 = \u7121\u7DDA\u90E8 / wireless
27
+ 22 = \u6709\u7DDA\u90E8 / wired
28
+ 30 = \u5916\u90E8\u30B5\u30FC\u30D0 / external server
29
+ 40 = \u5916\u90E8\u7AEF\u672B / external terminal
30
+
31
+ 100 : 10 20
32
+ 10 : 11 12
33
+ 20 : 21 22
34
+
35
+ 21 .> 40 : \u7121\u7DDA / wireless
36
+ 22 -> 30 : \u6709\u7DDA / wired
37
+ 30 <-> 40 : \u901A\u4FE1 / comm
38
+ `},iot:{label:"IoT/\u30AF\u30E9\u30A6\u30C9",hint:"\u30BB\u30F3\u30B5\u7AEF\u672B\u30FB\u30B2\u30FC\u30C8\u30A6\u30A7\u30A4\u30FB\u30AF\u30E9\u30A6\u30C9\u306E\u5178\u578B\u69CB\u6210",source:`# IoT/\u30AF\u30E9\u30A6\u30C9\u69CB\u6210
39
+ # \u30D2\u30F3\u30C8: \u7AEF\u672B\u5185\u90E8\u306E\u69CB\u6210\u3068\u30AF\u30E9\u30A6\u30C9\u5074\u306E\u69CB\u6210\u3092\u5225\u30B3\u30F3\u30C6\u30CA\u306B\u3059\u308B
40
+
41
+ 100 = \u30BB\u30F3\u30B5\u7AEF\u672B / sensor terminal
42
+ 10 = \u691C\u51FA\u90E8 / detector
43
+ 11 = \u6E29\u5EA6\u30BB\u30F3\u30B5 / temperature sensor
44
+ 12 = \u52A0\u901F\u5EA6\u30BB\u30F3\u30B5 / acceleration sensor
45
+ 20 = \u51E6\u7406\u90E8 / processor
46
+ 21 = \u53D6\u5F97\u90E8 / acquisition unit
47
+ 22 = \u5224\u5B9A\u90E8 / determination unit
48
+ 30 = \u901A\u4FE1\u90E8 / communication unit
49
+ 200 = \u30B2\u30FC\u30C8\u30A6\u30A7\u30A4 / gateway
50
+ 300 = \u30AF\u30E9\u30A6\u30C9\u30B5\u30FC\u30D0 / cloud server
51
+ 310 = \u53D7\u4FE1\u90E8 / receiver
52
+ 320 = \u89E3\u6790\u90E8 / analyzer
53
+ 330 = \u8A18\u61B6\u90E8 / storage
54
+
55
+ 100 : 10 20 30
56
+ 10 : 11 12
57
+ 20 : 21 22
58
+ 300 : 310 320 330
59
+
60
+ 10 -> 20 : \u30BB\u30F3\u30B5\u5024 / sensor value
61
+ 20 -> 30 : \u9001\u4FE1\u30C7\u30FC\u30BF / transmission data
62
+ 30 .> 200 : \u7121\u7DDA / wireless
63
+ 200 -> 310 : \u4E2D\u7D99 / relay
64
+ 310 -> 320 : \u30C7\u30FC\u30BF / data
65
+ 320 -> 330 : \u7D50\u679C / result
66
+ `},imagePipeline:{label:"\u753B\u50CF\u51E6\u7406",hint:"\u753B\u50CF\u5165\u529B\u304B\u3089\u5224\u5B9A\u7D50\u679C\u307E\u3067\u306E\u51E6\u7406\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3",source:`# \u753B\u50CF\u51E6\u7406\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3(\u65B9\u6CD5\u30AF\u30EC\u30FC\u30E0\u7528)
67
+ # \u30D2\u30F3\u30C8: \u7247\u65B9\u5411\u306E\u63A5\u7D9A\u306E\u307F\u306A\u3089\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8\u3068\u3057\u3066\u63CF\u753B\u3055\u308C\u308B
68
+
69
+ S100 = \u753B\u50CF\u3092\u53D6\u5F97 / Acquire image
70
+ S110 = \u524D\u51E6\u7406 / Preprocess
71
+ S120 = \u7279\u5FB4\u91CF\u3092\u62BD\u51FA / Extract features
72
+ S130 = \u6B20\u9665\u3042\u308A? / Defect?
73
+ S140 = \u30A2\u30E9\u30FC\u30C8\u3092\u51FA\u529B / Output alert
74
+ S150 = \u6B63\u5E38\u7D50\u679C\u3092\u8A18\u9332 / Record normal result
75
+ S160 = \u7D42\u4E86 / End
76
+
77
+ S100 -> S110
78
+ S110 -> S120
79
+ S120 -> S130
80
+ S130 -> S140 : Yes
81
+ S130 -> S150 : No
82
+ S140 -> S160
83
+ S150 -> S160
84
+ `},controlLoop:{label:"\u5236\u5FA1\u30EB\u30FC\u30D7",hint:"\u30BB\u30F3\u30B5\u30FB\u5236\u5FA1\u5668\u30FB\u30A2\u30AF\u30C1\u30E5\u30A8\u30FC\u30BF\u306E\u30D5\u30A3\u30FC\u30C9\u30D0\u30C3\u30AF\u69CB\u6210",source:`# \u5236\u5FA1\u30EB\u30FC\u30D7(\u88C5\u7F6E\u30AF\u30EC\u30FC\u30E0\u7528)
85
+ # \u30D2\u30F3\u30C8: \u30EB\u30FC\u30D7\u3059\u308B\u69CB\u6210\u306F\u30011\u3064\u306E\u30B7\u30B9\u30C6\u30E0\u5185\u3067\u6642\u8A08\u56DE\u308A\u306B\u4E26\u3079\u308B\u3068\u8AAD\u307F\u3084\u3059\u3044
86
+
87
+ 100 = \u5236\u5FA1\u30B7\u30B9\u30C6\u30E0 / control system
88
+ 10 = \u5236\u5FA1\u90E8 / controller
89
+ 11 = \u76EE\u6A19\u5024\u53D6\u5F97\u90E8 / target acquisition unit
90
+ 12 = \u504F\u5DEE\u7B97\u51FA\u90E8 / error calculator
91
+ 13 = \u6307\u4EE4\u751F\u6210\u90E8 / command generator
92
+ 20 = \u99C6\u52D5\u90E8 / driver
93
+ 30 = \u30BB\u30F3\u30B5\u90E8 / sensor unit
94
+ 40 = \u5BFE\u8C61\u88C5\u7F6E / controlled object
95
+
96
+ 100 : 30 10 40 20
97
+ 10 : 11 12 13
98
+
99
+ 30 -> 12 : \u6E2C\u5B9A\u5024 / measured value
100
+ 11 -> 12 : \u76EE\u6A19\u5024 / target value
101
+ 12 -> 13 : \u504F\u5DEE / error
102
+ 13 -> 20 : \u6307\u4EE4 / command
103
+ 20 -> 40 : \u99C6\u52D5\u4FE1\u53F7 / drive signal
104
+ 40 .> 30 : \u30D5\u30A3\u30FC\u30C9\u30D0\u30C3\u30AF / feedback
105
+ `},flow:{label:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8",hint:"\u30E9\u30D9\u30EB\u306B\u300C?\u300D\u304C\u3042\u308B \u2192 \u30D5\u30ED\u30FC\u3068\u5224\u5B9A",source:`# \u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8(\u65B9\u6CD5\u30AF\u30EC\u30FC\u30E0\u7528)
106
+ # \u30D2\u30F3\u30C8:\u30E9\u30D9\u30EB\u672B\u5C3E\u306B\u300C?\u300D \u2192 \u83F1\u5F62(\u6761\u4EF6\u5206\u5C90)\u306B\u81EA\u52D5\u63A8\u8AD6
107
+
108
+ S100 = \u958B\u59CB / Start
109
+ S110 = \u6761\u4EF6A? / "Condition A?"
110
+ S120 = \u51E6\u7406X / Process X
111
+ S130 = \u51E6\u7406Y / Process Y
112
+ S140 = \u7D42\u4E86 / End
113
+
114
+ S100 -> S110
115
+ S110 -> S120 : Yes
116
+ S110 -> S130 : No
117
+ S120 -> S140
118
+ S130 -> S140
119
+ `},state:{label:"\u72B6\u614B\u9077\u79FB\u56F3",hint:"\u300C*\u300D\u3092\u4F7F\u3046 \u2192 \u72B6\u614B\u9077\u79FB\u3068\u5224\u5B9A",source:`# \u72B6\u614B\u9077\u79FB\u56F3
120
+ # \u30D2\u30F3\u30C8:\u300C*\u300D\u304C\u521D\u671F/\u7D42\u7AEF\u306E\u7B26\u53F7(\u9ED2\u4E38\u3067\u63CF\u753B)
121
+
122
+ S1 = \u5F85\u6A5F / Idle
123
+ S2 = \u52D5\u4F5C\u4E2D / Running
124
+ S3 = \u30A8\u30E9\u30FC / Error
125
+
126
+ * -> S1
127
+ S1 -> S2 : \u8D77\u52D5 / start
128
+ S2 -> S1 : \u505C\u6B62 / stop
129
+ S2 -> S3 : \u7570\u5E38 / fault
130
+ S3 -> S1 : \u30EA\u30BB\u30C3\u30C8 / reset
131
+ S3 -> *
132
+ `},seq:{label:"\u30B7\u30FC\u30B1\u30F3\u30B9\u56F3",hint:"\u300C:\u300D\u3082\u300C?\u300D\u3082\u300C*\u300D\u3082\u306A\u3044 \u2192 \u30B7\u30FC\u30B1\u30F3\u30B9",source:`# \u30B7\u30FC\u30B1\u30F3\u30B9\u56F3(\u30D7\u30ED\u30C8\u30B3\u30EB\u7CFB)
133
+ # \u30D2\u30F3\u30C8:\u5305\u542B\u3082?\u3082*\u3082\u7121\u3044 \u2192 \u30B7\u30FC\u30B1\u30F3\u30B9\u56F3\u3068\u3057\u3066\u63CF\u753B
134
+ # \u30A2\u30AF\u30BF\u306F\u767B\u5834\u9806\u306B\u5DE6\u304B\u3089\u4E26\u3076
135
+
136
+ 100 = \u30AF\u30E9\u30A4\u30A2\u30F3\u30C8 / client
137
+ 200 = \u30B5\u30FC\u30D0 / server
138
+
139
+ 100 -> 200 : \u8A8D\u8A3C\u8981\u6C42 / auth request
140
+ 200 -> 100 : \u30C8\u30FC\u30AF\u30F3 / token
141
+ 100 -> 200 : \u30EA\u30BD\u30FC\u30B9\u8981\u6C42 / resource request
142
+ 200 -> 100 : \u30EA\u30BD\u30FC\u30B9\u5FDC\u7B54 / resource response
143
+ `},handshake:{label:"\u30CF\u30F3\u30C9\u30B7\u30A7\u30A4\u30AF",hint:"\u8981\u6C42/\u5FDC\u7B54/\u78BA\u7ACB/\u7D42\u4E86\u306E\u901A\u4FE1\u30B7\u30FC\u30B1\u30F3\u30B9",source:`# \u901A\u4FE1\u30CF\u30F3\u30C9\u30B7\u30A7\u30A4\u30AF(\u30B7\u30FC\u30B1\u30F3\u30B9\u56F3)
144
+ # \u30D2\u30F3\u30C8: \u5F80\u5FA9\u30E1\u30C3\u30BB\u30FC\u30B8\u304C\u3042\u308B\u3068\u30B7\u30FC\u30B1\u30F3\u30B9\u56F3\u306B\u306A\u308B
145
+
146
+ 100 = \u7AEF\u672B / terminal
147
+ 200 = \u30B5\u30FC\u30D0 / server
148
+
149
+ 100 -> 200 : \u63A5\u7D9A\u8981\u6C42 / connect request
150
+ 200 -> 100 : \u5FDC\u7B54 / response
151
+ 100 -> 200 : \u8A8D\u8A3C\u60C5\u5831 / credentials
152
+ 200 -> 100 : \u8A8D\u8A3C\u7D50\u679C / auth result
153
+ 100 <-> 200 : \u30C7\u30FC\u30BF\u901A\u4FE1 / data exchange
154
+ 100 -> 200 : \u5207\u65AD\u8981\u6C42 / disconnect
155
+ 200 -> 100 : \u5207\u65AD\u5B8C\u4E86 / disconnected
156
+ `}};var Lt={cond:`S100 = \u958B\u59CB / Start
157
+ S110 = \u5224\u5B9A? / Decision?
158
+ S120 = Yes\u51E6\u7406 / Yes Process
159
+ S130 = No\u51E6\u7406 / No Process
160
+ S140 = \u7D42\u4E86 / End
161
+ S100 -> S110
162
+ S110 -> S120 : Yes
163
+ S110 -> S130 : No
164
+ S120 -> S140
165
+ S130 -> S140`,container:`10 = \u89AA\u88C5\u7F6E / Parent
166
+ 11 = \u90E8\u54C11 / Part 1
167
+ 12 = \u90E8\u54C12 / Part 2
168
+ 13 = \u90E8\u54C13 / Part 3
169
+ 10 : 11 12 13`,external:`10 = \u5236\u5FA1\u88C5\u7F6E / control device
170
+ 11 = \u5165\u529B\u90E8 / input
171
+ 12 = \u51E6\u7406\u90E8 / processor
172
+ 20 = \u5916\u90E8\u6A5F\u5668 / external device
173
+ 10 : 11 12
174
+ 12 -> 20 : \u4FE1\u53F7 / signal`,seq:`100 = \u30AF\u30E9\u30A4\u30A2\u30F3\u30C8 / client
175
+ 200 = \u30B5\u30FC\u30D0 / server
176
+ 100 -> 200 : \u8981\u6C42 / request
177
+ 200 -> 100 : \u5FDC\u7B54 / response
178
+ 100 -> 200 : \u5207\u65AD / disconnect`,state:`S1 = \u5F85\u6A5F / Idle
179
+ S2 = \u52D5\u4F5C\u4E2D / Running
180
+ * -> S1
181
+ S1 -> S2 : \u8D77\u52D5 / start
182
+ S2 -> S1 : \u505C\u6B62 / stop`,bidir:`100 = \u7AEF\u672BA / Terminal A
183
+ 200 = \u7AEF\u672BB / Terminal B
184
+ 100 <-> 200 : \u901A\u4FE1 / comm`,hierarchy:`100 = \u30B7\u30B9\u30C6\u30E0 / System
185
+ 10 = \u30B5\u30D6\u30B7\u30B9\u30C6\u30E0A / Subsystem A
186
+ 20 = \u30B5\u30D6\u30B7\u30B9\u30C6\u30E0B / Subsystem B
187
+ 11 = \u90E8\u54C1A1 / Part A1
188
+ 12 = \u90E8\u54C1A2 / Part A2
189
+ 21 = \u90E8\u54C1B1 / Part B1
190
+ 22 = \u90E8\u54C1B2 / Part B2
191
+ 100 : 10 20
192
+ 10 : 11 12
193
+ 20 : 21 22`,pipeline:`S100 = \u5165\u529B / Input
194
+ S110 = \u524D\u51E6\u7406 / Preprocess
195
+ S120 = \u4E3B\u51E6\u7406 / Main Process
196
+ S130 = \u5F8C\u51E6\u7406 / Postprocess
197
+ S140 = \u51FA\u529B / Output
198
+ S100 -> S110
199
+ S110 -> S120
200
+ S120 -> S130
201
+ S130 -> S140`,parallel:`S100 = \u958B\u59CB / Start
202
+ S110 = \u5206\u5C90 / Branch
203
+ S120 = \u7D4C\u8DEFA / Path A
204
+ S130 = \u7D4C\u8DEFB / Path B
205
+ S140 = \u7D4C\u8DEFC / Path C
206
+ S150 = \u5408\u6D41 / Join
207
+ S160 = \u7D42\u4E86 / End
208
+ S100 -> S110
209
+ S110 -> S120
210
+ S110 -> S130
211
+ S110 -> S140
212
+ S120 -> S150
213
+ S130 -> S150
214
+ S140 -> S150
215
+ S150 -> S160`,handshake:`100 = \u7AEF\u672B / Terminal
216
+ 200 = \u30B5\u30FC\u30D0 / Server
217
+ 100 -> 200 : SYN\u8981\u6C42 / SYN
218
+ 200 -> 100 : SYN+ACK / SYN+ACK
219
+ 100 -> 200 : ACK\u5FDC\u7B54 / ACK
220
+ 100 <-> 200 : \u30C7\u30FC\u30BF\u4EA4\u63DB / data exchange
221
+ 100 -> 200 : FIN / FIN
222
+ 200 -> 100 : ACK / ACK`,state_with_cond:`S100 = \u5F85\u6A5F\u72B6\u614B / Idle state
223
+ S110 = \u691C\u8A3C\u51E6\u7406 / Verify
224
+ S120 = OK? / OK?
225
+ S130 = \u5B8C\u4E86\u72B6\u614B / Done state
226
+ S140 = \u5931\u6557\u72B6\u614B / Failed state
227
+ S150 = \u518D\u8A66\u884C / Retry
228
+ S100 -> S110 : \u8981\u6C42 / request
229
+ S110 -> S120 : \u5224\u5B9A / check
230
+ S120 -> S130 : OK
231
+ S120 -> S140 : NG
232
+ S140 -> S150
233
+ S150 -> S100`,system:`100 = \u30B7\u30B9\u30C6\u30E0\u672C\u4F53 / Main system
234
+ 10 = \u5236\u5FA1\u90E8 / Control
235
+ 20 = \u901A\u4FE1\u90E8 / Comm
236
+ 11 = CPU
237
+ 12 = \u30E1\u30E2\u30EA / memory
238
+ 21 = \u7121\u7DDA\u90E8 / wireless
239
+ 22 = \u6709\u7DDA\u90E8 / wired
240
+ 30 = \u5916\u90E8\u30B5\u30FC\u30D0 / external server
241
+ 40 = \u5916\u90E8\u7AEF\u672B / external terminal
242
+ 100 : 10 20
243
+ 10 : 11 12
244
+ 20 : 21 22
245
+ 21 .> 40 : \u7121\u7DDA / wireless
246
+ 22 -> 30 : \u6709\u7DDA / wired
247
+ 30 <-> 40 : \u901A\u4FE1 / comm`};var he={block:"\u30D6\u30ED\u30C3\u30AF\u56F3",flow:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8",state:"\u72B6\u614B\u9077\u79FB\u56F3",seq:"\u30B7\u30FC\u30B1\u30F3\u30B9\u56F3"};function Gn(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];if(r==='"')e=!e;else if(!e&&r==="#")return t.slice(n+1)}return null}function $n(t){let e=!1;for(let n=0;n<t.length;n++){let r=t[n];if(r==='"')e=!e;else if(!e&&r==="#")return t.slice(0,n)}return t}var Fn=/^\s*!?\s*(?:pdgkit\s*:)?\s*kind\s*[:=]?\s*(block|flow|state|seq)\b/i;function Yn(t){for(let e=0;e<t.length;e++){let n=Gn(t[e]);if(n==null)continue;let r=n.match(Fn);if(r)return{kind:r[1].toLowerCase(),line:e+1}}return null}var Xn=/(?:^|\s)(?:<->|=>|->|<-|\.>|\.\.|-)(?:\s|$)/g,jn=/[A-Za-z0-9_*](?:<->|<-|->|=>|\.>|\.\.|-)[A-Za-z0-9_*]/;function Vn(t){let e=t.match(Xn);return e?e.length:0}function me(t){let e=F(t),n=[...e.diagnostics],r=t.split(/\r?\n/),o=Yn(r),s=o?o.kind:null,i=null;o&&(i=o.kind===e.kind,i||n.push({severity:"error",line:o.line,col:1,message:`\u56F3\u7A2E\u30A2\u30B5\u30FC\u30B7\u30E7\u30F3\u4E0D\u4E00\u81F4: \u5BA3\u8A00=${he[o.kind]}(${o.kind}) \u3060\u304C\u63A8\u8AD6=${he[e.kind]}(${e.kind})\u3002\u69CB\u9020(\u5305\u542B\u300C:\u300D/ \u672B\u5C3E\u300C?\u300D/ \u7B26\u53F7\u300C*\u300D/ \u5F80\u5FA9\u30FB\u300C<->\u300D)\u3092\u898B\u76F4\u3059\u304B\u3001\u5BA3\u8A00\u3092\u4FEE\u6B63\u3057\u3066\u304F\u3060\u3055\u3044\u3002`}));let a=new Set(e.diagnostics.filter(l=>l.severity==="error"&&l.message.startsWith("\u69CB\u6587\u4E0D\u660E")).map(l=>l.line));for(let l of a){let u=$n(r[l-1]??"").trim();u&&(Vn(u)>=2?n.push({severity:"info",line:l,col:1,message:"\u9023\u9396\u8A18\u6CD5(A -> B -> C)\u306F\u672A\u5BFE\u5FDC\u3067\u3059\u30021\u884C\u306B1\u63A5\u7D9A\u3067\u5206\u5272\u3057\u3066\u304F\u3060\u3055\u3044(\u4F8B: A -> B / B -> C)\u3002"}):jn.test(u)&&n.push({severity:"info",line:l,col:1,message:'\u63A5\u7D9A\u6F14\u7B97\u5B50\u306E\u524D\u5F8C\u306B\u306F\u534A\u89D2\u30B9\u30DA\u30FC\u30B9\u304C\u5FC5\u8981\u3067\u3059(\u4F8B: "11-12" \u3067\u306F\u306A\u304F "11 - 12")\u3002'}))}n.sort((l,u)=>l.line-u.line||l.col-u.col);let c={errors:n.filter(l=>l.severity==="error").length,warnings:n.filter(l=>l.severity==="warning").length,infos:n.filter(l=>l.severity==="info").length};return{ok:c.errors===0,kind:e.kind,declaredKind:s,kindMatches:i,diagnostics:n,counts:c}}var Hn="0.1.0";function Wn(t,e="ja"){return ut(t,{lang:e}).svg}return Ee(Kn);})();