@johnoscott/isometric-engine 0.15.0 → 0.17.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/README.md +3 -1
- package/iso-editor.js +230 -193
- package/iso-remotion.js +353 -0
- package/iso-render.js +184 -147
- package/iso-systems.js +183 -146
- package/isometric-diagram.js +389 -0
- package/js/iso-core/arimo.js +5 -0
- package/js/iso-core/arimo.json +1 -0
- package/js/iso-core/index.js +8 -2
- package/js/iso-core/kernel.js +13 -2
- package/js/iso-core/mono.js +242 -0
- package/js/iso-editor/ui/canvas.js +23 -1
- package/js/iso-objects/ants.js +1 -1
- package/js/iso-objects/index.js +10 -2
- package/js/iso-objects/mono-paint.js +96 -0
- package/js/iso-objects/motion-doc.js +0 -79
- package/js/iso-objects/motion-entry.js +4 -2
- package/js/iso-objects/motion-schema.js +83 -0
- package/js/iso-objects/motion.js +9 -4
- package/js/iso-objects/timeline.js +60 -16
- package/js/iso-systems/compile.js +34 -3
- package/js/iso-systems/render.js +1 -1
- package/js/iso-systems/schema.json +1 -0
- package/js/iso-viewer/index.js +6 -0
- package/js/iso-viewer/page.js +40 -17
- package/js/iso-viewer/play.js +340 -0
- package/js/iso-viewer/player.js +147 -162
- package/js/iso-viewer/transport.js +289 -0
- package/package.json +61 -2
- package/src/iso-core/arimo.json +1 -0
- package/src/iso-core/arimo.ts +6 -0
- package/src/iso-core/index.ts +2 -1
- package/src/iso-core/kernel.ts +11 -1
- package/src/iso-core/mono.ts +306 -0
- package/src/iso-core/theme.ts +2 -1
- package/src/iso-editor/ui/canvas.ts +14 -1
- package/src/iso-objects/ants.ts +2 -2
- package/src/iso-objects/index.ts +5 -3
- package/src/iso-objects/mono-paint.ts +97 -0
- package/src/iso-objects/motion-doc.ts +0 -52
- package/src/iso-objects/motion-entry.ts +4 -3
- package/src/iso-objects/motion-schema.ts +55 -0
- package/src/iso-objects/motion.ts +6 -5
- package/src/iso-objects/scene.ts +3 -0
- package/src/iso-objects/timeline.ts +71 -15
- package/src/iso-objects/types.ts +2 -0
- package/src/iso-systems/compile.ts +37 -4
- package/src/iso-systems/render.ts +5 -1
- package/src/iso-systems/schema.json +1 -0
- package/src/iso-viewer/index.ts +4 -0
- package/src/iso-viewer/page.ts +28 -12
- package/src/iso-viewer/play.ts +280 -0
- package/src/iso-viewer/player.ts +133 -134
- package/src/iso-viewer/transport.ts +272 -0
- package/types/iso-core/arimo.d.ts +2 -0
- package/types/iso-core/index.d.ts +2 -1
- package/types/iso-core/kernel.d.ts +9 -0
- package/types/iso-core/mono.d.ts +61 -0
- package/types/iso-core/theme.d.ts +2 -0
- package/types/iso-objects/ants.d.ts +1 -0
- package/types/iso-objects/index.d.ts +5 -3
- package/types/iso-objects/mono-paint.d.ts +20 -0
- package/types/iso-objects/motion-doc.d.ts +0 -594
- package/types/iso-objects/motion-entry.d.ts +4 -3
- package/types/iso-objects/motion-schema.d.ts +594 -0
- package/types/iso-objects/motion.d.ts +4 -2
- package/types/iso-objects/scene.d.ts +3 -0
- package/types/iso-objects/timeline.d.ts +26 -3
- package/types/iso-objects/types.d.ts +2 -0
- package/types/iso-systems/compile.d.ts +8 -0
- package/types/iso-systems/render.d.ts +4 -0
- package/types/iso-viewer/index.d.ts +4 -0
- package/types/iso-viewer/play.d.ts +37 -0
- package/types/iso-viewer/transport.d.ts +73 -0
- package/types/player/isometric-diagram.d.ts +24 -0
- package/types/remotion/entry.d.ts +2 -0
- package/types/remotion/frames.d.ts +70 -0
- package/types/remotion/index.d.ts +39 -0
package/iso-render.js
CHANGED
|
@@ -1,154 +1,156 @@
|
|
|
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
|
-
`)}};
|
|
3
|
-
`)?
|
|
1
|
+
var Pd=Object.defineProperty;var Sa=(n,e)=>{for(var t in e)Pd(n,t,{get:e[t],enumerable:!0})};var If={};Sa(If,{Bounds:()=>kr,C:()=>wt,DiagError:()=>li,FONTS:()=>lt,Kernel:()=>js,MONO:()=>jt,S:()=>st,VEl:()=>Vr,allowed:()=>sl,apply:()=>xr,bubble:()=>ko,buildSvg:()=>Af,center:()=>xo,colorRef:()=>An,contrast:()=>qr,createHash:()=>Rf,depthSort:()=>Sr,didYouMean:()=>Bt,distance:()=>tl,envelope:()=>wo,esc:()=>mt,extendTheme:()=>Xs,faceFrame:()=>$a,fileLines:()=>vo,formatDiag:()=>nl,formatDiags:()=>Sf,greyOf:()=>Gr,iso:()=>Ce,keyGlyph:()=>Ac,loadTheme:()=>ii,matStr:()=>wr,monoOf:()=>ui,n1:()=>at,parse:()=>Mf,parseSvg:()=>rl,placeholderFace:()=>Nc,pt:()=>xs,screenFaces:()=>Ds,screenGlass:()=>Rc,serialize:()=>ci,sha256Hex:()=>ol,socketGlyph:()=>Oc,tag:()=>Te,termLines:()=>vr,textWidth:()=>ln,themeCss:()=>ai,themeParts:()=>Kr,vdoc:()=>Of,withFont:()=>Ec});var Tc={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 st=34,wt=Math.cos(Math.PI/6),Ce=(n,e,t=0)=>[(n-e)*wt*st,(n+e)*.5*st-t*st],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])}`,mt=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}="${mt(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}},yo;function Ec(n,e){let t=yo;yo=n;try{return e()}finally{yo=t}}function ln(n,e){let t=yo?.widths[e.key]??Tc[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 xr=(n,e,t)=>[n[0]*e+n[2]*t+n[4],n[1]*e+n[3]*t+n[5]],wr=n=>`matrix(${n.map(e=>Math.round(e*1e4)/1e4).join(" ")})`;function $a(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)*st,h:(n.z1-n.z0)*st}}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)*st,h:(n.z1-n.z0)*st}}let[t,s]=Ce(n.x0,n.y0,n.z1);return{m:[wt,.5,-wt,.5,t,s],w:(n.x1-n.x0)*st,h:(n.y1-n.y0)*st}}var kr=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}},js=class{bounds=new kr;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:l}=e;return this.poly([[t,o,i],[r,o,i],[r,o,l],[t,o,l]],"lft")+this.poly([[r,s,i],[r,o,i],[r,o,l],[r,s,l]],"rgt")+this.poly([[t,s,l],[r,s,l],[r,o,l],[t,o,l]],"top")}onFace(e,t,s,r){let o=$a(e,t);for(let[i,l]of[[0,0],[o.w,0],[0,o.h],[o.w,o.h]])this.bounds.add(xr(o.m,i,l));return Te("g",{class:r,transform:wr(o.m)},s(o.w,o.h))}onMatrix(e,t,s,r,o){for(let[i,l]of[[0,0],[t,0],[0,s],[t,s]])this.bounds.add(xr(e,i,l));return Te("g",{class:o,transform:wr(e)},r(t,s))}text(e,t,s,r,o,i="middle",l={},a){let c=ln(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:a};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,...l},mt(s))}planeText(e,t,s,r,o="start",i={}){let l=ln(t,r),a=o==="start"?0:o==="end"?-l:-l/2,c=[[a,-r.size*.8],[a+l,-r.size*.8],[a,r.size*.25],[a+l,r.size*.25]].map(([d,h])=>xr(e,d,h));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:wr(e),class:s,"text-anchor":o==="start"?void 0:o,...i},mt(t))}floorText(e,t,s,r,o,i="x",l="start",a={}){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,l,a)}faceText(e,t,s,r,o,i,l="left",a="start",c={}){let[f,u]=Ce(e,t,s),d=l==="left"?[wt,.5,0,1,f,u]:[wt,-.5,0,1,f,u];return this.planeText(d,r,o,i,a,c)}def(e,t){this.defs.set(e,t)}},xo=n=>[(n.x0+n.x1)/2,(n.y0+n.y1)/2,n.z1];function vr(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 wo(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],l=[e.x0+.55,e.y1-.55,s],a=[(e.x0+e.x1)/2,(e.y0+e.y1)/2,s];return n.poly([r,o,i,l],"det")+n.line3(r,a,"det")+n.line3(a,o,"det")}function ko(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 vo(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 Ac(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 l=0;l<20;l++){let a=l/20*Math.PI*2;i.push([t-o*1.4+Math.cos(a)*o,s+Math.sin(a)*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 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)*.28,i=[];for(let l=0;l<24;l++){let a=l/24*Math.PI*2;i.push([t+Math.cos(a)*o,s+Math.sin(a)*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}),Ds={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,l=(e-12-2.5*1)/2,a="";for(let c=0;c<2;c++)for(let f=0;f<3;f++){let u=6+f*(i+2.5),d=6+c*(l+2.5);a+=ws("t",u,d,i,l,1.5),[.3,.52,.74].forEach((h,b)=>{a+=Te("line",{class:"ln",x1:u+2.5,y1:d+l*h,x2:u+2.5+(i-5)*[.8,.5,.65][(b+c+f)%3],y2:d+l*h})})}return a}};function Nc(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 Rc(n,e){return ws("glass",3,3,n-6,e-6,3)}function Ld(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 Fd(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,l=n.z1<=e.z0+1e-6,a=e.z1<=n.z0+1e-6,c=s||o||l,f=r||i||a;return c&&!f?-1:f&&!c?1:0}function Sr(n){let e=n.length,t=n.map(c=>Ld(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 h=Fd(n[c].box,n[f].box);h<0?(r[c].push(f),o[f]++):h>0&&(r[f].push(c),o[c]++)}let i=[],l=n.map((c,f)=>f).filter(c=>!o[c]),a=new Array(e).fill(!1);for(;i.length<e;){if(!l.length){let f=n.map((u,d)=>d).filter(u=>!a[u]).sort((u,d)=>s(n[u])-s(n[d]));l.push(f[0]),o[f[0]]=0}l.sort((f,u)=>s(n[f])-s(n[u])||f-u);let c=l.shift();if(!a[c]){a[c]=!0,i.push(n[c]);for(let f of r[c])!a[f]&&--o[f]===0&&l.push(f)}}return i}var So=Symbol.for("yaml.alias"),$o=Symbol.for("yaml.document"),kn=Symbol.for("yaml.map"),Ma=Symbol.for("yaml.pair"),Qt=Symbol.for("yaml.scalar"),Wn=Symbol.for("yaml.seq"),Kt=Symbol.for("yaml.node.type"),vn=n=>!!n&&typeof n=="object"&&n[Kt]===So,Fn=n=>!!n&&typeof n=="object"&&n[Kt]===$o,qt=n=>!!n&&typeof n=="object"&&n[Kt]===kn,Ge=n=>!!n&&typeof n=="object"&&n[Kt]===Ma,_e=n=>!!n&&typeof n=="object"&&n[Kt]===Qt,Ut=n=>!!n&&typeof n=="object"&&n[Kt]===Wn;function Xe(n){if(n&&typeof n=="object")switch(n[Kt]){case kn:case Wn:return!0}return!1}function He(n){if(n&&typeof n=="object")switch(n[Kt]){case So:case kn:case Qt:case Wn:return!0}return!1}var Mo=n=>(_e(n)||Xe(n))&&!!n.anchor;var Ht=Symbol("break visit"),Pc=Symbol("skip children"),Bn=Symbol("remove node");function jn(n,e){let t=Cc(e);Fn(n)?_s(null,n.contents,t,Object.freeze([n]))===Bn&&(n.contents=null):_s(null,n,t,Object.freeze([]))}jn.BREAK=Ht;jn.SKIP=Pc;jn.REMOVE=Bn;function _s(n,e,t,s){let r=Ic(n,e,t,s);if(He(r)||Ge(r))return Lc(n,s,r),_s(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=_s(o,e.items[o],t,s);if(typeof i=="number")o=i-1;else{if(i===Ht)return Ht;i===Bn&&(e.items.splice(o,1),o-=1)}}}else if(Ge(e)){s=Object.freeze(s.concat(e));let o=_s("key",e.key,t,s);if(o===Ht)return Ht;o===Bn&&(e.key=null);let i=_s("value",e.value,t,s);if(i===Ht)return Ht;i===Bn&&(e.value=null)}}return r}async function To(n,e){let t=Cc(e);Fn(n)?await zs(null,n.contents,t,Object.freeze([n]))===Bn&&(n.contents=null):await zs(null,n,t,Object.freeze([]))}To.BREAK=Ht;To.SKIP=Pc;To.REMOVE=Bn;async function zs(n,e,t,s){let r=await Ic(n,e,t,s);if(He(r)||Ge(r))return Lc(n,s,r),zs(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 zs(o,e.items[o],t,s);if(typeof i=="number")o=i-1;else{if(i===Ht)return Ht;i===Bn&&(e.items.splice(o,1),o-=1)}}}else if(Ge(e)){s=Object.freeze(s.concat(e));let o=await zs("key",e.key,t,s);if(o===Ht)return Ht;o===Bn&&(e.key=null);let i=await zs("value",e.value,t,s);if(i===Ht)return Ht;i===Bn&&(e.value=null)}}return r}function Cc(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 Ic(n,e,t,s){if(typeof t=="function")return t(n,e,s);if(qt(e))return t.Map?.(n,e,s);if(Ut(e))return t.Seq?.(n,e,s);if(Ge(e))return t.Pair?.(n,e,s);if(_e(e))return t.Scalar?.(n,e,s);if(vn(e))return t.Alias?.(n,e,s)}function Lc(n,e,t){let s=e[e.length-1];if(Xe(s))s.items[n]=t;else if(Ge(s))n==="key"?s.key=t:s.value=t;else if(Fn(s))s.contents=t;else{let r=vn(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}var Bd={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},jd=n=>n.replace(/[!,[\]{}]/g,e=>Bd[e]),Dn=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+jd(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&&He(e.contents)){let o={};jn(e.contents,(i,l)=>{He(l)&&l.tag&&(o[l.tag]=!0)}),r=Object.keys(o)}else r=[];for(let[o,i]of s)o==="!!"&&i==="tag:yaml.org,2002:"||(!e||r.some(l=>l.startsWith(i)))&&t.push(`%TAG ${o} ${i}`);return t.join(`
|
|
2
|
+
`)}};Dn.defaultYaml={explicit:!1,version:"1.2"};Dn.defaultTags={"!!":"tag:yaml.org,2002:"};function Eo(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 Ta(n){let e=new Set;return jn(n,{Value(t,s){s.anchor&&e.add(s.anchor)}}),e}function Ea(n,e){for(let t=1;;++t){let s=`${n}${t}`;if(!e.has(s))return s}}function Fc(n,e){let t=[],s=new Map,r=null;return{onAnchor:o=>{t.push(o),r??(r=Ta(n));let i=Ea(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 l=new Error("Failed to resolve repeated object (this should not happen)");throw l.source=o,l}}},sourceObjects:s}}function rs(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],l=rs(n,s,String(r),i);l===void 0?delete s[r]:l!==i&&(s[r]=l)}else if(s instanceof Map)for(let r of Array.from(s.keys())){let o=s.get(r),i=rs(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=rs(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=rs(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||!Mo(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 os=class{constructor(e){Object.defineProperty(this,Kt,{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(!Fn(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},l=Mt(this,"",i);if(typeof r=="function")for(let{count:a,res:c}of i.anchors.values())r(c,a);return typeof o=="function"?rs(o,{"":l},"",l):l}};var Jn=class extends os{constructor(e){super(So),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=[],jn(e,{Node:(o,i)=>{(vn(i)||Mo(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:l}=t,a=o.get(r);if(a||(Mt(r,null,t),a=o.get(r)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(l>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Ao(i,r,o)),a.count*a.aliasCount>l)){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(Eo(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 Ao(n,e,t){if(vn(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=Ao(n,r,t);o>s&&(s=o)}return s}else if(Ge(e)){let s=Ao(n,e.key,t),r=Ao(n,e.value,t);return Math.max(s,r)}return 1}var Oo=n=>!n||typeof n!="function"&&typeof n!="object",Ae=class extends os{constructor(e){super(Qt),this.value=e}toJSON(e,t){return t?.keep?this.value:Mt(this.value,e,t)}toString(){return String(this.value)}};Ae.BLOCK_FOLDED="BLOCK_FOLDED";Ae.BLOCK_LITERAL="BLOCK_LITERAL";Ae.PLAIN="PLAIN";Ae.QUOTE_DOUBLE="QUOTE_DOUBLE";Ae.QUOTE_SINGLE="QUOTE_SINGLE";var Dd="tag:yaml.org,2002:";function _d(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 Xn(n,e,t){if(Fn(n)&&(n=n.contents),He(n))return n;if(Ge(n)){let u=t.schema[kn].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:l}=t,a;if(s&&n&&typeof n=="object"){if(a=l.get(n),a)return a.anchor??(a.anchor=r(n)),new Jn(a.anchor);a={anchor:null,node:null},l.set(n,a)}e?.startsWith("!!")&&(e=Dd+e.slice(2));let c=_d(n,e,i.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){let u=new Ae(n);return a&&(a.node=u),u}c=n instanceof Map?i[kn]:Symbol.iterator in Object(n)?i[Wn]:i[kn]}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 Ae(n);return e?f.tag=e:c.default||(f.tag=c.tag),a&&(a.node=f),f}function $r(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 Xn(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 Vs=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done,Ks=class extends os{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=>He(s)||Ge(s)?s.clone(e):s),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(Vs(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,$r(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(!Ge(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,$r(this.schema,r,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${r}`)}}};var Bc=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function cn(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}var _n=(n,e,t)=>n.endsWith(`
|
|
3
|
+
`)?cn(t,e):t.includes(`
|
|
4
4
|
`)?`
|
|
5
|
-
`+
|
|
6
|
-
`)t===
|
|
7
|
-
`&&
|
|
8
|
-
`&&x!==" "&&(d=m)}if(m>=u)if(d)c.push(d),u=d+
|
|
9
|
-
${e}${n.slice(0
|
|
10
|
-
${e}${n.slice(x+1
|
|
11
|
-
`);s=e,r=e+1,o=n[r]}return s}var
|
|
12
|
-
`){if(o-i>s)return!0;if(i=o+1,r-i<=s)return!1}return!0}function
|
|
5
|
+
`+cn(t,e):(n.endsWith(" ")?"":" ")+t;var Aa="flow",No="block",Mr="quoted";function Tr(n,e,t="flow",{indentAtStart:s,lineWidth:r=80,minContentWidth:o=20,onFold:i,onOverflow:l}={}){if(!r||r<0)return n;r<o&&(o=0);let a=Math.max(1+o,1+r-e.length);if(n.length<=a)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,h,b=!1,m=-1,y=-1,N=-1;t===No&&(m=jc(n,m,e.length),m!==-1&&(u=m+a));for(let g;g=n[m+=1];){if(t===Mr&&g==="\\"){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(g===`
|
|
6
|
+
`)t===No&&(m=jc(n,m,e.length)),u=m+e.length+a,d=void 0;else{if(g===" "&&h&&h!==" "&&h!==`
|
|
7
|
+
`&&h!==" "){let x=n[m+1];x&&x!==" "&&x!==`
|
|
8
|
+
`&&x!==" "&&(d=m)}if(m>=u)if(d)c.push(d),u=d+a,d=void 0;else if(t===Mr){for(;h===" "||h===" ";)h=g,g=n[m+=1],b=!0;let x=m>N+1?m-2:y-1;if(f[x])return n;c.push(x),f[x]=!0,u=x+a,d=void 0}else b=!0}h=g}if(b&&l&&l(),c.length===0)return n;i&&i();let p=n.slice(0,c[0]);for(let g=0;g<c.length;++g){let x=c[g],$=c[g+1]||n.length;x===0?p=`
|
|
9
|
+
${e}${n.slice(0,$)}`:(t===Mr&&f[x]&&(p+=`${n[x]}\\`),p+=`
|
|
10
|
+
${e}${n.slice(x+1,$)}`)}return p}function jc(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 Po=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),Co=n=>/^(%|---|\.\.\.)/m.test(n);function zd(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 Er(n,e){let t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;let{implicitKey:s}=e,r=e.options.doubleQuotedMinMultiLineLength,o=e.indent||(Co(n)?" ":""),i="",l=0;for(let a=0,c=t[a];c;c=t[++a])if(c===" "&&t[a+1]==="\\"&&t[a+2]==="n"&&(i+=t.slice(l,a)+"\\ ",a+=1,l=a,c="\\"),c==="\\")switch(t[a+1]){case"u":{i+=t.slice(l,a);let f=t.substr(a+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(a,6)}a+=5,l=a+1}break;case"n":if(s||t[a+2]==='"'||t.length<r)a+=1;else{for(i+=t.slice(l,a)+`
|
|
13
13
|
|
|
14
|
-
`;t[
|
|
15
|
-
`,
|
|
16
|
-
`)||/[ \t]\n|\n[ \t]/.test(n))return
|
|
17
|
-
${t}`)+"'";return e.implicitKey?s:
|
|
14
|
+
`;t[a+2]==="\\"&&t[a+3]==="n"&&t[a+4]!=='"';)i+=`
|
|
15
|
+
`,a+=2;i+=o,t[a+2]===" "&&(i+="\\"),a+=1,l=a+1}break;default:a+=1}return i=l?i+t.slice(l):t,s?i:Tr(i,o,Mr,Po(e,!1))}function Oa(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(n))return Er(n,e);let t=e.indent||(Co(n)?" ":""),s="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
17
|
+
${t}`)+"'";return e.implicitKey?s:Tr(s,t,Aa,Po(e,!1))}function Gs(n,e){let{singleQuote:t}=e.options,s;if(t===!1)s=Er;else{let r=n.includes('"'),o=n.includes("'");r&&!o?s=Oa:o&&!r?s=Er:s=t?Oa:Er}return s(n,e)}var Na;try{Na=new RegExp(`(^|(?<!
|
|
18
18
|
))
|
|
19
19
|
+(?!
|
|
20
|
-
|$)`,"g")}catch{
|
|
20
|
+
|$)`,"g")}catch{Na=/\n+(?!\n|$)/g}function Ro({comment:n,type:e,value:t},s,r,o){let{blockQuote:i,commentString:l,lineWidth:a}=s.options;if(!i||/\n[\t ]+$/.test(t))return Gs(t,s);let c=s.indent||(s.forceBlockIndent||Co(t)?" ":""),f=i==="literal"?!0:i==="folded"||e===Ae.BLOCK_FOLDED?!1:e===Ae.BLOCK_LITERAL?!0:!zd(t,a,c.length);if(!t)return f?`|
|
|
21
21
|
`:`>
|
|
22
|
-
`;let u,d;for(d=t.length;d>0;--d){let
|
|
23
|
-
|
|
24
|
-
`);
|
|
25
|
-
`&&(
|
|
26
|
-
`)N=y;else break}let
|
|
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
|
-
${
|
|
34
|
-
${e.indent}${
|
|
35
|
-
${
|
|
36
|
-
`:"",
|
|
37
|
-
${
|
|
38
|
-
`&&
|
|
22
|
+
`;let u,d;for(d=t.length;d>0;--d){let $=t[d-1];if($!==`
|
|
23
|
+
`&&$!==" "&&$!==" ")break}let h=t.substring(d),b=h.indexOf(`
|
|
24
|
+
`);b===-1?u="-":t===h||b!==h.length-1?(u="+",o&&o()):u="",h&&(t=t.slice(0,-h.length),h[h.length-1]===`
|
|
25
|
+
`&&(h=h.slice(0,-1)),h=h.replace(Na,`$&${c}`));let m=!1,y,N=-1;for(y=0;y<t.length;++y){let $=t[y];if($===" ")m=!0;else if($===`
|
|
26
|
+
`)N=y;else break}let p=t.substring(0,N<y?N+1:y);p&&(t=t.substring(p.length),p=p.replace(/\n+/g,`$&${c}`));let x=(m?c?"2":"1":"")+u;if(n&&(x+=" "+l(n.replace(/ ?[\r\n]+/g," ")),r&&r()),!f){let $=t.replace(/\n+/g,`
|
|
27
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),E=!1,v=Po(s,!0);i!=="folded"&&e!==Ae.BLOCK_FOLDED&&(v.onOverflow=()=>{E=!0});let A=Tr(`${p}${$}${h}`,c,No,v);if(!E)return`>${x}
|
|
28
|
+
${c}${A}`}return t=t.replace(/\n+/g,`$&${c}`),`|${x}
|
|
29
|
+
${c}${p}${t}${h}`}function Kd(n,e,t,s){let{type:r,value:o}=n,{actualString:i,implicitKey:l,indent:a,indentStep:c,inFlow:f}=e;if(l&&o.includes(`
|
|
30
|
+
`)||f&&/[[\]{},]/.test(o))return Gs(o,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(o))return l||f||!o.includes(`
|
|
31
|
+
`)?Gs(o,e):Ro(n,e,t,s);if(!l&&!f&&r!==Ae.PLAIN&&o.includes(`
|
|
32
|
+
`))return Ro(n,e,t,s);if(Co(o)){if(a==="")return e.forceBlockIndent=!0,Ro(n,e,t,s);if(l&&a===c)return Gs(o,e)}let u=o.replace(/\n+/g,`$&
|
|
33
|
+
${a}`);if(i){let d=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(u),{compat:h,tags:b}=e.doc.schema;if(b.some(d)||h?.some(d))return Gs(o,e)}return l?u:Tr(u,a,Aa,Po(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:l}=n;l!==Ae.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(i.value)&&(l=Ae.QUOTE_DOUBLE);let a=f=>{switch(f){case Ae.BLOCK_FOLDED:case Ae.BLOCK_LITERAL:return r||o?Gs(i.value,e):Ro(i,e,t,s);case Ae.QUOTE_DOUBLE:return Er(i.value,e);case Ae.QUOTE_SINGLE:return Oa(i.value,e);case Ae.PLAIN:return Kd(i,e,t,s);default:return null}},c=a(l);if(c===null){let{defaultKeyType:f,defaultStringType:u}=e.options,d=r&&f||u;if(c=a(d),c===null)throw new Error(`Unsupported default string type ${d}`)}return c}function Io(n,e){let t=Object.assign({blockQuote:!0,commentString:Bc,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 Vd(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 Gd(n,e,{anchors:t,doc:s}){if(!s.directives)return"";let r=[],o=(_e(n)||Xe(n))&&n.anchor;o&&Eo(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 Qn(n,e,t,s){if(Ge(n))return n.toString(e,t,s);if(vn(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=He(n)?n:e.doc.createNode(n,{onTagObj:a=>r=a});r??(r=Vd(e.doc.schema.tags,o));let i=Gd(o,r,e);i.length>0&&(e.indentAtStart=(e.indentAtStart??0)+i.length+1);let l=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)||l[0]==="{"||l[0]==="["?`${i} ${l}`:`${i}
|
|
34
|
+
${e.indent}${l}`:l}function Dc({key:n,value:e},t,s,r){let{allNullValues:o,doc:i,indent:l,indentStep:a,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t,d=He(n)&&n.comment||null;if(u){if(d)throw new Error("With simple keys, key nodes cannot have comments");if(Xe(n)||!He(n)&&typeof n=="object"){let v="With simple keys, collection cannot be used as a key value";throw new Error(v)}}let h=!u&&(!n||d&&e==null&&!t.inFlow||Xe(n)||(_e(n)?n.type===Ae.BLOCK_FOLDED||n.type===Ae.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!h&&(u||!o),indent:l+a});let b=!1,m=!1,y=Qn(n,t,()=>b=!0,()=>m=!0);if(!h&&!t.inFlow&&y.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(t.inFlow){if(o||e==null)return b&&s&&s(),y===""?"?":h?`? ${y}`:y}else if(o&&!u||e==null&&h)return y=`? ${y}`,d&&!b?y+=_n(y,t.indent,c(d)):m&&r&&r(),y;b&&(d=null),h?(d&&(y+=_n(y,t.indent,c(d))),y=`? ${y}
|
|
35
|
+
${l}:`):(y=`${y}:`,d&&(y+=_n(y,t.indent,c(d))));let N,p,g;He(e)?(N=!!e.spaceBefore,p=e.commentBefore,g=e.comment):(N=!1,p=null,g=null,e&&typeof e=="object"&&(e=i.createNode(e))),t.implicitKey=!1,!h&&!d&&_e(e)&&(t.indentAtStart=y.length+1),m=!1,!f&&a.length>=2&&!t.inFlow&&!h&&Ut(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let x=!1,$=Qn(e,t,()=>x=!0,()=>m=!0),E=" ";if(d||N||p){if(E=N?`
|
|
36
|
+
`:"",p){let v=c(p);E+=`
|
|
37
|
+
${cn(v,t.indent)}`}$===""&&!t.inFlow?E===`
|
|
38
|
+
`&&g&&(E=`
|
|
39
39
|
|
|
40
|
-
`):
|
|
41
|
-
${t.indent}`}else if(!
|
|
42
|
-
`),
|
|
43
|
-
${t.indent}`)}}else(
|
|
44
|
-
`)&&(
|
|
45
|
-
${
|
|
46
|
-
`}}return n?(
|
|
47
|
-
`+
|
|
48
|
-
`)),
|
|
40
|
+
`):E+=`
|
|
41
|
+
${t.indent}`}else if(!h&&Xe(e)){let v=$[0],A=$.indexOf(`
|
|
42
|
+
`),L=A!==-1,M=t.inFlow??e.flow??e.items.length===0;if(L||!M){let P=!1;if(L&&(v==="&"||v==="!")){let k=$.indexOf(" ");v==="&"&&k!==-1&&k<A&&$[k+1]==="!"&&(k=$.indexOf(" ",k+1)),(k===-1||A<k)&&(P=!0)}P||(E=`
|
|
43
|
+
${t.indent}`)}}else($===""||$[0]===`
|
|
44
|
+
`)&&(E="");return y+=E+$,t.inFlow?x&&s&&s():g&&!x?y+=_n(y,t.indent,c(g)):m&&r&&r(),y}function Lo(n,e){(n==="debug"||n==="warn")&&console.warn(e)}var Fo="<<",Sn={identify:n=>n===Fo||typeof n=="symbol"&&n.description===Fo,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ae(Symbol(Fo)),{addToJSMap:Pa}),stringify:()=>Fo},_c=(n,e)=>(Sn.identify(e)||_e(e)&&(!e.type||e.type===Ae.PLAIN)&&Sn.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===Sn.tag&&t.default);function Pa(n,e,t){let s=zc(n,t);if(Ut(s))for(let r of s.items)Ra(n,e,r);else if(Array.isArray(s))for(let r of s)Ra(n,e,r);else Ra(n,e,s)}function Ra(n,e,t){let s=zc(n,t);if(!qt(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 zc(n,e){return n&&vn(e)?e.resolve(n.doc,n):e}function Bo(n,e,{key:t,value:s}){if(He(t)&&t.addToJSMap)t.addToJSMap(n,e,s);else if(_c(n,t))Pa(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=qd(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 qd(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(He(n)&&t?.doc){let s=Io(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)+'..."'),Lo(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 qs(n,e,t){let s=Xn(n,void 0,t),r=Xn(e,void 0,t);return new yt(s,r)}var yt=class n{constructor(e,t=null){Object.defineProperty(this,Kt,{value:Ma}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return He(t)&&(t=t.clone(e)),He(s)&&(s=s.clone(e)),new n(t,s)}toJSON(e,t){let s=t?.mapAsMap?new Map:{};return Bo(t,s,this)}toString(e,t,s){return e?.doc?Dc(this,e,t,s):JSON.stringify(this)}};function Do(n,e,t){return(e.inFlow??n.flow?Hd:Ud)(n,e,t)}function Ud({comment:n,items:e},t,{blockItemPrefix:s,flowChars:r,itemIndent:o,onChompKeep:i,onComment:l}){let{indent:a,options:{commentString:c}}=t,f=Object.assign({},t,{indent:o,type:null}),u=!1,d=[];for(let b=0;b<e.length;++b){let m=e[b],y=null;if(He(m))!u&&m.spaceBefore&&d.push(""),jo(t,d,m.commentBefore,u),m.comment&&(y=m.comment);else if(Ge(m)){let p=He(m.key)?m.key:null;p&&(!u&&p.spaceBefore&&d.push(""),jo(t,d,p.commentBefore,u))}u=!1;let N=Qn(m,f,()=>y=null,()=>u=!0);y&&(N+=_n(N,o,c(y))),u&&y&&(u=!1),d.push(s+N)}let h;if(d.length===0)h=r.start+r.end;else{h=d[0];for(let b=1;b<d.length;++b){let m=d[b];h+=m?`
|
|
45
|
+
${a}${m}`:`
|
|
46
|
+
`}}return n?(h+=`
|
|
47
|
+
`+cn(c(n),a),l&&l()):u&&i&&i(),h}function Hd({items:n},e,{flowChars:t,itemIndent:s}){let{indent:r,indentStep:o,flowCollectionPadding:i,options:{commentString:l}}=e;s+=o;let a=Object.assign({},e,{indent:s,inFlow:!0,type:null}),c=!1,f=0,u=[];for(let b=0;b<n.length;++b){let m=n[b],y=null;if(He(m))m.spaceBefore&&u.push(""),jo(e,u,m.commentBefore,!1),m.comment&&(y=m.comment);else if(Ge(m)){let p=He(m.key)?m.key:null;p&&(p.spaceBefore&&u.push(""),jo(e,u,p.commentBefore,!1),p.comment&&(c=!0));let g=He(m.value)?m.value:null;g?(g.comment&&(y=g.comment),g.commentBefore&&(c=!0)):m.value==null&&p?.comment&&(y=p.comment)}y&&(c=!0);let N=Qn(m,a,()=>y=null);c||(c=u.length>f||N.includes(`
|
|
48
|
+
`)),b<n.length-1?N+=",":e.options.trailingComma&&(e.options.lineWidth>0&&(c||(c=u.reduce((p,g)=>p+g.length+2,2)+(N.length+2)>e.options.lineWidth)),c&&(N+=",")),y&&(N+=_n(N,s,l(y))),u.push(N),f=u.length}let{start:d,end:h}=t;if(u.length===0)return d+h;if(!c){let b=u.reduce((m,y)=>m+y.length+2,2);c=e.options.lineWidth>0&&b>e.options.lineWidth}if(c){let b=d;for(let m of u)b+=m?`
|
|
49
49
|
${o}${r}${m}`:`
|
|
50
|
-
`;return`${
|
|
51
|
-
${r}${
|
|
52
|
-
`:" ")}return ks({comment:n,type:e,value:
|
|
50
|
+
`;return`${b}
|
|
51
|
+
${r}${h}`}else return`${d}${i}${u.join(" ")}${i}${h}`}function jo({indent:n,options:{commentString:e}},t,s,r){if(s&&r&&(s=s.replace(/^\n+/,"")),s){let o=cn(e(s),n);t.push(o.trimStart())}}function is(n,e){let t=_e(e)?e.value:e;for(let s of n)if(Ge(s)&&(s.key===e||s.key===t||_e(s.key)&&s.key.value===t))return s}var kt=class extends Ks{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(kn,e),this.items=[]}static from(e,t,s){let{keepUndefined:r,replacer:o}=s,i=new this(e),l=(a,c)=>{if(typeof o=="function")c=o.call(t,a,c);else if(Array.isArray(o)&&!o.includes(a))return;(c!==void 0||r)&&i.items.push(qs(a,c,s))};if(t instanceof Map)for(let[a,c]of t)l(a,c);else if(t&&typeof t=="object")for(let a of Object.keys(t))l(a,t[a]);return typeof e.sortMapEntries=="function"&&i.items.sort(e.sortMapEntries),i}add(e,t){let s;Ge(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=is(this.items,s.key),o=this.schema?.sortMapEntries;if(r){if(!t)throw new Error(`Key ${s.key} already set`);_e(r.value)&&Oo(s.value)?r.value.value=s.value:r.value=s.value}else if(o){let i=this.items.findIndex(l=>o(s,l)<0);i===-1?this.items.push(s):this.items.splice(i,0,s)}else this.items.push(s)}delete(e){let t=is(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let r=is(this.items,e)?.value;return(!t&&_e(r)?r.value:r)??void 0}has(e){return!!is(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)Bo(t,r,o);return r}toString(e,t,s){if(!e)return JSON.stringify(this);for(let r of this.items)if(!Ge(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})),Do(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}};var $n={collection:"map",default:!0,nodeClass:kt,tag:"tag:yaml.org,2002:map",resolve(n,e){return qt(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>kt.from(n,e,t)};var Lt=class extends Ks{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(Wn,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=_o(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){let s=_o(e);if(typeof s!="number")return;let r=this.items[s];return!t&&_e(r)?r.value:r}has(e){let t=_o(e);return typeof t=="number"&&t<this.items.length}set(e,t){let s=_o(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);let r=this.items[s];_e(r)&&Oo(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?Do(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 l of t){if(typeof r=="function"){let a=t instanceof Set?l:String(i++);l=r.call(t,a,l)}o.items.push(Xn(l,void 0,s))}}return o}};function _o(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 Mn={collection:"seq",default:!0,nodeClass:Lt,tag:"tag:yaml.org,2002:seq",resolve(n,e){return Ut(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Lt.from(n,e,t)};var as={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 vs={identify:n=>n==null,createNode:()=>new Ae(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ae(null),stringify:({source:n},e)=>typeof n=="string"&&vs.test.test(n)?n:e.options.nullStr};var Ar={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new Ae(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&Ar.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 l=e-(o.length-i-1);for(;l-- >0;)o+="0"}return o}var zo={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},Ko={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)}},Vo={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 Ae(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:Ft};var Go=n=>typeof n=="bigint"||Number.isInteger(n),Ca=(n,e,t,{intAsBigInt:s})=>s?BigInt(n):parseInt(n.substring(e),t);function Kc(n,e,t){let{value:s}=n;return Go(s)&&s>=0?t+s.toString(e):Ft(n)}var qo={identify:n=>Go(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Ca(n,2,8,t),stringify:n=>Kc(n,8,"0o")},Uo={identify:Go,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Ca(n,0,10,t),stringify:Ft},Ho={identify:n=>Go(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Ca(n,2,16,t),stringify:n=>Kc(n,16,"0x")};var Vc=[$n,Mn,as,vs,Ar,qo,Uo,Ho,zo,Ko,Vo];function Gc(n){return typeof n=="bigint"||Number.isInteger(n)}var Yo=({value:n})=>JSON.stringify(n),Yd=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:Yo},{identify:n=>n==null,createNode:()=>new Ae(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Yo},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:Yo},{identify:Gc,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})=>Gc(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:Yo}],Wd={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},qc=[$n,Mn].concat(Yd,Wd);var Or={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,l;if(typeof btoa=="function"){let a="";for(let c=0;c<i.length;++c)a+=String.fromCharCode(i[c]);l=btoa(a)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=Ae.BLOCK_LITERAL),e!==Ae.QUOTE_DOUBLE){let a=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(l.length/a),f=new Array(c);for(let u=0,d=0;u<c;++u,d+=a)f[u]=l.substr(d,a);l=f.join(e===Ae.BLOCK_LITERAL?`
|
|
52
|
+
`:" ")}return ks({comment:n,type:e,value:l},s,r,o)}};function Ia(n,e){if(Ut(n))for(let t=0;t<n.items.length;++t){let s=n.items[t];if(!Ge(s)){if(qt(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");let r=s.items[0]||new yt(new Ae(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}n.items[t]=
|
|
55
|
-
`)?(t.push("..."),t.push(
|
|
54
|
+
${o.comment}`:s.comment}s=r}n.items[t]=Ge(s)?s:new yt(s)}}else e("Expected a sequence for this tag");return n}function La(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 l,a;if(Array.isArray(i))if(i.length===2)l=i[0],a=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)l=c[0],a=i[l];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else l=i;r.items.push(qs(l,a,t))}return r}var Nr={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ia,createNode:La};var Us=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(Ge(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=La(e,t,s),o=new this;return o.items=r.items,o}};Us.tag="tag:yaml.org,2002:omap";var Rr={collection:"seq",identify:n=>n instanceof Map,nodeClass:Us,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){let t=Ia(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 Us,t)},createNode:(n,e,t)=>Us.from(n,e,t)};function Uc({value:n,source:e},t){return e&&(n?Fa:Ba).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}var Fa={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 Ae(!0),stringify:Uc},Ba={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 Ae(!1),stringify:Uc};var Hc={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},Yc={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)}},Wc={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 Ae(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 Pr=n=>typeof n=="bigint"||Number.isInteger(n);function Wo(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 ja(n,e,t){let{value:s}=n;if(Pr(s)){let r=s.toString(e);return s<0?"-"+t+r.substr(1):t+r}return Ft(n)}var Jc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Wo(n,2,2,t),stringify:n=>ja(n,2,"0b")},Xc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Wo(n,1,8,t),stringify:n=>ja(n,8,"0")},Qc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Wo(n,0,10,t),stringify:Ft},Zc={identify:Pr,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Wo(n,2,16,t),stringify:n=>ja(n,16,"0x")};var Hs=class n extends kt{constructor(e){super(e),this.tag=n.tag}add(e){let t;Ge(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),is(this.items,t.key)||this.items.push(t)}get(e,t){let s=is(this.items,e);return!t&&Ge(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=is(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(qs(i,null,s));return o}};Hs.tag="tag:yaml.org,2002:set";var Cr={collection:"map",identify:n=>n instanceof Set,nodeClass:Hs,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>Hs.from(n,e,t),resolve(n,e){if(qt(n)){if(n.hasAllNullValues(!0))return Object.assign(new Hs,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};function Da(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,l)=>i*r(60)+r(l),r(0));return t==="-"?r(-1)*o:o}function ef(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 Jo={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})=>Da(n,t),stringify:ef},Xo={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=>Da(n,!1),stringify:ef},Ys={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(Ys.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,t,s,r,o,i,l]=e.map(Number),a=e[7]?Number((e[7]+"00").substr(1,3)):0,c=Date.UTC(t,s-1,r,o||0,i||0,l||0,a),f=e[8];if(f&&f!=="Z"){let u=Da(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 _a=[$n,Mn,as,vs,Fa,Ba,Jc,Xc,Qc,Zc,Hc,Yc,Wc,Or,Sn,Rr,Nr,Cr,Jo,Xo,Ys];var tf=new Map([["core",Vc],["failsafe",[$n,Mn,as]],["json",qc],["yaml11",_a],["yaml-1.1",_a]]),nf={binary:Or,bool:Ar,float:Vo,floatExp:Ko,floatNaN:zo,floatTime:Xo,int:Uo,intHex:Ho,intOct:qo,intTime:Jo,map:$n,merge:Sn,null:vs,omap:Rr,pairs:Nr,seq:Mn,set:Cr,timestamp:Ys},sf={"tag:yaml.org,2002:binary":Or,"tag:yaml.org,2002:merge":Sn,"tag:yaml.org,2002:omap":Rr,"tag:yaml.org,2002:pairs":Nr,"tag:yaml.org,2002:set":Cr,"tag:yaml.org,2002:timestamp":Ys};function Qo(n,e,t){let s=tf.get(e);if(s&&!n)return t&&!s.includes(Sn)?s.concat(Sn):s.slice();let r=s;if(!r)if(Array.isArray(n))r=[];else{let o=Array.from(tf.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(Sn)),r.reduce((o,i)=>{let l=typeof i=="string"?nf[i]:i;if(!l){let a=JSON.stringify(i),c=Object.keys(nf).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${a}; use one of ${c}`)}return o.includes(l)||o.push(l),o},[])}var Jd=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0,Ir=class n{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:r,schema:o,sortMapEntries:i,toStringDefaults:l}){this.compat=Array.isArray(e)?Qo(e,"compat"):e?Qo(null,e):null,this.name=typeof o=="string"&&o||"core",this.knownTags=r?sf:{},this.tags=Qo(t,this.name,s),this.toStringOptions=l??null,Object.defineProperty(this,kn,{value:$n}),Object.defineProperty(this,Qt,{value:as}),Object.defineProperty(this,Wn,{value:Mn}),this.sortMapEntries=typeof i=="function"?i:i===!0?Jd:null}clone(){let e=Object.create(n.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}};function rf(n,e){let t=[],s=e.directives===!0;if(e.directives!==!1&&n.directives){let a=n.directives.toString(n);a?(t.push(a),s=!0):n.directives.docStart&&(s=!0)}s&&t.push("---");let r=Io(n,e),{commentString:o}=r.options;if(n.commentBefore){t.length!==1&&t.unshift("");let a=o(n.commentBefore);t.unshift(cn(a,""))}let i=!1,l=null;if(n.contents){if(He(n.contents)){if(n.contents.spaceBefore&&s&&t.push(""),n.contents.commentBefore){let f=o(n.contents.commentBefore);t.push(cn(f,""))}r.forceBlockIndent=!!n.comment,l=n.contents.comment}let a=l?void 0:()=>i=!0,c=Qn(n.contents,r,()=>l=null,a);l&&(c+=_n(c,"",o(l))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(Qn(n.contents,r));if(n.directives?.docEnd)if(n.comment){let a=o(n.comment);a.includes(`
|
|
55
|
+
`)?(t.push("..."),t.push(cn(a,""))):t.push(`... ${a}`)}else t.push("...");else{let a=n.comment;a&&i&&(a=a.replace(/^\n+/,"")),a&&((!i||l)&&t[t.length-1]!==""&&t.push(""),t.push(cn(o(a),"")))}return t.join(`
|
|
56
56
|
`)+`
|
|
57
|
-
`}var
|
|
58
|
-
`),i=
|
|
57
|
+
`}var ls=class n{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,Kt,{value:$o});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 Dn({version:i}),this.setSchema(i,s),this.contents=e===void 0?null:this.createNode(e,r,s)}clone(){let e=Object.create(n.prototype,{[Kt]:{value:$o}});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=He(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Ws(this.contents)&&this.contents.add(e)}addIn(e,t){Ws(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let s=Ta(this);e.anchor=!t||s.has(t)?Ea(t||"a",s):t}return new Jn(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=p=>typeof p=="number"||p instanceof String||p 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:l,keepUndefined:a,onTagObj:c,tag:f}=s??{},{onAnchor:u,setAnchors:d,sourceObjects:h}=Fc(this,i||"a"),b={aliasDuplicateObjects:o??!0,keepUndefined:a??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:h},m=Xn(e,f,b);return l&&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 Ws(this.contents)?this.contents.delete(e):!1}deleteIn(e){return Vs(e)?this.contents==null?!1:(this.contents=null,!0):Ws(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 Vs(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 Vs(e)?this.contents!==void 0:Xe(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=$r(this.schema,[e],t):Ws(this.contents)&&this.contents.set(e,t)}setIn(e,t){Vs(e)?this.contents=t:this.contents==null?this.contents=$r(this.schema,Array.from(e),t):Ws(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 Dn({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 Dn({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 Ir(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 l={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},a=Mt(this.contents,t??"",l);if(typeof o=="function")for(let{count:c,res:f}of l.anchors.values())o(f,c);return typeof i=="function"?rs(i,{"":a},"",a):a}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 rf(this,e)}};function Ws(n){if(Xe(n))return!0;throw new Error("Expected a YAML collection as document contents")}var Lr=class extends Error{constructor(e,t,s,r){super(),this.name=e,this.code=s,this.message=r,this.pos=t}},Tn=class extends Lr{constructor(e,t,s){super("YAMLParseError",e,t,s)}},Fr=class extends Lr{constructor(e,t,s){super("YAMLWarning",e,t,s)}},za=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(l=>e.linePos(l));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 l=Math.min(o-39,i.length-79);i="\u2026"+i.substring(l),o-=l-1}if(i.length>80&&(i=i.substring(0,79)+"\u2026"),s>1&&/^ *$/.test(i.substring(0,o))){let l=n.substring(e.lineStarts[s-2],e.lineStarts[s-1]);l.length>80&&(l=l.substring(0,79)+`\u2026
|
|
58
|
+
`),i=l+i}if(/[^ ]/.test(i)){let l=1,a=t.linePos[1];a?.line===s&&a.col>r&&(l=Math.max(1,Math.min(a.col-r,80-o)));let c=" ".repeat(o)+"^".repeat(l);t.message+=`:
|
|
59
59
|
|
|
60
60
|
${i}
|
|
61
61
|
${c}
|
|
62
|
-
`}};function
|
|
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(
|
|
64
|
-
`+m.comment:
|
|
65
|
-
`+
|
|
66
|
-
`+
|
|
67
|
-
`+v:
|
|
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
|
|
71
|
-
`;for(let m=f;m<
|
|
72
|
-
`):y.length>
|
|
73
|
-
`:!
|
|
62
|
+
`}};function zn(n,{flow:e,indicator:t,next:s,offset:r,onError:o,parentIndent:i,startOnNewline:l}){let a=!1,c=l,f=l,u="",d="",h=!1,b=!1,m=null,y=null,N=null,p=null,g=null,x=null,$=null;for(let A of n)switch(b&&(A.type!=="space"&&A.type!=="newline"&&A.type!=="comma"&&o(A.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),b=!1),m&&(c&&A.type!=="comment"&&A.type!=="newline"&&o(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),A.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&A.source.includes(" ")&&(m=A),f=!0;break;case"comment":{f||o(A,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let L=A.source.substring(1)||" ";u?u+=d+L:u=L,d="",c=!1;break}case"newline":c?u?u+=A.source:(!x||t!=="seq-item-ind")&&(a=!0):d+=A.source,c=!0,h=!0,(y||N)&&(p=A),f=!0;break;case"anchor":y&&o(A,"MULTIPLE_ANCHORS","A node can have at most one anchor"),A.source.endsWith(":")&&o(A.offset+A.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),y=A,$??($=A.offset),c=!1,f=!1,b=!0;break;case"tag":{N&&o(A,"MULTIPLE_TAGS","A node can have at most one tag"),N=A,$??($=A.offset),c=!1,f=!1,b=!0;break}case t:(y||N)&&o(A,"BAD_PROP_ORDER",`Anchors and tags must be after the ${A.source} indicator`),x&&o(A,"UNEXPECTED_TOKEN",`Unexpected ${A.source} in ${e??"collection"}`),x=A,c=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){g&&o(A,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),g=A,c=!1,f=!1;break}default:o(A,"UNEXPECTED_TOKEN",`Unexpected ${A.type} token`),c=!1,f=!1}let E=n[n.length-1],v=E?E.offset+E.source.length:r;return b&&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:g,found:x,spaceBefore:a,comment:u,hasNewline:h,anchor:y,tag:N,newlineAfterProp:p,end:v,start:$??v}}function cs(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(cs(e.key)||cs(e.value))return!0}return!1;default:return!0}}function Br(n,e,t){if(e?.type==="flow-collection"){let s=e.end[0];s.indent===n&&(s.source==="]"||s.source==="}")&&cs(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Zo(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 of="All mapping items must start at the same column";function af({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=o?.nodeClass??kt,l=new i(t.schema);t.atRoot&&(t.atRoot=!1);let a=s.offset,c=null;for(let f of s.items){let{start:u,key:d,sep:h,value:b}=f,m=zn(u,{indicator:"explicit-key-ind",next:d??h?.[0],offset:a,onError:r,parentIndent:s.indent,startOnNewline:!0}),y=!m.found;if(y){if(d&&(d.type==="block-seq"?r(a,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in d&&d.indent!==s.indent&&r(a,"BAD_INDENT",of)),!m.anchor&&!m.tag&&!h){c=m.end,m.comment&&(l.comment?l.comment+=`
|
|
64
|
+
`+m.comment:l.comment=m.comment);continue}(m.newlineAfterProp||cs(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(a,"BAD_INDENT",of);t.atKey=!0;let N=m.end,p=d?n(t,d,m,r):e(t,N,u,null,m,r);t.schema.compat&&Br(s.indent,d,r),t.atKey=!1,Zo(t,l.items,p)&&r(N,"DUPLICATE_KEY","Map keys must be unique");let g=zn(h??[],{indicator:"map-value-ind",next:b,offset:p.range[2],onError:r,parentIndent:s.indent,startOnNewline:!d||d.type==="block-scalar"});if(a=g.end,g.found){y&&(b?.type==="block-map"&&!g.hasNewline&&r(a,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&m.start<g.found.offset-1024&&r(p.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let x=b?n(t,b,g,r):e(t,a,h,null,g,r);t.schema.compat&&Br(s.indent,b,r),a=x.range[2];let $=new yt(p,x);t.options.keepSourceTokens&&($.srcToken=f),l.items.push($)}else{y&&r(p.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),g.comment&&(p.comment?p.comment+=`
|
|
65
|
+
`+g.comment:p.comment=g.comment);let x=new yt(p);t.options.keepSourceTokens&&(x.srcToken=f),l.items.push(x)}}return c&&c<a&&r(c,"IMPOSSIBLE","Map comment with trailing content"),l.range=[s.offset,a,c??a],l}function lf({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=o?.nodeClass??Lt,l=new i(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let a=s.offset,c=null;for(let{start:f,value:u}of s.items){let d=zn(f,{indicator:"seq-item-ind",next:u,offset:a,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(a,"MISSING_CHAR","Sequence item without - indicator");else{c=d.end,d.comment&&(l.comment=d.comment);continue}let h=u?n(t,u,d,r):e(t,d.end,f,null,d,r);t.schema.compat&&Br(s.indent,u,r),a=h.range[2],l.items.push(h)}return l.range=[s.offset,a,c??a],l}function Kn(n,e,t,s){let r="";if(n){let o=!1,i="";for(let l of n){let{source:a,type:c}=l;switch(c){case"space":o=!0;break;case"comment":{t&&!o&&s(l,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=a.substring(1)||" ";r?r+=i+f:r=f,i="";break}case"newline":r&&(i+=a),o=!0;break;default:s(l,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=a.length}}return{comment:r,offset:e}}var Ka="Block collections are not allowed within flow collections",Va=n=>n&&(n.type==="block-map"||n.type==="block-seq");function cf({composeNode:n,composeEmptyNode:e},t,s,r,o){let i=s.start.source==="{",l=i?"flow map":"flow sequence",a=o?.nodeClass??(i?kt:Lt),c=new a(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:p,key:g,sep:x,value:$}=N,E=zn(p,{flow:l,indicator:"explicit-key-ind",next:g??x?.[0],offset:u,onError:r,parentIndent:s.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!x&&!$){y===0&&E.comma?r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${l}`):y<s.items.length-1&&r(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${l}`),E.comment&&(c.comment?c.comment+=`
|
|
66
|
+
`+E.comment:c.comment=E.comment),u=E.end;continue}!i&&t.options.strict&&cs(g)&&r(g,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(y===0)E.comma&&r(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${l}`);else if(E.comma||r(E.start,"MISSING_CHAR",`Missing , between ${l} items`),E.comment){let v="";e:for(let A of p)switch(A.type){case"comma":case"space":break;case"comment":v=A.source.substring(1);break e;default:break e}if(v){let A=c.items[c.items.length-1];Ge(A)&&(A=A.value??A.key),A.comment?A.comment+=`
|
|
67
|
+
`+v:A.comment=v,E.comment=E.comment.substring(v.length+1)}}if(!i&&!x&&!E.found){let v=$?n(t,$,E,r):e(t,E.end,x,null,E,r);c.items.push(v),u=v.range[2],Va($)&&r(v.range,"BLOCK_IN_FLOW",Ka)}else{t.atKey=!0;let v=E.end,A=g?n(t,g,E,r):e(t,v,p,null,E,r);Va(g)&&r(A.range,"BLOCK_IN_FLOW",Ka),t.atKey=!1;let L=zn(x??[],{flow:l,indicator:"map-value-ind",next:$,offset:A.range[2],onError:r,parentIndent:s.indent,startOnNewline:!1});if(L.found){if(!i&&!E.found&&t.options.strict){if(x)for(let k of x){if(k===L.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}}E.start<L.found.offset-1024&&r(L.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else $&&("source"in $&&$.source?.[0]===":"?r($,"MISSING_CHAR",`Missing space after : in ${l}`):r(L.start,"MISSING_CHAR",`Missing , or : between ${l} items`));let M=$?n(t,$,L,r):L.found?e(t,L.end,x,null,L,r):null;M?Va($)&&r(M.range,"BLOCK_IN_FLOW",Ka):L.comment&&(A.comment?A.comment+=`
|
|
68
|
+
`+L.comment:A.comment=L.comment);let P=new yt(A,M);if(t.options.keepSourceTokens&&(P.srcToken=N),i){let k=c;Zo(t,k.items,A)&&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 O=(M??A).range;k.range=[A.range[0],O[1],O[2]],c.items.push(k)}u=M?M.range[2]:L.end}}let d=i?"}":"]",[h,...b]=s.end,m=u;if(h?.source===d)m=h.offset+h.source.length;else{let y=l[0].toUpperCase()+l.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),h&&h.source.length!==1&&b.unshift(h)}if(b.length>0){let y=Kn(b,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 Ga(n,e,t,s,r,o){let i=t.type==="block-map"?af(n,e,t,s,o):t.type==="block-seq"?lf(n,e,t,s,o):cf(n,e,t,s,o),l=i.constructor;return r==="!"||r===l.tagName?(i.tag=l.tagName,i):(r&&(i.tag=r),i)}function ff(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:h}=s,b=d&&o?d.offset>o.offset?d:o:d??o;b&&(!h||h.offset<b.offset)&&r(b,"MISSING_CHAR","Missing newline after block sequence props")}let l=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!o||!i||i==="!"||i===kt.tagName&&l==="map"||i===Lt.tagName&&l==="seq")return Ga(n,e,t,r,i);let a=e.schema.tags.find(d=>d.tag===i&&d.collection===l);if(!a){let d=e.schema.knownTags[i];if(d?.collection===l)e.schema.tags.push(Object.assign({},d,{default:!1})),a=d;else return d?r(o,"BAD_COLLECTION_TYPE",`${d.tag} used for ${l} collection, but expects ${d.collection??"scalar"}`,!0):r(o,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,!0),Ga(n,e,t,r,i)}let c=Ga(n,e,t,r,i,a),f=a.resolve?.(c,d=>r(o,"TAG_RESOLVE_FAILED",d),e.options)??c,u=He(f)?f:new Ae(f);return u.range=c.range,u.tag=i,a?.format&&(u.format=a.format),u}function qa(n,e,t){let s=e.offset,r=Xd(e,n.options.strict,t);if(!r)return{value:"",type:null,comment:"",range:[s,s,s]};let o=r.mode===">"?Ae.BLOCK_FOLDED:Ae.BLOCK_LITERAL,i=e.source?Qd(e.source):[],l=i.length;for(let m=i.length-1;m>=0;--m){let y=i[m][1];if(y===""||y==="\r")l=m;else break}if(l===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 a=e.indent+r.indent,c=e.offset+r.length,f=0;for(let m=0;m<l;++m){let[y,N]=i[m];if(N===""||N==="\r")r.indent===0&&y.length>a&&(a=y.length);else{y.length<a&&t(c+y.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(a=y.length),f=m,a===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>=l;--m)i[m][0].length>a&&(l=m+1);let u="",d="",h=!1;for(let m=0;m<f;++m)u+=i[m][0].slice(a)+`
|
|
71
|
+
`;for(let m=f;m<l;++m){let[y,N]=i[m];c+=y.length+N.length+1;let p=N[N.length-1]==="\r";if(p&&(N=N.slice(0,-1)),N&&y.length<a){let x=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;t(c-N.length-(p?2:1),"BAD_INDENT",x),y=""}o===Ae.BLOCK_LITERAL?(u+=d+y.slice(a)+N,d=`
|
|
72
|
+
`):y.length>a||N[0]===" "?(d===" "?d=`
|
|
73
|
+
`:!h&&d===`
|
|
74
74
|
`&&(d=`
|
|
75
75
|
|
|
76
|
-
`),u+=d+y.slice(
|
|
77
|
-
`,
|
|
76
|
+
`),u+=d+y.slice(a)+N,d=`
|
|
77
|
+
`,h=!0):N===""?d===`
|
|
78
78
|
`?u+=`
|
|
79
79
|
`:d=`
|
|
80
|
-
`:(u+=d+N,d=" ",
|
|
81
|
-
`+i[m][0].slice(
|
|
80
|
+
`:(u+=d+N,d=" ",h=!1)}switch(r.chomp){case"-":break;case"+":for(let m=l;m<i.length;++m)u+=`
|
|
81
|
+
`+i[m][0].slice(a);u[u.length-1]!==`
|
|
82
82
|
`&&(u+=`
|
|
83
83
|
`);break;default:u+=`
|
|
84
|
-
`}let
|
|
84
|
+
`}let b=s+r.length+e.source.length;return{value:u,type:o,comment:r.comment,range:[s,b,b]}}function Xd({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,l="",a=-1;for(let d=1;d<r.length;++d){let h=r[d];if(!l&&(h==="-"||h==="+"))l=h;else{let b=Number(h);!i&&b?i=b:a===-1&&(a=n+d)}}a!==-1&&s(a,"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 h=e[d];switch(h.type){case"space":c=!0;case"newline":u+=h.source.length;break;case"comment":t&&!c&&s(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=h.source.length,f=h.source.substring(1);break;case"error":s(h,"UNEXPECTED_TOKEN",h.message),u+=h.source.length;break;default:{let b=`Unexpected token in block scalar header: ${h.type}`;s(h,"UNEXPECTED_TOKEN",b);let m=h.source;m&&typeof m=="string"&&(u+=m.length)}}}return{mode:o,indent:i,chomp:l,comment:f,length:u}}function Qd(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 Ua(n,e,t){let{offset:s,type:r,source:o,end:i}=n,l,a,c=(d,h,b)=>t(s+d,h,b);switch(r){case"scalar":l=Ae.PLAIN,a=Zd(o,c);break;case"single-quoted-scalar":l=Ae.QUOTE_SINGLE,a=em(o,c);break;case"double-quoted-scalar":l=Ae.QUOTE_DOUBLE,a=tm(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=Kn(i,f,e,t);return{value:a,type:l,comment:u.comment,range:[s,f,u.offset]}}function Zd(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}`),uf(n)}function em(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),uf(n.slice(1,-1)).replace(/''/g,"'")}function uf(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=" ",l=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=" "),
|
|
86
|
+
`:(o+=i+c,i=" "),l=e.lastIndex}let a=/[ \t]*(.*)/sy;return a.lastIndex=l,t=a.exec(n),o+i+(t?.[1]??"")}function tm(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}=
|
|
88
|
+
`){let{fold:o,offset:i}=nm(n,s);t+=o,s=i}else if(r==="\\"){let o=n[++s],i=sm[o];if(i)t+=i;else if(o===`
|
|
89
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
|
|
90
|
+
`)for(o=n[++s+1];o===" "||o===" ";)o=n[++s+1];else if(o==="x"||o==="u"||o==="U"){let l=o==="x"?2:o==="u"?4:8;t+=rm(n,s+1,l,e),s+=l}else{let l=n.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${l}`),t+=l}}else if(r===" "||r===" "){let o=s,i=n[s+1];for(;i===" "||i===" ";)i=n[++s+1];i!==`
|
|
91
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
|
|
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 nm(n,e){let t="",s=n[e+1];for(;(s===" "||s===" "||s===`
|
|
93
93
|
`||s==="\r")&&!(s==="\r"&&n[e+2]!==`
|
|
94
94
|
`);)s===`
|
|
95
95
|
`&&(t+=`
|
|
96
|
-
`),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}var
|
|
97
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
96
|
+
`),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}var sm={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 rm(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 l=n.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${l}`),l}}function Ha(n,e,t,s){let{value:r,type:o,comment:i,range:l}=e.type==="block-scalar"?qa(n,e,s):Ua(e,n.options.strict,s),a=t?n.directives.tagName(t.source,u=>s(t,"TAG_RESOLVE_FAILED",u)):null,c;n.options.stringKeys&&n.atKey?c=n.schema[Qt]:a?c=om(n.schema,r,a,t,s):e.type==="scalar"?c=im(n,r,e,s):c=n.schema[Qt];let f;try{let u=c.resolve(r,d=>s(t??e,"TAG_RESOLVE_FAILED",d),n.options);f=_e(u)?u:new Ae(u)}catch(u){let d=u instanceof Error?u.message:String(u);s(t??e,"TAG_RESOLVE_FAILED",d),f=new Ae(r)}return f.range=l,f.source=r,o&&(f.type=o),a&&(f.tag=a),c.format&&(f.format=c.format),i&&(f.comment=i),f}function om(n,e,t,s,r){if(t==="!")return n[Qt];let o=[];for(let l of n.tags)if(!l.collection&&l.tag===t)if(l.default&&l.test)o.push(l);else return l;for(let l of o)if(l.test?.test(e))return l;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[Qt])}function im({atKey:n,directives:e,schema:t},s,r,o){let i=t.tags.find(l=>(l.default===!0||n&&l.default==="key")&&l.test?.test(s))||t[Qt];if(t.compat){let l=t.compat.find(a=>a.default&&a.test?.test(s))??t[Qt];if(i.tag!==l.tag){let a=e.tagString(i.tag),c=e.tagString(l.tag),f=`Value may be parsed as either ${a} or ${c}`;o(r,"TAG_RESOLVE_FAILED",f,!0)}}return i}function df(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 am={composeNode:Ya,composeEmptyNode:ei};function Ya(n,e,t,s){let r=n.atKey,{spaceBefore:o,comment:i,anchor:l,tag:a}=t,c,f=!0;switch(e.type){case"alias":c=lm(n,e,s),(l||a)&&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=Ha(n,e,a,s),l&&(c.anchor=l.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=ff(am,n,e,t,s),l&&(c.anchor=l.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=ei(n,e.offset,void 0,null,t,s)),l&&c.anchor===""&&s(l,"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(a??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 ei(n,e,t,s,{spaceBefore:r,comment:o,anchor:i,tag:l,end:a},c){let f={type:"scalar",offset:df(e,t,s),indent:-1,source:""},u=Ha(n,f,l,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]=a),u}function lm({options:n},{offset:e,source:t,end:s},r){let o=new Jn(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,l=Kn(s,i,n.strict,r);return o.range=[e,i,l.offset],l.comment&&(o.comment=l.comment),o}function mf(n,e,{offset:t,start:s,value:r,end:o},i){let l=Object.assign({_directives:e},n),a=new ls(void 0,l),c={atKey:!1,atRoot:!0,directives:a.directives,options:a.options,schema:a.schema},f=zn(s,{indicator:"doc-start",next:r??o?.[0],offset:t,onError:i,parentIndent:0,startOnNewline:!0});f.found&&(a.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")),a.contents=r?Ya(c,r,f,i):ei(c,f.end,s,null,f,i);let u=a.contents.range[2],d=Kn(o,u,!1,i);return d.comment&&(a.comment=d.comment),a.range=[t,u,d.offset],a}function jr(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 pf(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)||" "),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
|
|
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];
|
|
102
|
-
${
|
|
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:
|
|
104
|
-
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new
|
|
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 Dr=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,r,o)=>{let i=jr(t);o?this.warnings.push(new Fr(i,s,r)):this.errors.push(new Tn(i,s,r))},this.directives=new Dn({version:e.version||"1.2"}),this.options=e}decorate(e,t){let{comment:s,afterEmptyLine:r}=pf(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];Ge(i)&&(i=i.key);let l=i.commentBefore;i.commentBefore=l?`${s}
|
|
102
|
+
${l}`:s}else{let i=o.commentBefore;o.commentBefore=i?`${s}
|
|
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:pf(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=jr(e);o[0]+=t,this.onError(o,"BAD_DIRECTIVE",s,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{let t=mf(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 Tn(jr(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 Tn(jr(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;let t=Kn(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 Tn(jr(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 ls(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 Wa=Symbol("break visit"),cm=Symbol("skip children"),hf=Symbol("remove item");function Ss(n,e){"type"in n&&n.type==="document"&&(n={start:n.start,value:n.value}),gf(Object.freeze([]),n,e)}Ss.BREAK=Wa;Ss.SKIP=cm;Ss.REMOVE=hf;Ss.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};Ss.parentCollection=(n,e)=>{let t=Ss.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 gf(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 l=gf(Object.freeze(n.concat([[r,i]])),o.items[i],t);if(typeof l=="number")i=l-1;else{if(l===Wa)return Wa;l===hf&&(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 Ja="\uFEFF",Xa="",Qa="",ti="";function bf(n){switch(n){case Ja:return"byte-order-mark";case Xa:return"doc-mode";case Qa:return"flow-error-end";case ti: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(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
|
|
107
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
108
|
-
\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(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 En(n){switch(n){case void 0:case" ":case`
|
|
107
|
+
`:case"\r":case" ":return!0;default:return!1}}var yf=new Set("0123456789ABCDEFabcdef"),um=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ni=new Set(",[]{}"),dm=new Set(` ,[]{}
|
|
108
|
+
\r `),Za=n=>!n||dm.has(n),_r=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
109
|
`?!0:t==="\r"?this.buffer[e+1]===`
|
|
110
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
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==="...")
|
|
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]===
|
|
112
|
+
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){let s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&En(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]===Ja&&(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 Xa,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==="...")&&En(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&&!En(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===":")&&En(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(Za),"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("..."))&&En(r[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield Qa,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(Za),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let i=this.charAt(1);if(this.flowKey||En(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&&(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
|
|
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=>En(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
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
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
|
-
`;)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
|
|
120
|
-
`&&o>=this.pos&&o+1+t>
|
|
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 l=o;for(;i===" ";)i=this.buffer[--o];if(i===`
|
|
120
|
+
`&&o>=this.pos&&o+1+t>l)e=o;else break}while(!0);return yield ti,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(En(o)||e&&ni.has(o))break;t=s}else if(En(r)){let o=this.buffer[s+1];if(r==="\r"&&(o===`
|
|
121
121
|
`?(s+=1,r=`
|
|
122
|
-
`,o=this.buffer[s+1]):t=s),o==="#"||e&&
|
|
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&&ni.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&&ni.has(r))break;t=s}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield ti,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(Za),e+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(En(s)||t&&ni.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(;!En(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(um.has(t))t=this.buffer[++e];else if(t==="%"&&yf.has(this.buffer[e+1])&&yf.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 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
|
|
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 fs(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function xf(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 kf(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 si(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 Js(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 ri(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 wf(n){if(n.start.type==="flow-seq-start")for(let e of n.items)e.sep&&!e.value&&!fs(e.start,"explicit-key-ind")&&!fs(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,kf(e.value)?e.value.end?ri(e.value.end,e.sep):e.value.end=e.sep:ri(e.start,e.sep),delete e.sep)}var zr=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 _r,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=bf(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"&&wf(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&&xf(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":{xf(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=si(this.peek(2)),s=Js(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
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)){
|
|
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)){ri(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 l=0;l<t.sep.length;++l){let a=t.sep[l];switch(a.type){case"newline":i.push(l);break;case"space":break;case"comment":a.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(fs(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(kf(t.key)&&!fs(t.sep,"newline")){let i=Js(t.start),l=t.key,a=t.sep;a.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:l,sep:a}]})}else o.length>0?t.sep=t.sep.concat(o,this.sourceToken):t.sep.push(this.sourceToken);else if(fs(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let i=Js(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]}):fs(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&&!fs(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)){ri(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||fs(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=si(s),o=Js(r);wf(e);let i=e.end.splice(1,e.end.length);i.push(this.sourceToken);let l={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]=l}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
128
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=
|
|
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=si(e),s=Js(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=si(e),s=Js(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 mm(n){let e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new $s||null,prettyErrors:e}}function oi(n,e={}){let{lineCounter:t,prettyErrors:s}=mm(e),r=new zr(t?.addNewLine),o=new Dr(e),i=null;for(let l of o.compose(r.parse(n),!0,n.length))if(!i)i=l;else if(i.options.logLevel!=="silent"){i.errors.push(new Tn(l.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(i.errors.forEach(za(n,t)),i.warnings.forEach(za(n,t))),i}function el(n,e,t){let s;typeof e=="function"?s=e:t===void 0&&e&&typeof e=="object"&&(t=e);let r=oi(n,t);if(!r)return null;if(r.warnings.forEach(o=>Lo(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 ii(n){let e=el(n);for(let t of["light","dark","kinds","roles"])if(!e||typeof e[t]!="object")throw new Error(`theme: missing "${t}"`);return e}function Xs(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 vf=n=>Object.entries(n).map(([e,t])=>`--${e}:${t}`).join(";");function An(n,e){return e in n.light?`var(--${e})`:e}function ai(n){let{light:e,dark:t,rest:s}=Kr(n);return`:root{${e}}
|
|
130
130
|
@media (prefers-color-scheme: dark){:root:not([data-theme="light"]){${t}}}
|
|
131
131
|
:root[data-theme="dark"]{${t}}
|
|
132
|
-
${s}`}function
|
|
133
|
-
`;for(let[t,s]of Object.entries(n.kinds)){let r=
|
|
134
|
-
`}return{light:
|
|
135
|
-
`)),this.diags=e}};function
|
|
136
|
-
${n.hint}`),t&&n.line){let i=t.split(/\r?\n/)[n.line-1]??"",
|
|
137
|
-
${
|
|
138
|
-
${" ".repeat(
|
|
132
|
+
${s}`}function Kr(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=An(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:vf(n.light),dark:vf(n.dark),rest:e}}var li=class extends Error{diags;constructor(e){super(e.map(t=>`${t.line}:${t.col} ${t.message}`).join(`
|
|
135
|
+
`)),this.diags=e}};function tl(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 l=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]+l),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 l=tl(r,i.toLowerCase());l<s&&(s=l,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 nl(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]??"",l=String(n.line).padStart(4);r+=`
|
|
137
|
+
${l} | ${i}
|
|
138
|
+
${" ".repeat(l.length)} | ${" ".repeat(Math.max(0,n.col-1))}^`}return r}function Sf(n,e,t){return n.map(s=>nl(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
|
|
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
|
|
144
|
-
`)[0]]?.includes(e)&&n.svg.slice(...c)!==r.slice(a
|
|
145
|
-
${t}`):void 0;
|
|
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=`
|
|
140
|
+
`)}function $f(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 Mf(n){let e=new $s,t=oi(n,{lineCounter:e,prettyErrors:!1,uniqueKeys:!0}),s=[],r=a=>{let c=e.linePos(a);return{line:c.line,col:c.col}};for(let a of t.errors){let c=r(a.pos[0]),f=a.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 a of t.warnings){let c=r(a.pos[0]);s.push({severity:"warning",message:`YAML: ${a.message.split(`
|
|
142
|
+
`)[0]}`,line:c.line,col:c.col,path:""})}function o(a,c={}){let f=$f(a),u=t.contents,d={line:1,col:1},h=b=>{let m=b?.range;m&&(d=r(m[0]))};h(u);for(let b=0;b<f.length;b++){let m=f[b];if(qt(u)){let y=u.items.find(N=>Ge(N)&&_e(N.key)&&String(N.key.value)===String(m));if(!y)break;if(c.key&&b===f.length-1)return h(y.key),d;h(y.key),u=y.value,u&&h(u)}else if(Ut(u)&&typeof m=="number"){if(u=u.items[m],!u)break;h(u)}else break}return d}function i(a){let c=t.contents;for(let h of $f(a)){if(qt(c)){let b=c.items.find(m=>Ge(m)&&_e(m.key)&&String(m.key.value)===String(h));if(!b)return;c=b.value}else if(Ut(c)&&typeof h=="number")c=c.items[h];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 l=null;return t.errors.length||(l=t.toJS({maxAliasCount:100})),{data:l,locate:o,span:i,diags:s}}var hm=new Set(["svg","g","defs","marker","symbol","title","desc","path","polygon","polyline","line","rect","circle","ellipse","text","tspan","linearGradient","radialGradient","stop","clipPath"]),gm=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"]),bm=new Set(["fill","stroke","marker-start","marker-mid","marker-end","clip-path","style"]),ym={amp:"&",lt:"<",gt:">",quot:'"',apos:"'","#39":"'"},Tf=n=>n.replace(/&(amp|lt|gt|quot|apos|#39);/g,(e,t)=>ym[t]);function sl(n,e){return n.startsWith("data-")||n.startsWith("aria-")?/^[a-z][\w-]*$/.test(n):!(!gm.has(n)||bm.has(n)&&/url\(\s*(?!['"]?#)|javascript:|expression\(|@import/i.test(e))}function rl(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 l=r[2],a=[];for(let u of r[3].matchAll(/([\w:-]+)="([^"]*)"/g)){let d=u[1],h=Tf(u[2]);d==="xmlns"||d.startsWith("xmlns:")||sl(d,h)&&a.push([d,h])}let c={name:l,attrs:a,children:[]},f=i.dropped||!hm.has(l);f||i.node.children.push(c),r[4]||t.push({node:c,dropped:f});continue}!i.dropped&&r[5].trim()&&i.node.children.push(Tf(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 xm="http://www.w3.org/2000/svg",Ef=n=>n.replace(/var\(--([a-zA-Z][\w-]*)/g,"var(--iso-$1");function Af(n,e=document){let t=r=>{let o=e.createElementNS(xm,r.name);for(let[i,l]of r.attrs)i==="style"?o.style.cssText=Ef(l):o.setAttribute(i,/var\(--/.test(l)?Ef(l):l);for(let i of r.children)o.append(typeof i=="string"?e.createTextNode(i):t(i));return o},s=rl(n).children.find(r=>typeof r!="string"&&r.name==="svg");if(!s)throw new Error("the drawing has no <svg>");return t(s)}var wm=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),Vr=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])=>`${wm(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 Vr(e)},Nf=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),km=n=>Nf(n).replace(/"/g,""");function ci(n,e=new Set(["style"])){if(typeof n=="string")return Nf(n);let t=n.attrs.map(([r,o])=>` ${r}="${km(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,"<\\/"):ci(r,e)).join(""):n.children.map(r=>ci(r,e)).join("");return`<${n.name}${t}>${s}</${n.name}>`}var vm=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 ol(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]),l=new Uint32Array(64),a=(c,f)=>c>>>f|c<<32-f;for(let c=0;c<s;c++){for(let p=0;p<16;p++)l[p]=o.getUint32(c*64+p*4);for(let p=16;p<64;p++){let g=a(l[p-15],7)^a(l[p-15],18)^l[p-15]>>>3,x=a(l[p-2],17)^a(l[p-2],19)^l[p-2]>>>10;l[p]=l[p-16]+g+l[p-7]+x>>>0}let[f,u,d,h,b,m,y,N]=i;for(let p=0;p<64;p++){let g=N+(a(b,6)^a(b,11)^a(b,25))+(b&m^~b&y)+vm[p]+l[p]>>>0,x=(a(f,2)^a(f,13)^a(f,22))+(f&u^f&d^u&d)>>>0;N=y,y=m,m=b,b=h+g>>>0,h=d,d=u,u=f,f=g+x>>>0}i[0]+=f,i[1]+=u,i[2]+=d,i[3]+=h,i[4]+=b,i[5]+=m,i[6]+=y,i[7]+=N}return[...i].map(c=>c.toString(16).padStart(8,"0")).join("")}function Rf(n){if(n!=="sha256")throw new Error(`only sha256 here, not ${n}`);let e="",t={update(s){return e+=s,t},digest(s){return ol(e)}};return t}var Cf=n=>{if(n&&typeof n=="object"){Object.freeze(n);for(let e of Object.values(n))Cf(e)}return n},fi=[86,81,76],Sm=["send","reply","token","blocked","user","event","control","planned"],jt=Cf({light:{paper:"#ffffff",ink:"#141414",steps:[{top:"#f4f4f4",left:"#dcdcdc",right:"#c4c4c4",edge:"#3a3a3a"},{top:"#dedede",left:"#bfbfbf",right:"#a2a2a2",edge:"#2e2e2e"},{top:"#bcbcbc",left:"#9a9a9a",right:"#7e7e7e",edge:"#222222"},{top:"#8f8f8f",left:"#707070",right:"#565656",edge:"#141414"}]},dark:{paper:"#161616",ink:"#f2f2f2",steps:[{top:"#2a2a2a",left:"#222222",right:"#1b1b1b",edge:"#b8b8b8"},{top:"#454545",left:"#383838",right:"#2c2c2c",edge:"#c8c8c8"},{top:"#6a6a6a",left:"#565656",right:"#444444",edge:"#dadada"},{top:"#9c9c9c",left:"#808080",right:"#686868",edge:"#141414"}]},patterns:["none","hatch","hatch-wide","dots"],rhythms:[{dash:[],width:2.6},{dash:[9,4],width:2.4},{dash:[7,6],width:2.4},{dash:[3,6],width:2.4},{dash:[1.5,3.5],width:2.6},{dash:[10,3,2,3],width:2.4},{dash:[],width:1.4},{dash:[7,6],width:1.4},{dash:[3,3],width:1.6},{dash:[14,4],width:1.8}],kindOrder:Sm,thresholds:fi,darkWidthAdd:.4}),$m=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,Mm=/^hsl\(\s*([+-]?(?:\d+\.?\d*|\.\d+))\s+([+-]?(?:\d+\.?\d*|\.\d+))%\s+([+-]?(?:\d+\.?\d*|\.\d+))%\s*\)$/i;function Tm(n){if(typeof n!="string")throw new Error(`mono: invalid colour "${String(n)}"`);let e=n.trim(),t=$m.exec(e);if(t){let r=t[1];return r.length===3?[parseInt(r[0]+r[0],16)/255,parseInt(r[1]+r[1],16)/255,parseInt(r[2]+r[2],16)/255]:[parseInt(r.slice(0,2),16)/255,parseInt(r.slice(2,4),16)/255,parseInt(r.slice(4,6),16)/255]}let s=Mm.exec(e);if(s){let r=Number(s[1]),o=Number(s[2]),i=Number(s[3]);if(!Number.isFinite(r)||o<0||o>100||i<0||i>100)throw new Error(`mono: invalid colour "${n}"`);let l=(r%360+360)%360,a=o/100,c=i/100,f=a*Math.min(c,1-c),u=d=>{let h=(d+l/30)%12;return c-f*Math.max(-1,Math.min(h-3,9-h,1))};return[u(0),u(8),u(4)]}throw new Error(`mono: invalid colour "${n}"`)}function il(n){let[e,t,s]=Tm(n),r=o=>o<=.04045?o/12.92:((o+.055)/1.055)**2.4;return .2126*r(e)+.7152*r(t)+.0722*r(s)}function Gr(n){let e=il(n);return e>216/24389?116*Math.cbrt(e)-16:24389/27*e}function qr(n,e){let t=il(n),s=il(e);return(Math.max(t,s)+.05)/(Math.min(t,s)+.05)}var Em=new Set(jt.patterns),Am=new Map(jt.kindOrder.map((n,e)=>[n,e])),Om=(n,e)=>n<e?-1:n>e?1:0,Pf=n=>[...new Set(n)].sort(Om),Nm=n=>Math.round(n*100)/100;function Rm(n){return n>=fi[0]?0:n>=fi[1]?1:n>=fi[2]?2:3}function Pm(n){if(n.roles)for(let[e,t]of Object.entries(n.roles)){if(t.step!==void 0&&(typeof t.step!="number"||!Number.isInteger(t.step)||t.step<0||t.step>3))throw new Error(`mono: invalid step "${String(t.step)}" for role "${e}"`);if(t.pattern!==void 0&&(typeof t.pattern!="string"||!Em.has(t.pattern)))throw new Error(`mono: invalid pattern "${String(t.pattern)}" for role "${e}"`)}if(n.kinds)for(let[e,t]of Object.entries(n.kinds)){if(t.dash!==void 0&&(!Array.isArray(t.dash)||!t.dash.every(s=>typeof s=="number"&&Number.isFinite(s)&&s>=0)))throw new Error(`mono: invalid dash "${String(t.dash)}" for kind "${e}"`);if(t.width!==void 0&&(typeof t.width!="number"||!Number.isFinite(t.width)||t.width<=0))throw new Error(`mono: invalid width "${String(t.width)}" for kind "${e}"`)}}function ui(n,e,t,s){if(e!=="light"&&e!=="dark")throw new Error(`mono: invalid mode "${String(e)}"`);s&&Pm(s);let r=jt[e],o=[],i=n.light["l-top"],l=Pf(t?.roles??Object.keys(n.roles)),a=new Map,c=[[],[],[],[]];for(let y of l){let N=s?.roles?.[y]?.step,p;if(N!==void 0)p=N;else{let g=n.roles[y];if(!g)throw new Error(`mono: unknown role "${y}"`);if(typeof i!="string")throw new Error('mono: theme.light is missing "l-top"');p=Rm(Gr(`hsl(${g.h} ${g.s}% ${i})`))}a.set(y,p),c[p].push(y)}let f=new Map;for(let y=0;y<c.length;y++){let N=c[y];for(let p=0;p<N.length;p++){let g=N[p],x=s?.roles?.[g]?.pattern;if(x!==void 0)f.set(g,x);else{let $=p%jt.patterns.length,E=jt.patterns[$];if(f.set(g,E),p>=jt.patterns.length){let v=N.slice(0,p).find(A=>f.get(A)===E);v!==void 0&&o.push(`role "${g}" wraps on step ${y} to pattern "${E}", matching "${v}"`)}}}}let u={};for(let y of l){let N=a.get(y),p=f.get(y),g=r.steps[N];u[y]={step:N,pattern:p,top:g.top,left:g.left,right:g.right,edge:g.edge}}let d=Pf(t?.kinds??Object.keys(n.kinds)),h=e==="dark"?jt.darkWidthAdd:0,b={},m=0;for(let y of d){let N=s?.kinds?.[y],p=Am.get(y),g;if(p!==void 0)g=p;else if(g=jt.kindOrder.length+m,m++,g>=jt.rhythms.length){let v=g%jt.rhythms.length;(!N||N.dash===void 0||N.width===void 0)&&o.push(`kind "${y}" exceeds the ${jt.rhythms.length} line rhythms; reusing rhythm ${v}`),g=v}let x=jt.rhythms[g],$=N?.dash!==void 0?[...N.dash]:[...x.dash],E=N?.width!==void 0?N.width:Nm(x.width+h);b[y]={dash:$,width:E}}return{mode:e,paper:r.paper,ink:r.ink,roles:u,kinds:b,warnings:o}}var Lu={};Sa(Lu,{ANTS_CSS:()=>lu,ANT_DASH:()=>Nl,ANT_SPEED:()=>Zr,ANT_STILL:()=>Rl,ASSEMBLE_STYLES:()=>nr,BOARD_3D:()=>ps,BOARD_CSS:()=>Pu,DISASSEMBLE_STYLES:()=>sr,EASING_NAMES:()=>so,EXTRAPOLATE:()=>Ns,FLAT_DEFAULTS:()=>Jl,FLAT_FONTS:()=>Xl,FONT_STACKS:()=>Fl,GRID_CSS:()=>Hl,LABEL_BUDGET:()=>ji,MARKS_CSS:()=>ql,MOTION_EASINGS:()=>Xf,MOTION_ORDERS:()=>Es,MOTION_SCHEMA:()=>pu,MotionBuilder:()=>to,NodesBuilder:()=>ir,Obstacles:()=>Ts,PAGE_CSS:()=>Vl,PLAYER_CSS:()=>Wi,PLAYER_UI_CSS:()=>Ul,ROUTE_BUDGET:()=>$i,SeriesBuilder:()=>ar,WALL_T:()=>Vn,alongPath:()=>Ii,antDash:()=>eo,antsOf:()=>_i,assemble:()=>Ol,assembly:()=>Ri,baseCss:()=>Yi,bezier:()=>ds,bindMotion:()=>io,boardCatalog:()=>Cu,boardDiagram:()=>Iu,boardErrors:()=>Xi,boardOf:()=>Qi,boxAsset:()=>Ff,boxSilhouette:()=>Tu,calloutRect:()=>yl,cardAsset:()=>Ql,checkMotion:()=>Vi,cloudPath:()=>ul,compileRaw:()=>Su,convexOverlap:()=>Jr,curveAt:()=>cr,defaultLabel:()=>jf,disassemble:()=>ou,drawCloud:()=>gi,drawDecos:()=>fl,drawLooks:()=>au,drawingCss:()=>Gl,durationFor:()=>zl,easeOf:()=>Pn,facePainter:()=>hi,flatHit:()=>Ru,floorAt:()=>Qs,floorOf:()=>Eu,focusView:()=>Ki,gateBox:()=>Yr,iconPainter:()=>Ur,inConvex:()=>xl,introSvg:()=>iu,kindsCss:()=>mi,labelRect:()=>Xr,layoutFlat:()=>dr,lineRectArea:()=>Gf,localAt:()=>Mu,markCss:()=>pi,metricsMeasure:()=>Nu,midpoint:()=>Kl,monoCss:()=>_l,monoOfDrawing:()=>vu,monoTheme:()=>Dl,motion:()=>uu,motionModel:()=>As,motionOfSteps:()=>Gi,motionOrder:()=>Ml,motionSource:()=>oo,msOf:()=>tn,noSource:()=>Yl,nodeKind:()=>Ms,nodeKindOr:()=>fn,offscreen:()=>tr,openList:()=>pl,overlap2:()=>yi,overlaps:()=>Ji,paddingOf:()=>Au,paint:()=>Li,paintMono:()=>ku,parseEnd:()=>Zt,place:()=>xi,placeBoard:()=>lo,placeCallout:()=>Oi,placeNodeLabel:()=>Qr,placeholderIcon:()=>cl,planOf:()=>rr,plate:()=>Bf,polyBounds:()=>On,polyRectArea:()=>er,readMs:()=>ro,rectArea:()=>bl,regionKind:()=>ht,regionRole:()=>Di,registerMarks:()=>Lf,renderScene:()=>or,resolveSteps:()=>Hi,resolveSvg:()=>wu,routeAll:()=>Mi,screenToGrid:()=>$u,silhouette:()=>Rt,simplify:()=>Wr,snapMove:()=>Ou,springAt:()=>lr,svgAt:()=>Al,usedIn:()=>jl,wallHeight:()=>di,wallsOf:()=>Bi,withAnts:()=>cu});var ht=(n,e)=>e!==void 0&&Object.hasOwn(n.regions,e)?n.regions[e]:void 0,Ms=(n,e)=>n.nodes[e??n.defaultNode],fn=(n,e)=>Ms(n,e)??n.nodes[n.defaultNode],di=n=>Object.values(n.regions).find(e=>e.shape==="walled")?.z[1]??.8,mi=n=>Object.values(n.regions).map(e=>e.css??"").join("");var al=Object.create(null),ll=[];function Lf(n){Object.assign(al,n.icons??{}),Object.assign(Ds,n.faces??{}),n.css&&!ll.includes(n.css)&&ll.push(n.css)}var pi=()=>ll.join(""),Ur=n=>Object.hasOwn(al,n)?al[n]:void 0,hi=n=>Object.hasOwn(Ds,n)?Ds[n]:void 0;function cl(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 fl(n,e,t){let s="";for(let r of t??[])r==="terminal"?s+=vr(n,e,3):r==="envelope"?s+=wo(n,e):r==="bubble"?s+=ko(n,e):r==="file-lines"?s+=vo(n,e):typeof r=="object"&&(r.terminal&&(s+=vr(n,e,r.terminal)),r.icon&&(s+=(Ur(r.icon)??cl)(n,e)));return s}var Cm=(n,e)=>(n.deco??e.deco??[]).filter(t=>t!=="ghost");function Ff(n,e,t,s,r,o){let i={name:n,description:e,size:t,role:s,deco:r,draw:(l,a,c)=>l.blockFaces(a)+fl(l,a,Cm(c,i))+(o?o(l,a):"")};return i}function Bf(n){let[e,t]=xo(n);return{x0:e-.75,y0:t-.75,x1:e+.75,y1:t+.75,z0:n.z0,z1:n.z0+.18}}function ul(n,e){let t=Math.max(8,Math.min(n,e)*.18),s=t*.55,r=s,o=s,i=n-s,l=e-s,a=(c,f,u,d)=>{let h=Math.hypot(u-c,d-f),b=Math.max(1,Math.round(h/(t*1.7))),m="";for(let y=1;y<=b;y++){let N=c+(u-c)*y/b,p=f+(d-f)*y/b,g=h/b/2*1.08;m+=` A${g.toFixed(1)},${g.toFixed(1)} 0 0 1 ${N.toFixed(1)},${p.toFixed(1)}`}return m};return`M${r.toFixed(1)},${o.toFixed(1)}`+a(r,o,i,o)+a(i,o,i,l)+a(i,l,r,l)+a(r,l,r,o)+"Z"}function gi(n,e){let t={...e,z0:e.z1},s=l=>{let[a,c]=Ce(e.x0,e.y0,l);return[wt,.5,-wt,.5,a,c]},r=(e.x1-e.x0)*st,o=(e.y1-e.y0)*st,i=ul(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 jf(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 Vn=.16,dl=["right-of","left-of","below","behind"];function xi(n,e,t,s,r,o={},i){let l=[],a=(k,O,w,R=!1,I="error")=>{let G=t.locate(k,{key:R});l.push({severity:I,message:O,line:G.line,col:G.col,path:k,hint:w})},c=[],f=new Map,u=[],d=new Map,h=new Set([...Object.keys(s.roles),...Object.keys(o)]);function b(k,O){let w=f.get(k.id);if(w){let R=t.locate(w.path+"/id");return a(k.path+"/id",`duplicate id "${k.id}" (first used on line ${R.line})`),!1}return f.set(k.id,k),c.push(k),k.parent=O,O?O.children.push(k):u.push(k),!0}let m=()=>({x0:0,y0:0,z0:0,x1:0,y1:0,z1:0});function y(k,O,w){let R={id:k.id,type:"node",path:O,children:[],box:m(),floor:0,node:k,appears:k.appears,disappears:k.disappears};b(R,w)&&(k.nodes??[]).forEach((I,G)=>y(I,`${O}/nodes/${G}`,R))}function N(k,O,w){let R={id:k.id,type:"region",path:O,children:[],box:m(),floor:0,region:k,appears:k.appears,disappears:k.disappears};b(R,w)&&((k.nodes??[]).forEach((I,G)=>y(I,`${O}/nodes/${G}`,R)),(k.regions??[]).forEach((I,G)=>N(I,`${O}/regions/${G}`,R)))}(n.regions??[]).forEach((k,O)=>N(k,`${e}/regions/${O}`,void 0)),(n.nodes??[]).forEach((k,O)=>y(k,`${e}/nodes/${O}`,void 0));let p=()=>f.keys(),g=()=>c.filter(k=>k.type==="region").map(k=>k.id);for(let k of[...c]){let O=k.node??k.region;if(O.in!==void 0){let R=f.get(O.in);if(!R){a(k.path+"/in",`unknown region "${O.in}"`+Hr(O.in,g()));continue}if(R.type!=="region"){a(k.path+"/in",`"${O.in}" is a node, not a region; put nodes on a node with its own "nodes:" list`);continue}if(k.parent&&k.parent!==R){a(k.path+"/in",`"${k.id}" is written inside "${k.parent.id}" but says in: ${O.in}; use one or the other`);continue}for(let I=R;I;I=I.parent)if(I===k){a(k.path+"/in",`"${k.id}" cannot be inside itself`);continue}k.parent||(u.splice(u.indexOf(k),1),k.parent=R,R.children.push(k))}if(k.node){let R=k.node.asset;R!==void 0&&!Ms(r,R)&&a(k.path+"/asset",`unknown asset "${R}"`+Hr(R,Object.keys(r.nodes)),`assets: ${Object.keys(r.nodes).join(", ")}`)}let w=(k.node??k.region).role;w!==void 0&&!h.has(w)&&a(k.path+"/role",`unknown colour role "${w}"`+Hr(w,h),`add it under "roles:" at the top of the file, or use one of: ${[...h].join(", ")}`)}for(let k of c){let O=k.region?.gate;if(!O?.node)continue;let w=f.get(O.node);if(!w){a(k.path+"/gate/node",`unknown node "${O.node}"`+Hr(O.node,p()));continue}if(w.type!=="node"){a(k.path+"/gate/node",`"${O.node}" is a region; a gate is a node`);continue}w.placedBy=k.id;let R=w.node;(R.at||dl.some(I=>R[I]))&&a(w.path,`"${w.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 $(k){let O=k.node,w=fn(r,O.asset),R=O.size,I=w.size[0],G=w.size[1],X=w.size[2];if(R&&(I=R[0],G=R[1],R.length>2&&(X=R[2])),k.placedBy){let U=f.get(k.placedBy).region,B=U.gate,H=B.width??2,Y=R?Math.min(I,G):.3;X=R&&R.length>2?X:B.height??(U.height??di(r))+.3,B.side==="e"||B.side==="w"?(I=Y,G=H):(I=H,G=Y)}return[I,G,X]}function E(k,O,w,R,I){for(let W of O)A(W);let G=O.filter(W=>!W.placedBy),X=new Set(G),U=new Set,B=[],H=new Set,Y=W=>{let oe=W.node??W.region,Me=[];for(let Le of dl){let C=oe[Le];if(C===void 0)continue;let V=f.get(C);if(!V){a(`${W.path}/${Le}`,`unknown id "${C}"`+Hr(C,p()));continue}if(V===W){a(`${W.path}/${Le}`,`"${W.id}" cannot be placed ${Le} itself`);continue}if(!X.has(V)){let te=ae=>ae.parent?`"${ae.parent.id}"`:"the scene";a(`${W.path}/${Le}`,`"${C}" is in ${te(V)} but "${W.id}" is in ${te(W)}; relative placement works between items in the same region`,V.placedBy?`"${C}" is a gate, placed by its ${f.get(V.placedBy)?.region?.kind??"region"}`:`place "${W.id}" relative to something in ${te(W)}, or use "at:"`);continue}Me.push(V)}if(!Me.length&&!oe.at){let Le=G.indexOf(W);Le>0&&Me.push(G[Le-1])}return Me},ee=W=>{if(!U.has(W)){if(H.has(W)){a(W.path,`placement loop: "${W.id}" is placed relative to something placed relative to it`);return}H.add(W),Y(W).forEach(ee),H.delete(W),U.add(W),B.push(W)}};G.forEach(ee);for(let W of B){let oe=W.node??W.region,Me=d.get(W),Le=dl.find(C=>oe[C]!==void 0&&f.get(oe[C])&&X.has(f.get(oe[C])));if(oe.at&&Le&&a(`${W.path}/at`,`"${W.id}" has both "at" and "${Le}"; "at" wins`,void 0,!0,"warning"),oe.at)Me.x=oe.at[0],Me.y=oe.at[1];else if(Le)v(Me,d.get(f.get(oe[Le])),Le,x(oe),oe.align??"center");else{let C=G.indexOf(W);C>0?v(Me,d.get(G[C-1]),R==="row"?"right-of":"below",x(oe),"center"):(Me.x=w,Me.y=w)}oe.shift&&(Me.x+=oe.shift[0],Me.y+=oe.shift[1])}if(I||!G.length)return{w:0,d:0};let F=1/0,K=1/0,q=-1/0,Z=-1/0;for(let W of G){let oe=d.get(W);F=Math.min(F,oe.x),K=Math.min(K,oe.y),q=Math.max(q,oe.x+oe.w),Z=Math.max(Z,oe.y+oe.d)}let le=Math.min(0,F-w),fe=Math.min(0,K-w);if(le||fe)for(let W of G){let oe=d.get(W);oe.x-=le,oe.y-=fe}return{w:q-le+w,d:Z-fe+w}}function v(k,O,w,R,I){let G=()=>{k.y=I==="start"?O.y:I==="end"?O.y+O.d-k.d:O.y+(O.d-k.d)/2},X=()=>{k.x=I==="start"?O.x:I==="end"?O.x+O.w-k.w:O.x+(O.w-k.w)/2};w==="right-of"?(k.x=O.x+O.w+R,G()):w==="left-of"?(k.x=O.x-R-k.w,G()):w==="below"?(k.y=O.y+O.d+R,X()):(k.y=O.y-R-k.d,X())}function A(k){if(k.type==="node"){let[B,H,Y]=$(k);d.set(k,{x:0,y:0,w:B,d:H,h:Y,z:k.node.z??0}),k.children.length&&E(k,k.children,0,"row",!0);return}let O=k.region,w=O.padding??ht(r,O.kind)?.pad,R=!!O.size,I=E(k,k.children,w,O.flow??"row",R),G=O.size?O.size[0]:Math.max(I.w,w*2+.5),X=O.size?O.size[1]:Math.max(I.d,w*2+.5);if(!O.size&&O.gate){let B=(O.gate.width??2)+1;O.gate.side==="e"||O.gate.side==="w"?X=Math.max(X,B):G=Math.max(G,B)}let U=O.size&&O.size.length>2?O.size[2]:O.height??ht(r,O.kind).z[1];d.set(k,{x:0,y:0,w:G,d:X,h:U,z:0})}E(void 0,u,0,n.flow??"row",!0);function L(k,O,w,R){let I=d.get(k),G=O+I.x,X=w+I.y;if(k.type==="region"){let U=ht(r,k.region.kind),[B]=U.z,H=U.floor,Y=U.shape==="slab"&&ht(r,k.parent?.region?.kind)?.shape==="slab"?0:B,ee=k.region.z??0,F=R+Y+ee,K=R+I.h+ee;k.box={x0:G,y0:X,z0:F,x1:G+I.w,y1:X+I.d,z1:K},k.floor=H?K:R}else{let U=R+I.z;k.box={x0:G,y0:X,z0:U,x1:G+I.w,y1:X+I.d,z1:U+I.h},k.floor=k.box.z1}for(let U of k.children)U.placedBy||L(U,G,X,k.floor)}for(let k of u)k.placedBy||L(k,0,0,0);if(i){let k=w=>Math.round(w/i)*i,O=w=>Math.round(w*1e9)/1e9;for(let w of c){if(w.placedBy)continue;let R=w.box,I=k(R.x0),G=k(R.x1),X=k(R.y0),U=k(R.y1);G-I<i&&(G=I+i),U-X<i&&(U=X+i),w.box={...R,x0:O(I),x1:O(G),y0:O(X),y1:O(U)};let B=w.node??w.region;B.at&&B.at.forEach((H,Y)=>{let ee=H/i;Math.abs(ee-Math.round(ee))>1e-6&&a(`${w.path}/at/${Y}`,`${H} is not on the ${i} grid; it is drawn at ${O(k(H))}`,void 0,!1,"warning")})}}for(let k of c){let O=k.region?.gate;if(!O?.node)continue;let w=f.get(O.node);!w||w.placedBy!==k.id||(w.box=Yr(k,d.get(w).h,d.get(w).w,d.get(w).d),w.floor=w.box.z1)}for(let k of c){let O=k.children.filter(w=>!w.placedBy);for(let w=0;w<O.length;w++)for(let R=w+1;R<O.length;R++){let I=O[w],G=O[R];bi(I,r)||bi(G,r)||yi(I.box,G.box)&&a(G.path,`"${G.id}" overlaps "${I.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}if(k.parent&&k.parent.type==="region"&&!k.placedBy){let w=k.parent.box,R=k.box,I=1e-6;(R.x0<w.x0-I||R.y0<w.y0-I||R.x1>w.x1+I||R.y1>w.y1+I)&&a(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(O=>!O.placedBy);for(let O=0;O<k.length;O++)for(let w=O+1;w<k.length;w++){let R=k[O],I=k[w];yi(R.box,I.box)&&!bi(R,r)&&!bi(I,r)&&a(I.path,`"${I.id}" overlaps "${R.id}"`,'move one with "at", a relative placement, "gap" or "shift"',!1,"warning")}}let M=new Set,P=l.filter(k=>{let O=k.path+k.message;return M.has(O)?!1:(M.add(O),!0)});return{items:c,byId:f,roots:u,diags:P,catalog:r}}var bi=(n,e)=>n.type==="region"&&["zone","tunnel"].includes(ht(e,n.region.kind)?.shape??"");function Yr(n,e,t,s){let r=n.region.gate,o=n.box,i=n.box.z0,l=r.at??.5,a=r.width??2;if(r.side==="w"||r.side==="e"){let u=r.side==="w"?o.x0+Vn/2:o.x1-Vn/2,d=o.y0+(o.y1-o.y0)*l;return{x0:u-t/2,x1:u+t/2,y0:d-a/2,y1:d+a/2,z0:i,z1:i+e}}let c=r.side==="n"?o.y0+Vn/2:o.y1-Vn/2,f=o.x0+(o.x1-o.x0)*l;return{x0:f-a/2,x1:f+a/2,y0:c-s/2,y1:c+s/2,z0:i,z1:i+e}}function yi(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 Hr(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}var Zn=.2,wi=.05,Im=.6,ki=.25,vi={n:[0,-1],s:[0,1],e:[1,0],w:[-1,0]};function Zt(n){let e=/^(.*?)(?:\.(n|e|s|w|top))?$/.exec(n);return{id:e[1],side:e[2]}}var Df=new WeakMap;function Qs(n,e,t){let s=Df.get(n);if(!s){s=[];for(let i of n.items){if(i.type!=="region"||!ht(n.catalog,i.region.kind)?.floor)continue;let l=0;for(let a=i.parent;a;a=a.parent)l++;s.push({r:i,d:l})}Df.set(n,s)}let r=0,o=-1;for(let{r:i,d:l}of s){let a=i.box,c=1e-6;e>=a.x0-c&&e<=a.x1+c&&t>=a.y0-c&&t<=a.y1+c&&l>o&&(o=l,r=i.floor)}return r}function Lm(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),l=Math.max(e.y0-n.y1,n.y0-e.y1);return i>0&&(l<=0||i>=l)?r>0?"e":"w":l>0?o>0?"s":"n":Math.abs(r)>=Math.abs(o)?r>0?"e":"w":o>0?"s":"n"}var $i=5e5;function Mi(n,e,t,s,r,o){let i=[],l=(g,x,$,E="error")=>{let v=s.locate(g);i.push({severity:E,message:x,line:v.line,col:v.col,path:g,hint:$})},a=n.routes??[],c={left:$i},f=0,u=()=>t.items.map(g=>g.id),d=new Map,h=[],b=[];a.forEach((g,x)=>{let $=`${e}/routes/${x}`;(d.has(g.id)||t.byId.has(g.id))&&l($+"/id",`duplicate id "${g.id}"`),d.set(g.id,x);let E=g.kind??"send";r.has(E)||l($+"/kind",`unknown flow kind "${E}"`+ml(E,r),`kinds: ${[...r].join(", ")}; add one under "kinds:"`);let v={id:g.id,raw:g,path:$,kind:E,points:[]},A=(L,M)=>{let{id:P}=Zt(L),k=t.byId.get(P);if(!k){l(`${$}/${M}`,`unknown node "${P}"`+ml(P,u()));return}return k};v.from=A(g.from,"from"),v.to=A(g.to,"to"),h.push(v),b.push({r:v})});let m=new Map;for(let g of b){let{r:x}=g;if(!x.from||!x.to||x.raw.points)continue;let $=Zt(x.raw.from).side,E=Zt(x.raw.to).side,v=x.raw.via?.[0],A=x.raw.via?.[x.raw.via.length-1],L=(O,w)=>{if(Array.isArray(O))return{x0:O[0],x1:O[0],y0:O[1],y1:O[1],z0:0,z1:0};if(typeof O=="string"){let R=t.byId.get(Zt(O).id);if(R)return R.box}return w.box},M=(O,w,R)=>{let I=w??Lm(O.box,R);return{node:O,side:I,explicit:!!w,p:[0,0],z:0}};g.a=M(x.from,$,L(v,x.to)),g.b=M(x.to,E,L(A,x.from));let P=L(v,x.to),k=L(A,x.from);for(let[O,w]of[[g.a,P],[g.b,k]]){let R=`${O.node.id}.${O.side}`;m.has(R)||m.set(R,[]),m.get(R).push({e:O,other:[(w.x0+w.x1)/2,(w.y0+w.y1)/2]})}}for(let[,g]of m){let x=g[0].e,$=x.node.box,E=x.side,v=E==="e"||E==="w"?1:0;g.sort((O,w)=>O.other[v]-w.other[v]);let A=v?$.y0:$.x0,L=v?$.y1:$.x1,M=(A+L)/2,P=Math.max(0,L-A-.3),k=g.length>1?Math.min(Im,P/(g.length-1)):0;g.forEach((O,w)=>{let R=(w-(g.length-1)/2)*k,I=M+R,G=O.e.node.box.z0;if(E==="top"){O.e.p=[($.x0+$.x1)/2,($.y0+$.y1)/2],O.e.z=$.z1;return}let[X,U]=vi[E];O.e.p=v?[X>0?$.x1+wi:$.x0-wi,I]:[I,U>0?$.y1+wi:$.y0-wi],O.e.z=G})}let y=[];for(let g of t.items)g.type==="node"&&y.push(g.box);let N=[];for(let g of t.items.filter(x=>ht(t.catalog,x.region?.kind)?.shape==="walled")){let{x0:x,y0:$,x1:E,y1:v}=g.box,A=Vn,L=g.region.gate,M=[[{x0:x,y0:$,x1:E,y1:$+A,z0:0,z1:0},"n"],[{x0:x,y0:v-A,x1:E,y1:v,z0:0,z1:0},"s"],[{x0:x,y0:$,x1:x+A,y1:v,z0:0,z1:0},"w"],[{x0:E-A,y0:$,x1:E,y1:v,z0:0,z1:0},"e"]];for(let[P,k]of M)if(L&&L.side===k){if(L.node)continue;let O=L.at??.5,w=L.width??2;if(k==="e"||k==="w"){let R=$+(v-$)*O;N.push({...P,y1:R-w/2},{...P,y0:R+w/2})}else{let R=x+(E-x)*O;N.push({...P,x1:R-w/2},{...P,x0:R+w/2})}}else N.push(P)}let p=new Map;for(let g of b){let{r:x,a:$,b:E}=g;if(x.raw.points){x.points=x.raw.points.map(I=>[I[0],I[1],I.length>2?I[2]:Qs(t,I[0],I[1])+.01]);continue}if(!$||!E)continue;let v=[];(x.raw.via??[]).forEach((I,G)=>{if(Array.isArray(I))if(o){let X=U=>Math.round(Math.round(U/o)*o*1e9)/1e9;I.forEach((U,B)=>{Math.abs(U/o-Math.round(U/o))>1e-6&&l(`${x.path}/via/${G}/${B}`,`${U} is not on the ${o} grid; it is drawn at ${X(U)}`,void 0,"warning")}),v.push({p:[X(I[0]),X(I[1])]})}else v.push({p:[I[0],I[1]]});else{let{id:X,side:U}=Zt(I),B=t.byId.get(X);if(!B){l(`${x.path}/via/${G}`,`unknown node "${X}"`+ml(X,u()));return}let H=U&&U!=="top"?U:"n",[Y,ee]=vi[H],F=B.box;v.push({p:[Y?Y>0?F.x1+.4:F.x0-.4:(F.x0+F.x1)/2,ee?ee>0?F.y1+.4:F.y0-.4:(F.y0+F.y1)/2]})}});let L=y.filter(I=>I!==$.node.box&&I!==E.node.box).concat(x.raw.cross?[]:N).filter(I=>!Si($.node.box,I)&&!Si(E.node.box,I)&&!Si(I,$.node.box)&&!Si(I,E.node.box)),M=$.side==="top"?void 0:vi[$.side],P=E.side==="top"?void 0:vi[E.side],k=[$.p,...v.map(I=>I.p),E.p],O=[$.p],w=M,R=!0;for(let I=0;I+1<k.length;I++){let G=I+2===k.length,X=Bm(k[I],k[I+1],L,p,w,G&&P?[-P[0],-P[1]]:void 0,c);if(!X){R=!1;break}O.push(...X.slice(1));let U=O.length;if(U>=2){let B=Math.sign(O[U-1][0]-O[U-2][0]),H=Math.sign(O[U-1][1]-O[U-2][1]);w=[B,H]}}!R&&c.left<=0?(f++,O=[$.p,[E.p[0],$.p[1]],E.p]):R||(l(x.path,`no path found for route "${x.id}" from "${$.node.id}" to "${E.node.id}"`,'add "via" points, or use "points" to draw it by hand',"warning"),O=[$.p,[E.p[0],$.p[1]],E.p]),O=Wr(O);for(let I=0;I+1<O.length;I++)Fm(p,O[I],O[I+1]);x.points=_m(t,O,$,E)}return f&&l(e,`${f} of ${h.length} routes were drawn as plain elbows: the scene is too large to route them all around what stands in the way (${$i.toLocaleString("en")} search steps)`,'split it into scenes, or give the busiest routes "via" points or "points"',"warning"),{routes:h,diags:i}}function Si(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 _f=(n,e)=>`${Math.round(n/Zn)},${Math.round(e/Zn)}`;function Fm(n,e,t){let s=Math.max(1,Math.round(Math.hypot(t[0]-e[0],t[1]-e[1])/Zn));for(let r=0;r<=s;r++){let o=_f(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 zf(n,e,t){for(let s of t)if(n>s.x0-ki&&n<s.x1+ki&&e>s.y0-ki&&e<s.y1+ki)return!0;return!1}function Bm(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)&&Dm(n,e,t)){let B=[Math.sign(e[0]-n[0]),Math.sign(e[1]-n[1])],H=!r||r[0]===B[0]&&r[1]===B[1],Y=!o||o[0]===B[0]&&o[1]===B[1];if(H&&Y)return[n,e]}if(i.left<=0)return null;let l=B=>Math.round((B-n[0])/Zn),a=B=>Math.round((B-n[1])/Zn),c=B=>n[0]+B*Zn,f=B=>n[1]+B*Zn,u=l(e[0]),d=a(e[1]),h=30,b=Math.min(0,u)-h,m=Math.max(0,u)+h,y=Math.min(0,d)-h,N=Math.max(0,d)+h,p=1.2,g=Zn,x=.06,$=[[1,0],[-1,0],[0,1],[0,-1]],E=m-b+1,v=N-y+1,A=(B,H)=>(B-b)*v+(H-y),L=new Int8Array(E*v).fill(-1),M=new Float64Array(E*v).fill(-1),P=new Float64Array(E*v*4).fill(1/0),k=(B,H)=>{let Y=A(B,H);return L[Y]<0&&(L[Y]=zf(c(B),f(H),t)?1:0),L[Y]===1},O=(B,H)=>{let Y=A(B,H);return M[Y]<0&&(M[Y]=s.get(_f(c(B),f(H)))??0),M[Y]},w=pl(),R=(B,H)=>(Math.abs(B-u)+Math.abs(H-d))*g,I=r?$.findIndex(B=>B[0]===r[0]&&B[1]===r[1]):-1;w.push({i:0,j:0,d:I,g:0,f:R(0,0),idx:0,hp:0});let G=(B,H)=>Math.abs(B)+Math.abs(H)<=2,X=(B,H)=>Math.abs(B-u)+Math.abs(H-d)<=2,U=0;for(;w.length()&&U++<2e5;){if(i.left--<=0)return null;let B=w.take();if(B.i===u&&B.j===d&&!(o&&B.d>=0&&($[B.d][0]!==o[0]||$[B.d][1]!==o[1]))){let H=[];for(let Y=B;Y;Y=Y.prev)H.push([c(Y.i),f(Y.j)]);return H.reverse(),H[0]=n,jm(Wr(H),e)}for(let H=0;H<4;H++){let Y=$[H];if(B.d>=0&&Y[0]===-$[B.d][0]&&Y[1]===-$[B.d][1])continue;let ee=B.i+Y[0],F=B.j+Y[1];if(ee<b||ee>m||F<y||F>N||!G(ee,F)&&!X(ee,F)&&k(ee,F))continue;if((G(ee,F)||X(ee,F))&&k(ee,F)&&!(ee===u&&F===d)){let le=G(ee,F)?r:o&&[-o[0],-o[1]];if(!le||(G(ee,F)?Y[0]!==le[0]||Y[1]!==le[1]:Y[0]!==o[0]||Y[1]!==o[1]))continue}let K=B.d>=0&&B.d!==H?p:0,q=B.g+g+K+O(ee,F)*x,Z=A(ee,F)*4+H;P[Z]<=q||(P[Z]=q,w.push({i:ee,j:F,d:H,g:q,f:q+R(ee,F),prev:B,idx:0,hp:0}))}}return null}function pl(){let n=[],e=[],t=(i,l)=>i.f<l.f||i.f===l.f&&i.idx<l.idx,s=(i,l)=>{let a=e[i];e[i]=e[l],e[l]=a,e[i].hp=i,e[l].hp=l},r=i=>{for(;i>0;){let l=i-1>>1;if(!t(e[i],e[l]))break;s(i,l),i=l}},o=i=>{for(;;){let l=2*i+1,a=l+1,c=i;if(l<e.length&&t(e[l],e[c])&&(c=l),a<e.length&&t(e[a],e[c])&&(c=a),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],l=e.pop();e.length&&(e[0]=l,l.hp=0,o(0));let a=n.pop();return a!==i&&(n[i.idx]=a,a.idx=i.idx,r(a.hp)),i}}}function jm(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,Wr(t)}function Dm(n,e,t){let s=Math.max(1,Math.round(Math.hypot(e[0]-n[0],e[1]-n[1])/(Zn/2)));for(let r=2;r<s-1;r++)if(zf(n[0]+(e[0]-n[0])*r/s,n[1]+(e[1]-n[1])*r/s,t))return!1;return!0}function Wr(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 _m(n,e,t,s){let r=new Set,o=new Set;for(let c of n.items)c.type!=="region"||!ht(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=[],l=(c,f)=>Qs(n,c,f)+.01;for(let c=0;c+1<e.length;c++){let[f,u]=e[c],[d,h]=e[c+1],b=[0,1];if(Math.abs(u-h)<1e-6)for(let m of r){let y=(m-f)/(d-f);y>1e-6&&y<1-1e-6&&b.push(y)}else for(let m of o){let y=(m-u)/(h-u);y>1e-6&&y<1-1e-6&&b.push(y)}b.sort((m,y)=>m-y);for(let m=0;m+1<b.length;m++){let y=b[m],N=b[m+1],p=(y+N)/2,g=l(f+(d-f)*p,u+(h-u)*p),x=[f+(d-f)*y,u+(h-u)*y,g],$=[f+(d-f)*N,u+(h-u)*N,g],E=i[i.length-1];E&&(Math.abs(E[0]-x[0])>1e-6||Math.abs(E[1]-x[1])>1e-6||Math.abs(E[2]-x[2])>1e-6)?i.push(x):E||i.push(x),i.push($)}}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 a=[];for(let c of i){let f=a.length;if(f>=2){let u=a[f-2],d=a[f-1],h=Math.abs(u[2]-d[2])<1e-9&&Math.abs(d[2]-c[2])<1e-9,b=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(h&&b){a[f-1]=c;continue}}a.push(c)}return a}function ml(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 On(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 er(n,e){let t=n,s=(l,a)=>{let c=[];for(let f=0;f<t.length;f++){let u=t[f],d=t[(f+1)%t.length],h=l(u),b=l(d);h&&c.push(u),h!==b&&c.push(a(u,d))}t=c},r=l=>(a,c)=>[l,a[1]+(c[1]-a[1])*(l-a[0])/(c[0]-a[0])],o=l=>(a,c)=>[a[0]+(c[0]-a[0])*(l-a[1])/(c[1]-a[1]),l];if(s(l=>l[0]>=e.x,r(e.x)),!t.length||(s(l=>l[0]<=e.x+e.w,r(e.x+e.w)),!t.length)||(s(l=>l[1]>=e.y,o(e.y)),!t.length)||(s(l=>l[1]<=e.y+e.h,o(e.y+e.h)),!t.length))return 0;let i=0;for(let l=0;l<t.length;l++){let a=t[l],c=t[(l+1)%t.length];i+=a[0]*c[1]-c[0]*a[1]}return Math.abs(i)/2}function bl(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 Gf(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]),l=Math.max(1,Math.ceil(i/4));for(let a=0;a<l;a++){let c=r[0]+(o[0]-r[0])*(a+.5)/l,f=r[1]+(o[1]-r[1])*(a+.5)/l;c>=e.x&&c<=e.x+e.w&&f>=e.y&&f<=e.y+e.h&&(t+=i/l*4)}}return t}var es=64,Ei=class{cells=new Map;n=0;add(e,t,s,r,o){for(let i=Math.floor(t/es);i<=Math.floor(r/es);i++)for(let l=Math.floor(s/es);l<=Math.floor(o/es);l++){let a=i*1048576+l,c=this.cells.get(a);c||this.cells.set(a,c=[]),c[c.length-1]!==e&&c.push(e)}}query(e,t,s,r){let o=new Set;for(let i=Math.floor(e/es);i<=Math.floor(s/es);i++)for(let l=Math.floor(t/es);l<=Math.floor(r/es);l++){let a=this.cells.get(i*1048576+l);if(a)for(let c of a)o.add(c)}return[...o].sort((i,l)=>i-l)}},hl=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]},Ai=new WeakMap;function us(n,e){let t=Ai.get(n);for((!t||t.n>n.length)&&Ai.set(n,t=new Ei);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 Kf(n){let e=Ai.get(n);for((!e||e.n>n.length)&&Ai.set(n,e=new Ei);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,l=Math.max(1,Math.ceil(Math.hypot(o[0]-r[0],o[1]-r[1])/(es/2)));for(let a=0;a<l;a++){let c=a/l,f=(a+1)/l,u=r[0]+(o[0]-r[0])*c,d=r[1]+(o[1]-r[1])*c,h=r[0]+(o[0]-r[0])*f,b=r[1]+(o[1]-r[1])*f;e.add(i,Math.min(u,h)-1,Math.min(d,b)-1,Math.max(u,h)+1,Math.max(d,b)+1)}}}return e}var Gn=(n,e,t,s,r)=>n.query(e,t,s,r),Zs=n=>hl(n),Ti=n=>[n.x,n.y,n.x+n.w,n.y+n.h];function Vf(n,e,t,[s,r,o,i]){let l=0,a=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 h=(u-n[c])/f*t-.5,b=(d-n[c])/f*t-.5;h>b&&([h,b]=[b,h]),l=Math.max(l,Math.floor(h)-1),a=Math.min(a,Math.ceil(b)+1)}return[l,a]}var Ts=class n{polys=[];rects=[];lines=[];solids=[];slants=[];budget={spots:1/0,over:!1,told:!1};hidden(e){let t=0;for(let s of Gn(us(this.solids,Zs),...Ti(e)))t+=er(this.solids[s],e);return t}hiddenPoly(e){let t=0;for(let s of Gn(us(this.solids,Zs),...hl(e)))t+=Jr(e,this.solids[s]);return t}costPoly(e,t=1/0){let s=hl(e),r=0;for(let o of Gn(us(this.polys,i=>Zs(i.poly)),...s))r+=Jr(e,this.polys[o].poly);for(let o of Gn(us(this.rects,i=>Ti(i.r)),...s))r+=er(e,this.rects[o].r)*2;for(let o of Gn(us(this.slants,Zs),...s))r+=Jr(e,this.slants[o])*2;if(r>=t)return r;for(let o of Gn(Kf(this.lines),...s)){if(r>=t)return r;let i=this.lines[Math.floor(o/65536)].pts,l=o%65536,a=i[l],c=i[l+1],f=Math.hypot(c[0]-a[0],c[1]-a[1]),u=Math.max(1,Math.ceil(f/4)),[d,h]=Vf(a,c,u,s);for(let b=d;b<=h;b++)xl(e,[a[0]+(c[0]-a[0])*(b+.5)/u,a[1]+(c[1]-a[1])*(b+.5)/u])&&(r+=f/u*4*.6)}return r}cost(e,t,s=.6){let r=Ti(e),o=0;for(let i of Gn(us(this.polys,l=>Zs(l.poly)),...r)){let l=this.polys[i];o+=er(l.poly,e)*(l.owner===t?1.5:1)}for(let i of Gn(us(this.rects,l=>Ti(l.r)),...r)){let l=this.rects[i];(l.owner!==t||!t)&&(o+=bl(l.r,e)*2)}for(let i of Gn(us(this.slants,Zs),...r))o+=er(this.slants[i],e)*2;if(s){let i=-1,l=0;for(let a of Gn(Kf(this.lines),...r)){let c=Math.floor(a/65536);c!==i&&(i>=0&&(o+=l*s),i=c,l=0);let f=this.lines[c].pts,u=a%65536,d=f[u],h=f[u+1],b=Math.hypot(h[0]-d[0],h[1]-d[1]),m=Math.max(1,Math.ceil(b/4)),[y,N]=Vf(d,h,m,r);for(let p=y;p<=N;p++){let g=d[0]+(h[0]-d[0])*(p+.5)/m,x=d[1]+(h[1]-d[1])*(p+.5)/m;g>=e.x&&g<=e.x+e.w&&x>=e.y&&x<=e.y+e.h&&(l+=b/m*4)}}i>=0&&(o+=l*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}},qf=14;function Xr(n,e,t,s){let r=Math.max(n.name?ln(n.name,lt.lbl):0,n.sub?ln(n.sub,lt.sub):0)+4,o=(n.name?1:0)+(n.sub?1:0),i=t-(n.name?11:9)-1,l=(o-1)*qf+(n.name?11:9)+4;return{x:s==="start"?e-2:s==="end"?e-r+2:e-r/2,y:i,w:r,h:l}}function Qr(n,e,t,s,r,o){let i=On(t),l=Ce((e.x0+e.x1)/2,(e.y0+e.y1)/2,e.z1)[0],c=((n.name?1:0)+(n.sub?1:0)-1)*qf+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:l,y:f,anchor:"middle",pen:o?20:0});for(let m of[12,24,40])d.push({x:l,y:f-m,anchor:"middle",pen:20+m});for(let m of[-30,30,-60,60])d.push({x:l+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:l,y:i.y+i.h+14,anchor:"middle",pen:300});let h,b=1/0;for(let m of d){let y=Xr(n,m.x,m.y,m.anchor),N=s.cost(y,r,.15)*2+m.pen;N<b&&(b=N,h={x:m.x,y:m.y,anchor:m.anchor,rect:y})}return h}function yl(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 Oi(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,l=s.y-t;for(let f of[-1,1])for(let u of[16,32,48])o.push({...s,y:t+l+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+l+d,pen:8+u*.6+Math.abs(d)});let a,c=1/0;for(let f of o){let u=yl(n,f.x,f.y,f.anchor),d=r.cost(u,void 0,.05)*3+f.pen;d<c&&(c=d,a={x:f.x,y:f.y,anchor:f.anchor,rect:u})}return a}var Uf=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},gl=n=>Uf(n)<0?[...n].reverse():n;function xl(n,e){let t=gl(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 Jr(n,e){let t=gl(n),s=gl(e);for(let r=0;r<s.length&&t.length;r++){let o=s[r],i=s[(r+1)%s.length],l=c=>(i[0]-o[0])*(c[1]-o[1])-(i[1]-o[1])*(c[0]-o[0]),a=t;t=[];for(let c=0;c<a.length;c++){let f=a[c],u=a[(c+1)%a.length],d=l(f),h=l(u);if(d>=0&&t.push(f),d>=0!=h>=0){let b=d/(d-h);t.push([f[0]+(u[0]-f[0])*b,f[1]+(u[1]-f[1])*b])}}}return t.length>=3?Math.abs(Uf(t)):0}var Ni=24;function tr(n,e){let[t,s,r,o]=e,i=n.x+n.w/2,l=n.y+n.h/2,a=[["left",i-t],["right",t+r-i],["top",l-s],["bottom",s+o-l]];a.sort((f,u)=>f[1]-u[1]);let c=a[0][0];return c==="left"?{edge:c,dx:-(n.x+n.w-t)-Ni,dy:0}:c==="right"?{edge:c,dx:t+r-n.x+Ni,dy:0}:c==="top"?{edge:c,dx:0,dy:-(n.y+n.h-s)-Ni}:{edge:c,dx:0,dy:s+o-n.y+Ni}}function Ri(n,e,t){let s=x=>{let $=0;for(let E=x.parent;E;E=E.parent)$++;return $},r=x=>x.box.x0+x.box.y0+x.box.z0*.01,o=n.items.filter(x=>x.type==="region").sort((x,$)=>s(x)-s($)||r(x)-r($)),i=n.items.filter(x=>x.type==="node").sort((x,$)=>r(x)-r($)||x.box.z0-$.box.z0),l=[],a=Math.min(90,400/Math.max(1,o.length)),c=650;o.forEach((x,$)=>{let E=On(Rt(x.box));l.push({id:x.id,kind:"region",...tr(E,t),delay:Math.round($*a),dur:c,bbox:E})});let f=250+Math.round(a*o.length),u=Math.min(70,700/Math.max(1,i.length)),d=600;i.forEach((x,$)=>{let E=On(Rt(x.box));l.push({id:x.id,kind:"node",...tr(E,t),delay:Math.round(f+$*u),dur:d,bbox:E})});let h=i.length?f+(i.length-1)*u:f,b=Math.round(h+300),m=Math.min(30,300/Math.max(1,e.length)),y=400,N=e.filter(x=>x.points.length>=2).map((x,$)=>({id:x.id,delay:Math.round(b+$*m),dur:y})),p={delay:b+200,dur:400},g=Math.max(...l.map(x=>x.delay+x.dur),...N.map(x=>x.delay+x.dur),p.delay+p.dur);return{pieces:l,routes:N,labels:p,total:g}}var nr=["edge","drop","rise","fly","pop","scatter","build","fade"],sr=["explode","lift-off","sink","scatter","fly-out","collapse","fade","reverse"],Es=["by-depth","by-layer","by-region","by-flow","as-listed","random"],Xf=["linear","ease","ease-in","ease-out","settle","spring","bounce"],un=n=>Math.round(n*100)/100||0,Vt=n=>Math.round(n*1e4)/1e4||0;function As(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 l=(i.region??i.node)?.motion;l&&o.unshift(l)}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),l=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:un(o.x0+o.y0+o.z0*.01),bbox:On(Rt(o)),foot:[un(i[0]),un(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(a=>[un(a[0]),un(a[1])]),...l?{motion:l}:{}}}),routes:n.routes.filter(r=>n.rendered.paths[r.id]).map(r=>({id:r.id,path:n.rendered.paths[r.id],...zm(r.raw)})),notes:Object.fromEntries((n.raw.notes??[]).map((r,o)=>[`${n.id}-note-${o}`,r.on])),intro:n.rendered.assembly}}var Hf=n=>typeof n=="string"?n.split(".")[0]:void 0,zm=n=>{let e=Hf(n.from),t=Hf(n.to);return{...e?{from:e}:{},...t?{to:t}:{}}},Pi=(n,e,t,s)=>r=>{if(r<=0)return 0;if(r>=1)return 1;let o=(a,c,f)=>3*a*f*(1-f)**2+3*c*f*f*(1-f)+f**3,i=0,l=1;for(let a=0;a<40;a++){let c=(i+l)/2;o(n,t,c)<r?i=c:l=c}return o(e,s,(i+l)/2)},wl={linear:n=>n,ease:Pi(.42,0,.58,1),"ease-in":Pi(.42,0,1,1),"ease-out":Pi(0,0,.58,1),settle:Pi(.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 Sl(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 Yf=n=>{let e=2166136261;for(let t=0;t<n.length;t++)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0},Nn=n=>Math.max(0,Math.min(1,n)),Ci=24;function kl(n,e,t){let[s,r,o,i]=e;return t==="left"?[-(n.x+n.w-s)-Ci,0]:t==="right"?[s+o-n.x+Ci,0]:t==="top"?[0,-(n.y+n.h-r)-Ci]:[0,r+i-n.y+Ci]}function Ml(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=Sl(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 l=[],a=new Set,c=m=>{if(a.has(m.id))return;let y=m.parent?r.get(m.parent):void 0;y&&c(y),a.add(m.id),l.push(m)};if(e==="by-region"){let m=y=>{for(let N of i.get(y)??[])c(N),m(N.id)};return m(),l}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,h=d?[d]:[],b=new Set(h);for(;h.length;){let m=h.shift(),y=r.get(m);y&&c(y);for(let N of f.get(m)??[])b.has(N)||(b.add(N),h.push(N))}for(let m of[...s].sort(o))c(m);return l}var Km={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"},Vm={"lift-off":"lift",sink:"rise",scatter:"scatter","fly-out":"edge",fade:"fade",explode:"explode",collapse:"collapse"};function rr(n,e,t={}){let s=t.seed??1,r=e==="disassemble",o=r&&t.style==="reverse",i=U=>{if(!r)return U.motion?.style??t.style??"edge";let B=U.motion?.out??t.style??"fly-out";return B==="reverse"?U.motion?.style??t.of??"edge":Vm[B]},l=U=>r?U.motion?.out??t.style??"fly-out":i(U),a=!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,h=(U,B,H)=>{let Y=i(U),ee=U.motion?.easing??t.easing??Km[r&&l(U)!=="reverse"?l(U):Y]??"ease";return{p:U,delay:B+(U.motion?.delay??0),dur:Math.max(1,U.motion?.duration??H),style:Y,curve:wl[ee],from:U.motion?.from??t.from??"left"}};if(a){let U=new Map(n.pieces.map(B=>[B.id,B]));for(let B of n.intro.pieces){let H=U.get(B.id);H&&f.push(h(H,B.delay,B.dur))}u=n.intro.routes.map(B=>({...B})),d={...n.intro.labels}}else{let U=Ml(n,c,{seed:s,source:t.source}),B=t.piece??600,H=t.stagger??Math.min(70,900/Math.max(1,U.length)),Y=Nn(t.overlap??.5),ee=o||r?[...U].reverse():U,F=Math.min(30,300/Math.max(1,n.routes.length)),K=400,q=400;if(r){d={delay:0,dur:q};let Z=q*(1-Y);u=[...n.routes].reverse().map((W,oe)=>({id:W.id,delay:Z+oe*F,dur:K}));let le=Math.max(Z,...u.map(W=>W.delay+W.dur)),fe=Math.max(0,le-Y*K);ee.forEach((W,oe)=>f.push(h(W,fe+oe*H,B)))}else{ee.forEach((W,oe)=>f.push(h(W,oe*H,B)));let Z=Math.max(0,...f.map(W=>W.delay+W.dur)),le=Math.max(0,Z-Y*B);u=n.routes.map((W,oe)=>({id:W.id,delay:le+oe*F,dur:K}));let fe=Math.max(le,...u.map(W=>W.delay+W.dur));d={delay:Math.max(0,fe-Y*q),dur:q}}}let b=t.pulses&&n.routes.length?700:0;if(b&&r)for(let U of[...f,...u,d])U.delay+=b;let m=Math.max(1,...f.map(U=>U.delay+U.dur),...u.map(U=>U.delay+U.dur),d.delay+d.dur),y=r?0:m;b&&!r&&(m+=b);let N=t.duration!==void 0?Math.max(1,t.duration)/m:1;for(let U of[...f,...u,d])U.delay=un(U.delay*N),U.dur=Math.max(.01,un(U.dur*N));let p=t.duration!==void 0?Math.max(1,t.duration):Math.max(1,un(m)),g=new Map(f.map(U=>[U.p.id,U])),x=new Map(u.map(U=>[U.id,U])),[$,E,v,A]=n.viewBox,L=[$+v/2,E+A/2],M=U=>[U.x+U.w/2,U.y+U.h/2],P=(U,B)=>{let H=t.point;if(Array.isArray(H))return H;if(H==="region"||B==="collapse"&&H===void 0&&U.parent){let Y=n.pieces.find(ee=>ee.id===U.parent);return Y?Y.foot:L}if(typeof H=="string"){let Y=n.pieces.find(ee=>ee.id===H);if(Y)return Y.foot}return L};function k(U,B,H){let{p:Y}=U,ee=Y.bbox,F=1-B,K=(q,Z)=>({dx:un(q*F),dy:un(Z*F)});switch(U.style){case"drop":return K(...kl(ee,n.viewBox,"top"));case"lift":return K(...kl(ee,n.viewBox,"top"));case"fly":return K(...kl(ee,n.viewBox,U.from));case"rise":{let q=ee.h*F,[Z,le,fe]=Y.base,W=ee.y-ee.h-4;return{...K(0,ee.h),clip:[[Z[0],Z[1]-q],[le[0],le[1]-q],[fe[0],fe[1]-q],[fe[0]+2,W-q],[Z[0]-2,W-q]].map(oe=>[un(oe[0]),un(oe[1])])}}case"pop":return{scale:Vt(Math.max(0,B)),about:Y.foot,opacity:Vt(Nn(H*4))};case"scatter":{let q=Sl((s^Yf(Y.id))>>>0),Z=q()*Math.PI*2,le=.35+q()*.65;return{...K(Math.cos(Z)*v*le*.6,Math.sin(Z)*A*le*.6),opacity:Vt(Nn(B*1.6))}}case"build":return{...K(0,-18),opacity:Vt(Nn(B))};case"fade":return{opacity:Vt(Nn(B))};case"explode":{let q=P(Y,"explode"),Z=M(ee),le=Z[0]-q[0],fe=Z[1]-q[1],W=Math.hypot(le,fe),oe=Sl((s^Yf(Y.id))>>>0),Me=oe()*Math.PI*2,Le=W>1?[le/W,fe/W]:[Math.cos(Me),Math.sin(Me)],C=Math.hypot(v,A)+Math.max(ee.w,ee.h);return K(Le[0]*C,Le[1]*C)}case"collapse":{let q=P(Y,"collapse");return{...K(q[0]-Y.foot[0],q[1]-Y.foot[1]),scale:Vt(Math.max(0,B)),about:Y.foot,opacity:Vt(Nn(B*3))}}default:{let q=tr(ee,n.viewBox);return K(q.dx,q.dy)}}}let O=(U,B,H)=>{let Y=Nn((U-B)/H);return r?1-Y:Y},w={opacity:0},R=t.connectors??"draw",I=t.labels??"fade",G=[...n.pieces.map(U=>U.id),...n.routes.map(U=>U.id),...Object.keys(n.notes)];function X(U){let B=Math.max(0,Math.min(p,Number.isFinite(U)?U:0));if(r?B<=0:B>=p)return{};let H=r?B>=p:B<=0,Y={},ee={},F={};for(let fe of f){let W=H?0:O(B,fe.delay,fe.dur);W<=0?Y[fe.p.id]=w:W<1&&(Y[fe.p.id]=k(fe,r?1-fe.curve(1-W):fe.curve(W),W))}for(let fe of n.routes){let W=x.get(fe.id),oe=H||!W?0:O(B,W.delay,W.dur);oe<=0?ee[fe.id]={opacity:0,drawn:0}:oe<1&&(ee[fe.id]=R==="fade"?{opacity:Vt(oe)}:R==="grow"?{drawn:Vt(oe),by:"grow"}:{drawn:Vt(wl["ease-out"](oe))})}let K=H?0:O(B,d.delay,d.dur),q=K<=0?w:K>=1?void 0:I==="type"?{typed:Vt(K)}:{opacity:Vt(K)};for(let fe of G){let W=q;if(I==="with-piece"){let oe=Object.hasOwn(n.notes,fe)?n.notes[fe]:fe,Me=oe===void 0?void 0:g.get(oe)??x.get(oe);if(Me){let Le=H?0:O(B,Me.delay,Me.dur);W=Le<=0?w:Le>=1?void 0:{opacity:Vt(Le)}}}W&&(F[fe]=W)}let Z=[];if(b&&!H){let fe=(B-y*N)/(b*N);if(fe>0&&fe<1)for(let W of n.routes)Z.push({route:W.id,at:Vt(wl.ease(fe))})}let le=fe=>Object.keys(fe).length>0;return{...le(Y)?{items:Y}:{},...le(F)?{labels:F}:{},...le(ee)?{routes:ee}:{},...K<1?{marks:{opacity:Vt(Math.max(0,K))}}:{},...Z.length?{tokens:Z}:{}}}return{kind:e,duration:p,pieces:f.map(U=>({id:U.p.id,delay:U.delay,dur:U.dur,style:l(U.p)})),routes:u,labels:d,at:X}}var ct=n=>{let e=n.toFixed(2);return e==="-0.00"?"0":String(Number(e))},Gm=(n,e)=>`translate(${ct(n[0])} ${ct(n[1])}) scale(${Number(e.toFixed(4))}) translate(${ct(-n[0])} ${ct(-n[1])})`,Tl=n=>[...n.matchAll(/(-?[\d.]+),(-?[\d.]+)/g)].map(e=>[Number(e[1]),Number(e[2])]),El=n=>n.slice(1).reduce((e,t,s)=>e+Math.hypot(t[0]-n[s][0],t[1]-n[s][1]),0);function Ii(n,e){let t=Tl(n),s=El(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 qm(n,e){let t=Tl(n),s=Ii(n,e),r=[],o=El(t)*e;for(let i=0;i<t.length;i++){r.push(t[i]);let l=i+1<t.length?Math.hypot(t[i+1][0]-t[i][0],t[i+1][1]-t[i][1]):1/0;if(o<=l)break;o-=l}return"M"+[...r,s].map(i=>`${ct(i[0])},${ct(i[1])}`).join(" L")}var qn=n=>String(Number(n.toFixed(4)));function Um(n,e){let t=n.match(/&[^;\s]+;|[\s\S]/gu)??[];return t.slice(0,Math.round(t.length*e)).join("")}function Hm(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(Gm(n.about??[0,0],n.scale)),{attrs:{...n.opacity===void 0||n.opacity===1?{}:{opacity:qn(n.opacity)},...e.length?{transform:e.join(" ")}:{}},clip:n.clip}}function Ym(n,e){let t={attrs:n.opacity===void 0||n.opacity===1?{}:{opacity:qn(n.opacity)}};if(n.drawn!==void 0&&n.drawn<1&&e!==void 0){let s=Nn(n.drawn),r=El(Tl(e));t.path=n.by==="grow"?{d:qm(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 Qf(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:qn(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&&Ym(i,r(t))}let o=n.items&&Object.hasOwn(n.items,t)?n.items[t]:void 0;return o&&Hm(o)}function Zf(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:qn(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:qn(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,l]=Ii(o,Nn(r.at));s.push(["circle",{cx:ct(i),cy:ct(l),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 eu=n=>Object.keys(n).every(e=>e==="morph"||n[e]===void 0),tu=new Set(["marks","badges"]),Wf=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/"/g,""");function $l(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:`${su(r)}
|
|
143
|
+
${o}`}:{},from:s.index+s[0].length})}return e}var Jf=new WeakMap;function Wm(n,e){let t=Jf.get(n)??new Map;Jf.set(n,t);let s=t.get(e);if(!s){t.set(e,s=new Map);let r=n.variants?.[e],o=$l(n.svg);if(r!==void 0)for(let[i,[l,a]]of $l(r)){let c=o.get(i);c&&n.looks?.[i.split(`
|
|
144
|
+
`)[0]]?.includes(e)&&n.svg.slice(...c)!==r.slice(l,a)&&s.set(i,r.slice(l,a))}}return s}function nu(n,e,t,s){let r=[];for(let o of n.looks?.[e]??[]){let i=Nn(s[o]??0),l=i>0?Wm(n,o).get(`${e}
|
|
145
|
+
${t}`):void 0;l!==void 0&&r.push([l,i])}return r.length?{own:Nn(1-r.reduce((o,[,i])=>o+i,0)),looks:r}:void 0}var Jm=(n,e)=>(e.own>0?`<g opacity="${qn(e.own)}">${n}</g>`:"")+e.looks.map(([t,s])=>`<g opacity="${qn(s)}">${t}</g>`).join("");function Xm(n,e){let t="",s=0;for(let[r,[o,i]]of[...$l(n.svg)].sort((l,a)=>l[1][0]-a[1][0])){let[l,a]=r.split(`
|
|
146
|
+
`),c=Object.hasOwn(e,l)?nu(n,l,a,e[l]):void 0;c&&(t+=n.svg.slice(s,o)+Jm(n.svg.slice(o,i),c),s=i)}return t+n.svg.slice(s)}function Al(n,e){if(eu(e))return n.rendered.svg;let t=e.variants?Xm(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="",l=0,a,c=t.replace(/<(\/?)([a-zA-Z]+)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|([^<]+)/g,(u,d,h,b,m,y)=>{if(y!==void 0)return a?.w.typed===void 0?u:Um(y,a.w.typed);if(d)return r--,a&&r===a.at&&(a=void 0),r===1&&(o=""),u;let N=r;m||r++;let p={};for(let[,g,x]of b.matchAll(/([\w:-]+)="([^"]*)"/g))p[g]=x;if(N===0){if(!e.camera)return u;p.viewBox=e.camera.map(ct).join(" ")}else if(N===1)if(o=h==="g"&&p.class?.startsWith("g-")?p.class.slice(2):"",tu.has(o)&&e.marks&&e.marks.opacity!==1)p.opacity=qn(e.marks.opacity);else return u;else if(N===2&&p["data-part"]!==void 0){let g=p["data-route"]===void 0?"item":"route",x=su(p["data-route"]??p["data-item"]??""),$=Qf(e,g,x,p["data-part"],s);if(!$)return u;for(let[E,v]of Object.entries($.attrs))p[E]=Wf(v);if($.clip){let E=`${n.id}-mc${l++}`;i+=`<clipPath id="${E}"><polygon points="${$.clip.map(v=>v.join(",")).join(" ")}"/></clipPath>`,p["clip-path"]=`url(#${E})`}if(!m&&($.path||$.typed!==void 0)&&(a={at:N,w:$}),!Object.keys($.attrs).length&&!$.clip)return u}else if(a?.w.path&&h==="path"&&p.class?.split(" ")[0]==="flow"){let g=a.w.path;g.d!==void 0&&(p.d=g.d),g.style!==void 0&&(p.style=g.style),g.head||delete p["marker-end"]}else return u;return`<${h}${Object.entries(p).map(([g,x])=>` ${g}="${x}"`).join("")}${m?"/":""}>`});i&&(c=c.replace(/<defs>|<defs\/>/,u=>u==="<defs/>"?`<defs>${i}</defs>`:u+i));let f=Zf(e,s,n.rendered.inks);return f.length&&(c=c.replace('<g class="g-anim">',u=>u+f.map(([d,h])=>`<${d}${Object.entries(h).map(([b,m])=>` ${b}="${Wf(m)}"`).join("")}/>`).join(""))),c}var su=n=>n.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&"),vl=new WeakMap;function Li(n,e,t,s={}){let r=vl.get(n);if(r){for(let[p,g]of r.mixed)p.replaceChildren(...g);for(let[p,g]of r.attrs)for(let[x,$]of g)$===null?p.removeAttribute(x):p.setAttribute(x,$);for(let[p,g,x]of r.gone.reverse())g.insertBefore(p,x);for(let[p,g]of r.texts)p.data=g;for(let p of r.made)p.remove();vl.delete(n)}if(eu(e))return;let o={attrs:new Map,texts:new Map,gone:[],made:[],mixed:[]};vl.set(n,o);let i=(p,g,x)=>{let $=o.attrs.get(p)??new Map;$.has(g)||$.set(g,g==="style"?p.getAttribute(g)||null:p.getAttribute(g)),o.attrs.set(p,$),x===null?p.removeAttribute(g):p.setAttribute(g,x)},l=n.ownerDocument,a=(p,g,x)=>{let $=l.createElementNS("http://www.w3.org/2000/svg",p);for(let[E,v]of Object.entries(g))$.setAttribute(E,v);return x.append($),o.made.push($),$},c=Array.from(n.children),f=p=>c.find(g=>g.getAttribute("class")===`g-${p}`),u=new Map;for(let p of Array.from(f("flows")?.children??[])){let g=p.getAttribute("data-route"),x=p.querySelector("path.flow")?.getAttribute("d");g!==null&&x&&u.set(g,x)}let d=p=>u.get(p);e.camera&&i(n,"viewBox",e.camera.map(ct).join(" "));for(let p of tu){let g=f(p);g&&e.marks&&e.marks.opacity!==1&&i(g,"opacity",qn(e.marks.opacity))}let h=0,b=c.find(p=>p.localName==="defs"),m=b?.firstChild??null,y=n.getAttribute("data-scene")??"scene";for(let p of c)for(let g of Array.from(p.children)){let x=g.getAttribute("data-part");if(x===null)continue;let $=g.getAttribute("data-route"),E=$===null?g.getAttribute("data-item")??"":"",v=t&&e.variants&&Object.hasOwn(e.variants,E)?nu(t,E,x,e.variants[E]):void 0;if(v){let M=Array.from(g.childNodes),P=(O,w)=>{let R=l.createElementNS("http://www.w3.org/2000/svg","g");return R.setAttribute("opacity",qn(O)),R.append(...w),R},k=O=>Array.from(l.importNode(new DOMParser().parseFromString(`<svg xmlns="http://www.w3.org/2000/svg">${O}</svg>`,"image/svg+xml").documentElement,!0).childNodes);o.mixed.push([g,M]),g.replaceChildren(...v.own>0?[P(v.own,M)]:[],...v.looks.map(([O,w])=>P(w,k(O))))}let A=Qf(e,$===null?"item":"route",$??g.getAttribute("data-item")??"",x,d);if(!A)continue;for(let[M,P]of Object.entries(A.attrs))i(g,M,P);if(A.clip&&b){let M=a("clipPath",{id:`${y}-mc${h++}`},b);b.insertBefore(M,m);let P=l.createElementNS("http://www.w3.org/2000/svg","polygon");P.setAttribute("points",A.clip.map(k=>k.join(",")).join(" ")),M.append(P),i(g,"clip-path",`url(#${M.id})`)}if(A.typed!==void 0){let M=[];for(let P=l.createTreeWalker(g,4);P.nextNode();)M.push(P.currentNode);for(let P of M)o.texts.set(P,P.data),P.data=Array.from(P.data).slice(0,Math.round(Array.from(P.data).length*A.typed)).join(""),P.data||(o.gone.push([P,P.parentNode,P.nextSibling]),P.remove())}let L=A.path&&g.querySelector("path.flow");L&&A.path&&(A.path.d!==void 0&&i(L,"d",A.path.d),A.path.style!==void 0&&(s.styles==="cssom"?(i(L,"style",null),L.style.cssText=A.path.style):i(L,"style",A.path.style)),A.path.head||i(L,"marker-end",null))}let N=f("anim");if(N)for(let[p,g]of Zf(e,d,t?.inks))a(p,g,N)}var ru=(n,e)=>({...e,frame:t=>Al(n,e.at(t))}),Ol=(n,e={})=>ru(n,rr(As(n),"assemble",e)),ou=(n,e={})=>ru(n,rr(As(n),"disassemble",e)),iu=(n,e)=>Ol(n).frame(e);var Di=(n,e)=>e.role??ht(n,e.kind)?.role,Fi=(n,e)=>ht(n,e.region.kind)?.shape,en=(n,e,t,s="item")=>t?Te("g",{[`data-${s}`]:n,"data-part":e},t):"";function or({scene:n,layout:e,routes:t,steps:s,theme:r,id:o,gridStep:i=1}){let l=new js,a={base:"",floor:"",flows:"",blocks:[],air:"",labels:"",marks:"",badges:""},c=new Ts;c.budget.spots=ji;let f=w=>s.vis[w]?{"data-vis":"1"}:{},u=e.items.filter(w=>w.type==="region"),d=w=>{let R=0;for(let I=w.parent;I;I=I.parent)R++;return R},h=e.catalog,b=u.filter(w=>Fi(h,w)!=="walled"&&Fi(h,w)!=="tunnel"),m=Sr(b.map(w=>({box:w.box,r:w}))).map(w=>w.r).sort((w,R)=>d(w)-d(R));for(let w of m)a.base+=Zm(l,h,w,f(w.id),i);for(let w of u.filter(R=>Fi(h,R)==="walled")){for(let I of Bi(w))c.solids.push(Rt(I));for(let[I,G]of Bi(w).entries())a.blocks.push({box:G,svg:en(w.id,`wall-${I+1}`,Te("g",{class:`blk k-${Di(h,w.region)} wall${w.region.ghost?" ghost":""}`,"data-id":w.id,"data-dim":"1",...f(w.id)},l.blockFaces(G)))});let R=w.region.gate;if(R&&!R.node){let I=Yr(w,R.height??(w.region.height??.8)+.3,.3,.3);c.solids.push(Rt(I)),a.blocks.push({box:I,svg:en(w.id,"gate",Te("g",{class:"blk k-gate","data-id":w.id,...f(w.id)},l.blockFaces(I)))})}w.region.label&&(w.region["label-style"]??"face")!=="none"&&(a.labels+=en(w.id,"name",l.faceText(w.box.x0+.3,w.box.y1,w.box.z0+.13,w.region.label,"slabname sm fz",lt.sm,"left","start",{"data-id":w.id,...f(w.id)})))}for(let w of u.filter(R=>Fi(h,R)==="tunnel"))a.air+=en(w.id,"block",tp(l,w,f(w.id)));let y=e.items.filter(w=>w.type==="node");for(let w of y){let R=w.node,I=fn(h,R.asset),G=R.ghost||(R.deco??[]).includes("ghost"),X=["blk",`k-${R.role??I.role}`,I.cls,G?"ghost":""].filter(Boolean).join(" ");a.blocks.push({box:w.box,svg:en(w.id,"block",Te("g",{class:X,"data-id":w.id,"data-dim":"1",...f(w.id)},I.draw(l,w.box,R)))}),c.polys.push({poly:Rt(w.box),owner:w.id}),c.solids.push(Rt(w.box))}let N=Sr(a.blocks).map(w=>w.svg).join(""),p=new Set,g={};for(let w of t){if(w.points.length<2)continue;let R=w.points.map(X=>Ce(X[0],X[1],X[2]));R.forEach(X=>l.bounds.add(X));let I="M"+R.map(xs).join(" L");g[w.id]=I;let G=w.raw.arrow!==!1;G&&p.add(w.kind),a.flows+=en(w.id,"line",Te("g",{"data-hl":w.id,"data-id":w.id,...f(w.id)},Te("path",{d:I,class:`flow f-${w.kind}`,"marker-end":G?`url(#ah-${o}-${w.kind})`:void 0})),"route"),c.lines.push({pts:R,owner:w.id})}for(let w of p)l.def(`ah-${o}-${w}`,Te("marker",{id:`ah-${o}-${w}`,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:${An(r,r.kinds[w]?.color??"control")}`})));for(let w of l.planePolys)c.slants.push(w);let x=y.filter(w=>w.node.label||w.node.sub).sort((w,R)=>(R.box.x1-R.box.x0)*(R.box.y1-R.box.y0)-(w.box.x1-w.box.x0)*(w.box.y1-w.box.y0));for(let w of x)a.labels+=en(w.id,"label",ep(l,h,w,c,f(w.id)));let $=[];for(let w of t)if(w.raw.label&&w.points.length>=2){let R=np(l,w,c,f(w.id),e);a.floor+=en(w.id,"label",R.svg,"route"),R.warning&&$.push({path:`${w.path}/label`,message:R.warning}),c.budget.over&&!c.budget.told&&(c.budget.told=!0,$.push({path:w.path,message:`from route "${w.id}" on, route labels were placed without weighing what other labels and lines cover: the scene is too large to search every spot (${ji.toLocaleString("en")} spots); split it into scenes, or give the labels "along", "side" or "at"`}))}(n.notes??[]).forEach((w,R)=>{let I=en(`${o}-note-${R}`,"note",sp(l,w,e,t,`${o}-note-${R}`));w.floor?a.floor+=I:a.labels+=I});let E=[],v=new Map;for(let w of s.says){let R=v.get(w.step)??c.fork();v.set(w.step,R);let I=ln(w.text,lt.say)+18,G=Oi(I,w.ax,w.ay,{x:w.x,y:w.y,anchor:w.anchor},R);R.rects.push({r:G.rect,owner:""}),E.push({step:w.step,...G.rect,text:w.text});let X=G.rect.x+2;l.bounds.addRect(G.rect.x,G.rect.y,G.rect.w,G.rect.h);let U=An(r,r.kinds[w.kind]?.color??"control");a.marks+=Te("g",{class:"say","data-step":w.step},Te("rect",{x:X,y:G.y-12,width:I,height:24,rx:12,style:`stroke:${U}`})+Te("text",{x:X+I/2,y:G.y+4,"text-anchor":"middle",style:`fill:${U}`},mt(w.text)))}for(let w of s.marks){let[R,I]=Ce(...w.p);l.bounds.addRect(R-12,I-12,24,24),a.marks+=Te("g",{class:"xm","data-step":w.step,"data-hl":w.on},Te("circle",{cx:R,cy:I,r:10})+Te("path",{d:`M${at(R-4.5)},${at(I-4.5)} L${at(R+4.5)},${at(I+4.5)} M${at(R+4.5)},${at(I-4.5)} L${at(R-4.5)},${at(I+4.5)}`}))}for(let w of s.badges){let[R,I]=Ce(...w.p);l.bounds.addRect(R-13,I-13,26,26),a.badges+=Te("g",{class:`badge c-${w.kind}`,"data-go":w.step,"data-badge":w.step,tabindex:"0",role:"button","aria-label":`Step ${w.num}`},Te("circle",{cx:R,cy:I,r:11.5})+Te("text",{x:R,y:I+.5},String(w.num)))}let A=l.bounds,L=22,M=A.empty?[0,0,100,100]:[Math.floor(A.x0-L),Math.floor(A.y0-L),Math.ceil(A.x1-A.x0+L*2),Math.ceil(A.y1-A.y0+L*2)],P=[...l.defs.values()].join(""),k=(w,R)=>Te("g",{class:"g-"+w},R);return{svg:Te("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:M.join(" "),role:"img","aria-label":n.aria??n.title,"data-scene":o},Te("defs",{},P)+k("base",a.base)+k("floor",a.floor)+k("flows",a.flows)+k("blocks",N)+k("air",a.air)+k("labels",a.labels)+k("marks",a.marks)+k("badges",a.badges)+k("anim","")),viewBox:M,texts:l.texts,paths:g,warnings:$,callouts:E,assembly:Ri(e,t,M)}}function Qm(n,e){let t=n.z1+.002,s=1e-6,r=[],o=(i,l)=>{let a=Ce(i[0],i[1],t),c=Ce(l[0],l[1],t);r.push(`M${xs(a)}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 Zm(n,e,t,s,r=1){let o=t.region,i=t.box,l=Di(e,o),a=ht(e,o.kind),c=a?.shape,f={"data-id":t.id,"data-dim":"1",...s},u="";c==="cloud"?u=Te("g",{class:`blk k-${l} cloud`,...f},gi(n,i)):c==="zone"?u=Te("g",{class:`zone k-${l}`,...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-${l}${o.ghost?" ghost":""}`,...f},n.blockFaces(i)+Qm(i,r)),u=en(t.id,"block",u);let d=o["label-style"]??a?.labelStyle;if(o.label&&d!=="none")if(d==="face"){let h=i.z1-i.z0,b=p=>p.size*.73/st,m=c==="slab"&&.28+b(lt.slabname)+.08>h,y=c==="slab"&&!m,N=y?i.z0+.28:m?i.z0+Math.max(.02,(h-b(lt.sm))/2):i.z0+Math.min(.1,h*.25);u+=en(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+=en(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 h=c==="cloud"?"middle":"start",b=c==="cloud"?(i.x0+i.x1)/2:i.x0+.35,m=c==="cloud"?(i.y0+i.y1)/2:i.y1-.35;u+=en(t.id,"name",Te("g",f,n.floorText(b,m,i.z1+.01,o.label,"slabname sm","x",h)))}return u}function Bi(n){let{x0:e,y0:t,x1:s,y1:r,z0:o,z1:i}=n.box,l=Vn,a=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,h,b)=>{if(!a||a.side!==b)return[[d,h]];let m=a.at??.5,y=a.width??2,N=b==="e"||b==="w"?t+(r-t)*m:e+(s-e)*m;return[[d,N-y/2],[N+y/2,h]]};for(let[d,h]of u(e,s,"n"))f({x0:d,y0:t,x1:h,y1:t+l});for(let[d,h]of u(t+l,r-l,"w"))f({x0:e,y0:d,x1:e+l,y1:h});for(let[d,h]of u(t+l,r-l,"e"))f({x0:s-l,y0:d,x1:s,y1:h});for(let[d,h]of u(e,s,"s"))f({x0:d,y0:r-l,x1:h,y1:r});return c}function ep(n,e,t,s,r){let o=t.node,i=fn(e,o.asset),l=t.box,a={name:o.label,sub:o.sub},c=o["label-at"],f;if(c){let d=On(Rt(l)),h=c.side??"above",b=d.y+Math.min(d.h,60)*.45;h==="right"?f={x:d.x+d.w+8,y:b,anchor:"start"}:h==="left"?f={x:d.x-8,y:b,anchor:"end"}:h==="below"?f={x:d.x+d.w/2,y:d.y+d.h+14,anchor:"middle"}:f=Qr(a,l,Rt(l),new Ts,t.id),f={...f,x:f.x+(c.dx??0),y:f.y+(c.dy??0)}}else{let d=i.label?i.label(l,o,!!o.sub):void 0;f=Qr(a,l,Rt(l),s,t.id,d)}s.rects.push({r:Xr(a,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 tp(n,e,t){let{x0:s,y0:r,x1:o,y1:i,z0:l,z1:a}=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 h=1;h<u;h++){let b=f?s+(o-s)*h/u:r+(i-r)*h/u;c+=n.poly(f?[[b,r,a],[b,i,a],[b,i,l]]:[[s,b,a],[o,b,a],[o,b,l]],"rib")}let d=e.region.label;return d&&e.region["label-style"]!=="none"&&(c+=f?n.faceText(s+.35,i,l+.14,d,"tunname",lt.tunname,"left","start"):n.faceText(o,i-.35,l+.18,d,"tunname",lt.tunname,"right","start")),Te("g",{class:"tunnel","data-id":e.id,"data-dim":"1",...t},c)}var ji=2e4;function np(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}`,l={"data-hl":e.id,...s},a=lt.floor;if(o.at){let p=o.at.length>2?o.at[2]:e.points[0][2];return{svg:n.floorText(o.at[0],o.at[1],p,o.text,i,o.dir??"x",o.anchor??"start",l)}}let c=e.points,f=[];for(let p=0;p+1<c.length;p++){let g=c[p],x=c[p+1];Math.abs(g[2]-x[2])>1e-6||f.push({i:p,len:Math.hypot(x[0]-g[0],x[1]-g[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(p=>p.i===Math.min(o.along-1,c.length-2)):[...f].sort((p,g)=>g.len-p.len),d=.22,h=11/st,b=p=>{let g=ln(p,a)/st,x,$=1/0,E=0;e:for(let v of u.length?u:f){let A=c[v.i],L=c[v.i+1],M=A[2],P=Math.abs(A[1]-L[1])<1e-6,k=P?Math.min(A[0],L[0]):Math.min(A[1],L[1]),O=P?Math.max(A[0],L[0]):Math.max(A[1],L[1]),w=P?A[1]:A[0],R=o.side==="left"?[-1]:o.side==="right"?[1]:[-1,1],I=[];for(let G=k+.3;G<=Math.max(k+.3,O-g-.2)+1e-9;G+=.4)I.push(G);for(let G=O-g-.2+.4;G<O+.5&&O-k<g+.5;G+=.6)I.push(G);for(let G of R)for(let X of I){if($<=E*.5)break e;let U=G<0?w-d:w+d+h,B,H,Y;if(P?(B=X,H=U,Y=[Ce(B,H-h,M),Ce(B+g,H-h,M),Ce(B+g,H,M),Ce(B,H,M)]):(B=U,H=X+g,Y=[Ce(B-h,H,M),Ce(B-h,H-g,M),Ce(B,H-g,M),Ce(B,H,M)]),(P?[[B,H-h],[B+g,H-h],[B+g,H],[B,H]]:[[B-h,H],[B-h,H-g],[B,H-g],[B,H]]).some(([le,fe])=>Math.abs(Qs(r,le,fe)+.01-M)>.001)){E++;continue}let F=t.hiddenPoly(Y),K=F*50+E*.5,q=t.budget.spots-- >0;q||(t.budget.over=!0);let Z=K>=$?1/0:q?K+t.costPoly(Y,$-K):K;E++,Z<$&&($=Z,x={x:B,y:H,z:M,dir:P?"x":"y",rect:On(Y),poly:Y,hidden:F})}}return x&&x.hidden<6?x:void 0},m=o.text,y=b(m),N;if(!y){let p=o.text.split(/(\s+)/);for(let g=p.length-1;g>0&&!y;g--){let x=p.slice(0,g).join("").trimEnd().replace(/[\s,;:·–-]+$/,"")+"\u2026";if(x.length<6)break;let $=b(x);$&&(y=$,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",l),warning:N}):{svg:"",warning:N}}function sp(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,l=e.at,a={"data-id":r,"data-hl":o?.id,"data-dim":o?void 0:"1"},c=e.kind??o?.kind??"control";if(e.floor){let f=l&&l.length>2?l[2]:o?o.points[0][2]:i?i.floor:.36,[u,d]=l?[l[0],l[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",a)}if(e.face){let f=i?.box,[u,d,h]=l?[l[0],l[1],l[2]??.45]:f?[f.x0+.3,f.y1,f.z0+.13]:[0,0,0];return n.faceText(u,d,h,e.face,"slabname sm",lt.sm,"left",e.anchor??"start",a)}if(e.label||e.sub){let f=i?.box,u=l?[l[0],l[1],l[2]??.36]:f?[(f.x0+f.x1)/2,(f.y0+f.y1)/2,f.z1+.75]:[0,0,0],[d,h]=Ce(u[0],u[1],u[2]),b=d+(e.dx??0),m=h-18+(e.dy??0),y=e.anchor??"middle",N="";return e.label&&(N+=n.text(b,m,e.label,"lbl",lt.lbl,y)),e.sub&&(N+=n.text(b,e.label?m+14:m,e.sub,"sub mono",lt.sub,y)),Te("g",a,N)}return""}function au(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,or({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 Zr=29.09090909090909,Nl={solid:[9,7],dashed:[7,6],dotted:[3,6]},Rl=["blocked","planned"],lu=`
|
|
147
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
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,"")}}
|
|
149
|
+
`;function eo(n,e={}){return(e.still??Rl).includes(n)?void 0:e.dash??e.kinds?.[n]?.ants??Nl[e.kinds?.[n]?.dash??"solid"]}function _i(n){let e=n?.ants;return e?e===!0?{}:Array.isArray(e)?{ids:e}:e:void 0}function cu(n,e={}){let t=new Map(n.routes.map(i=>[i.id,i.kind])),s=e.ids&&new Set(e.ids),r=e.speed??Zr,o=i=>String(Number(i.toFixed(3)));return n.rendered.svg.replace(/(<g data-route="([^"]*)" data-part="line">(?:<g[^>]*>)*)<path ([^>]*?)\s*\/>/g,(i,l,a,c)=>{let f=a.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&"),u=s&&!s.has(f)?void 0:eo(t.get(f)??"",e);if(!u||!/class="flow\b/.test(c))return i;let d=u[0]+u[1],h=o(d/Math.max(1e-6,Math.abs(r))),b=o(r<0?d:-d);return e.by==="css"?`${l}<path ${c.replace(/class="flow\b/,'class="flow iso-ants')} style="--ant-on:${o(u[0])};--ant-off:${o(u[1])};--ant-to:${b};--ant-turn:${h}s"/>`:e.by==="none"?`${l}<path ${c.replace(/ ?stroke-dasharray="[^"]*"/,"")} style="stroke-dasharray:${o(u[0])} ${o(u[1])}"/>`:`${l}<path ${c.replace(/ ?stroke-dasharray="[^"]*"/,"")} style="stroke-dasharray:${o(u[0])} ${o(u[1])}"><animate attributeName="stroke-dashoffset" from="0" to="${b}" dur="${h}s" repeatCount="indefinite"/></path>`})}var Os=n=>typeof n=="string"?[n]:[...n],zi=n=>JSON.parse(JSON.stringify(n)),dn=(n={})=>({...n.from===void 0?{}:{from:n.from},...n.over===void 0?{}:{duration:n.over},...n.easing===void 0?{}:{easing:n.easing}}),ir=class n{nodes=[];add(e){return this.nodes.push(zi(e)),this}assemble(e={},t={}){return this.add({assemble:e,...dn(t)})}disassemble(e={},t={}){return this.add({disassemble:e,...dn(t)})}travel(e,t={}){let{each:s,hold:r,loop:o}=t;return this.add({travel:e,...dn(t),each:s,hold:r,loop:o})}pulse(e,t={}){return this.add({pulse:Os(e),...dn(t),loop:t.loop})}ants(e=!0,t={}){return this.add({ants:e===!0?!0:Os(e),...dn(t),speed:t.speed,dash:t.dash})}draw(e,t={}){return this.add({draw:Os(e),...dn(t),by:t.by,stagger:t.stagger})}type(e,t={}){return this.add({type:Os(e),...dn(t)})}move(e,t){return this.add({move:e,...t})}lift(e,t,s={}){return this.add({lift:Os(e),by:t,...dn(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:Os(e),scope:s,level:r,always:o},...dn(t),fade:t.fade})}highlight(e,t={}){return this.add({highlight:Os(e),...dn(t),fade:t.fade})}get camera(){return{focus:(e,t={})=>this.add({camera:{focus:e,zoom:t.zoom,margin:t.margin},...dn(t)}),fit:(e={})=>this.add({camera:"fit",...dn(e)})}}sequence(e,t={},s){return this.add({sequence:fu(e,t,s)})}series(e){let t=new ar;return e(t),this.add({series:t.items})}layers(e){let t=new n;return e(t),this.add({layers:t.nodes})}};function fu(n,e,t){let{read:s,duration:r,...o}=e,i=new ir;return t?.(i),zi({...n===void 0?{}:{name:n},...o,...s!==void 0?{duration:{read:s}}:r!==void 0?{duration:r}:{},...i.nodes.length?{children:i.nodes}:{}})}var ar=class{items=[];sequence(e,t={},s){return this.items.push({sequence:fu(e,t,s)}),this}transition(e){return this.items.push({transition:zi(e)}),this}},to=class extends ar{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 ir;return e(t),this.over.push(...t.nodes),this}toJSON(){return zi({isomotion:1,...this.head,...this.items.length?{series:this.items}:{},...this.over.length?{layers:this.over}:{},...Object.keys(this.marks).length?{markers:this.marks}:{}})}},uu=(n={})=>new to(n);function Ki(n,e){if(!e)return n;let[t,s,r,o]=e,i=n[2]/n[3],l=r-t,a=o-s;l/a<i?l=a*i:a=l/i,l=Math.min(l,n[2]),a=Math.min(a,n[3]);let c=(t+r)/2,f=(s+o)/2,u=Math.max(n[0],Math.min(n[0]+n[2]-l,c-l/2)),d=Math.max(n[1],Math.min(n[1]+n[3]-a,f-a/2));return[u,d,l,a]}var so=["linear","ease","ease-in","ease-out","ease-in-out","settle","bounce"],Ns=["extend","clamp","wrap","identity"];function tn(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 ro(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 ds=(n,e,t,s)=>r=>{if(r<=0)return 0;if(r>=1)return 1;let o=(a,c,f)=>3*a*f*(1-f)**2+3*c*f*f*(1-f)+f**3,i=0,l=1;for(let a=0;a<50;a++){let c=(i+l)/2;o(n,t,c)<r?i=c:l=c}return o(e,s,(i+l)/2)},rp=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},op={linear:n=>n,ease:ds(.25,.1,.25,1),"ease-in":ds(.42,0,1,1),"ease-out":ds(0,0,.58,1),"ease-in-out":ds(.42,0,.58,1),settle:ds(.16,.84,.3,1),bounce:rp};function lr(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),l=r/(2*Math.sqrt(s*t)),a;if(l<1){let c=i*Math.sqrt(1-l*l);a=1-Math.exp(-l*i*o)*(Math.cos(c*o)+l*i/c*Math.sin(c*o))}else a=1-Math.exp(-i*o)*(1+i*o);return e.overshootClamping?Math.min(1,a):a}function Pn(n,e,t="ease-in-out"){let s=n??t;return typeof s=="string"?op[s]:"bezier"in s?ds(...s.bezier):r=>r<=0?0:r>=1?1:lr(r*e,s.spring)}function cr(n,e,t){let s=n.times.map(u=>tn(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 h=s[o-1]-s[0];return cr({...n,extrapolateLeft:"clamp",extrapolateRight:"clamp"},s[0]+((e-s[0])%h+h)%h,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 l=0;for(;l<o-2&&e>=s[l+1];)l++;let a=s[l+1]-s[l],c=(e-s[l])/a,f=c<0||c>1?c:Pn(n.easing,a,"linear")(c);return r[l]+(r[l+1]-r[l])*f}var Pl=["sequence","series","layers","assemble","disassemble","travel","pulse","ants","draw","type","move","lift","focus","highlight","camera"],du={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"},Rn=["from","duration","easing"],no={sequence:[],series:[],layers:[],assemble:Rn,disassemble:Rn,travel:[...Rn,"each","hold","loop"],pulse:[...Rn,"loop"],ants:[...Rn,"speed","dash"],draw:[...Rn,"by","stagger"],type:Rn,move:["from","x","y","scale","opacity"],lift:[...Rn,"by","stagger","to","opacity"],focus:[...Rn,"fade"],highlight:[...Rn,"fade"],camera:Rn},ip=["name","from","offset","duration","loop","playbackRate","trimBefore","say","show","hide","focus","highlight","levels","variants","enter","ants","children","layers","series"],gt=n=>!!n&&typeof n=="object"&&!Array.isArray(n);function Vi(n){let e=[],t=(p,g,x)=>{e.push({severity:"error",path:p,message:g,...x?{hint:x}:{}})},s=(p,g,x)=>{for(let $ of Object.keys(p))if(!g.includes($)){let E=Bt($,g);t(`${x}/${$}`,`unknown key "${$}"`,E?`did you mean "${E}"?`:void 0)}};if(!gt(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=(p,g,x={})=>{if(p===void 0)return;if(typeof p=="string"&&/f$/.test(p)&&r===void 0){t(g,`"${p}" is in frames: the document needs its fps`);return}let $=tn(p,r);$===void 0?t(g,`${JSON.stringify(p)} isn't a time (ms, "1.2s", "450ms", "30f")`):$<0&&!x.negative&&t(g,"a time can't be negative")},i=(p,g,x)=>{if(p!==void 0&&!g.includes(p)){let $=typeof p=="string"?Bt(p,g):void 0;t(x,`${JSON.stringify(p)} isn't one of ${g.join(", ")}`,$?`did you mean "${$}"?`:void 0)}},l=(p,g,x={})=>{p!==void 0&&(typeof p!="number"||!Number.isFinite(p)||x.min!==void 0&&p<x.min||x.max!==void 0&&p>x.max||x.over!==void 0&&p<=x.over)&&t(g,`${JSON.stringify(p)} 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}`:""}`:""}`)},a=(p,g)=>{if(p!==void 0){if(!Array.isArray(p)){t(g,"a list of ids");return}p.forEach((x,$)=>{typeof x!="string"&&t(`${g}/${$}`,"an id")})}},c=(p,g,x=[])=>{if(!gt(p)){t(g,"a spring is a map");return}s(p,["mass","damping","stiffness","overshootClamping",...x],g);for(let $ of["mass","damping","stiffness"])l(p[$],`${g}/${$}`,{over:0});p.overshootClamping!==void 0&&typeof p.overshootClamping!="boolean"&&t(`${g}/overshootClamping`,"true or false")},f=(p,g)=>{if(p!==void 0){if(typeof p=="string"){i(p,so,g);return}if(gt(p)&&"bezier"in p){s(p,["bezier"],g),(!Array.isArray(p.bezier)||p.bezier.length!==4||p.bezier.some(x=>typeof x!="number"))&&t(`${g}/bezier`,"four numbers");return}if(gt(p)&&"spring"in p){s(p,["spring"],g),c(p.spring,`${g}/spring`);return}t(g,"an easing is a name, { bezier: [a, b, c, d] } or { spring: { \u2026 } }")}},u=(p,g)=>{if(p===void 0)return;if(!gt(p)){t(g,"a curve is { times, values }");return}s(p,["times","values","easing","extrapolateLeft","extrapolateRight"],g);let x=p.times,$=p.values;if(!Array.isArray(x)||!x.length)t(`${g}/times`,"a list of times");else{x.forEach((v,A)=>o(v,`${g}/times/${A}`,{negative:!0}));let E=x.map(v=>tn(v,r));for(let v=1;v<E.length;v++)E[v]!==void 0&&E[v-1]!==void 0&&E[v]<=E[v-1]&&t(`${g}/times/${v}`,"times go up")}!Array.isArray($)||$.some(E=>typeof E!="number")?t(`${g}/values`,"a list of numbers"):Array.isArray(x)&&$.length!==x.length&&t(`${g}/values`,`${$.length} values for ${x.length} times`),f(p.easing,`${g}/easing`),i(p.extrapolateLeft,Ns,`${g}/extrapolateLeft`),i(p.extrapolateRight,Ns,`${g}/extrapolateRight`)},d=(p,g)=>{if(p!==void 0){if(!gt(p)){t(g,"focus is { lit: [ids] }");return}s(p,["lit","scope","level","always"],g),p.lit===void 0&&t(`${g}/lit`,"what is lit"),a(p.lit,`${g}/lit`),a(p.always,`${g}/always`),i(p.scope,["all","links"],`${g}/scope`),l(p.level,`${g}/level`,{min:0,max:1})}},h=(p,g)=>{p!==void 0&&typeof p!="string"&&t(g,"text")},b=new Map;function m(p,g,x){if(!gt(p)){t(g,"a sequence is a map");return}if(s(p,ip,g),p.name!==void 0&&(typeof p.name!="string"||!/^[A-Za-z][\w-]*$/.test(p.name)?t(`${g}/name`,"a name is letters, digits, - and _, from a letter"):b.has(p.name)?t(`${g}/name`,`"${p.name}" is already a name (${b.get(p.name)})`):b.set(p.name,g)),x&&p.from!==void 0&&t(`${g}/from`,"in a series a sequence follows the one before","offset moves it"),!x&&p.offset!==void 0&&t(`${g}/offset`,"offset is for a series","use from"),o(p.from,`${g}/from`),o(p.offset,`${g}/offset`,{negative:!0}),o(p.trimBefore,`${g}/trimBefore`),gt(p.duration)){s(p.duration,["read"],`${g}/duration`);let $=p.duration.read;if($!==!0&&!gt($))t(`${g}/duration/read`,"true, or { base, perChar, min, max }");else if(gt($)){s($,["base","perChar","min","max"],`${g}/duration/read`);for(let E of["base","perChar","min","max"])l($[E],`${g}/duration/read/${E}`,{min:0})}}else o(p.duration,`${g}/duration`);if(p.loop!==void 0&&typeof p.loop!="boolean"&&!(Number.isInteger(p.loop)&&p.loop>=1)&&t(`${g}/loop`,"true, false, or how many times"),l(p.playbackRate,`${g}/playbackRate`,{over:0}),p.say!==void 0)if(!gt(p.say))t(`${g}/say`,"say is a map");else{let $=p.say;s($,["chapter","title","text","code","facts","color"],`${g}/say`);for(let E of["chapter","title","text","code","color"])h($[E],`${g}/say/${E}`);$.facts!==void 0&&(!Array.isArray($.facts)||$.facts.some(E=>!Array.isArray(E)||E.length!==2||E.some(v=>typeof v!="string")))&&t(`${g}/say/facts`,"a list of [name, value]")}for(let $ of["show","hide","highlight"])a(p[$],`${g}/${$}`);if(d(p.focus,`${g}/focus`),p.levels!==void 0)if(!gt(p.levels))t(`${g}/levels`,"levels is a map: an id, and how much of it");else for(let[$,E]of Object.entries(p.levels))l(E,`${g}/levels/${$}`,{min:0,max:1});if(p.variants!==void 0)if(!gt(p.variants))t(`${g}/variants`,"variants is a map: an id, and the name of its look");else for(let[$,E]of Object.entries(p.variants))typeof E!="string"&&t(`${g}/variants/${$}`,`a look's name, or "" for its own`);p.enter!==void 0&&(gt(p.enter)?(s(p.enter,["fade","easing"],`${g}/enter`),p.enter.fade===void 0&&t(`${g}/enter/fade`,"how long the fade is"),o(p.enter.fade,`${g}/enter/fade`),f(p.enter.easing,`${g}/enter/easing`)):t(`${g}/enter`,"enter is { fade }")),p.ants!==void 0&&typeof p.ants!="boolean"&&a(p.ants,`${g}/ants`);for(let $ of["children","layers"])p[$]!==void 0&&N(p[$],`${g}/${$}`);p.series!==void 0&&y(p.series,`${g}/series`)}function y(p,g){if(!Array.isArray(p)){t(g,"a series is a list");return}p.forEach((x,$)=>{let E=`${g}/${$}`;if(!gt(x)||Object.keys(x).length!==1||!("sequence"in x||"transition"in x)){t(E,"a series holds sequences and transitions");return}if("sequence"in x){m(x.sequence,`${E}/sequence`,!0);return}let v=x.transition,A=`${E}/transition`,L=M=>gt(p[M])&&"sequence"in p[M];if((!L($-1)||!L($+1))&&t(A,"a transition is between two sequences"),!gt(v)){t(A,"a transition is { presentation, timing }");return}s(v,["presentation","timing"],A),v.presentation===void 0?t(`${A}/presentation`,"a presentation"):i(v.presentation,["fade","none"],`${A}/presentation`),gt(v.timing)?"linear"in v.timing?(s(v.timing,["linear"],`${A}/timing`),o(v.timing.linear,`${A}/timing/linear`)):"spring"in v.timing?(s(v.timing,["spring"],`${A}/timing`),c(v.timing.spring,`${A}/timing/spring`,["duration"]),gt(v.timing.spring)&&o(v.timing.spring.duration,`${A}/timing/spring/duration`)):t(`${A}/timing`,"a timing is { linear } or { spring }"):t(`${A}/timing`,"a timing is { linear } or { spring }")})}function N(p,g){if(!Array.isArray(p)){t(g,"a list");return}p.forEach((x,$)=>{let E=`${g}/${$}`;if(!gt(x)){t(E,"a map");return}let v=Pl.filter(P=>P in x);if(v.length!==1){let P=Object.keys(x).find(w=>w in du),k=Object.keys(x)[0],O=k?Bt(k,Pl):void 0;t(E,P?`${P}: ${du[P]}`:v.length?`one of ${v.join(", ")}, not several`:`one of ${Pl.join(", ")}`,!P&&!v.length&&O?`did you mean "${O}"?`:void 0);return}let A=v[0],L=x[A],M=`${E}/${A}`;s(x,[A,...no[A]],E),no[A].includes("from")&&o(x.from,`${E}/from`),no[A].includes("duration")&&(o(x.duration,`${E}/duration`),f(x.easing,`${E}/easing`));for(let P of["each","hold","stagger","fade"])no[A].includes(P)&&o(x[P],`${E}/${P}`);if(no[A].includes("loop")&&x.loop!==void 0&&typeof x.loop!="boolean"&&t(`${E}/loop`,"true or false"),A==="sequence")m(L,M,!1);else if(A==="series")y(L,M);else if(A==="layers")N(L,M);else if(A==="assemble"||A==="disassemble")gt(L)?(i(L.style,A==="assemble"?nr:sr,`${M}/style`),i(L.order,Es,`${M}/order`),L.duration!==void 0&&t(`${M}/duration`,"its length is beside it","duration is the node's")):t(M,`${A} is a map (its options)`);else if(A==="travel")!Array.isArray(L)||!L.length?t(M,"a list of connectors"):L.forEach((P,k)=>{Array.isArray(P)?a(P,`${M}/${k}`):typeof P!="string"&&t(`${M}/${k}`,"a connector, or a list of them at once")});else if(A==="ants")L!==!0&&a(L,M),l(x.speed,`${E}/speed`),x.dash!==void 0&&(!Array.isArray(x.dash)||x.dash.length!==2||x.dash.some(P=>typeof P!="number"||P<=0))&&t(`${E}/dash`,"two numbers over 0: on, off");else if(A==="move"){typeof L!="string"&&t(M,"an id");for(let P of["x","y","scale","opacity"])u(x[P],`${E}/${P}`)}else if(A==="focus")d(L,M);else if(A==="camera"){if(L!=="fit")if(!gt(L))t(M,'"fit", or { focus, zoom, margin }');else{s(L,["focus","zoom","margin"],M),l(L.zoom,`${M}/zoom`,{over:0}),l(L.margin,`${M}/margin`);let P=L.focus;typeof P=="string"||Array.isArray(P)&&(P.every(k=>typeof k=="string")||P.length===4&&P.every(k=>typeof k=="number"))||t(`${M}/focus`,"an id, some ids, or a box [x, y, w, h]")}}else a(L,M);A==="draw"&&i(x.by,["stroke","grow"],`${E}/by`),A==="lift"&&(x.by===void 0&&t(`${E}/by`,"how far apart"),l(x.by,`${E}/by`),i(x.to,["up","down"],`${E}/to`),u(x.opacity,`${E}/opacity`))})}if(n.series!==void 0&&y(n.series,"/series"),n.layers!==void 0&&N(n.layers,"/layers"),n.markers!==void 0)if(!gt(n.markers))t("/markers","markers is a map");else for(let[p,g]of Object.entries(n.markers))if(typeof g=="string"&&/^[A-Za-z][\w-]*([+-].+)?$/.test(g)){let x=/^([A-Za-z][\w-]*?)(?:([+-])(\d.*))?$/.exec(g);if(x&&(b.has(x[1])?x[1]:void 0))x[3]!==void 0&&o(x[3],`/markers/${p}`);else if(!b.has(g)){let v=Bt(x?.[1]??g,b.keys());t(`/markers/${p}`,`no sequence is named "${x?.[1]??g}"`,v?`did you mean "${v}"?`:void 0)}}else o(g,`/markers/${p}`);return e}var nn=n=>Math.round(n*100)/100||0,Pt=n=>Math.round(n*1e4)/1e4||0,mn=n=>Math.max(0,Math.min(1,n)),fr=(n,e,t)=>n+(e-n)*t,ap=250,Cl=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[h,b]of f){let m=u(b);Object.keys(m).length&&(d[h]=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=>({...nn(f.dx??0)?{dx:nn(f.dx)}:{},...nn(f.dy??0)?{dy:nn(f.dy)}:{}}),l=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}:{}})),a=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(l)&&(t.items=l),r(a)&&(t.labels=a),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 oo(n){let e=_i(n.raw),t=n.rendered.looks,s=As(n),r=Object.keys(s.notes).filter(o=>s.notes[o]===void 0);return{model:s,kinds:Object.fromEntries(n.routes.map(o=>[o.id,o.kind])),outlines:Object.fromEntries(n.layout.items.map(o=>[o.id,Rt(o.box).map(i=>[nn(i[0]),nn(i[1])])])),...t&&Object.keys(t).length?{looks:t}:{},...e?{ants:e}:{},...r.length?{free:r}:{}}}function io(n,e,t={}){let s="model"in n?n:oo(n),r=s.free?{...s.model,notes:{...s.model.notes,...Object.fromEntries(s.free.map(S=>[S,void 0]))}}:s.model,o=Vi(e),i=e.fps,l=s.ants,a=()=>({ok:!1,diags:o,duration:0,beats:[],markers:{},ambient:"on",loops:!1,at:()=>({}),cues:()=>{},beatAt:()=>{},startOf:()=>{}});if(o.length)return a();let c=(S,z,J)=>{o.push({severity:"error",path:S,message:z,...J?{hint:J}:{}})},f=(S,z)=>S===void 0?z:tn(S,i),u=new Map(r.pieces.map(S=>[S.id,S])),d=new Set(r.routes.map(S=>S.id)),h=new Set(Object.keys(r.notes)),b=new Map(Object.entries(s.kinds)),m=[...u.keys(),...d,...h],y=new Set(m),N=new Map;for(let[S,z]of Object.entries(r.notes))z!==void 0&&N.set(z,[...N.get(z)??[],S]);let p={any:y,thing:new Set(u.keys()),route:d},g={any:"thing, connector or note",thing:"thing",route:"connector"},x=(S,z,J="any")=>{if(!p[J].has(S)){let he=Bt(S,p[J]);c(z,`no ${g[J]} "${S}" in this drawing`,he?`did you mean "${he}"?`:void 0)}},$=(S,z,J="any")=>S?.forEach((he,de)=>x(he,`${z}/${de}`,J)),E=new Map(Object.entries(s.outlines)),v=new Map;function A(S,z){let J="from"in S?f(S.from,0):0,he="duration"in S?f(S.duration,NaN):NaN,de=Number.isFinite(he);if("sequence"in S){let Q=S.sequence;return f(Q.from,0)+k(Q,`${z}/sequence`)}if("series"in S)return O(S.series,`${z}/series`).end;if("layers"in S)return Math.max(0,...S.layers.map((Q,ne)=>A(Q,`${z}/layers/${ne}`)));if("assemble"in S||"disassemble"in S){let Q="assemble"in S?"assemble":"disassemble",ne="assemble"in S?S.assemble:S.disassemble,ge=v.get(S);return ge||v.set(S,ge=rr(r,Q,{seed:e.seed??1,...ne,...de?{duration:he}:{}})),J+ge.duration}return"draw"in S?J+(de?he:400)+Math.max(0,S.draw.length-1)*f(S.stagger,0):"lift"in S?J+Math.max(de?he:750,...S.opacity?.times.map(Q=>tn(Q,i))??[])+Math.max(0,S.lift.length-1)*f(S.stagger,0):de?J+he:"travel"in S?S.loop?J:J+S.travel.length*f(S.each,1150):"pulse"in S?S.loop?J:J+1500:"type"in S?J+400:"camera"in S?J+900:"move"in S?J+Math.max(0,...[S.x,S.y,S.scale,S.opacity].flatMap(Q=>Q?.times.map(ne=>tn(ne,i))??[])):J}let L=(S,z)=>Math.max(0,...(S.children??[]).map((J,he)=>A(J,`${z}/children/${he}`)),...(S.layers??[]).map((J,he)=>A(J,`${z}/layers/${he}`)),S.series?O(S.series,`${z}/series`).end:0),M=new Map;function P(S,z){let J=M.get(S);if(J!==void 0)return J;let he;return S.duration!==void 0&&typeof S.duration=="object"?he=ro(S.say,S.duration.read):he=S.duration!==void 0?f(S.duration,0):L(S,z),S.duration===void 0&&he<=0&&S.say&&(he=ro(S.say,!0)),he<=0&&c(`${z}/duration`,"how long is it? (nothing in it says)"),M.set(S,he),he}let k=(S,z)=>{let J=P(S,z),he=S.playbackRate??1;return S.loop===!0?J/he:(typeof S.loop=="number"?J*S.loop:J)/he};function O(S,z){let J=[],he=0,de;return S.forEach((Q,ne)=>{if("transition"in Q){let _=Q.transition,ce=_.timing,me=_.presentation==="none"?0:lp(ce,i);de={t:_,length:me};return}let ge=Q.sequence,ke=`${z}/${ne}/sequence`,T=k(ge,ke),j=Math.max(0,he+f(ge.offset,0)-(de?.length??0));de&&J.length&&de.length>Math.min(J[J.length-1].end-J[J.length-1].start,T)&&c(`${z}/${ne-1}/transition/timing`,"a transition is no longer than either side of it"),J.push({s:ge,path:ke,start:j,end:j+T,...de?{into:de}:{}}),he=j+T,de=void 0}),{list:J,end:Math.max(0,...J.map(Q=>Q.end))}}let w=O(e.series??[],"/series"),R=Math.max(0,...(e.layers??[]).map((S,z)=>A(S,`/layers/${z}`))),I=Math.max(w.end,R);I<=0&&!o.length&&c("","a motion document has a series, or layers, that last");let G=new Map,X=[],U=r.viewBox,B=(S,z,J)=>{let he=J!==void 0?1/J:Math.max((S.w+z*2)/U[2],(S.h+z*2)/U[3]);return[S.x+S.w/2-U[2]*he/2,S.y+S.h/2-U[3]*he/2,U[2]*he,U[3]*he]};function H(S,z,J){let he=de=>J?{at:J.at+de/J.rate,rate:J.rate}:void 0;if("sequence"in S){ee(S.sequence,`${z}/sequence`,he(f(S.sequence.from,0)),!1);return}if("series"in S){for(let de of O(S.series,`${z}/series`).list)ee(de.s,de.path,he(de.start),!1);return}if("layers"in S){S.layers.forEach((de,Q)=>H(de,`${z}/layers/${Q}`,J));return}if("travel"in S)S.travel.forEach((de,Q)=>(Array.isArray(de)?de:[de]).forEach((ne,ge)=>x(ne.split(":")[0],`${z}/travel/${Q}${Array.isArray(de)?`/${ge}`:""}`,"route")));else if("pulse"in S)$(S.pulse,`${z}/pulse`,"thing");else if("ants"in S)S.ants!==!0&&$(S.ants,`${z}/ants`,"route");else if("draw"in S)$(S.draw,`${z}/draw`,"route");else if("type"in S)$(S.type,`${z}/type`);else if("move"in S)x(S.move,`${z}/move`,"thing");else if("lift"in S)$(S.lift,`${z}/lift`,"thing");else if("focus"in S)Y(S.focus,`${z}/focus`);else if("highlight"in S)$(S.highlight,`${z}/highlight`,"thing");else if("camera"in S){let de=S.camera,Q=f(S.duration,900);if(!J){c(`${z}/camera`,"a camera can't be in a loop");return}let ne=U;if(de!=="fit"){let ge=de.focus;if(Array.isArray(ge)&&typeof ge[0]=="number")ne=B({x:ge[0],y:ge[1],w:ge[2],h:ge[3]},de.margin??0,de.zoom);else{let ke=typeof ge=="string"?[ge]:ge;ke.forEach((j,_)=>x(j,`${z}/camera/focus${typeof ge=="string"?"":`/${_}`}`,"thing"));let T=ke.map(j=>u.get(j)?.bbox).filter(j=>!!j);if(T.length){let j=Math.min(...T.map(ce=>ce.x)),_=Math.min(...T.map(ce=>ce.y));ne=B({x:j,y:_,w:Math.max(...T.map(ce=>ce.x+ce.w))-j,h:Math.max(...T.map(ce=>ce.y+ce.h))-_},de.margin??40,de.zoom)}}}X.push({at:J.at+f(S.from,0)/J.rate,over:Q/J.rate,ease:Pn(S.easing,Q,"settle"),to:ne})}}let Y=(S,z)=>{S&&($(S.lit,`${z}/lit`),$(S.always,`${z}/always`))};function ee(S,z,J,he){if(S.name!==void 0&&J&&G.set(S.name,J.at),!he)for(let ne of["show","hide","say","enter","focus","highlight","levels","variants","ants"])S[ne]!==void 0&&c(`${z}/${ne}`,`${ne} is for a sequence of the document's own series`,ne==="focus"||ne==="highlight"||ne==="ants"?`here, a child: { ${ne}: \u2026 }`:void 0);$(S.show,`${z}/show`),$(S.hide,`${z}/hide`),$(S.highlight,`${z}/highlight`,"thing"),Y(S.focus,`${z}/focus`);for(let ne of Object.keys(S.levels??{}))ne!=="*"&&x(ne,`${z}/levels/${ne}`);for(let[ne,ge]of Object.entries(S.variants??{})){x(ne,`${z}/variants/${ne}`,"thing");let ke=s.looks?.[ne]??[];if(u.has(ne)&&ge!==""&&!ke.includes(ge)){let T=Bt(ge,ke);c(`${z}/variants/${ne}`,ke.length?`${ne} has no look "${ge}" (it has ${ke.join(", ")})`:`${ne} declares no looks (variants: in the diagram)`,T?`did you mean "${T}"?`:void 0)}}Array.isArray(S.ants)&&$(S.ants,`${z}/ants`,"route");let de=S.playbackRate??1,Q=J&&!S.loop?{at:J.at-f(S.trimBefore,0)/(J.rate*de),rate:J.rate*de}:void 0;if((S.children??[]).forEach((ne,ge)=>H(ne,`${z}/children/${ge}`,Q)),(S.layers??[]).forEach((ne,ge)=>H(ne,`${z}/layers/${ge}`,Q)),S.series)for(let ne of O(S.series,`${z}/series`).list)ee(ne.s,ne.path,Q&&{at:Q.at+ne.start/Q.rate,rate:Q.rate},!1)}for(let S of w.list)ee(S.s,S.path,{at:S.start,rate:1},!0);(e.layers??[]).forEach((S,z)=>H(S,`/layers/${z}`,{at:0,rate:1})),X.sort((S,z)=>S.at-z.at);let F={};for(let[S,z]of Object.entries(e.markers??{})){let J=tn(z,i);if(J!==void 0){F[S]=J;continue}let he=String(z),de=[...G.keys()].filter(ge=>he===ge||he.startsWith(ge+"+")||he.startsWith(ge+"-")).sort((ge,ke)=>ke.length-ge.length)[0];if(de===void 0){c(`/markers/${S}`,`"${he}" isn't a moment of this document`);continue}let Q=he.slice(de.length),ne=Q?tn(Q.slice(1),i):0;if(ne===void 0){c(`/markers/${S}`,`"${Q}" isn't a time`);continue}F[S]=G.get(de)+(Q[0]==="-"?-ne:ne)}if(o.length)return a();let K=w.list.map((S,z)=>({name:S.s.name??`beat-${z+1}`,index:z,start:S.start,end:S.end,...S.s.say?{say:S.s.say}:{}})),q=new Map;for(let S of w.list){for(let z of S.s.show??[])q.has(z)||q.set(z,!1);for(let z of S.s.hide??[])q.has(z)||q.set(z,!0)}let Z=[new Map(q)];for(let S of w.list){let z=new Map(Z[Z.length-1]);for(let J of S.s.show??[])z.set(J,!0);for(let J of S.s.hide??[])z.set(J,!1);Z.push(z)}let le=[new Map];for(let S of w.list){let z=new Map(le[le.length-1]);for(let[J,he]of Object.entries(S.s.variants??{}))z.set(J,he);le.push(z)}let fe=(S,z)=>!S||S.lit.includes(z)||S.always?.includes(z)||S.scope==="links"&&u.has(z)?1:S.level??.12,W=(S,z)=>{let J=S<0?void 0:w.list[S].s.levels;return J?J[z]??J["*"]??1:1},oe=(S,z)=>(Z[S+1].get(z)===!1?0:1)*(S<0?1:fe(w.list[S].s.focus,z))*W(S,z),Me=(S,z)=>{let J=r.notes[z];if(J===void 0)return oe(S,z);let he=S<0?void 0:w.list[S].s.levels?.[z];return oe(S,J)*(Z[S+1].get(z)===!1?0:1)*(he??1)},Le=S=>{let z=-1;for(let J=0;J<w.list.length;J++)w.list[J].start<=S&&(z=J);return z},C=(S,z)=>{let J=w.list[S],he=z-J.start;if(J.into&&J.into.length>0)return cp(J.into.t.timing,he,J.into.length);let de=J.s.enter;if(!de)return 1;let Q=f(de.fade,0);return Q<=0?1:Pn(de.easing,Q,"ease")(mn(he/Q))};function V(S,z,J,he,de){if("sequence"in S){let ke=S.sequence,T=f(ke.from,0);we(ke,z-T,J-T,Oe(ke,he-T),de);return}if("series"in S){for(let ke of O(S.series,"").list)we(ke.s,z-ke.start,J-ke.start,ke.end-ke.start,de);return}if("layers"in S){for(let ke of S.layers)V(ke,z,J,he,de);return}let Q=f("from"in S?S.from:void 0,0),ne=z-Q;if("assemble"in S||"disassemble"in S){de.sum.add(v.get(S).at(ne));return}if("draw"in S){let ke=Math.max(1,f(S.duration,400)),T=f(S.stagger,0),j=Pn(S.easing,ke,"ease-out");S.draw.forEach((_,ce)=>{let me=j(mn((ne-ce*T)/ke));me<=0?(de.sum.route(_,{opacity:0,drawn:0}),de.sum.label(_,{opacity:0})):me<1&&(de.sum.route(_,{drawn:me,...S.by?{by:S.by}:{}}),de.sum.label(_,{opacity:me}))});return}if("type"in S){let ke=f(S.duration,400),T=Pn(S.easing,ke,"linear")(mn(ne/Math.max(1,ke)));if(T<1)for(let j of S.type)de.sum.label(j,T<=0?{opacity:0}:{typed:T});return}if("move"in S){let ke=me=>me?cr(me,ne,i):void 0,T=ke(S.x)??0,j=ke(S.y)??0,_=ke(S.scale),ce=ke(S.opacity);de.sum.item(S.move,{dx:T,dy:j,..._===void 0?{}:{scale:_,about:u.get(S.move).foot},...ce===void 0?{}:{opacity:mn(ce)}});for(let me of[S.move,...N.get(S.move)??[]])de.sum.label(me,{dx:T,dy:j,...ce===void 0?{}:{opacity:mn(ce)}});return}if("lift"in S){let ke=f(S.stagger,0),T=Math.max(1,f(S.duration,750)),j=Pn(S.easing,T,"ease-out"),_=S.to==="down",ce=S.lift.length;S.lift.forEach((me,Re)=>{let ie=ne-(_?ce-1-Re:Re)*ke,Pe=j(mn(ie/T)),Se=(Re+1)*S.by*(_?Pe:-Pe),xe=S.opacity?mn(cr(S.opacity,ie,i)):1;if(!(!Se&&xe>=1)){de.sum.item(me,{dy:Se,opacity:xe});for(let Ie of[me,...N.get(me)??[]])de.sum.label(Ie,{dy:Se,opacity:xe})}});return}if("camera"in S)return;let ge=S.duration===void 0?Math.max(0,he-Q):f(S.duration,0);if(!(ne<0||ne>ge)){if("focus"in S||"highlight"in S){let ke=Math.max(1,f(S.fade,ap)),T=mn(Math.min(ne/ke,S.duration===void 0?1:(ge-ne)/ke)),j=Pn(S.easing,ke,"linear")(T);if("focus"in S)ye(S.focus,j,de.sum);else for(let _ of S.highlight)de.shown(_)&&Ee(_,j,de.sum);return}if("ants"in S){Ne(S.ants===!0?[...d]:S.ants,de,S.speed,S.dash);return}if("pulse"in S){let T=S.loop?ae(J-Q,1500,de)/1500:ne/Math.max(1,S.duration===void 0?1500:ge);if(T<0||T>=1)return;for(let j of S.pulse)if(de.shown(j)){let _=u.get(j),ce=_.bbox.w*.5*(.7+T*.6);de.sum.pulses.push({x:nn(_.foot[0]),y:nn(_.foot[1]),rx:nn(ce),ry:nn(ce*.58),opacity:Pt(1-T)})}return}if("travel"in S){let ke=f(S.each,1150),T=f(S.hold,S.loop?700:0),j=S.travel.length*ke+T,_=S.loop?ae(J-Q,j,de):ne,ce=Math.floor(_/ke);if(ce>=S.travel.length)return;let me=(_-ce*ke)/ke,Re=Pn(S.easing,ke,"ease-in-out")(me),ie=S.travel[ce];for(let Pe of Array.isArray(ie)?ie:[ie]){let[Se,xe]=Pe.split(":");de.shown(Se)&&de.sum.tokens.push({route:Se,at:Pt((xe??b.get(Se))==="blocked"?te(me):Re),...xe?{kind:xe}:{}})}}}}let te=S=>S<.7?S/.7:1-(S-.7)/.3*.25,ae=(S,z,J)=>J.off?0:(S%z+z)%z,Ee=(S,z,J)=>{Pt(z)>0&&E.has(S)&&J.outlines.push({id:S,points:E.get(S),...Pt(z)<1?{opacity:Pt(z)}:{}})},ye=(S,z,J)=>{for(let he of m){let de=h.has(he)&&!S.lit.includes(he)&&!S.always?.includes(he)?r.notes[he]:void 0,Q=fr(1,fe(S,de??he),z);Q>=1||(u.has(he)?(J.item(he,{opacity:Q}),J.label(he,{opacity:Q})):d.has(he)?(J.route(he,{opacity:Q}),J.label(he,{opacity:Q})):J.label(he,{opacity:Q}))}},Ne=(S,z,J=Zr,he)=>{for(let de of S){let Q=eo(b.get(de)??"",{dash:he,kinds:t.kinds,still:t.still});if(!Q)continue;let ne=Q[0]+Q[1],ge=ae(J*z.A/1e3,ne,z);z.sum.route(de,{ants:{dash:Q,offset:nn(ge)}})}},Oe=(S,z)=>S.loop===!0?Math.max(0,z):k(S,"");function we(S,z,J,he,de){if(z<0||z>he||z===he&&he<I&&he>0&&S.loop)return;let Q=S.playbackRate??1,ne=P(S,""),ge=f(S.trimBefore,0),ke=S.loop&&ne>0?z*Q%ne:z*Q,T=ke+ge,j=J*Q+ge;for(let _ of S.children??[])V(_,T,j,ne+ge,de);for(let _ of S.layers??[])V(_,T,j,ne+ge,de);if(S.series)for(let _ of O(S.series,"").list)we(_.s,T-_.start,j-_.start,_.end-_.start,de)}function Fe(S,z={}){let J=Math.max(0,Math.min(I,Number.isFinite(S)?S:0)),he=z.ambient==="off"||e.ambient==="off"&&z.ambient===void 0,de=typeof z.ambient=="number"?z.ambient:J,Q=new Cl,ne=Le(J),ge=ne<0?1:C(ne,J),ke=(ie,Pe)=>ne<0?Pe(-1,ie):ge>=1?Pe(ne,ie):fr(Pe(ne-1,ie),Pe(ne,ie),ge),T=ie=>(ne<0?Z[0]:Z[ne+1]).get(ie)!==!1;if(q.size||w.list.some(ie=>ie.s.focus||ie.s.levels))for(let ie of m){let Pe=ke(ie,h.has(ie)?Me:oe);Pe>=1||(u.has(ie)&&Q.item(ie,{opacity:Pe}),d.has(ie)&&Q.route(ie,{opacity:Pe}),Q.label(ie,{opacity:Pe}))}if(ne>=0)for(let ie of le[le.length-1].keys()){let Pe=le[ne].get(ie)??"",Se=le[ne+1].get(ie)??"",xe={};Pe&&ge<1&&(xe[Pe]=Pt(1-ge)),Se&&(xe[Se]=Pt((xe[Se]??0)+ge));for(let Ie of Object.keys(xe))xe[Ie]<=0&&delete xe[Ie];Object.keys(xe).length&&(Q.variants[ie]=xe)}if(ne>=0){let ie=new Set(w.list[ne].s.highlight??[]),Pe=new Set(ne>0&&ge<1?w.list[ne-1].s.highlight??[]:[]);for(let Se of new Set([...Pe,...ie]))Ee(Se,fr(Pe.has(Se)?1:0,ie.has(Se)?1:0,ge),Q)}let j={sum:Q,shown:T,off:he,A:de},_=ne>=0?w.list[ne].s.ants:void 0,ce=_===void 0?l:void 0;_?Ne(_===!0?[...d]:_,j):ce&&Ne(ce.ids??[...d],j,ce.speed,ce.dash),w.list.forEach((ie,Pe)=>{J>=ie.start&&(J<ie.end||Pe===ne&&J<=ie.end)&&we(ie.s,J-ie.start,de-ie.start,ie.end-ie.start,j)});for(let ie of e.layers??[])V(ie,J,de,I,j);let me;for(let ie of X){if(ie.at>J)break;let Pe=ie.over<=0?1:ie.ease(mn((J-ie.at)/ie.over)),Se=me??U;if(Pe>=1){me=ie.to;continue}let xe=Se[2],Ie=ie.to[2],ze=Math.exp(fr(Math.log(xe),Math.log(Ie),Pe)),tt=Math.abs(Ie-xe)<1e-6?Pe:(ze-xe)/(Ie-xe),Yn=fr(Se[0]+Se[2]/2,ie.to[0]+ie.to[2]/2,tt),ft=fr(Se[1]+Se[3]/2,ie.to[1]+ie.to[3]/2,tt),Je=ze*U[3]/U[2];me=[Yn-ze/2,ft-Je/2,ze,Je]}let Re=me?.map(nn);return Q.state(Re&&Re.some((ie,Pe)=>Math.abs(ie-U[Pe])>.005)?Re:void 0)}let qe=S=>{if(!S||typeof S!="object")return!1;if(Array.isArray(S))return S.some(qe);let z=S;return z.ants!==void 0&&z.ants!==!1||z.loop===!0&&("travel"in z||"pulse"in z)?!0:Object.values(z).some(qe)},De=l!==void 0||qe(e.series)||qe(e.layers),Qe=S=>{let z=Le(Math.max(0,Math.min(I,S)));return z<0?void 0:K[z]};return{ok:!0,diags:o,duration:I,beats:K,markers:F,ambient:e.ambient??"on",loops:De,at:Fe,beatAt:Qe,startOf:S=>G.get(S)??K.find(z=>z.name===S)?.start,cues(S){let z=Qe(S);if(!z)return;let J=Math.max(0,Math.min(I,S));return{beat:z.name,index:z.index,of:K.length,progress:Pt(mn((J-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}:{}}:{}}}}}var lp=(n,e)=>"linear"in n?tn(n.linear,e)??0:tn(n.spring.duration,e)??fp(n.spring);function cp(n,e,t){return t<=0||e>=t?1:"spring"in n?mn(lr(e,{...n.spring,overshootClamping:!0})/lr(t,{...n.spring,overshootClamping:!0})):mn(e/t)}function fp(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 Gi(n){let{steps:e,vis:t}=n.steps,s=n.rendered.viewBox,r=!1,o=As(n),i=new Set([...o.pieces.map(f=>f.id),...o.routes.map(f=>f.id),...Object.keys(o.notes)]),l=f=>i.has(f),a=Object.keys(o.notes).filter(f=>o.notes[f]===void 0),c=e.map((f,u)=>{let d=[],h=[];for(let[p,g]of Object.entries(t))(u===0?!g.includes(!0):g[u-1]&&!g[u])?h.push(p):u>0&&g[u]&&!g[u-1]&&d.push(p);let b=[],m=p=>`${p.route}:${p.kind}`;f.phases.length&&b.push({travel:f.phases.map(p=>p.length===1?m(p[0]):p.map(m)),each:1150,hold:700,loop:!0});let y=(n.raw.steps??[])[u]?.pulse?.filter(p=>n.layout.byId.has(p))??[];if(y.length&&b.push({pulse:y,loop:!0}),f.focus){let[p,g,x,$]=Ki(s,f.focus).map(nn);b.push({camera:{focus:[p,g,x,$]},duration:900,easing:"ease-in-out"}),r=!0}else r&&(b.push({camera:"fit",duration:900,easing:"ease-in-out"}),r=!1);let N={name:`step-${f.n}`,duration:f.duration,say:{title:f.heading,...f.caption?{text:f.caption}:{},...f.command?{code:f.command}:{}}};return d.length&&(N.show=d),h.length&&(N.hide=h),N.focus=n.raw.dim==="all"?{lit:f.lit.filter(l),scope:"all",level:.14}:{lit:f.lit.filter(l),scope:"links",level:.12,...a.length?{always:a}:{}},b.length&&(N.children=b),{sequence:N}});return{isomotion:1,...c.length?{series:c}:{}}}var up={anyOf:[{type:"number"},{type:"string",pattern:"^-?\\d+(\\.\\d+)?(ms|s|f)?$"}]},dp={type:"array",items:{type:"string"}},mp={anyOf:[{enum:so},{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"}}}]},mu={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?mu:{},...t}}),pu={$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:up,ids:dp,ease:mp,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:Ns},extrapolateRight:{enum:Ns}}},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:nr},order:{enum:Es}}}),Yt("disassemble",{type:"object",properties:{style:{enum:sr},order:{enum:Es}}}),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"},...mu}},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"}}}]})]}}}};var bu=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"]),pp=new Set("cursor pointer-events transition animation transform-box transform-origin user-select".split(" "));function hp(n,e){let t={classes:[],not:[],attrs:[],child:e},s=n,r=i=>{let l=i.exec(s);return l&&(s=s.slice(l[0].length)),l},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 gp(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(":"),l=o.slice(0,i).trim(),a=o.slice(i+1).trim();return[l,a.replace(/\s*!important$/,""),/!important$/.test(a)]});for(let o of r)if(!o[0].startsWith("--")&&!bu.has(o[0])&&!pp.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 l=o.replace(/\s*>\s*/g," >").split(/\s+/).map(c=>hp(c.replace(/^>/,""),c.startsWith(">"))),a=l.reduce((c,f)=>c+10*(f.classes.length+f.not.length+f.attrs.length)+(f.tag?1:0),0);t.push({parts:l,spec:a,order:t.length,decls:r})}}return t}function bp(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 yu=n=>typeof n=="string"?n:`<${n.name}${n.attrs.map(([e,t])=>` ${e}="${t}"`).join("")}${n.children.length||n.name==="g"?`>${n.children.map(yu).join("")}</${n.name}>`:"/>"}`,ao=(n,e)=>n.attrs.find(t=>t[0]===e)?.[1],ur=(n,e,t)=>{let s=n.attrs.find(r=>r[0]===e);s?s[1]=t:n.attrs.push([e,t])},yp=n=>(ao(n,"class")??"").split(/\s+/).filter(Boolean);function xp(n,e){if(e.tag&&e.tag!==n.name)return!1;let t=yp(n);return e.classes.every(s=>t.includes(s))&&!e.not.some(s=>t.includes(s))&&e.attrs.every(([s,r])=>{let o=ao(n,s);return o!==void 0&&(r===void 0||o===r)})}function Il(n,e,t=e.length-1){if(!xp(n,e[t]))return!1;if(t===0)return!0;let s=n.parent;if(e[t].child)return!!s&&s.name!=="#root"&&Il(s,e,t-1);for(;s&&s.name!=="#root";s=s.parent)if(Il(s,e,t-1))return!0;return!1}var ms=n=>n.endsWith("%")?parseFloat(n)/100:parseFloat(n);function wp(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)),l=t-r/2,[a,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[(a+l)*255,(c+l)*255,(f+l)*255,s]}function xu(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 hu={transparent:[0,0,0,0],black:[0,0,0,1],white:[255,255,255,1]};function qi(n){let e=n.trim();if(Object.hasOwn(hu,e))return hu[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,l,a]=s.split(/[\s,]+/);return wp(parseFloat(o),ms(i),ms(l),r!==void 0?ms(r):a!==void 0?ms(a):1)}if(t=/^rgba?\((.*)\)$/.exec(e),t){let[s,r,o,i]=t[1].split(/[\s,/]+/).filter(Boolean);return[ms(s),ms(r),ms(o),i===void 0?1:ms(i)]}if(t=/^color-mix\(in srgb\s*,(.*)\)$/.exec(e),t){let[s,r]=xu(t[1],",").map(f=>{let u=/^(.*?)\s+([\d.]+)%$/.exec(f);return u?{c:qi(u[1]),p:Number(u[2])/100}:{c:qi(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,l=o+i,a=(s.c[3]*o+r.c[3]*i)/l,c=f=>a===0?0:(s.c[f]*s.c[3]*o+r.c[f]*r.c[3]*i)/l/a;return[c(0),c(1),c(2),a*Math.min(1,l)]}}var gu=n=>"#"+[n[0],n[1],n[2]].map(e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")).join(""),kp=n=>String(Math.round(n*1e4)/1e4);function Ll(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,...l]=xu(n.slice(s+4,o-1),","),a=e.get(i)??(l.length?l.join(","):void 0);if(a===void 0)throw new Error(`resolve: no value for ${i}`);return Ll(n.slice(0,s)+a+n.slice(o),e,t+1)}var vp=n=>new Map(n.split(";").filter(Boolean).map(e=>{let t=e.indexOf(":");return[e.slice(0,t).trim(),e.slice(t+1).trim()]})),Fl={sans:"system-ui, -apple-system, Segoe UI, Roboto, sans-serif",mono:"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace"};function wu(n,e){let t=Kr(e.theme),s=e.fonts??Fl,r=gp(`.mono{font-family:${s.mono.replace(/"/g,"")}}
|
|
150
150
|
${t.rest}
|
|
151
|
-
${e.css}`),o=
|
|
151
|
+
${e.css}`),o=bp(n);ur(o,"font-family",s.sans.replace(/"/g,""));let i=(l,a)=>{let c=a,f=new Map,u=(b,m,y)=>{let N=f.get(b);(!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(b,{v:m,rank:y})};for(let b of r)if(Il(l,b.parts))for(let[m,y,N]of b.decls)u(m,y,[N?1:0,b.spec,b.order]);let d=ao(l,"style");if(d){for(let b of d.split(";").map(m=>m.trim()).filter(Boolean)){let m=b.indexOf(":");u(b.slice(0,m).trim(),b.slice(m+1).trim(),[0,1e6,0])}l.attrs=l.attrs.filter(b=>b[0]!=="style")}for(let[b,m]of f)b.startsWith("--")&&(c===a&&(c=new Map(a)),c.set(b,m.v));let h={};for(let[b,m]of f){if(!bu.has(b))continue;let y=Ll(m.v,c).trim();if(b==="fill"||b==="stroke"||b==="stop-color"){if(y==="none"||y==="currentColor"||y==="inherit"||y.startsWith("url(")){ur(l,b,y);continue}let N=qi(y);if(!N)throw new Error(`resolve: a colour it doesn't know: ${y}`);ur(l,b,gu(N)),N[3]!==1&&(h[b==="stop-color"?"stop":b]=N[3])}else ur(l,b,b==="letter-spacing"||b==="font-size"||b==="stroke-width"?y:y.replace(/"/g,""))}for(let[b,m]of Object.entries(h))ur(l,`${b}-opacity`,kp(m*Number(ao(l,`${b}-opacity`)??1)));ao(l,"opacity")==="0"&&(ur(l,"display","none"),l.attrs=l.attrs.filter(b=>b[0]!=="opacity"));for(let b of l.attrs)if(/var\(|hsl\(|color-mix/.test(b[1])){let m=Ll(b[1],c),y=qi(m);b[1]=y?gu(y):m}for(let b of l.children)typeof b!="string"&&i(b,c)};return i(o,vp(e.mode==="dark"?`${t.light};${t.dark}`:t.light)),yu(o)}var Ui=n=>`${Math.round(parseInt(n.slice(1,3),16)/255*1e4)/100}%`,Bl=(n,e,t)=>{let[s,r]=[n,e].map(i=>parseInt(i.slice(1,3),16)),o=Math.round(s+(r-s)*t).toString(16).padStart(2,"0");return`#${o}${o}${o}`};function jl(n,e,t){let s=new Set([...n.matchAll(/\sclass="([^"]*)"/g)].flatMap(r=>r[1].split(/\s+/)).filter(r=>r.startsWith("k-")).map(r=>r.slice(2)));return{roles:Object.keys(e.roles).filter(r=>s.has(r)),kinds:[...new Set(t)].filter(r=>r in e.kinds)}}function Dl(n,e){let t=jt[e.mode].steps,s=(c,f)=>e.roles[c]??t[f],r={};for(let[c,f]of Object.entries(n.light))r[c]=/%$/.test(f)?f:e.ink;let o=s("slab",0),i=s("pad",0);Object.assign(r,{bg:e.paper,surface:e.paper,on:e.paper,ink:e.ink,muted:Bl(e.paper,e.ink,.72),line:Bl(e.paper,e.ink,.3),"code-bg":Bl(e.paper,e.ink,.06),"slab-top":o.top,"slab-l":o.left,"slab-r":o.right,"pad-top":i.top});let l=Object.fromEntries(Object.entries(n.roles).map(([c])=>[c,{h:0,s:0}])),a=Object.fromEntries(Object.entries(n.kinds).map(([c,f])=>[c,{...f,color:e.ink}]));return Xs({...n,light:r,dark:r,roles:l,kinds:a})}function _l(n){let e="";for(let[t,s]of Object.entries(n.roles))e+=`.k-${t}{--s:0%;--l-top:${Ui(s.top)};--l-left:${Ui(s.left)};--l-right:${Ui(s.right)};--l-edge:${Ui(s.edge)}}
|
|
152
|
+
`;for(let[t,s]of Object.entries(n.kinds))e+=`.flow.f-${t}{stroke-width:${s.width}${s.dash.length?`;stroke-dasharray:${s.dash.join(" ")}`:";stroke-dasharray:none"}}
|
|
153
|
+
`;return e}var Sp={hatch:{size:6,draw:(n,e)=>`<path d="M0,6L6,0M-1.5,1.5L1.5,-1.5M4.5,7.5L7.5,4.5" stroke="${n}" stroke-width="${e}" fill="none"/>`},"hatch-wide":{size:12,draw:(n,e)=>`<path d="M0,0L12,12M-3,9L3,15M9,-3L15,3" stroke="${n}" stroke-width="${e}" fill="none"/>`},dots:{size:8,draw:(n,e)=>`<circle cx="2" cy="2" r="${e+.2}" fill="${n}"/><circle cx="6" cy="6" r="${e+.2}" fill="${n}"/>`}},$p=n=>Math.round(n*100)/100,Mp=(n,e)=>qr(n,e.ink)>=qr(n,e.paper)?e.ink:e.paper;function ku(n,e,t){let s=new Map,r=(a,c)=>{let f=`${t}-mono-${a}-${c.slice(1)}`,u=Sp[a],d=e.mode==="dark"?1.2:.9;return s.has(f)||s.set(f,`<pattern id="${f}" width="${u.size}" height="${u.size}" patternUnits="userSpaceOnUse">${u.draw(c,$p(d))}</pattern>`),f},o=[],i="",l="";for(let a of n.matchAll(/<\/[a-zA-Z][\w:-]*>|<([a-zA-Z][\w:-]*)((?:\s+[\w:-]+="[^"]*")*)\s*(\/?)>|[^<]+/g)){if(i+=a[0],a[0].startsWith("</")){o.pop();continue}if(a[1]===void 0)continue;let c=(/\sclass="([^"]*)"/.exec(a[2])?.[1]??"").split(/\s+/);o.length===1&&(l=c.find(m=>m.startsWith("g-"))??"");let f=c.find(m=>m.startsWith("k-"))?.slice(2)??o.at(-1);if(a[3]||o.push(c.includes("ghost")?"":f),!a[3]||a[1]!=="polygon"&&a[1]!=="path"||!f||!c.some(m=>m==="top"||m==="lft"||m==="rgt")||l==="g-base"&&!c.includes("rgt"))continue;let u=Object.hasOwn(e.roles,f)?e.roles[f].pattern:"none",d=/\sfill="(#[0-9a-f]{6})"/.exec(a[2])?.[1],h=/\s(points|d)="[^"]*"/.exec(a[2])?.[0];if(u==="none"||!d||!h)continue;let b=/\sfill-opacity="[^"]*"/.exec(a[2])?.[0]??"";i+=`<${a[1]}${h} class="mono-pattern" fill="url(#${r(u,Mp(d,e))})" stroke="none"${b}/>`}return i=i.replace(/#([0-9a-f]{6})\b/g,(a,c)=>c.slice(0,2)===c.slice(2,4)&&c.slice(2,4)===c.slice(4,6)?a:Tp(a)),s.size&&(i=i.replace(/<defs\/>|<defs>/,a=>a==="<defs/>"?`<defs>${[...s.values()].join("")}</defs>`:a+[...s.values()].join(""))),i}function Tp(n){let e=Gr(n),t=e>8?((e+16)/116)**3:e/(24389/27),s=t<=.0031308?t*12.92:1.055*t**(1/2.4)-.055,r=Math.max(0,Math.min(255,Math.round(s*255))).toString(16).padStart(2,"0");return`#${r}${r}${r}`}function vu(n,e,t,s,r){let o=ui(e,t,jl(n,e,s),r);return{look:o,theme:Dl(e,o),css:_l(o)}}function zl(n){return Math.max(5600,Math.min(12500,2600+n.length*40))}function Hi(n,e,t,s,r,o){let i=[],l=(M,P,k,O="error")=>{let w=r.locate(M);i.push({severity:O,message:P,line:w.line,col:w.col,path:M,hint:k})},a=n.steps??[],c=new Set(Object.keys(o.kinds)),f=new Map(s.map(M=>[M.id,M])),u=()=>[...t.byId.keys(),...f.keys()],d=new Map;a.forEach((M,P)=>{M.id&&(d.has(M.id)&&l(`${e}/steps/${P}/id`,`duplicate step id "${M.id}"`),d.set(M.id,P+1))});let h=a.length,b=(M,P)=>{if(typeof M=="number"){if(M<1||M>h){l(P,`there is no step ${M}; this scene has ${h} step(s)`);return}return M}let k=d.get(M);return k===void 0&&l(P,`unknown step "${M}"`+pn(M,d.keys())),k},m=M=>An(o,o.kinds[M]?.color??"control"),y=[],N=M=>{y.includes(M)||y.push(M)};for(let M of s)N(M.kind);let p={},g=(M,P,k,O)=>{if(P===void 0&&k===void 0)return;let w=P!==void 0?b(P,O+"/appears"):1,R=k!==void 0?b(k,O+"/disappears"):h+1;p[M]=Array.from({length:h},(I,G)=>G+1>=(w??1)&&G+1<(R??h+1))};for(let M of t.items)g(M.id,M.appears,M.disappears,M.path);for(let M of s)g(M.id,M.raw.appears,M.raw.disappears,M.path);let x=[],$=[],E=[],v=[],A=()=>{for(let M of s){if(M.raw.appears!==void 0||M.raw.disappears!==void 0)continue;let P=[M.from,M.to].map(k=>k&&(p[k.id]??L(k)));P.some(Boolean)&&(p[M.id]=Array.from({length:h},(k,O)=>P.every(w=>!w||w[O])))}},L=M=>{for(let P=M.parent;P;P=P.parent)if(p[P.id])return p[P.id]};return a.forEach((M,P)=>{let k=P+1,O=`${e}/steps/${P}`,w=M.kind??"control";c.has(w)||l(O+"/kind",`unknown flow kind "${w}"`+pn(w,c)),N(w);let R=new Set,I=[];(M.animate??[]).forEach((B,H)=>{let Y=Array.isArray(B)?B:[B],ee=[];Y.forEach((F,K)=>{let q=Array.isArray(B)?`${O}/animate/${H}/${K}`:`${O}/animate/${H}`,Z,le;if(typeof F=="string"){let oe=/^([^:\s]+)\s*(?::\s*(\S+))?$/.exec(F.trim());Z=oe?oe[1]:F,le=oe?.[2]}else{let oe=Object.entries(F)[0];Z=oe[0],le=oe[1]}let fe=f.get(Z);if(!fe){l(q,`unknown route "${Z}"`+pn(Z,f.keys()));return}if(le&&!c.has(le)){l(q,`unknown flow kind "${le}"`+pn(le,c));return}let W=le??fe.kind;N(W),ee.push({route:Z,kind:W,color:m(W)}),R.add(Z),fe.from&&R.add(fe.from.id),fe.to&&R.add(fe.to.id)}),ee.length&&I.push(ee)});let G=[];(M.pulse??[]).forEach((B,H)=>{let Y=t.byId.get(B);if(!Y){l(`${O}/pulse/${H}`,`unknown node "${B}"`+pn(B,t.byId.keys()));return}let ee,F,K,q,Z=Y.node?Ms(t.catalog,Y.node.asset):void 0;if(Z?.pulse)[ee,F,K,q]=Z.pulse(Y.box);else{let W=Y.box;ee=(W.x0+W.x1)/2,F=(W.y0+W.y1)/2,K=W.z1,q=Math.max(22,Math.min(60,(W.x1-W.x0+W.y1-W.y0)*8.5))}let[le,fe]=Ce(ee,F,K);G.push([le,fe,q*1.7,q*.98]),R.add(B)}),(M.highlight??[]).forEach((B,H)=>{!t.byId.has(B)&&!f.has(B)&&l(`${O}/highlight/${H}`,`unknown id "${B}"`+pn(B,u())),R.add(B)});for(let[B,H]of[["show",!0],["hide",!1]])(M[B]??[]).forEach((Y,ee)=>{if(!t.byId.has(Y)&&!f.has(Y)){l(`${O}/${B}/${ee}`,`unknown id "${Y}"`+pn(Y,u()));return}let F=p[Y]??(p[Y]=Array(h).fill(!H));for(let K=P;K<h;K++)F[K]=H});if((M.say??[]).forEach((B,H)=>{let Y,ee;if(Array.isArray(B.at))[Y,ee]=Ce(B.at[0],B.at[1],B.at[2]??.36);else{let K=t.byId.get(B.at);if(!K){l(`${O}/say/${H}/at`,`unknown node "${B.at}"`+pn(B.at,t.byId.keys()));return}let q=K.box;[Y,ee]=Ce((q.x0+q.x1)/2,(q.y0+q.y1)/2,q.z1+.75)}let F=B.kind??w;c.has(F)||l(`${O}/say/${H}/kind`,`unknown flow kind "${F}"`+pn(F,c)),$.push({step:k,x:Y+(B.dx??0),y:ee+(B.dy??(Array.isArray(B.at)?0:-46)),ax:Y,ay:ee,text:B.text,kind:F,anchor:B.anchor??"middle"})}),(M.mark??[]).forEach((B,H)=>{if(B.at){E.push({step:k,p:[B.at[0],B.at[1],B.at[2]??.36]});return}let Y=B.on?f.get(B.on):void 0;if(!Y){l(`${O}/mark/${H}`,B.on?`unknown route "${B.on}"`+pn(B.on,f.keys()):'a mark needs "on: ROUTE" or "at: [x, y]"');return}let ee=Y.points[Y.points.length-1];E.push({step:k,p:[ee[0],ee[1],ee[2]+.6],on:Y.id}),R.add(Y.id)}),n.badges&&M.badge!==!1){let B=Array.isArray(M.badge)?[M.badge[0],M.badge[1],M.badge[2]??.36]:void 0,H=typeof M.badge=="string"?M.badge:I[0]?.[0]?.route,Y=H?f.get(H):void 0;if(!B)if(Y)B=Kl(Y.points);else if(H&&t.byId.get(H)){let ee=t.byId.get(H).box;B=[(ee.x0+ee.x1)/2,(ee.y0+ee.y1)/2,ee.z1+.3]}else typeof M.badge=="string"&&l(`${O}/badge`,`unknown id "${M.badge}"`+pn(M.badge,u()));B&&v.push({step:k,num:M.number??k,kind:w,p:B})}for(let B of[...R])for(let H=t.byId.get(B)?.parent;H;H=H.parent)R.add(H.id);for(let B of t.items)B.region?.kind==="tunnel"&&(B.region.around??[]).some(H=>R.has(H))&&R.add(B.id);let X;if(M.focus?.length){let B=1/0,H=1/0,Y=-1/0,ee=-1/0;M.focus.forEach((F,K)=>{let q=t.byId.get(F);if(!q){l(`${O}/focus/${K}`,`unknown node or region "${F}"`+pn(F,t.byId.keys()));return}let Z=q.box;for(let[le,fe,W]of[[Z.x0,Z.y0,Z.z1],[Z.x1,Z.y0,Z.z0],[Z.x0,Z.y1,Z.z0],[Z.x1,Z.y1,Z.z0],[Z.x1,Z.y0,Z.z1],[Z.x0,Z.y1,Z.z1]]){let[oe,Me]=Ce(le,fe,W);B=Math.min(B,oe),H=Math.min(H,Me),Y=Math.max(Y,oe),ee=Math.max(ee,Me)}R.add(F)}),B<1/0&&(X=[Math.round(B-60),Math.round(H-70),Math.round(Y+60),Math.round(ee+40)])}let U=M.caption??"";x.push({n:k,num:M.number??k,kind:w,color:m(w),heading:M.heading,caption:U,command:M.command??"",phases:I,pulses:G,lit:[...R],duration:M.duration===void 0||M.duration==="auto"?zl(U):M.duration,...X?{focus:X}:{}})}),A(),{steps:x,says:$,marks:E,badges:v,vis:p,diags:i,kindsUsed:y}}function Kl(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 pn(n,e){let t=Bt(n,e);return t?` (did you mean "${t}"?)`:""}var Vl=`
|
|
152
154
|
*{box-sizing:border-box}
|
|
153
155
|
html,body{margin:0}
|
|
154
156
|
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}
|
|
@@ -172,7 +174,7 @@ h2{font-size:20px;margin:44px 0 4px;letter-spacing:-.005em;text-wrap:balance}
|
|
|
172
174
|
.legend i{display:inline-block;width:26px;height:0;border-top:3px solid}
|
|
173
175
|
.legend i.box{height:10px;border-width:1.5px;border-style:solid;border-radius:2px}
|
|
174
176
|
footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
175
|
-
|
|
177
|
+
`,Gl=n=>Ep+mi(n)+Ap+pi(),Ep=`
|
|
176
178
|
/* blocks: hue per role, lightness per face and theme */
|
|
177
179
|
.blk .top{fill:hsl(var(--h) var(--s) var(--l-top))}
|
|
178
180
|
.blk .lft{fill:hsl(var(--h) var(--s) var(--l-left))}
|
|
@@ -213,14 +215,14 @@ footer{margin-top:40px;font-size:12.5px;color:var(--muted)}
|
|
|
213
215
|
.floor.t-control{fill:var(--muted)}
|
|
214
216
|
.slabname{font-size:15px;font-weight:800;fill:var(--muted);letter-spacing:.12em;opacity:.8}
|
|
215
217
|
.slabname.sm{font-size:10.5px;letter-spacing:.1em;opacity:1}
|
|
216
|
-
`,
|
|
218
|
+
`,Ap=`.tunnel polygon{fill:hsl(205 85% 55% / .17);stroke:hsl(205 75% 45% / .8);stroke-width:1.3;stroke-linejoin:round}
|
|
217
219
|
.tunnel .top{fill:hsl(205 85% 65% / .22)}
|
|
218
220
|
.tunnel .rib{fill:none;stroke:hsl(205 75% 45% / .5);stroke-width:1}
|
|
219
221
|
.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}
|
|
220
222
|
|
|
221
223
|
/* flows */
|
|
222
224
|
.flow{fill:none;stroke-width:3;stroke-linecap:round;stroke-linejoin:round}
|
|
223
|
-
`,
|
|
225
|
+
`,Yi=n=>Vl+Gl(n),ql=`
|
|
224
226
|
/* step marks */
|
|
225
227
|
.xm circle{fill:var(--surface);stroke:var(--blocked);stroke-width:2.5}
|
|
226
228
|
.xm path{stroke:var(--blocked);stroke-width:3;stroke-linecap:round}
|
|
@@ -243,7 +245,7 @@ svg.all .badge{opacity:1}
|
|
|
243
245
|
svg.focus.all [data-hl]:not(.hl),svg.focus.all.dim-all [data-dim]:not(.hl){opacity:.9}
|
|
244
246
|
svg [data-step]:not(.on),svg.all [data-step]{opacity:0!important;pointer-events:none}
|
|
245
247
|
.pre{opacity:0!important;pointer-events:none}
|
|
246
|
-
`,
|
|
248
|
+
`,Ul=`
|
|
247
249
|
/* player */
|
|
248
250
|
.player{display:flex;align-items:flex-start;gap:10px 14px;padding:12px 16px;border-top:1px solid var(--line);flex-wrap:wrap}
|
|
249
251
|
.ctrls{display:flex;gap:6px;flex:none}
|
|
@@ -278,57 +280,57 @@ details.steps li code{font-size:11.5px}
|
|
|
278
280
|
.still .ctrls,.still .tools{display:none}
|
|
279
281
|
.tools{display:flex;gap:6px;flex:none;order:3;margin-left:auto}
|
|
280
282
|
.pbtn.small{font-size:12px;padding:4px 11px;font-weight:600;color:var(--muted)}
|
|
281
|
-
.pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,
|
|
283
|
+
.pbtn.small[aria-pressed="true"]{color:var(--ink);border-color:var(--muted);background:var(--surface)}`,Hl=`
|
|
282
284
|
.grid{display:none;fill:none;stroke:var(--ink);stroke-width:.6;opacity:.16;pointer-events:none}
|
|
283
285
|
svg.show-grid .grid{display:inline}
|
|
284
286
|
svg.pre-assemble > g:not(.g-anim){opacity:0}
|
|
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":""}:
|
|
287
|
+
`,Wi=ql+Ul+Hl;var Yl=n=>({data:n,locate:()=>({line:0,col:0}),span:()=>{},diags:[]});function Su(n,e,t,s=Yl(n),r,o={},i=[]){let l=Xs(ii(e),n.roles,n.kinds),a=[],c=new Map;return n.scenes.forEach((f,u)=>{let d=`/scenes/${u}`;if(c.has(f.id)){let p=s.locate(d+"/id");i.push({severity:"error",message:`duplicate scene id "${f.id}"`,line:p.line,col:p.col,path:d+"/id"})}c.set(f.id,u);let h={...n.grid,...f.grid,...o.snap?{snap:o.snap}:{}},b=xi(f,d,s,l,t,n.roles,h.snap);i.push(...b.diags);let m=Mi(f,d,b,s,new Set(Object.keys(l.kinds)),h.snap);i.push(...m.diags);let y=Hi(f,d,b,m.routes,s,l);i.push(...y.diags),i.push(...Op(f,d,t,s));let N=or({scene:f,layout:b,routes:m.routes,steps:y,theme:l,id:f.id,gridStep:h.step??h.snap??1});for(let p of N.warnings){let g=s.locate(p.path);i.push({severity:"warning",message:p.message,line:g.line,col:g.col,path:p.path})}a.push({id:f.id,raw:f,layout:b,routes:m.routes,steps:y,rendered:N,grid:h,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:l,catalog:t,scenes:a,parsed:s,source:r}}function Op(n,e,t,s){let r=[],o=(l,a)=>{let c=s.locate(l);r.push({severity:"warning",message:a,line:c.line,col:c.col,path:l})},i=(l,a)=>{l.nodes?.forEach((c,f)=>{let u=`${a}/nodes/${f}`;(c.deco??fn(t,c.asset).deco??[]).forEach((d,h)=>{typeof d=="object"&&d.icon&&!Ur(d.icon)&&o(c.deco?`${u}/deco/${h}/icon`:u,`node "${c.id}": no icon "${d.icon}" is registered here, so it is drawn as a placeholder`)}),c.face!==void 0&&!hi(c.face)&&o(`${u}/face`,`node "${c.id}": no screen face "${c.face}" is registered here, so it is drawn as a placeholder`)}),l.regions?.forEach((c,f)=>i(c,`${a}/regions/${f}`))};return i(n,e),r}function $u(n,e){let t=n/(wt*st),s=2*e/st;return[(t+s)/2,(s-t)/2]}function Mu(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 Tu(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 Np(e)}function Eu(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 Np(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,l)=>(i[0]-o[0])*(l[1]-o[1])-(i[1]-o[1])*(l[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 Au=(n,e)=>e?.padding??ht(n,e?.kind)?.pad??0;function Ou(n,e,t,s,r){let o=f=>Math.round(f/t)*t,i=o(n[0]+e[0]),l=o(n[1]+e[1]),a={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,a.left=!0),u>=f&&i>u&&(i=u,a.right=!0),l<f&&(l=f,a.top=!0),d>=f&&l>d&&(l=d,a.bottom=!0)}let c=f=>Math.round(f*1e3)/1e3;return{at:[c(i),c(l)],delta:[c(i-n[0]),c(l-n[1])],clamped:a}}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 Jl=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}),Xl={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}},Nu=(n,e)=>ln(n,Xl[e]);function Xi(n){let e=[],t=new Map,s=(a,c)=>{if(typeof c!="string"||!c){e.push(`${a} has no id`);return}let f=t.get(c);f?e.push(`duplicate id "${c}": a ${f} and a ${a} (cards and panels share one set of ids)`):t.set(c,a)};for(let a of n.cards)s("card",a.id),(!Array.isArray(a.cell)||a.cell.length!==2||!a.cell.every(c=>Number.isInteger(c)&&c>=0))&&e.push(`card "${a.id}": cell must be [column, row], whole numbers from 0`);for(let a of n.panels??[]){s("panel",a.id);let c=a.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 "${a.id}": cells must be [c0, r0, c1, r1] with c0 \u2264 c1 and r0 \u2264 r1`)}let r=new Map;for(let a of n.cards){let c=String(a.cell);r.has(c)?e.push(`cards "${r.get(c)}" and "${a.id}" are both at cell [${c}]`):r.set(c,a.id)}let o=(n.panels??[]).filter(a=>Array.isArray(a.cells)&&a.cells.length===4);for(let a=0;a<o.length;a++)for(let c=a+1;c<o.length;c++){let f=o[a].cells,u=o[c].cells;f[0]<=u[2]&&u[0]<=f[2]&&f[1]<=u[3]&&u[1]<=f[3]&&!Wl(f,u)&&!Wl(u,f)&&e.push(`panels "${o[a].id}" and "${o[c].id}" overlap without one holding the other`)}let i=new Set([...n.cards.map(a=>a.id),...o.map(a=>a.id)]),l=new Set(o.map(a=>a.id));return(n.links??[]).forEach((a,c)=>{let f=`link ${a.id?`"${a.id}"`:c}`;for(let u of["a","b"])i.has(a[u])||e.push(`${f}: ${u} "${a[u]}" is no card or panel`);for(let u of["aOn","bOn"])a[u]!==void 0&&!l.has(a[u])&&e.push(`${f}: ${u} "${a[u]}" is no panel`);a.id!==void 0&&s("link",a.id)}),e}var Wl=(n,e)=>n[0]>=e[0]&&n[2]<=e[2]&&n[1]>=e[1]&&n[3]<=e[3];function lo(n,e){let{W:t,H:s,GX:r,GY:o,PAD:i,TITLE:l,CH:a}=e,c=n.panels??[],f=F=>(F[2]-F[0]+1)*(F[3]-F[1]+1),u=(F,K)=>{let q=c[F].cells,Z=c[K].cells;return Wl(Z,q)?f(q)>f(Z)||F<K:!1},d=c.map((F,K)=>{let q=-1;return c.forEach((Z,le)=>{le!==K&&u(le,K)&&(q<0||u(q,le))&&(q=le)}),q}),h=F=>d[F]<0?0:1+h(d[F]),b=(F,K)=>{let q=-1;c.forEach((le,fe)=>{let W=le.cells;F>=W[0]&&F<=W[2]&&K>=W[1]&&K<=W[3]&&(q<0||u(q,fe))&&(q=fe)});let Z=[];for(let le=q;le>=0;le=d[le])Z.unshift(le);return Z},m=Math.max(1,...n.cards.map(F=>F.cell[0]+1),...c.map(F=>F.cells[2]+1)),y=Math.max(1,...n.cards.map(F=>F.cell[1]+1),...c.map(F=>F.cells[3]+1)),N=[];for(let F=0;F<m;F++){N.push([]);for(let K=0;K<y;K++)N[F].push(b(F,K))}let p=(F,K,q)=>{let Z=F.filter(fe=>!K.includes(fe)),le=K.filter(fe=>!F.includes(fe));return!Z.length&&!le.length?0:Z.length*(i+(q?l:0))+le.length*i+a},g=new Array(m+1).fill(0),x=new Array(y+1).fill(0);for(let F=0;F<y;F++)for(let K=1;K<m;K++){let q=p(N[K-1][F],N[K][F],!1);q&&(g[K]=Math.max(g[K],q-r))}for(let F=0;F<m;F++)for(let K=1;K<y;K++){let q=p(N[F][K-1],N[F][K],!0);q&&(x[K]=Math.max(x[K],q-o))}let $=F=>{let K=F*(t+r);for(let q=1;q<=F;q++)K+=g[q];return K},E=F=>{let K=F*(s+o);for(let q=1;q<=F;q++)K+=x[q];return K},v=(F,K,q,Z)=>q===K?F(K):F(K)+(Z-K)*(F(q)-F(K))/(q-K),A=c.map(()=>new Set),L=(F,K)=>{for(let q=F;q>=0;q=d[q])A[q].add(K)};c.forEach((F,K)=>{L(K,F.cells[1]),L(K,F.cells[3])});for(let F of n.cards){let K=N[F.cell[0]][F.cell[1]];K.length&&L(K[K.length-1],F.cell[1])}let M=c.map(()=>new Map),P=(F,K)=>F.slice(F.indexOf(K)+1);for(let F of c.map((K,q)=>q).sort((K,q)=>h(K)-h(q)||K-q)){let K=c[F].cells,q=[...A[F]].sort((le,fe)=>le-fe),Z=d[F]>=0?M[d[F]].get(q[0]):E(q[0]);M[F].set(q[0],Z);for(let le=1;le<q.length;le++){let fe=0;for(let W=K[0];W<=K[2];W++)fe=Math.max(fe,p(P(N[W][q[le-1]],F),P(N[W][q[le]],F),!0));Z+=s+Math.max(o,fe),M[F].set(q[le],Z)}}let k=c.map(()=>new Set),O=(F,K)=>{for(let q=F;q>=0;q=d[q])k[q].add(K)};c.forEach((F,K)=>{O(K,F.cells[0]),O(K,F.cells[2])});for(let F of n.cards){let K=N[F.cell[0]][F.cell[1]];K.length&&O(K[K.length-1],F.cell[0])}let w=c.map(()=>new Map);for(let F of c.map((K,q)=>q).sort((K,q)=>h(K)-h(q)||K-q)){let K=c[F].cells,q=[...k[F]].sort((le,fe)=>le-fe);if(d[F]<0&&!d.includes(F)&&q.length===K[2]-K[0]+1){for(let le of q)w[F].set(le,v($,K[0],K[2],le));continue}let Z=d[F]>=0?w[d[F]].get(q[0]):$(q[0]);w[F].set(q[0],Z);for(let le=1;le<q.length;le++){let fe=0;for(let W=K[1];W<=K[3];W++)fe=Math.max(fe,p(P(N[q[le-1]][W],F),P(N[q[le]][W],F),!1));Z+=t+Math.max(r,fe),w[F].set(q[le],Z)}}let R=(F,K)=>{let q=N[F][K],Z=q.length?q[q.length-1]:-1;return Z>=0?[w[Z].get(F),M[Z].get(K)]:[$(F),E(K)]},I=c.map((F,K)=>K).sort((F,K)=>h(K)-h(F)||F-K),G=new Array(c.length);for(let F of I){let K=c[F].cells,q=[],Z=[];for(let W of n.cards){let oe=N[W.cell[0]][W.cell[1]];oe[oe.length-1]===F&&(q.push(w[F].get(W.cell[0])),Z.push(M[F].get(W.cell[1])))}let le=W=>W.cell[0]>=K[0]&&W.cell[0]<=K[2]&&W.cell[1]>=K[1]&&W.cell[1]<=K[3];for(let W of[K[1],K[3]])n.cards.some(oe=>oe.cell[1]===W&&le(oe))||Z.push(M[F].get(W));for(let W of[K[0],K[2]])n.cards.some(oe=>oe.cell[0]===W&&le(oe))||q.push(w[F].get(W));let fe={l:q.length?Math.min(...q):1/0,t:Z.length?Math.min(...Z):1/0,r:q.length?Math.max(...q)+t:-1/0,b:Z.length?Math.max(...Z)+s:-1/0};c.forEach((W,oe)=>{if(d[oe]!==F)return;let Me=G[oe];fe.l=Math.min(fe.l,Me.l),fe.t=Math.min(fe.t,Me.t),fe.r=Math.max(fe.r,Me.r),fe.b=Math.max(fe.b,Me.b)}),G[F]={l:fe.l-i,t:fe.t-i,r:fe.r+i,b:fe.b+i+l}}let X=n.cards.map(F=>R(F.cell[0],F.cell[1])),U=n.cards.map(F=>{let K=N[F.cell[0]][F.cell[1]];return K.length?K[K.length-1]:-1}),B=(F,K)=>{for(let q=F;q>=0;q=d[q])if(q===K)return!0;return!1},H=(F,K)=>{n.cards.forEach((q,Z)=>{U[Z]>=0&&B(U[Z],F)&&(X[Z]=[X[Z][0]+K,X[Z][1]])}),c.forEach((q,Z)=>{B(Z,F)&&(G[Z]={...G[Z],l:G[Z].l+K,r:G[Z].r+K})})},Y=F=>{let K=[],q=[],Z=[],le=[];n.cards.forEach((C,V)=>{U[V]===F&&(K.push(X[V][0]),Z.push(X[V][0]+t),q.push(X[V][1]),le.push(X[V][1]+s))}),c.forEach((C,V)=>{d[V]===F&&(K.push(G[V].l),Z.push(G[V].r),q.push(G[V].t),le.push(G[V].b))});let fe=G[F],W=Math.min(...K,fe.l+i),oe=Math.max(...Z,fe.r-i),Me=Math.min(...q,fe.t+i),Le=Math.max(...le,fe.b-i-l);G[F]={l:W-i,t:Me-i,r:oe+i,b:Le+i+l}};for(let F of I)if(d[F]<0&&!d.includes(F))Y(F);else{let q=[];n.cards.forEach((oe,Me)=>{U[Me]===F&&q.push({l:X[Me][0],r:X[Me][0]+t,t:X[Me][1],b:X[Me][1]+s,card:Me})}),c.forEach((oe,Me)=>{d[Me]===F&&q.push({...G[Me],panel:Me})}),q.sort((oe,Me)=>oe.l-Me.l||oe.t-Me.t);let Z=Math.min(...q.map(oe=>oe.l)),le=[];for(let oe of q){let Me=Z;for(let C of le)C.t<oe.b&&oe.t<C.b&&C.r<=oe.l+1e-6&&(Me=Math.max(Me,C.r+(C.card!==void 0&&oe.card!==void 0?r:a)));let Le=Me-oe.l;Le<-1e-6&&(oe.card!==void 0?X[oe.card]=[X[oe.card][0]+Le,X[oe.card][1]]:H(oe.panel,Le),oe.l+=Le,oe.r+=Le),le.push(oe)}let fe=q.map(oe=>oe.l),W=q.map(oe=>oe.r);G[F]={...G[F],l:Math.min(...fe)-i,r:Math.max(...W)+i}}return{prect:G,parentIx:d,depthOf:h,pos:R,cardAt:F=>X[F]}}function dr(n,e,t={}){if(t.wrap){let{wrap:T,...j}=t;return dr(Rp(n,e,T.aspect,j),e,j)}let s=Xi(n);if(s.length)throw new Error(`the board has ${s.length} error${s.length>1?"s":""}:
|
|
286
288
|
${s.join(`
|
|
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=`
|
|
289
|
+
`)}`);let r={...Jl,...t},{W:o,H:i}=r,l=T=>Math.round(T*10)/10,a=[],c=n.panels??[],{prect:f,parentIx:u,depthOf:d,cardAt:h}=lo(n,r),b=c.map((T,j)=>{let _=f[j],ce=e(T.label??"","title")+(T.sub?e(T.sub,"titleSub"):0);return{...T,rect:_,titleAt:[l(_.l+16),l(_.b-15)],depth:d(j),parent:u[j]>=0?c[u[j]].id:void 0,title:{l:_.l+10,r:_.l+22+ce,t:_.b-30,b:_.b-6}}}),m=n.cards.map(T=>{let[j,_]=h(n.cards.indexOf(T));return{...T,rect:{l:j,t:_,r:j+o,b:_+i}}}),y=new Map;b.forEach(T=>y.set(T.id,T.rect)),m.forEach(T=>y.set(T.id,T.rect));let N=m.map(T=>T.rect),p=b.map(T=>T.rect),g=b.filter(T=>T.label).map(T=>T.title),x=(T,j)=>T.l>=j.l&&T.r<=j.r&&T.t>=j.t&&T.b<=j.b,$=(T,j,_,ce)=>Math.min(T[0],j[0])<_.r+ce&&Math.max(T[0],j[0])>_.l-ce&&Math.min(T[1],j[1])<_.b+ce&&Math.max(T[1],j[1])>_.t-ce,E=(T,j)=>p.reduce((_,ce)=>{if(T[0]===j[0]){let me=Math.min(T[1],j[1]),Re=Math.max(T[1],j[1]);T[0]>ce.l&&T[0]<ce.r&&(_+=[ce.t,ce.b].filter(ie=>ie>me+1&&ie<Re-1).length)}else{let me=Math.min(T[0],j[0]),Re=Math.max(T[0],j[0]);T[1]>ce.t&&T[1]<ce.b&&(_+=[ce.l,ce.r].filter(ie=>ie>me+1&&ie<Re-1).length)}return _},0),v=(T,j)=>p.some(_=>T[1]===j[1]?[_.t,_.b].some(ce=>Math.abs(T[1]-ce)<16&&Math.max(T[0],j[0])>_.l&&Math.min(T[0],j[0])<_.r):[_.l,_.r].some(ce=>Math.abs(T[0]-ce)<16&&Math.max(T[1],j[1])>_.t&&Math.min(T[1],j[1])<_.b)),A=(T,j,_,ce)=>p.filter(me=>me!==_&&me!==ce&&!x(_,me)&&!x(ce,me)&&$(T,j,{l:me.l+3,r:me.r-3,t:me.t+3,b:me.b-3},0)).length,L=[],M=new Map,P=new Map,k=(T,j)=>{L.push([T,j]);let[_,ce]=T[1]===j[1]?[M,T[1]]:T[0]===j[0]?[P,T[0]]:[void 0,0];if(!_)return;let me=Math.floor(ce/6);(_.get(me)??_.set(me,[]).get(me)).push([T,j])},O=(T,j)=>{let _=T[1]===j[1];if(!_&&T[0]!==j[0])return 0;let ce=_?1:0,me=_?0:1,Re=_?M:P,ie=Math.floor(T[ce]/6),Pe=Math.min(T[me],j[me]),Se=Math.max(T[me],j[me]),xe=0;for(let Ie=ie-1;Ie<=ie+1;Ie++)for(let[ze,tt]of Re.get(Ie)??[])Math.abs(T[ce]-ze[ce])<6&&Math.min(Se,Math.max(ze[me],tt[me]))-Math.max(Pe,Math.min(ze[me],tt[me]))>0&&xe++;return xe},w=[...y.values()],R=Math.min(...w.map(T=>T.l)),I=Math.max(...w.map(T=>T.r)),G=Math.min(...w.map(T=>T.t)),X=Math.max(...w.map(T=>T.b)),U=(T,j)=>{let _=(T+j)/2;return[_,_-12,_+12,_-24,_+24]},B=(()=>{let T=[];return N.forEach(j=>N.forEach(_=>{_.t>j.b&&_.l<j.r+400&&_.r>j.l-400&&T.push(...U(j.b,_.t))})),T.push(G-22,G-34,X+22,X+34),[...new Set(T.map(Math.round))]})(),H=(()=>{let T=[];return N.forEach(j=>N.forEach(_=>{_.l>j.r&&T.push(...U(j.r,_.l))})),T.push(R-22,R-34,I+22,I+34),[...new Set(T.map(Math.round))]})(),Y=new Map,ee=new Map,F=T=>{let j=Y.get(T);return j||Y.set(T,j=N.filter(_=>T<_.b+6&&T>_.t-6)),j},K=T=>{let j=ee.get(T);return j||ee.set(T,j=N.filter(_=>T<_.r+6&&T>_.l-6)),j},q=r.crossPanel/r.overlap,Z=r.border/r.overlap,le=r.nearEdge/r.overlap;function fe(T,j,_,ce,me=!0){let Re=0;for(let xe=1;xe<T.length;xe++)Re+=Math.abs(T[xe-1][0]-T[xe][0])+Math.abs(T[xe-1][1]-T[xe][1]);let ie=Re+r.bend*(T.length-2);if(ie>=ce)return ie;let Pe=0,Se=0;for(let xe=1;xe<T.length;xe++){let Ie=T[xe-1],ze=T[xe];if(me){if(ae(Ie,ze,j,_)||v(Ie,ze))return 1/0;continue}for(let tt of Ie[1]===ze[1]?F(Ie[1]):K(Ie[0]))tt!==j&&tt!==_&&$(Ie,ze,tt,6)&&Pe++;for(let tt of g)$(Ie,ze,tt,2)&&Pe++}for(let xe=1;xe<T.length;xe++){let Ie=T[xe-1],ze=T[xe];if(Se+=O(Ie,ze)+q*A(Ie,ze,j,_)+Z*E(Ie,ze),v(Ie,ze)&&(Se+=le),ie+r.overlap*Se>=ce)return ie+r.overlap*Se}return ie+r.overlap*Se+Pe*1e5}let W=T=>(T.l+T.r)/2,oe=T=>(T.t+T.b)/2,Me=[0,-22,22,-44,44],Le={bc:1/0},C=(T,j,_,ce)=>Math.abs(T-_)+Math.abs(j-ce),V=(T,j,_,ce,me,Re,ie,Pe)=>{let Se=0;return Se+=C(T,j,_,ce),Se+=C(_,ce,me,Re),Se+=C(me,Re,ie,Pe),Se+r.bend*2},te=(T,j,_,ce,me,Re,ie,Pe,Se,xe)=>{let Ie=0;return Ie+=C(T,j,_,ce),Ie+=C(_,ce,me,Re),Ie+=C(me,Re,ie,Pe),Ie+=C(ie,Pe,Se,xe),Ie+r.bend*3},ae=(T,j,_,ce)=>{for(let me of T[1]===j[1]?F(T[1]):K(T[0]))if(me!==_&&me!==ce&&$(T,j,me,6))return!0;for(let me of g)if($(T,j,me,2))return!0;return v(T,j)};function Ee(T,j,_,ce){let me=Math.max(T.l,j.l),Re=Math.min(T.r,j.r);if(Re-me>24)for(let Je of Me){let rt=(me+Re)/2+Je;rt>me+8&&rt<Re-8&&_(j.t>=T.b?[[rt,T.b],[rt,j.t]]:[[rt,T.t],[rt,j.b]])}let ie=Math.max(T.t,j.t),Pe=Math.min(T.b,j.b);if(Pe-ie>16)for(let Je of[0,-10,10]){let rt=(ie+Pe)/2+Je;_(j.l>=T.r?[[T.r,rt],[j.l,rt]]:[[T.l,rt],[j.r,rt]])}let Se=H.length,xe=B.length,Ie=new Uint8Array(Me.length*xe),ze=new Uint8Array(Me.length*xe),tt=new Uint8Array(Me.length*Se),Yn=new Uint8Array(Me.length*Se),ft=(Je,rt,yn,Tt)=>ce?(Je[rt]||(Je[rt]=ae(yn,Tt,T,j)?2:1),Je[rt]===1):!0;Me.forEach((Je,rt)=>Me.forEach((yn,Tt)=>{let vt=W(T)+Je,St=W(j)+yn,Et=oe(T)+Je/3,ut=oe(j)+yn/3;B.forEach((Ve,xn)=>{let ot=Ve>T.b?T.b:Ve<T.t?T.t:null,Gt=Ve>j.b?j.b:Ve<j.t?j.t:null;ot!==null&&Gt!==null&&V(vt,ot,vt,Ve,St,Ve,St,Gt)<Le.bc&&ft(Ie,rt*xe+xn,[vt,ot],[vt,Ve])&&ft(ze,Tt*xe+xn,[St,Ve],[St,Gt])&&_([[vt,ot],[vt,Ve],[St,Ve],[St,Gt]])}),H.forEach((Ve,xn)=>{let ot=Ve>T.r?T.r:Ve<T.l?T.l:null,Gt=Ve>j.r?j.r:Ve<j.l?j.l:null;ot!==null&&Gt!==null&&V(ot,Et,Ve,Et,Ve,ut,Gt,ut)<Le.bc&&ft(tt,rt*Se+xn,[ot,Et],[Ve,Et])&&ft(Yn,Tt*Se+xn,[Ve,ut],[Gt,ut])&&_([[ot,Et],[Ve,Et],[Ve,ut],[Gt,ut]])}),Je===0&&yn===0&&H.forEach((Ve,xn)=>B.forEach((ot,Gt)=>{let D=Ve>T.r?T.r:Ve<T.l?T.l:null,se=ot>j.b?j.b:ot<j.t?j.t:null;D!==null&&se!==null&&te(D,Et,Ve,Et,Ve,ot,St,ot,St,se)<Le.bc&&ft(tt,rt*Se+xn,[D,Et],[Ve,Et])&&ft(ze,Tt*xe+Gt,[St,ot],[St,se])&&_([[D,Et],[Ve,Et],[Ve,ot],[St,ot],[St,se]]);let pe=ot>T.b?T.b:ot<T.t?T.t:null,be=Ve>j.r?j.r:Ve<j.l?j.l:null;pe!==null&&be!==null&&te(vt,pe,vt,ot,Ve,ot,Ve,ut,be,ut)<Le.bc&&ft(Ie,rt*xe+Gt,[vt,pe],[vt,ot])&&ft(Yn,Tt*Se+xn,[Ve,ut],[be,ut])&&_([[vt,pe],[vt,ot],[Ve,ot],[Ve,ut],[be,ut]])}));let Fs=W(T)<j.l?j.l:W(T)>j.r?j.r:null,At=ut<T.t?T.t:ut>T.b?T.b:null;Fs!==null&&At!==null&&_([[vt,At],[vt,ut],[Fs,ut]]);let ys=oe(T)<j.t?j.t:oe(T)>j.b?j.b:null,Bs=St<T.l?T.l:St>T.r?T.r:null;ys!==null&&Bs!==null&&_([[Bs,Et],[St,Et],[St,ys]])}))}function ye(T,j,_,ce){for(let me of Me){let Re=W(T)+me,ie=oe(T)+me/3,Pe=[[[Re,T.t],[Re,j.t]],[[T.r,ie],[j.r,ie]],[[Re,T.b],[Re,j.b]],[[T.l,ie],[j.l,ie]]];for(let Se of Pe)ce(_?[Se[1],Se[0]]:Se)}}let Ne=(T,j,_,ce)=>{let me=null;return Le.bc=1/0,T(Re=>{let ie=fe(Re,j,_,Le.bc,ce);ie<Le.bc&&(Le.bc=ie,me=Re)},ce),me},Oe=[],we=T=>p.some(j=>[j.l,j.r].some(_=>T.l<_+3&&T.r>_-3&&T.b>j.t&&T.t<j.b)||[j.t,j.b].some(_=>T.t<_+3&&T.b>_-3&&T.r>j.l&&T.l<j.r)),Fe=T=>L.filter(([j,_])=>$(j,_,T,1)).length,qe=T=>g.some(j=>T.l<j.r&&T.r>j.l&&T.t<j.b&&T.b>j.t),De=T=>N.filter(j=>T.l<j.r+3&&T.r>j.l-3&&T.t<j.b+3&&T.b>j.t-3).length,Qe=T=>Oe.filter(j=>T.l<j.r+4&&T.r>j.l-4&&T.t<j.b+2&&T.b>j.t-2).length,S=T=>50*de(T)+3*Fe(T)+(we(T)?1:0)+(qe(T)?5:0)+5*De(T)+5*Qe(T),z=T=>Fe(T)>0||we(T)||qe(T)||De(T)>0||Qe(T)>0,J=[];(n.links??[]).forEach((T,j)=>{let _=T.id??`link-${j}`,ce=y.get(T.aOn??T.a),me=y.get(T.bOn??T.b);if(ce===me){a.push(`link "${_}" joins "${T.aOn??T.a}" to itself: not drawn`),J.push({...T,id:_,points:[],routed:!1});return}let Re=x(ce,me)?Se=>ye(ce,me,!1,Se):x(me,ce)?Se=>ye(me,ce,!0,Se):(Se,xe)=>Ee(ce,me,Se,xe),ie=Ne(Re,ce,me,!0),Pe=!0;if(ie||(ie=Ne(Re,ce,me,!1),Pe=!1,a.push(`link "${_}": no clear route; drawn the least bad way`)),!ie){J.push({...T,id:_,points:[],routed:!1});return}for(let Se=1;Se<ie.length;Se++)k(ie[Se-1],ie[Se]);J.push({...T,id:_,points:ie,routed:Pe})});let he=[];for(let T=0;T<L.length;T++)for(let j=T+1;j<L.length;j++){let[_,ce]=L[T],[me,Re]=L[j],ie=_[1]===ce[1],Pe=me[1]===Re[1];if(ie===Pe)continue;let[Se,xe]=ie?[[_,ce],[me,Re]]:[[me,Re],[_,ce]],Ie=xe[0][0],ze=Se[0][1];Ie>Math.min(Se[0][0],Se[1][0])&&Ie<Math.max(Se[0][0],Se[1][0])&&ze>Math.min(xe[0][1],xe[1][1])&&ze<Math.max(xe[0][1],xe[1][1])&&he.push([Ie,ze])}let de=T=>he.filter(([j,_])=>j>T.l-2&&j<T.r+2&&_>T.t-2&&_<T.b+2).length;for(let T of J){let j=T,_=T.points;if(!j.label||!_.length)continue;let ce=[];for(let xe=1;xe<_.length;xe++)ce.push([_[xe-1],_[xe]]);let me=xe=>Math.abs(xe[0][0]-xe[1][0])+Math.abs(xe[0][1]-xe[1][1]);ce.sort((xe,Ie)=>me(Ie)-me(xe));let Re=e(j.label,"label")+6,ie=null,Pe=null,Se=1/0;for(let[xe,Ie]of ce){let ze=(xe[0]+Ie[0])/2,tt=(xe[1]+Ie[1])/2,Yn=xe[1]===Ie[1]?[0,-.3,.3,-.15,.15].flatMap(ft=>{let Je=ze+ft*Math.abs(xe[0]-Ie[0]);return[[Je,tt-6,"middle"],[Je,tt+15,"middle"]]}):[0,-.3,.3].flatMap(ft=>{let Je=tt+4+ft*Math.abs(xe[1]-Ie[1]);return[[ze+7,Je,"start"],[ze-7,Je,"end"],[ze+24,Je,"start"],[ze-24,Je,"end"]]});for(let[ft,Je,rt]of Yn){let yn=rt==="middle"?ft-Re/2:rt==="end"?ft-Re:ft,Tt={l:yn,r:yn+Re,t:Je-11,b:Je+3};if(!z(Tt)){ie=[ft,Je,rt,Tt];break}let vt=S(Tt);vt<Se&&(Se=vt,Pe=[ft,Je,rt,Tt])}if(ie)break}if(!ie&&Pe&&(ie=Pe),!ie){let[xe,Ie]=ce[0],ze=(xe[0]+Ie[0])/2,tt=(xe[1]+Ie[1])/2-6;ie=[ze,tt,"middle",{l:ze-Re/2,r:ze+Re/2,t:tt-11,b:tt+3}]}Oe.push(ie[3]),T.at={x:l(ie[0]),y:l(ie[1]),anchor:ie[2],box:ie[3],text:j.label}}let Q=[],ne=[];for(let T of[...w,...Oe,...b.map(j=>j.title)])Q.push(T.l,T.r),ne.push(T.t,T.b);for(let T of J)for(let j of T.points)Q.push(j[0]),ne.push(j[1]);let ge=r.margin,ke={l:Math.min(...Q)-ge,t:Math.min(...ne)-ge,r:Math.max(...Q)+ge,b:Math.max(...ne)+ge};return{cards:m,panels:b,links:J,bounds:ke,options:r,warnings:a}}function Ru(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 Rp(n,e,t,s={}){let r=l=>{let a=dr(l,e,s);return Math.max(a.bounds.r-a.bounds.l,(a.bounds.b-a.bounds.t)*t)},o=n,i=r(n);for(let l=0;l<12;l++){let a,c=i;for(let f of Pp(o)){if(Xi(f).length)continue;let u=r(f);u<c-.5&&(c=u,a=f)}if(!a)break;o=a,i=c}return o}function*Pp(n){let e=n.panels??[],t=(i,l)=>i[0]>=l[0]&&i[2]<=l[2]&&i[1]>=l[1]&&i[3]<=l[3],s=(i,l)=>i.every((a,c)=>a===l[c]),r=(i,l=-1)=>{let a=-1;return e.forEach((c,f)=>{f===l||!t(i,c.cells)||l>=0&&f>l&&s(c.cells,e[l].cells)||(a<0||t(c.cells,e[a].cells)&&(!s(c.cells,e[a].cells)||f>a))&&(a=f)}),a},o=i=>{let l=[];return e.forEach((a,c)=>{r(a.cells,c)===i&&l.push({range:[...a.cells],panel:c})}),n.cards.forEach((a,c)=>{let f=[a.cell[0],a.cell[1],a.cell[0],a.cell[1]];r(f)===i&&l.push({range:f,card:c})}),l};for(let i of[-1,...e.map((l,a)=>a)]){let l=o(i);if(i>=0&&!l.some(u=>u.panel!==void 0))continue;let a=u=>[u.range[1],u.range[3]],c=[];for(let u of[...l].sort((d,h)=>d.range[1]-h.range[1]||d.range[0]-h.range[0])){let d=c.find(h=>h.some(b=>a(b)[0]<=a(u)[1]&&a(u)[0]<=a(b)[1]));d?d.push(u):c.push([u])}let f=Math.max(...l.map(u=>u.range[3]));for(let u of c){u.sort((d,h)=>d.range[0]-h.range[0]);for(let d=1;d<u.length;d++){let h=u.slice(d),b=u[0].range[0],m=f+1,y=Math.min(...h.map(E=>E.range[1])),N=Math.max(...h.map(E=>E.range[3]))-y+1,p=n.cards.map(E=>({...E,cell:[...E.cell]})),g=e.map(E=>({...E,cells:[...E.cells]}));for(let E of p)E.cell[1]>f&&(E.cell[1]+=N);let x=new Set;for(let E=i;E>=0&&!x.has(E);E=r(e[E].cells,E))x.add(E);g.forEach((E,v)=>{E.cells[1]>f?(E.cells[1]+=N,E.cells[3]+=N):(x.has(v)||E.cells[1]<=f&&E.cells[3]>f)&&(E.cells[3]+=N)});let $=b;for(let E of h){let v=$-E.range[0],A=m+(E.range[1]-y)-E.range[1],L=M=>M[0]>=E.range[0]&&M[0]<=E.range[2]&&M[1]>=E.range[1]&&M[1]<=E.range[3];n.cards.forEach((M,P)=>{L([M.cell[0],M.cell[1]])&&(p[P].cell=[M.cell[0]+v,M.cell[1]+A])}),e.forEach((M,P)=>{t(M.cells,E.range)&&(g[P].cells=[M.cells[0]+v,M.cells[1]+A,M.cells[2]+v,M.cells[3]+A])}),$+=E.range[2]-E.range[0]+1}e.forEach((E,v)=>{let A=n.cards.map((L,M)=>t([L.cell[0],L.cell[1],L.cell[0],L.cell[1]],E.cells)?p[M].cell:void 0).filter(L=>!!L);A.length&&(g[v].cells=[Math.min(...A.map(L=>L[0])),Math.min(...A.map(L=>L[1])),Math.max(...A.map(L=>L[0])),Math.max(...A.map(L=>L[1]))])}),yield{cards:p,panels:g,links:n.links}}}}}function Qi(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(A=>e(A.id)):v.type==="node"&&!v.children.some(A=>A.type==="node"&&e(A.id)),i=t.filter(o),l=v=>{let A=[];for(let L=v;L;L=L.parent)A.unshift(L);return A},a=new Map(i.map(v=>[v.id,l(v)])),c=(v,A)=>{let L=a.get(v.id),M=a.get(A.id),P=0;for(;P<L.length&&P<M.length&&L[P]===M[P];)P++;return[L[P].box,M[P].box]},f=1e-6,u=(v,A)=>{let[L,M]=c(v,A);return L.y1<=M.y0+f&&L.x0<M.x1-f&&M.x0<L.x1-f},d=(v,A)=>{let[L,M]=c(v,A);return L.x1<=M.x0+f&&L.y0<M.y1-f&&M.y0<L.y1-f},h=(v,A)=>{let L=new Map,M=[];for(let P of[...i].sort((k,O)=>A(k)-A(O))){let k=0;for(let O of M)L.get(O.id)+1>k&&v(O,P)&&(k=L.get(O.id)+1);L.set(P.id,k),M.push(P)}return L},b=h(u,v=>v.box.y0),m=h(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 A of i)A.parent&&A.box.x0<=v.box.x0+y&&m.set(v.id,Math.max(m.get(v.id),m.get(A.id)));let N=new Map;for(let v of i)N.set(v.id,[m.get(v.id),b.get(v.id)]);let p=new Map;for(let v of i){let A=N.get(v.id),L=p.get(String(A));if(L!==void 0&&L!==v.id){for(let[,M]of N)M[0]>A[0]&&M!==A&&M[0]++;A[0]++,p.clear();for(let M of i)p.set(String(N.get(M.id)),M.id)}else p.set(String(A),v.id)}let g=i.map(v=>{if(v.region){let M=v.region;return{id:v.id,label:M.label??v.id,sub:void 0,role:M.role??ht(s,M.kind)?.role??"grey",ghost:M.ghost||void 0,cell:N.get(v.id)}}let A=v.node,L=fn(s,A.asset);return{id:v.id,label:A.label??v.id,sub:A.sub,role:A.role??L.role,ghost:A.ghost||void 0,cell:N.get(v.id)}}),x=[];for(let v of t){if(o(v))continue;let A=[],L=w=>{for(let R of w.children){let I=N.get(R.id);I&&A.push(I),L(R)}};if(L(v),!A.length)continue;let M=A.map(w=>w[0]),P=A.map(w=>w[1]),k=v.type==="region"?v.region.label:v.node.label??v.id,O=v.type==="region"?v.region.role??ht(s,v.region.kind)?.role:v.node.role??fn(s,v.node.asset).role;x.push({id:v.id,label:k,sub:v.type==="node"?v.node.sub:void 0,role:O,cells:[Math.min(...M),Math.min(...P),Math.max(...M),Math.max(...P)]})}let $=new Set([...g.map(v=>v.id),...x.map(v=>v.id)]),E=[];for(let v of n.routes){if(!e(v.id))continue;let A=Zt(v.raw.from).id,L=Zt(v.raw.to).id;if(!$.has(A)||!$.has(L))continue;let M=typeof v.raw.label=="string"?v.raw.label:v.raw.label?.text;E.push({id:v.id,a:A,b:L,kind:v.kind,label:M})}return{cards:g,panels:x,links:E}}var ps={W:4,D:2,H:.9,GX:2,GY:2.4,PAD:.6,CH:2.2,PANEL_H:.3},Pu=`
|
|
288
290
|
.blk .card-name{font-size:13px;font-weight:600;fill:var(--ink)}
|
|
289
291
|
.blk .card-sub{font-size:10px;fill:var(--ink);opacity:.75}
|
|
290
292
|
.blk.ghost .card-name,.blk.ghost .card-sub{fill:var(--muted)}
|
|
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}{${
|
|
293
|
-
`;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${
|
|
294
|
-
`}return s}var
|
|
295
|
-
<button class="pbtn small" type="button" data-a="grid" aria-pressed="${
|
|
293
|
+
`;function Ql(n){return{name:"card",description:"A card: a slab with its name on its front face",size:[ps.W,ps.D,ps.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 Cu(n){let e=new Map(n.cards.map(t=>[t.id,{label:t.label,sub:t.sub}]));return{regions:{panel:{shape:"slab",pad:ps.PAD,z:[ps.PANEL_H,0],floor:!0,role:"grey",labelStyle:"floor"}},nodes:{card:Ql(t=>e.get(t))},defaultNode:"card"}}function Iu(n,e={}){let t=ps,{prect:s,parentIx:r,cardAt:o}=lo(n,{W:t.W,H:t.D,GX:t.GX,GY:t.GY,PAD:t.PAD,TITLE:0,CH:t.CH}),i=n.panels??[],l=b=>Math.round(b*1e3)/1e3,a=b=>(b.cells[2]-b.cells[0]+1)*(b.cells[3]-b.cells[1]+1),c=b=>{let m=-1;return i.forEach((y,N)=>{let p=y.cells;b.cell[0]>=p[0]&&b.cell[0]<=p[2]&&b.cell[1]>=p[1]&&b.cell[1]<=p[3]&&(m<0||a(y)<=a(i[m]))&&(m=N)}),m},f=i.map((b,m)=>{let y=s[m],N=r[m]>=0?s[r[m]]:{l:0,t:0};return{id:b.id,kind:"panel",label:b.label,role:b.role,at:[l(y.l-N.l),l(y.t-N.t)],size:[l(y.r-y.l),l(y.b-y.t)],regions:[],nodes:[]}}),u=[],d=[];f.forEach((b,m)=>r[m]>=0?f[r[m]].regions.push(b):u.push(b));for(let b of n.cards){let[m,y]=o(n.cards.indexOf(b)),N=c(b),p=N>=0?s[N]:{l:0,t:0},g={id:b.id,asset:"card",role:b.role,ghost:b.ghost||void 0,at:[l(m-p.l),l(y-p.t)],size:[t.W,t.D,t.H]};(N>=0?f[N].nodes:d).push(g)}for(let b of f)b.regions.length||delete b.regions,b.nodes.length||delete b.nodes;let h=(n.links??[]).map((b,m)=>({id:b.id??`link-${m}`,from:b.aOn??b.a,to:b.bOn??b.b,kind:b.kind,label:b.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:h}]}}var Ed={};Sa(Ed,{APPEARS:()=>Du,BASE_FIELDS:()=>mc,BINS:()=>ed,BIN_MS:()=>gn,CARD:()=>pt,DUAL_VIEW_CSS:()=>Td,IDLES:()=>_u,MAX_ZOOM:()=>ea,MIN_ZOOM:()=>Zi,P3:()=>Ye,PLAY_CSS:()=>Qu,SEGMENT_NAME:()=>ia,SEVERITIES:()=>Wt,TIMELINE_VERSION:()=>Zu,activityOf:()=>xc,attr:()=>Cn,binNext:()=>da,binStart:()=>Rs,buildLayer:()=>ho,cardMotion:()=>zu,clamp:()=>ns,cls:()=>Vu,crumbs:()=>hr,dualView:()=>Sd,ease:()=>po,escapeName:()=>ca,extent:()=>ta,findGaps:()=>ma,fitWithOverlay:()=>Gu,flatCss:()=>yd,flatSvg:()=>xa,formatScope:()=>td,gapKey:()=>Cs,gapLabel:()=>Ps,h:()=>re,hasSegment:()=>rd,highlights:()=>uo,isZone:()=>ad,isoVars:()=>qu,join:()=>nd,kindOf:()=>mr,legend:()=>uc,levelOf:()=>Ct,markConnectors:()=>va,md:()=>sn,measureIn:()=>wa,memorySource:()=>dd,modeFor:()=>yc,morphSvgs:()=>vd,mountPlayer:()=>Xu,mountTimeline:()=>gd,n:()=>nc,nameOf:()=>pr,node:()=>Ku,offsetAt:()=>Dt,overlayPaint:()=>Bu,pageClock:()=>dc,parentOf:()=>sd,prefixAt:()=>ts,prune:()=>rc,pts:()=>co,rangeOf:()=>fo,readTime:()=>pc,rectOf:()=>xd,renderPage:()=>Hu,rewrite:()=>sc,scope:()=>ic,scopePattern:()=>aa,scopeRules:()=>la,scopeSelector:()=>oc,searchFor:()=>gr,severities:()=>od,stepData:()=>fc,storedMode:()=>$d,ticks:()=>pa,timeScale:()=>br,toCSV:()=>ga,toJSON:()=>ha,transport:()=>sa,unite:()=>na,viewToggle:()=>Md,viewport:()=>Fu,within:()=>Jt});function Cp(n,e,t){let r=(l,a,c,f,u)=>Math.min((l-48)/(c-a),...f===void 0||u===void 0?[]:[[u-f,12],[u-a,30],[c-f,30]].map(([d,h])=>d>0?(l-h)/d:1/0)),o=Math.min(ea,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=(l,a,c,f,u)=>{let d=(a+c)/2;if(f===void 0||u===void 0)return d;let h=u-(l/2-6)/o,b=f+(l/2-6)/o;return h>b?(h+b)/2:Math.max(h,Math.min(b,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,ea=8;function Fu(n,e){let t,s,r=!1,o=0,i=0,l=0,a=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 A=u();return Math.min(A.w/v.w,A.h/v.h)},h=v=>{o++;try{v()}finally{o--}};function b(){let v=e.svg();if(!v||!t)return;o||(r=!0);let A=u(),L=d(),M=A.w/L,P=A.h/L;t={x:t.x+(t.w-M)/2,y:t.y+(t.h-P)/2,w:M,h:P},v.setAttribute("viewBox",`${t.x.toFixed(2)} ${t.y.toFixed(2)} ${t.w.toFixed(2)} ${t.h.toFixed(2)}`),i=L,e.onApply(L),l&&Math.abs(L/l-1)>.02&&(cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=0,e.onRezoom()}))}let m=(v,A)=>{let L=n.getBoundingClientRect(),M=d();return{x:t.x+(v-L.left)/M,y:t.y+(A-L.top)/M}};function y(v,A,L){if(!t)return;let M=d(),P=Math.min(ea,Math.max(Zi,M*v)),k=n.getBoundingClientRect(),O=A??k.left+k.width/2,w=L??k.top+k.height/2,R=m(O,w),I=u();t={x:R.x-(O-k.left)/P,y:R.y-(w-k.top)/P,w:I.w/P,h:I.h/P},b()}function N(v=s,A){if(!v)return;let L=u(),{k:M,cx:P,cy:k}=Cp(L,v,A),O={x:P-L.w/M/2,y:k-L.h/M/2,w:L.w/M,h:L.h/M};if(t&&Math.abs(O.w/t.w-1)<.001&&Math.abs(O.h/t.h-1)<.001&&Math.abs(O.x-t.x)<O.w*.001&&Math.abs(O.y-t.y)<O.h*.001){b();return}t=O,b()}function p(){for(let v=0,A="";v<4;v++){let L=e.itemsBox()??s;if(!L)return;let M=[L.x,L.y,L.w,L.h].map(k=>Math.round(k)).join();if(M===A)break;A=M;let P=Math.max(24,Math.min(L.w,L.h)*.06);if(h(()=>N({x:L.x-P,y:L.y-P,w:L.w+P*2,h:L.h+P*2},e.alsoBox?.())),!e.marksShowing()||!l||Math.abs(d()/l-1)<=.02)break;cancelAnimationFrame(a),a=0,e.onRezoom()}r=!1}function g(){if(r||!e.svg()||!t)return;let v=n.getBoundingClientRect();v.width<2||v.height<2||p()}function x(){if(!t)return;let v=d();y(1/v)}function $(){return new Promise(v=>{let A=0,L=i,M=()=>{if(f){v();return}let P=!!(a||c)||i!==L;L=i,A=P?0:A+1,A>=2?v():requestAnimationFrame(M)};requestAnimationFrame(M)})}let E=new ResizeObserver(()=>{if(!(!t||f)){if(r&&i){let v=u(),A=t.x+t.w/2,L=t.y+t.h/2;t={x:A-v.w/i/2,y:L-v.h/i/2,w:v.w/i,h:v.h/i}}r||(cancelAnimationFrame(c),c=requestAnimationFrame(()=>{c=0,f||g()})),h(b)}});return E.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){l=v},size:u,scale:d,quietly:h,applyView:b,toSvg:m,zoomAt:y,fit:N,fitItems:p,autoFit:g,actual:x,settled:$,dispose(){cancelAnimationFrame(c),cancelAnimationFrame(a),E.disconnect(),f=!0}}}var bt="http://www.w3.org/2000/svg",pt={half:2.4,h:3.2,t:.25,above:1.4,lift:3.8,fan:.32,gap:.3},Ye=(n,e,t)=>[(n-e)*wt*st,(n+e)*.5*st-t*st],co=n=>n.map(([e,t])=>`${e.toFixed(1)},${t.toFixed(1)}`).join(" ");function Bu(n,e){function t(o,i,l){let a=n.k(),c=(u,d,h,b,m="")=>{let y=o.createElementNS(bt,"g");y.setAttribute("class",`live-badge ${h.cls} ${m}`.trim());let N=8/a,p=o.createElementNS(bt,"circle");if(p.setAttribute("cx",String(u)),p.setAttribute("cy",String(d)),p.setAttribute("r",String(N)),y.append(p),"g"in h){let x=o.createElementNS(bt,"text");x.setAttribute("x",String(u)),x.setAttribute("y",String(d)),x.style.fontSize=`${(10/a).toFixed(2)}px`,x.textContent=h.g,y.append(x)}else{let x=o.createElementNS(bt,"use");x.setAttribute("href",n.iconHref(h.icon));let $=11/a;x.setAttribute("x",String(u-$/2)),x.setAttribute("y",String(d-$/2)),x.setAttribute("width",String($)),x.setAttribute("height",String($)),y.append(x)}let g=o.createElementNS(bt,"title");g.textContent=b,y.append(g),i(y)},f=(u,d)=>{for(let h of n.outlinesFor(u)){if(h.kind!=="poly")continue;let b=o.createElementNS(bt,"polygon");b.setAttribute("class",d),b.setAttribute("points",h.points.map(([m,y])=>`${m.toFixed(1)},${y.toFixed(1)}`).join(" ")),i(b)}};for(let u of l){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 h=o.createElementNS(bt,"title");h.textContent=u.title;let b=o.createElementNS(bt,"rect");b.setAttribute("class","live-hit"),b.setAttribute("x",String(d.x)),b.setAttribute("y",String(d.y)),b.setAttribute("width",String(d.w)),b.setAttribute("height",String(d.h)),b.append(h),i(b)}if((u.beside??[]).forEach((h,b)=>c(d.x+18*(b+1)/a,d.y,h.glyph,h.title)),u.dot&&c(d.x,d.y+d.h,u.dot.glyph,u.dot.title),u.tag){let h=o.createElementNS(bt,"text");h.setAttribute("class",`live-life ${u.tag.cls}`),h.setAttribute("x",String(d.x+d.w)),h.setAttribute("y",String(d.y+d.h)),h.style.fontSize=`${(9/a).toFixed(2)}px`,h.textContent=u.tag.text,i(h)}}}}function s(o,i,l){for(let a of l){let c=o.createElementNS(bt,"g");c.setAttribute("class",`live-extra${a.cls}`);for(let[g,x]of a.data)c.setAttribute(g,x);let{x:f,y:u,w:d,hgt:h,k:b}=a.rect,m=o.createElementNS(bt,"rect");m.setAttribute("x",String(f)),m.setAttribute("y",String(u)),m.setAttribute("width",String(d)),m.setAttribute("height",String(h)),m.setAttribute("rx",String(6/b));let y=o.createElementNS(bt,"text");y.setAttribute("x",String(f+8/b)),y.setAttribute("y",String(u+13/b)),y.style.fontSize=`${(11/b).toFixed(2)}px`,y.textContent=a.line1;let N=o.createElementNS(bt,"text");N.setAttribute("class","sub"),N.setAttribute("x",String(f+8/b)),N.setAttribute("y",String(u+27/b)),N.style.fontSize=`${(9/b).toFixed(2)}px`,N.textContent=a.line2;let p=o.createElementNS(bt,"title");p.textContent=a.title,c.append(m,y,N,p),i(c)}}function r(o,i,l){let a=[];for(let c of l){let f=c.over,u=(f.x0+f.x1)/2,d=(f.y0+f.y1)/2,h=0,b={x0:0,y0:0,x1:0,y1:0};for(let B=0;B<6;B++){let H=f.z1+pt.above+h,Y=H+pt.h,ee=[Ye(u-pt.half,d+pt.t,H),Ye(u+pt.half,d+pt.t,H),Ye(u+pt.half,d-pt.t,Y),Ye(u-pt.half,d+pt.t,Y)];if(b={x0:Math.min(...ee.map(F=>F[0])),y0:Math.min(...ee.map(F=>F[1])),x1:Math.max(...ee.map(F=>F[0])),y1:Math.max(...ee.map(F=>F[1]))},!Ji(b,a))break;h+=pt.lift}a.push(b);let m=f.z1+pt.above+h,y=m+pt.h,N=u-pt.half,p=u+pt.half,g=d+pt.t,x=d-pt.t,$=o.createElementNS(bt,"g");$.setAttribute("class",`${e}-card${c.cls}`);for(let[B,H]of c.data)$.setAttribute(B,H);let[E,v]=Ye(u,d,f.z1+.15),A=`${E.toFixed(1)}px ${v.toFixed(1)}px`;$.style.transformOrigin=A;let L=o.createElementNS(bt,"g");L.setAttribute("class",`${e}-float`),L.style.transformOrigin=A;let M=[];for(let B=Math.min(c.count-1,3);B>=1;B--){let H=B*pt.fan,Y=x-(B-1)*(2*pt.t+pt.gap)-pt.gap,ee=Y-2*pt.t,F=N+H,K=p+H,q=m+H,Z=y+H,le=(fe,W)=>{let oe=o.createElementNS(bt,"polygon");oe.setAttribute("class",`${e}-face stacked ${fe}`),oe.setAttribute("points",co(W)),L.append(oe)};le("s-top",[Ye(F,ee,Z),Ye(K,ee,Z),Ye(K,Y,Z),Ye(F,Y,Z)]),le("s-side",[Ye(K,ee,q),Ye(K,Y,q),Ye(K,Y,Z),Ye(K,ee,Z)]),le("s-front",[Ye(F,Y,q),Ye(K,Y,q),Ye(K,Y,Z),Ye(F,Y,Z)]),M.push({x0:F,x1:K,y0:ee,y1:Y,z0:q,z1:Z})}let P=o.createElementNS(bt,"polygon");P.setAttribute("class",`${e}-tail`),P.setAttribute("points",co([Ye(u-.5,g,m+.05),Ye(u+.5,g,m+.05),Ye(u,d,f.z1+.15)]));let k=(B,H)=>{let Y=o.createElementNS(bt,"polygon");return Y.setAttribute("class",B),Y.setAttribute("points",co(H)),Y},O=k(`${e}-face front`,[Ye(N,g,m),Ye(p,g,m),Ye(p,g,y),Ye(N,g,y)]);L.append(P,k(`${e}-face top`,[Ye(N,x,y),Ye(p,x,y),Ye(p,g,y),Ye(N,g,y)]),k(`${e}-face side`,[Ye(p,x,m),Ye(p,g,m),Ye(p,g,y),Ye(p,x,y)]),O);let[w,R]=Ye(N,g,y),I=40,G=o.createElementNS(bt,"g");G.setAttribute("transform",`matrix(${(wt*st/I).toFixed(4)} ${(.5*st/I).toFixed(4)} 0 ${(st/I).toFixed(4)} ${w.toFixed(1)} ${R.toFixed(1)})`);let X=(B,H,Y,ee)=>{let F=o.createElementNS(bt,"text");return F.setAttribute("class",B),F.setAttribute("x",String(H)),F.setAttribute("y",String(Y)),F.textContent=ee,F};if(G.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&&G.append(X(`${e}-q`,12,118,c.line)),c.count>1){let B=o.createElementNS(bt,"circle");B.setAttribute("class",`${e}-count-bg`),B.setAttribute("cx","178"),B.setAttribute("cy","14"),B.setAttribute("r","15"),G.append(B,X(`${e}-count`,178,14,String(c.count)))}L.append(G);let U=o.createElementNS(bt,"title");U.textContent=c.title,$.append(L,U),n.onCard?.($,{cx:u,cy:d,tipZ:f.z1+.15,card:{x0:N,x1:p,y0:x,y1:g,z0:m,z1:y},panes:M.reverse()}),i($)}}return{paintMarks:t,paintGhosts:s,paintCards:r}}var Du=[["scale","Scale"],["spin","Spin"],["dissolve","Dissolve"],["inflate","Inflate"]],_u=[["none","None"],["jiggle","Jiggle"],["pirouette","Pirouette"],["glow","Glow"],["breathe","Breathe"]];function Ip(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 Zl=n=>n<0?0:n>1?1:1-Math.pow(1-n,3),ju=n=>n<0?0:n>1?1:n*n*n,ec=Math.PI*2,tc={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}},hn={windup:220,turn:980,land:260};function zu(n,e,{prefix:t,key:s,alt:r}){let o={...e},i=1,l=new Map,a=new WeakSet,c=0,f=0,u=new WeakMap,d=new WeakMap;function h(P){c=0;for(let[k,O]of l){if(!k.isConnected){l.delete(k);continue}let w;if(O.repeat){if(w=(P+(O.offset??0))%O.repeat/O.dur,w>1){a.has(k)&&(n.restore(k),a.delete(k),k.style.removeProperty("transform"));continue}}else if(w=(P-O.start)/O.dur,w>=1){b(k,O);continue}let R=O.frame(Math.max(0,w));n.spin(k,R.theta,R.lift),a.add(k),d.set(k,R),R.scale!==1?k.style.transform=`scale(${R.scale.toFixed(4)})`:k.style.removeProperty("transform"),f++}l.size&&(c=requestAnimationFrame(h))}function b(P,k){l.delete(P),a.has(P)&&(n.restore(P),a.delete(P)),P.style.removeProperty("transform"),k.done?.()}function m(P){let k=l.get(P.card);k&&b(P.card,k),l.set(P.card,P),c||(c=requestAnimationFrame(h))}let y=8,N=0,p=P=>(N++,P.finally(()=>{N--}));function g(P){return!o.enabled||N>=y?Promise.resolve():p($(P))}function x(P){return!o.enabled||N>=y?Promise.resolve():p(E(P))}function $(P){let k=tc.appear[o.appear]/i;if(o.appear==="spin")return new Promise(R=>m({card:P,start:performance.now(),dur:k,frame:I=>({theta:(1-Zl(I))*ec,lift:0,scale:Math.max(.001,Zl(I))}),done:R}));let O=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(O,{duration:k,easing:o.appear==="inflate"?"linear":"ease-out"}).finished.then(()=>{},()=>{})}function E(P){let k=tc.disappear[o.appear]/i;if(o.appear==="spin")return new Promise(R=>m({card:P,start:performance.now(),dur:k,frame:I=>({theta:ju(I)*ec,lift:0,scale:Math.max(.001,1-ju(I))}),done:()=>{P.style.transform="scale(0)",R()}}));let O=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(O,{duration:k,easing:"ease-in",fill:"forwards"}).finished.then(()=>{},()=>{})}function v(P){u.get(P)?.cancel(),u.delete(P);let k=l.get(P);k?.repeat&&b(P,k)}function A(P,k){if(v(P),!o.enabled||o.idle==="none"||P.classList.contains("still"))return;let O=P.getAttribute(s)??P.getAttribute(r)??"",w=(k??tc.period[o.idle])/i,R=Ip(O)*w;if(o.idle==="pirouette"){let B=(hn.windup+hn.turn+hn.land)/i,H=hn.windup/(hn.windup+hn.turn+hn.land),Y=(hn.windup+hn.turn)/(hn.windup+hn.turn+hn.land);m({card:P,start:0,dur:B,repeat:w,offset:R,frame:ee=>{if(ee<H)return{theta:-.35*Math.sin(ee/H*Math.PI/2),lift:0,scale:1};if(ee<Y){let K=(ee-H)/(Y-H);return{theta:-.35*(1-K)+Zl(K)*ec,lift:.9*Math.sin(K*Math.PI),scale:1}}let F=(ee-Y)/(1-Y);return{theta:0,lift:0,scale:1-.04*Math.sin(F*Math.PI)}}});return}let I=P.querySelector(`.${t}-float`)??P,G=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 ${G})`},{filter:`drop-shadow(0 0 7px ${G})`},{filter:`drop-shadow(0 0 0px ${G})`}]:[{transform:"scale(1)"},{transform:"scale(1.035)"},{transform:"scale(1)"}],U=I.animate(X,{duration:w,iterations:1/0,easing:o.idle==="jiggle"?"linear":"ease-in-out"});U.startTime=(document.timeline.currentTime??0)-((document.timeline.currentTime??0)+R)%w,u.set(P,U)}function L(P,k,O,w,R=!1){R&&(w=!1);for(let[G,X]of k)!P.has(G)&&!R&&g(X),!u.has(X)&&!l.get(X)?.repeat&&A(X);if(!o.enabled||!w)return;let I=n.leavingLayer();if(I)for(let[G,X]of O){let U=P.get(G);!U||k.has(G)||(v(U),U.setAttribute("class",`${t}-leaving${X?" expired":""}`),U.removeAttribute(r),I.append(U),x(U).then(()=>U.remove()))}}function M(P){for(let[k,O]of[...l])b(k,O);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 O=o;if(o={...o,...P},(!o.enabled||O.idle!==o.idle||O.enabled!==o.enabled)&&(M(void 0),o.enabled))for(let w of k)A(w)},update:L,appear:g,disappear:x,startIdle:A,stopIdle:v,stopAll:M,async preview(P){o.enabled&&await Promise.all(P.map(async k=>{if(v(k),await g(k),o.idle!=="none"&&!k.classList.contains("still")){let O=o.idle==="pirouette"?1800:1400;A(k,O),await new Promise(w=>setTimeout(w,O*2.2/i)),v(k)}else await new Promise(O=>setTimeout(O,700/i));await x(k);for(let O of k.getAnimations())O.cancel();k.style.removeProperty("transform"),A(k)}))},get stats(){return{jobs:l.size,raf:!!c,frames:f,effects:N}},setSpeed(P){i=P},lastFrame:P=>d.get(P)}}var nc=n=>String(Math.round(n*100)/100),Ku=(n,e={},...t)=>({name:n,attrs:Object.entries(e).map(([s,r])=>[s,typeof r=="number"?nc(r):r]),children:t});function sc(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,l)=>`url(${l}#${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=>sc(s,e))}}function rc(n,e){if(typeof n=="string")return n;if(!e(n))return{...n,children:n.children.map(t=>rc(t,e)).filter(t=>t!==void 0)}}var Vu=n=>(n.attrs.find(e=>e[0]==="class")?.[1]??"").split(/\s+/),Cn=(n,e)=>n.attrs.find(t=>t[0]===e)?.[1];function ta(n){let e=[],t=[],s=i=>{if(typeof i=="string")return;let l=Cn(i,"transform");if(l&&/matrix/.test(l))return;let a=Cn(i,"points");if(a)for(let c of a.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(Cn(i,"x")),f=Number(Cn(i,"y")),u=Number(Cn(i,"width")),d=Number(Cn(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(Cn(i,"cx")),f=Number(Cn(i,"cy")),u=Number(Cn(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 na=(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 Gu(n,e,t){let s=l=>Math.min((e.width-e.pad*2)/l.w,(e.height-e.pad*2)/l.h),r=s(n),o=t(r),i=na(n,ta(o));return r=s(i),o=t(r),i=na(n,ta(o)),r=s(i),{k:r,box:i,live:o}}var qu=n=>n.replace(/--([a-zA-Z][\w-]*)/g,"--iso-$1");function Lp(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 Fp(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 oc(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 ic(n,e,t){let s="";for(let[r,o]of Lp(n)){if(r.startsWith("@keyframes")){s+=`@keyframes iso-${r.slice(10).trim()}{${o}}
|
|
294
|
+
`;continue}if(r.startsWith("@media")||r.startsWith("@supports")){s+=`${r}{${ic(o,e,t)}}
|
|
295
|
+
`;continue}if(r.startsWith("@"))throw new Error(`the canvas's CSS has an at-rule it can't scope: ${r}`);s+=`${Fp(r).map(i=>oc(i,e,t)).join(",")}{${o.replace(/\banimation:\s*([a-z][\w-]*)/g,"animation:iso-$1")}}
|
|
296
|
+
`}return s}var ac=["<","script"].join("");function sn(n){return n?mt(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 lc=n=>(n??"").split(/\n\s*\n/).filter(Boolean).map(e=>`<p class="sec-sub">${sn(e.trim())}</p>`).join(""),Uu=(n,e)=>!!e.motion&&io(e,e.motion,{kinds:n.theme.kinds}).ok;function cc(n,e){return Uu(n,e)?io(e,e.motion,{kinds:n.theme.kinds}).beats.map(t=>({n:t.index+1,num:t.index+1,kind:"control",color:t.say?.color??An(n.theme,n.theme.kinds.control?.color??"control"),heading:t.say?.title??t.name,caption:t.say?.text??"",command:t.say?.code??"",phases:[],pulses:[],lit:[],duration:t.end-t.start})):e.steps.steps}function fc(n){return JSON.stringify({scenes:n.scenes.map(e=>{let t=Uu(n,e),s=cc(n,e),r=t?e.motion:e.steps.steps.length?Gi(e):void 0;return{id:e.id,loop:e.raw.loop??!0,dim:e.raw.dim??"flows",vis:e.steps.vis,steps:s.map(({focus:o,...i})=>({...i,caption:sn(i.caption)})),assemble:e.assemble,grid:!!e.grid.show,source:oo(e),...r?{doc:r}:{},...t?{own:t}:{}}})})}function uc(n,e){let t=n.theme,s=e.raw.legend;if(s===!1)return"";let r=Array.isArray(s)?s:e.steps.kindsUsed.filter(l=>e.routes.some(a=>a.kind===l)||e.steps.steps.some(a=>a.phases.some(c=>c.some(f=>f.kind===l)))),o=l=>`<span><i${l.box?' class="box"':""} style="${l.swatch}"></i>${l.label}</span>`,i=r.map(l=>{let a=ht(n.catalog,l)?.legend;if(a)return o(a);let c=t.kinds[l];return c?`<span><i style="${`border-color:${An(t,c.color)}${c.dash==="dashed"?";border-top-style:dashed":c.dash==="dotted"?";border-top-style:dotted":""}`}"></i>${sn(c.legend)}</span>`:""});if(!Array.isArray(s)){let l=new Set(e.layout.items.map(a=>a.region?.kind));for(let[a,c]of Object.entries(n.catalog.regions))c.legend?.auto&&l.has(a)&&i.push(o(c.legend))}return i.join("")}function Bp(n,e){let t=cc(n,e),s=`<div class="tools">
|
|
297
|
+
<button class="pbtn small" type="button" data-a="grid" aria-pressed="${e.grid.show?"true":"false"}" title="Show the floor grid">Grid</button>
|
|
296
298
|
<button class="pbtn small" type="button" data-a="assemble" title="Draw the diagram again, piece by piece">Assemble</button>
|
|
297
|
-
</div>`;if(!
|
|
299
|
+
</div>`;if(!t.length)return`<div class="player">${s}</div>`;let r=t[0];return`<div class="player">
|
|
298
300
|
<div class="ctrls">
|
|
299
301
|
<button class="pbtn icon" type="button" data-a="prev" aria-label="Previous step">\u2039</button>
|
|
300
302
|
<button class="pbtn primary" type="button" data-a="play" aria-label="Play">\u25B6 Play</button>
|
|
301
303
|
<button class="pbtn icon" type="button" data-a="next" aria-label="Next step">\u203A</button>
|
|
302
304
|
</div>
|
|
303
|
-
${
|
|
305
|
+
${s}
|
|
304
306
|
<div class="cap" aria-live="polite">
|
|
305
|
-
<div class="cap-h"><span class="num" style="background:${
|
|
306
|
-
<p class="cap-t">${
|
|
307
|
-
<pre class="cap-c">${
|
|
307
|
+
<div class="cap-h"><span class="num" style="background:${r.color}">${r.num}</span><span class="h">${mt(r.heading)}</span><span class="cnt">1 / ${t.length}</span></div>
|
|
308
|
+
<p class="cap-t">${sn(r.caption)}</p>
|
|
309
|
+
<pre class="cap-c">${mt(r.command)}</pre>
|
|
308
310
|
<div class="prog"><i></i></div>
|
|
309
311
|
</div>
|
|
310
312
|
<div class="dots"></div>
|
|
311
|
-
</div>`}function
|
|
312
|
-
<section class="scene" id="scene-${
|
|
313
|
-
<h2>${
|
|
314
|
-
${
|
|
313
|
+
</div>`}function jp(n,e){let t=cc(n,e);return t.length?`<details class="steps"><summary>All ${t.length} steps as text</summary><ol>${t.map(s=>`<li value="${s.num}"><b>${mt(s.heading)}.</b> ${sn(s.caption)}${s.command?`<br><code>${mt(s.command)}</code>`:""}</li>`).join("")}</ol></details>`:""}function Hu(n,e={}){let t=n.doc,s=t.title??t.scenes[0]?.title??"Diagram",r=(t.pills??[]).map(i=>`<span class="pill">${sn(i)}</span>`).join(""),o=n.scenes.map(i=>`
|
|
314
|
+
<section class="scene" id="scene-${mt(i.id)}">
|
|
315
|
+
<h2>${mt(i.raw.title)}</h2>
|
|
316
|
+
${lc(i.raw.caption)}
|
|
315
317
|
<div class="figure" tabindex="-1">
|
|
316
318
|
<div class="scroller">${i.grid.show?i.rendered.svg.replace("<svg ",'<svg class="show-grid" '):i.rendered.svg}</div>
|
|
317
|
-
${
|
|
318
|
-
<div class="legend">${
|
|
319
|
+
${Bp(n,i)}
|
|
320
|
+
<div class="legend">${uc(n,i)}</div>
|
|
319
321
|
</div>
|
|
320
|
-
${
|
|
321
|
-
${i.raw.after?`<div class="after">${
|
|
322
|
+
${jp(n,i)}
|
|
323
|
+
${i.raw.after?`<div class="after">${lc(i.raw.after)}</div>`:""}
|
|
322
324
|
</section>`).join(`
|
|
323
325
|
`);return`<!doctype html>
|
|
324
326
|
<html lang="en">
|
|
325
327
|
<head>
|
|
326
328
|
<meta charset="utf-8">
|
|
327
329
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
328
|
-
<title>${
|
|
329
|
-
${t.lede?`<meta name="description" content="${
|
|
330
|
+
<title>${mt(s)}</title>
|
|
331
|
+
${t.lede?`<meta name="description" content="${mt(t.lede)}">`:""}
|
|
330
332
|
<style>
|
|
331
|
-
${
|
|
333
|
+
${ai(n.theme)}${Yi(n.catalog)}${Wi}
|
|
332
334
|
</style>
|
|
333
335
|
${e.extraHead??""}
|
|
334
336
|
</head>
|
|
@@ -336,17 +338,17 @@ ${e.extraHead??""}
|
|
|
336
338
|
<div class="wrap">
|
|
337
339
|
<header class="page">
|
|
338
340
|
<div>
|
|
339
|
-
<h1>${
|
|
340
|
-
${t.lede?`<p class="lede">${
|
|
341
|
+
<h1>${mt(s)}</h1>
|
|
342
|
+
${t.lede?`<p class="lede">${sn(t.lede)}</p>`:""}
|
|
341
343
|
</div>
|
|
342
344
|
<div class="pills">${r}<button class="theme" id="themeBtn" type="button">Theme</button></div>
|
|
343
345
|
</header>
|
|
344
346
|
${o}
|
|
345
|
-
${t.after?
|
|
346
|
-
${t.footer?`<footer>${
|
|
347
|
+
${t.after?lc(t.after):""}
|
|
348
|
+
${t.footer?`<footer>${sn(t.footer)}</footer>`:""}
|
|
347
349
|
</div>
|
|
348
|
-
${
|
|
349
|
-
${
|
|
350
|
+
${ac} type="application/json" id="diagram-steps">${fc(n).replace(/</g,"\\u003c")}<\/script>
|
|
351
|
+
${ac}>
|
|
350
352
|
(function(){
|
|
351
353
|
var root=document.documentElement, m=/theme=(light|dark)/.exec(location.hash);
|
|
352
354
|
try{var t=localStorage.getItem('diagram-theme'); if(t) root.dataset.theme=t;}catch(e){}
|
|
@@ -358,14 +360,49 @@ ${zl}>
|
|
|
358
360
|
});
|
|
359
361
|
})();
|
|
360
362
|
<\/script>
|
|
361
|
-
${e.runtime?`${
|
|
363
|
+
${e.runtime?`${ac}>${e.runtime}<\/script>`:""}
|
|
362
364
|
${e.extraBody??""}
|
|
363
365
|
</body>
|
|
364
366
|
</html>
|
|
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
|
-
|
|
367
|
+
`}function dc(){let n=globalThis;return{now:()=>performance.now(),next(e){let t={},s=()=>{t.raf!==void 0&&n.cancelAnimationFrame?.(t.raf),clearTimeout(t.timer),e()};return t.raf=n.requestAnimationFrame?.(s),t.timer=setTimeout(s,t.raf===void 0?16:100),t},cancel(e){let t=e;t.raf!==void 0&&n.cancelAnimationFrame?.(t.raf),clearTimeout(t.timer)}}}var Dp=400;function sa(n,e={}){let t=e.clock??dc(),s=n,r=0,o=g(e.rate??1),i=e.loop??!1,l=!1,a=!0,c=!1,f=(e.ambient??s.ambient)==="on",u=f?0:"off",d,h=0,b=s.beatAt(0),m=!1,y=0,N,p={};function g(R){if(!(Number.isFinite(R)&&R>0))throw new Error("rate is a number over 0");return R}let x=R=>Math.max(0,Math.min(s.duration,R));function $(R,...I){for(let G of[...p[R]??[]])G(...I)}let E=()=>a&&!c&&(l||f&&s.loops);function v(){E()?d===void 0&&(h=t.now(),d=t.next(M)):d!==void 0&&(t.cancel(d),d=void 0)}function A(R,I){let G=y;for(let X of s.beats)if(!(X.start<=R||X.start>I||X.index===b?.index)&&(b=X,m=!0,$("beat",X,"play"),y!==G))return!1;return!0}function L(R){if(!l){$("time",r,"ambient");return}let I=r,G=r+R,X=y;if(N!==void 0&&G>=N){if(r=N,!A(I,r))return;N=void 0,l=!1,$("time",r,"play"),y===X&&$("pause");return}if(G<s.duration){r=G,A(I,r)&&$("time",r,"play");return}if(i){if(!A(I,s.duration)||(r=G%s.duration,f&&(u=r),b=void 0,$("loop"),y!==X))return;let U=s.beatAt(0);if(U&&(b=U,$("beat",U,"play"),y!==X||!A(U.start,r)))return;$("time",r,"play");return}r=s.duration,A(I,r)&&(l=!1,$("time",r,"play"),y===X&&($("pause"),y===X&&$("end")))}function M(){d=void 0;let R=t.now(),I=Math.max(0,R-h)*o;h=R,f&&u!=="off"&&(u+=I),L(I),d===void 0&&E()&&(d=t.next(M))}function P(R,I=!1){let G=s.beatAt(r);y++;let X=y,U=G?.name!==b?.name||G?.index!==b?.index;b=G,!(G&&(U||I)&&(m=!0,$("beat",G,R),y!==X))&&$("time",r,R)}function k(R,I={}){if(c||!Number.isFinite(R))return;let G=x(R);f&&u!=="off"&&(u=I.join?G:u+G-r),r=G,h=t.now(),N!==void 0&&r>=N&&(N=void 0),P("seek"),v()}function O(){c||(r=0,f&&(u=0),N=void 0,h=t.now(),P("seek",!0),v())}let w={get timeline(){return s},get duration(){return s.duration},get time(){return r},get ambientTime(){return u},get playing(){return l},get beat(){return b},get cue(){return s.cues(r)},get rate(){return o},set rate(R){let I=g(R);I!==o&&(o=I,$("rate",I))},get loop(){return i},set loop(R){i=R},get ambient(){return f},set ambient(R){c||R===f||(f=R,f&&u==="off"&&(u=b?.start??0),v(),$("ambient",f),$("time",r,"ambient"))},get active(){return a},set active(R){R!==a&&(a=R,v())},state:()=>s.at(r,{ambient:u}),play(R={}){c||l||s.duration<=0||(r>=s.duration&&R.until===void 0&&O(),N=R.until!==void 0&&R.until>r&&R.until<=s.duration?R.until:void 0,!(R.until!==void 0&&N===void 0)&&(l=!0,h=t.now(),v(),$("play"),l&&!m&&b&&(m=!0,$("beat",b,"play"))))},pause(){l&&(l=!1,N=void 0,y++,v(),$("pause"))},toggle(){l?w.pause():w.play()},seek:k,seekBeat(R){let I=typeof R=="number"?s.beats[R]?.start:s.beats.find(G=>G.name===R)?.start;return I===void 0?!1:(k(I),!0)},next(){let R=s.beats.find(I=>I.start>r);k(R?R.start:s.duration)},prev(){let R=[...s.beats].reverse().find(I=>I.start<r-Dp);k(R?R.start:0)},restart:O,rebind(R){if(c||!R.ok)return!1;N=void 0;let I=s.beatAt(r),G=I?(r-I.start)/Math.max(1,I.end-I.start):0,X=u==="off"?0:u-r,U=s;if(s=R,I){let B=R.beats.find(H=>H.name===I.name);if(B)r=B.start+G*(B.end-B.start);else{let H=U.beats.filter(Y=>Y.index<I.index).reverse().map(Y=>R.beats.find(ee=>ee.name===Y.name)).find(Boolean);r=H?H.start:0}}return r=x(r),f&&u!=="off"&&(u=r+X),h=t.now(),P("rebind"),v(),!0},on(R,I){let G=p[R]??=new Set;return G.add(I),()=>{G.delete(I)}},dispose(){c=!0,y++,l=!1,d!==void 0&&t.cancel(d),d=void 0;for(let R of Object.keys(p))p[R].clear()}};return v(),w}function re(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,l]of Object.entries(o))s.addEventListener(i,l);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 oa=new Map;function Yu(){let n,e=.35;for(let[t,s]of oa)s.wants&&s.seen>=e&&(s.seen>e||!n)&&(n=t,e=s.seen);for(let[t,s]of oa)s.wants&&s.auto(t===n)}var Wu=n=>{let e=new DOMParser().parseFromString(n,"image/svg+xml");if(e.documentElement.localName!=="svg")throw new Error("the drawing is not SVG");return document.importNode(e.documentElement,!0)},ra=n=>{let e=Math.round(n/1e3);return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`},Ju={ok:!0,diags:[],duration:0,beats:[],markers:{},ambient:"on",loops:!1,at:()=>({}),cues:()=>{},beatAt:()=>{},startOf:()=>{}};function _p(n){let e={...n.camera?{camera:n.camera}:{},...n.variants?{variants:n.variants}:{}};for(let t of["items","labels","routes"]){let s=Object.entries(n[t]??{}).filter(([,r])=>r.opacity===0).map(([r])=>[r,{opacity:0}]);s.length&&(e[t]=Object.fromEntries(s))}return e}function Xu(n,e){if(e.timeline&&!e.timeline.ok)throw new Error(`the motion has faults: ${e.timeline.diags.map(V=>`${V.path}: ${V.message}`).join("; ")}`);let t=e.scene,s=Wu(t.rendered.svg),r,o,i=!1,l=!1,a=sa(e.timeline??Ju,{loop:e.loop,rate:e.rate,ambient:e.ambient,clock:e.clock}),c=e.controls??!0,f=e.reducedMotion==="respect"&&typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,u=f,d=(V,te,ae,Ee)=>re("button",{type:"button",class:`iso-play-btn ${V}`,"aria-label":te,title:te,on:{click:Ee}},ae),h=re("div",{class:"iso-play-stage"},s),b=d("back","Back","\u2039",()=>le(()=>W(Math.max(0,q()-1)))),m=d("play","Play","\u25B6",()=>oe()),y=d("next","Next","\u203A",()=>le(()=>W(Math.min(a.timeline.beats.length-1,q()+1)))),N=d("again","Reset","\u21BA",()=>le(()=>{fe(),a.restart()})),p=d("ambient","Ambient motion","\u223F",()=>{Z(),a.ambient=!a.ambient,ee()}),g=re("input",{type:"range",class:"iso-play-bar",min:0,step:1,"aria-label":"Time",on:{input:(()=>le(()=>{fe(),a.seek(Number(g.value))}))}}),x=re("span",{class:"iso-play-time"}),$=re("div",{class:"iso-play-dots"}),E=re("span",{class:"iso-play-num"}),v=re("span",{class:"iso-play-title"}),A=re("span",{class:"iso-play-chapter"}),L=re("span",{class:"iso-play-count"}),M=re("div",{class:"iso-play-text"}),P=re("pre",{class:"iso-play-code"}),k=re("dl",{class:"iso-play-facts"}),O=re("div",{class:"iso-play-say","aria-live":"polite"},re("div",{class:"iso-play-head"},E,v,A,L),M,P,k),w=re("details",{class:"iso-play-list"}),R=re("div",{class:"iso-play-row"},b,m,y,N,p,g,x),I=re("div",{class:"iso-play",role:"group","aria-roledescription":"animated diagram","aria-label":e.label??"Diagram",tabindex:c?0:void 0,"data-mode":e.mode??"light"},h,c&&R,c&&$,c&&O,c&&w);n.append(I);let G=[];function X(){let V=a.timeline.beats,te=V.length>0,ae=V.some(Ne=>Ne.say);G=[],$.replaceChildren();let Ee,ye;for(let Ne of V){(!Ee||Ne.say?.chapter!==ye)&&(Ee=re("span",{class:"iso-play-group",role:"group","aria-label":Ne.say?.chapter,title:Ne.say?.chapter}),$.append(Ee),ye=Ne.say?.chapter);let Oe=re("button",{type:"button",class:"iso-play-dot","aria-label":`Step ${Ne.index+1}: ${Ne.say?.title??Ne.name}`,title:Ne.say?.title??Ne.name,on:{click:(()=>le(()=>W(Ne.index)))}});Ee.append(Oe),G.push(Oe)}w.replaceChildren(re("summary",null,`All ${V.length} steps as text`),re("ol",null,...V.map(Ne=>re("li",null,...U(Ne)))));for(let Ne of[b,y,$])Ne.hidden=!te;O.hidden=!ae,w.hidden=!ae,p.hidden=!a.timeline.loops,g.max=String(Math.round(a.duration));for(let Ne of[m,N,g,x])Ne.hidden=a.duration<=0;B=void 0}function U(V){let te=V.say,ae=[re("b",null,te?.title??V.name)];if(te?.text){let Ee=re("div",null);Ee.innerHTML=sn(te.text),ae.push(Ee)}return te?.code&&ae.push(re("code",null,te.code)),te?.facts?.length&&ae.push(re("span",null,te.facts.map(([Ee,ye])=>`${Ee}: ${ye}`).join(" \xB7 "))),ae}let B;function H(V){let te=String((V?.index??-1)+1);for(let ae of s.querySelectorAll("[data-badge]"))ae.classList.toggle("on",ae.getAttribute("data-badge")===te),e.steps&&(ae.getAttribute("data-badge")===te||u?ae.removeAttribute("opacity"):ae.setAttribute("opacity","0.14"));if(e.steps)for(let ae of s.querySelectorAll("[data-step]"))ae.setAttribute("visibility",ae.getAttribute("data-step")===te&&!u?"visible":"hidden")}function Y(){let V=a.beat;if(V===B||(B=V,H(V),!c))return;let te=V?.say;E.textContent=V?String(V.index+1):"",E.style.backgroundColor=te?.color??"",v.textContent=te?.title??V?.name??"",A.textContent=te?.chapter??"",L.textContent=V?`${V.index+1} / ${a.timeline.beats.length}`:"",M.innerHTML=sn(te?.text),P.textContent=te?.code??"",k.replaceChildren(...(te?.facts??[]).flatMap(([ae,Ee])=>[re("dt",null,ae),re("dd",null,Ee)])),P.hidden=!te?.code,k.hidden=!te?.facts?.length,G.forEach((ae,Ee)=>{ae.classList.toggle("on",Ee===V?.index),ae.classList.toggle("done",V!==void 0&&Ee<V.index),Ee===V?.index?ae.setAttribute("aria-current","step"):ae.removeAttribute("aria-current")})}function ee(){let V=r!==void 0?a.timeline.at(r,{ambient:r}):u?_p(a.timeline.at(a.duration,{ambient:"off"})):a.state();Li(s,V,t.rendered,{styles:"cssom"}),I.dataset.time=String(Math.round(r??a.time)),r!==void 0?H(a.timeline.beatAt(r)):Y(),c&&(g.value=String(Math.round(a.time)),g.setAttribute("aria-valuetext",`${ra(a.time)} of ${ra(a.duration)}${a.beat?`, ${a.beat.say?.title??a.beat.name}`:""}`),x.textContent=`${ra(a.time)} / ${ra(a.duration)}`)}function F(){let V=K();m.textContent=V?"\u275A\u275A":"\u25B6",m.setAttribute("aria-label",V?"Pause":"Play"),m.title=V?"Pause":"Play",p.setAttribute("aria-pressed",String(a.ambient)),O.setAttribute("aria-live",V?"off":"polite"),I.dataset.playing=String(V)}let K=()=>a.playing&&o===void 0,q=()=>a.beat?.index??0;function Z(){u&&(u=!1,B=void 0)}function le(V){Z(),i=!0,V(),F(),ee()}function fe(){o=void 0,a.pause()}function W(V){let te=a.timeline.beats[V];if(!te||l)return;a.pause(),a.seek(te.start,{join:!0});let ae=a.timeline.beats[V+1]?.start??1/0;o=Math.max(te.start,Math.min(te.end,ae,a.duration)-1),a.play({until:o})}function oe(){Z(),K()?(i=!0,fe()):(i=!1,o=void 0,a.pause(),a.play()),F(),ee()}a.on("time",ee),a.on("play",F),a.on("ambient",F),a.on("pause",()=>{o=void 0,F()}),I.addEventListener("keydown",V=>{let te=V.key,ae=V.target;V.altKey||V.ctrlKey||V.metaKey||ae===g||(te==="ArrowRight"||te==="ArrowLeft"?(V.preventDefault(),(te==="ArrowRight"?y:b).click()):te==="Home"?(V.preventDefault(),N.click()):(te===" "||te==="k")&&ae===I&&(V.preventDefault(),oe()))});let Me=V=>{let te=V.target.closest?.("[data-go]"),ae=V.key;!te||V.type==="keydown"&&ae!=="Enter"&&ae!==" "||(V.preventDefault(),V.stopPropagation(),le(()=>W(Number(te.getAttribute("data-go"))-1)))};h.addEventListener("click",Me),h.addEventListener("keydown",Me);let Le={seen:0,wants:e.autoplay==="visible"&&!f,auto(V){V?!i&&!K()&&(o=void 0,a.play()):K()&&(o=void 0,a.pause())}};oa.set(I,Le);let C=typeof IntersectionObserver=="function"?new IntersectionObserver(V=>{for(let te of V)Le.seen=te.isIntersecting?te.intersectionRatio:0,r===void 0&&(a.active=te.isIntersecting);Yu()},{threshold:[0,.2,.35,.5,.7,.9,1]}):void 0;return C?.observe(I),X(),F(),ee(),e.autoplay===!0&&!f&&a.play(),{root:I,transport:a,step:V=>le(()=>W(V)),set(V,te=Ju,ae){if(l||!te.ok)return!1;let Ee=Wu(V.rendered.svg);return t=V,s.replaceWith(Ee),s=Ee,ae&&(I.dataset.mode=ae),o!==void 0&&fe(),a.rebind(te),X(),F(),ee(),!0},freeze(V){r=V,a.pause(),a.active=!1,I.classList.add("frozen"),ee()},dispose(){l=!0,C?.disconnect(),oa.delete(I),a.dispose(),I.remove(),Yu()}}}var Qu=`
|
|
368
|
+
.iso-play{--ip-ink:#1c2026;--ip-muted:#68707c;--ip-line:#dfe3e8;--ip-bg:#fff;--ip-code:#f2f4f7;--ip-focus:#2a64d6;container:iso-play/inline-size;display:block;color:var(--ip-ink);background:var(--ip-bg);font:14px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;border-radius:10px}
|
|
369
|
+
.iso-play[data-mode="dark"]{--ip-ink:#e6e9ee;--ip-muted:#98a1ae;--ip-line:#333a44;--ip-bg:#15181d;--ip-code:#1f242b;--ip-focus:#7aa7ff;color-scheme:dark}
|
|
370
|
+
.iso-play:focus-visible,.iso-play button:focus-visible,.iso-play input:focus-visible,.iso-play summary:focus-visible{outline:2px solid var(--ip-focus);outline-offset:2px}
|
|
371
|
+
.iso-play [hidden]{display:none}
|
|
372
|
+
.iso-play-stage svg{display:block;width:100%;height:auto}
|
|
373
|
+
.iso-play-stage [data-go]{cursor:pointer}
|
|
374
|
+
.iso-play-row{display:flex;align-items:center;gap:6px;padding:8px 12px 4px}
|
|
375
|
+
.iso-play-btn{font:inherit;min-width:32px;height:32px;padding:0 8px;border:1px solid var(--ip-line);border-radius:8px;background:none;color:inherit;cursor:pointer}
|
|
376
|
+
.iso-play-btn:hover{border-color:var(--ip-muted)}
|
|
377
|
+
.iso-play-btn.play{background:var(--ip-ink);color:var(--ip-bg);border-color:var(--ip-ink);min-width:44px}
|
|
378
|
+
.iso-play-btn.ambient[aria-pressed="false"]{color:var(--ip-muted);text-decoration:line-through}
|
|
379
|
+
.iso-play-bar{flex:1 1 60px;min-width:0;accent-color:var(--ip-ink)}
|
|
380
|
+
.iso-play-time{color:var(--ip-muted);font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap}
|
|
381
|
+
.iso-play-dots{display:flex;flex-wrap:wrap;gap:4px 12px;padding:2px 12px}
|
|
382
|
+
.iso-play-group{display:inline-flex;gap:0}
|
|
383
|
+
.iso-play-dot{width:24px;height:24px;padding:0;border:0;background:none;cursor:pointer;display:grid;place-items:center}
|
|
384
|
+
.iso-play-dot::before{content:"";width:9px;height:9px;border-radius:50%;background:var(--ip-line)}
|
|
385
|
+
.iso-play-dot.done::before{background:var(--ip-muted)}
|
|
386
|
+
.iso-play-dot.on::before{background:var(--ip-ink);width:11px;height:11px}
|
|
387
|
+
.iso-play-say{padding:4px 12px 10px;min-height:5.2em}
|
|
388
|
+
.iso-play-head{display:flex;align-items:baseline;gap:8px;font-weight:700}
|
|
389
|
+
.iso-play-num{flex:none;display:inline-grid;place-items:center;min-width:22px;height:22px;border-radius:11px;background:var(--ip-ink);color:var(--ip-bg);font-size:11px;align-self:center}
|
|
390
|
+
.iso-play-chapter,.iso-play-count{color:var(--ip-muted);font-size:12px;font-weight:500}
|
|
391
|
+
.iso-play-count{margin-left:auto;white-space:nowrap}
|
|
392
|
+
.iso-play-text{max-width:80ch}
|
|
393
|
+
.iso-play-text a{color:inherit}
|
|
394
|
+
.iso-play-code{margin:6px 0 0;padding:6px 10px;border-radius:8px;background:var(--ip-code);font:12px/1.5 ui-monospace,Menlo,monospace;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
395
|
+
.iso-play-facts{display:flex;flex-wrap:wrap;gap:2px 16px;margin:6px 0 0;font-size:12px}
|
|
396
|
+
.iso-play-facts dt{color:var(--ip-muted)}
|
|
397
|
+
.iso-play-facts dd{margin:0 8px 0 -10px;font-weight:600}
|
|
398
|
+
.iso-play-list{padding:0 12px 10px;font-size:13px}
|
|
399
|
+
.iso-play-list summary{color:var(--ip-muted);cursor:pointer}
|
|
400
|
+
.iso-play.frozen>:not(.iso-play-stage){display:none}
|
|
401
|
+
@container iso-play (max-width:420px){.iso-play-time{display:none}.iso-play-row{flex-wrap:wrap}.iso-play-bar{flex-basis:100%;order:9}}
|
|
402
|
+
`;var Zu=1,ia="(?:[^/:%\\s]|%[0-9A-F]{2})+",Wt=["debug","info","notice","warning","error"],ed=["1m","1h","1d"],gn={"1m":6e4,"1h":36e5,"1d":864e5},aa=n=>`^(?:(?:${n.kinds.join("|")}):(?:${ia})(?:/(?:${n.kinds.join("|")}):(?:${ia}))*)?$`;function la(n){let e=new RegExp(aa(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 l=i.indexOf(":");return{kind:i.slice(0,l),name:decodeURIComponent(i.slice(l+1))}})}function r(o){let i="";for(let l of s(o)){if(!n.parents[l.kind].includes(i))return!1;i=l.kind}return!0}return{isScope:t,parseScope:s,wellNested:r}}var ca=n=>n.replace(/[%/:\s]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`),td=n=>n.map(e=>`${e.kind}:${ca(e.name)}`).join("/"),nd=(n,e,t)=>(n?`${n}/`:"")+`${e}:${ca(t)}`,Ct=n=>n===""?0:n.split("/").length;function ts(n,e){return e<=0?"":(n===""?[]:n.split("/")).slice(0,e).join("/")}var sd=n=>ts(n,Ct(n)-1),Jt=(n,e)=>e===""||n===e||n.startsWith(`${e}/`),rd=(n,e)=>n!==""&&n.split("/").includes(e),mr=n=>n===""?"fleet":n.slice(n.lastIndexOf("/")+1).split(":")[0],pr=n=>n===""?"all hosts":decodeURIComponent(n.slice(n.lastIndexOf("/")+1).split(":").slice(1).join(":"));function hr(n){let e=[{scope:"",label:"all hosts",kind:"fleet"}];for(let t=1;t<=Ct(n);t++){let s=ts(n,t);e.push({scope:s,label:pr(s),kind:mr(s)})}return e}var mc=["kind","source","severity","scope","since","before"];function zp(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="",l=!1;if(n[t]==='"'){let a=n.indexOf('"',t+1);i=n.slice(t+1,a<0?n.length:a),l=!0,t=a<0?n.length:a+1}else{let a=t;for(;t<n.length&&!/\s/.test(n[t]);)t++;i=n.slice(a,t)}e.push({neg:s,raw:i,quoted:l,field:o})}return e}var Kp=/^(\d+)(s|m|h|d|w)$/,Vp={s:1e3,m:6e4,h:36e5,d:864e5,w:7*864e5};function pc(n,e){let t=Kp.exec(n);if(t)return e-Number(t[1])*Vp[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,l="0",a="0",c="0",f="0",u]=s;if(u){let h=Date.parse(n.replace(" ","T"));return Number.isNaN(h)?void 0:h}let d=new Date(+r,+o-1,+i,+l,+a,+c,+f.padEnd(3,"0")).getTime();return Number.isNaN(d)?void 0:d}function Gp(n,e,t=Date.now()){let s=[],r=[];for(let o of zp(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 a=o.field;if(a==="severity"){let c=/^(>=|<=|>|<|=)?(.*)$/.exec(o.raw);if(!Wt.includes(c[2])){i(`no severity ${c[2]} (${Wt.join(", ")})`);continue}s.push({neg:o.neg,field:a,op:c[1]??"=",value:c[2]})}else if(a==="since"||a==="before"){let c=pc(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(`-${a} isn't allowed (use ${a==="since"?"before":"since"})`);continue}s.push({neg:!1,field:a,value:o.raw,time:c})}else s.push({neg:o.neg,field:a,value:o.raw})}return{terms:s,warnings:r}}var fa=n=>Wt.indexOf(n),qp={"=":"eq",">=":"ge",">":"gt","<=":"le","<":"lt"};function Up(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:qp[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 Hp(n,e){let t=[],s=new Map;for(let r of e.terms){let o=Up(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,l=s.get(i);if(l)l.any.push(o);else{let a={any:[o]};s.set(i,a),t.push(a)}}return{all:t}}function Yp(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=fa(t.severity),o=fa(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"?Jt(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 gr(n){let e=[...mc,...n.links],t=(l,a=Date.now())=>Gp(e,l,a),s=l=>Hp(n,l);function r(l,a,c,f){let u=t(l,a);return{where:s(u),...fo(u,c,f),warnings:u.warnings}}function o(l,a=[]){let c=new Set(a),f=l?.all??[];return f.length?u=>f.every(d=>d.any.some(h=>Yp(n,h,u,c))!==!!d.not):()=>!0}return{FIELDS:e,parseSearch:t,toAst:s,compileSearch:r,matchAst:o,matcher:(l,a=[])=>o(s(l),a)}}function fo(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 uo(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 l=t.indexOf(i);l>=0;l=t.indexOf(i,l+i.length))s.push([l,l+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 od=n=>Wt.filter(e=>fa(e)>=fa(n));var id=new Map,ua=new Map;function Dt(n,e){if(!n||n==="UTC")return 0;let t=`${n}|${Math.floor(e/(15*6e4))}`,s=ua.get(t);if(s!==void 0)return s;let r=id.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}id.set(n,r)}let o={};for(let a of r.formatToParts(new Date(e)))a.type!=="literal"&&(o[a.type]=Number(a.value));let i=Date.UTC(o.year,o.month-1,o.day,o.hour%24,o.minute,o.second),l=Math.round((i-Math.floor(e/1e3)*1e3)/6e4)*6e4;return ua.size>5e4&&ua.clear(),ua.set(t,l),l}var ad=n=>{try{return new Intl.DateTimeFormat("en-US",{timeZone:n}),!0}catch{return!1}};function Rs(n,e,t){if(e==="1m")return Math.floor(n/6e4)*6e4;let s=Dt(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-Dt(t,r-s);return o>n?o=r-864e5-Dt(t,r-864e5-s):da(o,t)<=n&&(o=da(o,t)),o}function da(n,e,t="1d"){if(t==="1m")return n+6e4;if(t==="1h")return n+36e5;let s=Dt(e,n),r=Math.floor((n+s)/864e5)*864e5+864e5;return r-Dt(e,r-s)}var hs=6e4,gs=36e5,bn=864e5;function ma(n,e,t,s={}){let r=Math.max((s.minFrac??.15)*(t-e),s.minMs??10*hs),o=n.filter(([a,c])=>c>=e&&a<t).map(([a,c])=>[Math.max(e,a),Math.min(t,Math.max(a,c))]).sort((a,c)=>a[0]-c[0]),i=[];if(!o.length)return i;let l=e;for(let[a,c]of o)a-l>r&&i.push({from:l,to:a}),l=Math.max(l,c);return t-l>r&&i.push({from:l,to:t}),i}function Ps(n){if(n>=bn){let e=Math.floor(n/bn),t=Math.round((n-e*bn)/gs);return t?`${e} d ${t} h`:`${e} d`}if(n>=gs){let e=Math.floor(n/gs),t=Math.round((n-e*gs)/hs);return t&&e<10?`${e} h ${t} min`:`${e} h`}return`${Math.max(1,Math.round(n/hs))} min`}var Cs=n=>`${n.from}-${n.to}`;function br(n,e,t,s=[],r={}){let o=r.cut??24,i=Math.max(1,t),l=Math.max(1,e-n),a=s.filter(g=>g.to>n&&g.from<e).map(g=>({from:Math.max(n,g.from),to:Math.min(e,g.to),w:r.weights?.get(Cs(g))??0})).sort((g,x)=>g.from-x.from),c=a.reduce((g,x)=>g+(x.to-x.from)*(1-x.w),0),f=a.reduce((g,x)=>g+(1-x.w)*o,0),u=(i-f)/Math.max(1,l-c);if(!(u>0)||f>i*.6)return br(n,e,t,[],r);let d=[[n,0]],h=0,b=n,m=[];for(let g of a){h+=(g.from-b)*u,d.push([g.from,h]);let x=(1-g.w)*o+g.w*u*(g.to-g.from);m.push({from:g.from,to:g.to,x0:h,x1:h+x,weight:g.w}),h+=x,d.push([g.to,h]),b=g.to}d.push([e,h+(e-b)*u]);let y=g=>{if(g<=n)return(g-n)*u;if(g>=e)return d[d.length-1][1]+(g-e)*u;let x=0,$=d.length-1;for(;$-x>1;){let M=x+$>>1;d[M][0]<=g?x=M:$=M}let[E,v]=d[x],[A,L]=d[$];return A===E?v:v+(g-E)/(A-E)*(L-v)},N=g=>m.find(x=>x.weight<1&&g>x.x0&&g<x.x1);return{t0:n,t1:e,width:i,cuts:m,x:y,t:g=>{let x=N(g);if(x)return g-x.x0<x.x1-g?x.from:x.to;if(g<=0)return n+g/u;let $=0,E=d.length-1;if(g>=d[E][1])return e+(g-d[E][1])/u;for(;E-$>1;){let P=$+E>>1;d[P][1]<=g?$=P:E=P}let[v,A]=d[$],[L,M]=d[E];return M===A?v:v+(g-A)/(M-A)*(L-v)},cutAt:N,msPerPx:1/u}}var hc=[1e3,5e3,15e3,3e4,hs,5*hs,15*hs,30*hs,gs,3*gs,6*gs,12*gs,bn,2*bn,7*bn,14*bn,28*bn];function pa(n,e,t=80){let s=hc.find(a=>a/n.msPerPx>=t)??hc[hc.length-1],r=[],o=a=>{let c=new Date(a+Dt(e,a)),f=String(c.getUTCHours()).padStart(2,"0"),u=String(c.getUTCMinutes()).padStart(2,"0"),d=String(c.getUTCSeconds()).padStart(2,"0"),h=`${c.getUTCDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][c.getUTCMonth()]}`,b=f==="00"&&u==="00"&&d==="00";return s>=bn||b?{label:h,major:!0}:{label:s<hs?`${f}:${u}:${d}`:`${f}:${u}`,major:!1}},i=[],l=n.t0;for(let a of n.cuts)a.weight<1&&(i.push([l,a.from]),l=a.to);i.push([l,n.t1]);for(let[a,c]of i){let f=d=>d-Dt(e,d-Dt(e,d)),u=Math.ceil((a+Dt(e,a))/s)*s;s>=7*bn&&(u=Math.ceil((a+Dt(e,a))/bn)*bn);for(let d=0,h=f(u);h<c&&d<2e3;d++,u+=s,h=f(u)){if(h<a)continue;let b=n.x(h),m=r[r.length-1];(!m||b-m.x>=t*.6)&&r.push({t:h,x:b,...o(h)})}}return r}var Wp=["id","time","t","dur","scope","source","kind","severity","summary"],Jp=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},ld=(n,e)=>e.size?{...n,attrs:Object.fromEntries(Object.entries(n.attrs).filter(([t])=>!e.has(`${n.source}.${t}`)))}:n;function ha(n,e=[]){let t=new Set(e);return JSON.stringify(n.map(s=>ld(s,t)),null,2)+`
|
|
403
|
+
`}function ga(n,e=[]){let t=new Set(e),s=n.map(a=>ld(a,t)),r=[...new Set(s.flatMap(a=>Object.keys(a.attrs)))].sort(),o=[...new Set(s.flatMap(a=>Object.keys(a.links)))].sort(),i=[...Wp,...r.map(a=>`attr.${a}`),...o.map(a=>`link.${a}`)],l=s.map(a=>[a.id,new Date(a.t).toISOString(),a.t,a.dur,a.scope,a.source,a.kind,a.severity,a.summary,...r.map(c=>a.attrs[c]),...o.map(c=>a.links[c])].map(Jp).join(","));return[i.join(","),...l].join(`\r
|
|
367
404
|
`)+`\r
|
|
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=`
|
|
405
|
+
`}var Xp=864e5,In=36e5,ba=(n,e)=>n.t-e.t||(n.id<e.id?-1:n.id>e.id?1:0);function Un(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 ud=(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 cd(n,e,t){let s=[];for(let r of n){let o=Rs(r.t,e,t),i=s[s.length-1];i&&i.t===o?ud(i,r):s.push({t:o,min:r.min,max:r.max,sum:r.sum,count:r.count})}return s}function gc(n,e,t,s){for(let i=Un(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=Un(n,e.t);for(;o<n.length&&s(n[o],e)<0;)o++;n.splice(o,0,e)}function fd(n,e,t){for(let s=Un(n,e);s<n.length&&n[s].t===e;s++)if(t(n[s])){n.splice(s,1);return}}function dd(n,e,t={}){let s=n.catalog,{isScope:r}=la(e),{parseSearch:o,matchAst:i,toAst:l}=gr(e),a=C=>Object.fromEntries(e.flags.filter(V=>C?.[V]).map(V=>[V,!0])),c=t.now??s.now,f=(s.names??[]).flatMap(C=>(C.aliases??[]).map(V=>[V,C.scope])).sort((C,V)=>V[0].length-C[0].length),u=new Map,d=C=>{if(!f.length)return C;let V=u.get(C);if(V===void 0){let te=f.find(([ae])=>Jt(C,ae));V=te?te[1]+C.slice(te[0].length):C,u.set(C,V)}return V},h=new Map((s.names??[]).map(C=>[C.scope,C])),b=C=>f.length?{...C,scope:d(C.scope)}:C,m=C=>`${C.source}\0${C.id}`,y=n.events.map(b).sort(ba),N=new Map;for(let C of y)N.set(m(C),C);let p=y.filter(C=>C.dur!==void 0&&!C.open),g=p.reduce((C,V)=>Math.max(C,V.dur),0),x=new Map;for(let C of y)C.open&&x.set(m(C),C);let $=new Map,E=new Set,v=C=>{for(let V=Ct(C);V>=1;V--){let te=ts(C,V);if(E.has(te))break;E.add(te)}},A=new Map;for(let C of s.sources)for(let V of C.series)A.set(V.name,V.type);let L=s.sources.flatMap(C=>(C.sensitive??[]).map(V=>`${C.name}.${V}`)),M=new Map;for(let C of s.sources)M.set(C.name,{events:C.defaultRetention.events,rollups:{...C.defaultRetention.rollups},setBy:"default"});for(let C of s.retention)M.set(C.source,{events:C.events,rollups:{...C.rollups},setBy:C.setBy});let P=new Map;for(let C of s.sources)for(let V of C.series)P.set(V.name,C.name);function k(C){let V=d(C.scope),te=`${C.series}\0${V}`,ae=$.get(te);ae||(ae={series:C.series,scope:V,fine:[],cache:new Map},$.set(te,ae),v(V));let Ee="value"in C?{t:C.t,min:C.value,max:C.value,sum:C.value,count:1}:{t:C.t,min:C.min,max:C.max,sum:C.sum,count:C.count};gc(ae.fine,Ee,ye=>ye.t===Ee.t,(ye,Ne)=>ye.t-Ne.t),ae.cache.clear()}for(let C of y)v(C.scope);for(let C of n.metrics)k(C);let O=new Map,w=new Set,R=(C,V)=>{w.add(C.source);let te=O.get(C.scope);te||O.set(C.scope,te=new Map);let ae=te.get(C.source);ae||te.set(C.source,ae=new Map);let Ee=Math.floor(C.t/In)*In,ye=ae.get(Ee);if(ye||ae.set(Ee,ye={t:Ee,count:0,severity:{},kinds:{},first:1/0,last:-1/0}),ye.count+=V,V>0)ye.first=Math.min(ye.first,C.t),ye.last=Math.max(ye.last,C.t);else if(C.t===ye.first||C.t===ye.last){ye.first=1/0,ye.last=-1/0;for(let Ne=Un(y,Ee);Ne<y.length&&y[Ne].t<Ee+In;Ne++){let Oe=y[Ne];Oe.scope===C.scope&&Oe.source===C.source&&(ye.first=Math.min(ye.first,Oe.t),ye.last=Math.max(ye.last,Oe.t))}}ye.severity[C.severity]=(ye.severity[C.severity]??0)+V,ye.kinds[C.kind]=(ye.kinds[C.kind]??0)+V,ye.severity[C.severity]===0&&delete ye.severity[C.severity],ye.kinds[C.kind]===0&&delete ye.kinds[C.kind],ye.count||ae.delete(Ee)};for(let C of y)R(C,1);let I=(C,V,te)=>{let ae=`${V}|${te??""}`,Ee=C.cache.get(ae);return Ee||(Ee=V==="1d"?cd(I(C,"1h",te),"1d",te):cd(C.fine,V,te),C.cache.set(ae,Ee)),Ee},G=C=>C===null?-1/0:c-C*Xp,X=C=>G(M.get(C)?.events??null),U=(C,V)=>{let te=M.get(C);return G(te?V?te.rollups[V]:te.events:null)};function B(C){let V=[];for(let te of new Set(C)){let ae=M.get(te);if(!ae)continue;let Ee=y.find(we=>we.source===te&&we.t>=X(te))?.t,ye=we=>{let Fe=1/0;for(let qe of $.values())if(P.get(qe.series)===te){let De=(we?I(qe,we):qe.fine).find(Qe=>Qe.t>=U(te,we));De&&De.t<Fe&&(Fe=De.t)}return Fe===1/0?void 0:Fe},Ne=[Ee,ye()].filter(we=>we!==void 0),Oe={};for(let we of["1m","1h","1d"]){let Fe=ye(we)??(Ee!==void 0&&Ee>=U(te,we)?Ee:void 0);Fe!==void 0&&(Oe[we]=Math.max(Fe,U(te,we)))}V.push({source:te,events:ae.events,rollups:{...ae.rollups},setBy:ae.setBy,keptFrom:{...Ne.length?{events:Math.min(...Ne)}:{},rollups:Oe}})}return V}function H(C){let V=C.where,te={from:C.from,to:C.to},ae=[];if(!V&&C.q){let De=o(C.q,c);V=l(De),te=fo(De,C.from,C.to),ae=De.warnings}let Ee=i(V,L),ye=C.filters??{},Ne=ye.source?.length?new Set(ye.source):void 0,Oe=ye.kind?.length?new Set(ye.kind):void 0,we=ye.severity?.length?new Set(ye.severity):void 0,Fe=ye.scope?.length?ye.scope:void 0;return{test:De=>Jt(De.scope,C.scope)&&(!Ne||Ne.has(De.source))&&(!Oe||Oe.has(De.kind))&&(!we||we.has(De.severity))&&(!Fe||Fe.some(Qe=>Jt(De.scope,Qe)))&&De.t>=X(De.source)&&Ee(De),range:te,warnings:ae}}function Y(C){let V=Ct(C.scope),te=V+C.depth,ae=new Map,Ee=we=>{let Fe=ae.get(we);return Fe===void 0&&!ae.has(we)&&(Fe=Jt(we,C.scope)?Ct(we)>=te?ts(we,te):we:void 0,ae.set(we,Fe)),Fe},ye=we=>{let Fe=0,qe=Ct(we)+1;for(let De of E)Ct(De)===qe&&Jt(De,we)&&Fe++;return Fe},Ne=new Map,Oe=we=>{let Fe=Ne.get(we);if(!Fe){let qe=Ct(we)-V,De=h.get(we);Fe={scope:we,label:De?.label??pr(we),kind:mr(we),...a(De),depth:qe,...qe<C.depth?{own:!0}:{},children:ye(we),count:0},Ne.set(we,Fe)}return Fe};for(let we of E)Ct(we)===te&&Jt(we,C.scope)&&Oe(we);return te===0&&Oe(""),{at:Ee,add:Oe,rows:Ne}}let ee=C=>[...C.values()].sort((V,te)=>V.scope===te.scope?0:V.scope<te.scope?-1:1);function F(C,V){let te=[];for(let ae=Un(p,C-g);ae<p.length&&p[ae].t<C;ae++)p[ae].t+p[ae].dur>C&&te.push(p[ae]);for(let ae of x.values())ae.t<C&&c>C&&te.push(ae);for(let ae=Un(y,C);ae<y.length&&y[ae].t<V;ae++)te.push(y[ae]);return te}function K(C,V,te,ae){let Ee=C.series?new Set(C.series):void 0,ye=new Map;for(let Oe of $.values()){if(Ee&&!Ee.has(Oe.series))continue;let we=V(Oe.scope);if(we===void 0)continue;let Fe=P.get(Oe.series)??"",qe=U(Fe,C.bin),De=C.bin?I(Oe,C.bin,C.tz):Oe.fine;for(let Qe=Un(De,C.bin?Rs(te,C.bin,C.tz):te);Qe<De.length&&De[Qe].t<ae;Qe++){let S=De[Qe];if(S.t<qe)continue;let z=`${Oe.series}\0${we}\0${S.t}`,J=ye.get(z);J?ud(J,S):ye.set(z,{series:Oe.series,scope:we,t:S.t,bin:C.bin??"1m",min:S.min,max:S.max,sum:S.sum,count:S.count})}}let Ne=[...ye.values()].sort((Oe,we)=>Oe.t-we.t||(Oe.series<we.series?-1:1)||(Oe.scope<we.scope?-1:1));return C.bin?Ne:Ne.map(Oe=>({series:Oe.series,scope:Oe.scope,t:Oe.t,value:Oe.count===1||A.get(Oe.series)!=="gauge"?Oe.sum:Oe.sum/Oe.count}))}let q=C=>`${C.t}:${C.id}`,Z=(C,V)=>{let te=V.indexOf(":"),ae=Number(V.slice(0,te)),Ee=V.slice(te+1);return C.t>ae||C.t===ae&&C.id>Ee};function le(C){if(C.bin!=="1h"&&C.bin!=="1d"||(C.where?.all.length??0)||C.q||C.filters?.kind?.length||C.filters?.severity?.length||C.filters?.scope?.length||Dt(C.tz,C.from)%In||Dt(C.tz,C.to)%In)return;let V=C.filters?.source?.length?new Set(C.filters.source):void 0,te=Q=>Math.max(C.from,X(Q)),{at:ae,add:Ee,rows:ye}=Y(C),Ne=new Set,Oe=new Map,we=0,Fe=(Q,ne)=>{let ge=Rs(ne,C.bin,C.tz),ke=`${Q}\0${ge}`,T=Oe.get(ke);return T||(T={scope:Q,t:ge,bin:C.bin,count:0,severity:{},kinds:{}},Oe.set(ke,T)),T},qe=(Q,ne,ge)=>{let ke=Ee(Q);ke.count+=ge,we+=ge,(ke.first===void 0||ne<ke.first)&&(ke.first=ne),(ke.last===void 0||ne>ke.last)&&(ke.last=ne)},De=Math.floor(C.to/In)*In;for(let[Q,ne]of O){let ge=ae(Q);if(ge!==void 0)for(let[ke,T]of ne){if(V&&!V.has(ke))continue;let j=Math.ceil(te(ke)/In)*In;for(let[_,ce]of T){if(_<j||_>=De)continue;qe(ge,ce.first,ce.count),ce.last>(ye.get(ge).last??-1/0)&&(ye.get(ge).last=ce.last),Ne.add(ke);let me=Fe(ge,_);me.count+=ce.count;for(let[Re,ie]of Object.entries(ce.severity))me.severity[Re]=(me.severity[Re]??0)+ie;for(let[Re,ie]of Object.entries(ce.kinds))me.kinds[Re]=(me.kinds[Re]??0)+ie}}}let Qe=Q=>Jt(Q.scope,C.scope)&&(!V||V.has(Q.source))&&Q.t>=X(Q.source)&&ae(Q.scope)!==void 0,S=Q=>{let ne=ae(Q.scope);qe(ne,Q.t,1),Ne.add(Q.source);let ge=Fe(ne,Q.t);ge.count++,ge.severity[Q.severity]=(ge.severity[Q.severity]??0)+1,ge.kinds[Q.kind]=(ge.kinds[Q.kind]??0)+1};for(let Q of w){if(V&&!V.has(Q))continue;let ne=te(Q),ge=Math.ceil(ne/In)*In,ke=ge>=De?[[ne,C.to]]:[[ne,ge],[De,C.to]];for(let[T,j]of ke)for(let _=Un(y,T);_<y.length&&y[_].t<j;_++){let ce=y[_];ce.source===Q&&Qe(ce)&&S(ce)}}let z=gn[C.bin],J=[];for(let Q=Un(p,C.from-g);Q<p.length&&p[Q].t<C.from;Q++){let ne=p[Q];ne.t+ne.dur>C.from&&Qe(ne)&&(qe(ae(ne.scope),ne.t,1),Ne.add(ne.source),ne.dur>=z&&J.length<5e3&&J.push(ne))}for(let Q of x.values())Q.t<C.from&&c>C.from&&Qe(Q)&&(qe(ae(Q.scope),Q.t,1),Ne.add(Q.source),J.length<5e3&&J.push(Q));for(let Q=Un(p,C.from);Q<p.length&&p[Q].t<C.to&&J.length<5e3;Q++)p[Q].dur>=z&&Qe(p[Q])&&J.push(p[Q]);for(let Q of x.values())Q.t>=C.from&&Q.t<C.to&&J.length<5e3&&Qe(Q)&&J.push(Q);let he=K(C,ae,C.from,C.to);for(let Q of he){let ne=P.get(Q.series);ne&&Ne.add(ne)}let de=[...Oe.values()].sort((Q,ne)=>Q.t-ne.t||(Q.scope<ne.scope?-1:1));return{timeline:1,type:"result",rows:ee(ye),bins:de,spans:J,metrics:he,total:we,retention:B(Ne)}}async function fe(C){if(!r(C.scope))throw new Error(`not a scope path: ${JSON.stringify(C.scope)}`);let V=le(C);if(V)return V;let{test:te,range:ae,warnings:Ee}=H(C),{at:ye,add:Ne,rows:Oe}=Y(C),we=new Set,Fe=[];for(let he of F(ae.from,ae.to)){if(!te(he))continue;let de=ye(he.scope);if(de===void 0)continue;let Q=Ne(de);Q.count++,(Q.first===void 0||he.t<Q.first)&&(Q.first=he.t),(Q.last===void 0||he.t>Q.last)&&(Q.last=he.t),we.add(he.source),Fe.push(he)}Fe.sort(ba);let qe=K(C,ye,ae.from,ae.to);for(let he of qe){let de=P.get(he.series);de&&we.add(de)}let De={timeline:1,type:"result",total:Fe.length,...Ee.length?{warnings:Ee}:{}};if(C.bin){let he=gn[C.bin],de=new Map,Q=[];for(let ge of Fe){if((ge.open||ge.dur!==void 0&&ge.dur>=he)&&Q.length<5e3&&Q.push(ge),ge.t<ae.from)continue;let ke=ye(ge.scope),T=Rs(ge.t,C.bin,C.tz),j=`${ke}\0${T}`,_=de.get(j);_||(_={scope:ke,t:T,bin:C.bin,count:0,severity:{},kinds:{}},de.set(j,_)),_.count++,_.severity[ge.severity]=(_.severity[ge.severity]??0)+1,_.kinds[ge.kind]=(_.kinds[ge.kind]??0)+1}let ne=[...de.values()].sort((ge,ke)=>ge.t-ke.t||(ge.scope<ke.scope?-1:1));return{...De,rows:ee(Oe),bins:ne,spans:Q,metrics:qe,retention:B(we)}}let Qe=Math.min(1e4,Math.max(1,C.limit??2e3)),S=C.cursor?Fe.findIndex(he=>Z(he,C.cursor)):0,z=S<0?[]:Fe.slice(S,S+Qe),J=S>=0&&S+Qe<Fe.length;return{...De,rows:ee(Oe),events:z,metrics:qe,retention:B(we),...J?{next:q(z[z.length-1])}:{}}}let W=new Set,oe=C=>Wt.includes(C),Me=0;function Le(C){let V=m(C),te=N.get(V);te&&(fd(y,te.t,ae=>ae===te),R(te,-1),te.dur!==void 0&&!te.open&&fd(p,te.t,ae=>ae===te),x.delete(V)),N.set(V,C),R(C,1),gc(y,C,()=>!1,ba),C.open?x.set(V,C):C.dur!==void 0&&(gc(p,C,()=>!1,ba),g=Math.max(g,C.dur)),v(C.scope)}return{async catalog(){return{...s,now:c,retention:B(s.sources.map(C=>C.name))}},query:fe,subscribe(C,V){let te={q:C,on:V};return W.add(te),()=>{W.delete(te)}},...t.stateAt?{stateAt:(C,V)=>t.stateAt(C,V)}:{},append(C,V=[],te){te!==void 0&&(c=Math.max(c,te));let ae=new Set(E),Ee=C.map(b);for(let ye of Ee){if(!oe(ye.severity))throw new Error(`not a severity: ${ye.severity}`);Le(ye)}for(let ye of V)k(ye);Me++;for(let ye of W){let{test:Ne}=H(ye.q),{at:Oe}=Y(ye.q),we=Ee.filter(z=>Ne(z)&&Oe(z.scope)!==void 0),Fe=ye.q.series?new Set(ye.q.series):void 0,qe=V.filter(z=>Jt(d(z.scope),ye.q.scope)&&(!Fe||Fe.has(z.series))).map(z=>({...z,scope:Oe(d(z.scope))})),De=[...E].filter(z=>!ae.has(z)),Qe=Ct(ye.q.scope)+ye.q.depth,S=De.filter(z=>Ct(z)===Qe&&Jt(z,ye.q.scope)).map(z=>({scope:z,label:h.get(z)?.label??pr(z),kind:mr(z),depth:ye.q.depth,children:0,count:0}));ye.on({timeline:1,type:"batch",events:we,metrics:qe,...S.length?{rows:S}:{},now:c,resume:String(Me)})}},setRetention(C,V){M.set(C,{events:V.events,rollups:{...V.rollups},setBy:"user"})},get now(){return c},get size(){let C=0;for(let V of $.values())C+=V.fine.length;return{events:y.length,samples:C}}}}var md="http://www.w3.org/2000/svg",Is=22,ya=38,Hn=26,Qp=210,Zp=24,mo=6e4,Ls=36e5,rn=864e5,pd={"15m":15*mo,"1h":Ls,"1d":rn,"1w":7*rn},hd=n=>Wt.indexOf(n),eh={debug:"dot",info:"circle",notice:"square",warning:"triangle",error:"diamond"},it=(n,e,t)=>{let s=document.createElementNS(md,n);for(let[r,o]of Object.entries(e))o!==void 0&&s.setAttribute(r,String(o));if(t){let r=document.createElementNS(md,"title");r.textContent=t,s.append(r)}return s},_t=(n,e)=>{try{return new Intl.DateTimeFormat(void 0,{timeZone:e,dateStyle:"medium",timeStyle:"medium"}).format(n)}catch{return new Date(n).toISOString()}},bc=n=>n<1e3?`${Math.round(n)} ms`:n<mo?`${(n/1e3).toFixed(1)} s`:Ps(n),th=(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 yc(n,e){if(n<=3*Ls)return{kind:"single"};for(let t of["1m","1h","1d"])if(n/gn[t]<=e/2)return{kind:"binned",bin:t};return{kind:"binned",bin:"1d"}}function xc(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"?gn[e.bin]:mo;for(let i of n.bins??[])i.count&&s.push([i.t,i.t+gn[i.bin]]);let o=new Map;for(let i of n.metrics){let l="value"in i?i.value:i.sum,a=`${i.series}|${i.scope}`,c=(t?.get(i.series)??"counter")==="counter"?l!==0:o.get(a)!==l;o.set(a,l),c&&s.push([i.t,i.t+r])}return s}function gd(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}=gr(e.catalog),l=(D="system")=>{n.style.colorScheme=D==="system"?"light dark":D,D==="system"?delete n.dataset.theme:n.dataset.theme=D};l(e.theme),n.setAttribute("role","region"),n.setAttribute("aria-label","Timeline");let a,c="",f=1,u="",d={},h=!1,b=e.collapseGaps??!0,m={t0:0,t1:rn},y,N="",p={from:0,to:0,mode:{kind:"single"},key:""},g,x,$,E,v=!0,A=0,L=0,M=!1,P,k=[],O=[],w=-1,R=new Set,I=new Map,G=[],X=br(0,rn,800),U=new Map,B=[],H=re("nav",{class:"tlx-crumbs","aria-label":"Scope"}),Y=re("div",{class:"segmented tlx-quick",role:"group","aria-label":"Range"});for(let D of["15m","1h","1d","1w","run"]){let se=re("button",{type:"button",class:"seg","data-v":D,title:D==="run"?"The latest run":`The last ${D}`},D==="run"?"this run":D);se.addEventListener("click",()=>Yn(D)),Y.append(se)}let ee=re("button",{type:"button",class:"btn sm tlx-live","aria-pressed":"false",title:"Follow what happens now"},"Live"),F=re("button",{type:"button",class:"btn sm quiet tlx-now",hidden:!0,title:"Back to the live edge"},"Back to now"),K=re("button",{type:"button",class:"btn sm quiet tlx-fit",title:"Everything in this scope"},"Fit"),q=re("input",{type:"checkbox",class:"tlx-gaps"});q.checked=b;let Z=!0,le=re("input",{type:"checkbox",class:"tlx-quiet"});le.checked=Z;let fe=re("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=re("span",{class:"tlx-hits",role:"status","aria-live":"polite"}),oe=re("button",{type:"button",class:"btn sm quiet tlx-prev",title:"Previous hit (\u21E7N)","aria-label":"Previous hit"},"\u2039"),Me=re("button",{type:"button",class:"btn sm quiet tlx-next",title:"Next hit (N)","aria-label":"Next hit"},"\u203A"),Le=re("div",{class:"tlx-facets",role:"group","aria-label":"Sources"}),C=re("select",{class:"input tlx-sev","aria-label":"Severity"},re("option",{value:""},"every severity"),...Wt.slice(1).map(D=>re("option",{value:D},`${D} and above`))),V=re("select",{class:"input tlx-views","aria-label":"Saved views",hidden:!e.views},re("option",{value:""},"Saved views\u2026")),te=re("button",{type:"button",class:"btn sm quiet tlx-save",hidden:!e.saveView,title:"Save this view"},"Save view"),ae=re("div",{class:"tlx-warn",role:"status",hidden:!0}),Ee=re("div",{class:"tlx-status",role:"status"}),ye=re("span",{class:"tlx-canvas-note"}),Ne=re("div",{class:"tlx-labels"}),Oe=re("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"}),we=it("svg",{class:"tlx-svg"});Oe.append(we);let Fe=re("div",{class:"tlx-scroll"},re("div",{class:"tlx-grid"},Ne,Oe)),qe=re("section",{class:"tlx-table",hidden:!0,"aria-label":"The events in the chosen range"}),De=re("aside",{class:"tlx-detail",hidden:!0,"aria-label":"The event"});n.replaceChildren(re("div",{class:"tlx-bar"},H,re("span",{class:"spacer"}),Y,ee,F,K,re("label",{class:"tlx-gaps-label",title:"Draw long empty stretches as narrow breaks"},q,"Collapse gaps"),re("label",{class:"tlx-gaps-label",title:"Hide the rows with nothing in this range"},le,"Hide quiet rows")),re("div",{class:"tlx-bar"},fe,W,oe,Me,C,V,te),Le,ae,re("div",{class:"tlx-body"},Fe,De),re("div",{class:"tlx-foot"},Ee,re("span",{class:"spacer"}),ye),qe);let Qe=()=>Math.max(200,Oe.clientWidth||800),S=()=>{let D=(ve,Ke)=>(ve.own?-1:0)-(Ke.own?-1:0)||ve.scope.localeCompare(Ke.scope,void 0,{numeric:!0}),pe=(y?.rows??[]).filter(ve=>!Z||ve.count>0||ve.own||(y?.rows.length??0)<=1).sort(D).map(ve=>({kind:"row",row:ve})),be=new Set(y?.metrics.map(ve=>ve.series)??[]);for(let ve of[...be].sort()){let Ke=U.get(ve);pe.push({kind:"metric",series:ve,unit:Ke?.unit??"count",type:Ke?.type??"counter",title:Ke?.title??ve})}return pe},z=(D,se)=>a?.names?.find(pe=>pe.scope===D)?.label??se,J=D=>D.kind==="metric"?ya:Is,he=()=>yc(m.t1-m.t0,Qe()),de=()=>a?.now??Date.now();function Q(){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}:{},...h?{live:h}:{},...b?{}:{collapseGaps:!1},...Z?{}:{quietRows:!0}}}function ne(D){D.scope!==void 0&&(c=D.scope),D.depth!==void 0&&(f=D.depth),u=D.q??"",fe.value=u,d=D.filters??{},C.value=d.severity?.length?d.severity[0]:"",b=D.collapseGaps??e.collapseGaps??!0,q.checked=b,Z=!D.quietRows,le.checked=Z,R.clear(),I.clear();let se=D.range;se&&"last"in se?Yn(se.last,!1):se&&(m={t0:se.from,t1:se.to}),ft(!!D.live,!1)}let ge=()=>{let D=Q();if(e.onViewChange?.(D),!!e.urlState)try{history.replaceState(null,"",`#timeline=${encodeURIComponent(JSON.stringify(D))}`)}catch{}},ke=()=>{if(!e.urlState)return;let D=/#timeline=(.+)$/.exec(location.hash);if(D)try{return JSON.parse(decodeURIComponent(D[1]))}catch{return}};function T(D,se,pe,be={}){let ve=i(u,de(),D,se);k=ve.warnings;let Ke=u?[]:d.source?[...U].filter(([,Ze])=>d.source.includes(Ze.source)).map(([Ze])=>Ze):void 0;return{timeline:1,type:"query",scope:c,depth:f,from:ve.from,to:ve.to,tz:t,...pe.kind==="binned"?{bin:pe.bin}:{},...u?{q:u,where:ve.where}:{},...Object.keys(d).length?{filters:d}:{},...Ke?{series:Ke}:{},...be}}let j=()=>JSON.stringify([c,f,u,d,he()]);async function _(D=!1){let se=he(),pe=j(),be=m.t1-m.t0;if(!D&&y&&pe===p.key&&m.t0>=p.from&&m.t1<=p.to){me();return}if(L){M=!0;return}L++;let ve=m.t0-be/2,Ke=Math.min(m.t1+be/2,Math.max(m.t1,de()+be*.1));try{let Ze=await e.source.query(T(ve,Ke,se,se.kind==="single"?{limit:1e4}:{}));se.kind==="single"&&Ze.next&&(Ze=await e.source.query(T(ve,Ke,{kind:"binned",bin:"1m"}))),y=Ze,N=pe,p={from:ve,to:Ke,mode:se,key:pe}}catch(Ze){Ee.textContent=`The history couldn't be read: ${String(Ze?.message??Ze)}`}finally{L--}me(),ge(),M&&(M=!1,_())}function ce(){let D=Qe(),se=he();if(G=[],b&&y){let pe=new Map([...U].map(([be,ve])=>[be,ve.type]));G=ma(xc(y,se,pe),m.t0,Math.min(m.t1,Math.max(m.t0,de())),{minFrac:.15,minMs:10*mo}),se.kind==="binned"&&(G=G.filter(be=>be.to-be.from>=2*gn[se.bin])),G=G.filter(be=>!(R.has(Cs(be))&&(I.get(Cs(be))??1)>=1))}X=br(m.t0,m.t1,D,G,{cut:Zp,weights:I})}let me=()=>{A||(A=requestAnimationFrame(Re))};function Re(){A=0,ce();let D=Qe(),se=S(),pe=p.mode,be=[],ve=Hn;for(let ue of se)be.push(ve),ve+=J(ue);let Ke=Math.max(ve,Hn+Is);we.setAttribute("width",String(D)),we.setAttribute("height",String(Ke)),we.setAttribute("viewBox",`0 0 ${D} ${Ke}`);let Ze=Fe.scrollTop-200,Ln=Fe.scrollTop+(Fe.clientHeight||600)+200,je=[],Be=X.x;je.push(it("rect",{class:"tlx-axis",x:0,y:0,width:D,height:Hn}));let It=(y?.retention??[]).map(ue=>({r:ue,from:pe.kind==="binned"?ue.keptFrom.rollups[pe.bin]??ue.keptFrom.events:ue.keptFrom.events,days:pe.kind==="binned"?ue.rollups[pe.bin]:ue.events})).filter(ue=>ue.from!==void 0);if(It.length){let ue=Math.min(...It.map($e=>$e.from));ue>m.t0&&je.push(it("rect",{class:"tlx-notkept",x:Math.max(0,Be(m.t0)),y:Hn,width:Math.max(0,Be(ue)-Math.max(0,Be(m.t0))),height:Ke-Hn},`Nothing kept before ${_t(ue,t)}: ${It.map($e=>`${$e.r.source} ${$e.days===null?"kept until deleted":`kept ${$e.days} days`}`).join(", ")}`))}let Xt=de();Xt<m.t1&&je.push(it("rect",{class:"tlx-future",x:Be(Xt),y:Hn,width:D-Be(Xt),height:Ke-Hn}));for(let ue of pa(X,t,90)){je.push(it("line",{class:`tlx-tick${ue.major?" major":""}`,x1:ue.x,x2:ue.x,y1:Hn-6,y2:Ke}));let $e=it("text",{class:"tlx-ticklabel",x:ue.x+3,y:16});$e.textContent=ue.label,je.push($e)}E&&je.push(it("rect",{class:"tlx-brush",x:Be(E.from),y:0,width:Math.max(1,Be(E.to)-Be(E.from)),height:Ke}));let go=pe.kind==="single"?(y?.events??[]).filter(ue=>ue.dur!==void 0||ue.open):y?.spans??[],Ad=pe.kind==="single"?(y?.events??[]).filter(ue=>ue.dur===void 0&&!ue.open):[],kc=new Map;se.forEach((ue,$e)=>{ue.kind==="row"&&kc.set(ue.row.scope,$e)});let bo=ue=>{let $e=Ct(c)+f,Ue=Ct(ue)>=$e?ts(ue,$e):ue;return kc.get(Ue)},yr=ue=>be[ue]+J(se[ue])>=Ze&&be[ue]<=Ln;if(se.forEach((ue,$e)=>{yr($e)&&je.push(it("rect",{class:`tlx-lane${$e%2?" odd":""}${ue.kind==="metric"?" metric":""}`,x:0,y:be[$e],width:D,height:J(ue)}))}),pe.kind==="binned"){let ue=new Map;for(let $e of y?.bins??[]){let Ue=bo($e.scope);Ue!==void 0&&ue.set(Ue,Math.max(ue.get(Ue)??0,$e.count))}for(let $e of y?.bins??[]){let Ue=bo($e.scope);if(Ue===void 0||!yr(Ue))continue;let et=Be($e.t),We=Be($e.t+gn[$e.bin]);if(We<0||et>D)continue;let dt=[...Wt].reverse().find(on=>($e.severity[on]??0)>0)??"info",Ot=Math.max(2,(Is-8)*Math.sqrt($e.count)/Math.sqrt(ue.get(Ue)||1));je.push(it("rect",{class:"tlx-countbar",x:et,y:be[Ue]+Is-3-Ot,width:Math.max(1,We-et-.5),height:Ot,"data-t":$e.t},`${_t($e.t,t)}: ${$e.count} event${$e.count===1?"":"s"}${dt!=="info"&&dt!=="debug"?`, the worst ${dt}`:""}`)),(dt==="warning"||dt==="error")&&je.push(it("rect",{class:`tlx-heat sev-${dt}`,x:et,y:be[Ue]+Is-(dt==="error"?4:3),width:Math.max(1,We-et-.5),height:dt==="error"?3:2}))}}for(let ue of go){let $e=bo(ue.scope);if($e===void 0||!yr($e))continue;let Ue=ue.open?Xt:ue.t+(ue.dur??0),et=Be(ue.t),We=Be(Ue);if(We<-2||et>D+2)continue;let dt=`tlx-span sev-${ue.severity}${ue.open?" open":""}${$?.id===ue.id?" selected":""}`,Ot=`${ue.summary} \xB7 ${_t(ue.t,t)}${ue.open?", still going":`, ${bc(Ue-ue.t)}`}`,on=be[$e]+5,ss=pe.kind==="binned"?4:8,an=et;for(let wn of X.cuts)wn.weight>=1||wn.x1<=et||wn.x0>=We||(wn.x0>an&&je.push(it("rect",{class:dt,x:an,y:on,width:Math.max(1,wn.x0-an),height:ss,rx:2,"data-id":ue.id},Ot)),je.push(it("path",{class:`${dt} through`,d:`M${wn.x0} ${on+ss/2} H${wn.x1}`,"data-id":ue.id},`${Ot} (lasted through the break)`)),an=wn.x1);We>an&&je.push(it("rect",{class:dt,x:Math.max(-2,an),y:on,width:Math.max(2,Math.min(D+2,We)-Math.max(-2,an)),height:ss,rx:2,"data-id":ue.id},Ot))}let vc=new Map;for(let ue of Ad){let $e=bo(ue.scope);if($e===void 0||!yr($e))continue;let Ue=Be(ue.t);if(Ue<-6||Ue>D+6||Ue-(vc.get($e)??-1/0)<3)continue;vc.set($e,Ue);let et=be[$e]+Is/2+2,We=4,dt=eh[ue.severity],Ot=dt==="diamond"?`M${Ue} ${et-We-1} l${We+1} ${We+1} l${-We-1} ${We+1} l${-We-1} ${-We-1} z`:dt==="triangle"?`M${Ue} ${et-We-1} l${We+1} ${2*We+1} h${-2*We-2} z`:dt==="square"?`M${Ue-We+.5} ${et-We+.5} h${2*We-1} v${2*We-1} h${-2*We+1} z`:"",on=`${_t(ue.t,t)} \xB7 ${ue.summary}`,ss=`tlx-mark sev-${ue.severity}${$?.id===ue.id?" selected":""}${w>=0&&O[w]?.id===ue.id?" hit":""}`;je.push(Ot?it("path",{class:ss,d:Ot,"data-id":ue.id},on):it("circle",{class:ss,cx:Ue,cy:et,r:dt==="dot"?2.5:We,"data-id":ue.id},on))}se.forEach((ue,$e)=>{if(ue.kind!=="metric"||!yr($e))return;let Ue=new Map;for(let nt of y?.metrics??[]){if(nt.series!==ue.series)continue;let Nt="value"in nt?{min:nt.value,max:nt.value,sum:nt.value,count:1}:{min:nt.min,max:nt.max,sum:nt.sum,count:nt.count},$t=Ue.get(nt.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(nt.t,{...Nt})}let et=[...Ue].sort((nt,Nt)=>nt[0]-Nt[0]);if(!et.length)return;let We=pe.kind==="binned"?gn[pe.bin]:mo,dt=nt=>ue.type==="gauge"?nt.sum/Math.max(1,nt.count):nt.sum,Ot=Math.max(1e-9,...et.map(([,nt])=>ue.type==="gauge"?nt.max:dt(nt))),on=be[$e]+ya-4,ss=ya-10,an=nt=>on-nt/Ot*ss;if(ue.type==="gauge"){let nt=et.map(([Nt,$t])=>`${Be(Nt)},${an($t.max)}`).join(" ")+" "+[...et].reverse().map(([Nt,$t])=>`${Be(Nt)},${an($t.min)}`).join(" ");je.push(it("polygon",{class:"tlx-band",points:nt})),je.push(it("polyline",{class:"tlx-line",points:et.map(([Nt,$t])=>`${Be(Nt+We/2)},${an(dt($t))}`).join(" ")}))}else{let nt="",Nt=-1/0;for(let[$t,Od]of et){let Nd=Be($t),Sc=Be($t+We),$c=an(dt(Od));nt+=$t>Nt?`M${Nd} ${on} V${$c} H${Sc}`:` V${$c} H${Sc}`,Nt=$t+We;let Mc=et.find(([Rd])=>Rd>$t);(!Mc||Mc[0]>Nt)&&(nt+=` V${on} Z`)}je.push(it("path",{class:"tlx-area",d:nt}))}let wn=it("text",{class:"tlx-peak",x:4,y:be[$e]+11});wn.textContent=`peak ${th(Ot,ue.unit)}${ue.type==="counter"?` per ${pe.kind==="binned"?pe.bin:"1m"}`:""}`,je.push(wn)});for(let ue of X.cuts){if(ue.weight>=1)continue;let $e=We=>{let dt=`M${We} 0`;for(let Ot=0;Ot<Ke;Ot+=8)dt+=` L${We+(Ot/8%2?-3:3)} ${Ot+8}`;return dt},Ue=it("g",{class:"tlx-cut",tabindex:0,role:"button","data-from":ue.from,"data-to":ue.to,"aria-label":`A break of ${Ps(ue.to-ue.from)} with nothing shown, from ${_t(ue.from,t)} to ${_t(ue.to,t)}: press to open it`},`${Ps(ue.to-ue.from)} with nothing here: ${_t(ue.from,t)} to ${_t(ue.to,t)} (click to open)`);Ue.append(it("rect",{class:"tlx-cut-bg",x:ue.x0,y:0,width:ue.x1-ue.x0,height:Ke})),Ue.append(it("path",{class:"tlx-cut-edge",d:$e(ue.x0+3)}),it("path",{class:"tlx-cut-edge",d:$e(ue.x1-3)}));let et=it("text",{class:"tlx-cut-label",x:(ue.x0+ue.x1)/2,y:15,"text-anchor":"middle"});et.textContent=Ps(ue.to-ue.from),Ue.append(et),je.push(Ue)}if(g!==void 0){let ue=Be(g);je.push(it("line",{class:"tlx-playhead",x1:ue,x2:ue,y1:0,y2:Ke})),je.push(it("path",{class:"tlx-handle",d:`M${ue-6} 0 h12 v8 l-6 7 l-6 -7 z`},`the playhead: ${_t(g,t)}`))}we.replaceChildren(...je),Ne.replaceChildren(re("div",{class:"tlx-labelhead",style:`height:${Hn}px`},he().kind==="single"?"single events":`per ${he().kind==="binned"?he().bin:""}`),...se.map(ue=>{if(ue.kind==="metric")return re("div",{class:"tlx-rowlabel metric",style:`height:${ya}px`,title:`${ue.title} (${ue.type==="counter"?"sums":"min, max and mean"})`},ue.title);let $e=ue.row,Ue=re("div",{class:`tlx-rowlabel${$e.own?" own":""}`,style:`height:${Is}px`,"data-scope":$e.scope,title:`${$e.scope||"all hosts"} \xB7 ${$e.count} event${$e.count===1?"":"s"}`},re("span",{class:"tlx-kind"},e.catalog.flags.find(et=>$e[et])??$e.kind),re("span",{class:"tlx-name"},$e.own?`${$e.label} (itself)`:$e.label),re("span",{class:"tlx-count"},String($e.count)));if(!$e.own&&$e.scope!==c){let et=re("button",{type:"button",class:"tlx-drill",title:$e.children?`Into ${$e.label}: its ${$e.children} part${$e.children===1?"":"s"}`:`Into ${$e.label}`,"aria-label":`Into ${$e.label}`},"\u203A");et.addEventListener("click",()=>Je($e.scope)),Ue.append(et)}return Ue})),Ne.style.width=`${Qp}px`,ie()}function ie(){H.replaceChildren(...hr(c).flatMap((be,ve,Ke)=>{let Ze=re("button",{type:"button",class:`tlx-crumb${ve===Ke.length-1?" current":""}`,"aria-current":ve===Ke.length-1?"location":void 0},z(be.scope,be.label));return Ze.addEventListener("click",()=>{be.scope!==c&&(c=be.scope,f=1,_(!0))}),ve?[re("span",{class:"tlx-sep","aria-hidden":"true"},"/"),Ze]:[Ze]})),ee.setAttribute("aria-pressed",String(h)),ee.classList.toggle("on",h),F.hidden=!h||v;let D=he(),se=y?.total??0,pe=(y?.retention??[]).filter(be=>be.events!==null).map(be=>`${be.source} kept ${be.events} d`);Ee.textContent=`${_t(m.t0,t)} \u2013 ${_t(m.t1,t)} \xB7 ${D.kind==="single"?"single events":`bins of ${D.bin}`} \xB7 ${se} event${se===1?"":"s"}${G.length?` \xB7 ${G.length} break${G.length===1?"":"s"}`:""}${pe.length?` \xB7 ${pe.slice(0,3).join(", ")}`:""}`,ae.hidden=!k.length,ae.textContent=k.join(" \xB7 "),W.textContent=u?O.length?`${w+1>0?`${w+1} of `:""}${O.length}${O.length>=2e3?"+":""} hit${O.length===1?"":"s"}`:`${se?`${se} hit${se===1?"":"s"}`:"no hits"}`:"";for(let be of Y.querySelectorAll(".seg"))be.classList.remove("on");ye.textContent=g===void 0?"":x?(()=>{let be=e.stamp?.(x)??{};return`Canvas: the state recorded at ${_t(Date.parse(be.at??"")||g,t)}${be.tag?` (${be.tag})`:""}`})():"No state recorded here",ye.classList.toggle("none",g!==void 0&&!x)}function Pe(){Le.replaceChildren();for(let D of a?.sources??[]){let se=!d.source?.length||d.source.includes(D.name),pe=re("button",{type:"button",class:`tlx-chip${se?" on":""}${D.status==="not-yet"?" notyet":""}`,"aria-pressed":String(se&&D.status!=="not-yet"),disabled:D.status==="not-yet",title:D.status==="not-yet"?`${D.title}: not kept yet`:`${D.title}${Se(D)}`},D.name);D.status!=="not-yet"&&pe.addEventListener("click",()=>xe(D.name)),Le.append(pe)}}let Se=D=>{let se=a?.retention.find(pe=>pe.source===D.name);return se?` (kept ${se.events===null?"until deleted":`${se.events} days`})`:""};function xe(D){let se=(a?.sources??[]).filter(be=>be.status==="kept").map(be=>be.name),pe=d.source?.length?[...d.source]:[...se];pe=pe.includes(D)?pe.filter(be=>be!==D):[...pe,D],d={...d,...pe.length===se.length?{source:void 0}:{source:pe}},d.source||delete d.source,Pe(),_(!0),ze()}let Ie=0;fe.addEventListener("input",()=>{clearTimeout(Ie),Ie=setTimeout(()=>{u=fe.value.trim(),w=-1,_(!0),ze()},250)}),fe.addEventListener("keydown",D=>{D.key==="Enter"&&(D.preventDefault(),clearTimeout(Ie),u=fe.value.trim(),_(!0).then(()=>ze()).then(()=>tt(D.shiftKey?-1:1)))});async function ze(){if(!u){O=[],w=-1,ie();return}let D=m.t1-m.t0;O=(await e.source.query(T(m.t0-D*4,Math.max(m.t1+D*4,de()),{kind:"single"},{limit:2e3}))).events??[],w=Math.min(w,O.length-1),ie()}function tt(D){if(!O.length)return;let se=(m.t0+m.t1)/2;w<0?w=D>0?Math.max(0,O.findIndex(ve=>ve.t>=se)):Math.max(0,O.length-1-[...O].reverse().findIndex(ve=>ve.t<=se)):w=(w+D+O.length)%O.length;let pe=O[w],be=Math.min(m.t1-m.t0,2*Ls);m={t0:pe.t-be/2,t1:pe.t+be/2},v=!1,ut(pe),_()}oe.addEventListener("click",()=>tt(-1)),Me.addEventListener("click",()=>tt(1)),C.addEventListener("change",()=>{let D=C.value;d={...d,...D?{severity:Wt.filter(se=>hd(se)>=hd(D))}:{}},D||delete d.severity,_(!0),ze()});async function Yn(D,se=!0){let pe=de();if(D==="run"){let be=await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:pe-30*rn,to:pe+1,filters:{kind:["run"]},limit:1e4}).catch(()=>{}),ve=be?.events?.[be.events.length-1];m=ve?{t0:ve.t-(ve.dur??Ls)*.02,t1:(ve.open?pe:ve.t+(ve.dur??Ls))+(ve.dur??Ls)*.04}:{t0:pe-rn,t1:pe+rn*.02}}else m={t0:pe-pd[D],t1:pe+pd[D]*.02};v=!0,R.clear(),I.clear(),se&&_()}function ft(D,se=!0){if(h=D,P?.(),P=void 0,D&&e.source.subscribe){let pe=0,be=0;P=e.source.subscribe(T(de()-Ls,de()+365*rn,{kind:"single"}),ve=>{if(a&&(a.now=Math.max(a.now,ve.now)),v){let Ze=m.t1-m.t0;m={t0:ve.now-Ze*.98,t1:ve.now+Ze*.02}}let Ke=Date.now();Ke-pe>500?(pe=Ke,_(!0)):be||(be=setTimeout(()=>{be=0,pe=Date.now(),_(!0)},500))}),v=!0}se&&(ie(),ge())}ee.addEventListener("click",()=>ft(!h)),F.addEventListener("click",()=>{v=!0;let D=m.t1-m.t0,se=de();m={t0:se-D*.98,t1:se+D*.02},_()}),K.addEventListener("click",()=>{rt()}),q.addEventListener("change",()=>{b=q.checked,R.clear(),I.clear(),me(),ge()}),le.addEventListener("change",()=>{Z=le.checked,me(),ge()});function Je(D){let se=y?.rows.find(pe=>pe.scope===D);c=D,f=se&&se.children===0?0:1,E=void 0,qe.hidden=!0,_(!0)}async function rt(){let D=de(),pe=((await e.source.query({timeline:1,type:"query",scope:c,depth:0,from:D-400*rn,to:D+1,bin:"1d",tz:t}).catch(()=>{}))?.bins??[]).map(ve=>ve.t),be=pe.length?Math.min(...pe):D-7*rn;m={t0:be,t1:D+(D-be)*.02},v=!0,_()}let yn=0;async function Tt(D){if(g=D,me(),D===void 0){x=void 0;return}let se=++yn,pe=e.source.stateAt?await e.source.stateAt(c,D).catch(()=>{}):void 0;se===yn&&(x=pe,e.onPlayhead?.(D,pe),ie())}async function vt(D,se){E={from:Math.min(D,se),to:Math.max(D,se)},me();let pe=await e.source.query(T(E.from,E.to,{kind:"single"},{limit:500})),be=o(u),ve=je=>{let Be=[],xt=0;for(let[It,Xt]of uo(be,je))Be.push(je.slice(xt,It),re("mark",null,je.slice(It,Xt))),xt=Xt;return Be.push(je.slice(xt)),Be},Ke=(pe.events??[]).map(je=>{let Be=re("tr",{"data-id":je.id,tabindex:"0"},re("td",null,_t(je.t,t)),re("td",null,je.dur!==void 0?bc(je.dur):je.open?"still going":""),re("td",null,je.source),re("td",null,je.kind),re("td",{class:`sev-${je.severity}`},je.severity),re("td",{class:"tlx-sum"},...ve(je.summary)),re("td",{class:"tlx-scope"},je.scope));return Be.addEventListener("click",()=>ut(je)),Be.addEventListener("keydown",xt=>{xt.key==="Enter"&&ut(je)}),Be}),Ze=re("button",{type:"button",class:"btn sm quiet","aria-label":"Close the table"},"Close");Ze.addEventListener("click",()=>{E=void 0,qe.hidden=!0,me()});let Ln=je=>{let Be=re("button",{type:"button",class:"btn sm","data-export":je},je.toUpperCase());return Be.addEventListener("click",()=>{Et(je)}),Be};qe.replaceChildren(re("div",{class:"tlx-table-head"},re("strong",null,`${pe.total} event${pe.total===1?"":"s"}`),re("span",null,` ${_t(E.from,t)} \u2013 ${_t(E.to,t)}${pe.total>500?" (the first 500 shown; the export has them all)":""}`),re("span",{class:"spacer"}),re("span",null,"Export: "),Ln("json"),Ln("csv"),Ze),re("div",{class:"tlx-table-wrap"},re("table",null,re("thead",null,re("tr",null,...["When","Long","Source","Kind","Severity","What","Scope"].map(je=>re("th",{scope:"col"},je)))),re("tbody",null,...Ke)))),qe.hidden=!1}async function St(){if(!E)return[];let D=[],se;do{let pe=await e.source.query(T(E.from,E.to,{kind:"single"},{limit:1e4,...se?{cursor:se}:{}}));D.push(...pe.events??[]),se=pe.next}while(se&&D.length<2e5);return D}async function Et(D){let se=await St(),pe=D==="json"?ha(se,B):ga(se,B),be=`timeline-${new Date(E.from).toISOString().slice(0,16).replace(/:/g,"")}.${D}`,ve=D==="json"?"application/json":"text/csv";if(e.onExport){e.onExport(be,pe,ve);return}let Ke=re("a",{href:`data:${ve};charset=utf-8,${encodeURIComponent(pe)}`,download:be});document.body.append(Ke),Ke.click(),Ke.remove()}function ut(D){if($=D,me(),!D){De.hidden=!0;return}let se=a?.sources.find(Be=>Be.name===D.source),pe=new Set(se?.sensitive??[]),be=o(u),ve=Be=>{let xt=[],It=0;for(let[Xt,go]of uo(be,Be))xt.push(Be.slice(It,Xt),re("mark",null,Be.slice(Xt,go))),It=go;return xt.push(Be.slice(It)),xt},Ke=(Be,xt)=>{if(!xt)return null;let It=re("button",{type:"button",class:"btn sm"},Be);return It.addEventListener("click",xt),It},Ze=Object.entries(D.attrs).map(([Be,xt])=>{if(!pe.has(Be))return re("tr",null,re("th",{scope:"row"},Be),re("td",null,...ve(String(xt))));let It=re("button",{type:"button",class:"btn sm quiet",title:"This can name a remote host, a folder or free text"},"Show"),Xt=re("td",{class:"tlx-sensitive"},"hidden ",It);return It.addEventListener("click",()=>Xt.replaceChildren(String(xt))),re("tr",null,re("th",{scope:"row"},Be),Xt)}),Ln=re("button",{type:"button",class:"btn sm quiet tlx-close","aria-label":"Close"},"\xD7");Ln.addEventListener("click",()=>ut(void 0));let je=hr(D.scope).slice(1).map(Be=>{let xt=re("button",{type:"button",class:"tlx-crumb"},z(Be.scope,Be.label));return xt.addEventListener("click",()=>Je(Be.scope)),xt});De.replaceChildren(re("div",{class:"tlx-detail-head"},re("strong",null,D.kind),Ln),re("p",{class:`tlx-sev sev-${D.severity}`},`${D.severity} \xB7 ${se?.title??D.source}`),re("p",{class:"tlx-sum"},...ve(D.summary)),re("p",null,_t(D.t,t),D.dur!==void 0?` \xB7 ${bc(D.dur)}${D.open?" so far":""}`:D.open?" \xB7 still going":""),re("p",{class:"tlx-crumbs small"},...je),...Ze.length?[re("table",{class:"tlx-attrs"},re("tbody",null,...Ze))]:[],re("div",{class:"tlx-links"},...(e.actions?.(D)??[]).map(([Be,xt])=>Ke(Be,xt)))),De.hidden=!1}function Fs(D,se){let pe=Cs({from:D,to:se});if(!G.find(Ze=>Ze.from===D&&Ze.to===se))return;if(R.add(pe),!r){I.set(pe,1),me();return}let ve=performance.now(),Ke=Ze=>{let Ln=Math.min(1,(Ze-ve)/260);I.set(pe,1-(1-Ln)**3),Re(),Ln<1&&requestAnimationFrame(Ke)};requestAnimationFrame(Ke)}let At,ys=D=>D.clientX-we.getBoundingClientRect().left;we.addEventListener("pointerdown",D=>{let se=ys(D),pe=D.clientY-we.getBoundingClientRect().top,be=D.target.closest?.(".tlx-cut");if(be){D.preventDefault(),Fs(Number(be.getAttribute("data-from")),Number(be.getAttribute("data-to")));return}we.setPointerCapture(D.pointerId),At={kind:pe<Hn||D.shiftKey?"brush":D.target.classList.contains("tlx-handle")?"scrub":"pan",x0:se,t0:X.t(se),v0:m,moved:!1},D.preventDefault(),Oe.focus({preventScroll:!0})}),we.addEventListener("pointermove",D=>{if(!At)return;let se=ys(D);if(Math.abs(se-At.x0)>3&&(At.moved=!0),!!At.moved)if(At.kind==="pan"){let pe=(At.x0-se)*X.msPerPx;m={t0:At.v0.t0+pe,t1:At.v0.t1+pe},v=!1,_()}else At.kind==="scrub"?Tt(X.t(se)):(E={from:Math.min(At.t0,X.t(se)),to:Math.max(At.t0,X.t(se))},me())}),we.addEventListener("pointerup",D=>{let se=At;if(At=void 0,!se)return;let pe=ys(D);if(se.kind==="brush"&&se.moved){vt(se.t0,X.t(pe));return}if(se.kind==="brush"&&!se.moved){Tt(X.t(pe));return}if(se.kind==="pan"&&!se.moved){let be=D.target.closest?.("[data-id]")?.getAttribute("data-id"),ve=be?[...y?.events??[],...y?.spans??[]].find(Ke=>Ke.id===be):void 0;ve?(ut(ve),Tt(ve.t)):Tt(X.t(pe))}}),we.addEventListener("keydown",D=>{let se=D.target.closest?.(".tlx-cut");se&&(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),Fs(Number(se.getAttribute("data-from")),Number(se.getAttribute("data-to"))))}),we.addEventListener("wheel",D=>{D.preventDefault();let se=ys(D);if(D.shiftKey||Math.abs(D.deltaX)>Math.abs(D.deltaY)){let pe=(D.shiftKey?D.deltaY:D.deltaX)*X.msPerPx;m={t0:m.t0+pe,t1:m.t1+pe},v=!1}else Bs(X.t(se),Math.exp(D.deltaY*.0015),se/Qe());_()},{passive:!1});function Bs(D,se,pe=.5){let be=Math.min(400*rn,Math.max(1e4,(m.t1-m.t0)*se));m={t0:D-pe*be,t1:D+(1-pe)*be},R.clear(),I.clear(),se<1&&(v=h&&m.t1>=de())}Oe.addEventListener("keydown",D=>{let se=m.t1-m.t0;if(D.key==="ArrowLeft"||D.key==="ArrowRight"){let pe=se*.15*(D.key==="ArrowLeft"?-1:1);m={t0:m.t0+pe,t1:m.t1+pe},v=!1}else if(D.key==="+"||D.key==="=")Bs((m.t0+m.t1)/2,.6);else if(D.key==="-"||D.key==="_")Bs((m.t0+m.t1)/2,1/.6);else if(D.key==="n"||D.key==="N"){tt(D.shiftKey?-1:1),D.preventDefault();return}else if(D.key==="Escape")ut(void 0),E=void 0,qe.hidden=!0;else return;D.preventDefault(),_()}),n.addEventListener("keydown",D=>{D.key==="/"&&document.activeElement!==fe&&!D.target.closest("input, select, textarea")&&(D.preventDefault(),fe.focus())}),Fe.addEventListener("scroll",()=>me(),{passive:!0}),te.addEventListener("click",async()=>{let D=`${hr(c).slice(-1)[0].label}${u?`: ${u}`:""}`.slice(0,80);await e.saveView?.({...Q(),name:D}),await xn()});let Ve=[];async function xn(){e.views&&(Ve=await e.views(),V.replaceChildren(re("option",{value:""},"Saved views\u2026"),...Ve.map((D,se)=>re("option",{value:String(se)},D.name))))}V.addEventListener("change",()=>{let D=Ve[Number(V.value)];D&&(ne(D),Pe(),_(!0)),V.value=""});let ot=typeof ResizeObserver=="function"?new ResizeObserver(()=>me()):void 0;ot?.observe(Oe);let Gt=(async()=>{a=await e.source.catalog(),B=a.sources.flatMap(be=>(be.sensitive??[]).map(ve=>`${be.name}.${ve}`));for(let be of a.sources)for(let ve of be.series)U.set(ve.name,{unit:ve.unit,type:ve.type,title:ve.title,source:be.name});c=a.hosts.length===1?`host:${a.hosts[0].replace(/[%/:\s]/g,be=>`%${be.charCodeAt(0).toString(16).toUpperCase().padStart(2,"0")}`)}`:"";let se=a.now;m={t0:se-rn,t1:se+rn*.02};let pe=ke()??e.view;pe&&ne(pe),Pe(),await xn(),await _(!0),u&&await ze()})();return{el:n,ready:Gt,get view(){return Q()},setView(D){return ne(D),Pe(),_(!0)},setRange(D,se){return m={t0:D,t1:se},v=!1,_()},setPlayhead:Tt,setLive:ft,setTheme:l,refresh:()=>_(!0),internal:{get result(){return y},get mode(){return he()},get scale(){return X},get gaps(){return G},get playState(){return x},get hits(){return O},get selected(){return $},get follow(){return v},openCut:Fs,showTable:vt,rangeEvents:St,exportRange:Et,select:ut,stepHit:tt,drill:Je,findHits:ze,paint:Re,lines:S},dispose(){P?.(),ot?.disconnect(),A&&cancelAnimationFrame(A),n.replaceChildren()}}}var nh={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}},zt=n=>(Math.round(n*10)/10).toString(),bd=n=>(n??"link").replace(/[^\w-]/g,"_");function xa(n,e){let{id:t}=e,s=e.styles??{},r=n.options,o=n.bounds,i=new Map,l=(h,b)=>{let m=s[h]??{},y=b==="start"?m.start??"none":m.end??"arrow";if(y!=="none")return(i.get(h)??i.set(h,new Set).get(h)).add(y),`url(#${t}-mk-${h}-${y})`},a="",c="",f="",u="";for(let h of[...n.panels].sort((b,m)=>b.depth-m.depth)){let b=h.rect,m=h.label?Te("text",{class:"pl",x:h.titleAt[0],y:h.titleAt[1]},mt(h.label)+(h.sub?Te("tspan",{class:"pls",dx:10},mt(h.sub)):"")):"";a+=Te("g",{class:`panel k-${h.role??"grey"}`,"data-id":h.id},Te("rect",{class:"face",x:zt(b.l),y:zt(b.t),width:zt(b.r-b.l),height:zt(b.b-b.t),rx:r.panelRx})+m)}for(let h of n.links){if(!h.points.length)continue;let b=bd(h.kind);c+=Te("path",{class:`conn k-${b}`,d:"M"+h.points.map(m=>`${zt(m[0])},${zt(m[1])}`).join(" L"),"data-id":h.id,"data-a":h.a,"data-b":h.b,"marker-start":l(b,"start"),"marker-end":l(b,"end")}),h.at&&(u+=Te("text",{class:`cl k-${b}`,x:h.at.x,y:h.at.y,"text-anchor":h.at.anchor==="start"?void 0:h.at.anchor,"data-for":h.id},mt(h.at.text)))}for(let h of n.cards){let b=h.rect;f+=Te("g",{class:`card k-${h.role??"grey"}${h.ghost?" ghost":""}`,"data-id":h.id,tabindex:0,role:"button","aria-label":h.sub?`${h.label}: ${h.sub}`:h.label},Te("rect",{class:"face",x:zt(b.l),y:zt(b.t),width:r.W,height:r.H,rx:r.cardRx})+Te("text",{class:"lt",x:zt(b.l+14),y:zt(b.t+24)},mt(h.label))+(h.sub?Te("text",{class:"st",x:zt(b.l+14),y:zt(b.t+42)},mt(h.sub)):""))}let d="";for(let[h,b]of i)for(let m of b){let y=nh[m];d+=Te("marker",{id:`${t}-mk-${h}-${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-${h}`}))}return Te("svg",{xmlns:"http://www.w3.org/2000/svg",class:"flat",viewBox:`${zt(o.l)} ${zt(o.t)} ${zt(o.r-o.l)} ${zt(o.b-o.t)}`,role:"img","aria-label":e.title??"drawing, flat view","data-view":"2d"},(d?Te("defs",{},d):"")+Te("g",{class:"panels"},a)+Te("g",{class:"conns"},c)+Te("g",{class:"cards"},f)+Te("g",{class:"labels"},u))}function yd(n={}){let e=s=>s?s.startsWith("#")||s.includes("(")?s:`var(--${s})`:"var(--ink)",t=`
|
|
369
406
|
.flat{font-family:inherit}
|
|
370
407
|
.flat .card{cursor:pointer;outline:none}
|
|
371
408
|
.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}
|
|
@@ -383,8 +420,8 @@ ${e.extraBody??""}
|
|
|
383
420
|
.flat .panel.sel .face{stroke:var(--accent,#2f6fd6);stroke-width:2}
|
|
384
421
|
.flat .conn.hot{stroke-width:3}
|
|
385
422
|
.flat .conn.dim,.flat .cl.dim{opacity:.3}
|
|
386
|
-
`;for(let[s,r]of Object.entries(n)){let o=
|
|
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=`
|
|
423
|
+
`;for(let[s,r]of Object.entries(n)){let o=bd(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}}
|
|
424
|
+
`}return t}var sh={name:["card","lt"],sub:["card","st"],title:["panel","pl"],titleSub:["panel","pls"],label:["","cl"]};function wa(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,[l,a]]of Object.entries(sh)){let c=document.createElementNS(e,"g");l&&c.setAttribute("class",l);let f=document.createElementNS(e,"text");f.setAttribute("class",a),c.appendChild(f),t.appendChild(c),s[i]=f}let r=new Map,o=((i,l)=>{let a=l+"\0"+i,c=r.get(a);return c===void 0&&(s[l].textContent=i,c=s[l].getComputedTextLength(),r.set(a,c)),c});return o.dispose=()=>t.remove(),o}var xd=(n,e)=>n.cards.find(t=>t.id===e)?.rect??n.panels.find(t=>t.id===e)?.rect;var bs="http://www.w3.org/2000/svg";function va(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??Zt(r.raw.from).id,l=o?.b??Zt(r.raw.to).id;for(let a of n.querySelectorAll(`[data-id="${CSS.escape(r.id)}"]`))a.setAttribute("data-a",i),a.setAttribute("data-b",l)}}var rh=(n="auto")=>n==="always"||n==="auto"&&!(typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches);function vd(n,e,t,s,r={}){let o=r.duration??600;if(!o||!rh(r.motion))return;let i=ho(n,e,t,s);n.appendChild(i.svg),i.at(0);let l=0,a=!1,c,f=new Promise(b=>c=b),u=()=>{a||(a=!0,cancelAnimationFrame(l),i.svg.remove(),c())},d=performance.now(),h=b=>{if(a)return;let m=Math.min(1,(b-d)/o);i.at(m),m<1?l=requestAnimationFrame(h):u()};return l=requestAnimationFrame(h),{done:f,finish:u}}var ns=n=>Math.max(0,Math.min(1,n)),po=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2;function ka(n){let e=n.cloneNode(!0),t=[n,...n.querySelectorAll("*")],s=[e,...e.querySelectorAll("*")];return t.forEach((r,o)=>{let i=getComputedStyle(r),l=s[o];l.removeAttribute("class"),l.removeAttribute("tabindex");for(let a 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"])l.style.setProperty(a,i.getPropertyValue(a))}),e}var wc=(n,e)=>{let t=n.getBoundingClientRect();return{x:t.left-e.left,y:t.top-e.top,w:t.width,h:t.height}},wd=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}},oh=(n,e)=>{let t=n.getScreenCTM();return`matrix(${t.a} ${t.b} ${t.c} ${t.d} ${t.e-e.left} ${t.f-e.top})`},kd=(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 ih(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 ho(n,e,t,s){let r=n.getBoundingClientRect(),o=document.createElementNS(bs,"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=$=>{let E=document.createElementNS(bs,"g");return E.setAttribute("transform",oh($,r)),E},l=$=>$.hasAttribute("data-a")||$.hasAttribute("data-for"),a=$=>{let E=new Map;for(let v of $.querySelectorAll("[data-id]")){if(l(v)||v.parentElement?.closest("[data-id]")||v.closest(".overlay"))continue;let A=v.getAttribute("data-id");(E.get(A)??E.set(A,[]).get(A)).push(v)}return E},c=a(e),f=a(t),u=document.createElementNS(bs,"g"),d=document.createElementNS(bs,"g"),h=i(e),b=i(t);for(let $ of e.querySelectorAll("[data-a],[data-for]"))$.closest(".overlay")||h.appendChild(ka($));for(let $ of t.querySelectorAll("[data-a],[data-for]"))$.closest(".overlay")||b.appendChild(ka($));u.appendChild(h),d.appendChild(b);let m=[...b.querySelectorAll("path")].map($=>{let E=$.getTotalLength?.()??0;return{p:$,len:E}}),y=[...b.children].filter($=>$.tagName.toLowerCase()==="text"),N=[...(s==="2d"?c:f).keys()],p=[],g=document.createElementNS(bs,"g");for(let $ of new Set([...N,...c.keys(),...f.keys()])){let E=c.get($),v=f.get($),A={};if(E){A.a=wd(E.map(R=>wc(R,r)));let O=document.createElementNS(bs,"g"),w=i(e);for(let R of E)w.appendChild(ka(R));O.appendChild(w),A.src=O}if(v){A.b=wd(v.map(R=>wc(R,r)));let O=document.createElementNS(bs,"g"),w=i(t);for(let R of v)w.appendChild(ka(R));O.appendChild(w),A.dst=O}let L=s==="3d"?E?.[0]:v?.[0],M=s==="3d"?v?.[0]:E?.[0],P=L?ih(L,r):void 0,k=M?.querySelector("rect.face");if(P&&k){let O=wc(k,r),w=[[O.x,O.y],[O.x+O.w,O.y],[O.x+O.w,O.y+O.h],[O.x,O.y+O.h]],R=P.pts.reduce((B,H,Y)=>H[0]<P.pts[B][0]?Y:B,0),I=[...P.pts.slice(R),...P.pts.slice(0,R)],G=[I[0],I[1],I[2],I[3]],X=getComputedStyle(k).fill,U=document.createElementNS(bs,"polygon");A.face=U,A.faceFrom=s==="3d"?G:w,A.faceTo=s==="3d"?w:G,A.faceFill=s==="3d"?[P.fill,X]:[X,P.fill]}A.src&&g.appendChild(A.src),A.face&&g.appendChild(A.face),A.dst&&g.appendChild(A.dst),p.push(A)}o.append(u,g,d);let x=($,E,v)=>`color-mix(in srgb, ${$} ${Math.round((1-v)*100)}%, ${E})`;return{svg:o,at($){let E=ns($/.2),v=po(ns(($-.2)/.6)),A=ns(($-.8)/.2);u.setAttribute("opacity",String(1-E));for(let{p:L,len:M}of m)L.style.strokeDasharray=`${M} ${M}`,L.style.strokeDashoffset=String(M*(1-A));d.setAttribute("opacity",String(A>0?1:0));for(let L of y)L.style.opacity=String(A);for(let L of p)if(L.src&&(L.src.setAttribute("transform",L.a&&L.b?kd(L.a,L.b,v):""),L.src.setAttribute("opacity",String(L.b?1-ns(v/(L.face?.35:.6)):1-v))),L.dst&&(L.dst.setAttribute("transform",L.a&&L.b?kd(L.b,L.a,1-v):""),L.dst.setAttribute("opacity",String(L.a?ns((v-(L.face?.65:.4))/(L.face?.35:.6)):v))),L.face){let M=L.faceFrom.map((P,k)=>[P[0]+(L.faceTo[k][0]-P[0])*v,P[1]+(L.faceTo[k][1]-P[1])*v]);L.face.setAttribute("points",M.map(P=>P.join(",")).join(" ")),L.face.style.fill=x(L.faceFill[0],L.faceFill[1],v),L.face.setAttribute("opacity",String(v<.08?v/.08:v>.92?(1-v)/.08:1))}}}}var ah=0;function Sd(n,e,t={}){let s=`dv${++ah}`,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 l=o.querySelector("svg");l.setAttribute("data-view","3d");let a=t.board??Qi(e);va(l,e,a);let c=new Set(e.routes.map(M=>M.id));for(let M of l.querySelectorAll("g[data-id]")){let P=M.getAttribute("data-id");c.has(P)||M.hasAttribute("tabindex")||!M.querySelector("polygon")||(M.setAttribute("tabindex","0"),M.setAttribute("role","button"),M.setAttribute("aria-label",P))}let f=wa(i),u=dr(a,f,t.flat);f.dispose(),i.innerHTML=xa(u,{id:s,title:t.title,styles:t.styles});let d=i.querySelector("svg");for(let M of[l,d])M.style.display="block",M.style.width="100%",M.style.height="auto";t.title&&l.setAttribute("aria-label",t.title);let h=t.mode??"3d",b,m=M=>M==="3d"?o:i,y=M=>M==="3d"?l:d,N=M=>{o.hidden=M!=="3d",i.hidden=M!=="2d";for(let P of[o,i])P.style.cssText="";r.style.height="",r.dataset.mode=M};N(h);let p=()=>{for(let M of[l,d]){for(let P of M.querySelectorAll("[data-id]"))P.classList.toggle("sel",!!b&&P.getAttribute("data-id")===b);for(let P of M.querySelectorAll("[data-a]")){let k=!!b&&(P.getAttribute("data-a")===b||P.getAttribute("data-b")===b);P.classList.toggle("hot",k),P.classList.toggle("dim",!!b&&!k),M.querySelector(`[data-for="${CSS.escape(P.getAttribute("data-id")??"")}"]`)?.classList.toggle("dim",!!b&&!k)}}},g=M=>{b=M,p()},x=M=>{let P=M.target.closest?.("[data-id]");if(!P||!r.contains(P)||P.hasAttribute("data-a"))return;let k=P.getAttribute("data-id");g(k),t.onSelect?.(k)},$=M=>{(M.key==="Enter"||M.key===" ")&&M.target.matches?.("[data-id][tabindex]")&&(M.preventDefault(),x(M))};r.addEventListener("click",x),r.addEventListener("keydown",$);let E,v=()=>{if(!E)return;cancelAnimationFrame(E.frame),E.layer.remove();let M=E;E=void 0,h=M.to,N(h),p(),M.done()},A=M=>{!M||!b||y(h).querySelector(`[data-id="${CSS.escape(b)}"][tabindex]`)?.focus({preventScroll:!0})};return{get mode(){return E?E.to:h},layout:u,root:r,morph:M=>{let P=r.contains(document.activeElement);if(E&&v(),M===h)return A(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)?(h=M,N(h),p(),A(P),Promise.resolve()):new Promise(w=>{let R=h,I=r.getBoundingClientRect().height;o.hidden=!1,i.hidden=!1;for(let ee of[o,i])ee.style.cssText="position:absolute;left:0;top:0;right:0;visibility:hidden";let G=m(M).getBoundingClientRect().height;r.style.height=`${I}px`;let X=ho(r,y(R),y(M),R);r.appendChild(X.svg);let U=t.duration??600,B=performance.now(),H={frame:0,layer:X.svg,to:M,done:()=>{A(P),w()}},Y=ee=>{if(E!==H)return;let F=Math.min(1,(ee-B)/U);X.at(F),r.style.height=`${I+(G-I)*po(ns((F-.2)/.6))}px`,F<1?H.frame=requestAnimationFrame(Y):v()};E=H,H.frame=requestAnimationFrame(Y)})},select:g,get selected(){return b},svgOf:y,destroy(){E&&v(),r.removeEventListener("click",x),r.removeEventListener("keydown",$),r.remove()}}}function $d(n="iso-view"){try{let e=localStorage.getItem(n);return e==="2d"||e==="3d"?e:void 0}catch{return}}function Md(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((a,c)=>{let f=document.createElement("button");return f.type="button",f.dataset.mode=a,f.textContent=(t.labels??["3D","2D"])[c],f.addEventListener("click",()=>{try{localStorage.setItem(s,a)}catch{}l(a);for(let u of r)u.morph(a)}),o.appendChild(f),f}),l=a=>i.forEach(c=>c.setAttribute("aria-pressed",String(c.dataset.mode===a)));return l(r[0]?.mode??"3d"),n.appendChild(o),o}var Td=`
|
|
388
425
|
.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)}
|
|
389
426
|
.view-switch button{font:inherit;border:0;background:none;color:var(--ink);padding:6px 10px;cursor:pointer}
|
|
390
427
|
.view-switch button+button{border-left:1px solid var(--line)}
|
|
@@ -394,4 +431,4 @@ ${e.extraBody??""}
|
|
|
394
431
|
.dual-view .blk.sel polygon{stroke:var(--accent,#2f6fd6);stroke-width:2.4}
|
|
395
432
|
.dual-view [data-a].dim{opacity:.3}
|
|
396
433
|
.dual-view [data-a].hot path{stroke-width:3.4}
|
|
397
|
-
`;export{
|
|
434
|
+
`;export{If as core,Lu as objects,Ed as viewer};
|