@johnoscott/isometric-engine 0.12.6 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EDITOR-GUIDE.md +9 -2
- package/README.md +1 -1
- package/assets/app.css +6 -0
- package/assets/marks.css +2 -0
- package/iso-editor.js +194 -184
- package/iso-render.js +157 -148
- package/iso-systems.js +170 -159
- package/js/iso-editor/make-way.js +62 -0
- package/js/iso-editor/ui/canvas.js +477 -216
- package/js/iso-editor/ui/palette-look.js +53 -0
- package/js/iso-editor/ui/setup.js +3 -0
- package/js/iso-objects/ants.js +36 -0
- package/js/iso-objects/index.js +47 -1
- package/js/iso-objects/looks.js +25 -0
- package/js/iso-objects/motion-builder.js +130 -0
- package/js/iso-objects/motion-doc.js +500 -0
- package/js/iso-objects/motion-entry.js +32 -0
- package/js/iso-objects/motion.js +635 -0
- package/js/iso-objects/resolve.js +238 -0
- package/js/iso-objects/scene.js +15 -13
- package/js/iso-objects/timeline.js +553 -0
- package/js/iso-systems/compile.js +59 -1
- package/js/iso-systems/index.js +4 -1
- package/js/iso-systems/render.js +20 -0
- package/js/iso-systems/schema.json +39 -0
- package/js/iso-viewer/page.js +2 -1
- package/js/iso-viewer/player.js +23 -34
- package/package.json +46 -1
- package/src/iso-editor/make-way.ts +89 -0
- package/src/iso-editor/ui/app.css +4 -0
- package/src/iso-editor/ui/canvas.ts +390 -170
- package/src/iso-editor/ui/marks.css +2 -0
- package/src/iso-editor/ui/palette-look.ts +51 -0
- package/src/iso-editor/ui/setup.ts +8 -0
- package/src/iso-objects/ants.ts +53 -0
- package/src/iso-objects/compile.ts +4 -1
- package/src/iso-objects/index.ts +14 -1
- package/src/iso-objects/looks.ts +21 -0
- package/src/iso-objects/motion-builder.ts +79 -0
- package/src/iso-objects/motion-doc.ts +361 -0
- package/src/iso-objects/motion-entry.ts +12 -0
- package/src/iso-objects/motion.ts +616 -0
- package/src/iso-objects/resolve.ts +196 -0
- package/src/iso-objects/scene.ts +29 -13
- package/src/iso-objects/timeline.ts +443 -0
- package/src/iso-objects/types.ts +20 -2
- package/src/iso-systems/compile.ts +58 -3
- package/src/iso-systems/index.ts +4 -1
- package/src/iso-systems/render.ts +41 -0
- package/src/iso-systems/schema.json +39 -0
- package/src/iso-viewer/page.ts +2 -1
- package/src/iso-viewer/player.ts +24 -41
- package/types/iso-editor/make-way.d.ts +40 -0
- package/types/iso-editor/ui/canvas.d.ts +33 -12
- package/types/iso-editor/ui/palette-look.d.ts +5 -0
- package/types/iso-editor/ui/setup.d.ts +5 -0
- package/types/iso-objects/ants.d.ts +33 -0
- package/types/iso-objects/compile.d.ts +3 -0
- package/types/iso-objects/index.d.ts +14 -1
- package/types/iso-objects/looks.d.ts +4 -0
- package/types/iso-objects/motion-builder.d.ts +105 -0
- package/types/iso-objects/motion-doc.d.ts +787 -0
- package/types/iso-objects/motion-entry.d.ts +10 -0
- package/types/iso-objects/motion.d.ts +200 -0
- package/types/iso-objects/resolve.d.ts +20 -0
- package/types/iso-objects/scene.d.ts +11 -0
- package/types/iso-objects/timeline.d.ts +46 -0
- package/types/iso-objects/types.d.ts +32 -0
- package/types/iso-systems/compile.d.ts +20 -3
- package/types/iso-systems/index.d.ts +4 -1
- package/types/iso-systems/render.d.ts +21 -0
package/iso-render.js
CHANGED
|
@@ -1,145 +1,154 @@
|
|
|
1
|
-
var xf=Object.defineProperty;var bi=(t,e)=>{for(var n in e)xf(t,n,{get:e[n],enumerable:!0})};var tc={};bi(tc,{Bounds:()=>js,C:()=>yt,DiagError:()=>go,FONTS:()=>at,Kernel:()=>gs,S:()=>Xe,VEl:()=>lr,allowed:()=>Qi,apply:()=>Ds,bubble:()=>Tr,buildSvg:()=>Xl,center:()=>$r,colorRef:()=>Mn,createHash:()=>ec,depthSort:()=>Ks,didYouMean:()=>Yn,distance:()=>Ji,envelope:()=>Er,esc:()=>ut,extendTheme:()=>mo,faceFrame:()=>yi,fileLines:()=>Ar,formatDiag:()=>Xi,formatDiags:()=>ql,iso:()=>we,keyGlyph:()=>Qa,loadTheme:()=>po,matStr:()=>zs,n1:()=>it,parse:()=>Hl,parseSvg:()=>Zi,placeholderFace:()=>el,pt:()=>ts,screenFaces:()=>bs,screenGlass:()=>tl,serialize:()=>bo,sha256Hex:()=>ea,socketGlyph:()=>Za,tag:()=>me,termLines:()=>Vs,textWidth:()=>Jt,themeCss:()=>ho,themeParts:()=>Wi,vdoc:()=>Ql});var Xa={sans700_13:{"0":.6787,"1":.5059,"2":.6372,"3":.6631,"4":.6812,"5":.6577,"6":.6777,"7":.6172,"8":.688,"9":.6777," ":.252,"!":.3506,'"':.563,"#":.6655,$:.6655,"%":1.0298,"&":.7388,"'":.3418,"(":.4229,")":.4229,"*":.4785,"+":.6655,",":.3418,"-":.4785,".":.3418,"/":.3286,":":.3418,";":.3418,"<":.6655,"=":.6655,">":.6655,"?":.5513,"@":.9214,A:.7266,B:.6875,C:.7354,D:.7417,E:.6162,F:.5918,G:.7544,H:.7773,I:.3125,J:.5952,K:.7036,L:.5889,M:.9009,N:.7622,O:.7808,P:.668,Q:.7808,R:.6885,S:.6694,T:.6543,U:.7544,V:.7153,W:1.0034,X:.7236,Y:.7021,Z:.6699,"[":.4229,"\\":.3286,"]":.4229,"^":.6655,_:.5845,"`":.4941,a:.584,b:.6455,c:.5815,d:.6455,e:.5952,f:.407,g:.6396,h:.6265,i:.2813,j:.2813,k:.5957,l:.2891,m:.9263,n:.6216,o:.6138,p:.6411,q:.6416,r:.4338,s:.5513,t:.4114,u:.6216,v:.5771,w:.8413,x:.5747,y:.5913,z:.5605,"{":.4229,"|":.2935,"}":.4229,"~":.6655,"\xB7":.3418,"\u2192":.9375,"\u2190":.9375,"\u2191":.8096,"\u2193":.8096,"\u2019":.3418,"\u2018":.3418,"\u201C":.5474,"\u201D":.5474,"\u2026":.9482,"\u2013":.6216,"\u2014":.9045,"\u2715":.7622,"\xD7":.6655,"\u2248":.6655,"\u2264":.6655,"\u2265":.6655,\u00E9:.5952},sans800_15:{"0":.687,"1":.5122,"2":.6406,"3":.6675,"4":.686,"5":.6626,"6":.6836,"7":.6191,"8":.6968,"9":.6836," ":.2344,"!":.3555,'"':.5835,"#":.6694,$:.6694,"%":1.0566,"&":.7397,"'":.3491,"(":.4287,")":.4287,"*":.4731,"+":.6694,",":.3491,"-":.4731,".":.3491,"/":.3286,":":.3491,";":.3491,"<":.6694,"=":.6694,">":.6694,"?":.5562,"@":.9146,A:.7363,B:.6899,C:.7339,D:.7388,E:.6147,F:.5903,G:.749,H:.7813,I:.3198,J:.6064,K:.7104,L:.5879,M:.9019,N:.7612,O:.7759,P:.6709,Q:.7759,R:.6924,S:.6719,T:.6533,U:.7524,V:.7212,W:1.0073,X:.731,Y:.71,Z:.6646,"[":.4287,"\\":.3286,"]":.4287,"^":.6694,_:.5889,"`":.4844,a:.5864,b:.6479,c:.5811,d:.6479,e:.5952,f:.4139,g:.6416,h:.6309,i:.2847,j:.2847,k:.605,l:.2935,m:.937,n:.626,o:.6138,p:.6436,q:.6445,r:.4406,s:.5557,t:.4198,u:.626,v:.5806,w:.856,x:.5835,y:.5996,z:.5601,"{":.4287,"|":.2974,"}":.4287,"~":.6694,"\xB7":.3491,"\u2192":.9404,"\u2190":.9404,"\u2191":.811,"\u2193":.811,"\u2019":.3491,"\u2018":.3491,"\u201C":.5688,"\u201D":.5688,"\u2026":.9883,"\u2013":.626,"\u2014":.9118,"\u2715":.7622,"\xD7":.6694,"\u2248":.6694,"\u2264":.6694,"\u2265":.6694,\u00E9:.5952},sans800_10_5:{"0":.7114,"1":.5366,"2":.665,"3":.6919,"4":.7104,"5":.687,"6":.708,"7":.6436,"8":.7212,"9":.708," ":.2588,"!":.3799,'"':.6079,"#":.6938,$:.6938,"%":1.0811,"&":.7642,"'":.3735,"(":.4531,")":.4531,"*":.4976,"+":.6938,",":.3735,"-":.4976,".":.3735,"/":.353,":":.3735,";":.3735,"<":.6938,"=":.6938,">":.6938,"?":.5806,"@":.939,A:.7607,B:.7144,C:.7583,D:.7632,E:.6392,F:.6147,G:.7734,H:.8057,I:.3442,J:.6309,K:.7349,L:.6123,M:.9263,N:.7856,O:.8003,P:.6953,Q:.8003,R:.7168,S:.6963,T:.6777,U:.7769,V:.7456,W:1.0317,X:.7554,Y:.7344,Z:.689,"[":.4531,"\\":.353,"]":.4531,"^":.6938,_:.6133,"`":.5088,a:.6108,b:.6724,c:.6055,d:.6724,e:.6196,f:.4383,g:.666,h:.6553,i:.3091,j:.3091,k:.6294,l:.3179,m:.9614,n:.6504,o:.6382,p:.668,q:.6689,r:.465,s:.5801,t:.4442,u:.6504,v:.605,w:.8804,x:.6079,y:.624,z:.5845,"{":.4531,"|":.3218,"}":.4531,"~":.6938,"\xB7":.3735,"\u2192":.9648,"\u2190":.9648,"\u2191":.8354,"\u2193":.8354,"\u2019":.3735,"\u2018":.3735,"\u201C":.5933,"\u201D":.5933,"\u2026":1.0127,"\u2013":.6504,"\u2014":.9204,"\u2715":.7622,"\xD7":.6938,"\u2248":.6938,"\u2264":.6938,"\u2265":.6938,\u00E9:.6196},sans600_12:{"0":.6665,"1":.4956,"2":.6299,"3":.6548,"4":.6724,"5":.6484,"6":.668,"7":.6113,"8":.6753,"9":.668," ":.2656,"!":.3413,'"':.5386,"#":.6577,$:.6577,"%":.999,"&":.7334,"'":.3306,"(":.4131,")":.4131,"*":.48,"+":.6577,",":.3306,"-":.48,".":.3306,"/":.3247,":":.3306,";":.3306,"<":.6577,"=":.6577,">":.6577,"?":.5425,"@":.9238,A:.7129,B:.6812,C:.7329,D:.7402,E:.6133,F:.5889,G:.7559,H:.7695,I:.3013,J:.5801,K:.6924,L:.5859,M:.8955,N:.7593,O:.7813,P:.6606,Q:.7813,R:.6807,S:.6626,T:.6514,U:.7524,V:.7056,W:.9956,X:.7124,Y:.6904,Z:.6709,"[":.4131,"\\":.3247,"]":.4131,"^":.6577,_:.5757,"`":.5,a:.5771,b:.6392,c:.5781,d:.6392,e:.5908,f:.3957,g:.6333,h:.6177,i:.2739,j:.2734,k:.582,l:.2808,m:.9116,n:.6128,o:.6099,p:.6348,q:.6348,r:.4232,s:.543,t:.3991,u:.6128,v:.5693,w:.8228,x:.562,y:.5791,z:.5571,"{":.4131,"|":.2856,"}":.4131,"~":.6577,"\xB7":.3306,"\u2192":.9307,"\u2190":.9307,"\u2191":.8037,"\u2193":.8037,"\u2019":.3306,"\u2018":.3306,"\u201C":.522,"\u201D":.522,"\u2026":.9043,"\u2013":.6128,"\u2014":.8957,"\u2715":.7622,"\xD7":.6577,"\u2248":.6577,"\u2264":.6577,"\u2265":.6577,\u00E9:.5908},sans800_12:{"0":.7026,"1":.5278,"2":.6563,"3":.6831,"4":.7017,"5":.6782,"6":.6992,"7":.6348,"8":.7124,"9":.6992," ":.25,"!":.3711,'"':.5991,"#":.6851,$:.6851,"%":1.0723,"&":.7554,"'":.3647,"(":.4443,")":.4443,"*":.4888,"+":.6851,",":.3647,"-":.4888,".":.3647,"/":.3442,":":.3647,";":.3647,"<":.6851,"=":.6851,">":.6851,"?":.5718,"@":.9302,A:.752,B:.7056,C:.7495,D:.7544,E:.6304,F:.606,G:.7646,H:.7969,I:.3354,J:.6221,K:.7261,L:.6035,M:.9175,N:.7769,O:.7915,P:.6865,Q:.7915,R:.708,S:.6875,T:.6689,U:.7681,V:.7368,W:1.0229,X:.7466,Y:.7256,Z:.6802,"[":.4443,"\\":.3442,"]":.4443,"^":.6851,_:.6045,"`":.5,a:.6021,b:.6636,c:.5967,d:.6636,e:.6108,f:.4295,g:.6572,h:.6465,i:.3003,j:.3003,k:.6206,l:.3091,m:.9526,n:.6416,o:.6294,p:.6592,q:.6602,r:.4562,s:.5713,t:.4354,u:.6416,v:.5962,w:.8716,x:.5991,y:.6152,z:.5757,"{":.4443,"|":.313,"}":.4443,"~":.6851,"\xB7":.3647,"\u2192":.9561,"\u2190":.9561,"\u2191":.8267,"\u2193":.8267,"\u2019":.3647,"\u2018":.3647,"\u201C":.5845,"\u201D":.5845,"\u2026":1.0039,"\u2013":.6416,"\u2014":.9173,"\u2715":.7622,"\xD7":.6851,"\u2248":.6851,"\u2264":.6851,"\u2265":.6851,\u00E9:.6108},sans800_11_5:{"0":.7056,"1":.5308,"2":.6592,"3":.686,"4":.7046,"5":.6812,"6":.7021,"7":.6377,"8":.7153,"9":.7021," ":.2529,"!":.374,'"':.6021,"#":.688,$:.688,"%":1.0752,"&":.7583,"'":.3677,"(":.4473,")":.4473,"*":.4917,"+":.688,",":.3677,"-":.4917,".":.3677,"/":.3472,":":.3677,";":.3677,"<":.688,"=":.688,">":.688,"?":.5747,"@":.9331,A:.7549,B:.7085,C:.7524,D:.7573,E:.6333,F:.6089,G:.7676,H:.7998,I:.3384,J:.625,K:.729,L:.6064,M:.9204,N:.7798,O:.7944,P:.6895,Q:.7944,R:.7109,S:.6904,T:.6719,U:.771,V:.7397,W:1.0259,X:.7495,Y:.7285,Z:.6831,"[":.4473,"\\":.3472,"]":.4473,"^":.688,_:.6074,"`":.5029,a:.605,b:.6665,c:.5996,d:.6665,e:.6138,f:.4325,g:.6602,h:.6494,i:.3032,j:.3032,k:.6235,l:.312,m:.9556,n:.6445,o:.6323,p:.6621,q:.6631,r:.4591,s:.5742,t:.4383,u:.6445,v:.5991,w:.8745,x:.6021,y:.6182,z:.5786,"{":.4473,"|":.3159,"}":.4473,"~":.688,"\xB7":.3677,"\u2192":.959,"\u2190":.959,"\u2191":.8296,"\u2193":.8296,"\u2019":.3677,"\u2018":.3677,"\u201C":.5874,"\u201D":.5874,"\u2026":1.0068,"\u2013":.6445,"\u2014":.9183,"\u2715":.7622,"\xD7":.688,"\u2248":.688,"\u2264":.688,"\u2265":.688,\u00E9:.6138},sans400_13:{"0":.624,"1":.458,"2":.5977,"3":.6211,"4":.6377,"5":.6123,"6":.6309,"7":.582,"8":.6328,"9":.6309," ":.2754,"!":.3052,'"':.4717,"#":.624,$:.624,"%":.9194,"&":.7056,"'":.291,"(":.376,")":.376,"*":.4658,"+":.624,",":.291,"-":.4658,".":.291,"/":.2988,":":.291,";":.291,"<":.624,"=":.624,">":.624,"?":.5068,"@":.9121,A:.668,B:.6514,C:.71,D:.7207,E:.5898,F:.5664,G:.7407,H:.7363,I:.2617,J:.5322,K:.6528,L:.562,M:.8682,N:.7363,O:.7656,P:.6294,Q:.7656,R:.6475,S:.6313,T:.6279,U:.7314,V:.668,W:.9619,X:.6729,Y:.6494,Z:.6558,"[":.376,"\\":.2988,"]":.376,"^":.624,_:.5405,"`":.4941,a:.5459,b:.6084,c:.5537,d:.6084,e:.5654,f:.356,g:.6035,h:.5825,i:.2412,j:.2407,k:.5371,l:.2471,m:.8643,n:.5776,o:.585,p:.6045,q:.6035,r:.3843,s:.5083,t:.3574,u:.5776,v:.5361,w:.7686,x:.5186,y:.5371,z:.5332,"{":.376,"|":.2529,"}":.376,"~":.624,"\xB7":.291,"\u2192":.8999,"\u2190":.8999,"\u2191":.7754,"\u2193":.7754,"\u2019":.291,"\u2018":.291,"\u201C":.4531,"\u201D":.4531,"\u2026":.7988,"\u2013":.5776,"\u2014":.872,"\u2715":.7622,"\xD7":.624,"\u2248":.624,"\u2264":.624,"\u2265":.624,\u00E9:.5654},mono400_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021},mono600_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021}};var Xe=34,yt=Math.cos(Math.PI/6),we=(t,e,n=0)=>[(t-e)*yt*Xe,(t+e)*.5*Xe-n*Xe],it=t=>{let e=Math.round(t*10)/10;return Object.is(e,-0)?"0":String(e)},ts=t=>`${it(t[0])},${it(t[1])}`,ut=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function me(t,e={},n){let s="";for(let r in e){let o=e[r];o==null||o===!1||o===""||(s+=` ${r}="${ut(typeof o=="number"?it(o):o)}"`)}return n===void 0?`<${t}${s}/>`:`<${t}${s}>${n}</${t}>`}var at={lbl:{key:"sans700_13",size:13},sub:{key:"mono400_11",size:11},slabname:{key:"sans800_15",size:15,spacing:.12},sm:{key:"sans800_10_5",size:10.5,spacing:.1},floor:{key:"mono600_11",size:11,spacing:.01},say:{key:"sans600_12",size:12},tunname:{key:"sans800_12",size:12,spacing:.14},badge:{key:"sans800_11_5",size:11.5}};function Jt(t,e){let n=Xa[e.key],s=e.key.startsWith("mono")?.6:.58,r=0;for(let o of t)r+=n[o]??s;return(r+(e.spacing??0)*[...t].length)*e.size}var Ds=(t,e,n)=>[t[0]*e+t[2]*n+t[4],t[1]*e+t[3]*n+t[5]],zs=t=>`matrix(${t.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function yi(t,e){if(e==="left"){let[r,o]=we(t.x0,t.y1,t.z1);return{m:[yt,.5,0,1,r,o],w:(t.x1-t.x0)*Xe,h:(t.z1-t.z0)*Xe}}if(e==="right"){let[r,o]=we(t.x1,t.y1,t.z1);return{m:[yt,-.5,0,1,r,o],w:(t.y1-t.y0)*Xe,h:(t.z1-t.z0)*Xe}}let[n,s]=we(t.x0,t.y0,t.z1);return{m:[yt,.5,-yt,.5,n,s],w:(t.x1-t.x0)*Xe,h:(t.y1-t.y0)*Xe}}var js=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(e){e[0]<this.x0&&(this.x0=e[0]),e[0]>this.x1&&(this.x1=e[0]),e[1]<this.y0&&(this.y0=e[1]),e[1]>this.y1&&(this.y1=e[1])}addRect(e,n,s,r){this.add([e,n]),this.add([e+s,n+r])}get empty(){return this.x0===1/0}},gs=class{bounds=new js;texts=[];planes=[];planePolys=[];defs=new Map;poly(e,n,s={}){let r=e.map(o=>we(o[0],o[1],o[2]));return r.forEach(o=>this.bounds.add(o)),me("polygon",{points:r.map(ts).join(" "),class:n,...s})}line3(e,n,s,r={}){let o=we(...e),i=we(...n);return this.bounds.add(o),this.bounds.add(i),me("line",{x1:o[0],y1:o[1],x2:i[0],y2:i[1],class:s,...r})}blockFaces(e){let{x0:n,y0:s,x1:r,y1:o,z0:i,z1:a}=e;return this.poly([[n,o,i],[r,o,i],[r,o,a],[n,o,a]],"lft")+this.poly([[r,s,i],[r,o,i],[r,o,a],[r,s,a]],"rgt")+this.poly([[n,s,a],[r,s,a],[r,o,a],[n,o,a]],"top")}onFace(e,n,s,r){let o=yi(e,n);for(let[i,a]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(Ds(o.m,i,a));return me("g",{class:r,transform:zs(o.m)},s(o.w,o.h))}onMatrix(e,n,s,r,o){for(let[i,a]of[[0,0],[n,0],[0,s],[n,s]])this.bounds.add(Ds(e,i,a));return me("g",{class:o,transform:zs(e)},r(n,s))}text(e,n,s,r,o,i="middle",a={},l){let c=Jt(s,o),u={x:i==="start"?e:i==="end"?e-c:e-c/2,y:n-o.size*.8,w:c,h:o.size*1.05,text:s,owner:l};return this.bounds.addRect(u.x-2,u.y-2,u.w+4,u.h+4),this.texts.push(u),me("text",{x:e,y:n,class:r,"text-anchor":i==="start"?void 0:i,...a},ut(s))}planeText(e,n,s,r,o="start",i={}){let a=Jt(n,r),l=o==="start"?0:o==="end"?-a:-a/2,c=[[l,-r.size*.8],[l+a,-r.size*.8],[l,r.size*.25],[l+a,r.size*.25]].map(([d,p])=>Ds(e,d,p));c.forEach(d=>this.bounds.add(d));let f=c.map(d=>d[0]),u=c.map(d=>d[1]);return this.planePolys.push([c[0],c[1],c[3],c[2]]),this.planes.push({x:Math.min(...f),y:Math.min(...u),w:Math.max(...f)-Math.min(...f),h:Math.max(...u)-Math.min(...u)}),me("text",{transform:zs(e),class:s,"text-anchor":o==="start"?void 0:o,...i},ut(n))}floorText(e,n,s,r,o,i="x",a="start",l={}){let[c,f]=we(e,n,s),u=i==="x"?[yt,.5,-yt,.5,c,f]:[yt,-.5,yt,.5,c,f];return this.planeText(u,r,o,at.floor,a,l)}faceText(e,n,s,r,o,i,a="left",l="start",c={}){let[f,u]=we(e,n,s),d=a==="left"?[yt,.5,0,1,f,u]:[yt,-.5,0,1,f,u];return this.planeText(d,r,o,i,l,c)}def(e,n){this.defs.set(e,n)}},$r=t=>[(t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1];function Vs(t,e,n){let s="";for(let r=0;r<n;r++){let o=e.z1-(e.z1-e.z0)*(.28+r*.2),i=(e.x1-e.x0)*(r===n-1?.35:.62-r*.1);s+=t.line3([e.x0+.35,e.y1,o],[e.x0+.35+i,e.y1,o],"det")}return s}function Er(t,e){let s=e.z1,r=[e.x0+.55,e.y0+.55,s],o=[e.x1-.55,e.y0+.55,s],i=[e.x1-.55,e.y1-.55,s],a=[e.x0+.55,e.y1-.55,s],l=[(e.x0+e.x1)/2,(e.y0+e.y1)/2,s];return t.poly([r,o,i,a],"det")+t.line3(r,l,"det")+t.line3(l,o,"det")}function Tr(t,e){let s=e.z1,r=t.poly([[e.x0+.55,e.y0+.55,s],[e.x1-.55,e.y0+.55,s],[e.x1-.55,e.y1-.55,s],[e.x0+.55,e.y1-.55,s]],"det");for(let o=1;o<=2;o++){let i=e.y0+.55+(e.y1-e.y0-1.1)*o/3;r+=t.line3([e.x0+.55+.3,i,s],[e.x1-.55-.3-(o===2?.5:0),i,s],"det")}return r}function Ar(t,e){let s=e.z1,r=(e.y0+e.y1)/2;return t.line3([e.x0+.3,r-.2,s],[e.x1-.3,r-.2,s],"det")+t.line3([e.x0+.3,r+.2,s],[e.x1-.3-.3,r+.2,s],"det")}function Qa(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.16,i=[];for(let a=0;a<20;a++){let l=a/20*Math.PI*2;i.push([n-o*1.4+Math.cos(l)*o,s+Math.sin(l)*o,r])}return t.poly(i,"det")+t.line3([n-o*.4,s,r],[n+o*2.2,s,r],"det")+t.line3([n+o*1.7,s,r],[n+o*1.7,s+o*.8,r],"det")}function Za(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.28,i=[];for(let a=0;a<24;a++){let l=a/24*Math.PI*2;i.push([n+Math.cos(l)*o,s+Math.sin(l)*o,r])}return t.poly(i,"det sock-hole")}var ns=(t,e,n,s,r,o=0)=>me("rect",{class:t,x:e,y:n,width:s,height:r,rx:o||void 0}),bs={terminal(t,e){let n="",s=Math.max(2,Math.floor((e-12)/9));for(let r=0;r<s;r++){let o=10+r*9,i=(t-18)*[.7,.45,.6,.3,.55][r%5];n+=me("line",{class:"ln",x1:8,y1:o,x2:8+i,y2:o})}return n},chat(t,e){return[[6,.62,"w"],[.3,.58,"m"],[6,.46,"w"],[.42,.5,"m"]].map((s,r)=>{let o=(t-14)*s[1],i=s[0]===6?7:t-7-o;return ns(s[2],i,8+r*(e-18)/4,o,(e-18)/4-4,3)}).join("")},desktop(t,e){return ns("wall",5,5,t-10,e-10,2)+ns("bar",5,5,t-10,6)+ns("win",t*.5,13,t*.38,e*.42,2)},tiles(t,e){let i=(t-12-5)/3,a=(e-12-2.5*1)/2,l="";for(let c=0;c<2;c++)for(let f=0;f<3;f++){let u=6+f*(i+2.5),d=6+c*(a+2.5);l+=ns("t",u,d,i,a,1.5),[.3,.52,.74].forEach((p,h)=>{l+=me("line",{class:"ln",x1:u+2.5,y1:d+a*p,x2:u+2.5+(i-5)*[.8,.5,.65][(h+c+f)%3],y2:d+a*p})})}return l}};function el(t,e){let n=t/2,s=e/2,r=Math.min(t,e)*.22;return ns("unk",t*.2,e*.2,t*.6,e*.6,2)+me("path",{class:"unk-q",d:`M${it(n-r*.5)},${it(s-r*.45)}a${it(r*.5)},${it(r*.5)} 0 1 1 ${it(r*.5)},${it(r*.55)}v${it(r*.3)}`})+me("circle",{class:"unk-dot",cx:it(n),cy:it(s+r*.75),r:it(Math.max(.8,r*.1))})}function tl(t,e){return ns("glass",3,3,t-6,e-6,3)}function vf(t){let e=[we(t.x0,t.y0,t.z1),we(t.x1,t.y0,t.z0),we(t.x0,t.y1,t.z0),we(t.x1,t.y1,t.z0),we(t.x1,t.y1,t.z1),we(t.x0,t.y0,t.z0)],n=e.map(r=>r[0]),s=e.map(r=>r[1]);return[Math.min(...n),Math.min(...s),Math.max(...n),Math.max(...s)]}function Sf(t,e){let s=t.x1<=e.x0+1e-6,r=e.x1<=t.x0+1e-6,o=t.y1<=e.y0+1e-6,i=e.y1<=t.y0+1e-6,a=t.z1<=e.z0+1e-6,l=e.z1<=t.z0+1e-6,c=s||o||a,f=r||i||l;return c&&!f?-1:f&&!c?1:0}function Ks(t){let e=t.length,n=t.map(c=>vf(c.box)),s=c=>c.box.x0+c.box.y0+c.box.z0*.01,r=t.map(()=>[]),o=new Array(e).fill(0);for(let c=0;c<e;c++)for(let f=c+1;f<e;f++){let u=n[c],d=n[f];if(u[2]<=d[0]||d[2]<=u[0]||u[3]<=d[1]||d[3]<=u[1])continue;let p=Sf(t[c].box,t[f].box);p<0?(r[c].push(f),o[f]++):p>0&&(r[f].push(c),o[c]++)}let i=[],a=t.map((c,f)=>f).filter(c=>!o[c]),l=new Array(e).fill(!1);for(;i.length<e;){if(!a.length){let f=t.map((u,d)=>d).filter(u=>!l[u]).sort((u,d)=>s(t[u])-s(t[d]));a.push(f[0]),o[f[0]]=0}a.sort((f,u)=>s(t[f])-s(t[u])||f-u);let c=a.shift();if(!l[c]){l[c]=!0,i.push(t[c]);for(let f of r[c])!l[f]&&--o[f]===0&&a.push(f)}}return i}var Nr=Symbol.for("yaml.alias"),Pr=Symbol.for("yaml.document"),an=Symbol.for("yaml.map"),xi=Symbol.for("yaml.pair"),Gt=Symbol.for("yaml.scalar"),Pn=Symbol.for("yaml.seq"),Ft=Symbol.for("yaml.node.type"),ln=t=>!!t&&typeof t=="object"&&t[Ft]===Nr,bn=t=>!!t&&typeof t=="object"&&t[Ft]===Pr,_t=t=>!!t&&typeof t=="object"&&t[Ft]===an,Le=t=>!!t&&typeof t=="object"&&t[Ft]===xi,Ne=t=>!!t&&typeof t=="object"&&t[Ft]===Gt,Dt=t=>!!t&&typeof t=="object"&&t[Ft]===Pn;function Ge(t){if(t&&typeof t=="object")switch(t[Ft]){case an:case Pn:return!0}return!1}function De(t){if(t&&typeof t=="object")switch(t[Ft]){case Nr:case an:case Gt:case Pn:return!0}return!1}var Rr=t=>(Ne(t)||Ge(t))&&!!t.anchor;var zt=Symbol("break visit"),nl=Symbol("skip children"),yn=Symbol("remove node");function xn(t,e){let n=sl(e);bn(t)?ys(null,t.contents,n,Object.freeze([t]))===yn&&(t.contents=null):ys(null,t,n,Object.freeze([]))}xn.BREAK=zt;xn.SKIP=nl;xn.REMOVE=yn;function ys(t,e,n,s){let r=rl(t,e,n,s);if(De(r)||Le(r))return ol(t,s,r),ys(t,r,n,s);if(typeof r!="symbol"){if(Ge(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=ys(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===zt)return zt;i===yn&&(e.items.splice(o,1),o-=1)}}}else if(Le(e)){s=Object.freeze(s.concat(e));let o=ys("key",e.key,n,s);if(o===zt)return zt;o===yn&&(e.key=null);let i=ys("value",e.value,n,s);if(i===zt)return zt;i===yn&&(e.value=null)}}return r}async function Or(t,e){let n=sl(e);bn(t)?await xs(null,t.contents,n,Object.freeze([t]))===yn&&(t.contents=null):await xs(null,t,n,Object.freeze([]))}Or.BREAK=zt;Or.SKIP=nl;Or.REMOVE=yn;async function xs(t,e,n,s){let r=await rl(t,e,n,s);if(De(r)||Le(r))return ol(t,s,r),xs(t,r,n,s);if(typeof r!="symbol"){if(Ge(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=await xs(o,e.items[o],n,s);if(typeof i=="number")o=i-1;else{if(i===zt)return zt;i===yn&&(e.items.splice(o,1),o-=1)}}}else if(Le(e)){s=Object.freeze(s.concat(e));let o=await xs("key",e.key,n,s);if(o===zt)return zt;o===yn&&(e.key=null);let i=await xs("value",e.value,n,s);if(i===zt)return zt;i===yn&&(e.value=null)}}return r}function sl(t){return typeof t=="object"&&(t.Collection||t.Node||t.Value)?Object.assign({Alias:t.Node,Map:t.Node,Scalar:t.Node,Seq:t.Node},t.Value&&{Map:t.Value,Scalar:t.Value,Seq:t.Value},t.Collection&&{Map:t.Collection,Seq:t.Collection},t):t}function rl(t,e,n,s){if(typeof n=="function")return n(t,e,s);if(_t(e))return n.Map?.(t,e,s);if(Dt(e))return n.Seq?.(t,e,s);if(Le(e))return n.Pair?.(t,e,s);if(Ne(e))return n.Scalar?.(t,e,s);if(ln(e))return n.Alias?.(t,e,s)}function ol(t,e,n){let s=e[e.length-1];if(Ge(s))s.items[t]=n;else if(Le(s))t==="key"?s.key=n:s.value=n;else if(bn(s))s.contents=n;else{let r=ln(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var Mf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},$f=t=>t.replace(/[!,[\]{}]/g,e=>Mf[e]),wn=class t{constructor(e,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},t.defaultYaml,e),this.tags=Object.assign({},t.defaultTags,n)}clone(){let e=new t(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new t(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:t.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},t.defaultTags);break}return e}add(e,n){this.atNextDocument&&(this.yaml={explicit:t.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},t.defaultTags),this.atNextDocument=!1);let s=e.trim().split(/[ \t]+/),r=s.shift();switch(r){case"%TAG":{if(s.length!==2&&(n(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;let[o,i]=s;return this.tags[o]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return n(0,"%YAML directive should contain exactly one part"),!1;let[o]=s;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let i=/^\d+\.\d+$/.test(o);return n(6,`Unsupported YAML version ${o}`,i),!1}}default:return n(0,`Unknown directive ${r}`,!0),!1}}tagName(e,n){if(e==="!")return"!";if(e[0]!=="!")return n(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);return i==="!"||i==="!!"?(n(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&n("Verbatim tags must end with a >"),i)}let[,s,r]=e.match(/^(.*!)([^!]*)$/s);r||n(`The ${e} tag has no suffix`);let o=this.tags[s];if(o)try{return o+decodeURIComponent(r)}catch(i){return n(String(i)),null}return s==="!"?e:(n(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[n,s]of Object.entries(this.tags))if(e.startsWith(s))return n+$f(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let n=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),r;if(e&&s.length>0&&De(e.contents)){let o={};xn(e.contents,(i,a)=>{De(a)&&a.tag&&(o[a.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,i]of s)o==="!!"&&i==="tag:yaml.org,2002:"||(!e||r.some(a=>a.startsWith(i)))&&n.push(`%TAG ${o} ${i}`);return n.join(`
|
|
2
|
-
`)}};
|
|
3
|
-
`)?
|
|
1
|
+
var sd=Object.defineProperty;var la=(n,e)=>{for(var t in e)sd(n,t,{get:e[t],enumerable:!0})};var cf={};la(cf,{Bounds:()=>br,C:()=>wt,DiagError:()=>ti,FONTS:()=>lt,Kernel:()=>Ls,S:()=>nt,VEl:()=>Dr,allowed:()=>Va,apply:()=>hr,bubble:()=>mo,buildSvg:()=>rf,center:()=>fo,colorRef:()=>_n,createHash:()=>lf,depthSort:()=>xr,didYouMean:()=>Bt,distance:()=>_a,envelope:()=>uo,esc:()=>dt,extendTheme:()=>Zo,faceFrame:()=>ca,fileLines:()=>po,formatDiag:()=>za,formatDiags:()=>Zc,iso:()=>Ce,keyGlyph:()=>oc,loadTheme:()=>Qo,matStr:()=>gr,n1:()=>at,parse:()=>tf,parseSvg:()=>Ka,placeholderFace:()=>ac,pt:()=>xs,screenFaces:()=>Fs,screenGlass:()=>lc,serialize:()=>ni,sha256Hex:()=>Ga,socketGlyph:()=>ic,tag:()=>Te,termLines:()=>yr,textWidth:()=>sn,themeCss:()=>ei,themeParts:()=>jr,vdoc:()=>of});var rc={sans700_13:{"0":.6787,"1":.5059,"2":.6372,"3":.6631,"4":.6812,"5":.6577,"6":.6777,"7":.6172,"8":.688,"9":.6777," ":.252,"!":.3506,'"':.563,"#":.6655,$:.6655,"%":1.0298,"&":.7388,"'":.3418,"(":.4229,")":.4229,"*":.4785,"+":.6655,",":.3418,"-":.4785,".":.3418,"/":.3286,":":.3418,";":.3418,"<":.6655,"=":.6655,">":.6655,"?":.5513,"@":.9214,A:.7266,B:.6875,C:.7354,D:.7417,E:.6162,F:.5918,G:.7544,H:.7773,I:.3125,J:.5952,K:.7036,L:.5889,M:.9009,N:.7622,O:.7808,P:.668,Q:.7808,R:.6885,S:.6694,T:.6543,U:.7544,V:.7153,W:1.0034,X:.7236,Y:.7021,Z:.6699,"[":.4229,"\\":.3286,"]":.4229,"^":.6655,_:.5845,"`":.4941,a:.584,b:.6455,c:.5815,d:.6455,e:.5952,f:.407,g:.6396,h:.6265,i:.2813,j:.2813,k:.5957,l:.2891,m:.9263,n:.6216,o:.6138,p:.6411,q:.6416,r:.4338,s:.5513,t:.4114,u:.6216,v:.5771,w:.8413,x:.5747,y:.5913,z:.5605,"{":.4229,"|":.2935,"}":.4229,"~":.6655,"\xB7":.3418,"\u2192":.9375,"\u2190":.9375,"\u2191":.8096,"\u2193":.8096,"\u2019":.3418,"\u2018":.3418,"\u201C":.5474,"\u201D":.5474,"\u2026":.9482,"\u2013":.6216,"\u2014":.9045,"\u2715":.7622,"\xD7":.6655,"\u2248":.6655,"\u2264":.6655,"\u2265":.6655,\u00E9:.5952},sans800_15:{"0":.687,"1":.5122,"2":.6406,"3":.6675,"4":.686,"5":.6626,"6":.6836,"7":.6191,"8":.6968,"9":.6836," ":.2344,"!":.3555,'"':.5835,"#":.6694,$:.6694,"%":1.0566,"&":.7397,"'":.3491,"(":.4287,")":.4287,"*":.4731,"+":.6694,",":.3491,"-":.4731,".":.3491,"/":.3286,":":.3491,";":.3491,"<":.6694,"=":.6694,">":.6694,"?":.5562,"@":.9146,A:.7363,B:.6899,C:.7339,D:.7388,E:.6147,F:.5903,G:.749,H:.7813,I:.3198,J:.6064,K:.7104,L:.5879,M:.9019,N:.7612,O:.7759,P:.6709,Q:.7759,R:.6924,S:.6719,T:.6533,U:.7524,V:.7212,W:1.0073,X:.731,Y:.71,Z:.6646,"[":.4287,"\\":.3286,"]":.4287,"^":.6694,_:.5889,"`":.4844,a:.5864,b:.6479,c:.5811,d:.6479,e:.5952,f:.4139,g:.6416,h:.6309,i:.2847,j:.2847,k:.605,l:.2935,m:.937,n:.626,o:.6138,p:.6436,q:.6445,r:.4406,s:.5557,t:.4198,u:.626,v:.5806,w:.856,x:.5835,y:.5996,z:.5601,"{":.4287,"|":.2974,"}":.4287,"~":.6694,"\xB7":.3491,"\u2192":.9404,"\u2190":.9404,"\u2191":.811,"\u2193":.811,"\u2019":.3491,"\u2018":.3491,"\u201C":.5688,"\u201D":.5688,"\u2026":.9883,"\u2013":.626,"\u2014":.9118,"\u2715":.7622,"\xD7":.6694,"\u2248":.6694,"\u2264":.6694,"\u2265":.6694,\u00E9:.5952},sans800_10_5:{"0":.7114,"1":.5366,"2":.665,"3":.6919,"4":.7104,"5":.687,"6":.708,"7":.6436,"8":.7212,"9":.708," ":.2588,"!":.3799,'"':.6079,"#":.6938,$:.6938,"%":1.0811,"&":.7642,"'":.3735,"(":.4531,")":.4531,"*":.4976,"+":.6938,",":.3735,"-":.4976,".":.3735,"/":.353,":":.3735,";":.3735,"<":.6938,"=":.6938,">":.6938,"?":.5806,"@":.939,A:.7607,B:.7144,C:.7583,D:.7632,E:.6392,F:.6147,G:.7734,H:.8057,I:.3442,J:.6309,K:.7349,L:.6123,M:.9263,N:.7856,O:.8003,P:.6953,Q:.8003,R:.7168,S:.6963,T:.6777,U:.7769,V:.7456,W:1.0317,X:.7554,Y:.7344,Z:.689,"[":.4531,"\\":.353,"]":.4531,"^":.6938,_:.6133,"`":.5088,a:.6108,b:.6724,c:.6055,d:.6724,e:.6196,f:.4383,g:.666,h:.6553,i:.3091,j:.3091,k:.6294,l:.3179,m:.9614,n:.6504,o:.6382,p:.668,q:.6689,r:.465,s:.5801,t:.4442,u:.6504,v:.605,w:.8804,x:.6079,y:.624,z:.5845,"{":.4531,"|":.3218,"}":.4531,"~":.6938,"\xB7":.3735,"\u2192":.9648,"\u2190":.9648,"\u2191":.8354,"\u2193":.8354,"\u2019":.3735,"\u2018":.3735,"\u201C":.5933,"\u201D":.5933,"\u2026":1.0127,"\u2013":.6504,"\u2014":.9204,"\u2715":.7622,"\xD7":.6938,"\u2248":.6938,"\u2264":.6938,"\u2265":.6938,\u00E9:.6196},sans600_12:{"0":.6665,"1":.4956,"2":.6299,"3":.6548,"4":.6724,"5":.6484,"6":.668,"7":.6113,"8":.6753,"9":.668," ":.2656,"!":.3413,'"':.5386,"#":.6577,$:.6577,"%":.999,"&":.7334,"'":.3306,"(":.4131,")":.4131,"*":.48,"+":.6577,",":.3306,"-":.48,".":.3306,"/":.3247,":":.3306,";":.3306,"<":.6577,"=":.6577,">":.6577,"?":.5425,"@":.9238,A:.7129,B:.6812,C:.7329,D:.7402,E:.6133,F:.5889,G:.7559,H:.7695,I:.3013,J:.5801,K:.6924,L:.5859,M:.8955,N:.7593,O:.7813,P:.6606,Q:.7813,R:.6807,S:.6626,T:.6514,U:.7524,V:.7056,W:.9956,X:.7124,Y:.6904,Z:.6709,"[":.4131,"\\":.3247,"]":.4131,"^":.6577,_:.5757,"`":.5,a:.5771,b:.6392,c:.5781,d:.6392,e:.5908,f:.3957,g:.6333,h:.6177,i:.2739,j:.2734,k:.582,l:.2808,m:.9116,n:.6128,o:.6099,p:.6348,q:.6348,r:.4232,s:.543,t:.3991,u:.6128,v:.5693,w:.8228,x:.562,y:.5791,z:.5571,"{":.4131,"|":.2856,"}":.4131,"~":.6577,"\xB7":.3306,"\u2192":.9307,"\u2190":.9307,"\u2191":.8037,"\u2193":.8037,"\u2019":.3306,"\u2018":.3306,"\u201C":.522,"\u201D":.522,"\u2026":.9043,"\u2013":.6128,"\u2014":.8957,"\u2715":.7622,"\xD7":.6577,"\u2248":.6577,"\u2264":.6577,"\u2265":.6577,\u00E9:.5908},sans800_12:{"0":.7026,"1":.5278,"2":.6563,"3":.6831,"4":.7017,"5":.6782,"6":.6992,"7":.6348,"8":.7124,"9":.6992," ":.25,"!":.3711,'"':.5991,"#":.6851,$:.6851,"%":1.0723,"&":.7554,"'":.3647,"(":.4443,")":.4443,"*":.4888,"+":.6851,",":.3647,"-":.4888,".":.3647,"/":.3442,":":.3647,";":.3647,"<":.6851,"=":.6851,">":.6851,"?":.5718,"@":.9302,A:.752,B:.7056,C:.7495,D:.7544,E:.6304,F:.606,G:.7646,H:.7969,I:.3354,J:.6221,K:.7261,L:.6035,M:.9175,N:.7769,O:.7915,P:.6865,Q:.7915,R:.708,S:.6875,T:.6689,U:.7681,V:.7368,W:1.0229,X:.7466,Y:.7256,Z:.6802,"[":.4443,"\\":.3442,"]":.4443,"^":.6851,_:.6045,"`":.5,a:.6021,b:.6636,c:.5967,d:.6636,e:.6108,f:.4295,g:.6572,h:.6465,i:.3003,j:.3003,k:.6206,l:.3091,m:.9526,n:.6416,o:.6294,p:.6592,q:.6602,r:.4562,s:.5713,t:.4354,u:.6416,v:.5962,w:.8716,x:.5991,y:.6152,z:.5757,"{":.4443,"|":.313,"}":.4443,"~":.6851,"\xB7":.3647,"\u2192":.9561,"\u2190":.9561,"\u2191":.8267,"\u2193":.8267,"\u2019":.3647,"\u2018":.3647,"\u201C":.5845,"\u201D":.5845,"\u2026":1.0039,"\u2013":.6416,"\u2014":.9173,"\u2715":.7622,"\xD7":.6851,"\u2248":.6851,"\u2264":.6851,"\u2265":.6851,\u00E9:.6108},sans800_11_5:{"0":.7056,"1":.5308,"2":.6592,"3":.686,"4":.7046,"5":.6812,"6":.7021,"7":.6377,"8":.7153,"9":.7021," ":.2529,"!":.374,'"':.6021,"#":.688,$:.688,"%":1.0752,"&":.7583,"'":.3677,"(":.4473,")":.4473,"*":.4917,"+":.688,",":.3677,"-":.4917,".":.3677,"/":.3472,":":.3677,";":.3677,"<":.688,"=":.688,">":.688,"?":.5747,"@":.9331,A:.7549,B:.7085,C:.7524,D:.7573,E:.6333,F:.6089,G:.7676,H:.7998,I:.3384,J:.625,K:.729,L:.6064,M:.9204,N:.7798,O:.7944,P:.6895,Q:.7944,R:.7109,S:.6904,T:.6719,U:.771,V:.7397,W:1.0259,X:.7495,Y:.7285,Z:.6831,"[":.4473,"\\":.3472,"]":.4473,"^":.688,_:.6074,"`":.5029,a:.605,b:.6665,c:.5996,d:.6665,e:.6138,f:.4325,g:.6602,h:.6494,i:.3032,j:.3032,k:.6235,l:.312,m:.9556,n:.6445,o:.6323,p:.6621,q:.6631,r:.4591,s:.5742,t:.4383,u:.6445,v:.5991,w:.8745,x:.6021,y:.6182,z:.5786,"{":.4473,"|":.3159,"}":.4473,"~":.688,"\xB7":.3677,"\u2192":.959,"\u2190":.959,"\u2191":.8296,"\u2193":.8296,"\u2019":.3677,"\u2018":.3677,"\u201C":.5874,"\u201D":.5874,"\u2026":1.0068,"\u2013":.6445,"\u2014":.9183,"\u2715":.7622,"\xD7":.688,"\u2248":.688,"\u2264":.688,"\u2265":.688,\u00E9:.6138},sans400_13:{"0":.624,"1":.458,"2":.5977,"3":.6211,"4":.6377,"5":.6123,"6":.6309,"7":.582,"8":.6328,"9":.6309," ":.2754,"!":.3052,'"':.4717,"#":.624,$:.624,"%":.9194,"&":.7056,"'":.291,"(":.376,")":.376,"*":.4658,"+":.624,",":.291,"-":.4658,".":.291,"/":.2988,":":.291,";":.291,"<":.624,"=":.624,">":.624,"?":.5068,"@":.9121,A:.668,B:.6514,C:.71,D:.7207,E:.5898,F:.5664,G:.7407,H:.7363,I:.2617,J:.5322,K:.6528,L:.562,M:.8682,N:.7363,O:.7656,P:.6294,Q:.7656,R:.6475,S:.6313,T:.6279,U:.7314,V:.668,W:.9619,X:.6729,Y:.6494,Z:.6558,"[":.376,"\\":.2988,"]":.376,"^":.624,_:.5405,"`":.4941,a:.5459,b:.6084,c:.5537,d:.6084,e:.5654,f:.356,g:.6035,h:.5825,i:.2412,j:.2407,k:.5371,l:.2471,m:.8643,n:.5776,o:.585,p:.6045,q:.6035,r:.3843,s:.5083,t:.3574,u:.5776,v:.5361,w:.7686,x:.5186,y:.5371,z:.5332,"{":.376,"|":.2529,"}":.376,"~":.624,"\xB7":.291,"\u2192":.8999,"\u2190":.8999,"\u2191":.7754,"\u2193":.7754,"\u2019":.291,"\u2018":.291,"\u201C":.4531,"\u201D":.4531,"\u2026":.7988,"\u2013":.5776,"\u2014":.872,"\u2715":.7622,"\xD7":.624,"\u2248":.624,"\u2264":.624,"\u2265":.624,\u00E9:.5654},mono400_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021},mono600_11:{"0":.6021,"1":.6021,"2":.6021,"3":.6021,"4":.6021,"5":.6021,"6":.6021,"7":.6021,"8":.6021,"9":.6021," ":.6021,"!":.6021,'"':.6021,"#":.6021,$:.6021,"%":.6021,"&":.6021,"'":.6021,"(":.6021,")":.6021,"*":.6021,"+":.6021,",":.6021,"-":.6021,".":.6021,"/":.6021,":":.6021,";":.6021,"<":.6021,"=":.6021,">":.6021,"?":.6021,"@":.6021,A:.6021,B:.6021,C:.6021,D:.6021,E:.6021,F:.6021,G:.6021,H:.6021,I:.6021,J:.6021,K:.6021,L:.6021,M:.6021,N:.6021,O:.6021,P:.6021,Q:.6021,R:.6021,S:.6021,T:.6021,U:.6021,V:.6021,W:.6021,X:.6021,Y:.6021,Z:.6021,"[":.6021,"\\":.6021,"]":.6021,"^":.6021,_:.6021,"`":.6021,a:.6021,b:.6021,c:.6021,d:.6021,e:.6021,f:.6021,g:.6021,h:.6021,i:.6021,j:.6021,k:.6021,l:.6021,m:.6021,n:.6021,o:.6021,p:.6021,q:.6021,r:.6021,s:.6021,t:.6021,u:.6021,v:.6021,w:.6021,x:.6021,y:.6021,z:.6021,"{":.6021,"|":.6021,"}":.6021,"~":.6021,"\xB7":.6021,"\u2192":.6021,"\u2190":.6021,"\u2191":.6021,"\u2193":.6021,"\u2019":.6021,"\u2018":.6021,"\u201C":.6021,"\u201D":.6021,"\u2026":.6021,"\u2013":.6021,"\u2014":.6021,"\u2715":.6021,"\xD7":.6021,"\u2248":.6021,"\u2264":.6021,"\u2265":.6021,\u00E9:.6021}};var nt=34,wt=Math.cos(Math.PI/6),Ce=(n,e,t=0)=>[(n-e)*wt*nt,(n+e)*.5*nt-t*nt],at=n=>{let e=Math.round(n*10)/10;return Object.is(e,-0)?"0":String(e)},xs=n=>`${at(n[0])},${at(n[1])}`,dt=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""");function Te(n,e={},t){let s="";for(let r in e){let o=e[r];o==null||o===!1||o===""||(s+=` ${r}="${dt(typeof o=="number"?at(o):o)}"`)}return t===void 0?`<${n}${s}/>`:`<${n}${s}>${t}</${n}>`}var lt={lbl:{key:"sans700_13",size:13},sub:{key:"mono400_11",size:11},slabname:{key:"sans800_15",size:15,spacing:.12},sm:{key:"sans800_10_5",size:10.5,spacing:.1},floor:{key:"mono600_11",size:11,spacing:.01},say:{key:"sans600_12",size:12},tunname:{key:"sans800_12",size:12,spacing:.14},badge:{key:"sans800_11_5",size:11.5}};function sn(n,e){let t=rc[e.key],s=e.key.startsWith("mono")?.6:.58,r=0;for(let o of n)r+=t[o]??s;return(r+(e.spacing??0)*[...n].length)*e.size}var hr=(n,e,t)=>[n[0]*e+n[2]*t+n[4],n[1]*e+n[3]*t+n[5]],gr=n=>`matrix(${n.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function ca(n,e){if(e==="left"){let[r,o]=Ce(n.x0,n.y1,n.z1);return{m:[wt,.5,0,1,r,o],w:(n.x1-n.x0)*nt,h:(n.z1-n.z0)*nt}}if(e==="right"){let[r,o]=Ce(n.x1,n.y1,n.z1);return{m:[wt,-.5,0,1,r,o],w:(n.y1-n.y0)*nt,h:(n.z1-n.z0)*nt}}let[t,s]=Ce(n.x0,n.y0,n.z1);return{m:[wt,.5,-wt,.5,t,s],w:(n.x1-n.x0)*nt,h:(n.y1-n.y0)*nt}}var br=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(e){e[0]<this.x0&&(this.x0=e[0]),e[0]>this.x1&&(this.x1=e[0]),e[1]<this.y0&&(this.y0=e[1]),e[1]>this.y1&&(this.y1=e[1])}addRect(e,t,s,r){this.add([e,t]),this.add([e+s,t+r])}get empty(){return this.x0===1/0}},Ls=class{bounds=new br;texts=[];planes=[];planePolys=[];defs=new Map;poly(e,t,s={}){let r=e.map(o=>Ce(o[0],o[1],o[2]));return r.forEach(o=>this.bounds.add(o)),Te("polygon",{points:r.map(xs).join(" "),class:t,...s})}line3(e,t,s,r={}){let o=Ce(...e),i=Ce(...t);return this.bounds.add(o),this.bounds.add(i),Te("line",{x1:o[0],y1:o[1],x2:i[0],y2:i[1],class:s,...r})}blockFaces(e){let{x0:t,y0:s,x1:r,y1:o,z0:i,z1:a}=e;return this.poly([[t,o,i],[r,o,i],[r,o,a],[t,o,a]],"lft")+this.poly([[r,s,i],[r,o,i],[r,o,a],[r,s,a]],"rgt")+this.poly([[t,s,a],[r,s,a],[r,o,a],[t,o,a]],"top")}onFace(e,t,s,r){let o=ca(e,t);for(let[i,a]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(hr(o.m,i,a));return Te("g",{class:r,transform:gr(o.m)},s(o.w,o.h))}onMatrix(e,t,s,r,o){for(let[i,a]of[[0,0],[t,0],[0,s],[t,s]])this.bounds.add(hr(e,i,a));return Te("g",{class:o,transform:gr(e)},r(t,s))}text(e,t,s,r,o,i="middle",a={},l){let c=sn(s,o),u={x:i==="start"?e:i==="end"?e-c:e-c/2,y:t-o.size*.8,w:c,h:o.size*1.05,text:s,owner:l};return this.bounds.addRect(u.x-2,u.y-2,u.w+4,u.h+4),this.texts.push(u),Te("text",{x:e,y:t,class:r,"text-anchor":i==="start"?void 0:i,...a},dt(s))}planeText(e,t,s,r,o="start",i={}){let a=sn(t,r),l=o==="start"?0:o==="end"?-a:-a/2,c=[[l,-r.size*.8],[l+a,-r.size*.8],[l,r.size*.25],[l+a,r.size*.25]].map(([d,p])=>hr(e,d,p));c.forEach(d=>this.bounds.add(d));let f=c.map(d=>d[0]),u=c.map(d=>d[1]);return this.planePolys.push([c[0],c[1],c[3],c[2]]),this.planes.push({x:Math.min(...f),y:Math.min(...u),w:Math.max(...f)-Math.min(...f),h:Math.max(...u)-Math.min(...u)}),Te("text",{transform:gr(e),class:s,"text-anchor":o==="start"?void 0:o,...i},dt(t))}floorText(e,t,s,r,o,i="x",a="start",l={}){let[c,f]=Ce(e,t,s),u=i==="x"?[wt,.5,-wt,.5,c,f]:[wt,-.5,wt,.5,c,f];return this.planeText(u,r,o,lt.floor,a,l)}faceText(e,t,s,r,o,i,a="left",l="start",c={}){let[f,u]=Ce(e,t,s),d=a==="left"?[wt,.5,0,1,f,u]:[wt,-.5,0,1,f,u];return this.planeText(d,r,o,i,l,c)}def(e,t){this.defs.set(e,t)}},fo=n=>[(n.x0+n.x1)/2,(n.y0+n.y1)/2,n.z1];function yr(n,e,t){let s="";for(let r=0;r<t;r++){let o=e.z1-(e.z1-e.z0)*(.28+r*.2),i=(e.x1-e.x0)*(r===t-1?.35:.62-r*.1);s+=n.line3([e.x0+.35,e.y1,o],[e.x0+.35+i,e.y1,o],"det")}return s}function uo(n,e){let s=e.z1,r=[e.x0+.55,e.y0+.55,s],o=[e.x1-.55,e.y0+.55,s],i=[e.x1-.55,e.y1-.55,s],a=[e.x0+.55,e.y1-.55,s],l=[(e.x0+e.x1)/2,(e.y0+e.y1)/2,s];return n.poly([r,o,i,a],"det")+n.line3(r,l,"det")+n.line3(l,o,"det")}function mo(n,e){let s=e.z1,r=n.poly([[e.x0+.55,e.y0+.55,s],[e.x1-.55,e.y0+.55,s],[e.x1-.55,e.y1-.55,s],[e.x0+.55,e.y1-.55,s]],"det");for(let o=1;o<=2;o++){let i=e.y0+.55+(e.y1-e.y0-1.1)*o/3;r+=n.line3([e.x0+.55+.3,i,s],[e.x1-.55-.3-(o===2?.5:0),i,s],"det")}return r}function po(n,e){let s=e.z1,r=(e.y0+e.y1)/2;return n.line3([e.x0+.3,r-.2,s],[e.x1-.3,r-.2,s],"det")+n.line3([e.x0+.3,r+.2,s],[e.x1-.3-.3,r+.2,s],"det")}function oc(n,e){let t=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.16,i=[];for(let a=0;a<20;a++){let l=a/20*Math.PI*2;i.push([t-o*1.4+Math.cos(l)*o,s+Math.sin(l)*o,r])}return n.poly(i,"det")+n.line3([t-o*.4,s,r],[t+o*2.2,s,r],"det")+n.line3([t+o*1.7,s,r],[t+o*1.7,s+o*.8,r],"det")}function ic(n,e){let t=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(e.x1-e.x0,e.y1-e.y0)*.28,i=[];for(let a=0;a<24;a++){let l=a/24*Math.PI*2;i.push([t+Math.cos(l)*o,s+Math.sin(l)*o,r])}return n.poly(i,"det sock-hole")}var ws=(n,e,t,s,r,o=0)=>Te("rect",{class:n,x:e,y:t,width:s,height:r,rx:o||void 0}),Fs={terminal(n,e){let t="",s=Math.max(2,Math.floor((e-12)/9));for(let r=0;r<s;r++){let o=10+r*9,i=(n-18)*[.7,.45,.6,.3,.55][r%5];t+=Te("line",{class:"ln",x1:8,y1:o,x2:8+i,y2:o})}return t},chat(n,e){return[[6,.62,"w"],[.3,.58,"m"],[6,.46,"w"],[.42,.5,"m"]].map((s,r)=>{let o=(n-14)*s[1],i=s[0]===6?7:n-7-o;return ws(s[2],i,8+r*(e-18)/4,o,(e-18)/4-4,3)}).join("")},desktop(n,e){return ws("wall",5,5,n-10,e-10,2)+ws("bar",5,5,n-10,6)+ws("win",n*.5,13,n*.38,e*.42,2)},tiles(n,e){let i=(n-12-5)/3,a=(e-12-2.5*1)/2,l="";for(let c=0;c<2;c++)for(let f=0;f<3;f++){let u=6+f*(i+2.5),d=6+c*(a+2.5);l+=ws("t",u,d,i,a,1.5),[.3,.52,.74].forEach((p,g)=>{l+=Te("line",{class:"ln",x1:u+2.5,y1:d+a*p,x2:u+2.5+(i-5)*[.8,.5,.65][(g+c+f)%3],y2:d+a*p})})}return l}};function ac(n,e){let t=n/2,s=e/2,r=Math.min(n,e)*.22;return ws("unk",n*.2,e*.2,n*.6,e*.6,2)+Te("path",{class:"unk-q",d:`M${at(t-r*.5)},${at(s-r*.45)}a${at(r*.5)},${at(r*.5)} 0 1 1 ${at(r*.5)},${at(r*.55)}v${at(r*.3)}`})+Te("circle",{class:"unk-dot",cx:at(t),cy:at(s+r*.75),r:at(Math.max(.8,r*.1))})}function lc(n,e){return ws("glass",3,3,n-6,e-6,3)}function id(n){let e=[Ce(n.x0,n.y0,n.z1),Ce(n.x1,n.y0,n.z0),Ce(n.x0,n.y1,n.z0),Ce(n.x1,n.y1,n.z0),Ce(n.x1,n.y1,n.z1),Ce(n.x0,n.y0,n.z0)],t=e.map(r=>r[0]),s=e.map(r=>r[1]);return[Math.min(...t),Math.min(...s),Math.max(...t),Math.max(...s)]}function ad(n,e){let s=n.x1<=e.x0+1e-6,r=e.x1<=n.x0+1e-6,o=n.y1<=e.y0+1e-6,i=e.y1<=n.y0+1e-6,a=n.z1<=e.z0+1e-6,l=e.z1<=n.z0+1e-6,c=s||o||a,f=r||i||l;return c&&!f?-1:f&&!c?1:0}function xr(n){let e=n.length,t=n.map(c=>id(c.box)),s=c=>c.box.x0+c.box.y0+c.box.z0*.01,r=n.map(()=>[]),o=new Array(e).fill(0);for(let c=0;c<e;c++)for(let f=c+1;f<e;f++){let u=t[c],d=t[f];if(u[2]<=d[0]||d[2]<=u[0]||u[3]<=d[1]||d[3]<=u[1])continue;let p=ad(n[c].box,n[f].box);p<0?(r[c].push(f),o[f]++):p>0&&(r[f].push(c),o[c]++)}let i=[],a=n.map((c,f)=>f).filter(c=>!o[c]),l=new Array(e).fill(!1);for(;i.length<e;){if(!a.length){let f=n.map((u,d)=>d).filter(u=>!l[u]).sort((u,d)=>s(n[u])-s(n[d]));a.push(f[0]),o[f[0]]=0}a.sort((f,u)=>s(n[f])-s(n[u])||f-u);let c=a.shift();if(!l[c]){l[c]=!0,i.push(n[c]);for(let f of r[c])!l[f]&&--o[f]===0&&a.push(f)}}return i}var ho=Symbol.for("yaml.alias"),go=Symbol.for("yaml.document"),yn=Symbol.for("yaml.map"),fa=Symbol.for("yaml.pair"),Xt=Symbol.for("yaml.scalar"),Yn=Symbol.for("yaml.seq"),zt=Symbol.for("yaml.node.type"),xn=n=>!!n&&typeof n=="object"&&n[zt]===ho,Cn=n=>!!n&&typeof n=="object"&&n[zt]===go,Gt=n=>!!n&&typeof n=="object"&&n[zt]===yn,qe=n=>!!n&&typeof n=="object"&&n[zt]===fa,_e=n=>!!n&&typeof n=="object"&&n[zt]===Xt,qt=n=>!!n&&typeof n=="object"&&n[zt]===Yn;function Xe(n){if(n&&typeof n=="object")switch(n[zt]){case yn:case Yn:return!0}return!1}function Ye(n){if(n&&typeof n=="object")switch(n[zt]){case ho:case yn:case Xt:case Yn:return!0}return!1}var bo=n=>(_e(n)||Xe(n))&&!!n.anchor;var Ut=Symbol("break visit"),cc=Symbol("skip children"),In=Symbol("remove node");function Ln(n,e){let t=fc(e);Cn(n)?Bs(null,n.contents,t,Object.freeze([n]))===In&&(n.contents=null):Bs(null,n,t,Object.freeze([]))}Ln.BREAK=Ut;Ln.SKIP=cc;Ln.REMOVE=In;function Bs(n,e,t,s){let r=uc(n,e,t,s);if(Ye(r)||qe(r))return dc(n,s,r),Bs(n,r,t,s);if(typeof r!="symbol"){if(Xe(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=Bs(o,e.items[o],t,s);if(typeof i=="number")o=i-1;else{if(i===Ut)return Ut;i===In&&(e.items.splice(o,1),o-=1)}}}else if(qe(e)){s=Object.freeze(s.concat(e));let o=Bs("key",e.key,t,s);if(o===Ut)return Ut;o===In&&(e.key=null);let i=Bs("value",e.value,t,s);if(i===Ut)return Ut;i===In&&(e.value=null)}}return r}async function yo(n,e){let t=fc(e);Cn(n)?await js(null,n.contents,t,Object.freeze([n]))===In&&(n.contents=null):await js(null,n,t,Object.freeze([]))}yo.BREAK=Ut;yo.SKIP=cc;yo.REMOVE=In;async function js(n,e,t,s){let r=await uc(n,e,t,s);if(Ye(r)||qe(r))return dc(n,s,r),js(n,r,t,s);if(typeof r!="symbol"){if(Xe(e)){s=Object.freeze(s.concat(e));for(let o=0;o<e.items.length;++o){let i=await js(o,e.items[o],t,s);if(typeof i=="number")o=i-1;else{if(i===Ut)return Ut;i===In&&(e.items.splice(o,1),o-=1)}}}else if(qe(e)){s=Object.freeze(s.concat(e));let o=await js("key",e.key,t,s);if(o===Ut)return Ut;o===In&&(e.key=null);let i=await js("value",e.value,t,s);if(i===Ut)return Ut;i===In&&(e.value=null)}}return r}function fc(n){return typeof n=="object"&&(n.Collection||n.Node||n.Value)?Object.assign({Alias:n.Node,Map:n.Node,Scalar:n.Node,Seq:n.Node},n.Value&&{Map:n.Value,Scalar:n.Value,Seq:n.Value},n.Collection&&{Map:n.Collection,Seq:n.Collection},n):n}function uc(n,e,t,s){if(typeof t=="function")return t(n,e,s);if(Gt(e))return t.Map?.(n,e,s);if(qt(e))return t.Seq?.(n,e,s);if(qe(e))return t.Pair?.(n,e,s);if(_e(e))return t.Scalar?.(n,e,s);if(xn(e))return t.Alias?.(n,e,s)}function dc(n,e,t){let s=e[e.length-1];if(Xe(s))s.items[n]=t;else if(qe(s))n==="key"?s.key=t:s.value=t;else if(Cn(s))s.contents=t;else{let r=xn(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var ld={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},cd=n=>n.replace(/[!,[\]{}]/g,e=>ld[e]),Fn=class n{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},n.defaultYaml,e),this.tags=Object.assign({},n.defaultTags,t)}clone(){let e=new n(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){let e=new n(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:n.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},n.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:n.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},n.defaultTags),this.atNextDocument=!1);let s=e.trim().split(/[ \t]+/),r=s.shift();switch(r){case"%TAG":{if(s.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;let[o,i]=s;return this.tags[o]=i,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;let[o]=s;if(o==="1.1"||o==="1.2")return this.yaml.version=o,!0;{let i=/^\d+\.\d+$/.test(o);return t(6,`Unsupported YAML version ${o}`,i),!1}}default:return t(0,`Unknown directive ${r}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){let i=e.slice(2,-1);return i==="!"||i==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),i)}let[,s,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let o=this.tags[s];if(o)try{return o+decodeURIComponent(r)}catch(i){return t(String(i)),null}return s==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+cd(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags),r;if(e&&s.length>0&&Ye(e.contents)){let o={};Ln(e.contents,(i,a)=>{Ye(a)&&a.tag&&(o[a.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,i]of s)o==="!!"&&i==="tag:yaml.org,2002:"||(!e||r.some(a=>a.startsWith(i)))&&t.push(`%TAG ${o} ${i}`);return t.join(`
|
|
2
|
+
`)}};Fn.defaultYaml={explicit:!1,version:"1.2"};Fn.defaultTags={"!!":"tag:yaml.org,2002:"};function xo(n){if(/[\x00-\x19\s,[\]{}]/.test(n)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(n)}`;throw new Error(t)}return!0}function ua(n){let e=new Set;return Ln(n,{Value(t,s){s.anchor&&e.add(s.anchor)}}),e}function da(n,e){for(let t=1;;++t){let s=`${n}${t}`;if(!e.has(s))return s}}function mc(n,e){let t=[],s=new Map,r=null;return{onAnchor:o=>{t.push(o),r??(r=ua(n));let i=da(e,r);return r.add(i),i},setAnchors:()=>{for(let o of t){let i=s.get(o);if(typeof i=="object"&&i.anchor&&(_e(i.node)||Xe(i.node)))i.node.anchor=i.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=o,a}}},sourceObjects:s}}function ns(n,e,t,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let r=0,o=s.length;r<o;++r){let i=s[r],a=ns(n,s,String(r),i);a===void 0?delete s[r]:a!==i&&(s[r]=a)}else if(s instanceof Map)for(let r of Array.from(s.keys())){let o=s.get(r),i=ns(n,s,r,o);i===void 0?s.delete(r):i!==o&&s.set(r,i)}else if(s instanceof Set)for(let r of Array.from(s)){let o=ns(n,s,r,r);o===void 0?s.delete(r):o!==r&&(s.delete(r),s.add(o))}else for(let[r,o]of Object.entries(s)){let i=ns(n,s,r,o);i===void 0?delete s[r]:i!==o&&(s[r]=i)}return n.call(e,t,s)}function Mt(n,e,t){if(Array.isArray(n))return n.map((s,r)=>Mt(s,String(r),t));if(n&&typeof n.toJSON=="function"){if(!t||!bo(n))return n.toJSON(e,t);let s={aliasCount:0,count:1,res:void 0};t.anchors.set(n,s),t.onCreate=o=>{s.res=o,delete t.onCreate};let r=n.toJSON(e,t);return t.onCreate&&t.onCreate(r),r}return typeof n=="bigint"&&!t?.keep?Number(n):n}var ss=class{constructor(e){Object.defineProperty(this,zt,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:s,onAnchor:r,reviver:o}={}){if(!Cn(e))throw new TypeError("A document argument is required");let i={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=Mt(this,"",i);if(typeof r=="function")for(let{count:l,res:c}of i.anchors.values())r(c,l);return typeof o=="function"?ns(o,{"":a},"",a):a}};var Hn=class extends ss{constructor(e){super(ho),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){if(t?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let s;t?.aliasResolveCache?s=t.aliasResolveCache:(s=[],Ln(e,{Node:(o,i)=>{(xn(i)||bo(i))&&s.push(i)}}),t&&(t.aliasResolveCache=s));let r;for(let o of s){if(o===this)break;o.anchor===this.source&&(r=o)}if(r&&t){let{anchors:o,doc:i,maxAliasCount:a}=t,l=o.get(r);if(l||(Mt(r,null,t),l=o.get(r)),l?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(l.count+=1,l.aliasCount===0&&(l.aliasCount=wo(i,r,o)),l.count*l.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}}return r}toJSON(e,t){if(!t)return{source:this.source};let s=this.resolve(t.doc,t);if(!s){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(r)}return t.anchors.get(s).res}toString(e,t,s){let r=`*${this.source}`;if(e){if(xo(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let o=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(o)}if(e.implicitKey)return`${r} `}return r}};function wo(n,e,t){if(xn(e)){let s=e.resolve(n),r=t&&s&&t.get(s);return r?r.count*r.aliasCount:0}else if(Xe(e)){let s=0;for(let r of e.items){let o=wo(n,r,t);o>s&&(s=o)}return s}else if(qe(e)){let s=wo(n,e.key,t),r=wo(n,e.value,t);return Math.max(s,r)}return 1}var ko=n=>!n||typeof n!="function"&&typeof n!="object",Ne=class extends ss{constructor(e){super(Xt),this.value=e}toJSON(e,t){return t?.keep?this.value:Mt(this.value,e,t)}toString(){return String(this.value)}};Ne.BLOCK_FOLDED="BLOCK_FOLDED";Ne.BLOCK_LITERAL="BLOCK_LITERAL";Ne.PLAIN="PLAIN";Ne.QUOTE_DOUBLE="QUOTE_DOUBLE";Ne.QUOTE_SINGLE="QUOTE_SINGLE";var fd="tag:yaml.org,2002:";function ud(n,e,t){if(e){let s=t.filter(o=>o.tag===e),r=s.find(o=>!o.format)??s[0];if(!r)throw new Error(`Tag ${e} not found`);return r}return t.find(s=>s.identify?.(n)&&!s.format)}function Wn(n,e,t){if(Cn(n)&&(n=n.contents),Ye(n))return n;if(qe(n)){let u=t.schema[yn].createNode?.(t.schema,null,t);return u.items.push(n),u}(n instanceof String||n instanceof Number||n instanceof Boolean||typeof BigInt<"u"&&n instanceof BigInt)&&(n=n.valueOf());let{aliasDuplicateObjects:s,onAnchor:r,onTagObj:o,schema:i,sourceObjects:a}=t,l;if(s&&n&&typeof n=="object"){if(l=a.get(n),l)return l.anchor??(l.anchor=r(n)),new Hn(l.anchor);l={anchor:null,node:null},a.set(n,l)}e?.startsWith("!!")&&(e=fd+e.slice(2));let c=ud(n,e,i.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let u=new Ne(n);return l&&(l.node=u),u}c=n instanceof Map?i[yn]:Symbol.iterator in Object(n)?i[Yn]:i[yn]}o&&(o(c),delete t.onTagObj);let f=c?.createNode?c.createNode(t.schema,n,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,n,t):new Ne(n);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}function wr(n,e,t){let s=t;for(let r=e.length-1;r>=0;--r){let o=e[r];if(typeof o=="number"&&Number.isInteger(o)&&o>=0){let i=[];i[o]=s,s=i}else s=new Map([[o,s]])}return Wn(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:n,sourceObjects:new Map})}var _s=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,Ds=class extends ss{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(s=>Ye(s)||qe(s)?s.clone(e):s),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(_s(e))this.add(t);else{let[s,...r]=e,o=this.get(s,!0);if(Xe(o))o.addIn(r,t);else if(o===void 0&&this.schema)this.set(s,wr(this.schema,r,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}deleteIn(e){let[t,...s]=e;if(s.length===0)return this.delete(t);let r=this.get(t,!0);if(Xe(r))return r.deleteIn(s);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){let[s,...r]=e,o=this.get(s,!0);return r.length===0?!t&&_e(o)?o.value:o:Xe(o)?o.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!qe(t))return!1;let s=t.value;return s==null||e&&_e(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){let[t,...s]=e;if(s.length===0)return this.has(t);let r=this.get(t,!0);return Xe(r)?r.hasIn(s):!1}setIn(e,t){let[s,...r]=e;if(r.length===0)this.set(s,t);else{let o=this.get(s,!0);if(Xe(o))o.setIn(r,t);else if(o===void 0&&this.schema)this.set(s,wr(this.schema,r,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}};var pc=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function rn(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var Bn=(n,e,t)=>n.endsWith(`
|
|
3
|
+
`)?rn(t,e):t.includes(`
|
|
4
4
|
`)?`
|
|
5
|
-
`+
|
|
6
|
-
`)
|
|
7
|
-
`&&p!==" "){let
|
|
8
|
-
|
|
9
|
-
${e}${
|
|
10
|
-
${e}${
|
|
11
|
-
`);s=e,r=e+1,o=
|
|
12
|
-
`){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function
|
|
5
|
+
`+rn(t,e):(n.endsWith(" ")?"":" ")+t;var ma="flow",So="block",kr="quoted";function Sr(n,e,t="flow",{indentAtStart:s,lineWidth:r=80,minContentWidth:o=20,onFold:i,onOverflow:a}={}){if(!r||r<0)return n;r<o&&(o=0);let l=Math.max(1+o,1+r-e.length);if(n.length<=l)return n;let c=[],f={},u=r-e.length;typeof s=="number"&&(s>r-Math.max(2,o)?c.push(0):u=r-s);let d,p,g=!1,m=-1,y=-1,N=-1;t===So&&(m=hc(n,m,e.length),m!==-1&&(u=m+l));for(let b;b=n[m+=1];){if(t===kr&&b==="\\"){switch(y=m,n[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}N=m}if(b===`
|
|
6
|
+
`)t===So&&(m=hc(n,m,e.length)),u=m+e.length+l,d=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
|
|
7
|
+
`&&p!==" "){let x=n[m+1];x&&x!==" "&&x!==`
|
|
8
|
+
`&&x!==" "&&(d=m)}if(m>=u)if(d)c.push(d),u=d+l,d=void 0;else if(t===kr){for(;p===" "||p===" ";)p=b,b=n[m+=1],g=!0;let x=m>N+1?m-2:y-1;if(f[x])return n;c.push(x),f[x]=!0,u=x+l,d=void 0}else g=!0}p=b}if(g&&a&&a(),c.length===0)return n;i&&i();let h=n.slice(0,c[0]);for(let b=0;b<c.length;++b){let x=c[b],A=c[b+1]||n.length;x===0?h=`
|
|
9
|
+
${e}${n.slice(0,A)}`:(t===kr&&f[x]&&(h+=`${n[x]}\\`),h+=`
|
|
10
|
+
${e}${n.slice(x+1,A)}`)}return h}function hc(n,e,t){let s=e,r=e+1,o=n[r];for(;o===" "||o===" ";)if(e<r+t)o=n[++e];else{do o=n[++e];while(o&&o!==`
|
|
11
|
+
`);s=e,r=e+1,o=n[r]}return s}var $o=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Mo=n=>/^(%|---|\.\.\.)/m.test(n);function dd(n,e,t){if(!e||e<0)return!1;let s=e-t,r=n.length;if(r<=s)return!1;for(let o=0,i=0;o<r;++o)if(n[o]===`
|
|
12
|
+
`){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function vr(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:s}=e,r=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Mo(n)?" ":""),i="",a=0;for(let l=0,c=t[l];c;c=t[++l])if(c===" "&&t[l+1]==="\\"&&t[l+2]==="n"&&(i+=t.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(t[l+1]){case"u":{i+=t.slice(a,l);let f=t.substr(l+2,4);switch(f){case"0000":i+="\\0";break;case"0007":i+="\\a";break;case"000b":i+="\\v";break;case"001b":i+="\\e";break;case"0085":i+="\\N";break;case"00a0":i+="\\_";break;case"2028":i+="\\L";break;case"2029":i+="\\P";break;default:f.substr(0,2)==="00"?i+="\\x"+f.substr(2):i+=t.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||t[l+2]==='"'||t.length<r)l+=1;else{for(i+=t.slice(a,l)+`
|
|
13
13
|
|
|
14
|
-
`;
|
|
15
|
-
`,l+=2;i+=o,
|
|
16
|
-
`)||/[ \t]\n|\n[ \t]/.test(
|
|
17
|
-
${
|
|
14
|
+
`;t[l+2]==="\\"&&t[l+3]==="n"&&t[l+4]!=='"';)i+=`
|
|
15
|
+
`,l+=2;i+=o,t[l+2]===" "&&(i+="\\"),l+=1,a=l+1}break;default:l+=1}return i=a?i+t.slice(a):t,s?i:Sr(i,o,kr,$o(e,!1))}function pa(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(n))return vr(n,e);let t=e.indent||(Mo(n)?" ":""),s="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
17
|
+
${t}`)+"'";return e.implicitKey?s:Sr(s,t,ma,$o(e,!1))}function zs(n,e){let{singleQuote:t}=e.options,s;if(t===!1)s=vr;else{let r=n.includes('"'),o=n.includes("'");r&&!o?s=pa:o&&!r?s=vr:s=t?pa:vr}return s(n,e)}var ha;try{ha=new RegExp(`(^|(?<!
|
|
18
18
|
))
|
|
19
19
|
+(?!
|
|
20
|
-
|$)`,"g")}catch{
|
|
20
|
+
|$)`,"g")}catch{ha=/\n+(?!\n|$)/g}function vo({comment:n,type:e,value:t},s,r,o){let{blockQuote:i,commentString:a,lineWidth:l}=s.options;if(!i||/\n[\t ]+$/.test(t))return zs(t,s);let c=s.indent||(s.forceBlockIndent||Mo(t)?" ":""),f=i==="literal"?!0:i==="folded"||e===Ne.BLOCK_FOLDED?!1:e===Ne.BLOCK_LITERAL?!0:!dd(t,l,c.length);if(!t)return f?`|
|
|
21
21
|
`:`>
|
|
22
|
-
`;let u,d;for(d=
|
|
23
|
-
`&&
|
|
24
|
-
`);
|
|
25
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
26
|
-
`)
|
|
27
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
28
|
-
${c}${
|
|
29
|
-
${c}${
|
|
30
|
-
`)||f&&/[[\]{},]/.test(o))return
|
|
31
|
-
`)?
|
|
32
|
-
`))return
|
|
33
|
-
${l}`);if(i){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(u),{compat:p,tags:
|
|
34
|
-
${e.indent}${a}`:a}function
|
|
35
|
-
${a}:`):(y=`${y}:`,d&&(y+=
|
|
36
|
-
`:"",
|
|
37
|
-
${
|
|
38
|
-
`&&
|
|
22
|
+
`;let u,d;for(d=t.length;d>0;--d){let A=t[d-1];if(A!==`
|
|
23
|
+
`&&A!==" "&&A!==" ")break}let p=t.substring(d),g=p.indexOf(`
|
|
24
|
+
`);g===-1?u="-":t===p||g!==p.length-1?(u="+",o&&o()):u="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
|
|
25
|
+
`&&(p=p.slice(0,-1)),p=p.replace(ha,`$&${c}`));let m=!1,y,N=-1;for(y=0;y<t.length;++y){let A=t[y];if(A===" ")m=!0;else if(A===`
|
|
26
|
+
`)N=y;else break}let h=t.substring(0,N<y?N+1:y);h&&(t=t.substring(h.length),h=h.replace(/\n+/g,`$&${c}`));let x=(m?c?"2":"1":"")+u;if(n&&(x+=" "+a(n.replace(/ ?[\r\n]+/g," ")),r&&r()),!f){let A=t.replace(/\n+/g,`
|
|
27
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),M=!1,v=$o(s,!0);i!=="folded"&&e!==Ne.BLOCK_FOLDED&&(v.onOverflow=()=>{M=!0});let O=Sr(`${h}${A}${p}`,c,So,v);if(!M)return`>${x}
|
|
28
|
+
${c}${O}`}return t=t.replace(/\n+/g,`$&${c}`),`|${x}
|
|
29
|
+
${c}${h}${t}${p}`}function md(n,e,t,s){let{type:r,value:o}=n,{actualString:i,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&o.includes(`
|
|
30
|
+
`)||f&&/[[\]{},]/.test(o))return zs(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return a||f||!o.includes(`
|
|
31
|
+
`)?zs(o,e):vo(n,e,t,s);if(!a&&!f&&r!==Ne.PLAIN&&o.includes(`
|
|
32
|
+
`))return vo(n,e,t,s);if(Mo(o)){if(l==="")return e.forceBlockIndent=!0,vo(n,e,t,s);if(a&&l===c)return zs(o,e)}let u=o.replace(/\n+/g,`$&
|
|
33
|
+
${l}`);if(i){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(u),{compat:p,tags:g}=e.doc.schema;if(g.some(d)||p?.some(d))return zs(o,e)}return a?u:Sr(u,l,ma,$o(e,!1))}function ks(n,e,t,s){let{implicitKey:r,inFlow:o}=e,i=typeof n.value=="string"?n:Object.assign({},n,{value:String(n.value)}),{type:a}=n;a!==Ne.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(a=Ne.QUOTE_DOUBLE);let l=f=>{switch(f){case Ne.BLOCK_FOLDED:case Ne.BLOCK_LITERAL:return r||o?zs(i.value,e):vo(i,e,t,s);case Ne.QUOTE_DOUBLE:return vr(i.value,e);case Ne.QUOTE_SINGLE:return pa(i.value,e);case Ne.PLAIN:return md(i,e,t,s);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=r&&f||u;if(c=l(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}function Eo(n,e){let t=Object.assign({blockQuote:!0,commentString:pc,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},n.schema.toStringOptions,e),s;switch(t.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:n,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:s,options:t}}function pd(n,e){if(e.tag){let r=n.filter(o=>o.tag===e.tag);if(r.length>0)return r.find(o=>o.format===e.format)??r[0]}let t,s;if(_e(e)){s=e.value;let r=n.filter(o=>o.identify?.(s));if(r.length>1){let o=r.filter(i=>i.test);o.length>0&&(r=o)}t=r.find(o=>o.format===e.format)??r.find(o=>!o.format)}else s=e,t=n.find(r=>r.nodeClass&&s instanceof r.nodeClass);if(!t){let r=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${r} value`)}return t}function hd(n,e,{anchors:t,doc:s}){if(!s.directives)return"";let r=[],o=(_e(n)||Xe(n))&&n.anchor;o&&xo(o)&&(t.add(o),r.push(`&${o}`));let i=n.tag??(e.default?null:e.tag);return i&&r.push(s.directives.tagString(i)),r.join(" ")}function Jn(n,e,t,s){if(qe(n))return n.toString(e,t,s);if(xn(n)){if(e.doc.directives)return n.toString(e);if(e.resolvedAliases?.has(n))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(n):e.resolvedAliases=new Set([n]),n=n.resolve(e.doc)}let r,o=Ye(n)?n:e.doc.createNode(n,{onTagObj:l=>r=l});r??(r=pd(e.doc.schema.tags,o));let i=hd(o,r,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let a=typeof r.stringify=="function"?r.stringify(o,e,t,s):_e(o)?ks(o,e,t,s):o.toString(e,t,s);return i?_e(o)||a[0]==="{"||a[0]==="["?`${i} ${a}`:`${i}
|
|
34
|
+
${e.indent}${a}`:a}function gc({key:n,value:e},t,s,r){let{allNullValues:o,doc:i,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t,d=Ye(n)&&n.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Xe(n)||!Ye(n)&&typeof n=="object"){let v="With simple keys, collection cannot be used as a key value";throw new Error(v)}}let p=!u&&(!n||d&&e==null&&!t.inFlow||Xe(n)||(_e(n)?n.type===Ne.BLOCK_FOLDED||n.type===Ne.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(u||!o),indent:a+l});let g=!1,m=!1,y=Jn(n,t,()=>g=!0,()=>m=!0);if(!p&&!t.inFlow&&y.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(t.inFlow){if(o||e==null)return g&&s&&s(),y===""?"?":p?`? ${y}`:y}else if(o&&!u||e==null&&p)return y=`? ${y}`,d&&!g?y+=Bn(y,t.indent,c(d)):m&&r&&r(),y;g&&(d=null),p?(d&&(y+=Bn(y,t.indent,c(d))),y=`? ${y}
|
|
35
|
+
${a}:`):(y=`${y}:`,d&&(y+=Bn(y,t.indent,c(d))));let N,h,b;Ye(e)?(N=!!e.spaceBefore,h=e.commentBefore,b=e.comment):(N=!1,h=null,b=null,e&&typeof e=="object"&&(e=i.createNode(e))),t.implicitKey=!1,!p&&!d&&_e(e)&&(t.indentAtStart=y.length+1),m=!1,!f&&l.length>=2&&!t.inFlow&&!p&&qt(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let x=!1,A=Jn(e,t,()=>x=!0,()=>m=!0),M=" ";if(d||N||h){if(M=N?`
|
|
36
|
+
`:"",h){let v=c(h);M+=`
|
|
37
|
+
${rn(v,t.indent)}`}A===""&&!t.inFlow?M===`
|
|
38
|
+
`&&b&&(M=`
|
|
39
39
|
|
|
40
|
-
`):
|
|
41
|
-
${
|
|
42
|
-
`),
|
|
43
|
-
${
|
|
44
|
-
`)&&(
|
|
40
|
+
`):M+=`
|
|
41
|
+
${t.indent}`}else if(!p&&Xe(e)){let v=A[0],O=A.indexOf(`
|
|
42
|
+
`),C=O!==-1,$=t.inFlow??e.flow??e.items.length===0;if(C||!$){let P=!1;if(C&&(v==="&"||v==="!")){let k=A.indexOf(" ");v==="&"&&k!==-1&&k<O&&A[k+1]==="!"&&(k=A.indexOf(" ",k+1)),(k===-1||O<k)&&(P=!0)}P||(M=`
|
|
43
|
+
${t.indent}`)}}else(A===""||A[0]===`
|
|
44
|
+
`)&&(M="");return y+=M+A,t.inFlow?x&&s&&s():b&&!x?y+=Bn(y,t.indent,c(b)):m&&r&&r(),y}function To(n,e){(n==="debug"||n==="warn")&&console.warn(e)}var Ao="<<",wn={identify:n=>n===Ao||typeof n=="symbol"&&n.description===Ao,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ne(Symbol(Ao)),{addToJSMap:ba}),stringify:()=>Ao},bc=(n,e)=>(wn.identify(e)||_e(e)&&(!e.type||e.type===Ne.PLAIN)&&wn.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===wn.tag&&t.default);function ba(n,e,t){let s=yc(n,t);if(qt(s))for(let r of s.items)ga(n,e,r);else if(Array.isArray(s))for(let r of s)ga(n,e,r);else ga(n,e,s)}function ga(n,e,t){let s=yc(n,t);if(!Gt(s))throw new Error("Merge sources must be maps or map aliases");let r=s.toJSON(null,n,Map);for(let[o,i]of r)e instanceof Map?e.has(o)||e.set(o,i):e instanceof Set?e.add(o):Object.prototype.hasOwnProperty.call(e,o)||Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0});return e}function yc(n,e){return n&&xn(e)?e.resolve(n.doc,n):e}function Oo(n,e,{key:t,value:s}){if(Ye(t)&&t.addToJSMap)t.addToJSMap(n,e,s);else if(bc(n,t))ba(n,e,s);else{let r=Mt(t,"",n);if(e instanceof Map)e.set(r,Mt(s,r,n));else if(e instanceof Set)e.add(r);else{let o=gd(t,r,n),i=Mt(s,o,n);o in e?Object.defineProperty(e,o,{value:i,writable:!0,enumerable:!0,configurable:!0}):e[o]=i}}return e}function gd(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(Ye(n)&&t?.doc){let s=Eo(t.doc,{});s.anchors=new Set;for(let o of t.anchors.keys())s.anchors.add(o.anchor);s.inFlow=!0,s.inStringifyKey=!0;let r=n.toString(s);if(!t.mapKeyWarned){let o=JSON.stringify(r);o.length>40&&(o=o.substring(0,36)+'..."'),To(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${o}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return r}return JSON.stringify(e)}function Vs(n,e,t){let s=Wn(n,void 0,t),r=Wn(e,void 0,t);return new yt(s,r)}var yt=class n{constructor(e,t=null){Object.defineProperty(this,zt,{value:fa}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return Ye(t)&&(t=t.clone(e)),Ye(s)&&(s=s.clone(e)),new n(t,s)}toJSON(e,t){let s=t?.mapAsMap?new Map:{};return Oo(t,s,this)}toString(e,t,s){return e?.doc?gc(this,e,t,s):JSON.stringify(this)}};function Ro(n,e,t){return(e.inFlow??n.flow?yd:bd)(n,e,t)}function bd({comment:n,items:e},t,{blockItemPrefix:s,flowChars:r,itemIndent:o,onChompKeep:i,onComment:a}){let{indent:l,options:{commentString:c}}=t,f=Object.assign({},t,{indent:o,type:null}),u=!1,d=[];for(let g=0;g<e.length;++g){let m=e[g],y=null;if(Ye(m))!u&&m.spaceBefore&&d.push(""),No(t,d,m.commentBefore,u),m.comment&&(y=m.comment);else if(qe(m)){let h=Ye(m.key)?m.key:null;h&&(!u&&h.spaceBefore&&d.push(""),No(t,d,h.commentBefore,u))}u=!1;let N=Jn(m,f,()=>y=null,()=>u=!0);y&&(N+=Bn(N,o,c(y))),u&&y&&(u=!1),d.push(s+N)}let p;if(d.length===0)p=r.start+r.end;else{p=d[0];for(let g=1;g<d.length;++g){let m=d[g];p+=m?`
|
|
45
45
|
${l}${m}`:`
|
|
46
|
-
`}}return
|
|
47
|
-
`+
|
|
48
|
-
`)),
|
|
46
|
+
`}}return n?(p+=`
|
|
47
|
+
`+rn(c(n),l),a&&a()):u&&i&&i(),p}function yd({items:n},e,{flowChars:t,itemIndent:s}){let{indent:r,indentStep:o,flowCollectionPadding:i,options:{commentString:a}}=e;s+=o;let l=Object.assign({},e,{indent:s,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let g=0;g<n.length;++g){let m=n[g],y=null;if(Ye(m))m.spaceBefore&&u.push(""),No(e,u,m.commentBefore,!1),m.comment&&(y=m.comment);else if(qe(m)){let h=Ye(m.key)?m.key:null;h&&(h.spaceBefore&&u.push(""),No(e,u,h.commentBefore,!1),h.comment&&(c=!0));let b=Ye(m.value)?m.value:null;b?(b.comment&&(y=b.comment),b.commentBefore&&(c=!0)):m.value==null&&h?.comment&&(y=h.comment)}y&&(c=!0);let N=Jn(m,l,()=>y=null);c||(c=u.length>f||N.includes(`
|
|
48
|
+
`)),g<n.length-1?N+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(c||(c=u.reduce((h,b)=>h+b.length+2,2)+(N.length+2)>e.options.lineWidth)),c&&(N+=",")),y&&(N+=Bn(N,s,a(y))),u.push(N),f=u.length}let{start:d,end:p}=t;if(u.length===0)return d+p;if(!c){let g=u.reduce((m,y)=>m+y.length+2,2);c=e.options.lineWidth>0&&g>e.options.lineWidth}if(c){let g=d;for(let m of u)g+=m?`
|
|
49
49
|
${o}${r}${m}`:`
|
|
50
|
-
`;return`${
|
|
51
|
-
${r}${p}`}else return`${d}${i}${u.join(" ")}${i}${p}`}function
|
|
52
|
-
`:" ")}return
|
|
50
|
+
`;return`${g}
|
|
51
|
+
${r}${p}`}else return`${d}${i}${u.join(" ")}${i}${p}`}function No({indent:n,options:{commentString:e}},t,s,r){if(s&&r&&(s=s.replace(/^\n+/,"")),s){let o=rn(e(s),n);t.push(o.trimStart())}}function rs(n,e){let t=_e(e)?e.value:e;for(let s of n)if(qe(s)&&(s.key===e||s.key===t||_e(s.key)&&s.key.value===t))return s}var kt=class extends Ds{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(yn,e),this.items=[]}static from(e,t,s){let{keepUndefined:r,replacer:o}=s,i=new this(e),a=(l,c)=>{if(typeof o=="function")c=o.call(t,l,c);else if(Array.isArray(o)&&!o.includes(l))return;(c!==void 0||r)&&i.items.push(Vs(l,c,s))};if(t instanceof Map)for(let[l,c]of t)a(l,c);else if(t&&typeof t=="object")for(let l of Object.keys(t))a(l,t[l]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,t){let s;qe(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new yt(e,e?.value):s=new yt(e.key,e.value);let r=rs(this.items,s.key),o=this.schema?.sortMapEntries;if(r){if(!t)throw new Error(`Key ${s.key} already set`);_e(r.value)&&ko(s.value)?r.value.value=s.value:r.value=s.value}else if(o){let i=this.items.findIndex(a=>o(s,a)<0);i===-1?this.items.push(s):this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let t=rs(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let r=rs(this.items,e)?.value;return(!t&&_e(r)?r.value:r)??void 0}has(e){return!!rs(this.items,e)}set(e,t){this.add(new yt(e,t),!0)}toJSON(e,t,s){let r=s?new s:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let o of this.items)Oo(t,r,o);return r}toString(e,t,s){if(!e)return JSON.stringify(this);for(let r of this.items)if(!qe(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Ro(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}};var kn={collection:"map",default:!0,nodeClass:kt,tag:"tag:yaml.org,2002:map",resolve(n,e){return Gt(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>kt.from(n,e,t)};var Lt=class extends Ds{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Yn,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Po(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let s=Po(e);if(typeof s!="number")return;let r=this.items[s];return!t&&_e(r)?r.value:r}has(e){let t=Po(e);return typeof t=="number"&&t<this.items.length}set(e,t){let s=Po(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[s];_e(r)&&ko(t)?r.value=t:this.items[s]=t}toJSON(e,t){let s=[];t?.onCreate&&t.onCreate(s);let r=0;for(let o of this.items)s.push(Mt(o,String(r++),t));return s}toString(e,t,s){return e?Ro(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t}):JSON.stringify(this)}static from(e,t,s){let{replacer:r}=s,o=new this(e);if(t&&Symbol.iterator in Object(t)){let i=0;for(let a of t){if(typeof r=="function"){let l=t instanceof Set?a:String(i++);a=r.call(t,l,a)}o.items.push(Wn(a,void 0,s))}}return o}};function Po(n){let e=_e(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}var Sn={collection:"seq",default:!0,nodeClass:Lt,tag:"tag:yaml.org,2002:seq",resolve(n,e){return qt(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Lt.from(n,e,t)};var os={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,s){return e=Object.assign({actualString:!0},e),ks(n,e,t,s)}};var Ss={identify:n=>n==null,createNode:()=>new Ne(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ne(null),stringify:({source:n},e)=>typeof n=="string"&&Ss.test.test(n)?n:e.options.nullStr};var $r={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new Ne(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&$r.test.test(n)){let s=n[0]==="t"||n[0]==="T";if(e===s)return n}return e?t.options.trueStr:t.options.falseStr}};function Ft({format:n,minFractionDigits:e,tag:t,value:s}){if(typeof s=="bigint")return String(s);let r=typeof s=="number"?s:Number(s);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let o=Object.is(s,-0)?"-0":JSON.stringify(s);if(!n&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^-?\d/.test(o)&&!o.includes("e")){let i=o.indexOf(".");i<0&&(i=o.length,o+=".");let a=e-(o.length-i-1);for(;a-- >0;)o+="0"}return o}var Co={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ft},Io={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():Ft(n)}},Lo={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){let e=new Ne(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Ft};var Fo=n=>typeof n=="bigint"||Number.isInteger(n),ya=(n,e,t,{intAsBigInt:s})=>s?BigInt(n):parseInt(n.substring(e),t);function xc(n,e,t){let{value:s}=n;return Fo(s)&&s>=0?t+s.toString(e):Ft(n)}var Bo={identify:n=>Fo(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>ya(n,2,8,t),stringify:n=>xc(n,8,"0o")},jo={identify:Fo,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>ya(n,0,10,t),stringify:Ft},Do={identify:n=>Fo(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>ya(n,2,16,t),stringify:n=>xc(n,16,"0x")};var wc=[kn,Sn,os,Ss,$r,Bo,jo,Do,Co,Io,Lo];function kc(n){return typeof n=="bigint"||Number.isInteger(n)}var _o=({value:n})=>JSON.stringify(n),xd=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:_o},{identify:n=>n==null,createNode:()=>new Ne(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:_o},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:_o},{identify:kc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>kc(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:_o}],wd={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},Sc=[kn,Sn].concat(xd,wd);var Mr={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof atob=="function"){let t=atob(n.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let r=0;r<t.length;++r)s[r]=t.charCodeAt(r);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},s,r,o){if(!t)return"";let i=t,a;if(typeof btoa=="function"){let l="";for(let c=0;c<i.length;++c)l+=String.fromCharCode(i[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Ne.BLOCK_LITERAL),e!==Ne.QUOTE_DOUBLE){let l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let u=0,d=0;u<c;++u,d+=l)f[u]=a.substr(d,l);a=f.join(e===Ne.BLOCK_LITERAL?`
|
|
52
|
+
`:" ")}return ks({comment:n,type:e,value:a},s,r,o)}};function xa(n,e){if(qt(n))for(let t=0;t<n.items.length;++t){let s=n.items[t];if(!qe(s)){if(Gt(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");let r=s.items[0]||new yt(new Ne(null));if(s.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${s.commentBefore}
|
|
53
53
|
${r.key.commentBefore}`:s.commentBefore),s.comment){let o=r.value??r.key;o.comment=o.comment?`${s.comment}
|
|
54
|
-
${o.comment}`:s.comment}s=r}
|
|
55
|
-
`)?(
|
|
54
|
+
${o.comment}`:s.comment}s=r}n.items[t]=qe(s)?s:new yt(s)}}else e("Expected a sequence for this tag");return n}function wa(n,e,t){let{replacer:s}=t,r=new Lt(n);r.tag="tag:yaml.org,2002:pairs";let o=0;if(e&&Symbol.iterator in Object(e))for(let i of e){typeof s=="function"&&(i=s.call(e,String(o++),i));let a,l;if(Array.isArray(i))if(i.length===2)a=i[0],l=i[1];else throw new TypeError(`Expected [key, value] tuple: ${i}`);else if(i&&i instanceof Object){let c=Object.keys(i);if(c.length===1)a=c[0],l=i[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=i;r.items.push(Vs(a,l,t))}return r}var Er={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:xa,createNode:wa};var Ks=class n extends Lt{constructor(){super(),this.add=kt.prototype.add.bind(this),this.delete=kt.prototype.delete.bind(this),this.get=kt.prototype.get.bind(this),this.has=kt.prototype.has.bind(this),this.set=kt.prototype.set.bind(this),this.tag=n.tag}toJSON(e,t){if(!t)return super.toJSON(e);let s=new Map;t?.onCreate&&t.onCreate(s);for(let r of this.items){let o,i;if(qe(r)?(o=Mt(r.key,"",t),i=Mt(r.value,o,t)):o=Mt(r,"",t),s.has(o))throw new Error("Ordered maps must not include duplicate keys");s.set(o,i)}return s}static from(e,t,s){let r=wa(e,t,s),o=new this;return o.items=r.items,o}};Ks.tag="tag:yaml.org,2002:omap";var Tr={collection:"seq",identify:n=>n instanceof Map,nodeClass:Ks,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=xa(n,e),s=[];for(let{key:r}of t.items)_e(r)&&(s.includes(r.value)?e(`Ordered maps must not include duplicate keys: ${r.value}`):s.push(r.value));return Object.assign(new Ks,t)},createNode:(n,e,t)=>Ks.from(n,e,t)};function vc({value:n,source:e},t){return e&&(n?ka:Sa).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var ka={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ne(!0),stringify:vc},Sa={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ne(!1),stringify:vc};var $c={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ft},Mc={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){let e=Number(n.value);return isFinite(e)?e.toExponential():Ft(n)}},Ec={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){let e=new Ne(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){let s=n.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:Ft};var Ar=n=>typeof n=="bigint"||Number.isInteger(n);function zo(n,e,t,{intAsBigInt:s}){let r=n[0];if((r==="-"||r==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),s){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}let i=BigInt(n);return r==="-"?BigInt(-1)*i:i}let o=parseInt(n,t);return r==="-"?-1*o:o}function va(n,e,t){let{value:s}=n;if(Ar(s)){let r=s.toString(e);return s<0?"-"+t+r.substr(1):t+r}return Ft(n)}var Tc={identify:Ar,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>zo(n,2,2,t),stringify:n=>va(n,2,"0b")},Ac={identify:Ar,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>zo(n,1,8,t),stringify:n=>va(n,8,"0")},Oc={identify:Ar,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>zo(n,0,10,t),stringify:Ft},Nc={identify:Ar,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>zo(n,2,16,t),stringify:n=>va(n,16,"0x")};var Gs=class n extends kt{constructor(e){super(e),this.tag=n.tag}add(e){let t;qe(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new yt(e.key,null):t=new yt(e,null),rs(this.items,t.key)||this.items.push(t)}get(e,t){let s=rs(this.items,e);return!t&&qe(s)?_e(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let s=rs(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new yt(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);throw new Error("Set items must all have null values")}static from(e,t,s){let{replacer:r}=s,o=new this(e);if(t&&Symbol.iterator in Object(t))for(let i of t)typeof r=="function"&&(i=r.call(t,i,i)),o.items.push(Vs(i,null,s));return o}};Gs.tag="tag:yaml.org,2002:set";var Or={collection:"map",identify:n=>n instanceof Set,nodeClass:Gs,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>Gs.from(n,e,t),resolve(n,e){if(Gt(n)){if(n.hasAllNullValues(!0))return Object.assign(new Gs,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};function $a(n,e){let t=n[0],s=t==="-"||t==="+"?n.substring(1):n,r=i=>e?BigInt(i):Number(i),o=s.replace(/_/g,"").split(":").reduce((i,a)=>i*r(60)+r(a),r(0));return t==="-"?r(-1)*o:o}function Rc(n){let{value:e}=n,t=i=>i;if(typeof e=="bigint")t=i=>BigInt(i);else if(isNaN(e)||!isFinite(e))return Ft(n);let s="";e<0&&(s="-",e*=t(-1));let r=t(60),o=[e%r];return e<60?o.unshift(0):(e=(e-o[0])/r,o.unshift(e%r),e>=60&&(e=(e-o[0])/r,o.unshift(e))),s+o.map(i=>String(i).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Vo={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>$a(n,t),stringify:Rc},Ko={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>$a(n,!1),stringify:Rc},qs={identify:n=>n instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(n){let e=n.match(qs.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,s,r,o,i,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(t,s-1,r,o||0,i||0,a||0,l),f=e[8];if(f&&f!=="Z"){let u=$a(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};var Ma=[kn,Sn,os,Ss,ka,Sa,Tc,Ac,Oc,Nc,$c,Mc,Ec,Mr,wn,Tr,Er,Or,Vo,Ko,qs];var Pc=new Map([["core",wc],["failsafe",[kn,Sn,os]],["json",Sc],["yaml11",Ma],["yaml-1.1",Ma]]),Cc={binary:Mr,bool:$r,float:Lo,floatExp:Io,floatNaN:Co,floatTime:Ko,int:jo,intHex:Do,intOct:Bo,intTime:Vo,map:kn,merge:wn,null:Ss,omap:Tr,pairs:Er,seq:Sn,set:Or,timestamp:qs},Ic={"tag:yaml.org,2002:binary":Mr,"tag:yaml.org,2002:merge":wn,"tag:yaml.org,2002:omap":Tr,"tag:yaml.org,2002:pairs":Er,"tag:yaml.org,2002:set":Or,"tag:yaml.org,2002:timestamp":qs};function Go(n,e,t){let s=Pc.get(e);if(s&&!n)return t&&!s.includes(wn)?s.concat(wn):s.slice();let r=s;if(!r)if(Array.isArray(n))r=[];else{let o=Array.from(Pc.keys()).filter(i=>i!=="yaml11").map(i=>JSON.stringify(i)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${o} or define customTags array`)}if(Array.isArray(n))for(let o of n)r=r.concat(o);else typeof n=="function"&&(r=n(r.slice()));return t&&(r=r.concat(wn)),r.reduce((o,i)=>{let a=typeof i=="string"?Cc[i]:i;if(!a){let l=JSON.stringify(i),c=Object.keys(Cc).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return o.includes(a)||o.push(a),o},[])}var kd=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,Nr=class n{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:r,schema:o,sortMapEntries:i,toStringDefaults:a}){this.compat=Array.isArray(e)?Go(e,"compat"):e?Go(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?Ic:{},this.tags=Go(t,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,yn,{value:kn}),Object.defineProperty(this,Xt,{value:os}),Object.defineProperty(this,Yn,{value:Sn}),this.sortMapEntries=typeof i=="function"?i:i===!0?kd:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function Lc(n,e){let t=[],s=e.directives===!0;if(e.directives!==!1&&n.directives){let l=n.directives.toString(n);l?(t.push(l),s=!0):n.directives.docStart&&(s=!0)}s&&t.push("---");let r=Eo(n,e),{commentString:o}=r.options;if(n.commentBefore){t.length!==1&&t.unshift("");let l=o(n.commentBefore);t.unshift(rn(l,""))}let i=!1,a=null;if(n.contents){if(Ye(n.contents)){if(n.contents.spaceBefore&&s&&t.push(""),n.contents.commentBefore){let f=o(n.contents.commentBefore);t.push(rn(f,""))}r.forceBlockIndent=!!n.comment,a=n.contents.comment}let l=a?void 0:()=>i=!0,c=Jn(n.contents,r,()=>a=null,l);a&&(c+=Bn(c,"",o(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(Jn(n.contents,r));if(n.directives?.docEnd)if(n.comment){let l=o(n.comment);l.includes(`
|
|
55
|
+
`)?(t.push("..."),t.push(rn(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=n.comment;l&&i&&(l=l.replace(/^\n+/,"")),l&&((!i||a)&&t[t.length-1]!==""&&t.push(""),t.push(rn(o(l),"")))}return t.join(`
|
|
56
56
|
`)+`
|
|
57
|
-
`}var
|
|
58
|
-
`),i=a+i}if(/[^ ]/.test(i)){let a=1,l=
|
|
57
|
+
`}var is=class n{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,zt,{value:go});let r=null;typeof t=="function"||Array.isArray(t)?r=t:s===void 0&&t&&(s=t,t=void 0);let o=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=o;let{version:i}=o;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(i=this.directives.yaml.version)):this.directives=new Fn({version:i}),this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,r,s)}clone(){let e=Object.create(n.prototype,{[zt]:{value:go}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=Ye(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Us(this.contents)&&this.contents.add(e)}addIn(e,t){Us(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let s=ua(this);e.anchor=!t||s.has(t)?da(t||"a",s):t}return new Hn(e.anchor)}createNode(e,t,s){let r;if(typeof t=="function")e=t.call({"":e},"",e),r=t;else if(Array.isArray(t)){let y=h=>typeof h=="number"||h instanceof String||h instanceof Number,N=t.filter(y).map(String);N.length>0&&(t=t.concat(N)),r=t}else s===void 0&&t&&(s=t,t=void 0);let{aliasDuplicateObjects:o,anchorPrefix:i,flow:a,keepUndefined:l,onTagObj:c,tag:f}=s??{},{onAnchor:u,setAnchors:d,sourceObjects:p}=mc(this,i||"a"),g={aliasDuplicateObjects:o??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:p},m=Wn(e,f,g);return a&&Xe(m)&&(m.flow=!0),d(),m}createPair(e,t,s={}){let r=this.createNode(e,null,s),o=this.createNode(t,null,s);return new yt(r,o)}delete(e){return Us(this.contents)?this.contents.delete(e):!1}deleteIn(e){return _s(e)?this.contents==null?!1:(this.contents=null,!0):Us(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return Xe(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return _s(e)?!t&&_e(this.contents)?this.contents.value:this.contents:Xe(this.contents)?this.contents.getIn(e,t):void 0}has(e){return Xe(this.contents)?this.contents.has(e):!1}hasIn(e){return _s(e)?this.contents!==void 0:Xe(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=wr(this.schema,[e],t):Us(this.contents)&&this.contents.set(e,t)}setIn(e,t){_s(e)?this.contents=t:this.contents==null?this.contents=wr(this.schema,Array.from(e),t):Us(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Fn({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new Fn({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{let r=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new Nr(Object.assign(s,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:r,onAnchor:o,reviver:i}={}){let a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},l=Mt(this.contents,t??"",a);if(typeof o=="function")for(let{count:c,res:f}of a.anchors.values())o(f,c);return typeof i=="function"?ns(i,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return Lc(this,e)}};function Us(n){if(Xe(n))return!0;throw new Error("Expected a YAML collection as document contents")}var Rr=class extends Error{constructor(e,t,s,r){super(),this.name=e,this.code=s,this.message=r,this.pos=t}},vn=class extends Rr{constructor(e,t,s){super("YAMLParseError",e,t,s)}},Pr=class extends Rr{constructor(e,t,s){super("YAMLWarning",e,t,s)}},Ea=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));let{line:s,col:r}=t.linePos[0];t.message+=` at line ${s}, column ${r}`;let o=r-1,i=n.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(o>=60&&i.length>80){let a=Math.min(o-39,i.length-79);i="\u2026"+i.substring(a),o-=a-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(i.substring(0,o))){let a=n.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
58
|
+
`),i=a+i}if(/[^ ]/.test(i)){let a=1,l=t.linePos[1];l?.line===s&&l.col>r&&(a=Math.max(1,Math.min(l.col-r,80-o)));let c=" ".repeat(o)+"^".repeat(a);t.message+=`:
|
|
59
59
|
|
|
60
60
|
${i}
|
|
61
61
|
${c}
|
|
62
|
-
`}};function
|
|
63
|
-
`))return!0;if(
|
|
64
|
-
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||
|
|
65
|
-
`+
|
|
66
|
-
`+
|
|
67
|
-
`+
|
|
68
|
-
`+
|
|
69
|
-
`+y.comment:c.comment=y.comment),c.range=[s.offset,m,y.offset]}else c.range=[s.offset,m,m];return c}function
|
|
70
|
-
`.repeat(Math.max(1,i.length-1)):"",y=s+r.length;return e.source&&(y+=e.source.length),{value:m,type:o,comment:r.comment,range:[s,y,y]}}let l=e.indent+r.indent,c=e.offset+r.length,f=0;for(let m=0;m<a;++m){let[y,
|
|
71
|
-
`;for(let m=f;m<a;++m){let[y,
|
|
72
|
-
`):y.length>l||
|
|
62
|
+
`}};function jn(n,{flow:e,indicator:t,next:s,offset:r,onError:o,parentIndent:i,startOnNewline:a}){let l=!1,c=a,f=a,u="",d="",p=!1,g=!1,m=null,y=null,N=null,h=null,b=null,x=null,A=null;for(let O of n)switch(g&&(O.type!=="space"&&O.type!=="newline"&&O.type!=="comma"&&o(O.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),g=!1),m&&(c&&O.type!=="comment"&&O.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),O.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&O.source.includes(" ")&&(m=O),f=!0;break;case"comment":{f||o(O,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let C=O.source.substring(1)||" ";u?u+=d+C:u=C,d="",c=!1;break}case"newline":c?u?u+=O.source:(!x||t!=="seq-item-ind")&&(l=!0):d+=O.source,c=!0,p=!0,(y||N)&&(h=O),f=!0;break;case"anchor":y&&o(O,"MULTIPLE_ANCHORS","A node can have at most one anchor"),O.source.endsWith(":")&&o(O.offset+O.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=O,A??(A=O.offset),c=!1,f=!1,g=!0;break;case"tag":{N&&o(O,"MULTIPLE_TAGS","A node can have at most one tag"),N=O,A??(A=O.offset),c=!1,f=!1,g=!0;break}case t:(y||N)&&o(O,"BAD_PROP_ORDER",`Anchors and tags must be after the ${O.source} indicator`),x&&o(O,"UNEXPECTED_TOKEN",`Unexpected ${O.source} in ${e??"collection"}`),x=O,c=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){b&&o(O,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),b=O,c=!1,f=!1;break}default:o(O,"UNEXPECTED_TOKEN",`Unexpected ${O.type} token`),c=!1,f=!1}let M=n[n.length-1],v=M?M.offset+M.source.length:r;return g&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&o(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m&&(c&&m.indent<=i||s?.type==="block-map"||s?.type==="block-seq")&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:x,spaceBefore:l,comment:u,hasNewline:p,anchor:y,tag:N,newlineAfterProp:h,end:v,start:A??v}}function as(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
|
|
63
|
+
`))return!0;if(n.end){for(let e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(let e of n.items){for(let t of e.start)if(t.type==="newline")return!0;if(e.sep){for(let t of e.sep)if(t.type==="newline")return!0}if(as(e.key)||as(e.value))return!0}return!1;default:return!0}}function Cr(n,e,t){if(e?.type==="flow-collection"){let s=e.end[0];s.indent===n&&(s.source==="]"||s.source==="}")&&as(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function qo(n,e,t){let{uniqueKeys:s}=n.options;if(s===!1)return!1;let r=typeof s=="function"?s:(o,i)=>o===i||_e(o)&&_e(i)&&o.value===i.value;return e.some(o=>r(o.key,t))}var Fc="All mapping items must start at the same column";function Bc({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=o?.nodeClass??kt,a=new i(t.schema);t.atRoot&&(t.atRoot=!1);let l=s.offset,c=null;for(let f of s.items){let{start:u,key:d,sep:p,value:g}=f,m=jn(u,{indicator:"explicit-key-ind",next:d??p?.[0],offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0}),y=!m.found;if(y){if(d&&(d.type==="block-seq"?r(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==s.indent&&r(l,"BAD_INDENT",Fc)),!m.anchor&&!m.tag&&!p){c=m.end,m.comment&&(a.comment?a.comment+=`
|
|
64
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||as(d))&&r(d??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==s.indent&&r(l,"BAD_INDENT",Fc);t.atKey=!0;let N=m.end,h=d?n(t,d,m,r):e(t,N,u,null,m,r);t.schema.compat&&Cr(s.indent,d,r),t.atKey=!1,qo(t,a.items,h)&&r(N,"DUPLICATE_KEY","Map keys must be unique");let b=jn(p??[],{indicator:"map-value-ind",next:g,offset:h.range[2],onError:r,parentIndent:s.indent,startOnNewline:!d||d.type==="block-scalar"});if(l=b.end,b.found){y&&(g?.type==="block-map"&&!b.hasNewline&&r(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&m.start<b.found.offset-1024&&r(h.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=g?n(t,g,b,r):e(t,l,p,null,b,r);t.schema.compat&&Cr(s.indent,g,r),l=x.range[2];let A=new yt(h,x);t.options.keepSourceTokens&&(A.srcToken=f),a.items.push(A)}else{y&&r(h.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(h.comment?h.comment+=`
|
|
65
|
+
`+b.comment:h.comment=b.comment);let x=new yt(h);t.options.keepSourceTokens&&(x.srcToken=f),a.items.push(x)}}return c&&c<l&&r(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,l,c??l],a}function jc({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=o?.nodeClass??Lt,a=new i(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=s.offset,c=null;for(let{start:f,value:u}of s.items){let d=jn(f,{indicator:"seq-item-ind",next:u,offset:l,onError:r,parentIndent:s.indent,startOnNewline:!0});if(!d.found)if(d.anchor||d.tag||u)u?.type==="block-seq"?r(d.end,"BAD_INDENT","All sequence items must start at the same column"):r(l,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(a.comment=d.comment);continue}let p=u?n(t,u,d,r):e(t,d.end,f,null,d,r);t.schema.compat&&Cr(s.indent,u,r),l=p.range[2],a.items.push(p)}return a.range=[s.offset,l,c??l],a}function Dn(n,e,t,s){let r="";if(n){let o=!1,i="";for(let a of n){let{source:l,type:c}=a;switch(c){case"space":o=!0;break;case"comment":{t&&!o&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";r?r+=i+f:r=f,i="";break}case"newline":r&&(i+=l),o=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:r,offset:e}}var Ta="Block collections are not allowed within flow collections",Aa=n=>n&&(n.type==="block-map"||n.type==="block-seq");function Dc({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=s.start.source==="{",a=i?"flow map":"flow sequence",l=o?.nodeClass??(i?kt:Lt),c=new l(t.schema);c.flow=!0;let f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=s.offset+s.start.source.length;for(let y=0;y<s.items.length;++y){let N=s.items[y],{start:h,key:b,sep:x,value:A}=N,M=jn(h,{flow:a,indicator:"explicit-key-ind",next:b??x?.[0],offset:u,onError:r,parentIndent:s.indent,startOnNewline:!1});if(!M.found){if(!M.anchor&&!M.tag&&!x&&!A){y===0&&M.comma?r(M.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):y<s.items.length-1&&r(M.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),M.comment&&(c.comment?c.comment+=`
|
|
66
|
+
`+M.comment:c.comment=M.comment),u=M.end;continue}!i&&t.options.strict&&as(b)&&r(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)M.comma&&r(M.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(M.comma||r(M.start,"MISSING_CHAR",`Missing , between ${a} items`),M.comment){let v="";e:for(let O of h)switch(O.type){case"comma":case"space":break;case"comment":v=O.source.substring(1);break e;default:break e}if(v){let O=c.items[c.items.length-1];qe(O)&&(O=O.value??O.key),O.comment?O.comment+=`
|
|
67
|
+
`+v:O.comment=v,M.comment=M.comment.substring(v.length+1)}}if(!i&&!x&&!M.found){let v=A?n(t,A,M,r):e(t,M.end,x,null,M,r);c.items.push(v),u=v.range[2],Aa(A)&&r(v.range,"BLOCK_IN_FLOW",Ta)}else{t.atKey=!0;let v=M.end,O=b?n(t,b,M,r):e(t,v,h,null,M,r);Aa(b)&&r(O.range,"BLOCK_IN_FLOW",Ta),t.atKey=!1;let C=jn(x??[],{flow:a,indicator:"map-value-ind",next:A,offset:O.range[2],onError:r,parentIndent:s.indent,startOnNewline:!1});if(C.found){if(!i&&!M.found&&t.options.strict){if(x)for(let k of x){if(k===C.found)break;if(k.type==="newline"){r(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}M.start<C.found.offset-1024&&r(C.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else A&&("source"in A&&A.source?.[0]===":"?r(A,"MISSING_CHAR",`Missing space after : in ${a}`):r(C.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let $=A?n(t,A,C,r):C.found?e(t,C.end,x,null,C,r):null;$?Aa(A)&&r($.range,"BLOCK_IN_FLOW",Ta):C.comment&&(O.comment?O.comment+=`
|
|
68
|
+
`+C.comment:O.comment=C.comment);let P=new yt(O,$);if(t.options.keepSourceTokens&&(P.srcToken=N),i){let k=c;qo(t,k.items,O)&&r(v,"DUPLICATE_KEY","Map keys must be unique"),k.items.push(P)}else{let k=new kt(t.schema);k.flow=!0,k.items.push(P);let E=($??O).range;k.range=[O.range[0],E[1],E[2]],c.items.push(k)}u=$?$.range[2]:C.end}}let d=i?"}":"]",[p,...g]=s.end,m=u;if(p?.source===d)m=p.offset+p.source.length;else{let y=a[0].toUpperCase()+a.substring(1),N=f?`${y} must end with a ${d}`:`${y} in block collection must be sufficiently indented and end with a ${d}`;r(u,f?"MISSING_CHAR":"BAD_INDENT",N),p&&p.source.length!==1&&g.unshift(p)}if(g.length>0){let y=Dn(g,m,t.options.strict,r);y.comment&&(c.comment?c.comment+=`
|
|
69
|
+
`+y.comment:c.comment=y.comment),c.range=[s.offset,m,y.offset]}else c.range=[s.offset,m,m];return c}function Oa(n,e,t,s,r,o){let i=t.type==="block-map"?Bc(n,e,t,s,o):t.type==="block-seq"?jc(n,e,t,s,o):Dc(n,e,t,s,o),a=i.constructor;return r==="!"||r===a.tagName?(i.tag=a.tagName,i):(r&&(i.tag=r),i)}function _c(n,e,t,s,r){let o=s.tag,i=o?e.directives.tagName(o.source,d=>r(o,"TAG_RESOLVE_FAILED",d)):null;if(t.type==="block-seq"){let{anchor:d,newlineAfterProp:p}=s,g=d&&o?d.offset>o.offset?d:o:d??o;g&&(!p||p.offset<g.offset)&&r(g,"MISSING_CHAR","Missing newline after block sequence props")}let a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===kt.tagName&&a==="map"||i===Lt.tagName&&a==="seq")return Oa(n,e,t,r,i);let l=e.schema.tags.find(d=>d.tag===i&&d.collection===a);if(!l){let d=e.schema.knownTags[i];if(d?.collection===a)e.schema.tags.push(Object.assign({},d,{default:!1})),l=d;else return d?r(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${a} collection, but expects ${d.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),Oa(n,e,t,r,i)}let c=Oa(n,e,t,r,i,l),f=l.resolve?.(c,d=>r(o,"TAG_RESOLVE_FAILED",d),e.options)??c,u=Ye(f)?f:new Ne(f);return u.range=c.range,u.tag=i,l?.format&&(u.format=l.format),u}function Na(n,e,t){let s=e.offset,r=Sd(e,n.options.strict,t);if(!r)return{value:"",type:null,comment:"",range:[s,s,s]};let o=r.mode===">"?Ne.BLOCK_FOLDED:Ne.BLOCK_LITERAL,i=e.source?vd(e.source):[],a=i.length;for(let m=i.length-1;m>=0;--m){let y=i[m][1];if(y===""||y==="\r")a=m;else break}if(a===0){let m=r.chomp==="+"&&i.length>0?`
|
|
70
|
+
`.repeat(Math.max(1,i.length-1)):"",y=s+r.length;return e.source&&(y+=e.source.length),{value:m,type:o,comment:r.comment,range:[s,y,y]}}let l=e.indent+r.indent,c=e.offset+r.length,f=0;for(let m=0;m<a;++m){let[y,N]=i[m];if(N===""||N==="\r")r.indent===0&&y.length>l&&(l=y.length);else{y.length<l&&t(c+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(l=y.length),f=m,l===0&&!n.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=y.length+N.length+1}for(let m=i.length-1;m>=a;--m)i[m][0].length>l&&(a=m+1);let u="",d="",p=!1;for(let m=0;m<f;++m)u+=i[m][0].slice(l)+`
|
|
71
|
+
`;for(let m=f;m<a;++m){let[y,N]=i[m];c+=y.length+N.length+1;let h=N[N.length-1]==="\r";if(h&&(N=N.slice(0,-1)),N&&y.length<l){let x=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;t(c-N.length-(h?2:1),"BAD_INDENT",x),y=""}o===Ne.BLOCK_LITERAL?(u+=d+y.slice(l)+N,d=`
|
|
72
|
+
`):y.length>l||N[0]===" "?(d===" "?d=`
|
|
73
73
|
`:!p&&d===`
|
|
74
74
|
`&&(d=`
|
|
75
75
|
|
|
76
|
-
`),u+=d+y.slice(l)+
|
|
77
|
-
`,p=!0):
|
|
76
|
+
`),u+=d+y.slice(l)+N,d=`
|
|
77
|
+
`,p=!0):N===""?d===`
|
|
78
78
|
`?u+=`
|
|
79
79
|
`:d=`
|
|
80
|
-
`:(u+=d+
|
|
80
|
+
`:(u+=d+N,d=" ",p=!1)}switch(r.chomp){case"-":break;case"+":for(let m=a;m<i.length;++m)u+=`
|
|
81
81
|
`+i[m][0].slice(l);u[u.length-1]!==`
|
|
82
82
|
`&&(u+=`
|
|
83
83
|
`);break;default:u+=`
|
|
84
|
-
`}let
|
|
84
|
+
`}let g=s+r.length+e.source.length;return{value:u,type:o,comment:r.comment,range:[s,g,g]}}function Sd({offset:n,props:e},t,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=e[0],o=r[0],i=0,a="",l=-1;for(let d=1;d<r.length;++d){let p=r[d];if(!a&&(p==="-"||p==="+"))a=p;else{let g=Number(p);!i&&g?i=g:l===-1&&(l=n+d)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let c=!1,f="",u=r.length;for(let d=1;d<e.length;++d){let p=e[d];switch(p.type){case"space":c=!0;case"newline":u+=p.source.length;break;case"comment":t&&!c&&s(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":s(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{let g=`Unexpected token in block scalar header: ${p.type}`;s(p,"UNEXPECTED_TOKEN",g);let m=p.source;m&&typeof m=="string"&&(u+=m.length)}}}return{mode:o,indent:i,chomp:a,comment:f,length:u}}function vd(n){let e=n.split(/\n( *)/),t=e[0],s=t.match(/^( *)/),o=[s?.[1]?[s[1],t.slice(s[1].length)]:["",t]];for(let i=1;i<e.length;i+=2)o.push([e[i],e[i+1]]);return o}function Ra(n,e,t){let{offset:s,type:r,source:o,end:i}=n,a,l,c=(d,p,g)=>t(s+d,p,g);switch(r){case"scalar":a=Ne.PLAIN,l=$d(o,c);break;case"single-quoted-scalar":a=Ne.QUOTE_SINGLE,l=Md(o,c);break;case"double-quoted-scalar":a=Ne.QUOTE_DOUBLE,l=Ed(o,c);break;default:return t(n,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[s,s+o.length,s+o.length]}}let f=s+o.length,u=Dn(i,f,e,t);return{value:l,type:a,comment:u.comment,range:[s,f,u.offset]}}function $d(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),zc(n)}function Md(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),zc(n.slice(1,-1)).replace(/''/g,"'")}function zc(n){let e=/(.*?)\r?\n/sy,t=e.exec(n);if(!t)return n;let s,r;try{s=new RegExp("(?<![ ])[ ]+$"),r=new RegExp("^[ ]+|(?<![ ])[ ]+$","g")}catch{s=/[ \t]+$/,r=/^[ \t]+|[ \t]+$/g}let o=t[1].replace(s,""),i=" ",a=e.lastIndex;for(;t=e.exec(n);){let c=t[1].replace(r,"");c===""?i===`
|
|
85
85
|
`?o+=i:i=`
|
|
86
|
-
`:(o+=i+c,i=" "),a=e.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,
|
|
86
|
+
`:(o+=i+c,i=" "),a=e.lastIndex}let l=/[ \t]*(.*)/sy;return l.lastIndex=a,t=l.exec(n),o+i+(t?.[1]??"")}function Ed(n,e){let t="";for(let s=1;s<n.length-1;++s){let r=n[s];if(!(r==="\r"&&n[s+1]===`
|
|
87
87
|
`))if(r===`
|
|
88
|
-
`){let{fold:o,offset:i}=
|
|
89
|
-
`)for(o=
|
|
90
|
-
`)for(o=
|
|
91
|
-
`&&!(i==="\r"&&
|
|
92
|
-
`)&&(
|
|
93
|
-
`||s==="\r")&&!(s==="\r"&&
|
|
88
|
+
`){let{fold:o,offset:i}=Td(n,s);t+=o,s=i}else if(r==="\\"){let o=n[++s],i=Ad[o];if(i)t+=i;else if(o===`
|
|
89
|
+
`)for(o=n[s+1];o===" "||o===" ";)o=n[++s+1];else if(o==="\r"&&n[s+1]===`
|
|
90
|
+
`)for(o=n[++s+1];o===" "||o===" ";)o=n[++s+1];else if(o==="x"||o==="u"||o==="U"){let a=o==="x"?2:o==="u"?4:8;t+=Od(n,s+1,a,e),s+=a}else{let a=n.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(r===" "||r===" "){let o=s,i=n[s+1];for(;i===" "||i===" ";)i=n[++s+1];i!==`
|
|
91
|
+
`&&!(i==="\r"&&n[s+2]===`
|
|
92
|
+
`)&&(t+=s>o?n.slice(o,s+1):r)}else t+=r}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function Td(n,e){let t="",s=n[e+1];for(;(s===" "||s===" "||s===`
|
|
93
|
+
`||s==="\r")&&!(s==="\r"&&n[e+2]!==`
|
|
94
94
|
`);)s===`
|
|
95
|
-
`&&(
|
|
96
|
-
`),e+=1,s=
|
|
97
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
95
|
+
`&&(t+=`
|
|
96
|
+
`),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}var Ad={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
97
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Od(n,e,t,s){let r=n.substr(e,t),i=r.length===t&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(i)}catch{let a=n.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}function Pa(n,e,t,s){let{value:r,type:o,comment:i,range:a}=e.type==="block-scalar"?Na(n,e,s):Ra(e,n.options.strict,s),l=t?n.directives.tagName(t.source,u=>s(t,"TAG_RESOLVE_FAILED",u)):null,c;n.options.stringKeys&&n.atKey?c=n.schema[Xt]:l?c=Nd(n.schema,r,l,t,s):e.type==="scalar"?c=Rd(n,r,e,s):c=n.schema[Xt];let f;try{let u=c.resolve(r,d=>s(t??e,"TAG_RESOLVE_FAILED",d),n.options);f=_e(u)?u:new Ne(u)}catch(u){let d=u instanceof Error?u.message:String(u);s(t??e,"TAG_RESOLVE_FAILED",d),f=new Ne(r)}return f.range=a,f.source=r,o&&(f.type=o),l&&(f.tag=l),c.format&&(f.format=c.format),i&&(f.comment=i),f}function Nd(n,e,t,s,r){if(t==="!")return n[Xt];let o=[];for(let a of n.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)o.push(a);else return a;for(let a of o)if(a.test?.test(e))return a;let i=n.knownTags[t];return i&&!i.collection?(n.tags.push(Object.assign({},i,{default:!1,test:void 0})),i):(r(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[Xt])}function Rd({atKey:n,directives:e,schema:t},s,r,o){let i=t.tags.find(a=>(a.default===!0||n&&a.default==="key")&&a.test?.test(s))||t[Xt];if(t.compat){let a=t.compat.find(l=>l.default&&l.test?.test(s))??t[Xt];if(i.tag!==a.tag){let l=e.tagString(i.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;o(r,"TAG_RESOLVE_FAILED",f,!0)}}return i}function Vc(n,e,t){if(e){t??(t=e.length);for(let s=t-1;s>=0;--s){let r=e[s];switch(r.type){case"space":case"comment":case"newline":n-=r.source.length;continue}for(r=e[++s];r?.type==="space";)n+=r.source.length,r=e[++s];break}}return n}var Pd={composeNode:Ca,composeEmptyNode:Uo};function Ca(n,e,t,s){let r=n.atKey,{spaceBefore:o,comment:i,anchor:a,tag:l}=t,c,f=!0;switch(e.type){case"alias":c=Cd(n,e,s),(a||l)&&s(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=Pa(n,e,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=_c(Pd,n,e,t,s),a&&(c.anchor=a.source.substring(1))}catch(u){let d=u instanceof Error?u.message:String(u);s(e,"RESOURCE_EXHAUSTION",d)}break;default:{let u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",u),f=!1}}return c??(c=Uo(n,e.offset,void 0,null,t,s)),a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),r&&n.options.stringKeys&&(!_e(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),o&&(c.spaceBefore=!0),i&&(e.type==="scalar"&&e.source===""?c.comment=i:c.commentBefore=i),n.options.keepSourceTokens&&f&&(c.srcToken=e),c}function Uo(n,e,t,s,{spaceBefore:r,comment:o,anchor:i,tag:a,end:l},c){let f={type:"scalar",offset:Vc(e,t,s),indent:-1,source:""},u=Pa(n,f,a,c);return i&&(u.anchor=i.source.substring(1),u.anchor===""&&c(i,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(u.spaceBefore=!0),o&&(u.comment=o,u.range[2]=l),u}function Cd({options:n},{offset:e,source:t,end:s},r){let o=new Hn(t.substring(1));o.source===""&&r(e,"BAD_ALIAS","Alias cannot be an empty string"),o.source.endsWith(":")&&r(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let i=e+t.length,a=Dn(s,i,n.strict,r);return o.range=[e,i,a.offset],a.comment&&(o.comment=a.comment),o}function Kc(n,e,{offset:t,start:s,value:r,end:o},i){let a=Object.assign({_directives:e},n),l=new is(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=jn(s,{indicator:"doc-start",next:r??o?.[0],offset:t,onError:i,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!f.hasNewline&&i(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=r?Ca(c,r,f,i):Uo(c,f.end,s,null,f,i);let u=l.contents.range[2],d=Dn(o,u,!1,i);return d.comment&&(l.comment=d.comment),l.range=[t,u,d.offset],l}function Ir(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];let{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function Gc(n){let e="",t=!1,s=!1;for(let r=0;r<n.length;++r){let o=n[r];switch(o[0]){case"#":e+=(e===""?"":s?`
|
|
98
98
|
|
|
99
99
|
`:`
|
|
100
|
-
`)+(o.substring(1)||" "),
|
|
101
|
-
${s}`:s;else if(r||e.directives.docStart||!o)e.commentBefore=s;else if(
|
|
100
|
+
`)+(o.substring(1)||" "),t=!0,s=!1;break;case"%":n[r+1]?.[0]!=="#"&&(r+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}var Lr=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,r,o)=>{let i=Ir(t);o?this.warnings.push(new Pr(i,s,r)):this.errors.push(new vn(i,s,r))},this.directives=new Fn({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:s,afterEmptyLine:r}=Gc(this.prelude);if(s){let o=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
101
|
+
${s}`:s;else if(r||e.directives.docStart||!o)e.commentBefore=s;else if(Xe(o)&&!o.flow&&o.items.length>0){let i=o.items[0];qe(i)&&(i=i.key);let a=i.commentBefore;i.commentBefore=a?`${s}
|
|
102
102
|
${a}`:s}else{let i=o.commentBefore;o.commentBefore=i?`${s}
|
|
103
|
-
${i}`:s}}if(
|
|
104
|
-
${
|
|
103
|
+
${i}`:s}}if(t){for(let o=0;o<this.errors.length;++o)e.errors.push(this.errors[o]);for(let o=0;o<this.warnings.length;++o)e.warnings.push(this.warnings[o])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Gc(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(let r of e)yield*this.next(r);yield*this.end(t,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,s,r)=>{let o=Ir(e);o[0]+=t,this.onError(o,"BAD_DIRECTIVE",s,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=Kc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new vn(Ir(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){let s="Unexpected doc-end without preceding document";this.errors.push(new vn(Ir(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;let t=Dn(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let s=this.doc.comment;this.doc.comment=s?`${s}
|
|
104
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new vn(Ir(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let s=Object.assign({_directives:this.directives},this.options),r=new is(void 0,s);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,t,t],this.decorate(r,!1),yield r}}};var Ia=Symbol("break visit"),Id=Symbol("skip children"),qc=Symbol("remove item");function vs(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),Uc(Object.freeze([]),n,e)}vs.BREAK=Ia;vs.SKIP=Id;vs.REMOVE=qc;vs.itemAtPath=(n,e)=>{let t=n;for(let[s,r]of e){let o=t?.[s];if(o&&"items"in o)t=o.items[r];else return}return t};vs.parentCollection=(n,e)=>{let t=vs.itemAtPath(n,e.slice(0,-1)),s=e[e.length-1][0],r=t?.[s];if(r&&"items"in r)return r;throw new Error("Parent collection not found")};function Uc(n,e,t){let s=t(e,n);if(typeof s=="symbol")return s;for(let r of["key","value"]){let o=e[r];if(o&&"items"in o){for(let i=0;i<o.items.length;++i){let a=Uc(Object.freeze(n.concat([[r,i]])),o.items[i],t);if(typeof a=="number")i=a-1;else{if(a===Ia)return Ia;a===qc&&(o.items.splice(i,1),i-=1)}}typeof s=="function"&&r==="key"&&(s=s(e,n))}}return typeof s=="function"?s(e,n):s}var La="\uFEFF",Fa="",Ba="",Yo="";function Yc(n){switch(n){case La:return"byte-order-mark";case Fa:return"doc-mode";case Ba:return"flow-error-end";case Yo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
105
105
|
`:case`\r
|
|
106
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(
|
|
107
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
108
|
-
\r `),
|
|
109
|
-
`?!0:
|
|
110
|
-
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let
|
|
111
|
-
`||!r&&!this.atEnd)return e+s+1}return
|
|
112
|
-
`||s>=this.indentNext||!
|
|
113
|
-
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===
|
|
106
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(n[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function $n(n){switch(n){case void 0:case" ":case`
|
|
107
|
+
`:case"\r":case" ":return!0;default:return!1}}var Hc=new Set("0123456789ABCDEFabcdef"),Fd=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ho=new Set(",[]{}"),Bd=new Set(` ,[]{}
|
|
108
|
+
\r `),ja=n=>!n||Bd.has(n),Fr=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let s=this.next??"stream";for(;s&&(t||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
|
109
|
+
`?!0:t==="\r"?this.buffer[e+1]===`
|
|
110
|
+
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let s=0;for(;t===" ";)t=this.buffer[++s+e];if(t==="\r"){let r=this.buffer[s+e+1];if(r===`
|
|
111
|
+
`||!r&&!this.atEnd)return e+s+1}return t===`
|
|
112
|
+
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&$n(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
113
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===La&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,s=e.indexOf("#");for(;s!==-1;){let o=e[s-1];if(o===" "||o===" "){t=s-1;break}else s=e.indexOf("#",s+1)}for(;;){let o=e[t-1];if(o===" "||o===" ")t-=1;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Fa,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let t=this.peek(3);if((t==="---"||t==="...")&&$n(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!$n(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&$n(t)){let s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ja),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,s=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=s=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&r[0]!=="#"||s===0&&(r.startsWith("---")||r.startsWith("..."))&&$n(r[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield Ba,yield*this.parseLineStart();let o=0;for(;r[o]===",";)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),r[o]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-o),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(ja),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||$n(i)||i===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let o=0;for(;this.buffer[t-1-o]==="\\";)o+=1;if(o%2===0)break;t=this.buffer.indexOf('"',t+1)}let s=this.buffer.substring(0,t),r=s.indexOf(`
|
|
114
114
|
`,this.pos);if(r!==-1){for(;r!==-1;){let o=this.continueScalar(r+1);if(o===-1)break;r=s.indexOf(`
|
|
115
|
-
`,o)}r!==-1&&(
|
|
116
|
-
`:e=o,
|
|
117
|
-
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(
|
|
115
|
+
`,o)}r!==-1&&(t=r-(s[r-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>$n(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let o=this.pos;s=this.buffer[o];++o)switch(s){case" ":t+=1;break;case`
|
|
116
|
+
`:e=o,t=0;break;case"\r":{let i=this.buffer[o+1];if(!i&&!this.atEnd)return this.setNext("block-scalar");if(i===`
|
|
117
|
+
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let o=this.continueScalar(e+1);if(o===-1)break;e=this.buffer.indexOf(`
|
|
118
118
|
`,o)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let r=e+1;for(s=this.buffer[r];s===" ";)s=this.buffer[++r];if(s===" "){for(;s===" "||s===" "||s==="\r"||s===`
|
|
119
119
|
`;)s=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let o=e-1,i=this.buffer[o];i==="\r"&&(i=this.buffer[--o]);let a=o;for(;i===" ";)i=this.buffer[--o];if(i===`
|
|
120
|
-
`&&o>=this.pos&&o+1+
|
|
120
|
+
`&&o>=this.pos&&o+1+t>a)e=o;else break}while(!0);return yield Yo,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,s=this.pos-1,r;for(;r=this.buffer[++s];)if(r===":"){let o=this.buffer[s+1];if($n(o)||e&&Ho.has(o))break;t=s}else if($n(r)){let o=this.buffer[s+1];if(r==="\r"&&(o===`
|
|
121
121
|
`?(s+=1,r=`
|
|
122
|
-
`,o=this.buffer[s+1]):
|
|
123
|
-
`){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&
|
|
122
|
+
`,o=this.buffer[s+1]):t=s),o==="#"||e&&Ho.has(o))break;if(r===`
|
|
123
|
+
`){let i=this.continueScalar(s+1);if(i===-1)break;s=Math.max(s,i-2)}}else{if(e&&Ho.has(r))break;t=s}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield Yo,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(t&&(yield""),0)}*pushIndicators(){let e=0;e:for(;;){switch(this.charAt(0)){case"!":e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue e;case"&":e+=yield*this.pushUntil(ja),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if($n(s)||t&&Ho.has(s)){t?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue e}}}break e}return e}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];for(;!$n(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Fd.has(t))t=this.buffer[++e];else if(t==="%"&&Hc.has(this.buffer[e+1])&&Hc.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
|
|
124
124
|
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
125
|
-
`?yield*this.pushCount(2):0}*pushSpaces(e){let
|
|
126
|
-
`)+1;for(;
|
|
127
|
-
`,
|
|
128
|
-
`)+1;for(;
|
|
129
|
-
`,
|
|
130
|
-
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${
|
|
131
|
-
:root[data-theme="dark"]{${
|
|
132
|
-
${s}`}function
|
|
133
|
-
`;for(let[
|
|
134
|
-
`}return{light:
|
|
135
|
-
`)),this.diags=e}};function
|
|
136
|
-
${
|
|
125
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s===" ");let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}};var $s=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t<s;){let o=t+s>>1;this.lineStarts[o]<e?t=o+1:s=o}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function ls(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function Wc(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Xc(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Wo(n){switch(n.type){case"document":return n.start;case"block-map":{let e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function Ys(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function Jo(n,e){if(e.length<1e5)Array.prototype.push.apply(n,e);else for(let t=0;t<e.length;++t)n.push(e[t])}function Jc(n){if(n.start.type==="flow-seq-start")for(let e of n.items)e.sep&&!e.value&&!ls(e.start,"explicit-key-ind")&&!ls(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Xc(e.value)?e.value.end?Jo(e.value.end,e.sep):e.value.end=e.sep:Jo(e.start,e.sep),delete e.sep)}var Br=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Fr,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let s of this.lexer.lex(e,t))yield*this.next(s);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Yc(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{let s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{let s=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in s?s.indent:0:t.type==="flow-collection"&&s.type==="document"&&(t.indent=0),t.type==="flow-collection"&&Jc(t),s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{let r=s.items[s.items.length-1];if(r.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=t;else{Object.assign(r,{key:t,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=s.items[s.items.length-1];r.value?s.items.push({start:[],value:t}):r.value=t;break}case"flow-collection":{let r=s.items[s.items.length-1];!r||r.value?s.items.push({start:[],key:t,sep:[]}):r.sep?r.value=t:Object.assign(r,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){let r=t.items[t.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&Wc(r.start)===-1&&(t.indent===0||r.start.every(o=>o.type!=="comment"||o.indent<t.indent))&&(s.type==="document"?s.end=r.start:s.items.push({start:r.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{Wc(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){let t=Wo(this.peek(2)),s=Ys(t),r;e.end?(r=e.end,r.push(this.sourceToken),delete e.end):r=[this.sourceToken];let o={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=o}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
|
|
126
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
127
|
+
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){let s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Jo(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let s=!this.onKeyLine&&this.indent===e.indent,r=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind",o=[];if(r&&t.sep&&!t.value){let i=[];for(let a=0;a<t.sep.length;++a){let l=t.sep[a];switch(l.type){case"newline":i.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(i.length=0);break;default:i.length=0}}i.length>=2&&(o=t.sep.splice(i[1]))}switch(this.type){case"anchor":case"tag":r||t.value?(o.push(this.sourceToken),e.items.push({start:o}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(o.push(this.sourceToken),e.items.push({start:o,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ls(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]});else if(Xc(t.key)&&!ls(t.sep,"newline")){let i=Ys(t.start),a=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:a,sep:l}]})}else o.length>0?t.sep=t.sep.concat(o,this.sourceToken):t.sep.push(this.sourceToken);else if(ls(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Ys(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||r?e.items.push({start:o,key:null,sep:[this.sourceToken]}):ls(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let i=this.flowScalar(this.type);r||t.value?(e.items.push({start:o,key:i,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(i):(Object.assign(t,{key:i,sep:[]}),this.onKeyLine=!0);return}default:{let i=this.startBlockValue(e);if(i){if(i.type==="block-seq"){if(!t.explicitKey&&t.sep&&!ls(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:o});this.stack.push(i);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){let s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let r=e.items[e.items.length-2]?.value?.end;if(Array.isArray(r)){Jo(r,t.start),r.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||ls(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:r,sep:[]}):t.sep?this.stack.push(r):Object.assign(t,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}let s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{let s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){let r=Wo(s),o=Ys(r);Jc(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:o,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
128
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
129
|
+
`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let t=Wo(e),s=Ys(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let t=Wo(e),s=Ys(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(s=>s.type==="newline"||s.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};function jd(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new $s||null,prettyErrors:e}}function Xo(n,e={}){let{lineCounter:t,prettyErrors:s}=jd(e),r=new Br(t?.addNewLine),o=new Lr(e),i=null;for(let a of o.compose(r.parse(n),!0,n.length))if(!i)i=a;else if(i.options.logLevel!=="silent"){i.errors.push(new vn(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(i.errors.forEach(Ea(n,t)),i.warnings.forEach(Ea(n,t))),i}function Da(n,e,t){let s;typeof e=="function"?s=e:t===void 0&&e&&typeof e=="object"&&(t=e);let r=Xo(n,t);if(!r)return null;if(r.warnings.forEach(o=>To(r.options.logLevel,o)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:s},t))}function Qo(n){let e=Da(n);for(let t of["light","dark","kinds","roles"])if(!e||typeof e[t]!="object")throw new Error(`theme: missing "${t}"`);return e}function Zo(n,e={},t={}){let s={...n.kinds};for(let[r,o]of Object.entries(t)){let i=s[o.like??r]??s.control;s[r]={color:o.color??i.color,dash:o.dash??i.dash,legend:o.legend??i.legend}}return{...n,roles:{...n.roles,...e},kinds:s}}var Qc=n=>Object.entries(n).map(([e,t])=>`--${e}:${t}`).join(";");function _n(n,e){return e in n.light?`var(--${e})`:e}function ei(n){let{light:e,dark:t,rest:s}=jr(n);return`:root{${e}}
|
|
130
|
+
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${t}}}
|
|
131
|
+
:root[data-theme="dark"]{${t}}
|
|
132
|
+
${s}`}function jr(n){let e="";for(let[t,s]of Object.entries(n.roles))e+=`.k-${t}{--h:${s.h};--s:${s.s}%}`,s.top?e+=`.k-${t} .top{fill:${s.top}}`:s.tint&&(e+=`.k-${t} .top{fill:color-mix(in srgb,hsl(${s.h} ${Math.min(100,s.s+15)}% 50%) ${s.tint}%,var(--pad-top))}`),e+=`
|
|
133
|
+
`;for(let[t,s]of Object.entries(n.kinds)){let r=_n(n,s.color),o=s.dash==="dashed"?";stroke-dasharray:7 6;stroke-width:2.4":s.dash==="dotted"?";stroke-dasharray:3 6;stroke-width:2.4":"";e+=`.f-${t}{stroke:${r}${o}} .t-${t}{fill:${r}} .c-${t}{--c:${r}}
|
|
134
|
+
`}return{light:Qc(n.light),dark:Qc(n.dark),rest:e}}var ti=class extends Error{diags;constructor(e){super(e.map(t=>`${t.line}:${t.col} ${t.message}`).join(`
|
|
135
|
+
`)),this.diags=e}};function _a(n,e){let t=n.length,s=e.length;if(!t)return s;if(!s)return t;let r=Array.from({length:t+1},(o,i)=>[i,...Array(s).fill(0)]);for(let o=0;o<=s;o++)r[0][o]=o;for(let o=1;o<=t;o++)for(let i=1;i<=s;i++){let a=n[o-1]===e[i-1]?0:1;r[o][i]=Math.min(r[o-1][i]+1,r[o][i-1]+1,r[o-1][i-1]+a),o>1&&i>1&&n[o-1]===e[i-2]&&n[o-2]===e[i-1]&&(r[o][i]=Math.min(r[o][i],r[o-2][i-2]+1))}return r[t][s]}function Bt(n,e){let t,s=1/0,r=n.toLowerCase();for(let i of e){let a=_a(r,i.toLowerCase());a<s&&(s=a,t=i)}if(t===void 0)return;let o=Math.max(1,Math.min(3,Math.floor(Math.max(n.length,t.length)/3)));return s<=o?t:void 0}function za(n,e,t){n.file&&(e=n.file,t=n.source);let r=`${n.line?`${e}:${n.line}:${n.col}`:e} ${n.severity}: ${n.message}`;if(n.hint&&(r+=`
|
|
136
|
+
${n.hint}`),t&&n.line){let i=t.split(/\r?\n/)[n.line-1]??"",a=String(n.line).padStart(4);r+=`
|
|
137
137
|
${a} | ${i}
|
|
138
|
-
${" ".repeat(a.length)} | ${" ".repeat(Math.max(0,
|
|
138
|
+
${" ".repeat(a.length)} | ${" ".repeat(Math.max(0,n.col-1))}^`}return r}function Zc(n,e,t){return n.map(s=>za(s,e,t)).join(`
|
|
139
139
|
|
|
140
|
-
`)}function
|
|
141
|
-
`)[0],u=/Nested mappings|Implicit keys|mapping values/i.test(f)?`text that contains ": " (a colon followed by a blank) must be in quotes, e.g. command: 'send "a: b"'`:/Map keys must be unique/i.test(f)?"a key is written twice in the same map":void 0;s.push({severity:"error",message:`YAML: ${f}`,line:c.line,col:c.col,path:"",hint:u})}for(let l of
|
|
142
|
-
`)[0]}`,line:c.line,col:c.col,path:""})}function o(l,c={}){let f=Yl(l),u=n.contents,d={line:1,col:1},p=h=>{let m=h?.range;m&&(d=r(m[0]))};p(u);for(let h=0;h<f.length;h++){let m=f[h];if(_t(u)){let y=u.items.find(I=>Le(I)&&Ne(I.key)&&String(I.key.value)===String(m));if(!y)break;if(c.key&&h===f.length-1)return p(y.key),d;p(y.key),u=y.value,u&&p(u)}else if(Dt(u)&&typeof m=="number"){if(u=u.items[m],!u)break;p(u)}else break}return d}function i(l){let c=n.contents;for(let p of Yl(l)){if(_t(c)){let h=c.items.find(m=>Le(m)&&Ne(m.key)&&String(m.key.value)===String(p));if(!h)return;c=h.value}else if(Dt(c)&&typeof p=="number")c=c.items[p];else return;if(!c)return}let f=c.range;if(!f)return;let u=e.linePos(Math.max(f[0],f[1]-1)).line,d=t.split(/\r?\n/);for(;u>e.linePos(f[0]).line&&/^\s*(#.*)?$/.test(d[u-1]??"");)u--;return{start:e.linePos(f[0]).line,end:u}}let a=null;return n.errors.length||(a=n.toJS({maxAliasCount:100})),{data:a,locate:o,span:i,diags:s}}var nu=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),su=new Set(["id","class","role","transform","viewBox","width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","fx","fy","d","points","offset","gradientUnits","gradientTransform","markerWidth","markerHeight","refX","refY","orient","markerUnits","text-anchor","dominant-baseline","font-size","font-weight","letter-spacing","fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity","fill-opacity","stroke-opacity","stop-color","stop-opacity","marker-start","marker-mid","marker-end","clip-path","preserveAspectRatio","vector-effect","paint-order","style"]),ru=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),ou={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},Wl=t=>t.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,n)=>ou[n]);function Qi(t,e){return t.startsWith("data-")||t.startsWith("aria-")?/^[a-z][\w-]*$/.test(t):!(!su.has(t)||ru.has(t)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function Zi(t){let e={name:"#root",attrs:[],children:[]},n=[{node:e,dropped:!1}],s=/<(?:!--)[\s\S]*?-->|<\/([a-zA-Z][\w:-]*)\s*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g,r,o=0;for(;r=s.exec(t);){if(r.index!==o)throw new Error(`not the renderer's SVG at ${o}: ${JSON.stringify(t.slice(o,o+40))}`);o=s.lastIndex;let i=n[n.length-1];if(r[0].charAt(1)!=="!"){if(r[1]){if(n.length<2||i.node.name!==r[1])throw new Error(`a stray </${r[1]}>`);n.pop();continue}if(r[2]){let a=r[2],l=[];for(let u of r[3].matchAll(/([\w:-]+)="([^"]*)"/g)){let d=u[1],p=Wl(u[2]);d==="xmlns"||d.startsWith("xmlns:")||Qi(d,p)&&l.push([d,p])}let c={name:a,attrs:l,children:[]},f=i.dropped||!nu.has(a);f||i.node.children.push(c),r[4]||n.push({node:c,dropped:f});continue}!i.dropped&&r[5].trim()&&i.node.children.push(Wl(r[5]))}}if(o!==t.length)throw new Error(`not the renderer's SVG at ${o}`);if(n.length!==1)throw new Error(`<${n[n.length-1].node.name}> is never closed`);return e}var iu="http://www.w3.org/2000/svg",Jl=t=>t.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function Xl(t,e=document){let n=r=>{let o=e.createElementNS(iu,r.name);for(let[i,a]of r.attrs)i==="style"?o.style.cssText=Jl(a):o.setAttribute(i,/var\(--/.test(a)?Jl(a):a);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):n(i));return o},s=Zi(t).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return n(s)}var au=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),lr=class t{name;attrs=[];children=[];style={};constructor(e){this.name=e}setAttribute(e,n){let s=this.attrs.findIndex(r=>r[0]===e);s>=0?this.attrs[s][1]=String(n):this.attrs.push([e,String(n)])}getAttribute(e){return this.attrs.find(n=>n[0]===e)?.[1]??null}append(...e){for(let n of e)n!=null&&this.children.push(n)}set textContent(e){this.children=[String(e)]}get textContent(){return this.children.map(e=>typeof e=="string"?e:e.textContent).join("")}toNode(){let e=Object.entries(this.style).filter(([,n])=>n!==""&&n!==void 0).map(([n,s])=>`${au(n)}:${s}`).join(";");return{name:this.name,attrs:e?[...this.attrs,["style",e]]:[...this.attrs],children:this.children.map(n=>n instanceof t?n.toNode():n)}}},Ql={createElementNS:(t,e)=>new lr(e)},Zl=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),lu=t=>Zl(t).replace(/"/g,""");function bo(t,e=new Set(["style"])){if(typeof t=="string")return Zl(t);let n=t.attrs.map(([r,o])=>` ${r}="${lu(o)}"`).join("");if(!t.children.length)return`<${t.name}${n}/>`;let s=e.has(t.name)?t.children.map(r=>typeof r=="string"?r.replace(/<\//g,"<\\/"):bo(r,e)).join(""):t.children.map(r=>bo(r,e)).join("");return`<${t.name}${n}>${s}</${t.name}>`}var cu=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ea(t){let e=new TextEncoder().encode(t),n=e.length,s=Math.ceil((n+9)/64),r=new Uint8Array(s*64);r.set(e),r[n]=128;let o=new DataView(r.buffer);o.setUint32(r.length-4,n*8>>>0),o.setUint32(r.length-8,Math.floor(n/536870912));let i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64),l=(c,f)=>c>>>f|c<<32-f;for(let c=0;c<s;c++){for(let N=0;N<16;N++)a[N]=o.getUint32(c*64+N*4);for(let N=16;N<64;N++){let M=l(a[N-15],7)^l(a[N-15],18)^a[N-15]>>>3,$=l(a[N-2],17)^l(a[N-2],19)^a[N-2]>>>10;a[N]=a[N-16]+M+a[N-7]+$>>>0}let[f,u,d,p,h,m,y,I]=i;for(let N=0;N<64;N++){let M=I+(l(h,6)^l(h,11)^l(h,25))+(h&m^~h&y)+cu[N]+a[N]>>>0,$=(l(f,2)^l(f,13)^l(f,22))+(f&u^f&d^u&d)>>>0;I=y,y=m,m=h,h=p+M>>>0,p=d,d=u,u=f,f=M+$>>>0}i[0]+=f,i[1]+=u,i[2]+=d,i[3]+=p,i[4]+=h,i[5]+=m,i[6]+=y,i[7]+=I}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function ec(t){if(t!=="sha256")throw new Error(`only sha256 here, not ${t}`);let e="",n={update(s){return e+=s,n},digest(s){return ea(e)}};return n}var Tc={};bi(Tc,{BOARD_3D:()=>Wn,BOARD_CSS:()=>Mc,FLAT_DEFAULTS:()=>Sa,FLAT_FONTS:()=>Ma,GRID_CSS:()=>wa,LABEL_BUDGET:()=>Vo,MARKS_CSS:()=>ya,Obstacles:()=>ls,PAGE_CSS:()=>ga,PLAYER_CSS:()=>qo,PLAYER_UI_CSS:()=>xa,ROUTE_BUDGET:()=>Po,WALL_T:()=>$n,assembly:()=>_o,baseCss:()=>Uo,boardCatalog:()=>$c,boardDiagram:()=>Ec,boardErrors:()=>Ho,boardOf:()=>Wo,boxAsset:()=>sc,boxSilhouette:()=>yc,calloutRect:()=>da,cardAsset:()=>$a,cloudPath:()=>oa,compileRaw:()=>hc,convexOverlap:()=>pr,defaultLabel:()=>oc,drawCloud:()=>vo,drawDecos:()=>ra,drawingCss:()=>ba,durationFor:()=>ma,facePainter:()=>ko,flatHit:()=>Sc,floorAt:()=>Ns,floorOf:()=>xc,focusView:()=>mc,gateBox:()=>ur,iconPainter:()=>cr,inConvex:()=>pa,kindsCss:()=>xo,labelRect:()=>mr,layoutFlat:()=>Os,lineRectArea:()=>uc,localAt:()=>bc,markCss:()=>wo,metricsMeasure:()=>vc,midpoint:()=>ha,noSource:()=>ka,nodeKind:()=>as,nodeKindOr:()=>Qt,offscreen:()=>Bo,openList:()=>la,overlap2:()=>Mo,overlaps:()=>Yo,paddingOf:()=>wc,parseEnd:()=>Ut,place:()=>$o,placeBoard:()=>gr,placeCallout:()=>Io,placeNodeLabel:()=>hr,placeholderIcon:()=>sa,plate:()=>rc,polyBounds:()=>Fn,polyRectArea:()=>Rs,rectArea:()=>ua,regionKind:()=>pt,regionRole:()=>Ko,registerMarks:()=>nc,renderScene:()=>Go,resolveSteps:()=>Do,routeAll:()=>Ro,screenToGrid:()=>gc,silhouette:()=>qt,simplify:()=>dr,snapMove:()=>kc,wallHeight:()=>yo,wallsOf:()=>jo});var pt=(t,e)=>e!==void 0&&Object.hasOwn(t.regions,e)?t.regions[e]:void 0,as=(t,e)=>t.nodes[e??t.defaultNode],Qt=(t,e)=>as(t,e)??t.nodes[t.defaultNode],yo=t=>Object.values(t.regions).find(e=>e.shape==="walled")?.z[1]??.8,xo=t=>Object.values(t.regions).map(e=>e.css??"").join("");var ta=Object.create(null),na=[];function nc(t){Object.assign(ta,t.icons??{}),Object.assign(bs,t.faces??{}),t.css&&!na.includes(t.css)&&na.push(t.css)}var wo=()=>na.join(""),cr=t=>Object.hasOwn(ta,t)?ta[t]:void 0,ko=t=>Object.hasOwn(bs,t)?bs[t]:void 0;function sa(t,e){let n=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(.6,(e.x1-e.x0)*.24,(e.y1-e.y0)*.24),i=[[n-o,s-o,r],[n+o,s-o,r],[n+o,s+o,r],[n-o,s+o,r]];return t.poly(i,"ico-unknown")+t.line3([n-o*.3,s-o*.35,r],[n+o*.3,s-o*.35,r],"ico-unknown-q")+t.line3([n+o*.3,s-o*.35,r],[n,s+o*.1,r],"ico-unknown-q")+t.line3([n,s+o*.45,r],[n,s+o*.5,r],"ico-unknown-q")}function ra(t,e,n){let s="";for(let r of n??[])r==="terminal"?s+=Vs(t,e,3):r==="envelope"?s+=Er(t,e):r==="bubble"?s+=Tr(t,e):r==="file-lines"?s+=Ar(t,e):typeof r=="object"&&(r.terminal&&(s+=Vs(t,e,r.terminal)),r.icon&&(s+=(cr(r.icon)??sa)(t,e)));return s}var fu=(t,e)=>(t.deco??e.deco??[]).filter(n=>n!=="ghost");function sc(t,e,n,s,r,o){let i={name:t,description:e,size:n,role:s,deco:r,draw:(a,l,c)=>a.blockFaces(l)+ra(a,l,fu(c,i))+(o?o(a,l):"")};return i}function rc(t){let[e,n]=$r(t);return{x0:e-.75,y0:n-.75,x1:e+.75,y1:n+.75,z0:t.z0,z1:t.z0+.18}}function oa(t,e){let n=Math.max(8,Math.min(t,e)*.18),s=n*.55,r=s,o=s,i=t-s,a=e-s,l=(c,f,u,d)=>{let p=Math.hypot(u-c,d-f),h=Math.max(1,Math.round(p/(n*1.7))),m="";for(let y=1;y<=h;y++){let I=c+(u-c)*y/h,N=f+(d-f)*y/h,M=p/h/2*1.08;m+=` A${M.toFixed(1)},${M.toFixed(1)} 0 0 1 ${I.toFixed(1)},${N.toFixed(1)}`}return m};return`M${r.toFixed(1)},${o.toFixed(1)}`+l(r,o,i,o)+l(i,o,i,a)+l(i,a,r,a)+l(r,a,r,o)+"Z"}function vo(t,e){let n={...e,z0:e.z1},s=a=>{let[l,c]=we(e.x0,e.y0,a);return[yt,.5,-yt,.5,l,c]},r=(e.x1-e.x0)*Xe,o=(e.y1-e.y0)*Xe,i=oa(r,o);return t.onMatrix(s(e.z0),r,o,()=>me("path",{d:i,class:"lft cloud-side"}))+t.onMatrix(s(e.z1),r,o,()=>me("path",{d:i,class:"top cloud-top"}))}function oc(t,e){let[n,s]=we((t.x0+t.x1)/2,(t.y0+t.y1)/2,t.z1+.75);return{x:n,y:s-18+(e?0:6),anchor:"middle"}}var $n=.16,ia=["right-of","left-of","below","behind"];function $o(t,e,n,s,r,o={},i){let a=[],l=(b,v,g,O=!1,F="error")=>{let j=n.locate(b,{key:O});a.push({severity:F,message:v,line:j.line,col:j.col,path:b,hint:g})},c=[],f=new Map,u=[],d=new Map,p=new Set([...Object.keys(s.roles),...Object.keys(o)]);function h(b,v){let g=f.get(b.id);if(g){let O=n.locate(g.path+"/id");return l(b.path+"/id",`duplicate id "${b.id}" (first used on line ${O.line})`),!1}return f.set(b.id,b),c.push(b),b.parent=v,v?v.children.push(b):u.push(b),!0}let m=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function y(b,v,g){let O={id:b.id,type:"node",path:v,children:[],box:m(),floor:0,node:b,appears:b.appears,disappears:b.disappears};h(O,g)&&(b.nodes??[]).forEach((F,j)=>y(F,`${v}/nodes/${j}`,O))}function I(b,v,g){let O={id:b.id,type:"region",path:v,children:[],box:m(),floor:0,region:b,appears:b.appears,disappears:b.disappears};h(O,g)&&((b.nodes??[]).forEach((F,j)=>y(F,`${v}/nodes/${j}`,O)),(b.regions??[]).forEach((F,j)=>I(F,`${v}/regions/${j}`,O)))}(t.regions??[]).forEach((b,v)=>I(b,`${e}/regions/${v}`,void 0)),(t.nodes??[]).forEach((b,v)=>y(b,`${e}/nodes/${v}`,void 0));let N=()=>f.keys(),M=()=>c.filter(b=>b.type==="region").map(b=>b.id);for(let b of[...c]){let v=b.node??b.region;if(v.in!==void 0){let O=f.get(v.in);if(!O){l(b.path+"/in",`unknown region "${v.in}"`+fr(v.in,M()));continue}if(O.type!=="region"){l(b.path+"/in",`"${v.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(b.parent&&b.parent!==O){l(b.path+"/in",`"${b.id}" is written inside "${b.parent.id}" but says in: ${v.in}; use one or the other`);continue}for(let F=O;F;F=F.parent)if(F===b){l(b.path+"/in",`"${b.id}" cannot be inside itself`);continue}b.parent||(u.splice(u.indexOf(b),1),b.parent=O,O.children.push(b))}if(b.node){let O=b.node.asset;O!==void 0&&!as(r,O)&&l(b.path+"/asset",`unknown asset "${O}"`+fr(O,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let g=(b.node??b.region).role;g!==void 0&&!p.has(g)&&l(b.path+"/role",`unknown colour role "${g}"`+fr(g,p),`add it under "roles:" at the top of the file, or use one of: ${[...p].join(", ")}`)}for(let b of c){let v=b.region?.gate;if(!v?.node)continue;let g=f.get(v.node);if(!g){l(b.path+"/gate/node",`unknown node "${v.node}"`+fr(v.node,N()));continue}if(g.type!=="node"){l(b.path+"/gate/node",`"${v.node}" is a region; a gate is a node`);continue}g.placedBy=b.id;let O=g.node;(O.at||ia.some(F=>O[F]))&&l(g.path,`"${g.id}" is the gate of "${b.id}", which places it; its own placement is ignored`,void 0,!1,"warning")}let $=b=>b.gap??t.gap??2;function R(b){let v=b.node,g=Qt(r,v.asset),O=v.size,F=g.size[0],j=g.size[1],U=g.size[2];if(O&&(F=O[0],j=O[1],O.length>2&&(U=O[2])),b.placedBy){let ne=f.get(b.placedBy).region,B=ne.gate,K=B.width??2,q=O?Math.min(F,j):.3;U=O&&O.length>2?U:B.height??(ne.height??yo(r))+.3,B.side==="e"||B.side==="w"?(F=q,j=K):(F=K,j=q)}return[F,j,U]}function E(b,v,g,O,F){for(let X of v)T(X);let j=v.filter(X=>!X.placedBy),U=new Set(j),ne=new Set,B=[],K=new Set,q=X=>{let te=X.node??X.region,ye=[];for(let Fe of ia){let S=te[Fe];if(S===void 0)continue;let Y=f.get(S);if(!Y){l(`${X.path}/${Fe}`,`unknown id "${S}"`+fr(S,N()));continue}if(Y===X){l(`${X.path}/${Fe}`,`"${X.id}" cannot be placed ${Fe} itself`);continue}if(!U.has(Y)){let se=le=>le.parent?`"${le.parent.id}"`:"the scene";l(`${X.path}/${Fe}`,`"${S}" is in ${se(Y)} but "${X.id}" is in ${se(X)}; relative placement works between items in the same region`,Y.placedBy?`"${S}" is a gate, placed by its ${f.get(Y.placedBy)?.region?.kind??"region"}`:`place "${X.id}" relative to something in ${se(X)}, or use "at:"`);continue}ye.push(Y)}if(!ye.length&&!te.at){let Fe=j.indexOf(X);Fe>0&&ye.push(j[Fe-1])}return ye},Z=X=>{if(!ne.has(X)){if(K.has(X)){l(X.path,`placement loop: "${X.id}" is placed relative to something placed relative to it`);return}K.add(X),q(X).forEach(Z),K.delete(X),ne.add(X),B.push(X)}};j.forEach(Z);for(let X of B){let te=X.node??X.region,ye=d.get(X),Fe=ia.find(S=>te[S]!==void 0&&f.get(te[S])&&U.has(f.get(te[S])));if(te.at&&Fe&&l(`${X.path}/at`,`"${X.id}" has both "at" and "${Fe}"; "at" wins`,void 0,!0,"warning"),te.at)ye.x=te.at[0],ye.y=te.at[1];else if(Fe)w(ye,d.get(f.get(te[Fe])),Fe,$(te),te.align??"center");else{let S=j.indexOf(X);S>0?w(ye,d.get(j[S-1]),O==="row"?"right-of":"below",$(te),"center"):(ye.x=g,ye.y=g)}te.shift&&(ye.x+=te.shift[0],ye.y+=te.shift[1])}if(F||!j.length)return{w:0,d:0};let A=1/0,D=1/0,V=-1/0,W=-1/0;for(let X of j){let te=d.get(X);A=Math.min(A,te.x),D=Math.min(D,te.y),V=Math.max(V,te.x+te.w),W=Math.max(W,te.y+te.d)}let ie=Math.min(0,A-g),de=Math.min(0,D-g);if(ie||de)for(let X of j){let te=d.get(X);te.x-=ie,te.y-=de}return{w:V-ie+g,d:W-de+g}}function w(b,v,g,O,F){let j=()=>{b.y=F==="start"?v.y:F==="end"?v.y+v.d-b.d:v.y+(v.d-b.d)/2},U=()=>{b.x=F==="start"?v.x:F==="end"?v.x+v.w-b.w:v.x+(v.w-b.w)/2};g==="right-of"?(b.x=v.x+v.w+O,j()):g==="left-of"?(b.x=v.x-O-b.w,j()):g==="below"?(b.y=v.y+v.d+O,U()):(b.y=v.y-O-b.d,U())}function T(b){if(b.type==="node"){let[B,K,q]=R(b);d.set(b,{x:0,y:0,w:B,d:K,h:q,z:b.node.z??0}),b.children.length&&E(b,b.children,0,"row",!0);return}let v=b.region,g=v.padding??pt(r,v.kind)?.pad,O=!!v.size,F=E(b,b.children,g,v.flow??"row",O),j=v.size?v.size[0]:Math.max(F.w,g*2+.5),U=v.size?v.size[1]:Math.max(F.d,g*2+.5);if(!v.size&&v.gate){let B=(v.gate.width??2)+1;v.gate.side==="e"||v.gate.side==="w"?U=Math.max(U,B):j=Math.max(j,B)}let ne=v.size&&v.size.length>2?v.size[2]:v.height??pt(r,v.kind).z[1];d.set(b,{x:0,y:0,w:j,d:U,h:ne,z:0})}E(void 0,u,0,t.flow??"row",!0);function L(b,v,g,O){let F=d.get(b),j=v+F.x,U=g+F.y;if(b.type==="region"){let ne=pt(r,b.region.kind),[B]=ne.z,K=ne.floor,q=ne.shape==="slab"&&pt(r,b.parent?.region?.kind)?.shape==="slab"?0:B,Z=b.region.z??0,A=O+q+Z,D=O+F.h+Z;b.box={x0:j,y0:U,z0:A,x1:j+F.w,y1:U+F.d,z1:D},b.floor=K?D:O}else{let ne=O+F.z;b.box={x0:j,y0:U,z0:ne,x1:j+F.w,y1:U+F.d,z1:ne+F.h},b.floor=b.box.z1}for(let ne of b.children)ne.placedBy||L(ne,j,U,b.floor)}for(let b of u)b.placedBy||L(b,0,0,0);if(i){let b=g=>Math.round(g/i)*i,v=g=>Math.round(g*1e9)/1e9;for(let g of c){if(g.placedBy)continue;let O=g.box,F=b(O.x0),j=b(O.x1),U=b(O.y0),ne=b(O.y1);j-F<i&&(j=F+i),ne-U<i&&(ne=U+i),g.box={...O,x0:v(F),x1:v(j),y0:v(U),y1:v(ne)};let B=g.node??g.region;B.at&&B.at.forEach((K,q)=>{let Z=K/i;Math.abs(Z-Math.round(Z))>1e-6&&l(`${g.path}/at/${q}`,`${K} is not on the ${i} grid; it is drawn at ${v(b(K))}`,void 0,!1,"warning")})}}for(let b of c){let v=b.region?.gate;if(!v?.node)continue;let g=f.get(v.node);!g||g.placedBy!==b.id||(g.box=ur(b,d.get(g).h,d.get(g).w,d.get(g).d),g.floor=g.box.z1)}for(let b of c){let v=b.children.filter(g=>!g.placedBy);for(let g=0;g<v.length;g++)for(let O=g+1;O<v.length;O++){let F=v[g],j=v[O];So(F,r)||So(j,r)||Mo(F.box,j.box)&&l(j.path,`"${j.id}" overlaps "${F.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}if(b.parent&&b.parent.type==="region"&&!b.placedBy){let g=b.parent.box,O=b.box,F=1e-6;(O.x0<g.x0-F||O.y0<g.y0-F||O.x1>g.x1+F||O.y1>g.y1+F)&&l(b.path,`"${b.id}" sticks out of region "${b.parent.id}"`,`make "${b.parent.id}" bigger, or leave out its "size" so it fits its contents`,!1,"warning")}}{let b=u.filter(v=>!v.placedBy);for(let v=0;v<b.length;v++)for(let g=v+1;g<b.length;g++){let O=b[v],F=b[g];Mo(O.box,F.box)&&!So(O,r)&&!So(F,r)&&l(F.path,`"${F.id}" overlaps "${O.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let x=new Set,P=a.filter(b=>{let v=b.path+b.message;return x.has(v)?!1:(x.add(v),!0)});return{items:c,byId:f,roots:u,diags:P,catalog:r}}var So=(t,e)=>t.type==="region"&&["zone","tunnel"].includes(pt(e,t.region.kind)?.shape??"");function ur(t,e,n,s){let r=t.region.gate,o=t.box,i=t.box.z0,a=r.at??.5,l=r.width??2;if(r.side==="w"||r.side==="e"){let u=r.side==="w"?o.x0+$n/2:o.x1-$n/2,d=o.y0+(o.y1-o.y0)*a;return{x0:u-n/2,x1:u+n/2,y0:d-l/2,y1:d+l/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+$n/2:o.y1-$n/2,f=o.x0+(o.x1-o.x0)*a;return{x0:f-l/2,x1:f+l/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function Mo(t,e,n=1e-6){return t.x0<e.x1-n&&e.x0<t.x1-n&&t.y0<e.y1-n&&e.y0<t.y1-n}function fr(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}var Ln=.2,Eo=.05,uu=.6,To=.25,Ao={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function Ut(t){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(t);return{id:e[1],side:e[2]}}var ic=new WeakMap;function Ns(t,e,n){let s=ic.get(t);if(!s){s=[];for(let i of t.items){if(i.type!=="region"||!pt(t.catalog,i.region.kind)?.floor)continue;let a=0;for(let l=i.parent;l;l=l.parent)a++;s.push({r:i,d:a})}ic.set(t,s)}let r=0,o=-1;for(let{r:i,d:a}of s){let l=i.box,c=1e-6;e>=l.x0-c&&e<=l.x1+c&&n>=l.y0-c&&n<=l.y1+c&&a>o&&(o=a,r=i.floor)}return r}function du(t,e){let n=[(t.x0+t.x1)/2,(t.y0+t.y1)/2],s=[(e.x0+e.x1)/2,(e.y0+e.y1)/2],r=s[0]-n[0],o=s[1]-n[1],i=Math.max(e.x0-t.x1,t.x0-e.x1),a=Math.max(e.y0-t.y1,t.y0-e.y1);return i>0&&(a<=0||i>=a)?r>0?"e":"w":a>0?o>0?"s":"n":Math.abs(r)>=Math.abs(o)?r>0?"e":"w":o>0?"s":"n"}var Po=5e5;function Ro(t,e,n,s,r,o){let i=[],a=(M,$,R,E="error")=>{let w=s.locate(M);i.push({severity:E,message:$,line:w.line,col:w.col,path:M,hint:R})},l=t.routes??[],c={left:Po},f=0,u=()=>n.items.map(M=>M.id),d=new Map,p=[],h=[];l.forEach((M,$)=>{let R=`${e}/routes/${$}`;(d.has(M.id)||n.byId.has(M.id))&&a(R+"/id",`duplicate id "${M.id}"`),d.set(M.id,$);let E=M.kind??"send";r.has(E)||a(R+"/kind",`unknown flow kind "${E}"`+aa(E,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let w={id:M.id,raw:M,path:R,kind:E,points:[]},T=(L,x)=>{let{id:P}=Ut(L),b=n.byId.get(P);if(!b){a(`${R}/${x}`,`unknown node "${P}"`+aa(P,u()));return}return b};w.from=T(M.from,"from"),w.to=T(M.to,"to"),p.push(w),h.push({r:w})});let m=new Map;for(let M of h){let{r:$}=M;if(!$.from||!$.to||$.raw.points)continue;let R=Ut($.raw.from).side,E=Ut($.raw.to).side,w=$.raw.via?.[0],T=$.raw.via?.[$.raw.via.length-1],L=(v,g)=>{if(Array.isArray(v))return{x0:v[0],x1:v[0],y0:v[1],y1:v[1],z0:0,z1:0};if(typeof v=="string"){let O=n.byId.get(Ut(v).id);if(O)return O.box}return g.box},x=(v,g,O)=>{let F=g??du(v.box,O);return{node:v,side:F,explicit:!!g,p:[0,0],z:0}};M.a=x($.from,R,L(w,$.to)),M.b=x($.to,E,L(T,$.from));let P=L(w,$.to),b=L(T,$.from);for(let[v,g]of[[M.a,P],[M.b,b]]){let O=`${v.node.id}.${v.side}`;m.has(O)||m.set(O,[]),m.get(O).push({e:v,other:[(g.x0+g.x1)/2,(g.y0+g.y1)/2]})}}for(let[,M]of m){let $=M[0].e,R=$.node.box,E=$.side,w=E==="e"||E==="w"?1:0;M.sort((v,g)=>v.other[w]-g.other[w]);let T=w?R.y0:R.x0,L=w?R.y1:R.x1,x=(T+L)/2,P=Math.max(0,L-T-.3),b=M.length>1?Math.min(uu,P/(M.length-1)):0;M.forEach((v,g)=>{let O=(g-(M.length-1)/2)*b,F=x+O,j=v.e.node.box.z0;if(E==="top"){v.e.p=[(R.x0+R.x1)/2,(R.y0+R.y1)/2],v.e.z=R.z1;return}let[U,ne]=Ao[E];v.e.p=w?[U>0?R.x1+Eo:R.x0-Eo,F]:[F,ne>0?R.y1+Eo:R.y0-Eo],v.e.z=j})}let y=[];for(let M of n.items)M.type==="node"&&y.push(M.box);let I=[];for(let M of n.items.filter($=>pt(n.catalog,$.region?.kind)?.shape==="walled")){let{x0:$,y0:R,x1:E,y1:w}=M.box,T=$n,L=M.region.gate,x=[[{x0:$,y0:R,x1:E,y1:R+T,z0:0,z1:0},"n"],[{x0:$,y0:w-T,x1:E,y1:w,z0:0,z1:0},"s"],[{x0:$,y0:R,x1:$+T,y1:w,z0:0,z1:0},"w"],[{x0:E-T,y0:R,x1:E,y1:w,z0:0,z1:0},"e"]];for(let[P,b]of x)if(L&&L.side===b){if(L.node)continue;let v=L.at??.5,g=L.width??2;if(b==="e"||b==="w"){let O=R+(w-R)*v;I.push({...P,y1:O-g/2},{...P,y0:O+g/2})}else{let O=$+(E-$)*v;I.push({...P,x1:O-g/2},{...P,x0:O+g/2})}}else I.push(P)}let N=new Map;for(let M of h){let{r:$,a:R,b:E}=M;if($.raw.points){$.points=$.raw.points.map(F=>[F[0],F[1],F.length>2?F[2]:Ns(n,F[0],F[1])+.01]);continue}if(!R||!E)continue;let w=[];($.raw.via??[]).forEach((F,j)=>{if(Array.isArray(F))if(o){let U=ne=>Math.round(Math.round(ne/o)*o*1e9)/1e9;F.forEach((ne,B)=>{Math.abs(ne/o-Math.round(ne/o))>1e-6&&a(`${$.path}/via/${j}/${B}`,`${ne} is not on the ${o} grid; it is drawn at ${U(ne)}`,void 0,"warning")}),w.push({p:[U(F[0]),U(F[1])]})}else w.push({p:[F[0],F[1]]});else{let{id:U,side:ne}=Ut(F),B=n.byId.get(U);if(!B){a(`${$.path}/via/${j}`,`unknown node "${U}"`+aa(U,u()));return}let K=ne&&ne!=="top"?ne:"n",[q,Z]=Ao[K],A=B.box;w.push({p:[q?q>0?A.x1+.4:A.x0-.4:(A.x0+A.x1)/2,Z?Z>0?A.y1+.4:A.y0-.4:(A.y0+A.y1)/2]})}});let L=y.filter(F=>F!==R.node.box&&F!==E.node.box).concat($.raw.cross?[]:I).filter(F=>!No(R.node.box,F)&&!No(E.node.box,F)&&!No(F,R.node.box)&&!No(F,E.node.box)),x=R.side==="top"?void 0:Ao[R.side],P=E.side==="top"?void 0:Ao[E.side],b=[R.p,...w.map(F=>F.p),E.p],v=[R.p],g=x,O=!0;for(let F=0;F+1<b.length;F++){let j=F+2===b.length,U=mu(b[F],b[F+1],L,N,g,j&&P?[-P[0],-P[1]]:void 0,c);if(!U){O=!1;break}v.push(...U.slice(1));let ne=v.length;if(ne>=2){let B=Math.sign(v[ne-1][0]-v[ne-2][0]),K=Math.sign(v[ne-1][1]-v[ne-2][1]);g=[B,K]}}!O&&c.left<=0?(f++,v=[R.p,[E.p[0],R.p[1]],E.p]):O||(a($.path,`no path found for route "${$.id}" from "${R.node.id}" to "${E.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),v=[R.p,[E.p[0],R.p[1]],E.p]),v=dr(v);for(let F=0;F+1<v.length;F++)pu(N,v[F],v[F+1]);$.points=bu(n,v,R,E)}return f&&a(e,`${f} of ${p.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${Po.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:p,diags:i}}function No(t,e){return e.x0>=t.x0-1e-6&&e.x1<=t.x1+1e-6&&e.y0>=t.y0-1e-6&&e.y1<=t.y1+1e-6&&e.z0>=t.z1-1e-6}var ac=(t,e)=>`${Math.round(t/Ln)},${Math.round(e/Ln)}`;function pu(t,e,n){let s=Math.max(1,Math.round(Math.hypot(n[0]-e[0],n[1]-e[1])/Ln));for(let r=0;r<=s;r++){let o=ac(e[0]+(n[0]-e[0])*r/s,e[1]+(n[1]-e[1])*r/s);t.set(o,(t.get(o)??0)+1)}}function lc(t,e,n){for(let s of n)if(t>s.x0-To&&t<s.x1+To&&e>s.y0-To&&e<s.y1+To)return!0;return!1}function mu(t,e,n,s,r,o,i={left:1/0}){if((Math.abs(t[0]-e[0])<1e-6||Math.abs(t[1]-e[1])<1e-6)&&gu(t,e,n)){let B=[Math.sign(e[0]-t[0]),Math.sign(e[1]-t[1])],K=!r||r[0]===B[0]&&r[1]===B[1],q=!o||o[0]===B[0]&&o[1]===B[1];if(K&&q)return[t,e]}if(i.left<=0)return null;let a=B=>Math.round((B-t[0])/Ln),l=B=>Math.round((B-t[1])/Ln),c=B=>t[0]+B*Ln,f=B=>t[1]+B*Ln,u=a(e[0]),d=l(e[1]),p=30,h=Math.min(0,u)-p,m=Math.max(0,u)+p,y=Math.min(0,d)-p,I=Math.max(0,d)+p,N=1.2,M=Ln,$=.06,R=[[1,0],[-1,0],[0,1],[0,-1]],E=m-h+1,w=I-y+1,T=(B,K)=>(B-h)*w+(K-y),L=new Int8Array(E*w).fill(-1),x=new Float64Array(E*w).fill(-1),P=new Float64Array(E*w*4).fill(1/0),b=(B,K)=>{let q=T(B,K);return L[q]<0&&(L[q]=lc(c(B),f(K),n)?1:0),L[q]===1},v=(B,K)=>{let q=T(B,K);return x[q]<0&&(x[q]=s.get(ac(c(B),f(K)))??0),x[q]},g=la(),O=(B,K)=>(Math.abs(B-u)+Math.abs(K-d))*M,F=r?R.findIndex(B=>B[0]===r[0]&&B[1]===r[1]):-1;g.push({i:0,j:0,d:F,g:0,f:O(0,0),idx:0,hp:0});let j=(B,K)=>Math.abs(B)+Math.abs(K)<=2,U=(B,K)=>Math.abs(B-u)+Math.abs(K-d)<=2,ne=0;for(;g.length()&&ne++<2e5;){if(i.left--<=0)return null;let B=g.take();if(B.i===u&&B.j===d&&!(o&&B.d>=0&&(R[B.d][0]!==o[0]||R[B.d][1]!==o[1]))){let K=[];for(let q=B;q;q=q.prev)K.push([c(q.i),f(q.j)]);return K.reverse(),K[0]=t,hu(dr(K),e)}for(let K=0;K<4;K++){let q=R[K];if(B.d>=0&&q[0]===-R[B.d][0]&&q[1]===-R[B.d][1])continue;let Z=B.i+q[0],A=B.j+q[1];if(Z<h||Z>m||A<y||A>I||!j(Z,A)&&!U(Z,A)&&b(Z,A))continue;if((j(Z,A)||U(Z,A))&&b(Z,A)&&!(Z===u&&A===d)){let ie=j(Z,A)?r:o&&[-o[0],-o[1]];if(!ie||(j(Z,A)?q[0]!==ie[0]||q[1]!==ie[1]:q[0]!==o[0]||q[1]!==o[1]))continue}let D=B.d>=0&&B.d!==K?N:0,V=B.g+M+D+v(Z,A)*$,W=T(Z,A)*4+K;P[W]<=V||(P[W]=V,g.push({i:Z,j:A,d:K,g:V,f:V+O(Z,A),prev:B,idx:0,hp:0}))}}return null}function la(){let t=[],e=[],n=(i,a)=>i.f<a.f||i.f===a.f&&i.idx<a.idx,s=(i,a)=>{let l=e[i];e[i]=e[a],e[a]=l,e[i].hp=i,e[a].hp=a},r=i=>{for(;i>0;){let a=i-1>>1;if(!n(e[i],e[a]))break;s(i,a),i=a}},o=i=>{for(;;){let a=2*i+1,l=a+1,c=i;if(a<e.length&&n(e[a],e[c])&&(c=a),l<e.length&&n(e[l],e[c])&&(c=l),c===i)return;s(i,c),i=c}};return{length:()=>t.length,push(i){i.idx=t.length,t.push(i),i.hp=e.length,e.push(i),r(i.hp)},take(){let i=e[0],a=e.pop();e.length&&(e[0]=a,a.hp=0,o(0));let l=t.pop();return l!==i&&(t[i.idx]=l,l.idx=i.idx,r(l.hp)),i}}}function hu(t,e){let n=t.map(o=>[o[0],o[1]]),s=n.length,r=n[s-1];if(s>=2){let o=n[s-2];Math.abs(o[1]-r[1])<1e-9?(o[1]=e[1],s>=3&&Math.abs(n[s-3][1]-r[1])<1e-9&&(n[s-3][1]=e[1])):Math.abs(o[0]-r[0])<1e-9&&(o[0]=e[0],s>=3&&Math.abs(n[s-3][0]-r[0])<1e-9&&(n[s-3][0]=e[0]))}return n[s-1]=e,dr(n)}function gu(t,e,n){let s=Math.max(1,Math.round(Math.hypot(e[0]-t[0],e[1]-t[1])/(Ln/2)));for(let r=2;r<s-1;r++)if(lc(t[0]+(e[0]-t[0])*r/s,t[1]+(e[1]-t[1])*r/s,n))return!1;return!0}function dr(t){let e=[];for(let n of t){let s=e.length;if(!(s&&Math.abs(e[s-1][0]-n[0])<1e-6&&Math.abs(e[s-1][1]-n[1])<1e-6)){if(s>=2){let r=e[s-2],o=e[s-1];if(Math.abs(r[0]-o[0])<1e-6&&Math.abs(o[0]-n[0])<1e-6||Math.abs(r[1]-o[1])<1e-6&&Math.abs(o[1]-n[1])<1e-6){e[s-1]=n;continue}}e.push(n)}}return e}function bu(t,e,n,s){let r=new Set,o=new Set;for(let c of t.items)c.type!=="region"||!pt(t.catalog,c.region.kind)?.floor||(r.add(c.box.x0),r.add(c.box.x1),o.add(c.box.y0),o.add(c.box.y1));let i=[],a=(c,f)=>Ns(t,c,f)+.01;for(let c=0;c+1<e.length;c++){let[f,u]=e[c],[d,p]=e[c+1],h=[0,1];if(Math.abs(u-p)<1e-6)for(let m of r){let y=(m-f)/(d-f);y>1e-6&&y<1-1e-6&&h.push(y)}else for(let m of o){let y=(m-u)/(p-u);y>1e-6&&y<1-1e-6&&h.push(y)}h.sort((m,y)=>m-y);for(let m=0;m+1<h.length;m++){let y=h[m],I=h[m+1],N=(y+I)/2,M=a(f+(d-f)*N,u+(p-u)*N),$=[f+(d-f)*y,u+(p-u)*y,M],R=[f+(d-f)*I,u+(p-u)*I,M],E=i[i.length-1];E&&(Math.abs(E[0]-$[0])>1e-6||Math.abs(E[1]-$[1])>1e-6||Math.abs(E[2]-$[2])>1e-6)?i.push($):E||i.push($),i.push(R)}}i.length&&(i[0][2]=n.side==="top"?n.z:n.node.box.z0+.01,i[i.length-1][2]=s.side==="top"?s.z:s.node.box.z0+.01);let l=[];for(let c of i){let f=l.length;if(f>=2){let u=l[f-2],d=l[f-1],p=Math.abs(u[2]-d[2])<1e-9&&Math.abs(d[2]-c[2])<1e-9,h=Math.abs(u[0]-d[0])<1e-6&&Math.abs(d[0]-c[0])<1e-6||Math.abs(u[1]-d[1])<1e-6&&Math.abs(d[1]-c[1])<1e-6;if(p&&h){l[f-1]=c;continue}}l.push(c)}return l}function aa(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}function qt(t){return[we(t.x0,t.y0,t.z1),we(t.x1,t.y0,t.z1),we(t.x1,t.y0,t.z0),we(t.x1,t.y1,t.z0),we(t.x0,t.y1,t.z0),we(t.x0,t.y1,t.z1)]}function Fn(t){let e=t.map(o=>o[0]),n=t.map(o=>o[1]),s=Math.min(...e),r=Math.min(...n);return{x:s,y:r,w:Math.max(...e)-s,h:Math.max(...n)-r}}function Rs(t,e){let n=t,s=(a,l)=>{let c=[];for(let f=0;f<n.length;f++){let u=n[f],d=n[(f+1)%n.length],p=a(u),h=a(d);p&&c.push(u),p!==h&&c.push(l(u,d))}n=c},r=a=>(l,c)=>[a,l[1]+(c[1]-l[1])*(a-l[0])/(c[0]-l[0])],o=a=>(l,c)=>[l[0]+(c[0]-l[0])*(a-l[1])/(c[1]-l[1]),a];if(s(a=>a[0]>=e.x,r(e.x)),!n.length||(s(a=>a[0]<=e.x+e.w,r(e.x+e.w)),!n.length)||(s(a=>a[1]>=e.y,o(e.y)),!n.length)||(s(a=>a[1]<=e.y+e.h,o(e.y+e.h)),!n.length))return 0;let i=0;for(let a=0;a<n.length;a++){let l=n[a],c=n[(a+1)%n.length];i+=l[0]*c[1]-c[0]*l[1]}return Math.abs(i)/2}function ua(t,e){let n=Math.min(t.x+t.w,e.x+e.w)-Math.max(t.x,e.x),s=Math.min(t.y+t.h,e.y+e.h)-Math.max(t.y,e.y);return n>0&&s>0?n*s:0}function uc(t,e){let n=0;for(let s=0;s+1<t.length;s++){let r=t[s],o=t[s+1],i=Math.hypot(o[0]-r[0],o[1]-r[1]),a=Math.max(1,Math.ceil(i/4));for(let l=0;l<a;l++){let c=r[0]+(o[0]-r[0])*(l+.5)/a,f=r[1]+(o[1]-r[1])*(l+.5)/a;c>=e.x&&c<=e.x+e.w&&f>=e.y&&f<=e.y+e.h&&(n+=i/a*4)}}return n}var In=64,Co=class{cells=new Map;n=0;add(e,n,s,r,o){for(let i=Math.floor(n/In);i<=Math.floor(r/In);i++)for(let a=Math.floor(s/In);a<=Math.floor(o/In);a++){let l=i*1048576+a,c=this.cells.get(l);c||this.cells.set(l,c=[]),c[c.length-1]!==e&&c.push(e)}}query(e,n,s,r){let o=new Set;for(let i=Math.floor(e/In);i<=Math.floor(s/In);i++)for(let a=Math.floor(n/In);a<=Math.floor(r/In);a++){let l=this.cells.get(i*1048576+a);if(l)for(let c of l)o.add(c)}return[...o].sort((i,a)=>i-a)}},ca=t=>{let e=1/0,n=1/0,s=-1/0,r=-1/0;for(let[o,i]of t)o<e&&(e=o),o>s&&(s=o),i<n&&(n=i),i>r&&(r=i);return[e,n,s,r]},Lo=new WeakMap;function Hn(t,e){let n=Lo.get(t);for((!n||n.n>t.length)&&Lo.set(t,n=new Co);n.n<t.length;n.n++){let[s,r,o,i]=e(t[n.n]);n.add(n.n,s,r,o,i)}return n}function cc(t){let e=Lo.get(t);for((!e||e.n>t.length)&&Lo.set(t,e=new Co);e.n<t.length;e.n++){let n=t[e.n].pts;for(let s=0;s+1<n.length;s++){let r=n[s],o=n[s+1],i=e.n*65536+s,a=Math.max(1,Math.ceil(Math.hypot(o[0]-r[0],o[1]-r[1])/(In/2)));for(let l=0;l<a;l++){let c=l/a,f=(l+1)/a,u=r[0]+(o[0]-r[0])*c,d=r[1]+(o[1]-r[1])*c,p=r[0]+(o[0]-r[0])*f,h=r[1]+(o[1]-r[1])*f;e.add(i,Math.min(u,p)-1,Math.min(d,h)-1,Math.max(u,p)+1,Math.max(d,h)+1)}}}return e}var En=(t,e,n,s,r)=>t.query(e,n,s,r),Ps=t=>ca(t),Oo=t=>[t.x,t.y,t.x+t.w,t.y+t.h];function fc(t,e,n,[s,r,o,i]){let a=0,l=n-1;for(let c of[0,1]){let f=e[c]-t[c],u=c?r:s,d=c?i:o;if(Math.abs(f)<1e-12){if(t[c]<u||t[c]>d)return[1,0];continue}let p=(u-t[c])/f*n-.5,h=(d-t[c])/f*n-.5;p>h&&([p,h]=[h,p]),a=Math.max(a,Math.floor(p)-1),l=Math.min(l,Math.ceil(h)+1)}return[a,l]}var ls=class t{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let n=0;for(let s of En(Hn(this.solids,Ps),...Oo(e)))n+=Rs(this.solids[s],e);return n}hiddenPoly(e){let n=0;for(let s of En(Hn(this.solids,Ps),...ca(e)))n+=pr(e,this.solids[s]);return n}costPoly(e,n=1/0){let s=ca(e),r=0;for(let o of En(Hn(this.polys,i=>Ps(i.poly)),...s))r+=pr(e,this.polys[o].poly);for(let o of En(Hn(this.rects,i=>Oo(i.r)),...s))r+=Rs(e,this.rects[o].r)*2;for(let o of En(Hn(this.slants,Ps),...s))r+=pr(e,this.slants[o])*2;if(r>=n)return r;for(let o of En(cc(this.lines),...s)){if(r>=n)return r;let i=this.lines[Math.floor(o/65536)].pts,a=o%65536,l=i[a],c=i[a+1],f=Math.hypot(c[0]-l[0],c[1]-l[1]),u=Math.max(1,Math.ceil(f/4)),[d,p]=fc(l,c,u,s);for(let h=d;h<=p;h++)pa(e,[l[0]+(c[0]-l[0])*(h+.5)/u,l[1]+(c[1]-l[1])*(h+.5)/u])&&(r+=f/u*4*.6)}return r}cost(e,n,s=.6){let r=Oo(e),o=0;for(let i of En(Hn(this.polys,a=>Ps(a.poly)),...r)){let a=this.polys[i];o+=Rs(a.poly,e)*(a.owner===n?1.5:1)}for(let i of En(Hn(this.rects,a=>Oo(a.r)),...r)){let a=this.rects[i];(a.owner!==n||!n)&&(o+=ua(a.r,e)*2)}for(let i of En(Hn(this.slants,Ps),...r))o+=Rs(this.slants[i],e)*2;if(s){let i=-1,a=0;for(let l of En(cc(this.lines),...r)){let c=Math.floor(l/65536);c!==i&&(i>=0&&(o+=a*s),i=c,a=0);let f=this.lines[c].pts,u=l%65536,d=f[u],p=f[u+1],h=Math.hypot(p[0]-d[0],p[1]-d[1]),m=Math.max(1,Math.ceil(h/4)),[y,I]=fc(d,p,m,r);for(let N=y;N<=I;N++){let M=d[0]+(p[0]-d[0])*(N+.5)/m,$=d[1]+(p[1]-d[1])*(N+.5)/m;M>=e.x&&M<=e.x+e.w&&$>=e.y&&$<=e.y+e.h&&(a+=h/m*4)}}i>=0&&(o+=a*s)}return o}fork(){let e=new t;return e.budget=this.budget,e.polys=this.polys,e.lines=this.lines,e.solids=this.solids,e.rects=[...this.rects],e.slants=this.slants,e}},dc=14;function mr(t,e,n,s){let r=Math.max(t.name?Jt(t.name,at.lbl):0,t.sub?Jt(t.sub,at.sub):0)+4,o=(t.name?1:0)+(t.sub?1:0),i=n-(t.name?11:9)-1,a=(o-1)*dc+(t.name?11:9)+4;return{x:s==="start"?e-2:s==="end"?e-r+2:e-r/2,y:i,w:r,h:a}}function hr(t,e,n,s,r,o){let i=Fn(n),a=we((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((t.name?1:0)+(t.sub?1:0)-1)*dc+4,f=i.y-6-c,u=i.y+Math.min(i.h,60)*.45,d=[];o&&d.push({...o,pen:0}),d.push({x:a,y:f,anchor:"middle",pen:o?20:0});for(let m of[12,24,40])d.push({x:a,y:f-m,anchor:"middle",pen:20+m});for(let m of[-30,30,-60,60])d.push({x:a+m,y:f-4,anchor:"middle",pen:30+Math.abs(m)});d.push({x:i.x+i.w+8,y:u,anchor:"start",pen:120}),d.push({x:i.x-8,y:u,anchor:"end",pen:120}),d.push({x:a,y:i.y+i.h+14,anchor:"middle",pen:300});let p,h=1/0;for(let m of d){let y=mr(t,m.x,m.y,m.anchor),I=s.cost(y,r,.15)*2+m.pen;I<h&&(h=I,p={x:m.x,y:m.y,anchor:m.anchor,rect:y})}return p}function da(t,e,n,s){return{x:(s==="start"?e:s==="end"?e-t:e-t/2)-2,y:n-14,w:t+4,h:28}}function Io(t,e,n,s,r){let o=[{...s,pen:0}];for(let f of[-46,-66,-86,-106,-126,-146])for(let u of[0,-70,70,-140,140])o.push({x:e+u,y:n+f,anchor:"middle",pen:10+(-f-46)*.5+Math.abs(u)*.4});for(let f of[34,60,86])o.push({x:e,y:n+f,anchor:"middle",pen:60+f*.3});let i=s.x-e,a=s.y-n;for(let f of[-1,1])for(let u of[16,32,48])o.push({...s,y:n+a+f*u,x:e+i,pen:5+u});for(let f of[-1,1])for(let u of[30,60,90])for(let d of[0,16,-16])o.push({...s,x:e+i+f*u,y:n+a+d,pen:8+u*.6+Math.abs(d)});let l,c=1/0;for(let f of o){let u=da(t,f.x,f.y,f.anchor),d=r.cost(u,void 0,.05)*3+f.pen;d<c&&(c=d,l={x:f.x,y:f.y,anchor:f.anchor,rect:u})}return l}var pc=t=>{let e=0;for(let n=0;n<t.length;n++){let s=t[n],r=t[(n+1)%t.length];e+=s[0]*r[1]-r[0]*s[1]}return e/2},fa=t=>pc(t)<0?[...t].reverse():t;function pa(t,e){let n=fa(t);for(let s=0;s<n.length;s++){let r=n[s],o=n[(s+1)%n.length];if((o[0]-r[0])*(e[1]-r[1])-(o[1]-r[1])*(e[0]-r[0])<0)return!1}return!0}function pr(t,e){let n=fa(t),s=fa(e);for(let r=0;r<s.length&&n.length;r++){let o=s[r],i=s[(r+1)%s.length],a=c=>(i[0]-o[0])*(c[1]-o[1])-(i[1]-o[1])*(c[0]-o[0]),l=n;n=[];for(let c=0;c<l.length;c++){let f=l[c],u=l[(c+1)%l.length],d=a(f),p=a(u);if(d>=0&&n.push(f),d>=0!=p>=0){let h=d/(d-p);n.push([f[0]+(u[0]-f[0])*h,f[1]+(u[1]-f[1])*h])}}}return n.length>=3?Math.abs(pc(n)):0}var Fo=24;function Bo(t,e){let[n,s,r,o]=e,i=t.x+t.w/2,a=t.y+t.h/2,l=[["left",i-n],["right",n+r-i],["top",a-s],["bottom",s+o-a]];l.sort((f,u)=>f[1]-u[1]);let c=l[0][0];return c==="left"?{edge:c,dx:-(t.x+t.w-n)-Fo,dy:0}:c==="right"?{edge:c,dx:n+r-t.x+Fo,dy:0}:c==="top"?{edge:c,dx:0,dy:-(t.y+t.h-s)-Fo}:{edge:c,dx:0,dy:s+o-t.y+Fo}}function _o(t,e,n){let s=$=>{let R=0;for(let E=$.parent;E;E=E.parent)R++;return R},r=$=>$.box.x0+$.box.y0+$.box.z0*.01,o=t.items.filter($=>$.type==="region").sort(($,R)=>s($)-s(R)||r($)-r(R)),i=t.items.filter($=>$.type==="node").sort(($,R)=>r($)-r(R)||$.box.z0-R.box.z0),a=[],l=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach(($,R)=>{let E=Fn(qt($.box));a.push({id:$.id,kind:"region",...Bo(E,n),delay:Math.round(R*l),dur:c,bbox:E})});let f=250+Math.round(l*o.length),u=Math.min(70,700/Math.max(1,i.length)),d=600;i.forEach(($,R)=>{let E=Fn(qt($.box));a.push({id:$.id,kind:"node",...Bo(E,n),delay:Math.round(f+R*u),dur:d,bbox:E})});let p=i.length?f+(i.length-1)*u:f,h=Math.round(p+300),m=Math.min(30,300/Math.max(1,e.length)),y=400,I=e.filter($=>$.points.length>=2).map(($,R)=>({id:$.id,delay:Math.round(h+R*m),dur:y})),N={delay:h+200,dur:400},M=Math.max(...a.map($=>$.delay+$.dur),...I.map($=>$.delay+$.dur),N.delay+N.dur);return{pieces:a,routes:I,labels:N,total:M}}function ma(t){return Math.max(5600,Math.min(12500,2600+t.length*40))}function Do(t,e,n,s,r,o){let i=[],a=(x,P,b,v="error")=>{let g=r.locate(x);i.push({severity:v,message:P,line:g.line,col:g.col,path:x,hint:b})},l=t.steps??[],c=new Set(Object.keys(o.kinds)),f=new Map(s.map(x=>[x.id,x])),u=()=>[...n.byId.keys(),...f.keys()],d=new Map;l.forEach((x,P)=>{x.id&&(d.has(x.id)&&a(`${e}/steps/${P}/id`,`duplicate step id "${x.id}"`),d.set(x.id,P+1))});let p=l.length,h=(x,P)=>{if(typeof x=="number"){if(x<1||x>p){a(P,`there is no step ${x}; this scene has ${p} step(s)`);return}return x}let b=d.get(x);return b===void 0&&a(P,`unknown step "${x}"`+Zt(x,d.keys())),b},m=x=>Mn(o,o.kinds[x]?.color??"control"),y=[],I=x=>{y.includes(x)||y.push(x)};for(let x of s)I(x.kind);let N={},M=(x,P,b,v)=>{if(P===void 0&&b===void 0)return;let g=P!==void 0?h(P,v+"/appears"):1,O=b!==void 0?h(b,v+"/disappears"):p+1;N[x]=Array.from({length:p},(F,j)=>j+1>=(g??1)&&j+1<(O??p+1))};for(let x of n.items)M(x.id,x.appears,x.disappears,x.path);for(let x of s)M(x.id,x.raw.appears,x.raw.disappears,x.path);let $=[],R=[],E=[],w=[],T=()=>{for(let x of s){if(x.raw.appears!==void 0||x.raw.disappears!==void 0)continue;let P=[x.from,x.to].map(b=>b&&(N[b.id]??L(b)));P.some(Boolean)&&(N[x.id]=Array.from({length:p},(b,v)=>P.every(g=>!g||g[v])))}},L=x=>{for(let P=x.parent;P;P=P.parent)if(N[P.id])return N[P.id]};return l.forEach((x,P)=>{let b=P+1,v=`${e}/steps/${P}`,g=x.kind??"control";c.has(g)||a(v+"/kind",`unknown flow kind "${g}"`+Zt(g,c)),I(g);let O=new Set,F=[];(x.animate??[]).forEach((B,K)=>{let q=Array.isArray(B)?B:[B],Z=[];q.forEach((A,D)=>{let V=Array.isArray(B)?`${v}/animate/${K}/${D}`:`${v}/animate/${K}`,W,ie;if(typeof A=="string"){let te=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(A.trim());W=te?te[1]:A,ie=te?.[2]}else{let te=Object.entries(A)[0];W=te[0],ie=te[1]}let de=f.get(W);if(!de){a(V,`unknown route "${W}"`+Zt(W,f.keys()));return}if(ie&&!c.has(ie)){a(V,`unknown flow kind "${ie}"`+Zt(ie,c));return}let X=ie??de.kind;I(X),Z.push({route:W,kind:X,color:m(X)}),O.add(W),de.from&&O.add(de.from.id),de.to&&O.add(de.to.id)}),Z.length&&F.push(Z)});let j=[];(x.pulse??[]).forEach((B,K)=>{let q=n.byId.get(B);if(!q){a(`${v}/pulse/${K}`,`unknown node "${B}"`+Zt(B,n.byId.keys()));return}let Z,A,D,V,W=q.node?as(n.catalog,q.node.asset):void 0;if(W?.pulse)[Z,A,D,V]=W.pulse(q.box);else{let X=q.box;Z=(X.x0+X.x1)/2,A=(X.y0+X.y1)/2,D=X.z1,V=Math.max(22,Math.min(60,(X.x1-X.x0+X.y1-X.y0)*8.5))}let[ie,de]=we(Z,A,D);j.push([ie,de,V*1.7,V*.98]),O.add(B)}),(x.highlight??[]).forEach((B,K)=>{!n.byId.has(B)&&!f.has(B)&&a(`${v}/highlight/${K}`,`unknown id "${B}"`+Zt(B,u())),O.add(B)});for(let[B,K]of[["show",!0],["hide",!1]])(x[B]??[]).forEach((q,Z)=>{if(!n.byId.has(q)&&!f.has(q)){a(`${v}/${B}/${Z}`,`unknown id "${q}"`+Zt(q,u()));return}let A=N[q]??(N[q]=Array(p).fill(!K));for(let D=P;D<p;D++)A[D]=K});if((x.say??[]).forEach((B,K)=>{let q,Z;if(Array.isArray(B.at))[q,Z]=we(B.at[0],B.at[1],B.at[2]??.36);else{let D=n.byId.get(B.at);if(!D){a(`${v}/say/${K}/at`,`unknown node "${B.at}"`+Zt(B.at,n.byId.keys()));return}let V=D.box;[q,Z]=we((V.x0+V.x1)/2,(V.y0+V.y1)/2,V.z1+.75)}let A=B.kind??g;c.has(A)||a(`${v}/say/${K}/kind`,`unknown flow kind "${A}"`+Zt(A,c)),R.push({step:b,x:q+(B.dx??0),y:Z+(B.dy??(Array.isArray(B.at)?0:-46)),ax:q,ay:Z,text:B.text,kind:A,anchor:B.anchor??"middle"})}),(x.mark??[]).forEach((B,K)=>{if(B.at){E.push({step:b,p:[B.at[0],B.at[1],B.at[2]??.36]});return}let q=B.on?f.get(B.on):void 0;if(!q){a(`${v}/mark/${K}`,B.on?`unknown route "${B.on}"`+Zt(B.on,f.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let Z=q.points[q.points.length-1];E.push({step:b,p:[Z[0],Z[1],Z[2]+.6],on:q.id}),O.add(q.id)}),t.badges&&x.badge!==!1){let B=Array.isArray(x.badge)?[x.badge[0],x.badge[1],x.badge[2]??.36]:void 0,K=typeof x.badge=="string"?x.badge:F[0]?.[0]?.route,q=K?f.get(K):void 0;if(!B)if(q)B=ha(q.points);else if(K&&n.byId.get(K)){let Z=n.byId.get(K).box;B=[(Z.x0+Z.x1)/2,(Z.y0+Z.y1)/2,Z.z1+.3]}else typeof x.badge=="string"&&a(`${v}/badge`,`unknown id "${x.badge}"`+Zt(x.badge,u()));B&&w.push({step:b,num:x.number??b,kind:g,p:B})}for(let B of[...O])for(let K=n.byId.get(B)?.parent;K;K=K.parent)O.add(K.id);for(let B of n.items)B.region?.kind==="tunnel"&&(B.region.around??[]).some(K=>O.has(K))&&O.add(B.id);let U;if(x.focus?.length){let B=1/0,K=1/0,q=-1/0,Z=-1/0;x.focus.forEach((A,D)=>{let V=n.byId.get(A);if(!V){a(`${v}/focus/${D}`,`unknown node or region "${A}"`+Zt(A,n.byId.keys()));return}let W=V.box;for(let[ie,de,X]of[[W.x0,W.y0,W.z1],[W.x1,W.y0,W.z0],[W.x0,W.y1,W.z0],[W.x1,W.y1,W.z0],[W.x1,W.y0,W.z1],[W.x0,W.y1,W.z1]]){let[te,ye]=we(ie,de,X);B=Math.min(B,te),K=Math.min(K,ye),q=Math.max(q,te),Z=Math.max(Z,ye)}O.add(A)}),B<1/0&&(U=[Math.round(B-60),Math.round(K-70),Math.round(q+60),Math.round(Z+40)])}let ne=x.caption??"";$.push({n:b,num:x.number??b,kind:g,color:m(g),heading:x.heading,caption:ne,command:x.command??"",phases:F,pulses:j,lit:[...O],duration:x.duration===void 0||x.duration==="auto"?ma(ne):x.duration,...U?{focus:U}:{}})}),T(),{steps:$,says:R,marks:E,badges:w,vis:N,diags:i,kindsUsed:y}}function ha(t){let e=t.slice(1).map((s,r)=>Math.hypot(s[0]-t[r][0],s[1]-t[r][1],s[2]-t[r][2])),n=e.reduce((s,r)=>s+r,0)/2;for(let s=0;s<e.length;s++){if(n<=e[s]&&e[s]>0){let r=n/e[s],o=t[s],i=t[s+1];return[o[0]+(i[0]-o[0])*r,o[1]+(i[1]-o[1])*r,o[2]+(i[2]-o[2])*r]}n-=e[s]}return t[0]}function Zt(t,e){let n=Yn(t,e);return n?` (did you mean "${n}"?)`:""}function mc(t,e){if(!e)return t;let[n,s,r,o]=e,i=t[2]/t[3],a=r-n,l=o-s;a/l<i?a=l*i:l=a/i,a=Math.min(a,t[2]),l=Math.min(l,t[3]);let c=(n+r)/2,f=(s+o)/2,u=Math.max(t[0],Math.min(t[0]+t[2]-a,c-a/2)),d=Math.max(t[1],Math.min(t[1]+t[3]-l,f-l/2));return[u,d,a,l]}var Ko=(t,e)=>e.role??pt(t,e.kind)?.role,zo=(t,e)=>pt(t,e.region.kind)?.shape;function Go({scene:t,layout:e,routes:n,steps:s,theme:r,id:o,gridStep:i=1}){let a=new gs,l={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new ls;c.budget.spots=Vo;let f=g=>s.vis[g]?{"data-vis":"1"}:{},u=e.items.filter(g=>g.type==="region"),d=g=>{let O=0;for(let F=g.parent;F;F=F.parent)O++;return O},p=e.catalog,h=u.filter(g=>zo(p,g)!=="walled"&&zo(p,g)!=="tunnel"),m=Ks(h.map(g=>({box:g.box,r:g}))).map(g=>g.r).sort((g,O)=>d(g)-d(O));for(let g of m)l.base+=xu(a,p,g,f(g.id),i);for(let g of u.filter(O=>zo(p,O)==="walled")){for(let F of jo(g))c.solids.push(qt(F));for(let F of jo(g))l.blocks.push({box:F,svg:me("g",{class:`blk k-${Ko(p,g.region)} wall${g.region.ghost?" ghost":""}`,"data-id":g.id,"data-dim":"1",...f(g.id)},a.blockFaces(F))});let O=g.region.gate;if(O&&!O.node){let F=ur(g,O.height??(g.region.height??.8)+.3,.3,.3);c.solids.push(qt(F)),l.blocks.push({box:F,svg:me("g",{class:"blk k-gate","data-id":g.id,...f(g.id)},a.blockFaces(F))})}g.region.label&&(g.region["label-style"]??"face")!=="none"&&(l.labels+=a.faceText(g.box.x0+.3,g.box.y1,g.box.z0+.13,g.region.label,"slabname sm fz",at.sm,"left","start",{"data-id":g.id,...f(g.id)}))}for(let g of u.filter(O=>zo(p,O)==="tunnel"))l.air+=ku(a,g,f(g.id));let y=e.items.filter(g=>g.type==="node");for(let g of y){let O=g.node,F=Qt(p,O.asset),j=O.ghost||(O.deco??[]).includes("ghost"),U=["blk",`k-${O.role??F.role}`,F.cls,j?"ghost":""].filter(Boolean).join(" ");l.blocks.push({box:g.box,svg:me("g",{class:U,"data-id":g.id,"data-dim":"1",...f(g.id)},F.draw(a,g.box,O))}),c.polys.push({poly:qt(g.box),owner:g.id}),c.solids.push(qt(g.box))}let I=Ks(l.blocks).map(g=>g.svg).join(""),N=new Set,M={};for(let g of n){if(g.points.length<2)continue;let O=g.points.map(U=>we(U[0],U[1],U[2]));O.forEach(U=>a.bounds.add(U));let F="M"+O.map(ts).join(" L");M[g.id]=F;let j=g.raw.arrow!==!1;j&&N.add(g.kind),l.flows+=me("g",{"data-hl":g.id,"data-id":g.id,...f(g.id)},me("path",{d:F,class:`flow f-${g.kind}`,"marker-end":j?`url(#ah-${o}-${g.kind})`:void 0})),c.lines.push({pts:O,owner:g.id})}for(let g of N)a.def(`ah-${o}-${g}`,me("marker",{id:`ah-${o}-${g}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"4.2",markerHeight:"4.2",orient:"auto-start-reverse"},me("path",{d:"M0,0 L10,5 L0,10 z",style:`fill:${Mn(r,r.kinds[g]?.color??"control")}`})));for(let g of a.planePolys)c.slants.push(g);let $=y.filter(g=>g.node.label||g.node.sub).sort((g,O)=>(O.box.x1-O.box.x0)*(O.box.y1-O.box.y0)-(g.box.x1-g.box.x0)*(g.box.y1-g.box.y0));for(let g of $)l.labels+=wu(a,p,g,c,f(g.id));let R=[];for(let g of n)if(g.raw.label&&g.points.length>=2){let O=vu(a,g,c,f(g.id),e);l.floor+=O.svg,O.warning&&R.push({path:`${g.path}/label`,message:O.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,R.push({path:g.path,message:`from route "${g.id}" on, route labels were placed without weighing what other labels and lines cover: the scene is too large to search every spot (${Vo.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(t.notes??[]).forEach((g,O)=>{let F=Su(a,g,e,n,`${o}-note-${O}`);g.floor?l.floor+=F:l.labels+=F});let E=[],w=new Map;for(let g of s.says){let O=w.get(g.step)??c.fork();w.set(g.step,O);let F=Jt(g.text,at.say)+18,j=Io(F,g.ax,g.ay,{x:g.x,y:g.y,anchor:g.anchor},O);O.rects.push({r:j.rect,owner:""}),E.push({step:g.step,...j.rect,text:g.text});let U=j.rect.x+2;a.bounds.addRect(j.rect.x,j.rect.y,j.rect.w,j.rect.h);let ne=Mn(r,r.kinds[g.kind]?.color??"control");l.marks+=me("g",{class:"say","data-step":g.step},me("rect",{x:U,y:j.y-12,width:F,height:24,rx:12,style:`stroke:${ne}`})+me("text",{x:U+F/2,y:j.y+4,"text-anchor":"middle",style:`fill:${ne}`},ut(g.text)))}for(let g of s.marks){let[O,F]=we(...g.p);a.bounds.addRect(O-12,F-12,24,24),l.marks+=me("g",{class:"xm","data-step":g.step,"data-hl":g.on},me("circle",{cx:O,cy:F,r:10})+me("path",{d:`M${it(O-4.5)},${it(F-4.5)} L${it(O+4.5)},${it(F+4.5)} M${it(O+4.5)},${it(F-4.5)} L${it(O-4.5)},${it(F+4.5)}`}))}for(let g of s.badges){let[O,F]=we(...g.p);a.bounds.addRect(O-13,F-13,26,26),l.badges+=me("g",{class:`badge c-${g.kind}`,"data-go":g.step,"data-badge":g.step,tabindex:"0",role:"button","aria-label":`Step ${g.num}`},me("circle",{cx:O,cy:F,r:11.5})+me("text",{x:O,y:F+.5},String(g.num)))}let T=a.bounds,L=22,x=T.empty?[0,0,100,100]:[Math.floor(T.x0-L),Math.floor(T.y0-L),Math.ceil(T.x1-T.x0+L*2),Math.ceil(T.y1-T.y0+L*2)],P=[...a.defs.values()].join(""),b=(g,O)=>me("g",{class:"g-"+g},O);return{svg:me("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:x.join(" "),role:"img","aria-label":t.aria??t.title,"data-scene":o},me("defs",{},P)+b("base",l.base)+b("floor",l.floor)+b("flows",l.flows)+b("blocks",I)+b("air",l.air)+b("labels",l.labels)+b("marks",l.marks)+b("badges",l.badges)+b("anim","")),viewBox:x,texts:a.texts,paths:M,warnings:R,callouts:E,assembly:_o(e,n,x)}}function yu(t,e){let n=t.z1+.002,s=1e-6,r=[],o=(i,a)=>{let l=we(i[0],i[1],n),c=we(a[0],a[1],n);r.push(`M${ts(l)}L${ts(c)}`)};for(let i=Math.ceil((t.x0+s)/e)*e;i<t.x1-s;i+=e)o([i,t.y0],[i,t.y1]);for(let i=Math.ceil((t.y0+s)/e)*e;i<t.y1-s;i+=e)o([t.x0,i],[t.x1,i]);return r.length?me("path",{class:"grid",d:r.join("")}):""}function xu(t,e,n,s,r=1){let o=n.region,i=n.box,a=Ko(e,o),l=pt(e,o.kind),c=l?.shape,f={"data-id":n.id,"data-dim":"1",...s},u="";c==="cloud"?u=me("g",{class:`blk k-${a} cloud`,...f},vo(t,i)):c==="zone"?u=me("g",{class:`zone k-${a}`,...f},t.poly([[i.x0,i.y0,i.z1],[i.x1,i.y0,i.z1],[i.x1,i.y1,i.z1],[i.x0,i.y1,i.z1]])):u=me("g",{class:`blk k-${a}${o.ghost?" ghost":""}`,...f},t.blockFaces(i)+yu(i,r));let d=o["label-style"]??l?.labelStyle;if(o.label&&d!=="none")if(d==="face"){let p=i.z1-i.z0,h=N=>N.size*.73/Xe,m=c==="slab"&&.28+h(at.slabname)+.08>p,y=c==="slab"&&!m,I=y?i.z0+.28:m?i.z0+Math.max(.02,(p-h(at.sm))/2):i.z0+Math.min(.1,p*.25);u+=me("g",f,t.faceText(i.x0+(y?.6:.3),i.y1,I,o.label,y?"slabname":"slabname sm",y?at.slabname:at.sm,"left","start"))}else if(d==="face-right")u+=me("g",f,t.faceText(i.x1,i.y0+.6,i.z0+Math.max(.14,(i.z1-i.z0)*.2),o.label,"slabname",at.slabname,"right","end"));else{let p=c==="cloud"?"middle":"start",h=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,m=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=me("g",f,t.floorText(h,m,i.z1+.01,o.label,"slabname sm","x",p))}return u}function jo(t){let{x0:e,y0:n,x1:s,y1:r,z0:o,z1:i}=t.box,a=$n,l=t.region.gate,c=[],f=d=>{d.x1-d.x0>1e-6&&d.y1-d.y0>1e-6&&c.push({...d,z0:o,z1:i})},u=(d,p,h)=>{if(!l||l.side!==h)return[[d,p]];let m=l.at??.5,y=l.width??2,I=h==="e"||h==="w"?n+(r-n)*m:e+(s-e)*m;return[[d,I-y/2],[I+y/2,p]]};for(let[d,p]of u(e,s,"n"))f({x0:d,y0:n,x1:p,y1:n+a});for(let[d,p]of u(n+a,r-a,"w"))f({x0:e,y0:d,x1:e+a,y1:p});for(let[d,p]of u(n+a,r-a,"e"))f({x0:s-a,y0:d,x1:s,y1:p});for(let[d,p]of u(e,s,"s"))f({x0:d,y0:r-a,x1:p,y1:r});return c}function wu(t,e,n,s,r){let o=n.node,i=Qt(e,o.asset),a=n.box,l={name:o.label,sub:o.sub},c=o["label-at"],f;if(c){let d=Fn(qt(a)),p=c.side??"above",h=d.y+Math.min(d.h,60)*.45;p==="right"?f={x:d.x+d.w+8,y:h,anchor:"start"}:p==="left"?f={x:d.x-8,y:h,anchor:"end"}:p==="below"?f={x:d.x+d.w/2,y:d.y+d.h+14,anchor:"middle"}:f=hr(l,a,qt(a),new ls,n.id),f={...f,x:f.x+(c.dx??0),y:f.y+(c.dy??0)}}else{let d=i.label?i.label(a,o,!!o.sub):void 0;f=hr(l,a,qt(a),s,n.id,d)}s.rects.push({r:mr(l,f.x,f.y,f.anchor),owner:""});let u="";return o.label&&(u+=t.text(f.x,f.y,o.label,"lbl",at.lbl,f.anchor,{},n.id)),o.sub&&(u+=t.text(f.x,o.label?f.y+14:f.y,o.sub,"sub mono",at.sub,f.anchor,{},n.id)),me("g",{"data-id":n.id,"data-dim":"1",...r},u)}function ku(t,e,n){let{x0:s,y0:r,x1:o,y1:i,z0:a,z1:l}=e.box,c=t.blockFaces(e.box),f=o-s>=i-r,u=Math.max(1,Math.round((f?o-s:i-r)/1.6));for(let p=1;p<u;p++){let h=f?s+(o-s)*p/u:r+(i-r)*p/u;c+=t.poly(f?[[h,r,l],[h,i,l],[h,i,a]]:[[s,h,l],[o,h,l],[o,h,a]],"rib")}let d=e.region.label;return d&&e.region["label-style"]!=="none"&&(c+=f?t.faceText(s+.35,i,a+.14,d,"tunname",at.tunname,"left","start"):t.faceText(o,i-.35,a+.18,d,"tunname",at.tunname,"right","start")),me("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...n},c)}var Vo=2e4;function vu(t,e,n,s,r){let o=typeof e.raw.label=="string"?{text:e.raw.label}:e.raw.label,i=`floor mono t-${e.kind}`,a={"data-hl":e.id,...s},l=at.floor;if(o.at){let N=o.at.length>2?o.at[2]:e.points[0][2];return{svg:t.floorText(o.at[0],o.at[1],N,o.text,i,o.dir??"x",o.anchor??"start",a)}}let c=e.points,f=[];for(let N=0;N+1<c.length;N++){let M=c[N],$=c[N+1];Math.abs(M[2]-$[2])>1e-6||f.push({i:N,len:Math.hypot($[0]-M[0],$[1]-M[1])})}if(!f.length)return{svg:"",warning:`label "${o.text}" of route "${e.id}" was dropped: the route has no level segment`};let u=o.along?f.filter(N=>N.i===Math.min(o.along-1,c.length-2)):[...f].sort((N,M)=>M.len-N.len),d=.22,p=11/Xe,h=N=>{let M=Jt(N,l)/Xe,$,R=1/0,E=0;e:for(let w of u.length?u:f){let T=c[w.i],L=c[w.i+1],x=T[2],P=Math.abs(T[1]-L[1])<1e-6,b=P?Math.min(T[0],L[0]):Math.min(T[1],L[1]),v=P?Math.max(T[0],L[0]):Math.max(T[1],L[1]),g=P?T[1]:T[0],O=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],F=[];for(let j=b+.3;j<=Math.max(b+.3,v-M-.2)+1e-9;j+=.4)F.push(j);for(let j=v-M-.2+.4;j<v+.5&&v-b<M+.5;j+=.6)F.push(j);for(let j of O)for(let U of F){if(R<=E*.5)break e;let ne=j<0?g-d:g+d+p,B,K,q;if(P?(B=U,K=ne,q=[we(B,K-p,x),we(B+M,K-p,x),we(B+M,K,x),we(B,K,x)]):(B=ne,K=U+M,q=[we(B-p,K,x),we(B-p,K-M,x),we(B,K-M,x),we(B,K,x)]),(P?[[B,K-p],[B+M,K-p],[B+M,K],[B,K]]:[[B-p,K],[B-p,K-M],[B,K-M],[B,K]]).some(([ie,de])=>Math.abs(Ns(r,ie,de)+.01-x)>.001)){E++;continue}let A=n.hiddenPoly(q),D=A*50+E*.5,V=n.budget.spots-- >0;V||(n.budget.over=!0);let W=D>=R?1/0:V?D+n.costPoly(q,R-D):D;E++,W<R&&(R=W,$={x:B,y:K,z:x,dir:P?"x":"y",rect:Fn(q),poly:q,hidden:A})}}return $&&$.hidden<6?$:void 0},m=o.text,y=h(m),I;if(!y){let N=o.text.split(/(\s+)/);for(let M=N.length-1;M>0&&!y;M--){let $=N.slice(0,M).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if($.length<6)break;let R=h($);R&&(y=R,m=$)}I=y?`label of route "${e.id}" shortened to "${m}": no clear floor for the whole text`:`label "${o.text}" of route "${e.id}" was dropped: blocks cover every spot beside it`,y?I+='; give it "along", "side" or "at", or move the nodes apart':I+='; give it "at: [x, y]", or move the nodes apart'}return y?(n.slants.push(y.poly),{svg:t.floorText(y.x,y.y,y.z+.01,m,i,y.dir,"start",a),warning:I}):{svg:"",warning:I}}function Su(t,e,n,s,r){let o=e.on?s.find(f=>f.id===e.on):void 0,i=e.on&&!o?n.byId.get(e.on):void 0,a=e.at,l={"data-id":r,"data-hl":o?.id,"data-dim":o?void 0:"1"},c=e.kind??o?.kind??"control";if(e.floor){let f=a&&a.length>2?a[2]:o?o.points[0][2]:i?i.floor:.36,[u,d]=a?[a[0],a[1]]:o?[o.points[0][0]+.35,o.points[0][1]-.25]:i?[i.box.x0+.3,i.box.y1-.3]:[0,0];return t.floorText(u,d,f+.01,e.floor,`floor mono t-${c}`,e.dir??"x",e.anchor??"start",l)}if(e.face){let f=i?.box,[u,d,p]=a?[a[0],a[1],a[2]??.45]:f?[f.x0+.3,f.y1,f.z0+.13]:[0,0,0];return t.faceText(u,d,p,e.face,"slabname sm",at.sm,"left",e.anchor??"start",l)}if(e.label||e.sub){let f=i?.box,u=a?[a[0],a[1],a[2]??.36]:f?[(f.x0+f.x1)/2,(f.y0+f.y1)/2,f.z1+.75]:[0,0,0],[d,p]=we(u[0],u[1],u[2]),h=d+(e.dx??0),m=p-18+(e.dy??0),y=e.anchor??"middle",I="";return e.label&&(I+=t.text(h,m,e.label,"lbl",at.lbl,y)),e.sub&&(I+=t.text(h,e.label?m+14:m,e.sub,"sub mono",at.sub,y)),me("g",l,I)}return""}var ga=`
|
|
140
|
+
`)}function ef(n){return n.split("/").slice(1).map(e=>{let t=e.replace(/~1/g,"/").replace(/~0/g,"~");return/^\d+$/.test(t)?Number(t):t})}function tf(n){let e=new $s,t=Xo(n,{lineCounter:e,prettyErrors:!1,uniqueKeys:!0}),s=[],r=l=>{let c=e.linePos(l);return{line:c.line,col:c.col}};for(let l of t.errors){let c=r(l.pos[0]),f=l.message.split(`
|
|
141
|
+
`)[0],u=/Nested mappings|Implicit keys|mapping values/i.test(f)?`text that contains ": " (a colon followed by a blank) must be in quotes, e.g. command: 'send "a: b"'`:/Map keys must be unique/i.test(f)?"a key is written twice in the same map":void 0;s.push({severity:"error",message:`YAML: ${f}`,line:c.line,col:c.col,path:"",hint:u})}for(let l of t.warnings){let c=r(l.pos[0]);s.push({severity:"warning",message:`YAML: ${l.message.split(`
|
|
142
|
+
`)[0]}`,line:c.line,col:c.col,path:""})}function o(l,c={}){let f=ef(l),u=t.contents,d={line:1,col:1},p=g=>{let m=g?.range;m&&(d=r(m[0]))};p(u);for(let g=0;g<f.length;g++){let m=f[g];if(Gt(u)){let y=u.items.find(N=>qe(N)&&_e(N.key)&&String(N.key.value)===String(m));if(!y)break;if(c.key&&g===f.length-1)return p(y.key),d;p(y.key),u=y.value,u&&p(u)}else if(qt(u)&&typeof m=="number"){if(u=u.items[m],!u)break;p(u)}else break}return d}function i(l){let c=t.contents;for(let p of ef(l)){if(Gt(c)){let g=c.items.find(m=>qe(m)&&_e(m.key)&&String(m.key.value)===String(p));if(!g)return;c=g.value}else if(qt(c)&&typeof p=="number")c=c.items[p];else return;if(!c)return}let f=c.range;if(!f)return;let u=e.linePos(Math.max(f[0],f[1]-1)).line,d=n.split(/\r?\n/);for(;u>e.linePos(f[0]).line&&/^\s*(#.*)?$/.test(d[u-1]??"");)u--;return{start:e.linePos(f[0]).line,end:u}}let a=null;return t.errors.length||(a=t.toJS({maxAliasCount:100})),{data:a,locate:o,span:i,diags:s}}var _d=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),zd=new Set(["id","class","role","transform","viewBox","width","height","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","fx","fy","d","points","offset","gradientUnits","gradientTransform","markerWidth","markerHeight","refX","refY","orient","markerUnits","text-anchor","dominant-baseline","font-size","font-weight","letter-spacing","fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity","fill-opacity","stroke-opacity","stop-color","stop-opacity","marker-start","marker-mid","marker-end","clip-path","preserveAspectRatio","vector-effect","paint-order","style"]),Vd=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),Kd={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},nf=n=>n.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,t)=>Kd[t]);function Va(n,e){return n.startsWith("data-")||n.startsWith("aria-")?/^[a-z][\w-]*$/.test(n):!(!zd.has(n)||Vd.has(n)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function Ka(n){let e={name:"#root",attrs:[],children:[]},t=[{node:e,dropped:!1}],s=/<(?:!--)[\s\S]*?-->|<\/([a-zA-Z][\w:-]*)\s*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g,r,o=0;for(;r=s.exec(n);){if(r.index!==o)throw new Error(`not the renderer's SVG at ${o}: ${JSON.stringify(n.slice(o,o+40))}`);o=s.lastIndex;let i=t[t.length-1];if(r[0].charAt(1)!=="!"){if(r[1]){if(t.length<2||i.node.name!==r[1])throw new Error(`a stray </${r[1]}>`);t.pop();continue}if(r[2]){let a=r[2],l=[];for(let u of r[3].matchAll(/([\w:-]+)="([^"]*)"/g)){let d=u[1],p=nf(u[2]);d==="xmlns"||d.startsWith("xmlns:")||Va(d,p)&&l.push([d,p])}let c={name:a,attrs:l,children:[]},f=i.dropped||!_d.has(a);f||i.node.children.push(c),r[4]||t.push({node:c,dropped:f});continue}!i.dropped&&r[5].trim()&&i.node.children.push(nf(r[5]))}}if(o!==n.length)throw new Error(`not the renderer's SVG at ${o}`);if(t.length!==1)throw new Error(`<${t[t.length-1].node.name}> is never closed`);return e}var Gd="http://www.w3.org/2000/svg",sf=n=>n.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function rf(n,e=document){let t=r=>{let o=e.createElementNS(Gd,r.name);for(let[i,a]of r.attrs)i==="style"?o.style.cssText=sf(a):o.setAttribute(i,/var\(--/.test(a)?sf(a):a);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):t(i));return o},s=Ka(n).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return t(s)}var qd=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Dr=class n{name;attrs=[];children=[];style={};constructor(e){this.name=e}setAttribute(e,t){let s=this.attrs.findIndex(r=>r[0]===e);s>=0?this.attrs[s][1]=String(t):this.attrs.push([e,String(t)])}getAttribute(e){return this.attrs.find(t=>t[0]===e)?.[1]??null}append(...e){for(let t of e)t!=null&&this.children.push(t)}set textContent(e){this.children=[String(e)]}get textContent(){return this.children.map(e=>typeof e=="string"?e:e.textContent).join("")}toNode(){let e=Object.entries(this.style).filter(([,t])=>t!==""&&t!==void 0).map(([t,s])=>`${qd(t)}:${s}`).join(";");return{name:this.name,attrs:e?[...this.attrs,["style",e]]:[...this.attrs],children:this.children.map(t=>t instanceof n?t.toNode():t)}}},of={createElementNS:(n,e)=>new Dr(e)},af=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),Ud=n=>af(n).replace(/"/g,""");function ni(n,e=new Set(["style"])){if(typeof n=="string")return af(n);let t=n.attrs.map(([r,o])=>` ${r}="${Ud(o)}"`).join("");if(!n.children.length)return`<${n.name}${t}/>`;let s=e.has(n.name)?n.children.map(r=>typeof r=="string"?r.replace(/<\//g,"<\\/"):ni(r,e)).join(""):n.children.map(r=>ni(r,e)).join("");return`<${n.name}${t}>${s}</${n.name}>`}var Yd=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Ga(n){let e=new TextEncoder().encode(n),t=e.length,s=Math.ceil((t+9)/64),r=new Uint8Array(s*64);r.set(e),r[t]=128;let o=new DataView(r.buffer);o.setUint32(r.length-4,t*8>>>0),o.setUint32(r.length-8,Math.floor(t/536870912));let i=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64),l=(c,f)=>c>>>f|c<<32-f;for(let c=0;c<s;c++){for(let h=0;h<16;h++)a[h]=o.getUint32(c*64+h*4);for(let h=16;h<64;h++){let b=l(a[h-15],7)^l(a[h-15],18)^a[h-15]>>>3,x=l(a[h-2],17)^l(a[h-2],19)^a[h-2]>>>10;a[h]=a[h-16]+b+a[h-7]+x>>>0}let[f,u,d,p,g,m,y,N]=i;for(let h=0;h<64;h++){let b=N+(l(g,6)^l(g,11)^l(g,25))+(g&m^~g&y)+Yd[h]+a[h]>>>0,x=(l(f,2)^l(f,13)^l(f,22))+(f&u^f&d^u&d)>>>0;N=y,y=m,m=g,g=p+b>>>0,p=d,d=u,u=f,f=b+x>>>0}i[0]+=f,i[1]+=u,i[2]+=d,i[3]+=p,i[4]+=g,i[5]+=m,i[6]+=y,i[7]+=N}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function lf(n){if(n!=="sha256")throw new Error(`only sha256 here, not ${n}`);let e="",t={update(s){return e+=s,t},digest(s){return Ga(e)}};return t}var du={};la(du,{ANTS_CSS:()=>jf,ANT_DASH:()=>pl,ANT_SPEED:()=>Wr,ANT_STILL:()=>hl,ASSEMBLE_STYLES:()=>Yr,BOARD_3D:()=>ms,BOARD_CSS:()=>cu,DISASSEMBLE_STYLES:()=>Hr,EASING_NAMES:()=>Pi,EXTRAPOLATE:()=>sr,FLAT_DEFAULTS:()=>Nl,FLAT_FONTS:()=>Rl,FONT_STACKS:()=>wl,GRID_CSS:()=>Tl,LABEL_BUDGET:()=>Ai,MARKS_CSS:()=>Ml,MOTION_EASINGS:()=>Ef,MOTION_ORDERS:()=>Qs,MOTION_SCHEMA:()=>Gf,MotionBuilder:()=>Xr,NodesBuilder:()=>tr,Obstacles:()=>Es,PAGE_CSS:()=>vl,PLAYER_CSS:()=>Bi,PLAYER_UI_CSS:()=>El,ROUTE_BUDGET:()=>hi,SeriesBuilder:()=>nr,WALL_T:()=>zn,alongPath:()=>Mi,antDash:()=>Jr,antsOf:()=>Ni,assemble:()=>ml,assembly:()=>Si,baseCss:()=>Fi,bezier:()=>us,bindMotion:()=>qf,boardCatalog:()=>fu,boardDiagram:()=>uu,boardErrors:()=>Di,boardOf:()=>_i,boxAsset:()=>uf,boxSilhouette:()=>su,calloutRect:()=>nl,cardAsset:()=>Pl,checkMotion:()=>Ci,cloudPath:()=>Wa,compileRaw:()=>eu,convexOverlap:()=>Gr,curveAt:()=>or,defaultLabel:()=>mf,disassemble:()=>Lf,drawCloud:()=>ai,drawDecos:()=>Ha,drawLooks:()=>Bf,drawingCss:()=>$l,durationFor:()=>kl,easeOf:()=>On,facePainter:()=>ii,flatHit:()=>lu,floorAt:()=>Hs,floorOf:()=>ru,focusView:()=>Zf,gateBox:()=>Vr,iconPainter:()=>_r,inConvex:()=>sl,introSvg:()=>Ff,kindsCss:()=>ri,labelRect:()=>qr,layoutFlat:()=>lr,lineRectArea:()=>xf,localAt:()=>nu,markCss:()=>oi,metricsMeasure:()=>au,midpoint:()=>Sl,motion:()=>zf,motionModel:()=>fs,motionOfSteps:()=>Uf,motionOrder:()=>cl,msOf:()=>An,noSource:()=>Al,nodeKind:()=>Ms,nodeKindOr:()=>on,offscreen:()=>Xs,openList:()=>Qa,overlap2:()=>ci,overlaps:()=>ji,paddingOf:()=>ou,paint:()=>Cf,parseEnd:()=>Qt,place:()=>fi,placeBoard:()=>to,placeCallout:()=>wi,placeNodeLabel:()=>Ur,placeholderIcon:()=>Ya,planOf:()=>Zs,plate:()=>df,polyBounds:()=>Mn,polyRectArea:()=>Js,readMs:()=>Zr,rectArea:()=>tl,regionKind:()=>pt,regionRole:()=>Oi,registerMarks:()=>ff,renderScene:()=>er,resolveSteps:()=>Li,resolveSvg:()=>Qf,routeAll:()=>gi,screenToGrid:()=>tu,silhouette:()=>Rt,simplify:()=>Kr,snapMove:()=>iu,springAt:()=>rr,svgAt:()=>dl,wallHeight:()=>si,wallsOf:()=>Ti,withAnts:()=>Df});var pt=(n,e)=>e!==void 0&&Object.hasOwn(n.regions,e)?n.regions[e]:void 0,Ms=(n,e)=>n.nodes[e??n.defaultNode],on=(n,e)=>Ms(n,e)??n.nodes[n.defaultNode],si=n=>Object.values(n.regions).find(e=>e.shape==="walled")?.z[1]??.8,ri=n=>Object.values(n.regions).map(e=>e.css??"").join("");var qa=Object.create(null),Ua=[];function ff(n){Object.assign(qa,n.icons??{}),Object.assign(Fs,n.faces??{}),n.css&&!Ua.includes(n.css)&&Ua.push(n.css)}var oi=()=>Ua.join(""),_r=n=>Object.hasOwn(qa,n)?qa[n]:void 0,ii=n=>Object.hasOwn(Fs,n)?Fs[n]:void 0;function Ya(n,e){let t=(e.x0+e.x1)/2,s=(e.y0+e.y1)/2,r=e.z1+.005,o=Math.min(.6,(e.x1-e.x0)*.24,(e.y1-e.y0)*.24),i=[[t-o,s-o,r],[t+o,s-o,r],[t+o,s+o,r],[t-o,s+o,r]];return n.poly(i,"ico-unknown")+n.line3([t-o*.3,s-o*.35,r],[t+o*.3,s-o*.35,r],"ico-unknown-q")+n.line3([t+o*.3,s-o*.35,r],[t,s+o*.1,r],"ico-unknown-q")+n.line3([t,s+o*.45,r],[t,s+o*.5,r],"ico-unknown-q")}function Ha(n,e,t){let s="";for(let r of t??[])r==="terminal"?s+=yr(n,e,3):r==="envelope"?s+=uo(n,e):r==="bubble"?s+=mo(n,e):r==="file-lines"?s+=po(n,e):typeof r=="object"&&(r.terminal&&(s+=yr(n,e,r.terminal)),r.icon&&(s+=(_r(r.icon)??Ya)(n,e)));return s}var Hd=(n,e)=>(n.deco??e.deco??[]).filter(t=>t!=="ghost");function uf(n,e,t,s,r,o){let i={name:n,description:e,size:t,role:s,deco:r,draw:(a,l,c)=>a.blockFaces(l)+Ha(a,l,Hd(c,i))+(o?o(a,l):"")};return i}function df(n){let[e,t]=fo(n);return{x0:e-.75,y0:t-.75,x1:e+.75,y1:t+.75,z0:n.z0,z1:n.z0+.18}}function Wa(n,e){let t=Math.max(8,Math.min(n,e)*.18),s=t*.55,r=s,o=s,i=n-s,a=e-s,l=(c,f,u,d)=>{let p=Math.hypot(u-c,d-f),g=Math.max(1,Math.round(p/(t*1.7))),m="";for(let y=1;y<=g;y++){let N=c+(u-c)*y/g,h=f+(d-f)*y/g,b=p/g/2*1.08;m+=` A${b.toFixed(1)},${b.toFixed(1)} 0 0 1 ${N.toFixed(1)},${h.toFixed(1)}`}return m};return`M${r.toFixed(1)},${o.toFixed(1)}`+l(r,o,i,o)+l(i,o,i,a)+l(i,a,r,a)+l(r,a,r,o)+"Z"}function ai(n,e){let t={...e,z0:e.z1},s=a=>{let[l,c]=Ce(e.x0,e.y0,a);return[wt,.5,-wt,.5,l,c]},r=(e.x1-e.x0)*nt,o=(e.y1-e.y0)*nt,i=Wa(r,o);return n.onMatrix(s(e.z0),r,o,()=>Te("path",{d:i,class:"lft cloud-side"}))+n.onMatrix(s(e.z1),r,o,()=>Te("path",{d:i,class:"top cloud-top"}))}function mf(n,e){let[t,s]=Ce((n.x0+n.x1)/2,(n.y0+n.y1)/2,n.z1+.75);return{x:t,y:s-18+(e?0:6),anchor:"middle"}}var zn=.16,Ja=["right-of","left-of","below","behind"];function fi(n,e,t,s,r,o={},i){let a=[],l=(k,E,S,F=!1,D="error")=>{let H=t.locate(k,{key:F});a.push({severity:D,message:E,line:H.line,col:H.col,path:k,hint:S})},c=[],f=new Map,u=[],d=new Map,p=new Set([...Object.keys(s.roles),...Object.keys(o)]);function g(k,E){let S=f.get(k.id);if(S){let F=t.locate(S.path+"/id");return l(k.path+"/id",`duplicate id "${k.id}" (first used on line ${F.line})`),!1}return f.set(k.id,k),c.push(k),k.parent=E,E?E.children.push(k):u.push(k),!0}let m=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function y(k,E,S){let F={id:k.id,type:"node",path:E,children:[],box:m(),floor:0,node:k,appears:k.appears,disappears:k.disappears};g(F,S)&&(k.nodes??[]).forEach((D,H)=>y(D,`${E}/nodes/${H}`,F))}function N(k,E,S){let F={id:k.id,type:"region",path:E,children:[],box:m(),floor:0,region:k,appears:k.appears,disappears:k.disappears};g(F,S)&&((k.nodes??[]).forEach((D,H)=>y(D,`${E}/nodes/${H}`,F)),(k.regions??[]).forEach((D,H)=>N(D,`${E}/regions/${H}`,F)))}(n.regions??[]).forEach((k,E)=>N(k,`${e}/regions/${E}`,void 0)),(n.nodes??[]).forEach((k,E)=>y(k,`${e}/nodes/${E}`,void 0));let h=()=>f.keys(),b=()=>c.filter(k=>k.type==="region").map(k=>k.id);for(let k of[...c]){let E=k.node??k.region;if(E.in!==void 0){let F=f.get(E.in);if(!F){l(k.path+"/in",`unknown region "${E.in}"`+zr(E.in,b()));continue}if(F.type!=="region"){l(k.path+"/in",`"${E.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(k.parent&&k.parent!==F){l(k.path+"/in",`"${k.id}" is written inside "${k.parent.id}" but says in: ${E.in}; use one or the other`);continue}for(let D=F;D;D=D.parent)if(D===k){l(k.path+"/in",`"${k.id}" cannot be inside itself`);continue}k.parent||(u.splice(u.indexOf(k),1),k.parent=F,F.children.push(k))}if(k.node){let F=k.node.asset;F!==void 0&&!Ms(r,F)&&l(k.path+"/asset",`unknown asset "${F}"`+zr(F,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let S=(k.node??k.region).role;S!==void 0&&!p.has(S)&&l(k.path+"/role",`unknown colour role "${S}"`+zr(S,p),`add it under "roles:" at the top of the file, or use one of: ${[...p].join(", ")}`)}for(let k of c){let E=k.region?.gate;if(!E?.node)continue;let S=f.get(E.node);if(!S){l(k.path+"/gate/node",`unknown node "${E.node}"`+zr(E.node,h()));continue}if(S.type!=="node"){l(k.path+"/gate/node",`"${E.node}" is a region; a gate is a node`);continue}S.placedBy=k.id;let F=S.node;(F.at||Ja.some(D=>F[D]))&&l(S.path,`"${S.id}" is the gate of "${k.id}", which places it; its own placement is ignored`,void 0,!1,"warning")}let x=k=>k.gap??n.gap??2;function A(k){let E=k.node,S=on(r,E.asset),F=E.size,D=S.size[0],H=S.size[1],X=S.size[2];if(F&&(D=F[0],H=F[1],F.length>2&&(X=F[2])),k.placedBy){let Y=f.get(k.placedBy).region,L=Y.gate,q=L.width??2,U=F?Math.min(D,H):.3;X=F&&F.length>2?X:L.height??(Y.height??si(r))+.3,L.side==="e"||L.side==="w"?(D=U,H=q):(D=q,H=U)}return[D,H,X]}function M(k,E,S,F,D){for(let W of E)O(W);let H=E.filter(W=>!W.placedBy),X=new Set(H),Y=new Set,L=[],q=new Set,U=W=>{let ne=W.node??W.region,Ae=[];for(let Be of Ja){let R=ne[Be];if(R===void 0)continue;let ee=f.get(R);if(!ee){l(`${W.path}/${Be}`,`unknown id "${R}"`+zr(R,h()));continue}if(ee===W){l(`${W.path}/${Be}`,`"${W.id}" cannot be placed ${Be} itself`);continue}if(!X.has(ee)){let ge=we=>we.parent?`"${we.parent.id}"`:"the scene";l(`${W.path}/${Be}`,`"${R}" is in ${ge(ee)} but "${W.id}" is in ${ge(W)}; relative placement works between items in the same region`,ee.placedBy?`"${R}" is a gate, placed by its ${f.get(ee.placedBy)?.region?.kind??"region"}`:`place "${W.id}" relative to something in ${ge(W)}, or use "at:"`);continue}Ae.push(ee)}if(!Ae.length&&!ne.at){let Be=H.indexOf(W);Be>0&&Ae.push(H[Be-1])}return Ae},Z=W=>{if(!Y.has(W)){if(q.has(W)){l(W.path,`placement loop: "${W.id}" is placed relative to something placed relative to it`);return}q.add(W),U(W).forEach(Z),q.delete(W),Y.add(W),L.push(W)}};H.forEach(Z);for(let W of L){let ne=W.node??W.region,Ae=d.get(W),Be=Ja.find(R=>ne[R]!==void 0&&f.get(ne[R])&&X.has(f.get(ne[R])));if(ne.at&&Be&&l(`${W.path}/at`,`"${W.id}" has both "at" and "${Be}"; "at" wins`,void 0,!0,"warning"),ne.at)Ae.x=ne.at[0],Ae.y=ne.at[1];else if(Be)v(Ae,d.get(f.get(ne[Be])),Be,x(ne),ne.align??"center");else{let R=H.indexOf(W);R>0?v(Ae,d.get(H[R-1]),F==="row"?"right-of":"below",x(ne),"center"):(Ae.x=S,Ae.y=S)}ne.shift&&(Ae.x+=ne.shift[0],Ae.y+=ne.shift[1])}if(D||!H.length)return{w:0,d:0};let I=1/0,_=1/0,K=-1/0,J=-1/0;for(let W of H){let ne=d.get(W);I=Math.min(I,ne.x),_=Math.min(_,ne.y),K=Math.max(K,ne.x+ne.w),J=Math.max(J,ne.y+ne.d)}let de=Math.min(0,I-S),ce=Math.min(0,_-S);if(de||ce)for(let W of H){let ne=d.get(W);ne.x-=de,ne.y-=ce}return{w:K-de+S,d:J-ce+S}}function v(k,E,S,F,D){let H=()=>{k.y=D==="start"?E.y:D==="end"?E.y+E.d-k.d:E.y+(E.d-k.d)/2},X=()=>{k.x=D==="start"?E.x:D==="end"?E.x+E.w-k.w:E.x+(E.w-k.w)/2};S==="right-of"?(k.x=E.x+E.w+F,H()):S==="left-of"?(k.x=E.x-F-k.w,H()):S==="below"?(k.y=E.y+E.d+F,X()):(k.y=E.y-F-k.d,X())}function O(k){if(k.type==="node"){let[L,q,U]=A(k);d.set(k,{x:0,y:0,w:L,d:q,h:U,z:k.node.z??0}),k.children.length&&M(k,k.children,0,"row",!0);return}let E=k.region,S=E.padding??pt(r,E.kind)?.pad,F=!!E.size,D=M(k,k.children,S,E.flow??"row",F),H=E.size?E.size[0]:Math.max(D.w,S*2+.5),X=E.size?E.size[1]:Math.max(D.d,S*2+.5);if(!E.size&&E.gate){let L=(E.gate.width??2)+1;E.gate.side==="e"||E.gate.side==="w"?X=Math.max(X,L):H=Math.max(H,L)}let Y=E.size&&E.size.length>2?E.size[2]:E.height??pt(r,E.kind).z[1];d.set(k,{x:0,y:0,w:H,d:X,h:Y,z:0})}M(void 0,u,0,n.flow??"row",!0);function C(k,E,S,F){let D=d.get(k),H=E+D.x,X=S+D.y;if(k.type==="region"){let Y=pt(r,k.region.kind),[L]=Y.z,q=Y.floor,U=Y.shape==="slab"&&pt(r,k.parent?.region?.kind)?.shape==="slab"?0:L,Z=k.region.z??0,I=F+U+Z,_=F+D.h+Z;k.box={x0:H,y0:X,z0:I,x1:H+D.w,y1:X+D.d,z1:_},k.floor=q?_:F}else{let Y=F+D.z;k.box={x0:H,y0:X,z0:Y,x1:H+D.w,y1:X+D.d,z1:Y+D.h},k.floor=k.box.z1}for(let Y of k.children)Y.placedBy||C(Y,H,X,k.floor)}for(let k of u)k.placedBy||C(k,0,0,0);if(i){let k=S=>Math.round(S/i)*i,E=S=>Math.round(S*1e9)/1e9;for(let S of c){if(S.placedBy)continue;let F=S.box,D=k(F.x0),H=k(F.x1),X=k(F.y0),Y=k(F.y1);H-D<i&&(H=D+i),Y-X<i&&(Y=X+i),S.box={...F,x0:E(D),x1:E(H),y0:E(X),y1:E(Y)};let L=S.node??S.region;L.at&&L.at.forEach((q,U)=>{let Z=q/i;Math.abs(Z-Math.round(Z))>1e-6&&l(`${S.path}/at/${U}`,`${q} is not on the ${i} grid; it is drawn at ${E(k(q))}`,void 0,!1,"warning")})}}for(let k of c){let E=k.region?.gate;if(!E?.node)continue;let S=f.get(E.node);!S||S.placedBy!==k.id||(S.box=Vr(k,d.get(S).h,d.get(S).w,d.get(S).d),S.floor=S.box.z1)}for(let k of c){let E=k.children.filter(S=>!S.placedBy);for(let S=0;S<E.length;S++)for(let F=S+1;F<E.length;F++){let D=E[S],H=E[F];li(D,r)||li(H,r)||ci(D.box,H.box)&&l(H.path,`"${H.id}" overlaps "${D.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}if(k.parent&&k.parent.type==="region"&&!k.placedBy){let S=k.parent.box,F=k.box,D=1e-6;(F.x0<S.x0-D||F.y0<S.y0-D||F.x1>S.x1+D||F.y1>S.y1+D)&&l(k.path,`"${k.id}" sticks out of region "${k.parent.id}"`,`make "${k.parent.id}" bigger, or leave out its "size" so it fits its contents`,!1,"warning")}}{let k=u.filter(E=>!E.placedBy);for(let E=0;E<k.length;E++)for(let S=E+1;S<k.length;S++){let F=k[E],D=k[S];ci(F.box,D.box)&&!li(F,r)&&!li(D,r)&&l(D.path,`"${D.id}" overlaps "${F.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let $=new Set,P=a.filter(k=>{let E=k.path+k.message;return $.has(E)?!1:($.add(E),!0)});return{items:c,byId:f,roots:u,diags:P,catalog:r}}var li=(n,e)=>n.type==="region"&&["zone","tunnel"].includes(pt(e,n.region.kind)?.shape??"");function Vr(n,e,t,s){let r=n.region.gate,o=n.box,i=n.box.z0,a=r.at??.5,l=r.width??2;if(r.side==="w"||r.side==="e"){let u=r.side==="w"?o.x0+zn/2:o.x1-zn/2,d=o.y0+(o.y1-o.y0)*a;return{x0:u-t/2,x1:u+t/2,y0:d-l/2,y1:d+l/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+zn/2:o.y1-zn/2,f=o.x0+(o.x1-o.x0)*a;return{x0:f-l/2,x1:f+l/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function ci(n,e,t=1e-6){return n.x0<e.x1-t&&e.x0<n.x1-t&&n.y0<e.y1-t&&e.y0<n.y1-t}function zr(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}var Xn=.2,ui=.05,Wd=.6,di=.25,mi={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function Qt(n){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(n);return{id:e[1],side:e[2]}}var pf=new WeakMap;function Hs(n,e,t){let s=pf.get(n);if(!s){s=[];for(let i of n.items){if(i.type!=="region"||!pt(n.catalog,i.region.kind)?.floor)continue;let a=0;for(let l=i.parent;l;l=l.parent)a++;s.push({r:i,d:a})}pf.set(n,s)}let r=0,o=-1;for(let{r:i,d:a}of s){let l=i.box,c=1e-6;e>=l.x0-c&&e<=l.x1+c&&t>=l.y0-c&&t<=l.y1+c&&a>o&&(o=a,r=i.floor)}return r}function Jd(n,e){let t=[(n.x0+n.x1)/2,(n.y0+n.y1)/2],s=[(e.x0+e.x1)/2,(e.y0+e.y1)/2],r=s[0]-t[0],o=s[1]-t[1],i=Math.max(e.x0-n.x1,n.x0-e.x1),a=Math.max(e.y0-n.y1,n.y0-e.y1);return i>0&&(a<=0||i>=a)?r>0?"e":"w":a>0?o>0?"s":"n":Math.abs(r)>=Math.abs(o)?r>0?"e":"w":o>0?"s":"n"}var hi=5e5;function gi(n,e,t,s,r,o){let i=[],a=(b,x,A,M="error")=>{let v=s.locate(b);i.push({severity:M,message:x,line:v.line,col:v.col,path:b,hint:A})},l=n.routes??[],c={left:hi},f=0,u=()=>t.items.map(b=>b.id),d=new Map,p=[],g=[];l.forEach((b,x)=>{let A=`${e}/routes/${x}`;(d.has(b.id)||t.byId.has(b.id))&&a(A+"/id",`duplicate id "${b.id}"`),d.set(b.id,x);let M=b.kind??"send";r.has(M)||a(A+"/kind",`unknown flow kind "${M}"`+Xa(M,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let v={id:b.id,raw:b,path:A,kind:M,points:[]},O=(C,$)=>{let{id:P}=Qt(C),k=t.byId.get(P);if(!k){a(`${A}/${$}`,`unknown node "${P}"`+Xa(P,u()));return}return k};v.from=O(b.from,"from"),v.to=O(b.to,"to"),p.push(v),g.push({r:v})});let m=new Map;for(let b of g){let{r:x}=b;if(!x.from||!x.to||x.raw.points)continue;let A=Qt(x.raw.from).side,M=Qt(x.raw.to).side,v=x.raw.via?.[0],O=x.raw.via?.[x.raw.via.length-1],C=(E,S)=>{if(Array.isArray(E))return{x0:E[0],x1:E[0],y0:E[1],y1:E[1],z0:0,z1:0};if(typeof E=="string"){let F=t.byId.get(Qt(E).id);if(F)return F.box}return S.box},$=(E,S,F)=>{let D=S??Jd(E.box,F);return{node:E,side:D,explicit:!!S,p:[0,0],z:0}};b.a=$(x.from,A,C(v,x.to)),b.b=$(x.to,M,C(O,x.from));let P=C(v,x.to),k=C(O,x.from);for(let[E,S]of[[b.a,P],[b.b,k]]){let F=`${E.node.id}.${E.side}`;m.has(F)||m.set(F,[]),m.get(F).push({e:E,other:[(S.x0+S.x1)/2,(S.y0+S.y1)/2]})}}for(let[,b]of m){let x=b[0].e,A=x.node.box,M=x.side,v=M==="e"||M==="w"?1:0;b.sort((E,S)=>E.other[v]-S.other[v]);let O=v?A.y0:A.x0,C=v?A.y1:A.x1,$=(O+C)/2,P=Math.max(0,C-O-.3),k=b.length>1?Math.min(Wd,P/(b.length-1)):0;b.forEach((E,S)=>{let F=(S-(b.length-1)/2)*k,D=$+F,H=E.e.node.box.z0;if(M==="top"){E.e.p=[(A.x0+A.x1)/2,(A.y0+A.y1)/2],E.e.z=A.z1;return}let[X,Y]=mi[M];E.e.p=v?[X>0?A.x1+ui:A.x0-ui,D]:[D,Y>0?A.y1+ui:A.y0-ui],E.e.z=H})}let y=[];for(let b of t.items)b.type==="node"&&y.push(b.box);let N=[];for(let b of t.items.filter(x=>pt(t.catalog,x.region?.kind)?.shape==="walled")){let{x0:x,y0:A,x1:M,y1:v}=b.box,O=zn,C=b.region.gate,$=[[{x0:x,y0:A,x1:M,y1:A+O,z0:0,z1:0},"n"],[{x0:x,y0:v-O,x1:M,y1:v,z0:0,z1:0},"s"],[{x0:x,y0:A,x1:x+O,y1:v,z0:0,z1:0},"w"],[{x0:M-O,y0:A,x1:M,y1:v,z0:0,z1:0},"e"]];for(let[P,k]of $)if(C&&C.side===k){if(C.node)continue;let E=C.at??.5,S=C.width??2;if(k==="e"||k==="w"){let F=A+(v-A)*E;N.push({...P,y1:F-S/2},{...P,y0:F+S/2})}else{let F=x+(M-x)*E;N.push({...P,x1:F-S/2},{...P,x0:F+S/2})}}else N.push(P)}let h=new Map;for(let b of g){let{r:x,a:A,b:M}=b;if(x.raw.points){x.points=x.raw.points.map(D=>[D[0],D[1],D.length>2?D[2]:Hs(t,D[0],D[1])+.01]);continue}if(!A||!M)continue;let v=[];(x.raw.via??[]).forEach((D,H)=>{if(Array.isArray(D))if(o){let X=Y=>Math.round(Math.round(Y/o)*o*1e9)/1e9;D.forEach((Y,L)=>{Math.abs(Y/o-Math.round(Y/o))>1e-6&&a(`${x.path}/via/${H}/${L}`,`${Y} is not on the ${o} grid; it is drawn at ${X(Y)}`,void 0,"warning")}),v.push({p:[X(D[0]),X(D[1])]})}else v.push({p:[D[0],D[1]]});else{let{id:X,side:Y}=Qt(D),L=t.byId.get(X);if(!L){a(`${x.path}/via/${H}`,`unknown node "${X}"`+Xa(X,u()));return}let q=Y&&Y!=="top"?Y:"n",[U,Z]=mi[q],I=L.box;v.push({p:[U?U>0?I.x1+.4:I.x0-.4:(I.x0+I.x1)/2,Z?Z>0?I.y1+.4:I.y0-.4:(I.y0+I.y1)/2]})}});let C=y.filter(D=>D!==A.node.box&&D!==M.node.box).concat(x.raw.cross?[]:N).filter(D=>!pi(A.node.box,D)&&!pi(M.node.box,D)&&!pi(D,A.node.box)&&!pi(D,M.node.box)),$=A.side==="top"?void 0:mi[A.side],P=M.side==="top"?void 0:mi[M.side],k=[A.p,...v.map(D=>D.p),M.p],E=[A.p],S=$,F=!0;for(let D=0;D+1<k.length;D++){let H=D+2===k.length,X=Qd(k[D],k[D+1],C,h,S,H&&P?[-P[0],-P[1]]:void 0,c);if(!X){F=!1;break}E.push(...X.slice(1));let Y=E.length;if(Y>=2){let L=Math.sign(E[Y-1][0]-E[Y-2][0]),q=Math.sign(E[Y-1][1]-E[Y-2][1]);S=[L,q]}}!F&&c.left<=0?(f++,E=[A.p,[M.p[0],A.p[1]],M.p]):F||(a(x.path,`no path found for route "${x.id}" from "${A.node.id}" to "${M.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),E=[A.p,[M.p[0],A.p[1]],M.p]),E=Kr(E);for(let D=0;D+1<E.length;D++)Xd(h,E[D],E[D+1]);x.points=tm(t,E,A,M)}return f&&a(e,`${f} of ${p.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${hi.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:p,diags:i}}function pi(n,e){return e.x0>=n.x0-1e-6&&e.x1<=n.x1+1e-6&&e.y0>=n.y0-1e-6&&e.y1<=n.y1+1e-6&&e.z0>=n.z1-1e-6}var hf=(n,e)=>`${Math.round(n/Xn)},${Math.round(e/Xn)}`;function Xd(n,e,t){let s=Math.max(1,Math.round(Math.hypot(t[0]-e[0],t[1]-e[1])/Xn));for(let r=0;r<=s;r++){let o=hf(e[0]+(t[0]-e[0])*r/s,e[1]+(t[1]-e[1])*r/s);n.set(o,(n.get(o)??0)+1)}}function gf(n,e,t){for(let s of t)if(n>s.x0-di&&n<s.x1+di&&e>s.y0-di&&e<s.y1+di)return!0;return!1}function Qd(n,e,t,s,r,o,i={left:1/0}){if((Math.abs(n[0]-e[0])<1e-6||Math.abs(n[1]-e[1])<1e-6)&&em(n,e,t)){let L=[Math.sign(e[0]-n[0]),Math.sign(e[1]-n[1])],q=!r||r[0]===L[0]&&r[1]===L[1],U=!o||o[0]===L[0]&&o[1]===L[1];if(q&&U)return[n,e]}if(i.left<=0)return null;let a=L=>Math.round((L-n[0])/Xn),l=L=>Math.round((L-n[1])/Xn),c=L=>n[0]+L*Xn,f=L=>n[1]+L*Xn,u=a(e[0]),d=l(e[1]),p=30,g=Math.min(0,u)-p,m=Math.max(0,u)+p,y=Math.min(0,d)-p,N=Math.max(0,d)+p,h=1.2,b=Xn,x=.06,A=[[1,0],[-1,0],[0,1],[0,-1]],M=m-g+1,v=N-y+1,O=(L,q)=>(L-g)*v+(q-y),C=new Int8Array(M*v).fill(-1),$=new Float64Array(M*v).fill(-1),P=new Float64Array(M*v*4).fill(1/0),k=(L,q)=>{let U=O(L,q);return C[U]<0&&(C[U]=gf(c(L),f(q),t)?1:0),C[U]===1},E=(L,q)=>{let U=O(L,q);return $[U]<0&&($[U]=s.get(hf(c(L),f(q)))??0),$[U]},S=Qa(),F=(L,q)=>(Math.abs(L-u)+Math.abs(q-d))*b,D=r?A.findIndex(L=>L[0]===r[0]&&L[1]===r[1]):-1;S.push({i:0,j:0,d:D,g:0,f:F(0,0),idx:0,hp:0});let H=(L,q)=>Math.abs(L)+Math.abs(q)<=2,X=(L,q)=>Math.abs(L-u)+Math.abs(q-d)<=2,Y=0;for(;S.length()&&Y++<2e5;){if(i.left--<=0)return null;let L=S.take();if(L.i===u&&L.j===d&&!(o&&L.d>=0&&(A[L.d][0]!==o[0]||A[L.d][1]!==o[1]))){let q=[];for(let U=L;U;U=U.prev)q.push([c(U.i),f(U.j)]);return q.reverse(),q[0]=n,Zd(Kr(q),e)}for(let q=0;q<4;q++){let U=A[q];if(L.d>=0&&U[0]===-A[L.d][0]&&U[1]===-A[L.d][1])continue;let Z=L.i+U[0],I=L.j+U[1];if(Z<g||Z>m||I<y||I>N||!H(Z,I)&&!X(Z,I)&&k(Z,I))continue;if((H(Z,I)||X(Z,I))&&k(Z,I)&&!(Z===u&&I===d)){let de=H(Z,I)?r:o&&[-o[0],-o[1]];if(!de||(H(Z,I)?U[0]!==de[0]||U[1]!==de[1]:U[0]!==o[0]||U[1]!==o[1]))continue}let _=L.d>=0&&L.d!==q?h:0,K=L.g+b+_+E(Z,I)*x,J=O(Z,I)*4+q;P[J]<=K||(P[J]=K,S.push({i:Z,j:I,d:q,g:K,f:K+F(Z,I),prev:L,idx:0,hp:0}))}}return null}function Qa(){let n=[],e=[],t=(i,a)=>i.f<a.f||i.f===a.f&&i.idx<a.idx,s=(i,a)=>{let l=e[i];e[i]=e[a],e[a]=l,e[i].hp=i,e[a].hp=a},r=i=>{for(;i>0;){let a=i-1>>1;if(!t(e[i],e[a]))break;s(i,a),i=a}},o=i=>{for(;;){let a=2*i+1,l=a+1,c=i;if(a<e.length&&t(e[a],e[c])&&(c=a),l<e.length&&t(e[l],e[c])&&(c=l),c===i)return;s(i,c),i=c}};return{length:()=>n.length,push(i){i.idx=n.length,n.push(i),i.hp=e.length,e.push(i),r(i.hp)},take(){let i=e[0],a=e.pop();e.length&&(e[0]=a,a.hp=0,o(0));let l=n.pop();return l!==i&&(n[i.idx]=l,l.idx=i.idx,r(l.hp)),i}}}function Zd(n,e){let t=n.map(o=>[o[0],o[1]]),s=t.length,r=t[s-1];if(s>=2){let o=t[s-2];Math.abs(o[1]-r[1])<1e-9?(o[1]=e[1],s>=3&&Math.abs(t[s-3][1]-r[1])<1e-9&&(t[s-3][1]=e[1])):Math.abs(o[0]-r[0])<1e-9&&(o[0]=e[0],s>=3&&Math.abs(t[s-3][0]-r[0])<1e-9&&(t[s-3][0]=e[0]))}return t[s-1]=e,Kr(t)}function em(n,e,t){let s=Math.max(1,Math.round(Math.hypot(e[0]-n[0],e[1]-n[1])/(Xn/2)));for(let r=2;r<s-1;r++)if(gf(n[0]+(e[0]-n[0])*r/s,n[1]+(e[1]-n[1])*r/s,t))return!1;return!0}function Kr(n){let e=[];for(let t of n){let s=e.length;if(!(s&&Math.abs(e[s-1][0]-t[0])<1e-6&&Math.abs(e[s-1][1]-t[1])<1e-6)){if(s>=2){let r=e[s-2],o=e[s-1];if(Math.abs(r[0]-o[0])<1e-6&&Math.abs(o[0]-t[0])<1e-6||Math.abs(r[1]-o[1])<1e-6&&Math.abs(o[1]-t[1])<1e-6){e[s-1]=t;continue}}e.push(t)}}return e}function tm(n,e,t,s){let r=new Set,o=new Set;for(let c of n.items)c.type!=="region"||!pt(n.catalog,c.region.kind)?.floor||(r.add(c.box.x0),r.add(c.box.x1),o.add(c.box.y0),o.add(c.box.y1));let i=[],a=(c,f)=>Hs(n,c,f)+.01;for(let c=0;c+1<e.length;c++){let[f,u]=e[c],[d,p]=e[c+1],g=[0,1];if(Math.abs(u-p)<1e-6)for(let m of r){let y=(m-f)/(d-f);y>1e-6&&y<1-1e-6&&g.push(y)}else for(let m of o){let y=(m-u)/(p-u);y>1e-6&&y<1-1e-6&&g.push(y)}g.sort((m,y)=>m-y);for(let m=0;m+1<g.length;m++){let y=g[m],N=g[m+1],h=(y+N)/2,b=a(f+(d-f)*h,u+(p-u)*h),x=[f+(d-f)*y,u+(p-u)*y,b],A=[f+(d-f)*N,u+(p-u)*N,b],M=i[i.length-1];M&&(Math.abs(M[0]-x[0])>1e-6||Math.abs(M[1]-x[1])>1e-6||Math.abs(M[2]-x[2])>1e-6)?i.push(x):M||i.push(x),i.push(A)}}i.length&&(i[0][2]=t.side==="top"?t.z:t.node.box.z0+.01,i[i.length-1][2]=s.side==="top"?s.z:s.node.box.z0+.01);let l=[];for(let c of i){let f=l.length;if(f>=2){let u=l[f-2],d=l[f-1],p=Math.abs(u[2]-d[2])<1e-9&&Math.abs(d[2]-c[2])<1e-9,g=Math.abs(u[0]-d[0])<1e-6&&Math.abs(d[0]-c[0])<1e-6||Math.abs(u[1]-d[1])<1e-6&&Math.abs(d[1]-c[1])<1e-6;if(p&&g){l[f-1]=c;continue}}l.push(c)}return l}function Xa(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}function Rt(n){return[Ce(n.x0,n.y0,n.z1),Ce(n.x1,n.y0,n.z1),Ce(n.x1,n.y0,n.z0),Ce(n.x1,n.y1,n.z0),Ce(n.x0,n.y1,n.z0),Ce(n.x0,n.y1,n.z1)]}function Mn(n){let e=n.map(o=>o[0]),t=n.map(o=>o[1]),s=Math.min(...e),r=Math.min(...t);return{x:s,y:r,w:Math.max(...e)-s,h:Math.max(...t)-r}}function Js(n,e){let t=n,s=(a,l)=>{let c=[];for(let f=0;f<t.length;f++){let u=t[f],d=t[(f+1)%t.length],p=a(u),g=a(d);p&&c.push(u),p!==g&&c.push(l(u,d))}t=c},r=a=>(l,c)=>[a,l[1]+(c[1]-l[1])*(a-l[0])/(c[0]-l[0])],o=a=>(l,c)=>[l[0]+(c[0]-l[0])*(a-l[1])/(c[1]-l[1]),a];if(s(a=>a[0]>=e.x,r(e.x)),!t.length||(s(a=>a[0]<=e.x+e.w,r(e.x+e.w)),!t.length)||(s(a=>a[1]>=e.y,o(e.y)),!t.length)||(s(a=>a[1]<=e.y+e.h,o(e.y+e.h)),!t.length))return 0;let i=0;for(let a=0;a<t.length;a++){let l=t[a],c=t[(a+1)%t.length];i+=l[0]*c[1]-c[0]*l[1]}return Math.abs(i)/2}function tl(n,e){let t=Math.min(n.x+n.w,e.x+e.w)-Math.max(n.x,e.x),s=Math.min(n.y+n.h,e.y+e.h)-Math.max(n.y,e.y);return t>0&&s>0?t*s:0}function xf(n,e){let t=0;for(let s=0;s+1<n.length;s++){let r=n[s],o=n[s+1],i=Math.hypot(o[0]-r[0],o[1]-r[1]),a=Math.max(1,Math.ceil(i/4));for(let l=0;l<a;l++){let c=r[0]+(o[0]-r[0])*(l+.5)/a,f=r[1]+(o[1]-r[1])*(l+.5)/a;c>=e.x&&c<=e.x+e.w&&f>=e.y&&f<=e.y+e.h&&(t+=i/a*4)}}return t}var Qn=64,yi=class{cells=new Map;n=0;add(e,t,s,r,o){for(let i=Math.floor(t/Qn);i<=Math.floor(r/Qn);i++)for(let a=Math.floor(s/Qn);a<=Math.floor(o/Qn);a++){let l=i*1048576+a,c=this.cells.get(l);c||this.cells.set(l,c=[]),c[c.length-1]!==e&&c.push(e)}}query(e,t,s,r){let o=new Set;for(let i=Math.floor(e/Qn);i<=Math.floor(s/Qn);i++)for(let a=Math.floor(t/Qn);a<=Math.floor(r/Qn);a++){let l=this.cells.get(i*1048576+a);if(l)for(let c of l)o.add(c)}return[...o].sort((i,a)=>i-a)}},Za=n=>{let e=1/0,t=1/0,s=-1/0,r=-1/0;for(let[o,i]of n)o<e&&(e=o),o>s&&(s=o),i<t&&(t=i),i>r&&(r=i);return[e,t,s,r]},xi=new WeakMap;function cs(n,e){let t=xi.get(n);for((!t||t.n>n.length)&&xi.set(n,t=new yi);t.n<n.length;t.n++){let[s,r,o,i]=e(n[t.n]);t.add(t.n,s,r,o,i)}return t}function bf(n){let e=xi.get(n);for((!e||e.n>n.length)&&xi.set(n,e=new yi);e.n<n.length;e.n++){let t=n[e.n].pts;for(let s=0;s+1<t.length;s++){let r=t[s],o=t[s+1],i=e.n*65536+s,a=Math.max(1,Math.ceil(Math.hypot(o[0]-r[0],o[1]-r[1])/(Qn/2)));for(let l=0;l<a;l++){let c=l/a,f=(l+1)/a,u=r[0]+(o[0]-r[0])*c,d=r[1]+(o[1]-r[1])*c,p=r[0]+(o[0]-r[0])*f,g=r[1]+(o[1]-r[1])*f;e.add(i,Math.min(u,p)-1,Math.min(d,g)-1,Math.max(u,p)+1,Math.max(d,g)+1)}}}return e}var Vn=(n,e,t,s,r)=>n.query(e,t,s,r),Ws=n=>Za(n),bi=n=>[n.x,n.y,n.x+n.w,n.y+n.h];function yf(n,e,t,[s,r,o,i]){let a=0,l=t-1;for(let c of[0,1]){let f=e[c]-n[c],u=c?r:s,d=c?i:o;if(Math.abs(f)<1e-12){if(n[c]<u||n[c]>d)return[1,0];continue}let p=(u-n[c])/f*t-.5,g=(d-n[c])/f*t-.5;p>g&&([p,g]=[g,p]),a=Math.max(a,Math.floor(p)-1),l=Math.min(l,Math.ceil(g)+1)}return[a,l]}var Es=class n{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let t=0;for(let s of Vn(cs(this.solids,Ws),...bi(e)))t+=Js(this.solids[s],e);return t}hiddenPoly(e){let t=0;for(let s of Vn(cs(this.solids,Ws),...Za(e)))t+=Gr(e,this.solids[s]);return t}costPoly(e,t=1/0){let s=Za(e),r=0;for(let o of Vn(cs(this.polys,i=>Ws(i.poly)),...s))r+=Gr(e,this.polys[o].poly);for(let o of Vn(cs(this.rects,i=>bi(i.r)),...s))r+=Js(e,this.rects[o].r)*2;for(let o of Vn(cs(this.slants,Ws),...s))r+=Gr(e,this.slants[o])*2;if(r>=t)return r;for(let o of Vn(bf(this.lines),...s)){if(r>=t)return r;let i=this.lines[Math.floor(o/65536)].pts,a=o%65536,l=i[a],c=i[a+1],f=Math.hypot(c[0]-l[0],c[1]-l[1]),u=Math.max(1,Math.ceil(f/4)),[d,p]=yf(l,c,u,s);for(let g=d;g<=p;g++)sl(e,[l[0]+(c[0]-l[0])*(g+.5)/u,l[1]+(c[1]-l[1])*(g+.5)/u])&&(r+=f/u*4*.6)}return r}cost(e,t,s=.6){let r=bi(e),o=0;for(let i of Vn(cs(this.polys,a=>Ws(a.poly)),...r)){let a=this.polys[i];o+=Js(a.poly,e)*(a.owner===t?1.5:1)}for(let i of Vn(cs(this.rects,a=>bi(a.r)),...r)){let a=this.rects[i];(a.owner!==t||!t)&&(o+=tl(a.r,e)*2)}for(let i of Vn(cs(this.slants,Ws),...r))o+=Js(this.slants[i],e)*2;if(s){let i=-1,a=0;for(let l of Vn(bf(this.lines),...r)){let c=Math.floor(l/65536);c!==i&&(i>=0&&(o+=a*s),i=c,a=0);let f=this.lines[c].pts,u=l%65536,d=f[u],p=f[u+1],g=Math.hypot(p[0]-d[0],p[1]-d[1]),m=Math.max(1,Math.ceil(g/4)),[y,N]=yf(d,p,m,r);for(let h=y;h<=N;h++){let b=d[0]+(p[0]-d[0])*(h+.5)/m,x=d[1]+(p[1]-d[1])*(h+.5)/m;b>=e.x&&b<=e.x+e.w&&x>=e.y&&x<=e.y+e.h&&(a+=g/m*4)}}i>=0&&(o+=a*s)}return o}fork(){let e=new n;return e.budget=this.budget,e.polys=this.polys,e.lines=this.lines,e.solids=this.solids,e.rects=[...this.rects],e.slants=this.slants,e}},wf=14;function qr(n,e,t,s){let r=Math.max(n.name?sn(n.name,lt.lbl):0,n.sub?sn(n.sub,lt.sub):0)+4,o=(n.name?1:0)+(n.sub?1:0),i=t-(n.name?11:9)-1,a=(o-1)*wf+(n.name?11:9)+4;return{x:s==="start"?e-2:s==="end"?e-r+2:e-r/2,y:i,w:r,h:a}}function Ur(n,e,t,s,r,o){let i=Mn(t),a=Ce((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((n.name?1:0)+(n.sub?1:0)-1)*wf+4,f=i.y-6-c,u=i.y+Math.min(i.h,60)*.45,d=[];o&&d.push({...o,pen:0}),d.push({x:a,y:f,anchor:"middle",pen:o?20:0});for(let m of[12,24,40])d.push({x:a,y:f-m,anchor:"middle",pen:20+m});for(let m of[-30,30,-60,60])d.push({x:a+m,y:f-4,anchor:"middle",pen:30+Math.abs(m)});d.push({x:i.x+i.w+8,y:u,anchor:"start",pen:120}),d.push({x:i.x-8,y:u,anchor:"end",pen:120}),d.push({x:a,y:i.y+i.h+14,anchor:"middle",pen:300});let p,g=1/0;for(let m of d){let y=qr(n,m.x,m.y,m.anchor),N=s.cost(y,r,.15)*2+m.pen;N<g&&(g=N,p={x:m.x,y:m.y,anchor:m.anchor,rect:y})}return p}function nl(n,e,t,s){return{x:(s==="start"?e:s==="end"?e-n:e-n/2)-2,y:t-14,w:n+4,h:28}}function wi(n,e,t,s,r){let o=[{...s,pen:0}];for(let f of[-46,-66,-86,-106,-126,-146])for(let u of[0,-70,70,-140,140])o.push({x:e+u,y:t+f,anchor:"middle",pen:10+(-f-46)*.5+Math.abs(u)*.4});for(let f of[34,60,86])o.push({x:e,y:t+f,anchor:"middle",pen:60+f*.3});let i=s.x-e,a=s.y-t;for(let f of[-1,1])for(let u of[16,32,48])o.push({...s,y:t+a+f*u,x:e+i,pen:5+u});for(let f of[-1,1])for(let u of[30,60,90])for(let d of[0,16,-16])o.push({...s,x:e+i+f*u,y:t+a+d,pen:8+u*.6+Math.abs(d)});let l,c=1/0;for(let f of o){let u=nl(n,f.x,f.y,f.anchor),d=r.cost(u,void 0,.05)*3+f.pen;d<c&&(c=d,l={x:f.x,y:f.y,anchor:f.anchor,rect:u})}return l}var kf=n=>{let e=0;for(let t=0;t<n.length;t++){let s=n[t],r=n[(t+1)%n.length];e+=s[0]*r[1]-r[0]*s[1]}return e/2},el=n=>kf(n)<0?[...n].reverse():n;function sl(n,e){let t=el(n);for(let s=0;s<t.length;s++){let r=t[s],o=t[(s+1)%t.length];if((o[0]-r[0])*(e[1]-r[1])-(o[1]-r[1])*(e[0]-r[0])<0)return!1}return!0}function Gr(n,e){let t=el(n),s=el(e);for(let r=0;r<s.length&&t.length;r++){let o=s[r],i=s[(r+1)%s.length],a=c=>(i[0]-o[0])*(c[1]-o[1])-(i[1]-o[1])*(c[0]-o[0]),l=t;t=[];for(let c=0;c<l.length;c++){let f=l[c],u=l[(c+1)%l.length],d=a(f),p=a(u);if(d>=0&&t.push(f),d>=0!=p>=0){let g=d/(d-p);t.push([f[0]+(u[0]-f[0])*g,f[1]+(u[1]-f[1])*g])}}}return t.length>=3?Math.abs(kf(t)):0}var ki=24;function Xs(n,e){let[t,s,r,o]=e,i=n.x+n.w/2,a=n.y+n.h/2,l=[["left",i-t],["right",t+r-i],["top",a-s],["bottom",s+o-a]];l.sort((f,u)=>f[1]-u[1]);let c=l[0][0];return c==="left"?{edge:c,dx:-(n.x+n.w-t)-ki,dy:0}:c==="right"?{edge:c,dx:t+r-n.x+ki,dy:0}:c==="top"?{edge:c,dx:0,dy:-(n.y+n.h-s)-ki}:{edge:c,dx:0,dy:s+o-n.y+ki}}function Si(n,e,t){let s=x=>{let A=0;for(let M=x.parent;M;M=M.parent)A++;return A},r=x=>x.box.x0+x.box.y0+x.box.z0*.01,o=n.items.filter(x=>x.type==="region").sort((x,A)=>s(x)-s(A)||r(x)-r(A)),i=n.items.filter(x=>x.type==="node").sort((x,A)=>r(x)-r(A)||x.box.z0-A.box.z0),a=[],l=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach((x,A)=>{let M=Mn(Rt(x.box));a.push({id:x.id,kind:"region",...Xs(M,t),delay:Math.round(A*l),dur:c,bbox:M})});let f=250+Math.round(l*o.length),u=Math.min(70,700/Math.max(1,i.length)),d=600;i.forEach((x,A)=>{let M=Mn(Rt(x.box));a.push({id:x.id,kind:"node",...Xs(M,t),delay:Math.round(f+A*u),dur:d,bbox:M})});let p=i.length?f+(i.length-1)*u:f,g=Math.round(p+300),m=Math.min(30,300/Math.max(1,e.length)),y=400,N=e.filter(x=>x.points.length>=2).map((x,A)=>({id:x.id,delay:Math.round(g+A*m),dur:y})),h={delay:g+200,dur:400},b=Math.max(...a.map(x=>x.delay+x.dur),...N.map(x=>x.delay+x.dur),h.delay+h.dur);return{pieces:a,routes:N,labels:h,total:b}}var Yr=["edge","drop","rise","fly","pop","scatter","build","fade"],Hr=["explode","lift-off","sink","scatter","fly-out","collapse","fade","reverse"],Qs=["by-depth","by-layer","by-region","by-flow","as-listed","random"],Ef=["linear","ease","ease-in","ease-out","settle","spring","bounce"],an=n=>Math.round(n*100)/100||0,Vt=n=>Math.round(n*1e4)/1e4||0;function fs(n){let e=r=>{let o=0;for(let i=r.parent;i;i=i.parent)o++;return o},t=r=>{let o=[];for(let i=r;i;i=i.parent){let a=(i.region??i.node)?.motion;a&&o.unshift(a)}return o.length?Object.assign({},...o):void 0},s=new Set(n.layout.items.filter(r=>r.region&&n.layout.catalog&&n.rendered.svg.includes(`class="tunnel" data-id="${r.id}"`)).map(r=>r.id));return{viewBox:n.rendered.viewBox,pieces:n.layout.items.map(r=>{let o=r.box,i=Ce((o.x0+o.x1)/2,(o.y0+o.y1)/2,o.z0),a=t(r);return{id:r.id,kind:r.type,...r.parent?{parent:r.parent.id}:{},depth:e(r),layer:s.has(r.id)?2:r.type==="region"?0:1,key:an(o.x0+o.y0+o.z0*.01),bbox:Mn(Rt(o)),foot:[an(i[0]),an(i[1])],base:[Ce(o.x0,o.y1,o.z0),Ce(o.x1,o.y1,o.z0),Ce(o.x1,o.y0,o.z0)].map(l=>[an(l[0]),an(l[1])]),...a?{motion:a}:{}}}),routes:n.routes.filter(r=>n.rendered.paths[r.id]).map(r=>({id:r.id,path:n.rendered.paths[r.id],...nm(r.raw)})),notes:Object.fromEntries((n.raw.notes??[]).map((r,o)=>[`${n.id}-note-${o}`,r.on])),intro:n.rendered.assembly}}var Sf=n=>typeof n=="string"?n.split(".")[0]:void 0,nm=n=>{let e=Sf(n.from),t=Sf(n.to);return{...e?{from:e}:{},...t?{to:t}:{}}},vi=(n,e,t,s)=>r=>{if(r<=0)return 0;if(r>=1)return 1;let o=(l,c,f)=>3*l*f*(1-f)**2+3*c*f*f*(1-f)+f**3,i=0,a=1;for(let l=0;l<40;l++){let c=(i+a)/2;o(n,t,c)<r?i=c:a=c}return o(e,s,(i+a)/2)},rl={linear:n=>n,ease:vi(.42,0,.58,1),"ease-in":vi(.42,0,1,1),"ease-out":vi(0,0,.58,1),settle:vi(.16,.84,.3,1),spring:n=>n<=0?0:n>=1?1:1-Math.exp(-6*n)*Math.cos(9.5*n)*(1-n),bounce:n=>{if(n<=0)return 0;if(n>=1)return 1;let e=7.5625,t=2.75;return n<1/t?e*n*n:n<2/t?e*(n-1.5/t)**2+.75:n<2.5/t?e*(n-2.25/t)**2+.9375:e*(n-2.625/t)**2+.984375}};function al(n){let e=n>>>0;return()=>{e=e+1831565813>>>0;let t=e;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}}var vf=n=>{let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0},En=n=>Math.max(0,Math.min(1,n)),$i=24;function ol(n,e,t){let[s,r,o,i]=e;return t==="left"?[-(n.x+n.w-s)-$i,0]:t==="right"?[s+o-n.x+$i,0]:t==="top"?[0,-(n.y+n.h-r)-$i]:[0,r+i-n.y+$i]}function cl(n,e,t={}){let s=n.pieces,r=new Map(s.map(m=>[m.id,m])),o=(m,y)=>m.depth-y.depth||m.key-y.key;if(e==="as-listed")return[...s];if(e==="random"){let m=al(t.seed??1);return s.map(y=>[m(),y]).sort((y,N)=>y[0]-N[0]).map(y=>y[1])}if(e==="by-layer")return[...s].sort((m,y)=>m.layer-y.layer||o(m,y));if(e==="by-depth")return[...s].sort((m,y)=>m.key-y.key||m.depth-y.depth);let i=new Map;for(let m of[...s].sort(o)){let y=i.get(m.parent)??[];y.push(m),i.set(m.parent,y)}let a=[],l=new Set,c=m=>{if(l.has(m.id))return;let y=m.parent?r.get(m.parent):void 0;y&&c(y),l.add(m.id),a.push(m)};if(e==="by-region"){let m=y=>{for(let N of i.get(y)??[])c(N),m(N.id)};return m(),a}let f=new Map,u=new Set;for(let m of n.routes)m.from&&m.to&&(f.set(m.from,[...f.get(m.from)??[],m.to]),u.add(m.to));let d=t.source??n.routes.find(m=>m.from&&!u.has(m.from))?.from??n.routes[0]?.from,p=d?[d]:[],g=new Set(p);for(;p.length;){let m=p.shift(),y=r.get(m);y&&c(y);for(let N of f.get(m)??[])g.has(N)||(g.add(N),p.push(N))}for(let m of[...s].sort(o))c(m);return a}var sm={edge:"settle",drop:"settle",rise:"ease-out",fly:"settle",pop:"spring",scatter:"settle",build:"ease-out",fade:"linear",explode:"ease-in","lift-off":"ease-in",sink:"ease-in","fly-out":"ease-in",collapse:"ease-in"},rm={"lift-off":"lift",sink:"rise",scatter:"scatter","fly-out":"edge",fade:"fade",explode:"explode",collapse:"collapse"};function Zs(n,e,t={}){let s=t.seed??1,r=e==="disassemble",o=r&&t.style==="reverse",i=Y=>{if(!r)return Y.motion?.style??t.style??"edge";let L=Y.motion?.out??t.style??"fly-out";return L==="reverse"?Y.motion?.style??t.of??"edge":rm[L]},a=Y=>r?Y.motion?.out??t.style??"fly-out":i(Y),l=!r&&!t.order&&t.stagger===void 0&&t.piece===void 0&&t.overlap===void 0&&(t.style??"edge")==="edge",c=t.order??(t.style==="build"?"by-layer":"by-depth"),f=[],u,d,p=(Y,L,q)=>{let U=i(Y),Z=Y.motion?.easing??t.easing??sm[r&&a(Y)!=="reverse"?a(Y):U]??"ease";return{p:Y,delay:L+(Y.motion?.delay??0),dur:Math.max(1,Y.motion?.duration??q),style:U,curve:rl[Z],from:Y.motion?.from??t.from??"left"}};if(l){let Y=new Map(n.pieces.map(L=>[L.id,L]));for(let L of n.intro.pieces){let q=Y.get(L.id);q&&f.push(p(q,L.delay,L.dur))}u=n.intro.routes.map(L=>({...L})),d={...n.intro.labels}}else{let Y=cl(n,c,{seed:s,source:t.source}),L=t.piece??600,q=t.stagger??Math.min(70,900/Math.max(1,Y.length)),U=En(t.overlap??.5),Z=o||r?[...Y].reverse():Y,I=Math.min(30,300/Math.max(1,n.routes.length)),_=400,K=400;if(r){d={delay:0,dur:K};let J=K*(1-U);u=[...n.routes].reverse().map((W,ne)=>({id:W.id,delay:J+ne*I,dur:_}));let de=Math.max(J,...u.map(W=>W.delay+W.dur)),ce=Math.max(0,de-U*_);Z.forEach((W,ne)=>f.push(p(W,ce+ne*q,L)))}else{Z.forEach((W,ne)=>f.push(p(W,ne*q,L)));let J=Math.max(0,...f.map(W=>W.delay+W.dur)),de=Math.max(0,J-U*L);u=n.routes.map((W,ne)=>({id:W.id,delay:de+ne*I,dur:_}));let ce=Math.max(de,...u.map(W=>W.delay+W.dur));d={delay:Math.max(0,ce-U*K),dur:K}}}let g=t.pulses&&n.routes.length?700:0;if(g&&r)for(let Y of[...f,...u,d])Y.delay+=g;let m=Math.max(1,...f.map(Y=>Y.delay+Y.dur),...u.map(Y=>Y.delay+Y.dur),d.delay+d.dur),y=r?0:m;g&&!r&&(m+=g);let N=t.duration!==void 0?Math.max(1,t.duration)/m:1;for(let Y of[...f,...u,d])Y.delay=an(Y.delay*N),Y.dur=Math.max(.01,an(Y.dur*N));let h=t.duration!==void 0?Math.max(1,t.duration):Math.max(1,an(m)),b=new Map(f.map(Y=>[Y.p.id,Y])),x=new Map(u.map(Y=>[Y.id,Y])),[A,M,v,O]=n.viewBox,C=[A+v/2,M+O/2],$=Y=>[Y.x+Y.w/2,Y.y+Y.h/2],P=(Y,L)=>{let q=t.point;if(Array.isArray(q))return q;if(q==="region"||L==="collapse"&&q===void 0&&Y.parent){let U=n.pieces.find(Z=>Z.id===Y.parent);return U?U.foot:C}if(typeof q=="string"){let U=n.pieces.find(Z=>Z.id===q);if(U)return U.foot}return C};function k(Y,L,q){let{p:U}=Y,Z=U.bbox,I=1-L,_=(K,J)=>({dx:an(K*I),dy:an(J*I)});switch(Y.style){case"drop":return _(...ol(Z,n.viewBox,"top"));case"lift":return _(...ol(Z,n.viewBox,"top"));case"fly":return _(...ol(Z,n.viewBox,Y.from));case"rise":{let K=Z.h*I,[J,de,ce]=U.base,W=Z.y-Z.h-4;return{..._(0,Z.h),clip:[[J[0],J[1]-K],[de[0],de[1]-K],[ce[0],ce[1]-K],[ce[0]+2,W-K],[J[0]-2,W-K]].map(ne=>[an(ne[0]),an(ne[1])])}}case"pop":return{scale:Vt(Math.max(0,L)),about:U.foot,opacity:Vt(En(q*4))};case"scatter":{let K=al((s^vf(U.id))>>>0),J=K()*Math.PI*2,de=.35+K()*.65;return{..._(Math.cos(J)*v*de*.6,Math.sin(J)*O*de*.6),opacity:Vt(En(L*1.6))}}case"build":return{..._(0,-18),opacity:Vt(En(L))};case"fade":return{opacity:Vt(En(L))};case"explode":{let K=P(U,"explode"),J=$(Z),de=J[0]-K[0],ce=J[1]-K[1],W=Math.hypot(de,ce),ne=al((s^vf(U.id))>>>0),Ae=ne()*Math.PI*2,Be=W>1?[de/W,ce/W]:[Math.cos(Ae),Math.sin(Ae)],R=Math.hypot(v,O)+Math.max(Z.w,Z.h);return _(Be[0]*R,Be[1]*R)}case"collapse":{let K=P(U,"collapse");return{..._(K[0]-U.foot[0],K[1]-U.foot[1]),scale:Vt(Math.max(0,L)),about:U.foot,opacity:Vt(En(L*3))}}default:{let K=Xs(Z,n.viewBox);return _(K.dx,K.dy)}}}let E=(Y,L,q)=>{let U=En((Y-L)/q);return r?1-U:U},S={opacity:0},F=t.connectors??"draw",D=t.labels??"fade",H=[...n.pieces.map(Y=>Y.id),...n.routes.map(Y=>Y.id),...Object.keys(n.notes)];function X(Y){let L=Math.max(0,Math.min(h,Number.isFinite(Y)?Y:0));if(r?L<=0:L>=h)return{};let q=r?L>=h:L<=0,U={},Z={},I={};for(let ce of f){let W=q?0:E(L,ce.delay,ce.dur);W<=0?U[ce.p.id]=S:W<1&&(U[ce.p.id]=k(ce,r?1-ce.curve(1-W):ce.curve(W),W))}for(let ce of n.routes){let W=x.get(ce.id),ne=q||!W?0:E(L,W.delay,W.dur);ne<=0?Z[ce.id]={opacity:0,drawn:0}:ne<1&&(Z[ce.id]=F==="fade"?{opacity:Vt(ne)}:F==="grow"?{drawn:Vt(ne),by:"grow"}:{drawn:Vt(rl["ease-out"](ne))})}let _=q?0:E(L,d.delay,d.dur),K=_<=0?S:_>=1?void 0:D==="type"?{typed:Vt(_)}:{opacity:Vt(_)};for(let ce of H){let W=K;if(D==="with-piece"){let ne=Object.hasOwn(n.notes,ce)?n.notes[ce]:ce,Ae=ne===void 0?void 0:b.get(ne)??x.get(ne);if(Ae){let Be=q?0:E(L,Ae.delay,Ae.dur);W=Be<=0?S:Be>=1?void 0:{opacity:Vt(Be)}}}W&&(I[ce]=W)}let J=[];if(g&&!q){let ce=(L-y*N)/(g*N);if(ce>0&&ce<1)for(let W of n.routes)J.push({route:W.id,at:Vt(rl.ease(ce))})}let de=ce=>Object.keys(ce).length>0;return{...de(U)?{items:U}:{},...de(I)?{labels:I}:{},...de(Z)?{routes:Z}:{},..._<1?{marks:{opacity:Vt(Math.max(0,_))}}:{},...J.length?{tokens:J}:{}}}return{kind:e,duration:h,pieces:f.map(Y=>({id:Y.p.id,delay:Y.delay,dur:Y.dur,style:a(Y.p)})),routes:u,labels:d,at:X}}var ct=n=>{let e=n.toFixed(2);return e==="-0.00"?"0":String(Number(e))},om=(n,e)=>`translate(${ct(n[0])} ${ct(n[1])}) scale(${Number(e.toFixed(4))}) translate(${ct(-n[0])} ${ct(-n[1])})`,fl=n=>[...n.matchAll(/(-?[\d.]+),(-?[\d.]+)/g)].map(e=>[Number(e[1]),Number(e[2])]),ul=n=>n.slice(1).reduce((e,t,s)=>e+Math.hypot(t[0]-n[s][0],t[1]-n[s][1]),0);function Mi(n,e){let t=fl(n),s=ul(t)*e;for(let r=0;r+1<t.length;r++){let o=Math.hypot(t[r+1][0]-t[r][0],t[r+1][1]-t[r][1]);if(s<=o&&o>0){let i=s/o;return[t[r][0]+(t[r+1][0]-t[r][0])*i,t[r][1]+(t[r+1][1]-t[r][1])*i]}s-=o}return t[t.length-1]??[0,0]}function im(n,e){let t=fl(n),s=Mi(n,e),r=[],o=ul(t)*e;for(let i=0;i<t.length;i++){r.push(t[i]);let a=i+1<t.length?Math.hypot(t[i+1][0]-t[i][0],t[i+1][1]-t[i][1]):1/0;if(o<=a)break;o-=a}return"M"+[...r,s].map(i=>`${ct(i[0])},${ct(i[1])}`).join(" L")}var Kn=n=>String(Number(n.toFixed(4)));function am(n,e){let t=n.match(/&[^;\s]+;|[\s\S]/gu)??[];return t.slice(0,Math.round(t.length*e)).join("")}function lm(n){let e=[];return(n.dx||n.dy)&&e.push(`translate(${ct(n.dx??0)} ${ct(n.dy??0)})`),n.scale!==void 0&&n.scale!==1&&e.push(om(n.about??[0,0],n.scale)),{attrs:{...n.opacity===void 0||n.opacity===1?{}:{opacity:Kn(n.opacity)},...e.length?{transform:e.join(" ")}:{}},clip:n.clip}}function cm(n,e){let t={attrs:n.opacity===void 0||n.opacity===1?{}:{opacity:Kn(n.opacity)}};if(n.drawn!==void 0&&n.drawn<1&&e!==void 0){let s=En(n.drawn),r=ul(fl(e));t.path=n.by==="grow"?{d:im(e,s),head:!1}:{style:`stroke-dasharray:${ct(r)} ${ct(r)};stroke-dashoffset:${ct(r*(1-s))}`,head:!1}}else n.ants&&(t.path={style:`stroke-dasharray:${ct(n.ants.dash[0])} ${ct(n.ants.dash[1])};stroke-dashoffset:${ct(-n.ants.offset)}`,head:!0});return t}function Tf(n,e,t,s,r){if(s==="label"||s==="note"){let i=n.labels&&Object.hasOwn(n.labels,t)?n.labels[t]:void 0;return i&&{attrs:{...i.opacity===void 0||i.opacity===1?{}:{opacity:Kn(i.opacity)},...i.dx||i.dy?{transform:`translate(${ct(i.dx??0)} ${ct(i.dy??0)})`}:{}},...i.typed===void 0||i.typed>=1?{}:{typed:i.typed}}}if(e==="route"){let i=n.routes&&Object.hasOwn(n.routes,t)?n.routes[t]:void 0;return i&&cm(i,r(t))}let o=n.items&&Object.hasOwn(n.items,t)?n.items[t]:void 0;return o&&lm(o)}function Af(n,e,t){let s=[];for(let r of n.outlines??[])s.push(["polygon",{points:r.points.map(o=>o.map(ct).join(",")).join(" "),class:"ring",fill:"none","stroke-width":"2.5","stroke-linejoin":"round",...r.opacity===void 0?{}:{opacity:Kn(r.opacity)},...t?{stroke:r.color??t.control}:{style:`stroke:${r.color??"var(--ring,var(--control,currentColor))"}`}}]);for(let r of n.pulses??[])s.push(["ellipse",{cx:ct(r.x),cy:ct(r.y),rx:ct(r.rx),ry:ct(r.ry),class:"ring",fill:"none","stroke-width":"2.5",...r.opacity===void 0?{}:{opacity:Kn(r.opacity)},...t?{stroke:r.color??t.control}:{style:`stroke:${r.color??"currentColor"}`}}]);for(let r of n.tokens??[]){let o=e(r.route);if(o===void 0)continue;let[i,a]=Mi(o,En(r.at));s.push(["circle",{cx:ct(i),cy:ct(a),r:"7",class:"tok",...t?{fill:r.color??(r.kind!==void 0?t.kinds?.[r.kind]:void 0)??t.control,stroke:t.surface,"stroke-width":"2.5"}:{style:`fill:${r.color??(r.kind!==void 0?`var(--${r.kind},var(--control,currentColor))`:"var(--control,currentColor)")}`}}])}return s}var Of=n=>Object.keys(n).every(e=>e==="morph"||n[e]===void 0),Nf=new Set(["marks","badges"]),$f=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""");function ll(n){let e=new Map,t=[];for(let s of n.matchAll(/<(\/?)([a-zA-Z]+)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>/g)){if(s[1]){let i=t.pop();i?.key!==void 0&&e.set(i.key,[i.from,s.index]);continue}if(s[4])continue;let r=/\sdata-item="([^"]*)"/.exec(s[3])?.[1],o=/\sdata-part="([^"]*)"/.exec(s[3])?.[1];t.push({...t.length===2&&r!==void 0&&o!==void 0?{key:`${Pf(r)}
|
|
143
|
+
${o}`}:{},from:s.index+s[0].length})}return e}var Mf=new WeakMap;function fm(n,e){let t=Mf.get(n)??new Map;Mf.set(n,t);let s=t.get(e);if(!s){t.set(e,s=new Map);let r=n.variants?.[e],o=ll(n.svg);if(r!==void 0)for(let[i,[a,l]]of ll(r)){let c=o.get(i);c&&n.looks?.[i.split(`
|
|
144
|
+
`)[0]]?.includes(e)&&n.svg.slice(...c)!==r.slice(a,l)&&s.set(i,r.slice(a,l))}}return s}function Rf(n,e,t,s){let r=[];for(let o of n.looks?.[e]??[]){let i=En(s[o]??0),a=i>0?fm(n,o).get(`${e}
|
|
145
|
+
${t}`):void 0;a!==void 0&&r.push([a,i])}return r.length?{own:En(1-r.reduce((o,[,i])=>o+i,0)),looks:r}:void 0}var um=(n,e)=>(e.own>0?`<g opacity="${Kn(e.own)}">${n}</g>`:"")+e.looks.map(([t,s])=>`<g opacity="${Kn(s)}">${t}</g>`).join("");function dm(n,e){let t="",s=0;for(let[r,[o,i]]of[...ll(n.svg)].sort((a,l)=>a[1][0]-l[1][0])){let[a,l]=r.split(`
|
|
146
|
+
`),c=Object.hasOwn(e,a)?Rf(n,a,l,e[a]):void 0;c&&(t+=n.svg.slice(s,o)+um(n.svg.slice(o,i),c),s=i)}return t+n.svg.slice(s)}function dl(n,e){if(Of(e))return n.rendered.svg;let t=e.variants?dm(n.rendered,e.variants):n.rendered.svg,s=u=>Object.hasOwn(n.rendered.paths,u)?n.rendered.paths[u]:void 0,r=0,o="",i="",a=0,l,c=t.replace(/<(\/?)([a-zA-Z]+)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g,(u,d,p,g,m,y)=>{if(y!==void 0)return l?.w.typed===void 0?u:am(y,l.w.typed);if(d)return r--,l&&r===l.at&&(l=void 0),r===1&&(o=""),u;let N=r;m||r++;let h={};for(let[,b,x]of g.matchAll(/([\w:-]+)="([^"]*)"/g))h[b]=x;if(N===0){if(!e.camera)return u;h.viewBox=e.camera.map(ct).join(" ")}else if(N===1)if(o=p==="g"&&h.class?.startsWith("g-")?h.class.slice(2):"",Nf.has(o)&&e.marks&&e.marks.opacity!==1)h.opacity=Kn(e.marks.opacity);else return u;else if(N===2&&h["data-part"]!==void 0){let b=h["data-route"]===void 0?"item":"route",x=Pf(h["data-route"]??h["data-item"]??""),A=Tf(e,b,x,h["data-part"],s);if(!A)return u;for(let[M,v]of Object.entries(A.attrs))h[M]=$f(v);if(A.clip){let M=`${n.id}-mc${a++}`;i+=`<clipPath id="${M}"><polygon points="${A.clip.map(v=>v.join(",")).join(" ")}"/></clipPath>`,h["clip-path"]=`url(#${M})`}if(!m&&(A.path||A.typed!==void 0)&&(l={at:N,w:A}),!Object.keys(A.attrs).length&&!A.clip)return u}else if(l?.w.path&&p==="path"&&h.class?.split(" ")[0]==="flow"){let b=l.w.path;b.d!==void 0&&(h.d=b.d),b.style!==void 0&&(h.style=b.style),b.head||delete h["marker-end"]}else return u;return`<${p}${Object.entries(h).map(([b,x])=>` ${b}="${x}"`).join("")}${m?"/":""}>`});i&&(c=c.replace(/<defs>|<defs\/>/,u=>u==="<defs/>"?`<defs>${i}</defs>`:u+i));let f=Af(e,s,n.rendered.inks);return f.length&&(c=c.replace('<g class="g-anim">',u=>u+f.map(([d,p])=>`<${d}${Object.entries(p).map(([g,m])=>` ${g}="${$f(m)}"`).join("")}/>`).join(""))),c}var Pf=n=>n.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&"),il=new WeakMap;function Cf(n,e,t){let s=il.get(n);if(s){for(let[N,h]of s.mixed)N.replaceChildren(...h);for(let[N,h]of s.attrs)for(let[b,x]of h)x===null?N.removeAttribute(b):N.setAttribute(b,x);for(let[N,h,b]of s.gone.reverse())h.insertBefore(N,b);for(let[N,h]of s.texts)N.data=h;for(let N of s.made)N.remove();il.delete(n)}if(Of(e))return;let r={attrs:new Map,texts:new Map,gone:[],made:[],mixed:[]};il.set(n,r);let o=(N,h,b)=>{let x=r.attrs.get(N)??new Map;x.has(h)||x.set(h,N.getAttribute(h)),r.attrs.set(N,x),b===null?N.removeAttribute(h):N.setAttribute(h,b)},i=n.ownerDocument,a=(N,h,b)=>{let x=i.createElementNS("http://www.w3.org/2000/svg",N);for(let[A,M]of Object.entries(h))x.setAttribute(A,M);return b.append(x),r.made.push(x),x},l=Array.from(n.children),c=N=>l.find(h=>h.getAttribute("class")===`g-${N}`),f=new Map;for(let N of Array.from(c("flows")?.children??[])){let h=N.getAttribute("data-route"),b=N.querySelector("path.flow")?.getAttribute("d");h!==null&&b&&f.set(h,b)}let u=N=>f.get(N);e.camera&&o(n,"viewBox",e.camera.map(ct).join(" "));for(let N of Nf){let h=c(N);h&&e.marks&&e.marks.opacity!==1&&o(h,"opacity",Kn(e.marks.opacity))}let d=0,p=l.find(N=>N.localName==="defs"),g=p?.firstChild??null,m=n.getAttribute("data-scene")??"scene";for(let N of l)for(let h of Array.from(N.children)){let b=h.getAttribute("data-part");if(b===null)continue;let x=h.getAttribute("data-route"),A=x===null?h.getAttribute("data-item")??"":"",M=t&&e.variants&&Object.hasOwn(e.variants,A)?Rf(t,A,b,e.variants[A]):void 0;if(M){let C=Array.from(h.childNodes),$=(k,E)=>{let S=i.createElementNS("http://www.w3.org/2000/svg","g");return S.setAttribute("opacity",Kn(k)),S.append(...E),S},P=k=>Array.from(i.importNode(new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${k}</svg>`,"image/svg+xml").documentElement,!0).childNodes);r.mixed.push([h,C]),h.replaceChildren(...M.own>0?[$(M.own,C)]:[],...M.looks.map(([k,E])=>$(E,P(k))))}let v=Tf(e,x===null?"item":"route",x??h.getAttribute("data-item")??"",b,u);if(!v)continue;for(let[C,$]of Object.entries(v.attrs))o(h,C,$);if(v.clip&&p){let C=a("clipPath",{id:`${m}-mc${d++}`},p);p.insertBefore(C,g);let $=i.createElementNS("http://www.w3.org/2000/svg","polygon");$.setAttribute("points",v.clip.map(P=>P.join(",")).join(" ")),C.append($),o(h,"clip-path",`url(#${C.id})`)}if(v.typed!==void 0){let C=[];for(let $=i.createTreeWalker(h,4);$.nextNode();)C.push($.currentNode);for(let $ of C)r.texts.set($,$.data),$.data=Array.from($.data).slice(0,Math.round(Array.from($.data).length*v.typed)).join(""),$.data||(r.gone.push([$,$.parentNode,$.nextSibling]),$.remove())}let O=v.path&&h.querySelector("path.flow");O&&v.path&&(v.path.d!==void 0&&o(O,"d",v.path.d),v.path.style!==void 0&&o(O,"style",v.path.style),v.path.head||o(O,"marker-end",null))}let y=c("anim");if(y)for(let[N,h]of Af(e,u))a(N,h,y)}var If=(n,e)=>({...e,frame:t=>dl(n,e.at(t))}),ml=(n,e={})=>If(n,Zs(fs(n),"assemble",e)),Lf=(n,e={})=>If(n,Zs(fs(n),"disassemble",e)),Ff=(n,e)=>ml(n).frame(e);var Oi=(n,e)=>e.role??pt(n,e.kind)?.role,Ei=(n,e)=>pt(n,e.region.kind)?.shape,Zt=(n,e,t,s="item")=>t?Te("g",{[`data-${s}`]:n,"data-part":e},t):"";function er({scene:n,layout:e,routes:t,steps:s,theme:r,id:o,gridStep:i=1}){let a=new Ls,l={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new Es;c.budget.spots=Ai;let f=S=>s.vis[S]?{"data-vis":"1"}:{},u=e.items.filter(S=>S.type==="region"),d=S=>{let F=0;for(let D=S.parent;D;D=D.parent)F++;return F},p=e.catalog,g=u.filter(S=>Ei(p,S)!=="walled"&&Ei(p,S)!=="tunnel"),m=xr(g.map(S=>({box:S.box,r:S}))).map(S=>S.r).sort((S,F)=>d(S)-d(F));for(let S of m)l.base+=pm(a,p,S,f(S.id),i);for(let S of u.filter(F=>Ei(p,F)==="walled")){for(let D of Ti(S))c.solids.push(Rt(D));for(let[D,H]of Ti(S).entries())l.blocks.push({box:H,svg:Zt(S.id,`wall-${D+1}`,Te("g",{class:`blk k-${Oi(p,S.region)} wall${S.region.ghost?" ghost":""}`,"data-id":S.id,"data-dim":"1",...f(S.id)},a.blockFaces(H)))});let F=S.region.gate;if(F&&!F.node){let D=Vr(S,F.height??(S.region.height??.8)+.3,.3,.3);c.solids.push(Rt(D)),l.blocks.push({box:D,svg:Zt(S.id,"gate",Te("g",{class:"blk k-gate","data-id":S.id,...f(S.id)},a.blockFaces(D)))})}S.region.label&&(S.region["label-style"]??"face")!=="none"&&(l.labels+=Zt(S.id,"name",a.faceText(S.box.x0+.3,S.box.y1,S.box.z0+.13,S.region.label,"slabname sm fz",lt.sm,"left","start",{"data-id":S.id,...f(S.id)})))}for(let S of u.filter(F=>Ei(p,F)==="tunnel"))l.air+=Zt(S.id,"block",gm(a,S,f(S.id)));let y=e.items.filter(S=>S.type==="node");for(let S of y){let F=S.node,D=on(p,F.asset),H=F.ghost||(F.deco??[]).includes("ghost"),X=["blk",`k-${F.role??D.role}`,D.cls,H?"ghost":""].filter(Boolean).join(" ");l.blocks.push({box:S.box,svg:Zt(S.id,"block",Te("g",{class:X,"data-id":S.id,"data-dim":"1",...f(S.id)},D.draw(a,S.box,F)))}),c.polys.push({poly:Rt(S.box),owner:S.id}),c.solids.push(Rt(S.box))}let N=xr(l.blocks).map(S=>S.svg).join(""),h=new Set,b={};for(let S of t){if(S.points.length<2)continue;let F=S.points.map(X=>Ce(X[0],X[1],X[2]));F.forEach(X=>a.bounds.add(X));let D="M"+F.map(xs).join(" L");b[S.id]=D;let H=S.raw.arrow!==!1;H&&h.add(S.kind),l.flows+=Zt(S.id,"line",Te("g",{"data-hl":S.id,"data-id":S.id,...f(S.id)},Te("path",{d:D,class:`flow f-${S.kind}`,"marker-end":H?`url(#ah-${o}-${S.kind})`:void 0})),"route"),c.lines.push({pts:F,owner:S.id})}for(let S of h)a.def(`ah-${o}-${S}`,Te("marker",{id:`ah-${o}-${S}`,viewBox:"0 0 10 10",refX:"7",refY:"5",markerWidth:"4.2",markerHeight:"4.2",orient:"auto-start-reverse"},Te("path",{d:"M0,0 L10,5 L0,10 z",style:`fill:${_n(r,r.kinds[S]?.color??"control")}`})));for(let S of a.planePolys)c.slants.push(S);let x=y.filter(S=>S.node.label||S.node.sub).sort((S,F)=>(F.box.x1-F.box.x0)*(F.box.y1-F.box.y0)-(S.box.x1-S.box.x0)*(S.box.y1-S.box.y0));for(let S of x)l.labels+=Zt(S.id,"label",hm(a,p,S,c,f(S.id)));let A=[];for(let S of t)if(S.raw.label&&S.points.length>=2){let F=bm(a,S,c,f(S.id),e);l.floor+=Zt(S.id,"label",F.svg,"route"),F.warning&&A.push({path:`${S.path}/label`,message:F.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,A.push({path:S.path,message:`from route "${S.id}" on, route labels were placed without weighing what other labels and lines cover: the scene is too large to search every spot (${Ai.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(n.notes??[]).forEach((S,F)=>{let D=Zt(`${o}-note-${F}`,"note",ym(a,S,e,t,`${o}-note-${F}`));S.floor?l.floor+=D:l.labels+=D});let M=[],v=new Map;for(let S of s.says){let F=v.get(S.step)??c.fork();v.set(S.step,F);let D=sn(S.text,lt.say)+18,H=wi(D,S.ax,S.ay,{x:S.x,y:S.y,anchor:S.anchor},F);F.rects.push({r:H.rect,owner:""}),M.push({step:S.step,...H.rect,text:S.text});let X=H.rect.x+2;a.bounds.addRect(H.rect.x,H.rect.y,H.rect.w,H.rect.h);let Y=_n(r,r.kinds[S.kind]?.color??"control");l.marks+=Te("g",{class:"say","data-step":S.step},Te("rect",{x:X,y:H.y-12,width:D,height:24,rx:12,style:`stroke:${Y}`})+Te("text",{x:X+D/2,y:H.y+4,"text-anchor":"middle",style:`fill:${Y}`},dt(S.text)))}for(let S of s.marks){let[F,D]=Ce(...S.p);a.bounds.addRect(F-12,D-12,24,24),l.marks+=Te("g",{class:"xm","data-step":S.step,"data-hl":S.on},Te("circle",{cx:F,cy:D,r:10})+Te("path",{d:`M${at(F-4.5)},${at(D-4.5)} L${at(F+4.5)},${at(D+4.5)} M${at(F+4.5)},${at(D-4.5)} L${at(F-4.5)},${at(D+4.5)}`}))}for(let S of s.badges){let[F,D]=Ce(...S.p);a.bounds.addRect(F-13,D-13,26,26),l.badges+=Te("g",{class:`badge c-${S.kind}`,"data-go":S.step,"data-badge":S.step,tabindex:"0",role:"button","aria-label":`Step ${S.num}`},Te("circle",{cx:F,cy:D,r:11.5})+Te("text",{x:F,y:D+.5},String(S.num)))}let O=a.bounds,C=22,$=O.empty?[0,0,100,100]:[Math.floor(O.x0-C),Math.floor(O.y0-C),Math.ceil(O.x1-O.x0+C*2),Math.ceil(O.y1-O.y0+C*2)],P=[...a.defs.values()].join(""),k=(S,F)=>Te("g",{class:"g-"+S},F);return{svg:Te("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:$.join(" "),role:"img","aria-label":n.aria??n.title,"data-scene":o},Te("defs",{},P)+k("base",l.base)+k("floor",l.floor)+k("flows",l.flows)+k("blocks",N)+k("air",l.air)+k("labels",l.labels)+k("marks",l.marks)+k("badges",l.badges)+k("anim","")),viewBox:$,texts:a.texts,paths:b,warnings:A,callouts:M,assembly:Si(e,t,$)}}function mm(n,e){let t=n.z1+.002,s=1e-6,r=[],o=(i,a)=>{let l=Ce(i[0],i[1],t),c=Ce(a[0],a[1],t);r.push(`M${xs(l)}L${xs(c)}`)};for(let i=Math.ceil((n.x0+s)/e)*e;i<n.x1-s;i+=e)o([i,n.y0],[i,n.y1]);for(let i=Math.ceil((n.y0+s)/e)*e;i<n.y1-s;i+=e)o([n.x0,i],[n.x1,i]);return r.length?Te("path",{class:"grid",d:r.join("")}):""}function pm(n,e,t,s,r=1){let o=t.region,i=t.box,a=Oi(e,o),l=pt(e,o.kind),c=l?.shape,f={"data-id":t.id,"data-dim":"1",...s},u="";c==="cloud"?u=Te("g",{class:`blk k-${a} cloud`,...f},ai(n,i)):c==="zone"?u=Te("g",{class:`zone k-${a}`,...f},n.poly([[i.x0,i.y0,i.z1],[i.x1,i.y0,i.z1],[i.x1,i.y1,i.z1],[i.x0,i.y1,i.z1]])):u=Te("g",{class:`blk k-${a}${o.ghost?" ghost":""}`,...f},n.blockFaces(i)+mm(i,r)),u=Zt(t.id,"block",u);let d=o["label-style"]??l?.labelStyle;if(o.label&&d!=="none")if(d==="face"){let p=i.z1-i.z0,g=h=>h.size*.73/nt,m=c==="slab"&&.28+g(lt.slabname)+.08>p,y=c==="slab"&&!m,N=y?i.z0+.28:m?i.z0+Math.max(.02,(p-g(lt.sm))/2):i.z0+Math.min(.1,p*.25);u+=Zt(t.id,"name",Te("g",f,n.faceText(i.x0+(y?.6:.3),i.y1,N,o.label,y?"slabname":"slabname sm",y?lt.slabname:lt.sm,"left","start")))}else if(d==="face-right")u+=Zt(t.id,"name",Te("g",f,n.faceText(i.x1,i.y0+.6,i.z0+Math.max(.14,(i.z1-i.z0)*.2),o.label,"slabname",lt.slabname,"right","end")));else{let p=c==="cloud"?"middle":"start",g=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,m=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=Zt(t.id,"name",Te("g",f,n.floorText(g,m,i.z1+.01,o.label,"slabname sm","x",p)))}return u}function Ti(n){let{x0:e,y0:t,x1:s,y1:r,z0:o,z1:i}=n.box,a=zn,l=n.region.gate,c=[],f=d=>{d.x1-d.x0>1e-6&&d.y1-d.y0>1e-6&&c.push({...d,z0:o,z1:i})},u=(d,p,g)=>{if(!l||l.side!==g)return[[d,p]];let m=l.at??.5,y=l.width??2,N=g==="e"||g==="w"?t+(r-t)*m:e+(s-e)*m;return[[d,N-y/2],[N+y/2,p]]};for(let[d,p]of u(e,s,"n"))f({x0:d,y0:t,x1:p,y1:t+a});for(let[d,p]of u(t+a,r-a,"w"))f({x0:e,y0:d,x1:e+a,y1:p});for(let[d,p]of u(t+a,r-a,"e"))f({x0:s-a,y0:d,x1:s,y1:p});for(let[d,p]of u(e,s,"s"))f({x0:d,y0:r-a,x1:p,y1:r});return c}function hm(n,e,t,s,r){let o=t.node,i=on(e,o.asset),a=t.box,l={name:o.label,sub:o.sub},c=o["label-at"],f;if(c){let d=Mn(Rt(a)),p=c.side??"above",g=d.y+Math.min(d.h,60)*.45;p==="right"?f={x:d.x+d.w+8,y:g,anchor:"start"}:p==="left"?f={x:d.x-8,y:g,anchor:"end"}:p==="below"?f={x:d.x+d.w/2,y:d.y+d.h+14,anchor:"middle"}:f=Ur(l,a,Rt(a),new Es,t.id),f={...f,x:f.x+(c.dx??0),y:f.y+(c.dy??0)}}else{let d=i.label?i.label(a,o,!!o.sub):void 0;f=Ur(l,a,Rt(a),s,t.id,d)}s.rects.push({r:qr(l,f.x,f.y,f.anchor),owner:""});let u="";return o.label&&(u+=n.text(f.x,f.y,o.label,"lbl",lt.lbl,f.anchor,{},t.id)),o.sub&&(u+=n.text(f.x,o.label?f.y+14:f.y,o.sub,"sub mono",lt.sub,f.anchor,{},t.id)),Te("g",{"data-id":t.id,"data-dim":"1",...r},u)}function gm(n,e,t){let{x0:s,y0:r,x1:o,y1:i,z0:a,z1:l}=e.box,c=n.blockFaces(e.box),f=o-s>=i-r,u=Math.max(1,Math.round((f?o-s:i-r)/1.6));for(let p=1;p<u;p++){let g=f?s+(o-s)*p/u:r+(i-r)*p/u;c+=n.poly(f?[[g,r,l],[g,i,l],[g,i,a]]:[[s,g,l],[o,g,l],[o,g,a]],"rib")}let d=e.region.label;return d&&e.region["label-style"]!=="none"&&(c+=f?n.faceText(s+.35,i,a+.14,d,"tunname",lt.tunname,"left","start"):n.faceText(o,i-.35,a+.18,d,"tunname",lt.tunname,"right","start")),Te("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...t},c)}var Ai=2e4;function bm(n,e,t,s,r){let o=typeof e.raw.label=="string"?{text:e.raw.label}:e.raw.label,i=`floor mono t-${e.kind}`,a={"data-hl":e.id,...s},l=lt.floor;if(o.at){let h=o.at.length>2?o.at[2]:e.points[0][2];return{svg:n.floorText(o.at[0],o.at[1],h,o.text,i,o.dir??"x",o.anchor??"start",a)}}let c=e.points,f=[];for(let h=0;h+1<c.length;h++){let b=c[h],x=c[h+1];Math.abs(b[2]-x[2])>1e-6||f.push({i:h,len:Math.hypot(x[0]-b[0],x[1]-b[1])})}if(!f.length)return{svg:"",warning:`label "${o.text}" of route "${e.id}" was dropped: the route has no level segment`};let u=o.along?f.filter(h=>h.i===Math.min(o.along-1,c.length-2)):[...f].sort((h,b)=>b.len-h.len),d=.22,p=11/nt,g=h=>{let b=sn(h,l)/nt,x,A=1/0,M=0;e:for(let v of u.length?u:f){let O=c[v.i],C=c[v.i+1],$=O[2],P=Math.abs(O[1]-C[1])<1e-6,k=P?Math.min(O[0],C[0]):Math.min(O[1],C[1]),E=P?Math.max(O[0],C[0]):Math.max(O[1],C[1]),S=P?O[1]:O[0],F=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],D=[];for(let H=k+.3;H<=Math.max(k+.3,E-b-.2)+1e-9;H+=.4)D.push(H);for(let H=E-b-.2+.4;H<E+.5&&E-k<b+.5;H+=.6)D.push(H);for(let H of F)for(let X of D){if(A<=M*.5)break e;let Y=H<0?S-d:S+d+p,L,q,U;if(P?(L=X,q=Y,U=[Ce(L,q-p,$),Ce(L+b,q-p,$),Ce(L+b,q,$),Ce(L,q,$)]):(L=Y,q=X+b,U=[Ce(L-p,q,$),Ce(L-p,q-b,$),Ce(L,q-b,$),Ce(L,q,$)]),(P?[[L,q-p],[L+b,q-p],[L+b,q],[L,q]]:[[L-p,q],[L-p,q-b],[L,q-b],[L,q]]).some(([de,ce])=>Math.abs(Hs(r,de,ce)+.01-$)>.001)){M++;continue}let I=t.hiddenPoly(U),_=I*50+M*.5,K=t.budget.spots-- >0;K||(t.budget.over=!0);let J=_>=A?1/0:K?_+t.costPoly(U,A-_):_;M++,J<A&&(A=J,x={x:L,y:q,z:$,dir:P?"x":"y",rect:Mn(U),poly:U,hidden:I})}}return x&&x.hidden<6?x:void 0},m=o.text,y=g(m),N;if(!y){let h=o.text.split(/(\s+)/);for(let b=h.length-1;b>0&&!y;b--){let x=h.slice(0,b).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if(x.length<6)break;let A=g(x);A&&(y=A,m=x)}N=y?`label of route "${e.id}" shortened to "${m}": no clear floor for the whole text`:`label "${o.text}" of route "${e.id}" was dropped: blocks cover every spot beside it`,y?N+='; give it "along", "side" or "at", or move the nodes apart':N+='; give it "at: [x, y]", or move the nodes apart'}return y?(t.slants.push(y.poly),{svg:n.floorText(y.x,y.y,y.z+.01,m,i,y.dir,"start",a),warning:N}):{svg:"",warning:N}}function ym(n,e,t,s,r){let o=e.on?s.find(f=>f.id===e.on):void 0,i=e.on&&!o?t.byId.get(e.on):void 0,a=e.at,l={"data-id":r,"data-hl":o?.id,"data-dim":o?void 0:"1"},c=e.kind??o?.kind??"control";if(e.floor){let f=a&&a.length>2?a[2]:o?o.points[0][2]:i?i.floor:.36,[u,d]=a?[a[0],a[1]]:o?[o.points[0][0]+.35,o.points[0][1]-.25]:i?[i.box.x0+.3,i.box.y1-.3]:[0,0];return n.floorText(u,d,f+.01,e.floor,`floor mono t-${c}`,e.dir??"x",e.anchor??"start",l)}if(e.face){let f=i?.box,[u,d,p]=a?[a[0],a[1],a[2]??.45]:f?[f.x0+.3,f.y1,f.z0+.13]:[0,0,0];return n.faceText(u,d,p,e.face,"slabname sm",lt.sm,"left",e.anchor??"start",l)}if(e.label||e.sub){let f=i?.box,u=a?[a[0],a[1],a[2]??.36]:f?[(f.x0+f.x1)/2,(f.y0+f.y1)/2,f.z1+.75]:[0,0,0],[d,p]=Ce(u[0],u[1],u[2]),g=d+(e.dx??0),m=p-18+(e.dy??0),y=e.anchor??"middle",N="";return e.label&&(N+=n.text(g,m,e.label,"lbl",lt.lbl,y)),e.sub&&(N+=n.text(g,e.label?m+14:m,e.sub,"sub mono",lt.sub,y)),Te("g",l,N)}return""}function Bf(n,e){let t={};for(let s of n.layout.items){let r=(s.region??s.node)?.variants;r&&(t[s.id]=Object.keys(r))}Object.keys(t).length&&(n.rendered.looks=t,n.rendered.variants=Object.fromEntries([...new Set(Object.values(t).flat())].map(s=>[s,er({scene:n.raw,routes:n.routes,steps:n.steps,theme:e,id:n.raw.id,gridStep:n.grid.step??n.grid.snap??1,layout:{...n.layout,items:n.layout.items.map(r=>{let o=(r.region??r.node)?.variants?.[s];return o?r.region?{...r,region:{...r.region,...o,deco:void 0}}:{...r,node:{...r.node,...o}}:r})}}).svg])))}var Wr=29.09090909090909,pl={solid:[9,7],dashed:[7,6],dotted:[3,6]},hl=["blocked","planned"],jf=`
|
|
147
|
+
.flow.iso-ants{stroke-dasharray:var(--ant-on) var(--ant-off);animation:iso-ants var(--ant-turn) linear infinite;animation-play-state:var(--ants,running)}
|
|
148
|
+
@keyframes iso-ants{to{stroke-dashoffset:var(--ant-to)}}
|
|
149
|
+
`;function Jr(n,e={}){return(e.still??hl).includes(n)?void 0:e.dash??pl[e.kinds?.[n]?.dash??"solid"]}function Ni(n){let e=n?.ants;return e?e===!0?{}:Array.isArray(e)?{ids:e}:e:void 0}function Df(n,e={}){let t=new Map(n.routes.map(i=>[i.id,i.kind])),s=e.ids&&new Set(e.ids),r=e.speed??Wr,o=i=>String(Number(i.toFixed(3)));return n.rendered.svg.replace(/(<g data-route="([^"]*)" data-part="line">(?:<g[^>]*>)*)<path ([^>]*?)\s*\/>/g,(i,a,l,c)=>{let f=l.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),u=s&&!s.has(f)?void 0:Jr(t.get(f)??"",e);if(!u||!/class="flow\b/.test(c))return i;let d=u[0]+u[1],p=o(d/Math.max(1e-6,Math.abs(r))),g=o(r<0?d:-d);return e.by==="css"?`${a}<path ${c.replace(/class="flow\b/,'class="flow iso-ants')} style="--ant-on:${o(u[0])};--ant-off:${o(u[1])};--ant-to:${g};--ant-turn:${p}s"/>`:e.by==="none"?`${a}<path ${c.replace(/ ?stroke-dasharray="[^"]*"/,"")} style="stroke-dasharray:${o(u[0])} ${o(u[1])}"/>`:`${a}<path ${c.replace(/ ?stroke-dasharray="[^"]*"/,"")} style="stroke-dasharray:${o(u[0])} ${o(u[1])}"><animate attributeName="stroke-dashoffset" from="0" to="${g}" dur="${p}s" repeatCount="indefinite"/></path>`})}var Ts=n=>typeof n=="string"?[n]:[...n],Ri=n=>JSON.parse(JSON.stringify(n)),ln=(n={})=>({...n.from===void 0?{}:{from:n.from},...n.over===void 0?{}:{duration:n.over},...n.easing===void 0?{}:{easing:n.easing}}),tr=class n{nodes=[];add(e){return this.nodes.push(Ri(e)),this}assemble(e={},t={}){return this.add({assemble:e,...ln(t)})}disassemble(e={},t={}){return this.add({disassemble:e,...ln(t)})}travel(e,t={}){let{each:s,hold:r,loop:o}=t;return this.add({travel:e,...ln(t),each:s,hold:r,loop:o})}pulse(e,t={}){return this.add({pulse:Ts(e),...ln(t),loop:t.loop})}ants(e=!0,t={}){return this.add({ants:e===!0?!0:Ts(e),...ln(t),speed:t.speed,dash:t.dash})}draw(e,t={}){return this.add({draw:Ts(e),...ln(t),by:t.by,stagger:t.stagger})}type(e,t={}){return this.add({type:Ts(e),...ln(t)})}move(e,t){return this.add({move:e,...t})}lift(e,t,s={}){return this.add({lift:Ts(e),by:t,...ln(s),stagger:s.stagger,to:s.to,opacity:s.opacity})}focus(e,t={}){let{scope:s,level:r,always:o}=t;return this.add({focus:{lit:Ts(e),scope:s,level:r,always:o},...ln(t),fade:t.fade})}highlight(e,t={}){return this.add({highlight:Ts(e),...ln(t),fade:t.fade})}get camera(){return{focus:(e,t={})=>this.add({camera:{focus:e,zoom:t.zoom,margin:t.margin},...ln(t)}),fit:(e={})=>this.add({camera:"fit",...ln(e)})}}sequence(e,t={},s){return this.add({sequence:_f(e,t,s)})}series(e){let t=new nr;return e(t),this.add({series:t.items})}layers(e){let t=new n;return e(t),this.add({layers:t.nodes})}};function _f(n,e,t){let{read:s,duration:r,...o}=e,i=new tr;return t?.(i),Ri({...n===void 0?{}:{name:n},...o,...s!==void 0?{duration:{read:s}}:r!==void 0?{duration:r}:{},...i.nodes.length?{children:i.nodes}:{}})}var nr=class{items=[];sequence(e,t={},s){return this.items.push({sequence:_f(e,t,s)}),this}transition(e){return this.items.push({transition:Ri(e)}),this}},Xr=class extends nr{over=[];marks={};head;constructor(e={}){super(),this.head=e}beat(e,t,s={},r){return this.sequence(e,{...s,say:t},r)}assemble(e={},t={}){return this.sequence(void 0,{},s=>s.assemble(e,t))}disassemble(e={},t={}){return this.sequence(void 0,{},s=>s.disassemble(e,t))}mark(e,t){return this.marks[e]=t,this}layers(e){let t=new tr;return e(t),this.over.push(...t.nodes),this}toJSON(){return Ri({isomotion:1,...this.head,...this.items.length?{series:this.items}:{},...this.over.length?{layers:this.over}:{},...Object.keys(this.marks).length?{markers:this.marks}:{}})}},zf=(n={})=>new Xr(n);var Pi=["linear","ease","ease-in","ease-out","ease-in-out","settle","bounce"],sr=["extend","clamp","wrap","identity"];function An(n,e){if(typeof n=="number")return Number.isFinite(n)?n:void 0;if(typeof n!="string")return;let t=/^(-?\d+(?:\.\d+)?)(ms|s|f)?$/.exec(n.trim());if(!t)return;let s=Number(t[1]);return t[2]==="s"?s*1e3:t[2]==="f"?e?s/e*1e3:void 0:s}function Zr(n,e){let t=e===!0?{}:e,s=t.base??2600,r=t.perChar??40,o=t.min??5600,i=t.max??12500;return Math.max(o,Math.min(i,s+(n?.text??"").length*r))}var us=(n,e,t,s)=>r=>{if(r<=0)return 0;if(r>=1)return 1;let o=(l,c,f)=>3*l*f*(1-f)**2+3*c*f*f*(1-f)+f**3,i=0,a=1;for(let l=0;l<50;l++){let c=(i+a)/2;o(n,t,c)<r?i=c:a=c}return o(e,s,(i+a)/2)},xm=n=>{if(n<=0)return 0;if(n>=1)return 1;let e=7.5625,t=2.75;return n<1/t?e*n*n:n<2/t?e*(n-1.5/t)**2+.75:n<2.5/t?e*(n-2.25/t)**2+.9375:e*(n-2.625/t)**2+.984375},wm={linear:n=>n,ease:us(.25,.1,.25,1),"ease-in":us(.42,0,1,1),"ease-out":us(0,0,.58,1),"ease-in-out":us(.42,0,.58,1),settle:us(.16,.84,.3,1),bounce:xm};function rr(n,e={}){let t=e.mass??1,s=e.stiffness??100,r=e.damping??10,o=Math.max(0,n)/1e3,i=Math.sqrt(s/t),a=r/(2*Math.sqrt(s*t)),l;if(a<1){let c=i*Math.sqrt(1-a*a);l=1-Math.exp(-a*i*o)*(Math.cos(c*o)+a*i/c*Math.sin(c*o))}else l=1-Math.exp(-i*o)*(1+i*o);return e.overshootClamping?Math.min(1,l):l}function On(n,e,t="ease-in-out"){let s=n??t;return typeof s=="string"?wm[s]:"bezier"in s?us(...s.bezier):r=>r<=0?0:r>=1?1:rr(r*e,s.spring)}function or(n,e,t){let s=n.times.map(u=>An(u,t)),r=n.values,o=s.length;if(o===1)return r[0];let i=(u,d)=>{if(u==="clamp")return d?r[0]:r[o-1];if(u==="identity")return e;if(u==="wrap"){let p=s[o-1]-s[0];return or({...n,extrapolateLeft:"clamp",extrapolateRight:"clamp"},s[0]+((e-s[0])%p+p)%p,t)}};if(e<s[0]){let u=i(n.extrapolateLeft??"extend",!0);if(u!==void 0)return u}if(e>s[o-1]){let u=i(n.extrapolateRight??"extend",!1);if(u!==void 0)return u}let a=0;for(;a<o-2&&e>=s[a+1];)a++;let l=s[a+1]-s[a],c=(e-s[a])/l,f=c<0||c>1?c:On(n.easing,l,"linear")(c);return r[a]+(r[a+1]-r[a])*f}var km={anyOf:[{type:"number"},{type:"string",pattern:"^-?\\d+(\\.\\d+)?(ms|s|f)?$"}]},Sm={type:"array",items:{type:"string"}},vm={anyOf:[{enum:Pi},{type:"object",required:["bezier"],additionalProperties:!1,properties:{bezier:{type:"array",items:{type:"number"},minItems:4,maxItems:4}}},{type:"object",required:["spring"],additionalProperties:!1,properties:{spring:{$ref:"#/$defs/spring"}}}]},Kf={from:{$ref:"#/$defs/time"},duration:{$ref:"#/$defs/time"},easing:{$ref:"#/$defs/ease"}},Yt=(n,e,t={},s=!0)=>({type:"object",required:[n],additionalProperties:!1,properties:{[n]:e,...s?Kf:{},...t}}),Gf={$schema:"https://json-schema.org/draft/2020-12/schema",title:"isomotion/1",type:"object",required:["isomotion"],additionalProperties:!1,properties:{isomotion:{const:1},fps:{type:"number",exclusiveMinimum:0,description:'Frames a second, for lengths written "30f".'},seed:{type:"integer"},ambient:{enum:["on","off"],description:"Off: the ants and the looping tokens and pulses stand still, each at its start."},series:{$ref:"#/$defs/series"},layers:{$ref:"#/$defs/nodes"},markers:{type:"object",additionalProperties:{anyOf:[{type:"number"},{type:"string"}]}}},$defs:{time:km,ids:Sm,ease:vm,spring:{type:"object",additionalProperties:!1,properties:{mass:{type:"number",exclusiveMinimum:0},damping:{type:"number",exclusiveMinimum:0},stiffness:{type:"number",exclusiveMinimum:0},overshootClamping:{type:"boolean"}}},curve:{type:"object",required:["times","values"],additionalProperties:!1,properties:{times:{type:"array",items:{$ref:"#/$defs/time"},minItems:1},values:{type:"array",items:{type:"number"},minItems:1},easing:{$ref:"#/$defs/ease"},extrapolateLeft:{enum:sr},extrapolateRight:{enum:sr}}},say:{type:"object",additionalProperties:!1,properties:{chapter:{type:"string"},title:{type:"string"},text:{type:"string"},code:{type:"string"},color:{type:"string"},facts:{type:"array",items:{type:"array",items:{type:"string"},minItems:2,maxItems:2}}}},focus:{type:"object",required:["lit"],additionalProperties:!1,properties:{lit:{$ref:"#/$defs/ids"},scope:{enum:["all","links"]},level:{type:"number",minimum:0,maximum:1},always:{$ref:"#/$defs/ids"}}},sequence:{type:"object",additionalProperties:!1,properties:{name:{type:"string",pattern:"^[A-Za-z][\\w-]*$"},from:{$ref:"#/$defs/time"},offset:{$ref:"#/$defs/time"},trimBefore:{$ref:"#/$defs/time"},duration:{anyOf:[{$ref:"#/$defs/time"},{type:"object",required:["read"],additionalProperties:!1,properties:{read:{anyOf:[{const:!0},{type:"object",additionalProperties:!1,properties:{base:{type:"number"},perChar:{type:"number"},min:{type:"number"},max:{type:"number"}}}]}}}]},loop:{anyOf:[{type:"boolean"},{type:"integer",minimum:1}]},playbackRate:{type:"number",exclusiveMinimum:0},say:{$ref:"#/$defs/say"},show:{$ref:"#/$defs/ids"},hide:{$ref:"#/$defs/ids"},focus:{$ref:"#/$defs/focus"},highlight:{$ref:"#/$defs/ids"},levels:{type:"object",additionalProperties:{type:"number",minimum:0,maximum:1}},variants:{type:"object",additionalProperties:{type:"string"}},enter:{type:"object",required:["fade"],additionalProperties:!1,properties:{fade:{$ref:"#/$defs/time"},easing:{$ref:"#/$defs/ease"}}},ants:{anyOf:[{type:"boolean"},{$ref:"#/$defs/ids"}]},children:{$ref:"#/$defs/nodes"},layers:{$ref:"#/$defs/nodes"},series:{$ref:"#/$defs/series"}}},series:{type:"array",items:{anyOf:[{$ref:"#/$defs/seq"},Yt("transition",{type:"object",required:["presentation","timing"],additionalProperties:!1,properties:{presentation:{enum:["fade","none"]},timing:{anyOf:[{type:"object",required:["linear"],additionalProperties:!1,properties:{linear:{$ref:"#/$defs/time"}}},{type:"object",required:["spring"],additionalProperties:!1,properties:{spring:{type:"object",additionalProperties:!1,properties:{mass:{type:"number",exclusiveMinimum:0},damping:{type:"number",exclusiveMinimum:0},stiffness:{type:"number",exclusiveMinimum:0},overshootClamping:{type:"boolean"},duration:{$ref:"#/$defs/time"}}}}}]}}},{},!1)]}},seq:Yt("sequence",{$ref:"#/$defs/sequence"},{},!1),plan:{type:"object"},nodes:{type:"array",items:{anyOf:[{$ref:"#/$defs/seq"},Yt("series",{$ref:"#/$defs/series"},{},!1),Yt("layers",{$ref:"#/$defs/nodes"},{},!1),Yt("assemble",{type:"object",properties:{style:{enum:Yr},order:{enum:Qs}}}),Yt("disassemble",{type:"object",properties:{style:{enum:Hr},order:{enum:Qs}}}),Yt("travel",{type:"array",items:{anyOf:[{type:"string"},{$ref:"#/$defs/ids"}]},minItems:1},{each:{$ref:"#/$defs/time"},hold:{$ref:"#/$defs/time"},loop:{type:"boolean"}}),Yt("pulse",{$ref:"#/$defs/ids"},{loop:{type:"boolean"}}),Yt("ants",{anyOf:[{const:!0},{$ref:"#/$defs/ids"}]},{speed:{type:"number"},dash:{type:"array",items:{type:"number",exclusiveMinimum:0},minItems:2,maxItems:2}}),Yt("draw",{$ref:"#/$defs/ids"},{by:{enum:["stroke","grow"]},stagger:{$ref:"#/$defs/time"}}),Yt("type",{$ref:"#/$defs/ids"}),{type:"object",required:["move"],additionalProperties:!1,properties:{move:{type:"string"},from:{$ref:"#/$defs/time"},x:{$ref:"#/$defs/curve"},y:{$ref:"#/$defs/curve"},scale:{$ref:"#/$defs/curve"},opacity:{$ref:"#/$defs/curve"}}},{type:"object",required:["lift","by"],additionalProperties:!1,properties:{lift:{$ref:"#/$defs/ids"},by:{type:"number"},stagger:{$ref:"#/$defs/time"},to:{enum:["up","down"]},opacity:{$ref:"#/$defs/curve"},...Kf}},Yt("focus",{$ref:"#/$defs/focus"},{fade:{$ref:"#/$defs/time"}}),Yt("highlight",{$ref:"#/$defs/ids"},{fade:{$ref:"#/$defs/time"}}),Yt("camera",{anyOf:[{const:"fit"},{type:"object",required:["focus"],additionalProperties:!1,properties:{focus:{anyOf:[{type:"string"},{$ref:"#/$defs/ids"},{type:"array",items:{type:"number"},minItems:4,maxItems:4}]},zoom:{type:"number",exclusiveMinimum:0},margin:{type:"number"}}}]})]}}}},gl=["sequence","series","layers","assemble","disassemble","travel","pulse","ants","draw","type","move","lift","focus","highlight","camera"],Vf={morph:"the 2D morph is a later version's",diff:"diffs are a later version's",switch:"a look is a beat's: its variants"},Tn=["from","duration","easing"],Qr={sequence:[],series:[],layers:[],assemble:Tn,disassemble:Tn,travel:[...Tn,"each","hold","loop"],pulse:[...Tn,"loop"],ants:[...Tn,"speed","dash"],draw:[...Tn,"by","stagger"],type:Tn,move:["from","x","y","scale","opacity"],lift:[...Tn,"by","stagger","to","opacity"],focus:[...Tn,"fade"],highlight:[...Tn,"fade"],camera:Tn},$m=["name","from","offset","duration","loop","playbackRate","trimBefore","say","show","hide","focus","highlight","levels","variants","enter","ants","children","layers","series"],ht=n=>!!n&&typeof n=="object"&&!Array.isArray(n);function Ci(n){let e=[],t=(h,b,x)=>{e.push({severity:"error",path:h,message:b,...x?{hint:x}:{}})},s=(h,b,x)=>{for(let A of Object.keys(h))if(!b.includes(A)){let M=Bt(A,b);t(`${x}/${A}`,`unknown key "${A}"`,M?`did you mean "${M}"?`:void 0)}};if(!ht(n))return t("","a motion document is a map"),e;s(n,["isomotion","fps","seed","ambient","series","layers","markers"],""),n.isomotion!==1&&t("/isomotion","isomotion is 1");let r=typeof n.fps=="number"&&n.fps>0?n.fps:void 0;n.fps!==void 0&&r===void 0&&t("/fps","fps is a number over 0"),n.seed!==void 0&&!Number.isInteger(n.seed)&&t("/seed","seed is a whole number"),n.ambient!==void 0&&n.ambient!=="on"&&n.ambient!=="off"&&t("/ambient",'ambient is "on" or "off"');let o=(h,b,x={})=>{if(h===void 0)return;if(typeof h=="string"&&/f$/.test(h)&&r===void 0){t(b,`"${h}" is in frames: the document needs its fps`);return}let A=An(h,r);A===void 0?t(b,`${JSON.stringify(h)} isn't a time (ms, "1.2s", "450ms", "30f")`):A<0&&!x.negative&&t(b,"a time can't be negative")},i=(h,b,x)=>{if(h!==void 0&&!b.includes(h)){let A=typeof h=="string"?Bt(h,b):void 0;t(x,`${JSON.stringify(h)} isn't one of ${b.join(", ")}`,A?`did you mean "${A}"?`:void 0)}},a=(h,b,x={})=>{h!==void 0&&(typeof h!="number"||!Number.isFinite(h)||x.min!==void 0&&h<x.min||x.max!==void 0&&h>x.max||x.over!==void 0&&h<=x.over)&&t(b,`${JSON.stringify(h)} isn't a number${x.over!==void 0?` over ${x.over}`:x.min!==void 0?` from ${x.min}${x.max!==void 0?` to ${x.max}`:""}`:""}`)},l=(h,b)=>{if(h!==void 0){if(!Array.isArray(h)){t(b,"a list of ids");return}h.forEach((x,A)=>{typeof x!="string"&&t(`${b}/${A}`,"an id")})}},c=(h,b,x=[])=>{if(!ht(h)){t(b,"a spring is a map");return}s(h,["mass","damping","stiffness","overshootClamping",...x],b);for(let A of["mass","damping","stiffness"])a(h[A],`${b}/${A}`,{over:0});h.overshootClamping!==void 0&&typeof h.overshootClamping!="boolean"&&t(`${b}/overshootClamping`,"true or false")},f=(h,b)=>{if(h!==void 0){if(typeof h=="string"){i(h,Pi,b);return}if(ht(h)&&"bezier"in h){s(h,["bezier"],b),(!Array.isArray(h.bezier)||h.bezier.length!==4||h.bezier.some(x=>typeof x!="number"))&&t(`${b}/bezier`,"four numbers");return}if(ht(h)&&"spring"in h){s(h,["spring"],b),c(h.spring,`${b}/spring`);return}t(b,"an easing is a name, { bezier: [a, b, c, d] } or { spring: { \u2026 } }")}},u=(h,b)=>{if(h===void 0)return;if(!ht(h)){t(b,"a curve is { times, values }");return}s(h,["times","values","easing","extrapolateLeft","extrapolateRight"],b);let x=h.times,A=h.values;if(!Array.isArray(x)||!x.length)t(`${b}/times`,"a list of times");else{x.forEach((v,O)=>o(v,`${b}/times/${O}`,{negative:!0}));let M=x.map(v=>An(v,r));for(let v=1;v<M.length;v++)M[v]!==void 0&&M[v-1]!==void 0&&M[v]<=M[v-1]&&t(`${b}/times/${v}`,"times go up")}!Array.isArray(A)||A.some(M=>typeof M!="number")?t(`${b}/values`,"a list of numbers"):Array.isArray(x)&&A.length!==x.length&&t(`${b}/values`,`${A.length} values for ${x.length} times`),f(h.easing,`${b}/easing`),i(h.extrapolateLeft,sr,`${b}/extrapolateLeft`),i(h.extrapolateRight,sr,`${b}/extrapolateRight`)},d=(h,b)=>{if(h!==void 0){if(!ht(h)){t(b,"focus is { lit: [ids] }");return}s(h,["lit","scope","level","always"],b),h.lit===void 0&&t(`${b}/lit`,"what is lit"),l(h.lit,`${b}/lit`),l(h.always,`${b}/always`),i(h.scope,["all","links"],`${b}/scope`),a(h.level,`${b}/level`,{min:0,max:1})}},p=(h,b)=>{h!==void 0&&typeof h!="string"&&t(b,"text")},g=new Map;function m(h,b,x){if(!ht(h)){t(b,"a sequence is a map");return}if(s(h,$m,b),h.name!==void 0&&(typeof h.name!="string"||!/^[A-Za-z][\w-]*$/.test(h.name)?t(`${b}/name`,"a name is letters, digits, - and _, from a letter"):g.has(h.name)?t(`${b}/name`,`"${h.name}" is already a name (${g.get(h.name)})`):g.set(h.name,b)),x&&h.from!==void 0&&t(`${b}/from`,"in a series a sequence follows the one before","offset moves it"),!x&&h.offset!==void 0&&t(`${b}/offset`,"offset is for a series","use from"),o(h.from,`${b}/from`),o(h.offset,`${b}/offset`,{negative:!0}),o(h.trimBefore,`${b}/trimBefore`),ht(h.duration)){s(h.duration,["read"],`${b}/duration`);let A=h.duration.read;if(A!==!0&&!ht(A))t(`${b}/duration/read`,"true, or { base, perChar, min, max }");else if(ht(A)){s(A,["base","perChar","min","max"],`${b}/duration/read`);for(let M of["base","perChar","min","max"])a(A[M],`${b}/duration/read/${M}`,{min:0})}}else o(h.duration,`${b}/duration`);if(h.loop!==void 0&&typeof h.loop!="boolean"&&!(Number.isInteger(h.loop)&&h.loop>=1)&&t(`${b}/loop`,"true, false, or how many times"),a(h.playbackRate,`${b}/playbackRate`,{over:0}),h.say!==void 0)if(!ht(h.say))t(`${b}/say`,"say is a map");else{let A=h.say;s(A,["chapter","title","text","code","facts","color"],`${b}/say`);for(let M of["chapter","title","text","code","color"])p(A[M],`${b}/say/${M}`);A.facts!==void 0&&(!Array.isArray(A.facts)||A.facts.some(M=>!Array.isArray(M)||M.length!==2||M.some(v=>typeof v!="string")))&&t(`${b}/say/facts`,"a list of [name, value]")}for(let A of["show","hide","highlight"])l(h[A],`${b}/${A}`);if(d(h.focus,`${b}/focus`),h.levels!==void 0)if(!ht(h.levels))t(`${b}/levels`,"levels is a map: an id, and how much of it");else for(let[A,M]of Object.entries(h.levels))a(M,`${b}/levels/${A}`,{min:0,max:1});if(h.variants!==void 0)if(!ht(h.variants))t(`${b}/variants`,"variants is a map: an id, and the name of its look");else for(let[A,M]of Object.entries(h.variants))typeof M!="string"&&t(`${b}/variants/${A}`,`a look's name, or "" for its own`);h.enter!==void 0&&(ht(h.enter)?(s(h.enter,["fade","easing"],`${b}/enter`),h.enter.fade===void 0&&t(`${b}/enter/fade`,"how long the fade is"),o(h.enter.fade,`${b}/enter/fade`),f(h.enter.easing,`${b}/enter/easing`)):t(`${b}/enter`,"enter is { fade }")),h.ants!==void 0&&typeof h.ants!="boolean"&&l(h.ants,`${b}/ants`);for(let A of["children","layers"])h[A]!==void 0&&N(h[A],`${b}/${A}`);h.series!==void 0&&y(h.series,`${b}/series`)}function y(h,b){if(!Array.isArray(h)){t(b,"a series is a list");return}h.forEach((x,A)=>{let M=`${b}/${A}`;if(!ht(x)||Object.keys(x).length!==1||!("sequence"in x||"transition"in x)){t(M,"a series holds sequences and transitions");return}if("sequence"in x){m(x.sequence,`${M}/sequence`,!0);return}let v=x.transition,O=`${M}/transition`,C=$=>ht(h[$])&&"sequence"in h[$];if((!C(A-1)||!C(A+1))&&t(O,"a transition is between two sequences"),!ht(v)){t(O,"a transition is { presentation, timing }");return}s(v,["presentation","timing"],O),v.presentation===void 0?t(`${O}/presentation`,"a presentation"):i(v.presentation,["fade","none"],`${O}/presentation`),ht(v.timing)?"linear"in v.timing?(s(v.timing,["linear"],`${O}/timing`),o(v.timing.linear,`${O}/timing/linear`)):"spring"in v.timing?(s(v.timing,["spring"],`${O}/timing`),c(v.timing.spring,`${O}/timing/spring`,["duration"]),ht(v.timing.spring)&&o(v.timing.spring.duration,`${O}/timing/spring/duration`)):t(`${O}/timing`,"a timing is { linear } or { spring }"):t(`${O}/timing`,"a timing is { linear } or { spring }")})}function N(h,b){if(!Array.isArray(h)){t(b,"a list");return}h.forEach((x,A)=>{let M=`${b}/${A}`;if(!ht(x)){t(M,"a map");return}let v=gl.filter(P=>P in x);if(v.length!==1){let P=Object.keys(x).find(S=>S in Vf),k=Object.keys(x)[0],E=k?Bt(k,gl):void 0;t(M,P?`${P}: ${Vf[P]}`:v.length?`one of ${v.join(", ")}, not several`:`one of ${gl.join(", ")}`,!P&&!v.length&&E?`did you mean "${E}"?`:void 0);return}let O=v[0],C=x[O],$=`${M}/${O}`;s(x,[O,...Qr[O]],M),Qr[O].includes("from")&&o(x.from,`${M}/from`),Qr[O].includes("duration")&&(o(x.duration,`${M}/duration`),f(x.easing,`${M}/easing`));for(let P of["each","hold","stagger","fade"])Qr[O].includes(P)&&o(x[P],`${M}/${P}`);if(Qr[O].includes("loop")&&x.loop!==void 0&&typeof x.loop!="boolean"&&t(`${M}/loop`,"true or false"),O==="sequence")m(C,$,!1);else if(O==="series")y(C,$);else if(O==="layers")N(C,$);else if(O==="assemble"||O==="disassemble")ht(C)?(i(C.style,O==="assemble"?Yr:Hr,`${$}/style`),i(C.order,Qs,`${$}/order`),C.duration!==void 0&&t(`${$}/duration`,"its length is beside it","duration is the node's")):t($,`${O} is a map (its options)`);else if(O==="travel")!Array.isArray(C)||!C.length?t($,"a list of connectors"):C.forEach((P,k)=>{Array.isArray(P)?l(P,`${$}/${k}`):typeof P!="string"&&t(`${$}/${k}`,"a connector, or a list of them at once")});else if(O==="ants")C!==!0&&l(C,$),a(x.speed,`${M}/speed`),x.dash!==void 0&&(!Array.isArray(x.dash)||x.dash.length!==2||x.dash.some(P=>typeof P!="number"||P<=0))&&t(`${M}/dash`,"two numbers over 0: on, off");else if(O==="move"){typeof C!="string"&&t($,"an id");for(let P of["x","y","scale","opacity"])u(x[P],`${M}/${P}`)}else if(O==="focus")d(C,$);else if(O==="camera"){if(C!=="fit")if(!ht(C))t($,'"fit", or { focus, zoom, margin }');else{s(C,["focus","zoom","margin"],$),a(C.zoom,`${$}/zoom`,{over:0}),a(C.margin,`${$}/margin`);let P=C.focus;typeof P=="string"||Array.isArray(P)&&(P.every(k=>typeof k=="string")||P.length===4&&P.every(k=>typeof k=="number"))||t(`${$}/focus`,"an id, some ids, or a box [x, y, w, h]")}}else l(C,$);O==="draw"&&i(x.by,["stroke","grow"],`${M}/by`),O==="lift"&&(x.by===void 0&&t(`${M}/by`,"how far apart"),a(x.by,`${M}/by`),i(x.to,["up","down"],`${M}/to`),u(x.opacity,`${M}/opacity`))})}if(n.series!==void 0&&y(n.series,"/series"),n.layers!==void 0&&N(n.layers,"/layers"),n.markers!==void 0)if(!ht(n.markers))t("/markers","markers is a map");else for(let[h,b]of Object.entries(n.markers))if(typeof b=="string"&&/^[A-Za-z][\w-]*([+-].+)?$/.test(b)){let x=/^([A-Za-z][\w-]*?)(?:([+-])(\d.*))?$/.exec(b);if(x&&(g.has(x[1])?x[1]:void 0))x[3]!==void 0&&o(x[3],`/markers/${h}`);else if(!g.has(b)){let v=Bt(x?.[1]??b,g.keys());t(`/markers/${h}`,`no sequence is named "${x?.[1]??b}"`,v?`did you mean "${v}"?`:void 0)}}else o(b,`/markers/${h}`);return e}var fn=n=>Math.round(n*100)/100||0,Pt=n=>Math.round(n*1e4)/1e4||0,cn=n=>Math.max(0,Math.min(1,n)),ir=(n,e,t)=>n+(e-n)*t,Mm=250,bl=class{items=new Map;labels=new Map;routes=new Map;tokens=[];pulses=[];outlines=[];variants={};marks=1;at(e,t){let s=e.get(t);return s||e.set(t,s={}),s}item(e,t){let s=this.at(this.items,e);t.opacity!==void 0&&(s.opacity=(s.opacity??1)*t.opacity),t.dx&&(s.dx=(s.dx??0)+t.dx),t.dy&&(s.dy=(s.dy??0)+t.dy),t.scale!==void 0&&(s.scale=(s.scale??1)*t.scale,s.about=t.about??s.about),t.clip&&(s.clip=t.clip)}label(e,t){let s=this.at(this.labels,e);t.opacity!==void 0&&(s.opacity=(s.opacity??1)*t.opacity),t.dx&&(s.dx=(s.dx??0)+t.dx),t.dy&&(s.dy=(s.dy??0)+t.dy),t.typed!==void 0&&(s.typed=Math.min(s.typed??1,t.typed))}route(e,t){let s=this.at(this.routes,e);t.opacity!==void 0&&(s.opacity=(s.opacity??1)*t.opacity),t.drawn!==void 0&&t.drawn<(s.drawn??1)&&(s.drawn=t.drawn,s.by=t.by),t.ants&&(s.ants=t.ants)}add(e){for(let[t,s]of Object.entries(e.items??{}))this.item(t,s);for(let[t,s]of Object.entries(e.labels??{}))this.label(t,s);for(let[t,s]of Object.entries(e.routes??{}))this.route(t,s);e.marks&&(this.marks*=e.marks.opacity),this.tokens.push(...e.tokens??[]),this.pulses.push(...e.pulses??[])}state(e){let t={},s=(f,u)=>{let d={};for(let[p,g]of f){let m=u(g);Object.keys(m).length&&(d[p]=m)}return d},r=f=>Object.keys(f).length>0,o=f=>f===void 0||Pt(f)>=1?{}:{opacity:Pt(Math.max(0,f))},i=f=>({...fn(f.dx??0)?{dx:fn(f.dx)}:{},...fn(f.dy??0)?{dy:fn(f.dy)}:{}}),a=s(this.items,f=>({...o(f.opacity),...i(f),...f.scale!==void 0&&Pt(f.scale)!==1?{scale:Pt(f.scale),...f.about?{about:f.about}:{}}:{},...f.clip?{clip:f.clip}:{}})),l=s(this.labels,f=>({...o(f.opacity),...f.typed!==void 0&&f.typed<1?{typed:Pt(f.typed)}:{},...i(f)})),c=s(this.routes,f=>{let u=f.opacity!==void 0&&Pt(f.opacity)<=0,d=f.drawn!==void 0&&f.drawn<1;return{...o(f.opacity),...d?{drawn:Pt(f.drawn),...f.by?{by:f.by}:{}}:{},...f.ants&&!u&&!d?{ants:f.ants}:{}}});return r(a)&&(t.items=a),r(l)&&(t.labels=l),r(c)&&(t.routes=c),Pt(this.marks)<1&&(t.marks={opacity:Pt(this.marks)}),this.tokens.length&&(t.tokens=this.tokens),this.pulses.length&&(t.pulses=this.pulses),this.outlines.length&&(t.outlines=this.outlines),r(this.variants)&&(t.variants=this.variants),e&&(t.camera=e),t}};function qf(n,e,t={}){let s=Ci(e),r=fs(n),o=e.fps,i=Ni(n.raw),a=()=>({ok:!1,diags:s,duration:0,beats:[],markers:{},at:()=>({}),cues:()=>{},beatAt:()=>{},startOf:()=>{}});if(s.length)return a();let l=(w,z,G)=>{s.push({severity:"error",path:w,message:z,...G?{hint:G}:{}})},c=(w,z)=>w===void 0?z:An(w,o),f=new Map(r.pieces.map(w=>[w.id,w])),u=new Set(r.routes.map(w=>w.id)),d=new Set(Object.keys(r.notes)),p=new Map(n.routes.map(w=>[w.id,w.kind])),g=[...f.keys(),...u,...d],m=new Set(g),y=new Map;for(let[w,z]of Object.entries(r.notes))z!==void 0&&y.set(z,[...y.get(z)??[],w]);let N={any:m,thing:new Set(f.keys()),route:u},h={any:"thing, connector or note",thing:"thing",route:"connector"},b=(w,z,G="any")=>{if(!N[G].has(w)){let ae=Bt(w,N[G]);l(z,`no ${h[G]} "${w}" in this drawing`,ae?`did you mean "${ae}"?`:void 0)}},x=(w,z,G="any")=>w?.forEach((ae,le)=>b(ae,`${z}/${le}`,G)),A=new Map(n.layout.items.map(w=>[w.id,Rt(w.box).map(z=>[fn(z[0]),fn(z[1])])])),M=new Map;function v(w,z){let G="from"in w?c(w.from,0):0,ae="duration"in w?c(w.duration,NaN):NaN,le=Number.isFinite(ae);if("sequence"in w){let ue=w.sequence;return c(ue.from,0)+P(ue,`${z}/sequence`)}if("series"in w)return k(w.series,`${z}/series`).end;if("layers"in w)return Math.max(0,...w.layers.map((ue,se)=>v(ue,`${z}/layers/${se}`)));if("assemble"in w||"disassemble"in w){let ue="assemble"in w?"assemble":"disassemble",se="assemble"in w?w.assemble:w.disassemble,be=M.get(w);return be||M.set(w,be=Zs(r,ue,{seed:e.seed??1,...se,...le?{duration:ae}:{}})),G+be.duration}return"draw"in w?G+(le?ae:400)+Math.max(0,w.draw.length-1)*c(w.stagger,0):"lift"in w?G+Math.max(le?ae:750,...w.opacity?.times.map(ue=>An(ue,o))??[])+Math.max(0,w.lift.length-1)*c(w.stagger,0):le?G+ae:"travel"in w?w.loop?G:G+w.travel.length*c(w.each,1150):"pulse"in w?w.loop?G:G+1500:"type"in w?G+400:"camera"in w?G+900:"move"in w?G+Math.max(0,...[w.x,w.y,w.scale,w.opacity].flatMap(ue=>ue?.times.map(se=>An(se,o))??[])):G}let O=(w,z)=>Math.max(0,...(w.children??[]).map((G,ae)=>v(G,`${z}/children/${ae}`)),...(w.layers??[]).map((G,ae)=>v(G,`${z}/layers/${ae}`)),w.series?k(w.series,`${z}/series`).end:0),C=new Map;function $(w,z){let G=C.get(w);if(G!==void 0)return G;let ae;return w.duration!==void 0&&typeof w.duration=="object"?ae=Zr(w.say,w.duration.read):ae=w.duration!==void 0?c(w.duration,0):O(w,z),w.duration===void 0&&ae<=0&&w.say&&(ae=Zr(w.say,!0)),ae<=0&&l(`${z}/duration`,"how long is it? (nothing in it says)"),C.set(w,ae),ae}let P=(w,z)=>{let G=$(w,z),ae=w.playbackRate??1;return w.loop===!0?G/ae:(typeof w.loop=="number"?G*w.loop:G)/ae};function k(w,z){let G=[],ae=0,le;return w.forEach((ue,se)=>{if("transition"in ue){let he=ue.transition,Oe=he.timing,T=he.presentation==="none"?0:"linear"in Oe?c(Oe.linear,0):c(Oe.spring.duration,Em(Oe.spring));le={t:he,length:T};return}let be=ue.sequence,Se=`${z}/${se}/sequence`,te=P(be,Se),xe=Math.max(0,ae+c(be.offset,0)-(le?.length??0));le&&G.length&&le.length>Math.min(G[G.length-1].end-G[G.length-1].start,te)&&l(`${z}/${se-1}/transition/timing`,"a transition is no longer than either side of it"),G.push({s:be,path:Se,start:xe,end:xe+te,...le?{into:le}:{}}),ae=xe+te,le=void 0}),{list:G,end:Math.max(0,...G.map(ue=>ue.end))}}let E=k(e.series??[],"/series"),S=Math.max(0,...(e.layers??[]).map((w,z)=>v(w,`/layers/${z}`))),F=Math.max(E.end,S);F<=0&&!s.length&&l("","a motion document has a series, or layers, that last");let D=new Map,H=[],X=r.viewBox,Y=(w,z,G)=>{let ae=G!==void 0?1/G:Math.max((w.w+z*2)/X[2],(w.h+z*2)/X[3]);return[w.x+w.w/2-X[2]*ae/2,w.y+w.h/2-X[3]*ae/2,X[2]*ae,X[3]*ae]};function L(w,z,G){let ae=le=>G?{at:G.at+le/G.rate,rate:G.rate}:void 0;if("sequence"in w){U(w.sequence,`${z}/sequence`,ae(c(w.sequence.from,0)),!1);return}if("series"in w){for(let le of k(w.series,`${z}/series`).list)U(le.s,le.path,ae(le.start),!1);return}if("layers"in w){w.layers.forEach((le,ue)=>L(le,`${z}/layers/${ue}`,G));return}if("travel"in w)w.travel.forEach((le,ue)=>(Array.isArray(le)?le:[le]).forEach((se,be)=>b(se.split(":")[0],`${z}/travel/${ue}${Array.isArray(le)?`/${be}`:""}`,"route")));else if("pulse"in w)x(w.pulse,`${z}/pulse`,"thing");else if("ants"in w)w.ants!==!0&&x(w.ants,`${z}/ants`,"route");else if("draw"in w)x(w.draw,`${z}/draw`,"route");else if("type"in w)x(w.type,`${z}/type`);else if("move"in w)b(w.move,`${z}/move`,"thing");else if("lift"in w)x(w.lift,`${z}/lift`,"thing");else if("focus"in w)q(w.focus,`${z}/focus`);else if("highlight"in w)x(w.highlight,`${z}/highlight`,"thing");else if("camera"in w){let le=w.camera,ue=c(w.duration,900);if(!G){l(`${z}/camera`,"a camera can't be in a loop");return}let se=X;if(le!=="fit"){let be=le.focus;if(Array.isArray(be)&&typeof be[0]=="number")se=Y({x:be[0],y:be[1],w:be[2],h:be[3]},le.margin??0,le.zoom);else{let Se=typeof be=="string"?[be]:be;Se.forEach((xe,he)=>b(xe,`${z}/camera/focus${typeof be=="string"?"":`/${he}`}`,"thing"));let te=Se.map(xe=>f.get(xe)?.bbox).filter(xe=>!!xe);if(te.length){let xe=Math.min(...te.map(Oe=>Oe.x)),he=Math.min(...te.map(Oe=>Oe.y));se=Y({x:xe,y:he,w:Math.max(...te.map(Oe=>Oe.x+Oe.w))-xe,h:Math.max(...te.map(Oe=>Oe.y+Oe.h))-he},le.margin??40,le.zoom)}}}H.push({at:G.at+c(w.from,0)/G.rate,over:ue/G.rate,ease:On(w.easing,ue,"settle"),to:se})}}let q=(w,z)=>{w&&(x(w.lit,`${z}/lit`),x(w.always,`${z}/always`))};function U(w,z,G,ae){if(w.name!==void 0&&G&&D.set(w.name,G.at),!ae)for(let se of["show","hide","say","enter","focus","highlight","levels","variants","ants"])w[se]!==void 0&&l(`${z}/${se}`,`${se} is for a sequence of the document's own series`,se==="focus"||se==="highlight"||se==="ants"?`here, a child: { ${se}: \u2026 }`:void 0);x(w.show,`${z}/show`),x(w.hide,`${z}/hide`),x(w.highlight,`${z}/highlight`,"thing"),q(w.focus,`${z}/focus`);for(let se of Object.keys(w.levels??{}))se!=="*"&&b(se,`${z}/levels/${se}`);for(let[se,be]of Object.entries(w.variants??{})){b(se,`${z}/variants/${se}`,"thing");let Se=n.rendered.looks?.[se]??[];if(f.has(se)&&be!==""&&!Se.includes(be)){let te=Bt(be,Se);l(`${z}/variants/${se}`,Se.length?`${se} has no look "${be}" (it has ${Se.join(", ")})`:`${se} declares no looks (variants: in the diagram)`,te?`did you mean "${te}"?`:void 0)}}Array.isArray(w.ants)&&x(w.ants,`${z}/ants`,"route");let le=w.playbackRate??1,ue=G&&!w.loop?{at:G.at-c(w.trimBefore,0)/(G.rate*le),rate:G.rate*le}:void 0;if((w.children??[]).forEach((se,be)=>L(se,`${z}/children/${be}`,ue)),(w.layers??[]).forEach((se,be)=>L(se,`${z}/layers/${be}`,ue)),w.series)for(let se of k(w.series,`${z}/series`).list)U(se.s,se.path,ue&&{at:ue.at+se.start/ue.rate,rate:ue.rate},!1)}for(let w of E.list)U(w.s,w.path,{at:w.start,rate:1},!0);(e.layers??[]).forEach((w,z)=>L(w,`/layers/${z}`,{at:0,rate:1})),H.sort((w,z)=>w.at-z.at);let Z={};for(let[w,z]of Object.entries(e.markers??{})){let G=An(z,o);if(G!==void 0){Z[w]=G;continue}let ae=String(z),le=[...D.keys()].filter(be=>ae===be||ae.startsWith(be+"+")||ae.startsWith(be+"-")).sort((be,Se)=>Se.length-be.length)[0];if(le===void 0){l(`/markers/${w}`,`"${ae}" isn't a moment of this document`);continue}let ue=ae.slice(le.length),se=ue?An(ue.slice(1),o):0;if(se===void 0){l(`/markers/${w}`,`"${ue}" isn't a time`);continue}Z[w]=D.get(le)+(ue[0]==="-"?-se:se)}if(s.length)return a();let I=E.list.map((w,z)=>({name:w.s.name??`beat-${z+1}`,index:z,start:w.start,end:w.end,...w.s.say?{say:w.s.say}:{}})),_=new Map;for(let w of E.list){for(let z of w.s.show??[])_.has(z)||_.set(z,!1);for(let z of w.s.hide??[])_.has(z)||_.set(z,!0)}let K=[new Map(_)];for(let w of E.list){let z=new Map(K[K.length-1]);for(let G of w.s.show??[])z.set(G,!0);for(let G of w.s.hide??[])z.set(G,!1);K.push(z)}let J=[new Map];for(let w of E.list){let z=new Map(J[J.length-1]);for(let[G,ae]of Object.entries(w.s.variants??{}))z.set(G,ae);J.push(z)}let de=(w,z)=>!w||w.lit.includes(z)||w.always?.includes(z)||w.scope==="links"&&f.has(z)?1:w.level??.12,ce=(w,z)=>{let G=w<0?void 0:E.list[w].s.levels;return G?G[z]??G["*"]??1:1},W=(w,z)=>(K[w+1].get(z)===!1?0:1)*(w<0?1:de(E.list[w].s.focus,z))*ce(w,z),ne=(w,z)=>{let G=r.notes[z];if(G===void 0)return W(w,z);let ae=w<0?void 0:E.list[w].s.levels?.[z];return W(w,G)*(K[w+1].get(z)===!1?0:1)*(ae??1)},Ae=w=>{let z=-1;for(let G=0;G<E.list.length;G++)E.list[G].start<=w&&(z=G);return z},Be=(w,z)=>{let G=E.list[w],ae=z-G.start;if(G.into&&G.into.length>0){let se=G.into.t.timing;return"spring"in se?ae>=G.into.length?1:cn(rr(ae,{...se.spring,overshootClamping:!0})/rr(G.into.length,{...se.spring,overshootClamping:!0})):cn(ae/G.into.length)}let le=G.s.enter;if(!le)return 1;let ue=c(le.fade,0);return ue<=0?1:On(le.easing,ue,"ease")(cn(ae/ue))};function R(w,z,G,ae,le){if("sequence"in w){let Se=w.sequence,te=c(Se.from,0);ze(Se,z-te,G-te,ye(Se,ae-te),le);return}if("series"in w){for(let Se of k(w.series,"").list)ze(Se.s,z-Se.start,G-Se.start,Se.end-Se.start,le);return}if("layers"in w){for(let Se of w.layers)R(Se,z,G,ae,le);return}let ue=c("from"in w?w.from:void 0,0),se=z-ue;if("assemble"in w||"disassemble"in w){le.sum.add(M.get(w).at(se));return}if("draw"in w){let Se=Math.max(1,c(w.duration,400)),te=c(w.stagger,0),xe=On(w.easing,Se,"ease-out");w.draw.forEach((he,Oe)=>{let T=xe(cn((se-Oe*te)/Se));T<=0?(le.sum.route(he,{opacity:0,drawn:0}),le.sum.label(he,{opacity:0})):T<1&&(le.sum.route(he,{drawn:T,...w.by?{by:w.by}:{}}),le.sum.label(he,{opacity:T}))});return}if("type"in w){let Se=c(w.duration,400),te=On(w.easing,Se,"linear")(cn(se/Math.max(1,Se)));if(te<1)for(let xe of w.type)le.sum.label(xe,te<=0?{opacity:0}:{typed:te});return}if("move"in w){let Se=T=>T?or(T,se,o):void 0,te=Se(w.x)??0,xe=Se(w.y)??0,he=Se(w.scale),Oe=Se(w.opacity);le.sum.item(w.move,{dx:te,dy:xe,...he===void 0?{}:{scale:he,about:f.get(w.move).foot},...Oe===void 0?{}:{opacity:cn(Oe)}});for(let T of[w.move,...y.get(w.move)??[]])le.sum.label(T,{dx:te,dy:xe,...Oe===void 0?{}:{opacity:cn(Oe)}});return}if("lift"in w){let Se=c(w.stagger,0),te=Math.max(1,c(w.duration,750)),xe=On(w.easing,te,"ease-out"),he=w.to==="down",Oe=w.lift.length;w.lift.forEach((T,V)=>{let j=se-(he?Oe-1-V:V)*Se,re=xe(cn(j/te)),fe=(V+1)*w.by*(he?re:-re),Ee=w.opacity?cn(or(w.opacity,j,o)):1;if(!(!fe&&Ee>=1)){le.sum.item(T,{dy:fe,opacity:Ee});for(let ve of[T,...y.get(T)??[]])le.sum.label(ve,{dy:fe,opacity:Ee})}});return}if("camera"in w)return;let be=w.duration===void 0?Math.max(0,ae-ue):c(w.duration,0);if(!(se<0||se>be)){if("focus"in w||"highlight"in w){let Se=Math.max(1,c(w.fade,Mm)),te=cn(Math.min(se/Se,w.duration===void 0?1:(be-se)/Se)),xe=On(w.easing,Se,"linear")(te);if("focus"in w)we(w.focus,xe,le.sum);else for(let he of w.highlight)le.shown(he)&&ge(he,xe,le.sum);return}if("ants"in w){je(w.ants===!0?[...u]:w.ants,le,w.speed,w.dash);return}if("pulse"in w){let te=w.loop?ee(G-ue,1500,le)/1500:se/Math.max(1,w.duration===void 0?1500:be);if(te<0||te>=1)return;for(let xe of w.pulse)if(le.shown(xe)){let he=f.get(xe),Oe=he.bbox.w*.5*(.7+te*.6);le.sum.pulses.push({x:fn(he.foot[0]),y:fn(he.foot[1]),rx:fn(Oe),ry:fn(Oe*.58),opacity:Pt(1-te)})}return}if("travel"in w){let Se=c(w.each,1150),te=c(w.hold,w.loop?700:0),xe=w.travel.length*Se+te,he=w.loop?ee(G-ue,xe,le):se,Oe=Math.floor(he/Se);if(Oe>=w.travel.length)return;let T=On(w.easing,Se,"ease-in-out")((he-Oe*Se)/Se),V=w.travel[Oe];for(let j of Array.isArray(V)?V:[V]){let[re,fe]=j.split(":");le.shown(re)&&le.sum.tokens.push({route:re,at:Pt(T),...fe?{kind:fe}:{}})}}}}let ee=(w,z,G)=>G.off?0:(w%z+z)%z,ge=(w,z,G)=>{Pt(z)>0&&A.has(w)&&G.outlines.push({id:w,points:A.get(w),...Pt(z)<1?{opacity:Pt(z)}:{}})},we=(w,z,G)=>{for(let ae of g){let le=d.has(ae)&&!w.lit.includes(ae)&&!w.always?.includes(ae)?r.notes[ae]:void 0,ue=ir(1,de(w,le??ae),z);ue>=1||(f.has(ae)?(G.item(ae,{opacity:ue}),G.label(ae,{opacity:ue})):u.has(ae)?(G.route(ae,{opacity:ue}),G.label(ae,{opacity:ue})):G.label(ae,{opacity:ue}))}},je=(w,z,G=Wr,ae)=>{for(let le of w){let ue=Jr(p.get(le)??"",{dash:ae,kinds:t.kinds,still:t.still});if(!ue)continue;let se=ue[0]+ue[1],be=ee(G*z.A/1e3,se,z);z.sum.route(le,{ants:{dash:ue,offset:fn(be)}})}},ye=(w,z)=>w.loop===!0?Math.max(0,z):P(w,"");function ze(w,z,G,ae,le){if(z<0||z>ae||z===ae&&ae<F&&ae>0&&w.loop)return;let ue=w.playbackRate??1,se=$(w,""),be=c(w.trimBefore,0),Se=w.loop&&se>0?z*ue%se:z*ue,te=Se+be,xe=G*ue+be;for(let he of w.children??[])R(he,te,xe,se+be,le);for(let he of w.layers??[])R(he,te,xe,se+be,le);if(w.series)for(let he of k(w.series,"").list)ze(he.s,te-he.start,xe-he.start,he.end-he.start,le)}function Pe(w,z={}){let G=Math.max(0,Math.min(F,Number.isFinite(w)?w:0)),ae=z.ambient==="off"||e.ambient==="off"&&z.ambient===void 0,le=typeof z.ambient=="number"?z.ambient:G,ue=new bl,se=Ae(G),be=se<0?1:Be(se,G),Se=(j,re)=>se<0?re(-1,j):be>=1?re(se,j):ir(re(se-1,j),re(se,j),be),te=j=>(se<0?K[0]:K[se+1]).get(j)!==!1;if(_.size||E.list.some(j=>j.s.focus||j.s.levels))for(let j of g){let re=Se(j,d.has(j)?ne:W);re>=1||(f.has(j)&&ue.item(j,{opacity:re}),u.has(j)&&ue.route(j,{opacity:re}),ue.label(j,{opacity:re}))}if(se>=0)for(let j of J[J.length-1].keys()){let re=J[se].get(j)??"",fe=J[se+1].get(j)??"",Ee={};re&&be<1&&(Ee[re]=Pt(1-be)),fe&&(Ee[fe]=Pt((Ee[fe]??0)+be));for(let ve of Object.keys(Ee))Ee[ve]<=0&&delete Ee[ve];Object.keys(Ee).length&&(ue.variants[j]=Ee)}if(se>=0){let j=new Set(E.list[se].s.highlight??[]),re=new Set(se>0&&be<1?E.list[se-1].s.highlight??[]:[]);for(let fe of new Set([...re,...j]))ge(fe,ir(re.has(fe)?1:0,j.has(fe)?1:0,be),ue)}let xe={sum:ue,shown:te,off:ae,A:le},he=se>=0?E.list[se].s.ants:void 0,Oe=he===void 0?i:void 0;he?je(he===!0?[...u]:he,xe):Oe&&je(Oe.ids??[...u],xe,Oe.speed,Oe.dash),E.list.forEach((j,re)=>{G>=j.start&&(G<j.end||re===se&&G<=j.end)&&ze(j.s,G-j.start,le-j.start,j.end-j.start,xe)});for(let j of e.layers??[])R(j,G,le,F,xe);let T;for(let j of H){if(j.at>G)break;let re=j.over<=0?1:j.ease(cn((G-j.at)/j.over)),fe=T??X;if(re>=1){T=j.to;continue}let Ee=fe[2],ve=j.to[2],We=Math.exp(ir(Math.log(Ee),Math.log(ve),re)),Ie=Math.abs(ve-Ee)<1e-6?re:(We-Ee)/(ve-Ee),Re=ir(fe[0]+fe[2]/2,j.to[0]+j.to[2]/2,Ie),De=ir(fe[1]+fe[3]/2,j.to[1]+j.to[3]/2,Ie),Ke=We*X[3]/X[2];T=[Re-We/2,De-Ke/2,We,Ke]}let V=T?.map(fn);return ue.state(V&&V.some((j,re)=>Math.abs(j-X[re])>.005)?V:void 0)}let ke=w=>{let z=Ae(Math.max(0,Math.min(F,w)));return z<0?void 0:I[z]};return{ok:!0,diags:s,duration:F,beats:I,markers:Z,at:Pe,beatAt:ke,startOf:w=>D.get(w)??I.find(z=>z.name===w)?.start,cues(w){let z=ke(w);if(!z)return;let G=Math.max(0,Math.min(F,w));return{beat:z.name,index:z.index,of:I.length,progress:Pt(cn((G-z.start)/Math.max(1,z.end-z.start))),...z.say?{say:z.say,...z.say.chapter!==void 0?{chapter:z.say.chapter}:{},...z.say.color!==void 0?{color:z.say.color}:{}}:{}}}}}function Em(n){let e=n.mass??1,t=n.stiffness??100,s=n.damping??10,r=Math.sqrt(t/e),o=Math.min(1,s/(2*Math.sqrt(t*e)));return Math.ceil(Math.log(200)/(o*r)*1e3*(o>=1?1.6:1))}function Uf(n){let{steps:e,vis:t}=n.steps,s=e.map((r,o)=>{let i=[],a=[];for(let[u,d]of Object.entries(t))(o===0?!d.includes(!0):d[o-1]&&!d[o])?a.push(u):o>0&&d[o]&&!d[o-1]&&i.push(u);let l=[];r.phases.length&&l.push({travel:r.phases.map(u=>u.length===1?u[0].route:u.map(d=>d.route)),each:1150,hold:700,loop:!0});let c=(n.raw.steps??[])[o]?.pulse?.filter(u=>n.layout.byId.has(u))??[];c.length&&l.push({pulse:c,loop:!0});let f={name:`step-${r.n}`,duration:r.duration,say:{title:r.heading,...r.caption?{text:r.caption}:{},...r.command?{code:r.command}:{}}};return i.length&&(f.show=i),a.length&&(f.hide=a),l.length&&(f.children=l),{sequence:f}});return{isomotion:1,...s.length?{series:s}:{}}}var Wf=new Set(["fill","stroke","stroke-width","stroke-dasharray","stroke-linecap","stroke-linejoin","opacity","fill-opacity","stroke-opacity","font-size","font-weight","font-family","letter-spacing","text-anchor","dominant-baseline","paint-order","display","stop-color","stop-opacity"]),Tm=new Set("cursor pointer-events transition animation transform-box transform-origin user-select".split(" "));function Am(n,e){let t={classes:[],not:[],attrs:[],child:e},s=n,r=i=>{let a=i.exec(s);return a&&(s=s.slice(a[0].length)),a},o=r(/^[a-zA-Z][\w-]*/);for(o?t.tag=o[0]:r(/^\*/);s;){let i;if(i=r(/^\.([\w-]+)/))t.classes.push(i[1]);else if(i=r(/^:not\(\.([\w-]+)\)/))t.not.push(i[1]);else if(i=r(/^\[([\w-]+)(?:="([^"]*)")?\]/))t.attrs.push([i[1],i[2]]);else throw new Error(`resolve: a selector it doesn't know: ${n}`)}return t}function Om(n){let e=n.replace(/\/\*[\s\S]*?\*\//g,"").replace(/@keyframes[^{]*\{(?:[^{}]*\{[^}]*\})*[^{}]*\}/g,"").replace(/@media[^{]*\{(?:[^{}]*\{[^}]*\})*[^{}]*\}/g,"");if(/@/.test(e.replace(/"[^"]*"/g,"")))throw new Error("resolve: an at-rule it doesn't know");let t=[];for(let s of e.matchAll(/([^{}]+)\{([^{}]*)\}/g)){let r=s[2].split(";").map(o=>o.trim()).filter(Boolean).map(o=>{let i=o.indexOf(":"),a=o.slice(0,i).trim(),l=o.slice(i+1).trim();return[a,l.replace(/\s*!important$/,""),/!important$/.test(l)]});for(let o of r)if(!o[0].startsWith("--")&&!Wf.has(o[0])&&!Tm.has(o[0]))throw new Error(`resolve: a property it doesn't know: ${o[0]}`);for(let o of s[1].split(",").map(i=>i.trim()).filter(Boolean)){if(o.includes(":root")||o.includes("::")||/^(html|body)\b/.test(o))continue;let a=o.replace(/\s*>\s*/g," >").split(/\s+/).map(c=>Am(c.replace(/^>/,""),c.startsWith(">"))),l=a.reduce((c,f)=>c+10*(f.classes.length+f.not.length+f.attrs.length)+(f.tag?1:0),0);t.push({parts:a,spec:l,order:t.length,decls:r})}}return t}function Nm(n){let e={name:"#root",attrs:[],children:[]},t=e;for(let s of n.matchAll(/<\/[a-zA-Z][\w:-]*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g)){if(s[4]!==void 0){t.children.push(s[4]);continue}if(s[1]===void 0){t=t.parent;continue}let r={name:s[1],attrs:[...s[2].matchAll(/([\w:-]+)="([^"]*)"/g)].map(o=>[o[1],o[2]]),children:[],parent:t};t.children.push(r),s[3]||(t=r)}return e.children[0]}var Jf=n=>typeof n=="string"?n:`<${n.name}${n.attrs.map(([e,t])=>` ${e}="${t}"`).join("")}${n.children.length||n.name==="g"?`>${n.children.map(Jf).join("")}</${n.name}>`:"/>"}`,eo=(n,e)=>n.attrs.find(t=>t[0]===e)?.[1],ar=(n,e,t)=>{let s=n.attrs.find(r=>r[0]===e);s?s[1]=t:n.attrs.push([e,t])},Rm=n=>(eo(n,"class")??"").split(/\s+/).filter(Boolean);function Pm(n,e){if(e.tag&&e.tag!==n.name)return!1;let t=Rm(n);return e.classes.every(s=>t.includes(s))&&!e.not.some(s=>t.includes(s))&&e.attrs.every(([s,r])=>{let o=eo(n,s);return o!==void 0&&(r===void 0||o===r)})}function yl(n,e,t=e.length-1){if(!Pm(n,e[t]))return!1;if(t===0)return!0;let s=n.parent;if(e[t].child)return!!s&&s.name!=="#root"&&yl(s,e,t-1);for(;s&&s.name!=="#root";s=s.parent)if(yl(s,e,t-1))return!0;return!1}var ds=n=>n.endsWith("%")?parseFloat(n)/100:parseFloat(n);function Cm(n,e,t,s){let r=(1-Math.abs(2*t-1))*e,o=(n%360+360)%360/60,i=r*(1-Math.abs(o%2-1)),a=t-r/2,[l,c,f]=o<1?[r,i,0]:o<2?[i,r,0]:o<3?[0,r,i]:o<4?[0,i,r]:o<5?[i,0,r]:[r,0,i];return[(l+a)*255,(c+a)*255,(f+a)*255,s]}function Xf(n,e){let t=[],s=0,r="";for(let o of n)o==="("&&s++,o===")"&&s--,o===e&&s===0?(t.push(r.trim()),r=""):r+=o;return[...t,r.trim()].filter(Boolean)}var Yf={transparent:[0,0,0,0],black:[0,0,0,1],white:[255,255,255,1]};function Ii(n){let e=n.trim();if(Object.hasOwn(Yf,e))return Yf[e];let t=/^#([0-9a-f]{3,8})$/i.exec(e);if(t){let s=t[1].length<6?[...t[1]].map(r=>r+r).join(""):t[1];return[parseInt(s.slice(0,2),16),parseInt(s.slice(2,4),16),parseInt(s.slice(4,6),16),s.length===8?parseInt(s.slice(6),16)/255:1]}if(t=/^hsla?\((.*)\)$/.exec(e),t){let[s,r]=t[1].split("/").map(c=>c.trim()),[o,i,a,l]=s.split(/[\s,]+/);return Cm(parseFloat(o),ds(i),ds(a),r!==void 0?ds(r):l!==void 0?ds(l):1)}if(t=/^rgba?\((.*)\)$/.exec(e),t){let[s,r,o,i]=t[1].split(/[\s,/]+/).filter(Boolean);return[ds(s),ds(r),ds(o),i===void 0?1:ds(i)]}if(t=/^color-mix\(in srgb\s*,(.*)\)$/.exec(e),t){let[s,r]=Xf(t[1],",").map(f=>{let u=/^(.*?)\s+([\d.]+)%$/.exec(f);return u?{c:Ii(u[1]),p:Number(u[2])/100}:{c:Ii(f),p:void 0}});if(!s?.c||!r?.c)return;let o=s.p??(r.p===void 0?.5:1-r.p),i=r.p??1-o,a=o+i,l=(s.c[3]*o+r.c[3]*i)/a,c=f=>l===0?0:(s.c[f]*s.c[3]*o+r.c[f]*r.c[3]*i)/a/l;return[c(0),c(1),c(2),l*Math.min(1,a)]}}var Hf=n=>"#"+[n[0],n[1],n[2]].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")).join(""),Im=n=>String(Math.round(n*1e4)/1e4);function xl(n,e,t=0){if(t>20)throw new Error(`resolve: a custom property in a loop: ${n}`);let s=n.indexOf("var(");if(s<0)return n;let r=0,o=s+3;do n[o]==="("&&r++,n[o]===")"&&r--,o++;while(r>0&&o<n.length);let[i,...a]=Xf(n.slice(s+4,o-1),","),l=e.get(i)??(a.length?a.join(","):void 0);if(l===void 0)throw new Error(`resolve: no value for ${i}`);return xl(n.slice(0,s)+l+n.slice(o),e,t+1)}var Lm=n=>new Map(n.split(";").filter(Boolean).map(e=>{let t=e.indexOf(":");return[e.slice(0,t).trim(),e.slice(t+1).trim()]})),wl={sans:"system-ui, -apple-system, Segoe UI, Roboto, sans-serif",mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"};function Qf(n,e){let t=jr(e.theme),s=e.fonts??wl,r=Om(`.mono{font-family:${s.mono.replace(/"/g,"")}}
|
|
150
|
+
${t.rest}
|
|
151
|
+
${e.css}`),o=Nm(n);ar(o,"font-family",s.sans.replace(/"/g,""));let i=(a,l)=>{let c=l,f=new Map,u=(g,m,y)=>{let N=f.get(g);(!N||y[0]>N.rank[0]||y[0]===N.rank[0]&&(y[1]>N.rank[1]||y[1]===N.rank[1]&&y[2]>=N.rank[2]))&&f.set(g,{v:m,rank:y})};for(let g of r)if(yl(a,g.parts))for(let[m,y,N]of g.decls)u(m,y,[N?1:0,g.spec,g.order]);let d=eo(a,"style");if(d){for(let g of d.split(";").map(m=>m.trim()).filter(Boolean)){let m=g.indexOf(":");u(g.slice(0,m).trim(),g.slice(m+1).trim(),[0,1e6,0])}a.attrs=a.attrs.filter(g=>g[0]!=="style")}for(let[g,m]of f)g.startsWith("--")&&(c===l&&(c=new Map(l)),c.set(g,m.v));let p={};for(let[g,m]of f){if(!Wf.has(g))continue;let y=xl(m.v,c).trim();if(g==="fill"||g==="stroke"||g==="stop-color"){if(y==="none"||y==="currentColor"||y==="inherit"||y.startsWith("url(")){ar(a,g,y);continue}let N=Ii(y);if(!N)throw new Error(`resolve: a colour it doesn't know: ${y}`);ar(a,g,Hf(N)),N[3]!==1&&(p[g==="stop-color"?"stop":g]=N[3])}else ar(a,g,g==="letter-spacing"||g==="font-size"||g==="stroke-width"?y:y.replace(/"/g,""))}for(let[g,m]of Object.entries(p))ar(a,`${g}-opacity`,Im(m*Number(eo(a,`${g}-opacity`)??1)));eo(a,"opacity")==="0"&&(ar(a,"display","none"),a.attrs=a.attrs.filter(g=>g[0]!=="opacity"));for(let g of a.attrs)if(/var\(|hsl\(|color-mix/.test(g[1])){let m=xl(g[1],c),y=Ii(m);g[1]=y?Hf(y):m}for(let g of a.children)typeof g!="string"&&i(g,c)};return i(o,Lm(e.mode==="dark"?`${t.light};${t.dark}`:t.light)),Jf(o)}function kl(n){return Math.max(5600,Math.min(12500,2600+n.length*40))}function Li(n,e,t,s,r,o){let i=[],a=($,P,k,E="error")=>{let S=r.locate($);i.push({severity:E,message:P,line:S.line,col:S.col,path:$,hint:k})},l=n.steps??[],c=new Set(Object.keys(o.kinds)),f=new Map(s.map($=>[$.id,$])),u=()=>[...t.byId.keys(),...f.keys()],d=new Map;l.forEach(($,P)=>{$.id&&(d.has($.id)&&a(`${e}/steps/${P}/id`,`duplicate step id "${$.id}"`),d.set($.id,P+1))});let p=l.length,g=($,P)=>{if(typeof $=="number"){if($<1||$>p){a(P,`there is no step ${$}; this scene has ${p} step(s)`);return}return $}let k=d.get($);return k===void 0&&a(P,`unknown step "${$}"`+un($,d.keys())),k},m=$=>_n(o,o.kinds[$]?.color??"control"),y=[],N=$=>{y.includes($)||y.push($)};for(let $ of s)N($.kind);let h={},b=($,P,k,E)=>{if(P===void 0&&k===void 0)return;let S=P!==void 0?g(P,E+"/appears"):1,F=k!==void 0?g(k,E+"/disappears"):p+1;h[$]=Array.from({length:p},(D,H)=>H+1>=(S??1)&&H+1<(F??p+1))};for(let $ of t.items)b($.id,$.appears,$.disappears,$.path);for(let $ of s)b($.id,$.raw.appears,$.raw.disappears,$.path);let x=[],A=[],M=[],v=[],O=()=>{for(let $ of s){if($.raw.appears!==void 0||$.raw.disappears!==void 0)continue;let P=[$.from,$.to].map(k=>k&&(h[k.id]??C(k)));P.some(Boolean)&&(h[$.id]=Array.from({length:p},(k,E)=>P.every(S=>!S||S[E])))}},C=$=>{for(let P=$.parent;P;P=P.parent)if(h[P.id])return h[P.id]};return l.forEach(($,P)=>{let k=P+1,E=`${e}/steps/${P}`,S=$.kind??"control";c.has(S)||a(E+"/kind",`unknown flow kind "${S}"`+un(S,c)),N(S);let F=new Set,D=[];($.animate??[]).forEach((L,q)=>{let U=Array.isArray(L)?L:[L],Z=[];U.forEach((I,_)=>{let K=Array.isArray(L)?`${E}/animate/${q}/${_}`:`${E}/animate/${q}`,J,de;if(typeof I=="string"){let ne=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(I.trim());J=ne?ne[1]:I,de=ne?.[2]}else{let ne=Object.entries(I)[0];J=ne[0],de=ne[1]}let ce=f.get(J);if(!ce){a(K,`unknown route "${J}"`+un(J,f.keys()));return}if(de&&!c.has(de)){a(K,`unknown flow kind "${de}"`+un(de,c));return}let W=de??ce.kind;N(W),Z.push({route:J,kind:W,color:m(W)}),F.add(J),ce.from&&F.add(ce.from.id),ce.to&&F.add(ce.to.id)}),Z.length&&D.push(Z)});let H=[];($.pulse??[]).forEach((L,q)=>{let U=t.byId.get(L);if(!U){a(`${E}/pulse/${q}`,`unknown node "${L}"`+un(L,t.byId.keys()));return}let Z,I,_,K,J=U.node?Ms(t.catalog,U.node.asset):void 0;if(J?.pulse)[Z,I,_,K]=J.pulse(U.box);else{let W=U.box;Z=(W.x0+W.x1)/2,I=(W.y0+W.y1)/2,_=W.z1,K=Math.max(22,Math.min(60,(W.x1-W.x0+W.y1-W.y0)*8.5))}let[de,ce]=Ce(Z,I,_);H.push([de,ce,K*1.7,K*.98]),F.add(L)}),($.highlight??[]).forEach((L,q)=>{!t.byId.has(L)&&!f.has(L)&&a(`${E}/highlight/${q}`,`unknown id "${L}"`+un(L,u())),F.add(L)});for(let[L,q]of[["show",!0],["hide",!1]])($[L]??[]).forEach((U,Z)=>{if(!t.byId.has(U)&&!f.has(U)){a(`${E}/${L}/${Z}`,`unknown id "${U}"`+un(U,u()));return}let I=h[U]??(h[U]=Array(p).fill(!q));for(let _=P;_<p;_++)I[_]=q});if(($.say??[]).forEach((L,q)=>{let U,Z;if(Array.isArray(L.at))[U,Z]=Ce(L.at[0],L.at[1],L.at[2]??.36);else{let _=t.byId.get(L.at);if(!_){a(`${E}/say/${q}/at`,`unknown node "${L.at}"`+un(L.at,t.byId.keys()));return}let K=_.box;[U,Z]=Ce((K.x0+K.x1)/2,(K.y0+K.y1)/2,K.z1+.75)}let I=L.kind??S;c.has(I)||a(`${E}/say/${q}/kind`,`unknown flow kind "${I}"`+un(I,c)),A.push({step:k,x:U+(L.dx??0),y:Z+(L.dy??(Array.isArray(L.at)?0:-46)),ax:U,ay:Z,text:L.text,kind:I,anchor:L.anchor??"middle"})}),($.mark??[]).forEach((L,q)=>{if(L.at){M.push({step:k,p:[L.at[0],L.at[1],L.at[2]??.36]});return}let U=L.on?f.get(L.on):void 0;if(!U){a(`${E}/mark/${q}`,L.on?`unknown route "${L.on}"`+un(L.on,f.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let Z=U.points[U.points.length-1];M.push({step:k,p:[Z[0],Z[1],Z[2]+.6],on:U.id}),F.add(U.id)}),n.badges&&$.badge!==!1){let L=Array.isArray($.badge)?[$.badge[0],$.badge[1],$.badge[2]??.36]:void 0,q=typeof $.badge=="string"?$.badge:D[0]?.[0]?.route,U=q?f.get(q):void 0;if(!L)if(U)L=Sl(U.points);else if(q&&t.byId.get(q)){let Z=t.byId.get(q).box;L=[(Z.x0+Z.x1)/2,(Z.y0+Z.y1)/2,Z.z1+.3]}else typeof $.badge=="string"&&a(`${E}/badge`,`unknown id "${$.badge}"`+un($.badge,u()));L&&v.push({step:k,num:$.number??k,kind:S,p:L})}for(let L of[...F])for(let q=t.byId.get(L)?.parent;q;q=q.parent)F.add(q.id);for(let L of t.items)L.region?.kind==="tunnel"&&(L.region.around??[]).some(q=>F.has(q))&&F.add(L.id);let X;if($.focus?.length){let L=1/0,q=1/0,U=-1/0,Z=-1/0;$.focus.forEach((I,_)=>{let K=t.byId.get(I);if(!K){a(`${E}/focus/${_}`,`unknown node or region "${I}"`+un(I,t.byId.keys()));return}let J=K.box;for(let[de,ce,W]of[[J.x0,J.y0,J.z1],[J.x1,J.y0,J.z0],[J.x0,J.y1,J.z0],[J.x1,J.y1,J.z0],[J.x1,J.y0,J.z1],[J.x0,J.y1,J.z1]]){let[ne,Ae]=Ce(de,ce,W);L=Math.min(L,ne),q=Math.min(q,Ae),U=Math.max(U,ne),Z=Math.max(Z,Ae)}F.add(I)}),L<1/0&&(X=[Math.round(L-60),Math.round(q-70),Math.round(U+60),Math.round(Z+40)])}let Y=$.caption??"";x.push({n:k,num:$.number??k,kind:S,color:m(S),heading:$.heading,caption:Y,command:$.command??"",phases:D,pulses:H,lit:[...F],duration:$.duration===void 0||$.duration==="auto"?kl(Y):$.duration,...X?{focus:X}:{}})}),O(),{steps:x,says:A,marks:M,badges:v,vis:h,diags:i,kindsUsed:y}}function Sl(n){let e=n.slice(1).map((s,r)=>Math.hypot(s[0]-n[r][0],s[1]-n[r][1],s[2]-n[r][2])),t=e.reduce((s,r)=>s+r,0)/2;for(let s=0;s<e.length;s++){if(t<=e[s]&&e[s]>0){let r=t/e[s],o=n[s],i=n[s+1];return[o[0]+(i[0]-o[0])*r,o[1]+(i[1]-o[1])*r,o[2]+(i[2]-o[2])*r]}t-=e[s]}return n[0]}function un(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}function Zf(n,e){if(!e)return n;let[t,s,r,o]=e,i=n[2]/n[3],a=r-t,l=o-s;a/l<i?a=l*i:l=a/i,a=Math.min(a,n[2]),l=Math.min(l,n[3]);let c=(t+r)/2,f=(s+o)/2,u=Math.max(n[0],Math.min(n[0]+n[2]-a,c-a/2)),d=Math.max(n[1],Math.min(n[1]+n[3]-l,f-l/2));return[u,d,a,l]}var vl=`
|
|
143
152
|
*{box-sizing:border-box}
|
|
144
153
|
html,body{margin:0}
|
|
145
154
|
body{background:var(--bg);color:var(--ink);font:15px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;-webkit-font-smoothing:antialiased;overflow-x:hidden}
|
|
@@ -163,7 +172,7 @@ h2{font-size:20px;margin:44px 0 4px;letter-spacing:-.005em;text-wrap:balance}
|
|
|
163
172
|
.legend i{display:inline-block;width:26px;height:0;border-top:3px solid}
|
|
164
173
|
.legend i.box{height:10px;border-width:1.5px;border-style:solid;border-radius:2px}
|
|
165
174
|
footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
166
|
-
|
|
175
|
+
`,$l=n=>Fm+ri(n)+Bm+oi(),Fm=`
|
|
167
176
|
/* blocks: hue per role, lightness per face and theme */
|
|
168
177
|
.blk .top{fill:hsl(var(--h) var(--s) var(--l-top))}
|
|
169
178
|
.blk .lft{fill:hsl(var(--h) var(--s) var(--l-left))}
|
|
@@ -204,14 +213,14 @@ footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
|
204
213
|
.floor.t-control{fill:var(--muted)}
|
|
205
214
|
.slabname{font-size:15px;font-weight:800;fill:var(--muted);letter-spacing:.12em;opacity:.8}
|
|
206
215
|
.slabname.sm{font-size:10.5px;letter-spacing:.1em;opacity:1}
|
|
207
|
-
|
|
216
|
+
`,Bm=`.tunnel polygon{fill:hsl(205 85% 55% / .17);stroke:hsl(205 75% 45% / .8);stroke-width:1.3;stroke-linejoin:round}
|
|
208
217
|
.tunnel .top{fill:hsl(205 85% 65% / .22)}
|
|
209
218
|
.tunnel .rib{fill:none;stroke:hsl(205 75% 45% / .5);stroke-width:1}
|
|
210
219
|
.tunname{font-size:12px;font-weight:800;letter-spacing:.14em;fill:var(--tunnel-text);paint-order:stroke;stroke:var(--surface);stroke-width:3px;stroke-linejoin:round}
|
|
211
220
|
|
|
212
221
|
/* flows */
|
|
213
222
|
.flow{fill:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
|
|
214
|
-
`,
|
|
223
|
+
`,Fi=n=>vl+$l(n),Ml=`
|
|
215
224
|
/* step marks */
|
|
216
225
|
.xm circle{fill:var(--surface);stroke:var(--blocked);stroke-width:2.5}
|
|
217
226
|
.xm path{stroke:var(--blocked);stroke-width:3;stroke-linecap:round}
|
|
@@ -234,7 +243,7 @@ svg.all .badge{opacity:1}
|
|
|
234
243
|
svg.focus.all [data-hl]:not(.hl),svg.focus.all.dim-all [data-dim]:not(.hl){opacity:.9}
|
|
235
244
|
svg [data-step]:not(.on),svg.all [data-step]{opacity:0!important;pointer-events:none}
|
|
236
245
|
.pre{opacity:0!important;pointer-events:none}
|
|
237
|
-
`,
|
|
246
|
+
`,El=`
|
|
238
247
|
/* player */
|
|
239
248
|
.player{display:flex;align-items:flex-start;gap:10px 14px;padding:12px 16px;border-top:1px solid var(--line);flex-wrap:wrap}
|
|
240
249
|
.ctrls{display:flex;gap:6px;flex:none}
|
|
@@ -269,57 +278,57 @@ details.steps li code{font-size:11.5px}
|
|
|
269
278
|
.still .ctrls,.still .tools{display:none}
|
|
270
279
|
.tools{display:flex;gap:6px;flex:none;order:3;margin-left:auto}
|
|
271
280
|
.pbtn.small{font-size:12px;padding:4px 11px;font-weight:600;color:var(--muted)}
|
|
272
|
-
.pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,
|
|
281
|
+
.pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,Tl=`
|
|
273
282
|
.grid{display:none;fill:none;stroke:var(--ink);stroke-width:.6;opacity:.16;pointer-events:none}
|
|
274
283
|
svg.show-grid .grid{display:inline}
|
|
275
284
|
svg.pre-assemble > g:not(.g-anim){opacity:0}
|
|
276
|
-
`,qo=ya+xa+wa;var ka=t=>({data:t,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function hc(t,e,n,s=ka(t),r,o={},i=[]){let a=mo(po(e),t.roles,t.kinds),l=[],c=new Map;return t.scenes.forEach((f,u)=>{let d=`/scenes/${u}`;if(c.has(f.id)){let N=s.locate(d+"/id");i.push({severity:"error",message:`duplicate scene id "${f.id}"`,line:N.line,col:N.col,path:d+"/id"})}c.set(f.id,u);let p={...t.grid,...f.grid,...o.snap?{snap:o.snap}:{}},h=$o(f,d,s,a,n,t.roles,p.snap);i.push(...h.diags);let m=Ro(f,d,h,s,new Set(Object.keys(a.kinds)),p.snap);i.push(...m.diags);let y=Do(f,d,h,m.routes,s,a);i.push(...y.diags),i.push(...Eu(f,d,n,s));let I=Go({scene:f,layout:h,routes:m.routes,steps:y,theme:a,id:f.id,gridStep:p.step??p.snap??1});for(let N of I.warnings){let M=s.locate(N.path);i.push({severity:"warning",message:N.message,line:M.line,col:M.col,path:N.path})}l.push({id:f.id,raw:f,layout:h,routes:m.routes,steps:y,rendered:I,grid:p,assemble:f.assemble??t.assemble??!1})}),i.sort((f,u)=>f.line-u.line||f.col-u.col),{ok:!i.some(f=>f.severity==="error"),diags:i,doc:t,theme:a,catalog:n,scenes:l,parsed:s,source:r}}function Eu(t,e,n,s){let r=[],o=(a,l)=>{let c=s.locate(a);r.push({severity:"warning",message:l,line:c.line,col:c.col,path:a})},i=(a,l)=>{a.nodes?.forEach((c,f)=>{let u=`${l}/nodes/${f}`;(c.deco??Qt(n,c.asset).deco??[]).forEach((d,p)=>{typeof d=="object"&&d.icon&&!cr(d.icon)&&o(c.deco?`${u}/deco/${p}/icon`:u,`node "${c.id}": no icon "${d.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!ko(c.face)&&o(`${u}/face`,`node "${c.id}": no screen face "${c.face}" is registered here, so it is drawn as a placeholder`)}),a.regions?.forEach((c,f)=>i(c,`${l}/regions/${f}`))};return i(t,e),r}function gc(t,e){let n=t/(yt*Xe),s=2*e/Xe;return[(n+s)/2,(s-n)/2]}function bc(t,e){let n=t.layout.byId.get(e);if(!n)return;let s=n.parent?[n.parent.box.x0,n.parent.box.y0]:[0,0];return[n.box.x0-s[0],n.box.y0-s[1]]}function yc(t){let e=[];for(let n of[t.x0,t.x1])for(let s of[t.y0,t.y1])for(let r of[t.z0,t.z1])e.push(we(n,s,r));return Tu(e)}function xc(t){return[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]].map(([e,n])=>we(e,n,t.z0))}function Tu(t){let e=[...new Map(t.map(o=>[`${o[0].toFixed(3)},${o[1].toFixed(3)}`,o])).values()].sort((o,i)=>o[0]-i[0]||o[1]-i[1]);if(e.length<3)return e;let n=(o,i,a)=>(i[0]-o[0])*(a[1]-o[1])-(i[1]-o[1])*(a[0]-o[0]),s=[],r=[];for(let o of e){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],o)<=1e-9;)s.pop();s.push(o)}for(let o of[...e].reverse()){for(;r.length>=2&&n(r[r.length-2],r[r.length-1],o)<=1e-9;)r.pop();r.push(o)}return[...s.slice(0,-1),...r.slice(0,-1)]}var wc=(t,e)=>e?.padding??pt(t,e?.kind)?.pad??0;function kc(t,e,n,s,r){let o=f=>Math.round(f/n)*n,i=o(t[0]+e[0]),a=o(t[1]+e[1]),l={left:!1,right:!1,top:!1,bottom:!1};if(r){let f=Math.ceil(r.pad/n-1e-9)*n,u=Math.floor((r.w-r.pad-s[0])/n+1e-9)*n,d=Math.floor((r.d-r.pad-s[1])/n+1e-9)*n;i<f&&(i=f,l.left=!0),u>=f&&i>u&&(i=u,l.right=!0),a<f&&(a=f,l.top=!0),d>=f&&a>d&&(a=d,l.bottom=!0)}let c=f=>Math.round(f*1e3)/1e3;return{at:[c(i),c(a)],delta:[c(i-t[0]),c(a-t[1])],clamped:l}}function Yo(t,e){return e.some(s=>t.x0<s.x1-1e-6&&t.x1>s.x0+1e-6&&t.y0<s.y1-1e-6&&t.y1>s.y0+1e-6)}var Sa=Object.freeze({W:178,H:58,GX:44,GY:44,PAD:22,TITLE:30,CH:96,cardRx:9,panelRx:14,bend:70,overlap:400,crossPanel:300,border:120,nearEdge:200,margin:16}),Ma={name:{key:"sans600_12",size:13},sub:{key:"sans400_13",size:10},title:{key:"sans700_13",size:12,spacing:.02},titleSub:{key:"sans400_13",size:10.5},label:{key:"sans600_12",size:10.5}},vc=(t,e)=>Jt(t,Ma[e]);function Ho(t){let e=[],n=new Map,s=(l,c)=>{if(typeof c!="string"||!c){e.push(`${l} has no id`);return}let f=n.get(c);f?e.push(`duplicate id "${c}": a ${f} and a ${l} (cards and panels share one set of ids)`):n.set(c,l)};for(let l of t.cards)s("card",l.id),(!Array.isArray(l.cell)||l.cell.length!==2||!l.cell.every(c=>Number.isInteger(c)&&c>=0))&&e.push(`card "${l.id}": cell must be [column, row], whole numbers from 0`);for(let l of t.panels??[]){s("panel",l.id);let c=l.cells;(!Array.isArray(c)||c.length!==4||!c.every(f=>Number.isInteger(f)&&f>=0)||c[2]<c[0]||c[3]<c[1])&&e.push(`panel "${l.id}": cells must be [c0, r0, c1, r1] with c0 \u2264 c1 and r0 \u2264 r1`)}let r=new Map;for(let l of t.cards){let c=String(l.cell);r.has(c)?e.push(`cards "${r.get(c)}" and "${l.id}" are both at cell [${c}]`):r.set(c,l.id)}let o=(t.panels??[]).filter(l=>Array.isArray(l.cells)&&l.cells.length===4);for(let l=0;l<o.length;l++)for(let c=l+1;c<o.length;c++){let f=o[l].cells,u=o[c].cells;f[0]<=u[2]&&u[0]<=f[2]&&f[1]<=u[3]&&u[1]<=f[3]&&!va(f,u)&&!va(u,f)&&e.push(`panels "${o[l].id}" and "${o[c].id}" overlap without one holding the other`)}let i=new Set([...t.cards.map(l=>l.id),...o.map(l=>l.id)]),a=new Set(o.map(l=>l.id));return(t.links??[]).forEach((l,c)=>{let f=`link ${l.id?`"${l.id}"`:c}`;for(let u of["a","b"])i.has(l[u])||e.push(`${f}: ${u} "${l[u]}" is no card or panel`);for(let u of["aOn","bOn"])l[u]!==void 0&&!a.has(l[u])&&e.push(`${f}: ${u} "${l[u]}" is no panel`);l.id!==void 0&&s("link",l.id)}),e}var va=(t,e)=>t[0]>=e[0]&&t[2]<=e[2]&&t[1]>=e[1]&&t[3]<=e[3];function gr(t,e){let{W:n,H:s,GX:r,GY:o,PAD:i,TITLE:a,CH:l}=e,c=t.panels??[],f=A=>(A[2]-A[0]+1)*(A[3]-A[1]+1),u=(A,D)=>{let V=c[A].cells,W=c[D].cells;return va(W,V)?f(V)>f(W)||A<D:!1},d=c.map((A,D)=>{let V=-1;return c.forEach((W,ie)=>{ie!==D&&u(ie,D)&&(V<0||u(V,ie))&&(V=ie)}),V}),p=A=>d[A]<0?0:1+p(d[A]),h=(A,D)=>{let V=-1;c.forEach((ie,de)=>{let X=ie.cells;A>=X[0]&&A<=X[2]&&D>=X[1]&&D<=X[3]&&(V<0||u(V,de))&&(V=de)});let W=[];for(let ie=V;ie>=0;ie=d[ie])W.unshift(ie);return W},m=Math.max(1,...t.cards.map(A=>A.cell[0]+1),...c.map(A=>A.cells[2]+1)),y=Math.max(1,...t.cards.map(A=>A.cell[1]+1),...c.map(A=>A.cells[3]+1)),I=[];for(let A=0;A<m;A++){I.push([]);for(let D=0;D<y;D++)I[A].push(h(A,D))}let N=(A,D,V)=>{let W=A.filter(de=>!D.includes(de)),ie=D.filter(de=>!A.includes(de));return!W.length&&!ie.length?0:W.length*(i+(V?a:0))+ie.length*i+l},M=new Array(m+1).fill(0),$=new Array(y+1).fill(0);for(let A=0;A<y;A++)for(let D=1;D<m;D++){let V=N(I[D-1][A],I[D][A],!1);V&&(M[D]=Math.max(M[D],V-r))}for(let A=0;A<m;A++)for(let D=1;D<y;D++){let V=N(I[A][D-1],I[A][D],!0);V&&($[D]=Math.max($[D],V-o))}let R=A=>{let D=A*(n+r);for(let V=1;V<=A;V++)D+=M[V];return D},E=A=>{let D=A*(s+o);for(let V=1;V<=A;V++)D+=$[V];return D},w=(A,D,V,W)=>V===D?A(D):A(D)+(W-D)*(A(V)-A(D))/(V-D),T=c.map(()=>new Set),L=(A,D)=>{for(let V=A;V>=0;V=d[V])T[V].add(D)};c.forEach((A,D)=>{L(D,A.cells[1]),L(D,A.cells[3])});for(let A of t.cards){let D=I[A.cell[0]][A.cell[1]];D.length&&L(D[D.length-1],A.cell[1])}let x=c.map(()=>new Map),P=(A,D)=>A.slice(A.indexOf(D)+1);for(let A of c.map((D,V)=>V).sort((D,V)=>p(D)-p(V)||D-V)){let D=c[A].cells,V=[...T[A]].sort((ie,de)=>ie-de),W=d[A]>=0?x[d[A]].get(V[0]):E(V[0]);x[A].set(V[0],W);for(let ie=1;ie<V.length;ie++){let de=0;for(let X=D[0];X<=D[2];X++)de=Math.max(de,N(P(I[X][V[ie-1]],A),P(I[X][V[ie]],A),!0));W+=s+Math.max(o,de),x[A].set(V[ie],W)}}let b=c.map(()=>new Set),v=(A,D)=>{for(let V=A;V>=0;V=d[V])b[V].add(D)};c.forEach((A,D)=>{v(D,A.cells[0]),v(D,A.cells[2])});for(let A of t.cards){let D=I[A.cell[0]][A.cell[1]];D.length&&v(D[D.length-1],A.cell[0])}let g=c.map(()=>new Map);for(let A of c.map((D,V)=>V).sort((D,V)=>p(D)-p(V)||D-V)){let D=c[A].cells,V=[...b[A]].sort((ie,de)=>ie-de);if(d[A]<0&&!d.includes(A)&&V.length===D[2]-D[0]+1){for(let ie of V)g[A].set(ie,w(R,D[0],D[2],ie));continue}let W=d[A]>=0?g[d[A]].get(V[0]):R(V[0]);g[A].set(V[0],W);for(let ie=1;ie<V.length;ie++){let de=0;for(let X=D[1];X<=D[3];X++)de=Math.max(de,N(P(I[V[ie-1]][X],A),P(I[V[ie]][X],A),!1));W+=n+Math.max(r,de),g[A].set(V[ie],W)}}let O=(A,D)=>{let V=I[A][D],W=V.length?V[V.length-1]:-1;return W>=0?[g[W].get(A),x[W].get(D)]:[R(A),E(D)]},F=c.map((A,D)=>D).sort((A,D)=>p(D)-p(A)||A-D),j=new Array(c.length);for(let A of F){let D=c[A].cells,V=[],W=[];for(let X of t.cards){let te=I[X.cell[0]][X.cell[1]];te[te.length-1]===A&&(V.push(g[A].get(X.cell[0])),W.push(x[A].get(X.cell[1])))}let ie=X=>X.cell[0]>=D[0]&&X.cell[0]<=D[2]&&X.cell[1]>=D[1]&&X.cell[1]<=D[3];for(let X of[D[1],D[3]])t.cards.some(te=>te.cell[1]===X&&ie(te))||W.push(x[A].get(X));for(let X of[D[0],D[2]])t.cards.some(te=>te.cell[0]===X&&ie(te))||V.push(g[A].get(X));let de={l:V.length?Math.min(...V):1/0,t:W.length?Math.min(...W):1/0,r:V.length?Math.max(...V)+n:-1/0,b:W.length?Math.max(...W)+s:-1/0};c.forEach((X,te)=>{if(d[te]!==A)return;let ye=j[te];de.l=Math.min(de.l,ye.l),de.t=Math.min(de.t,ye.t),de.r=Math.max(de.r,ye.r),de.b=Math.max(de.b,ye.b)}),j[A]={l:de.l-i,t:de.t-i,r:de.r+i,b:de.b+i+a}}let U=t.cards.map(A=>O(A.cell[0],A.cell[1])),ne=t.cards.map(A=>{let D=I[A.cell[0]][A.cell[1]];return D.length?D[D.length-1]:-1}),B=(A,D)=>{for(let V=A;V>=0;V=d[V])if(V===D)return!0;return!1},K=(A,D)=>{t.cards.forEach((V,W)=>{ne[W]>=0&&B(ne[W],A)&&(U[W]=[U[W][0]+D,U[W][1]])}),c.forEach((V,W)=>{B(W,A)&&(j[W]={...j[W],l:j[W].l+D,r:j[W].r+D})})},q=A=>{let D=[],V=[],W=[],ie=[];t.cards.forEach((S,Y)=>{ne[Y]===A&&(D.push(U[Y][0]),W.push(U[Y][0]+n),V.push(U[Y][1]),ie.push(U[Y][1]+s))}),c.forEach((S,Y)=>{d[Y]===A&&(D.push(j[Y].l),W.push(j[Y].r),V.push(j[Y].t),ie.push(j[Y].b))});let de=j[A],X=Math.min(...D,de.l+i),te=Math.max(...W,de.r-i),ye=Math.min(...V,de.t+i),Fe=Math.max(...ie,de.b-i-a);j[A]={l:X-i,t:ye-i,r:te+i,b:Fe+i+a}};for(let A of F)if(d[A]<0&&!d.includes(A))q(A);else{let V=[];t.cards.forEach((te,ye)=>{ne[ye]===A&&V.push({l:U[ye][0],r:U[ye][0]+n,t:U[ye][1],b:U[ye][1]+s,card:ye})}),c.forEach((te,ye)=>{d[ye]===A&&V.push({...j[ye],panel:ye})}),V.sort((te,ye)=>te.l-ye.l||te.t-ye.t);let W=Math.min(...V.map(te=>te.l)),ie=[];for(let te of V){let ye=W;for(let S of ie)S.t<te.b&&te.t<S.b&&S.r<=te.l+1e-6&&(ye=Math.max(ye,S.r+(S.card!==void 0&&te.card!==void 0?r:l)));let Fe=ye-te.l;Fe<-1e-6&&(te.card!==void 0?U[te.card]=[U[te.card][0]+Fe,U[te.card][1]]:K(te.panel,Fe),te.l+=Fe,te.r+=Fe),ie.push(te)}let de=V.map(te=>te.l),X=V.map(te=>te.r);j[A]={...j[A],l:Math.min(...de)-i,r:Math.max(...X)+i}}return{prect:j,parentIx:d,depthOf:p,pos:O,cardAt:A=>U[A]}}function Os(t,e,n={}){if(n.wrap){let{wrap:k,..._}=n;return Os(Au(t,e,k.aspect,_),e,_)}let s=Ho(t);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
|
|
285
|
+
`,Bi=Ml+El+Tl;var Al=n=>({data:n,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function eu(n,e,t,s=Al(n),r,o={},i=[]){let a=Zo(Qo(e),n.roles,n.kinds),l=[],c=new Map;return n.scenes.forEach((f,u)=>{let d=`/scenes/${u}`;if(c.has(f.id)){let h=s.locate(d+"/id");i.push({severity:"error",message:`duplicate scene id "${f.id}"`,line:h.line,col:h.col,path:d+"/id"})}c.set(f.id,u);let p={...n.grid,...f.grid,...o.snap?{snap:o.snap}:{}},g=fi(f,d,s,a,t,n.roles,p.snap);i.push(...g.diags);let m=gi(f,d,g,s,new Set(Object.keys(a.kinds)),p.snap);i.push(...m.diags);let y=Li(f,d,g,m.routes,s,a);i.push(...y.diags),i.push(...jm(f,d,t,s));let N=er({scene:f,layout:g,routes:m.routes,steps:y,theme:a,id:f.id,gridStep:p.step??p.snap??1});for(let h of N.warnings){let b=s.locate(h.path);i.push({severity:"warning",message:h.message,line:b.line,col:b.col,path:h.path})}l.push({id:f.id,raw:f,layout:g,routes:m.routes,steps:y,rendered:N,grid:p,assemble:f.assemble??n.assemble??!1})}),i.sort((f,u)=>f.line-u.line||f.col-u.col),{ok:!i.some(f=>f.severity==="error"),diags:i,doc:n,theme:a,catalog:t,scenes:l,parsed:s,source:r}}function jm(n,e,t,s){let r=[],o=(a,l)=>{let c=s.locate(a);r.push({severity:"warning",message:l,line:c.line,col:c.col,path:a})},i=(a,l)=>{a.nodes?.forEach((c,f)=>{let u=`${l}/nodes/${f}`;(c.deco??on(t,c.asset).deco??[]).forEach((d,p)=>{typeof d=="object"&&d.icon&&!_r(d.icon)&&o(c.deco?`${u}/deco/${p}/icon`:u,`node "${c.id}": no icon "${d.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!ii(c.face)&&o(`${u}/face`,`node "${c.id}": no screen face "${c.face}" is registered here, so it is drawn as a placeholder`)}),a.regions?.forEach((c,f)=>i(c,`${l}/regions/${f}`))};return i(n,e),r}function tu(n,e){let t=n/(wt*nt),s=2*e/nt;return[(t+s)/2,(s-t)/2]}function nu(n,e){let t=n.layout.byId.get(e);if(!t)return;let s=t.parent?[t.parent.box.x0,t.parent.box.y0]:[0,0];return[t.box.x0-s[0],t.box.y0-s[1]]}function su(n){let e=[];for(let t of[n.x0,n.x1])for(let s of[n.y0,n.y1])for(let r of[n.z0,n.z1])e.push(Ce(t,s,r));return Dm(e)}function ru(n){return[[n.x0,n.y0],[n.x1,n.y0],[n.x1,n.y1],[n.x0,n.y1]].map(([e,t])=>Ce(e,t,n.z0))}function Dm(n){let e=[...new Map(n.map(o=>[`${o[0].toFixed(3)},${o[1].toFixed(3)}`,o])).values()].sort((o,i)=>o[0]-i[0]||o[1]-i[1]);if(e.length<3)return e;let t=(o,i,a)=>(i[0]-o[0])*(a[1]-o[1])-(i[1]-o[1])*(a[0]-o[0]),s=[],r=[];for(let o of e){for(;s.length>=2&&t(s[s.length-2],s[s.length-1],o)<=1e-9;)s.pop();s.push(o)}for(let o of[...e].reverse()){for(;r.length>=2&&t(r[r.length-2],r[r.length-1],o)<=1e-9;)r.pop();r.push(o)}return[...s.slice(0,-1),...r.slice(0,-1)]}var ou=(n,e)=>e?.padding??pt(n,e?.kind)?.pad??0;function iu(n,e,t,s,r){let o=f=>Math.round(f/t)*t,i=o(n[0]+e[0]),a=o(n[1]+e[1]),l={left:!1,right:!1,top:!1,bottom:!1};if(r){let f=Math.ceil(r.pad/t-1e-9)*t,u=Math.floor((r.w-r.pad-s[0])/t+1e-9)*t,d=Math.floor((r.d-r.pad-s[1])/t+1e-9)*t;i<f&&(i=f,l.left=!0),u>=f&&i>u&&(i=u,l.right=!0),a<f&&(a=f,l.top=!0),d>=f&&a>d&&(a=d,l.bottom=!0)}let c=f=>Math.round(f*1e3)/1e3;return{at:[c(i),c(a)],delta:[c(i-n[0]),c(a-n[1])],clamped:l}}function ji(n,e){return e.some(s=>n.x0<s.x1-1e-6&&n.x1>s.x0+1e-6&&n.y0<s.y1-1e-6&&n.y1>s.y0+1e-6)}var Nl=Object.freeze({W:178,H:58,GX:44,GY:44,PAD:22,TITLE:30,CH:96,cardRx:9,panelRx:14,bend:70,overlap:400,crossPanel:300,border:120,nearEdge:200,margin:16}),Rl={name:{key:"sans600_12",size:13},sub:{key:"sans400_13",size:10},title:{key:"sans700_13",size:12,spacing:.02},titleSub:{key:"sans400_13",size:10.5},label:{key:"sans600_12",size:10.5}},au=(n,e)=>sn(n,Rl[e]);function Di(n){let e=[],t=new Map,s=(l,c)=>{if(typeof c!="string"||!c){e.push(`${l} has no id`);return}let f=t.get(c);f?e.push(`duplicate id "${c}": a ${f} and a ${l} (cards and panels share one set of ids)`):t.set(c,l)};for(let l of n.cards)s("card",l.id),(!Array.isArray(l.cell)||l.cell.length!==2||!l.cell.every(c=>Number.isInteger(c)&&c>=0))&&e.push(`card "${l.id}": cell must be [column, row], whole numbers from 0`);for(let l of n.panels??[]){s("panel",l.id);let c=l.cells;(!Array.isArray(c)||c.length!==4||!c.every(f=>Number.isInteger(f)&&f>=0)||c[2]<c[0]||c[3]<c[1])&&e.push(`panel "${l.id}": cells must be [c0, r0, c1, r1] with c0 \u2264 c1 and r0 \u2264 r1`)}let r=new Map;for(let l of n.cards){let c=String(l.cell);r.has(c)?e.push(`cards "${r.get(c)}" and "${l.id}" are both at cell [${c}]`):r.set(c,l.id)}let o=(n.panels??[]).filter(l=>Array.isArray(l.cells)&&l.cells.length===4);for(let l=0;l<o.length;l++)for(let c=l+1;c<o.length;c++){let f=o[l].cells,u=o[c].cells;f[0]<=u[2]&&u[0]<=f[2]&&f[1]<=u[3]&&u[1]<=f[3]&&!Ol(f,u)&&!Ol(u,f)&&e.push(`panels "${o[l].id}" and "${o[c].id}" overlap without one holding the other`)}let i=new Set([...n.cards.map(l=>l.id),...o.map(l=>l.id)]),a=new Set(o.map(l=>l.id));return(n.links??[]).forEach((l,c)=>{let f=`link ${l.id?`"${l.id}"`:c}`;for(let u of["a","b"])i.has(l[u])||e.push(`${f}: ${u} "${l[u]}" is no card or panel`);for(let u of["aOn","bOn"])l[u]!==void 0&&!a.has(l[u])&&e.push(`${f}: ${u} "${l[u]}" is no panel`);l.id!==void 0&&s("link",l.id)}),e}var Ol=(n,e)=>n[0]>=e[0]&&n[2]<=e[2]&&n[1]>=e[1]&&n[3]<=e[3];function to(n,e){let{W:t,H:s,GX:r,GY:o,PAD:i,TITLE:a,CH:l}=e,c=n.panels??[],f=I=>(I[2]-I[0]+1)*(I[3]-I[1]+1),u=(I,_)=>{let K=c[I].cells,J=c[_].cells;return Ol(J,K)?f(K)>f(J)||I<_:!1},d=c.map((I,_)=>{let K=-1;return c.forEach((J,de)=>{de!==_&&u(de,_)&&(K<0||u(K,de))&&(K=de)}),K}),p=I=>d[I]<0?0:1+p(d[I]),g=(I,_)=>{let K=-1;c.forEach((de,ce)=>{let W=de.cells;I>=W[0]&&I<=W[2]&&_>=W[1]&&_<=W[3]&&(K<0||u(K,ce))&&(K=ce)});let J=[];for(let de=K;de>=0;de=d[de])J.unshift(de);return J},m=Math.max(1,...n.cards.map(I=>I.cell[0]+1),...c.map(I=>I.cells[2]+1)),y=Math.max(1,...n.cards.map(I=>I.cell[1]+1),...c.map(I=>I.cells[3]+1)),N=[];for(let I=0;I<m;I++){N.push([]);for(let _=0;_<y;_++)N[I].push(g(I,_))}let h=(I,_,K)=>{let J=I.filter(ce=>!_.includes(ce)),de=_.filter(ce=>!I.includes(ce));return!J.length&&!de.length?0:J.length*(i+(K?a:0))+de.length*i+l},b=new Array(m+1).fill(0),x=new Array(y+1).fill(0);for(let I=0;I<y;I++)for(let _=1;_<m;_++){let K=h(N[_-1][I],N[_][I],!1);K&&(b[_]=Math.max(b[_],K-r))}for(let I=0;I<m;I++)for(let _=1;_<y;_++){let K=h(N[I][_-1],N[I][_],!0);K&&(x[_]=Math.max(x[_],K-o))}let A=I=>{let _=I*(t+r);for(let K=1;K<=I;K++)_+=b[K];return _},M=I=>{let _=I*(s+o);for(let K=1;K<=I;K++)_+=x[K];return _},v=(I,_,K,J)=>K===_?I(_):I(_)+(J-_)*(I(K)-I(_))/(K-_),O=c.map(()=>new Set),C=(I,_)=>{for(let K=I;K>=0;K=d[K])O[K].add(_)};c.forEach((I,_)=>{C(_,I.cells[1]),C(_,I.cells[3])});for(let I of n.cards){let _=N[I.cell[0]][I.cell[1]];_.length&&C(_[_.length-1],I.cell[1])}let $=c.map(()=>new Map),P=(I,_)=>I.slice(I.indexOf(_)+1);for(let I of c.map((_,K)=>K).sort((_,K)=>p(_)-p(K)||_-K)){let _=c[I].cells,K=[...O[I]].sort((de,ce)=>de-ce),J=d[I]>=0?$[d[I]].get(K[0]):M(K[0]);$[I].set(K[0],J);for(let de=1;de<K.length;de++){let ce=0;for(let W=_[0];W<=_[2];W++)ce=Math.max(ce,h(P(N[W][K[de-1]],I),P(N[W][K[de]],I),!0));J+=s+Math.max(o,ce),$[I].set(K[de],J)}}let k=c.map(()=>new Set),E=(I,_)=>{for(let K=I;K>=0;K=d[K])k[K].add(_)};c.forEach((I,_)=>{E(_,I.cells[0]),E(_,I.cells[2])});for(let I of n.cards){let _=N[I.cell[0]][I.cell[1]];_.length&&E(_[_.length-1],I.cell[0])}let S=c.map(()=>new Map);for(let I of c.map((_,K)=>K).sort((_,K)=>p(_)-p(K)||_-K)){let _=c[I].cells,K=[...k[I]].sort((de,ce)=>de-ce);if(d[I]<0&&!d.includes(I)&&K.length===_[2]-_[0]+1){for(let de of K)S[I].set(de,v(A,_[0],_[2],de));continue}let J=d[I]>=0?S[d[I]].get(K[0]):A(K[0]);S[I].set(K[0],J);for(let de=1;de<K.length;de++){let ce=0;for(let W=_[1];W<=_[3];W++)ce=Math.max(ce,h(P(N[K[de-1]][W],I),P(N[K[de]][W],I),!1));J+=t+Math.max(r,ce),S[I].set(K[de],J)}}let F=(I,_)=>{let K=N[I][_],J=K.length?K[K.length-1]:-1;return J>=0?[S[J].get(I),$[J].get(_)]:[A(I),M(_)]},D=c.map((I,_)=>_).sort((I,_)=>p(_)-p(I)||I-_),H=new Array(c.length);for(let I of D){let _=c[I].cells,K=[],J=[];for(let W of n.cards){let ne=N[W.cell[0]][W.cell[1]];ne[ne.length-1]===I&&(K.push(S[I].get(W.cell[0])),J.push($[I].get(W.cell[1])))}let de=W=>W.cell[0]>=_[0]&&W.cell[0]<=_[2]&&W.cell[1]>=_[1]&&W.cell[1]<=_[3];for(let W of[_[1],_[3]])n.cards.some(ne=>ne.cell[1]===W&&de(ne))||J.push($[I].get(W));for(let W of[_[0],_[2]])n.cards.some(ne=>ne.cell[0]===W&&de(ne))||K.push(S[I].get(W));let ce={l:K.length?Math.min(...K):1/0,t:J.length?Math.min(...J):1/0,r:K.length?Math.max(...K)+t:-1/0,b:J.length?Math.max(...J)+s:-1/0};c.forEach((W,ne)=>{if(d[ne]!==I)return;let Ae=H[ne];ce.l=Math.min(ce.l,Ae.l),ce.t=Math.min(ce.t,Ae.t),ce.r=Math.max(ce.r,Ae.r),ce.b=Math.max(ce.b,Ae.b)}),H[I]={l:ce.l-i,t:ce.t-i,r:ce.r+i,b:ce.b+i+a}}let X=n.cards.map(I=>F(I.cell[0],I.cell[1])),Y=n.cards.map(I=>{let _=N[I.cell[0]][I.cell[1]];return _.length?_[_.length-1]:-1}),L=(I,_)=>{for(let K=I;K>=0;K=d[K])if(K===_)return!0;return!1},q=(I,_)=>{n.cards.forEach((K,J)=>{Y[J]>=0&&L(Y[J],I)&&(X[J]=[X[J][0]+_,X[J][1]])}),c.forEach((K,J)=>{L(J,I)&&(H[J]={...H[J],l:H[J].l+_,r:H[J].r+_})})},U=I=>{let _=[],K=[],J=[],de=[];n.cards.forEach((R,ee)=>{Y[ee]===I&&(_.push(X[ee][0]),J.push(X[ee][0]+t),K.push(X[ee][1]),de.push(X[ee][1]+s))}),c.forEach((R,ee)=>{d[ee]===I&&(_.push(H[ee].l),J.push(H[ee].r),K.push(H[ee].t),de.push(H[ee].b))});let ce=H[I],W=Math.min(..._,ce.l+i),ne=Math.max(...J,ce.r-i),Ae=Math.min(...K,ce.t+i),Be=Math.max(...de,ce.b-i-a);H[I]={l:W-i,t:Ae-i,r:ne+i,b:Be+i+a}};for(let I of D)if(d[I]<0&&!d.includes(I))U(I);else{let K=[];n.cards.forEach((ne,Ae)=>{Y[Ae]===I&&K.push({l:X[Ae][0],r:X[Ae][0]+t,t:X[Ae][1],b:X[Ae][1]+s,card:Ae})}),c.forEach((ne,Ae)=>{d[Ae]===I&&K.push({...H[Ae],panel:Ae})}),K.sort((ne,Ae)=>ne.l-Ae.l||ne.t-Ae.t);let J=Math.min(...K.map(ne=>ne.l)),de=[];for(let ne of K){let Ae=J;for(let R of de)R.t<ne.b&&ne.t<R.b&&R.r<=ne.l+1e-6&&(Ae=Math.max(Ae,R.r+(R.card!==void 0&&ne.card!==void 0?r:l)));let Be=Ae-ne.l;Be<-1e-6&&(ne.card!==void 0?X[ne.card]=[X[ne.card][0]+Be,X[ne.card][1]]:q(ne.panel,Be),ne.l+=Be,ne.r+=Be),de.push(ne)}let ce=K.map(ne=>ne.l),W=K.map(ne=>ne.r);H[I]={...H[I],l:Math.min(...ce)-i,r:Math.max(...W)+i}}return{prect:H,parentIx:d,depthOf:p,pos:F,cardAt:I=>X[I]}}function lr(n,e,t={}){if(t.wrap){let{wrap:T,...V}=t;return lr(_m(n,e,T.aspect,V),e,V)}let s=Di(n);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
|
|
277
286
|
${s.join(`
|
|
278
|
-
`)}`);let r={...Sa,...n},{W:o,H:i}=r,a=k=>Math.round(k*10)/10,l=[],c=t.panels??[],{prect:f,parentIx:u,depthOf:d,cardAt:p}=gr(t,r),h=c.map((k,_)=>{let z=f[_],oe=e(k.label??"","title")+(k.sub?e(k.sub,"titleSub"):0);return{...k,rect:z,titleAt:[a(z.l+16),a(z.b-15)],depth:d(_),parent:u[_]>=0?c[u[_]].id:void 0,title:{l:z.l+10,r:z.l+22+oe,t:z.b-30,b:z.b-6}}}),m=t.cards.map(k=>{let[_,z]=p(t.cards.indexOf(k));return{...k,rect:{l:_,t:z,r:_+o,b:z+i}}}),y=new Map;h.forEach(k=>y.set(k.id,k.rect)),m.forEach(k=>y.set(k.id,k.rect));let I=m.map(k=>k.rect),N=h.map(k=>k.rect),M=h.filter(k=>k.label).map(k=>k.title),$=(k,_)=>k.l>=_.l&&k.r<=_.r&&k.t>=_.t&&k.b<=_.b,R=(k,_,z,oe)=>Math.min(k[0],_[0])<z.r+oe&&Math.max(k[0],_[0])>z.l-oe&&Math.min(k[1],_[1])<z.b+oe&&Math.max(k[1],_[1])>z.t-oe,E=(k,_)=>N.reduce((z,oe)=>{if(k[0]===_[0]){let re=Math.min(k[1],_[1]),ke=Math.max(k[1],_[1]);k[0]>oe.l&&k[0]<oe.r&&(z+=[oe.t,oe.b].filter(he=>he>re+1&&he<ke-1).length)}else{let re=Math.min(k[0],_[0]),ke=Math.max(k[0],_[0]);k[1]>oe.t&&k[1]<oe.b&&(z+=[oe.l,oe.r].filter(he=>he>re+1&&he<ke-1).length)}return z},0),w=(k,_)=>N.some(z=>k[1]===_[1]?[z.t,z.b].some(oe=>Math.abs(k[1]-oe)<16&&Math.max(k[0],_[0])>z.l&&Math.min(k[0],_[0])<z.r):[z.l,z.r].some(oe=>Math.abs(k[0]-oe)<16&&Math.max(k[1],_[1])>z.t&&Math.min(k[1],_[1])<z.b)),T=(k,_,z,oe)=>N.filter(re=>re!==z&&re!==oe&&!$(z,re)&&!$(oe,re)&&R(k,_,{l:re.l+3,r:re.r-3,t:re.t+3,b:re.b-3},0)).length,L=[],x=new Map,P=new Map,b=(k,_)=>{L.push([k,_]);let[z,oe]=k[1]===_[1]?[x,k[1]]:k[0]===_[0]?[P,k[0]]:[void 0,0];if(!z)return;let re=Math.floor(oe/6);(z.get(re)??z.set(re,[]).get(re)).push([k,_])},v=(k,_)=>{let z=k[1]===_[1];if(!z&&k[0]!==_[0])return 0;let oe=z?1:0,re=z?0:1,ke=z?x:P,he=Math.floor(k[oe]/6),He=Math.min(k[re],_[re]),$e=Math.max(k[re],_[re]),be=0;for(let Ae=he-1;Ae<=he+1;Ae++)for(let[Ie,ot]of ke.get(Ae)??[])Math.abs(k[oe]-Ie[oe])<6&&Math.min($e,Math.max(Ie[re],ot[re]))-Math.max(He,Math.min(Ie[re],ot[re]))>0&&be++;return be},g=[...y.values()],O=Math.min(...g.map(k=>k.l)),F=Math.max(...g.map(k=>k.r)),j=Math.min(...g.map(k=>k.t)),U=Math.max(...g.map(k=>k.b)),ne=(k,_)=>{let z=(k+_)/2;return[z,z-12,z+12,z-24,z+24]},B=(()=>{let k=[];return I.forEach(_=>I.forEach(z=>{z.t>_.b&&z.l<_.r+400&&z.r>_.l-400&&k.push(...ne(_.b,z.t))})),k.push(j-22,j-34,U+22,U+34),[...new Set(k.map(Math.round))]})(),K=(()=>{let k=[];return I.forEach(_=>I.forEach(z=>{z.l>_.r&&k.push(...ne(_.r,z.l))})),k.push(O-22,O-34,F+22,F+34),[...new Set(k.map(Math.round))]})(),q=new Map,Z=new Map,A=k=>{let _=q.get(k);return _||q.set(k,_=I.filter(z=>k<z.b+6&&k>z.t-6)),_},D=k=>{let _=Z.get(k);return _||Z.set(k,_=I.filter(z=>k<z.r+6&&k>z.l-6)),_},V=r.crossPanel/r.overlap,W=r.border/r.overlap,ie=r.nearEdge/r.overlap;function de(k,_,z,oe,re=!0){let ke=0;for(let be=1;be<k.length;be++)ke+=Math.abs(k[be-1][0]-k[be][0])+Math.abs(k[be-1][1]-k[be][1]);let he=ke+r.bend*(k.length-2);if(he>=oe)return he;let He=0,$e=0;for(let be=1;be<k.length;be++){let Ae=k[be-1],Ie=k[be];if(re){if(le(Ae,Ie,_,z)||w(Ae,Ie))return 1/0;continue}for(let ot of Ae[1]===Ie[1]?A(Ae[1]):D(Ae[0]))ot!==_&&ot!==z&&R(Ae,Ie,ot,6)&&He++;for(let ot of M)R(Ae,Ie,ot,2)&&He++}for(let be=1;be<k.length;be++){let Ae=k[be-1],Ie=k[be];if($e+=v(Ae,Ie)+V*T(Ae,Ie,_,z)+W*E(Ae,Ie),w(Ae,Ie)&&($e+=ie),he+r.overlap*$e>=oe)return he+r.overlap*$e}return he+r.overlap*$e+He*1e5}let X=k=>(k.l+k.r)/2,te=k=>(k.t+k.b)/2,ye=[0,-22,22,-44,44],Fe={bc:1/0},S=(k,_,z,oe)=>Math.abs(k-z)+Math.abs(_-oe),Y=(k,_,z,oe,re,ke,he,He)=>{let $e=0;return $e+=S(k,_,z,oe),$e+=S(z,oe,re,ke),$e+=S(re,ke,he,He),$e+r.bend*2},se=(k,_,z,oe,re,ke,he,He,$e,be)=>{let Ae=0;return Ae+=S(k,_,z,oe),Ae+=S(z,oe,re,ke),Ae+=S(re,ke,he,He),Ae+=S(he,He,$e,be),Ae+r.bend*3},le=(k,_,z,oe)=>{for(let re of k[1]===_[1]?A(k[1]):D(k[0]))if(re!==z&&re!==oe&&R(k,_,re,6))return!0;for(let re of M)if(R(k,_,re,2))return!0;return w(k,_)};function Pe(k,_,z,oe){let re=Math.max(k.l,_.l),ke=Math.min(k.r,_.r);if(ke-re>24)for(let We of ye){let Ze=(re+ke)/2+We;Ze>re+8&&Ze<ke-8&&z(_.t>=k.b?[[Ze,k.b],[Ze,_.t]]:[[Ze,k.t],[Ze,_.b]])}let he=Math.max(k.t,_.t),He=Math.min(k.b,_.b);if(He-he>16)for(let We of[0,-10,10]){let Ze=(he+He)/2+We;z(_.l>=k.r?[[k.r,Ze],[_.l,Ze]]:[[k.l,Ze],[_.r,Ze]])}let $e=K.length,be=B.length,Ae=new Uint8Array(ye.length*be),Ie=new Uint8Array(ye.length*be),ot=new Uint8Array(ye.length*$e),Zn=new Uint8Array(ye.length*$e),ht=(We,Ze,sn,Mt)=>oe?(We[Ze]||(We[Ze]=le(sn,Mt,k,_)?2:1),We[Ze]===1):!0;ye.forEach((We,Ze)=>ye.forEach((sn,Mt)=>{let wt=X(k)+We,kt=X(_)+sn,$t=te(k)+We/3,ct=te(_)+sn/3;B.forEach((Ce,rn)=>{let et=Ce>k.b?k.b:Ce<k.t?k.t:null,Bt=Ce>_.b?_.b:Ce<_.t?_.t:null;et!==null&&Bt!==null&&Y(wt,et,wt,Ce,kt,Ce,kt,Bt)<Fe.bc&&ht(Ae,Ze*be+rn,[wt,et],[wt,Ce])&&ht(Ie,Mt*be+rn,[kt,Ce],[kt,Bt])&&z([[wt,et],[wt,Ce],[kt,Ce],[kt,Bt]])}),K.forEach((Ce,rn)=>{let et=Ce>k.r?k.r:Ce<k.l?k.l:null,Bt=Ce>_.r?_.r:Ce<_.l?_.l:null;et!==null&&Bt!==null&&Y(et,$t,Ce,$t,Ce,ct,Bt,ct)<Fe.bc&&ht(ot,Ze*$e+rn,[et,$t],[Ce,$t])&&ht(Zn,Mt*$e+rn,[Ce,ct],[Bt,ct])&&z([[et,$t],[Ce,$t],[Ce,ct],[Bt,ct]])}),We===0&&sn===0&&K.forEach((Ce,rn)=>B.forEach((et,Bt)=>{let C=Ce>k.r?k.r:Ce<k.l?k.l:null,G=et>_.b?_.b:et<_.t?_.t:null;C!==null&&G!==null&&se(C,$t,Ce,$t,Ce,et,kt,et,kt,G)<Fe.bc&&ht(ot,Ze*$e+rn,[C,$t],[Ce,$t])&&ht(Ie,Mt*be+Bt,[kt,et],[kt,G])&&z([[C,$t],[Ce,$t],[Ce,et],[kt,et],[kt,G]]);let J=et>k.b?k.b:et<k.t?k.t:null,ee=Ce>_.r?_.r:Ce<_.l?_.l:null;J!==null&&ee!==null&&se(wt,J,wt,et,Ce,et,Ce,ct,ee,ct)<Fe.bc&&ht(Ae,Ze*be+Bt,[wt,J],[wt,et])&&ht(Zn,Mt*$e+rn,[Ce,ct],[ee,ct])&&z([[wt,J],[wt,et],[Ce,et],[Ce,ct],[ee,ct]])}));let ms=X(k)<_.l?_.l:X(k)>_.r?_.r:null,Et=ct<k.t?k.t:ct>k.b?k.b:null;ms!==null&&Et!==null&&z([[wt,Et],[wt,ct],[ms,ct]]);let es=te(k)<_.t?_.t:te(k)>_.b?_.b:null,hs=kt<k.l?k.l:kt>k.r?k.r:null;es!==null&&hs!==null&&z([[hs,$t],[kt,$t],[kt,es]])}))}function ae(k,_,z,oe){for(let re of ye){let ke=X(k)+re,he=te(k)+re/3,He=[[[ke,k.t],[ke,_.t]],[[k.r,he],[_.r,he]],[[ke,k.b],[ke,_.b]],[[k.l,he],[_.l,he]]];for(let $e of He)oe(z?[$e[1],$e[0]]:$e)}}let Be=(k,_,z,oe)=>{let re=null;return Fe.bc=1/0,k(ke=>{let he=de(ke,_,z,Fe.bc,oe);he<Fe.bc&&(Fe.bc=he,re=ke)},oe),re},xe=[],fe=k=>N.some(_=>[_.l,_.r].some(z=>k.l<z+3&&k.r>z-3&&k.b>_.t&&k.t<_.b)||[_.t,_.b].some(z=>k.t<z+3&&k.b>z-3&&k.r>_.l&&k.l<_.r)),Se=k=>L.filter(([_,z])=>R(_,z,k,1)).length,Ke=k=>M.some(_=>k.l<_.r&&k.r>_.l&&k.t<_.b&&k.b>_.t),Te=k=>I.filter(_=>k.l<_.r+3&&k.r>_.l-3&&k.t<_.b+3&&k.b>_.t-3).length,Qe=k=>xe.filter(_=>k.l<_.r+4&&k.r>_.l-4&&k.t<_.b+2&&k.b>_.t-2).length,lt=k=>50*rt(k)+3*Se(k)+(fe(k)?1:0)+(Ke(k)?5:0)+5*Te(k)+5*Qe(k),je=k=>Se(k)>0||fe(k)||Ke(k)||Te(k)>0||Qe(k)>0,st=[];(t.links??[]).forEach((k,_)=>{let z=k.id??`link-${_}`,oe=y.get(k.aOn??k.a),re=y.get(k.bOn??k.b);if(oe===re){l.push(`link "${z}" joins "${k.aOn??k.a}" to itself: not drawn`),st.push({...k,id:z,points:[],routed:!1});return}let ke=$(oe,re)?$e=>ae(oe,re,!1,$e):$(re,oe)?$e=>ae(re,oe,!0,$e):($e,be)=>Pe(oe,re,$e,be),he=Be(ke,oe,re,!0),He=!0;if(he||(he=Be(ke,oe,re,!1),He=!1,l.push(`link "${z}": no clear route; drawn the least bad way`)),!he){st.push({...k,id:z,points:[],routed:!1});return}for(let $e=1;$e<he.length;$e++)b(he[$e-1],he[$e]);st.push({...k,id:z,points:he,routed:He})});let Ye=[];for(let k=0;k<L.length;k++)for(let _=k+1;_<L.length;_++){let[z,oe]=L[k],[re,ke]=L[_],he=z[1]===oe[1],He=re[1]===ke[1];if(he===He)continue;let[$e,be]=he?[[z,oe],[re,ke]]:[[re,ke],[z,oe]],Ae=be[0][0],Ie=$e[0][1];Ae>Math.min($e[0][0],$e[1][0])&&Ae<Math.max($e[0][0],$e[1][0])&&Ie>Math.min(be[0][1],be[1][1])&&Ie<Math.max(be[0][1],be[1][1])&&Ye.push([Ae,Ie])}let rt=k=>Ye.filter(([_,z])=>_>k.l-2&&_<k.r+2&&z>k.t-2&&z<k.b+2).length;for(let k of st){let _=k,z=k.points;if(!_.label||!z.length)continue;let oe=[];for(let be=1;be<z.length;be++)oe.push([z[be-1],z[be]]);let re=be=>Math.abs(be[0][0]-be[1][0])+Math.abs(be[0][1]-be[1][1]);oe.sort((be,Ae)=>re(Ae)-re(be));let ke=e(_.label,"label")+6,he=null,He=null,$e=1/0;for(let[be,Ae]of oe){let Ie=(be[0]+Ae[0])/2,ot=(be[1]+Ae[1])/2,Zn=be[1]===Ae[1]?[0,-.3,.3,-.15,.15].flatMap(ht=>{let We=Ie+ht*Math.abs(be[0]-Ae[0]);return[[We,ot-6,"middle"],[We,ot+15,"middle"]]}):[0,-.3,.3].flatMap(ht=>{let We=ot+4+ht*Math.abs(be[1]-Ae[1]);return[[Ie+7,We,"start"],[Ie-7,We,"end"],[Ie+24,We,"start"],[Ie-24,We,"end"]]});for(let[ht,We,Ze]of Zn){let sn=Ze==="middle"?ht-ke/2:Ze==="end"?ht-ke:ht,Mt={l:sn,r:sn+ke,t:We-11,b:We+3};if(!je(Mt)){he=[ht,We,Ze,Mt];break}let wt=lt(Mt);wt<$e&&($e=wt,He=[ht,We,Ze,Mt])}if(he)break}if(!he&&He&&(he=He),!he){let[be,Ae]=oe[0],Ie=(be[0]+Ae[0])/2,ot=(be[1]+Ae[1])/2-6;he=[Ie,ot,"middle",{l:Ie-ke/2,r:Ie+ke/2,t:ot-11,b:ot+3}]}xe.push(he[3]),k.at={x:a(he[0]),y:a(he[1]),anchor:he[2],box:he[3],text:_.label}}let ce=[],Oe=[];for(let k of[...g,...xe,...h.map(_=>_.title)])ce.push(k.l,k.r),Oe.push(k.t,k.b);for(let k of st)for(let _ of k.points)ce.push(_[0]),Oe.push(_[1]);let Ee=r.margin,tt={l:Math.min(...ce)-Ee,t:Math.min(...Oe)-Ee,r:Math.max(...ce)+Ee,b:Math.max(...Oe)+Ee};return{cards:m,panels:h,links:st,bounds:tt,options:r,warnings:l}}function Sc(t,e,n){let s=o=>e>=o.l&&e<=o.r&&n>=o.t&&n<=o.b,r=t.cards.find(o=>s(o.rect));return r?r.id:[...t.panels].sort((o,i)=>i.depth-o.depth).find(o=>s(o.rect))?.id}function Au(t,e,n,s={}){let r=a=>{let l=Os(a,e,s);return Math.max(l.bounds.r-l.bounds.l,(l.bounds.b-l.bounds.t)*n)},o=t,i=r(t);for(let a=0;a<12;a++){let l,c=i;for(let f of Nu(o)){if(Ho(f).length)continue;let u=r(f);u<c-.5&&(c=u,l=f)}if(!l)break;o=l,i=c}return o}function*Nu(t){let e=t.panels??[],n=(i,a)=>i[0]>=a[0]&&i[2]<=a[2]&&i[1]>=a[1]&&i[3]<=a[3],s=(i,a)=>i.every((l,c)=>l===a[c]),r=(i,a=-1)=>{let l=-1;return e.forEach((c,f)=>{f===a||!n(i,c.cells)||a>=0&&f>a&&s(c.cells,e[a].cells)||(l<0||n(c.cells,e[l].cells)&&(!s(c.cells,e[l].cells)||f>l))&&(l=f)}),l},o=i=>{let a=[];return e.forEach((l,c)=>{r(l.cells,c)===i&&a.push({range:[...l.cells],panel:c})}),t.cards.forEach((l,c)=>{let f=[l.cell[0],l.cell[1],l.cell[0],l.cell[1]];r(f)===i&&a.push({range:f,card:c})}),a};for(let i of[-1,...e.map((a,l)=>l)]){let a=o(i);if(i>=0&&!a.some(u=>u.panel!==void 0))continue;let l=u=>[u.range[1],u.range[3]],c=[];for(let u of[...a].sort((d,p)=>d.range[1]-p.range[1]||d.range[0]-p.range[0])){let d=c.find(p=>p.some(h=>l(h)[0]<=l(u)[1]&&l(u)[0]<=l(h)[1]));d?d.push(u):c.push([u])}let f=Math.max(...a.map(u=>u.range[3]));for(let u of c){u.sort((d,p)=>d.range[0]-p.range[0]);for(let d=1;d<u.length;d++){let p=u.slice(d),h=u[0].range[0],m=f+1,y=Math.min(...p.map(E=>E.range[1])),I=Math.max(...p.map(E=>E.range[3]))-y+1,N=t.cards.map(E=>({...E,cell:[...E.cell]})),M=e.map(E=>({...E,cells:[...E.cells]}));for(let E of N)E.cell[1]>f&&(E.cell[1]+=I);let $=new Set;for(let E=i;E>=0&&!$.has(E);E=r(e[E].cells,E))$.add(E);M.forEach((E,w)=>{E.cells[1]>f?(E.cells[1]+=I,E.cells[3]+=I):($.has(w)||E.cells[1]<=f&&E.cells[3]>f)&&(E.cells[3]+=I)});let R=h;for(let E of p){let w=R-E.range[0],T=m+(E.range[1]-y)-E.range[1],L=x=>x[0]>=E.range[0]&&x[0]<=E.range[2]&&x[1]>=E.range[1]&&x[1]<=E.range[3];t.cards.forEach((x,P)=>{L([x.cell[0],x.cell[1]])&&(N[P].cell=[x.cell[0]+w,x.cell[1]+T])}),e.forEach((x,P)=>{n(x.cells,E.range)&&(M[P].cells=[x.cells[0]+w,x.cells[1]+T,x.cells[2]+w,x.cells[3]+T])}),R+=E.range[2]-E.range[0]+1}e.forEach((E,w)=>{let T=t.cards.map((L,x)=>n([L.cell[0],L.cell[1],L.cell[0],L.cell[1]],E.cells)?N[x].cell:void 0).filter(L=>!!L);T.length&&(M[w].cells=[Math.min(...T.map(L=>L[0])),Math.min(...T.map(L=>L[1])),Math.max(...T.map(L=>L[0])),Math.max(...T.map(L=>L[1]))])}),yield{cards:N,panels:M,links:t.links}}}}}function Wo(t,e=()=>!0){let n=t.layout.items.filter(w=>e(w.id)),s=t.layout.catalog,r=!t.layout.items.some(w=>w.type==="node"),o=w=>r?!w.children.some(T=>e(T.id)):w.type==="node"&&!w.children.some(T=>T.type==="node"&&e(T.id)),i=n.filter(o),a=w=>{let T=[];for(let L=w;L;L=L.parent)T.unshift(L);return T},l=new Map(i.map(w=>[w.id,a(w)])),c=(w,T)=>{let L=l.get(w.id),x=l.get(T.id),P=0;for(;P<L.length&&P<x.length&&L[P]===x[P];)P++;return[L[P].box,x[P].box]},f=1e-6,u=(w,T)=>{let[L,x]=c(w,T);return L.y1<=x.y0+f&&L.x0<x.x1-f&&x.x0<L.x1-f},d=(w,T)=>{let[L,x]=c(w,T);return L.x1<=x.x0+f&&L.y0<x.y1-f&&x.y0<L.y1-f},p=(w,T)=>{let L=new Map,x=[];for(let P of[...i].sort((b,v)=>T(b)-T(v))){let b=0;for(let v of x)L.get(v.id)+1>b&&w(v,P)&&(b=L.get(v.id)+1);L.set(P.id,b),x.push(P)}return L},h=p(u,w=>w.box.y0),m=p(d,w=>w.box.x0),y=Math.min(...i.map(w=>w.box.x1-w.box.x0))/2;for(let w of i)if(!w.parent)for(let T of i)T.parent&&T.box.x0<=w.box.x0+y&&m.set(w.id,Math.max(m.get(w.id),m.get(T.id)));let I=new Map;for(let w of i)I.set(w.id,[m.get(w.id),h.get(w.id)]);let N=new Map;for(let w of i){let T=I.get(w.id),L=N.get(String(T));if(L!==void 0&&L!==w.id){for(let[,x]of I)x[0]>T[0]&&x!==T&&x[0]++;T[0]++,N.clear();for(let x of i)N.set(String(I.get(x.id)),x.id)}else N.set(String(T),w.id)}let M=i.map(w=>{if(w.region){let x=w.region;return{id:w.id,label:x.label??w.id,sub:void 0,role:x.role??pt(s,x.kind)?.role??"grey",ghost:x.ghost||void 0,cell:I.get(w.id)}}let T=w.node,L=Qt(s,T.asset);return{id:w.id,label:T.label??w.id,sub:T.sub,role:T.role??L.role,ghost:T.ghost||void 0,cell:I.get(w.id)}}),$=[];for(let w of n){if(o(w))continue;let T=[],L=g=>{for(let O of g.children){let F=I.get(O.id);F&&T.push(F),L(O)}};if(L(w),!T.length)continue;let x=T.map(g=>g[0]),P=T.map(g=>g[1]),b=w.type==="region"?w.region.label:w.node.label??w.id,v=w.type==="region"?w.region.role??pt(s,w.region.kind)?.role:w.node.role??Qt(s,w.node.asset).role;$.push({id:w.id,label:b,sub:w.type==="node"?w.node.sub:void 0,role:v,cells:[Math.min(...x),Math.min(...P),Math.max(...x),Math.max(...P)]})}let R=new Set([...M.map(w=>w.id),...$.map(w=>w.id)]),E=[];for(let w of t.routes){if(!e(w.id))continue;let T=Ut(w.raw.from).id,L=Ut(w.raw.to).id;if(!R.has(T)||!R.has(L))continue;let x=typeof w.raw.label=="string"?w.raw.label:w.raw.label?.text;E.push({id:w.id,a:T,b:L,kind:w.kind,label:x})}return{cards:M,panels:$,links:E}}var Wn={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},Mc=`
|
|
287
|
+
`)}`);let r={...Nl,...t},{W:o,H:i}=r,a=T=>Math.round(T*10)/10,l=[],c=n.panels??[],{prect:f,parentIx:u,depthOf:d,cardAt:p}=to(n,r),g=c.map((T,V)=>{let j=f[V],re=e(T.label??"","title")+(T.sub?e(T.sub,"titleSub"):0);return{...T,rect:j,titleAt:[a(j.l+16),a(j.b-15)],depth:d(V),parent:u[V]>=0?c[u[V]].id:void 0,title:{l:j.l+10,r:j.l+22+re,t:j.b-30,b:j.b-6}}}),m=n.cards.map(T=>{let[V,j]=p(n.cards.indexOf(T));return{...T,rect:{l:V,t:j,r:V+o,b:j+i}}}),y=new Map;g.forEach(T=>y.set(T.id,T.rect)),m.forEach(T=>y.set(T.id,T.rect));let N=m.map(T=>T.rect),h=g.map(T=>T.rect),b=g.filter(T=>T.label).map(T=>T.title),x=(T,V)=>T.l>=V.l&&T.r<=V.r&&T.t>=V.t&&T.b<=V.b,A=(T,V,j,re)=>Math.min(T[0],V[0])<j.r+re&&Math.max(T[0],V[0])>j.l-re&&Math.min(T[1],V[1])<j.b+re&&Math.max(T[1],V[1])>j.t-re,M=(T,V)=>h.reduce((j,re)=>{if(T[0]===V[0]){let fe=Math.min(T[1],V[1]),Ee=Math.max(T[1],V[1]);T[0]>re.l&&T[0]<re.r&&(j+=[re.t,re.b].filter(ve=>ve>fe+1&&ve<Ee-1).length)}else{let fe=Math.min(T[0],V[0]),Ee=Math.max(T[0],V[0]);T[1]>re.t&&T[1]<re.b&&(j+=[re.l,re.r].filter(ve=>ve>fe+1&&ve<Ee-1).length)}return j},0),v=(T,V)=>h.some(j=>T[1]===V[1]?[j.t,j.b].some(re=>Math.abs(T[1]-re)<16&&Math.max(T[0],V[0])>j.l&&Math.min(T[0],V[0])<j.r):[j.l,j.r].some(re=>Math.abs(T[0]-re)<16&&Math.max(T[1],V[1])>j.t&&Math.min(T[1],V[1])<j.b)),O=(T,V,j,re)=>h.filter(fe=>fe!==j&&fe!==re&&!x(j,fe)&&!x(re,fe)&&A(T,V,{l:fe.l+3,r:fe.r-3,t:fe.t+3,b:fe.b-3},0)).length,C=[],$=new Map,P=new Map,k=(T,V)=>{C.push([T,V]);let[j,re]=T[1]===V[1]?[$,T[1]]:T[0]===V[0]?[P,T[0]]:[void 0,0];if(!j)return;let fe=Math.floor(re/6);(j.get(fe)??j.set(fe,[]).get(fe)).push([T,V])},E=(T,V)=>{let j=T[1]===V[1];if(!j&&T[0]!==V[0])return 0;let re=j?1:0,fe=j?0:1,Ee=j?$:P,ve=Math.floor(T[re]/6),We=Math.min(T[fe],V[fe]),Ie=Math.max(T[fe],V[fe]),Re=0;for(let De=ve-1;De<=ve+1;De++)for(let[Ke,it]of Ee.get(De)??[])Math.abs(T[re]-Ke[re])<6&&Math.min(Ie,Math.max(Ke[fe],it[fe]))-Math.max(We,Math.min(Ke[fe],it[fe]))>0&&Re++;return Re},S=[...y.values()],F=Math.min(...S.map(T=>T.l)),D=Math.max(...S.map(T=>T.r)),H=Math.min(...S.map(T=>T.t)),X=Math.max(...S.map(T=>T.b)),Y=(T,V)=>{let j=(T+V)/2;return[j,j-12,j+12,j-24,j+24]},L=(()=>{let T=[];return N.forEach(V=>N.forEach(j=>{j.t>V.b&&j.l<V.r+400&&j.r>V.l-400&&T.push(...Y(V.b,j.t))})),T.push(H-22,H-34,X+22,X+34),[...new Set(T.map(Math.round))]})(),q=(()=>{let T=[];return N.forEach(V=>N.forEach(j=>{j.l>V.r&&T.push(...Y(V.r,j.l))})),T.push(F-22,F-34,D+22,D+34),[...new Set(T.map(Math.round))]})(),U=new Map,Z=new Map,I=T=>{let V=U.get(T);return V||U.set(T,V=N.filter(j=>T<j.b+6&&T>j.t-6)),V},_=T=>{let V=Z.get(T);return V||Z.set(T,V=N.filter(j=>T<j.r+6&&T>j.l-6)),V},K=r.crossPanel/r.overlap,J=r.border/r.overlap,de=r.nearEdge/r.overlap;function ce(T,V,j,re,fe=!0){let Ee=0;for(let Re=1;Re<T.length;Re++)Ee+=Math.abs(T[Re-1][0]-T[Re][0])+Math.abs(T[Re-1][1]-T[Re][1]);let ve=Ee+r.bend*(T.length-2);if(ve>=re)return ve;let We=0,Ie=0;for(let Re=1;Re<T.length;Re++){let De=T[Re-1],Ke=T[Re];if(fe){if(we(De,Ke,V,j)||v(De,Ke))return 1/0;continue}for(let it of De[1]===Ke[1]?I(De[1]):_(De[0]))it!==V&&it!==j&&A(De,Ke,it,6)&&We++;for(let it of b)A(De,Ke,it,2)&&We++}for(let Re=1;Re<T.length;Re++){let De=T[Re-1],Ke=T[Re];if(Ie+=E(De,Ke)+K*O(De,Ke,V,j)+J*M(De,Ke),v(De,Ke)&&(Ie+=de),ve+r.overlap*Ie>=re)return ve+r.overlap*Ie}return ve+r.overlap*Ie+We*1e5}let W=T=>(T.l+T.r)/2,ne=T=>(T.t+T.b)/2,Ae=[0,-22,22,-44,44],Be={bc:1/0},R=(T,V,j,re)=>Math.abs(T-j)+Math.abs(V-re),ee=(T,V,j,re,fe,Ee,ve,We)=>{let Ie=0;return Ie+=R(T,V,j,re),Ie+=R(j,re,fe,Ee),Ie+=R(fe,Ee,ve,We),Ie+r.bend*2},ge=(T,V,j,re,fe,Ee,ve,We,Ie,Re)=>{let De=0;return De+=R(T,V,j,re),De+=R(j,re,fe,Ee),De+=R(fe,Ee,ve,We),De+=R(ve,We,Ie,Re),De+r.bend*3},we=(T,V,j,re)=>{for(let fe of T[1]===V[1]?I(T[1]):_(T[0]))if(fe!==j&&fe!==re&&A(T,V,fe,6))return!0;for(let fe of b)if(A(T,V,fe,2))return!0;return v(T,V)};function je(T,V,j,re){let fe=Math.max(T.l,V.l),Ee=Math.min(T.r,V.r);if(Ee-fe>24)for(let et of Ae){let st=(fe+Ee)/2+et;st>fe+8&&st<Ee-8&&j(V.t>=T.b?[[st,T.b],[st,V.t]]:[[st,T.t],[st,V.b]])}let ve=Math.max(T.t,V.t),We=Math.min(T.b,V.b);if(We-ve>16)for(let et of[0,-10,10]){let st=(ve+We)/2+et;j(V.l>=T.r?[[T.r,st],[V.l,st]]:[[T.l,st],[V.r,st]])}let Ie=q.length,Re=L.length,De=new Uint8Array(Ae.length*Re),Ke=new Uint8Array(Ae.length*Re),it=new Uint8Array(Ae.length*Ie),bs=new Uint8Array(Ae.length*Ie),bt=(et,st,hn,Et)=>re?(et[st]||(et[st]=we(hn,Et,T,V)?2:1),et[st]===1):!0;Ae.forEach((et,st)=>Ae.forEach((hn,Et)=>{let St=W(T)+et,vt=W(V)+hn,Tt=ne(T)+et/3,ft=ne(V)+hn/3;L.forEach((Ge,gn)=>{let rt=Ge>T.b?T.b:Ge<T.t?T.t:null,Kt=Ge>V.b?V.b:Ge<V.t?V.t:null;rt!==null&&Kt!==null&&ee(St,rt,St,Ge,vt,Ge,vt,Kt)<Be.bc&&bt(De,st*Re+gn,[St,rt],[St,Ge])&&bt(Ke,Et*Re+gn,[vt,Ge],[vt,Kt])&&j([[St,rt],[St,Ge],[vt,Ge],[vt,Kt]])}),q.forEach((Ge,gn)=>{let rt=Ge>T.r?T.r:Ge<T.l?T.l:null,Kt=Ge>V.r?V.r:Ge<V.l?V.l:null;rt!==null&&Kt!==null&&ee(rt,Tt,Ge,Tt,Ge,ft,Kt,ft)<Be.bc&&bt(it,st*Ie+gn,[rt,Tt],[Ge,Tt])&&bt(bs,Et*Ie+gn,[Ge,ft],[Kt,ft])&&j([[rt,Tt],[Ge,Tt],[Ge,ft],[Kt,ft]])}),et===0&&hn===0&&q.forEach((Ge,gn)=>L.forEach((rt,Kt)=>{let B=Ge>T.r?T.r:Ge<T.l?T.l:null,Q=rt>V.b?V.b:rt<V.t?V.t:null;B!==null&&Q!==null&&ge(B,Tt,Ge,Tt,Ge,rt,vt,rt,vt,Q)<Be.bc&&bt(it,st*Ie+gn,[B,Tt],[Ge,Tt])&&bt(Ke,Et*Re+Kt,[vt,rt],[vt,Q])&&j([[B,Tt],[Ge,Tt],[Ge,rt],[vt,rt],[vt,Q]]);let ie=rt>T.b?T.b:rt<T.t?T.t:null,pe=Ge>V.r?V.r:Ge<V.l?V.l:null;ie!==null&&pe!==null&&ge(St,ie,St,rt,Ge,rt,Ge,ft,pe,ft)<Be.bc&&bt(De,st*Re+Kt,[St,ie],[St,rt])&&bt(bs,Et*Ie+gn,[Ge,ft],[pe,ft])&&j([[St,ie],[St,rt],[Ge,rt],[Ge,ft],[pe,ft]])}));let Cs=W(T)<V.l?V.l:W(T)>V.r?V.r:null,At=ft<T.t?T.t:ft>T.b?T.b:null;Cs!==null&&At!==null&&j([[St,At],[St,ft],[Cs,ft]]);let ys=ne(T)<V.t?V.t:ne(T)>V.b?V.b:null,Is=vt<T.l?T.l:vt>T.r?T.r:null;ys!==null&&Is!==null&&j([[Is,Tt],[vt,Tt],[vt,ys]])}))}function ye(T,V,j,re){for(let fe of Ae){let Ee=W(T)+fe,ve=ne(T)+fe/3,We=[[[Ee,T.t],[Ee,V.t]],[[T.r,ve],[V.r,ve]],[[Ee,T.b],[Ee,V.b]],[[T.l,ve],[V.l,ve]]];for(let Ie of We)re(j?[Ie[1],Ie[0]]:Ie)}}let ze=(T,V,j,re)=>{let fe=null;return Be.bc=1/0,T(Ee=>{let ve=ce(Ee,V,j,Be.bc,re);ve<Be.bc&&(Be.bc=ve,fe=Ee)},re),fe},Pe=[],ke=T=>h.some(V=>[V.l,V.r].some(j=>T.l<j+3&&T.r>j-3&&T.b>V.t&&T.t<V.b)||[V.t,V.b].some(j=>T.t<j+3&&T.b>j-3&&T.r>V.l&&T.l<V.r)),w=T=>C.filter(([V,j])=>A(V,j,T,1)).length,z=T=>b.some(V=>T.l<V.r&&T.r>V.l&&T.t<V.b&&T.b>V.t),G=T=>N.filter(V=>T.l<V.r+3&&T.r>V.l-3&&T.t<V.b+3&&T.b>V.t-3).length,ae=T=>Pe.filter(V=>T.l<V.r+4&&T.r>V.l-4&&T.t<V.b+2&&T.b>V.t-2).length,le=T=>50*Se(T)+3*w(T)+(ke(T)?1:0)+(z(T)?5:0)+5*G(T)+5*ae(T),ue=T=>w(T)>0||ke(T)||z(T)||G(T)>0||ae(T)>0,se=[];(n.links??[]).forEach((T,V)=>{let j=T.id??`link-${V}`,re=y.get(T.aOn??T.a),fe=y.get(T.bOn??T.b);if(re===fe){l.push(`link "${j}" joins "${T.aOn??T.a}" to itself: not drawn`),se.push({...T,id:j,points:[],routed:!1});return}let Ee=x(re,fe)?Ie=>ye(re,fe,!1,Ie):x(fe,re)?Ie=>ye(fe,re,!0,Ie):(Ie,Re)=>je(re,fe,Ie,Re),ve=ze(Ee,re,fe,!0),We=!0;if(ve||(ve=ze(Ee,re,fe,!1),We=!1,l.push(`link "${j}": no clear route; drawn the least bad way`)),!ve){se.push({...T,id:j,points:[],routed:!1});return}for(let Ie=1;Ie<ve.length;Ie++)k(ve[Ie-1],ve[Ie]);se.push({...T,id:j,points:ve,routed:We})});let be=[];for(let T=0;T<C.length;T++)for(let V=T+1;V<C.length;V++){let[j,re]=C[T],[fe,Ee]=C[V],ve=j[1]===re[1],We=fe[1]===Ee[1];if(ve===We)continue;let[Ie,Re]=ve?[[j,re],[fe,Ee]]:[[fe,Ee],[j,re]],De=Re[0][0],Ke=Ie[0][1];De>Math.min(Ie[0][0],Ie[1][0])&&De<Math.max(Ie[0][0],Ie[1][0])&&Ke>Math.min(Re[0][1],Re[1][1])&&Ke<Math.max(Re[0][1],Re[1][1])&&be.push([De,Ke])}let Se=T=>be.filter(([V,j])=>V>T.l-2&&V<T.r+2&&j>T.t-2&&j<T.b+2).length;for(let T of se){let V=T,j=T.points;if(!V.label||!j.length)continue;let re=[];for(let Re=1;Re<j.length;Re++)re.push([j[Re-1],j[Re]]);let fe=Re=>Math.abs(Re[0][0]-Re[1][0])+Math.abs(Re[0][1]-Re[1][1]);re.sort((Re,De)=>fe(De)-fe(Re));let Ee=e(V.label,"label")+6,ve=null,We=null,Ie=1/0;for(let[Re,De]of re){let Ke=(Re[0]+De[0])/2,it=(Re[1]+De[1])/2,bs=Re[1]===De[1]?[0,-.3,.3,-.15,.15].flatMap(bt=>{let et=Ke+bt*Math.abs(Re[0]-De[0]);return[[et,it-6,"middle"],[et,it+15,"middle"]]}):[0,-.3,.3].flatMap(bt=>{let et=it+4+bt*Math.abs(Re[1]-De[1]);return[[Ke+7,et,"start"],[Ke-7,et,"end"],[Ke+24,et,"start"],[Ke-24,et,"end"]]});for(let[bt,et,st]of bs){let hn=st==="middle"?bt-Ee/2:st==="end"?bt-Ee:bt,Et={l:hn,r:hn+Ee,t:et-11,b:et+3};if(!ue(Et)){ve=[bt,et,st,Et];break}let St=le(Et);St<Ie&&(Ie=St,We=[bt,et,st,Et])}if(ve)break}if(!ve&&We&&(ve=We),!ve){let[Re,De]=re[0],Ke=(Re[0]+De[0])/2,it=(Re[1]+De[1])/2-6;ve=[Ke,it,"middle",{l:Ke-Ee/2,r:Ke+Ee/2,t:it-11,b:it+3}]}Pe.push(ve[3]),T.at={x:a(ve[0]),y:a(ve[1]),anchor:ve[2],box:ve[3],text:V.label}}let te=[],xe=[];for(let T of[...S,...Pe,...g.map(V=>V.title)])te.push(T.l,T.r),xe.push(T.t,T.b);for(let T of se)for(let V of T.points)te.push(V[0]),xe.push(V[1]);let he=r.margin,Oe={l:Math.min(...te)-he,t:Math.min(...xe)-he,r:Math.max(...te)+he,b:Math.max(...xe)+he};return{cards:m,panels:g,links:se,bounds:Oe,options:r,warnings:l}}function lu(n,e,t){let s=o=>e>=o.l&&e<=o.r&&t>=o.t&&t<=o.b,r=n.cards.find(o=>s(o.rect));return r?r.id:[...n.panels].sort((o,i)=>i.depth-o.depth).find(o=>s(o.rect))?.id}function _m(n,e,t,s={}){let r=a=>{let l=lr(a,e,s);return Math.max(l.bounds.r-l.bounds.l,(l.bounds.b-l.bounds.t)*t)},o=n,i=r(n);for(let a=0;a<12;a++){let l,c=i;for(let f of zm(o)){if(Di(f).length)continue;let u=r(f);u<c-.5&&(c=u,l=f)}if(!l)break;o=l,i=c}return o}function*zm(n){let e=n.panels??[],t=(i,a)=>i[0]>=a[0]&&i[2]<=a[2]&&i[1]>=a[1]&&i[3]<=a[3],s=(i,a)=>i.every((l,c)=>l===a[c]),r=(i,a=-1)=>{let l=-1;return e.forEach((c,f)=>{f===a||!t(i,c.cells)||a>=0&&f>a&&s(c.cells,e[a].cells)||(l<0||t(c.cells,e[l].cells)&&(!s(c.cells,e[l].cells)||f>l))&&(l=f)}),l},o=i=>{let a=[];return e.forEach((l,c)=>{r(l.cells,c)===i&&a.push({range:[...l.cells],panel:c})}),n.cards.forEach((l,c)=>{let f=[l.cell[0],l.cell[1],l.cell[0],l.cell[1]];r(f)===i&&a.push({range:f,card:c})}),a};for(let i of[-1,...e.map((a,l)=>l)]){let a=o(i);if(i>=0&&!a.some(u=>u.panel!==void 0))continue;let l=u=>[u.range[1],u.range[3]],c=[];for(let u of[...a].sort((d,p)=>d.range[1]-p.range[1]||d.range[0]-p.range[0])){let d=c.find(p=>p.some(g=>l(g)[0]<=l(u)[1]&&l(u)[0]<=l(g)[1]));d?d.push(u):c.push([u])}let f=Math.max(...a.map(u=>u.range[3]));for(let u of c){u.sort((d,p)=>d.range[0]-p.range[0]);for(let d=1;d<u.length;d++){let p=u.slice(d),g=u[0].range[0],m=f+1,y=Math.min(...p.map(M=>M.range[1])),N=Math.max(...p.map(M=>M.range[3]))-y+1,h=n.cards.map(M=>({...M,cell:[...M.cell]})),b=e.map(M=>({...M,cells:[...M.cells]}));for(let M of h)M.cell[1]>f&&(M.cell[1]+=N);let x=new Set;for(let M=i;M>=0&&!x.has(M);M=r(e[M].cells,M))x.add(M);b.forEach((M,v)=>{M.cells[1]>f?(M.cells[1]+=N,M.cells[3]+=N):(x.has(v)||M.cells[1]<=f&&M.cells[3]>f)&&(M.cells[3]+=N)});let A=g;for(let M of p){let v=A-M.range[0],O=m+(M.range[1]-y)-M.range[1],C=$=>$[0]>=M.range[0]&&$[0]<=M.range[2]&&$[1]>=M.range[1]&&$[1]<=M.range[3];n.cards.forEach(($,P)=>{C([$.cell[0],$.cell[1]])&&(h[P].cell=[$.cell[0]+v,$.cell[1]+O])}),e.forEach(($,P)=>{t($.cells,M.range)&&(b[P].cells=[$.cells[0]+v,$.cells[1]+O,$.cells[2]+v,$.cells[3]+O])}),A+=M.range[2]-M.range[0]+1}e.forEach((M,v)=>{let O=n.cards.map((C,$)=>t([C.cell[0],C.cell[1],C.cell[0],C.cell[1]],M.cells)?h[$].cell:void 0).filter(C=>!!C);O.length&&(b[v].cells=[Math.min(...O.map(C=>C[0])),Math.min(...O.map(C=>C[1])),Math.max(...O.map(C=>C[0])),Math.max(...O.map(C=>C[1]))])}),yield{cards:h,panels:b,links:n.links}}}}}function _i(n,e=()=>!0){let t=n.layout.items.filter(v=>e(v.id)),s=n.layout.catalog,r=!n.layout.items.some(v=>v.type==="node"),o=v=>r?!v.children.some(O=>e(O.id)):v.type==="node"&&!v.children.some(O=>O.type==="node"&&e(O.id)),i=t.filter(o),a=v=>{let O=[];for(let C=v;C;C=C.parent)O.unshift(C);return O},l=new Map(i.map(v=>[v.id,a(v)])),c=(v,O)=>{let C=l.get(v.id),$=l.get(O.id),P=0;for(;P<C.length&&P<$.length&&C[P]===$[P];)P++;return[C[P].box,$[P].box]},f=1e-6,u=(v,O)=>{let[C,$]=c(v,O);return C.y1<=$.y0+f&&C.x0<$.x1-f&&$.x0<C.x1-f},d=(v,O)=>{let[C,$]=c(v,O);return C.x1<=$.x0+f&&C.y0<$.y1-f&&$.y0<C.y1-f},p=(v,O)=>{let C=new Map,$=[];for(let P of[...i].sort((k,E)=>O(k)-O(E))){let k=0;for(let E of $)C.get(E.id)+1>k&&v(E,P)&&(k=C.get(E.id)+1);C.set(P.id,k),$.push(P)}return C},g=p(u,v=>v.box.y0),m=p(d,v=>v.box.x0),y=Math.min(...i.map(v=>v.box.x1-v.box.x0))/2;for(let v of i)if(!v.parent)for(let O of i)O.parent&&O.box.x0<=v.box.x0+y&&m.set(v.id,Math.max(m.get(v.id),m.get(O.id)));let N=new Map;for(let v of i)N.set(v.id,[m.get(v.id),g.get(v.id)]);let h=new Map;for(let v of i){let O=N.get(v.id),C=h.get(String(O));if(C!==void 0&&C!==v.id){for(let[,$]of N)$[0]>O[0]&&$!==O&&$[0]++;O[0]++,h.clear();for(let $ of i)h.set(String(N.get($.id)),$.id)}else h.set(String(O),v.id)}let b=i.map(v=>{if(v.region){let $=v.region;return{id:v.id,label:$.label??v.id,sub:void 0,role:$.role??pt(s,$.kind)?.role??"grey",ghost:$.ghost||void 0,cell:N.get(v.id)}}let O=v.node,C=on(s,O.asset);return{id:v.id,label:O.label??v.id,sub:O.sub,role:O.role??C.role,ghost:O.ghost||void 0,cell:N.get(v.id)}}),x=[];for(let v of t){if(o(v))continue;let O=[],C=S=>{for(let F of S.children){let D=N.get(F.id);D&&O.push(D),C(F)}};if(C(v),!O.length)continue;let $=O.map(S=>S[0]),P=O.map(S=>S[1]),k=v.type==="region"?v.region.label:v.node.label??v.id,E=v.type==="region"?v.region.role??pt(s,v.region.kind)?.role:v.node.role??on(s,v.node.asset).role;x.push({id:v.id,label:k,sub:v.type==="node"?v.node.sub:void 0,role:E,cells:[Math.min(...$),Math.min(...P),Math.max(...$),Math.max(...P)]})}let A=new Set([...b.map(v=>v.id),...x.map(v=>v.id)]),M=[];for(let v of n.routes){if(!e(v.id))continue;let O=Qt(v.raw.from).id,C=Qt(v.raw.to).id;if(!A.has(O)||!A.has(C))continue;let $=typeof v.raw.label=="string"?v.raw.label:v.raw.label?.text;M.push({id:v.id,a:O,b:C,kind:v.kind,label:$})}return{cards:b,panels:x,links:M}}var ms={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},cu=`
|
|
279
288
|
.blk .card-name{font-size:13px;font-weight:600;fill:var(--ink)}
|
|
280
289
|
.blk .card-sub{font-size:10px;fill:var(--ink);opacity:.75}
|
|
281
290
|
.blk.ghost .card-name,.blk.ghost .card-sub{fill:var(--muted)}
|
|
282
|
-
`;function $a(t){return{name:"card",description:"A card: a slab with its name on its front face",size:[Wn.W,Wn.D,Wn.H],role:"grey",draw(e,n,s){let r=t(s.id),o=e.blockFaces(n);if(!r)return o;let i=n.z1-n.z0;return o+=e.faceText(n.x0+.2,n.y1,n.z0+(r.sub?i*.52:i*.34),r.label,"card-name",at.lbl,"left","start"),r.sub&&(o+=e.faceText(n.x0+.2,n.y1,n.z0+i*.14,r.sub,"card-sub",at.sub,"left","start")),o}}}function $c(t){let e=new Map(t.cards.map(n=>[n.id,{label:n.label,sub:n.sub}]));return{regions:{panel:{shape:"slab",pad:Wn.PAD,z:[Wn.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:$a(n=>e.get(n))},defaultNode:"card"}}function Ec(t,e={}){let n=Wn,{prect:s,parentIx:r,cardAt:o}=gr(t,{W:n.W,H:n.D,GX:n.GX,GY:n.GY,PAD:n.PAD,TITLE:0,CH:n.CH}),i=t.panels??[],a=h=>Math.round(h*1e3)/1e3,l=h=>(h.cells[2]-h.cells[0]+1)*(h.cells[3]-h.cells[1]+1),c=h=>{let m=-1;return i.forEach((y,I)=>{let N=y.cells;h.cell[0]>=N[0]&&h.cell[0]<=N[2]&&h.cell[1]>=N[1]&&h.cell[1]<=N[3]&&(m<0||l(y)<=l(i[m]))&&(m=I)}),m},f=i.map((h,m)=>{let y=s[m],I=r[m]>=0?s[r[m]]:{l:0,t:0};return{id:h.id,kind:"panel",label:h.label,role:h.role,at:[a(y.l-I.l),a(y.t-I.t)],size:[a(y.r-y.l),a(y.b-y.t)],regions:[],nodes:[]}}),u=[],d=[];f.forEach((h,m)=>r[m]>=0?f[r[m]].regions.push(h):u.push(h));for(let h of t.cards){let[m,y]=o(t.cards.indexOf(h)),I=c(h),N=I>=0?s[I]:{l:0,t:0},M={id:h.id,asset:"card",role:h.role,ghost:h.ghost||void 0,at:[a(m-N.l),a(y-N.t)],size:[n.W,n.D,n.H]};(I>=0?f[I].nodes:d).push(M)}for(let h of f)h.regions.length||delete h.regions,h.nodes.length||delete h.nodes;let p=(t.links??[]).map((h,m)=>({id:h.id??`link-${m}`,from:h.aOn??h.a,to:h.bOn??h.b,kind:h.kind,label:h.label}));return{isodiag:1,title:e.title,kinds:e.kinds,roles:e.roles,scenes:[{id:"board",title:e.title??"board",regions:u,nodes:d,routes:p}]}}var mf={};bi(mf,{APPEARS:()=>Rc,BASE_FIELDS:()=>_a,BINS:()=>zc,BIN_MS:()=>tn,CARD:()=>dt,DUAL_VIEW_CSS:()=>pf,IDLES:()=>Oc,MAX_ZOOM:()=>Xo,MIN_ZOOM:()=>Jo,P3:()=>ze,SEGMENT_NAME:()=>ei,SEVERITIES:()=>jt,TIMELINE_VERSION:()=>Dc,activityOf:()=>Ga,attr:()=>mn,binNext:()=>ii,binStart:()=>cs,buildLayer:()=>vr,cardMotion:()=>Cc,clamp:()=>_n,cls:()=>Ic,crumbs:()=>Is,dualView:()=>ff,ease:()=>kr,escapeName:()=>si,extent:()=>Qo,findGaps:()=>ai,fitWithOverlay:()=>Fc,flatCss:()=>rf,flatSvg:()=>pi,formatScope:()=>jc,gapKey:()=>us,gapLabel:()=>fs,h:()=>Q,hasSegment:()=>Gc,highlights:()=>xr,isZone:()=>Yc,isoVars:()=>Bc,join:()=>Vc,kindOf:()=>Cs,legend:()=>Ba,levelOf:()=>Nt,markConnectors:()=>gi,md:()=>Tn,measureIn:()=>mi,memorySource:()=>Qc,modeFor:()=>Ka,morphSvgs:()=>cf,mountTimeline:()=>nf,n:()=>Na,nameOf:()=>Ls,node:()=>Lc,offsetAt:()=>Ct,overlayPaint:()=>Nc,parentOf:()=>Kc,prefixAt:()=>Bn,prune:()=>Ra,pts:()=>br,rangeOf:()=>yr,readTime:()=>Da,rectOf:()=>of,renderPage:()=>_c,rewrite:()=>Pa,scope:()=>Ca,scopePattern:()=>ti,scopeRules:()=>ni,scopeSelector:()=>Oa,searchFor:()=>Fs,severities:()=>Uc,stepData:()=>Fa,storedMode:()=>uf,ticks:()=>li,timeScale:()=>Bs,toCSV:()=>fi,toJSON:()=>ci,unite:()=>Zo,viewToggle:()=>df,viewport:()=>Ac,within:()=>Vt});function Pu(t,e,n){let r=(a,l,c,f,u)=>Math.min((a-48)/(c-l),...f===void 0||u===void 0?[]:[[u-f,12],[u-l,30],[c-f,30]].map(([d,p])=>d>0?(a-p)/d:1/0)),o=Math.min(Xo,Math.max(Jo,Math.min(r(t.w,e.x,e.x+e.w,n?.x,n&&n.x+n.w),r(t.h,e.y,e.y+e.h,n?.y,n&&n.y+n.h)))),i=(a,l,c,f,u)=>{let d=(l+c)/2;if(f===void 0||u===void 0)return d;let p=u-(a/2-6)/o,h=f+(a/2-6)/o;return p>h?(p+h)/2:Math.max(p,Math.min(h,d))};return{k:o,cx:i(t.w,e.x,e.x+e.w,n?.x,n&&n.x+n.w),cy:i(t.h,e.y,e.y+e.h,n?.y,n&&n.y+n.h)}}var Jo=.1,Xo=8;function Ac(t,e){let n,s,r=!1,o=0,i=0,a=0,l=0,c=0,f=!1,u=()=>{let w=t.getBoundingClientRect();return{w:Math.max(1,w.width),h:Math.max(1,w.height)}},d=(w=n)=>{let T=u();return Math.min(T.w/w.w,T.h/w.h)},p=w=>{o++;try{w()}finally{o--}};function h(){let w=e.svg();if(!w||!n)return;o||(r=!0);let T=u(),L=d(),x=T.w/L,P=T.h/L;n={x:n.x+(n.w-x)/2,y:n.y+(n.h-P)/2,w:x,h:P},w.setAttribute("viewBox",`${n.x.toFixed(2)} ${n.y.toFixed(2)} ${n.w.toFixed(2)} ${n.h.toFixed(2)}`),i=L,e.onApply(L),a&&Math.abs(L/a-1)>.02&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,e.onRezoom()}))}let m=(w,T)=>{let L=t.getBoundingClientRect(),x=d();return{x:n.x+(w-L.left)/x,y:n.y+(T-L.top)/x}};function y(w,T,L){if(!n)return;let x=d(),P=Math.min(Xo,Math.max(Jo,x*w)),b=t.getBoundingClientRect(),v=T??b.left+b.width/2,g=L??b.top+b.height/2,O=m(v,g),F=u();n={x:O.x-(v-b.left)/P,y:O.y-(g-b.top)/P,w:F.w/P,h:F.h/P},h()}function I(w=s,T){if(!w)return;let L=u(),{k:x,cx:P,cy:b}=Pu(L,w,T),v={x:P-L.w/x/2,y:b-L.h/x/2,w:L.w/x,h:L.h/x};if(n&&Math.abs(v.w/n.w-1)<.001&&Math.abs(v.h/n.h-1)<.001&&Math.abs(v.x-n.x)<v.w*.001&&Math.abs(v.y-n.y)<v.h*.001){h();return}n=v,h()}function N(){for(let w=0,T="";w<4;w++){let L=e.itemsBox()??s;if(!L)return;let x=[L.x,L.y,L.w,L.h].map(b=>Math.round(b)).join();if(x===T)break;T=x;let P=Math.max(24,Math.min(L.w,L.h)*.06);if(p(()=>I({x:L.x-P,y:L.y-P,w:L.w+P*2,h:L.h+P*2},e.alsoBox?.())),!e.marksShowing()||!a||Math.abs(d()/a-1)<=.02)break;cancelAnimationFrame(l),l=0,e.onRezoom()}r=!1}function M(){if(r||!e.svg()||!n)return;let w=t.getBoundingClientRect();w.width<2||w.height<2||N()}function $(){if(!n)return;let w=d();y(1/w)}function R(){return new Promise(w=>{let T=0,L=i,x=()=>{if(f){w();return}let P=!!(l||c)||i!==L;L=i,T=P?0:T+1,T>=2?w():requestAnimationFrame(x)};requestAnimationFrame(x)})}let E=new ResizeObserver(()=>{if(!(!n||f)){if(r&&i){let w=u(),T=n.x+n.w/2,L=n.y+n.h/2;n={x:T-w.w/i/2,y:L-w.h/i/2,w:w.w/i,h:w.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,f||M()})),p(h)}});return E.observe(t),{get view(){return n},set view(w){n=w},get full(){return s},set full(w){s=w},get moved(){return r},get zoom(){return i},painted(w){a=w},size:u,scale:d,quietly:p,applyView:h,toSvg:m,zoomAt:y,fit:I,fitItems:N,autoFit:M,actual:$,settled:R,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(l),E.disconnect(),f=!0}}}var mt="http://www.w3.org/2000/svg",dt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},ze=(t,e,n)=>[(t-e)*yt*Xe,(t+e)*.5*Xe-n*Xe],br=t=>t.map(([e,n])=>`${e.toFixed(1)},${n.toFixed(1)}`).join(" ");function Nc(t,e){function n(o,i,a){let l=t.k(),c=(u,d,p,h,m="")=>{let y=o.createElementNS(mt,"g");y.setAttribute("class",`live-badge ${p.cls} ${m}`.trim());let I=8/l,N=o.createElementNS(mt,"circle");if(N.setAttribute("cx",String(u)),N.setAttribute("cy",String(d)),N.setAttribute("r",String(I)),y.append(N),"g"in p){let $=o.createElementNS(mt,"text");$.setAttribute("x",String(u)),$.setAttribute("y",String(d)),$.style.fontSize=`${(10/l).toFixed(2)}px`,$.textContent=p.g,y.append($)}else{let $=o.createElementNS(mt,"use");$.setAttribute("href",t.iconHref(p.icon));let R=11/l;$.setAttribute("x",String(u-R/2)),$.setAttribute("y",String(d-R/2)),$.setAttribute("width",String(R)),$.setAttribute("height",String(R)),y.append($)}let M=o.createElementNS(mt,"title");M.textContent=h,y.append(M),i(y)},f=(u,d)=>{for(let p of t.outlinesFor(u)){if(p.kind!=="poly")continue;let h=o.createElementNS(mt,"polygon");h.setAttribute("class",d),h.setAttribute("points",p.points.map(([m,y])=>`${m.toFixed(1)},${y.toFixed(1)}`).join(" ")),i(h)}};for(let u of a){let d=t.boxOf(u.at);if(d){if(u.outline&&f(u.at,u.outline),u.badge)c(d.x,d.y,u.badge,u.title);else if(u.hit){let p=o.createElementNS(mt,"title");p.textContent=u.title;let h=o.createElementNS(mt,"rect");h.setAttribute("class","live-hit"),h.setAttribute("x",String(d.x)),h.setAttribute("y",String(d.y)),h.setAttribute("width",String(d.w)),h.setAttribute("height",String(d.h)),h.append(p),i(h)}if((u.beside??[]).forEach((p,h)=>c(d.x+18*(h+1)/l,d.y,p.glyph,p.title)),u.dot&&c(d.x,d.y+d.h,u.dot.glyph,u.dot.title),u.tag){let p=o.createElementNS(mt,"text");p.setAttribute("class",`live-life ${u.tag.cls}`),p.setAttribute("x",String(d.x+d.w)),p.setAttribute("y",String(d.y+d.h)),p.style.fontSize=`${(9/l).toFixed(2)}px`,p.textContent=u.tag.text,i(p)}}}}function s(o,i,a){for(let l of a){let c=o.createElementNS(mt,"g");c.setAttribute("class",`live-extra${l.cls}`);for(let[M,$]of l.data)c.setAttribute(M,$);let{x:f,y:u,w:d,hgt:p,k:h}=l.rect,m=o.createElementNS(mt,"rect");m.setAttribute("x",String(f)),m.setAttribute("y",String(u)),m.setAttribute("width",String(d)),m.setAttribute("height",String(p)),m.setAttribute("rx",String(6/h));let y=o.createElementNS(mt,"text");y.setAttribute("x",String(f+8/h)),y.setAttribute("y",String(u+13/h)),y.style.fontSize=`${(11/h).toFixed(2)}px`,y.textContent=l.line1;let I=o.createElementNS(mt,"text");I.setAttribute("class","sub"),I.setAttribute("x",String(f+8/h)),I.setAttribute("y",String(u+27/h)),I.style.fontSize=`${(9/h).toFixed(2)}px`,I.textContent=l.line2;let N=o.createElementNS(mt,"title");N.textContent=l.title,c.append(m,y,I,N),i(c)}}function r(o,i,a){let l=[];for(let c of a){let f=c.over,u=(f.x0+f.x1)/2,d=(f.y0+f.y1)/2,p=0,h={x0:0,y0:0,x1:0,y1:0};for(let B=0;B<6;B++){let K=f.z1+dt.above+p,q=K+dt.h,Z=[ze(u-dt.half,d+dt.t,K),ze(u+dt.half,d+dt.t,K),ze(u+dt.half,d-dt.t,q),ze(u-dt.half,d+dt.t,q)];if(h={x0:Math.min(...Z.map(A=>A[0])),y0:Math.min(...Z.map(A=>A[1])),x1:Math.max(...Z.map(A=>A[0])),y1:Math.max(...Z.map(A=>A[1]))},!Yo(h,l))break;p+=dt.lift}l.push(h);let m=f.z1+dt.above+p,y=m+dt.h,I=u-dt.half,N=u+dt.half,M=d+dt.t,$=d-dt.t,R=o.createElementNS(mt,"g");R.setAttribute("class",`${e}-card${c.cls}`);for(let[B,K]of c.data)R.setAttribute(B,K);let[E,w]=ze(u,d,f.z1+.15),T=`${E.toFixed(1)}px ${w.toFixed(1)}px`;R.style.transformOrigin=T;let L=o.createElementNS(mt,"g");L.setAttribute("class",`${e}-float`),L.style.transformOrigin=T;let x=[];for(let B=Math.min(c.count-1,3);B>=1;B--){let K=B*dt.fan,q=$-(B-1)*(2*dt.t+dt.gap)-dt.gap,Z=q-2*dt.t,A=I+K,D=N+K,V=m+K,W=y+K,ie=(de,X)=>{let te=o.createElementNS(mt,"polygon");te.setAttribute("class",`${e}-face stacked ${de}`),te.setAttribute("points",br(X)),L.append(te)};ie("s-top",[ze(A,Z,W),ze(D,Z,W),ze(D,q,W),ze(A,q,W)]),ie("s-side",[ze(D,Z,V),ze(D,q,V),ze(D,q,W),ze(D,Z,W)]),ie("s-front",[ze(A,q,V),ze(D,q,V),ze(D,q,W),ze(A,q,W)]),x.push({x0:A,x1:D,y0:Z,y1:q,z0:V,z1:W})}let P=o.createElementNS(mt,"polygon");P.setAttribute("class",`${e}-tail`),P.setAttribute("points",br([ze(u-.5,M,m+.05),ze(u+.5,M,m+.05),ze(u,d,f.z1+.15)]));let b=(B,K)=>{let q=o.createElementNS(mt,"polygon");return q.setAttribute("class",B),q.setAttribute("points",br(K)),q},v=b(`${e}-face front`,[ze(I,M,m),ze(N,M,m),ze(N,M,y),ze(I,M,y)]);L.append(P,b(`${e}-face top`,[ze(I,$,y),ze(N,$,y),ze(N,M,y),ze(I,M,y)]),b(`${e}-face side`,[ze(N,$,m),ze(N,M,m),ze(N,M,y),ze(N,$,y)]),v);let[g,O]=ze(I,M,y),F=40,j=o.createElementNS(mt,"g");j.setAttribute("transform",`matrix(${(yt*Xe/F).toFixed(4)} ${(.5*Xe/F).toFixed(4)} 0 ${(Xe/F).toFixed(4)} ${g.toFixed(1)} ${O.toFixed(1)})`);let U=(B,K,q,Z)=>{let A=o.createElementNS(mt,"text");return A.setAttribute("class",B),A.setAttribute("x",String(K)),A.setAttribute("y",String(q)),A.textContent=Z,A};if(j.append(U(`${e}-mark`,34,98,c.mark),U(`${e}-who`,70,52,c.who),U(`${e}-age`,70,82,c.age)),c.line!==void 0&&j.append(U(`${e}-q`,12,118,c.line)),c.count>1){let B=o.createElementNS(mt,"circle");B.setAttribute("class",`${e}-count-bg`),B.setAttribute("cx","178"),B.setAttribute("cy","14"),B.setAttribute("r","15"),j.append(B,U(`${e}-count`,178,14,String(c.count)))}L.append(j);let ne=o.createElementNS(mt,"title");ne.textContent=c.title,R.append(L,ne),t.onCard?.(R,{cx:u,cy:d,tipZ:f.z1+.15,card:{x0:I,x1:N,y0:$,y1:M,z0:m,z1:y},panes:x.reverse()}),i(R)}}return{paintMarks:n,paintGhosts:s,paintCards:r}}var Rc=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],Oc=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function Ru(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n),e=Math.imul(e,16777619);return(e>>>0)%1e3/1e3}var Ea=t=>t<0?0:t>1?1:1-Math.pow(1-t,3),Pc=t=>t<0?0:t>1?1:t*t*t,Ta=Math.PI*2,Aa={appear:{scale:420,spin:760,dissolve:520,inflate:640},disappear:{scale:320,spin:600,dissolve:420,inflate:420},period:{jiggle:4200,pirouette:6400,glow:3200,breathe:4400}},en={windup:220,turn:980,land:260};function Cc(t,e,{prefix:n,key:s,alt:r}){let o={...e},i=1,a=new Map,l=new WeakSet,c=0,f=0,u=new WeakMap,d=new WeakMap;function p(P){c=0;for(let[b,v]of a){if(!b.isConnected){a.delete(b);continue}let g;if(v.repeat){if(g=(P+(v.offset??0))%v.repeat/v.dur,g>1){l.has(b)&&(t.restore(b),l.delete(b),b.style.removeProperty("transform"));continue}}else if(g=(P-v.start)/v.dur,g>=1){h(b,v);continue}let O=v.frame(Math.max(0,g));t.spin(b,O.theta,O.lift),l.add(b),d.set(b,O),O.scale!==1?b.style.transform=`scale(${O.scale.toFixed(4)})`:b.style.removeProperty("transform"),f++}a.size&&(c=requestAnimationFrame(p))}function h(P,b){a.delete(P),l.has(P)&&(t.restore(P),l.delete(P)),P.style.removeProperty("transform"),b.done?.()}function m(P){let b=a.get(P.card);b&&h(P.card,b),a.set(P.card,P),c||(c=requestAnimationFrame(p))}let y=8,I=0,N=P=>(I++,P.finally(()=>{I--}));function M(P){return!o.enabled||I>=y?Promise.resolve():N(R(P))}function $(P){return!o.enabled||I>=y?Promise.resolve():N(E(P))}function R(P){let b=Aa.appear[o.appear]/i;if(o.appear==="spin")return new Promise(O=>m({card:P,start:performance.now(),dur:b,frame:F=>({theta:(1-Ea(F))*Ta,lift:0,scale:Math.max(.001,Ea(F))}),done:O}));let v=o.appear==="scale"?[{transform:"scale(0)"},{transform:"scale(1)"}]:o.appear==="dissolve"?[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"blur(0px)"}]:[{transform:"scale(0)",easing:"cubic-bezier(.3,0,.4,1)"},{transform:"scale(1.16)",offset:.55,easing:"ease-in-out"},{transform:"scale(.95)",offset:.78,easing:"ease-in-out"},{transform:"scale(1)"}];return P.animate(v,{duration:b,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function E(P){let b=Aa.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(O=>m({card:P,start:performance.now(),dur:b,frame:F=>({theta:Pc(F)*Ta,lift:0,scale:Math.max(.001,1-Pc(F))}),done:()=>{P.style.transform="scale(0)",O()}}));let v=o.appear==="scale"?[{transform:"scale(1)"},{transform:"scale(0)"}]:o.appear==="dissolve"?[{opacity:1,filter:"blur(0px)"},{opacity:0,filter:"blur(4px)"}]:[{transform:"scale(1)"},{transform:"scale(1.08)",offset:.3},{transform:"scale(0)"}];return P.animate(v,{duration:b,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function w(P){u.get(P)?.cancel(),u.delete(P);let b=a.get(P);b?.repeat&&h(P,b)}function T(P,b){if(w(P),!o.enabled||o.idle==="none"||P.classList.contains("still"))return;let v=P.getAttribute(s)??P.getAttribute(r)??"",g=(b??Aa.period[o.idle])/i,O=Ru(v)*g;if(o.idle==="pirouette"){let B=(en.windup+en.turn+en.land)/i,K=en.windup/(en.windup+en.turn+en.land),q=(en.windup+en.turn)/(en.windup+en.turn+en.land);m({card:P,start:0,dur:B,repeat:g,offset:O,frame:Z=>{if(Z<K)return{theta:-.35*Math.sin(Z/K*Math.PI/2),lift:0,scale:1};if(Z<q){let D=(Z-K)/(q-K);return{theta:-.35*(1-D)+Ea(D)*Ta,lift:.9*Math.sin(D*Math.PI),scale:1}}let A=(Z-q)/(1-q);return{theta:0,lift:0,scale:1-.04*Math.sin(A*Math.PI)}}});return}let F=P.querySelector(`.${n}-float`)??P,j=t.amber(),U=o.idle==="jiggle"?[{transform:"scale(1)",offset:0},{transform:"scale(1.07)",offset:.04},{transform:"scale(.97)",offset:.08},{transform:"scale(1.02)",offset:.11},{transform:"scale(1)",offset:.14},{transform:"scale(1)",offset:1}]:o.idle==="glow"?[{filter:`drop-shadow(0 0 0px ${j})`},{filter:`drop-shadow(0 0 7px ${j})`},{filter:`drop-shadow(0 0 0px ${j})`}]:[{transform:"scale(1)"},{transform:"scale(1.035)"},{transform:"scale(1)"}],ne=F.animate(U,{duration:g,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});ne.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+O)%g,u.set(P,ne)}function L(P,b,v,g,O=!1){O&&(g=!1);for(let[j,U]of b)!P.has(j)&&!O&&M(U),!u.has(U)&&!a.get(U)?.repeat&&T(U);if(!o.enabled||!g)return;let F=t.leavingLayer();if(F)for(let[j,U]of v){let ne=P.get(j);!ne||b.has(j)||(w(ne),ne.setAttribute("class",`${n}-leaving${U?" expired":""}`),ne.removeAttribute(r),F.append(ne),$(ne).then(()=>ne.remove()))}}function x(P){for(let[b,v]of[...a])h(b,v);c&&cancelAnimationFrame(c),c=0;for(let b of document.getAnimations())b.effect?.target?.closest?.(`.live-layer, .${n}-leaving-layer`)&&b.cancel();t.leavingLayer()?.replaceChildren()}return{get settings(){return{...o}},set(P,b){let v=o;if(o={...o,...P},(!o.enabled||v.idle!==o.idle||v.enabled!==o.enabled)&&(x(void 0),o.enabled))for(let g of b)T(g)},update:L,appear:M,disappear:$,startIdle:T,stopIdle:w,stopAll:x,async preview(P){o.enabled&&await Promise.all(P.map(async b=>{if(w(b),await M(b),o.idle!=="none"&&!b.classList.contains("still")){let v=o.idle==="pirouette"?1800:1400;T(b,v),await new Promise(g=>setTimeout(g,v*2.2/i)),w(b)}else await new Promise(v=>setTimeout(v,700/i));await $(b);for(let v of b.getAnimations())v.cancel();b.style.removeProperty("transform"),T(b)}))},get stats(){return{jobs:a.size,raf:!!c,frames:f,effects:I}},setSpeed(P){i=P},lastFrame:P=>d.get(P)}}var Na=t=>String(Math.round(t*100)/100),Lc=(t,e={},...n)=>({name:t,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?Na(r):r]),children:n});function Pa(t,e){if(typeof t=="string")return t;let n=t.attrs.map(([s,r])=>{if(s==="id")return[s,e+r];let o=r.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1").replace(/url\(\s*(['"]?)#/g,(i,a)=>`url(${a}#${e}`);return(s==="href"||s==="xlink:href")&&o.startsWith("#")&&!o.startsWith(`#${e}`)&&(o=`#${e}${o.slice(1)}`),[s,o]});return{name:t.name,attrs:n,children:t.children.map(s=>Pa(s,e))}}function Ra(t,e){if(typeof t=="string")return t;if(!e(t))return{...t,children:t.children.map(n=>Ra(n,e)).filter(n=>n!==void 0)}}var Ic=t=>(t.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),mn=(t,e)=>t.attrs.find(n=>n[0]===e)?.[1];function Qo(t){let e=[],n=[],s=i=>{if(typeof i=="string")return;let a=mn(i,"transform");if(a&&/matrix/.test(a))return;let l=mn(i,"points");if(l)for(let c of l.trim().split(/\s+/)){let[f,u]=c.split(",").map(Number);Number.isFinite(f)&&Number.isFinite(u)&&(e.push(f),n.push(u))}if(i.name==="rect"){let c=Number(mn(i,"x")),f=Number(mn(i,"y")),u=Number(mn(i,"width")),d=Number(mn(i,"height"));[c,f,u,d].every(Number.isFinite)&&(e.push(c,c+u),n.push(f,f+d))}if(i.name==="circle"){let c=Number(mn(i,"cx")),f=Number(mn(i,"cy")),u=Number(mn(i,"r"));[c,f,u].every(Number.isFinite)&&(e.push(c-u,c+u),n.push(f-u,f+u))}i.children.forEach(s)};if(t.forEach(s),!e.length)return;let r=Math.min(...e),o=Math.min(...n);return{x:r,y:o,w:Math.max(...e)-r,h:Math.max(...n)-o}}var Zo=(t,e)=>{if(!e)return t;let n=Math.min(t.x,e.x),s=Math.min(t.y,e.y);return{x:n,y:s,w:Math.max(t.x+t.w,e.x+e.w)-n,h:Math.max(t.y+t.h,e.y+e.h)-s}};function Fc(t,e,n){let s=a=>Math.min((e.width-e.pad*2)/a.w,(e.height-e.pad*2)/a.h),r=s(t),o=n(r),i=Zo(t,Qo(o));return r=s(i),o=n(r),i=Zo(t,Qo(o)),r=s(i),{k:r,box:i,live:o}}var Bc=t=>t.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Ou(t){let e=[],n=0,s=t.replace(/\/\*[\s\S]*?\*\//g,"");for(;n<s.length;){let r=s.indexOf("{",n);if(r<0)break;let o=1,i=r+1;for(;i<s.length&&o;)s[i]==="{"?o++:s[i]==="}"&&o--,i++;e.push([s.slice(n,r).trim(),s.slice(r+1,i-1)]),n=i}return e}function Cu(t){let e=[],n=0,s=0;for(let r=0;r<t.length;r++){let o=t[r];o==="("||o==="["?n++:o===")"||o==="]"?n--:o===","&&!n&&(e.push(t.slice(s,r).trim()),s=r+1)}return e.push(t.slice(s).trim()),e.filter(Boolean)}function Oa(t,e,n){let s=/^:root((?:\[[^\]]*\]|:not\([^)]*\))*)(.*)$/.exec(t),r=n.replace(/^\./,"");if(s){let o=s[1],i=s[2].trim();return`${o?`.${r}${o} `:""}${e}${i?" "+i:""}`}if(/^(html|body|\*)\b/.test(t)||/^[a-z]+$/.test(t)&&!/^(svg|g|text|path|polygon|rect|circle|line)$/.test(t))throw new Error(`the canvas's CSS can't style the page: "${t}"`);return`${e} ${t}`}function Ca(t,e,n){let s="";for(let[r,o]of Ou(t)){if(r.startsWith("@keyframes")){s+=`@keyframes iso-${r.slice(10).trim()}{${o}}
|
|
283
|
-
`;continue}if(r.startsWith("@media")||r.startsWith("@supports")){s+=`${r}{${
|
|
284
|
-
`;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${
|
|
285
|
-
`}return s}var
|
|
286
|
-
<button class="pbtn small" type="button" data-a="grid" aria-pressed="${
|
|
291
|
+
`;function Pl(n){return{name:"card",description:"A card: a slab with its name on its front face",size:[ms.W,ms.D,ms.H],role:"grey",draw(e,t,s){let r=n(s.id),o=e.blockFaces(t);if(!r)return o;let i=t.z1-t.z0;return o+=e.faceText(t.x0+.2,t.y1,t.z0+(r.sub?i*.52:i*.34),r.label,"card-name",lt.lbl,"left","start"),r.sub&&(o+=e.faceText(t.x0+.2,t.y1,t.z0+i*.14,r.sub,"card-sub",lt.sub,"left","start")),o}}}function fu(n){let e=new Map(n.cards.map(t=>[t.id,{label:t.label,sub:t.sub}]));return{regions:{panel:{shape:"slab",pad:ms.PAD,z:[ms.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:Pl(t=>e.get(t))},defaultNode:"card"}}function uu(n,e={}){let t=ms,{prect:s,parentIx:r,cardAt:o}=to(n,{W:t.W,H:t.D,GX:t.GX,GY:t.GY,PAD:t.PAD,TITLE:0,CH:t.CH}),i=n.panels??[],a=g=>Math.round(g*1e3)/1e3,l=g=>(g.cells[2]-g.cells[0]+1)*(g.cells[3]-g.cells[1]+1),c=g=>{let m=-1;return i.forEach((y,N)=>{let h=y.cells;g.cell[0]>=h[0]&&g.cell[0]<=h[2]&&g.cell[1]>=h[1]&&g.cell[1]<=h[3]&&(m<0||l(y)<=l(i[m]))&&(m=N)}),m},f=i.map((g,m)=>{let y=s[m],N=r[m]>=0?s[r[m]]:{l:0,t:0};return{id:g.id,kind:"panel",label:g.label,role:g.role,at:[a(y.l-N.l),a(y.t-N.t)],size:[a(y.r-y.l),a(y.b-y.t)],regions:[],nodes:[]}}),u=[],d=[];f.forEach((g,m)=>r[m]>=0?f[r[m]].regions.push(g):u.push(g));for(let g of n.cards){let[m,y]=o(n.cards.indexOf(g)),N=c(g),h=N>=0?s[N]:{l:0,t:0},b={id:g.id,asset:"card",role:g.role,ghost:g.ghost||void 0,at:[a(m-h.l),a(y-h.t)],size:[t.W,t.D,t.H]};(N>=0?f[N].nodes:d).push(b)}for(let g of f)g.regions.length||delete g.regions,g.nodes.length||delete g.nodes;let p=(n.links??[]).map((g,m)=>({id:g.id??`link-${m}`,from:g.aOn??g.a,to:g.bOn??g.b,kind:g.kind,label:g.label}));return{isodiag:1,title:e.title,kinds:e.kinds,roles:e.roles,scenes:[{id:"board",title:e.title??"board",regions:u,nodes:d,routes:p}]}}var Qu={};la(Qu,{APPEARS:()=>gu,BASE_FIELDS:()=>ql,BINS:()=>Mu,BIN_MS:()=>mn,CARD:()=>mt,DUAL_VIEW_CSS:()=>Xu,IDLES:()=>bu,MAX_ZOOM:()=>Vi,MIN_ZOOM:()=>zi,P3:()=>He,SEGMENT_NAME:()=>qi,SEVERITIES:()=>Ht,TIMELINE_VERSION:()=>$u,activityOf:()=>Xl,attr:()=>Nn,binNext:()=>Xi,binStart:()=>As,buildLayer:()=>ao,cardMotion:()=>yu,clamp:()=>es,cls:()=>wu,crumbs:()=>ur,dualView:()=>Hu,ease:()=>io,escapeName:()=>Hi,extent:()=>Ki,findGaps:()=>Qi,fitWithOverlay:()=>ku,flatCss:()=>Ku,flatSvg:()=>ra,formatScope:()=>Eu,gapKey:()=>Ns,gapLabel:()=>Os,h:()=>me,hasSegment:()=>Ou,highlights:()=>ro,isZone:()=>Pu,isoVars:()=>Su,join:()=>Tu,kindOf:()=>cr,legend:()=>Gl,levelOf:()=>Ct,markConnectors:()=>aa,md:()=>Gn,measureIn:()=>oa,memorySource:()=>Bu,modeFor:()=>Jl,morphSvgs:()=>Yu,mountTimeline:()=>zu,n:()=>Fl,nameOf:()=>fr,node:()=>xu,offsetAt:()=>jt,overlayPaint:()=>pu,parentOf:()=>Au,prefixAt:()=>Zn,prune:()=>jl,pts:()=>no,rangeOf:()=>so,readTime:()=>Ul,rectOf:()=>Gu,renderPage:()=>vu,rewrite:()=>Bl,scope:()=>_l,scopePattern:()=>Ui,scopeRules:()=>Yi,scopeSelector:()=>Dl,searchFor:()=>dr,severities:()=>Nu,stepData:()=>Kl,storedMode:()=>Wu,ticks:()=>Zi,timeScale:()=>mr,toCSV:()=>ta,toJSON:()=>ea,unite:()=>Gi,viewToggle:()=>Ju,viewport:()=>mu,within:()=>Wt});function Vm(n,e,t){let r=(a,l,c,f,u)=>Math.min((a-48)/(c-l),...f===void 0||u===void 0?[]:[[u-f,12],[u-l,30],[c-f,30]].map(([d,p])=>d>0?(a-p)/d:1/0)),o=Math.min(Vi,Math.max(zi,Math.min(r(n.w,e.x,e.x+e.w,t?.x,t&&t.x+t.w),r(n.h,e.y,e.y+e.h,t?.y,t&&t.y+t.h)))),i=(a,l,c,f,u)=>{let d=(l+c)/2;if(f===void 0||u===void 0)return d;let p=u-(a/2-6)/o,g=f+(a/2-6)/o;return p>g?(p+g)/2:Math.max(p,Math.min(g,d))};return{k:o,cx:i(n.w,e.x,e.x+e.w,t?.x,t&&t.x+t.w),cy:i(n.h,e.y,e.y+e.h,t?.y,t&&t.y+t.h)}}var zi=.1,Vi=8;function mu(n,e){let t,s,r=!1,o=0,i=0,a=0,l=0,c=0,f=!1,u=()=>{let v=n.getBoundingClientRect();return{w:Math.max(1,v.width),h:Math.max(1,v.height)}},d=(v=t)=>{let O=u();return Math.min(O.w/v.w,O.h/v.h)},p=v=>{o++;try{v()}finally{o--}};function g(){let v=e.svg();if(!v||!t)return;o||(r=!0);let O=u(),C=d(),$=O.w/C,P=O.h/C;t={x:t.x+(t.w-$)/2,y:t.y+(t.h-P)/2,w:$,h:P},v.setAttribute("viewBox",`${t.x.toFixed(2)} ${t.y.toFixed(2)} ${t.w.toFixed(2)} ${t.h.toFixed(2)}`),i=C,e.onApply(C),a&&Math.abs(C/a-1)>.02&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,e.onRezoom()}))}let m=(v,O)=>{let C=n.getBoundingClientRect(),$=d();return{x:t.x+(v-C.left)/$,y:t.y+(O-C.top)/$}};function y(v,O,C){if(!t)return;let $=d(),P=Math.min(Vi,Math.max(zi,$*v)),k=n.getBoundingClientRect(),E=O??k.left+k.width/2,S=C??k.top+k.height/2,F=m(E,S),D=u();t={x:F.x-(E-k.left)/P,y:F.y-(S-k.top)/P,w:D.w/P,h:D.h/P},g()}function N(v=s,O){if(!v)return;let C=u(),{k:$,cx:P,cy:k}=Vm(C,v,O),E={x:P-C.w/$/2,y:k-C.h/$/2,w:C.w/$,h:C.h/$};if(t&&Math.abs(E.w/t.w-1)<.001&&Math.abs(E.h/t.h-1)<.001&&Math.abs(E.x-t.x)<E.w*.001&&Math.abs(E.y-t.y)<E.h*.001){g();return}t=E,g()}function h(){for(let v=0,O="";v<4;v++){let C=e.itemsBox()??s;if(!C)return;let $=[C.x,C.y,C.w,C.h].map(k=>Math.round(k)).join();if($===O)break;O=$;let P=Math.max(24,Math.min(C.w,C.h)*.06);if(p(()=>N({x:C.x-P,y:C.y-P,w:C.w+P*2,h:C.h+P*2},e.alsoBox?.())),!e.marksShowing()||!a||Math.abs(d()/a-1)<=.02)break;cancelAnimationFrame(l),l=0,e.onRezoom()}r=!1}function b(){if(r||!e.svg()||!t)return;let v=n.getBoundingClientRect();v.width<2||v.height<2||h()}function x(){if(!t)return;let v=d();y(1/v)}function A(){return new Promise(v=>{let O=0,C=i,$=()=>{if(f){v();return}let P=!!(l||c)||i!==C;C=i,O=P?0:O+1,O>=2?v():requestAnimationFrame($)};requestAnimationFrame($)})}let M=new ResizeObserver(()=>{if(!(!t||f)){if(r&&i){let v=u(),O=t.x+t.w/2,C=t.y+t.h/2;t={x:O-v.w/i/2,y:C-v.h/i/2,w:v.w/i,h:v.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,f||b()})),p(g)}});return M.observe(n),{get view(){return t},set view(v){t=v},get full(){return s},set full(v){s=v},get moved(){return r},get zoom(){return i},painted(v){a=v},size:u,scale:d,quietly:p,applyView:g,toSvg:m,zoomAt:y,fit:N,fitItems:h,autoFit:b,actual:x,settled:A,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(l),M.disconnect(),f=!0}}}var gt="http://www.w3.org/2000/svg",mt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},He=(n,e,t)=>[(n-e)*wt*nt,(n+e)*.5*nt-t*nt],no=n=>n.map(([e,t])=>`${e.toFixed(1)},${t.toFixed(1)}`).join(" ");function pu(n,e){function t(o,i,a){let l=n.k(),c=(u,d,p,g,m="")=>{let y=o.createElementNS(gt,"g");y.setAttribute("class",`live-badge ${p.cls} ${m}`.trim());let N=8/l,h=o.createElementNS(gt,"circle");if(h.setAttribute("cx",String(u)),h.setAttribute("cy",String(d)),h.setAttribute("r",String(N)),y.append(h),"g"in p){let x=o.createElementNS(gt,"text");x.setAttribute("x",String(u)),x.setAttribute("y",String(d)),x.style.fontSize=`${(10/l).toFixed(2)}px`,x.textContent=p.g,y.append(x)}else{let x=o.createElementNS(gt,"use");x.setAttribute("href",n.iconHref(p.icon));let A=11/l;x.setAttribute("x",String(u-A/2)),x.setAttribute("y",String(d-A/2)),x.setAttribute("width",String(A)),x.setAttribute("height",String(A)),y.append(x)}let b=o.createElementNS(gt,"title");b.textContent=g,y.append(b),i(y)},f=(u,d)=>{for(let p of n.outlinesFor(u)){if(p.kind!=="poly")continue;let g=o.createElementNS(gt,"polygon");g.setAttribute("class",d),g.setAttribute("points",p.points.map(([m,y])=>`${m.toFixed(1)},${y.toFixed(1)}`).join(" ")),i(g)}};for(let u of a){let d=n.boxOf(u.at);if(d){if(u.outline&&f(u.at,u.outline),u.badge)c(d.x,d.y,u.badge,u.title);else if(u.hit){let p=o.createElementNS(gt,"title");p.textContent=u.title;let g=o.createElementNS(gt,"rect");g.setAttribute("class","live-hit"),g.setAttribute("x",String(d.x)),g.setAttribute("y",String(d.y)),g.setAttribute("width",String(d.w)),g.setAttribute("height",String(d.h)),g.append(p),i(g)}if((u.beside??[]).forEach((p,g)=>c(d.x+18*(g+1)/l,d.y,p.glyph,p.title)),u.dot&&c(d.x,d.y+d.h,u.dot.glyph,u.dot.title),u.tag){let p=o.createElementNS(gt,"text");p.setAttribute("class",`live-life ${u.tag.cls}`),p.setAttribute("x",String(d.x+d.w)),p.setAttribute("y",String(d.y+d.h)),p.style.fontSize=`${(9/l).toFixed(2)}px`,p.textContent=u.tag.text,i(p)}}}}function s(o,i,a){for(let l of a){let c=o.createElementNS(gt,"g");c.setAttribute("class",`live-extra${l.cls}`);for(let[b,x]of l.data)c.setAttribute(b,x);let{x:f,y:u,w:d,hgt:p,k:g}=l.rect,m=o.createElementNS(gt,"rect");m.setAttribute("x",String(f)),m.setAttribute("y",String(u)),m.setAttribute("width",String(d)),m.setAttribute("height",String(p)),m.setAttribute("rx",String(6/g));let y=o.createElementNS(gt,"text");y.setAttribute("x",String(f+8/g)),y.setAttribute("y",String(u+13/g)),y.style.fontSize=`${(11/g).toFixed(2)}px`,y.textContent=l.line1;let N=o.createElementNS(gt,"text");N.setAttribute("class","sub"),N.setAttribute("x",String(f+8/g)),N.setAttribute("y",String(u+27/g)),N.style.fontSize=`${(9/g).toFixed(2)}px`,N.textContent=l.line2;let h=o.createElementNS(gt,"title");h.textContent=l.title,c.append(m,y,N,h),i(c)}}function r(o,i,a){let l=[];for(let c of a){let f=c.over,u=(f.x0+f.x1)/2,d=(f.y0+f.y1)/2,p=0,g={x0:0,y0:0,x1:0,y1:0};for(let L=0;L<6;L++){let q=f.z1+mt.above+p,U=q+mt.h,Z=[He(u-mt.half,d+mt.t,q),He(u+mt.half,d+mt.t,q),He(u+mt.half,d-mt.t,U),He(u-mt.half,d+mt.t,U)];if(g={x0:Math.min(...Z.map(I=>I[0])),y0:Math.min(...Z.map(I=>I[1])),x1:Math.max(...Z.map(I=>I[0])),y1:Math.max(...Z.map(I=>I[1]))},!ji(g,l))break;p+=mt.lift}l.push(g);let m=f.z1+mt.above+p,y=m+mt.h,N=u-mt.half,h=u+mt.half,b=d+mt.t,x=d-mt.t,A=o.createElementNS(gt,"g");A.setAttribute("class",`${e}-card${c.cls}`);for(let[L,q]of c.data)A.setAttribute(L,q);let[M,v]=He(u,d,f.z1+.15),O=`${M.toFixed(1)}px ${v.toFixed(1)}px`;A.style.transformOrigin=O;let C=o.createElementNS(gt,"g");C.setAttribute("class",`${e}-float`),C.style.transformOrigin=O;let $=[];for(let L=Math.min(c.count-1,3);L>=1;L--){let q=L*mt.fan,U=x-(L-1)*(2*mt.t+mt.gap)-mt.gap,Z=U-2*mt.t,I=N+q,_=h+q,K=m+q,J=y+q,de=(ce,W)=>{let ne=o.createElementNS(gt,"polygon");ne.setAttribute("class",`${e}-face stacked ${ce}`),ne.setAttribute("points",no(W)),C.append(ne)};de("s-top",[He(I,Z,J),He(_,Z,J),He(_,U,J),He(I,U,J)]),de("s-side",[He(_,Z,K),He(_,U,K),He(_,U,J),He(_,Z,J)]),de("s-front",[He(I,U,K),He(_,U,K),He(_,U,J),He(I,U,J)]),$.push({x0:I,x1:_,y0:Z,y1:U,z0:K,z1:J})}let P=o.createElementNS(gt,"polygon");P.setAttribute("class",`${e}-tail`),P.setAttribute("points",no([He(u-.5,b,m+.05),He(u+.5,b,m+.05),He(u,d,f.z1+.15)]));let k=(L,q)=>{let U=o.createElementNS(gt,"polygon");return U.setAttribute("class",L),U.setAttribute("points",no(q)),U},E=k(`${e}-face front`,[He(N,b,m),He(h,b,m),He(h,b,y),He(N,b,y)]);C.append(P,k(`${e}-face top`,[He(N,x,y),He(h,x,y),He(h,b,y),He(N,b,y)]),k(`${e}-face side`,[He(h,x,m),He(h,b,m),He(h,b,y),He(h,x,y)]),E);let[S,F]=He(N,b,y),D=40,H=o.createElementNS(gt,"g");H.setAttribute("transform",`matrix(${(wt*nt/D).toFixed(4)} ${(.5*nt/D).toFixed(4)} 0 ${(nt/D).toFixed(4)} ${S.toFixed(1)} ${F.toFixed(1)})`);let X=(L,q,U,Z)=>{let I=o.createElementNS(gt,"text");return I.setAttribute("class",L),I.setAttribute("x",String(q)),I.setAttribute("y",String(U)),I.textContent=Z,I};if(H.append(X(`${e}-mark`,34,98,c.mark),X(`${e}-who`,70,52,c.who),X(`${e}-age`,70,82,c.age)),c.line!==void 0&&H.append(X(`${e}-q`,12,118,c.line)),c.count>1){let L=o.createElementNS(gt,"circle");L.setAttribute("class",`${e}-count-bg`),L.setAttribute("cx","178"),L.setAttribute("cy","14"),L.setAttribute("r","15"),H.append(L,X(`${e}-count`,178,14,String(c.count)))}C.append(H);let Y=o.createElementNS(gt,"title");Y.textContent=c.title,A.append(C,Y),n.onCard?.(A,{cx:u,cy:d,tipZ:f.z1+.15,card:{x0:N,x1:h,y0:x,y1:b,z0:m,z1:y},panes:$.reverse()}),i(A)}}return{paintMarks:t,paintGhosts:s,paintCards:r}}var gu=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],bu=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function Km(n){let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return(e>>>0)%1e3/1e3}var Cl=n=>n<0?0:n>1?1:1-Math.pow(1-n,3),hu=n=>n<0?0:n>1?1:n*n*n,Il=Math.PI*2,Ll={appear:{scale:420,spin:760,dissolve:520,inflate:640},disappear:{scale:320,spin:600,dissolve:420,inflate:420},period:{jiggle:4200,pirouette:6400,glow:3200,breathe:4400}},dn={windup:220,turn:980,land:260};function yu(n,e,{prefix:t,key:s,alt:r}){let o={...e},i=1,a=new Map,l=new WeakSet,c=0,f=0,u=new WeakMap,d=new WeakMap;function p(P){c=0;for(let[k,E]of a){if(!k.isConnected){a.delete(k);continue}let S;if(E.repeat){if(S=(P+(E.offset??0))%E.repeat/E.dur,S>1){l.has(k)&&(n.restore(k),l.delete(k),k.style.removeProperty("transform"));continue}}else if(S=(P-E.start)/E.dur,S>=1){g(k,E);continue}let F=E.frame(Math.max(0,S));n.spin(k,F.theta,F.lift),l.add(k),d.set(k,F),F.scale!==1?k.style.transform=`scale(${F.scale.toFixed(4)})`:k.style.removeProperty("transform"),f++}a.size&&(c=requestAnimationFrame(p))}function g(P,k){a.delete(P),l.has(P)&&(n.restore(P),l.delete(P)),P.style.removeProperty("transform"),k.done?.()}function m(P){let k=a.get(P.card);k&&g(P.card,k),a.set(P.card,P),c||(c=requestAnimationFrame(p))}let y=8,N=0,h=P=>(N++,P.finally(()=>{N--}));function b(P){return!o.enabled||N>=y?Promise.resolve():h(A(P))}function x(P){return!o.enabled||N>=y?Promise.resolve():h(M(P))}function A(P){let k=Ll.appear[o.appear]/i;if(o.appear==="spin")return new Promise(F=>m({card:P,start:performance.now(),dur:k,frame:D=>({theta:(1-Cl(D))*Il,lift:0,scale:Math.max(.001,Cl(D))}),done:F}));let E=o.appear==="scale"?[{transform:"scale(0)"},{transform:"scale(1)"}]:o.appear==="dissolve"?[{opacity:0,filter:"blur(4px)"},{opacity:1,filter:"blur(0px)"}]:[{transform:"scale(0)",easing:"cubic-bezier(.3,0,.4,1)"},{transform:"scale(1.16)",offset:.55,easing:"ease-in-out"},{transform:"scale(.95)",offset:.78,easing:"ease-in-out"},{transform:"scale(1)"}];return P.animate(E,{duration:k,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function M(P){let k=Ll.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(F=>m({card:P,start:performance.now(),dur:k,frame:D=>({theta:hu(D)*Il,lift:0,scale:Math.max(.001,1-hu(D))}),done:()=>{P.style.transform="scale(0)",F()}}));let E=o.appear==="scale"?[{transform:"scale(1)"},{transform:"scale(0)"}]:o.appear==="dissolve"?[{opacity:1,filter:"blur(0px)"},{opacity:0,filter:"blur(4px)"}]:[{transform:"scale(1)"},{transform:"scale(1.08)",offset:.3},{transform:"scale(0)"}];return P.animate(E,{duration:k,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function v(P){u.get(P)?.cancel(),u.delete(P);let k=a.get(P);k?.repeat&&g(P,k)}function O(P,k){if(v(P),!o.enabled||o.idle==="none"||P.classList.contains("still"))return;let E=P.getAttribute(s)??P.getAttribute(r)??"",S=(k??Ll.period[o.idle])/i,F=Km(E)*S;if(o.idle==="pirouette"){let L=(dn.windup+dn.turn+dn.land)/i,q=dn.windup/(dn.windup+dn.turn+dn.land),U=(dn.windup+dn.turn)/(dn.windup+dn.turn+dn.land);m({card:P,start:0,dur:L,repeat:S,offset:F,frame:Z=>{if(Z<q)return{theta:-.35*Math.sin(Z/q*Math.PI/2),lift:0,scale:1};if(Z<U){let _=(Z-q)/(U-q);return{theta:-.35*(1-_)+Cl(_)*Il,lift:.9*Math.sin(_*Math.PI),scale:1}}let I=(Z-U)/(1-U);return{theta:0,lift:0,scale:1-.04*Math.sin(I*Math.PI)}}});return}let D=P.querySelector(`.${t}-float`)??P,H=n.amber(),X=o.idle==="jiggle"?[{transform:"scale(1)",offset:0},{transform:"scale(1.07)",offset:.04},{transform:"scale(.97)",offset:.08},{transform:"scale(1.02)",offset:.11},{transform:"scale(1)",offset:.14},{transform:"scale(1)",offset:1}]:o.idle==="glow"?[{filter:`drop-shadow(0 0 0px ${H})`},{filter:`drop-shadow(0 0 7px ${H})`},{filter:`drop-shadow(0 0 0px ${H})`}]:[{transform:"scale(1)"},{transform:"scale(1.035)"},{transform:"scale(1)"}],Y=D.animate(X,{duration:S,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});Y.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+F)%S,u.set(P,Y)}function C(P,k,E,S,F=!1){F&&(S=!1);for(let[H,X]of k)!P.has(H)&&!F&&b(X),!u.has(X)&&!a.get(X)?.repeat&&O(X);if(!o.enabled||!S)return;let D=n.leavingLayer();if(D)for(let[H,X]of E){let Y=P.get(H);!Y||k.has(H)||(v(Y),Y.setAttribute("class",`${t}-leaving${X?" expired":""}`),Y.removeAttribute(r),D.append(Y),x(Y).then(()=>Y.remove()))}}function $(P){for(let[k,E]of[...a])g(k,E);c&&cancelAnimationFrame(c),c=0;for(let k of document.getAnimations())k.effect?.target?.closest?.(`.live-layer, .${t}-leaving-layer`)&&k.cancel();n.leavingLayer()?.replaceChildren()}return{get settings(){return{...o}},set(P,k){let E=o;if(o={...o,...P},(!o.enabled||E.idle!==o.idle||E.enabled!==o.enabled)&&($(void 0),o.enabled))for(let S of k)O(S)},update:C,appear:b,disappear:x,startIdle:O,stopIdle:v,stopAll:$,async preview(P){o.enabled&&await Promise.all(P.map(async k=>{if(v(k),await b(k),o.idle!=="none"&&!k.classList.contains("still")){let E=o.idle==="pirouette"?1800:1400;O(k,E),await new Promise(S=>setTimeout(S,E*2.2/i)),v(k)}else await new Promise(E=>setTimeout(E,700/i));await x(k);for(let E of k.getAnimations())E.cancel();k.style.removeProperty("transform"),O(k)}))},get stats(){return{jobs:a.size,raf:!!c,frames:f,effects:N}},setSpeed(P){i=P},lastFrame:P=>d.get(P)}}var Fl=n=>String(Math.round(n*100)/100),xu=(n,e={},...t)=>({name:n,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?Fl(r):r]),children:t});function Bl(n,e){if(typeof n=="string")return n;let t=n.attrs.map(([s,r])=>{if(s==="id")return[s,e+r];let o=r.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1").replace(/url\(\s*(['"]?)#/g,(i,a)=>`url(${a}#${e}`);return(s==="href"||s==="xlink:href")&&o.startsWith("#")&&!o.startsWith(`#${e}`)&&(o=`#${e}${o.slice(1)}`),[s,o]});return{name:n.name,attrs:t,children:n.children.map(s=>Bl(s,e))}}function jl(n,e){if(typeof n=="string")return n;if(!e(n))return{...n,children:n.children.map(t=>jl(t,e)).filter(t=>t!==void 0)}}var wu=n=>(n.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),Nn=(n,e)=>n.attrs.find(t=>t[0]===e)?.[1];function Ki(n){let e=[],t=[],s=i=>{if(typeof i=="string")return;let a=Nn(i,"transform");if(a&&/matrix/.test(a))return;let l=Nn(i,"points");if(l)for(let c of l.trim().split(/\s+/)){let[f,u]=c.split(",").map(Number);Number.isFinite(f)&&Number.isFinite(u)&&(e.push(f),t.push(u))}if(i.name==="rect"){let c=Number(Nn(i,"x")),f=Number(Nn(i,"y")),u=Number(Nn(i,"width")),d=Number(Nn(i,"height"));[c,f,u,d].every(Number.isFinite)&&(e.push(c,c+u),t.push(f,f+d))}if(i.name==="circle"){let c=Number(Nn(i,"cx")),f=Number(Nn(i,"cy")),u=Number(Nn(i,"r"));[c,f,u].every(Number.isFinite)&&(e.push(c-u,c+u),t.push(f-u,f+u))}i.children.forEach(s)};if(n.forEach(s),!e.length)return;let r=Math.min(...e),o=Math.min(...t);return{x:r,y:o,w:Math.max(...e)-r,h:Math.max(...t)-o}}var Gi=(n,e)=>{if(!e)return n;let t=Math.min(n.x,e.x),s=Math.min(n.y,e.y);return{x:t,y:s,w:Math.max(n.x+n.w,e.x+e.w)-t,h:Math.max(n.y+n.h,e.y+e.h)-s}};function ku(n,e,t){let s=a=>Math.min((e.width-e.pad*2)/a.w,(e.height-e.pad*2)/a.h),r=s(n),o=t(r),i=Gi(n,Ki(o));return r=s(i),o=t(r),i=Gi(n,Ki(o)),r=s(i),{k:r,box:i,live:o}}var Su=n=>n.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Gm(n){let e=[],t=0,s=n.replace(/\/\*[\s\S]*?\*\//g,"");for(;t<s.length;){let r=s.indexOf("{",t);if(r<0)break;let o=1,i=r+1;for(;i<s.length&&o;)s[i]==="{"?o++:s[i]==="}"&&o--,i++;e.push([s.slice(t,r).trim(),s.slice(r+1,i-1)]),t=i}return e}function qm(n){let e=[],t=0,s=0;for(let r=0;r<n.length;r++){let o=n[r];o==="("||o==="["?t++:o===")"||o==="]"?t--:o===","&&!t&&(e.push(n.slice(s,r).trim()),s=r+1)}return e.push(n.slice(s).trim()),e.filter(Boolean)}function Dl(n,e,t){let s=/^:root((?:\[[^\]]*\]|:not\([^)]*\))*)(.*)$/.exec(n),r=t.replace(/^\./,"");if(s){let o=s[1],i=s[2].trim();return`${o?`.${r}${o} `:""}${e}${i?" "+i:""}`}if(/^(html|body|\*)\b/.test(n)||/^[a-z]+$/.test(n)&&!/^(svg|g|text|path|polygon|rect|circle|line)$/.test(n))throw new Error(`the canvas's CSS can't style the page: "${n}"`);return`${e} ${n}`}function _l(n,e,t){let s="";for(let[r,o]of Gm(n)){if(r.startsWith("@keyframes")){s+=`@keyframes iso-${r.slice(10).trim()}{${o}}
|
|
292
|
+
`;continue}if(r.startsWith("@media")||r.startsWith("@supports")){s+=`${r}{${_l(o,e,t)}}
|
|
293
|
+
`;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${qm(r).map(i=>Dl(i,e,t)).join(",")}{${o.replace(/\banimation:\s*([a-z][\w-]*)/g,"animation:iso-$1")}}
|
|
294
|
+
`}return s}var zl=["<","script"].join("");function Gn(n){return n?dt(n).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>").replace(/(^|[^*])\*([^*\s][^*]*)\*/g,"$1<em>$2</em>").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(e,t,s)=>/^(https?:|#|\.{0,2}\/)/.test(s.replace(/&/g,"&"))?`<a href="${s}">${t}</a>`:t):""}var Vl=n=>(n??"").split(/\n\s*\n/).filter(Boolean).map(e=>`<p class="sec-sub">${Gn(e.trim())}</p>`).join("");function Kl(n){return JSON.stringify({scenes:n.scenes.map(e=>({id:e.id,loop:e.raw.loop??!0,dim:e.raw.dim??"flows",vis:e.steps.vis,steps:e.steps.steps.map(t=>({...t,caption:Gn(t.caption)})),assemble:e.assemble,grid:!!e.grid.show,motion:fs(e)}))})}function Gl(n,e){let t=n.theme,s=e.raw.legend;if(s===!1)return"";let r=Array.isArray(s)?s:e.steps.kindsUsed.filter(a=>e.routes.some(l=>l.kind===a)||e.steps.steps.some(l=>l.phases.some(c=>c.some(f=>f.kind===a)))),o=a=>`<span><i${a.box?' class="box"':""} style="${a.swatch}"></i>${a.label}</span>`,i=r.map(a=>{let l=pt(n.catalog,a)?.legend;if(l)return o(l);let c=t.kinds[a];return c?`<span><i style="${`border-color:${_n(t,c.color)}${c.dash==="dashed"?";border-top-style:dashed":c.dash==="dotted"?";border-top-style:dotted":""}`}"></i>${Gn(c.legend)}</span>`:""});if(!Array.isArray(s)){let a=new Set(e.layout.items.map(l=>l.region?.kind));for(let[l,c]of Object.entries(n.catalog.regions))c.legend?.auto&&a.has(l)&&i.push(o(c.legend))}return i.join("")}function Um(n){let e=n.steps.steps,t=`<div class="tools">
|
|
295
|
+
<button class="pbtn small" type="button" data-a="grid" aria-pressed="${n.grid.show?"true":"false"}" title="Show the floor grid">Grid</button>
|
|
287
296
|
<button class="pbtn small" type="button" data-a="assemble" title="Draw the diagram again, piece by piece">Assemble</button>
|
|
288
|
-
</div>`;if(!e.length)return`<div class="player">${
|
|
297
|
+
</div>`;if(!e.length)return`<div class="player">${t}</div>`;let s=e[0];return`<div class="player">
|
|
289
298
|
<div class="ctrls">
|
|
290
299
|
<button class="pbtn icon" type="button" data-a="prev" aria-label="Previous step">\u2039</button>
|
|
291
300
|
<button class="pbtn primary" type="button" data-a="play" aria-label="Play">\u25B6 Play</button>
|
|
292
301
|
<button class="pbtn icon" type="button" data-a="next" aria-label="Next step">\u203A</button>
|
|
293
302
|
</div>
|
|
294
|
-
${
|
|
303
|
+
${t}
|
|
295
304
|
<div class="cap" aria-live="polite">
|
|
296
|
-
<div class="cap-h"><span class="num" style="background:${s.color}">${s.num}</span><span class="h">${
|
|
297
|
-
<p class="cap-t">${
|
|
298
|
-
<pre class="cap-c">${
|
|
305
|
+
<div class="cap-h"><span class="num" style="background:${s.color}">${s.num}</span><span class="h">${dt(s.heading)}</span><span class="cnt">1 / ${e.length}</span></div>
|
|
306
|
+
<p class="cap-t">${Gn(s.caption)}</p>
|
|
307
|
+
<pre class="cap-c">${dt(s.command)}</pre>
|
|
299
308
|
<div class="prog"><i></i></div>
|
|
300
309
|
</div>
|
|
301
310
|
<div class="dots"></div>
|
|
302
|
-
</div>`}function
|
|
303
|
-
<section class="scene" id="scene-${
|
|
304
|
-
<h2>${
|
|
305
|
-
${
|
|
311
|
+
</div>`}function Ym(n){let e=n.steps.steps;return e.length?`<details class="steps"><summary>All ${e.length} steps as text</summary><ol>${e.map(t=>`<li value="${t.num}"><b>${dt(t.heading)}.</b> ${Gn(t.caption)}${t.command?`<br><code>${dt(t.command)}</code>`:""}</li>`).join("")}</ol></details>`:""}function vu(n,e={}){let t=n.doc,s=t.title??t.scenes[0]?.title??"Diagram",r=(t.pills??[]).map(i=>`<span class="pill">${Gn(i)}</span>`).join(""),o=n.scenes.map(i=>`
|
|
312
|
+
<section class="scene" id="scene-${dt(i.id)}">
|
|
313
|
+
<h2>${dt(i.raw.title)}</h2>
|
|
314
|
+
${Vl(i.raw.caption)}
|
|
306
315
|
<div class="figure" tabindex="-1">
|
|
307
316
|
<div class="scroller">${i.grid.show?i.rendered.svg.replace("<svg ",'<svg class="show-grid" '):i.rendered.svg}</div>
|
|
308
|
-
${
|
|
309
|
-
<div class="legend">${
|
|
317
|
+
${Um(i)}
|
|
318
|
+
<div class="legend">${Gl(n,i)}</div>
|
|
310
319
|
</div>
|
|
311
|
-
${
|
|
312
|
-
${i.raw.after?`<div class="after">${
|
|
320
|
+
${Ym(i)}
|
|
321
|
+
${i.raw.after?`<div class="after">${Vl(i.raw.after)}</div>`:""}
|
|
313
322
|
</section>`).join(`
|
|
314
323
|
`);return`<!doctype html>
|
|
315
324
|
<html lang="en">
|
|
316
325
|
<head>
|
|
317
326
|
<meta charset="utf-8">
|
|
318
327
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
319
|
-
<title>${
|
|
320
|
-
${
|
|
328
|
+
<title>${dt(s)}</title>
|
|
329
|
+
${t.lede?`<meta name="description" content="${dt(t.lede)}">`:""}
|
|
321
330
|
<style>
|
|
322
|
-
${
|
|
331
|
+
${ei(n.theme)}${Fi(n.catalog)}${Bi}
|
|
323
332
|
</style>
|
|
324
333
|
${e.extraHead??""}
|
|
325
334
|
</head>
|
|
@@ -327,17 +336,17 @@ ${e.extraHead??""}
|
|
|
327
336
|
<div class="wrap">
|
|
328
337
|
<header class="page">
|
|
329
338
|
<div>
|
|
330
|
-
<h1>${
|
|
331
|
-
${
|
|
339
|
+
<h1>${dt(s)}</h1>
|
|
340
|
+
${t.lede?`<p class="lede">${Gn(t.lede)}</p>`:""}
|
|
332
341
|
</div>
|
|
333
342
|
<div class="pills">${r}<button class="theme" id="themeBtn" type="button">Theme</button></div>
|
|
334
343
|
</header>
|
|
335
344
|
${o}
|
|
336
|
-
${
|
|
337
|
-
${
|
|
345
|
+
${t.after?Vl(t.after):""}
|
|
346
|
+
${t.footer?`<footer>${Gn(t.footer)}</footer>`:""}
|
|
338
347
|
</div>
|
|
339
|
-
${
|
|
340
|
-
${
|
|
348
|
+
${zl} type="application/json" id="diagram-steps">${Kl(n).replace(/</g,"\\u003c")}<\/script>
|
|
349
|
+
${zl}>
|
|
341
350
|
(function(){
|
|
342
351
|
var root=document.documentElement, m=/theme=(light|dark)/.exec(location.hash);
|
|
343
352
|
try{var t=localStorage.getItem('diagram-theme'); if(t) root.dataset.theme=t;}catch(e){}
|
|
@@ -349,14 +358,14 @@ ${La}>
|
|
|
349
358
|
});
|
|
350
359
|
})();
|
|
351
360
|
<\/script>
|
|
352
|
-
${e.runtime?`${
|
|
361
|
+
${e.runtime?`${zl}>${e.runtime}<\/script>`:""}
|
|
353
362
|
${e.extraBody??""}
|
|
354
363
|
</body>
|
|
355
364
|
</html>
|
|
356
|
-
`}function Q(t,e=null,...n){let s=document.createElement(t);for(let[r,o]of Object.entries(e??{}))if(!(o==null||o===!1))if(r==="class")s.className=String(o);else if(r==="on")for(let[i,a]of Object.entries(o))s.addEventListener(i,a);else s.setAttribute(r,o===!0?"":String(o));for(let r of n)r!=null&&r!==!1&&s.append(r instanceof Node?r:document.createTextNode(String(r)));return s}var Dc=1,ei="(?:[^/:%\\s]|%[0-9A-F]{2})+",jt=["debug","info","notice","warning","error"],zc=["1m","1h","1d"],tn={"1m":6e4,"1h":36e5,"1d":864e5},ti=t=>`^(?:(?:${t.kinds.join("|")}):(?:${ei})(?:/(?:${t.kinds.join("|")}):(?:${ei}))*)?$`;function ni(t){let e=new RegExp(ti(t)),n=o=>e.test(o);function s(o){if(!e.test(o))throw new Error(`not a scope path: ${JSON.stringify(o)}`);return o===""?[]:o.split("/").map(i=>{let a=i.indexOf(":");return{kind:i.slice(0,a),name:decodeURIComponent(i.slice(a+1))}})}function r(o){let i="";for(let a of s(o)){if(!t.parents[a.kind].includes(i))return!1;i=a.kind}return!0}return{isScope:n,parseScope:s,wellNested:r}}var si=t=>t.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),jc=t=>t.map(e=>`${e.kind}:${si(e.name)}`).join("/"),Vc=(t,e,n)=>(t?`${t}/`:"")+`${e}:${si(n)}`,Nt=t=>t===""?0:t.split("/").length;function Bn(t,e){return e<=0?"":(t===""?[]:t.split("/")).slice(0,e).join("/")}var Kc=t=>Bn(t,Nt(t)-1),Vt=(t,e)=>e===""||t===e||t.startsWith(`${e}/`),Gc=(t,e)=>t!==""&&t.split("/").includes(e),Cs=t=>t===""?"fleet":t.slice(t.lastIndexOf("/")+1).split(":")[0],Ls=t=>t===""?"all hosts":decodeURIComponent(t.slice(t.lastIndexOf("/")+1).split(":").slice(1).join(":"));function Is(t){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let n=1;n<=Nt(t);n++){let s=Bn(t,n);e.push({scope:s,label:Ls(s),kind:Cs(s)})}return e}var _a=["kind","source","severity","scope","since","before"];function Fu(t){let e=[],n=0;for(;n<t.length;){for(;n<t.length&&/\s/.test(t[n]);)n++;if(n>=t.length)break;let s=!1;t[n]==="-"&&n+1<t.length&&!/\s/.test(t[n+1])&&(s=!0,n++);let r=/^(attr\.[a-z][a-z0-9_]*|[a-z]+):/.exec(t.slice(n)),o;r&&(o=r[1],n+=r[0].length);let i="",a=!1;if(t[n]==='"'){let l=t.indexOf('"',n+1);i=t.slice(n+1,l<0?t.length:l),a=!0,n=l<0?t.length:l+1}else{let l=n;for(;n<t.length&&!/\s/.test(t[n]);)n++;i=t.slice(l,n)}e.push({neg:s,raw:i,quoted:a,field:o})}return e}var Bu=/^(\d+)(s|m|h|d|w)$/,_u={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function Da(t,e){let n=Bu.exec(t);if(n)return e-Number(n[1])*_u[n[2]];let s=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?)?(Z|[+-]\d{2}:?\d{2})?$/.exec(t);if(!s)return;let[,r,o,i,a="0",l="0",c="0",f="0",u]=s;if(u){let p=Date.parse(t.replace(" ","T"));return Number.isNaN(p)?void 0:p}let d=new Date(+r,+o-1,+i,+a,+l,+c,+f.padEnd(3,"0")).getTime();return Number.isNaN(d)?void 0:d}function Du(t,e,n=Date.now()){let s=[],r=[];for(let o of Fu(e??"")){let i=c=>{let f=o.field?`${o.field}:${o.raw}`:o.raw;c&&r.push(`${JSON.stringify(f)}: ${c}; searched as text`),f&&s.push({neg:o.neg,value:f})};if(!o.field){i();continue}if(!(t.includes(o.field)||o.field.startsWith("attr."))){i(`no field ${o.field}`);continue}if(!o.raw){i(`${o.field}: needs a value`);continue}let l=o.field;if(l==="severity"){let c=/^(>=|<=|>|<|=)?(.*)$/.exec(o.raw);if(!jt.includes(c[2])){i(`no severity ${c[2]} (${jt.join(", ")})`);continue}s.push({neg:o.neg,field:l,op:c[1]??"=",value:c[2]})}else if(l==="since"||l==="before"){let c=Da(o.raw,n);if(c===void 0){i(`can't read the time ${o.raw} (15m, 2h, 3d, 1w, or a date like 2026-11-20 or 2026-11-20T09:30)`);continue}if(o.neg){i(`-${l} isn't allowed (use ${l==="since"?"before":"since"})`);continue}s.push({neg:!1,field:l,value:o.raw,time:c})}else s.push({neg:o.neg,field:l,value:o.raw})}return{terms:s,warnings:r}}var ri=t=>jt.indexOf(t),zu={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function ju(t,e){switch(t.field){case void 0:return{field:"text",value:t.value};case"kind":case"source":return t.value.endsWith("*")?{field:t.field,value:t.value.slice(0,-1),prefix:!0}:{field:t.field,value:t.value};case"severity":return{field:"severity",op:zu[t.op??"="],value:t.value};case"scope":return{field:"scope",value:t.value,from:e.topKinds.some(n=>t.value.startsWith(`${n}:`))?"top":"segments"};case"since":case"before":return;default:return e.links.includes(t.field)?{field:"link",link:t.field,value:t.value}:{field:"attr",key:t.field.slice(5),value:t.value}}}function Vu(t,e){let n=[],s=new Map;for(let r of e.terms){let o=ju(r,t);if(!o)continue;if(r.neg){n.push({not:!0,any:[o]});continue}if(o.field==="text"||o.field==="severity"){n.push({any:[o]});continue}let i=o.field==="link"?`link.${o.link}`:o.field==="attr"?`attr.${o.key}`:o.field,a=s.get(i);if(a)a.any.push(o);else{let l={any:[o]};s.set(i,l),n.push(l)}}return{all:n}}function Ku(t,e,n,s){switch(e.field){case"text":{let r=e.value.toLowerCase();if(n.summary.toLowerCase().includes(r)||n.kind.toLowerCase().includes(r)||n.source.toLowerCase().includes(r)||n.scope.toLowerCase().includes(r))return!0;for(let[o,i]of Object.entries(n.attrs))if(typeof i=="string"&&!s.has(`${n.source}.${o}`)&&i.toLowerCase().includes(r))return!0;return!1}case"kind":case"source":{let r=n[e.field];return e.prefix?r.startsWith(e.value):r===e.value}case"severity":{let r=ri(n.severity),o=ri(e.value);return e.op==="ge"?r>=o:e.op==="gt"?r>o:e.op==="le"?r<=o:e.op==="lt"?r<o:r===o}case"scope":return e.from==="top"?Vt(n.scope,e.value):`/${n.scope}/`.includes(`/${e.value}/`);case"link":return t.linkMatch?.(String(e.link),e.value,n)??n.links[e.link]===e.value;case"attr":{let r=n.attrs[e.key];return r!=null&&String(r).toLowerCase()===e.value.toLowerCase()}}}function Fs(t){let e=[..._a,...t.links],n=(a,l=Date.now())=>Du(e,a,l),s=a=>Vu(t,a);function r(a,l,c,f){let u=n(a,l);return{where:s(u),...yr(u,c,f),warnings:u.warnings}}function o(a,l=[]){let c=new Set(l),f=a?.all??[];return f.length?u=>f.every(d=>d.any.some(p=>Ku(t,p,u,c))!==!!d.not):()=>!0}return{FIELDS:e,parseSearch:n,toAst:s,compileSearch:r,matchAst:o,matcher:(a,l=[])=>o(s(a),l)}}function yr(t,e,n){for(let s of t.terms)s.field==="since"&&(e=Math.max(e,s.time)),s.field==="before"&&(n=Math.min(n,s.time));return{from:e,to:Math.max(e,n)}}function xr(t,e){let n=e.toLowerCase(),s=[];for(let o of t.terms){if(o.neg||o.field||!o.value)continue;let i=o.value.toLowerCase();for(let a=n.indexOf(i);a>=0;a=n.indexOf(i,a+i.length))s.push([a,a+i.length])}s.sort((o,i)=>o[0]-i[0]);let r=[];for(let o of s){let i=r[r.length-1];i&&o[0]<=i[1]?i[1]=Math.max(i[1],o[1]):r.push([...o])}return r}var Uc=t=>jt.filter(e=>ri(e)>=ri(t));var qc=new Map,oi=new Map;function Ct(t,e){if(!t||t==="UTC")return 0;let n=`${t}|${Math.floor(e/(15*6e4))}`,s=oi.get(n);if(s!==void 0)return s;let r=qc.get(t);if(!r){try{r=new Intl.DateTimeFormat("en-US",{timeZone:t,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch{return 0}qc.set(t,r)}let o={};for(let l of r.formatToParts(new Date(e)))l.type!=="literal"&&(o[l.type]=Number(l.value));let i=Date.UTC(o.year,o.month-1,o.day,o.hour%24,o.minute,o.second),a=Math.round((i-Math.floor(e/1e3)*1e3)/6e4)*6e4;return oi.size>5e4&&oi.clear(),oi.set(n,a),a}var Yc=t=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:t}),!0}catch{return!1}};function cs(t,e,n){if(e==="1m")return Math.floor(t/6e4)*6e4;let s=Ct(n,t);if(e==="1h")return s%36e5===0?Math.floor(t/36e5)*36e5:Math.floor((t+s)/36e5)*36e5-s;let r=Math.floor((t+s)/864e5)*864e5,o=r-Ct(n,r-s);return o>t?o=r-864e5-Ct(n,r-864e5-s):ii(o,n)<=t&&(o=ii(o,n)),o}function ii(t,e,n="1d"){if(n==="1m")return t+6e4;if(n==="1h")return t+36e5;let s=Ct(e,t),r=Math.floor((t+s)/864e5)*864e5+864e5;return r-Ct(e,r-s)}var Jn=6e4,Xn=36e5,nn=864e5;function ai(t,e,n,s={}){let r=Math.max((s.minFrac??.15)*(n-e),s.minMs??10*Jn),o=t.filter(([l,c])=>c>=e&&l<n).map(([l,c])=>[Math.max(e,l),Math.min(n,Math.max(l,c))]).sort((l,c)=>l[0]-c[0]),i=[];if(!o.length)return i;let a=e;for(let[l,c]of o)l-a>r&&i.push({from:a,to:l}),a=Math.max(a,c);return n-a>r&&i.push({from:a,to:n}),i}function fs(t){if(t>=nn){let e=Math.floor(t/nn),n=Math.round((t-e*nn)/Xn);return n?`${e} d ${n} h`:`${e} d`}if(t>=Xn){let e=Math.floor(t/Xn),n=Math.round((t-e*Xn)/Jn);return n&&e<10?`${e} h ${n} min`:`${e} h`}return`${Math.max(1,Math.round(t/Jn))} min`}var us=t=>`${t.from}-${t.to}`;function Bs(t,e,n,s=[],r={}){let o=r.cut??24,i=Math.max(1,n),a=Math.max(1,e-t),l=s.filter(M=>M.to>t&&M.from<e).map(M=>({from:Math.max(t,M.from),to:Math.min(e,M.to),w:r.weights?.get(us(M))??0})).sort((M,$)=>M.from-$.from),c=l.reduce((M,$)=>M+($.to-$.from)*(1-$.w),0),f=l.reduce((M,$)=>M+(1-$.w)*o,0),u=(i-f)/Math.max(1,a-c);if(!(u>0)||f>i*.6)return Bs(t,e,n,[],r);let d=[[t,0]],p=0,h=t,m=[];for(let M of l){p+=(M.from-h)*u,d.push([M.from,p]);let $=(1-M.w)*o+M.w*u*(M.to-M.from);m.push({from:M.from,to:M.to,x0:p,x1:p+$,weight:M.w}),p+=$,d.push([M.to,p]),h=M.to}d.push([e,p+(e-h)*u]);let y=M=>{if(M<=t)return(M-t)*u;if(M>=e)return d[d.length-1][1]+(M-e)*u;let $=0,R=d.length-1;for(;R-$>1;){let x=$+R>>1;d[x][0]<=M?$=x:R=x}let[E,w]=d[$],[T,L]=d[R];return T===E?w:w+(M-E)/(T-E)*(L-w)},I=M=>m.find($=>$.weight<1&&M>$.x0&&M<$.x1);return{t0:t,t1:e,width:i,cuts:m,x:y,t:M=>{let $=I(M);if($)return M-$.x0<$.x1-M?$.from:$.to;if(M<=0)return t+M/u;let R=0,E=d.length-1;if(M>=d[E][1])return e+(M-d[E][1])/u;for(;E-R>1;){let P=R+E>>1;d[P][1]<=M?R=P:E=P}let[w,T]=d[R],[L,x]=d[E];return x===T?w:w+(M-T)/(x-T)*(L-w)},cutAt:I,msPerPx:1/u}}var za=[1e3,5e3,15e3,3e4,Jn,5*Jn,15*Jn,30*Jn,Xn,3*Xn,6*Xn,12*Xn,nn,2*nn,7*nn,14*nn,28*nn];function li(t,e,n=80){let s=za.find(l=>l/t.msPerPx>=n)??za[za.length-1],r=[],o=l=>{let c=new Date(l+Ct(e,l)),f=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),d=String(c.getUTCSeconds()).padStart(2,"0"),p=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,h=f==="00"&&u==="00"&&d==="00";return s>=nn||h?{label:p,major:!0}:{label:s<Jn?`${f}:${u}:${d}`:`${f}:${u}`,major:!1}},i=[],a=t.t0;for(let l of t.cuts)l.weight<1&&(i.push([a,l.from]),a=l.to);i.push([a,t.t1]);for(let[l,c]of i){let f=d=>d-Ct(e,d-Ct(e,d)),u=Math.ceil((l+Ct(e,l))/s)*s;s>=7*nn&&(u=Math.ceil((l+Ct(e,l))/nn)*nn);for(let d=0,p=f(u);p<c&&d<2e3;d++,u+=s,p=f(u)){if(p<l)continue;let h=t.x(p),m=r[r.length-1];(!m||h-m.x>=n*.6)&&r.push({t:p,x:h,...o(p)})}}return r}var Gu=["id","time","t","dur","scope","source","kind","severity","summary"],Uu=t=>{if(t==null)return"";let e=typeof t=="string"&&/^[=+\-@\t\r]/.test(t)?`'${t}`:String(t);return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e},Hc=(t,e)=>e.size?{...t,attrs:Object.fromEntries(Object.entries(t.attrs).filter(([n])=>!e.has(`${t.source}.${n}`)))}:t;function ci(t,e=[]){let n=new Set(e);return JSON.stringify(t.map(s=>Hc(s,n)),null,2)+`
|
|
357
|
-
`}function
|
|
365
|
+
`}function me(n,e=null,...t){let s=document.createElement(n);for(let[r,o]of Object.entries(e??{}))if(!(o==null||o===!1))if(r==="class")s.className=String(o);else if(r==="on")for(let[i,a]of Object.entries(o))s.addEventListener(i,a);else s.setAttribute(r,o===!0?"":String(o));for(let r of t)r!=null&&r!==!1&&s.append(r instanceof Node?r:document.createTextNode(String(r)));return s}var $u=1,qi="(?:[^/:%\\s]|%[0-9A-F]{2})+",Ht=["debug","info","notice","warning","error"],Mu=["1m","1h","1d"],mn={"1m":6e4,"1h":36e5,"1d":864e5},Ui=n=>`^(?:(?:${n.kinds.join("|")}):(?:${qi})(?:/(?:${n.kinds.join("|")}):(?:${qi}))*)?$`;function Yi(n){let e=new RegExp(Ui(n)),t=o=>e.test(o);function s(o){if(!e.test(o))throw new Error(`not a scope path: ${JSON.stringify(o)}`);return o===""?[]:o.split("/").map(i=>{let a=i.indexOf(":");return{kind:i.slice(0,a),name:decodeURIComponent(i.slice(a+1))}})}function r(o){let i="";for(let a of s(o)){if(!n.parents[a.kind].includes(i))return!1;i=a.kind}return!0}return{isScope:t,parseScope:s,wellNested:r}}var Hi=n=>n.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),Eu=n=>n.map(e=>`${e.kind}:${Hi(e.name)}`).join("/"),Tu=(n,e,t)=>(n?`${n}/`:"")+`${e}:${Hi(t)}`,Ct=n=>n===""?0:n.split("/").length;function Zn(n,e){return e<=0?"":(n===""?[]:n.split("/")).slice(0,e).join("/")}var Au=n=>Zn(n,Ct(n)-1),Wt=(n,e)=>e===""||n===e||n.startsWith(`${e}/`),Ou=(n,e)=>n!==""&&n.split("/").includes(e),cr=n=>n===""?"fleet":n.slice(n.lastIndexOf("/")+1).split(":")[0],fr=n=>n===""?"all hosts":decodeURIComponent(n.slice(n.lastIndexOf("/")+1).split(":").slice(1).join(":"));function ur(n){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let t=1;t<=Ct(n);t++){let s=Zn(n,t);e.push({scope:s,label:fr(s),kind:cr(s)})}return e}var ql=["kind","source","severity","scope","since","before"];function Hm(n){let e=[],t=0;for(;t<n.length;){for(;t<n.length&&/\s/.test(n[t]);)t++;if(t>=n.length)break;let s=!1;n[t]==="-"&&t+1<n.length&&!/\s/.test(n[t+1])&&(s=!0,t++);let r=/^(attr\.[a-z][a-z0-9_]*|[a-z]+):/.exec(n.slice(t)),o;r&&(o=r[1],t+=r[0].length);let i="",a=!1;if(n[t]==='"'){let l=n.indexOf('"',t+1);i=n.slice(t+1,l<0?n.length:l),a=!0,t=l<0?n.length:l+1}else{let l=t;for(;t<n.length&&!/\s/.test(n[t]);)t++;i=n.slice(l,t)}e.push({neg:s,raw:i,quoted:a,field:o})}return e}var Wm=/^(\d+)(s|m|h|d|w)$/,Jm={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function Ul(n,e){let t=Wm.exec(n);if(t)return e-Number(t[1])*Jm[t[2]];let s=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?)?(Z|[+-]\d{2}:?\d{2})?$/.exec(n);if(!s)return;let[,r,o,i,a="0",l="0",c="0",f="0",u]=s;if(u){let p=Date.parse(n.replace(" ","T"));return Number.isNaN(p)?void 0:p}let d=new Date(+r,+o-1,+i,+a,+l,+c,+f.padEnd(3,"0")).getTime();return Number.isNaN(d)?void 0:d}function Xm(n,e,t=Date.now()){let s=[],r=[];for(let o of Hm(e??"")){let i=c=>{let f=o.field?`${o.field}:${o.raw}`:o.raw;c&&r.push(`${JSON.stringify(f)}: ${c}; searched as text`),f&&s.push({neg:o.neg,value:f})};if(!o.field){i();continue}if(!(n.includes(o.field)||o.field.startsWith("attr."))){i(`no field ${o.field}`);continue}if(!o.raw){i(`${o.field}: needs a value`);continue}let l=o.field;if(l==="severity"){let c=/^(>=|<=|>|<|=)?(.*)$/.exec(o.raw);if(!Ht.includes(c[2])){i(`no severity ${c[2]} (${Ht.join(", ")})`);continue}s.push({neg:o.neg,field:l,op:c[1]??"=",value:c[2]})}else if(l==="since"||l==="before"){let c=Ul(o.raw,t);if(c===void 0){i(`can't read the time ${o.raw} (15m, 2h, 3d, 1w, or a date like 2026-11-20 or 2026-11-20T09:30)`);continue}if(o.neg){i(`-${l} isn't allowed (use ${l==="since"?"before":"since"})`);continue}s.push({neg:!1,field:l,value:o.raw,time:c})}else s.push({neg:o.neg,field:l,value:o.raw})}return{terms:s,warnings:r}}var Wi=n=>Ht.indexOf(n),Qm={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function Zm(n,e){switch(n.field){case void 0:return{field:"text",value:n.value};case"kind":case"source":return n.value.endsWith("*")?{field:n.field,value:n.value.slice(0,-1),prefix:!0}:{field:n.field,value:n.value};case"severity":return{field:"severity",op:Qm[n.op??"="],value:n.value};case"scope":return{field:"scope",value:n.value,from:e.topKinds.some(t=>n.value.startsWith(`${t}:`))?"top":"segments"};case"since":case"before":return;default:return e.links.includes(n.field)?{field:"link",link:n.field,value:n.value}:{field:"attr",key:n.field.slice(5),value:n.value}}}function ep(n,e){let t=[],s=new Map;for(let r of e.terms){let o=Zm(r,n);if(!o)continue;if(r.neg){t.push({not:!0,any:[o]});continue}if(o.field==="text"||o.field==="severity"){t.push({any:[o]});continue}let i=o.field==="link"?`link.${o.link}`:o.field==="attr"?`attr.${o.key}`:o.field,a=s.get(i);if(a)a.any.push(o);else{let l={any:[o]};s.set(i,l),t.push(l)}}return{all:t}}function tp(n,e,t,s){switch(e.field){case"text":{let r=e.value.toLowerCase();if(t.summary.toLowerCase().includes(r)||t.kind.toLowerCase().includes(r)||t.source.toLowerCase().includes(r)||t.scope.toLowerCase().includes(r))return!0;for(let[o,i]of Object.entries(t.attrs))if(typeof i=="string"&&!s.has(`${t.source}.${o}`)&&i.toLowerCase().includes(r))return!0;return!1}case"kind":case"source":{let r=t[e.field];return e.prefix?r.startsWith(e.value):r===e.value}case"severity":{let r=Wi(t.severity),o=Wi(e.value);return e.op==="ge"?r>=o:e.op==="gt"?r>o:e.op==="le"?r<=o:e.op==="lt"?r<o:r===o}case"scope":return e.from==="top"?Wt(t.scope,e.value):`/${t.scope}/`.includes(`/${e.value}/`);case"link":return n.linkMatch?.(String(e.link),e.value,t)??t.links[e.link]===e.value;case"attr":{let r=t.attrs[e.key];return r!=null&&String(r).toLowerCase()===e.value.toLowerCase()}}}function dr(n){let e=[...ql,...n.links],t=(a,l=Date.now())=>Xm(e,a,l),s=a=>ep(n,a);function r(a,l,c,f){let u=t(a,l);return{where:s(u),...so(u,c,f),warnings:u.warnings}}function o(a,l=[]){let c=new Set(l),f=a?.all??[];return f.length?u=>f.every(d=>d.any.some(p=>tp(n,p,u,c))!==!!d.not):()=>!0}return{FIELDS:e,parseSearch:t,toAst:s,compileSearch:r,matchAst:o,matcher:(a,l=[])=>o(s(a),l)}}function so(n,e,t){for(let s of n.terms)s.field==="since"&&(e=Math.max(e,s.time)),s.field==="before"&&(t=Math.min(t,s.time));return{from:e,to:Math.max(e,t)}}function ro(n,e){let t=e.toLowerCase(),s=[];for(let o of n.terms){if(o.neg||o.field||!o.value)continue;let i=o.value.toLowerCase();for(let a=t.indexOf(i);a>=0;a=t.indexOf(i,a+i.length))s.push([a,a+i.length])}s.sort((o,i)=>o[0]-i[0]);let r=[];for(let o of s){let i=r[r.length-1];i&&o[0]<=i[1]?i[1]=Math.max(i[1],o[1]):r.push([...o])}return r}var Nu=n=>Ht.filter(e=>Wi(e)>=Wi(n));var Ru=new Map,Ji=new Map;function jt(n,e){if(!n||n==="UTC")return 0;let t=`${n}|${Math.floor(e/(15*6e4))}`,s=Ji.get(t);if(s!==void 0)return s;let r=Ru.get(n);if(!r){try{r=new Intl.DateTimeFormat("en-US",{timeZone:n,hourCycle:"h23",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})}catch{return 0}Ru.set(n,r)}let o={};for(let l of r.formatToParts(new Date(e)))l.type!=="literal"&&(o[l.type]=Number(l.value));let i=Date.UTC(o.year,o.month-1,o.day,o.hour%24,o.minute,o.second),a=Math.round((i-Math.floor(e/1e3)*1e3)/6e4)*6e4;return Ji.size>5e4&&Ji.clear(),Ji.set(t,a),a}var Pu=n=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}};function As(n,e,t){if(e==="1m")return Math.floor(n/6e4)*6e4;let s=jt(t,n);if(e==="1h")return s%36e5===0?Math.floor(n/36e5)*36e5:Math.floor((n+s)/36e5)*36e5-s;let r=Math.floor((n+s)/864e5)*864e5,o=r-jt(t,r-s);return o>n?o=r-864e5-jt(t,r-864e5-s):Xi(o,t)<=n&&(o=Xi(o,t)),o}function Xi(n,e,t="1d"){if(t==="1m")return n+6e4;if(t==="1h")return n+36e5;let s=jt(e,n),r=Math.floor((n+s)/864e5)*864e5+864e5;return r-jt(e,r-s)}var ps=6e4,hs=36e5,pn=864e5;function Qi(n,e,t,s={}){let r=Math.max((s.minFrac??.15)*(t-e),s.minMs??10*ps),o=n.filter(([l,c])=>c>=e&&l<t).map(([l,c])=>[Math.max(e,l),Math.min(t,Math.max(l,c))]).sort((l,c)=>l[0]-c[0]),i=[];if(!o.length)return i;let a=e;for(let[l,c]of o)l-a>r&&i.push({from:a,to:l}),a=Math.max(a,c);return t-a>r&&i.push({from:a,to:t}),i}function Os(n){if(n>=pn){let e=Math.floor(n/pn),t=Math.round((n-e*pn)/hs);return t?`${e} d ${t} h`:`${e} d`}if(n>=hs){let e=Math.floor(n/hs),t=Math.round((n-e*hs)/ps);return t&&e<10?`${e} h ${t} min`:`${e} h`}return`${Math.max(1,Math.round(n/ps))} min`}var Ns=n=>`${n.from}-${n.to}`;function mr(n,e,t,s=[],r={}){let o=r.cut??24,i=Math.max(1,t),a=Math.max(1,e-n),l=s.filter(b=>b.to>n&&b.from<e).map(b=>({from:Math.max(n,b.from),to:Math.min(e,b.to),w:r.weights?.get(Ns(b))??0})).sort((b,x)=>b.from-x.from),c=l.reduce((b,x)=>b+(x.to-x.from)*(1-x.w),0),f=l.reduce((b,x)=>b+(1-x.w)*o,0),u=(i-f)/Math.max(1,a-c);if(!(u>0)||f>i*.6)return mr(n,e,t,[],r);let d=[[n,0]],p=0,g=n,m=[];for(let b of l){p+=(b.from-g)*u,d.push([b.from,p]);let x=(1-b.w)*o+b.w*u*(b.to-b.from);m.push({from:b.from,to:b.to,x0:p,x1:p+x,weight:b.w}),p+=x,d.push([b.to,p]),g=b.to}d.push([e,p+(e-g)*u]);let y=b=>{if(b<=n)return(b-n)*u;if(b>=e)return d[d.length-1][1]+(b-e)*u;let x=0,A=d.length-1;for(;A-x>1;){let $=x+A>>1;d[$][0]<=b?x=$:A=$}let[M,v]=d[x],[O,C]=d[A];return O===M?v:v+(b-M)/(O-M)*(C-v)},N=b=>m.find(x=>x.weight<1&&b>x.x0&&b<x.x1);return{t0:n,t1:e,width:i,cuts:m,x:y,t:b=>{let x=N(b);if(x)return b-x.x0<x.x1-b?x.from:x.to;if(b<=0)return n+b/u;let A=0,M=d.length-1;if(b>=d[M][1])return e+(b-d[M][1])/u;for(;M-A>1;){let P=A+M>>1;d[P][1]<=b?A=P:M=P}let[v,O]=d[A],[C,$]=d[M];return $===O?v:v+(b-O)/($-O)*(C-v)},cutAt:N,msPerPx:1/u}}var Yl=[1e3,5e3,15e3,3e4,ps,5*ps,15*ps,30*ps,hs,3*hs,6*hs,12*hs,pn,2*pn,7*pn,14*pn,28*pn];function Zi(n,e,t=80){let s=Yl.find(l=>l/n.msPerPx>=t)??Yl[Yl.length-1],r=[],o=l=>{let c=new Date(l+jt(e,l)),f=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),d=String(c.getUTCSeconds()).padStart(2,"0"),p=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,g=f==="00"&&u==="00"&&d==="00";return s>=pn||g?{label:p,major:!0}:{label:s<ps?`${f}:${u}:${d}`:`${f}:${u}`,major:!1}},i=[],a=n.t0;for(let l of n.cuts)l.weight<1&&(i.push([a,l.from]),a=l.to);i.push([a,n.t1]);for(let[l,c]of i){let f=d=>d-jt(e,d-jt(e,d)),u=Math.ceil((l+jt(e,l))/s)*s;s>=7*pn&&(u=Math.ceil((l+jt(e,l))/pn)*pn);for(let d=0,p=f(u);p<c&&d<2e3;d++,u+=s,p=f(u)){if(p<l)continue;let g=n.x(p),m=r[r.length-1];(!m||g-m.x>=t*.6)&&r.push({t:p,x:g,...o(p)})}}return r}var np=["id","time","t","dur","scope","source","kind","severity","summary"],sp=n=>{if(n==null)return"";let e=typeof n=="string"&&/^[=+\-@\t\r]/.test(n)?`'${n}`:String(n);return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e},Cu=(n,e)=>e.size?{...n,attrs:Object.fromEntries(Object.entries(n.attrs).filter(([t])=>!e.has(`${n.source}.${t}`)))}:n;function ea(n,e=[]){let t=new Set(e);return JSON.stringify(n.map(s=>Cu(s,t)),null,2)+`
|
|
366
|
+
`}function ta(n,e=[]){let t=new Set(e),s=n.map(l=>Cu(l,t)),r=[...new Set(s.flatMap(l=>Object.keys(l.attrs)))].sort(),o=[...new Set(s.flatMap(l=>Object.keys(l.links)))].sort(),i=[...np,...r.map(l=>`attr.${l}`),...o.map(l=>`link.${l}`)],a=s.map(l=>[l.id,new Date(l.t).toISOString(),l.t,l.dur,l.scope,l.source,l.kind,l.severity,l.summary,...r.map(c=>l.attrs[c]),...o.map(c=>l.links[c])].map(sp).join(","));return[i.join(","),...a].join(`\r
|
|
358
367
|
`)+`\r
|
|
359
|
-
`}var qu=864e5,hn=36e5,ui=(t,e)=>t.t-e.t||(t.id<e.id?-1:t.id>e.id?1:0);function An(t,e){let n=0,s=t.length;for(;n<s;){let r=n+s>>1;t[r].t<e?n=r+1:s=r}return n}var Xc=(t,e)=>{t.min=Math.min(t.min,e.min),t.max=Math.max(t.max,e.max),t.sum+=e.sum,t.count+=e.count};function Wc(t,e,n){let s=[];for(let r of t){let o=cs(r.t,e,n),i=s[s.length-1];i&&i.t===o?Xc(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function ja(t,e,n,s){for(let i=An(t,e.t);i<t.length&&t[i].t===e.t;i++)if(n(t[i])){t[i]=e;return}let r=t[t.length-1];if(!r||s(r,e)<=0){t.push(e);return}let o=An(t,e.t);for(;o<t.length&&s(t[o],e)<0;)o++;t.splice(o,0,e)}function Jc(t,e,n){for(let s=An(t,e);s<t.length&&t[s].t===e;s++)if(n(t[s])){t.splice(s,1);return}}function Qc(t,e,n={}){let s=t.catalog,{isScope:r}=ni(e),{parseSearch:o,matchAst:i,toAst:a}=Fs(e),l=S=>Object.fromEntries(e.flags.filter(Y=>S?.[Y]).map(Y=>[Y,!0])),c=n.now??s.now,f=(s.names??[]).flatMap(S=>(S.aliases??[]).map(Y=>[Y,S.scope])).sort((S,Y)=>Y[0].length-S[0].length),u=new Map,d=S=>{if(!f.length)return S;let Y=u.get(S);if(Y===void 0){let se=f.find(([le])=>Vt(S,le));Y=se?se[1]+S.slice(se[0].length):S,u.set(S,Y)}return Y},p=new Map((s.names??[]).map(S=>[S.scope,S])),h=S=>f.length?{...S,scope:d(S.scope)}:S,m=S=>`${S.source}\0${S.id}`,y=t.events.map(h).sort(ui),I=new Map;for(let S of y)I.set(m(S),S);let N=y.filter(S=>S.dur!==void 0&&!S.open),M=N.reduce((S,Y)=>Math.max(S,Y.dur),0),$=new Map;for(let S of y)S.open&&$.set(m(S),S);let R=new Map,E=new Set,w=S=>{for(let Y=Nt(S);Y>=1;Y--){let se=Bn(S,Y);if(E.has(se))break;E.add(se)}},T=new Map;for(let S of s.sources)for(let Y of S.series)T.set(Y.name,Y.type);let L=s.sources.flatMap(S=>(S.sensitive??[]).map(Y=>`${S.name}.${Y}`)),x=new Map;for(let S of s.sources)x.set(S.name,{events:S.defaultRetention.events,rollups:{...S.defaultRetention.rollups},setBy:"default"});for(let S of s.retention)x.set(S.source,{events:S.events,rollups:{...S.rollups},setBy:S.setBy});let P=new Map;for(let S of s.sources)for(let Y of S.series)P.set(Y.name,S.name);function b(S){let Y=d(S.scope),se=`${S.series}\0${Y}`,le=R.get(se);le||(le={series:S.series,scope:Y,fine:[],cache:new Map},R.set(se,le),w(Y));let Pe="value"in S?{t:S.t,min:S.value,max:S.value,sum:S.value,count:1}:{t:S.t,min:S.min,max:S.max,sum:S.sum,count:S.count};ja(le.fine,Pe,ae=>ae.t===Pe.t,(ae,Be)=>ae.t-Be.t),le.cache.clear()}for(let S of y)w(S.scope);for(let S of t.metrics)b(S);let v=new Map,g=new Set,O=(S,Y)=>{g.add(S.source);let se=v.get(S.scope);se||v.set(S.scope,se=new Map);let le=se.get(S.source);le||se.set(S.source,le=new Map);let Pe=Math.floor(S.t/hn)*hn,ae=le.get(Pe);if(ae||le.set(Pe,ae={t:Pe,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ae.count+=Y,Y>0)ae.first=Math.min(ae.first,S.t),ae.last=Math.max(ae.last,S.t);else if(S.t===ae.first||S.t===ae.last){ae.first=1/0,ae.last=-1/0;for(let Be=An(y,Pe);Be<y.length&&y[Be].t<Pe+hn;Be++){let xe=y[Be];xe.scope===S.scope&&xe.source===S.source&&(ae.first=Math.min(ae.first,xe.t),ae.last=Math.max(ae.last,xe.t))}}ae.severity[S.severity]=(ae.severity[S.severity]??0)+Y,ae.kinds[S.kind]=(ae.kinds[S.kind]??0)+Y,ae.severity[S.severity]===0&&delete ae.severity[S.severity],ae.kinds[S.kind]===0&&delete ae.kinds[S.kind],ae.count||le.delete(Pe)};for(let S of y)O(S,1);let F=(S,Y,se)=>{let le=`${Y}|${se??""}`,Pe=S.cache.get(le);return Pe||(Pe=Y==="1d"?Wc(F(S,"1h",se),"1d",se):Wc(S.fine,Y,se),S.cache.set(le,Pe)),Pe},j=S=>S===null?-1/0:c-S*qu,U=S=>j(x.get(S)?.events??null),ne=(S,Y)=>{let se=x.get(S);return j(se?Y?se.rollups[Y]:se.events:null)};function B(S){let Y=[];for(let se of new Set(S)){let le=x.get(se);if(!le)continue;let Pe=y.find(fe=>fe.source===se&&fe.t>=U(se))?.t,ae=fe=>{let Se=1/0;for(let Ke of R.values())if(P.get(Ke.series)===se){let Te=(fe?F(Ke,fe):Ke.fine).find(Qe=>Qe.t>=ne(se,fe));Te&&Te.t<Se&&(Se=Te.t)}return Se===1/0?void 0:Se},Be=[Pe,ae()].filter(fe=>fe!==void 0),xe={};for(let fe of["1m","1h","1d"]){let Se=ae(fe)??(Pe!==void 0&&Pe>=ne(se,fe)?Pe:void 0);Se!==void 0&&(xe[fe]=Math.max(Se,ne(se,fe)))}Y.push({source:se,events:le.events,rollups:{...le.rollups},setBy:le.setBy,keptFrom:{...Be.length?{events:Math.min(...Be)}:{},rollups:xe}})}return Y}function K(S){let Y=S.where,se={from:S.from,to:S.to},le=[];if(!Y&&S.q){let Te=o(S.q,c);Y=a(Te),se=yr(Te,S.from,S.to),le=Te.warnings}let Pe=i(Y,L),ae=S.filters??{},Be=ae.source?.length?new Set(ae.source):void 0,xe=ae.kind?.length?new Set(ae.kind):void 0,fe=ae.severity?.length?new Set(ae.severity):void 0,Se=ae.scope?.length?ae.scope:void 0;return{test:Te=>Vt(Te.scope,S.scope)&&(!Be||Be.has(Te.source))&&(!xe||xe.has(Te.kind))&&(!fe||fe.has(Te.severity))&&(!Se||Se.some(Qe=>Vt(Te.scope,Qe)))&&Te.t>=U(Te.source)&&Pe(Te),range:se,warnings:le}}function q(S){let Y=Nt(S.scope),se=Y+S.depth,le=new Map,Pe=fe=>{let Se=le.get(fe);return Se===void 0&&!le.has(fe)&&(Se=Vt(fe,S.scope)?Nt(fe)>=se?Bn(fe,se):fe:void 0,le.set(fe,Se)),Se},ae=fe=>{let Se=0,Ke=Nt(fe)+1;for(let Te of E)Nt(Te)===Ke&&Vt(Te,fe)&&Se++;return Se},Be=new Map,xe=fe=>{let Se=Be.get(fe);if(!Se){let Ke=Nt(fe)-Y,Te=p.get(fe);Se={scope:fe,label:Te?.label??Ls(fe),kind:Cs(fe),...l(Te),depth:Ke,...Ke<S.depth?{own:!0}:{},children:ae(fe),count:0},Be.set(fe,Se)}return Se};for(let fe of E)Nt(fe)===se&&Vt(fe,S.scope)&&xe(fe);return se===0&&xe(""),{at:Pe,add:xe,rows:Be}}let Z=S=>[...S.values()].sort((Y,se)=>Y.scope===se.scope?0:Y.scope<se.scope?-1:1);function A(S,Y){let se=[];for(let le=An(N,S-M);le<N.length&&N[le].t<S;le++)N[le].t+N[le].dur>S&&se.push(N[le]);for(let le of $.values())le.t<S&&c>S&&se.push(le);for(let le=An(y,S);le<y.length&&y[le].t<Y;le++)se.push(y[le]);return se}function D(S,Y,se,le){let Pe=S.series?new Set(S.series):void 0,ae=new Map;for(let xe of R.values()){if(Pe&&!Pe.has(xe.series))continue;let fe=Y(xe.scope);if(fe===void 0)continue;let Se=P.get(xe.series)??"",Ke=ne(Se,S.bin),Te=S.bin?F(xe,S.bin,S.tz):xe.fine;for(let Qe=An(Te,S.bin?cs(se,S.bin,S.tz):se);Qe<Te.length&&Te[Qe].t<le;Qe++){let lt=Te[Qe];if(lt.t<Ke)continue;let je=`${xe.series}\0${fe}\0${lt.t}`,st=ae.get(je);st?Xc(st,lt):ae.set(je,{series:xe.series,scope:fe,t:lt.t,bin:S.bin??"1m",min:lt.min,max:lt.max,sum:lt.sum,count:lt.count})}}let Be=[...ae.values()].sort((xe,fe)=>xe.t-fe.t||(xe.series<fe.series?-1:1)||(xe.scope<fe.scope?-1:1));return S.bin?Be:Be.map(xe=>({series:xe.series,scope:xe.scope,t:xe.t,value:xe.count===1||T.get(xe.series)!=="gauge"?xe.sum:xe.sum/xe.count}))}let V=S=>`${S.t}:${S.id}`,W=(S,Y)=>{let se=Y.indexOf(":"),le=Number(Y.slice(0,se)),Pe=Y.slice(se+1);return S.t>le||S.t===le&&S.id>Pe};function ie(S){if(S.bin!=="1h"&&S.bin!=="1d"||(S.where?.all.length??0)||S.q||S.filters?.kind?.length||S.filters?.severity?.length||S.filters?.scope?.length||Ct(S.tz,S.from)%hn||Ct(S.tz,S.to)%hn)return;let Y=S.filters?.source?.length?new Set(S.filters.source):void 0,se=ce=>Math.max(S.from,U(ce)),{at:le,add:Pe,rows:ae}=q(S),Be=new Set,xe=new Map,fe=0,Se=(ce,Oe)=>{let Ee=cs(Oe,S.bin,S.tz),tt=`${ce}\0${Ee}`,k=xe.get(tt);return k||(k={scope:ce,t:Ee,bin:S.bin,count:0,severity:{},kinds:{}},xe.set(tt,k)),k},Ke=(ce,Oe,Ee)=>{let tt=Pe(ce);tt.count+=Ee,fe+=Ee,(tt.first===void 0||Oe<tt.first)&&(tt.first=Oe),(tt.last===void 0||Oe>tt.last)&&(tt.last=Oe)},Te=Math.floor(S.to/hn)*hn;for(let[ce,Oe]of v){let Ee=le(ce);if(Ee!==void 0)for(let[tt,k]of Oe){if(Y&&!Y.has(tt))continue;let _=Math.ceil(se(tt)/hn)*hn;for(let[z,oe]of k){if(z<_||z>=Te)continue;Ke(Ee,oe.first,oe.count),oe.last>(ae.get(Ee).last??-1/0)&&(ae.get(Ee).last=oe.last),Be.add(tt);let re=Se(Ee,z);re.count+=oe.count;for(let[ke,he]of Object.entries(oe.severity))re.severity[ke]=(re.severity[ke]??0)+he;for(let[ke,he]of Object.entries(oe.kinds))re.kinds[ke]=(re.kinds[ke]??0)+he}}}let Qe=ce=>Vt(ce.scope,S.scope)&&(!Y||Y.has(ce.source))&&ce.t>=U(ce.source)&&le(ce.scope)!==void 0,lt=ce=>{let Oe=le(ce.scope);Ke(Oe,ce.t,1),Be.add(ce.source);let Ee=Se(Oe,ce.t);Ee.count++,Ee.severity[ce.severity]=(Ee.severity[ce.severity]??0)+1,Ee.kinds[ce.kind]=(Ee.kinds[ce.kind]??0)+1};for(let ce of g){if(Y&&!Y.has(ce))continue;let Oe=se(ce),Ee=Math.ceil(Oe/hn)*hn,tt=Ee>=Te?[[Oe,S.to]]:[[Oe,Ee],[Te,S.to]];for(let[k,_]of tt)for(let z=An(y,k);z<y.length&&y[z].t<_;z++){let oe=y[z];oe.source===ce&&Qe(oe)&<(oe)}}let je=tn[S.bin],st=[];for(let ce=An(N,S.from-M);ce<N.length&&N[ce].t<S.from;ce++){let Oe=N[ce];Oe.t+Oe.dur>S.from&&Qe(Oe)&&(Ke(le(Oe.scope),Oe.t,1),Be.add(Oe.source),Oe.dur>=je&&st.length<5e3&&st.push(Oe))}for(let ce of $.values())ce.t<S.from&&c>S.from&&Qe(ce)&&(Ke(le(ce.scope),ce.t,1),Be.add(ce.source),st.length<5e3&&st.push(ce));for(let ce=An(N,S.from);ce<N.length&&N[ce].t<S.to&&st.length<5e3;ce++)N[ce].dur>=je&&Qe(N[ce])&&st.push(N[ce]);for(let ce of $.values())ce.t>=S.from&&ce.t<S.to&&st.length<5e3&&Qe(ce)&&st.push(ce);let Ye=D(S,le,S.from,S.to);for(let ce of Ye){let Oe=P.get(ce.series);Oe&&Be.add(Oe)}let rt=[...xe.values()].sort((ce,Oe)=>ce.t-Oe.t||(ce.scope<Oe.scope?-1:1));return{timeline:1,type:"result",rows:Z(ae),bins:rt,spans:st,metrics:Ye,total:fe,retention:B(Be)}}async function de(S){if(!r(S.scope))throw new Error(`not a scope path: ${JSON.stringify(S.scope)}`);let Y=ie(S);if(Y)return Y;let{test:se,range:le,warnings:Pe}=K(S),{at:ae,add:Be,rows:xe}=q(S),fe=new Set,Se=[];for(let Ye of A(le.from,le.to)){if(!se(Ye))continue;let rt=ae(Ye.scope);if(rt===void 0)continue;let ce=Be(rt);ce.count++,(ce.first===void 0||Ye.t<ce.first)&&(ce.first=Ye.t),(ce.last===void 0||Ye.t>ce.last)&&(ce.last=Ye.t),fe.add(Ye.source),Se.push(Ye)}Se.sort(ui);let Ke=D(S,ae,le.from,le.to);for(let Ye of Ke){let rt=P.get(Ye.series);rt&&fe.add(rt)}let Te={timeline:1,type:"result",total:Se.length,...Pe.length?{warnings:Pe}:{}};if(S.bin){let Ye=tn[S.bin],rt=new Map,ce=[];for(let Ee of Se){if((Ee.open||Ee.dur!==void 0&&Ee.dur>=Ye)&&ce.length<5e3&&ce.push(Ee),Ee.t<le.from)continue;let tt=ae(Ee.scope),k=cs(Ee.t,S.bin,S.tz),_=`${tt}\0${k}`,z=rt.get(_);z||(z={scope:tt,t:k,bin:S.bin,count:0,severity:{},kinds:{}},rt.set(_,z)),z.count++,z.severity[Ee.severity]=(z.severity[Ee.severity]??0)+1,z.kinds[Ee.kind]=(z.kinds[Ee.kind]??0)+1}let Oe=[...rt.values()].sort((Ee,tt)=>Ee.t-tt.t||(Ee.scope<tt.scope?-1:1));return{...Te,rows:Z(xe),bins:Oe,spans:ce,metrics:Ke,retention:B(fe)}}let Qe=Math.min(1e4,Math.max(1,S.limit??2e3)),lt=S.cursor?Se.findIndex(Ye=>W(Ye,S.cursor)):0,je=lt<0?[]:Se.slice(lt,lt+Qe),st=lt>=0&<+Qe<Se.length;return{...Te,rows:Z(xe),events:je,metrics:Ke,retention:B(fe),...st?{next:V(je[je.length-1])}:{}}}let X=new Set,te=S=>jt.includes(S),ye=0;function Fe(S){let Y=m(S),se=I.get(Y);se&&(Jc(y,se.t,le=>le===se),O(se,-1),se.dur!==void 0&&!se.open&&Jc(N,se.t,le=>le===se),$.delete(Y)),I.set(Y,S),O(S,1),ja(y,S,()=>!1,ui),S.open?$.set(Y,S):S.dur!==void 0&&(ja(N,S,()=>!1,ui),M=Math.max(M,S.dur)),w(S.scope)}return{async catalog(){return{...s,now:c,retention:B(s.sources.map(S=>S.name))}},query:de,subscribe(S,Y){let se={q:S,on:Y};return X.add(se),()=>{X.delete(se)}},...n.stateAt?{stateAt:(S,Y)=>n.stateAt(S,Y)}:{},append(S,Y=[],se){se!==void 0&&(c=Math.max(c,se));let le=new Set(E),Pe=S.map(h);for(let ae of Pe){if(!te(ae.severity))throw new Error(`not a severity: ${ae.severity}`);Fe(ae)}for(let ae of Y)b(ae);ye++;for(let ae of X){let{test:Be}=K(ae.q),{at:xe}=q(ae.q),fe=Pe.filter(je=>Be(je)&&xe(je.scope)!==void 0),Se=ae.q.series?new Set(ae.q.series):void 0,Ke=Y.filter(je=>Vt(d(je.scope),ae.q.scope)&&(!Se||Se.has(je.series))).map(je=>({...je,scope:xe(d(je.scope))})),Te=[...E].filter(je=>!le.has(je)),Qe=Nt(ae.q.scope)+ae.q.depth,lt=Te.filter(je=>Nt(je)===Qe&&Vt(je,ae.q.scope)).map(je=>({scope:je,label:p.get(je)?.label??Ls(je),kind:Cs(je),depth:ae.q.depth,children:0,count:0}));ae.on({timeline:1,type:"batch",events:fe,metrics:Ke,...lt.length?{rows:lt}:{},now:c,resume:String(ye)})}},setRetention(S,Y){x.set(S,{events:Y.events,rollups:{...Y.rollups},setBy:"user"})},get now(){return c},get size(){let S=0;for(let Y of R.values())S+=Y.fine.length;return{events:y.length,samples:S}}}}var Zc="http://www.w3.org/2000/svg",ds=22,di=38,Nn=26,Yu=210,Hu=24,wr=6e4,ps=36e5,Yt=864e5,ef={"15m":15*wr,"1h":ps,"1d":Yt,"1w":7*Yt},tf=t=>jt.indexOf(t),Wu={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},nt=(t,e,n)=>{let s=document.createElementNS(Zc,t);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(n){let r=document.createElementNS(Zc,"title");r.textContent=n,s.append(r)}return s},Lt=(t,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(t)}catch{return new Date(t).toISOString()}},Va=t=>t<1e3?`${Math.round(t)} ms`:t<wr?`${(t/1e3).toFixed(1)} s`:fs(t),Ju=(t,e)=>e==="bytes"?t>=1e9?`${(t/1e9).toFixed(1)} GB`:t>=1e6?`${(t/1e6).toFixed(1)} MB`:t>=1e3?`${(t/1e3).toFixed(1)} kB`:`${Math.round(t)} B`:`${Math.round(t*10)/10}${e==="count"?"":` ${e}`}`;function Ka(t,e){if(t<=3*ps)return{kind:"single"};for(let n of["1m","1h","1d"])if(t/tn[n]<=e/2)return{kind:"binned",bin:n};return{kind:"binned",bin:"1d"}}function Ga(t,e,n){let s=[];for(let i of t.events??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);for(let i of t.spans??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);let r=e.kind==="binned"?tn[e.bin]:wr;for(let i of t.bins??[])i.count&&s.push([i.t,i.t+tn[i.bin]]);let o=new Map;for(let i of t.metrics){let a="value"in i?i.value:i.sum,l=`${i.series}|${i.scope}`,c=(n?.get(i.series)??"counter")==="counter"?a!==0:o.get(l)!==a;o.set(l,a),c&&s.push([i.t,i.t+r])}return s}function nf(t,e){let n=e.tz??Intl.DateTimeFormat().resolvedOptions().timeZone,s=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,r=e.motion??!s;t.classList.add(...e.rootClass??[],"tlx");let{parseSearch:o,compileSearch:i}=Fs(e.catalog),a=(C="system")=>{t.style.colorScheme=C==="system"?"light dark":C,C==="system"?delete t.dataset.theme:t.dataset.theme=C};a(e.theme),t.setAttribute("role","region"),t.setAttribute("aria-label","Timeline");let l,c="",f=1,u="",d={},p=!1,h=e.collapseGaps??!0,m={t0:0,t1:Yt},y,I="",N={from:0,to:0,mode:{kind:"single"},key:""},M,$,R,E,w=!0,T=0,L=0,x=!1,P,b=[],v=[],g=-1,O=new Set,F=new Map,j=[],U=Bs(0,Yt,800),ne=new Map,B=[],K=Q("nav",{class:"tlx-crumbs","aria-label":"Scope"}),q=Q("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let C of["15m","1h","1d","1w","run"]){let G=Q("button",{type:"button",class:"seg","data-v":C,title:C==="run"?"The latest run":`The last ${C}`},C==="run"?"this run":C);G.addEventListener("click",()=>Zn(C)),q.append(G)}let Z=Q("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),A=Q("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),D=Q("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),V=Q("input",{type:"checkbox",class:"tlx-gaps"});V.checked=h;let W=!0,ie=Q("input",{type:"checkbox",class:"tlx-quiet"});ie.checked=W;let de=Q("input",{type:"search",class:"input tlx-q",placeholder:"Search: words, kind:\u2026, source:\u2026, severity:>=warning, -kind:\u2026","aria-label":"Search the timeline",spellcheck:"false"}),X=Q("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),te=Q("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),ye=Q("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Fe=Q("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),S=Q("select",{class:"input tlx-sev","aria-label":"Severity"},Q("option",{value:""},"every severity"),...jt.slice(1).map(C=>Q("option",{value:C},`${C} and above`))),Y=Q("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},Q("option",{value:""},"Saved views\u2026")),se=Q("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),le=Q("div",{class:"tlx-warn",role:"status",hidden:!0}),Pe=Q("div",{class:"tlx-status",role:"status"}),ae=Q("span",{class:"tlx-canvas-note"}),Be=Q("div",{class:"tlx-labels"}),xe=Q("div",{class:"tlx-lanes",tabindex:"0",role:"application","aria-label":"Timeline lanes: drag to pan, wheel to zoom, drag the axis to choose a range, click it to move the playhead. Keys: \u2190 \u2192 pan, + \u2212 zoom, N next hit"}),fe=nt("svg",{class:"tlx-svg"});xe.append(fe);let Se=Q("div",{class:"tlx-scroll"},Q("div",{class:"tlx-grid"},Be,xe)),Ke=Q("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),Te=Q("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});t.replaceChildren(Q("div",{class:"tlx-bar"},K,Q("span",{class:"spacer"}),q,Z,A,D,Q("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},V,"Collapse gaps"),Q("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},ie,"Hide quiet rows")),Q("div",{class:"tlx-bar"},de,X,te,ye,S,Y,se),Fe,le,Q("div",{class:"tlx-body"},Se,Te),Q("div",{class:"tlx-foot"},Pe,Q("span",{class:"spacer"}),ae),Ke);let Qe=()=>Math.max(200,xe.clientWidth||800),lt=()=>{let C=(ue,Re)=>(ue.own?-1:0)-(Re.own?-1:0)||ue.scope.localeCompare(Re.scope,void 0,{numeric:!0}),J=(y?.rows??[]).filter(ue=>!W||ue.count>0||ue.own||(y?.rows.length??0)<=1).sort(C).map(ue=>({kind:"row",row:ue})),ee=new Set(y?.metrics.map(ue=>ue.series)??[]);for(let ue of[...ee].sort()){let Re=ne.get(ue);J.push({kind:"metric",series:ue,unit:Re?.unit??"count",type:Re?.type??"counter",title:Re?.title??ue})}return J},je=(C,G)=>l?.names?.find(J=>J.scope===C)?.label??G,st=C=>C.kind==="metric"?di:ds,Ye=()=>Ka(m.t1-m.t0,Qe()),rt=()=>l?.now??Date.now();function ce(){return{timeline:1,type:"view",name:"",scope:c,depth:f,range:{from:Math.round(m.t0),to:Math.round(m.t1)},...u?{q:u}:{},...Object.keys(d).length?{filters:d}:{},...p?{live:p}:{},...h?{}:{collapseGaps:!1},...W?{}:{quietRows:!0}}}function Oe(C){C.scope!==void 0&&(c=C.scope),C.depth!==void 0&&(f=C.depth),u=C.q??"",de.value=u,d=C.filters??{},S.value=d.severity?.length?d.severity[0]:"",h=C.collapseGaps??e.collapseGaps??!0,V.checked=h,W=!C.quietRows,ie.checked=W,O.clear(),F.clear();let G=C.range;G&&"last"in G?Zn(G.last,!1):G&&(m={t0:G.from,t1:G.to}),ht(!!C.live,!1)}let Ee=()=>{let C=ce();if(e.onViewChange?.(C),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(C))}`)}catch{}},tt=()=>{if(!e.urlState)return;let C=/#timeline=(.+)$/.exec(location.hash);if(C)try{return JSON.parse(decodeURIComponent(C[1]))}catch{return}};function k(C,G,J,ee={}){let ue=i(u,rt(),C,G);b=ue.warnings;let Re=u?[]:d.source?[...ne].filter(([,Ue])=>d.source.includes(Ue.source)).map(([Ue])=>Ue):void 0;return{timeline:1,type:"query",scope:c,depth:f,from:ue.from,to:ue.to,tz:n,...J.kind==="binned"?{bin:J.bin}:{},...u?{q:u,where:ue.where}:{},...Object.keys(d).length?{filters:d}:{},...Re?{series:Re}:{},...ee}}let _=()=>JSON.stringify([c,f,u,d,Ye()]);async function z(C=!1){let G=Ye(),J=_(),ee=m.t1-m.t0;if(!C&&y&&J===N.key&&m.t0>=N.from&&m.t1<=N.to){re();return}if(L){x=!0;return}L++;let ue=m.t0-ee/2,Re=Math.min(m.t1+ee/2,Math.max(m.t1,rt()+ee*.1));try{let Ue=await e.source.query(k(ue,Re,G,G.kind==="single"?{limit:1e4}:{}));G.kind==="single"&&Ue.next&&(Ue=await e.source.query(k(ue,Re,{kind:"binned",bin:"1m"}))),y=Ue,I=J,N={from:ue,to:Re,mode:G,key:J}}catch(Ue){Pe.textContent=`The history couldn't be read: ${String(Ue?.message??Ue)}`}finally{L--}re(),Ee(),x&&(x=!1,z())}function oe(){let C=Qe(),G=Ye();if(j=[],h&&y){let J=new Map([...ne].map(([ee,ue])=>[ee,ue.type]));j=ai(Ga(y,G,J),m.t0,Math.min(m.t1,Math.max(m.t0,rt())),{minFrac:.15,minMs:10*wr}),G.kind==="binned"&&(j=j.filter(ee=>ee.to-ee.from>=2*tn[G.bin])),j=j.filter(ee=>!(O.has(us(ee))&&(F.get(us(ee))??1)>=1))}U=Bs(m.t0,m.t1,C,j,{cut:Hu,weights:F})}let re=()=>{T||(T=requestAnimationFrame(ke))};function ke(){T=0,oe();let C=Qe(),G=lt(),J=N.mode,ee=[],ue=Nn;for(let H of G)ee.push(ue),ue+=st(H);let Re=Math.max(ue,Nn+ds);fe.setAttribute("width",String(C)),fe.setAttribute("height",String(Re)),fe.setAttribute("viewBox",`0 0 ${C} ${Re}`);let Ue=Se.scrollTop-200,gn=Se.scrollTop+(Se.clientHeight||600)+200,Me=[],ve=U.x;Me.push(nt("rect",{class:"tlx-axis",x:0,y:0,width:C,height:Nn}));let Pt=(y?.retention??[]).map(H=>({r:H,from:J.kind==="binned"?H.keptFrom.rollups[J.bin]??H.keptFrom.events:H.keptFrom.events,days:J.kind==="binned"?H.rollups[J.bin]:H.events})).filter(H=>H.from!==void 0);if(Pt.length){let H=Math.min(...Pt.map(pe=>pe.from));H>m.t0&&Me.push(nt("rect",{class:"tlx-notkept",x:Math.max(0,ve(m.t0)),y:Nn,width:Math.max(0,ve(H)-Math.max(0,ve(m.t0))),height:Re-Nn},`Nothing kept before ${Lt(H,n)}: ${Pt.map(pe=>`${pe.r.source} ${pe.days===null?"kept until deleted":`kept ${pe.days} days`}`).join(", ")}`))}let Kt=rt();Kt<m.t1&&Me.push(nt("rect",{class:"tlx-future",x:ve(Kt),y:Nn,width:C-ve(Kt),height:Re-Nn}));for(let H of li(U,n,90)){Me.push(nt("line",{class:`tlx-tick${H.major?" major":""}`,x1:H.x,x2:H.x,y1:Nn-6,y2:Re}));let pe=nt("text",{class:"tlx-ticklabel",x:H.x+3,y:16});pe.textContent=H.label,Me.push(pe)}E&&Me.push(nt("rect",{class:"tlx-brush",x:ve(E.from),y:0,width:Math.max(1,ve(E.to)-ve(E.from)),height:Re}));let Sr=J.kind==="single"?(y?.events??[]).filter(H=>H.dur!==void 0||H.open):y?.spans??[],hf=J.kind==="single"?(y?.events??[]).filter(H=>H.dur===void 0&&!H.open):[],qa=new Map;G.forEach((H,pe)=>{H.kind==="row"&&qa.set(H.row.scope,pe)});let Mr=H=>{let pe=Nt(c)+f,_e=Nt(H)>=pe?Bn(H,pe):H;return qa.get(_e)},_s=H=>ee[H]+st(G[H])>=Ue&&ee[H]<=gn;if(G.forEach((H,pe)=>{_s(pe)&&Me.push(nt("rect",{class:`tlx-lane${pe%2?" odd":""}${H.kind==="metric"?" metric":""}`,x:0,y:ee[pe],width:C,height:st(H)}))}),J.kind==="binned"){let H=new Map;for(let pe of y?.bins??[]){let _e=Mr(pe.scope);_e!==void 0&&H.set(_e,Math.max(H.get(_e)??0,pe.count))}for(let pe of y?.bins??[]){let _e=Mr(pe.scope);if(_e===void 0||!_s(_e))continue;let qe=ve(pe.t),Ve=ve(pe.t+tn[pe.bin]);if(Ve<0||qe>C)continue;let ft=[...jt].reverse().find(Ht=>(pe.severity[Ht]??0)>0)??"info",Tt=Math.max(2,(ds-8)*Math.sqrt(pe.count)/Math.sqrt(H.get(_e)||1));Me.push(nt("rect",{class:"tlx-countbar",x:qe,y:ee[_e]+ds-3-Tt,width:Math.max(1,Ve-qe-.5),height:Tt,"data-t":pe.t},`${Lt(pe.t,n)}: ${pe.count} event${pe.count===1?"":"s"}${ft!=="info"&&ft!=="debug"?`, the worst ${ft}`:""}`)),(ft==="warning"||ft==="error")&&Me.push(nt("rect",{class:`tlx-heat sev-${ft}`,x:qe,y:ee[_e]+ds-(ft==="error"?4:3),width:Math.max(1,Ve-qe-.5),height:ft==="error"?3:2}))}}for(let H of Sr){let pe=Mr(H.scope);if(pe===void 0||!_s(pe))continue;let _e=H.open?Kt:H.t+(H.dur??0),qe=ve(H.t),Ve=ve(_e);if(Ve<-2||qe>C+2)continue;let ft=`tlx-span sev-${H.severity}${H.open?" open":""}${R?.id===H.id?" selected":""}`,Tt=`${H.summary} \xB7 ${Lt(H.t,n)}${H.open?", still going":`, ${Va(_e-H.t)}`}`,Ht=ee[pe]+5,Dn=J.kind==="binned"?4:8,Wt=qe;for(let on of U.cuts)on.weight>=1||on.x1<=qe||on.x0>=Ve||(on.x0>Wt&&Me.push(nt("rect",{class:ft,x:Wt,y:Ht,width:Math.max(1,on.x0-Wt),height:Dn,rx:2,"data-id":H.id},Tt)),Me.push(nt("path",{class:`${ft} through`,d:`M${on.x0} ${Ht+Dn/2} H${on.x1}`,"data-id":H.id},`${Tt} (lasted through the break)`)),Wt=on.x1);Ve>Wt&&Me.push(nt("rect",{class:ft,x:Math.max(-2,Wt),y:Ht,width:Math.max(2,Math.min(C+2,Ve)-Math.max(-2,Wt)),height:Dn,rx:2,"data-id":H.id},Tt))}let Ya=new Map;for(let H of hf){let pe=Mr(H.scope);if(pe===void 0||!_s(pe))continue;let _e=ve(H.t);if(_e<-6||_e>C+6||_e-(Ya.get(pe)??-1/0)<3)continue;Ya.set(pe,_e);let qe=ee[pe]+ds/2+2,Ve=4,ft=Wu[H.severity],Tt=ft==="diamond"?`M${_e} ${qe-Ve-1} l${Ve+1} ${Ve+1} l${-Ve-1} ${Ve+1} l${-Ve-1} ${-Ve-1} z`:ft==="triangle"?`M${_e} ${qe-Ve-1} l${Ve+1} ${2*Ve+1} h${-2*Ve-2} z`:ft==="square"?`M${_e-Ve+.5} ${qe-Ve+.5} h${2*Ve-1} v${2*Ve-1} h${-2*Ve+1} z`:"",Ht=`${Lt(H.t,n)} \xB7 ${H.summary}`,Dn=`tlx-mark sev-${H.severity}${R?.id===H.id?" selected":""}${g>=0&&v[g]?.id===H.id?" hit":""}`;Me.push(Tt?nt("path",{class:Dn,d:Tt,"data-id":H.id},Ht):nt("circle",{class:Dn,cx:_e,cy:qe,r:ft==="dot"?2.5:Ve,"data-id":H.id},Ht))}G.forEach((H,pe)=>{if(H.kind!=="metric"||!_s(pe))return;let _e=new Map;for(let Je of y?.metrics??[]){if(Je.series!==H.series)continue;let At="value"in Je?{min:Je.value,max:Je.value,sum:Je.value,count:1}:{min:Je.min,max:Je.max,sum:Je.sum,count:Je.count},vt=_e.get(Je.t);vt?(vt.min=Math.min(vt.min,At.min),vt.max=Math.max(vt.max,At.max),vt.sum+=At.sum,vt.count+=At.count):_e.set(Je.t,{...At})}let qe=[..._e].sort((Je,At)=>Je[0]-At[0]);if(!qe.length)return;let Ve=J.kind==="binned"?tn[J.bin]:wr,ft=Je=>H.type==="gauge"?Je.sum/Math.max(1,Je.count):Je.sum,Tt=Math.max(1e-9,...qe.map(([,Je])=>H.type==="gauge"?Je.max:ft(Je))),Ht=ee[pe]+di-4,Dn=di-10,Wt=Je=>Ht-Je/Tt*Dn;if(H.type==="gauge"){let Je=qe.map(([At,vt])=>`${ve(At)},${Wt(vt.max)}`).join(" ")+" "+[...qe].reverse().map(([At,vt])=>`${ve(At)},${Wt(vt.min)}`).join(" ");Me.push(nt("polygon",{class:"tlx-band",points:Je})),Me.push(nt("polyline",{class:"tlx-line",points:qe.map(([At,vt])=>`${ve(At+Ve/2)},${Wt(ft(vt))}`).join(" ")}))}else{let Je="",At=-1/0;for(let[vt,gf]of qe){let bf=ve(vt),Ha=ve(vt+Ve),Wa=Wt(ft(gf));Je+=vt>At?`M${bf} ${Ht} V${Wa} H${Ha}`:` V${Wa} H${Ha}`,At=vt+Ve;let Ja=qe.find(([yf])=>yf>vt);(!Ja||Ja[0]>At)&&(Je+=` V${Ht} Z`)}Me.push(nt("path",{class:"tlx-area",d:Je}))}let on=nt("text",{class:"tlx-peak",x:4,y:ee[pe]+11});on.textContent=`peak ${Ju(Tt,H.unit)}${H.type==="counter"?` per ${J.kind==="binned"?J.bin:"1m"}`:""}`,Me.push(on)});for(let H of U.cuts){if(H.weight>=1)continue;let pe=Ve=>{let ft=`M${Ve} 0`;for(let Tt=0;Tt<Re;Tt+=8)ft+=` L${Ve+(Tt/8%2?-3:3)} ${Tt+8}`;return ft},_e=nt("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":H.from,"data-to":H.to,"aria-label":`A break of ${fs(H.to-H.from)} with nothing shown, from ${Lt(H.from,n)} to ${Lt(H.to,n)}: press to open it`},`${fs(H.to-H.from)} with nothing here: ${Lt(H.from,n)} to ${Lt(H.to,n)} (click to open)`);_e.append(nt("rect",{class:"tlx-cut-bg",x:H.x0,y:0,width:H.x1-H.x0,height:Re})),_e.append(nt("path",{class:"tlx-cut-edge",d:pe(H.x0+3)}),nt("path",{class:"tlx-cut-edge",d:pe(H.x1-3)}));let qe=nt("text",{class:"tlx-cut-label",x:(H.x0+H.x1)/2,y:15,"text-anchor":"middle"});qe.textContent=fs(H.to-H.from),_e.append(qe),Me.push(_e)}if(M!==void 0){let H=ve(M);Me.push(nt("line",{class:"tlx-playhead",x1:H,x2:H,y1:0,y2:Re})),Me.push(nt("path",{class:"tlx-handle",d:`M${H-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${Lt(M,n)}`))}fe.replaceChildren(...Me),Be.replaceChildren(Q("div",{class:"tlx-labelhead",style:`height:${Nn}px`},Ye().kind==="single"?"single events":`per ${Ye().kind==="binned"?Ye().bin:""}`),...G.map(H=>{if(H.kind==="metric")return Q("div",{class:"tlx-rowlabel metric",style:`height:${di}px`,title:`${H.title} (${H.type==="counter"?"sums":"min, max and mean"})`},H.title);let pe=H.row,_e=Q("div",{class:`tlx-rowlabel${pe.own?" own":""}`,style:`height:${ds}px`,"data-scope":pe.scope,title:`${pe.scope||"all hosts"} \xB7 ${pe.count} event${pe.count===1?"":"s"}`},Q("span",{class:"tlx-kind"},e.catalog.flags.find(qe=>pe[qe])??pe.kind),Q("span",{class:"tlx-name"},pe.own?`${pe.label} (itself)`:pe.label),Q("span",{class:"tlx-count"},String(pe.count)));if(!pe.own&&pe.scope!==c){let qe=Q("button",{type:"button",class:"tlx-drill",title:pe.children?`Into ${pe.label}: its ${pe.children} part${pe.children===1?"":"s"}`:`Into ${pe.label}`,"aria-label":`Into ${pe.label}`},"\u203A");qe.addEventListener("click",()=>We(pe.scope)),_e.append(qe)}return _e})),Be.style.width=`${Yu}px`,he()}function he(){K.replaceChildren(...Is(c).flatMap((ee,ue,Re)=>{let Ue=Q("button",{type:"button",class:`tlx-crumb${ue===Re.length-1?" current":""}`,"aria-current":ue===Re.length-1?"location":void 0},je(ee.scope,ee.label));return Ue.addEventListener("click",()=>{ee.scope!==c&&(c=ee.scope,f=1,z(!0))}),ue?[Q("span",{class:"tlx-sep","aria-hidden":"true"},"/"),Ue]:[Ue]})),Z.setAttribute("aria-pressed",String(p)),Z.classList.toggle("on",p),A.hidden=!p||w;let C=Ye(),G=y?.total??0,J=(y?.retention??[]).filter(ee=>ee.events!==null).map(ee=>`${ee.source} kept ${ee.events} d`);Pe.textContent=`${Lt(m.t0,n)} \u2013 ${Lt(m.t1,n)} \xB7 ${C.kind==="single"?"single events":`bins of ${C.bin}`} \xB7 ${G} event${G===1?"":"s"}${j.length?` \xB7 ${j.length} break${j.length===1?"":"s"}`:""}${J.length?` \xB7 ${J.slice(0,3).join(", ")}`:""}`,le.hidden=!b.length,le.textContent=b.join(" \xB7 "),X.textContent=u?v.length?`${g+1>0?`${g+1} of `:""}${v.length}${v.length>=2e3?"+":""} hit${v.length===1?"":"s"}`:`${G?`${G} hit${G===1?"":"s"}`:"no hits"}`:"";for(let ee of q.querySelectorAll(".seg"))ee.classList.remove("on");ae.textContent=M===void 0?"":$?(()=>{let ee=e.stamp?.($)??{};return`Canvas: the state recorded at ${Lt(Date.parse(ee.at??"")||M,n)}${ee.tag?` (${ee.tag})`:""}`})():"No state recorded here",ae.classList.toggle("none",M!==void 0&&!$)}function He(){Fe.replaceChildren();for(let C of l?.sources??[]){let G=!d.source?.length||d.source.includes(C.name),J=Q("button",{type:"button",class:`tlx-chip${G?" on":""}${C.status==="not-yet"?" notyet":""}`,"aria-pressed":String(G&&C.status!=="not-yet"),disabled:C.status==="not-yet",title:C.status==="not-yet"?`${C.title}: not kept yet`:`${C.title}${$e(C)}`},C.name);C.status!=="not-yet"&&J.addEventListener("click",()=>be(C.name)),Fe.append(J)}}let $e=C=>{let G=l?.retention.find(J=>J.source===C.name);return G?` (kept ${G.events===null?"until deleted":`${G.events} days`})`:""};function be(C){let G=(l?.sources??[]).filter(ee=>ee.status==="kept").map(ee=>ee.name),J=d.source?.length?[...d.source]:[...G];J=J.includes(C)?J.filter(ee=>ee!==C):[...J,C],d={...d,...J.length===G.length?{source:void 0}:{source:J}},d.source||delete d.source,He(),z(!0),Ie()}let Ae=0;de.addEventListener("input",()=>{clearTimeout(Ae),Ae=setTimeout(()=>{u=de.value.trim(),g=-1,z(!0),Ie()},250)}),de.addEventListener("keydown",C=>{C.key==="Enter"&&(C.preventDefault(),clearTimeout(Ae),u=de.value.trim(),z(!0).then(()=>Ie()).then(()=>ot(C.shiftKey?-1:1)))});async function Ie(){if(!u){v=[],g=-1,he();return}let C=m.t1-m.t0;v=(await e.source.query(k(m.t0-C*4,Math.max(m.t1+C*4,rt()),{kind:"single"},{limit:2e3}))).events??[],g=Math.min(g,v.length-1),he()}function ot(C){if(!v.length)return;let G=(m.t0+m.t1)/2;g<0?g=C>0?Math.max(0,v.findIndex(ue=>ue.t>=G)):Math.max(0,v.length-1-[...v].reverse().findIndex(ue=>ue.t<=G)):g=(g+C+v.length)%v.length;let J=v[g],ee=Math.min(m.t1-m.t0,2*ps);m={t0:J.t-ee/2,t1:J.t+ee/2},w=!1,ct(J),z()}te.addEventListener("click",()=>ot(-1)),ye.addEventListener("click",()=>ot(1)),S.addEventListener("change",()=>{let C=S.value;d={...d,...C?{severity:jt.filter(G=>tf(G)>=tf(C))}:{}},C||delete d.severity,z(!0),Ie()});async function Zn(C,G=!0){let J=rt();if(C==="run"){let ee=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:J-30*Yt,to:J+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),ue=ee?.events?.[ee.events.length-1];m=ue?{t0:ue.t-(ue.dur??ps)*.02,t1:(ue.open?J:ue.t+(ue.dur??ps))+(ue.dur??ps)*.04}:{t0:J-Yt,t1:J+Yt*.02}}else m={t0:J-ef[C],t1:J+ef[C]*.02};w=!0,O.clear(),F.clear(),G&&z()}function ht(C,G=!0){if(p=C,P?.(),P=void 0,C&&e.source.subscribe){let J=0,ee=0;P=e.source.subscribe(k(rt()-ps,rt()+365*Yt,{kind:"single"}),ue=>{if(l&&(l.now=Math.max(l.now,ue.now)),w){let Ue=m.t1-m.t0;m={t0:ue.now-Ue*.98,t1:ue.now+Ue*.02}}let Re=Date.now();Re-J>500?(J=Re,z(!0)):ee||(ee=setTimeout(()=>{ee=0,J=Date.now(),z(!0)},500))}),w=!0}G&&(he(),Ee())}Z.addEventListener("click",()=>ht(!p)),A.addEventListener("click",()=>{w=!0;let C=m.t1-m.t0,G=rt();m={t0:G-C*.98,t1:G+C*.02},z()}),D.addEventListener("click",()=>{Ze()}),V.addEventListener("change",()=>{h=V.checked,O.clear(),F.clear(),re(),Ee()}),ie.addEventListener("change",()=>{W=ie.checked,re(),Ee()});function We(C){let G=y?.rows.find(J=>J.scope===C);c=C,f=G&&G.children===0?0:1,E=void 0,Ke.hidden=!0,z(!0)}async function Ze(){let C=rt(),J=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:C-400*Yt,to:C+1,bin:"1d",tz:n}).catch(()=>{}))?.bins??[]).map(ue=>ue.t),ee=J.length?Math.min(...J):C-7*Yt;m={t0:ee,t1:C+(C-ee)*.02},w=!0,z()}let sn=0;async function Mt(C){if(M=C,re(),C===void 0){$=void 0;return}let G=++sn,J=e.source.stateAt?await e.source.stateAt(c,C).catch(()=>{}):void 0;G===sn&&($=J,e.onPlayhead?.(C,J),he())}async function wt(C,G){E={from:Math.min(C,G),to:Math.max(C,G)},re();let J=await e.source.query(k(E.from,E.to,{kind:"single"},{limit:500})),ee=o(u),ue=Me=>{let ve=[],bt=0;for(let[Pt,Kt]of xr(ee,Me))ve.push(Me.slice(bt,Pt),Q("mark",null,Me.slice(Pt,Kt))),bt=Kt;return ve.push(Me.slice(bt)),ve},Re=(J.events??[]).map(Me=>{let ve=Q("tr",{"data-id":Me.id,tabindex:"0"},Q("td",null,Lt(Me.t,n)),Q("td",null,Me.dur!==void 0?Va(Me.dur):Me.open?"still going":""),Q("td",null,Me.source),Q("td",null,Me.kind),Q("td",{class:`sev-${Me.severity}`},Me.severity),Q("td",{class:"tlx-sum"},...ue(Me.summary)),Q("td",{class:"tlx-scope"},Me.scope));return ve.addEventListener("click",()=>ct(Me)),ve.addEventListener("keydown",bt=>{bt.key==="Enter"&&ct(Me)}),ve}),Ue=Q("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");Ue.addEventListener("click",()=>{E=void 0,Ke.hidden=!0,re()});let gn=Me=>{let ve=Q("button",{type:"button",class:"btn sm","data-export":Me},Me.toUpperCase());return ve.addEventListener("click",()=>{$t(Me)}),ve};Ke.replaceChildren(Q("div",{class:"tlx-table-head"},Q("strong",null,`${J.total} event${J.total===1?"":"s"}`),Q("span",null,` ${Lt(E.from,n)} \u2013 ${Lt(E.to,n)}${J.total>500?" (the first 500 shown; the export has them all)":""}`),Q("span",{class:"spacer"}),Q("span",null,"Export: "),gn("json"),gn("csv"),Ue),Q("div",{class:"tlx-table-wrap"},Q("table",null,Q("thead",null,Q("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(Me=>Q("th",{scope:"col"},Me)))),Q("tbody",null,...Re)))),Ke.hidden=!1}async function kt(){if(!E)return[];let C=[],G;do{let J=await e.source.query(k(E.from,E.to,{kind:"single"},{limit:1e4,...G?{cursor:G}:{}}));C.push(...J.events??[]),G=J.next}while(G&&C.length<2e5);return C}async function $t(C){let G=await kt(),J=C==="json"?ci(G,B):fi(G,B),ee=`timeline-${new Date(E.from).toISOString().slice(0,16).replace(/:/g,"")}.${C}`,ue=C==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(ee,J,ue);return}let Re=Q("a",{href:`data:${ue};charset=utf-8,${encodeURIComponent(J)}`,download:ee});document.body.append(Re),Re.click(),Re.remove()}function ct(C){if(R=C,re(),!C){Te.hidden=!0;return}let G=l?.sources.find(ve=>ve.name===C.source),J=new Set(G?.sensitive??[]),ee=o(u),ue=ve=>{let bt=[],Pt=0;for(let[Kt,Sr]of xr(ee,ve))bt.push(ve.slice(Pt,Kt),Q("mark",null,ve.slice(Kt,Sr))),Pt=Sr;return bt.push(ve.slice(Pt)),bt},Re=(ve,bt)=>{if(!bt)return null;let Pt=Q("button",{type:"button",class:"btn sm"},ve);return Pt.addEventListener("click",bt),Pt},Ue=Object.entries(C.attrs).map(([ve,bt])=>{if(!J.has(ve))return Q("tr",null,Q("th",{scope:"row"},ve),Q("td",null,...ue(String(bt))));let Pt=Q("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),Kt=Q("td",{class:"tlx-sensitive"},"hidden ",Pt);return Pt.addEventListener("click",()=>Kt.replaceChildren(String(bt))),Q("tr",null,Q("th",{scope:"row"},ve),Kt)}),gn=Q("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");gn.addEventListener("click",()=>ct(void 0));let Me=Is(C.scope).slice(1).map(ve=>{let bt=Q("button",{type:"button",class:"tlx-crumb"},je(ve.scope,ve.label));return bt.addEventListener("click",()=>We(ve.scope)),bt});Te.replaceChildren(Q("div",{class:"tlx-detail-head"},Q("strong",null,C.kind),gn),Q("p",{class:`tlx-sev sev-${C.severity}`},`${C.severity} \xB7 ${G?.title??C.source}`),Q("p",{class:"tlx-sum"},...ue(C.summary)),Q("p",null,Lt(C.t,n),C.dur!==void 0?` \xB7 ${Va(C.dur)}${C.open?" so far":""}`:C.open?" \xB7 still going":""),Q("p",{class:"tlx-crumbs small"},...Me),...Ue.length?[Q("table",{class:"tlx-attrs"},Q("tbody",null,...Ue))]:[],Q("div",{class:"tlx-links"},...(e.actions?.(C)??[]).map(([ve,bt])=>Re(ve,bt)))),Te.hidden=!1}function ms(C,G){let J=us({from:C,to:G});if(!j.find(Ue=>Ue.from===C&&Ue.to===G))return;if(O.add(J),!r){F.set(J,1),re();return}let ue=performance.now(),Re=Ue=>{let gn=Math.min(1,(Ue-ue)/260);F.set(J,1-(1-gn)**3),ke(),gn<1&&requestAnimationFrame(Re)};requestAnimationFrame(Re)}let Et,es=C=>C.clientX-fe.getBoundingClientRect().left;fe.addEventListener("pointerdown",C=>{let G=es(C),J=C.clientY-fe.getBoundingClientRect().top,ee=C.target.closest?.(".tlx-cut");if(ee){C.preventDefault(),ms(Number(ee.getAttribute("data-from")),Number(ee.getAttribute("data-to")));return}fe.setPointerCapture(C.pointerId),Et={kind:J<Nn||C.shiftKey?"brush":C.target.classList.contains("tlx-handle")?"scrub":"pan",x0:G,t0:U.t(G),v0:m,moved:!1},C.preventDefault(),xe.focus({preventScroll:!0})}),fe.addEventListener("pointermove",C=>{if(!Et)return;let G=es(C);if(Math.abs(G-Et.x0)>3&&(Et.moved=!0),!!Et.moved)if(Et.kind==="pan"){let J=(Et.x0-G)*U.msPerPx;m={t0:Et.v0.t0+J,t1:Et.v0.t1+J},w=!1,z()}else Et.kind==="scrub"?Mt(U.t(G)):(E={from:Math.min(Et.t0,U.t(G)),to:Math.max(Et.t0,U.t(G))},re())}),fe.addEventListener("pointerup",C=>{let G=Et;if(Et=void 0,!G)return;let J=es(C);if(G.kind==="brush"&&G.moved){wt(G.t0,U.t(J));return}if(G.kind==="brush"&&!G.moved){Mt(U.t(J));return}if(G.kind==="pan"&&!G.moved){let ee=C.target.closest?.("[data-id]")?.getAttribute("data-id"),ue=ee?[...y?.events??[],...y?.spans??[]].find(Re=>Re.id===ee):void 0;ue?(ct(ue),Mt(ue.t)):Mt(U.t(J))}}),fe.addEventListener("keydown",C=>{let G=C.target.closest?.(".tlx-cut");G&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),ms(Number(G.getAttribute("data-from")),Number(G.getAttribute("data-to"))))}),fe.addEventListener("wheel",C=>{C.preventDefault();let G=es(C);if(C.shiftKey||Math.abs(C.deltaX)>Math.abs(C.deltaY)){let J=(C.shiftKey?C.deltaY:C.deltaX)*U.msPerPx;m={t0:m.t0+J,t1:m.t1+J},w=!1}else hs(U.t(G),Math.exp(C.deltaY*.0015),G/Qe());z()},{passive:!1});function hs(C,G,J=.5){let ee=Math.min(400*Yt,Math.max(1e4,(m.t1-m.t0)*G));m={t0:C-J*ee,t1:C+(1-J)*ee},O.clear(),F.clear(),G<1&&(w=p&&m.t1>=rt())}xe.addEventListener("keydown",C=>{let G=m.t1-m.t0;if(C.key==="ArrowLeft"||C.key==="ArrowRight"){let J=G*.15*(C.key==="ArrowLeft"?-1:1);m={t0:m.t0+J,t1:m.t1+J},w=!1}else if(C.key==="+"||C.key==="=")hs((m.t0+m.t1)/2,.6);else if(C.key==="-"||C.key==="_")hs((m.t0+m.t1)/2,1/.6);else if(C.key==="n"||C.key==="N"){ot(C.shiftKey?-1:1),C.preventDefault();return}else if(C.key==="Escape")ct(void 0),E=void 0,Ke.hidden=!0;else return;C.preventDefault(),z()}),t.addEventListener("keydown",C=>{C.key==="/"&&document.activeElement!==de&&!C.target.closest("input, select, textarea")&&(C.preventDefault(),de.focus())}),Se.addEventListener("scroll",()=>re(),{passive:!0}),se.addEventListener("click",async()=>{let C=`${Is(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...ce(),name:C}),await rn()});let Ce=[];async function rn(){e.views&&(Ce=await e.views(),Y.replaceChildren(Q("option",{value:""},"Saved views\u2026"),...Ce.map((C,G)=>Q("option",{value:String(G)},C.name))))}Y.addEventListener("change",()=>{let C=Ce[Number(Y.value)];C&&(Oe(C),He(),z(!0)),Y.value=""});let et=typeof ResizeObserver=="function"?new ResizeObserver(()=>re()):void 0;et?.observe(xe);let Bt=(async()=>{l=await e.source.catalog(),B=l.sources.flatMap(ee=>(ee.sensitive??[]).map(ue=>`${ee.name}.${ue}`));for(let ee of l.sources)for(let ue of ee.series)ne.set(ue.name,{unit:ue.unit,type:ue.type,title:ue.title,source:ee.name});c=l.hosts.length===1?`host:${l.hosts[0].replace(/[%/:\s]/g,ee=>`%${ee.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let G=l.now;m={t0:G-Yt,t1:G+Yt*.02};let J=tt()??e.view;J&&Oe(J),He(),await rn(),await z(!0),u&&await Ie()})();return{el:t,ready:Bt,get view(){return ce()},setView(C){return Oe(C),He(),z(!0)},setRange(C,G){return m={t0:C,t1:G},w=!1,z()},setPlayhead:Mt,setLive:ht,setTheme:a,refresh:()=>z(!0),internal:{get result(){return y},get mode(){return Ye()},get scale(){return U},get gaps(){return j},get playState(){return $},get hits(){return v},get selected(){return R},get follow(){return w},openCut:ms,showTable:wt,rangeEvents:kt,exportRange:$t,select:ct,stepHit:ot,drill:We,findHits:Ie,paint:ke,lines:lt},dispose(){P?.(),et?.disconnect(),T&&cancelAnimationFrame(T),t.replaceChildren()}}}var Xu={arrow:{d:"M0,0 L10,5 L0,10 z",refX:9},open:{d:"M0,0 L10,5 L0,10 L3,5 z",refX:9},diamond:{d:"M0,5 L5,1.5 L10,5 L5,8.5 z",refX:1}},It=t=>(Math.round(t*10)/10).toString(),sf=t=>(t??"link").replace(/[^\w-]/g,"_");function pi(t,e){let{id:n}=e,s=e.styles??{},r=t.options,o=t.bounds,i=new Map,a=(p,h)=>{let m=s[p]??{},y=h==="start"?m.start??"none":m.end??"arrow";if(y!=="none")return(i.get(p)??i.set(p,new Set).get(p)).add(y),`url(#${n}-mk-${p}-${y})`},l="",c="",f="",u="";for(let p of[...t.panels].sort((h,m)=>h.depth-m.depth)){let h=p.rect,m=p.label?me("text",{class:"pl",x:p.titleAt[0],y:p.titleAt[1]},ut(p.label)+(p.sub?me("tspan",{class:"pls",dx:10},ut(p.sub)):"")):"";l+=me("g",{class:`panel k-${p.role??"grey"}`,"data-id":p.id},me("rect",{class:"face",x:It(h.l),y:It(h.t),width:It(h.r-h.l),height:It(h.b-h.t),rx:r.panelRx})+m)}for(let p of t.links){if(!p.points.length)continue;let h=sf(p.kind);c+=me("path",{class:`conn k-${h}`,d:"M"+p.points.map(m=>`${It(m[0])},${It(m[1])}`).join(" L"),"data-id":p.id,"data-a":p.a,"data-b":p.b,"marker-start":a(h,"start"),"marker-end":a(h,"end")}),p.at&&(u+=me("text",{class:`cl k-${h}`,x:p.at.x,y:p.at.y,"text-anchor":p.at.anchor==="start"?void 0:p.at.anchor,"data-for":p.id},ut(p.at.text)))}for(let p of t.cards){let h=p.rect;f+=me("g",{class:`card k-${p.role??"grey"}${p.ghost?" ghost":""}`,"data-id":p.id,tabindex:0,role:"button","aria-label":p.sub?`${p.label}: ${p.sub}`:p.label},me("rect",{class:"face",x:It(h.l),y:It(h.t),width:r.W,height:r.H,rx:r.cardRx})+me("text",{class:"lt",x:It(h.l+14),y:It(h.t+24)},ut(p.label))+(p.sub?me("text",{class:"st",x:It(h.l+14),y:It(h.t+42)},ut(p.sub)):""))}let d="";for(let[p,h]of i)for(let m of h){let y=Xu[m];d+=me("marker",{id:`${n}-mk-${p}-${m}`,viewBox:"0 0 10 10",refX:y.refX,refY:5,markerWidth:5.4,markerHeight:5.4,orient:"auto-start-reverse"},me("path",{d:y.d,class:`mk k-${p}`}))}return me("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${It(o.l)} ${It(o.t)} ${It(o.r-o.l)} ${It(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(d?me("defs",{},d):"")+me("g",{class:"panels"},l)+me("g",{class:"conns"},c)+me("g",{class:"cards"},f)+me("g",{class:"labels"},u))}function rf(t={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",n=`
|
|
368
|
+
`}var rp=864e5,Rn=36e5,na=(n,e)=>n.t-e.t||(n.id<e.id?-1:n.id>e.id?1:0);function qn(n,e){let t=0,s=n.length;for(;t<s;){let r=t+s>>1;n[r].t<e?t=r+1:s=r}return t}var Fu=(n,e)=>{n.min=Math.min(n.min,e.min),n.max=Math.max(n.max,e.max),n.sum+=e.sum,n.count+=e.count};function Iu(n,e,t){let s=[];for(let r of n){let o=As(r.t,e,t),i=s[s.length-1];i&&i.t===o?Fu(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function Hl(n,e,t,s){for(let i=qn(n,e.t);i<n.length&&n[i].t===e.t;i++)if(t(n[i])){n[i]=e;return}let r=n[n.length-1];if(!r||s(r,e)<=0){n.push(e);return}let o=qn(n,e.t);for(;o<n.length&&s(n[o],e)<0;)o++;n.splice(o,0,e)}function Lu(n,e,t){for(let s=qn(n,e);s<n.length&&n[s].t===e;s++)if(t(n[s])){n.splice(s,1);return}}function Bu(n,e,t={}){let s=n.catalog,{isScope:r}=Yi(e),{parseSearch:o,matchAst:i,toAst:a}=dr(e),l=R=>Object.fromEntries(e.flags.filter(ee=>R?.[ee]).map(ee=>[ee,!0])),c=t.now??s.now,f=(s.names??[]).flatMap(R=>(R.aliases??[]).map(ee=>[ee,R.scope])).sort((R,ee)=>ee[0].length-R[0].length),u=new Map,d=R=>{if(!f.length)return R;let ee=u.get(R);if(ee===void 0){let ge=f.find(([we])=>Wt(R,we));ee=ge?ge[1]+R.slice(ge[0].length):R,u.set(R,ee)}return ee},p=new Map((s.names??[]).map(R=>[R.scope,R])),g=R=>f.length?{...R,scope:d(R.scope)}:R,m=R=>`${R.source}\0${R.id}`,y=n.events.map(g).sort(na),N=new Map;for(let R of y)N.set(m(R),R);let h=y.filter(R=>R.dur!==void 0&&!R.open),b=h.reduce((R,ee)=>Math.max(R,ee.dur),0),x=new Map;for(let R of y)R.open&&x.set(m(R),R);let A=new Map,M=new Set,v=R=>{for(let ee=Ct(R);ee>=1;ee--){let ge=Zn(R,ee);if(M.has(ge))break;M.add(ge)}},O=new Map;for(let R of s.sources)for(let ee of R.series)O.set(ee.name,ee.type);let C=s.sources.flatMap(R=>(R.sensitive??[]).map(ee=>`${R.name}.${ee}`)),$=new Map;for(let R of s.sources)$.set(R.name,{events:R.defaultRetention.events,rollups:{...R.defaultRetention.rollups},setBy:"default"});for(let R of s.retention)$.set(R.source,{events:R.events,rollups:{...R.rollups},setBy:R.setBy});let P=new Map;for(let R of s.sources)for(let ee of R.series)P.set(ee.name,R.name);function k(R){let ee=d(R.scope),ge=`${R.series}\0${ee}`,we=A.get(ge);we||(we={series:R.series,scope:ee,fine:[],cache:new Map},A.set(ge,we),v(ee));let je="value"in R?{t:R.t,min:R.value,max:R.value,sum:R.value,count:1}:{t:R.t,min:R.min,max:R.max,sum:R.sum,count:R.count};Hl(we.fine,je,ye=>ye.t===je.t,(ye,ze)=>ye.t-ze.t),we.cache.clear()}for(let R of y)v(R.scope);for(let R of n.metrics)k(R);let E=new Map,S=new Set,F=(R,ee)=>{S.add(R.source);let ge=E.get(R.scope);ge||E.set(R.scope,ge=new Map);let we=ge.get(R.source);we||ge.set(R.source,we=new Map);let je=Math.floor(R.t/Rn)*Rn,ye=we.get(je);if(ye||we.set(je,ye={t:je,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ye.count+=ee,ee>0)ye.first=Math.min(ye.first,R.t),ye.last=Math.max(ye.last,R.t);else if(R.t===ye.first||R.t===ye.last){ye.first=1/0,ye.last=-1/0;for(let ze=qn(y,je);ze<y.length&&y[ze].t<je+Rn;ze++){let Pe=y[ze];Pe.scope===R.scope&&Pe.source===R.source&&(ye.first=Math.min(ye.first,Pe.t),ye.last=Math.max(ye.last,Pe.t))}}ye.severity[R.severity]=(ye.severity[R.severity]??0)+ee,ye.kinds[R.kind]=(ye.kinds[R.kind]??0)+ee,ye.severity[R.severity]===0&&delete ye.severity[R.severity],ye.kinds[R.kind]===0&&delete ye.kinds[R.kind],ye.count||we.delete(je)};for(let R of y)F(R,1);let D=(R,ee,ge)=>{let we=`${ee}|${ge??""}`,je=R.cache.get(we);return je||(je=ee==="1d"?Iu(D(R,"1h",ge),"1d",ge):Iu(R.fine,ee,ge),R.cache.set(we,je)),je},H=R=>R===null?-1/0:c-R*rp,X=R=>H($.get(R)?.events??null),Y=(R,ee)=>{let ge=$.get(R);return H(ge?ee?ge.rollups[ee]:ge.events:null)};function L(R){let ee=[];for(let ge of new Set(R)){let we=$.get(ge);if(!we)continue;let je=y.find(ke=>ke.source===ge&&ke.t>=X(ge))?.t,ye=ke=>{let w=1/0;for(let z of A.values())if(P.get(z.series)===ge){let G=(ke?D(z,ke):z.fine).find(ae=>ae.t>=Y(ge,ke));G&&G.t<w&&(w=G.t)}return w===1/0?void 0:w},ze=[je,ye()].filter(ke=>ke!==void 0),Pe={};for(let ke of["1m","1h","1d"]){let w=ye(ke)??(je!==void 0&&je>=Y(ge,ke)?je:void 0);w!==void 0&&(Pe[ke]=Math.max(w,Y(ge,ke)))}ee.push({source:ge,events:we.events,rollups:{...we.rollups},setBy:we.setBy,keptFrom:{...ze.length?{events:Math.min(...ze)}:{},rollups:Pe}})}return ee}function q(R){let ee=R.where,ge={from:R.from,to:R.to},we=[];if(!ee&&R.q){let G=o(R.q,c);ee=a(G),ge=so(G,R.from,R.to),we=G.warnings}let je=i(ee,C),ye=R.filters??{},ze=ye.source?.length?new Set(ye.source):void 0,Pe=ye.kind?.length?new Set(ye.kind):void 0,ke=ye.severity?.length?new Set(ye.severity):void 0,w=ye.scope?.length?ye.scope:void 0;return{test:G=>Wt(G.scope,R.scope)&&(!ze||ze.has(G.source))&&(!Pe||Pe.has(G.kind))&&(!ke||ke.has(G.severity))&&(!w||w.some(ae=>Wt(G.scope,ae)))&&G.t>=X(G.source)&&je(G),range:ge,warnings:we}}function U(R){let ee=Ct(R.scope),ge=ee+R.depth,we=new Map,je=ke=>{let w=we.get(ke);return w===void 0&&!we.has(ke)&&(w=Wt(ke,R.scope)?Ct(ke)>=ge?Zn(ke,ge):ke:void 0,we.set(ke,w)),w},ye=ke=>{let w=0,z=Ct(ke)+1;for(let G of M)Ct(G)===z&&Wt(G,ke)&&w++;return w},ze=new Map,Pe=ke=>{let w=ze.get(ke);if(!w){let z=Ct(ke)-ee,G=p.get(ke);w={scope:ke,label:G?.label??fr(ke),kind:cr(ke),...l(G),depth:z,...z<R.depth?{own:!0}:{},children:ye(ke),count:0},ze.set(ke,w)}return w};for(let ke of M)Ct(ke)===ge&&Wt(ke,R.scope)&&Pe(ke);return ge===0&&Pe(""),{at:je,add:Pe,rows:ze}}let Z=R=>[...R.values()].sort((ee,ge)=>ee.scope===ge.scope?0:ee.scope<ge.scope?-1:1);function I(R,ee){let ge=[];for(let we=qn(h,R-b);we<h.length&&h[we].t<R;we++)h[we].t+h[we].dur>R&&ge.push(h[we]);for(let we of x.values())we.t<R&&c>R&&ge.push(we);for(let we=qn(y,R);we<y.length&&y[we].t<ee;we++)ge.push(y[we]);return ge}function _(R,ee,ge,we){let je=R.series?new Set(R.series):void 0,ye=new Map;for(let Pe of A.values()){if(je&&!je.has(Pe.series))continue;let ke=ee(Pe.scope);if(ke===void 0)continue;let w=P.get(Pe.series)??"",z=Y(w,R.bin),G=R.bin?D(Pe,R.bin,R.tz):Pe.fine;for(let ae=qn(G,R.bin?As(ge,R.bin,R.tz):ge);ae<G.length&&G[ae].t<we;ae++){let le=G[ae];if(le.t<z)continue;let ue=`${Pe.series}\0${ke}\0${le.t}`,se=ye.get(ue);se?Fu(se,le):ye.set(ue,{series:Pe.series,scope:ke,t:le.t,bin:R.bin??"1m",min:le.min,max:le.max,sum:le.sum,count:le.count})}}let ze=[...ye.values()].sort((Pe,ke)=>Pe.t-ke.t||(Pe.series<ke.series?-1:1)||(Pe.scope<ke.scope?-1:1));return R.bin?ze:ze.map(Pe=>({series:Pe.series,scope:Pe.scope,t:Pe.t,value:Pe.count===1||O.get(Pe.series)!=="gauge"?Pe.sum:Pe.sum/Pe.count}))}let K=R=>`${R.t}:${R.id}`,J=(R,ee)=>{let ge=ee.indexOf(":"),we=Number(ee.slice(0,ge)),je=ee.slice(ge+1);return R.t>we||R.t===we&&R.id>je};function de(R){if(R.bin!=="1h"&&R.bin!=="1d"||(R.where?.all.length??0)||R.q||R.filters?.kind?.length||R.filters?.severity?.length||R.filters?.scope?.length||jt(R.tz,R.from)%Rn||jt(R.tz,R.to)%Rn)return;let ee=R.filters?.source?.length?new Set(R.filters.source):void 0,ge=te=>Math.max(R.from,X(te)),{at:we,add:je,rows:ye}=U(R),ze=new Set,Pe=new Map,ke=0,w=(te,xe)=>{let he=As(xe,R.bin,R.tz),Oe=`${te}\0${he}`,T=Pe.get(Oe);return T||(T={scope:te,t:he,bin:R.bin,count:0,severity:{},kinds:{}},Pe.set(Oe,T)),T},z=(te,xe,he)=>{let Oe=je(te);Oe.count+=he,ke+=he,(Oe.first===void 0||xe<Oe.first)&&(Oe.first=xe),(Oe.last===void 0||xe>Oe.last)&&(Oe.last=xe)},G=Math.floor(R.to/Rn)*Rn;for(let[te,xe]of E){let he=we(te);if(he!==void 0)for(let[Oe,T]of xe){if(ee&&!ee.has(Oe))continue;let V=Math.ceil(ge(Oe)/Rn)*Rn;for(let[j,re]of T){if(j<V||j>=G)continue;z(he,re.first,re.count),re.last>(ye.get(he).last??-1/0)&&(ye.get(he).last=re.last),ze.add(Oe);let fe=w(he,j);fe.count+=re.count;for(let[Ee,ve]of Object.entries(re.severity))fe.severity[Ee]=(fe.severity[Ee]??0)+ve;for(let[Ee,ve]of Object.entries(re.kinds))fe.kinds[Ee]=(fe.kinds[Ee]??0)+ve}}}let ae=te=>Wt(te.scope,R.scope)&&(!ee||ee.has(te.source))&&te.t>=X(te.source)&&we(te.scope)!==void 0,le=te=>{let xe=we(te.scope);z(xe,te.t,1),ze.add(te.source);let he=w(xe,te.t);he.count++,he.severity[te.severity]=(he.severity[te.severity]??0)+1,he.kinds[te.kind]=(he.kinds[te.kind]??0)+1};for(let te of S){if(ee&&!ee.has(te))continue;let xe=ge(te),he=Math.ceil(xe/Rn)*Rn,Oe=he>=G?[[xe,R.to]]:[[xe,he],[G,R.to]];for(let[T,V]of Oe)for(let j=qn(y,T);j<y.length&&y[j].t<V;j++){let re=y[j];re.source===te&&ae(re)&&le(re)}}let ue=mn[R.bin],se=[];for(let te=qn(h,R.from-b);te<h.length&&h[te].t<R.from;te++){let xe=h[te];xe.t+xe.dur>R.from&&ae(xe)&&(z(we(xe.scope),xe.t,1),ze.add(xe.source),xe.dur>=ue&&se.length<5e3&&se.push(xe))}for(let te of x.values())te.t<R.from&&c>R.from&&ae(te)&&(z(we(te.scope),te.t,1),ze.add(te.source),se.length<5e3&&se.push(te));for(let te=qn(h,R.from);te<h.length&&h[te].t<R.to&&se.length<5e3;te++)h[te].dur>=ue&&ae(h[te])&&se.push(h[te]);for(let te of x.values())te.t>=R.from&&te.t<R.to&&se.length<5e3&&ae(te)&&se.push(te);let be=_(R,we,R.from,R.to);for(let te of be){let xe=P.get(te.series);xe&&ze.add(xe)}let Se=[...Pe.values()].sort((te,xe)=>te.t-xe.t||(te.scope<xe.scope?-1:1));return{timeline:1,type:"result",rows:Z(ye),bins:Se,spans:se,metrics:be,total:ke,retention:L(ze)}}async function ce(R){if(!r(R.scope))throw new Error(`not a scope path: ${JSON.stringify(R.scope)}`);let ee=de(R);if(ee)return ee;let{test:ge,range:we,warnings:je}=q(R),{at:ye,add:ze,rows:Pe}=U(R),ke=new Set,w=[];for(let be of I(we.from,we.to)){if(!ge(be))continue;let Se=ye(be.scope);if(Se===void 0)continue;let te=ze(Se);te.count++,(te.first===void 0||be.t<te.first)&&(te.first=be.t),(te.last===void 0||be.t>te.last)&&(te.last=be.t),ke.add(be.source),w.push(be)}w.sort(na);let z=_(R,ye,we.from,we.to);for(let be of z){let Se=P.get(be.series);Se&&ke.add(Se)}let G={timeline:1,type:"result",total:w.length,...je.length?{warnings:je}:{}};if(R.bin){let be=mn[R.bin],Se=new Map,te=[];for(let he of w){if((he.open||he.dur!==void 0&&he.dur>=be)&&te.length<5e3&&te.push(he),he.t<we.from)continue;let Oe=ye(he.scope),T=As(he.t,R.bin,R.tz),V=`${Oe}\0${T}`,j=Se.get(V);j||(j={scope:Oe,t:T,bin:R.bin,count:0,severity:{},kinds:{}},Se.set(V,j)),j.count++,j.severity[he.severity]=(j.severity[he.severity]??0)+1,j.kinds[he.kind]=(j.kinds[he.kind]??0)+1}let xe=[...Se.values()].sort((he,Oe)=>he.t-Oe.t||(he.scope<Oe.scope?-1:1));return{...G,rows:Z(Pe),bins:xe,spans:te,metrics:z,retention:L(ke)}}let ae=Math.min(1e4,Math.max(1,R.limit??2e3)),le=R.cursor?w.findIndex(be=>J(be,R.cursor)):0,ue=le<0?[]:w.slice(le,le+ae),se=le>=0&&le+ae<w.length;return{...G,rows:Z(Pe),events:ue,metrics:z,retention:L(ke),...se?{next:K(ue[ue.length-1])}:{}}}let W=new Set,ne=R=>Ht.includes(R),Ae=0;function Be(R){let ee=m(R),ge=N.get(ee);ge&&(Lu(y,ge.t,we=>we===ge),F(ge,-1),ge.dur!==void 0&&!ge.open&&Lu(h,ge.t,we=>we===ge),x.delete(ee)),N.set(ee,R),F(R,1),Hl(y,R,()=>!1,na),R.open?x.set(ee,R):R.dur!==void 0&&(Hl(h,R,()=>!1,na),b=Math.max(b,R.dur)),v(R.scope)}return{async catalog(){return{...s,now:c,retention:L(s.sources.map(R=>R.name))}},query:ce,subscribe(R,ee){let ge={q:R,on:ee};return W.add(ge),()=>{W.delete(ge)}},...t.stateAt?{stateAt:(R,ee)=>t.stateAt(R,ee)}:{},append(R,ee=[],ge){ge!==void 0&&(c=Math.max(c,ge));let we=new Set(M),je=R.map(g);for(let ye of je){if(!ne(ye.severity))throw new Error(`not a severity: ${ye.severity}`);Be(ye)}for(let ye of ee)k(ye);Ae++;for(let ye of W){let{test:ze}=q(ye.q),{at:Pe}=U(ye.q),ke=je.filter(ue=>ze(ue)&&Pe(ue.scope)!==void 0),w=ye.q.series?new Set(ye.q.series):void 0,z=ee.filter(ue=>Wt(d(ue.scope),ye.q.scope)&&(!w||w.has(ue.series))).map(ue=>({...ue,scope:Pe(d(ue.scope))})),G=[...M].filter(ue=>!we.has(ue)),ae=Ct(ye.q.scope)+ye.q.depth,le=G.filter(ue=>Ct(ue)===ae&&Wt(ue,ye.q.scope)).map(ue=>({scope:ue,label:p.get(ue)?.label??fr(ue),kind:cr(ue),depth:ye.q.depth,children:0,count:0}));ye.on({timeline:1,type:"batch",events:ke,metrics:z,...le.length?{rows:le}:{},now:c,resume:String(Ae)})}},setRetention(R,ee){$.set(R,{events:ee.events,rollups:{...ee.rollups},setBy:"user"})},get now(){return c},get size(){let R=0;for(let ee of A.values())R+=ee.fine.length;return{events:y.length,samples:R}}}}var ju="http://www.w3.org/2000/svg",Rs=22,sa=38,Un=26,op=210,ip=24,oo=6e4,Ps=36e5,en=864e5,Du={"15m":15*oo,"1h":Ps,"1d":en,"1w":7*en},_u=n=>Ht.indexOf(n),ap={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},ot=(n,e,t)=>{let s=document.createElementNS(ju,n);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(t){let r=document.createElementNS(ju,"title");r.textContent=t,s.append(r)}return s},Dt=(n,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(n)}catch{return new Date(n).toISOString()}},Wl=n=>n<1e3?`${Math.round(n)} ms`:n<oo?`${(n/1e3).toFixed(1)} s`:Os(n),lp=(n,e)=>e==="bytes"?n>=1e9?`${(n/1e9).toFixed(1)} GB`:n>=1e6?`${(n/1e6).toFixed(1)} MB`:n>=1e3?`${(n/1e3).toFixed(1)} kB`:`${Math.round(n)} B`:`${Math.round(n*10)/10}${e==="count"?"":` ${e}`}`;function Jl(n,e){if(n<=3*Ps)return{kind:"single"};for(let t of["1m","1h","1d"])if(n/mn[t]<=e/2)return{kind:"binned",bin:t};return{kind:"binned",bin:"1d"}}function Xl(n,e,t){let s=[];for(let i of n.events??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);for(let i of n.spans??[])s.push([i.t,i.t]),i.dur!==void 0&&!i.open&&s.push([i.t+i.dur,i.t+i.dur]);let r=e.kind==="binned"?mn[e.bin]:oo;for(let i of n.bins??[])i.count&&s.push([i.t,i.t+mn[i.bin]]);let o=new Map;for(let i of n.metrics){let a="value"in i?i.value:i.sum,l=`${i.series}|${i.scope}`,c=(t?.get(i.series)??"counter")==="counter"?a!==0:o.get(l)!==a;o.set(l,a),c&&s.push([i.t,i.t+r])}return s}function zu(n,e){let t=e.tz??Intl.DateTimeFormat().resolvedOptions().timeZone,s=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,r=e.motion??!s;n.classList.add(...e.rootClass??[],"tlx");let{parseSearch:o,compileSearch:i}=dr(e.catalog),a=(B="system")=>{n.style.colorScheme=B==="system"?"light dark":B,B==="system"?delete n.dataset.theme:n.dataset.theme=B};a(e.theme),n.setAttribute("role","region"),n.setAttribute("aria-label","Timeline");let l,c="",f=1,u="",d={},p=!1,g=e.collapseGaps??!0,m={t0:0,t1:en},y,N="",h={from:0,to:0,mode:{kind:"single"},key:""},b,x,A,M,v=!0,O=0,C=0,$=!1,P,k=[],E=[],S=-1,F=new Set,D=new Map,H=[],X=mr(0,en,800),Y=new Map,L=[],q=me("nav",{class:"tlx-crumbs","aria-label":"Scope"}),U=me("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let B of["15m","1h","1d","1w","run"]){let Q=me("button",{type:"button",class:"seg","data-v":B,title:B==="run"?"The latest run":`The last ${B}`},B==="run"?"this run":B);Q.addEventListener("click",()=>bs(B)),U.append(Q)}let Z=me("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),I=me("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),_=me("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),K=me("input",{type:"checkbox",class:"tlx-gaps"});K.checked=g;let J=!0,de=me("input",{type:"checkbox",class:"tlx-quiet"});de.checked=J;let ce=me("input",{type:"search",class:"input tlx-q",placeholder:"Search: words, kind:\u2026, source:\u2026, severity:>=warning, -kind:\u2026","aria-label":"Search the timeline",spellcheck:"false"}),W=me("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),ne=me("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),Ae=me("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Be=me("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),R=me("select",{class:"input tlx-sev","aria-label":"Severity"},me("option",{value:""},"every severity"),...Ht.slice(1).map(B=>me("option",{value:B},`${B} and above`))),ee=me("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},me("option",{value:""},"Saved views\u2026")),ge=me("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),we=me("div",{class:"tlx-warn",role:"status",hidden:!0}),je=me("div",{class:"tlx-status",role:"status"}),ye=me("span",{class:"tlx-canvas-note"}),ze=me("div",{class:"tlx-labels"}),Pe=me("div",{class:"tlx-lanes",tabindex:"0",role:"application","aria-label":"Timeline lanes: drag to pan, wheel to zoom, drag the axis to choose a range, click it to move the playhead. Keys: \u2190 \u2192 pan, + \u2212 zoom, N next hit"}),ke=ot("svg",{class:"tlx-svg"});Pe.append(ke);let w=me("div",{class:"tlx-scroll"},me("div",{class:"tlx-grid"},ze,Pe)),z=me("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),G=me("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});n.replaceChildren(me("div",{class:"tlx-bar"},q,me("span",{class:"spacer"}),U,Z,I,_,me("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},K,"Collapse gaps"),me("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},de,"Hide quiet rows")),me("div",{class:"tlx-bar"},ce,W,ne,Ae,R,ee,ge),Be,we,me("div",{class:"tlx-body"},w,G),me("div",{class:"tlx-foot"},je,me("span",{class:"spacer"}),ye),z);let ae=()=>Math.max(200,Pe.clientWidth||800),le=()=>{let B=($e,Ve)=>($e.own?-1:0)-(Ve.own?-1:0)||$e.scope.localeCompare(Ve.scope,void 0,{numeric:!0}),ie=(y?.rows??[]).filter($e=>!J||$e.count>0||$e.own||(y?.rows.length??0)<=1).sort(B).map($e=>({kind:"row",row:$e})),pe=new Set(y?.metrics.map($e=>$e.series)??[]);for(let $e of[...pe].sort()){let Ve=Y.get($e);ie.push({kind:"metric",series:$e,unit:Ve?.unit??"count",type:Ve?.type??"counter",title:Ve?.title??$e})}return ie},ue=(B,Q)=>l?.names?.find(ie=>ie.scope===B)?.label??Q,se=B=>B.kind==="metric"?sa:Rs,be=()=>Jl(m.t1-m.t0,ae()),Se=()=>l?.now??Date.now();function te(){return{timeline:1,type:"view",name:"",scope:c,depth:f,range:{from:Math.round(m.t0),to:Math.round(m.t1)},...u?{q:u}:{},...Object.keys(d).length?{filters:d}:{},...p?{live:p}:{},...g?{}:{collapseGaps:!1},...J?{}:{quietRows:!0}}}function xe(B){B.scope!==void 0&&(c=B.scope),B.depth!==void 0&&(f=B.depth),u=B.q??"",ce.value=u,d=B.filters??{},R.value=d.severity?.length?d.severity[0]:"",g=B.collapseGaps??e.collapseGaps??!0,K.checked=g,J=!B.quietRows,de.checked=J,F.clear(),D.clear();let Q=B.range;Q&&"last"in Q?bs(Q.last,!1):Q&&(m={t0:Q.from,t1:Q.to}),bt(!!B.live,!1)}let he=()=>{let B=te();if(e.onViewChange?.(B),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(B))}`)}catch{}},Oe=()=>{if(!e.urlState)return;let B=/#timeline=(.+)$/.exec(location.hash);if(B)try{return JSON.parse(decodeURIComponent(B[1]))}catch{return}};function T(B,Q,ie,pe={}){let $e=i(u,Se(),B,Q);k=$e.warnings;let Ve=u?[]:d.source?[...Y].filter(([,Qe])=>d.source.includes(Qe.source)).map(([Qe])=>Qe):void 0;return{timeline:1,type:"query",scope:c,depth:f,from:$e.from,to:$e.to,tz:t,...ie.kind==="binned"?{bin:ie.bin}:{},...u?{q:u,where:$e.where}:{},...Object.keys(d).length?{filters:d}:{},...Ve?{series:Ve}:{},...pe}}let V=()=>JSON.stringify([c,f,u,d,be()]);async function j(B=!1){let Q=be(),ie=V(),pe=m.t1-m.t0;if(!B&&y&&ie===h.key&&m.t0>=h.from&&m.t1<=h.to){fe();return}if(C){$=!0;return}C++;let $e=m.t0-pe/2,Ve=Math.min(m.t1+pe/2,Math.max(m.t1,Se()+pe*.1));try{let Qe=await e.source.query(T($e,Ve,Q,Q.kind==="single"?{limit:1e4}:{}));Q.kind==="single"&&Qe.next&&(Qe=await e.source.query(T($e,Ve,{kind:"binned",bin:"1m"}))),y=Qe,N=ie,h={from:$e,to:Ve,mode:Q,key:ie}}catch(Qe){je.textContent=`The history couldn't be read: ${String(Qe?.message??Qe)}`}finally{C--}fe(),he(),$&&($=!1,j())}function re(){let B=ae(),Q=be();if(H=[],g&&y){let ie=new Map([...Y].map(([pe,$e])=>[pe,$e.type]));H=Qi(Xl(y,Q,ie),m.t0,Math.min(m.t1,Math.max(m.t0,Se())),{minFrac:.15,minMs:10*oo}),Q.kind==="binned"&&(H=H.filter(pe=>pe.to-pe.from>=2*mn[Q.bin])),H=H.filter(pe=>!(F.has(Ns(pe))&&(D.get(Ns(pe))??1)>=1))}X=mr(m.t0,m.t1,B,H,{cut:ip,weights:D})}let fe=()=>{O||(O=requestAnimationFrame(Ee))};function Ee(){O=0,re();let B=ae(),Q=le(),ie=h.mode,pe=[],$e=Un;for(let oe of Q)pe.push($e),$e+=se(oe);let Ve=Math.max($e,Un+Rs);ke.setAttribute("width",String(B)),ke.setAttribute("height",String(Ve)),ke.setAttribute("viewBox",`0 0 ${B} ${Ve}`);let Qe=w.scrollTop-200,Pn=w.scrollTop+(w.clientHeight||600)+200,Fe=[],Le=X.x;Fe.push(ot("rect",{class:"tlx-axis",x:0,y:0,width:B,height:Un}));let It=(y?.retention??[]).map(oe=>({r:oe,from:ie.kind==="binned"?oe.keptFrom.rollups[ie.bin]??oe.keptFrom.events:oe.keptFrom.events,days:ie.kind==="binned"?oe.rollups[ie.bin]:oe.events})).filter(oe=>oe.from!==void 0);if(It.length){let oe=Math.min(...It.map(Me=>Me.from));oe>m.t0&&Fe.push(ot("rect",{class:"tlx-notkept",x:Math.max(0,Le(m.t0)),y:Un,width:Math.max(0,Le(oe)-Math.max(0,Le(m.t0))),height:Ve-Un},`Nothing kept before ${Dt(oe,t)}: ${It.map(Me=>`${Me.r.source} ${Me.days===null?"kept until deleted":`kept ${Me.days} days`}`).join(", ")}`))}let Jt=Se();Jt<m.t1&&Fe.push(ot("rect",{class:"tlx-future",x:Le(Jt),y:Un,width:B-Le(Jt),height:Ve-Un}));for(let oe of Zi(X,t,90)){Fe.push(ot("line",{class:`tlx-tick${oe.major?" major":""}`,x1:oe.x,x2:oe.x,y1:Un-6,y2:Ve}));let Me=ot("text",{class:"tlx-ticklabel",x:oe.x+3,y:16});Me.textContent=oe.label,Fe.push(Me)}M&&Fe.push(ot("rect",{class:"tlx-brush",x:Le(M.from),y:0,width:Math.max(1,Le(M.to)-Le(M.from)),height:Ve}));let lo=ie.kind==="single"?(y?.events??[]).filter(oe=>oe.dur!==void 0||oe.open):y?.spans??[],Zu=ie.kind==="single"?(y?.events??[]).filter(oe=>oe.dur===void 0&&!oe.open):[],Zl=new Map;Q.forEach((oe,Me)=>{oe.kind==="row"&&Zl.set(oe.row.scope,Me)});let co=oe=>{let Me=Ct(c)+f,Ue=Ct(oe)>=Me?Zn(oe,Me):oe;return Zl.get(Ue)},pr=oe=>pe[oe]+se(Q[oe])>=Qe&&pe[oe]<=Pn;if(Q.forEach((oe,Me)=>{pr(Me)&&Fe.push(ot("rect",{class:`tlx-lane${Me%2?" odd":""}${oe.kind==="metric"?" metric":""}`,x:0,y:pe[Me],width:B,height:se(oe)}))}),ie.kind==="binned"){let oe=new Map;for(let Me of y?.bins??[]){let Ue=co(Me.scope);Ue!==void 0&&oe.set(Ue,Math.max(oe.get(Ue)??0,Me.count))}for(let Me of y?.bins??[]){let Ue=co(Me.scope);if(Ue===void 0||!pr(Ue))continue;let Ze=Le(Me.t),Je=Le(Me.t+mn[Me.bin]);if(Je<0||Ze>B)continue;let ut=[...Ht].reverse().find(tn=>(Me.severity[tn]??0)>0)??"info",Ot=Math.max(2,(Rs-8)*Math.sqrt(Me.count)/Math.sqrt(oe.get(Ue)||1));Fe.push(ot("rect",{class:"tlx-countbar",x:Ze,y:pe[Ue]+Rs-3-Ot,width:Math.max(1,Je-Ze-.5),height:Ot,"data-t":Me.t},`${Dt(Me.t,t)}: ${Me.count} event${Me.count===1?"":"s"}${ut!=="info"&&ut!=="debug"?`, the worst ${ut}`:""}`)),(ut==="warning"||ut==="error")&&Fe.push(ot("rect",{class:`tlx-heat sev-${ut}`,x:Ze,y:pe[Ue]+Rs-(ut==="error"?4:3),width:Math.max(1,Je-Ze-.5),height:ut==="error"?3:2}))}}for(let oe of lo){let Me=co(oe.scope);if(Me===void 0||!pr(Me))continue;let Ue=oe.open?Jt:oe.t+(oe.dur??0),Ze=Le(oe.t),Je=Le(Ue);if(Je<-2||Ze>B+2)continue;let ut=`tlx-span sev-${oe.severity}${oe.open?" open":""}${A?.id===oe.id?" selected":""}`,Ot=`${oe.summary} \xB7 ${Dt(oe.t,t)}${oe.open?", still going":`, ${Wl(Ue-oe.t)}`}`,tn=pe[Me]+5,ts=ie.kind==="binned"?4:8,nn=Ze;for(let bn of X.cuts)bn.weight>=1||bn.x1<=Ze||bn.x0>=Je||(bn.x0>nn&&Fe.push(ot("rect",{class:ut,x:nn,y:tn,width:Math.max(1,bn.x0-nn),height:ts,rx:2,"data-id":oe.id},Ot)),Fe.push(ot("path",{class:`${ut} through`,d:`M${bn.x0} ${tn+ts/2} H${bn.x1}`,"data-id":oe.id},`${Ot} (lasted through the break)`)),nn=bn.x1);Je>nn&&Fe.push(ot("rect",{class:ut,x:Math.max(-2,nn),y:tn,width:Math.max(2,Math.min(B+2,Je)-Math.max(-2,nn)),height:ts,rx:2,"data-id":oe.id},Ot))}let ec=new Map;for(let oe of Zu){let Me=co(oe.scope);if(Me===void 0||!pr(Me))continue;let Ue=Le(oe.t);if(Ue<-6||Ue>B+6||Ue-(ec.get(Me)??-1/0)<3)continue;ec.set(Me,Ue);let Ze=pe[Me]+Rs/2+2,Je=4,ut=ap[oe.severity],Ot=ut==="diamond"?`M${Ue} ${Ze-Je-1} l${Je+1} ${Je+1} l${-Je-1} ${Je+1} l${-Je-1} ${-Je-1} z`:ut==="triangle"?`M${Ue} ${Ze-Je-1} l${Je+1} ${2*Je+1} h${-2*Je-2} z`:ut==="square"?`M${Ue-Je+.5} ${Ze-Je+.5} h${2*Je-1} v${2*Je-1} h${-2*Je+1} z`:"",tn=`${Dt(oe.t,t)} \xB7 ${oe.summary}`,ts=`tlx-mark sev-${oe.severity}${A?.id===oe.id?" selected":""}${S>=0&&E[S]?.id===oe.id?" hit":""}`;Fe.push(Ot?ot("path",{class:ts,d:Ot,"data-id":oe.id},tn):ot("circle",{class:ts,cx:Ue,cy:Ze,r:ut==="dot"?2.5:Je,"data-id":oe.id},tn))}Q.forEach((oe,Me)=>{if(oe.kind!=="metric"||!pr(Me))return;let Ue=new Map;for(let tt of y?.metrics??[]){if(tt.series!==oe.series)continue;let Nt="value"in tt?{min:tt.value,max:tt.value,sum:tt.value,count:1}:{min:tt.min,max:tt.max,sum:tt.sum,count:tt.count},$t=Ue.get(tt.t);$t?($t.min=Math.min($t.min,Nt.min),$t.max=Math.max($t.max,Nt.max),$t.sum+=Nt.sum,$t.count+=Nt.count):Ue.set(tt.t,{...Nt})}let Ze=[...Ue].sort((tt,Nt)=>tt[0]-Nt[0]);if(!Ze.length)return;let Je=ie.kind==="binned"?mn[ie.bin]:oo,ut=tt=>oe.type==="gauge"?tt.sum/Math.max(1,tt.count):tt.sum,Ot=Math.max(1e-9,...Ze.map(([,tt])=>oe.type==="gauge"?tt.max:ut(tt))),tn=pe[Me]+sa-4,ts=sa-10,nn=tt=>tn-tt/Ot*ts;if(oe.type==="gauge"){let tt=Ze.map(([Nt,$t])=>`${Le(Nt)},${nn($t.max)}`).join(" ")+" "+[...Ze].reverse().map(([Nt,$t])=>`${Le(Nt)},${nn($t.min)}`).join(" ");Fe.push(ot("polygon",{class:"tlx-band",points:tt})),Fe.push(ot("polyline",{class:"tlx-line",points:Ze.map(([Nt,$t])=>`${Le(Nt+Je/2)},${nn(ut($t))}`).join(" ")}))}else{let tt="",Nt=-1/0;for(let[$t,ed]of Ze){let td=Le($t),tc=Le($t+Je),nc=nn(ut(ed));tt+=$t>Nt?`M${td} ${tn} V${nc} H${tc}`:` V${nc} H${tc}`,Nt=$t+Je;let sc=Ze.find(([nd])=>nd>$t);(!sc||sc[0]>Nt)&&(tt+=` V${tn} Z`)}Fe.push(ot("path",{class:"tlx-area",d:tt}))}let bn=ot("text",{class:"tlx-peak",x:4,y:pe[Me]+11});bn.textContent=`peak ${lp(Ot,oe.unit)}${oe.type==="counter"?` per ${ie.kind==="binned"?ie.bin:"1m"}`:""}`,Fe.push(bn)});for(let oe of X.cuts){if(oe.weight>=1)continue;let Me=Je=>{let ut=`M${Je} 0`;for(let Ot=0;Ot<Ve;Ot+=8)ut+=` L${Je+(Ot/8%2?-3:3)} ${Ot+8}`;return ut},Ue=ot("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":oe.from,"data-to":oe.to,"aria-label":`A break of ${Os(oe.to-oe.from)} with nothing shown, from ${Dt(oe.from,t)} to ${Dt(oe.to,t)}: press to open it`},`${Os(oe.to-oe.from)} with nothing here: ${Dt(oe.from,t)} to ${Dt(oe.to,t)} (click to open)`);Ue.append(ot("rect",{class:"tlx-cut-bg",x:oe.x0,y:0,width:oe.x1-oe.x0,height:Ve})),Ue.append(ot("path",{class:"tlx-cut-edge",d:Me(oe.x0+3)}),ot("path",{class:"tlx-cut-edge",d:Me(oe.x1-3)}));let Ze=ot("text",{class:"tlx-cut-label",x:(oe.x0+oe.x1)/2,y:15,"text-anchor":"middle"});Ze.textContent=Os(oe.to-oe.from),Ue.append(Ze),Fe.push(Ue)}if(b!==void 0){let oe=Le(b);Fe.push(ot("line",{class:"tlx-playhead",x1:oe,x2:oe,y1:0,y2:Ve})),Fe.push(ot("path",{class:"tlx-handle",d:`M${oe-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${Dt(b,t)}`))}ke.replaceChildren(...Fe),ze.replaceChildren(me("div",{class:"tlx-labelhead",style:`height:${Un}px`},be().kind==="single"?"single events":`per ${be().kind==="binned"?be().bin:""}`),...Q.map(oe=>{if(oe.kind==="metric")return me("div",{class:"tlx-rowlabel metric",style:`height:${sa}px`,title:`${oe.title} (${oe.type==="counter"?"sums":"min, max and mean"})`},oe.title);let Me=oe.row,Ue=me("div",{class:`tlx-rowlabel${Me.own?" own":""}`,style:`height:${Rs}px`,"data-scope":Me.scope,title:`${Me.scope||"all hosts"} \xB7 ${Me.count} event${Me.count===1?"":"s"}`},me("span",{class:"tlx-kind"},e.catalog.flags.find(Ze=>Me[Ze])??Me.kind),me("span",{class:"tlx-name"},Me.own?`${Me.label} (itself)`:Me.label),me("span",{class:"tlx-count"},String(Me.count)));if(!Me.own&&Me.scope!==c){let Ze=me("button",{type:"button",class:"tlx-drill",title:Me.children?`Into ${Me.label}: its ${Me.children} part${Me.children===1?"":"s"}`:`Into ${Me.label}`,"aria-label":`Into ${Me.label}`},"\u203A");Ze.addEventListener("click",()=>et(Me.scope)),Ue.append(Ze)}return Ue})),ze.style.width=`${op}px`,ve()}function ve(){q.replaceChildren(...ur(c).flatMap((pe,$e,Ve)=>{let Qe=me("button",{type:"button",class:`tlx-crumb${$e===Ve.length-1?" current":""}`,"aria-current":$e===Ve.length-1?"location":void 0},ue(pe.scope,pe.label));return Qe.addEventListener("click",()=>{pe.scope!==c&&(c=pe.scope,f=1,j(!0))}),$e?[me("span",{class:"tlx-sep","aria-hidden":"true"},"/"),Qe]:[Qe]})),Z.setAttribute("aria-pressed",String(p)),Z.classList.toggle("on",p),I.hidden=!p||v;let B=be(),Q=y?.total??0,ie=(y?.retention??[]).filter(pe=>pe.events!==null).map(pe=>`${pe.source} kept ${pe.events} d`);je.textContent=`${Dt(m.t0,t)} \u2013 ${Dt(m.t1,t)} \xB7 ${B.kind==="single"?"single events":`bins of ${B.bin}`} \xB7 ${Q} event${Q===1?"":"s"}${H.length?` \xB7 ${H.length} break${H.length===1?"":"s"}`:""}${ie.length?` \xB7 ${ie.slice(0,3).join(", ")}`:""}`,we.hidden=!k.length,we.textContent=k.join(" \xB7 "),W.textContent=u?E.length?`${S+1>0?`${S+1} of `:""}${E.length}${E.length>=2e3?"+":""} hit${E.length===1?"":"s"}`:`${Q?`${Q} hit${Q===1?"":"s"}`:"no hits"}`:"";for(let pe of U.querySelectorAll(".seg"))pe.classList.remove("on");ye.textContent=b===void 0?"":x?(()=>{let pe=e.stamp?.(x)??{};return`Canvas: the state recorded at ${Dt(Date.parse(pe.at??"")||b,t)}${pe.tag?` (${pe.tag})`:""}`})():"No state recorded here",ye.classList.toggle("none",b!==void 0&&!x)}function We(){Be.replaceChildren();for(let B of l?.sources??[]){let Q=!d.source?.length||d.source.includes(B.name),ie=me("button",{type:"button",class:`tlx-chip${Q?" on":""}${B.status==="not-yet"?" notyet":""}`,"aria-pressed":String(Q&&B.status!=="not-yet"),disabled:B.status==="not-yet",title:B.status==="not-yet"?`${B.title}: not kept yet`:`${B.title}${Ie(B)}`},B.name);B.status!=="not-yet"&&ie.addEventListener("click",()=>Re(B.name)),Be.append(ie)}}let Ie=B=>{let Q=l?.retention.find(ie=>ie.source===B.name);return Q?` (kept ${Q.events===null?"until deleted":`${Q.events} days`})`:""};function Re(B){let Q=(l?.sources??[]).filter(pe=>pe.status==="kept").map(pe=>pe.name),ie=d.source?.length?[...d.source]:[...Q];ie=ie.includes(B)?ie.filter(pe=>pe!==B):[...ie,B],d={...d,...ie.length===Q.length?{source:void 0}:{source:ie}},d.source||delete d.source,We(),j(!0),Ke()}let De=0;ce.addEventListener("input",()=>{clearTimeout(De),De=setTimeout(()=>{u=ce.value.trim(),S=-1,j(!0),Ke()},250)}),ce.addEventListener("keydown",B=>{B.key==="Enter"&&(B.preventDefault(),clearTimeout(De),u=ce.value.trim(),j(!0).then(()=>Ke()).then(()=>it(B.shiftKey?-1:1)))});async function Ke(){if(!u){E=[],S=-1,ve();return}let B=m.t1-m.t0;E=(await e.source.query(T(m.t0-B*4,Math.max(m.t1+B*4,Se()),{kind:"single"},{limit:2e3}))).events??[],S=Math.min(S,E.length-1),ve()}function it(B){if(!E.length)return;let Q=(m.t0+m.t1)/2;S<0?S=B>0?Math.max(0,E.findIndex($e=>$e.t>=Q)):Math.max(0,E.length-1-[...E].reverse().findIndex($e=>$e.t<=Q)):S=(S+B+E.length)%E.length;let ie=E[S],pe=Math.min(m.t1-m.t0,2*Ps);m={t0:ie.t-pe/2,t1:ie.t+pe/2},v=!1,ft(ie),j()}ne.addEventListener("click",()=>it(-1)),Ae.addEventListener("click",()=>it(1)),R.addEventListener("change",()=>{let B=R.value;d={...d,...B?{severity:Ht.filter(Q=>_u(Q)>=_u(B))}:{}},B||delete d.severity,j(!0),Ke()});async function bs(B,Q=!0){let ie=Se();if(B==="run"){let pe=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:ie-30*en,to:ie+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),$e=pe?.events?.[pe.events.length-1];m=$e?{t0:$e.t-($e.dur??Ps)*.02,t1:($e.open?ie:$e.t+($e.dur??Ps))+($e.dur??Ps)*.04}:{t0:ie-en,t1:ie+en*.02}}else m={t0:ie-Du[B],t1:ie+Du[B]*.02};v=!0,F.clear(),D.clear(),Q&&j()}function bt(B,Q=!0){if(p=B,P?.(),P=void 0,B&&e.source.subscribe){let ie=0,pe=0;P=e.source.subscribe(T(Se()-Ps,Se()+365*en,{kind:"single"}),$e=>{if(l&&(l.now=Math.max(l.now,$e.now)),v){let Qe=m.t1-m.t0;m={t0:$e.now-Qe*.98,t1:$e.now+Qe*.02}}let Ve=Date.now();Ve-ie>500?(ie=Ve,j(!0)):pe||(pe=setTimeout(()=>{pe=0,ie=Date.now(),j(!0)},500))}),v=!0}Q&&(ve(),he())}Z.addEventListener("click",()=>bt(!p)),I.addEventListener("click",()=>{v=!0;let B=m.t1-m.t0,Q=Se();m={t0:Q-B*.98,t1:Q+B*.02},j()}),_.addEventListener("click",()=>{st()}),K.addEventListener("change",()=>{g=K.checked,F.clear(),D.clear(),fe(),he()}),de.addEventListener("change",()=>{J=de.checked,fe(),he()});function et(B){let Q=y?.rows.find(ie=>ie.scope===B);c=B,f=Q&&Q.children===0?0:1,M=void 0,z.hidden=!0,j(!0)}async function st(){let B=Se(),ie=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:B-400*en,to:B+1,bin:"1d",tz:t}).catch(()=>{}))?.bins??[]).map($e=>$e.t),pe=ie.length?Math.min(...ie):B-7*en;m={t0:pe,t1:B+(B-pe)*.02},v=!0,j()}let hn=0;async function Et(B){if(b=B,fe(),B===void 0){x=void 0;return}let Q=++hn,ie=e.source.stateAt?await e.source.stateAt(c,B).catch(()=>{}):void 0;Q===hn&&(x=ie,e.onPlayhead?.(B,ie),ve())}async function St(B,Q){M={from:Math.min(B,Q),to:Math.max(B,Q)},fe();let ie=await e.source.query(T(M.from,M.to,{kind:"single"},{limit:500})),pe=o(u),$e=Fe=>{let Le=[],xt=0;for(let[It,Jt]of ro(pe,Fe))Le.push(Fe.slice(xt,It),me("mark",null,Fe.slice(It,Jt))),xt=Jt;return Le.push(Fe.slice(xt)),Le},Ve=(ie.events??[]).map(Fe=>{let Le=me("tr",{"data-id":Fe.id,tabindex:"0"},me("td",null,Dt(Fe.t,t)),me("td",null,Fe.dur!==void 0?Wl(Fe.dur):Fe.open?"still going":""),me("td",null,Fe.source),me("td",null,Fe.kind),me("td",{class:`sev-${Fe.severity}`},Fe.severity),me("td",{class:"tlx-sum"},...$e(Fe.summary)),me("td",{class:"tlx-scope"},Fe.scope));return Le.addEventListener("click",()=>ft(Fe)),Le.addEventListener("keydown",xt=>{xt.key==="Enter"&&ft(Fe)}),Le}),Qe=me("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");Qe.addEventListener("click",()=>{M=void 0,z.hidden=!0,fe()});let Pn=Fe=>{let Le=me("button",{type:"button",class:"btn sm","data-export":Fe},Fe.toUpperCase());return Le.addEventListener("click",()=>{Tt(Fe)}),Le};z.replaceChildren(me("div",{class:"tlx-table-head"},me("strong",null,`${ie.total} event${ie.total===1?"":"s"}`),me("span",null,` ${Dt(M.from,t)} \u2013 ${Dt(M.to,t)}${ie.total>500?" (the first 500 shown; the export has them all)":""}`),me("span",{class:"spacer"}),me("span",null,"Export: "),Pn("json"),Pn("csv"),Qe),me("div",{class:"tlx-table-wrap"},me("table",null,me("thead",null,me("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(Fe=>me("th",{scope:"col"},Fe)))),me("tbody",null,...Ve)))),z.hidden=!1}async function vt(){if(!M)return[];let B=[],Q;do{let ie=await e.source.query(T(M.from,M.to,{kind:"single"},{limit:1e4,...Q?{cursor:Q}:{}}));B.push(...ie.events??[]),Q=ie.next}while(Q&&B.length<2e5);return B}async function Tt(B){let Q=await vt(),ie=B==="json"?ea(Q,L):ta(Q,L),pe=`timeline-${new Date(M.from).toISOString().slice(0,16).replace(/:/g,"")}.${B}`,$e=B==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(pe,ie,$e);return}let Ve=me("a",{href:`data:${$e};charset=utf-8,${encodeURIComponent(ie)}`,download:pe});document.body.append(Ve),Ve.click(),Ve.remove()}function ft(B){if(A=B,fe(),!B){G.hidden=!0;return}let Q=l?.sources.find(Le=>Le.name===B.source),ie=new Set(Q?.sensitive??[]),pe=o(u),$e=Le=>{let xt=[],It=0;for(let[Jt,lo]of ro(pe,Le))xt.push(Le.slice(It,Jt),me("mark",null,Le.slice(Jt,lo))),It=lo;return xt.push(Le.slice(It)),xt},Ve=(Le,xt)=>{if(!xt)return null;let It=me("button",{type:"button",class:"btn sm"},Le);return It.addEventListener("click",xt),It},Qe=Object.entries(B.attrs).map(([Le,xt])=>{if(!ie.has(Le))return me("tr",null,me("th",{scope:"row"},Le),me("td",null,...$e(String(xt))));let It=me("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),Jt=me("td",{class:"tlx-sensitive"},"hidden ",It);return It.addEventListener("click",()=>Jt.replaceChildren(String(xt))),me("tr",null,me("th",{scope:"row"},Le),Jt)}),Pn=me("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");Pn.addEventListener("click",()=>ft(void 0));let Fe=ur(B.scope).slice(1).map(Le=>{let xt=me("button",{type:"button",class:"tlx-crumb"},ue(Le.scope,Le.label));return xt.addEventListener("click",()=>et(Le.scope)),xt});G.replaceChildren(me("div",{class:"tlx-detail-head"},me("strong",null,B.kind),Pn),me("p",{class:`tlx-sev sev-${B.severity}`},`${B.severity} \xB7 ${Q?.title??B.source}`),me("p",{class:"tlx-sum"},...$e(B.summary)),me("p",null,Dt(B.t,t),B.dur!==void 0?` \xB7 ${Wl(B.dur)}${B.open?" so far":""}`:B.open?" \xB7 still going":""),me("p",{class:"tlx-crumbs small"},...Fe),...Qe.length?[me("table",{class:"tlx-attrs"},me("tbody",null,...Qe))]:[],me("div",{class:"tlx-links"},...(e.actions?.(B)??[]).map(([Le,xt])=>Ve(Le,xt)))),G.hidden=!1}function Cs(B,Q){let ie=Ns({from:B,to:Q});if(!H.find(Qe=>Qe.from===B&&Qe.to===Q))return;if(F.add(ie),!r){D.set(ie,1),fe();return}let $e=performance.now(),Ve=Qe=>{let Pn=Math.min(1,(Qe-$e)/260);D.set(ie,1-(1-Pn)**3),Ee(),Pn<1&&requestAnimationFrame(Ve)};requestAnimationFrame(Ve)}let At,ys=B=>B.clientX-ke.getBoundingClientRect().left;ke.addEventListener("pointerdown",B=>{let Q=ys(B),ie=B.clientY-ke.getBoundingClientRect().top,pe=B.target.closest?.(".tlx-cut");if(pe){B.preventDefault(),Cs(Number(pe.getAttribute("data-from")),Number(pe.getAttribute("data-to")));return}ke.setPointerCapture(B.pointerId),At={kind:ie<Un||B.shiftKey?"brush":B.target.classList.contains("tlx-handle")?"scrub":"pan",x0:Q,t0:X.t(Q),v0:m,moved:!1},B.preventDefault(),Pe.focus({preventScroll:!0})}),ke.addEventListener("pointermove",B=>{if(!At)return;let Q=ys(B);if(Math.abs(Q-At.x0)>3&&(At.moved=!0),!!At.moved)if(At.kind==="pan"){let ie=(At.x0-Q)*X.msPerPx;m={t0:At.v0.t0+ie,t1:At.v0.t1+ie},v=!1,j()}else At.kind==="scrub"?Et(X.t(Q)):(M={from:Math.min(At.t0,X.t(Q)),to:Math.max(At.t0,X.t(Q))},fe())}),ke.addEventListener("pointerup",B=>{let Q=At;if(At=void 0,!Q)return;let ie=ys(B);if(Q.kind==="brush"&&Q.moved){St(Q.t0,X.t(ie));return}if(Q.kind==="brush"&&!Q.moved){Et(X.t(ie));return}if(Q.kind==="pan"&&!Q.moved){let pe=B.target.closest?.("[data-id]")?.getAttribute("data-id"),$e=pe?[...y?.events??[],...y?.spans??[]].find(Ve=>Ve.id===pe):void 0;$e?(ft($e),Et($e.t)):Et(X.t(ie))}}),ke.addEventListener("keydown",B=>{let Q=B.target.closest?.(".tlx-cut");Q&&(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),Cs(Number(Q.getAttribute("data-from")),Number(Q.getAttribute("data-to"))))}),ke.addEventListener("wheel",B=>{B.preventDefault();let Q=ys(B);if(B.shiftKey||Math.abs(B.deltaX)>Math.abs(B.deltaY)){let ie=(B.shiftKey?B.deltaY:B.deltaX)*X.msPerPx;m={t0:m.t0+ie,t1:m.t1+ie},v=!1}else Is(X.t(Q),Math.exp(B.deltaY*.0015),Q/ae());j()},{passive:!1});function Is(B,Q,ie=.5){let pe=Math.min(400*en,Math.max(1e4,(m.t1-m.t0)*Q));m={t0:B-ie*pe,t1:B+(1-ie)*pe},F.clear(),D.clear(),Q<1&&(v=p&&m.t1>=Se())}Pe.addEventListener("keydown",B=>{let Q=m.t1-m.t0;if(B.key==="ArrowLeft"||B.key==="ArrowRight"){let ie=Q*.15*(B.key==="ArrowLeft"?-1:1);m={t0:m.t0+ie,t1:m.t1+ie},v=!1}else if(B.key==="+"||B.key==="=")Is((m.t0+m.t1)/2,.6);else if(B.key==="-"||B.key==="_")Is((m.t0+m.t1)/2,1/.6);else if(B.key==="n"||B.key==="N"){it(B.shiftKey?-1:1),B.preventDefault();return}else if(B.key==="Escape")ft(void 0),M=void 0,z.hidden=!0;else return;B.preventDefault(),j()}),n.addEventListener("keydown",B=>{B.key==="/"&&document.activeElement!==ce&&!B.target.closest("input, select, textarea")&&(B.preventDefault(),ce.focus())}),w.addEventListener("scroll",()=>fe(),{passive:!0}),ge.addEventListener("click",async()=>{let B=`${ur(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...te(),name:B}),await gn()});let Ge=[];async function gn(){e.views&&(Ge=await e.views(),ee.replaceChildren(me("option",{value:""},"Saved views\u2026"),...Ge.map((B,Q)=>me("option",{value:String(Q)},B.name))))}ee.addEventListener("change",()=>{let B=Ge[Number(ee.value)];B&&(xe(B),We(),j(!0)),ee.value=""});let rt=typeof ResizeObserver=="function"?new ResizeObserver(()=>fe()):void 0;rt?.observe(Pe);let Kt=(async()=>{l=await e.source.catalog(),L=l.sources.flatMap(pe=>(pe.sensitive??[]).map($e=>`${pe.name}.${$e}`));for(let pe of l.sources)for(let $e of pe.series)Y.set($e.name,{unit:$e.unit,type:$e.type,title:$e.title,source:pe.name});c=l.hosts.length===1?`host:${l.hosts[0].replace(/[%/:\s]/g,pe=>`%${pe.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let Q=l.now;m={t0:Q-en,t1:Q+en*.02};let ie=Oe()??e.view;ie&&xe(ie),We(),await gn(),await j(!0),u&&await Ke()})();return{el:n,ready:Kt,get view(){return te()},setView(B){return xe(B),We(),j(!0)},setRange(B,Q){return m={t0:B,t1:Q},v=!1,j()},setPlayhead:Et,setLive:bt,setTheme:a,refresh:()=>j(!0),internal:{get result(){return y},get mode(){return be()},get scale(){return X},get gaps(){return H},get playState(){return x},get hits(){return E},get selected(){return A},get follow(){return v},openCut:Cs,showTable:St,rangeEvents:vt,exportRange:Tt,select:ft,stepHit:it,drill:et,findHits:Ke,paint:Ee,lines:le},dispose(){P?.(),rt?.disconnect(),O&&cancelAnimationFrame(O),n.replaceChildren()}}}var cp={arrow:{d:"M0,0 L10,5 L0,10 z",refX:9},open:{d:"M0,0 L10,5 L0,10 L3,5 z",refX:9},diamond:{d:"M0,5 L5,1.5 L10,5 L5,8.5 z",refX:1}},_t=n=>(Math.round(n*10)/10).toString(),Vu=n=>(n??"link").replace(/[^\w-]/g,"_");function ra(n,e){let{id:t}=e,s=e.styles??{},r=n.options,o=n.bounds,i=new Map,a=(p,g)=>{let m=s[p]??{},y=g==="start"?m.start??"none":m.end??"arrow";if(y!=="none")return(i.get(p)??i.set(p,new Set).get(p)).add(y),`url(#${t}-mk-${p}-${y})`},l="",c="",f="",u="";for(let p of[...n.panels].sort((g,m)=>g.depth-m.depth)){let g=p.rect,m=p.label?Te("text",{class:"pl",x:p.titleAt[0],y:p.titleAt[1]},dt(p.label)+(p.sub?Te("tspan",{class:"pls",dx:10},dt(p.sub)):"")):"";l+=Te("g",{class:`panel k-${p.role??"grey"}`,"data-id":p.id},Te("rect",{class:"face",x:_t(g.l),y:_t(g.t),width:_t(g.r-g.l),height:_t(g.b-g.t),rx:r.panelRx})+m)}for(let p of n.links){if(!p.points.length)continue;let g=Vu(p.kind);c+=Te("path",{class:`conn k-${g}`,d:"M"+p.points.map(m=>`${_t(m[0])},${_t(m[1])}`).join(" L"),"data-id":p.id,"data-a":p.a,"data-b":p.b,"marker-start":a(g,"start"),"marker-end":a(g,"end")}),p.at&&(u+=Te("text",{class:`cl k-${g}`,x:p.at.x,y:p.at.y,"text-anchor":p.at.anchor==="start"?void 0:p.at.anchor,"data-for":p.id},dt(p.at.text)))}for(let p of n.cards){let g=p.rect;f+=Te("g",{class:`card k-${p.role??"grey"}${p.ghost?" ghost":""}`,"data-id":p.id,tabindex:0,role:"button","aria-label":p.sub?`${p.label}: ${p.sub}`:p.label},Te("rect",{class:"face",x:_t(g.l),y:_t(g.t),width:r.W,height:r.H,rx:r.cardRx})+Te("text",{class:"lt",x:_t(g.l+14),y:_t(g.t+24)},dt(p.label))+(p.sub?Te("text",{class:"st",x:_t(g.l+14),y:_t(g.t+42)},dt(p.sub)):""))}let d="";for(let[p,g]of i)for(let m of g){let y=cp[m];d+=Te("marker",{id:`${t}-mk-${p}-${m}`,viewBox:"0 0 10 10",refX:y.refX,refY:5,markerWidth:5.4,markerHeight:5.4,orient:"auto-start-reverse"},Te("path",{d:y.d,class:`mk k-${p}`}))}return Te("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${_t(o.l)} ${_t(o.t)} ${_t(o.r-o.l)} ${_t(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(d?Te("defs",{},d):"")+Te("g",{class:"panels"},l)+Te("g",{class:"conns"},c)+Te("g",{class:"cards"},f)+Te("g",{class:"labels"},u))}function Ku(n={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",t=`
|
|
360
369
|
.flat{font-family:inherit}
|
|
361
370
|
.flat .card{cursor:pointer;outline:none}
|
|
362
371
|
.flat .card .face{fill:hsl(var(--h) var(--s) var(--l-top));stroke:hsl(var(--h) var(--s) var(--l-edge) / .55);stroke-width:1}
|
|
@@ -374,8 +383,8 @@ ${e.extraBody??""}
|
|
|
374
383
|
.flat .panel.sel .face{stroke:var(--accent,#2f6fd6);stroke-width:2}
|
|
375
384
|
.flat .conn.hot{stroke-width:3}
|
|
376
385
|
.flat .conn.dim,.flat .cl.dim{opacity:.3}
|
|
377
|
-
`;for(let[s,r]of Object.entries(
|
|
378
|
-
`}return n}var Qu={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function mi(t){let e="http://www.w3.org/2000/svg",n=document.createElementNS(e,"svg");n.setAttribute("class","flat"),n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;left:-10000px;top:0;width:10px;height:10px;visibility:hidden",t.appendChild(n);let s={};for(let[i,[a,l]]of Object.entries(Qu)){let c=document.createElementNS(e,"g");a&&c.setAttribute("class",a);let f=document.createElementNS(e,"text");f.setAttribute("class",l),c.appendChild(f),n.appendChild(c),s[i]=f}let r=new Map,o=((i,a)=>{let l=a+"\0"+i,c=r.get(l);return c===void 0&&(s[a].textContent=i,c=s[a].getComputedTextLength(),r.set(l,c)),c});return o.dispose=()=>n.remove(),o}var of=(t,e)=>t.cards.find(n=>n.id===e)?.rect??t.panels.find(n=>n.id===e)?.rect;var Qn="http://www.w3.org/2000/svg";function gi(t,e,n){let s=new Map((n?.links??[]).map((r,o)=>[r.id??`link-${o}`,r]));for(let r of e.routes){let o=s.get(r.id),i=o?.a??Ut(r.raw.from).id,a=o?.b??Ut(r.raw.to).id;for(let l of t.querySelectorAll(`[data-id="${CSS.escape(r.id)}"]`))l.setAttribute("data-a",i),l.setAttribute("data-b",a)}}var Zu=(t="auto")=>t==="always"||t==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function cf(t,e,n,s,r={}){let o=r.duration??600;if(!o||!Zu(r.motion))return;let i=vr(t,e,n,s);t.appendChild(i.svg),i.at(0);let a=0,l=!1,c,f=new Promise(h=>c=h),u=()=>{l||(l=!0,cancelAnimationFrame(a),i.svg.remove(),c())},d=performance.now(),p=h=>{if(l)return;let m=Math.min(1,(h-d)/o);i.at(m),m<1?a=requestAnimationFrame(p):u()};return a=requestAnimationFrame(p),{done:f,finish:u}}var _n=t=>Math.max(0,Math.min(1,t)),kr=t=>t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2;function hi(t){let e=t.cloneNode(!0),n=[t,...t.querySelectorAll("*")],s=[e,...e.querySelectorAll("*")];return n.forEach((r,o)=>{let i=getComputedStyle(r),a=s[o];a.removeAttribute("class"),a.removeAttribute("tabindex");for(let l of["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-opacity","opacity","font-size","font-weight","font-family","letter-spacing","paint-order","stroke-linejoin","text-anchor"])a.style.setProperty(l,i.getPropertyValue(l))}),e}var Ua=(t,e)=>{let n=t.getBoundingClientRect();return{x:n.left-e.left,y:n.top-e.top,w:n.width,h:n.height}},af=t=>{let e=Math.min(...t.map(o=>o.x)),n=Math.min(...t.map(o=>o.y)),s=Math.max(...t.map(o=>o.x+o.w)),r=Math.max(...t.map(o=>o.y+o.h));return{x:e,y:n,w:s-e,h:r-n}},ed=(t,e)=>{let n=t.getScreenCTM();return`matrix(${n.a} ${n.b} ${n.c} ${n.d} ${n.e-e.left} ${n.f-e.top})`},lf=(t,e,n)=>{let s=1+(e.w/Math.max(t.w,1e-6)-1)*n,r=1+(e.h/Math.max(t.h,1e-6)-1)*n,o=(e.x-t.x*(e.w/Math.max(t.w,1e-6)))*n,i=(e.y-t.y*(e.h/Math.max(t.h,1e-6)))*n;return`matrix(${s} 0 0 ${r} ${o} ${i})`};function td(t,e){let n=t.querySelector("polygon.top");if(!n)return;let s=n.getScreenCTM(),r=[];for(let o=0;o<n.points.numberOfItems;o++){let i=n.points.getItem(o);r.push([s.a*i.x+s.c*i.y+s.e-e.left,s.b*i.x+s.d*i.y+s.f-e.top])}return r.length===4?{pts:r,fill:getComputedStyle(n).fill}:void 0}function vr(t,e,n,s){let r=t.getBoundingClientRect(),o=document.createElementNS(Qn,"svg");o.setAttribute("class","dual-morph"),o.setAttribute("aria-hidden","true"),o.style.cssText=`position:absolute;left:0;top:0;width:${r.width}px;height:${Math.max(r.height,e.getBoundingClientRect().height,n.getBoundingClientRect().height)}px;overflow:visible;pointer-events:none`;let i=R=>{let E=document.createElementNS(Qn,"g");return E.setAttribute("transform",ed(R,r)),E},a=R=>R.hasAttribute("data-a")||R.hasAttribute("data-for"),l=R=>{let E=new Map;for(let w of R.querySelectorAll("[data-id]")){if(a(w)||w.parentElement?.closest("[data-id]")||w.closest(".overlay"))continue;let T=w.getAttribute("data-id");(E.get(T)??E.set(T,[]).get(T)).push(w)}return E},c=l(e),f=l(n),u=document.createElementNS(Qn,"g"),d=document.createElementNS(Qn,"g"),p=i(e),h=i(n);for(let R of e.querySelectorAll("[data-a],[data-for]"))R.closest(".overlay")||p.appendChild(hi(R));for(let R of n.querySelectorAll("[data-a],[data-for]"))R.closest(".overlay")||h.appendChild(hi(R));u.appendChild(p),d.appendChild(h);let m=[...h.querySelectorAll("path")].map(R=>{let E=R.getTotalLength?.()??0;return{p:R,len:E}}),y=[...h.children].filter(R=>R.tagName.toLowerCase()==="text"),I=[...(s==="2d"?c:f).keys()],N=[],M=document.createElementNS(Qn,"g");for(let R of new Set([...I,...c.keys(),...f.keys()])){let E=c.get(R),w=f.get(R),T={};if(E){T.a=af(E.map(O=>Ua(O,r)));let v=document.createElementNS(Qn,"g"),g=i(e);for(let O of E)g.appendChild(hi(O));v.appendChild(g),T.src=v}if(w){T.b=af(w.map(O=>Ua(O,r)));let v=document.createElementNS(Qn,"g"),g=i(n);for(let O of w)g.appendChild(hi(O));v.appendChild(g),T.dst=v}let L=s==="3d"?E?.[0]:w?.[0],x=s==="3d"?w?.[0]:E?.[0],P=L?td(L,r):void 0,b=x?.querySelector("rect.face");if(P&&b){let v=Ua(b,r),g=[[v.x,v.y],[v.x+v.w,v.y],[v.x+v.w,v.y+v.h],[v.x,v.y+v.h]],O=P.pts.reduce((B,K,q)=>K[0]<P.pts[B][0]?q:B,0),F=[...P.pts.slice(O),...P.pts.slice(0,O)],j=[F[0],F[1],F[2],F[3]],U=getComputedStyle(b).fill,ne=document.createElementNS(Qn,"polygon");T.face=ne,T.faceFrom=s==="3d"?j:g,T.faceTo=s==="3d"?g:j,T.faceFill=s==="3d"?[P.fill,U]:[U,P.fill]}T.src&&M.appendChild(T.src),T.face&&M.appendChild(T.face),T.dst&&M.appendChild(T.dst),N.push(T)}o.append(u,M,d);let $=(R,E,w)=>`color-mix(in srgb, ${R} ${Math.round((1-w)*100)}%, ${E})`;return{svg:o,at(R){let E=_n(R/.2),w=kr(_n((R-.2)/.6)),T=_n((R-.8)/.2);u.setAttribute("opacity",String(1-E));for(let{p:L,len:x}of m)L.style.strokeDasharray=`${x} ${x}`,L.style.strokeDashoffset=String(x*(1-T));d.setAttribute("opacity",String(T>0?1:0));for(let L of y)L.style.opacity=String(T);for(let L of N)if(L.src&&(L.src.setAttribute("transform",L.a&&L.b?lf(L.a,L.b,w):""),L.src.setAttribute("opacity",String(L.b?1-_n(w/(L.face?.35:.6)):1-w))),L.dst&&(L.dst.setAttribute("transform",L.a&&L.b?lf(L.b,L.a,1-w):""),L.dst.setAttribute("opacity",String(L.a?_n((w-(L.face?.65:.4))/(L.face?.35:.6)):w))),L.face){let x=L.faceFrom.map((P,b)=>[P[0]+(L.faceTo[b][0]-P[0])*w,P[1]+(L.faceTo[b][1]-P[1])*w]);L.face.setAttribute("points",x.map(P=>P.join(",")).join(" ")),L.face.style.fill=$(L.faceFill[0],L.faceFill[1],w),L.face.setAttribute("opacity",String(w<.08?w/.08:w>.92?(1-w)/.08:1))}}}}var nd=0;function ff(t,e,n={}){let s=`dv${++nd}`,r=document.createElement("div");r.className="dual-view",r.style.position="relative",t.appendChild(r);let o=document.createElement("div"),i=document.createElement("div");o.className="dual-3d",i.className="dual-2d",r.append(o,i),o.innerHTML=e.rendered.svg;let a=o.querySelector("svg");a.setAttribute("data-view","3d");let l=n.board??Wo(e);gi(a,e,l);let c=new Set(e.routes.map(x=>x.id));for(let x of a.querySelectorAll("g[data-id]")){let P=x.getAttribute("data-id");c.has(P)||x.hasAttribute("tabindex")||!x.querySelector("polygon")||(x.setAttribute("tabindex","0"),x.setAttribute("role","button"),x.setAttribute("aria-label",P))}let f=mi(i),u=Os(l,f,n.flat);f.dispose(),i.innerHTML=pi(u,{id:s,title:n.title,styles:n.styles});let d=i.querySelector("svg");for(let x of[a,d])x.style.display="block",x.style.width="100%",x.style.height="auto";n.title&&a.setAttribute("aria-label",n.title);let p=n.mode??"3d",h,m=x=>x==="3d"?o:i,y=x=>x==="3d"?a:d,I=x=>{o.hidden=x!=="3d",i.hidden=x!=="2d";for(let P of[o,i])P.style.cssText="";r.style.height="",r.dataset.mode=x};I(p);let N=()=>{for(let x of[a,d]){for(let P of x.querySelectorAll("[data-id]"))P.classList.toggle("sel",!!h&&P.getAttribute("data-id")===h);for(let P of x.querySelectorAll("[data-a]")){let b=!!h&&(P.getAttribute("data-a")===h||P.getAttribute("data-b")===h);P.classList.toggle("hot",b),P.classList.toggle("dim",!!h&&!b),x.querySelector(`[data-for="${CSS.escape(P.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!h&&!b)}}},M=x=>{h=x,N()},$=x=>{let P=x.target.closest?.("[data-id]");if(!P||!r.contains(P)||P.hasAttribute("data-a"))return;let b=P.getAttribute("data-id");M(b),n.onSelect?.(b)},R=x=>{(x.key==="Enter"||x.key===" ")&&x.target.matches?.("[data-id][tabindex]")&&(x.preventDefault(),$(x))};r.addEventListener("click",$),r.addEventListener("keydown",R);let E,w=()=>{if(!E)return;cancelAnimationFrame(E.frame),E.layer.remove();let x=E;E=void 0,p=x.to,I(p),N(),x.done()},T=x=>{!x||!h||y(p).querySelector(`[data-id="${CSS.escape(h)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return E?E.to:p},layout:u,root:r,morph:x=>{let P=r.contains(document.activeElement);if(E&&w(),x===p)return T(P),Promise.resolve();let b=n.motion??"auto";return b==="never"||b==="auto"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches||!(n.duration??600)?(p=x,I(p),N(),T(P),Promise.resolve()):new Promise(g=>{let O=p,F=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let Z of[o,i])Z.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let j=m(x).getBoundingClientRect().height;r.style.height=`${F}px`;let U=vr(r,y(O),y(x),O);r.appendChild(U.svg);let ne=n.duration??600,B=performance.now(),K={frame:0,layer:U.svg,to:x,done:()=>{T(P),g()}},q=Z=>{if(E!==K)return;let A=Math.min(1,(Z-B)/ne);U.at(A),r.style.height=`${F+(j-F)*kr(_n((A-.2)/.6))}px`,A<1?K.frame=requestAnimationFrame(q):w()};E=K,K.frame=requestAnimationFrame(q)})},select:M,get selected(){return h},svgOf:y,destroy(){E&&w(),r.removeEventListener("click",$),r.removeEventListener("keydown",R),r.remove()}}}function uf(t="iso-view"){try{let e=localStorage.getItem(t);return e==="2d"||e==="3d"?e:void 0}catch{return}}function df(t,e,n={}){let s=n.storageKey??"iso-view",r=Array.isArray(e)?e:[e],o=document.createElement("div");o.className="view-switch",o.setAttribute("role","group"),o.setAttribute("aria-label","Drawing view");let i=["3d","2d"].map((l,c)=>{let f=document.createElement("button");return f.type="button",f.dataset.mode=l,f.textContent=(n.labels??["3D","2D"])[c],f.addEventListener("click",()=>{try{localStorage.setItem(s,l)}catch{}a(l);for(let u of r)u.morph(l)}),o.appendChild(f),f}),a=l=>i.forEach(c=>c.setAttribute("aria-pressed",String(c.dataset.mode===l)));return a(r[0]?.mode??"3d"),t.appendChild(o),o}var pf=`
|
|
386
|
+
`;for(let[s,r]of Object.entries(n)){let o=Vu(s),i=e(r.color);t+=`.flat .conn.k-${o}{stroke:${i}${r.dash?`;stroke-dasharray:${r.dash}`:""}${r.width?`;stroke-width:${r.width}`:""}} .flat .mk.k-${o}{fill:${i}} .flat .cl.k-${o}{fill:${i}}
|
|
387
|
+
`}return t}var fp={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function oa(n){let e="http://www.w3.org/2000/svg",t=document.createElementNS(e,"svg");t.setAttribute("class","flat"),t.setAttribute("aria-hidden","true"),t.style.cssText="position:absolute;left:-10000px;top:0;width:10px;height:10px;visibility:hidden",n.appendChild(t);let s={};for(let[i,[a,l]]of Object.entries(fp)){let c=document.createElementNS(e,"g");a&&c.setAttribute("class",a);let f=document.createElementNS(e,"text");f.setAttribute("class",l),c.appendChild(f),t.appendChild(c),s[i]=f}let r=new Map,o=((i,a)=>{let l=a+"\0"+i,c=r.get(l);return c===void 0&&(s[a].textContent=i,c=s[a].getComputedTextLength(),r.set(l,c)),c});return o.dispose=()=>t.remove(),o}var Gu=(n,e)=>n.cards.find(t=>t.id===e)?.rect??n.panels.find(t=>t.id===e)?.rect;var gs="http://www.w3.org/2000/svg";function aa(n,e,t){let s=new Map((t?.links??[]).map((r,o)=>[r.id??`link-${o}`,r]));for(let r of e.routes){let o=s.get(r.id),i=o?.a??Qt(r.raw.from).id,a=o?.b??Qt(r.raw.to).id;for(let l of n.querySelectorAll(`[data-id="${CSS.escape(r.id)}"]`))l.setAttribute("data-a",i),l.setAttribute("data-b",a)}}var up=(n="auto")=>n==="always"||n==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function Yu(n,e,t,s,r={}){let o=r.duration??600;if(!o||!up(r.motion))return;let i=ao(n,e,t,s);n.appendChild(i.svg),i.at(0);let a=0,l=!1,c,f=new Promise(g=>c=g),u=()=>{l||(l=!0,cancelAnimationFrame(a),i.svg.remove(),c())},d=performance.now(),p=g=>{if(l)return;let m=Math.min(1,(g-d)/o);i.at(m),m<1?a=requestAnimationFrame(p):u()};return a=requestAnimationFrame(p),{done:f,finish:u}}var es=n=>Math.max(0,Math.min(1,n)),io=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2;function ia(n){let e=n.cloneNode(!0),t=[n,...n.querySelectorAll("*")],s=[e,...e.querySelectorAll("*")];return t.forEach((r,o)=>{let i=getComputedStyle(r),a=s[o];a.removeAttribute("class"),a.removeAttribute("tabindex");for(let l of["fill","fill-opacity","stroke","stroke-width","stroke-dasharray","stroke-opacity","opacity","font-size","font-weight","font-family","letter-spacing","paint-order","stroke-linejoin","text-anchor"])a.style.setProperty(l,i.getPropertyValue(l))}),e}var Ql=(n,e)=>{let t=n.getBoundingClientRect();return{x:t.left-e.left,y:t.top-e.top,w:t.width,h:t.height}},qu=n=>{let e=Math.min(...n.map(o=>o.x)),t=Math.min(...n.map(o=>o.y)),s=Math.max(...n.map(o=>o.x+o.w)),r=Math.max(...n.map(o=>o.y+o.h));return{x:e,y:t,w:s-e,h:r-t}},dp=(n,e)=>{let t=n.getScreenCTM();return`matrix(${t.a} ${t.b} ${t.c} ${t.d} ${t.e-e.left} ${t.f-e.top})`},Uu=(n,e,t)=>{let s=1+(e.w/Math.max(n.w,1e-6)-1)*t,r=1+(e.h/Math.max(n.h,1e-6)-1)*t,o=(e.x-n.x*(e.w/Math.max(n.w,1e-6)))*t,i=(e.y-n.y*(e.h/Math.max(n.h,1e-6)))*t;return`matrix(${s} 0 0 ${r} ${o} ${i})`};function mp(n,e){let t=n.querySelector("polygon.top");if(!t)return;let s=t.getScreenCTM(),r=[];for(let o=0;o<t.points.numberOfItems;o++){let i=t.points.getItem(o);r.push([s.a*i.x+s.c*i.y+s.e-e.left,s.b*i.x+s.d*i.y+s.f-e.top])}return r.length===4?{pts:r,fill:getComputedStyle(t).fill}:void 0}function ao(n,e,t,s){let r=n.getBoundingClientRect(),o=document.createElementNS(gs,"svg");o.setAttribute("class","dual-morph"),o.setAttribute("aria-hidden","true"),o.style.cssText=`position:absolute;left:0;top:0;width:${r.width}px;height:${Math.max(r.height,e.getBoundingClientRect().height,t.getBoundingClientRect().height)}px;overflow:visible;pointer-events:none`;let i=A=>{let M=document.createElementNS(gs,"g");return M.setAttribute("transform",dp(A,r)),M},a=A=>A.hasAttribute("data-a")||A.hasAttribute("data-for"),l=A=>{let M=new Map;for(let v of A.querySelectorAll("[data-id]")){if(a(v)||v.parentElement?.closest("[data-id]")||v.closest(".overlay"))continue;let O=v.getAttribute("data-id");(M.get(O)??M.set(O,[]).get(O)).push(v)}return M},c=l(e),f=l(t),u=document.createElementNS(gs,"g"),d=document.createElementNS(gs,"g"),p=i(e),g=i(t);for(let A of e.querySelectorAll("[data-a],[data-for]"))A.closest(".overlay")||p.appendChild(ia(A));for(let A of t.querySelectorAll("[data-a],[data-for]"))A.closest(".overlay")||g.appendChild(ia(A));u.appendChild(p),d.appendChild(g);let m=[...g.querySelectorAll("path")].map(A=>{let M=A.getTotalLength?.()??0;return{p:A,len:M}}),y=[...g.children].filter(A=>A.tagName.toLowerCase()==="text"),N=[...(s==="2d"?c:f).keys()],h=[],b=document.createElementNS(gs,"g");for(let A of new Set([...N,...c.keys(),...f.keys()])){let M=c.get(A),v=f.get(A),O={};if(M){O.a=qu(M.map(F=>Ql(F,r)));let E=document.createElementNS(gs,"g"),S=i(e);for(let F of M)S.appendChild(ia(F));E.appendChild(S),O.src=E}if(v){O.b=qu(v.map(F=>Ql(F,r)));let E=document.createElementNS(gs,"g"),S=i(t);for(let F of v)S.appendChild(ia(F));E.appendChild(S),O.dst=E}let C=s==="3d"?M?.[0]:v?.[0],$=s==="3d"?v?.[0]:M?.[0],P=C?mp(C,r):void 0,k=$?.querySelector("rect.face");if(P&&k){let E=Ql(k,r),S=[[E.x,E.y],[E.x+E.w,E.y],[E.x+E.w,E.y+E.h],[E.x,E.y+E.h]],F=P.pts.reduce((L,q,U)=>q[0]<P.pts[L][0]?U:L,0),D=[...P.pts.slice(F),...P.pts.slice(0,F)],H=[D[0],D[1],D[2],D[3]],X=getComputedStyle(k).fill,Y=document.createElementNS(gs,"polygon");O.face=Y,O.faceFrom=s==="3d"?H:S,O.faceTo=s==="3d"?S:H,O.faceFill=s==="3d"?[P.fill,X]:[X,P.fill]}O.src&&b.appendChild(O.src),O.face&&b.appendChild(O.face),O.dst&&b.appendChild(O.dst),h.push(O)}o.append(u,b,d);let x=(A,M,v)=>`color-mix(in srgb, ${A} ${Math.round((1-v)*100)}%, ${M})`;return{svg:o,at(A){let M=es(A/.2),v=io(es((A-.2)/.6)),O=es((A-.8)/.2);u.setAttribute("opacity",String(1-M));for(let{p:C,len:$}of m)C.style.strokeDasharray=`${$} ${$}`,C.style.strokeDashoffset=String($*(1-O));d.setAttribute("opacity",String(O>0?1:0));for(let C of y)C.style.opacity=String(O);for(let C of h)if(C.src&&(C.src.setAttribute("transform",C.a&&C.b?Uu(C.a,C.b,v):""),C.src.setAttribute("opacity",String(C.b?1-es(v/(C.face?.35:.6)):1-v))),C.dst&&(C.dst.setAttribute("transform",C.a&&C.b?Uu(C.b,C.a,1-v):""),C.dst.setAttribute("opacity",String(C.a?es((v-(C.face?.65:.4))/(C.face?.35:.6)):v))),C.face){let $=C.faceFrom.map((P,k)=>[P[0]+(C.faceTo[k][0]-P[0])*v,P[1]+(C.faceTo[k][1]-P[1])*v]);C.face.setAttribute("points",$.map(P=>P.join(",")).join(" ")),C.face.style.fill=x(C.faceFill[0],C.faceFill[1],v),C.face.setAttribute("opacity",String(v<.08?v/.08:v>.92?(1-v)/.08:1))}}}}var pp=0;function Hu(n,e,t={}){let s=`dv${++pp}`,r=document.createElement("div");r.className="dual-view",r.style.position="relative",n.appendChild(r);let o=document.createElement("div"),i=document.createElement("div");o.className="dual-3d",i.className="dual-2d",r.append(o,i),o.innerHTML=e.rendered.svg;let a=o.querySelector("svg");a.setAttribute("data-view","3d");let l=t.board??_i(e);aa(a,e,l);let c=new Set(e.routes.map($=>$.id));for(let $ of a.querySelectorAll("g[data-id]")){let P=$.getAttribute("data-id");c.has(P)||$.hasAttribute("tabindex")||!$.querySelector("polygon")||($.setAttribute("tabindex","0"),$.setAttribute("role","button"),$.setAttribute("aria-label",P))}let f=oa(i),u=lr(l,f,t.flat);f.dispose(),i.innerHTML=ra(u,{id:s,title:t.title,styles:t.styles});let d=i.querySelector("svg");for(let $ of[a,d])$.style.display="block",$.style.width="100%",$.style.height="auto";t.title&&a.setAttribute("aria-label",t.title);let p=t.mode??"3d",g,m=$=>$==="3d"?o:i,y=$=>$==="3d"?a:d,N=$=>{o.hidden=$!=="3d",i.hidden=$!=="2d";for(let P of[o,i])P.style.cssText="";r.style.height="",r.dataset.mode=$};N(p);let h=()=>{for(let $ of[a,d]){for(let P of $.querySelectorAll("[data-id]"))P.classList.toggle("sel",!!g&&P.getAttribute("data-id")===g);for(let P of $.querySelectorAll("[data-a]")){let k=!!g&&(P.getAttribute("data-a")===g||P.getAttribute("data-b")===g);P.classList.toggle("hot",k),P.classList.toggle("dim",!!g&&!k),$.querySelector(`[data-for="${CSS.escape(P.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!g&&!k)}}},b=$=>{g=$,h()},x=$=>{let P=$.target.closest?.("[data-id]");if(!P||!r.contains(P)||P.hasAttribute("data-a"))return;let k=P.getAttribute("data-id");b(k),t.onSelect?.(k)},A=$=>{($.key==="Enter"||$.key===" ")&&$.target.matches?.("[data-id][tabindex]")&&($.preventDefault(),x($))};r.addEventListener("click",x),r.addEventListener("keydown",A);let M,v=()=>{if(!M)return;cancelAnimationFrame(M.frame),M.layer.remove();let $=M;M=void 0,p=$.to,N(p),h(),$.done()},O=$=>{!$||!g||y(p).querySelector(`[data-id="${CSS.escape(g)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return M?M.to:p},layout:u,root:r,morph:$=>{let P=r.contains(document.activeElement);if(M&&v(),$===p)return O(P),Promise.resolve();let k=t.motion??"auto";return k==="never"||k==="auto"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches||!(t.duration??600)?(p=$,N(p),h(),O(P),Promise.resolve()):new Promise(S=>{let F=p,D=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let Z of[o,i])Z.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let H=m($).getBoundingClientRect().height;r.style.height=`${D}px`;let X=ao(r,y(F),y($),F);r.appendChild(X.svg);let Y=t.duration??600,L=performance.now(),q={frame:0,layer:X.svg,to:$,done:()=>{O(P),S()}},U=Z=>{if(M!==q)return;let I=Math.min(1,(Z-L)/Y);X.at(I),r.style.height=`${D+(H-D)*io(es((I-.2)/.6))}px`,I<1?q.frame=requestAnimationFrame(U):v()};M=q,q.frame=requestAnimationFrame(U)})},select:b,get selected(){return g},svgOf:y,destroy(){M&&v(),r.removeEventListener("click",x),r.removeEventListener("keydown",A),r.remove()}}}function Wu(n="iso-view"){try{let e=localStorage.getItem(n);return e==="2d"||e==="3d"?e:void 0}catch{return}}function Ju(n,e,t={}){let s=t.storageKey??"iso-view",r=Array.isArray(e)?e:[e],o=document.createElement("div");o.className="view-switch",o.setAttribute("role","group"),o.setAttribute("aria-label","Drawing view");let i=["3d","2d"].map((l,c)=>{let f=document.createElement("button");return f.type="button",f.dataset.mode=l,f.textContent=(t.labels??["3D","2D"])[c],f.addEventListener("click",()=>{try{localStorage.setItem(s,l)}catch{}a(l);for(let u of r)u.morph(l)}),o.appendChild(f),f}),a=l=>i.forEach(c=>c.setAttribute("aria-pressed",String(c.dataset.mode===l)));return a(r[0]?.mode??"3d"),n.appendChild(o),o}var Xu=`
|
|
379
388
|
.view-switch{display:inline-flex;border:1px solid var(--line);border-radius:8px;overflow:hidden;background:var(--surface);font:600 12px/1 system-ui,sans-serif;box-shadow:0 1px 4px rgba(0,0,0,.12)}
|
|
380
389
|
.view-switch button{font:inherit;border:0;background:none;color:var(--ink);padding:6px 10px;cursor:pointer}
|
|
381
390
|
.view-switch button+button{border-left:1px solid var(--line)}
|
|
@@ -385,4 +394,4 @@ ${e.extraBody??""}
|
|
|
385
394
|
.dual-view .blk.sel polygon{stroke:var(--accent,#2f6fd6);stroke-width:2.4}
|
|
386
395
|
.dual-view [data-a].dim{opacity:.3}
|
|
387
396
|
.dual-view [data-a].hot path{stroke-width:3.4}
|
|
388
|
-
`;export{
|
|
397
|
+
`;export{cf as core,du as objects,Qu as viewer};
|