@hyperpuncher/pi-ui 0.62.4 → 0.62.5
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.
- package/dist/npm/server-main.js +9 -9
- package/package.json +1 -1
- package/static/app.css +1 -1
package/dist/npm/server-main.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var eLn=Object.create;var{getPrototypeOf:tLn,defineProperty:BN,getOwnPropertyNames:WZe,getOwnPropertyDescriptor:nLn}=Object,dwe=Object.prototype.hasOwnProperty;function zZe(e){return this[e]}var rLn,aLn,gn=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var a=t?rLn??=new WeakMap:aLn??=new WeakMap,i=a.get(e);if(i)return i}n=e!=null?eLn(tLn(e)):{};let o=t||!e||!e.__esModule||!dwe.call(e,"default")?BN(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let s of WZe(e))if(!dwe.call(o,s))BN(o,s,{get:zZe.bind(e,s),enumerable:!0})}if(r)a.set(e,o);return o},JZe=(e)=>{var t=(HZe??=new WeakMap).get(e),n;if(t)return t;if(t=BN({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of WZe(e))if(!dwe.call(t,r))BN(t,r,{get:zZe.bind(e,r),enumerable:!(n=nLn(e,r))||n.enumerable})}return HZe.set(e,t),t},HZe,yt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var iLn=(e)=>e;function oLn(e,t){this[e]=iLn.bind(null,t)}var Ke=(e,t)=>{for(var n in t)BN(e,n,{get:t[n],enumerable:!0,configurable:!0,set:oLn.bind(t,n)})};var v=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var mn=import.meta.require;async function c0(e,t={}){let n=Bun.spawn([e,...t.args??[]],{cwd:t.cwd,env:{...process.env,...t.env},stdin:t.stdin??"ignore",stdout:"pipe",stderr:"pipe",windowsHide:!0,signal:t.signal,timeout:t.timeout}),[r,a,i]=await Promise.all([new Response(n.stdout).bytes(),new Response(n.stderr).bytes(),n.exited]);return{code:i,stdout:r,stderr:a,success:i===0,timedOut:t.timeout!==void 0&&n.signalCode==="SIGTERM"&&!t.signal?.aborted}}function IK(e,t){return Error.isError(e)&&"code"in e&&e.code===t}function QK(e){return IK(e,"EEXIST")}function fc(e){return IK(e,"ENOENT")}function pwe(e){return IK(e,"EACCES")||IK(e,"EPERM")}var SK,vd;var fI=v(()=>{SK=globalThis.navigator?.platform??globalThis.process?.platform,vd=SK==="win32"||SK?.startsWith("Win")?"windows":SK==="darwin"||SK?.startsWith("Mac")?"darwin":"linux"});var uVe;var lVe=v(()=>{uVe={name:"@hyperpuncher/pi-ui",version:"0.62.
|
|
3
|
+
var eLn=Object.create;var{getPrototypeOf:tLn,defineProperty:BN,getOwnPropertyNames:WZe,getOwnPropertyDescriptor:nLn}=Object,dwe=Object.prototype.hasOwnProperty;function zZe(e){return this[e]}var rLn,aLn,gn=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var a=t?rLn??=new WeakMap:aLn??=new WeakMap,i=a.get(e);if(i)return i}n=e!=null?eLn(tLn(e)):{};let o=t||!e||!e.__esModule||!dwe.call(e,"default")?BN(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let s of WZe(e))if(!dwe.call(o,s))BN(o,s,{get:zZe.bind(e,s),enumerable:!0})}if(r)a.set(e,o);return o},JZe=(e)=>{var t=(HZe??=new WeakMap).get(e),n;if(t)return t;if(t=BN({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function"){for(var r of WZe(e))if(!dwe.call(t,r))BN(t,r,{get:zZe.bind(e,r),enumerable:!(n=nLn(e,r))||n.enumerable})}return HZe.set(e,t),t},HZe,yt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var iLn=(e)=>e;function oLn(e,t){this[e]=iLn.bind(null,t)}var Ke=(e,t)=>{for(var n in t)BN(e,n,{get:t[n],enumerable:!0,configurable:!0,set:oLn.bind(t,n)})};var v=(e,t,n)=>()=>{if(e)try{t=e(e=0)}catch(r){n=[r]}if(n)throw n[0];return t};var mn=import.meta.require;async function c0(e,t={}){let n=Bun.spawn([e,...t.args??[]],{cwd:t.cwd,env:{...process.env,...t.env},stdin:t.stdin??"ignore",stdout:"pipe",stderr:"pipe",windowsHide:!0,signal:t.signal,timeout:t.timeout}),[r,a,i]=await Promise.all([new Response(n.stdout).bytes(),new Response(n.stderr).bytes(),n.exited]);return{code:i,stdout:r,stderr:a,success:i===0,timedOut:t.timeout!==void 0&&n.signalCode==="SIGTERM"&&!t.signal?.aborted}}function IK(e,t){return Error.isError(e)&&"code"in e&&e.code===t}function QK(e){return IK(e,"EEXIST")}function fc(e){return IK(e,"ENOENT")}function pwe(e){return IK(e,"EACCES")||IK(e,"EPERM")}var SK,vd;var fI=v(()=>{SK=globalThis.navigator?.platform??globalThis.process?.platform,vd=SK==="win32"||SK?.startsWith("Win")?"windows":SK==="darwin"||SK?.startsWith("Mac")?"darwin":"linux"});var uVe;var lVe=v(()=>{uVe={name:"@hyperpuncher/pi-ui",version:"0.62.5",description:"keyboard-first minimal gui for pi",homepage:"https://pi-ui.app",bugs:"https://github.com/hyperpuncher/pi-ui/issues",license:"MIT",repository:{type:"git",url:"git+https://github.com/hyperpuncher/pi-ui.git"},bin:{"pi-ui":"dist/npm/server-main.js"},files:["dist/npm","static","!static/app"],type:"module",imports:{"#src/*":"./src/*","#static/*":"./static/*","#tests/*":"./tests/*","#testing/*":"./tests/src/testing/*","#tools/*":"./tools/*","#package":"./package.json","#testing/assertions":"./tests/src/testing/assertions.ts","#testing/temp":"./tests/src/testing/temp.ts"},publishConfig:{access:"public"},scripts:{dev:"bun run assets:build && bun src/server-main.ts","assets:build":"bun scripts/check-typebox.ts && bun scripts/generate-icons.ts && bun scripts/build-assets.ts",build:"bun run assets:build && bun scripts/build.ts","npm:build":"bun run assets:build && bun scripts/build-npm.ts",prepack:"bun run npm:build",run:"./dist/pi-ui",release:"bun scripts/release.ts","schema:build":"bun scripts/generate-config-schema.ts","schema:check":"bun scripts/generate-config-schema.ts --check",fmt:"bun run schema:build && dsfmt --write . && bun fmt","fmt:check":"bun run schema:check && bun fmt --no-script --check",lint:"bunx oxlint && bun run lint:css","lint:css":'bunx stylelint "src/**/*.css"',"lint:fix":"bunx oxlint --fix && bun run lint:css --fix",check:"bun run schema:check && bun check",test:"bun test --parallel=8",audit:"bunx fallow audit"},devDependencies:{"@earendil-works/pi-ai":"^1.4.0","@earendil-works/pi-coding-agent":"^1.4.0","@earendil-works/pi-tui":"^1.4.0","@iconify-json/lucide":"^1.2.150","@kitajs/html":"5.0.0-next.1","@oxlint/plugins":"1.90.0","@pierre/diffs":"^1.6.2","@pierre/highlights":"0.3.0","@pierre/trees":"^1.0.0-beta.6","@starfederation/datastar-sdk":"^1.0.0","@types/bun":"^1.4.4","open-props":"^1.7.23",oxlint:"1.90.0",pele:"1.13.0",stylelint:"^17.16.0","stylelint-config-standard":"^40.0.0",typebox:"1.3.27",typescript:"^7.0.2"},engines:{bun:">=1.4.4"},packageManager:"bun@1.4.4",patchedDependencies:{"@earendil-works/pi-coding-agent@1.4.0":"patches/@earendil-works%2Fpi-coding-agent@1.4.0.patch"}}});function dVe(e){return e.length===1&&e[0]==="--version"}var TK;var kwe=v(()=>{lVe();TK=uVe.version});var pVe=1000,AVe=!1,mVe=!1,Ewe="selector",RK="mode",Bwe="elements",xN="namespace",gVe="useViewTransition",Cwe="signals",fVe="onlyIfMissing",xwe,_we,hVe="outer",bVe="html";var vwe=v(()=>{xwe=["outer","inner","replace","prepend","append","before","after","remove"],_we=["html","svg","mathml"]});var yVe,Iwe;var Qwe=v(()=>{vwe();yVe={"Cache-Control":"no-cache",Connection:"keep-alive","Content-Type":"text/event-stream"},Iwe={[RK]:hVe,[xN]:bVe,[gVe]:AVe,[fVe]:mVe}});class Swe{constructor(){}validateElementPatchMode(e){if(!xwe.includes(e))throw Error(`Invalid ElementPatchMode: "${e}". Valid modes are: ${xwe.join(", ")}`)}validateNamespace(e){if(!_we.includes(e))throw Error(`Invalid namespace: "${e}". Valid namespaces are: ${_we.join(", ")}`)}validateRequired(e,t){if(!e||e.trim()==="")throw Error(`${t} is required and cannot be empty`)}send(e,t,n){let{eventId:r,retryDuration:a}=n||{},i=[`event: ${e}
|
|
4
4
|
`],o=r?[`id: ${r}
|
|
5
5
|
`]:[],s=!a||a===1000?[]:[`retry: ${a??pVe}
|
|
6
6
|
`];return i.concat(o,s,t.map((c)=>`data: ${c}
|
|
@@ -544,12 +544,12 @@ ${r}`;return new Dr(s,"syntax",{type:e,...i})}function vor(e){if(!pne){pne=new M
|
|
|
544
544
|
`):void 0,root:n.root,count:n.count}}function kDe(e,t){if(e===void 0||!Object.prototype.hasOwnProperty.call(e,t))return;let n=e[t];return typeof n=="string"?n:void 0}function p0r(e,t){let n=kDe(t?.filenameIcons,e);if(n)return n;let r=e.lastIndexOf(".");if(r>0){let a=e.substring(r).toLowerCase();return kDe(t?.extensionIcons,a)??kDe(t?.extensionIcons,a.slice(1))}}function FPt(e,t){return e.includes(":")?e:vTe.has(e)||!t?`${gae}:${e}`:`${t}:${e}`}function jPt(e,t){if(e.icon!=="none"){if(e.icon)return FPt(e.icon,t.defaultIconPack);if(t.showIcons){if(e.nodeType==="file"){let n=p0r(e.name,t);if(n==="none")return;if(n)return FPt(n,t.defaultIconPack)}return`${gae}:${e.nodeType==="directory"?"folder":"file"}`}}}function A0r(e){let t=(r)=>typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0,n=t(e.treeView)??{};return{showIcons:!!n.showIcons,defaultIconPack:typeof n.defaultIconPack=="string"?n.defaultIconPack:"",filenameIcons:t(n.filenameIcons),extensionIcons:t(n.extensionIcons)}}function pre(e,t,n,r,a){let i=e.treeView?.[t];return typeof i=="number"&&i>=r&&i<=a?i:n}function b0r(e){return{paddingX:pre(e,"paddingX",5,0,100),paddingY:pre(e,"paddingY",2,0,100),rowIndent:pre(e,"rowIndent",15,0,400),lineThickness:pre(e,"lineThickness",1,0.25,12)}}function y0r(e,t,n){return dx(n,(r)=>w0r(e,t,n,r))}function w0r(e,t,n,r){let a=n.fontSize??16,i=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),o=n.padding??8,s=A0r(t),c=Array.isArray(n.monospace)&&n.monospace.includes("files"),u=c?` font-family="${GM}"`:"",{paddingX:l,paddingY:d,rowIndent:p,lineThickness:A}=b0r(t),m=0,g=e.root.children.map((H)=>[H,0]);for(let H=0;r&&H<g.length;H++){let[X,z]=g[H];m=Math.max(m,z);for(let te of X.children)g.push([te,z+1])}let h=r?Math.min(p+l,Math.max(2,((n.maxWidth??320)-120)/Math.max(1,m))):p+l,f=Math.round(a*1.5)+2*d,b=a,y=Cn(e.title,!1,i,a,r?ad(n):4000,1),w=y.height>0?y.height+12:0,k=(H)=>H.some((X)=>jPt(X,s)!==void 0),E=[],B=new Map,x=[],_=(H,X)=>{let z=k(H);for(let te=H.length-1;te>=0;te--)x.push([H[te],X,z])};_(e.root.children,0);let Q=0,U=!1,O=0;for(;x.length>0;){let[H,X,z]=x.pop(),te=X*h,Y=Qo(H.name),ne=te+(z?b+m0r:0),K=Math.max(40,(n.maxWidth??320)-2*o-2*dre-ne),re=(H.nodeType==="directory"?1:0)|(c?4:0),ae=r?eae(Y,i,a,K,re):void 0,pe=r&&H.description?eae(Qo(H.description),i,a,K,2):void 0,le=ae?ae.width:i.width(Y,a,re);ne+le>Q&&(Q=ne+le);let ee=H.cssClass!==void 0&&H.cssClass.split(/\s+/).includes("highlight");ee&&(U=!0);let ce=r?Math.max(f,(ae?.height??0)+(pe?.height??0)+2*d):f,fe=O+(r?d+Math.max(b,ae?.height??0)/2:ce/2),de={node:H,x:te,cy:fe,icon:jPt(H,s),text:Y,labelX:ne,highlighted:ee,label:ae,description:pe,top:O,height:ce};O+=ce,E.push(de),B.set(H,de),_(H.children,X+1)}let R=Q+g0r,G=Q;for(let H of E){let X=H.node.description;if(!X)continue;let z=H.description?H.description.width:i.width(Qo(X),a,2);G=Math.max(G,(r?H.labelX:R)+z)}G=Math.max(G,y.width);let q=o+(U?dre:0),N=o+w,L=Math.ceil(G+2*q),D=Math.ceil(N+O+o),P="";for(let H of E){let X=H.node.children;if(X.length===0)continue;let z=q+H.x+f0r,te=Math.max(z,q+H.x+h-l),Y=N+B.get(X[X.length-1]).cy,ne=Math.min(h0r,te-z),K=`M${J(z)},${J(N+H.top+H.height-2)}V${J(Y-ne)}`;ne>0&&(K+=`Q${J(z)},${J(Y)} ${J(z+ne)},${J(Y)}H${J(te)}`);for(let re=0;re<X.length-1&&te>z;re++)K+=`M${J(z)},${J(N+B.get(X[re]).cy)}H${J(te)}`;P+=`<path d="${K}"/>`}let F=a*0.35,oe="";for(let H of E){let X=H.node,z=N+H.cy,te=X.nodeType==="directory",Y="";if(H.highlighted){let ne=q+H.x-dre;Y+=`<rect class="pele-tree-highlight" x="${J(ne)}" y="${J(N+H.top+1)}" width="${J(L-q+dre-ne)}" height="${J(H.height-2)}" fill="var(--_c)" fill-opacity="0.14"${Ji}/>`}if(H.icon!==void 0){let ne=H.icon.startsWith(gae+":")?H.icon.slice(gae.length+1):"",K=vTe.get(ne)??vTe.get(te?"folder":"file"),re=n.icons?.(H.icon)??`<path d="${K}" stroke="var(--_m)" stroke-width="1.5"/>`;Y+=`<svg class="pele-icon" data-icon="${kn(H.icon)}" x="${J(q+H.x)}" y="${J(z-b/2)}" width="${J(b)}" height="${J(b)}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${re}</svg>`}H.label?Y+=IM(H.label,q+H.labelX,N+H.top+d,` class="pele-label"${te?' font-weight="var(--_hw)"':""}${u}`):H.text!==""&&(Y+=`<text class="pele-label" x="${J(q+H.labelX)}" y="${J(z+F)}"${te?' font-weight="var(--_hw)"':""}${u} xml:space="preserve">${$r(H.text)}</text>`),H.description?Y+=IM(H.description,q+H.labelX,N+H.top+d+(H.label?.height??0),' class="pele-tree-description" font-style="italic" fill="var(--_m)"'):X.description&&(Y+=`<text class="pele-tree-description" x="${J(q+R)}" y="${J(z+F)}" font-style="italic" fill="var(--_m)" xml:space="preserve">${$r(Qo(X.description))}</text>`),oe+=`<g class="pele-node pele-tree-${te?"dir":"file"}${_u(X.cssClass??"")}" data-id="${kn(X.name)}">${Y}</g>`}let V=Xt(y,L/2,o+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+(P?`<g class="pele-tree-guides" fill="none" stroke="var(--_b)" stroke-width="${J(A)}">${P}</g>`:"")+oe;return{svg:Ni("treeView",L,D,a,n,e,V),width:L,height:D,links:[]}}function E0r(e){let t=[],n=[];for(let r of e){let a=r.type==="Leaf",i={name:r.name,children:a?void 0:[]};for(i.classSelector=r.classSelector,r.cssCompiledStyles&&(i.cssCompiledStyles=r.cssCompiledStyles),a&&r.value!==void 0&&(i.value=r.value);n.length>0&&n[n.length-1].level>=r.level;)n.pop();n.length===0?t.push(i):n[n.length-1].node.children.push(i),a||n.push({node:i,level:r.level})}return t}function B0r(e,t){let n=new Map;for(let a of e.TreemapRows){if(a.$type!=="ClassDefStatement")continue;let i=n.get(a.className);i||n.set(a.className,i=[]);let o=(a.styleText??"").replace(/\\,/g,"\xA7\xA7\xA7").replace(/,/g,";").replace(/\u00A7\u00A7\u00A7/g,",");for(let s of o.split(";"))i.push(s)}let r=[];for(let a of e.TreemapRows){if(a.$type!=="TreemapRow")continue;let i=a.item,o=i.classSelector?n.get(i.classSelector):void 0;r.push({level:a.indent??0,name:i.name,type:i.$type,value:i.$type==="Leaf"?i.value:void 0,classSelector:i.classSelector,cssCompiledStyles:o&&o.length>0?o:void 0})}return{type:"treemap",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
545
545
|
`):void 0,roots:E0r(r),classes:n}}function x0r(e){let t=new qf($f(e,LPt,"treemap"),LPt,"treemap"),n=t.kinds,r={$type:"Treemap",TreemapRows:[]},a=()=>t.accept(5)?t.expect(12):void 0;for(t.expect(3);t.kind!==-1;){let i=t.kind;if(i===0){r.accDescr=Uf(t.take());continue}if(i===1){r.accTitle=Gf(t.take());continue}if(i===2){r.title=Of(t.take());continue}i!==8&&i!==14&&i!==4&&t.fail("a node, a class definition, or a title");let o=i===8?t.take().length:void 0;if(t.kind===4){let p=C0r.exec(t.take()),A={$type:"ClassDefStatement",className:p[1]};p[2]&&(A.styleText=p[2]),o!==void 0&&(A.indent=o),r.TreemapRows.push(A);continue}let s=t.expect(14).slice(1,-1),c=n[t.i]===8?t.i+1:t.i,u;n[c]===6||n[c]===7?(t.i=c+1,t.accept(8),u={$type:"Leaf",name:s,value:parseFloat(t.expect(13).replace(/,/g,""))}):u={$type:"Section",name:s};let l=a();l!==void 0&&(u.classSelector=l);let d={$type:"TreemapRow",item:u};o!==void 0&&(d.indent=o),r.TreemapRows.push(d)}return r}function NPt(e){let t="";for(let n=e.length;n>0;n-=3)t=e.slice(Math.max(0,n-3),n)+(t?","+t:"");return t}function _0r(e){let t=PPt.exec(e==="$0,0"?"$,":e)??PPt.exec(","),n=t[1]==="+",r=t[3]!==void 0,a=t[4]===void 0?void 0:Math.min(Number(t[4]),20),i=t[6]??"";return(o)=>{let s=Math.abs(o),c,u="";if(i==="f"?c=s.toFixed(a??6):i==="%"?(c=(s*100).toFixed(a??6),u="%"):i==="d"?c=Math.round(s).toFixed(0):i==="e"?c=s.toExponential(a??6):c=String(Number(s.toPrecision(Math.max(1,a??12)))),t[5]&&c.includes(".")&&!c.includes("e")&&(c=c.replace(/\.?0+$/,"")),r&&!c.includes("e")){let l=c.indexOf(".");c=l===-1?NPt(c):NPt(c.slice(0,l))+c.slice(l)}return(o<0?"-":n?"+":"")+(t[2]??"")+c+u}}function $Pt(e,t,n){let r=e.children===void 0&&Number.isFinite(e.value)&&e.value>0?e.value:0;return{node:e,parent:t,series:n,value:r,children:[],headed:!1,header:0,x:0,y:0,w:0,h:0}}function v0r(e,t,n,r,a,i,o){let s=t,c=0;for(;c<e.length;){let u=a*i/s,l=Math.min(a,i),d=e[c].value*u,p=d,A=Math.max(l*l*p/(d*d),d*d/(l*l*p)),m=c+1;for(;m<e.length;){let f=e[m].value*u,b=d+f,y=Math.max(l*l*p/(b*b),b*b/(l*l*f));if(y>A)break;A=y,d=b,m++}let g=d/l,h=0;for(let f=c;f<m;f++){let b=e[f],y=f===m-1?l-h:b.value*u/g,w=a>=i?n:n+h,k=a>=i?r+h:r,E=a>=i?g:y,B=a>=i?y:g,x=Math.round(w+E-o/2)>Math.round(w+o/2)?o/2:0,_=Math.round(k+B-o/2)>Math.round(k+o/2)?o/2:0;b.x=Math.round(w+x),b.y=Math.round(k+_),b.w=Math.round(w+E-x)-b.x,b.h=Math.round(k+B-_)-b.y,h+=y,s-=b.value}a>=i?(n+=g,a-=g):(r+=g,i-=g),c=m}}function I0r(e,t,n,r){let a=e.map((p,A)=>$Pt(p,void 0,A)),i=a.slice();for(let p=0;p<i.length;p++){let A=i[p];for(let m of A.node.children??[]){let g=$Pt(m,A,A.series);A.children.push(g),i.push(g)}}for(let p=i.length-1;p>=0;p--){let A=i[p];A.parent&&(A.parent.value+=A.value)}let{gap:o,header:s,short:c,side:u}=r,l=[],d=(p,A,m,g,h)=>{let f=p.filter((y)=>y.value>0).sort((y,w)=>w.value-y.value),b=0;for(let y of f)b+=y.value;if(!(f.length===0||!Number.isFinite(b))){g=Math.max(0,g),h=Math.max(0,h),g>0&&h>0&&v0r(f,b,A-o/2,m-o/2,g+o,h+o,o);for(let y of f){let w=Are(y.x,A,A+g),k=Are(y.y,m,m+h);y.w=Are(y.x+y.w,w,A+g)-w,y.h=Are(y.y+y.h,k,m+h)-k,y.x=w,y.y=k,l.push(y)}}};d(a,0,0,t,n);for(let p=0;p<l.length;p++){let A=l[p];if(A.children.length===0)continue;let m=A.h-s-u>=12?s:c;A.headed=A.w>Math.max(24,2*u)&&A.h-m-u>=8,A.header=A.headed?m:0,A.headed?d(A.children,A.x+u,A.y+m,A.w-2*u,A.h-m-u):d(A.children,A.x,A.y,A.w,A.h)}return l}function S0r(e){let t=0,n=e.slice();for(;n.length>0;){let r=n.pop();r.children!==void 0?n.push(...r.children):Number.isFinite(r.value)&&r.value>0&&t++}return t}function GPt(e,t){let n=Math.min(t.w,t.h)/4;return n<4?Io(e).replace("rx:var(--_r)",`rx:min(var(--_r),${J(n)}px)`):Io(e)}function mre(e,t,n,r,a){let i=e.treemap?.[t];return typeof i=="number"&&i>=r?Math.min(i,a):n}function D0r(e,t,n){let r=n.fontSize??16,a=Math.round(r*0.875),i=Math.round(r*0.75),o=Math.round(r*0.5625),s=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),c=t.treemap??{},u=n.padding??mre(t,"diagramPadding",8,0,2000),l=Math.round(Iae(n,mre(t,"nodeWidth",64,1,400)*10,200,2*u)),d=Math.round(mre(t,"nodeHeight",40,1,400)*10),p=c.showValues!==!1,A=_0r(typeof c.valueFormat=="string"?c.valueFormat:","),m=Math.min(1,Math.max(0,Math.log10(l*d/Math.max(1,S0r(e.roots))/800))),g=I0r(e.roots,l,d,{gap:mre(t,"padding",Math.round(2+2*m),0,200),header:EDe,short:Q0r,side:Math.round(3+3*m)}),h=Cn(e.title,!1,s,r,ad(n),1),f=h.height>0?h.height+8:0,b=u+Math.max(0,(h.width-l)/2),y=u+f,w="",k="";for(let _ of g){let Q=_.node,U=vc(Q.cssCompiledStyles??[]),O=ho(_.series),R=b+_.x,G=y+_.y,q=Qo(Q.name).trim(),N=p?A(_.value):"",L=`data-id="${kn(Q.name)}">`,D=OPt(Q.name),P=D===""?[]:[D];for(let ae=_.parent;ae!==void 0&&!ae.headed;ae=ae.parent){let pe=OPt(ae.node.name);pe!==""&&P.unshift(pe)}let F=P.join(" \u203A "),oe=(ae)=>F===""||ae===q&&F===D?"":`<title>${F}</title>`,V=`<rect x="${J(R)}" y="${J(G)}" width="${J(_.w)}" height="${J(_.h)}" fill="${O}"`,H=U.fontSize,X=(U.bold?1:0)|(U.italic?2:0),z=CQ(U.shape)?nd(U):Eae(_.series);if(Q.children!==void 0){let ae="",pe;if(_.headed){let ce=_.header<EDe,fe=H??(ce?i:a),de=H??i,Ae=_.w-2*BDe-4,ue=N?s.width(N,de,X):0,ie=!ce&&ue>0&&Ae-ue-12>=3*fe,ke=fe*iQ<_.header?yTe(q,ie?Ae-ue-12:Ae,fe,fe,s,X|1):void 0,xe=G+_.header/2+1;pe=ke?.text,ke&&(ae+=`<text x="${J(R+BDe+2)}" y="${J(xe+fe*0.35)}" font-weight="var(--_hw)"${ce?` font-size="${fe}"`:""}${z}${U.text}>${$r(ke.text)}</text>`),ie&&de*iQ<=EDe&&(ae+=`<text class="pele-value" x="${J(R+_.w-BDe-2)}" y="${J(xe+de*0.35)}" font-size="${i}" text-anchor="end"${z||' fill="var(--_m)"'}${U.text}>${$r(N)}</text>`)}let le=/[";]fill:/.test(U.shape)?"":' fill-opacity="0.12"',ee=_.headed?`${V}${GPt(`${le} stroke="${O}"${U.shape}`,_)}/>`:`<rect x="${J(R)}" y="${J(G)}" width="${J(_.w)}" height="${J(_.h)}" fill="none"/>`;w+=`<g class="pele-node pele-section${_u(Q.classSelector??"")}" ${L}${oe(pe)}${ee}${ae}</g>`;continue}let te="",Y=_.w-8,ne=H??o,K=H===void 0?Math.min(r,Math.floor((_.h-4)/iQ)):H*iQ<=_.h-4?H:0,re=K>=ne?yTe(q,Y,K,ne,s,X):void 0;if(re){let ae=J(R+_.w/2),pe=G+_.h/2,le=H??Math.max(o,Math.round(re.size*0.8)),ee=(re.size+le)*iQ;if(N&&ee<=_.h-4&&s.width(N,le,X)<=Y){let ce=pe-ee/2+re.size*iQ/2,fe=pe+ee/2-le*iQ/2;te=`<text x="${ae}" y="${J(ce+re.size*0.35)}" font-size="${J(re.size)}"${z}${U.text}>${$r(re.text)}</text><text class="pele-value" x="${ae}" y="${J(fe+le*0.35)}" font-size="${J(le)}"${z}${U.text}>${$r(N)}</text>`}else te=`<text x="${ae}" y="${J(pe+re.size*0.35)}" font-size="${J(re.size)}"${z}${U.text}>${$r(re.text)}</text>`}k+=`<g class="pele-node pele-leaf${_u(Q.classSelector??"")}" ${L}${oe(re?.text)}${V}${GPt(U.shape,_)}/>${te}</g>`}let E=Math.ceil(Math.max(l,h.width)+2*u),B=Math.ceil(d+f+2*u),x=Xt(h,E/2,u+h.height/2,' class="pele-title" font-weight="var(--_tw)"')+(w?`<g class="pele-sections" font-size="${a}">${w}</g>`:"")+(k?`<g class="pele-leaves" text-anchor="middle" fill="var(--_bg)">${k}</g>`:"");return{svg:Ni("treemap",E,B,r,n,e,x),width:E,height:B,links:[]}}function gre(e){return e<128&&(ux[e]&r5)!==0}function CDe(e,t,n){for(let r=0;r<n.length;r++)if((e.charCodeAt(t+r)|32)!==n.charCodeAt(r))return!1;return!0}function R0r(e,t,n){switch(n){case 97:return e.startsWith("actor",t)?2:0;case 115:return e.startsWith("systemBoundary",t)?3:e.startsWith("style",t)?16:0;case 101:return e.startsWith("end",t)?4:CDe(e,t,"extend")?18:0;case 69:return CDe(e,t,"extend")?18:0;case 100:return e.startsWith("direction",t)?5:0;case 84:return e.startsWith("TD",t)?6:e.startsWith("TB",t)?7:0;case 66:return e.startsWith("BT",t)?8:0;case 76:return e.startsWith("LR",t)?9:0;case 82:return e.startsWith("RL",t)?10:0;case 110:return e.startsWith("note",t)?11:0;case 102:return e.startsWith("for",t)?12:e.startsWith("false",t)?20:0;case 106:return e.startsWith("json",t)?13:0;case 99:return e.startsWith("classDef",t)?14:e.startsWith("class",t)?15:0;case 105:case 73:return CDe(e,t,"include")?17:0;case 116:return e.startsWith("true",t)?19:0;case 117:return e.startsWith("usecase-beta",t)?1:0;default:return 0}}function a5(e,t){[e,t]=hQ(e,t);let n=1,r=0;for(let a=0;a<t;a++){let i=e.charCodeAt(a);i!==10&&i!==13||(i===13&&a+1<t&&e.charCodeAt(a+1)===10&&a++,n++,r=a+1)}return[n,t-r+1]}function bNt(e,t,n){let[r,a]=a5(e,t);return`line ${r}, column ${a} [${hQ(e,t)[1]},${hQ(e,n)[1]})`}function yNt(e,t,n){for(let r=t+1;r<e.length;r++){let a=e.charCodeAt(r);if(a===n)return r+1;if(a===10||a===13)return-1}return-1}function M0r(e,t){let n=e.charCodeAt(t);return n!==34&&n!==39?!0:n===34&&e.charCodeAt(t+1)===96||yNt(e,t,n)!==-1}function qPt(e,t,n){let[r,a]=a5(e,t),[i,o]=[hQ(e,t)[1],hQ(e,t+n)[1]];return new Dr(`Error lexing usecase diagram: unexpected character: ->${e.charAt(t)}<- at offset: ${i}, skipped ${o-i} characters. at line ${r}, column ${a} [${i},${o})`,"syntax",{type:"usecase",line:r,column:a})}function F0r(e){let t=[],n=[],r=[],a=e.length,i=0,o=!0,s=!1;for(;i<a;){let c=e.charCodeAt(i);if(c===32||c===9){i++;continue}let u,l=i+1,d=!1;if(c<128&&(ux[c]&r5)!==0){if(u=0,c===97&&o&&e.startsWith("acc",i)){let p=e.startsWith("Descr",i+3);if(p||e.startsWith("Title",i+3)){let A=i+8;for(;z0(e.charCodeAt(A));)A++;let m=e.charCodeAt(A);if(m===58)for(u=p?42:41,l=A+1;l<a&&e.charCodeAt(l)!==10&&e.charCodeAt(l)!==13;)l++;else if(m===123&&p&&!s){let g=e.indexOf("}",A+1);g===-1?s=!0:(u=40,l=g+1)}}}else if(c===106&&e.startsWith("json",i)&&z0(e.charCodeAt(i+4))){let p=i+5;for(;z0(e.charCodeAt(p));)p++;let A=p;for(;gre(e.charCodeAt(p));)p++;if(p>A){for(;z0(e.charCodeAt(p));)p++;if(e.charCodeAt(p)===64){for(p++;z0(e.charCodeAt(p));)p++;if(e.charCodeAt(p)===123){t.push(43),n.push(i),r.push(p),i=p;let m=0,g=!1,h=!1,f=p;for(;f<a;f++){let b=e.charCodeAt(f);if(g)h?h=!1:b===92?h=!0:b===34&&(g=!1);else if(b===34)g=!0;else if(b===123)m++;else if(b===125&&--m===0)break}t.push(f<a?44:45),n.push(p),i=f<a?f+1:a,r.push(i),o=!1;continue}}}}if(u===0){for(;l<a&&gre(e.charCodeAt(l));)l++;let p=R0r(e,i,c);if(p!==0)p===1||l-i===UPt[p]?(u=p,l=i+UPt[p]):u=21;else if((c===111||c===120)&&e.charCodeAt(i+1)===45&&e.charCodeAt(i+2)===45)u=c===111?56:58,l=i+3;else if(Pi(c)){let A=i+1;for(;Pi(e.charCodeAt(A));)A++;if(e.charCodeAt(A)===46&&Pi(e.charCodeAt(A+1))){for(u=22,l=A+2;Pi(e.charCodeAt(l));)l++;for(;DM(e.charCodeAt(l));)l++}else u=21}else for(u=21;e.charCodeAt(l)===45&&gre(e.charCodeAt(l+1));)for(u=27,l+=2;gre(e.charCodeAt(l));)l++}}else if(c===10)u=39,d=!0;else if(c===13)u=39,d=!0,e.charCodeAt(l)===10&&l++;else if(c===34||c===39){if(c===34&&e.charCodeAt(i+1)===96){let p=e.indexOf('`"',i+2);u=p===-1?37:36,l=p===-1?a:p+2}else if(u=35,l=yNt(e,i,c),l===-1){let p=i+1;for(;p<a&&!M0r(e,p);)p++;throw qPt(e,i,p-i)}}else if(c===37)if(o&&e.charCodeAt(l)===37)for(u=38;l<a&&e.charCodeAt(l)!==10&&e.charCodeAt(l)!==13;)l++;else u=31;else if(c===45)if(e.charCodeAt(l)!==45)u=29;else{for(;e.charCodeAt(l)===45;)l++;let p=e.charCodeAt(l),A=l-i===2;A&&p===124&&e.charCodeAt(l+1)===62?(u=46,l+=2):p===62?(u=53,l++):A&&(p===111||p===120)?(u=p===111?55:57,l++):u=59}else if(c===46){let p=e.charCodeAt(l);if(p===46&&e.charCodeAt(l+1)===62)u=47,l+=2;else if(Pi(p)){for(u=22;Pi(e.charCodeAt(l));)l++;for(;DM(e.charCodeAt(l));)l++}else u=30}else if(c===60)if(e.charCodeAt(l)===60){if(t.push(48),n.push(i),r.push(i+2),o=!1,i+=2,i>=a)break;if(e.charCodeAt(i)===62&&e.charCodeAt(i+1)===62)u=49,l=i+2;else{let p=i,A=!1;for(;p<a;p++){let m=e.charCodeAt(p);if(m===10||m===13)break;if(m===62&&e.charCodeAt(p+1)===62){A=!0;break}}if(A&&e.slice(i,p).trim()!=="")t.push(50),n.push(i),r.push(p),u=49,i=p,l=p+2;else{for(;p<a&&e.charCodeAt(p)!==10&&e.charCodeAt(p)!==13;)p++;if(p===i){for(;p<a&&(e.charCodeAt(p)===10||e.charCodeAt(p)===13);)p++;throw qPt(e,i,p-i)}u=51,l=p}}}else if(e.charCodeAt(l)===45&&e.charCodeAt(l+1)===45)for(u=54,l+=2;e.charCodeAt(l)===45;)l++;else u=33;else if(c===58)e.charCodeAt(l)===58&&e.charCodeAt(l+1)===58?(u=52,l+=2):u=25;else if(c===64)e.charCodeAt(l)===123?(u=60,l++):u=23;else if(c===123)u=61;else if(c===125)u=62;else if(c===91)u=63;else if(c===93)u=64;else if(c===40)u=65;else if(c===41)u=66;else if(c===44)u=24;else if(c===35){for(;Q8t(e.charCodeAt(l));)l++;u=l>i+1?26:32}else if(c===92)e.charCodeAt(l)===44?(u=28,l++):u=33;else if(c<127&&c>32)u=(ux[c]&hNt)!==0?32:33;else for(u=34;l<a;){let p=e.charCodeAt(l);if(p>=32&&p<127||p===9||p===10||p===13)break;l++}t.push(u),n.push(i),r.push(l),i=l,o=d}for(let c=0;c<3;c++)t.push(0),n.push(a),r.push(a);return{types:t,starts:n,ends:r}}function j0r(){return{type:"usecase",actors:new Map,useCases:new Map,systemBoundaries:new Map,relationships:[],notes:new Map,jsonNodes:new Map,classDefs:new Map,direction:"LR",title:void 0,accTitle:"",accDescr:"",accDescription:"",source:"",headerSpan:[0,0],statements:[]}}function L0r(){return{elements:[],boundaries:[],jsons:[],relationships:[],notes:[],metadata:[],classes:[],styles:[],classDefs:[],direction:void 0,accTitle:"",accDescription:""}}function xDe(e,t){if(t.length===0)return;let n=new Set(e);for(let r of t)n.has(r)||(n.add(r),e.push(r))}function P0r(e){let t=new Set(["actor","usecase","boundary","edge"]);for(let{key:n,value:r}of e)if(n==="icon")t.clear(),t.add("actor");else if(n==="animate"||n==="animation")t.clear(),t.add("edge");else if(n==="type")t.clear(),r==="rect"||r==="package"?t.add("boundary"):(r==="normal"||r==="hollow"||r==="awesome")&&t.add("actor");else if(n==="business")t.delete("boundary"),t.delete("edge");else return;return t.size===1?[...t][0]:void 0}function N0r(e,t,n,r,a){let i=j0r(),{actors:o,useCases:s,systemBoundaries:c}=i,u=new Map,l=new Map,d=new Map,p=new Map,A=new Map,m=(F)=>bNt(e,F[0],F[1]),g=(F,oe)=>{let[V,H]=a5(e,oe[0]);return new Dr(F,"semantic",{type:"usecase",line:V,column:H})},h=(F,oe)=>{throw g(`${F} at ${m(oe)}`,oe)},f=(F,oe,V,H,X)=>{let z=(te)=>te===void 0?"":` (label "${te}")`;throw g(`${F} at ${m(oe)}${z(H)}; previous declaration at ${m(V)}${z(X)}`,oe)},b=(F,oe,V)=>h(`Metadata property '${V.key}' is invalid for ${oe} '${F}'`,V.keySpan),y=(F,oe)=>{let V=A.get(F);(V===void 0||oe<V)&&A.set(F,oe)},w=(F)=>[...F].sort((oe,V)=>(A.get(oe.id)??0)-(A.get(V.id)??0)),k=(F,oe)=>{u.set(F.id,{kind:oe,span:F.span,generated:F.generated,label:F.label.text})},E=(F,oe)=>{let V=u.get(F.id);if(!V)return;let H=F.generated?F.label.text:void 0,X=V.generated?V.label:void 0;V.kind!==oe&&f(`ID '${F.id}' is declared as both ${V.kind} and ${oe}`,F.span,V.span,H,X),(V.generated||F.generated)&&f(`Generated ID '${F.id}' collides with another declaration`,F.span,V.span,H,X)},B=(F,oe,V)=>{let H=u.get(F);H&&f(`ID '${F}' is declared more than once (${H.kind} and ${oe})`,V,H.span,void 0,H.generated?H.label:void 0),u.set(F,{kind:oe,span:V,generated:!1})},x=(F,oe,V)=>{let{key:H,value:X}=oe,z=(te)=>{!V&&te!==void 0&&te!==X&&f(`Actor '${F.id}' has conflicting ${H} metadata`,oe.keySpan,F.span)};H==="type"&&(X==="normal"||X==="hollow"||X==="awesome")?(z(F.actorType),F.actorType=X):H==="icon"&&typeof X=="string"?(z(F.icon),F.icon=X):H==="business"&&typeof X=="boolean"?(z(F.business),F.business=X):b(F.id,"actor",oe)},_=(F,oe,V)=>{for(let H of oe??[])F.kind==="actor"?x(F,H,V):H.key==="business"&&typeof H.value=="boolean"?(!V&&F.business!==void 0&&F.business!==H.value&&f(`Use case '${F.id}' has conflicting business metadata`,H.keySpan,F.span),F.business=H.value):b(F.id,"usecase",H)},Q=(F)=>{let oe;if(F.kind==="actor"){s.delete(F.id);let V={id:F.id,label:F.label.text,labelType:F.label.type,business:F.business??!1,classes:[...F.classes],type:F.icon?"icon":F.actorType??"normal",styles:o.get(F.id)?.styles??[]};F.icon&&(V.icon=F.icon),o.set(F.id,V),oe=V}else o.delete(F.id),oe={id:F.id,label:F.label.text,labelType:F.label.type,business:F.business??!1,classes:[...F.classes],shape:F.shape??"ellipse",styles:s.get(F.id)?.styles??[]},s.set(F.id,oe);F.stereotype&&(oe.stereotype=F.stereotype),F.parent?.id&&(oe.parentId=F.parent.id)},U=(F)=>{E(F,F.kind);let oe=F.parent?.id?F.parent:void 0,V=l.get(F.id);if(!V){let H={kind:F.kind,id:F.id,label:F.label,span:F.span,generated:F.generated,classes:[...F.classes],parent:oe,shape:F.shape,stereotype:F.stereotype,stereotypeSpan:F.stereotype?F.span:void 0};_(H,F.metadata,!1),l.set(F.id,H),k(F,F.kind);return}(V.label.text!==F.label.text||V.label.type!==F.label.type)&&f(`ID '${F.id}' has conflicting labels`,F.span,V.span),F.shape&&V.shape&&F.shape!==V.shape&&f(`Use case '${F.id}' has conflicting shapes`,F.span,V.span),oe&&V.parent?.id&&oe.id!==V.parent.id&&f(`Element '${F.id}' belongs to more than one system boundary`,oe.span,V.parent.span),F.stereotype&&V.stereotype&&F.stereotype!==V.stereotype&&f(`Element '${F.id}' has conflicting stereotypes`,F.span,V.stereotypeSpan??V.span),V.shape??=F.shape,V.parent??=F.parent,V.stereotype??=F.stereotype,V.stereotypeSpan??=F.stereotype?F.span:void 0,xDe(V.classes,F.classes),_(V,F.metadata,!1)},O=(F)=>{E(F,"boundary");let oe=d.get(F.id);if(oe){(oe.label.text!==F.label.text||oe.label.type!==F.label.type)&&f(`Boundary '${F.id}' has conflicting titles`,F.span,oe.span),xDe(oe.classes,F.classes);return}d.set(F.id,{...F,classes:[...F.classes],members:[]}),k(F,"boundary")},R=(F)=>{F.classed&&!F.declares&&h(`Relationship endpoint '${F.id}' uses ::: without declaring the node`,F.span);let oe=u.get(F.id);return oe?oe.kind:(l.set(F.id,{...F,kind:"usecase",shape:"ellipse",classes:[]}),k(F,"usecase"),y(F.id,F.span[0]),"usecase")},G=(F,oe)=>{let V=u.get(F)?.kind;return(V==="actor"?o.get(F):V==="usecase"?s.get(F):V==="boundary"?c.get(F):V==="json"?i.jsonNodes.get(F):p.get(F))??h(`Class/style target '${F}' is unresolved or anonymous`,oe)},q=[];for(let{source:F,target:oe}of t.relationships)y(F.id,F.span[0]),y(oe.id,oe.span[0]);for(let F of t.elements)y(F.id,F.span[0]),q.push({offset:F.span[0],run:()=>U(F)});for(let F of t.boundaries)y(F.id,F.span[0]),q.push({offset:F.span[0],run:()=>O(F)});for(let F of t.jsons)y(F.id,F.span[0]),q.push({offset:F.span[0],run:()=>B(F.id,"json",F.span)});for(let{id:F,idSpan:oe}of t.relationships)F&&oe&&q.push({offset:oe[0],run:()=>B(F,"edge",oe)});q.sort((F,oe)=>F.offset-oe.offset);for(let F of q)F.run();for(let F of w(l.values()))Q(F);for(let F of w(d.values()))c.set(F.id,{id:F.id,label:F.label.text,labelType:F.label.type,type:"rect",members:[],classes:[],styles:[]});for(let F of w(t.jsons))i.jsonNodes.set(F.id,{id:F.id,value:F.value,propertyOrder:F.propertyOrder,classes:[...F.classes],styles:[]});let N=0;for(let F of t.relationships){let{source:oe,target:V,type:H}=F,X=R(oe),z=R(V),te=(K)=>K==="actor"||K==="usecase"||K==="json";te(X)||f(`Relationship source '${oe.id}' cannot be ${X}`,oe.span,u.get(oe.id).span),te(z)||f(`Relationship target '${V.id}' cannot be ${z}`,V.span,u.get(V.id).span),(H==="include"||H==="extend")&&(X!=="usecase"||z!=="usecase")&&h(`${H} relationship requires use-case endpoints`,F.span),H==="generalization"&&(X==="json"||X!==z)&&h("Generalization requires actor-to-actor or use-case-to-use-case endpoints",F.span),H==="association"&&(X==="json"||z==="json")&&F.arrowType>2&&h(`JSON relationship '${oe.id}' to '${V.id}' permits only point, reversed-point, or markerless solid association`,F.span);let Y=F.id??`edge-${N++}`,ne={id:Y,explicitId:!!F.id,source:oe.id,target:V.id,type:H,arrowType:F.arrowType,minlen:F.minlen,classes:[],styles:[],animate:!1};F.label&&(ne.label=F.label.text,ne.labelType=F.label.type),i.relationships.push(ne),p.set(Y,ne)}let L=new Map(o),D=new Map(s);o.clear(),s.clear();for(let F of w(l.values())){let oe=L.get(F.id),V=D.get(F.id);oe?o.set(F.id,oe):V?s.set(F.id,V):Q(F)}for(let{target:F,span:oe,properties:V,statement:H}of t.metadata){let X=u.get(F);if(!X){let ne=P0r(V);return h(`Metadata target '${F}' is unresolved${ne?` (metadata implies ${ne})`:""}`,oe)}let z=X.kind;z==="actor"||z==="usecase"?_(l.get(F),V,!0):z==="edge"&&(H.kind="edgeMetadata",H.edges=[{id:F,span:H.span,idSpan:oe,metadata:H.metadata}],delete H.nodes);let te=d.get(F),Y=p.get(F);for(let ne of z==="actor"||z==="usecase"?[]:V){let{key:K,value:re}=ne;z==="boundary"&&te&&K==="type"&&(re==="rect"||re==="package")?te.type=re:z==="edge"&&Y&&K==="animate"&&typeof re=="boolean"?Y.animate=re:z==="edge"&&Y&&K==="animation"&&(re==="fast"||re==="slow")?(Y.animation=re,Y.animate=!0):b(F,z,ne)}}for(let F of i.relationships)F.animation&&(F.animate=!0);for(let F of l.values())F.kind==="actor"?(F.icon&&F.actorType&&F.actorType!=="normal"&&h(`Actor '${F.id}' cannot combine icon with type '${F.actorType}'`,F.span),F.business&&(F.icon||F.actorType==="awesome")&&h(`Business actor '${F.id}' must use normal or hollow geometry`,F.span)):F.shape==="rect"&&F.business&&h(`Rectangular use case '${F.id}' cannot be a business use case`,F.span),Q(F);for(let F of[...t.elements].sort((oe,V)=>oe.span[0]-V.span[0])){if(!F.parent?.id)continue;let oe=d.get(F.parent.id).members;oe.includes(F.id)||oe.push(F.id)}for(let F of d.values()){let oe=c.get(F.id);oe.type=F.type??"rect",oe.members=F.members,oe.classes=[...F.classes]}let P=0;for(let F of t.notes){let oe=u.get(F.target);if(!oe)return h(`Note target '${F.target}' is unresolved`,F.span);oe.kind!=="actor"&&oe.kind!=="usecase"&&f(`Note target '${F.target}' must be an actor or use case, not ${oe.kind}`,F.span,oe.span);let V=`note-${P++}`;i.notes.set(V,{id:V,target:F.target,label:F.label.text,labelType:F.label.type})}for(let F of t.classDefs)for(let oe of F.ids)i.classDefs.set(oe,{id:oe,styles:[...F.styles]});for(let F of t.classes)for(let oe of F.targets)xDe(G(oe.id,oe.span).classes,F.classes);for(let F of t.styles)G(F.target,F.span).styles.push(...F.styles);return i.direction=t.direction??i.direction,i.title=a,i.accTitle=t.accTitle,i.accDescription=t.accDescription,i.accDescr=t.accDescription.replace(/\n\s+/g,`
|
|
546
546
|
`),i.source=e,i.headerSpan=n,i.statements=r,i}function HPt(e){let t=new Map,n=[],r=[],a=e.length,i=0,o="",s=0,c=()=>{for(;i<a;){let p=e.charCodeAt(i);if(p!==32&&p!==9&&p!==10&&p!==13)return;i++}},u=(p)=>{i++;let A="";for(;i<a;){let m=i,g=e[i++];if(g==='"')return A;if(g.charCodeAt(0)<32)throw new gm(m);if(g!=="\\"){p&&(A+=g);continue}let h=i,f=e[i++],b;if(f==='"'||f==="\\"||f==="/")b=f;else if(f==="b")b="\b";else if(f==="f")b="\f";else if(f==="n")b=`
|
|
547
|
-
`;else if(f==="r")b="\r";else if(f==="t")b="\t";else if(f==="u"){let y=e.slice(i,i+4);if(!/^[\dA-Fa-f]{4}$/.test(y))throw new gm(i);b=String.fromCharCode(parseInt(y,16)),i+=4}else throw new gm(h);p&&(A+=b)}throw new gm(i)},l=(p)=>{for(let A=0;A<p.length;A++)if(e[i+A]!==p[A])throw new gm(i+A);i+=p.length},d=()=>{if(e.charCodeAt(i)===45&&i++,e.charCodeAt(i)===48)i++;else if(Pi(e.charCodeAt(i)))for(;Pi(e.charCodeAt(i));)i++;else throw new gm(i);if(e.charCodeAt(i)===46){if(i++,!Pi(e.charCodeAt(i)))throw new gm(i);for(;Pi(e.charCodeAt(i));)i++}if((e.charCodeAt(i)|32)===101){if(i++,(e.charCodeAt(i)===43||e.charCodeAt(i)===45)&&i++,!Pi(e.charCodeAt(i)))throw new gm(i);for(;Pi(e.charCodeAt(i));)i++}};for(c();;)if(s===0){c();let p=e.charCodeAt(i);if(s=2,p===123){i++;let A=[];t.set(o,A),n.push(o),c(),e.charCodeAt(i)===125?i++:(r.push({object:!0,pointer:o,keys:A,ranges:new Map,key:"",from:0,index:0}),s=1)}else if(p===91)i++,c(),e.charCodeAt(i)===93?i++:(r.push({object:!1,pointer:o,keys:[],ranges:new Map,key:"",from:0,index:0}),o+="/0",s=0);else if(p===34)u(!1);else if(p===116)l("true");else if(p===102)l("false");else if(p===110)l("null");else if(p===45||Pi(p))d();else throw new gm(i)}else if(s===1){let p=r[r.length-1];if(e.charCodeAt(i)!==34)throw new gm(i);let A=u(!0),m=p.ranges.get(A);if(m===void 0)p.keys.push(A);else for(let g=m[0];g<m[1];g++)t.delete(n[g]);if(p.key=A,p.from=n.length,c(),e.charCodeAt(i)!==58)throw new gm(i);i++,o=`${p.pointer}/${A.replaceAll("~","~0").replaceAll("/","~1")}`,s=0}else{let p=r[r.length-1];if(p===void 0)break;p.object?p.ranges.set(p.key,[p.from,n.length]):p.index++,c();let A=e.charCodeAt(i);if(A===(p.object?125:93))i++,r.pop();else{if(A!==44)throw new gm(i);i++,c(),o=`${p.pointer}/${p.index}`,s=p.object?1:0}}if(c(),i!==a)throw new gm(i);return t}function ITe(e,t,n,r){let a=Math.min(Math.max(t,0),e.length);for(let i=0;i<a;i++){let o=e.charCodeAt(i);o===13?(n++,r=1):o===10?(i===0||e.charCodeAt(i-1)!==13)&&(n++,r=1):r++}return[n,r]}function $0r(e,t,n,r){let a=/\bposition (\d+)\b/.exec(e);if(a)return ITe(t,parseInt(a[1],10),n,r);let i=/\bline (\d+) column (\d+)\b/.exec(e);if(i){let o=parseInt(i[1],10),s=parseInt(i[2],10);return[n+o-1,o===1?r+s-1:s]}if(/unexpected end|end of json input/i.test(e))return ITe(t,t.length,n,r)}function WPt(e,t,n){return new Dr(`${e} (line ${t}, column ${n})`,"syntax",{type:"usecase",line:t,column:n})}function O0r(e,t){let n;try{n=JSON.parse(e)}catch(r){let a=r instanceof Error?r.message:String(r),i=jDe(e);if(i!==e)try{JSON.parse(i)}catch(u){u instanceof Error&&(a=u.message)}let[o,s]=t(),c=$0r(a,i,o,s);if(!c){let u=0;try{HPt(i)}catch(l){l instanceof gm&&(u=l.offset)}c=ITe(i,u,o,s)}throw WPt(`Invalid JSON: ${a}`,c[0],c[1])}if(typeof n!="object"||n===null||Array.isArray(n)){let[r,a]=t();throw WPt("JSON value must have an object root",r,a)}return{value:n,propertyOrder:HPt(e)}}function vQ(e,t){for(let n of e.split("|"))if(n==="WORD")for(let r=1;r<=21;r++)oy[r]|=t;else oy[fNt.indexOf(n)]|=t}function Kl(e){return lA.slice(rd[e],uA[e])}function Mg(e){return[rd[e],uA[e]]}function Wae(e){let[t,n]=a5(lA,rd[
|
|
547
|
+
`;else if(f==="r")b="\r";else if(f==="t")b="\t";else if(f==="u"){let y=e.slice(i,i+4);if(!/^[\dA-Fa-f]{4}$/.test(y))throw new gm(i);b=String.fromCharCode(parseInt(y,16)),i+=4}else throw new gm(h);p&&(A+=b)}throw new gm(i)},l=(p)=>{for(let A=0;A<p.length;A++)if(e[i+A]!==p[A])throw new gm(i+A);i+=p.length},d=()=>{if(e.charCodeAt(i)===45&&i++,e.charCodeAt(i)===48)i++;else if(Pi(e.charCodeAt(i)))for(;Pi(e.charCodeAt(i));)i++;else throw new gm(i);if(e.charCodeAt(i)===46){if(i++,!Pi(e.charCodeAt(i)))throw new gm(i);for(;Pi(e.charCodeAt(i));)i++}if((e.charCodeAt(i)|32)===101){if(i++,(e.charCodeAt(i)===43||e.charCodeAt(i)===45)&&i++,!Pi(e.charCodeAt(i)))throw new gm(i);for(;Pi(e.charCodeAt(i));)i++}};for(c();;)if(s===0){c();let p=e.charCodeAt(i);if(s=2,p===123){i++;let A=[];t.set(o,A),n.push(o),c(),e.charCodeAt(i)===125?i++:(r.push({object:!0,pointer:o,keys:A,ranges:new Map,key:"",from:0,index:0}),s=1)}else if(p===91)i++,c(),e.charCodeAt(i)===93?i++:(r.push({object:!1,pointer:o,keys:[],ranges:new Map,key:"",from:0,index:0}),o+="/0",s=0);else if(p===34)u(!1);else if(p===116)l("true");else if(p===102)l("false");else if(p===110)l("null");else if(p===45||Pi(p))d();else throw new gm(i)}else if(s===1){let p=r[r.length-1];if(e.charCodeAt(i)!==34)throw new gm(i);let A=u(!0),m=p.ranges.get(A);if(m===void 0)p.keys.push(A);else for(let g=m[0];g<m[1];g++)t.delete(n[g]);if(p.key=A,p.from=n.length,c(),e.charCodeAt(i)!==58)throw new gm(i);i++,o=`${p.pointer}/${A.replaceAll("~","~0").replaceAll("/","~1")}`,s=0}else{let p=r[r.length-1];if(p===void 0)break;p.object?p.ranges.set(p.key,[p.from,n.length]):p.index++,c();let A=e.charCodeAt(i);if(A===(p.object?125:93))i++,r.pop();else{if(A!==44)throw new gm(i);i++,c(),o=`${p.pointer}/${p.index}`,s=p.object?1:0}}if(c(),i!==a)throw new gm(i);return t}function ITe(e,t,n,r){let a=Math.min(Math.max(t,0),e.length);for(let i=0;i<a;i++){let o=e.charCodeAt(i);o===13?(n++,r=1):o===10?(i===0||e.charCodeAt(i-1)!==13)&&(n++,r=1):r++}return[n,r]}function $0r(e,t,n,r){let a=/\bposition (\d+)\b/.exec(e);if(a)return ITe(t,parseInt(a[1],10),n,r);let i=/\bline (\d+) column (\d+)\b/.exec(e);if(i){let o=parseInt(i[1],10),s=parseInt(i[2],10);return[n+o-1,o===1?r+s-1:s]}if(/unexpected end|end of json input/i.test(e))return ITe(t,t.length,n,r)}function WPt(e,t,n){return new Dr(`${e} (line ${t}, column ${n})`,"syntax",{type:"usecase",line:t,column:n})}function O0r(e,t){let n;try{n=JSON.parse(e)}catch(r){let a=r instanceof Error?r.message:String(r),i=jDe(e);if(i!==e)try{JSON.parse(i)}catch(u){u instanceof Error&&(a=u.message)}let[o,s]=t(),c=$0r(a,i,o,s);if(!c){let u=0;try{HPt(i)}catch(l){l instanceof gm&&(u=l.offset)}c=ITe(i,u,o,s)}throw WPt(`Invalid JSON: ${a}`,c[0],c[1])}if(typeof n!="object"||n===null||Array.isArray(n)){let[r,a]=t();throw WPt("JSON value must have an object root",r,a)}return{value:n,propertyOrder:HPt(e)}}function vQ(e,t){for(let n of e.split("|"))if(n==="WORD")for(let r=1;r<=21;r++)oy[r]|=t;else oy[fNt.indexOf(n)]|=t}function Kl(e){return lA.slice(rd[e],uA[e])}function Mg(e){return[rd[e],uA[e]]}function Wae(e){let[t,n]=a5(lA,rd[ln]);throw new Dr(`Error parsing usecase diagram: ${e} at ${bNt(lA,rd[ln],uA[ln])}`,"syntax",{type:"usecase",line:t,column:n})}function SNt(e){Wae(`Expecting token of type --> ${e} <-- but found --> '${Kl(ln)}' <--`)}function xu(e){return Nr[ln]!==e&&SNt(fNt[e]),ln++}function Nf(e){let t=e.split("|").map((n,r)=>` ${r+1}. [${n}]`);Wae(`Expecting: one of these possible Token sequences:
|
|
548
548
|
${t.join(`
|
|
549
549
|
`)}
|
|
550
|
-
but found: '${Kl(
|
|
550
|
+
but found: '${Kl(ln)}'`)}function zPt(){let e=Hae.split("|"),t=e.flatMap((a)=>["NEWLINE","IDENTIFIER","PLAIN_STRING","RBRACE"].map((i)=>`${a}, METADATA_START, ${i}`)),n=`STEREOTYPE_START|CLASS_SEPARATOR|IDENTIFIER|${qae}|NEWLINE|EOF`.split("|"),r=e.flatMap((a,i)=>(i===0?["LPAREN","LBRACKET",...n]:n).map((o)=>`${a}, ${o}`));return[xNt,...t,...r,...t].join("|")}function JPt(e){return e>=1&&e<=21}function KPt(e){return e>=1&&e<=34}function kQ(){vNt=uA[ln-1],Nr[ln]===39?ln++:Nr[ln]!==0&&Nf("NEWLINE|EOF")}function zO(e){let t=Nr[e]===36?2:Nr[e]===35?1:0;return[rd[e]+t,uA[e]-t]}function STe(e){let t=zO(e);return{text:lA.slice(t[0],t[1]),type:Nr[e]===36?"markdown":"text",span:t}}function DNt(e){return e.replace(/\W/g,"_")}function LO(){let e=Nr[ln];if(e===35||e===36)return STe(ln++);KPt(e)||Nf(G0r);let t=ln;for(;KPt(Nr[ln]);)ln++;let n=[rd[t],uA[ln-1]];return{text:lA.slice(n[0],n[1]),type:"text",span:n}}function mQ(e){return e===21||e===35}function YPt(){let e=ln;mQ(Nr[ln])||Nf("IDENTIFIER|PLAIN_STRING"),ln++,xu(25);let t=ln,n=Nr[ln];!mQ(n)&&n!==19&&n!==20&&Nf("IDENTIFIER|PLAIN_STRING|TRUE|FALSE"),ln++;let r=zO(e),a=zO(t);return{key:lA.slice(r[0],r[1]),value:n===19?!0:n===20?!1:lA.slice(a[0],a[1]),span:[rd[e],uA[t]],keySpan:r,valueSpan:a}}function q0r(){let e=Nr[ln],t=Nr[ln+1],n=Nr[ln+2];return e===24?mQ(t)||t===39&&(n===39||mQ(n)):e!==39?!1:t===24||mQ(t)||t===39&&(n===39||n===24||mQ(n))}function aRe(){xu(60);let e=[];for(;Nr[ln]===39;)ln++;if(mQ(Nr[ln])){for(e.push(YPt());q0r();){if(Nr[ln]===24)ln++;else{for(;Nr[ln]===39;)ln++;Nr[ln]===24&&ln++}for(;Nr[ln]===39;)ln++;e.push(YPt())}for(Nr[ln]===24&&ln++;Nr[ln]===39;)ln++}return xu(62),e}function iRe(e){return e.map(({key:t,span:n,keySpan:r,valueSpan:a})=>({key:t,span:n,keySpan:r,valueSpan:a}))}function oRe(e,t){do{ln++;let n=xu(21);e.push(Kl(n)),t.push(Mg(n))}while(Nr[ln]===24)}function TNt(e){let t=ln,n=Nr[ln],r={id:"",label:void 0,span:zO(t),generated:n!==21,classes:[],classSpans:[],explicit:!1,nodeSpan:[0,0]};if(n===21){ln++,r.id=Kl(t);let a=Nr[ln];a===65||e&&a===63?(ln++,r.label=LO(),xu(a===65?66:64),r.shape=a===65?"ellipse":"rect"):r.label=STe(t)}else n===35||n===36?(ln++,r.label=STe(t),r.id=DNt(r.label.text)):Nf(Hae);return r}function hae(e){let t=ln,n=TNt(!e);if(e&&(n.shape=void 0),Nr[ln]===60&&(n.metadata=aRe()),Nr[ln]===48){ln++;let r=xu(50);xu(49),n.stereotype=Kl(r).trim(),n.stereotypeSpan=Mg(r)}return Nr[ln]===52&&oRe(n.classes,n.classSpans),n.explicit=!!(n.shape||n.metadata||n.stereotype),n.nodeSpan=[rd[t],uA[ln-1]],n}function sRe(e,t){return{id:e.id,kind:t,label:e.label,span:e.span,generated:e.generated,parent:fae,shape:e.shape,metadata:e.metadata,stereotype:e.stereotype,classes:e.classes}}function ZPt(e,t){return{id:e.id,label:e.label,span:e.span,generated:e.generated,declares:t,classed:e.classes.length>0}}function cRe(e,t){let n={id:e.id,span:e.nodeSpan,idSpan:e.span,labelSpan:e.label.span};return t&&(n.defines=!0),e.stereotypeSpan&&(n.stereotypeSpan=e.stereotypeSpan),e.metadata&&(n.metadata=iRe(e.metadata)),e.classSpans.length>0&&(n.classSpans=e.classSpans),n}function _De(e){if(Nr[ln]<1||Nr[ln]>36)return!1;for(let t=ln+1;;t++){let n=Nr[t];if(n===59||(oy[n]&e)!==0)return!0;if(n<1||n>36)return!1}}function uO(e){let t=uA[e]-rd[e]-(Nr[e]===59?0:1);return Math.max(1,t-1)}function RNt(){let e=ln,t={type:"association",arrowType:0,minlen:1,target:void 0,span:[0,0]};Nr[ln]===21&&Nr[ln+1]===23&&(t.explicitId=Kl(ln),t.explicitIdSpan=Mg(ln),ln+=2);let n=ln,r=Nr[ln++];if(r===47)xu(25),Nr[ln]!==17&&Nr[ln]!==18&&Nf("INCLUDE|EXTEND"),t.type=Nr[ln]===17?"include":"extend",t.label={text:t.type,type:"text",span:Mg(ln)},ln++;else if(r===46)t.type="generalization";else if(r===53)t.minlen=uO(n);else if(r===54)t.arrowType=1,uA[n]-rd[n]===3&&_De(0)?(t.label=LO(),t.minlen=uO(xu(59))):t.minlen=uO(n);else if(r===59)if(t.arrowType=2,uA[n]-rd[n]===2&&_De(BNt)){t.label=LO();let a=Nr[ln];a===53?t.arrowType=0:a===55?t.arrowType=3:a===57?t.arrowType=4:a!==59&&Nf("FORWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|FORWARD_CROSS"),(t.arrowType===0||t.arrowType===2)&&(t.minlen=uO(ln)),ln++}else t.minlen=uO(n);else r===55?t.arrowType=3:r===57?t.arrowType=4:r===56||r===58?(t.arrowType=r===56?5:6,_De(0)&&(t.label=LO(),xu(59))):(ln--,Nf(qae));return t.target=hae(!1),t.span=[rd[e],uA[ln-1]],t}function ty(e){return{kind:e,span:[0,0]}}function MNt(e,t,n,r){let a=n.target;a.explicit&&ed.elements.push(sRe(a,"usecase")),ed.relationships.push({source:ZPt(e,t),target:ZPt(a,a.explicit),span:n.span,id:n.explicitId,idSpan:n.explicitIdSpan,type:n.type,arrowType:n.arrowType,label:n.label,minlen:n.minlen}),r.push(cRe(a,a.explicit));let i=ty("edge");return i.nodes=r,i.edges=[{id:n.explicitId??`edge-${INt++}`,span:i.span}],n.explicitIdSpan&&(i.edges[0].idSpan=n.explicitIdSpan),n.label&&(i.edges[0].labelSpan=n.label.span),i}function FNt(e){let t=ty("node");return t.nodes=e,t}function jNt(e){ln++;let t=[hae(!0)],n;if(Nr[ln]===24)do ln++,t.push(hae(!0));while(Nr[ln]===24);else e&&(oy[Nr[ln]]&rRe)!==0&&(n=RNt());kQ();for(let a of t)ed.elements.push(sRe(a,"actor"));let r=t.map((a)=>cRe(a,!0));return n?MNt(t[0],!0,n,r):FNt(r)}function LNt(e){let t=hae(!1),n=e&&(oy[Nr[ln]]&rRe)!==0?RNt():void 0;kQ(),n||(t.explicit=!0,t.shape??="ellipse"),t.explicit&&ed.elements.push(sRe(t,"usecase"));let r=[cRe(t,t.explicit)];return n?MNt(t,t.explicit,n,r):FNt(r)}function H0r(){ln++;let e=TNt(!0),t={id:e.id,label:e.label,span:e.span,generated:e.generated,classes:e.classes},n=Nr[ln]===60?aRe():void 0;Nr[ln]===52&&oRe(e.classes,e.classSpans),kQ(),ed.boundaries.push(t),fae=t;let r=[];for(;(oy[Nr[ln]]&ENt)!==0;)r.push(PNt(!1));fae=void 0;let a=xu(4);kQ();let i=ty("group");return i.group=t.id,i.idSpan=t.span,i.titleSpan=t.label.span,i.endSpan=Mg(a),i.classSpans=e.classSpans,r.length>0&&(i.children=r),n&&(i.metadata=iRe(n),ed.metadata.push({target:t.id,span:t.span,properties:n,statement:i})),i}function VPt(){let e=ln,t=Nr[ln];for(JPt(t)||t===27?ln++:t===59?(ln++,JPt(Nr[ln])||SNt("WORD"),ln++):Nf("WORD|CSS_IDENTIFIER|MARKERLESS_SOLID"),xu(25),(oy[Nr[ln]]&QTe)===0&&Wae(`Expecting: expecting at least one iteration which starts with one of these possible Token sequences::
|
|
551
551
|
<[${_Nt.replaceAll("|","] ,[")}]>
|
|
552
|
-
but found: '${Kl(cn)}'`);(oy[Nr[cn]]&QTe)!==0;)cn++;return lA.slice(rd[e],uA[cn-1]).replaceAll("\\,",",")}function XPt(){let e=[VPt()];for(;Nr[cn]===24;)cn++,e.push(VPt());return e}function vDe(){let e=[xu(21)];for(;Nr[cn]===24;)cn++,e.push(xu(21));return e}function fre(e){let t=zO(e);return{id:Kl(e),span:t,idSpan:t}}function W0r(){let e=cn,t=Nr[cn],n;if(t===41||t===42||t===40){cn++;let r=Kl(e);t===40?ed.accDescription=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim():t===42?ed.accDescription=r.slice(r.indexOf(":")+1).trim():ed.accTitle=r.slice(r.indexOf(":")+1).trim(),n=ty(t===41?"accTitle":"accDescr")}else if(t===5){cn++;let r=Nr[cn];(r<6||r>10)&&Nf("TD|TB|BT|LR|RL"),ed.direction=r===6?"TB":Kl(cn),cn++,n=ty("direction")}else{if(t===2)return jNt(!0);if(t===3)return H0r();if(t===11){cn++,xu(12);let r=xu(21),a=LO();ed.notes.push({target:Kl(r),span:Mg(r),label:a}),n=ty("note"),n.ref=`note-${QNt++}`,n.refSpan=a.span,n.nodes=[fre(r)]}else if(t===43){cn++;let r=xu(44),a=[],i=[];Nr[cn]===52&&oRe(a,i);let o=rd[e]+4;for(;lA.charCodeAt(o)===32||lA.charCodeAt(o)===9;)o++;let s=o;for(;/\w/.test(lA.charAt(s));)s++;let c={id:lA.slice(o,s),value:{},propertyOrder:new Map,span:[o,s],classes:a};ed.jsons.push(c),Ure.push([c,r]),n=ty("json"),n.nodes=[{id:c.id,span:c.span,idSpan:c.span,defines:!0,classSpans:i}],n.classSpans=i}else if(t===14){cn++;let r=vDe();ed.classDefs.push({ids:r.map(Kl),styles:XPt()}),n=ty("classDef"),n.ref=Kl(r[0]),n.refSpan=Mg(r[0])}else if(t===15){cn++;let r=vDe(),a=vDe();ed.classes.push({targets:r.map((i)=>({id:Kl(i),span:Mg(i)})),classes:a.map(Kl)}),n=ty("classAssign"),n.ref=Kl(a[0]),n.refSpan=Mg(a[0]),n.nodes=r.map(fre)}else if(t===16){cn++;let r=xu(21);ed.styles.push({target:Kl(r),span:Mg(r),styles:XPt()}),n=ty("style"),n.nodes=[fre(r)]}else{let r=Nr[cn+1];if(r===60){(oy[Nr[cn+2]]&CNt)===0&&Nf(zPt()),cn++;let a=fre(e);t!==21&&(a.id=DNt(lA.slice(a.span[0],a.span[1])));let i=aRe();n=ty("metadata"),n.nodes=[a],n.metadata=iRe(i),ed.metadata.push({target:a.id,span:a.span,properties:i,statement:n})}else return(!((oy[r]&kNt)!==0||t===21&&(r===65||r===63))||t===21&&U0r.has(Kl(e).toLowerCase()))&&Nf(zPt()),LNt(!0)}}return kQ(),n}function PNt(e){let t=cn,n=Nr[cn];if(n===39)return cn++,{kind:"blank",span:Mg(t)};if(n===38)return cn++,kQ(),{kind:"comment",span:Mg(t)};let r=e?W0r():n===2?jNt(!1):LNt(!1);if(r.span=[rd[t],vNt],r.edges)for(let a of r.edges)a.span=r.span;return r}function z0r(e,t){lA=e,{types:Nr,starts:rd,ends:uA}=F0r(e),cn=0,ed=L0r(),fae=void 0,Ure=[],INt=0,QNt=0;try{let n=xu(1);kQ();let r=[];for(;(oy[Nr[cn]]&wNt)!==0;)r.push(PNt(!0));Nr[cn]!==0&&Wae(`Redundant input, expecting EOF but found: ${Kl(cn)}`);for(let[a,i]of Ure){let o=O0r(Kl(i),()=>a5(e,rd[i]));a.value=o.value,a.propertyOrder=o.propertyOrder}return N0r(e,ed,Mg(n),r,t)}finally{lA="",Nr=rd=uA=Ure=[]}}function e8t(e){return typeof e=="string"?e:e===null?"null":String(e)}function K0r(e){let t=[],n=[[e.value,"",""]],r=[];for(;n.length>0;){let[a,i,o]=n.pop();if(r.length=0,Array.isArray(a))a.length===0?t.push({key:i,accessibleKey:i,value:"[]"}):a.every((s)=>s===null||typeof s!="object")?a.forEach((s,c)=>t.push({key:c===0?i:"",accessibleKey:i,value:e8t(s)})):a.forEach((s,c)=>r.push([s,`${i}[${c}]`,`${o}/${c}`]));else if(a!==null&&typeof a=="object"){let s=a,c=e.propertyOrder.get(o)??Object.keys(s);c.length===0&&t.push({key:i,accessibleKey:i,value:"{}"});for(let u of c)r.push([Object.prototype.hasOwnProperty.call(s,u)?s[u]:void 0,i?`${i}.${u}`:u,`${o}/${u.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:i,accessibleKey:i,value:e8t(a)});for(let s=r.length-1;s>=0;s--)n.push(r[s])}return t}function dO(...e){return e.filter(Boolean).join(" ")}function Y0r(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?IDe[0]:IDe[e.arrowType]??IDe[2]}function Z0r(e){let t=[],n=[],r=(a)=>{let i=new Map;for(let o of["default",...a]){let s=e.classDefs.get(o);if(s)for(let c of s.styles){let u=c.trim(),l=u.indexOf(":"),d=(l===-1?u:u.slice(0,l)).trim();d&&i.set(d,u)}}return[...i.values()]};for(let a of e.actors.values())t.push({id:a.id,label:a.label,labelType:a.labelType,shape:J0r[a.type],isGroup:!1,padding:10,cssClasses:dO("default","usecase-actor",`usecase-actor-${a.type}`,a.business&&"usecase-business",...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),actorType:a.type,business:a.business,icon:a.icon||void 0,stereotype:a.stereotype||void 0,parentId:a.parentId||void 0});for(let a of e.useCases.values()){let i=a.shape==="ellipse";t.push({id:a.id,label:a.label,labelType:a.labelType,shape:i?a.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:i?20:10,cssClasses:dO("default","usecase-element",`usecase-${a.shape}`,a.business&&"usecase-business",...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),business:a.business,stereotype:a.stereotype||void 0,parentId:a.parentId||void 0})}for(let a of e.notes.values())t.push({id:a.id,label:a.label,labelType:a.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:r([]),noteTarget:a.target});for(let a of e.jsonNodes.values())t.push({id:a.id,label:a.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:dO("default","usecase-json-table",...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),jsonRows:K0r(a)});for(let a of e.systemBoundaries.values())t.push({id:a.id,label:a.label,labelType:a.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:dO("default","system-boundary",`system-boundary-${a.type}`,...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),boundaryType:a.type});for(let a of e.relationships){let i=a.type==="include"||a.type==="extend",[o,s]=Y0r(a),c=a.animate||a.animation!==void 0,u={id:a.id,start:a.source,end:a.target,relationshipType:a.type,pattern:i?"dotted":"solid",arrowTypeStart:o,arrowTypeEnd:s,classes:dO("default","relationship",`relationship-${a.type}`,...a.classes,c&&`edge-animation-${a.animation??"fast"}`),style:[...a.styles],cssCompiledStyles:r(a.classes),animate:a.animate,animation:a.animation,minlen:a.minlen,explicitId:a.explicitId,internal:!1};i?(u.label=a.type,u.labelType="text"):a.type==="association"&&(a.label&&(u.label=a.label),a.labelType&&(u.labelType=a.labelType)),n.push(u)}for(let a of e.notes.values())n.push({id:`${a.id}-edge`,start:a.id,end:a.target,relationshipType:"note",pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",classes:"default relationship relationship-note",style:[],cssCompiledStyles:r([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:n}}function n8t(e,t,n){let r=e.usecase?.[t];return typeof r=="number"&&r>0?Math.min(r,2000):n}function nwr(e){return e.replace(/[&<>\\]/g,(t)=>`&#${t.charCodeAt(0)};`)}function VC(e,t,n,r,a,i=0){return Cn(e&&!t?nwr(e):e,t,n,r,a,i)}function DTe(e,t,n,r){let a=n===1||n===2?1:-1,i=n===1||n===3,o=(i?e.w:e.h)/2,s=0;if(e.kind===0)i?(o=lRe/2+3,s=(PO-e.h)/2):o+=2;else if(e.kind===1){let c=(i?e.h:e.w)/2;o*=Math.sqrt(Math.max(1-(r/c)**2,0))}return i?[t.x+a*o,t.y+s+r]:[t.x+r,t.y+a*o]}function NNt(e,t){let n=t===1||t===3;if(e.kind===0)return n?PO*0.5:lRe*0.6;let r=n?e.h:e.w;return e.kind===1?r*0.6:r-16}function rwr(e,t,n){let r=new Map,a=(i,o,s,c)=>{let u=t[i];if(u.isGroup)return;let l=o[s]-u.x,d=o[s+1]-u.y,p;if(Math.abs(Math.abs(d)-u.h/2)<0.5)p=d<0?0:2;else if(Math.abs(Math.abs(l)-u.w/2)<0.5)p=l<0?3:1;else return;let A=i*4+p,m={route:o,at:s,toward:o[c+(p&1?1:0)]},g=r.get(A);g?g.push(m):r.set(A,[m])};for(let i of e){let o=i.route.length-3;i.src===i.dst||o<3||(a(i.src,i.route,0,3),a(i.dst,i.route,o,o-3))}for(let[i,o]of r){let s=i>>2,c=i&3,u=n[s],l=o.length>1?Math.min(twr,NNt(u,c)/(o.length-1)):0;o.sort((d,p)=>d.toward-p.toward);for(let d=0;d<o.length;d++){let[p,A]=DTe(u,t[s],c,(d-(o.length-1)/2)*l);o[d].route[o[d].at]=p,o[d].route[o[d].at+1]=A}}}function awr(e,t,n,r,a){let i=e-n*qre,o=t-r*qre,s=qre*0.5;return`<path class="pele-marker" d="M${J(e)},${J(t)}L${J(i-r*s)},${J(o+n*s)}L${J(i+r*s)},${J(o-n*s)}Z" fill="var(--_bg)" stroke="${a}" stroke-linejoin="round"/>`}function yre(e){return e==="extension"?qre:Po(e)}function wre(e,t,n,r,a,i,o){return e==="extension"?awr(t,n,r,a,i):es(e,t,n,r,a,i,o)}function iwr(e,t){let n=e.node,r=e.style.shape,a=` fill="none" stroke="var(--_b)"${e.style.line}`,i=-21,o=9,s;return n.actorType==="hollow"?(o=8,s=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${r}/><path d="M-20,-9H20V0H5.5L20,15.5L12,25.5L0,12L-12,25.5L-20,15.5L-5.5,0H-20Z" fill="var(--_bg)" stroke="var(--_b)" stroke-linejoin="round"${r}/>`):n.actorType==="awesome"?s=`<path d="M0,-30A11,11 0 1 1 0,-8A11,11 0 1 1 0,-30ZM-20,25C-20,9 -12,-3 0,-3C12,-3 20,9 20,25C20,28 18,30 15,30H-15C-18,30 -20,28 -20,25Z" fill="var(--_b)"${r}/>`:n.actorType==="icon"?(i=-14,o=12,s=`<rect x="-22" y="-26" width="44" height="44"${Io(NO+r)}/><svg class="pele-icon" data-icon="${kn(n.icon??"")}" x="-14" y="-18" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t?.(n.icon??"")??""}</svg>`):s=`<circle cy="-21" r="9"${NO}${r}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${a}/>`,n.business&&(s+=`<path class="pele-business" d="M${J(0.12*o)},${J(i+0.99*o)}L${J(0.92*o)},${J(i-0.39*o)}"${a}/>`),s}function owr(e,t,n){return xQ(e.direction)?hm(n,(r)=>r8t(e,t,n,r)):r8t(e,t,n,!1)}function r8t(e,t,n,r){let a=Z0r(e),i=n.fontSize??16,o=Math.round(i*0.875),s=Math.round(i*0.8125),c=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),u=n.padding??8,l=n.icons,d=r?"TB":ay(e.direction),p=d==="LR"||d==="RL",A=new Map,m=[],g=[];a.nodes.forEach((P,F)=>A.set(P.id,F));for(let P of a.nodes){let F=vc(P.cssStyles.length>0?P.cssCompiledStyles.concat(P.cssStyles):P.cssCompiledStyles),oe=(F.bold?1:0)|(F.italic?2:0),V=F.fontSize??i,H=P.labelType==="markdown",X=VC(P.stereotype&&`\xAB${P.stereotype}\xBB`,!1,c,s,200,oe),z={node:P,kind:2,style:F,label:X,stereotype:X,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},te;if(P.isGroup){z.kind=4,z.label=VC(P.label,H,c,V,4000,oe);let Y=z.label.height;te=Yl(0,0),te.isGroup=!0,te.padX=hre,te.padBottom=hre,te.padTop=P.boundaryType==="package"?Y+2*SDe+16:Y>0?Y+16:hre,te.minW=z.label.width+2*hre}else{if(P.jsonRows){z.kind=3,z.label=VC(P.label,!1,c,V,4000,oe|1);let Y=0;for(let ne of P.jsonRows){let K=VC(ne.key,!1,c,o,4000,oe),re=VC(ne.value,!1,c,o,260,oe);z.rows.push([K,re]),z.keyW=Math.max(z.keyW,K.width),Y=Math.max(Y,re.width),z.h+=Math.max(K.height,re.height,Math.round(o*1.5))+DDe}z.keyW>0&&(z.keyW+=2*pO),z.headH=Math.max(z.label.height,Math.round(V*1.5))+DDe,z.w=Math.max(z.label.width+2*pO,z.rows.length>0?z.keyW+Y+2*pO:0,72),z.h+=z.headH}else if(P.actorType)z.kind=0,z.label=VC(P.label,H,c,V,140,oe),z.w=Math.max(lRe,z.label.width,X.width),z.h=PO+t8t+X.height+z.label.height;else{z.label=VC(P.label,H,c,P.shape==="note"?o:V,180,oe);let Y=Math.max(z.label.width,X.width),ne=z.label.height+X.height;P.shape==="usecaseEllipse"||P.shape==="usecaseBusiness"?(z.kind=1,z.w=Math.max(Y+2*P.padding+(P.business?16:4),88),z.h=Math.max(ne+28,48)):P.shape==="note"?(z.w=Y+2*P.padding+6,z.h=ne+18):(z.w=Math.max(Y+2*P.padding+12,80),z.h=Math.max(ne+24,44))}te=Yl(z.w,z.h)}te.seq=m.length,m.push(z),g.push(te)}a.nodes.forEach((P,F)=>{g[F].parent=P.parentId!==void 0?A.get(P.parentId)??-1:-1});let h=[],f=[],b=[];for(let P of a.edges){let F=A.get(P.start),oe=A.get(P.end);if(F===void 0||oe===void 0)continue;let V=P.relationshipType==="include"||P.relationshipType==="extend",H=VC(V?`\xAB${P.label}\xBB`:P.label,P.labelType==="markdown",c,o,200);F===oe&&(m[F].loops++,p?g[F].h+=2*(QDe+(H.height>0?H.height+8:0)):g[F].w+=2*(QDe+(H.width>0?H.width+12:0))),b.push(P),f.push(H),h.push({src:F,dst:oe,minlen:P.minlen,labelW:H.width>0?H.width+12:0,labelH:H.height>0?H.height+4:0,route:[],labelX:0,labelY:0})}let y=EQ(g,h,d,{nodeSep:n8t(t,"nodeSpacing",V0r),edgeSep:X0r,rankSep:n8t(t,"rankSpacing",ewr),portSep:20}),w=gE(e.title,c,i,4000),k=w.height>0?w.height+12:0,E=Math.max(y.width,w.width),B=u+(E-y.width)/2,x=u+k;YO(g,h,B,x);let _=Math.ceil(E+2*u),Q=Math.ceil(y.height+k+2*u),U=new Map;for(let P of h)RM(U,P.route);rwr(h,g,m);let O="",R=[],G="";for(let P=0;P<m.length;P++){let F=m[P],oe=g[P],V=F.node,H=_u(V.cssClasses.replace(/^default\s?/,"")),X=kn(V.id),z=F.style.text,te=F.style.shape,Y=nd(F.style),ne=Y||' fill="var(--_m)"',{w:K,h:re}=F;if(F.kind===4){let le=oe.x-oe.w/2,ee=oe.y-oe.h/2;cx(te)&&R.push({box:[le,ee,le+oe.w,ee+oe.h],shape:te});let ce=` fill="var(--_a)"${CQ(te)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${te}`,fe=` class="pele-cluster-label"${ne}${z}`,de;if(V.boundaryType==="package"){let Ae=Math.min(F.label.width+2*SDe+8,oe.w),ue=F.label.height+2*SDe;de=`<rect class="pele-boundary-tab" x="${J(le)}" y="${J(ee)}" width="${J(Ae)}" height="${J(ue)}"${ce}/><rect x="${J(le)}" y="${J(ee+ue)}" width="${J(oe.w)}" height="${J(oe.h-ue)}"${ce}/>`+Xt(F.label,le+Ae/2,ee+ue/2,fe,l)}else de=`<rect x="${J(le)}" y="${J(ee)}" width="${J(oe.w)}" height="${J(oe.h)}"${Io(ce)}/>`+Xt(F.label,swr(oe,F.label.width,U),ee+8+F.label.height/2,fe,l);O+=`<g class="pele-cluster pele-boundary${H}" data-id="${X}">${de}</g>`;continue}let ae,pe;if(F.kind===0){pe="pele-actor";let le=-re/2,ee=le+PO+t8t+F.stereotype.height/2;ae=`<g class="pele-actor-figure" transform="translate(0,${J(le+PO/2)})">${iwr(F,l)}</g>`+Xt(F.stereotype,0,ee,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,l)+Xt(F.label,0,re/2-F.label.height/2,` class="pele-label"${z}`,l)}else if(F.kind===3){pe="pele-json";let le=-K/2,ee=-re/2+F.headH,ce="",fe=`M${J(le)},${J(ee)}H${J(le+K)}`;F.keyW>0&&(fe+=`M${J(le+F.keyW)},${J(ee)}V${J(re/2)}`);for(let[de,Ae]of F.rows){let ue=Math.max(de.height,Ae.height,Math.round(o*1.5))+DDe;ce+=Xt(de,le+pO+de.width/2,ee+ue/2,` class="pele-json-key"${ne}`,l)+cwr(Ae,le+F.keyW+pO,ee+ue/2,` class="pele-json-value"${Y}${z}`,l),ee+=ue}ae=`<rect x="${J(le)}" y="${J(-re/2)}" width="${J(K)}" height="${J(re)}"${Io(NO+te)}/><path class="pele-json-lines" d="${fe}" fill="none" stroke="var(--_b)"${F.style.line}/>`+Xt(F.label,0,-re/2+F.headH/2,` class="pele-label" font-weight="var(--_hw)"${Y}${z}`,l)+`<g font-size="${o}">${ce}</g>`}else{let le=F.stereotype.height/2,ee;if(F.kind===1){if(pe="pele-usecase",ee=`<ellipse rx="${J(K/2)}" ry="${J(re/2)}"${NO}${te}/>`,V.business){let ce=K/2-15,fe=K/2-5,de=(Ae)=>re/2*Math.sqrt(1-(Ae/(K/2))**2);ee+=`<path class="pele-business" d="M${J(ce)},${J(de(ce))}L${J(fe)},${J(-de(fe))}" fill="none" stroke="var(--_b)"${F.style.line}/>`}}else if(V.shape==="note"){pe="pele-note";let ce=K/2,fe=re/2;ee=`<path d="M${J(-ce)},${J(-fe)}H${J(ce-bre)}L${J(ce)},${J(bre-fe)}V${J(fe)}H${J(-ce)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${te}/><path d="M${J(ce-bre)},${J(-fe)}V${J(bre-fe)}H${J(ce)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${F.style.line}/>`}else pe="pele-usecase",ee=`<rect x="${J(-K/2)}" y="${J(-re/2)}" width="${J(K)}" height="${J(re)}"${Io(NO+te)}/>`;ae=ee+Xt(F.stereotype,0,-F.label.height/2,` class="pele-stereotype" font-size="${s}"${ne}`,l)+Xt(F.label,0,le,` class="pele-label"${V.shape==="note"?` font-size="${o}"`:""}${Y}${z}`,l)}G+=`<g class="pele-node ${pe}${H}" data-id="${X}" transform="translate(${J(oe.x)},${J(oe.y)})">${ae}</g>`}let q="",N="",L="",D=new Map;for(let P=0;P<h.length;P++){let F=h[P],oe=b[P],V=f[P],H=oe.style.length>0||oe.cssCompiledStyles.length>0?vc(oe.cssCompiledStyles.concat(oe.style)):void 0,{arrowTypeStart:X,arrowTypeEnd:z}=oe,te;if(F.src===F.dst){let pe=g[F.src],le=m[F.src],ee=D.get(F.src)??0;D.set(F.src,ee+1);let ce=p?2:1,fe=Math.min(NNt(le,ce)/2,8+ee*6),de=QDe+ee*8,[Ae,ue]=DTe(le,pe,ce,-fe),[ie,ke]=DTe(le,pe,ce,fe),xe=Math.hypot(de,fe)||1,Ne=p?fe/xe:de/xe,Ee=p?de/xe:fe/xe,be=yre(X),Be=yre(z),Le=(ge,we,Ce,Me)=>p?`${J(ge+Ce*fe*(Me?1:0))},${J(we+Me)}`:`${J(ge+Me)},${J(we+Ce*fe*(Me?1:0))}`,Ve=p?Ae-Ne*be:Ae+Ne*be,tt=p?ue+Ee*be:ue-Ee*be,Ye=ie+Ne*Be,et=ke+Ee*Be;te={d:`M${J(Ve)},${J(tt)}C${Le(Ae,ue,-1,de)} ${Le(ie,ke,1,de)} ${J(Ye)},${J(et)}`,sx:Ae,sy:ue,sdx:p?Ne:-Ne,sdy:p?-Ee:Ee,ex:ie,ey:ke,edx:-Ne,edy:-Ee},p?(F.labelX=pe.x,F.labelY=Math.max(ue,ke)+de*0.75+6+V.height/2):(F.labelX=Math.max(Ae,ie)+de*0.75+8+V.width/2,F.labelY=pe.y)}else{if(F.route.length<6)continue;te=lx(F.route,void 0,yre(X),yre(z))}let Y=$Te(te.d,[te.sx,te.sy,te.ex,te.ey],R,te.tokens),ne=Y&&OTe(Y,H?.line),K=ne||(H?.stroke?$r(H.stroke):"var(--_l)");if(ne===""){let pe="var(--_bg)";q+=GTe(te.d,wre(X,te.sx,te.sy,te.sdx,te.sdy,pe,pe)+wre(z,te.ex,te.ey,te.edx,te.edy,pe,pe),H?.line)}let re=oe.internal?"2 3":oe.pattern==="dotted"?"5 4":oe.animate?"9 5":"",ae=wre(X,te.sx,te.sy,te.sdx,te.sdy,K)+wre(z,te.ex,te.ey,te.edx,te.edy,K);if(N+=`<g class="pele-edge pele-${oe.relationshipType}${_u(oe.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${kn(oe.id)}"${ne?` stroke="${ne}"`:""}${H?.line??""}><path d="${te.d}"${re?` stroke-dasharray="${re}"`:""}/>`+(Y&&ne?XDe(ae,Y):ae)+"</g>",V.width>0){let{labelX:pe,labelY:le}=F,ee=oe.relationshipType==="include"||oe.relationshipType==="extend";L+=mE(oe.id,V,pe,le,(ee?' fill="var(--_m)"':"")+(H?.text??""),l)}}return{svg:Ni("usecase",_,Q,i,n,e,Xt(w,_/2,u+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+(O?`<g class="pele-clusters">${O}</g>`:"")+BQ(q)+(N?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${N}</g>`:"")+(L?`<g class="pele-edge-labels" font-size="${o}">${L}</g>`:"")+`<g class="pele-nodes">${G}</g>`),width:_,height:Q,links:[]}}function swr(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let a=e.x-e.w/2+6,i=e.x+e.w/2-6,o=r.filter((p)=>p>a&&p<i).sort((p,A)=>p-A);o.push(i);let s=t/2+6,c=e.x,u=1/0,l=0,d=a;for(let p of o){if(p-d>=2*s){let A=Math.min(Math.max(e.x,d+s),p-s);Math.abs(A-e.x)<u&&(u=Math.abs(A-e.x),c=A)}else u===1/0&&p-d>l&&(l=p-d,c=(d+p)/2);d=p}return c}function cwr(e,t,n,r,a){if(e.lines.length<2)return Xt(e,t+e.width/2,n,r,a);let i="";for(let o=0;o<e.lines.length;o++)i+=Xt(e5(e,o),t+e.widths[o]/2,n-e.height/2+XO(e,o),r,a);return i}function dQ(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function TDe(e){return e.map(dQ).sort()}function gwr(e,t){let n=new pwr(e,t),r=-1,a=()=>r===-1?r=n.next():r,i=(A)=>{throw a()===1?co("venn",e,n.start,"",!0):co("venn",e,n.start,`Expecting ${A}, got '${a8t[r]}'`)},o=()=>(r=-1,n.text),s=(A)=>(a()!==A&&i(`'${a8t[A]}'`),o()),c=()=>(a()!==16&&r!==17&&i("'IDENTIFIER', 'STRING'"),o()),u=()=>{let A=[c()];for(;a()===18;)o(),A.push(c());return A},l=(A,m)=>{let g=a()===11?o():void 0,h;if(a()===19&&(o(),h=parseFloat(s(12))),m){if(A.length<2)throw new Dr("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(A)}t.addSubsetData(A,g,h),t.setIndentMode(!0)},d=(A)=>{let m=a();m!==16&&m!==17&&m!==12&&i("'NUMERIC', 'IDENTIFIER', 'STRING'");let g=o(),h=m!==12&&a()===11?o():void 0;t.addTextData(A(),g,h)},p=()=>{let A=u(),m=[];for(;;){let g=s(16);s(19);let h;if(a()===17)h=o();else{let f=[];for(;a()===16||r>=12&&r<=15;)f.push(o());f.length===0&&i(mwr),h=f.join(" ")}if(m.push([g,h]),a()!==18)break;o()}t.addStyleData(A,m)};for(;a()===3;)o();for(s(4);;){let A=a();if(A===2)return;if((A<3||A>10||A===4)&&i(Awr),o(),A===5)t.setDiagramTitle(n.text.slice(6));else if(A===6)l([c()],!1);else if(A===7)l(u(),!0);else if(A===8){let m=u();d(()=>m)}else A===9?d(()=>{let m=t.getCurrentSets();if(!m)throw new Dr("text requires set","semantic",{type:"venn"});return m}):A===10&&p()}}function fwr(e){let t=new Set,n=new Map;for(let a of e)t.add(JSON.stringify([...a.sets].sort())),a.sets.length===1&&n.set(a.sets[0],a.size);let r=[];for(let a of e){if(a.sets.length<3)continue;let i=[...a.sets].sort();for(let o=0;o<i.length-1;o++)for(let s=o+1;s<i.length;s++){let c=[i[o],i[s]],u=JSON.stringify(c);if(t.has(u))continue;t.add(u);let l=n.get(c[0]),d=n.get(c[1]);r.push({sets:c,size:l!==void 0&&d!==void 0?Math.min(l,d)/4:2.5,label:""})}}return r.length>0?[...e,...r]:e}function hwr(e,t,n){if(n>=e+t)return 0;let r=Math.min(e,t);if(n<=Math.abs(e-t))return Math.PI*r*r;let a=e*e*Math.acos((n*n+e*e-t*t)/(2*n*e)),i=t*t*Math.acos((n*n+t*t-e*e)/(2*n*t)),o=0.5*Math.sqrt(Math.max((-n+e+t)*(n+e-t)*(n-e+t)*(n+e+t),0));return a+i-o}function bwr(e,t,n){let r=Math.abs(e-t),a=e+t;if(!(n>0))return a;if(n>=Math.PI*Math.min(e,t)**2)return r;for(let i=0;i<48;i++){let o=(r+a)/2;hwr(e,t,o)>n?r=o:a=o}return(r+a)/2}function i8t(e,t,n,r,a,i){let o=1/0;for(let s of t){let c=e[s],u=r-c.x,l=a-c.y,d=c.r-Math.sqrt(u*u+l*l);if(d<o){if(d<i)return d;o=d}}for(let s of n){let c=e[s],u=r-c.x,l=a-c.y,d=Math.sqrt(u*u+l*l)-c.r;if(d<o){if(d<i)return d;o=d}}return o}function TTe(e,t,n){let r=0,a=0,i=e[t[0]];for(let m of t){let g=e[m];r+=g.x/t.length,a+=g.y/t.length,g.r<i.r&&(i=g)}let o=i.r,s=r,c=a,u=i8t(e,t,n,s,c,-1/0),l=0,d=(m,g)=>{let h=i8t(e,t,n,m,g,u-o*0.000000001);if(!(h>u-o*0.000000001))return!1;let f=Math.hypot(m-r,g-a);return h>u+o*0.000000001||f<l-o*0.000000001?(u=h,l=f,s=m,c=g,!0):!1},p=10;for(let m=-p;m<=p;m++)for(let g=-p;g<=p;g++)g*g+m*m<=p*p&&d(i.x+g*o/p,i.y+m*o/p);let A=o/p;for(let m=0;m<40&&A>o*0.000001;m++){let g=!1;for(let h=0;h<8;h++){let f=h*bae/8;d(s+Math.cos(f)*A,c+Math.sin(f)*A)&&(g=!0)}g||(A/=2)}return{x:s,y:c,margin:u}}function ywr(e){let t=new Map;for(let h of e)for(let f of h.sets)t.has(f)||t.set(f,10);for(let h of e)h.sets.length===1&&t.set(h.sets[0],h.size);let n=new Map,r=[],a=0;for(let h of t.values())Number.isFinite(h)&&h>a&&(a=h);a===0&&(a=10);let i=Math.sqrt(a/Math.PI);for(let[h,f]of t){n.set(h,r.length);let b=Number.isFinite(f)&&f>0?Math.sqrt(f/Math.PI):0;r.push({id:h,x:0,y:0,r:Math.max(b,i*0.3)})}let o=r.length;if(o<2)return r;let s=new Map;for(let h of fwr(e)){if(h.sets.length!==2)continue;let f=n.get(h.sets[0]),b=n.get(h.sets[1]);f!==b&&s.set(Math.min(f,b)*o+Math.max(f,b),h.size)}let c=new Map;for(let[h,f]of s)c.set(h,bwr(r[Math.floor(h/o)].r,r[h%o].r,f));let u=i*0.15,l=(h,f)=>c.get(h*o+f)??r[h].r+r[f].r+u;if(o===2)return r[1].x=l(0,1),r;if(o===3){let h=l(0,1),f=l(0,2),b=l(1,2),y=e.some((w)=>new Set(w.sets).size===3);for(let w=0;w<40;w++){let k=h>0?(h*h+f*f-b*b)/(2*h):0;if(r[1].x=h,r[2].x=Math.max(-f,Math.min(f,k)),r[2].y=Math.sqrt(Math.max(f*f-k*k,0)),!y||TTe(r,[0,1,2],[]).margin>i*0.12)break;h*=0.94,f*=0.94,b*=0.94}return r}let d=0;for(let h of r)d+=2*h.r+u;let p=Math.min(300,Math.floor(3000000/(o*o)));if(o<=64){let h=d/bae;r.forEach((f,b)=>{let y=b*bae/o-Math.PI/2;f.x=Math.cos(y)*h,f.y=Math.sin(y)*h})}else{let h=Math.ceil(Math.sqrt(o)),f=2*i+u;r.forEach((b,y)=>{b.x=y%h*f,b.y=Math.floor(y/h)*f})}let A=new Float64Array(o),m=new Float64Array(o),g=new Int32Array(o);for(let h=0;h<p;h++){A.fill(0),m.fill(0),g.fill(0);for(let f=0;f<o;f++)for(let b=f+1;b<o;b++){let y=c.get(f*o+b),w=r[f].r+r[b].r+u,k=r[b].x-r[f].x,E=r[b].y-r[f].y,B=Math.hypot(k,E);if(y===void 0&&B>=w)continue;B<0.000000001&&(k=Math.cos(f+b),E=Math.sin(f+b),B=1);let x=(B-(y??w))/2/B;A[f]+=k*x,m[f]+=E*x,A[b]-=k*x,m[b]-=E*x,g[f]++,g[b]++}for(let f=0;f<o;f++)g[f]!==0&&(r[f].x+=A[f]/g[f],r[f].y+=m[f]/g[f])}return r}function wwr(e,t){let n=(c)=>`M${t(c.x-c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x+c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x-c.r)},${t(c.y)}Z`;if(e.length===1)return n(e[0]);let r=(c,u,l,d)=>{for(let p of e)if(p!==l&&p!==d&&Math.hypot(c-p.x,u-p.y)>p.r*1.000000001)return!1;return!0},a=[];for(let c=0;c<e.length;c++)for(let u=c+1;u<e.length;u++){let l=e[c],d=e[u],p=Math.hypot(d.x-l.x,d.y-l.y);if(p>=l.r+d.r||p<=Math.abs(l.r-d.r)||p===0)continue;let A=(l.r*l.r-d.r*d.r+p*p)/(2*p),m=Math.sqrt(Math.max(l.r*l.r-A*A,0)),g=l.x+(d.x-l.x)*A/p,h=l.y+(d.y-l.y)*A/p;for(let f of[1,-1]){let b=g+f*m*(d.y-l.y)/p,y=h-f*m*(d.x-l.x)/p;r(b,y,l,d)&&a.push({x:b,y,a:l,b:d})}}if(a.length<2){let c=e[0];for(let u of e)u.r<c.r&&(c=u);for(let u of e)if(u!==c&&Math.hypot(u.x-c.x,u.y-c.y)+c.r>u.r*1.000000001)return"";return n(c)}let i=0,o=0;for(let c of a)i+=c.x/a.length,o+=c.y/a.length;a.sort((c,u)=>Math.atan2(c.y-o,c.x-i)-Math.atan2(u.y-o,u.x-i));let s="";for(let c=0;c<a.length;c++){let u=a[c],l=a[(c+1)%a.length];c===0&&(s=`M${t(u.x)},${t(u.y)}`);let d,p=0,A=1/0;for(let m of[u.a,u.b]){if(m!==l.a&&m!==l.b)continue;let g=Math.atan2(u.y-m.y,u.x-m.x),h=Math.atan2(l.y-m.y,l.x-m.x)-g;h<=0&&(h+=bae);let f=m.x+m.r*Math.cos(g+h/2),b=m.y+m.r*Math.sin(g+h/2),y=Math.hypot(f-(u.x+l.x)/2,b-(u.y+l.y)/2);y<A&&(A=y,d=m,p=h>Math.PI?1:0)}d===void 0?s+=`L${t(l.x)},${t(l.y)}`:s+=`A${t(d.r)},${t(d.r)} 0 ${p} 1 ${t(l.x)},${t(l.y)}`}return s+"Z"}function RDe(e){return e.length===1?e[0]:JSON.stringify(e)}function Bwr(e,t,n){let r=n.fontSize??16,a=Math.round(r*0.875),i=Math.round(r*0.8125),o=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),s=n.padding??8,c=ywr(e.subsets),u=new Map;c.forEach((P,F)=>u.set(P.id,F));let l=new Map;for(let{targets:P,styles:F}of e.styles){let oe=RDe(P),V=l.get(oe);V||l.set(oe,V=new Map);for(let[H,X]of F)V.set(H,X)}let d=(P)=>{let F=l.get(P);if(!F)return o8t;let oe=[];for(let[V,H]of F)oe.push(`${V}:${H}`);return vc(oe)},p=c.map(()=>[]);for(let P=0;P<c.length;P++)for(let F=P+1;F<c.length;F++)Math.hypot(c[P].x-c[F].x,c[P].y-c[F].y)<c[P].r+c[F].r&&(p[P].push(F),p[F].push(P));let A=new Map;for(let P of e.subsets)A.set(RDe(P.sets),P);let m=new Map;for(let[P,F]of A){let oe=[...new Set(F.sets)],V=oe.map((pe)=>u.get(pe)),H=new Set(V),X=V[0];for(let pe of V)c[pe].r<c[X].r&&(X=pe);let z=d(P),te=F.label??(F.sets.length===1?F.sets[0]:void 0),Y=(z.bold?1:0)|(z.italic?2:0),ne=p[X].filter((pe)=>!H.has(pe)),K=TTe(c,V,ne),re=ne.length>0&&K.margin<c[X].r*0.2;re&&(K=TTe(c,V,[]));let ae={sets:oe,inside:V,spot:K,lines:[],style:z,across:re};if(te){let pe=oe.length===1?r:a;ae.lines.push({id:void 0,raw:te,size:pe,base:Y,label:Cn(te,!1,o,pe,4000,Y)})}m.set(P,ae)}for(let P of e.textNodes){let F=P.label??P.id;m.get(RDe(P.sets))?.lines.push({id:P.id,raw:F,size:i,base:0,label:Cn(F,!1,o,i,4000)})}let g=0;for(let P of c)P.r>g&&(g=P.r);let h=g>0?kwr/g:1,f=1;for(let P of m.values()){if(P.spot.margin<=0)continue;let F=0,oe=0;for(let H of P.lines)F=Math.max(F,H.label.width),oe+=H.label.height;let V=Math.hypot(F,oe)/2+4;f=Math.max(f,Math.min(V/(P.spot.margin*h),Ewr))}h*=f;for(let P of m.values()){let F=Math.max(P.spot.margin*h*1.8,72);for(let oe of P.lines)oe.label.width>F&&(oe.label=Cn(oe.raw,!1,o,oe.size,F,oe.base))}let b=1/0,y=1/0,w=-1/0,k=-1/0;for(let P of c)b=Math.min(b,(P.x-P.r)*h),y=Math.min(y,(P.y-P.r)*h),w=Math.max(w,(P.x+P.r)*h),k=Math.max(k,(P.y+P.r)*h);for(let P of m.values()){let F=0,oe=0;for(let V of P.lines)F=Math.max(F,V.label.width),oe+=V.label.height;b=Math.min(b,P.spot.x*h-F/2),w=Math.max(w,P.spot.x*h+F/2),y=Math.min(y,P.spot.y*h-oe/2),k=Math.max(k,P.spot.y*h+oe/2)}c.length===0&&(b=y=w=k=0);let E=Cn(e.title&&dQ(e.title),!1,o,r,4000,1),B=E.height>0?E.height+12:0,x=Math.max(w-b,E.width),_=s+(x-(w-b))/2-b,Q=s+B-y,U=Math.ceil(x+2*s),O=Math.ceil(k-y+B+2*s),R=c.map((P)=>({id:P.id,x:P.x*h+_,y:P.y*h+Q,r:P.r*h})),G="";R.forEach((P,F)=>{let oe=ho(F),V=m.get(P.id)?.style??o8t;G+=`<circle class="pele-venn-set" data-id="${kn(P.id)}" cx="${J(P.x)}" cy="${J(P.y)}" r="${J(P.r)}" fill="${oe}" fill-opacity="0.2" stroke="${oe}"${V.shape}/>`});let q=[...m.values()].filter((P)=>P.sets.length>1&&P.style.shape!==""),N=(P)=>{if(P.across)return"";let F=P.sets.length===1&&/[";]fill-opacity:/.test(P.style.shape)?P.style.shape:"";for(let oe of q)oe.sets.every((V)=>P.sets.includes(V))&&(F=oe.style.shape);return F},L="",D="";for(let P of m.values()){let F=kn(P.sets.join("|"));if(P.sets.length>1&&P.style.shape!==""){let te=wwr(P.inside.map((Y)=>R[Y]),J);te!==""&&(L+=`<path class="pele-venn-overlap" data-id="${F}" d="${te}" fill="none"${P.style.shape}/>`)}let oe=0;for(let te of P.lines)oe+=te.label.height;if(oe===0)continue;let V=P.spot.x*h+_,H=P.spot.y*h+Q-oe/2,X=N(P),z="";for(let te of P.lines){let Y=te.id===void 0?P.style.text:d(te.id).text,ne=NM(X,Y),K=te.id===void 0?` class="pele-label"${te.size===r?"":` font-size="${te.size}"`}${ne?` fill="${ne}"`:""}${Y}`:` class="pele-venn-text" data-id="${kn(te.id)}" font-size="${i}" fill="${ne??"var(--_m)"}"${Y}`;z+=Xt(te.label,V,H+te.label.height/2,K),H+=te.label.height}D+=`<g class="pele-venn-region" data-id="${F}">${z}</g>`}return{svg:Ni("venn",U,O,r,n,{},Xt(E,U/2,s+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${G}</g>`+(L?`<g class="pele-venn-overlaps">${L}</g>`:"")+(D?`<g class="pele-venn-labels">${D}</g>`:"")),width:U,height:O,links:[]}}function yae(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new Dr(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,"semantic",{type:"wardley"});return n}function oQ(e,t,n){return{x:yae(t,`${n} evolution`),y:yae(e,`${n} visibility`)}}function s8t(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function _wr(e){if(!e?.startsWith("+"))return{};let t=e.indexOf("'",2),n=e[1]==="'"&&t!==-1?e.slice(2,t):void 0;return e.includes("<>")?{flow:"bidirectional",label:n}:e.includes("<")?{flow:"backward",label:n}:e.includes(">")?{flow:"forward",label:n}:{label:n}}function c8t(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function vwr(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map((n)=>n.secondName?`${n.name.trim()} / ${n.secondName.trim()}`:n.name.trim()),stageBoundaries:e.evolution.stages.filter((n)=>n.boundary!==void 0).map((n)=>n.boundary)});for(let n of e.anchors){let r=oQ(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"anchor"})}for(let n of e.components){let r=oQ(n.visibility,n.evolution,`Component "${n.name}"`),[a,i]=c8t(n.label);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"component",labelOffsetX:a,labelOffsetY:i,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let r=oQ(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:r.x,y:r.y})}for(let n of e.pipelines){let r=t.getNode(n.parent);if(!r||typeof r.y!="number")throw new Dr(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let a=r.y;t.startPipeline(n.parent);for(let i of n.components){let o=`${n.parent}_${i.name}`,[s,c]=c8t(i.label),u=yae(i.evolution,`Pipeline component "${i.name}" evolution`);t.addNode({id:o,label:i.name,x:u,y:a,className:"pipeline-component",labelOffsetX:s,labelOffsetY:c,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,o)}}for(let n of e.links){let r=!!n.arrow&&(n.arrow.includes("-.->")||n.arrow.includes(".-.")),a=_wr(n.arrow),i=s8t(n.fromPort)??s8t(n.toPort)??a.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:r,label:a.label??n.linkLabel,flow:i})}for(let n of e.evolves){let r=t.getNode(n.component);r?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:yae(n.target,`Evolve target for "${n.component}"`),targetY:r.y})}if(e.annotations.length>0){let n=oQ(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let r=oQ(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:r.x,y:r.y}],text:n.text})}for(let n of e.accelerators){let r=oQ(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:r.x,y:r.y})}for(let n of e.deaccelerators){let r=oQ(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:r.x,y:r.y})}}function Iwr(e,t){let n=new xwr;return vwr(e,n),{type:"wardley",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
552
|
+
but found: '${Kl(ln)}'`);(oy[Nr[ln]]&QTe)!==0;)ln++;return lA.slice(rd[e],uA[ln-1]).replaceAll("\\,",",")}function XPt(){let e=[VPt()];for(;Nr[ln]===24;)ln++,e.push(VPt());return e}function vDe(){let e=[xu(21)];for(;Nr[ln]===24;)ln++,e.push(xu(21));return e}function fre(e){let t=zO(e);return{id:Kl(e),span:t,idSpan:t}}function W0r(){let e=ln,t=Nr[ln],n;if(t===41||t===42||t===40){ln++;let r=Kl(e);t===40?ed.accDescription=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim():t===42?ed.accDescription=r.slice(r.indexOf(":")+1).trim():ed.accTitle=r.slice(r.indexOf(":")+1).trim(),n=ty(t===41?"accTitle":"accDescr")}else if(t===5){ln++;let r=Nr[ln];(r<6||r>10)&&Nf("TD|TB|BT|LR|RL"),ed.direction=r===6?"TB":Kl(ln),ln++,n=ty("direction")}else{if(t===2)return jNt(!0);if(t===3)return H0r();if(t===11){ln++,xu(12);let r=xu(21),a=LO();ed.notes.push({target:Kl(r),span:Mg(r),label:a}),n=ty("note"),n.ref=`note-${QNt++}`,n.refSpan=a.span,n.nodes=[fre(r)]}else if(t===43){ln++;let r=xu(44),a=[],i=[];Nr[ln]===52&&oRe(a,i);let o=rd[e]+4;for(;lA.charCodeAt(o)===32||lA.charCodeAt(o)===9;)o++;let s=o;for(;/\w/.test(lA.charAt(s));)s++;let c={id:lA.slice(o,s),value:{},propertyOrder:new Map,span:[o,s],classes:a};ed.jsons.push(c),Ure.push([c,r]),n=ty("json"),n.nodes=[{id:c.id,span:c.span,idSpan:c.span,defines:!0,classSpans:i}],n.classSpans=i}else if(t===14){ln++;let r=vDe();ed.classDefs.push({ids:r.map(Kl),styles:XPt()}),n=ty("classDef"),n.ref=Kl(r[0]),n.refSpan=Mg(r[0])}else if(t===15){ln++;let r=vDe(),a=vDe();ed.classes.push({targets:r.map((i)=>({id:Kl(i),span:Mg(i)})),classes:a.map(Kl)}),n=ty("classAssign"),n.ref=Kl(a[0]),n.refSpan=Mg(a[0]),n.nodes=r.map(fre)}else if(t===16){ln++;let r=xu(21);ed.styles.push({target:Kl(r),span:Mg(r),styles:XPt()}),n=ty("style"),n.nodes=[fre(r)]}else{let r=Nr[ln+1];if(r===60){(oy[Nr[ln+2]]&CNt)===0&&Nf(zPt()),ln++;let a=fre(e);t!==21&&(a.id=DNt(lA.slice(a.span[0],a.span[1])));let i=aRe();n=ty("metadata"),n.nodes=[a],n.metadata=iRe(i),ed.metadata.push({target:a.id,span:a.span,properties:i,statement:n})}else return(!((oy[r]&kNt)!==0||t===21&&(r===65||r===63))||t===21&&U0r.has(Kl(e).toLowerCase()))&&Nf(zPt()),LNt(!0)}}return kQ(),n}function PNt(e){let t=ln,n=Nr[ln];if(n===39)return ln++,{kind:"blank",span:Mg(t)};if(n===38)return ln++,kQ(),{kind:"comment",span:Mg(t)};let r=e?W0r():n===2?jNt(!1):LNt(!1);if(r.span=[rd[t],vNt],r.edges)for(let a of r.edges)a.span=r.span;return r}function z0r(e,t){lA=e,{types:Nr,starts:rd,ends:uA}=F0r(e),ln=0,ed=L0r(),fae=void 0,Ure=[],INt=0,QNt=0;try{let n=xu(1);kQ();let r=[];for(;(oy[Nr[ln]]&wNt)!==0;)r.push(PNt(!0));Nr[ln]!==0&&Wae(`Redundant input, expecting EOF but found: ${Kl(ln)}`);for(let[a,i]of Ure){let o=O0r(Kl(i),()=>a5(e,rd[i]));a.value=o.value,a.propertyOrder=o.propertyOrder}return N0r(e,ed,Mg(n),r,t)}finally{lA="",Nr=rd=uA=Ure=[]}}function e8t(e){return typeof e=="string"?e:e===null?"null":String(e)}function K0r(e){let t=[],n=[[e.value,"",""]],r=[];for(;n.length>0;){let[a,i,o]=n.pop();if(r.length=0,Array.isArray(a))a.length===0?t.push({key:i,accessibleKey:i,value:"[]"}):a.every((s)=>s===null||typeof s!="object")?a.forEach((s,c)=>t.push({key:c===0?i:"",accessibleKey:i,value:e8t(s)})):a.forEach((s,c)=>r.push([s,`${i}[${c}]`,`${o}/${c}`]));else if(a!==null&&typeof a=="object"){let s=a,c=e.propertyOrder.get(o)??Object.keys(s);c.length===0&&t.push({key:i,accessibleKey:i,value:"{}"});for(let u of c)r.push([Object.prototype.hasOwnProperty.call(s,u)?s[u]:void 0,i?`${i}.${u}`:u,`${o}/${u.replaceAll("~","~0").replaceAll("/","~1")}`])}else t.push({key:i,accessibleKey:i,value:e8t(a)});for(let s=r.length-1;s>=0;s--)n.push(r[s])}return t}function dO(...e){return e.filter(Boolean).join(" ")}function Y0r(e){return e.type==="generalization"?["none","extension"]:e.type!=="association"?IDe[0]:IDe[e.arrowType]??IDe[2]}function Z0r(e){let t=[],n=[],r=(a)=>{let i=new Map;for(let o of["default",...a]){let s=e.classDefs.get(o);if(s)for(let c of s.styles){let u=c.trim(),l=u.indexOf(":"),d=(l===-1?u:u.slice(0,l)).trim();d&&i.set(d,u)}}return[...i.values()]};for(let a of e.actors.values())t.push({id:a.id,label:a.label,labelType:a.labelType,shape:J0r[a.type],isGroup:!1,padding:10,cssClasses:dO("default","usecase-actor",`usecase-actor-${a.type}`,a.business&&"usecase-business",...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),actorType:a.type,business:a.business,icon:a.icon||void 0,stereotype:a.stereotype||void 0,parentId:a.parentId||void 0});for(let a of e.useCases.values()){let i=a.shape==="ellipse";t.push({id:a.id,label:a.label,labelType:a.labelType,shape:i?a.business?"usecaseBusiness":"usecaseEllipse":"rect",isGroup:!1,padding:i?20:10,cssClasses:dO("default","usecase-element",`usecase-${a.shape}`,a.business&&"usecase-business",...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),business:a.business,stereotype:a.stereotype||void 0,parentId:a.parentId||void 0})}for(let a of e.notes.values())t.push({id:a.id,label:a.label,labelType:a.labelType,shape:"note",isGroup:!1,padding:10,cssClasses:"default usecase-note",cssStyles:[],cssCompiledStyles:r([]),noteTarget:a.target});for(let a of e.jsonNodes.values())t.push({id:a.id,label:a.id,labelType:"text",shape:"usecaseJsonTable",isGroup:!1,padding:10,cssClasses:dO("default","usecase-json-table",...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),jsonRows:K0r(a)});for(let a of e.systemBoundaries.values())t.push({id:a.id,label:a.label,labelType:a.labelType,shape:"usecaseSystemBoundary",isGroup:!0,padding:20,cssClasses:dO("default","system-boundary",`system-boundary-${a.type}`,...a.classes),cssStyles:[...a.styles],cssCompiledStyles:r(a.classes),boundaryType:a.type});for(let a of e.relationships){let i=a.type==="include"||a.type==="extend",[o,s]=Y0r(a),c=a.animate||a.animation!==void 0,u={id:a.id,start:a.source,end:a.target,relationshipType:a.type,pattern:i?"dotted":"solid",arrowTypeStart:o,arrowTypeEnd:s,classes:dO("default","relationship",`relationship-${a.type}`,...a.classes,c&&`edge-animation-${a.animation??"fast"}`),style:[...a.styles],cssCompiledStyles:r(a.classes),animate:a.animate,animation:a.animation,minlen:a.minlen,explicitId:a.explicitId,internal:!1};i?(u.label=a.type,u.labelType="text"):a.type==="association"&&(a.label&&(u.label=a.label),a.labelType&&(u.labelType=a.labelType)),n.push(u)}for(let a of e.notes.values())n.push({id:`${a.id}-edge`,start:a.id,end:a.target,relationshipType:"note",pattern:"dotted",arrowTypeStart:"none",arrowTypeEnd:"none",classes:"default relationship relationship-note",style:[],cssCompiledStyles:r([]),animate:!1,minlen:1,explicitId:!1,internal:!0});return{nodes:t,edges:n}}function n8t(e,t,n){let r=e.usecase?.[t];return typeof r=="number"&&r>0?Math.min(r,2000):n}function nwr(e){return e.replace(/[&<>\\]/g,(t)=>`&#${t.charCodeAt(0)};`)}function VC(e,t,n,r,a,i=0){return Cn(e&&!t?nwr(e):e,t,n,r,a,i)}function DTe(e,t,n,r){let a=n===1||n===2?1:-1,i=n===1||n===3,o=(i?e.w:e.h)/2,s=0;if(e.kind===0)i?(o=lRe/2+3,s=(PO-e.h)/2):o+=2;else if(e.kind===1){let c=(i?e.h:e.w)/2;o*=Math.sqrt(Math.max(1-(r/c)**2,0))}return i?[t.x+a*o,t.y+s+r]:[t.x+r,t.y+a*o]}function NNt(e,t){let n=t===1||t===3;if(e.kind===0)return n?PO*0.5:lRe*0.6;let r=n?e.h:e.w;return e.kind===1?r*0.6:r-16}function rwr(e,t,n){let r=new Map,a=(i,o,s,c)=>{let u=t[i];if(u.isGroup)return;let l=o[s]-u.x,d=o[s+1]-u.y,p;if(Math.abs(Math.abs(d)-u.h/2)<0.5)p=d<0?0:2;else if(Math.abs(Math.abs(l)-u.w/2)<0.5)p=l<0?3:1;else return;let A=i*4+p,m={route:o,at:s,toward:o[c+(p&1?1:0)]},g=r.get(A);g?g.push(m):r.set(A,[m])};for(let i of e){let o=i.route.length-3;i.src===i.dst||o<3||(a(i.src,i.route,0,3),a(i.dst,i.route,o,o-3))}for(let[i,o]of r){let s=i>>2,c=i&3,u=n[s],l=o.length>1?Math.min(twr,NNt(u,c)/(o.length-1)):0;o.sort((d,p)=>d.toward-p.toward);for(let d=0;d<o.length;d++){let[p,A]=DTe(u,t[s],c,(d-(o.length-1)/2)*l);o[d].route[o[d].at]=p,o[d].route[o[d].at+1]=A}}}function awr(e,t,n,r,a){let i=e-n*qre,o=t-r*qre,s=qre*0.5;return`<path class="pele-marker" d="M${J(e)},${J(t)}L${J(i-r*s)},${J(o+n*s)}L${J(i+r*s)},${J(o-n*s)}Z" fill="var(--_bg)" stroke="${a}" stroke-linejoin="round"/>`}function yre(e){return e==="extension"?qre:Po(e)}function wre(e,t,n,r,a,i,o){return e==="extension"?awr(t,n,r,a,i):es(e,t,n,r,a,i,o)}function iwr(e,t){let n=e.node,r=e.style.shape,a=` fill="none" stroke="var(--_b)"${e.style.line}`,i=-21,o=9,s;return n.actorType==="hollow"?(o=8,s=`<circle cy="-21" r="8" fill="var(--_bg)" stroke="var(--_b)"${r}/><path d="M-20,-9H20V0H5.5L20,15.5L12,25.5L0,12L-12,25.5L-20,15.5L-5.5,0H-20Z" fill="var(--_bg)" stroke="var(--_b)" stroke-linejoin="round"${r}/>`):n.actorType==="awesome"?s=`<path d="M0,-30A11,11 0 1 1 0,-8A11,11 0 1 1 0,-30ZM-20,25C-20,9 -12,-3 0,-3C12,-3 20,9 20,25C20,28 18,30 15,30H-15C-18,30 -20,28 -20,25Z" fill="var(--_b)"${r}/>`:n.actorType==="icon"?(i=-14,o=12,s=`<rect x="-22" y="-26" width="44" height="44"${Io(NO+r)}/><svg class="pele-icon" data-icon="${kn(n.icon??"")}" x="-14" y="-18" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t?.(n.icon??"")??""}</svg>`):s=`<circle cy="-21" r="9"${NO}${r}/><path d="M0,-12V10M-14,-3H14M0,10L-12,30M0,10L12,30"${a}/>`,n.business&&(s+=`<path class="pele-business" d="M${J(0.12*o)},${J(i+0.99*o)}L${J(0.92*o)},${J(i-0.39*o)}"${a}/>`),s}function owr(e,t,n){return xQ(e.direction)?hm(n,(r)=>r8t(e,t,n,r)):r8t(e,t,n,!1)}function r8t(e,t,n,r){let a=Z0r(e),i=n.fontSize??16,o=Math.round(i*0.875),s=Math.round(i*0.8125),c=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),u=n.padding??8,l=n.icons,d=r?"TB":ay(e.direction),p=d==="LR"||d==="RL",A=new Map,m=[],g=[];a.nodes.forEach((P,F)=>A.set(P.id,F));for(let P of a.nodes){let F=vc(P.cssStyles.length>0?P.cssCompiledStyles.concat(P.cssStyles):P.cssCompiledStyles),oe=(F.bold?1:0)|(F.italic?2:0),V=F.fontSize??i,H=P.labelType==="markdown",X=VC(P.stereotype&&`\xAB${P.stereotype}\xBB`,!1,c,s,200,oe),z={node:P,kind:2,style:F,label:X,stereotype:X,w:0,h:0,rows:[],keyW:0,headH:0,loops:0},te;if(P.isGroup){z.kind=4,z.label=VC(P.label,H,c,V,4000,oe);let Y=z.label.height;te=Yl(0,0),te.isGroup=!0,te.padX=hre,te.padBottom=hre,te.padTop=P.boundaryType==="package"?Y+2*SDe+16:Y>0?Y+16:hre,te.minW=z.label.width+2*hre}else{if(P.jsonRows){z.kind=3,z.label=VC(P.label,!1,c,V,4000,oe|1);let Y=0;for(let ne of P.jsonRows){let K=VC(ne.key,!1,c,o,4000,oe),re=VC(ne.value,!1,c,o,260,oe);z.rows.push([K,re]),z.keyW=Math.max(z.keyW,K.width),Y=Math.max(Y,re.width),z.h+=Math.max(K.height,re.height,Math.round(o*1.5))+DDe}z.keyW>0&&(z.keyW+=2*pO),z.headH=Math.max(z.label.height,Math.round(V*1.5))+DDe,z.w=Math.max(z.label.width+2*pO,z.rows.length>0?z.keyW+Y+2*pO:0,72),z.h+=z.headH}else if(P.actorType)z.kind=0,z.label=VC(P.label,H,c,V,140,oe),z.w=Math.max(lRe,z.label.width,X.width),z.h=PO+t8t+X.height+z.label.height;else{z.label=VC(P.label,H,c,P.shape==="note"?o:V,180,oe);let Y=Math.max(z.label.width,X.width),ne=z.label.height+X.height;P.shape==="usecaseEllipse"||P.shape==="usecaseBusiness"?(z.kind=1,z.w=Math.max(Y+2*P.padding+(P.business?16:4),88),z.h=Math.max(ne+28,48)):P.shape==="note"?(z.w=Y+2*P.padding+6,z.h=ne+18):(z.w=Math.max(Y+2*P.padding+12,80),z.h=Math.max(ne+24,44))}te=Yl(z.w,z.h)}te.seq=m.length,m.push(z),g.push(te)}a.nodes.forEach((P,F)=>{g[F].parent=P.parentId!==void 0?A.get(P.parentId)??-1:-1});let h=[],f=[],b=[];for(let P of a.edges){let F=A.get(P.start),oe=A.get(P.end);if(F===void 0||oe===void 0)continue;let V=P.relationshipType==="include"||P.relationshipType==="extend",H=VC(V?`\xAB${P.label}\xBB`:P.label,P.labelType==="markdown",c,o,200);F===oe&&(m[F].loops++,p?g[F].h+=2*(QDe+(H.height>0?H.height+8:0)):g[F].w+=2*(QDe+(H.width>0?H.width+12:0))),b.push(P),f.push(H),h.push({src:F,dst:oe,minlen:P.minlen,labelW:H.width>0?H.width+12:0,labelH:H.height>0?H.height+4:0,route:[],labelX:0,labelY:0})}let y=EQ(g,h,d,{nodeSep:n8t(t,"nodeSpacing",V0r),edgeSep:X0r,rankSep:n8t(t,"rankSpacing",ewr),portSep:20}),w=gE(e.title,c,i,4000),k=w.height>0?w.height+12:0,E=Math.max(y.width,w.width),B=u+(E-y.width)/2,x=u+k;YO(g,h,B,x);let _=Math.ceil(E+2*u),Q=Math.ceil(y.height+k+2*u),U=new Map;for(let P of h)RM(U,P.route);rwr(h,g,m);let O="",R=[],G="";for(let P=0;P<m.length;P++){let F=m[P],oe=g[P],V=F.node,H=_u(V.cssClasses.replace(/^default\s?/,"")),X=kn(V.id),z=F.style.text,te=F.style.shape,Y=nd(F.style),ne=Y||' fill="var(--_m)"',{w:K,h:re}=F;if(F.kind===4){let le=oe.x-oe.w/2,ee=oe.y-oe.h/2;cx(te)&&R.push({box:[le,ee,le+oe.w,ee+oe.h],shape:te});let ce=` fill="var(--_a)"${CQ(te)?"":' fill-opacity="0.5"'} stroke="var(--_b)"${te}`,fe=` class="pele-cluster-label"${ne}${z}`,de;if(V.boundaryType==="package"){let Ae=Math.min(F.label.width+2*SDe+8,oe.w),ue=F.label.height+2*SDe;de=`<rect class="pele-boundary-tab" x="${J(le)}" y="${J(ee)}" width="${J(Ae)}" height="${J(ue)}"${ce}/><rect x="${J(le)}" y="${J(ee+ue)}" width="${J(oe.w)}" height="${J(oe.h-ue)}"${ce}/>`+Xt(F.label,le+Ae/2,ee+ue/2,fe,l)}else de=`<rect x="${J(le)}" y="${J(ee)}" width="${J(oe.w)}" height="${J(oe.h)}"${Io(ce)}/>`+Xt(F.label,swr(oe,F.label.width,U),ee+8+F.label.height/2,fe,l);O+=`<g class="pele-cluster pele-boundary${H}" data-id="${X}">${de}</g>`;continue}let ae,pe;if(F.kind===0){pe="pele-actor";let le=-re/2,ee=le+PO+t8t+F.stereotype.height/2;ae=`<g class="pele-actor-figure" transform="translate(0,${J(le+PO/2)})">${iwr(F,l)}</g>`+Xt(F.stereotype,0,ee,` class="pele-stereotype" font-size="${s}" fill="var(--_m)"`,l)+Xt(F.label,0,re/2-F.label.height/2,` class="pele-label"${z}`,l)}else if(F.kind===3){pe="pele-json";let le=-K/2,ee=-re/2+F.headH,ce="",fe=`M${J(le)},${J(ee)}H${J(le+K)}`;F.keyW>0&&(fe+=`M${J(le+F.keyW)},${J(ee)}V${J(re/2)}`);for(let[de,Ae]of F.rows){let ue=Math.max(de.height,Ae.height,Math.round(o*1.5))+DDe;ce+=Xt(de,le+pO+de.width/2,ee+ue/2,` class="pele-json-key"${ne}`,l)+cwr(Ae,le+F.keyW+pO,ee+ue/2,` class="pele-json-value"${Y}${z}`,l),ee+=ue}ae=`<rect x="${J(le)}" y="${J(-re/2)}" width="${J(K)}" height="${J(re)}"${Io(NO+te)}/><path class="pele-json-lines" d="${fe}" fill="none" stroke="var(--_b)"${F.style.line}/>`+Xt(F.label,0,-re/2+F.headH/2,` class="pele-label" font-weight="var(--_hw)"${Y}${z}`,l)+`<g font-size="${o}">${ce}</g>`}else{let le=F.stereotype.height/2,ee;if(F.kind===1){if(pe="pele-usecase",ee=`<ellipse rx="${J(K/2)}" ry="${J(re/2)}"${NO}${te}/>`,V.business){let ce=K/2-15,fe=K/2-5,de=(Ae)=>re/2*Math.sqrt(1-(Ae/(K/2))**2);ee+=`<path class="pele-business" d="M${J(ce)},${J(de(ce))}L${J(fe)},${J(-de(fe))}" fill="none" stroke="var(--_b)"${F.style.line}/>`}}else if(V.shape==="note"){pe="pele-note";let ce=K/2,fe=re/2;ee=`<path d="M${J(-ce)},${J(-fe)}H${J(ce-bre)}L${J(ce)},${J(bre-fe)}V${J(fe)}H${J(-ce)}Z" fill="var(--_a)" stroke="var(--_b)" stroke-linejoin="round"${te}/><path d="M${J(ce-bre)},${J(-fe)}V${J(bre-fe)}H${J(ce)}" fill="none" stroke="var(--_b)" stroke-linejoin="round"${F.style.line}/>`}else pe="pele-usecase",ee=`<rect x="${J(-K/2)}" y="${J(-re/2)}" width="${J(K)}" height="${J(re)}"${Io(NO+te)}/>`;ae=ee+Xt(F.stereotype,0,-F.label.height/2,` class="pele-stereotype" font-size="${s}"${ne}`,l)+Xt(F.label,0,le,` class="pele-label"${V.shape==="note"?` font-size="${o}"`:""}${Y}${z}`,l)}G+=`<g class="pele-node ${pe}${H}" data-id="${X}" transform="translate(${J(oe.x)},${J(oe.y)})">${ae}</g>`}let q="",N="",L="",D=new Map;for(let P=0;P<h.length;P++){let F=h[P],oe=b[P],V=f[P],H=oe.style.length>0||oe.cssCompiledStyles.length>0?vc(oe.cssCompiledStyles.concat(oe.style)):void 0,{arrowTypeStart:X,arrowTypeEnd:z}=oe,te;if(F.src===F.dst){let pe=g[F.src],le=m[F.src],ee=D.get(F.src)??0;D.set(F.src,ee+1);let ce=p?2:1,fe=Math.min(NNt(le,ce)/2,8+ee*6),de=QDe+ee*8,[Ae,ue]=DTe(le,pe,ce,-fe),[ie,ke]=DTe(le,pe,ce,fe),xe=Math.hypot(de,fe)||1,Ne=p?fe/xe:de/xe,Ee=p?de/xe:fe/xe,be=yre(X),Be=yre(z),Le=(ge,we,Ce,Me)=>p?`${J(ge+Ce*fe*(Me?1:0))},${J(we+Me)}`:`${J(ge+Me)},${J(we+Ce*fe*(Me?1:0))}`,Ve=p?Ae-Ne*be:Ae+Ne*be,tt=p?ue+Ee*be:ue-Ee*be,Ye=ie+Ne*Be,et=ke+Ee*Be;te={d:`M${J(Ve)},${J(tt)}C${Le(Ae,ue,-1,de)} ${Le(ie,ke,1,de)} ${J(Ye)},${J(et)}`,sx:Ae,sy:ue,sdx:p?Ne:-Ne,sdy:p?-Ee:Ee,ex:ie,ey:ke,edx:-Ne,edy:-Ee},p?(F.labelX=pe.x,F.labelY=Math.max(ue,ke)+de*0.75+6+V.height/2):(F.labelX=Math.max(Ae,ie)+de*0.75+8+V.width/2,F.labelY=pe.y)}else{if(F.route.length<6)continue;te=lx(F.route,void 0,yre(X),yre(z))}let Y=$Te(te.d,[te.sx,te.sy,te.ex,te.ey],R,te.tokens),ne=Y&&OTe(Y,H?.line),K=ne||(H?.stroke?$r(H.stroke):"var(--_l)");if(ne===""){let pe="var(--_bg)";q+=GTe(te.d,wre(X,te.sx,te.sy,te.sdx,te.sdy,pe,pe)+wre(z,te.ex,te.ey,te.edx,te.edy,pe,pe),H?.line)}let re=oe.internal?"2 3":oe.pattern==="dotted"?"5 4":oe.animate?"9 5":"",ae=wre(X,te.sx,te.sy,te.sdx,te.sdy,K)+wre(z,te.ex,te.ey,te.edx,te.edy,K);if(N+=`<g class="pele-edge pele-${oe.relationshipType}${_u(oe.classes.replace(/^default relationship relationship-\S+\s?/,""))}" data-id="${kn(oe.id)}"${ne?` stroke="${ne}"`:""}${H?.line??""}><path d="${te.d}"${re?` stroke-dasharray="${re}"`:""}/>`+(Y&&ne?XDe(ae,Y):ae)+"</g>",V.width>0){let{labelX:pe,labelY:le}=F,ee=oe.relationshipType==="include"||oe.relationshipType==="extend";L+=mE(oe.id,V,pe,le,(ee?' fill="var(--_m)"':"")+(H?.text??""),l)}}return{svg:Ni("usecase",_,Q,i,n,e,Xt(w,_/2,u+w.height/2,' class="pele-title" font-weight="var(--_tw)"')+(O?`<g class="pele-clusters">${O}</g>`:"")+BQ(q)+(N?`<g class="pele-edges" fill="none" stroke="var(--_l)" stroke-linecap="round">${N}</g>`:"")+(L?`<g class="pele-edge-labels" font-size="${o}">${L}</g>`:"")+`<g class="pele-nodes">${G}</g>`),width:_,height:Q,links:[]}}function swr(e,t,n){let r=n.get(Math.round(e.y-e.h/2));if(t===0||r===void 0)return e.x;let a=e.x-e.w/2+6,i=e.x+e.w/2-6,o=r.filter((p)=>p>a&&p<i).sort((p,A)=>p-A);o.push(i);let s=t/2+6,c=e.x,u=1/0,l=0,d=a;for(let p of o){if(p-d>=2*s){let A=Math.min(Math.max(e.x,d+s),p-s);Math.abs(A-e.x)<u&&(u=Math.abs(A-e.x),c=A)}else u===1/0&&p-d>l&&(l=p-d,c=(d+p)/2);d=p}return c}function cwr(e,t,n,r,a){if(e.lines.length<2)return Xt(e,t+e.width/2,n,r,a);let i="";for(let o=0;o<e.lines.length;o++)i+=Xt(e5(e,o),t+e.widths[o]/2,n-e.height/2+XO(e,o),r,a);return i}function dQ(e){let t=e.trim();return t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function TDe(e){return e.map(dQ).sort()}function gwr(e,t){let n=new pwr(e,t),r=-1,a=()=>r===-1?r=n.next():r,i=(A)=>{throw a()===1?co("venn",e,n.start,"",!0):co("venn",e,n.start,`Expecting ${A}, got '${a8t[r]}'`)},o=()=>(r=-1,n.text),s=(A)=>(a()!==A&&i(`'${a8t[A]}'`),o()),c=()=>(a()!==16&&r!==17&&i("'IDENTIFIER', 'STRING'"),o()),u=()=>{let A=[c()];for(;a()===18;)o(),A.push(c());return A},l=(A,m)=>{let g=a()===11?o():void 0,h;if(a()===19&&(o(),h=parseFloat(s(12))),m){if(A.length<2)throw new Dr("union requires multiple identifiers","semantic",{type:"venn"});t.validateUnionIdentifiers(A)}t.addSubsetData(A,g,h),t.setIndentMode(!0)},d=(A)=>{let m=a();m!==16&&m!==17&&m!==12&&i("'NUMERIC', 'IDENTIFIER', 'STRING'");let g=o(),h=m!==12&&a()===11?o():void 0;t.addTextData(A(),g,h)},p=()=>{let A=u(),m=[];for(;;){let g=s(16);s(19);let h;if(a()===17)h=o();else{let f=[];for(;a()===16||r>=12&&r<=15;)f.push(o());f.length===0&&i(mwr),h=f.join(" ")}if(m.push([g,h]),a()!==18)break;o()}t.addStyleData(A,m)};for(;a()===3;)o();for(s(4);;){let A=a();if(A===2)return;if((A<3||A>10||A===4)&&i(Awr),o(),A===5)t.setDiagramTitle(n.text.slice(6));else if(A===6)l([c()],!1);else if(A===7)l(u(),!0);else if(A===8){let m=u();d(()=>m)}else A===9?d(()=>{let m=t.getCurrentSets();if(!m)throw new Dr("text requires set","semantic",{type:"venn"});return m}):A===10&&p()}}function fwr(e){let t=new Set,n=new Map;for(let a of e)t.add(JSON.stringify([...a.sets].sort())),a.sets.length===1&&n.set(a.sets[0],a.size);let r=[];for(let a of e){if(a.sets.length<3)continue;let i=[...a.sets].sort();for(let o=0;o<i.length-1;o++)for(let s=o+1;s<i.length;s++){let c=[i[o],i[s]],u=JSON.stringify(c);if(t.has(u))continue;t.add(u);let l=n.get(c[0]),d=n.get(c[1]);r.push({sets:c,size:l!==void 0&&d!==void 0?Math.min(l,d)/4:2.5,label:""})}}return r.length>0?[...e,...r]:e}function hwr(e,t,n){if(n>=e+t)return 0;let r=Math.min(e,t);if(n<=Math.abs(e-t))return Math.PI*r*r;let a=e*e*Math.acos((n*n+e*e-t*t)/(2*n*e)),i=t*t*Math.acos((n*n+t*t-e*e)/(2*n*t)),o=0.5*Math.sqrt(Math.max((-n+e+t)*(n+e-t)*(n-e+t)*(n+e+t),0));return a+i-o}function bwr(e,t,n){let r=Math.abs(e-t),a=e+t;if(!(n>0))return a;if(n>=Math.PI*Math.min(e,t)**2)return r;for(let i=0;i<48;i++){let o=(r+a)/2;hwr(e,t,o)>n?r=o:a=o}return(r+a)/2}function i8t(e,t,n,r,a,i){let o=1/0;for(let s of t){let c=e[s],u=r-c.x,l=a-c.y,d=c.r-Math.sqrt(u*u+l*l);if(d<o){if(d<i)return d;o=d}}for(let s of n){let c=e[s],u=r-c.x,l=a-c.y,d=Math.sqrt(u*u+l*l)-c.r;if(d<o){if(d<i)return d;o=d}}return o}function TTe(e,t,n){let r=0,a=0,i=e[t[0]];for(let m of t){let g=e[m];r+=g.x/t.length,a+=g.y/t.length,g.r<i.r&&(i=g)}let o=i.r,s=r,c=a,u=i8t(e,t,n,s,c,-1/0),l=0,d=(m,g)=>{let h=i8t(e,t,n,m,g,u-o*0.000000001);if(!(h>u-o*0.000000001))return!1;let f=Math.hypot(m-r,g-a);return h>u+o*0.000000001||f<l-o*0.000000001?(u=h,l=f,s=m,c=g,!0):!1},p=10;for(let m=-p;m<=p;m++)for(let g=-p;g<=p;g++)g*g+m*m<=p*p&&d(i.x+g*o/p,i.y+m*o/p);let A=o/p;for(let m=0;m<40&&A>o*0.000001;m++){let g=!1;for(let h=0;h<8;h++){let f=h*bae/8;d(s+Math.cos(f)*A,c+Math.sin(f)*A)&&(g=!0)}g||(A/=2)}return{x:s,y:c,margin:u}}function ywr(e){let t=new Map;for(let h of e)for(let f of h.sets)t.has(f)||t.set(f,10);for(let h of e)h.sets.length===1&&t.set(h.sets[0],h.size);let n=new Map,r=[],a=0;for(let h of t.values())Number.isFinite(h)&&h>a&&(a=h);a===0&&(a=10);let i=Math.sqrt(a/Math.PI);for(let[h,f]of t){n.set(h,r.length);let b=Number.isFinite(f)&&f>0?Math.sqrt(f/Math.PI):0;r.push({id:h,x:0,y:0,r:Math.max(b,i*0.3)})}let o=r.length;if(o<2)return r;let s=new Map;for(let h of fwr(e)){if(h.sets.length!==2)continue;let f=n.get(h.sets[0]),b=n.get(h.sets[1]);f!==b&&s.set(Math.min(f,b)*o+Math.max(f,b),h.size)}let c=new Map;for(let[h,f]of s)c.set(h,bwr(r[Math.floor(h/o)].r,r[h%o].r,f));let u=i*0.15,l=(h,f)=>c.get(h*o+f)??r[h].r+r[f].r+u;if(o===2)return r[1].x=l(0,1),r;if(o===3){let h=l(0,1),f=l(0,2),b=l(1,2),y=e.some((w)=>new Set(w.sets).size===3);for(let w=0;w<40;w++){let k=h>0?(h*h+f*f-b*b)/(2*h):0;if(r[1].x=h,r[2].x=Math.max(-f,Math.min(f,k)),r[2].y=Math.sqrt(Math.max(f*f-k*k,0)),!y||TTe(r,[0,1,2],[]).margin>i*0.12)break;h*=0.94,f*=0.94,b*=0.94}return r}let d=0;for(let h of r)d+=2*h.r+u;let p=Math.min(300,Math.floor(3000000/(o*o)));if(o<=64){let h=d/bae;r.forEach((f,b)=>{let y=b*bae/o-Math.PI/2;f.x=Math.cos(y)*h,f.y=Math.sin(y)*h})}else{let h=Math.ceil(Math.sqrt(o)),f=2*i+u;r.forEach((b,y)=>{b.x=y%h*f,b.y=Math.floor(y/h)*f})}let A=new Float64Array(o),m=new Float64Array(o),g=new Int32Array(o);for(let h=0;h<p;h++){A.fill(0),m.fill(0),g.fill(0);for(let f=0;f<o;f++)for(let b=f+1;b<o;b++){let y=c.get(f*o+b),w=r[f].r+r[b].r+u,k=r[b].x-r[f].x,E=r[b].y-r[f].y,B=Math.hypot(k,E);if(y===void 0&&B>=w)continue;B<0.000000001&&(k=Math.cos(f+b),E=Math.sin(f+b),B=1);let x=(B-(y??w))/2/B;A[f]+=k*x,m[f]+=E*x,A[b]-=k*x,m[b]-=E*x,g[f]++,g[b]++}for(let f=0;f<o;f++)g[f]!==0&&(r[f].x+=A[f]/g[f],r[f].y+=m[f]/g[f])}return r}function wwr(e,t){let n=(c)=>`M${t(c.x-c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x+c.r)},${t(c.y)}A${t(c.r)},${t(c.r)} 0 1 1 ${t(c.x-c.r)},${t(c.y)}Z`;if(e.length===1)return n(e[0]);let r=(c,u,l,d)=>{for(let p of e)if(p!==l&&p!==d&&Math.hypot(c-p.x,u-p.y)>p.r*1.000000001)return!1;return!0},a=[];for(let c=0;c<e.length;c++)for(let u=c+1;u<e.length;u++){let l=e[c],d=e[u],p=Math.hypot(d.x-l.x,d.y-l.y);if(p>=l.r+d.r||p<=Math.abs(l.r-d.r)||p===0)continue;let A=(l.r*l.r-d.r*d.r+p*p)/(2*p),m=Math.sqrt(Math.max(l.r*l.r-A*A,0)),g=l.x+(d.x-l.x)*A/p,h=l.y+(d.y-l.y)*A/p;for(let f of[1,-1]){let b=g+f*m*(d.y-l.y)/p,y=h-f*m*(d.x-l.x)/p;r(b,y,l,d)&&a.push({x:b,y,a:l,b:d})}}if(a.length<2){let c=e[0];for(let u of e)u.r<c.r&&(c=u);for(let u of e)if(u!==c&&Math.hypot(u.x-c.x,u.y-c.y)+c.r>u.r*1.000000001)return"";return n(c)}let i=0,o=0;for(let c of a)i+=c.x/a.length,o+=c.y/a.length;a.sort((c,u)=>Math.atan2(c.y-o,c.x-i)-Math.atan2(u.y-o,u.x-i));let s="";for(let c=0;c<a.length;c++){let u=a[c],l=a[(c+1)%a.length];c===0&&(s=`M${t(u.x)},${t(u.y)}`);let d,p=0,A=1/0;for(let m of[u.a,u.b]){if(m!==l.a&&m!==l.b)continue;let g=Math.atan2(u.y-m.y,u.x-m.x),h=Math.atan2(l.y-m.y,l.x-m.x)-g;h<=0&&(h+=bae);let f=m.x+m.r*Math.cos(g+h/2),b=m.y+m.r*Math.sin(g+h/2),y=Math.hypot(f-(u.x+l.x)/2,b-(u.y+l.y)/2);y<A&&(A=y,d=m,p=h>Math.PI?1:0)}d===void 0?s+=`L${t(l.x)},${t(l.y)}`:s+=`A${t(d.r)},${t(d.r)} 0 ${p} 1 ${t(l.x)},${t(l.y)}`}return s+"Z"}function RDe(e){return e.length===1?e[0]:JSON.stringify(e)}function Bwr(e,t,n){let r=n.fontSize??16,a=Math.round(r*0.875),i=Math.round(r*0.8125),o=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),s=n.padding??8,c=ywr(e.subsets),u=new Map;c.forEach((P,F)=>u.set(P.id,F));let l=new Map;for(let{targets:P,styles:F}of e.styles){let oe=RDe(P),V=l.get(oe);V||l.set(oe,V=new Map);for(let[H,X]of F)V.set(H,X)}let d=(P)=>{let F=l.get(P);if(!F)return o8t;let oe=[];for(let[V,H]of F)oe.push(`${V}:${H}`);return vc(oe)},p=c.map(()=>[]);for(let P=0;P<c.length;P++)for(let F=P+1;F<c.length;F++)Math.hypot(c[P].x-c[F].x,c[P].y-c[F].y)<c[P].r+c[F].r&&(p[P].push(F),p[F].push(P));let A=new Map;for(let P of e.subsets)A.set(RDe(P.sets),P);let m=new Map;for(let[P,F]of A){let oe=[...new Set(F.sets)],V=oe.map((pe)=>u.get(pe)),H=new Set(V),X=V[0];for(let pe of V)c[pe].r<c[X].r&&(X=pe);let z=d(P),te=F.label??(F.sets.length===1?F.sets[0]:void 0),Y=(z.bold?1:0)|(z.italic?2:0),ne=p[X].filter((pe)=>!H.has(pe)),K=TTe(c,V,ne),re=ne.length>0&&K.margin<c[X].r*0.2;re&&(K=TTe(c,V,[]));let ae={sets:oe,inside:V,spot:K,lines:[],style:z,across:re};if(te){let pe=oe.length===1?r:a;ae.lines.push({id:void 0,raw:te,size:pe,base:Y,label:Cn(te,!1,o,pe,4000,Y)})}m.set(P,ae)}for(let P of e.textNodes){let F=P.label??P.id;m.get(RDe(P.sets))?.lines.push({id:P.id,raw:F,size:i,base:0,label:Cn(F,!1,o,i,4000)})}let g=0;for(let P of c)P.r>g&&(g=P.r);let h=g>0?kwr/g:1,f=1;for(let P of m.values()){if(P.spot.margin<=0)continue;let F=0,oe=0;for(let H of P.lines)F=Math.max(F,H.label.width),oe+=H.label.height;let V=Math.hypot(F,oe)/2+4;f=Math.max(f,Math.min(V/(P.spot.margin*h),Ewr))}h*=f;for(let P of m.values()){let F=Math.max(P.spot.margin*h*1.8,72);for(let oe of P.lines)oe.label.width>F&&(oe.label=Cn(oe.raw,!1,o,oe.size,F,oe.base))}let b=1/0,y=1/0,w=-1/0,k=-1/0;for(let P of c)b=Math.min(b,(P.x-P.r)*h),y=Math.min(y,(P.y-P.r)*h),w=Math.max(w,(P.x+P.r)*h),k=Math.max(k,(P.y+P.r)*h);for(let P of m.values()){let F=0,oe=0;for(let V of P.lines)F=Math.max(F,V.label.width),oe+=V.label.height;b=Math.min(b,P.spot.x*h-F/2),w=Math.max(w,P.spot.x*h+F/2),y=Math.min(y,P.spot.y*h-oe/2),k=Math.max(k,P.spot.y*h+oe/2)}c.length===0&&(b=y=w=k=0);let E=Cn(e.title&&dQ(e.title),!1,o,r,4000,1),B=E.height>0?E.height+12:0,x=Math.max(w-b,E.width),_=s+(x-(w-b))/2-b,Q=s+B-y,U=Math.ceil(x+2*s),O=Math.ceil(k-y+B+2*s),R=c.map((P)=>({id:P.id,x:P.x*h+_,y:P.y*h+Q,r:P.r*h})),G="";R.forEach((P,F)=>{let oe=ho(F),V=m.get(P.id)?.style??o8t;G+=`<circle class="pele-venn-set" data-id="${kn(P.id)}" cx="${J(P.x)}" cy="${J(P.y)}" r="${J(P.r)}" fill="${oe}" fill-opacity="0.2" stroke="${oe}"${V.shape}/>`});let q=[...m.values()].filter((P)=>P.sets.length>1&&P.style.shape!==""),N=(P)=>{if(P.across)return"";let F=P.sets.length===1&&/[";]fill-opacity:/.test(P.style.shape)?P.style.shape:"";for(let oe of q)oe.sets.every((V)=>P.sets.includes(V))&&(F=oe.style.shape);return F},L="",D="";for(let P of m.values()){let F=kn(P.sets.join("|"));if(P.sets.length>1&&P.style.shape!==""){let te=wwr(P.inside.map((Y)=>R[Y]),J);te!==""&&(L+=`<path class="pele-venn-overlap" data-id="${F}" d="${te}" fill="none"${P.style.shape}/>`)}let oe=0;for(let te of P.lines)oe+=te.label.height;if(oe===0)continue;let V=P.spot.x*h+_,H=P.spot.y*h+Q-oe/2,X=N(P),z="";for(let te of P.lines){let Y=te.id===void 0?P.style.text:d(te.id).text,ne=NM(X,Y),K=te.id===void 0?` class="pele-label"${te.size===r?"":` font-size="${te.size}"`}${ne?` fill="${ne}"`:""}${Y}`:` class="pele-venn-text" data-id="${kn(te.id)}" font-size="${i}" fill="${ne??"var(--_m)"}"${Y}`;z+=Xt(te.label,V,H+te.label.height/2,K),H+=te.label.height}D+=`<g class="pele-venn-region" data-id="${F}">${z}</g>`}return{svg:Ni("venn",U,O,r,n,{},Xt(E,U/2,s+E.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g class="pele-venn-sets">${G}</g>`+(L?`<g class="pele-venn-overlaps">${L}</g>`:"")+(D?`<g class="pele-venn-labels">${D}</g>`:"")),width:U,height:O,links:[]}}function yae(e,t){let n=e<=1?e*100:e;if(n<0||n>100)throw new Dr(`${t} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`,"semantic",{type:"wardley"});return n}function oQ(e,t,n){return{x:yae(t,`${n} evolution`),y:yae(e,`${n} visibility`)}}function s8t(e){return e==="+<>"?"bidirectional":e==="+<"?"backward":e==="+>"?"forward":void 0}function _wr(e){if(!e?.startsWith("+"))return{};let t=e.indexOf("'",2),n=e[1]==="'"&&t!==-1?e.slice(2,t):void 0;return e.includes("<>")?{flow:"bidirectional",label:n}:e.includes("<")?{flow:"backward",label:n}:e.includes(">")?{flow:"forward",label:n}:{label:n}}function c8t(e){return e?[(e.negX?-1:1)*e.offsetX,(e.negY?-1:1)*e.offsetY]:[void 0,void 0]}function vwr(e,t){e.size&&t.setSize(e.size.width,e.size.height),e.evolution&&t.setAxes({stages:e.evolution.stages.map((n)=>n.secondName?`${n.name.trim()} / ${n.secondName.trim()}`:n.name.trim()),stageBoundaries:e.evolution.stages.filter((n)=>n.boundary!==void 0).map((n)=>n.boundary)});for(let n of e.anchors){let r=oQ(n.visibility,n.evolution,`Anchor "${n.name}"`);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"anchor"})}for(let n of e.components){let r=oQ(n.visibility,n.evolution,`Component "${n.name}"`),[a,i]=c8t(n.label);t.addNode({id:n.name,label:n.name,x:r.x,y:r.y,className:"component",labelOffsetX:a,labelOffsetY:i,inertia:n.inertia,sourceStrategy:n.decorator?.strategy})}for(let n of e.notes){let r=oQ(n.visibility,n.evolution,`Note "${n.text}"`);t.addNote({text:n.text,x:r.x,y:r.y})}for(let n of e.pipelines){let r=t.getNode(n.parent);if(!r||typeof r.y!="number")throw new Dr(`Pipeline "${n.parent}" must reference an existing component with coordinates.`,"semantic",{type:"wardley"});let a=r.y;t.startPipeline(n.parent);for(let i of n.components){let o=`${n.parent}_${i.name}`,[s,c]=c8t(i.label),u=yae(i.evolution,`Pipeline component "${i.name}" evolution`);t.addNode({id:o,label:i.name,x:u,y:a,className:"pipeline-component",labelOffsetX:s,labelOffsetY:c,inertia:void 0,sourceStrategy:void 0}),t.addPipelineComponent(n.parent,o)}}for(let n of e.links){let r=!!n.arrow&&(n.arrow.includes("-.->")||n.arrow.includes(".-.")),a=_wr(n.arrow),i=s8t(n.fromPort)??s8t(n.toPort)??a.flow;t.addLink({source:t.resolveNodeId(n.from),target:t.resolveNodeId(n.to),dashed:r,label:a.label??n.linkLabel,flow:i})}for(let n of e.evolves){let r=t.getNode(n.component);r?.y!==void 0&&t.addTrend({nodeId:n.component,targetX:yae(n.target,`Evolve target for "${n.component}"`),targetY:r.y})}if(e.annotations.length>0){let n=oQ(e.annotations[0].x,e.annotations[0].y,"Annotations box");t.setAnnotationsBox(n.x,n.y)}for(let n of e.annotation){let r=oQ(n.x,n.y,`Annotation ${n.number}`);t.addAnnotation({number:n.number,coordinates:[{x:r.x,y:r.y}],text:n.text})}for(let n of e.accelerators){let r=oQ(n.x,n.y,`Accelerator "${n.name}"`);t.addAccelerator({name:n.name,x:r.x,y:r.y})}for(let n of e.deaccelerators){let r=oQ(n.x,n.y,`Deaccelerator "${n.name}"`);t.addDeaccelerator({name:n.name,x:r.x,y:r.y})}}function Iwr(e,t){let n=new xwr;return vwr(e,n),{type:"wardley",title:e.title||t,accTitle:e.accTitle?e.accTitle.replace(/^\s+/g,""):void 0,accDescr:e.accDescr?e.accDescr.replace(/\n\s+/g,`
|
|
553
553
|
`):void 0,...n.build()}}function l8t(e,t){let n=t;for(let r=e.charCodeAt(n);r>=48&&r<=57;r=e.charCodeAt(n))n++;return n}function Qwr(){let e=0,t=0;return(n,r)=>{if((r<e||r>=t)&&(e=r,t=l8t(n,r)),t===r||n.charCodeAt(t)!==46)return-1;let a=l8t(n,t+1);return a>t+1?a:-1}}function Swr(e){let t=new qf($f(e,p8t,"wardley"),p8t,"wardley"),n={$type:"Wardley",anchors:[],components:[],links:[],evolves:[],pipelines:[],notes:[],annotations:[],annotation:[],accelerators:[],deaccelerators:[]},r=(A)=>t.kinds[t.i]===A,a=()=>r(36)||r(37)||r(30),i=()=>r(36)?ry(t.take()):r(37)||r(30)?t.take():t.fail("a name"),o=()=>Number(t.expect(10)),s=()=>parseInt(t.expect(35)),c=()=>r(10)?Number(t.take()):parseInt(t.expect(35)),u=()=>{if(!r(-1))for(r(38)||t.fail("a line break or the end of input");r(38);)t.i++},l=(A)=>{t.expect(0);let m=A();t.expect(1);let g=A();return t.expect(2),[m,g]},d=()=>{t.expect(21),t.expect(0);let A=t.accept(7),m=s();t.expect(1);let g=t.accept(7),h=s();return t.expect(2),{$type:"Label",negX:A,offsetX:m,negY:g,offsetY:h}},p=()=>{let A={$type:"EvolutionStage",name:i()};return t.accept(3)&&(A.boundary=o()),t.accept(4)&&(A.secondName=i()),A};for(;r(38);)t.i++;for(t.expect(16);!r(-1);)switch(t.kind){case 38:t.i++;break;case 32:n.accDescr=Uf(t.take()),u();break;case 33:n.accTitle=Gf(t.take()),u();break;case 34:n.title=Of(t.take()),u();break;case 17:{t.i++;let[A,m]=l(s);u(),n.size={$type:"Size",width:A,height:m};break}case 18:{t.i++;let A=[p()];for(t.expect(11),A.push(p());t.accept(11);)A.push(p());u(),n.evolution={$type:"Evolution",stages:A};break}case 19:{t.i++;let A=i(),[m,g]=l(o);u(),n.anchors.push({$type:"Anchor",name:A,visibility:m,evolution:g});break}case 20:{t.i++;let A={$type:"Component",name:i(),visibility:0,evolution:0,inertia:!1};[A.visibility,A.evolution]=l(o),r(21)&&(A.label=d()),r(5)&&t.kinds[t.i+1]===15&&(t.i++,A.decorator={$type:"Decorator",strategy:t.take()},t.expect(6)),t.accept(22)?A.inertia=!0:t.accept(5)&&(t.expect(22),t.expect(6),A.inertia=!0),u(),n.components.push(A);break}case 23:{t.i++;let A=i(),m=o();u(),n.evolves.push({$type:"Evolve",component:A,target:m});break}case 24:{t.i++;let A=i();for(t.expect(8),t.expect(38);r(38);)t.i++;let m=[];do{t.expect(20);let g={$type:"PipelineComponent",name:i(),evolution:0};t.expect(0),g.evolution=o(),t.expect(2),r(21)&&(g.label=d()),u(),m.push(g)}while(r(20));t.expect(9),u(),n.pipelines.push({$type:"Pipeline",parent:A,components:m});break}case 25:{t.i++;let A=ry(t.expect(36)),[m,g]=l(o);u(),n.notes.push({$type:"Note",text:A,visibility:m,evolution:g});break}case 26:{t.i++;let[A,m]=l(c);u(),n.annotations.push({$type:"Annotations",x:A,y:m});break}case 27:{t.i++;let A=s();t.expect(1);let[m,g]=l(c),h=ry(t.expect(36));u(),n.annotation.push({$type:"Annotation",number:A,x:m,y:g,text:h});break}case 28:case 29:{let A=t.kind===29;t.i++;let m=i(),[g,h]=l(o);u(),A?n.deaccelerators.push({$type:"Deaccelerator",name:m,x:g,y:h}):n.accelerators.push({$type:"Accelerator",name:m,x:g,y:h});break}default:{a()||t.fail("a statement");let A={$type:"Link",from:i(),to:""};r(12)&&(A.fromPort=t.take()),(r(13)||r(11))&&(A.arrow=t.take()),A.to=i(),r(12)&&(A.toPort=t.take()),r(14)&&(A.linkLabel=t.take().substring(1).trim()),u(),n.links.push(A)}}return n}function Fwr(e,t,n,r,a){let i=e["wardley-beta"]?.[t];return typeof i=="number"&&i>=r&&i<=a?i:n}function hM(e,t,n){return e<t?t:e>n?n:e}function m8t(e,t,n,r){let a=JO(e),i="",o=n;for(let s of e.lines){let c=!0;for(let u of s){if(u.icon!==void 0)continue;let l=TM(u.style&~a);i+=`<tspan${c?` x="${J(t)}" y="${J(o)}"`:""}${l}>${$r(u.text)}</tspan>`,c=!1}o+=e.lineHeight}return i===""?"":`<text${bQ(r,a)} xml:space="preserve">${i}</text>`}function $Nt(e,t,n,r){let a=typeof t=="number"&&Number.isFinite(t)?t:Fwr(e,n,r,1,1e6);return hM(a,200,1e4)-2*Twr}function jwr(e,t,n){let r=$Nt(t,e.size?.width,"width",900);return vae(n,r,160,(a,i)=>Lwr(e,t,n,a,r,i))}function Lwr(e,t,n,r,a,i){let o=n.fontSize??16,s=Math.round(o*0.8125),c=Math.round(o*0.6875),u=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),l=n.padding??8,d=$Nt(t,e.size?.height,"height",600)*Math.max(0.75,r/a),p=t["wardley-beta"]?.showGrid===!0,A=0,m=0,g=r,h=d,f=(be,Be,Le,Ve)=>{be<A&&(A=be),Be<m&&(m=Be),Le>g&&(g=Le),Ve>h&&(h=Ve)},b=(be,Be,Le,Ve)=>(f(Be-be.width/2,Le-be.height/2,Be+be.width/2,Le+be.height/2),Xt(be,Be,Le,Ve,n.icons)),y=(be,Be,Le,Ve)=>(f(Be,Le-be.size,Be+be.width,Le-be.size+be.height+4),m8t(be,Be,Le,Ve)),w=(be,Be,Le=i?Math.max(64,Math.min(120,r/2)):4000,Ve=0)=>Cn(be,!1,u,Be,Le,Ve),k=(be)=>be/100*r,E=(be)=>d-be/100*d,B=e.axes.stages&&e.axes.stages.length>0?e.axes.stages:Dwr,x=e.axes.stageBoundaries,_=x!==void 0&&x.length===B.length,Q="",U="",O=d,R=0;if(B.forEach((be,Be)=>{let Le=_?R:Be/B.length,Ve=_?hM(x[Be],0,1):(Be+1)/B.length;R=Ve,Be>0&&(Q+=`<path class="pele-wardley-stage" d="M${J(Le*r)},0V${J(d)}" stroke="var(--_b)" stroke-dasharray="4 4"/>`);let tt=w(be,s,Math.max(48,Math.abs(Ve-Le)*r-12));U+=b(tt,(Le+Ve)/2*r,d+8+tt.height/2,` class="pele-wardley-stage-label" font-size="${s}" fill="var(--_m)"`),O=Math.max(O,d+8+tt.height)}),p)for(let be=1;be<4;be++)Q+=`<path class="pele-wardley-grid" d="M${J(r*be/4)},0V${J(d)}M0,${J(d*be/4)}H${J(r)}" stroke="var(--_b)" stroke-dasharray="2 6"/>`;Q+=`<path class="pele-wardley-axis" d="M0,0V${J(d)}H${J(r)}" stroke="${Sg}"/>`;let G=w(e.axes.xLabel??"Evolution",s),q=w(e.axes.yLabel??"Visibility",s),N=` class="pele-wardley-axis-label" font-size="${s}" font-weight="var(--_hw)"`,L=b(G,r/2,O+6+G.height/2,N)+Xt(q,-16,d/2,`${N} transform="rotate(-90 -16 ${J(d/2)})"`);f(-16-q.height/2,0,0,0);let D=O+6+G.height+10,P=new Map;for(let be of e.nodes)P.set(be.id,{x:k(be.x),y:E(be.y),node:be});let F="",oe=new Map;for(let be of e.pipelines){oe.set(be.nodeId,new Set(be.componentIds));let Be=[];for(let ge of be.componentIds){let we=P.get(ge);we&&Be.push(we)}if(Be.length===0)continue;Be.sort((ge,we)=>ge.x-we.x);let Le=Be[0].x,Ve=Be[Be.length-1].x,tt=Be[0].y,Ye=tt-2*Ts,et=P.get(be.nodeId);et&&(et.x=(Le+Ve)/2,et.y=Ye-sQ/6),f(Le-kre,Ye,Ve+kre,Ye+4*Ts),F+=`<g class="pele-wardley-pipeline" data-id="${kn(be.nodeId)}"><rect x="${J(Le-kre)}" y="${J(Ye)}" width="${J(Ve-Le+2*kre)}" height="${J(4*Ts)}" fill="var(--_s)" stroke="var(--_b)"${Ji}/>`+(Be.length>1?`<path d="M${J(Le)},${J(tt)}H${J(Ve)}" stroke="${Sg}" stroke-dasharray="4 4"/>`:"")+"</g>"}let V=new Map,H=(be,Be,Le)=>{let Ve=be.node;if(Ve.className==="anchor"){let tt=V.get(Ve);return tt||V.set(Ve,tt=w(Ve.label,s,i?Math.max(64,r/2):4000,1)),1/Math.hypot(Be/(tt.width/2+5),Le/(s*0.8))}return Ve.isPipelineParent?sQ/Math.SQRT2:Ve.sourceStrategy?2*Ts:Ts},X=new Map,z=(be,Be,Le)=>{Math.abs(Be)<0.25||Math.abs(Le)<0.25||X.set(be,(X.get(be)??0)|(Be>0?Le<0?1:2:Le<0?4:8))},te="";for(let be of e.links){let Be=P.get(be.source),Le=P.get(be.target);if(!Be||!Le||Be===Le||oe.get(be.target)?.has(be.source))continue;let Ve=Le.x-Be.x,tt=Le.y-Be.y,Ye=Math.hypot(Ve,tt);if(Ye<0.01)continue;let et=Ve/Ye,ge=tt/Ye,we=H(Be,et,ge),Ce=H(Le,et,ge);if(we+Ce>=Ye)continue;z(Be,et,ge),z(Le,-et,-ge);let Me=Be.x+et*we,We=Be.y+ge*we,ve=Le.x-et*Ce,Ze=Le.y-ge*Ce,st="";(be.flow==="forward"||be.flow==="bidirectional")&&(st+=es("arrow_point",ve,Ze,et,ge,Sg),ve-=et*Po("arrow_point"),Ze-=ge*Po("arrow_point")),(be.flow==="backward"||be.flow==="bidirectional")&&(st+=es("arrow_point",Me,We,-et,-ge,Sg),Me+=et*Po("arrow_point"),We+=ge*Po("arrow_point"));let Ie="";if(be.label){let Oe=w(be.label,c+1,200),lt=et>=0?1:-1,ze=ge*lt,rt=-et*lt,Te=5+Math.abs(ze)*Oe.width/2+Math.abs(rt)*Oe.height/2;Ie=b(Oe,(Be.x+Le.x)/2+ze*Te,(Be.y+Le.y)/2+rt*Te,` class="pele-edge-label" font-size="${c+1}" fill="var(--_m)"`)}te+=`<g class="pele-edge${be.dashed?" pele-wardley-dashed":""}" data-id="${kn(be.source)}-${kn(be.target)}"><path d="M${J(Me)},${J(We)}L${J(ve)},${J(Ze)}" stroke="${Sg}"${be.dashed?' stroke-dasharray="6 6"':""}/>`+st+Ie+"</g>"}let Y="";for(let be of e.trends){let Be=P.get(be.nodeId);if(!Be)continue;let Le=k(be.targetX),Ve=E(be.targetY),tt=Le-Be.x,Ye=Ve-Be.y,et=Math.hypot(tt,Ye),ge="",we=et>0?H(Be,tt/et,Ye/et):0;if(et>we+Ts+4){let Ce=tt/et,Me=Ye/et,We=Le-Ce*(Ts+2),ve=Ve-Me*(Ts+2);ge=`<path d="M${J(Be.x+Ce*we)},${J(Be.y+Me*we)}L${J(We-Ce*Po("arrow_point"))},${J(ve-Me*Po("arrow_point"))}" stroke="${MDe}" stroke-dasharray="4 4"/>`+es("arrow_point",We,ve,Ce,Me,MDe)}f(Le-Ts,Ve-Ts,Le+Ts,Ve+Ts),Y+=`<g class="pele-wardley-trend" data-id="${kn(be.nodeId)}">${ge}<circle cx="${J(Le)}" cy="${J(Ve)}" r="${Ts}" fill="var(--_bg)" stroke="${MDe}"/></g>`}let ne="",K=1.2*Ts,re=0.7*Ts;for(let be of P.values()){let Be=be.node,{x:Le,y:Ve}=be,tt=Be.className==="anchor",Ye=Be.sourceStrategy,et="";if(Ye){let Me=Ye==="outsource"?"var(--_m)":Ye==="buy"?"var(--_a)":Ye==="build"?"var(--_s)":"var(--_bg)";et+=`<circle class="pele-wardley-${Ye}" cx="${J(Le)}" cy="${J(Ve)}" r="${2*Ts}" fill="${Me}" stroke="${Sg}"/>`}if(Ye==="market"){let Me=K*Math.cos(Math.PI/6),We=Ve+K*Math.sin(Math.PI/6);et+=`<path d="M${J(Le)},${J(Ve-K)}L${J(Le-Me)},${J(We)}H${J(Le+Me)}Z" fill="none" stroke="${Sg}"/>`;for(let[ve,Ze]of[[Le,Ve-K],[Le-Me,We],[Le+Me,We]])et+=`<circle cx="${J(ve)}" cy="${J(Ze)}" r="${J(re)}" fill="var(--_bg)" stroke="${Sg}"/>`}else Be.isPipelineParent?et+=`<rect x="${J(Le-sQ/2)}" y="${J(Ve-sQ/2)}" width="${sQ}" height="${sQ}" fill="var(--_bg)" stroke="${Sg}"/>`:tt||(et+=`<circle cx="${J(Le)}" cy="${J(Ve)}" r="${Ts}" fill="var(--_bg)" stroke="${Sg}"/>`);if(Be.inertia===!0){let Me=(Be.isPipelineParent?sQ/2:Ts)+10+(Ye?Ts+4:0);et+=`<rect class="pele-wardley-inertia" x="${J(Le+Me)}" y="${J(Ve-Ts)}" width="4" height="${2*Ts}" fill="${Sg}"/>`}let ge=Be.labelOffsetX===void 0?void 0:hM(Be.labelOffsetX,-5000,5000),we=Be.labelOffsetY===void 0?void 0:hM(Be.labelOffsetY,-5000,5000),Ce;if(tt){let Me=V.get(Be)??w(Be.label,s,i?Math.max(64,r/2):4000,1);Ce=b(Me,Le+(ge??0),Ve+(we??-3),` class="pele-label" font-size="${s}" font-weight="var(--_hw)"`)}else{let Me=w(Be.label,s),We=` class="pele-label" font-size="${s}"`,ve=Rwr+(Ye?10:0);if(ge!==void 0||we!==void 0)Ce=y(Me,Le+(ge??ve),Ve+(we??-ve),We);else if(Be.inPipeline)Ce=b(Me,Le,Ve+2*Ts+4+Me.height/2,We);else{let Ze=X.get(be)??0,st=(Ze&1)===0?1:(Ze&2)===0?2:(Ze&4)===0?4:(Ze&8)===0?8:1,Ie=st===1||st===2,Oe=st===1||st===4;Ce=y(Me,Ie?Le+ve:Le-ve-Me.width,Oe?Ve-ve:Ve+ve+s*0.75,We)}}f(Le-2*Ts,Ve-2*Ts,Le+2*Ts+20,Ve+2*Ts),ne+=`<g class="pele-node pele-wardley-${tt?"anchor":Be.isPipelineParent?"pipeline-parent":Be.inPipeline?"pipeline-component":"component"}" data-id="${kn(Be.id)}">${et}${Ce}</g>`}let ae="";for(let be of e.annotations){let Be=w(String(be.number),c,4000,1),Le="";for(let Ve of be.coordinates){let tt=k(Ve.x),Ye=E(Ve.y),et=Math.max(10,Be.width/2+4);f(tt-et,Ye-et,tt+et,Ye+et),Le+=`<circle cx="${J(tt)}" cy="${J(Ye)}" r="${J(et)}" fill="var(--_bg)" stroke="${Sg}"/>`+Xt(Be,tt,Ye,` font-size="${c}" font-weight="var(--_hw)"`)}ae+=`<g class="pele-wardley-annotation" data-id="${kn(String(be.number))}">${Le}</g>`}let pe=e.annotations.filter((be)=>be.text).sort((be,Be)=>be.number-Be.number);if(pe.length>0){let be=pe.map((we)=>w(`${we.number}. ${we.text}`,s,i?Math.max(80,r-20):320)),Be=0,Le=0;for(let we of be)Be=Math.max(Be,we.width),Le+=we.height;Be+=20,Le+=14;let Ve=e.annotationsBox,tt=Ve?hM(k(Ve.x),0,Math.max(0,r-Be)):0,Ye=Ve?hM(E(Ve.y),0,Math.max(0,d-Le)):D;f(tt,Ye,tt+Be,Ye+Le);let et="",ge=Ye+7;for(let we of be)et+=m8t(we,tt+10,ge+we.lineHeight/2+s*0.35,` font-size="${s}"`),ge+=we.height;ae+=`<g class="pele-wardley-annotations"><rect x="${J(tt)}" y="${J(Ye)}" width="${J(Be)}" height="${J(Le)}" fill="var(--_bg)" stroke="var(--_b)"${Ji}/>${et}</g>`}let le="";for(let be of e.notes)le+=y(w(be.text,s,Math.min(360,r*0.6),1),k(be.x),E(be.y),` class="pele-wardley-note" font-size="${s}" font-weight="var(--_hw)"`);let ee="",ce=(be,Be,Le,Ve)=>{let tt=k(Be),Ye=E(Le),et=Mwr/2,ge=Ve?tt+AO:tt,we=Ve?tt:tt+AO,Ce=Ve?tt+AO-A8t:tt+A8t,Me=`M${J(we)},${J(Ye-et)}H${J(Ce)}V${J(Ye-et-8)}L${J(ge)},${J(Ye)}L${J(Ce)},${J(Ye+et+8)}V${J(Ye+et)}H${J(we)}Z`;f(tt,Ye-et-8,tt+AO,Ye+et+8),ee+=`<g class="pele-wardley-${Ve?"accelerator":"deaccelerator"}" data-id="${kn(be)}"><path d="${Me}" fill="var(--_s)" stroke="${Sg}"/>`+b(w(be,c+1,160,1),tt+AO/2,Ye+et+8+12,` font-size="${c+1}" font-weight="var(--_hw)"`)+"</g>"};for(let be of e.accelerators)ce(be.name,be.x,be.y,!0);for(let be of e.deaccelerators)ce(be.name,be.x,be.y,!1);let fe=Cn(e.title,!1,u,o,i?Math.max(80,r):4000,1),de=fe.height>0?fe.height+12:0,Ae=Math.min(A,r/2-fe.width/2),ue=Math.max(g,r/2+fe.width/2),ie=l-Ae,ke=l+de-m,xe=Math.ceil(ue-Ae+2*l),Ne=Math.ceil(h-m+de+2*l),Ee=Xt(fe,ie+r/2,l+fe.height/2,' class="pele-title" font-weight="var(--_tw)"')+`<g transform="translate(${J(ie)},${J(ke)})"><g class="pele-wardley-frame" fill="none">${Q}</g>`+U+L+F+(te?`<g class="pele-edges" fill="none">${te}</g>`:"")+(Y?`<g class="pele-wardley-trends" fill="none">${Y}</g>`:"")+ne+ae+le+ee+"</g>";return{svg:Ni("wardley",xe,Ne,o,n,e,Ee),width:xe,height:Ne,links:[]}}function $wr(e){let t=e.length,n=[],r=[],a=[],i=[],o=0,s=0,c=(g,h,f)=>{n.push(g),r.push(e.slice(h,f)),a.push(h),s=f},u=(g)=>{i.push(o),o=g},l=()=>{i.length>0&&(o=i.pop())},d=(g)=>{let h=e.indexOf(`
|
|
554
554
|
`,g);return h===-1?t:h},p=(g)=>{for(;g<t&&Rn(e.charCodeAt(g));)g++;return g},A=(g)=>{for(;Pi(e.charCodeAt(g));)g++;return g},m=(g)=>Ep(e,s,g)&&!da(e.charCodeAt(s+g.length));for(;s<t;){let g=e.charCodeAt(s);if(o===5){if(g===34)s++,l();else{let f=e.indexOf('"',s);c(19,s,f===-1?t:f)}continue}if(o===6||o===7){c(f8t[o],s,d(s)),l();continue}if(o===8){if(g===125)s++,l();else{let f=e.indexOf("}",s);c(8,s,f===-1?t:f)}continue}let h=e.charCodeAt(s+1);if(g===37&&h===37){s=d(s+2);continue}if(g===10||g===13){if((o===1||o===3)&&(g===10||h===10)){c(2,s,g===10?s+1:s+2),l();continue}let f=s+1;for(let b=e.charCodeAt(f);b===10||b===13;b=e.charCodeAt(++f));c(2,s,f);continue}switch(g|32){case 116:if(m("title")){c(3,s,s+5);continue}break;case 97:if(Ep(e,s,"acc")){let f=Ep(e,s+3,"descr");if(f||Ep(e,s+3,"title")){let b=p(s+8),y=e.charCodeAt(b);if(y===58){c(f?6:4,s,p(b+1)),u(f?7:6);continue}if(y===123&&f){s=p(b+1),u(8);continue}}}break;case 120:if(m("xychart-beta")){c(9,s,s+12);continue}if(m("xychart")){c(9,s,s+7);continue}if(m("x-axis")){c(11,s,s+6),u(1);continue}break;case 121:if(m("y-axis")){c(12,s,s+6),u(1);continue}break;case 118:if(Ep(e,s,"vertical")){c(10,s,s+8);continue}break;case 104:if(Ep(e,s,"horizontal")){c(10,s,s+10);continue}break;case 108:if(m("line")){c(14,s,s+4),u(3);continue}break;case 98:if(m("bar")){c(15,s,s+3),u(3);continue}break}if(g===91){o===1?u(2):o===3&&u(4),c(17,s,s+1);continue}if(g===93){(o===4||o===2)&&l(),c(18,s,s+1);continue}if(o===1&&g===45&&h===45&&e.charCodeAt(s+2)===62){c(13,s,s+3);continue}if(o===1||o===4){let f=g===43||g===45?s+1:s,b=e.charCodeAt(f),y=-1;if(Pi(b)?(y=A(f+1),e.charCodeAt(y)===46&&Pi(e.charCodeAt(y+1))&&(y=A(y+2))):b===46&&Pi(e.charCodeAt(f+1))&&(y=A(f+2)),y!==-1){c(16,s,y);continue}}if(g===96&&Ep(e,s,h8t)){s+=h8t.length,l();continue}if(g===34){s++,u(5);continue}if(DM(g)){let f=s+1;for(;DM(e.charCodeAt(f));)f++;c(20,s,f);continue}if(Pi(g)){c(31,s,A(s+1));continue}if(Rn(g)){s=p(s+1);continue}if(g<128&&RTe[g]!==0){c(RTe[g],s,s+1);continue}break}return s<t?(n.push(1),r.push(""),a.push(s),{types:n,texts:r,starts:a}):(n.push(f8t[o]),r.push(""),a.push(t),n.push(0),r.push(""),a.push(t),{types:n,texts:r,starts:a})}function ONt(...e){let t=new Uint8Array(34);for(let n of e)t[n]=1;return t}function Owr(e,t){let{types:n,texts:r,starts:a}=$wr(e),i=0,o=(p)=>{let A=n[i];throw A===1?co("xychart",e,a[i],"",!0):co("xychart",e,a[i],`Expecting ${p}, got '${g8t[A]}'`)},s=(p)=>(n[i]!==p&&o(`'${g8t[p]}'`),r[i++]),c=(p)=>p===19||b8t[p]===1,u=()=>{c(n[i])||o("'STR', 'ALPHA', 'NUM'");let p=r[i++];if(n[i-1]!==19)for(;b8t[n[i]]===1;)p+=r[i++];return{text:p,type:"text"}},l=()=>{let p=Number(s(16));return s(13),[p,Number(s(16))]},d=()=>{let p=[];for(s(17);;){let A=Number(s(16));if(p.push({value:A,label:n[i]===19?r[i++]:""}),n[i]!==23)break;i++}return s(18),p};for(;;)if(y8t[n[i]]===1)i++;else{if(n[i]!==9)break;n[++i]===10&&t.setOrientation(r[i++])}for(;n[i]!==0;){let p=n[i++];switch(p){case 3:t.setDiagramTitle(u().text.trim());break;case 11:case 12:{let A=c(n[i])?u():void 0;if(p===11&&n[i]===17){let m=[];do i++,m.push(u());while(n[i]===23);s(18),t.setXAxisBand(m)}else if(n[i]===16||A===void 0){let[m,g]=l();p===11?t.setXAxisRangeData(m,g):t.setYAxisRangeData(m,g)}p===11?t.setXAxisTitle(A??{type:"text",text:""}):t.setYAxisTitle(A??{type:"text",text:""});break}case 14:case 15:{let A=n[i]===17?{text:"",type:"text"}:u(),m=d();p===14?t.setLineData(A,m):t.setBarData(A,m);break}case 4:t.setAccTitle(s(5).trim());break;case 6:t.setAccDescription(s(7).trim());break;case 8:t.setAccDescription(r[i-1].trim());break;default:i--,o("'title', 'X_AXIS', 'Y_AXIS', 'LINE', 'BAR', 'acc_title', 'acc_descr', 'acc_descr_multiline_value'")}for(;y8t[n[i]]===1;)i++}}function w8t(e,t){let n=e/Math.max(t,1),r=Math.floor(Math.log10(n)),a=n/10**r,i=a>=7.07?10:a>=3.16?5:a>=1.41?2:1;return r<0?-(10**-r)/i:i*10**r}function wae(e,t){return e>0?t/e:t*-e}function $O(e,t){return e>0?t*e:t/-e}function k8t(e,t,n){let r=Math.round(wae(n,e));$O(n,r)<e&&r++;let a=Math.round(wae(n,t));$O(n,a)>t&&a--;let i=[];for(let o=r;o<=a&&i.length<100;o++)i.push($O(n,o));return i}function FDe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function Lf(e,t,n=!0){let r=e[t];return typeof r=="boolean"?r:n}function _8t(e,t){return typeof e=="number"&&e>0?Math.round(Math.min(Math.max(e,100),4000)):t}function XC(e){return typeof e=="number"&&isFinite(e)?Math.min(Math.max(e,-x8t),x8t):void 0}function Gwr(e){let t=0;for(let n of e)t=Math.max(t,n.label.width);return t}function Ere(e,t,n,r){let a=e.lines.length===1?e.lines[0]:void 0;return a&&a.length===1&&a[0].icon===void 0&&a[0].style===0?`<text x="${J(t)}" y="${J(n+e.size*0.35)}" text-anchor="${r}">${$r(a[0].text)}</text>`:Xt(e,t+(r==="start"?e.width/2:r==="end"?-e.width/2:0),n,"")}function Uwr(e,t,n){if(e.plots.length===0)throw new Dr("No Plot to render, please provide a plot with some data","semantic",{type:"xychart"});let r=FDe(t.xyChart),a=n.fontSize??16,i=Math.round(a*0.875),o=Math.round(a*0.75),s=n.measurer??Ki(n.fontFamily,n.fontFamilyMono),c=n.padding??8,u=_8t(r.width,700),l=Iae(n,u,240),d=Math.round(_8t(r.height,500)*Math.max(0.6,l/u)),p=(e.orientation??r.chartOrientation)==="horizontal",A=Lf(r,"showDataLabel",!1),{xAxis:m,plots:g}=e,h=(it,bt,Ft)=>Cn(it,!1,s,bt,Ft),f=h("0",i,4000).height,b=h("0",o,4000).height,y=Cn(Lf(r,"showTitle")?e.title:void 0,!1,s,a,l-2*c,1),w=y.height>0?y.height+12:0,k=[],E=0;Lf(r,"showLegend")&&g.forEach((it,bt)=>{if(it.title==="")return;let Ft=h(it.title,i,l*0.3);k.push({index:bt,label:Ft}),E=Math.max(E,Ft.width+mM+8)});let B=k.length>0?E+C8t:0,x=g.filter((it)=>it.type==="bar").length,_=XC(e.yAxis.min)??1/0,Q=XC(e.yAxis.max)??-1/0,U=e.hasSetYAxis&&isFinite(_)&&isFinite(Q)&&_!==Q;if(!U){_=1/0,Q=-1/0;for(let it of g)for(let[,bt]of it.data){let Ft=XC(bt);Ft!==void 0&&(Ft<_&&(_=Ft),Ft>Q&&(Q=Ft))}_>Q&&(_=Q=0),x>0&&(_=Math.min(_,0),Q=Math.max(Q,0)),_===Q&&(_===0?Q=1:(_-=Math.abs(_)/2,Q+=Math.abs(Q)/2))}let O=(it,bt)=>{let Ft=w8t(Math.abs(Q-_),Math.max(2,Math.min(10,Math.floor(it/bt))));return U||(_=$O(Ft,Math.floor(wae(Ft,_)+0.000000001)),Q=$O(Ft,Math.ceil(wae(Ft,Q)-0.000000001))),k8t(Math.min(_,Q),Math.max(_,Q),Ft).map((Ot)=>({at:(Ot-_)/(Q-_),label:h(String(Ot),i,4000)}))},R=1;if(m.type==="band")R=Math.max(m.categories.length,1);else for(let it of g)R=Math.max(R,it.data.length);let G=1/R,q=m.type==="band"||x>0?G/2:0,N=XC(m.type==="linear"?m.min:void 0),L=XC(m.type==="linear"?m.max:void 0),D=N!==void 0&&L!==void 0&&N!==L,P=(it,bt)=>m.type==="band"?(it+0.5)*G:q+(bt>1?it/(bt-1):D?0:0.5)*(1-2*q),F=FDe(r.xAxis),oe=FDe(r.yAxis),V=p?F:oe,H=p?oe:F,X=h(Lf(V,"showTitle")?p?m.title:e.yAxis.title:void 0,i,d*0.8),z=h(Lf(H,"showTitle")?p?e.yAxis.title:m.title:void 0,i,l*0.8),te=Lf(V,"showTick")?E8t:0,Y=Lf(H,"showTick")?E8t:0,ne=Lf(V,"showLabel"),K=Lf(H,"showLabel"),re=p?l*0.3:Math.max(48,(l-2*c-64-B)*G-8),ae=m.type==="band"&&Lf(F,"showLabel")?m.categories.map((it)=>h(it,i,re)):[],pe=0,le=0;for(let it of ae)pe=Math.max(pe,it.width),le=Math.max(le,it.height);let ee=(it)=>{let bt=[];if(m.type==="band"){let Ft=ae.length===0?8:p?le:pe+12,Ot=Math.max(1,Math.ceil(Ft/(it*G)));for(let tn=0;tn<m.categories.length;tn+=Ot)bt.push({at:(tn+0.5)*G,label:ae[tn]??h(void 0,i,0)})}else if(D){let Ft=w8t(Math.abs(L-N),Math.max(2,Math.min(10,Math.floor(it/(p?32:80)))));for(let Ot of k8t(Math.min(N,L),Math.max(N,L),Ft))bt.push({at:q+(Ot-N)/(L-N)*(1-2*q),label:h(String(Ot),i,4000)})}else N!==void 0&&bt.push({at:0.5,label:h(String(N),i,4000)});return bt},ce=0,fe=0;for(let it of g){for(let bt of it.pointLabels??[])ce=Math.max(ce,s.width(bt,o,0));if(A&&p&&it.type==="bar")for(let[,bt]of it.data)fe=Math.max(fe,s.width(String(XC(bt)??""),o,0))}let de=K?p||m.type!=="band"?f:le:0,Ae=Y+(de>0?de+4:0)+(z.height>0?z.height+4:0),ue=p?0:ce>0||A?b+4:ne?f/2:0,ie=c+w+ue,ke=Math.max(1,d-c-Ae-ie),xe=ie+ke,Ne=p?ee(ke):O(ke,56),Ee=ne?Gwr(Ne):0,be=c+(X.height>0?X.height+6:0)+(Ee>0?Ee+6:0)+te,Be=Math.max(ce>0?ce+12:0,fe>0?fe+8:0),Le=p?Math.min(l*0.25,Be):0,Ve=Math.max(1,l-c-be-B-Le),tt=p?O(Ve,80):ee(Ve);if(K&&B+Le===0){let it=0;for(let bt of tt)it=Math.max(it,bt.at*Ve+bt.label.width/2-Ve);Ve=Math.max(1,Ve-it)}let Ye=be+Ve,et=(it,bt)=>p?be+bt*Ve:be+it*Ve,ge=(it,bt)=>p?ie+it*ke:xe-bt*ke,we=(it)=>(it-_)/(Q-_),Ce=(it)=>Math.min(Math.max(it,0),1),Me=(it)=>p?`M${J(et(0,it))},${J(ie)}V${J(xe)}`:`M${J(be)},${J(ge(0,it))}H${J(Ye)}`,We="";for(let it of p?tt:Ne)We+=Me(it.at);let ve="",Ze="";Lf(V,"showAxisLine")&&(ve+=`M${J(be)},${J(ie)}V${J(xe)}`),Lf(H,"showAxisLine")&&(ve+=`M${J(be)},${J(xe)}H${J(Ye)}`);for(let it of Ne){let bt=p?ie+it.at*ke:xe-it.at*ke;te&&(ve+=`M${J(be)},${J(bt)}h${-te}`),ne&&(Ze+=Ere(it.label,be-te-6,bt,"end"))}for(let it of tt){let bt=be+it.at*Ve;Y&&(ve+=`M${J(bt)},${J(xe)}v${Y}`),K&&(Ze+=Ere(it.label,bt,xe+Y+4+it.label.height/2,"middle"))}let st=(p?ke:Ve)*G,Ie=st*0.7/Math.max(x,1),Oe=x>1?Math.min(2,Ie*0.2):0,lt=Ce(we(0));x>0&<>0&<<1&&(ve+=Me(lt));let ze="",rt="",Te="",qe="",Ge=0;g.forEach((it,bt)=>{let Ft=ho(bt),Ot=it.title?` data-id="${kn(it.title)}"`:"",tn=m.type==="band"?Math.min(it.data.length,R):it.data.length;if(it.type==="bar"){let Kt=(Ge++-(x-1)/2)*Ie-(Ie-Oe)/2,an="";for(let Tt=0;Tt<tn;Tt++){let dn=XC(it.data[Tt][1]);if(dn===void 0)continue;let $t=P(Tt,tn),En=Ce(we(dn)),ar=Math.min(lt,En),In=Math.max(lt,En),Ut=p?et($t,ar):et($t,0)+Kt,Lr=p?ge($t,0)+Kt:ge($t,In),vr=p?(In-ar)*Ve:Ie-Oe,ia=p?Ie-Oe:(In-ar)*ke;if(an+=`<rect x="${J(Ut)}" y="${J(Lr)}" width="${J(vr)}" height="${J(ia)}"/>`,!A)continue;let Ca=String(dn),uo=s.width(Ca,o,0),qi=En>=lt?1:-1,zt=Ut+vr/2,Ht=Lr+ia/2,xn="middle";if(p){if(ia<o)continue;zt=(qi>0?Ut+vr:Ut)+qi*6,xn=qi>0?"start":"end"}else{if(uo+2>st/x)continue;Ht=(qi>0?Lr:Lr+ia)-qi*(b/2+2)}Te+=`<text x="${J(zt)}" y="${J(Ht+o*0.35)}" text-anchor="${xn}">${Ca}</text>`}ze+=`<g class="pele-series pele-bars"${Ot} fill="${Ft}">${an}</g>`;return}let ot="",Bt="",St=!1,It=0,Gt=NaN;for(let Kt=0;Kt<tn;Kt++){let an=XC(it.data[Kt][1]);if(an===void 0){Gt=NaN;continue}let Tt=P(Kt,tn),dn=we(an),$t=dn>=0&&dn<=1;if(Gt!==Gt)$t&&(ot+=`M${J(et(Tt,dn))},${J(ge(Tt,dn))}`),St=$t;else{let Ut=dn-Gt,Lr=0,vr=1;if(Ut!==0){let ia=-Gt/Ut,Ca=(1-Gt)/Ut;Lr=Math.max(Lr,Math.min(ia,Ca)),vr=Math.min(vr,Math.max(ia,Ca))}else $t||(Lr=2);if(Lr<=vr){let ia=It+(Tt-It)*Lr,Ca=Gt+Ut*Lr,uo=It+(Tt-It)*vr,qi=Gt+Ut*vr;(!St||Lr>0)&&(ot+=`M${J(et(ia,Ca))},${J(ge(ia,Ca))}`),ot+=`L${J(et(uo,qi))},${J(ge(uo,qi))}`}St=$t}if(It=Tt,Gt=dn,!$t)continue;let En=et(Tt,dn),ar=ge(Tt,dn);st>=12&&(Bt+=`<circle cx="${J(En)}" cy="${J(ar)}" r="3"/>`);let In=h(it.pointLabels?.[Kt],o,4000);if(In.height>0){let Ut=In.width/2;qe+=p?Ere(In,En+10,ar,"start"):Ere(In,Math.max(Math.min(En,Ye-Ut),be+Ut),ar-6-In.height/2,"middle")}}rt+=`<g class="pele-series pele-line"${Ot} fill="${Ft}">`+(ot?`<path d="${ot}" fill="none" stroke="${Ft}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`:"")+Bt+"</g>"});let ct="";X.height>0&&(ct+=`<g transform="translate(${J(c+X.height/2)},${J(ie+ke/2)}) rotate(-90)">${Xt(X,0,0,"")}</g>`),ct+=Xt(z,be+Ve/2,d-c-z.height/2,"");let Qe="",He=0;for(let it of k)He+=Math.max(B8t,it.label.height+6);let at=ie+Math.max(0,(ke-He)/2),$e=Ye+Le+C8t;for(let{index:it,label:bt}of k){let Ft=Math.max(B8t,bt.height+6);if(at+Ft>d)break;let Ot=at+Ft/2,tn=ho(it);Qe+=`<g class="pele-legend-item" data-id="${kn(g[it].title)}">`+(g[it].type==="bar"?`<rect x="${J($e)}" y="${J(Ot-mM/2)}" width="${mM}" height="${mM}" rx="2" fill="${tn}"/>`:`<path d="M${J($e)},${J(Ot)}h${mM}" stroke="${tn}" stroke-width="2" stroke-linecap="round"/>`)+Xt(bt,$e+mM+8+bt.width/2,Ot,"")+"</g>",at+=Ft}let kt=Xt(y,l/2,c+y.height/2,' class="pele-title" font-weight="var(--_tw)"')+(We?`<path class="pele-grid" d="${We}" stroke="var(--_a)"/>`:"")+`<g class="pele-plot">${ze}${rt}</g>`+(ve?`<path class="pele-axis" d="${ve}" fill="none" stroke="var(--_b)"/>`:"")+(Ze?`<g class="pele-axis-labels" font-size="${i}" fill="var(--_m)">${Ze}</g>`:"")+(ct?`<g class="pele-axis-titles" font-size="${i}">${ct}</g>`:"")+(Te?`<g class="pele-data-labels" font-size="${o}">${Te}</g>`:"")+(qe?`<g class="pele-point-labels" font-size="${o}">${qe}</g>`:"")+(Qe?`<g class="pele-legend" font-size="${i}">${Qe}</g>`:"");return{svg:Ni("xychart",l,d,a,n,e,kt),width:l,height:d,links:[]}}var Eor,Dr,xM,_or="amp:38,lt:60,gt:62,quot:34,apos:39,nbsp:160,shy:173,iexcl:161,cent:162,pound:163,curren:164,yen:165,sect:167,copy:169,laquo:171,not:172,reg:174,deg:176,plusmn:177,sup2:178,sup3:179,micro:181,para:182,middot:183,sup1:185,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,euro:8364,trade:8482,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,radic:8730,infin:8734,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830,check:10003,cross:10007,AMP:38,LT:60,GT:62,QUOT:34,lsqb:91,rsqb:93,lcub:123,rcub:125,verbar:124,VerticalLine:124,midast:42,DiacriticalGrave:96,Hat:94,UnderBar:95,equals:61,colon:58,semi:59,num:35,percnt:37,lpar:40,rpar:41,lbrack:91,rbrack:93,lbrace:123,rbrace:125,vert:124,sol:47,bsol:92,quest:63,excl:33,ast:42,plus:43,comma:44,period:46,dollar:36,commat:64,grave:96,hat:94,lowbar:95,tilde:126,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969",pne,Ior,SMt="\uFB02\xB0",v8t="\xB6\xDF",Sor,EO,BO,K0,_M,bM=class{constructor(e){this.message=e}message},I8t=64,jor=class{lines;i=0;constructor(e){this.lines=(e.includes("\r")?e.replace(/\r\n?/g,`
|
|
555
555
|
`):e).split(`
|
|
@@ -584,7 +584,7 @@ but found: '${Kl(cn)}'`);(oy[Nr[cn]]&QTe)!==0;)cn++;return lA.slice(rd[e],uA[cn-
|
|
|
584
584
|
`+a+`
|
|
585
585
|
}`)}catch(d){throw new Dr(`Config of participant "${e}" is not valid YAML. ${d.message}`,"syntax",{type:"sequence"})}l!==null&&typeof l=="object"&&!Array.isArray(l)&&(o=l)}let s=o&&Object.prototype.hasOwnProperty.call(o,"type")?o.type:void 0,c=o&&Object.prototype.hasOwnProperty.call(o,"alias")?o.alias:void 0;s!=null&&(r=String(s)),c&&(!n||n.text===t)&&(n={text:String(c),wrap:n?.wrap,type:r});let u=this.actors.get(e);if(!(u&&(this.currentBox&&u.box&&this.currentBox!==u.box&&sO(`A same participant should only be defined in one Box: ${u.name} can't be in '${u.box.name}' and in '${this.currentBox.name}' at the same time.`),i=u.box?u.box:this.currentBox,u.box=i,t===u.name&&n==null))){if((n?.text==null||r==null)&&(n={text:t,type:r}),this.actors.set(e,{box:i,name:t,description:n.text,wrap:n.wrap??this.autoWrap(),prevActor:this.prevActor,links:new Map,properties:new Map,type:r??"participant"}),this.prevActor){let l=this.actors.get(this.prevActor);l&&(l.nextActor=e)}this.currentBox&&this.currentBox.actorKeys.push(e),this.prevActor=e}}addMessage(e,t,n,r){this.messages.push({id:String(this.messages.length),from:e,to:t,message:n.text,wrap:n.wrap??this.autoWrap(),answer:r})}addSignal(e,t,n,r,a=!1,i){if(r===18){let o=e?this.active.get(e)??0:0;o<1&&sO(`Trying to inactivate an inactive participant (${e})`),this.active.set(e,o-1)}else r===17&&e&&this.active.set(e,(this.active.get(e)??0)+1);return this.messages.push({id:String(this.messages.length),from:e,to:t,message:n?.text??"",wrap:n?.wrap??this.autoWrap(),type:r,activate:a,centralConnection:i??0}),!0}addNote(e,t,n){let r=n.wrap??this.autoWrap(),a={actor:e,placement:t,message:n.text,wrap:r},i=typeof e=="string"?[e,e]:e;this.notes.push(a),this.messages.push({id:String(this.messages.length),from:i[0],to:i[1],message:n.text,wrap:r,type:2,placement:t})}addLinks(e,t){let n=this.actors.get(e);if(n)try{let r=JSON.parse(t.text);for(let[a,i]of aPt(r))n.links.set(a,i)}catch{return}}addALink(e,t){let n=this.actors.get(e);if(!n)return;let r=t.text.indexOf("@");n.links.set(t.text.slice(0,r-1).trim(),t.text.slice(r+1).trim())}addProperties(e,t){let n=this.actors.get(e);if(n)try{let r=JSON.parse(t.text);for(let[a,i]of aPt(r))n.properties.set(a,i)}catch{return}}addDetails(e,t){let n=this.actors.get(e);n&&(n.details=t.text)}apply(e){let t=[],n=[],r=e;for(;;){r!==void 0&&(Array.isArray(r)?(t.push(r),n.push(0)):typeof r!="string"&&this.applyOne(r));let a=t.length-1;if(a<0)return;let i=t[a];n[a]<i.length?r=i[n[a]++]:(t.pop(),n.pop(),r=void 0)}}applyOne(e){let t=e.actor;switch(e.type){case"sequenceIndex":this.messages.push({id:String(this.messages.length),from:void 0,to:void 0,message:{start:e.sequenceIndex,step:e.sequenceIndexStep,visible:e.sequenceVisible===!0},wrap:!1,type:e.signalType});break;case"addParticipant":this.addActor(t,t,e.description,e.draw,e.config);break;case"createParticipant":this.actors.has(t)&&sO("It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior"),this.lastCreated=t,this.addActor(t,t,e.description,e.draw,e.config),this.createdActors.set(t,this.messages.length);break;case"destroyParticipant":this.lastDestroyed=t,this.destroyedActors.set(t,this.messages.length);break;case"activeStart":case"activeEnd":case"centralConnection":case"centralConnectionReverse":this.addSignal(t,void 0,void 0,e.signalType);break;case"addNote":this.addNote(e.actor,e.placement,e.text);break;case"addLinks":this.addLinks(t,e.text);break;case"addALink":this.addALink(t,e.text);break;case"addProperties":this.addProperties(t,e.text);break;case"addDetails":this.addDetails(t,e.text);break;case"addMessage":this.lastCreated?(e.to!==this.lastCreated&&sO(`The created participant ${this.lastCreated} does not have an associated creating message after its declaration. Please check the sequence diagram.`),this.lastCreated=void 0):this.lastDestroyed&&(e.to!==this.lastDestroyed&&e.from!==this.lastDestroyed&&sO(`The destroyed participant ${this.lastDestroyed} does not have an associated destroying message after its declaration. Please check the sequence diagram.`),this.lastDestroyed=void 0),this.addSignal(e.from,e.to,e.msg,e.signalType,e.activate,e.centralConnection);break;case"boxStart":this.addBox(e.boxData);break;case"boxEnd":this.currentBox=void 0;break;case"loopStart":this.addSignal(void 0,void 0,e.loopText,e.signalType);break;case"rectStart":this.addSignal(void 0,void 0,e.color,e.signalType);break;case"optStart":this.addSignal(void 0,void 0,e.optText,e.signalType);break;case"altStart":case"else":this.addSignal(void 0,void 0,e.altText,e.signalType);break;case"parStart":case"and":this.addSignal(void 0,void 0,e.parText,e.signalType);break;case"criticalStart":this.addSignal(void 0,void 0,e.criticalText,e.signalType);break;case"option":this.addSignal(void 0,void 0,e.optionText,e.signalType);break;case"breakStart":this.addSignal(void 0,void 0,e.breakText,e.signalType);break;case"loopEnd":case"rectEnd":case"optEnd":case"altEnd":case"parEnd":case"criticalEnd":case"breakEnd":this.addSignal(void 0,void 0,void 0,e.signalType);break}}},iPt,lNt,fs,rw,Pbr="'SOLID_OPEN_ARROW', 'DOTTED_OPEN_ARROW', 'SOLID_ARROW', 'DOTTED_ARROW', 'SOLID_CROSS', 'DOTTED_CROSS', 'SOLID_POINT', 'DOTTED_POINT'",$br=16,Obr=10,uNt=34,dNt=4,uQ=5,lQ=6,uE=' fill="var(--_s)" stroke="var(--_b)"',fM=' fill="none" stroke="var(--_b)"',Gbr,Ubr,nRe,Jbr,Kbr=12,dDe=28,oPt=22,jf=10,sPt=4,Ybr=14,dM=10,Zbr=16,Vbr=20,Xbr=10,tre=20,cPt=240,nre=16,pM=4,lPt=' stroke-dasharray="4 4"',uPt,ryr,oyr=class{type="state";rootDoc=[];states=new Map;relations=[];classes=new Map;links=new Map;graph={nodes:[],edges:[]};title;accTitle;accDescr;dividerCount=0;get direction(){let e="TB";for(let t of this.rootDoc)typeof t!="string"&&t.stmt==="dir"&&(e=t.value);return e}setRootDoc(e){this.rootDoc=e,this.translate(),this.extract(e)}extract(e){this.states=new Map,this.relations=[],this.classes=new Map;let t=Array.isArray(e)?e:e.doc;for(let n of t)if(typeof n!="string")switch(n.stmt){case"state":this.addState(n.id.trim(),n.type,n.doc,n.description,n.note);break;case"relation":this.addRelation(n.state1,n.state2,n.description);break;case"classDef":this.addStyleClass(n.id.trim(),n.classes);break;case"style":{let r=n.styleClass.split(",").map((a)=>a.replace(/;/g,"").trim());for(let a of this.named(n.id.trim()))a.styles=r.slice();break}case"applyClass":this.setCssClass(n.id.trim(),n.styleClass);break;case"click":this.addLink(typeof n.id=="string"?n.id:n.id.id,n.url,n.tooltip);break}this.graph=iyr(t,this.states,this.classes)}translate(){let e=[["root",{stmt:"root",id:"root",doc:this.rootDoc},!0]];for(;e.length>0;){let[t,n,r]=e.pop();if(typeof n=="string")continue;if(n.stmt==="relation"){e.push([t,n.state2,!1],[t,n.state1,!0]);continue}if(n.stmt==="state")n.id==="[*]"?(n.id=t+(r?"_start":"_end"),n.start=r):n.id=n.id.trim();else if(n.stmt!=="root")continue;if(!n.doc)continue;let a=[],i=[];for(let o of n.doc)typeof o!="string"&&o.stmt==="state"&&o.type==="divider"&&!o.doc?(a.push({...o,doc:i}),i=[]):i.push(o);a.length>0&&(i.length>0&&a.push({stmt:"state",id:this.getDividerId(),type:"divider",doc:i}),n.doc=a);for(let o=n.doc.length-1;o>=0;o--)e.push([n.id,n.doc[o],!0])}}addState(e,t="default",n,r,a,i){let o=e.trim(),s=this.states.get(o);if(s?(s.doc||(s.doc=n),s.type||(s.type=t)):(s={stmt:"state",id:o,descriptions:[],type:t,doc:n,note:a,classes:[],styles:[],textStyles:[]},this.states.set(o,s)),r)for(let c of Array.isArray(r)?r:[r])this.addDescription(o,c.trim());if(a&&(s.note=a),i)for(let c of i)this.setCssClass(o,c.trim())}getState(e){return this.states.get(e)}addLink(e,t,n){this.links.set(e,{url:t,tooltip:n})}addRelation(e,t,n=""){for(let r of[e,t])this.addState(r.id,r.type,r.doc,r.description,r.note,r.classes);this.relations.push({id1:e.id.trim(),id2:t.id.trim(),relationTitle:n})}addDescription(e,t){this.states.get(e)?.descriptions?.push(t.startsWith(":")?t.replace(":","").trim():t)}getDividerId(){return`divider-id-${++this.dividerCount}`}addStyleClass(e,t=""){let n=this.classes.get(e);if(n||(n={id:e,styles:[],textStyles:[]},this.classes.set(e,n)),!!t)for(let r of t.split(",")){let a=r.replace(";","").trim();r.includes("color")&&n.textStyles.push(a.replace("fill","bgFill").replace("color","fill")),n.styles.push(a)}}setCssClass(e,t){for(let n of this.named(e))n.classes?.push(t)}getDirection(){for(let e of this.rootDoc)if(typeof e!="string"&&e.stmt==="dir")return e.value;return"TB"}setDirection(e){for(let t of this.rootDoc)if(typeof t!="string"&&t.stmt==="dir"){t.value=e;return}this.rootDoc.unshift({stmt:"dir",value:e})}trimColon(e){return e.startsWith(":")?e.slice(1).trim():e.trim()}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
586
586
|
`)}named(e){let t=[];for(let n of e.split(",")){let r=this.states.get(n);r||(this.addState(n),r=this.states.get(n.trim())),r&&t.push(r)}return t}},pPt,syr,cyr,lyr,uyr,dyr,Ayr,are="'NL', 'ID', 'HIDE_EMPTY', 'scale', 'COMPOSIT_STATE', 'STATE_DESCR', 'FORK', 'JOIN', 'CHOICE', 'CONCURRENT', 'note', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLICK', 'classDef', 'style', 'class', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'EDGE_STATE'",gyr=40,fyr=16,hyr=44,CM=16,pDe=10,byr=16,APt=10,ADe=26,mPt=8,yyr=320,mDe=10,gPt=8,fPt=' fill="var(--_s)" stroke="var(--_b)"',ire=' fill="none" stroke="var(--_b)"',wyr,kyr,Eyr,xyr,_yr=34,vyr=24,Iyr=8,Qyr=20000,kPt=1e4,fDe=2000000,EPt=4,Syr=3,BPt=8,hDe=20,CPt=20,xPt=14,Dyr=3,vPt="__swimlane_default__",jyr,Lyr,Pyr=class{type="timeline";title;accTitle;accDescr;direction="LR";sections=[];periods=[];currentSection="";getCommonDb(){return this}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
587
|
-
`)}setDirection(e){this.direction=e}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t,n){this.periods.push({text:e,events:n?[n]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(e){let t=this.periods[this.periods.length-1];if(!t)throw new Dr("An event needs a time period before it.","semantic",{type:"timeline"});t.events.push(e)}},Nyr,Oyr="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'",cre=12,IPt=8,Uyr=152,qyr=216,Hyr=264,aQ=20,AM=20,lre=14,lO=8,bDe=8,ure=12,Wyr=' fill="var(--_bg)"',QPt=' fill="none" stroke="var(--_b)"',Jyr,_Te,ANt,Kyr,DPt,Yyr,Zyr,Vyr,Xyr=" ",RPt,MPt,c0r=class{count=1;root={id:0,level:-1,name:"/",nodeType:"directory",children:[]};stack=[this.root];addNode(e,t,n,r,a,i){let o=this.stack;for(;e<=o[o.length-1].level;)o.pop();let s={id:this.count++,level:e,name:t,nodeType:n,icon:a,cssClass:r,description:i,children:[]};o[o.length-1].children.push(s),o.push(s)}},gae="mermaid-treeview",vTe,m0r=6,g0r=16,f0r=7,h0r=4,dre=4,k0r,LPt,C0r,PPt,Are=(e,t,n)=>e>=t?Math.min(e,n):t,EDe=28,Q0r=18,BDe=6,iQ=1.25,OPt=(e)=>$r(Qo(e).trim()).trim(),T0r,fNt,r5=1,hNt=2,ux,UPt,gm,wNt=1,rRe=2,QTe=4,kNt=8,ENt=16,BNt=32,CNt=64,qae="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",Hae="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",G0r="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",xNt="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",_Nt="WORD|PLAIN_STRING|NUMBER|HASH_COLOR|CSS_IDENTIFIER|CSS_ESCAPED_COMMA|DASH|DOT|PERCENT|CSS_PUNCTUATION|COLON|LPAREN|RPAREN|LBRACKET|RBRACKET|LBRACE|RBRACE|AT|MARKERLESS_SOLID",oy,U0r,lA="",Nr,rd,uA,
|
|
587
|
+
`)}setDirection(e){this.direction=e}addSection(e){this.currentSection=e,this.sections.push(e)}addTask(e,t,n){this.periods.push({text:e,events:n?[n]:[],section:this.currentSection,sectionIndex:this.sections.length-1})}addEvent(e){let t=this.periods[this.periods.length-1];if(!t)throw new Dr("An event needs a time period before it.","semantic",{type:"timeline"});t.events.push(e)}},Nyr,Oyr="'EOF', 'SPACE', 'NEWLINE', 'title', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'section', 'period', 'event'",cre=12,IPt=8,Uyr=152,qyr=216,Hyr=264,aQ=20,AM=20,lre=14,lO=8,bDe=8,ure=12,Wyr=' fill="var(--_bg)"',QPt=' fill="none" stroke="var(--_b)"',Jyr,_Te,ANt,Kyr,DPt,Yyr,Zyr,Vyr,Xyr=" ",RPt,MPt,c0r=class{count=1;root={id:0,level:-1,name:"/",nodeType:"directory",children:[]};stack=[this.root];addNode(e,t,n,r,a,i){let o=this.stack;for(;e<=o[o.length-1].level;)o.pop();let s={id:this.count++,level:e,name:t,nodeType:n,icon:a,cssClass:r,description:i,children:[]};o[o.length-1].children.push(s),o.push(s)}},gae="mermaid-treeview",vTe,m0r=6,g0r=16,f0r=7,h0r=4,dre=4,k0r,LPt,C0r,PPt,Are=(e,t,n)=>e>=t?Math.min(e,n):t,EDe=28,Q0r=18,BDe=6,iQ=1.25,OPt=(e)=>$r(Qo(e).trim()).trim(),T0r,fNt,r5=1,hNt=2,ux,UPt,gm,wNt=1,rRe=2,QTe=4,kNt=8,ENt=16,BNt=32,CNt=64,qae="DEPENDENCY_ARROW|GENERALIZATION|FORWARD_SOLID|BACKWARD_SOLID|MARKERLESS_SOLID|FORWARD_CIRCLE|BACKWARD_CIRCLE|FORWARD_CROSS|BACKWARD_CROSS",Hae="IDENTIFIER|PLAIN_STRING|MARKDOWN_STRING",G0r="PLAIN_STRING|MARKDOWN_STRING|LABEL_TEXT",xNt="ACC_TITLE_LINE|ACC_DESCR_LINE|ACC_DESCR_BLOCK|DIRECTION|ACTOR|SYSTEM_BOUNDARY|NOTE|JSON_DECLARATION_START|CLASS_DEF|CLASS|STYLE",_Nt="WORD|PLAIN_STRING|NUMBER|HASH_COLOR|CSS_IDENTIFIER|CSS_ESCAPED_COMMA|DASH|DOT|PERCENT|CSS_PUNCTUATION|COLON|LPAREN|RPAREN|LBRACKET|RBRACKET|LBRACE|RBRACE|AT|MARKERLESS_SOLID",oy,U0r,lA="",Nr,rd,uA,ln=0,vNt=0,ed,fae,Ure,INt=0,QNt=0,J0r,IDe,V0r=32,X0r=16,ewr=72,hre=20,QDe=26,lRe=40,PO=60,t8t=6,SDe=6,pO=10,DDe=8,bre=9,qre=12,twr=14,NO=' fill="var(--_s)" stroke="var(--_b)"',lwr,uwr=class{type="venn";title;subsets=[];textNodes=[];styles=[];known=new Set;current;indent=!1;setDiagramTitle(e){this.title=e}addSubsetData(e,t,n){let r=TDe(e);this.current=r,r.length===1&&this.known.add(r[0]),this.subsets.push({sets:r,size:n??10/e.length**2,label:t?dQ(t):void 0})}addTextData(e,t,n){this.textNodes.push({sets:TDe(e),id:dQ(t),label:n?dQ(n):void 0})}addStyleData(e,t){let n=new Map;for(let[r,a]of t)n.set(r,a&&dQ(a));this.styles.push({targets:TDe(e),styles:n})}validateUnionIdentifiers(e){let t=e.map(dQ).filter((n)=>!this.known.has(n));if(t.length>0)throw new Dr(`unknown set identifier: ${t.join(", ")}`,"semantic",{type:"venn"})}getCurrentSets(){return this.current}getIndentMode(){return this.indent}setIndentMode(e){this.indent=e}},a8t,dwr,pwr=class{constructor(e,t){this.src=e,this.host=t}src;host;text="";start=0;at=0;lineStart=!1;ended=!1;word(e,t){let n=this.src;for(let r=0;r<t.length;r++){let a=n.charCodeAt(e+r),i=t.charCodeAt(r);if(a!==i&&(a+32!==i||a<65||a>90))return!1}return!0}keyword(e,t){return this.word(e,t)&&!da(this.src.charCodeAt(e+t.length))}color(e,t){let n=this.src,r=e+1;for(let a=0;a<t;a++){for(;Rn(n.charCodeAt(r));)r++;let i=r;for(;Pi(n.charCodeAt(r))||n.charCodeAt(r)===46;)r++;if(r===i)return-1;for(;Rn(n.charCodeAt(r));)r++;if(n.charCodeAt(r)!==(a===t-1?41:44))return-1;r++}return r}afterLineFeed(e){let t=e-1;for(;this.src.charCodeAt(t)===32||this.src.charCodeAt(t)===9;)t--;return this.src.charCodeAt(t)===10}lineEnd(e){let t=this.src.indexOf(`
|
|
588
588
|
`,e);return t===-1?this.src.length:t}next(){let e=this.src,t=e.length;for(;;){let n=this.at;if(this.start=n,this.text="",n>=t)return this.ended?0:(this.ended=!0,2);let r=e.charCodeAt(n);if(r===37&&e.charCodeAt(n+1)===37&&e.charCodeAt(n+2)!==123){this.at=this.lineEnd(n+2);continue}if(this.lineStart&&this.word(n,"title")&&this.afterLineFeed(n)&&e.slice(n+5,this.lineEnd(n+5)).trim()===""){let a=this.lineEnd(n+5);for(;e.charCodeAt(a)===10||e.charCodeAt(a)===13;)a++;this.at=a;continue}if(this.lineStart){if(r===32||r===9){let a=n+1;for(;e.charCodeAt(a)===32||e.charCodeAt(a)===9;)a++;if(this.at=a,this.keyword(a,"text")&&this.host.getIndentMode())return this.at=a+4,this.lineStart=!1,this.text=e.slice(n,a),9;continue}r!==10&&r!==13&&(this.host.setIndentMode(!1),this.lineStart=!1)}if(r===10||r===13){for(n++;e.charCodeAt(n)===10||e.charCodeAt(n)===13;)n++;return this.lineStart=!0,this.token(3,n)}if(r===37&&e.charCodeAt(n+1)===37){this.at=this.lineEnd(n);continue}if(r===32||r===9){for(n++;e.charCodeAt(n)===32||e.charCodeAt(n)===9;)n++;this.at=n;continue}if((r|32)>=97&&(r|32)<=122||r===95){let a=e.charCodeAt(n+5);if(this.word(n,"title")&&Rn(a)&&a!==10&&a!==13){let i=n+6;for(;i<t;){let o=e.charCodeAt(i);if(o===35||o===10||o===59)break;i++}if(i>n+6)return this.token(5,i)}for(let[i,o]of dwr)if(this.keyword(n,i)&&e.charCodeAt(n+i.length)!==45)return this.token(o,n+i.length);if(this.word(n,"rgb")){let i=(e.charCodeAt(n+3)|32)===97,o=n+(i?4:3),s=e.charCodeAt(o)===40?this.color(o,i?4:3):-1;if(s!==-1)return this.token(i?15:14,s)}for(n++;da(e.charCodeAt(n))||e.charCodeAt(n)===45;)n++;return this.token(16,n)}if(r===91){if(e.charCodeAt(n+1)===34){let i=e.indexOf('"',n+2);return i===-1||e.charCodeAt(i+1)!==93?1:(this.at=i+2,this.text=e.slice(n+2,i),11)}let a=n+1;for(;a<t&&e.charCodeAt(a)!==93&&e.charCodeAt(a)!==34;)a++;return a===n+1||e.charCodeAt(a)!==93?1:(this.at=a+1,this.text=e.slice(n+1,a).trim(),11)}if(Pi(r)||r===46||r===43||r===45){(r===43||r===45)&&n++;let a=n;for(;Pi(e.charCodeAt(n));)n++;if(n>a){if(e.charCodeAt(n)===46&&Pi(e.charCodeAt(n+1)))for(n+=2;Pi(e.charCodeAt(n));)n++}else if(e.charCodeAt(n)===46&&Pi(e.charCodeAt(n+1)))for(n+=2;Pi(e.charCodeAt(n));)n++;else return 1;return this.token(12,n)}if(r===35){let a=n+1;for(;a<n+9&&Q8t(e.charCodeAt(a));)a++;return a>=n+4?this.token(13,a):1}if(r===34){let a=e.indexOf('"',n+1);return a===-1?1:this.token(17,a+1)}return r===44?this.token(18,n+1):r===58?this.token(19,n+1):1}}token(e,t){return this.text=this.src.slice(this.at,t),this.at=t,e}},Awr="'EOF', 'NEWLINE', 'TITLE', 'SET', 'UNION', 'TEXT', 'INDENT_TEXT', 'STYLE'",mwr="'NUMERIC', 'IDENTIFIER', 'STRING', 'HEXCOLOR', 'RGBCOLOR', 'RGBACOLOR'",bae,kwr=100,Ewr=1.6,o8t,Cwr,xwr=class{nodes=new Map;labels;links=[];trends=new Map;pipelines=new Map;annotations=[];notes=[];accelerators=[];deaccelerators=[];annotationsBox;axes={};size;addNode(e){let t=this.nodes.get(e.id)??{id:e.id,label:e.label};this.nodes.set(e.id,{...t,...e,className:e.className??t.className,labelOffsetX:e.labelOffsetX??t.labelOffsetX,labelOffsetY:e.labelOffsetY??t.labelOffsetY}),this.labels=void 0}addLink(e){this.links.push(e)}addTrend(e){this.trends.set(e.nodeId,e)}startPipeline(e){this.pipelines.set(e,{nodeId:e,componentIds:[]});let t=this.nodes.get(e);t&&(t.isPipelineParent=!0)}addPipelineComponent(e,t){this.pipelines.get(e)?.componentIds.push(t);let n=this.nodes.get(t);n&&(n.inPipeline=!0)}addAnnotation(e){this.annotations.push(e)}addNote(e){this.notes.push(e)}addAccelerator(e){this.accelerators.push(e)}addDeaccelerator(e){this.deaccelerators.push(e)}setAnnotationsBox(e,t){this.annotationsBox={x:e,y:t}}setAxes(e){this.axes={...this.axes,...e}}setSize(e,t){this.size={width:e,height:t}}getNode(e){return this.nodes.get(e)}resolveNodeId(e){if(this.nodes.has(e))return e;if(!this.labels){this.labels=new Map;for(let[t,n]of this.nodes)this.labels.has(n.label)||this.labels.set(n.label,t)}return this.labels.get(e)??e}build(){let e=[];for(let t of this.nodes.values()){if(typeof t.x!="number"||typeof t.y!="number")throw new Dr(`Node "${t.label}" is missing coordinates`,"semantic",{type:"wardley"});e.push(t)}return{nodes:e,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}},u8t,d8t,mm=(e,t)=>({name:e,pattern:new RegExp(t,"y"),first:t[0]}),p8t,Dwr,Twr=48,Ts=6,sQ=10,Rwr=8,kre=15,AO=60,Mwr=30,A8t=20,MDe="var(--_c)",Sg="var(--_l)",Pwr,Nwr=class{type="xychart";title;accTitle;accDescr;orientation;xAxis={type:"band",title:"",categories:[]};yAxis={type:"linear",title:"",min:1/0,max:-1/0};hasSetXAxis=!1;hasSetYAxis=!1;plots=[];setOrientation(e){this.orientation=e==="horizontal"?"horizontal":"vertical"}setXAxisTitle(e){this.xAxis.title=e.text.trim()}setXAxisRangeData(e,t){this.xAxis={type:"linear",title:this.xAxis.title,min:e,max:t},this.hasSetXAxis=!0}setXAxisBand(e){this.xAxis={type:"band",title:this.xAxis.title,categories:e.map((t)=>t.text.trim())},this.hasSetXAxis=!0}setYAxisTitle(e){this.yAxis.title=e.text.trim()}setYAxisRangeData(e,t){this.yAxis={type:"linear",title:this.yAxis.title,min:e,max:t},this.hasSetYAxis=!0}plotData(e){if(e.length===0)return[];this.hasSetXAxis||this.setXAxisRangeData(1,e.length);let t=this.xAxis;if(t.type==="band"&&e.length>t.categories.length&&(e=e.slice(0,t.categories.length)),!this.hasSetYAxis){let{min:r,max:a}=this.yAxis;for(let i of e)i<r&&(r=i),i>a&&(a=i);this.yAxis={type:"linear",title:this.yAxis.title,min:r,max:a}}if(t.type==="band")return t.categories.map((r,a)=>[r,e[a]]);if(e.length===1)return[[`${t.min}`,e[0]]];let n=(t.max-t.min)/(e.length-1);return e.map((r,a)=>[`${t.min+a*n}`,r])}addPlot(e,t,n){let r={type:e,title:t.text.trim(),data:this.plotData(n.map((a)=>a.value))};e==="line"&&n.some((a)=>a.label.trim()!=="")&&(r.pointLabels=n.map((a)=>a.label.trim())),this.plots.push(r)}setLineData(e,t){this.addPlot("line",e,t)}setBarData(e,t){this.addPlot("bar",e,t)}setDiagramTitle(e){this.title=e}setAccTitle(e){this.accTitle=e.replace(/^\s+/g,"")}setAccDescription(e){this.accDescr=e.replace(/\n\s+/g,`
|
|
589
589
|
`)}},g8t,f8t,h8t,RTe,b8t,y8t,E8t=4,mM=12,B8t=26,C8t=24,x8t=1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000,qwr,Hwr;var UNt=v(()=>{Eor=[["flowchart","flowchart-elk",/^\s*flowchart-elk/],["mindmap","mindmap",/^\s*mindmap/],["architecture","architecture",/^\s*architecture/],["agentflow","agentflow",/^\s*agentflow-beta\b/],["c4","c4",/^\s*(?:C4Context|C4Container|C4Component|C4Dynamic|C4Deployment)/],["kanban","kanban",/^\s*kanban/],["class","classDiagram",/^\s*classDiagram/],["er","er",/^\s*erDiagram/],["gantt","gantt",/^\s*gantt/],["info","info",/^\s*info/],["pie","pie",/^\s*pie/],["requirement","requirement",/^\s*requirement(Diagram)?/],["sequence","sequence",/^\s*sequenceDiagram/],["swimlane","swimlane",/^\s*swimlane-beta\b/],["flowchart","flowchart-v2",/^\s*(graph|flowchart)/],["timeline","timeline",/^\s*timeline/],["gitGraph","gitGraph",/^\s*gitGraph/],["state","stateDiagram",/^\s*stateDiagram/],["journey","journey",/^\s*journey/],["quadrantChart","quadrantChart",/^\s*quadrantChart/],["sankey","sankey",/^\s*sankey(-beta)?/],["packet","packet",/^\s*packet(-beta)?/],["xychart","xychart",/^\s*xychart(-beta)?/],["block","block",/^\s*block(-beta)?/],["eventmodeling","eventmodeling",/^\s*eventmodeling/],["treeView","treeView",/^\s*treeView-beta/],["radar","radar",/^\s*radar-beta/],["ishikawa","ishikawa",/^\s*ishikawa(-beta)?\b/i],["treemap","treemap",/^\s*treemap/],["railroad","railroad",/^\s*railroad-beta/i],["railroad","railroadEbnf",/^\s*railroad-ebnf-beta/i],["railroad","railroadAbnf",/^\s*railroad-abnf-beta/i],["railroad","railroadPeg",/^\s*railroad-peg-beta/i],["venn","venn",/^\s*venn-beta/],["wardley","wardley",/^\s*wardley-beta/i],["cynefin","cynefin",/^\s*cynefin-beta(?:[\s:]|$)/],["usecase","usecase",/^\s*usecase-beta(?:\s|$)/]];Dr=class extends Error{code;type;mermaidType;line;column;snippet;constructor(e,t="syntax",n={}){super(e),this.name="PeleError",this.code=t,this.type=n.type??null,this.mermaidType=n.mermaidType??null,this.line=n.line??0,this.column=n.column??0,this.snippet=n.snippet??""}};Ior=/&(?:#(\d+)|#[xX]([0-9a-fA-F]+)|(\w+));/g;Sor=/\uFB02\u00B0\u00B0?(\w+)\u00B6\u00DF/g;BO=new Map;_M=new Map;Lor=/^[-+]?(?:0|[1-9][0-9]*)$/,Por=/^[-+]?0x[0-9a-fA-F]+$/,Nor=/^[-+]?0o[0-7]+$/,$or=/^[-+]?0b[01]+$/,Oor=/^[-+]?(?:[0-9][0-9]*(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][-+]?[0-9]+)?$/,Gor=/[\s#:,[\]{}&*!|>'"%@`]/;TMt={0:"\x00",a:"\x07",b:"\b",t:"\t",n:`
|
|
590
590
|
`,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"};Hor=/^\s*%%(?!{)[^\n]+\n?/gm,YR=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,Wor=/<(\w+)([^>]*)>/g,zor=/="([^"]*)"/g,Jor=new Set(["__proto__","constructor","prototype"]);Zor=/#\w+;/g,Vor=/^\+?\d+$/,RSe=new RegExp("[\\n\\r\u2028\u2029]","g");isr={width(e,t,n){let r=(n&4)!==0,a=n&24?t/j8t:t,i=n&1?nsr??=FMt(esr):tsr??=FMt(Xor),o=0;for(let s=0;s<e.length;s++){let c=e.charCodeAt(s);if(!(c<32))if(c<127)o+=r?600:i[c-32];else{if(asr(c))continue;rsr(c)?o+=r?1200:1000:o+=r?600:580}}return o*a/1000}};LMt=new Map;usr=/[&<>"\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u,dsr=/[&<>"]|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]+/gu,psr={"&":"&","<":"<",">":">",'"':"""},L8t=/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\ud800-\udfff\ufffe\uffff]/u;PDe=[];for(let e=0;e<100;e++)PDe.push(e===0?"":e%10===0?"."+e/10:"."+(e<10?"0"+e:e));Asr=/ fill="([^"]*)"/,msr=/ stroke="([^"]*)"/,gsr=/ style="([^"]*)"/,fsr=/(?:^|;)\s*fill:([^;]*)/,hsr=/(?:^|;)\s*opacity:([^;]*)/;O8t=new Set("black blue blueviolet brown crimson darkblue darkcyan darkgreen darkmagenta darkolivegreen darkorchid darkred darkslateblue darkslategray darkviolet dimgray firebrick forestgreen green indigo maroon mediumblue mediumslateblue mediumvioletred midnightblue navy olive purple rebeccapurple royalblue saddlebrown seagreen sienna slateblue steelblue teal".split(" ")),G8t=new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque blanchedalmond burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk cyan darkgoldenrod darkgray darkkhaki darkorange darksalmon darkseagreen darkturquoise deeppink deepskyblue dodgerblue floralwhite fuchsia gainsboro ghostwhite gold goldenrod gray greenyellow honeydew hotpink indianred ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta mediumaquamarine mediumorchid mediumpurple mediumseagreen mediumspringgreen mediumturquoise mintcream mistyrose moccasin navajowhite oldlace olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue red rosybrown salmon sandybrown seashell silver skyblue slategray snow springgreen tan thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" ")),ODe=/[";]fill:([^;"]*)/,Bsr=/[";](?:fill-)?opacity:([^;"]*)/g,U8t=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$/i,Csr=/^(rgba?|hsla?)\(([^()]*)\)$/i,q8t=/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?(%|deg|grad|rad|turn)?$/i,_sr=Math.sqrt(1.05*(GDe(0.12156862745098039,0.12156862745098039,0.12156862745098039)+0.05))-0.05;j$=new Map;Dsr={pie:{prefix:"pie",first:1},gitGraph:{prefix:"git",first:0},timeline:{prefix:"cScale",first:0},radar:{prefix:"cScale",first:0},treemap:{prefix:"cScale",first:0},mindmap:{prefix:"cScale",first:1},venn:{prefix:"venn",first:1,repeat:!0}},Tsr=/^[\w\s#%.,+\-/()]{1,200}$/,Rsr=/([\w-]*)\s*\(/g,Msr=/var\(\s*([\w-]*)/gi,Fsr=new Set(["rgb","rgba","hsl","hsla","hwb","lab","lch","oklab","oklch","color","color-mix","light-dark","var"]);UDe={style:"",inks:[]};vO=UDe;s$i=Math.random().toString(36).slice(2,7),J8t=new Map;zsr=new WeakMap;Zsr=/^([^\w]*)(javascript|data|vbscript)/im,PMt=/&#(\w+)(^\w|;)?/g,NMt=/&(newline|tab);/gi,FSe=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF\uD800-\uDFFF\uFFFE\uFFFF]/gimu,Vsr=/^.+(:|:)/gim,$Mt=/(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;Xsr=["http","https","mailto","tel"],ecr=["http","https"],tcr=/^([a-z][a-z0-9+.-]*):/i,ncr=/^[\\/]{2}/;acr=new RegExp(L8t.source,"gu");icr=[["rect","proc","process","rectangle","squareRect"],["rounded","event","roundedRect"],["stadium","terminal","pill"],["fr-rect","subprocess","subproc","framed-rectangle","subroutine"],["cyl","db","database","cylinder"],["datastore","data-store"],["folder","directory"],["bucket"],["console"],["browser"],["person"],["circle","circ"],["bang"],["cloud"],["diam","decision","diamond","question"],["hex","hexagon","prepare"],["lean-r","lean-right","in-out","lean_right"],["lean-l","lean-left","out-in","lean_left"],["trap-b","priority","trapezoid-bottom","trapezoid"],["trap-t","manual","trapezoid-top","inv-trapezoid","inv_trapezoid"],["dbl-circ","double-circle","doublecircle"],["text"],["notch-rect","card","notched-rectangle"],["lin-rect","lined-rectangle","lined-process","lin-proc","shaded-process"],["sm-circ","start","small-circle","stateStart"],["fr-circ","stop","framed-circle","stateEnd"],["fork","join","forkJoin"],["hourglass","collate"],["brace","comment","brace-l"],["brace-r"],["braces"],["bolt","com-link","lightning-bolt"],["doc","document"],["delay","half-rounded-rectangle"],["h-cyl","das","horizontal-cylinder"],["lin-cyl","disk","lined-cylinder"],["curv-trap","curved-trapezoid","display"],["div-rect","div-proc","divided-rectangle","divided-process"],["tri","extract","triangle"],["win-pane","internal-storage","window-pane"],["f-circ","junction","filled-circle"],["notch-pent","loop-limit","notched-pentagon"],["flip-tri","manual-file","flipped-triangle"],["sl-rect","manual-input","sloped-rectangle"],["docs","documents","st-doc","stacked-document"],["st-rect","procs","processes","stacked-rectangle"],["bow-rect","stored-data","bow-tie-rectangle"],["cross-circ","summary","crossed-circle"],["tag-doc","tagged-document"],["tag-rect","tagged-rectangle","tag-proc","tagged-process"],["flag","paper-tape"],["odd","rect_left_inv_arrow"],["lin-doc","lined-document"]],ocr=["state","choice","note","composite","rectWithTitle","labelRect","block_arrow","collapsedGroup","iconSquare","iconCircle","icon","iconRounded","imageSquare","anchor","kanbanItem","mindmapCircle","defaultMindmapNode","classBox","erBox","requirementBox","usecaseActor","usecaseActorHollow","usecaseActorAwesome","usecaseActorIcon","usecaseBusiness","usecaseEllipse","usecaseJsonTable"],scr=new Map([["square","rect"],["round","rounded"],["ellipse","ellipse"],["hexagon","hex"],["diamond","diam"]]),Cae=new Map;for(let e of icr)for(let t of e)Cae.set(t,e[0]);for(let e of ocr)Cae.set(e,e);ccr=new Map([["task","roundedRect"],["tool","subroutine"],["input","lean-right"],["decision","diamond"],["refdoc","lin-doc"],["action","hexagon"],["round","rect"]]),lcr=new Set(["doc","stadium","terminal","circle","trapezoid","inv_trapezoid","inv-trapezoid","doublecircle","double-circle","typeDeclaration","procs","lean_left","lean-left","in-out","cylinder","ellipse","odd","tag-rect","tagged-rectangle","delay","half-rounded-rectangle","lin-rect","lined-rectangle","win-pane","window-pane","curv-trap","curved-trapezoid"]),ucr=new Set(["roundedRect","subroutine","subprocess","subproc","framed-rectangle","lean-right","diamond","lin-doc","lined-document","hexagon","hex","connector","collapsedGroup"]);Acr=new Set(["shape","view","icon","img","form","pos","w","h","class","style","labelType"]),mcr=new Set(["subroutine","subprocess","subproc","framed-rectangle","tool"]);hcr=/:\s*[>|][\d+-]*\s*$/,bcr=/,([\t ]*)$/;HMt=["$end","INVALID","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","SHAPE_DATA","CALLBACKNAME","CALLBACKARGS","MD_STR","STR","STYLE","DEFAULT","LINKSTYLE","INTERPOLATE","CLASSDEF","CLASS","HREF","CLICK","GRAPH","flow","connector","global","end","LINK_TARGET","NODIR","DIR","direction_tb","direction_bt","direction_rl","direction_lr","direction_td","LINK_ID","NUM","BRKT","STYLE_SEPARATOR","COLON","AMP","SEMI","COMMA","MULT","LINK","START_LINK","EDGE_TEXT","-)","TEXT","(-","STADIUMEND","STADIUMSTART","SUBROUTINEEND","SUBROUTINESTART","VERTEX_WITH_PROPS_START","TAGEND","CYLINDEREND","CYLINDERSTART","DOUBLECIRCLEEND","DOUBLECIRCLESTART","TRAPEND","INVTRAPEND","TRAPSTART","INVTRAPSTART","TAGSTART","UP","SEP","DOWN","COMMENT","NODE_STRING","MINUS","UNICODE_TEXT","PIPE","PE","PS","SQE","SQS","DIAMOND_STOP","DIAMOND_START","NEWLINE","SPACE","EOF"],X8t=new Uint8Array(128);for(let e of"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'*+.`?\\_/")X8t[e.charCodeAt(0)]=1;_cr=/accTitle\s*:\s*/y,vcr=/accDescr\s*:\s*/y,Icr=/accDescr\s*\{\s*/y,Qcr=/call\s+/y,Scr=/click\s+/y,Dcr=/(?:\r?\n)*\s*\n/y,Tcr=/\s*(?:LR|RL|TB|BT|TD|BR)\b/y,Rcr=/\s*[<>^]/y,Mcr=/\s*v\b/y,Fcr=[/.*direction\s+TB[^\n]*/y,/.*direction\s+BT[^\n]*/y,/.*direction\s+RL[^\n]*/y,/.*direction\s+LR[^\n]*/y,/.*direction\s+TD[^\n]*/y],LSe=/[\n\r\u2028\u2029]/g,jcr=/\(\s*\)/y,Lcr=/\n\s*/g;_re=new Uint8Array(80);for(let e of[34,67,65,68,13,40,37,38,35,41,69])_re[e]=1;WDe=new Uint8Array(80);for(let e of[34,69,67,27,65,68,40,37,38,35,41])WDe[e]=1;zDe=new Uint8Array(80);for(let e of[34,67,78,68,38,69,37,41,35,12,14,16,17,19,20,27,21,22,23,24,65,63,43])zDe[e]=1;JDe=new Uint8Array(80);for(let e of[34,67,37,78,35,12])JDe[e]=1;vre=new Uint8Array(80);for(let e of[77,39,79,66])vre[e]=1;e3t=new Uint8Array(80);for(let e of[66,77,78,79])e3t[e]=1;P$=[],zMt=/}[^\S\n]*\n/g;$cr=["TB","BT","RL","LR","TD"];NSe=new Float64Array(2*yM+2),$Se=new Float64Array(2*yM+2);flr=Math.max(3,ZDe,VDe+1);wlr=Array.from({length:23},(e,t)=>+`1e${t}`);Qlr=/[";]fill:/;sFt=String.raw`(?:"[^"'\\\n<>{}();:@]*"|'[^"'\\\n<>{}();:@]*'|[\p{L}\p{N}_-][\p{L}\p{N}_ .-]*)`,Slr=new RegExp(String.raw`^\s*${sFt}(?:\s*,\s*${sFt})*\s*$`,"u");Tlr=new Set(["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","opacity","rx","ry"]),Rlr=new Set(["color","font-size","font-family","font-weight","font-style","text-decoration","letter-spacing","word-spacing","opacity"]),Mlr=/url\s*\(|expression\s*\(|javascript:|[<>{};\\]|@import|image-set|\/\*/i,lFt={shape:"",line:"",text:"",stroke:void 0,bold:!1,italic:!1,fontSize:void 0};Flr=/[^\w-]+/g;jlr=["#4c78a8","#f58518","#54a24b","#e45756","#72b7b2","#eeca3b","#b279a2","#9d755d"];Llr=[["tw","title"],["hw","heading"],["w","bold"]],Plr=/var\(--_(r|tw|hw|w)\)/g;l3t={rect:{size:O$,span:Qg,draw:(e,t,n)=>wp(e,t,Io(n))},rounded:{size:O$,span:Qg,draw:(e,t,n)=>wp(e,t,n,` rx="${J(Math.min(12,t/2))}"`)},stadium:{inset:(e,t,n,r)=>n&1?Kre(r,t/2,t/2):0,span:(e,t,n)=>n?t*0.6:e-t,size:(e,t)=>{let n=t+2*yi;return{w:e+n*0.5+2*mi-8,h:n,dy:0}},draw:(e,t,n)=>wp(e,t,n,` rx="${J(t/2)}"`)},"fr-rect":{span:Qg,size:(e,t)=>({w:e+2*mi+16,h:t+2*yi,dy:0}),draw:(e,t,n,r)=>{let a=e/2-8;return wp(e,t,Io(n))+`<path d="M${J(-a)},${J(-t/2)}V${J(t/2)}M${J(a)},${J(-t/2)}V${J(t/2)}" fill="none"${r}/>`}},cyl:{inset:uFt,span:(e,t,n)=>n?t-2*kM-12:e*0.6,size:(e,t)=>{let n=Math.max(e+2*mi,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*yi+2*r,dy:r/2}},draw:(e,t,n,r)=>{let a=e/2,i=Math.min(12,Math.max(6,e/14)),o=-t/2+i,s=t/2-i;return`<path d="M${J(-a)},${J(o)}A${J(a)},${J(i)} 0 0 1 ${J(a)},${J(o)}V${J(s)}A${J(a)},${J(i)} 0 0 1 ${J(-a)},${J(s)}Z"${n}/><path d="M${J(-a)},${J(o)}A${J(a)},${J(i)} 0 0 0 ${J(a)},${J(o)}" fill="none"${r}/>`}},circle:{inset:J1,span:K1,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+16,44);return{w:n,h:n,dy:0}},draw:(e,t,n)=>`<circle r="${J(e/2)}"${n}/>`},"dbl-circ":{inset:J1,span:K1,size:(e,t)=>{let n=Math.max(Math.sqrt(e*e+t*t)+26,54);return{w:n,h:n,dy:0}},draw:(e,t,n,r)=>`<circle r="${J(e/2)}"${n}/><circle r="${J(e/2-5)}" fill="none"${r}/>`},ellipse:{inset:J1,span:K1,size:(e,t)=>({w:e*1.3+2*mi,h:t*1.2+2*yi,dy:0}),draw:(e,t,n)=>`<ellipse rx="${J(e/2)}" ry="${J(t/2)}"${n}/>`},diam:{inset:(e,t,n,r)=>n&1?Math.abs(r)*e/t:Math.abs(r)*t/e,span:(e,t,n)=>(n?t:e)*0.6,size:(e,t)=>{let n=e+16,r=t+8;return{w:n+1.6*r,h:n/1.6+r,dy:0}},draw:(e,t,n)=>sA([0,-t/2,e/2,0,0,t/2,-e/2,0],n)},hex:{inset:(e,t,n,r)=>n&1?Math.abs(r)/2:0,span:(e,t,n)=>n?t*0.5:e-t/2-kM,size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return sA([-e/2+r,-t/2,e/2-r,-t/2,e/2,0,e/2-r,t/2,-e/2+r,t/2,-e/2,0],n)}},odd:{inset:(e,t,n)=>n===3?t/4:0,span:$$(()=>0),size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return sA([-e/2,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2+r,0],n)}},"lean-r":{inset:yne,span:$$((e)=>e/4),size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return sA([-e/2+r,-t/2,e/2,-t/2,e/2-r,t/2,-e/2,t/2],n)}},"lean-l":{inset:yne,span:$$((e)=>e/4),size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return sA([-e/2,-t/2,e/2-r,-t/2,e/2,t/2,-e/2+r,t/2],n)}},"trap-b":{inset:yne,span:$$((e)=>e/4),size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return sA([-e/2+r,-t/2,e/2-r,-t/2,e/2,t/2,-e/2,t/2],n)}},"trap-t":{inset:yne,span:$$((e)=>e/4),size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n/2,h:n,dy:0}},draw:(e,t,n)=>{let r=t/4;return sA([-e/2,-t/2,e/2,-t/2,e/2-r,t/2,-e/2+r,t/2],n)}},text:{bare:!0,span:Qg,size:(e,t)=>({w:e+8,h:t+8,dy:0}),draw:(e,t)=>wp(e,t,' fill="none" stroke="none"')},"sm-circ":{noLabel:!0,inset:J1,span:K1,size:Y1(14,14),draw:(e,t,n)=>`<circle r="${J(e/2)}"${n}/>`},"f-circ":{noLabel:!0,inset:J1,span:K1,size:Y1(14,14),draw:(e,t,n,r)=>`<circle r="${J(e/2)}" fill="var(--_l)"${r}/>`},"fr-circ":{noLabel:!0,inset:J1,span:K1,size:Y1(18,18),draw:(e,t,n,r)=>`<circle r="${J(e/2)}"${n}/><circle r="${J(e/2-4)}" fill="var(--_l)"${r}/>`},fork:{noLabel:!0,span:(e,t,n)=>(n?t:e)-8,size:Y1(72,8),draw:(e,t,n,r)=>wp(e,t,` fill="var(--_l)"${r}`,' rx="2"')},"notch-rect":{size:O$,span:Qg,draw:(e,t,n)=>sA([-e/2+10,-t/2,e/2,-t/2,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},"lin-rect":{span:Qg,size:(e,t)=>({w:e+2*mi+8,h:t+2*yi,dy:0}),draw:(e,t,n,r)=>wp(e,t,Io(n))+`<path d="M${J(-e/2+8)},${J(-t/2)}V${J(t/2)}" fill="none"${r}/>`},"div-rect":{span:Qg,size:(e,t)=>({w:e+2*mi,h:t+2*yi+8,dy:4}),draw:(e,t,n,r)=>wp(e,t,Io(n))+`<path d="M${J(-e/2)},${J(-t/2+8)}H${J(e/2)}" fill="none"${r}/>`},"win-pane":{span:Qg,size:(e,t)=>({w:e+2*mi+8,h:t+2*yi+8,dy:4}),draw:(e,t,n,r)=>wp(e,t,Io(n))+`<path d="M${J(-e/2+8)},${J(-t/2)}V${J(t/2)}M${J(-e/2)},${J(-t/2+8)}H${J(e/2)}" fill="none"${r}/>`},tri:{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>dFt(e,t,!1),draw:(e,t,n)=>sA([0,-t/2,e/2,t/2,-e/2,t/2],n)},"flip-tri":{inset:(e,t,n)=>n&1?e/4:0,size:(e,t)=>dFt(e,t,!0),draw:(e,t,n)=>sA([-e/2,-t/2,e/2,-t/2,0,t/2],n)},"sl-rect":{inset:(e,t,n)=>n===0?5:0,size:(e,t)=>({w:e+2*mi,h:t+2*yi+10,dy:5}),draw:(e,t,n)=>sA([-e/2,-t/2+10,e/2,-t/2,e/2,t/2,-e/2,t/2],n)},"notch-pent":{span:Qg,size:(e,t)=>({w:e+2*mi,h:t+2*yi,dy:0}),draw:(e,t,n)=>sA([-e/2+10,-t/2,e/2-10,-t/2,e/2,-t/2+10,e/2,t/2,-e/2,t/2,-e/2,-t/2+10],n)},hourglass:{noLabel:!0,inset:(e,t,n)=>n&1?e/2:0,size:Y1(32,40),draw:(e,t,n)=>sA([-e/2,-t/2,e/2,-t/2,-e/2,t/2,e/2,t/2],n)},delay:{size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n/4,h:n,dy:0}},draw:(e,t,n)=>{let r=t/2;return`<path d="M${J(-e/2)},${J(-r)}H${J(e/2-r)}A${J(r)},${J(r)} 0 0 1 ${J(e/2-r)},${J(r)}H${J(-e/2)}Z"${n}/>`}},"h-cyl":{size:(e,t)=>{let n=t+2*yi,r=Math.min(12,n/4);return{w:e+2*mi+2*r,h:n,dy:0}},draw:(e,t,n,r)=>{let a=t/2,i=Math.min(12,t/4),o=-e/2+i,s=e/2-i;return`<path d="M${J(o)},${J(-a)}H${J(s)}A${J(i)},${J(a)} 0 0 1 ${J(s)},${J(a)}H${J(o)}A${J(i)},${J(a)} 0 0 1 ${J(o)},${J(-a)}Z"${n}/><path d="M${J(s)},${J(-a)}A${J(i)},${J(a)} 0 0 0 ${J(s)},${J(a)}" fill="none"${r}/>`}},"cross-circ":{noLabel:!0,inset:J1,span:K1,size:Y1(44,44),draw:(e,t,n,r)=>{let a=e/2,i=a*Math.SQRT1_2;return`<circle r="${J(a)}"${n}/><path d="M${J(-i)},${J(-i)}L${J(i)},${J(i)}M${J(i)},${J(-i)}L${J(-i)},${J(i)}" fill="none"${r}/>`}},"st-rect":{span:(e,t,n)=>(n?t:e)-2*kM-8,size:(e,t)=>({w:e+2*mi+8,h:t+2*yi+8,dy:4}),draw:(e,t,n)=>{let r=e-8,a=t-8,i="";for(let o=0;o<3;o++){let s=-e/2+(2-o)*4,c=-t/2+o*4;i+=`<rect x="${J(s)}" y="${J(c)}" width="${J(r)}" height="${J(a)}"${Io(n)}/>`}return i}},doc:{inset:(e,t,n)=>n===2?10:0,size:(e,t)=>({w:e+2*mi,h:t+2*yi+10,dy:-5}),draw:(e,t,n)=>kne(e,t,n)},flag:{inset:(e,t,n)=>n&1?0:8,size:(e,t)=>({w:e+2*mi,h:t+2*yi+16,dy:0}),draw:(e,t,n)=>{let r=e/2,a=t/2-8,i=e/4;return`<path d="M${J(-r)},${J(-a)}q${J(i)},-10 ${J(2*i)},0t${J(2*i)},0V${J(a)}q${J(-i)},10 ${J(-2*i)},0t${J(-2*i)},0Z"${n}/>`}},datastore:{size:O$,span:Qg,draw:(e,t,n,r)=>wp(e,t,n.replace('stroke="var(--_b)"','stroke="none"'))+`<path d="M${J(-e/2)},${J(-t/2)}H${J(e/2)}M${J(-e/2)},${J(t/2)}H${J(e/2)}" fill="none"${r}/>`},folder:{size:(e,t)=>({w:Math.max(e+2*mi,64),h:t+2*yi+8,dy:4}),draw:(e,t,n)=>{let r=e/2,a=t/2,i=Math.min(e*0.4,48);return ZR(`M${J(-r)},${J(-a)}H${J(-r+i)}L${J(-r+i+8)},${J(-a+8)}H${J(r)}V${J(a)}H${J(-r)}Z`,n)}},bucket:{size:(e,t)=>({w:e+2*mi+20,h:t+2*yi+10,dy:3}),inset:(e,t,n)=>n&1?t/12:0,draw:(e,t,n,r)=>{let a=e/2,i=t/2,o=5,s=t/6;return ZR(`M${J(-a)},${J(-i+o)}A${J(a)},${J(o)} 0 0 1 ${J(a)},${J(-i+o)}L${J(a-s)},${J(i-o)}A${J(a-s)},${J(o)} 0 0 1 ${J(-a+s)},${J(i-o)}Z`,n)+`<path d="M${J(-a)},${J(-i+o)}A${J(a)},${J(o)} 0 0 0 ${J(a)},${J(-i+o)}" fill="none"${r}/>`}},console:{span:Qg,size:(e,t)=>({w:Math.max(e+2*mi,72),h:t+2*yi+12,dy:6}),draw:(e,t,n,r)=>wp(e,t,Io(n))+`<path d="M${J(-e/2)},${J(-t/2+12)}H${J(e/2)}M${J(-e/2+7)},${J(-t/2+4)}l3,2.5l-3,2.5M${J(-e/2+13)},${J(-t/2+9)}h4" fill="none"${r}/>`},browser:{span:Qg,size:(e,t)=>({w:Math.max(e+2*mi,72),h:t+2*yi+12,dy:6}),draw:(e,t,n,r)=>{let a="";for(let i=0;i<3;i++)a+=`<circle cx="${J(-e/2+8+i*7)}" cy="${J(-t/2+6)}" r="1.5" fill="none"${r}/>`;return wp(e,t,Io(n))+`<path d="M${J(-e/2)},${J(-t/2+12)}H${J(e/2)}" fill="none"${r}/>`+a}},person:{size:(e,t)=>({w:Math.max(e+2*mi,56),h:t+2*yi+26,dy:13}),draw:(e,t,n)=>{let r=-t/2;return`<rect x="${J(-e/2)}" y="${J(r+26)}" width="${J(e)}" height="${J(t-26)}" rx="12"${n}/><circle cy="${J(r+14)}" r="13"${n}/>`}},bang:{size:(e,t)=>({w:e+2*mi+28,h:t+2*yi+24,dy:0}),inset:()=>3,draw:(e,t,n)=>{let r=[];for(let a=0;a<28;a++){let i=Math.PI*a/14-Math.PI/2,o=a%2===0?1:0.82;r.push(Math.cos(i)*(e/2)*o,Math.sin(i)*(t/2)*o)}return sA(r,n)}},cloud:{size:(e,t)=>({w:e+2*mi+32,h:t+2*yi+24,dy:0}),inset:(e,t,n)=>n&1?2:1,draw:(e,t,n)=>{let r=e/2,a=t/2,i=a*0.55;return ZR(`M${J(-r+i)},${J(a)}A${J(i)},${J(i)} 0 0 1 ${J(-r+i*0.6)},${J(-a*0.1)}A${J(r*0.42)},${J(a*0.7)} 0 0 1 ${J(-r*0.1)},${J(-a*0.72)}A${J(r*0.4)},${J(a*0.62)} 0 0 1 ${J(r*0.62)},${J(-a*0.42)}A${J(i*1.05)},${J(i*1.05)} 0 0 1 ${J(r-i)},${J(a)}Z`,n)}},brace:{bare:!0,size:(e,t)=>({w:e+2*mi+12,h:t+2*yi,dy:0}),draw:(e,t,n,r)=>wp(e,t,' fill="none" stroke="none"')+wne(-e/2+12,t,-1,r)},"brace-r":{bare:!0,size:(e,t)=>({w:e+2*mi+12,h:t+2*yi,dy:0}),draw:(e,t,n,r)=>wp(e,t,' fill="none" stroke="none"')+wne(e/2-12,t,1,r)},braces:{bare:!0,size:(e,t)=>({w:e+2*mi+24,h:t+2*yi,dy:0}),draw:(e,t,n,r)=>wp(e,t,' fill="none" stroke="none"')+wne(-e/2+12,t,-1,r)+wne(e/2-12,t,1,r)},bolt:{noLabel:!0,size:Y1(36,56),inset:(e,t,n)=>n&1?e/4:0,draw:(e,t,n)=>sA([e*0.15,-t/2,-e/2,t*0.08,-e*0.05,t*0.08,-e*0.15,t/2,e/2,-t*0.08,e*0.05,-t*0.08],n)},"lin-cyl":{inset:uFt,span:(e,t,n)=>n?t-2*kM-20:e*0.6,size:(e,t)=>{let n=Math.max(e+2*mi,56),r=Math.min(12,Math.max(6,n/14));return{w:n,h:t+2*yi+2*r+8,dy:r/2+4}},draw:(e,t,n,r)=>{let a=e/2,i=Math.min(12,Math.max(6,e/14)),o=-t/2+i,s=t/2-i,c=(u)=>`M${J(-a)},${J(u)}A${J(a)},${J(i)} 0 0 0 ${J(a)},${J(u)}`;return ZR(`M${J(-a)},${J(o)}A${J(a)},${J(i)} 0 0 1 ${J(a)},${J(o)}V${J(s)}A${J(a)},${J(i)} 0 0 1 ${J(-a)},${J(s)}Z`,n)+`<path d="${c(o)}${c(o+8)}" fill="none"${r}/>`}},"curv-trap":{size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n*0.6,h:n,dy:0}},draw:(e,t,n)=>{let r=e/2,a=t/2,i=t*0.3;return ZR(`M${J(-r+i)},${J(-a)}H${J(r-i)}A${J(i)},${J(a)} 0 0 1 ${J(r-i)},${J(a)}H${J(-r+i)}L${J(-r)},0Z`,n)}},docs:{size:(e,t)=>({w:e+2*mi+8,h:t+2*yi+18,dy:-1}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n)=>{let r="";for(let a=0;a<3;a++)r+=`<g transform="translate(${(1-a)*4},${(a-1)*4})">${kne(e-8,t-8,n)}</g>`;return r}},"bow-rect":{size:(e,t)=>{let n=t+2*yi;return{w:e+2*mi+n*0.4,h:n,dy:0}},inset:(e,t,n)=>n===1?t*0.2:0,draw:(e,t,n)=>{let r=e/2,a=t/2,i=t*0.2;return ZR(`M${J(-r+i)},${J(-a)}H${J(r)}A${J(i)},${J(a)} 0 0 0 ${J(r)},${J(a)}H${J(-r+i)}A${J(i)},${J(a)} 0 0 1 ${J(-r+i)},${J(-a)}Z`,n)}},"tag-rect":{size:O$,span:Qg,draw:(e,t,n,r)=>wp(e,t,Io(n))+`<path d="M${J(e/2-12)},${J(t/2)}L${J(e/2)},${J(t/2-12)}" fill="none"${r}/>`},"tag-doc":{size:(e,t)=>({w:e+2*mi,h:t+2*yi+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>kne(e,t,n)+`<path d="M${J(e/2-12)},${J(t/2-14)}L${J(e/2)},${J(t/2-26)}" fill="none"${r}/>`},"lin-doc":{size:(e,t)=>({w:e+2*mi+8,h:t+2*yi+10,dy:-5}),inset:(e,t,n)=>n===2?10:0,draw:(e,t,n,r)=>kne(e,t,n)+`<path d="M${J(-e/2+8)},${J(-t/2)}V${J(t/2-6)}" fill="none"${r}/>`},collapsedGroup:{size:(e,t)=>({w:e+2*mi+8,h:t+2*yi+8,dy:-2}),draw:(e,t,n)=>`<rect x="${J(-e/2+6)}" y="${J(-t/2+8)}" width="${J(e-12)}" height="${J(t-8)}"${Io(n)}/><rect x="${J(-e/2)}" y="${J(-t/2)}" width="${J(e)}" height="${J(t-4)}"${Io(n)}/>`}};UTe=l3t.rect,UM=new Map(Object.entries(l3t));Glr=/<br\s*\/?>|\\n|\n/gi,pFt=/<\/?([a-zA-Z][\w-]*)(?:\s[^<>]*)?\/?>/y,AFt=/(fa[bklrs]?):fa-([\w-]+)/g,Ulr=/[<\\\n*_]|fa[bklrs]?:fa-/,qlr=new Map([["b",1],["strong",1],["i",2],["em",2],["cite",2],["dfn",2],["var",2],["code",4],["kbd",4],["samp",4],["tt",4],["sub",8],["sup",16],["u",32],["ins",32]]),Wlr=new Set("a abbr address article aside audio b bdi bdo big blockquote body br button caption center cite code col colgroup data dd del details dfn dialog div dl dt em embed fieldset figcaption figure font footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd label legend li link main map mark meta meter nav noscript object ol optgroup option output p picture pre progress q rp rt ruby s samp script section select small source span strike strong style sub summary sup table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr".split(" ")),Jlr=new RegExp(`[${nTe}]`),Klr=new RegExp(`[${Ire}]`),Ylr=new RegExp(`\\s*(?:[${zlr}]*[${nTe}][${mFt}]*|[^\\s${nTe}${Ire}]+[${Ire}]*[${mFt}]*|[${Ire}]+)\\s*|\\s+`,"g"),Vlr=/\$\$(.+?)\$\$/g,p3t=/[\ue000-\uf8ff]/,Xlr=/([\ue000-\uf8ff])/,eur={lines:[],widths:[],width:0,height:0,size:0,lineHeight:0};EM=new Map([["tool",0],["task",1],["decision",2],["input",3],["refdoc",4],["connector",5],["action",6]]),m3t=EM.size;gur={TB:2,RL:3,BT:0,LR:1},fFt=new WeakMap;hur={type:"agentflow",keepComments:!0,parse(e,t,n,r,a){let i=t.flowchart??{},o=new Ecr({inheritDir:i.inheritDir===!0,direction:typeof t.direction=="string"?t.direction:void 0,lineOffset:r,source:e,maxEdges:a.maxEdges});return n&&(o.title=n),Ncr(e,o),g3t(o,t),o},render:fur};f3t=new WeakMap;ew={name:"ACC_DESCR",pattern:/[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/y,first:"\t a"},sy={name:"ACC_TITLE",pattern:/[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/y,first:"\t a"},qM={name:"TITLE",pattern:/[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/y,first:"\t t"};_Q={name:"STRING",pattern:/"([^"\\]|\\.)*"|'([^'\\]|\\.)*'/y,first:`"'`},px={name:"NEWLINE",pattern:/\r?\n/y,first:`\r
|
|
@@ -602,15 +602,15 @@ but found: '${Kl(cn)}'`);(oy[Nr[cn]]&QTe)!==0;)cn++;return lA.slice(rd[e],uA[cn-
|
|
|
602
602
|
`)){let c=o.length-t.length-1;n={index:r,source:o.slice(0,o.lastIndexOf(`
|
|
603
603
|
`,c-1)+1)}}return r+=1,""}},{noHtmlBlocks:!0,noHtmlSpans:!0}),n}function akr(e,t="",n){let r=0;return e.replace(JNt,(a,i,o)=>{let s=r++;if(n?.index===s)return n.html;let c=r4t(o).replace(/\n$/,"");if(!c)return"";if(Zae(i)==="mermaid"){let d=zae(c,t||e,s);if(d!==void 0)return d}let u=dkr(i),l=c.replace(/\n`{1,2}[ \t]*$/,"");return t?skr(l,u,`${t}:${s}`):VNt(l,u)})}async function ikr(e,t){let n=[],r=0,a=0;for(let i of e.matchAll(JNt)){let[o,s,c]=i,u=a++;n.push(e.slice(r,i.index)),r=i.index+o.length;let l=r4t(c).replace(/\n$/,"");if(Zae(s)==="mermaid"){let p=zae(l,t,u);if(p!==void 0){n.push(p);continue}}let d=await e4t(s);n.push(sn(Hf.jsxDEV(Yae,{pre:await okr(l,d),language:d,source:l},void 0,!1,void 0,this)))}return n.push(e.slice(r)),n.join("")}async function okr(e,t){let n=`${Q0()}\x00${t}\x00${e}`,r=HNt.get(n);if(r)return r;let a=await une(e,t);return HNt.set(n,a),a}function skr(e,t,n){let r=_l();if(!r||!M$(t)){if(t!=="text")zC(t);return VNt(e,t)}let a=`${Q0()}:${n}`,i=ARe.get(a);if(!i||i.language!==t||!e.startsWith(i.code))i?.tokenizer.dispose(),i={language:t,code:"",tokenizer:r.createStreamTokenizer({lang:t,themes:al,defaultColor:"light-dark()"}),stable:[],unstable:[]},ARe.set(a,i);let o=e.slice(i.code.length);if(o){let s=i.tokenizer.enqueue(o);if(s instanceof Promise)throw Error("Highlights stream tokenizer must be synchronous");i.stable.push(...s.stable),i.unstable=s.unstable,i.code=e}return sn(Hf.jsxDEV(Yae,{pre:ckr([...i.stable,...i.unstable]),language:t,source:e},void 0,!1,void 0,this))}function ckr(e){let t=[""];for(let n of e){let r=QC(n,!0),a=r?` style="${Bun.escapeHTML(r)}"`:"",i=n.content.split(`
|
|
604
604
|
`);for(let[o,s]of i.entries()){if(s)t[t.length-1]+=`<span${a}>${Bun.escapeHTML(s)}</span>`;if(o<i.length-1)t.push("")}}if(t.length>1&&t.at(-1)==="")t.pop();return XNt(t)}function VNt(e,t){return sn(Hf.jsxDEV(Yae,{pre:XNt(e.split(`
|
|
605
|
-
`).map(Bun.escapeHTML)),language:t,source:e},void 0,!1,void 0,this))}function XNt(e){return`<pre class="plain-code" tabindex="0"><code class="streaming-code">${e.map((t,n)=>`<span class="streaming-code-line-number">${n+1}</span><span class="streaming-code-line">${t||" "}</span>`).join("")}</code></pre>`}function lkr(e,t,n={}){let r=`<pre class="plain-code" tabindex="0"><code class="language-${Bun.escapeHTML(t)}">${Bun.escapeHTML(e)}</code></pre>`;return n.chrome===!1?r:sn(Hf.jsxDEV(Yae,{pre:r,language:t},void 0,!1,void 0,this))}function Yae(e){return Hf.jsxDEV("div",{class:"code-block","data-code-block":!0,"data-code-source":e.source===void 0?void 0:Bun.escapeHTML(e.source),children:[Hf.jsxDEV("div",{class:"code-block-header",children:[Hf.jsxDEV("span",{safe:!0,children:e.language},void 0,!1,void 0,this),Hf.jsxDEV("button",{class:"btn code-copy-button","data-variant":"ghost","data-size":"icon-xs",type:"button","data-copy-code":!0,"aria-label":"Copy code",children:[Hf.jsxDEV(Mr,{name:"copy"},void 0,!1,void 0,this),Hf.jsxDEV(Mr,{name:"check"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Hf.jsxDEV("div",{class:"code-block-content",children:e.pre},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}async function e4t(e){let t=t4t(e);return await zC(t)?t:"text"}function dkr(e){let t=t4t(e);if(M$(t))return t;if(t!=="text")zC(t);return"text"}function t4t(e){let t=Zae(e),n=ukr.get(t);if(n)return n;let r=$c(`code.${t}`);return r!=="text"&&Df(r)?r:t}function Zae(e){return e?.trim().split(/\s+/)[0]?.toLowerCase()||"text"}function mkr(e,t){return new HTMLRewriter().on("img",{element(n){let r=n.getAttribute("src");if(!r)return;let a=URL.parse(r,"http://pi-ui.local");if(!a||a.origin!=="http://pi-ui.local"||r.startsWith("/"))return;try{let i=decodeURIComponent(r.split(/[?#]/,1)[0]??""),o=n4t(Jwr(t,i));if(o)n.setAttribute("src",o);n.setAttribute("loading","lazy"),n.setAttribute("decoding","async")}catch{}}}).transform(e)}function n4t(e){let t=e.startsWith("file:")?Jae(e):e.startsWith("~/")?`${zwr()}${e.slice(1)}`:e.startsWith("/")?e:void 0;if(!t||!pkr.test(t)||!Wwr(t))return;return zV(t)}function WNt(e,t){let n=URL.parse(e,"http://pi-ui.local");if(!n)return;if(n.protocol==="data:")return t.allowDataImage&&/^data:image\/(png|jpeg|gif|webp);base64,/i.test(e)?n:void 0;return Akr.has(n.protocol)?n:void 0}function r4t(e){if(!e.includes("&"))return e;return e.replaceAll("<","<").replaceAll(">",">").replaceAll(""",'"').replaceAll("'","'").replaceAll("'","'").replaceAll("&","&")}var Hf,Kwr=100,Ywr=500,Zwr=500,Vwr=8388608,dRe,zNt,pRe,HNt,ARe,Xwr,JNt,ekr,ukr,pkr,Akr;var Vae=v(()=>{H1();x1();Gb();bi();dne();Ju();qNt();Hf=gn(Ar(),1),dRe=new Ig(Kwr),zNt={maxWeight:Vwr,weight:(e,t)=>2*(e.length+t.length)},pRe=new Ig(Ywr,zNt),HNt=new Ig(Zwr,zNt),ARe=new Map,Xwr=/^\[([^[\]\n]+)\]\([^\n)]*$/,JNt=/<pre><code(?: class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,ekr=new HTMLRewriter().on("a",{element(e){let t=e.getAttribute("href"),n=t?WNt(t,{allowDataImage:!1}):void 0;if(!t||!n){e.before("<span>",{html:!0}),e.after("</span>",{html:!0}),e.removeAndKeepContent();return}if(n.protocol==="file:")e.setAttribute("href","#"),e.setAttribute("data-pi-file-link",t);else e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer")}}).on("img",{element(e){let t=e.getAttribute("src");if(!t||!WNt(t,{allowDataImage:!0})){e.remove();return}let n=n4t(t);if(n)e.setAttribute("src",n);e.setAttribute("loading","lazy"),e.setAttribute("decoding","async")}}).on("table",{element(e){e.setAttribute("class","markdown-table"),e.before('<div class="table-container">',{html:!0}),e.after("</div>",{html:!0})}}).on("th",{element(e){e.setAttribute("class","markdown-table-heading")}}).on("td",{element(e){e.setAttribute("class","markdown-table-cell")}});ukr=new Map([["bash","bash"],["sh","shellscript"],["tf","terraform"],["yml","yaml"]]);pkr=/\.(?:avif|bmp|gif|jpe?g|png|svg|webp)$/i,Akr=new Set(["http:","https:","mailto:","file:"])});function Xae(e){return`${e} message${e===1?"":"s"}`}function fx(e){if(e<1000)return e.toString();if(e<1e4)return`${(e/1000).toFixed(1)}k`;if(e<1e6)return`${Math.round(e/1000)}k`;if(e<1e7)return`${(e/1e6).toFixed(1)}M`;return`${Math.round(e/1e6)}M`}function zM(e){let t=KR(e.session.cwd),n=t?`${t.project} \xB7 ${t.branch}`:e.workspaceNameOnly?qC(e.session.cwd):Rf(e.session.cwd),r=`${Dt.sessionsFavicon}?cwd=${encodeURIComponent(e.session.cwd)}`;return sn(aw.jsxDEV("span",{class:e.class,children:aw.jsxDEV("span",{class:"session-subtitle-content",children:[aw.jsxDEV("span",{class:"session-favicon",style:`--favicon: url("${r}")`,"aria-hidden":"true"},void 0,!1,void 0,this),aw.jsxDEV("span",{class:"session-workspace",safe:!0,children:n},void 0,!1,void 0,this),e.showSubtitle!==!1&&aw.jsxDEV(aw.Fragment,{children:[aw.jsxDEV("span",{class:"session-subtitle-separator","aria-hidden":"true"},void 0,!1,void 0,this),aw.jsxDEV("span",{class:"session-subtitle-text",safe:!0,children:Xae(e.session.messageCount)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this))}var aw;var eie=v(()=>{bi();Mf();aw=gn(Ar(),1)});function hx(e){let t=e.state==="error"?"tool-status-error":"tool-status-success",n=e.state==="running";return sn(i5.jsxDEV("span",{class:["status-dot",e.class],"aria-label":e.label,role:"status",children:[i5.jsxDEV("span",{class:["tool-status-ball tool-status-active status-dot-layer",e.runningClass??"status-dot-running",n?"status-visible":"status-hidden"]},void 0,!1,void 0,this),i5.jsxDEV("span",{class:["tool-status-ball tool-status-result status-dot-layer",t,n?"status-hidden":"status-visible"]},void 0,!1,void 0,this),i5.jsxDEV("span",{class:["tool-status-ball tool-status-pulse status-dot-layer",n?"status-pulse":"status-hidden"]},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}var i5;var tie=v(()=>{i5=gn(Ar(),1)});function i4t(e){return s4t(e).slice(0,4)}function o4t(e,t){let n=s4t(e);if(t==="application/pdf"||n==="pdf")return"pdf";if(t?.startsWith("audio/")||gkr.has(n))return"audio";if(t?.startsWith("video/")||fkr.has(n))return"video";if(t?.includes("zip")||hkr.has(n))return"archive";if(bkr.has(n)||t==="application/json"||t?.includes("javascript")||t?.includes("xml"))return"code";if(t?.startsWith("text/")||ykr.has(n))return"text";return"file"}function s4t(e){return e.match(/\.([^.]+)$/)?.[1].toLowerCase()??""}var a4t,gkr,fkr,hkr,bkr,ykr;var c4t=v(()=>{a4t={archive:{paths:["M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5","M14 2v5a1 1 0 0 0 1 1h5M8 12v-1m0 7v-2m0-9V6"],circle:{cx:8,cy:20,r:2}},audio:{paths:["M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3","M14 2v4a2 2 0 0 0 2 2h4M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0"]},code:{paths:["M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4","M14 2v4a2 2 0 0 0 2 2h4M5 12l-3 3l3 3m4 0l3-3l-3-3"]},file:{paths:["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5"]},pdf:{paths:["M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4","M14 2v4a2 2 0 0 0 2 2h4M2 13v-1h6v1m-3-1v6m-1 0h2"]},text:{paths:["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5M10 9H8m8 4H8m8 4H8"]},video:{paths:["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5m-4.967 5.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z"]}},gkr=new Set(["aac","flac","m4a","mp3","ogg","wav"]),fkr=new Set(["avi","m4v","mkv","mov","mp4","webm"]),hkr=new Set(["7z","bz2","gz","rar","tar","xz","zip"]),bkr=new Set(["c","cpp","css","go","h","html","java","js","json","jsx","py","rs","sh","sql","toml","ts","tsx","xml","yaml","yml"]),ykr=new Set(["csv","log","md","rst","txt"])});function wkr(e,t){if(e===void 0||t===void 0)return;let n=t>u4t?u4t/t:1;return{width:Math.round(e*n),height:Math.round(t*n)}}function nie(e,t,n=!1,r=[],a=!0,i=!1,o=!1){return sn(
|
|
605
|
+
`).map(Bun.escapeHTML)),language:t,source:e},void 0,!1,void 0,this))}function XNt(e){return`<pre class="plain-code" tabindex="0"><code class="streaming-code">${e.map((t,n)=>`<span class="streaming-code-line-number">${n+1}</span><span class="streaming-code-line">${t||" "}</span>`).join("")}</code></pre>`}function lkr(e,t,n={}){let r=`<pre class="plain-code" tabindex="0"><code class="language-${Bun.escapeHTML(t)}">${Bun.escapeHTML(e)}</code></pre>`;return n.chrome===!1?r:sn(Hf.jsxDEV(Yae,{pre:r,language:t},void 0,!1,void 0,this))}function Yae(e){return Hf.jsxDEV("div",{class:"code-block","data-code-block":!0,"data-code-source":e.source===void 0?void 0:Bun.escapeHTML(e.source),children:[Hf.jsxDEV("div",{class:"code-block-header",children:[Hf.jsxDEV("span",{safe:!0,children:e.language},void 0,!1,void 0,this),Hf.jsxDEV("button",{class:"btn code-copy-button","data-variant":"ghost","data-size":"icon-xs",type:"button","data-copy-code":!0,"aria-label":"Copy code",children:[Hf.jsxDEV(Mr,{name:"copy"},void 0,!1,void 0,this),Hf.jsxDEV(Mr,{name:"check"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Hf.jsxDEV("div",{class:"code-block-content",children:e.pre},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}async function e4t(e){let t=t4t(e);return await zC(t)?t:"text"}function dkr(e){let t=t4t(e);if(M$(t))return t;if(t!=="text")zC(t);return"text"}function t4t(e){let t=Zae(e),n=ukr.get(t);if(n)return n;let r=$c(`code.${t}`);return r!=="text"&&Df(r)?r:t}function Zae(e){return e?.trim().split(/\s+/)[0]?.toLowerCase()||"text"}function mkr(e,t){return new HTMLRewriter().on("img",{element(n){let r=n.getAttribute("src");if(!r)return;let a=URL.parse(r,"http://pi-ui.local");if(!a||a.origin!=="http://pi-ui.local"||r.startsWith("/"))return;try{let i=decodeURIComponent(r.split(/[?#]/,1)[0]??""),o=n4t(Jwr(t,i));if(o)n.setAttribute("src",o);n.setAttribute("loading","lazy"),n.setAttribute("decoding","async")}catch{}}}).transform(e)}function n4t(e){let t=e.startsWith("file:")?Jae(e):e.startsWith("~/")?`${zwr()}${e.slice(1)}`:e.startsWith("/")?e:void 0;if(!t||!pkr.test(t)||!Wwr(t))return;return zV(t)}function WNt(e,t){let n=URL.parse(e,"http://pi-ui.local");if(!n)return;if(n.protocol==="data:")return t.allowDataImage&&/^data:image\/(png|jpeg|gif|webp);base64,/i.test(e)?n:void 0;return Akr.has(n.protocol)?n:void 0}function r4t(e){if(!e.includes("&"))return e;return e.replaceAll("<","<").replaceAll(">",">").replaceAll(""",'"').replaceAll("'","'").replaceAll("'","'").replaceAll("&","&")}var Hf,Kwr=100,Ywr=500,Zwr=500,Vwr=8388608,dRe,zNt,pRe,HNt,ARe,Xwr,JNt,ekr,ukr,pkr,Akr;var Vae=v(()=>{H1();x1();Gb();bi();dne();Ju();qNt();Hf=gn(Ar(),1),dRe=new Ig(Kwr),zNt={maxWeight:Vwr,weight:(e,t)=>2*(e.length+t.length)},pRe=new Ig(Ywr,zNt),HNt=new Ig(Zwr,zNt),ARe=new Map,Xwr=/^\[([^[\]\n]+)\]\([^\n)]*$/,JNt=/<pre><code(?: class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,ekr=new HTMLRewriter().on("a",{element(e){let t=e.getAttribute("href"),n=t?WNt(t,{allowDataImage:!1}):void 0;if(!t||!n){e.before("<span>",{html:!0}),e.after("</span>",{html:!0}),e.removeAndKeepContent();return}if(n.protocol==="file:")e.setAttribute("href","#"),e.setAttribute("data-pi-file-link",t);else e.setAttribute("target","_blank"),e.setAttribute("rel","noreferrer")}}).on("img",{element(e){let t=e.getAttribute("src");if(!t||!WNt(t,{allowDataImage:!0})){e.remove();return}let n=n4t(t);if(n)e.setAttribute("src",n);e.setAttribute("loading","lazy"),e.setAttribute("decoding","async")}}).on("table",{element(e){e.setAttribute("class","markdown-table"),e.before('<div class="table-container">',{html:!0}),e.after("</div>",{html:!0})}}).on("th",{element(e){e.setAttribute("class","markdown-table-heading")}}).on("td",{element(e){e.setAttribute("class","markdown-table-cell")}});ukr=new Map([["bash","bash"],["sh","shellscript"],["tf","terraform"],["yml","yaml"]]);pkr=/\.(?:avif|bmp|gif|jpe?g|png|svg|webp)$/i,Akr=new Set(["http:","https:","mailto:","file:"])});function Xae(e){return`${e} message${e===1?"":"s"}`}function fx(e){if(e<1000)return e.toString();if(e<1e4)return`${(e/1000).toFixed(1)}k`;if(e<1e6)return`${Math.round(e/1000)}k`;if(e<1e7)return`${(e/1e6).toFixed(1)}M`;return`${Math.round(e/1e6)}M`}function zM(e){let t=KR(e.session.cwd),n=t?`${t.project} \xB7 ${t.branch}`:e.workspaceNameOnly?qC(e.session.cwd):Rf(e.session.cwd),r=`${Dt.sessionsFavicon}?cwd=${encodeURIComponent(e.session.cwd)}`;return sn(aw.jsxDEV("span",{class:e.class,children:aw.jsxDEV("span",{class:"session-subtitle-content",children:[aw.jsxDEV("span",{class:"session-favicon",style:`--favicon: url("${r}")`,"aria-hidden":"true"},void 0,!1,void 0,this),aw.jsxDEV("span",{class:"session-workspace",safe:!0,children:n},void 0,!1,void 0,this),e.showSubtitle!==!1&&aw.jsxDEV(aw.Fragment,{children:[aw.jsxDEV("span",{class:"session-subtitle-separator","aria-hidden":"true"},void 0,!1,void 0,this),aw.jsxDEV("span",{class:"session-subtitle-text",safe:!0,children:Xae(e.session.messageCount)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this))}var aw;var eie=v(()=>{bi();Mf();aw=gn(Ar(),1)});function hx(e){let t=e.state==="error"?"tool-status-error":"tool-status-success",n=e.state==="running";return sn(i5.jsxDEV("span",{class:["status-dot",e.class],"aria-label":e.label,role:"status",children:[i5.jsxDEV("span",{class:["tool-status-ball tool-status-active status-dot-layer",e.runningClass??"status-dot-running",n?"status-visible":"status-hidden"]},void 0,!1,void 0,this),i5.jsxDEV("span",{class:["tool-status-ball tool-status-result status-dot-layer",t,n?"status-hidden":"status-visible"]},void 0,!1,void 0,this),i5.jsxDEV("span",{class:["tool-status-ball tool-status-pulse status-dot-layer",n?"status-pulse":"status-hidden"]},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}var i5;var tie=v(()=>{i5=gn(Ar(),1)});function i4t(e){return s4t(e).slice(0,4)}function o4t(e,t){let n=s4t(e);if(t==="application/pdf"||n==="pdf")return"pdf";if(t?.startsWith("audio/")||gkr.has(n))return"audio";if(t?.startsWith("video/")||fkr.has(n))return"video";if(t?.includes("zip")||hkr.has(n))return"archive";if(bkr.has(n)||t==="application/json"||t?.includes("javascript")||t?.includes("xml"))return"code";if(t?.startsWith("text/")||ykr.has(n))return"text";return"file"}function s4t(e){return e.match(/\.([^.]+)$/)?.[1].toLowerCase()??""}var a4t,gkr,fkr,hkr,bkr,ykr;var c4t=v(()=>{a4t={archive:{paths:["M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5","M14 2v5a1 1 0 0 0 1 1h5M8 12v-1m0 7v-2m0-9V6"],circle:{cx:8,cy:20,r:2}},audio:{paths:["M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3","M14 2v4a2 2 0 0 0 2 2h4M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0"]},code:{paths:["M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4","M14 2v4a2 2 0 0 0 2 2h4M5 12l-3 3l3 3m4 0l3-3l-3-3"]},file:{paths:["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5"]},pdf:{paths:["M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4","M14 2v4a2 2 0 0 0 2 2h4M2 13v-1h6v1m-3-1v6m-1 0h2"]},text:{paths:["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5M10 9H8m8 4H8m8 4H8"]},video:{paths:["M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z","M14 2v5a1 1 0 0 0 1 1h5m-4.967 5.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z"]}},gkr=new Set(["aac","flac","m4a","mp3","ogg","wav"]),fkr=new Set(["avi","m4v","mkv","mov","mp4","webm"]),hkr=new Set(["7z","bz2","gz","rar","tar","xz","zip"]),bkr=new Set(["c","cpp","css","go","h","html","java","js","json","jsx","py","rs","sh","sql","toml","ts","tsx","xml","yaml","yml"]),ykr=new Set(["csv","log","md","rst","txt"])});function wkr(e,t){if(e===void 0||t===void 0)return;let n=t>u4t?u4t/t:1;return{width:Math.round(e*n),height:Math.round(t*n)}}function nie(e,t,n=!1,r=[],a=!0,i=!1,o=!1){return sn(cn.jsxDEV("main",{id:"messages",class:e.length===0?"messages-empty":void 0,"data-class:messages-loading":"$_sessionTransitionStatus === 'loading'","data-attr:aria-busy":"$_sessionTransitionStatus === 'loading' ? 'true' : 'false'","aria-live":"polite","aria-keyshortcuts":bp("focus-conversation"),tabindex:"-1","data-init":`
|
|
606
606
|
window.piUi.messageScroll.bindResize();
|
|
607
607
|
window.piUi.messageScroll.checkOlder()
|
|
608
608
|
`,"data-preserve-attr":"style","data-on:scroll":"window.piUi.messageScroll.checkOlder()","data-indicator:_history-trimming":!0,"data-on:pi-ui-trim":`if (!$_historyLoading && !$_historyTrimming && $_sessionTransitionStatus !== 'loading') {
|
|
609
609
|
@post('${Dt.messagesTrim}', { payload: evt.detail, retry: 'never' });
|
|
610
|
-
}`,"data-on:keydown__window":$b(["toggle-thinking",`@post('${Dt.thinkingVisibilityToggle}', { payload: {}, retryMaxCount: 0 });`],["focus-conversation","el.focus({ preventScroll: true });"]),children:
|
|
610
|
+
}`,"data-on:keydown__window":$b(["toggle-thinking",`@post('${Dt.thinkingVisibilityToggle}', { payload: {}, retryMaxCount: 0 });`],["focus-conversation","el.focus({ preventScroll: true });"]),children:cn.jsxDEV("div",{class:"messages-stack",children:[cn.jsxDEV("div",{id:"message-list",children:[cn.jsxDEV("div",{class:"older-messages-loading","data-show":"$_historyLoading",style:"display: none",children:cn.jsxDEV(Mr,{name:"loader",label:"Loading older messages",role:"status",class:"icon-spin"},void 0,!1,void 0,this)},void 0,!1,void 0,this),rie(n),e.length===0?kkr(t,r.slice(0,3),a,i):e.map((s)=>aie(s,o))]},void 0,!0,void 0,this),e.length>0&&cn.jsxDEV("div",{id:"messages-prompt-spacer",class:"messages-prompt-spacer",style:"height: 12rem","data-preserve-attr":"style","aria-hidden":"true"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this))}function rie(e){return sn(cn.jsxDEV("div",{id:"older-messages-trigger",style:"height: 1px","data-active":e&&"1","data-indicator:_history-loading":!0,"data-on:pi-ui-older":e&&`if (!$_historyLoading) { @post('${Dt.messagesOlder}', { payload: {}, retry: 'never' }) }`,"data-on:datastar-fetch":e&&"if (evt.detail.el === el && evt.detail.type === 'finished') window.piUi.messageScroll.checkOlder()","aria-hidden":"true"},void 0,!1,void 0,this))}function kkr(e,t,n,r){return cn.jsxDEV("div",{class:"messages-empty-state",children:cn.jsxDEV("div",{class:"messages-empty-content",children:[cn.jsxDEV("p",{class:"messages-empty-title",children:"What can I help with?"},void 0,!1,void 0,this),cn.jsxDEV("p",{class:"messages-empty-hint","data-keybind-hint":!0,children:[cn.jsxDEV(Bl,{shortcut:e.keys},void 0,!1,void 0,this),cn.jsxDEV("span",{safe:!0,children:e.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!n?cn.jsxDEV("p",{class:"messages-empty-login",children:[cn.jsxDEV("button",{type:"button",class:"btn messages-login-button","data-variant":"link","data-on:click":aR("login"),children:"/login"},void 0,!1,void 0,this)," ","to connect a provider and start chatting"]},void 0,!0,void 0,this):(r||t.length>0)&&cn.jsxDEV("div",{class:"recent-sessions",children:[cn.jsxDEV("p",{class:"recent-sessions-heading",children:"Recent sessions"},void 0,!1,void 0,this),r&&t.length===0?cn.jsxDEV("div",{class:"recent-sessions-loading",role:"status","aria-label":"Loading recent sessions",children:cn.jsxDEV(Mr,{name:"loader",class:"icon-spin"},void 0,!1,void 0,this)},void 0,!1,void 0,this):cn.jsxDEV("div",{class:"recent-sessions-list",children:t.map((a,i)=>Ekr(a,i))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Ekr(e,t){let n=`ctrl ${t+1}`;return cn.jsxDEV("button",{type:"button",class:"recent-session","data-attr:disabled":"$_sessionTransitionStatus === 'loading'","data-on:click":A1(e.path),children:[cn.jsxDEV("span",{class:"recent-session-main",children:[cn.jsxDEV("span",{class:"recent-session-title",safe:!0,children:e.title},void 0,!1,void 0,this),cn.jsxDEV(zM,{session:e,class:"recent-session-subtitle"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),cn.jsxDEV("span",{class:"recent-session-meta",children:[cn.jsxDEV(WC,{dateTime:e.modifiedAt,label:e.modified},void 0,!1,void 0,this),cn.jsxDEV(Bl,{shortcut:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function m4t(e){return cn.jsxDEV("div",{class:"tool-output-surface tool-pre-output",children:cn.jsxDEV("pre",{class:"tool-pre",children:cn.jsxDEV("code",{safe:!0,children:e},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function Bkr(e){return cn.jsxDEV("div",{class:"diff-output tool-output-surface tool-rendered-output",children:e.renderedHtml??g4t(vkr(e.text),"tool-output-diff-padding")},void 0,!1,void 0,this)}function Ckr(e){return cn.jsxDEV("div",{class:"code-output tool-output-surface tool-rendered-output",children:e.renderedHtml??_kr(e.text)},void 0,!1,void 0,this)}function xkr(e){return cn.jsxDEV("div",{class:"tool-output tool-output-surface tool-plain-output",children:g4t(e.text,"tool-output-padding")},void 0,!1,void 0,this)}function _kr(e){return cn.jsxDEV("pre",{class:"tool-pending-output tool-pending-code",children:cn.jsxDEV("code",{children:f4t(e)},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function g4t(e,t){return cn.jsxDEV("pre",{class:["tool-pending-output",t],children:cn.jsxDEV("code",{safe:!0,children:e},void 0,!1,void 0,this)},void 0,!1,void 0,this)}function vkr(e){return e.split(`
|
|
611
611
|
`).filter((t)=>!t.startsWith("--- ")&&!t.startsWith("+++ ")&&!t.startsWith("@@ ")).join(`
|
|
612
|
-
`)}function Ikr(e,t,n=[]){if(!t?.length)return
|
|
613
|
-
`);return l4t.set(i,{html:u}),u}catch{return Bun.escapeHTML(e)+t}}function Qkr(e){let t=QC(e,!0);return`<span${t?` style="${Bun.escapeHTML(t)}"`:""}>${Bun.escapeHTML(e.content)}</span>`}function Skr(e){let t=i4t(e.name),n=o4t(e.name,e.mimeType);return ln.jsxDEV("div",{class:"message-file",children:[ln.jsxDEV("span",{class:"fine-print message-file-icon",children:[ln.jsxDEV(Dkr,{kind:n},void 0,!1,void 0,this),t&&ln.jsxDEV("span",{class:"message-file-extension",safe:!0,children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ln.jsxDEV("span",{class:"message-file-content",children:[ln.jsxDEV("span",{class:"message-file-name",safe:!0,children:e.name},void 0,!1,void 0,this),ln.jsxDEV("span",{class:"fine-print message-file-kind",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Dkr(e){let t=a4t[e.kind];return ln.jsxDEV(Mr,{children:ln.jsxDEV(ln.Fragment,{children:[t.paths.map((n)=>ln.jsxDEV("path",{d:n},void 0,!1,void 0,this)),"circle"in t&&ln.jsxDEV("circle",{...t.circle},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function d4t(e,t){let n=[];if(t===0&&!e.mono)n.push("tool-title-gap");if(e.mono)n.push("tool-title-mono");if(e.highlight)n.push(`tool-title-${e.highlight}`);if(e.tone==="accent")n.push("tool-title-accent");if(e.tone==="warning")n.push("warning-foreground");if(e.tone==="muted")n.push("tool-title-muted");return n.join(" ")}function p4t(e){let t=e.split(/(https?:\/\/\S+)/gu);return sn(ln.jsxDEV(ln.Fragment,{children:t.filter(Boolean).map((n)=>n.startsWith("http://")||n.startsWith("https://")?ln.jsxDEV("a",{class:"message-link",href:n,target:"_blank",rel:"noreferrer",safe:!0,children:n},void 0,!1,void 0,this):ln.jsxDEV("span",{safe:!0,children:n},void 0,!1,void 0,this))},void 0,!1,void 0,this))}function aie(e,t=!1){if(e.role==="user")return Rkr(e);if(e.role==="assistant"||e.role==="thought")return Mkr(e);if(e.role==="system"||e.role==="notice")return Fkr(e);if(e.role==="compaction"||e.role==="summary"||e.role==="skill")return Lkr(e);return b4t(e,t)}function h4t(e,t){let n=e?.filter((r)=>r.image)??[];if(!n.length)return"";return ln.jsxDEV("div",{class:["message-attachments",t],children:n.map((r,a)=>Tkr(r,a))},void 0,!1,void 0,this)}function Tkr(e,t){let n=e.image,r=n.url??`data:${n.mimeType};base64,${n.data}`,a=n.url&&n.mimeType!=="image/gif"?`${n.url}&thumb=1`:void 0,i=a??r,o=wkr(n.width,n.height),s=ln.jsxDEV("img",{class:"message-image message-image-frame",src:i,alt:e.name||`Attached image ${t+1}`,loading:"lazy",decoding:"async",width:o?.width,height:o?.height},void 0,!1,void 0,this);return a?ln.jsxDEV("a",{href:r,children:s},void 0,!1,void 0,this):s}function Rkr(e){let t=e.attachments?.filter((n)=>!n.image)??[];return sn(ln.jsxDEV("article",{class:"message message-user",id:`message-${e.id}`,children:[h4t(e.attachments),t.length?ln.jsxDEV("div",{class:"message-attachments",children:t.map(Skr)},void 0,!1,void 0,this):"",e.text&&ln.jsxDEV("p",{class:"message-user-text",safe:!0,children:e.text},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}function Mkr(e){let t=e.renderedHtml??mx(e.text);if(e.role==="thought")return sn(ln.jsxDEV("article",{class:"message message-narrative message-thought thought-foreground",id:`message-${e.id}`,children:[ln.jsxDEV("p",{class:"thinking-placeholder",children:"Thinking..."},void 0,!1,void 0,this),ln.jsxDEV("div",{class:"tool-timeline-item minimal-activity",children:[ln.jsxDEV(hx,{class:"tool-state-dot",state:"running",label:"Thinking"},void 0,!1,void 0,this),ln.jsxDEV("p",{class:"minimal-activity-label",children:"thinking..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ln.jsxDEV("div",{class:"thought-content",children:ln.jsxDEV("div",{class:"markdown-content",children:t},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this));return sn(ln.jsxDEV("article",{class:"message message-narrative message-assistant",id:`message-${e.id}`,children:[e.activitySummary&&ln.jsxDEV("div",{class:"activity-summary tool-timeline-item minimal-activity",children:[ln.jsxDEV(hx,{class:"tool-state-dot",state:"success",label:"Completed"},void 0,!1,void 0,this),ln.jsxDEV("p",{class:"minimal-activity-label",children:["completed ",e.activitySummary.stepCount," ",e.activitySummary.stepCount===1?"step":"steps"," in"," ",e.activitySummary.duration]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),ln.jsxDEV("div",{class:"markdown-content",children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}function Fkr(e){if(e.state==="error")return jkr(e);let t=e.role==="notice";return sn(ln.jsxDEV("article",{class:["message message-narrative message-system-row",t&&"message-status-row tool-timeline-item",t?"message-notice":"message-system message-muted"],id:`message-${e.id}`,role:t?"status":void 0,children:[t&&ln.jsxDEV("span",{class:"tool-state-dot status-dot","aria-hidden":"true",children:ln.jsxDEV("span",{class:"tool-status-ball warning-foreground"},void 0,!1,void 0,this)},void 0,!1,void 0,this),ln.jsxDEV("p",{class:["message-system-text",t&&"tool-header"],children:ln.jsxDEV("span",{class:t?"tool-title":void 0,children:[t&&ln.jsxDEV("span",{class:"sr-only",children:"Warning: "},void 0,!1,void 0,this),e.title?ln.jsxDEV(ln.Fragment,{children:[ln.jsxDEV("span",{safe:!0,children:e.title},void 0,!1,void 0,this),ln.jsxDEV("span",{class:"context-meta",children:p4t(e.text)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):p4t(e.text)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}function jkr(e){let{summary:t,details:n}=zRt(e.text);return sn(ln.jsxDEV("article",{class:"message message-narrative message-system message-system-row message-status-row tool-timeline-item",id:`message-${e.id}`,role:"alert",children:ln.jsxDEV("details",{class:"context-details","data-preserve-attr":"open",children:[ln.jsxDEV("summary",{class:"context-summary",children:[ln.jsxDEV("span",{class:"tool-state-dot status-dot","aria-hidden":"true",children:ln.jsxDEV("span",{class:"tool-status-ball tool-status-error"},void 0,!1,void 0,this)},void 0,!1,void 0,this),ln.jsxDEV("span",{class:"context-title",children:["error",ln.jsxDEV("span",{class:"context-meta",safe:!0,children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ln.jsxDEV("span",{class:"context-chevron",children:ln.jsxDEV(Mr,{name:"chevron-right"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m4t(n)]},void 0,!0,void 0,this)},void 0,!1,void 0,this))}function Lkr(e){let t=e.role==="compaction"?"compaction":e.role==="summary"?"summarize":"skill";return sn(ln.jsxDEV("article",{class:["message message-context tool-timeline-item",e.role==="compaction"?"message-compaction":e.role==="skill"?"message-skill":void 0],id:`message-${e.id}`,children:ln.jsxDEV("details",{class:"context-details","data-preserve-attr":"open",children:[ln.jsxDEV("summary",{class:"context-summary",children:[ln.jsxDEV("span",{class:"tool-state-dot status-dot","aria-hidden":"true",children:ln.jsxDEV("span",{class:"tool-status-ball tool-status-success"},void 0,!1,void 0,this)},void 0,!1,void 0,this),ln.jsxDEV("span",{class:"context-title",children:[ln.jsxDEV("span",{safe:!0,children:t},void 0,!1,void 0,this),e.meta&&ln.jsxDEV("span",{class:"context-meta",safe:!0,children:e.meta},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ln.jsxDEV("span",{class:"context-chevron",children:ln.jsxDEV(Mr,{name:"chevron-right"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ln.jsxDEV("div",{class:"tool-output-surface context-output",children:ln.jsxDEV("div",{class:"markdown-content",children:ln.jsxDEV("div",{children:e.renderedHtml??mx(e.text)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this))}function Pkr(e){if(!e.text.trim())return"";if(e.format==="diff")return Bkr(e);if(e.format==="code")return Ckr(e);if(e.format==="output")return xkr(e);return m4t(e.text)}function Nkr(e){if(e.state==="running")return{state:"running",label:"Running"};if(e.state==="error")return{state:"error",label:"Failed"};return{state:"success",label:"Completed"}}function $kr(e){let t=e.nestedCalls;if(!t?.calls.length)return"";return ln.jsxDEV("div",{class:"nested-tool-calls","aria-label":"Nested tool calls",children:[t.calls.map((n)=>b4t({id:`${e.id}-${n.id}`,role:"tool",timestamp:e.timestamp,presentationState:"plain",presentationVersion:0,title:n.name,titleParts:W1(n.name,n.arguments??{}),state:n.status==="ok"?"success":n.status==="unfinished"&&e.state==="running"?"running":"error",text:n.error??(n.argumentsBytes!==void 0?`arguments omitted: ${n.argumentsBytes} bytes`:""),format:"output",meta:n.status==="unfinished"&&e.state!=="running"?"unfinished":n.durationMs!==void 0?ySe(n.durationMs):void 0})),!t.complete&&ln.jsxDEV("p",{class:"fine-print",children:"Nested call record is incomplete."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function A4t(e){let t=e.highlight?e.text.trim():e.text,r=(t.split(/[\r\n\u2028\u2029]/,1)[0]??"").match(/^[\s\S]{0,256}/u)?.[0]??"";return{...e,text:r+(r===t?"":"\u2026")}}function b4t(e,t=!1){let n=Nkr(e),r=t?e.titleParts?.map(A4t):e.titleParts,a=t?void 0:r?.find((u)=>u.highlight==="javascript"),i=a?cMt(e.nestedCalls,a.text.length):[],o=e.title??"Tool",s=Ikr(t?A4t({text:o}).text:o,r,i),c=ln.jsxDEV("span",{class:"tool-meta","aria-hidden":e.meta?void 0:"true",safe:!0,children:e.meta??""},void 0,!1,void 0,this);return sn(ln.jsxDEV("article",{class:"message message-tool tool-timeline-item",id:`message-${e.id}`,children:[ln.jsxDEV(hx,{class:"tool-state-dot",state:n.state,label:n.label},void 0,!1,void 0,this),t?ln.jsxDEV("p",{class:"tool-title-compact",children:[ln.jsxDEV("span",{class:"tool-title-compact-content",children:s},void 0,!1,void 0,this),c]},void 0,!0,void 0,this):ln.jsxDEV(ln.Fragment,{children:[ln.jsxDEV("header",{class:"tool-header",children:[ln.jsxDEV("span",{class:"tool-title",children:s},void 0,!1,void 0,this),c]},void 0,!0,void 0,this),ln.jsxDEV("div",{children:[$kr(e),h4t(e.attachments,"tool-image-attachments"),Pkr(e)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this))}var ln,l4t,u4t=288;var iie=v(()=>{H1();nne();Q$();iR();Ob();Gb();bi();xSe();R$();Ju();_f();Vae();eie();m1();tie();c4t();ln=gn(Ar(),1),l4t=new Ig(500)});function fRe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function _4t(e){SQ=e}function JM(e){let t=[];return(n)=>{let r=Math.max(0,Math.min(3,n-1)),a=t[r];return a||(a=e(r),t[r]=a),a}}function Di(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(a,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(Bp.caret,"$1"),n=n.replace(a,o),r},getRegex:()=>new RegExp(n,t)};return r}function iw(e,t){if(t){if(Bp.escapeTest.test(e))return e.replace(Bp.escapeReplace,k4t)}else if(Bp.escapeTestNoEncode.test(e))return e.replace(Bp.escapeReplaceNoEncode,k4t);return e}function E4t(e){try{e=encodeURI(e).replace(Bp.percentDecode,"%")}catch{return null}return e}function B4t(e,t){let n=e.replace(Bp.findPipe,(i,o,s)=>{let c=!1,u=o;for(;--u>=0&&s[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(Bp.splitPipe),a=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;a<r.length;a++)r[a]=r[a].trim().replace(Bp.slashPipe,"|");return r}function bx(e,t,n){let r=e.length;if(r===0)return"";let a=0;for(;a<r;){let i=e.charAt(r-a-1);if(i===t&&!n)a++;else if(i!==t&&n)a++;else break}return e.slice(0,r-a)}function C4t(e){let t=e.split(`
|
|
612
|
+
`)}function Ikr(e,t,n=[]){if(!t?.length)return cn.jsxDEV("span",{safe:!0,children:e},void 0,!1,void 0,this);if(t[0]?.text==="$ "&&t[1]?.highlight==="bash")return cn.jsxDEV("span",{class:"tool-command-title",children:[cn.jsxDEV("span",{class:"tool-command-prompt",safe:!0,children:t[0].text.trimEnd()},void 0,!1,void 0,this),cn.jsxDEV("span",{class:"tool-command-content",children:mRe(t[1],1,t.slice(2).map((r,a)=>mRe(r,a+2)).join(""))},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return cn.jsxDEV(cn.Fragment,{children:t.map((r,a)=>mRe(r,a,"",n))},void 0,!1,void 0,this)}function mRe(e,t,n="",r=[]){return e.highlight?cn.jsxDEV("span",{class:d4t(e,t),children:f4t(e.highlight==="javascript"?e.text.trimEnd():e.text,n,e.highlight,r)},void 0,!1,void 0,this):cn.jsxDEV("span",{class:d4t(e,t),safe:!0,children:e.text},void 0,!1,void 0,this)}function f4t(e,t="",n="bash",r=[]){let a=r.map(({field:s,language:c,value:u})=>`${s}:${c}:${Bun.hash(u)}`).join("\x00"),i=`${Q0()}\x00${n}\x00${e}\x00${t}\x00${a}`,o=l4t.get(i);if(o)return o.html;try{let s=n==="bash"?CSe(e,{format:!0}):lMt(e,r);if(!s)return Bun.escapeHTML(e)+t;let{tokens:c}=s,u=c.map((l,d)=>`<span class="shell-line" style="--shell-indent:${(l.map((m)=>m.content).join("").match(/^[\t ]*/)?.[0]??"").replaceAll("\t"," ").length+2}ch">${l.map(Qkr).join("")}${d===c.length-1?t:""}</span>`).join(`
|
|
613
|
+
`);return l4t.set(i,{html:u}),u}catch{return Bun.escapeHTML(e)+t}}function Qkr(e){let t=QC(e,!0);return`<span${t?` style="${Bun.escapeHTML(t)}"`:""}>${Bun.escapeHTML(e.content)}</span>`}function Skr(e){let t=i4t(e.name),n=o4t(e.name,e.mimeType);return cn.jsxDEV("div",{class:"message-file",children:[cn.jsxDEV("span",{class:"fine-print message-file-icon",children:[cn.jsxDEV(Dkr,{kind:n},void 0,!1,void 0,this),t&&cn.jsxDEV("span",{class:"message-file-extension",safe:!0,children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),cn.jsxDEV("span",{class:"message-file-content",children:[cn.jsxDEV("span",{class:"message-file-name",safe:!0,children:e.name},void 0,!1,void 0,this),cn.jsxDEV("span",{class:"fine-print message-file-kind",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Dkr(e){let t=a4t[e.kind];return cn.jsxDEV(Mr,{children:cn.jsxDEV(cn.Fragment,{children:[t.paths.map((n)=>cn.jsxDEV("path",{d:n},void 0,!1,void 0,this)),"circle"in t&&cn.jsxDEV("circle",{...t.circle},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function d4t(e,t){let n=[];if(t===0&&!e.mono)n.push("tool-title-gap");if(e.mono)n.push("tool-title-mono");if(e.highlight)n.push(`tool-title-${e.highlight}`);if(e.tone==="accent")n.push("tool-title-accent");if(e.tone==="warning")n.push("warning-foreground");if(e.tone==="muted")n.push("tool-title-muted");return n.join(" ")}function p4t(e){let t=e.split(/(https?:\/\/\S+)/gu);return sn(cn.jsxDEV(cn.Fragment,{children:t.filter(Boolean).map((n)=>n.startsWith("http://")||n.startsWith("https://")?cn.jsxDEV("a",{class:"message-link",href:n,target:"_blank",rel:"noreferrer",safe:!0,children:n},void 0,!1,void 0,this):cn.jsxDEV("span",{safe:!0,children:n},void 0,!1,void 0,this))},void 0,!1,void 0,this))}function aie(e,t=!1){if(e.role==="user")return Rkr(e);if(e.role==="assistant"||e.role==="thought")return Mkr(e);if(e.role==="system"||e.role==="notice")return Fkr(e);if(e.role==="compaction"||e.role==="summary"||e.role==="skill")return Lkr(e);return b4t(e,t)}function h4t(e,t){let n=e?.filter((r)=>r.image)??[];if(!n.length)return"";return cn.jsxDEV("div",{class:["message-attachments",t],children:n.map((r,a)=>Tkr(r,a))},void 0,!1,void 0,this)}function Tkr(e,t){let n=e.image,r=n.url??`data:${n.mimeType};base64,${n.data}`,a=n.url&&n.mimeType!=="image/gif"?`${n.url}&thumb=1`:void 0,i=a??r,o=wkr(n.width,n.height),s=cn.jsxDEV("img",{class:"message-image",src:i,alt:e.name||`Attached image ${t+1}`,loading:"lazy",decoding:"async",width:o?.width,height:o?.height},void 0,!1,void 0,this);return a?cn.jsxDEV("a",{class:"message-image-frame",href:r,children:s},void 0,!1,void 0,this):cn.jsxDEV("span",{class:"message-image-frame",children:s},void 0,!1,void 0,this)}function Rkr(e){let t=e.attachments?.filter((n)=>!n.image)??[];return sn(cn.jsxDEV("article",{class:"message message-user",id:`message-${e.id}`,children:[h4t(e.attachments),t.length?cn.jsxDEV("div",{class:"message-attachments",children:t.map(Skr)},void 0,!1,void 0,this):"",e.text&&cn.jsxDEV("p",{class:"message-user-text",safe:!0,children:e.text},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}function Mkr(e){let t=e.renderedHtml??mx(e.text);if(e.role==="thought")return sn(cn.jsxDEV("article",{class:"message message-narrative message-thought thought-foreground",id:`message-${e.id}`,children:[cn.jsxDEV("p",{class:"thinking-placeholder",children:"Thinking..."},void 0,!1,void 0,this),cn.jsxDEV("div",{class:"tool-timeline-item minimal-activity",children:[cn.jsxDEV(hx,{class:"tool-state-dot",state:"running",label:"Thinking"},void 0,!1,void 0,this),cn.jsxDEV("p",{class:"minimal-activity-label",children:"thinking..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),cn.jsxDEV("div",{class:"thought-content",children:cn.jsxDEV("div",{class:"markdown-content",children:t},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this));return sn(cn.jsxDEV("article",{class:"message message-narrative message-assistant",id:`message-${e.id}`,children:[e.activitySummary&&cn.jsxDEV("div",{class:"activity-summary tool-timeline-item minimal-activity",children:[cn.jsxDEV(hx,{class:"tool-state-dot",state:"success",label:"Completed"},void 0,!1,void 0,this),cn.jsxDEV("p",{class:"minimal-activity-label",children:["completed ",e.activitySummary.stepCount," ",e.activitySummary.stepCount===1?"step":"steps"," in"," ",e.activitySummary.duration]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),cn.jsxDEV("div",{class:"markdown-content",children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}function Fkr(e){if(e.state==="error")return jkr(e);let t=e.role==="notice";return sn(cn.jsxDEV("article",{class:["message message-narrative message-system-row",t&&"message-status-row tool-timeline-item",t?"message-notice":"message-system message-muted"],id:`message-${e.id}`,role:t?"status":void 0,children:[t&&cn.jsxDEV("span",{class:"tool-state-dot status-dot","aria-hidden":"true",children:cn.jsxDEV("span",{class:"tool-status-ball warning-foreground"},void 0,!1,void 0,this)},void 0,!1,void 0,this),cn.jsxDEV("p",{class:["message-system-text",t&&"tool-header"],children:cn.jsxDEV("span",{class:t?"tool-title":void 0,children:[t&&cn.jsxDEV("span",{class:"sr-only",children:"Warning: "},void 0,!1,void 0,this),e.title?cn.jsxDEV(cn.Fragment,{children:[cn.jsxDEV("span",{safe:!0,children:e.title},void 0,!1,void 0,this),cn.jsxDEV("span",{class:"context-meta",children:p4t(e.text)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):p4t(e.text)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this))}function jkr(e){let{summary:t,details:n}=zRt(e.text);return sn(cn.jsxDEV("article",{class:"message message-narrative message-system message-system-row message-status-row tool-timeline-item",id:`message-${e.id}`,role:"alert",children:cn.jsxDEV("details",{class:"context-details","data-preserve-attr":"open",children:[cn.jsxDEV("summary",{class:"context-summary",children:[cn.jsxDEV("span",{class:"tool-state-dot status-dot","aria-hidden":"true",children:cn.jsxDEV("span",{class:"tool-status-ball tool-status-error"},void 0,!1,void 0,this)},void 0,!1,void 0,this),cn.jsxDEV("span",{class:"context-title",children:["error",cn.jsxDEV("span",{class:"context-meta",safe:!0,children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),cn.jsxDEV("span",{class:"context-chevron",children:cn.jsxDEV(Mr,{name:"chevron-right"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),m4t(n)]},void 0,!0,void 0,this)},void 0,!1,void 0,this))}function Lkr(e){let t=e.role==="compaction"?"compaction":e.role==="summary"?"summarize":"skill";return sn(cn.jsxDEV("article",{class:["message message-context tool-timeline-item",e.role==="compaction"?"message-compaction":e.role==="skill"?"message-skill":void 0],id:`message-${e.id}`,children:cn.jsxDEV("details",{class:"context-details","data-preserve-attr":"open",children:[cn.jsxDEV("summary",{class:"context-summary",children:[cn.jsxDEV("span",{class:"tool-state-dot status-dot","aria-hidden":"true",children:cn.jsxDEV("span",{class:"tool-status-ball tool-status-success"},void 0,!1,void 0,this)},void 0,!1,void 0,this),cn.jsxDEV("span",{class:"context-title",children:[cn.jsxDEV("span",{safe:!0,children:t},void 0,!1,void 0,this),e.meta&&cn.jsxDEV("span",{class:"context-meta",safe:!0,children:e.meta},void 0,!1,void 0,this)]},void 0,!0,void 0,this),cn.jsxDEV("span",{class:"context-chevron",children:cn.jsxDEV(Mr,{name:"chevron-right"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),cn.jsxDEV("div",{class:"tool-output-surface context-output",children:cn.jsxDEV("div",{class:"markdown-content",children:cn.jsxDEV("div",{children:e.renderedHtml??mx(e.text)},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this))}function Pkr(e){if(!e.text.trim())return"";if(e.format==="diff")return Bkr(e);if(e.format==="code")return Ckr(e);if(e.format==="output")return xkr(e);return m4t(e.text)}function Nkr(e){if(e.state==="running")return{state:"running",label:"Running"};if(e.state==="error")return{state:"error",label:"Failed"};return{state:"success",label:"Completed"}}function $kr(e){let t=e.nestedCalls;if(!t?.calls.length)return"";return cn.jsxDEV("div",{class:"nested-tool-calls","aria-label":"Nested tool calls",children:[t.calls.map((n)=>b4t({id:`${e.id}-${n.id}`,role:"tool",timestamp:e.timestamp,presentationState:"plain",presentationVersion:0,title:n.name,titleParts:W1(n.name,n.arguments??{}),state:n.status==="ok"?"success":n.status==="unfinished"&&e.state==="running"?"running":"error",text:n.error??(n.argumentsBytes!==void 0?`arguments omitted: ${n.argumentsBytes} bytes`:""),format:"output",meta:n.status==="unfinished"&&e.state!=="running"?"unfinished":n.durationMs!==void 0?ySe(n.durationMs):void 0})),!t.complete&&cn.jsxDEV("p",{class:"fine-print",children:"Nested call record is incomplete."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function A4t(e){let t=e.highlight?e.text.trim():e.text,r=(t.split(/[\r\n\u2028\u2029]/,1)[0]??"").match(/^[\s\S]{0,256}/u)?.[0]??"";return{...e,text:r+(r===t?"":"\u2026")}}function b4t(e,t=!1){let n=Nkr(e),r=t?e.titleParts?.map(A4t):e.titleParts,a=t?void 0:r?.find((u)=>u.highlight==="javascript"),i=a?cMt(e.nestedCalls,a.text.length):[],o=e.title??"Tool",s=Ikr(t?A4t({text:o}).text:o,r,i),c=cn.jsxDEV("span",{class:"tool-meta","aria-hidden":e.meta?void 0:"true",safe:!0,children:e.meta??""},void 0,!1,void 0,this);return sn(cn.jsxDEV("article",{class:"message message-tool tool-timeline-item",id:`message-${e.id}`,children:[cn.jsxDEV(hx,{class:"tool-state-dot",state:n.state,label:n.label},void 0,!1,void 0,this),t?cn.jsxDEV("p",{class:"tool-title-compact",children:[cn.jsxDEV("span",{class:"tool-title-compact-content",children:s},void 0,!1,void 0,this),c]},void 0,!0,void 0,this):cn.jsxDEV(cn.Fragment,{children:[cn.jsxDEV("header",{class:"tool-header",children:[cn.jsxDEV("span",{class:"tool-title",children:s},void 0,!1,void 0,this),c]},void 0,!0,void 0,this),cn.jsxDEV("div",{children:[$kr(e),h4t(e.attachments,"tool-image-attachments"),Pkr(e)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this))}var cn,l4t,u4t=288;var iie=v(()=>{H1();nne();Q$();iR();Ob();Gb();bi();xSe();R$();Ju();_f();Vae();eie();m1();tie();c4t();cn=gn(Ar(),1),l4t=new Ig(500)});function fRe(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}function _4t(e){SQ=e}function JM(e){let t=[];return(n)=>{let r=Math.max(0,Math.min(3,n-1)),a=t[r];return a||(a=e(r),t[r]=a),a}}function Di(e,t=""){let n=typeof e=="string"?e:e.source,r={replace:(a,i)=>{let o=typeof i=="string"?i:i.source;return o=o.replace(Bp.caret,"$1"),n=n.replace(a,o),r},getRegex:()=>new RegExp(n,t)};return r}function iw(e,t){if(t){if(Bp.escapeTest.test(e))return e.replace(Bp.escapeReplace,k4t)}else if(Bp.escapeTestNoEncode.test(e))return e.replace(Bp.escapeReplaceNoEncode,k4t);return e}function E4t(e){try{e=encodeURI(e).replace(Bp.percentDecode,"%")}catch{return null}return e}function B4t(e,t){let n=e.replace(Bp.findPipe,(i,o,s)=>{let c=!1,u=o;for(;--u>=0&&s[u]==="\\";)c=!c;return c?"|":" |"}),r=n.split(Bp.splitPipe),a=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length<t;)r.push("");for(;a<r.length;a++)r[a]=r[a].trim().replace(Bp.slashPipe,"|");return r}function bx(e,t,n){let r=e.length;if(r===0)return"";let a=0;for(;a<r;){let i=e.charAt(r-a-1);if(i===t&&!n)a++;else if(i!==t&&n)a++;else break}return e.slice(0,r-a)}function C4t(e){let t=e.split(`
|
|
614
614
|
`),n=t.length-1;for(;n>=0&&Bp.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
615
615
|
`)}function REr(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]==="\\")r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function MEr(e,t=0){let n=t,r="";for(let a of e)if(a==="\t"){let i=4-n%4;r+=" ".repeat(i),n+=i}else r+=a,n++;return r}function x4t(e,t,n,r,a){let i=t.href,o=t.title||null,s=e[1].replace(a.other.outputLinkReplace,"$1"),c=e[0].charAt(0)==="!";r.state.inLink=!0;let u=r.state.linkEmitted,l=r.state.inRawBlock;r.state.linkEmitted=!1;let d=r.inlineTokens(s),p=r.state.linkEmitted;if(r.state.linkEmitted=u,r.state.inLink=!1,!c){if(p){r.state.inRawBlock=l;return}r.state.linkEmitted=!0}return{type:c?"image":"link",raw:n,href:i,title:o,text:s,tokens:d}}function FEr(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let a=r[1];return t.split(`
|
|
616
616
|
`).map((i)=>{let o=i.match(n.other.beginningSpace);if(o===null)return i;let[s]=o;return s.length>=a.length?i.slice(a.length):i}).join(`
|