koboyo 0.4.0 → 0.5.1

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.
Files changed (169) hide show
  1. package/README.md +26 -0
  2. package/assets/editor/assets/ContextMenuTrigger-C6XZ9rqq.js +1 -0
  3. package/assets/editor/assets/{IconHelp-CaEwHrsN.js → IconHelp-Bf6OkQYw.js} +2 -2
  4. package/assets/editor/assets/IconReplace-CYUD1RLF.js +1 -0
  5. package/assets/editor/assets/IconSquare-Ce_qY-mF.js +1 -0
  6. package/assets/editor/assets/MenuSubmenuTrigger-CTLO1z_0.js +1 -0
  7. package/assets/editor/assets/{PopoverPopup-B3Y0VRYc.js → PopoverPopup-CvnB7nJs.js} +1 -1
  8. package/assets/editor/assets/asset-glyph-Dxg-7b67.js +1 -0
  9. package/assets/editor/assets/build-pips-DsgLkk6R.js +1 -0
  10. package/assets/editor/assets/build-visibility-0Y4EP2Ka.js +1 -0
  11. package/assets/editor/assets/builders-hABCgtrj.js +1 -0
  12. package/assets/editor/assets/{chrome-layout-BzPU9far.js → chrome-layout-500Q9pcx.js} +1 -1
  13. package/assets/editor/assets/code-panel-CHMqHqc6.js +18 -0
  14. package/assets/editor/assets/color-swatches-BC1-16T-.js +1 -0
  15. package/assets/editor/assets/{command-palette-BR-_ChOL.js → command-palette-BNj4FPOh.js} +1 -1
  16. package/assets/editor/assets/connector-labels-piWvprqQ.js +2 -0
  17. package/assets/editor/assets/{copy-image-dialog-BzGP7Xw8.js → copy-image-dialog-BdQfoSGr.js} +1 -1
  18. package/assets/editor/assets/core-DnS-1skV.js +1 -0
  19. package/assets/editor/assets/create-Bd0K44Bi.js +1 -0
  20. package/assets/editor/assets/custom-shape-view-_TxDE4zO.js +1 -0
  21. package/assets/editor/assets/custom-shapes-D3n9PjCN.js +1 -0
  22. package/assets/editor/assets/diagram-fingerprint-CtYYDDQV.js +3 -0
  23. package/assets/editor/assets/edit-NIyQT3d_.js +1 -0
  24. package/assets/editor/assets/editor-CpiNbiMQ.js +1 -0
  25. package/assets/editor/assets/{elk-api-C4wlHVIw.js → elk-api-DfUWdVFD.js} +1 -1
  26. package/assets/editor/assets/elk-worker-loader-D09QKxa0.js +3 -0
  27. package/assets/editor/assets/embed-input-D77Udvni.js +1 -0
  28. package/assets/editor/assets/excalidraw-D0kr_KKg.js +1 -0
  29. package/assets/editor/assets/export-DUFOrZJ-.js +6 -0
  30. package/assets/editor/assets/export-HJI2Aq3h.js +2 -0
  31. package/assets/editor/assets/export-dialog-Edoe6LBK.js +1 -0
  32. package/assets/editor/assets/flow-layer-DX6oKkg8.js +1 -0
  33. package/assets/editor/assets/flow-panel-BsbC8WAJ.js +1 -0
  34. package/assets/editor/assets/flow-stage-DFvraJ0j.js +1 -0
  35. package/assets/editor/assets/{flow-start-CpAvU-9P.js → flow-start-D_gK7Gur.js} +1 -1
  36. package/assets/editor/assets/flows-BAU4NQGk.js +3 -0
  37. package/assets/editor/assets/frames-C-jROub3.js +5 -0
  38. package/assets/editor/assets/generate-BWJhhTxM.js +26 -0
  39. package/assets/editor/assets/geometry-CVRSymIE.js +1 -0
  40. package/assets/editor/assets/icon-picker-cggWIJiD.js +1 -0
  41. package/assets/editor/assets/icons-K7FjuB-c.js +2 -0
  42. package/assets/editor/assets/{image-library-JQu_tb8P.js → image-library-BG41F2Zi.js} +1 -1
  43. package/assets/editor/assets/{index-DBrN0u0i.css → index-B0dKwEIM.css} +1 -1
  44. package/assets/editor/assets/index-BSs3RHtR.js +25 -0
  45. package/assets/editor/assets/layout-offthread-3DtYtT7h.js +18 -0
  46. package/assets/editor/assets/layout.worker-B99h3Wv0.js +28 -0
  47. package/assets/editor/assets/menu-rOnlAYaK.js +1 -0
  48. package/assets/editor/assets/mermaid-paste-C1_G99Lz.js +1 -0
  49. package/assets/editor/assets/panel-controls-BT48HF6c.js +1 -0
  50. package/assets/editor/assets/{panel-shell-BnMOHgWM.js → panel-shell-CSvihB5L.js} +1 -1
  51. package/assets/editor/assets/plan-BS_pzMjA.js +1 -0
  52. package/assets/editor/assets/presentation-DlKoEXsq.js +1 -0
  53. package/assets/editor/assets/{presenter-keys-Bs3LnmOa.js → presenter-keys-uSrN0NG3.js} +1 -1
  54. package/assets/editor/assets/rich-paste-route-Bx69sREx.js +1 -0
  55. package/assets/editor/assets/ride-overlay-ChaS8O9D.js +1 -0
  56. package/assets/editor/assets/selection-overlay-primitives-DXtdWjNx.js +1 -0
  57. package/assets/editor/assets/shape-meta-CZ0aZy7a.js +1 -0
  58. package/assets/editor/assets/shape-render-PK6dqxxf.js +1 -0
  59. package/assets/editor/assets/shapes-CHDGoELO.js +11 -0
  60. package/assets/editor/assets/shared-DKcKntwk.js +1 -0
  61. package/assets/editor/assets/{slide-notes-dialog-BQBXpep6.js → slide-notes-dialog-CypGkEmF.js} +1 -1
  62. package/assets/editor/assets/slides-panel-D22Fponu.js +26 -0
  63. package/assets/editor/assets/table-PnIQtvp1.js +7 -0
  64. package/assets/editor/assets/text-breaks-BDwq8Wxj.js +7 -0
  65. package/assets/editor/assets/{theme-palette-Dl_G_VIJ.js → theme-palette-DZtiNUYJ.js} +1 -1
  66. package/assets/editor/assets/tidy-browser-DqAPzbkG.js +1 -0
  67. package/assets/editor/assets/tidy-scope-CQinfwtO.js +1 -0
  68. package/assets/editor/assets/tldraw-DSRiyEEW.js +2 -0
  69. package/assets/editor/assets/tool-catalog-DM8xoisn.js +1 -0
  70. package/assets/editor/assets/tool-drawer-hovu85Xd.js +1 -0
  71. package/assets/editor/assets/{tooltip-CyBz17g8.js → tooltip-ClTJbfBH.js} +1 -1
  72. package/assets/editor/assets/tree-Ch-RF7UJ.js +1 -0
  73. package/assets/editor/assets/use-export-command-CZva79qg.js +2 -0
  74. package/assets/editor/assets/use-grid-keyboard-nav-BhzrY178.js +0 -0
  75. package/assets/editor/assets/{use-icon-node-BxqH7H27.js → use-icon-node-B5V42drv.js} +1 -1
  76. package/assets/editor/assets/{use-key-held-094C3Mn3.js → use-key-held-DRn09Hq8.js} +1 -1
  77. package/assets/editor/assets/use-web-environment-Ce65LEhf.js +1 -0
  78. package/assets/editor/assets/useTriggerFocusGuards-Mibi8yYw.js +1 -0
  79. package/assets/editor/assets/web-card-BTru0lge.js +1 -0
  80. package/assets/editor/assets/web-card-font-BbZEq3En.js +1 -0
  81. package/assets/editor/assets/web-controls-DIAT8wcZ.js +1 -0
  82. package/assets/editor/assets/web-embed-dialog-CnaSzcu9.js +1 -0
  83. package/assets/editor/assets/web-embed-url-CHu4SU82.js +1 -0
  84. package/assets/editor/assets/web-embeds-I3saJ_yp.js +1 -0
  85. package/assets/editor/assets/web-html-dialog-DpkLs7qD.js +1 -0
  86. package/assets/editor/assets/web-runtime-DNdRiAlf.js +1 -0
  87. package/assets/editor/assets/web-widget-limits-DeMquLIR.js +1 -0
  88. package/assets/editor/assets/web-widgets-DsFUBhiq.js +325 -0
  89. package/assets/editor/assets/widget-source-C3N9ZKTz.js +2 -0
  90. package/assets/editor/assets/widget-target-C9a207gT.js +1 -0
  91. package/assets/editor/index.html +46 -40
  92. package/dist/koboyo.js +605 -269
  93. package/package.json +3 -3
  94. package/skills/koboyo/SKILL.md +8 -3
  95. package/skills/koboyo/references/architecture.md +3 -1
  96. package/skills/koboyo/references/bpmn.md +1 -1
  97. package/skills/koboyo/references/chart.md +1 -1
  98. package/skills/koboyo/references/cycle.md +1 -1
  99. package/skills/koboyo/references/erd.md +1 -1
  100. package/skills/koboyo/references/flowchart.md +1 -1
  101. package/skills/koboyo/references/funnel.md +1 -1
  102. package/skills/koboyo/references/gantt.md +1 -1
  103. package/skills/koboyo/references/gitgraph.md +1 -1
  104. package/skills/koboyo/references/journey.md +1 -1
  105. package/skills/koboyo/references/matrix.md +1 -1
  106. package/skills/koboyo/references/mindmap.md +1 -1
  107. package/skills/koboyo/references/orgchart.md +1 -1
  108. package/skills/koboyo/references/pyramid.md +1 -1
  109. package/skills/koboyo/references/sankey.md +1 -1
  110. package/skills/koboyo/references/sequence.md +1 -1
  111. package/skills/koboyo/references/statemachine.md +1 -1
  112. package/skills/koboyo/references/timeline.md +1 -1
  113. package/skills/koboyo/references/venn.md +1 -1
  114. package/skills/koboyo/references/wireframe.md +1 -1
  115. package/assets/editor/assets/MenuSubmenuTrigger-KacA9GM8.js +0 -1
  116. package/assets/editor/assets/asset-glyph-C1E6cGwM.js +0 -1
  117. package/assets/editor/assets/build-pips-BV-uwXlP.js +0 -1
  118. package/assets/editor/assets/build-visibility-DyML9SHt.js +0 -1
  119. package/assets/editor/assets/builders-DMHAOPEv.js +0 -1
  120. package/assets/editor/assets/chart-4iRduYdU.js +0 -7
  121. package/assets/editor/assets/code-panel-koBUgEWp.js +0 -43
  122. package/assets/editor/assets/connector-labels-CrEgadsC.js +0 -2
  123. package/assets/editor/assets/core-CmsJyU_-.js +0 -1
  124. package/assets/editor/assets/diagram-fingerprint-WGQ5iVXx.js +0 -3
  125. package/assets/editor/assets/edit-C0sBxxsg.js +0 -1
  126. package/assets/editor/assets/editor-BeufBV54.js +0 -1
  127. package/assets/editor/assets/elk-worker-loader-CVBdN1je.js +0 -3
  128. package/assets/editor/assets/excalidraw-BwgRIDi9.js +0 -1
  129. package/assets/editor/assets/export-Bce6ra0N.js +0 -2
  130. package/assets/editor/assets/export-K2VWg76n.js +0 -6
  131. package/assets/editor/assets/export-dialog-x2n2a4KX.js +0 -1
  132. package/assets/editor/assets/flow-layer-ewaL7g2y.js +0 -1
  133. package/assets/editor/assets/flow-panel-BzXNGGke.js +0 -1
  134. package/assets/editor/assets/flow-stage-Ba_CAggI.js +0 -1
  135. package/assets/editor/assets/flows-Cj7AFMIA.js +0 -3
  136. package/assets/editor/assets/frames-Cp1QD3LR.js +0 -1
  137. package/assets/editor/assets/icon-picker-Cg39IKNJ.js +0 -1
  138. package/assets/editor/assets/icon-sources-CZI1h18s.js +0 -1
  139. package/assets/editor/assets/icons-DzW1j-r3.js +0 -2
  140. package/assets/editor/assets/index-CBPPqsiR.js +0 -24
  141. package/assets/editor/assets/layout-offthread-mRHRulkS.js +0 -18
  142. package/assets/editor/assets/layout.worker-CekYkaxO.js +0 -27
  143. package/assets/editor/assets/menu-B9BAk63v.js +0 -1
  144. package/assets/editor/assets/panel-controls-DWVXiNUZ.js +0 -1
  145. package/assets/editor/assets/plan-CkgM52Yh.js +0 -1
  146. package/assets/editor/assets/presentation-DJUO0t7I.js +0 -1
  147. package/assets/editor/assets/reflow-DaYiVkwp.js +0 -1
  148. package/assets/editor/assets/registry-rEGZW7Ab.js +0 -1
  149. package/assets/editor/assets/ride-overlay-Hx90v4ZK.js +0 -1
  150. package/assets/editor/assets/selection-overlay-primitives-BRp854AD.js +0 -1
  151. package/assets/editor/assets/shape-meta-COE2ATNh.js +0 -1
  152. package/assets/editor/assets/shared-DjLCTIA9.js +0 -1
  153. package/assets/editor/assets/slides-D686obFO.js +0 -15
  154. package/assets/editor/assets/slides-panel-BEJCevJi.js +0 -26
  155. package/assets/editor/assets/style-BENGW2ZV.js +0 -1
  156. package/assets/editor/assets/text-breaks-DM4W6y5f.js +0 -7
  157. package/assets/editor/assets/tidy-browser-dF3BON7J.js +0 -1
  158. package/assets/editor/assets/tidy-scope-BGG3ZXvZ.js +0 -1
  159. package/assets/editor/assets/tldraw-CE87oKyq.js +0 -2
  160. package/assets/editor/assets/tool-catalog-DXPhX2S1.js +0 -1
  161. package/assets/editor/assets/tool-drawer-CWOX_njp.js +0 -1
  162. package/assets/editor/assets/tree-KSgPjntC.js +0 -1
  163. package/assets/editor/assets/use-export-command-sC9UHj3_.js +0 -2
  164. package/assets/editor/assets/use-grid-keyboard-nav-DhQKecO1.js +0 -0
  165. package/assets/editor/assets/web-controls-CLE9zr7i.js +0 -1
  166. package/assets/editor/assets/web-embed-dialog-XUNelFFM.js +0 -1
  167. package/assets/editor/assets/web-html-dialog-BcAyzH5D.js +0 -1
  168. package/assets/editor/assets/web-shape-C941TGTy.js +0 -1
  169. package/assets/editor/assets/widget-source-CHujvUeA.js +0 -1
@@ -0,0 +1,6 @@
1
+ import{$ as e,At as t,Bt as n,C as r,Ct as i,Dt as a,G as o,H as s,K as c,Mt as l,Ot as u,R as d,St as f,Tt as p,V as m,bt as h,c as g,ct as _,it as v,j as y,jt as b,k as x,kt as S,l as C,mt as w,nt as T,ot as E,pt as D,s as ee,st as te,u as ne,wt as re,xt as O,z as ie}from"./shapes-CHDGoELO.js";import{H as ae,X as k,ct as oe,it as se,k as ce,ot as le,rt as ue}from"./geometry-CVRSymIE.js";import{r as de}from"./custom-shapes-D3n9PjCN.js";import{$ as fe,bn as pe,c as me,h as he,i as ge,m as A,s as _e,u as ve}from"./frames-C-jROub3.js";import{A as ye,D as be,E as xe,O as Se,S as Ce,T as we,a as Te,i as Ee,k as De,t as j,w as Oe,y as ke}from"./table-PnIQtvp1.js";import{a as Ae,l as je,t as Me,u as M}from"./text-breaks-BDwq8Wxj.js";import{t as N}from"./web-card-font-BbZEq3En.js";import{n as P,t as Ne}from"./connector-labels-piWvprqQ.js";import{t as F}from"./web-card-BTru0lge.js";var I=`#ffffff`;function L(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function Pe(e){return String(e).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`)}function Fe(e){let t=Object.entries(e).filter(e=>e[1]!==void 0&&e[1]!==null&&e[1]!==``),n=t.filter(([e,t])=>e!==`style`&&typeof t==`string`&&t.includes(`var(--`));if(n.length===0)return t.map(([e,t])=>`${e}="${Pe(t)}"`).join(` `);let r=t.find(([e])=>e===`style`)?.[1],i=[...n.map(([e,t])=>`${e}:${t}`),...r?[r]:[]];return[...t.filter(e=>!n.includes(e)&&e[0]!==`style`),[`style`,i.join(`;`)]].map(([e,t])=>`${e}="${Pe(t)}"`).join(` `)}function R(e,t,n){let r=Fe(t);return n===void 0?`<${e}${r?` `+r:``}/>`:`<${e}${r?` `+r:``}>${n}</${e}>`}function z(e,t){if(e)return`rotate(${e} ${t.x+t.width/2} ${t.y+t.height/2})`}function Ie(e,t,n){if(!t&&!n)return;let r=`scale(${t?-1:1} ${n?-1:1})`;return`translate(${e.x} ${e.y}) ${r} translate(${-e.x} ${-e.y})`}function Le(e,t){let n=z(e.rotation??0,t),r=Ie({x:t.x+t.width/2,y:t.y+t.height/2},e.flipX,e.flipY);return r?n?`${n} ${r}`:r:n}var Re=`'JetBrains Mono', ui-monospace, monospace`,ze=.9,Be=`#fde68a`;function B(e,t){let n=e.fontSize??t;return e.code?n*ze:n}function V(e,t,n,r,i){let a=t.code?Re:n,o=B(t,r),s=t.bold?700:i??400;return e.measure(t.text,o,a,s,t.italic)}var H=.55,Ve=1.4,He=1.4;function Ue(e,t){return(e.depth??0)*He*t}function We(e){return e.kind===`bullet`?`• `:e.kind===`number`?`${e.text} `:null}function U(e,t,n,r,i,a){if(!e)return 0;let o=We(e);return o===null?Ve*t:a.measure(o,t,n,r)+i*o.length}function Ge(e,t,n,r,i,a){let o=r*.8,s=e+r*.25,c=t+(n-o)/2,l=R(`rect`,{x:s,y:c,width:o,height:o,rx:r*.15,fill:i?a:`none`,stroke:a,"stroke-width":1.5});if(!i)return l;let u=R(`path`,{d:`M ${s+o*.24} ${c+o*.54} L ${s+o*.44} ${c+o*.72} L ${s+o*.78} ${c+o*.3}`,fill:`none`,stroke:`#ffffff`,"stroke-width":Math.max(1.5,o*.12),"stroke-linecap":`round`,"stroke-linejoin":`round`});return R(`g`,{opacity:H},l+u)}function Ke(e,t,n,r,i,a){return Ae(e,t,e=>a.measure(e,n,r,i))}function qe(e){let t=[];for(let n of e)for(let e of n.text.split(/(\s+)/).filter(e=>e.length>0)){let r=e.trim().length===0,i=t[t.length-1];if(i&&i.space===r&&!r){i.piece.push({run:n,text:e});continue}t.push({space:r,piece:[{run:n,text:e}]})}return t}function W(e,t,n){let r=[],i=0;for(let a of e){let e=Array.from(a.text),o=Math.max(t-i,0),s=Math.min(n-i,e.length);o<s&&r.push({run:a.run,text:e.slice(o,s).join(``)}),i+=e.length}return r}function Je(e,t,n,r,i,a){let o=[];for(let s of e){let e=U(s.marker,r,n,i,0,a),c=Math.max(r,t-e-Ue(s,r)),l=[],u=0,d=!0,f=null,p=()=>{for(;l.length>0;){let e=l[l.length-1];if(e.text=e.text.replace(/\s+$/,``),e.text.length>0)break;l.pop()}o.push({runs:l,marker:d?s.marker:void 0,checked:s.checked,depth:s.depth}),d=!1,l=[],u=0,f=null},m=(e,t,n)=>{f===e&&l.length>0?l[l.length-1].text+=t:(l.push({...e,text:t}),f=e),u+=n},h=e=>e.reduce((e,t)=>e+V(a,{...t.run,text:t.text},n,r,i),0),g=(e,t)=>{for(let t of e)m(t.run,t.text,V(a,{...t.run,text:t.text},n,r,i));return t},_=e=>u+e<=c;for(let e of qe(s.runs)){if(e.space){_(h(e.piece))?g(e.piece,0):p();continue}let t=h(e.piece);if(_(t)){g(e.piece,t);continue}if(l.length>0&&p(),t<=c){g(e.piece,t);continue}let n=e.piece.map(e=>e.text).join(``),r=[0,...Me(n),Array.from(n).length];for(let t=0;t<r.length-1;t+=1){let n=W(e.piece,r[t],r[t+1]),i=h(n);if(_(i)){g(n,i);continue}if(l.length>0&&p(),i<=c){g(n,i);continue}let a=r[t+1]-r[t],o=0;for(let e=1;e<=a;e+=1){let t=W(n,o,e);e-o>1&&h(t)>c&&(g(W(n,o,e-1),0),p(),o=e-1)}g(W(n,o,a),0)}}p()}return o}function Ye(e){return e.fontSize*(e.lineHeight??1.2)}function Xe(e){return(e.letterSpacing??0)*e.fontSize}function Ze(e,t,n,r,i){let a=e;t.background&&(a=R(`rect`,{x:t.x-n/2-10,y:t.y-r/2,width:n+20,height:r,rx:2,fill:i.theme.paint(e=>e.bg,I)})+a);let o=t.rotateCenter;if(!o)return a;let s=[t.rotation?`rotate(${t.rotation} ${o.x} ${o.y})`:void 0,Ie(o,t.flipX,t.flipY)].filter(Boolean).join(` `);return s?R(`g`,{transform:s},a):a}function Qe(e,t,n){if(e)return t.fixedInk?e:n.theme.paint(t=>v(d(e),t),e)}function G(e,t){if(s(e.text)&&m())return $e(e,t);let n=k(e.fontFamily),r=e.maxWidth,i=c(e.text).split(`
2
+ `);r!==void 0&&(i=i.flatMap(i=>Ke(i,r,e.fontSize,e.fontFamily,n,t.text)));let a=e.ascent??l(e.fontSize,e.lineHeight??1.2),o=Ye(e),u=Xe(e),d=i.length*o,f=e.vAlign===`center`?e.y-d/2+a:e.vAlign===`bottom`?e.y-d+a:e.y+a,p=i.map((t,n)=>R(`tspan`,{x:e.x,y:f+n*o},L(t)||` `)).join(``);return Ze(R(`text`,{"font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":n,fill:e.color,"text-anchor":e.align,"white-space":`pre`,"letter-spacing":u||void 0},p),e,e.background?Math.max(...i.map(r=>t.text.measure(r,e.fontSize,e.fontFamily,n)+u*r.length)):0,d,t)}function $e(e,t){let n=k(e.fontFamily),r=o(e.text);e.maxWidth!==void 0&&(r=Je(r,e.maxWidth,e.fontFamily,e.fontSize,n,t.text));let a=e.lineHeight??1.2,s=e.letterSpacing??0,c=r.map(t=>Math.max(e.fontSize,...t.runs.map(t=>B(t,e.fontSize)))),u=c.map(e=>e*a),d=u.reduce((e,t)=>e+t,0),p=e.vAlign===`center`?e.y-d/2:e.vAlign===`bottom`?e.y-d:e.y,m=[],h=[],g=0,_=p;r.forEach((r,o)=>{let d=e.ascent?e.ascent/e.fontSize*c[o]:l(c[o],a),p=u[o],v=_,y=v+d;_+=p;let b=U(r.marker,e.fontSize,e.fontFamily,n,s*e.fontSize,t.text),x=r.runs.map(t=>B(t,e.fontSize)),S=r.runs.map((r,i)=>V(t.text,r,e.fontFamily,e.fontSize,n)+s*x[i]*r.text.length),C=S.reduce((e,t)=>e+t,0),w=Ue(r,e.fontSize),T=w+b+C;g=Math.max(g,T);let E=e.align===`middle`?e.x-T/2:e.align===`end`?e.x-T:e.x;if(E+=w,r.marker){let t=We(r.marker);t===null?m.push(Ge(E,v,p,e.fontSize,r.checked,e.color)):h.push(R(`tspan`,{x:E,y},L(t))),E+=b}r.runs.forEach((n,a)=>{let o=S[a],c=x[a];n.highlight&&m.push(R(`rect`,{x:E,y:y-c*f,width:o,height:c*(f+i),rx:3,fill:Be,opacity:r.checked?H:void 0}));let l=[n.href||n.underline?`underline`:``,n.strike?`line-through`:``].filter(Boolean).join(` `);h.push(R(`tspan`,{x:E,y,"font-style":n.italic?`italic`:void 0,"font-weight":n.bold?700:void 0,"font-family":n.code?Re:void 0,"font-size":c===e.fontSize?void 0:c,"letter-spacing":s?s*c:void 0,fill:n.href?ae:Qe(n.color,e,t),"fill-opacity":r.checked?H:void 0,"text-decoration":l||void 0},L(n.text)||` `)),E+=o})});let v=R(`text`,{"font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":n,fill:e.color,"text-anchor":`start`,"white-space":`pre`},h.join(``));return Ze(m.join(``)+v,e,g,d,t)}var et=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,tt=(()=>{let e=new Int8Array(128).fill(-1);for(let t=0;t<64;t+=1)e[et.charCodeAt(t)]=t;return e})();function nt(e){let t=e.replace(/[\s=]+$/g,``).replace(/\s+/g,``),n=``,r=0,i=0;for(let e=0;e<t.length;e+=1){let a=t.charCodeAt(e),o=a<128?tt[a]:-1;if(o<0)throw Error(`invalid base64`);i=i<<6|o,r+=6,r>=8&&(r-=8,n+=String.fromCharCode(i>>r&255))}return n}function rt(e,t){let n=se(e);return it(e)?t.theme.paint(e=>v(n,e),n):n}function it(e){return e.fill===`transparent`||e.fill===`#ffffff`||le(e)!==null}function at(t,n,r,i,a){let o=i.color===`transparent`?e:i.color,s=a.theme.paint(e=>v(o,e),o);return G({text:t,fontSize:r,fontFamily:i.fontFamily??ce,color:s,lineHeight:p,x:n.x,y:n.y,align:`middle`,vAlign:`center`,background:!0},a)}function ot(e,t,n){let r=e.label??``;return r?at(r,t,e.fontSize??20,e,n):``}function K(e,t,n,r){let i={};for(let[a,o]of Object.entries(e))i[a]=typeof o==`string`?n.paint(e=>w(a,o,t,t=>v(t,e),t=>te(t,e),r?E(r,e):void 0),o):o;return i}function q(e,t,n=`keep`,r){return e.filter(e=>e!==null).map(e=>R(e.tag,K(e.attrs,n,t,r))).join(``)}function st(e,t){let n=Oe(e);return q(n.strokes,t.theme)+q(n.heads,t.theme,`ink`)}function ct(e,t){let n=t.cachedNode(e);return n?n.map(([e,t])=>R(e,t)).join(``):``}function lt(e){let t=/^data:image\/svg\+xml(;base64)?,([\s\S]*)$/.exec(e.dataUrl);if(!t)return null;let n;try{n=t[1]?nt(t[2]):decodeURIComponent(t[2])}catch{return null}let r=/<svg\b[^>]*>/i.exec(n),i=n.lastIndexOf(`</svg>`);if(!r||i<0)return null;let a=/viewBox="([^"]*)"/i.exec(r[0])?.[1];if(!a)return null;let o={x:e.x,y:e.y,width:e.size,height:e.height,viewBox:a,fill:`currentColor`,color:e.ink},s=a.trim().split(/[\s,]+/).map(Number),[,,c,l]=s,u=s.length===4&&c>0&&l>0?Math.min(e.size/c,e.height/l):1,d=(e.weight??0)/u,f=n.slice(r.index+r[0].length,i);if(d>0)o.overflow=`visible`,o.stroke=`currentColor`,o[`stroke-width`]=d,o[`stroke-linejoin`]=`round`,o[`stroke-linecap`]=`round`;else if(d<0&&e.weightId){let t=`mono-erode-${e.weightId}`;f=R(`filter`,{id:t},R(`feMorphology`,{operator:`erode`,radius:-d/4}))+R(`g`,{filter:`url(#${t})`},f)}return R(`svg`,o,f)}function J(e){let{source:t,name:n,srcMap:r,icons:i,x:a,y:o,size:s,height:c=e.size,stroke:l,strokeWidth:u=2,weight:d,weightId:f}=e;if(A(t)){let e=i.assetIconUrl(t,n),u=r.get(e);if(u&&he(t)){let e=lt({dataUrl:u,x:a,y:o,size:s,height:c,ink:l,weight:d,weightId:f});if(e)return e}return R(`image`,{href:u??e,x:a,y:o,width:s,height:c})}return R(`g`,{transform:`translate(${a} ${o}) scale(${s/24})`,fill:`none`,stroke:l,"stroke-width":u,"stroke-linecap":`round`,"stroke-linejoin":`round`},ct(n,i))}function ut(e,t,n){let r=x(t),i=b(t.kind,r.width,r.height,{x:t.flipX,y:t.flipY}),a=r.x+i.x-28/2,o=r.y+i.y-28/2,s=R(`rect`,{x:a,y:o,width:28,height:28,rx:6,fill:`#ffffff`,stroke:t.color,"stroke-width":1.5}),c=J({source:e.source,name:e.name,srcMap:n.srcMap,icons:n.icons,x:a+5,y:o+5,size:18,stroke:t.color});return R(`g`,{transform:z(t.rotation??0,r)},s+c)}function dt(e,n,r){let i=x(n),a=n.fontSize??20,o=S(a),s=u(a),d=n.textPadding??6,f=n.textAlign??`center`,p=n.textVAlign??`middle`,m=k(n.fontFamily),h=c(n.label).split(`
3
+ `),g=t(n.kind,i.width,i.height,{x:n.flipX,y:n.flipY}),_=Math.max(a,i.width-g.left-g.right-d*2-o-s),v=h.map(e=>r.text.measure(e,a,n.fontFamily,m)),y=Math.min(_,Math.max(0,...v)),b=v.reduce((e,t)=>e+Math.max(1,Math.ceil(t/_)),0)*(a*(n.lineHeight??1.25)),C=p===`top`?i.y+d:p===`bottom`?i.y+i.height-d-b:i.y+i.height/2-b/2,w=o+s+y,T=f===`left`?i.x+d:f===`right`?i.x+i.width-d-w:i.x+i.width/2-w/2,E=C+l(a,n.lineHeight??1.25)-a*.3-o/2,D=rt(n,r),ee=J({source:e.source,name:e.name,srcMap:r.srcMap,icons:r.icons,x:T,y:E,size:o,stroke:D});return R(`g`,{transform:z(n.rotation??0,i)},ee)}function ft(e,t){let n=e=>e===void 0?void 0:t.paint(t=>D(e,t),D(e));return e.kind===`rect`?R(`rect`,{x:e.x,y:e.y,width:e.width,height:Math.max(0,e.height),rx:e.rx,fill:n(e.fill)}):e.kind===`line`?R(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:n(e.stroke),"stroke-width":e.width}):e.kind===`polyline`?R(`polyline`,{points:e.points.map(e=>`${e.x},${e.y}`).join(` `),fill:`none`,stroke:n(e.stroke),"stroke-width":e.width,"stroke-linecap":`round`,"stroke-linejoin":`round`}):e.kind===`path`?R(`path`,{d:e.d,fill:n(e.fill)??`none`,"fill-opacity":e.fillOpacity,stroke:n(e.stroke)??`none`,"stroke-width":e.width}):e.kind===`circle`?R(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:n(e.fill),stroke:n(e.stroke),"stroke-width":e.width}):R(`text`,{x:e.x,y:e.y,"font-family":e.family,"font-size":e.size,fill:n(e.color),"text-anchor":e.anchor,"dominant-baseline":e.baseline,transform:e.rotate?`rotate(${e.rotate} ${e.x} ${e.y})`:void 0},L(e.text))}function pt(e,n){if(!e.label)return``;let r=x(e),i=t(e.kind,r.width,r.height,{x:e.flipX,y:e.flipY}),a={x:r.x+i.left,y:r.y+i.top,width:r.width-i.left-i.right,height:r.height-i.top-i.bottom},o=rt(e,n),s=e.textAlign??`center`,c=e.textVAlign??`middle`,l=e.textPadding??6,d=e.fontSize??20,f=e.titleIcon?.placement===`inside`?S(d)+u(d):0;return G({text:e.label,fontSize:d,fontFamily:e.fontFamily,color:o,fixedInk:!it(e),lineHeight:e.lineHeight??1.25,letterSpacing:e.letterSpacing,x:s===`left`?a.x+l+f:s===`right`?a.x+a.width-l:a.x+a.width/2+f/2,y:c===`top`?a.y+l:c===`bottom`?a.y+a.height-l:a.y+a.height/2,align:s===`left`?`start`:s===`right`?`end`:`middle`,vAlign:c===`top`?`top`:c===`bottom`?`bottom`:`center`,maxWidth:a.width-l*2-f,rotation:e.rotation,rotateCenter:{x:a.x+a.width/2,y:a.y+a.height/2}},n)}function mt(e,t){let n=x(e),r=De(e),i={x:0,y:0,width:n.width,height:n.height},a=`translate(${n.x} ${n.y})`,o=z(e.rotation??0,i),s=e.fill===`#ffffff`?`paper`:`keep`,c=le(e)??void 0;return R(`g`,{transform:o?`${a} ${o}`:a},q([r.shadow],t.theme)+q([r.fill],t.theme,s,c)+q(r.strokes,t.theme,`keep`,c))}var ht={svg:(e,t)=>mt(e,t)+pt(e,t)+(e.titleIcon?e.titleIcon.placement===`inside`?dt(e.titleIcon,e,t):ut(e.titleIcon,e,t):``),assetUrls:(e,t)=>e.titleIcon&&A(e.titleIcon.source)?[t.assetIconUrl(e.titleIcon.source,e.titleIcon.name)]:[],link:e=>h(e.link)};function gt(e,t){let n=``;for(let r of Ne(e))n+=at(r.text,r.point,14,e,t);return n}var _t={svg:(e,t)=>st(e,t)+ot(e,n(e),t)+gt(e,t),labelBounds:P};function vt(e,t){if(!e.text)return``;let n=x(e,t.measurement),r=e.textAlign??`left`,i=e.textVAlign??`top`,a=k(e.fontFamily),o=(e.letterSpacing??0)*e.fontSize,s=e.width??Math.max(...c(e.text).split(`
4
+ `).map(n=>t.text.measure(n,e.fontSize,e.fontFamily,a)+o*n.length));return G({text:e.text,fontSize:e.fontSize,fontFamily:e.fontFamily,color:t.theme.paint(t=>v(e.color,t),e.color),lineHeight:e.lineHeight??1.15,letterSpacing:e.letterSpacing,x:r===`center`?e.x+s/2:r===`right`?e.x+s:e.x,y:e.height==null||i===`top`?e.y:i===`bottom`?e.y+n.height:e.y+n.height/2,align:r===`center`?`middle`:r===`right`?`end`:`start`,vAlign:e.height==null||i===`top`?`top`:i===`bottom`?`bottom`:`center`,maxWidth:e.width,ascent:l(e.fontSize,e.lineHeight??1.15),rotation:e.rotation,rotateCenter:{x:n.x+n.width/2,y:n.y+n.height/2},flipX:e.flipX,flipY:e.flipY},t)}var yt={svg:vt};function bt(e){return`light`in e&&`dark`in e}function xt(){return{paint:(e,t)=>t,css:()=>``,rootClass:void 0}}function St(e){return{paint:t=>t(e),css:()=>``,rootClass:void 0}}var Y=`koboyo-adaptive`;function Ct(e){if(ue(e.light.bg,1)<.5||ue(e.dark.bg,0)>=.5)throw Error(`an adaptive export needs a light palette and a dark one, in that order`);let t=new Map;return{paint(n){let r=n(e.light),i=n(e.dark);return r===i?r:`var(${wt(t,r,i)})`},css(){if(t.size===0)return``;let e=e=>[...t].map(([t,n])=>`${t}:${n[e]}`).join(`;`);return`.${Y}{${e(0)}}@media (prefers-color-scheme: dark){.${Y}{${e(1)}}}`},rootClass:Y}}function wt(e,t,n){let r=`--kb-${Tt(`${t}|${n}`)}`,i=r;for(let a=1;;a+=1){let o=e.get(i);if(!o)return e.set(i,[t,n]),i;if(o[0]===t&&o[1]===n)return i;i=`${r}-${a}`}}function Tt(e){let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}function Et(e){let t=x(e),n=ye(e),r={x:0,y:0,width:t.width,height:t.height},i=`translate(${t.x} ${t.y})`,a=z(y(e),r);return R(`g`,{transform:a?`${i} ${a}`:i},q([n.shadow,n.card],xt()))}function Dt(t,n){if(!t.text)return``;let r=x(t),i=t.fill===`transparent`?n.theme.paint(t=>v(e,t),oe(t.fill)):oe(t.fill);return G({text:t.text,fontSize:t.fontSize,fontFamily:t.fontFamily,color:i,fixedInk:t.fill!==`transparent`,lineHeight:t.lineHeight??1.25,letterSpacing:t.letterSpacing,x:r.x+r.width/2,y:r.y+r.height/2,align:`middle`,vAlign:`center`,maxWidth:r.width-28,rotation:t.rotation,rotateCenter:{x:r.x+r.width/2,y:r.y+r.height/2}},n)}var Ot={svg:(e,t)=>Et(e)+Dt(e,t)};function kt(e,t){let n=we(e),r=K(n.attrs,`ink`,t.theme),i=e.highlighter?{style:`mix-blend-mode:${t.theme.paint(T,T())}`}:void 0;return R(n.tag,{...r,opacity:e.opacity,...i})}var At={svg:kt,ownOpacity:!0};function jt(e,t){return R(`path`,{...K({d:Se(e.points,e.smooth,e.holes),fill:e.fill,stroke:e.color},`ink`,t.theme),"fill-rule":be(e),"stroke-width":e.strokeWidth})}var Mt={svg:jt},Nt={svg:(e,t)=>st(e,t)+ot(e,pe(e.points,e.labelAlong),t),labelBounds:P};function Pt(e,t){let n=x(e),{x:r,y:i,width:a,height:o}=C(n,e.crop),s=`imgclip-${e.id}`,c=t.srcMap.get(e.src)??e.src,l=R(`clipPath`,{id:s},R(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,rx:g(e.corner,n)})),u=R(`image`,{href:c,x:r,y:i,width:a,height:o,preserveAspectRatio:`none`,"clip-path":`url(#${s})`});return R(`g`,{transform:Le(e,n)},l+u)}var Ft={svg:Pt,assetUrls:e=>e.src.startsWith(`data:`)?[]:[e.src]};function It(t,n){if(!t.label)return``;let r=x(t),i=r.x+r.width/2,o=t.fontSize??36,s=a(o),c=t.color===`transparent`?e:t.color;return G({text:t.label,fontSize:o,fontFamily:t.fontFamily,color:n.theme.paint(e=>v(c,e),c),lineHeight:re,x:i,y:r.y+r.height+s,align:`middle`,vAlign:`top`,rotation:t.rotation,rotateCenter:{x:i,y:r.y+r.height/2}},n)}function Lt(e,t){let n=x(e),r=n.width/24,i=J({source:e.source,name:e.name,srcMap:t.srcMap,icons:t.icons,x:n.x,y:n.y,size:n.width,height:n.height,stroke:t.theme.paint(t=>v(e.color,t),e.color),strokeWidth:r>0?ee(e.strokeWidth,n.width)/r:e.strokeWidth,weight:ne(e.strokeWidth,n.width),weightId:e.id});return R(`g`,{transform:Le(e,n)},i)}var Rt={svg:(e,t)=>Lt(e,t)+It(e,t),assetUrls:(e,t)=>A(e.source)?[t.assetIconUrl(e.source,e.name)]:[]},zt=15;function Bt(e){return e.titleIcon?19:0}function Vt(e,t){let n=e.titleIcon;if(!n||!e.label)return``;let r=x(e),i=r.x,a=r.y-O-14*1.2+l(14,1.2)-14*.35-zt/2;return J({source:n.source,name:n.name,srcMap:t.srcMap,icons:t.icons,x:i,y:a,size:zt,stroke:t.theme.paint(t=>v(e.color,t),e.color)})}function Ht(e,t){if(!e.label)return``;let n=x(e);return Vt(e,t)+G({text:e.label,fontSize:14,fontFamily:e.fontFamily,color:t.theme.paint(t=>v(e.color,t),e.color),x:n.x+Bt(e),y:n.y-O,align:`start`,vAlign:`bottom`},t)}function Ut(e,t){let n=e.lanes??[];if(!_e(e.kind)||n.length===0)return``;let r=ve(e.kind),i=x(e),a=me(n.length,r?i.width:i.height,e.laneSizes),o=t.theme.paint(t=>v(e.color,t),e.color),s=n.map((n,s)=>{if(!n)return``;let c=(a[s]+a[s+1])/2,l=r?i.x+c:i.x+30/2,u=r?i.y+30/2:i.y+c;return G({text:n,fontSize:14,fontFamily:e.fontFamily,color:o,x:l,y:u,align:`middle`,vAlign:`center`,lineHeight:1,rotation:r?void 0:-90,rotateCenter:r?void 0:{x:l,y:u}},t)}).join(``);return R(`g`,{opacity:ge},s)}function Wt(e,t){if(!e.label)return null;let n=x(e),r=k(e.fontFamily),i=c(e.label).split(`
5
+ `),a=i.length*14*1.2,o=Bt(e)+Math.max(...i.map(n=>t.measure(n,14,e.fontFamily,r))),s=n.y-O-a;return{x:n.x,y:s,width:o,height:n.y-s}}function Gt(e,t){let n=x(e),r=xe(e);return R(`g`,{transform:z(y(e),n)},q([r.outline],t.theme,`paper`)+q(r.chrome,t.theme))}var Kt={svg:(e,t)=>Gt(e,t)+Ut(e,t)+Ht(e,t),labelBounds:(e,t)=>{let n=Wt(e,t);return n?[n]:[]},assetUrls:(e,t)=>e.titleIcon&&A(e.titleIcon.source)?[t.assetIconUrl(e.titleIcon.source,e.titleIcon.name)]:[],paintsBehind:!0};function qt(e,t){let n=ke(e),r=R(`rect`,{x:n.frame.x,y:n.frame.y,width:n.frame.width,height:n.frame.height,fill:t.theme.paint(e=>_(`#ffffff`,e),`#ffffff`),stroke:j,"stroke-width":1});for(let e of n.cellFills)r+=R(`rect`,{x:e.rect.x,y:e.rect.y,width:e.rect.width,height:e.rect.height,fill:t.theme.paint(t=>_(e.fill,t),e.fill)});for(let e of n.dividers)r+=R(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:j,"stroke-width":1});for(let n=0;n<e.cells.length;n+=1)for(let i=0;i<e.cells[n].length;i+=1){let a=e.cells[n][i];if(!a)continue;let o=Ee(e,n,i),s=Te(e,n,i);r+=G({text:a,fontSize:s.fontSize,fontFamily:s.fontFamily,color:t.theme.paint(e=>v(s.color,e),s.color),x:o.x+8,y:o.y+o.height/2,align:`start`,vAlign:`center`,maxWidth:Math.max(1,o.width-16),lineHeight:re},t)}return r}var Jt={svg:qt};function Yt(e,t){let n=x(e),r=t.theme.paint(e=>_(I,e),I),i=R(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,rx:4,fill:r});for(let n of Ce(e))n.testId!==`chart-empty`&&(i+=ft(n,t.theme));return R(`g`,{transform:z(y(e),n)},i)}var Xt={svg:Yt};function Zt(e,t){let n=x(e),r=``;for(let n of fe(e,t.text))r+=ft(n,t.theme);return R(`g`,{transform:z(y(e),n)},r)}var Qt={svg:Zt,link:e=>h(e.link)},X=15,$t=12,en=28,tn=16;function nn(e,t,n,r){let i=e=>r.text.measure(e,n,N)<=t;if(i(e))return e;let a=Array.from(new Intl.Segmenter(void 0,{granularity:`grapheme`}).segment(e),e=>e.segment),o=0,s=a.length;for(;o<s;){let e=Math.ceil((o+s)/2);i(`${a.slice(0,e).join(``)}…`)?o=e:s=e-1}return o===0?``:`${a.slice(0,o).join(``).trimEnd()}…`}function rn(e,t,n,r){let i=en/2,a={fill:`none`,stroke:r,"stroke-width":1.75,"stroke-linecap":`round`};if(e===`play`){let e=i*.42;return R(`circle`,{cx:t,cy:n,r:i,...a})+R(`path`,{d:`M${t-e*.7} ${n-e}L${t+e} ${n}L${t-e*.7} ${n+e}Z`,fill:r})}if(e===`code`){let e=i*.9,r=i*.6;return R(`path`,{d:`M${t-e*.45} ${n-r}L${t-e} ${n}L${t-e*.45} ${n+r}M${t+e*.45} ${n-r}L${t+e} ${n}L${t+e*.45} ${n+r}M${t+e*.15} ${n-r*1.15}L${t-e*.15} ${n+r*1.15}`,...a,"stroke-linejoin":`round`})}return R(`circle`,{cx:t,cy:n,r:i,...a})+R(`ellipse`,{cx:t,cy:n,rx:i*.45,ry:i,...a})+R(`path`,{d:`M${t-i} ${n}H${t+i}`,...a})}function an(e){let t=F(e);return`${t.title} ${t.caption}`}function on(t,n){let r=x(t),i=Math.min(12,r.width/4,r.height/4),a=n.theme.paint(t=>v(e,t),e),o=R(`rect`,{x:r.x,y:r.y,width:r.width,height:r.height,rx:i,fill:`none`,stroke:a,"stroke-opacity":.2});if(t.poster){let e=`webclip-${t.id}`;return R(`clipPath`,{id:e},R(`rect`,{x:r.x,y:r.y,width:r.width,height:r.height,rx:i}))+R(`image`,{href:n.srcMap.get(t.poster)??t.poster,x:r.x,y:r.y,width:r.width,height:r.height,preserveAspectRatio:`xMidYMid slice`,"clip-path":`url(#${e})`})+o}let s=n.theme.paint(e=>_(I,e),I),c=R(`rect`,{x:r.x,y:r.y,width:r.width,height:r.height,rx:i,fill:s,stroke:a,"stroke-opacity":.2}),l=F(t),u=Math.max(0,r.width-tn*2),d=nn(l.title,u,X,n),f=nn(l.caption,u,$t,n),p=r.height>=96,m=f!==``&&r.height>=52,h=p?38:0,g=m?19:0,y=h+X*1.25+g,b=r.x+r.width/2,S=r.y+(r.height-y)/2,C=c;p&&(C+=rn(l.glyph,b,S+en/2,a),S+=h);let w=(e,t,n,r)=>R(`text`,{x:b,y:n+t*.95,"font-family":N,"font-size":t,fill:a,"fill-opacity":r,"text-anchor":`middle`},L(e));return d&&(C+=w(d,X,S)),S+=X*1.25,m&&(C+=w(f,$t,S+4,.6)),C}var sn={svg:on,assetUrls:e=>e.poster&&!e.poster.startsWith(`data:`)?[e.poster]:[],link:e=>e.kind===`embed`?h(e.url):void 0},cn=14,Z=11;function ln(t,n){let r=x(t),i=n.theme.paint(t=>v(e,t),e),a=n.theme.paint(e=>_(I,e),I),o=R(`rect`,{x:r.x,y:r.y,width:r.width,height:r.height,rx:Math.min(8,r.width/4,r.height/4),fill:a,stroke:i,"stroke-opacity":.35,"stroke-dasharray":`6 4`}),s=r.x+r.width/2,c=r.y+r.height/2,l=(e,t,n,r)=>R(`text`,{x:s,y:t,"text-anchor":`middle`,"dominant-baseline":`middle`,"font-family":`sans-serif`,"font-size":n,fill:i,"fill-opacity":r},L(e)),u=t.label?l(t.label,c-Z*.7,cn,.85):``,d=l(t.kind,t.label?c+cn*.7:c,Z,.55);return o+u+d}var Q={rectangle:ht,arrow:_t,text:yt,sticky:Ot,draw:At,polygon:Mt,line:Nt,image:Ft,icon:Rt,figure:Kt,table:Jt,chart:Xt,control:Qt,web:sn,custom:{svg:(e,t)=>{let n=de(e),r=x(e),i=n.ok&&n.kind.toSvg?R(`g`,{transform:`translate(${r.x} ${r.y})`},n.kind.toSvg(e,n.props)):ln(e,t),a=z(y(e),r);return a?R(`g`,{transform:a},i):i}}};function $(e){let t=e.type;switch(t){case`rectangle`:return Q.rectangle;case`arrow`:return Q.arrow;case`text`:return Q.text;case`sticky`:return Q.sticky;case`draw`:return Q.draw;case`polygon`:return Q.polygon;case`line`:return Q.line;case`image`:return Q.image;case`icon`:return Q.icon;case`figure`:return Q.figure;case`table`:return Q.table;case`chart`:return Q.chart;case`control`:return Q.control;case`web`:return Q.web;case`custom`:return Q.custom;default:return un(t)}}function un(e){throw Error(`no definition for shape type ${String(e)}`)}function dn(e,t){let n=$(e).svg(e,t);return!n||$(e).ownOpacity||!(e.opacity<1)?n:R(`g`,{opacity:e.opacity},n)}async function fn(e,t,n){let r=new Set;for(let n of e)for(let e of $(n).assetUrls?.(n,t)??[])r.add(e);let i=new Map;return await Promise.all([...r].map(async e=>{let t=await n.inline(e);if(t){i.set(e,t);return}M(`asset-inline`,Error(`asset was not inlined`),e)})),i}function pn(e){let t=e.filter(e=>$(e).paintsBehind),n=e.filter(e=>!$(e).paintsBehind);return[...t,...n]}function mn(e){return e?bt(e)?Ct(e):St(e):xt()}async function hn(e,t,n={}){await ie();let i=n.padding??16,a=n.bounds??r(e,n.measurement);if(!a)return R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:1,height:1});let o=a.x,s=a.y,c=a.x+a.width,l=a.y+a.height;if(!n.bounds)for(let n of e){let e=$(n).labelBounds?.(n,t.text)??[];for(let t of e)o=Math.min(o,t.x),s=Math.min(s,t.y),c=Math.max(c,t.x+t.width),l=Math.max(l,t.y+t.height)}let u={x:o,y:s,width:c-o,height:l-s};await t.text.prepare(n.fonts);let[,d,f]=await Promise.all([t.icons.ensureCatalog().catch(e=>{M(`icon-catalog`,e)}),n.embedFonts===!1?Promise.resolve(``):t.fonts.embed(je(e,an),n.fonts),fn(e,t.icons,t.assets)]),p=u.x-i,m=u.y-i,h=Math.max(1,Math.round(u.width+i*2)),g=Math.max(1,Math.round(u.height+i*2)),_=mn(n.palette),v={text:t.text,icons:t.icons,srcMap:f,theme:_,measurement:n.measurement},y=pn(e).map(e=>{let t=dn(e,v),n=$(e).link?.(e);return n?R(`a`,{href:n,target:`_blank`,rel:`noopener`},t):t}).join(``),b=n.palette!==void 0&&bt(n.palette),x=n.background??(b?_.paint(e=>e.bg,`#ffffff`):`#ffffff`),S=x===`transparent`?``:R(`rect`,{x:0,y:0,width:h,height:g,fill:x}),C=[d,_.css()].filter(Boolean).join(`
6
+ `),w=C?R(`defs`,{},R(`style`,{type:`text/css`},`\n${C}\n`)):``,T=R(`g`,{transform:`translate(${-p} ${-m})`},y),E=n.width?{width:n.width,height:Math.max(1,Math.round(g*n.width/h))}:{width:h,height:g},D=n.title?R(`title`,{},L(n.title)):``;return R(`svg`,{xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,class:_.rootClass,role:n.title?`img`:void 0,"aria-label":n.title,width:E.width,height:E.height,viewBox:`0 0 ${h} ${g}`},D+w+S+T)}function gn(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}export{hn as n,gn as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jspdf.es.min-CxZaZThI.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-Czpn1I53.js","assets/typeof-B5XbjTb1.js"])))=>i.map(i=>d[i]);
2
+ import{k as e}from"./shapes-CHDGoELO.js";import{S as t,T as n,b as r}from"./frames-C-jROub3.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./blob-CTPsKWYv.js";import{t as o}from"./theme-palette-DZtiNUYJ.js";import{n as s,r as c}from"./clipboard-CO7YHov7.js";import{n as l,t as u}from"./export-DUFOrZJ-.js";function d(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.rel=`noopener`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e3)}var f={"16:9":[1280,720],a4:[1123,794],letter:[1056,816]};function p(e,t=`fit`){let n=e.height>e.width;if(t===`fit`)return{format:[e.width,e.height],orientation:n?`portrait`:`landscape`,image:{x:0,y:0,width:e.width,height:e.height}};let[r,i]=f[t],a=n&&t!==`16:9`?{width:i,height:r}:{width:r,height:i},o=Math.min(a.width/e.width,a.height/e.height),s=e.width*o,c=e.height*o;return{format:[a.width,a.height],orientation:a.height>a.width?`portrait`:`landscape`,image:{x:(a.width-s)/2,y:(a.height-c)/2,width:s,height:c}}}var m=2,h=8192;async function g(e,t=m){let n=u(e),r=new Image;await new Promise((e,t)=>{r.onload=()=>e(),r.onerror=()=>t(Error(`Failed to rasterize SVG`)),r.src=n});let i=Math.min(h/r.width,h/r.height),a=Math.min(t,i),o=Math.max(1,Math.round(r.width*a)),s=Math.max(1,Math.round(r.height*a)),c=document.createElement(`canvas`);c.width=o,c.height=s;let l=c.getContext(`2d`);if(!l)throw Error(`No 2D context`);return l.imageSmoothingEnabled=!0,l.imageSmoothingQuality=`high`,l.drawImage(r,0,0,o,s),new Promise((e,t)=>{c.toBlob(n=>n?e(n):t(Error(`toBlob failed`)),`image/png`)})}function _(e={}){let t=e.theme===`dark`,n=t?o:e.palette;return e.transparent?{...e,palette:n,background:`transparent`}:{...e,palette:n,background:e.background??(t?o.bg:void 0)}}function v(o){function u(e,t){return l(e,o,_(t))}async function f(e,t,n=`canvas`){let r=await u(e,t);d(new Blob([r],{type:`image/svg+xml`}),`${n}.svg`)}async function m(e,t,n=`canvas`){d(await g(await u(e,t),t?.scale),`${n}.png`)}async function h(e,t){await c(await u(e,t))}async function v(e,t){await s(u(e,t).then(e=>g(e,t?.scale)))}async function y(s,c,u=`slides`){let d=t(r(s));if(d.length===0)return;let{jsPDF:f}=await i(async()=>{let{jsPDF:e}=await import(`./jspdf.es.min-CxZaZThI.js`);return{jsPDF:e}},__vite__mapDeps([0,1,2,3])),m=null;for(let t of d){let r=e(t,c?.measurement),i=await a(await g(await l(n(s,t),o,{bounds:r,padding:0,background:t.fill,measurement:c?.measurement}))),{format:u,orientation:d,image:h}=p(r,c?.pageSize);m?m.addPage(u,d):m=new f({unit:`px`,format:u,orientation:d,hotfixes:[`px_scaling`]}),m.addImage(i,`PNG`,h.x,h.y,h.width,h.height)}m?.save(`${u}.pdf`)}return{svgToPngBlob:g,downloadSvg:f,downloadPng:m,copySvg:h,copyPng:v,downloadSlidesPdf:y}}export{v as createBrowserExport};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./react-lCSYwAWP.js";import{t as n}from"./jsx-runtime-DKdBMi_L.js";import{a as r,i,o as a,s as o}from"./editor-CpiNbiMQ.js";import{i as s}from"./config-D8b1QyEk.js";import{M as c,S as l,b as u}from"./frames-C-jROub3.js";import{c as d,i as f,n as p,o as m,r as h,s as g,t as ee}from"./export-options-CJwykdP5.js";import{t as _}from"./IconX-KrRqxr2j.js";import{t as te}from"./use-export-command-CZva79qg.js";import{n as v}from"./surface-Dke4SWpE.js";import{i as y,n as b,r as x,t as S}from"./DialogRoot-DUeVfNhS.js";import{n as C,t as w}from"./DialogTitle-D5au2NAn.js";import{t as T}from"./dialog-DnXgEbpz.js";var E=e(t(),1),D=n(),O=`flex h-7 items-center rounded-lg px-2.5 text-[12px] outline-none transition-colors disabled:cursor-not-allowed disabled:text-[var(--chrome-fg-300)]`,k=`bg-[var(--chrome-active)] text-[var(--chrome-fg-900)]`,A=`text-[var(--chrome-fg-500)] hover:bg-[var(--chrome-hover)]`,ne=[{id:`png`,label:`PNG`},{id:`svg`,label:`SVG`},{id:`pdf`,label:`PDF`}];function j(e){let{request:t,onClose:n}=e,O=o(),k=r(),{canvasMeta:A}=s(),j=te(),P=a(e=>e.selectedIds.size),F=i(e=>[e.shapes],e=>l(u(e)).length),I=A?.name,[L,R]=(0,E.useState)(m),[z]=(0,E.useState)(()=>f(t,L,{hasSelection:P>0,hasSlides:F>0})),[B,V]=(0,E.useState)(z.format),[H,U]=(0,E.useState)(z.scope),[W,G]=(0,E.useState)(()=>h(I,z.format)),[K,q]=(0,E.useState)(!1),[J,Y]=(0,E.useState)(!1),X=(0,E.useRef)(!0);(0,E.useEffect)(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=B===`pdf`,Q=P>0?H:`board`;function $(e,t){R(n=>({...n,[e]:t}))}function re(e){V(e),K||G(h(I,e))}async function ie(e){if(e.preventDefault(),J)return;g(Z?L:{...L,format:B}),Y(!0);let t=h(W,B),{shapes:r,selectedIds:i}=O.getState(),a=Q===`board`?r:c(r,d(r,i),k.measurement),o=Z?await j(`downloadPdf`,r,{options:{pageSize:L.pageSize},filename:t}):await j(B===`png`?`downloadPng`:`downloadSvg`,a,{options:{scale:B===`png`?L.scale:void 0,transparent:L.transparent,theme:L.theme},filename:t});X.current&&(Y(!1),o&&n())}return(0,D.jsx)(S,{open:!0,onOpenChange:e=>{e||n()},children:(0,D.jsxs)(b,{children:[(0,D.jsx)(y,{className:v.dialogBackdrop}),(0,D.jsxs)(x,{"data-overlay":!0,"data-testid":`export-dialog`,className:`w-[min(420px,92vw)] p-5 ${v.dialogPopup}`,children:[(0,D.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,D.jsx)(w,{className:T.title,children:`Export`}),(0,D.jsx)(C,{"aria-label":`Close`,"data-testid":`export-close`,className:`-mr-1.5 -mt-1.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-lg text-[var(--chrome-fg-500)] outline-none transition-colors hover:bg-[var(--chrome-hover)]`,children:(0,D.jsx)(_,{size:16,stroke:2})})]}),(0,D.jsxs)(`form`,{className:`mt-4 flex flex-col gap-3`,onSubmit:e=>void ie(e),children:[(0,D.jsx)(M,{label:`Format`,children:(0,D.jsx)(N,{label:`Format`,testId:`export-format`,value:B,options:ne.map(e=>({...e,disabled:e.id===`pdf`&&F===0})),onChange:re})}),Z?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{label:`Page size`,children:(0,D.jsx)(N,{label:`Page size`,testId:`export-page`,value:L.pageSize,options:p,onChange:e=>$(`pageSize`,e)})}),(0,D.jsxs)(`p`,{"data-testid":`export-pdf-summary`,className:`text-[12px] leading-relaxed text-[var(--chrome-fg-400)]`,children:[F===1?`One slide`:`${F} slides`,`, one page each. Skipped slides are left out.`]})]}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(M,{label:`Export`,children:(0,D.jsx)(N,{label:`Export`,testId:`export-scope`,value:Q,options:[{id:`selection`,label:P>0?`Selection (${P})`:`Selection`,disabled:P===0},{id:`board`,label:`Whole board`}],onChange:U})}),B===`png`&&(0,D.jsx)(M,{label:`Scale`,children:(0,D.jsx)(N,{label:`Scale`,testId:`export-scale`,value:L.scale,options:ee.map(e=>({id:e,label:`${e}×`})),onChange:e=>$(`scale`,e)})}),(0,D.jsx)(M,{label:`Background`,children:(0,D.jsx)(N,{label:`Background`,testId:`export-background`,value:L.transparent?`transparent`:`solid`,options:[{id:`solid`,label:`Solid`},{id:`transparent`,label:`Transparent`}],onChange:e=>$(`transparent`,e===`transparent`)})}),(0,D.jsx)(M,{label:`Theme`,children:(0,D.jsx)(N,{label:`Theme`,testId:`export-theme`,value:L.theme,options:[{id:`light`,label:`Light`},{id:`dark`,label:`Dark`}],onChange:e=>$(`theme`,e)})})]}),(0,D.jsxs)(`label`,{className:`mt-1 flex flex-col gap-1.5`,children:[(0,D.jsx)(`span`,{className:T.label,children:`File name`}),(0,D.jsxs)(`div`,{className:`relative`,children:[(0,D.jsx)(`input`,{"data-testid":`export-filename`,className:`${T.field} pr-12`,value:W,maxLength:120,placeholder:h(null,B),onChange:e=>{G(e.target.value),q(!0)}}),(0,D.jsxs)(`span`,{className:`pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-[13px] text-[var(--chrome-fg-400)]`,children:[`.`,B]})]})]}),(0,D.jsxs)(`div`,{className:`mt-2 ${T.actions}`,children:[(0,D.jsx)(C,{className:T.cancelButton,children:`Cancel`}),(0,D.jsx)(`button`,{type:`submit`,"data-testid":`export-submit`,"data-busy":J?`true`:`false`,disabled:J,className:T.submitButton,children:J?`Exporting…`:`Export`})]})]})]})]})})}function M(e){let{label:t,children:n}=e;return(0,D.jsxs)(`div`,{className:`flex min-h-8 items-center justify-between gap-3`,children:[(0,D.jsx)(`span`,{className:T.label,children:t}),n]})}function N(e){let{label:t,testId:n,value:r,options:i,onChange:a}=e;return(0,D.jsx)(`div`,{className:`flex items-center gap-1`,role:`radiogroup`,"aria-label":t,children:i.map(e=>(0,D.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":r===e.id,"data-testid":`${n}-${String(e.id).replace(`:`,`-`)}`,disabled:e.disabled,onClick:()=>a(e.id),className:`${O} ${r===e.id?k:A}`,children:e.label},e.id))})}export{j as ExportDialog};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./react-lCSYwAWP.js";import{t as n}from"./jsx-runtime-DKdBMi_L.js";import{Bt as r,C as i,Pn as a,k as o}from"./shapes-CHDGoELO.js";import{a as s,o as c}from"./editor-CpiNbiMQ.js";import{B as l,L as u,R as d,z as f}from"./frames-C-jROub3.js";import{r as p,t as m}from"./dom-PAoZruqo.js";import{t as h}from"./editable-target-BTLnvKNi.js";import{t as g}from"./use-key-held-DRn09Hq8.js";import{t as _}from"./createReactComponent-C51FAx3B.js";import{a as v,r as y}from"./flow-start-D_gK7Gur.js";import{a as b,c as x,d as S,f as C,g as w,h as T,m as E,n as D,o as O,r as k,x as A,y as j}from"./tree-Ch-RF7UJ.js";import{t as M}from"./IconChevronLeft-D7e7QC0h.js";import{t as N}from"./IconChevronRight-csfMBSUs.js";import{t as P}from"./IconFocusCentered-Cn8rbfRI.js";import{t as F}from"./IconLink-VS5p9Ytk.js";import{t as I}from"./IconPencil-D_pQsAyv.js";import{t as L}from"./IconPlus-D4tAoi-A.js";import{t as R}from"./IconX-KrRqxr2j.js";import{t as z}from"./IconPlayerPlayFilled-DVAWmYt7.js";import{n as B}from"./core-DnS-1skV.js";import{r as ee,t as V}from"./chrome-layout-500Q9pcx.js";import{c as te,d as H,i as U,l as W,n as G,t as ne,u as K}from"./flows-BAU4NQGk.js";import{a as q,i as re,n as ie,o as ae,r as oe,t as se}from"./flow-stage-DFvraJ0j.js";var ce=_(`outline`,`rotate`,`Rotate`,[[`path`,{d:`M19.95 11a8 8 0 1 0 -.5 4m.5 5v-5h-5`,key:`svg-0`}]]),le=_(`filled`,`player-pause-filled`,`PlayerPauseFilled`,[[`path`,{d:`M9 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z`,key:`svg-0`}],[`path`,{d:`M17 4h-2a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h2a2 2 0 0 0 2 -2v-12a2 2 0 0 0 -2 -2z`,key:`svg-1`}]]),J=e(t(),1),ue=6;function de(e){let t=e instanceof Element?e:null;return!!(t?.closest(`[data-canvas-root]`)&&!t.closest(`[data-overlay]`))}function fe(e){let t=(0,J.useRef)(e);t.current=e,(0,J.useEffect)(()=>{let e=null,n=new Set,r=t=>{n.add(t.pointerId),e=n.size===1&&t.button===0&&de(t.target)?{id:t.pointerId,x:t.clientX,y:t.clientY}:null},i=r=>{n.delete(r.pointerId);let i=e;!i||i.id!==r.pointerId||(e=null,Math.hypot(r.clientX-i.x,r.clientY-i.y)<=ue&&t.current(r))},a=t=>{n.delete(t.pointerId),e=null};return window.addEventListener(`pointerdown`,r,!0),window.addEventListener(`pointerup`,i,!0),window.addEventListener(`pointercancel`,a,!0),()=>{window.removeEventListener(`pointerdown`,r,!0),window.removeEventListener(`pointerup`,i,!0),window.removeEventListener(`pointercancel`,a,!0)}},[])}var Y=n(),X=10,Z=28,pe=.5,me=4,he=24;function ge(e){let{frame:t,flow:n,targets:r,viewport:i}=e,a=s(),d=c(e=>e.hoveredId),p=c(e=>e.flowEdit)??{},m=ee()===`docked`,h=n.steps.length;(0,J.useEffect)(()=>{let{store:e,viewportAnimation:n}=a,r=e.getState(),i=document.querySelector(`[data-canvas-root]`),s={width:(i?.clientWidth??window.innerWidth)-(m?V(`flow`):0),height:i?.clientHeight??window.innerHeight},c=o(t),d=l({x:c.x,y:c.y-Z},r.viewport),f=l({x:c.x+c.width,y:c.y+c.height},r.viewport),p=d.x>=0&&d.y>=0&&f.x<=s.width&&f.y<=s.height,h=f.x-d.x>=s.width*pe||f.y-d.y>=s.height*pe;p&&h||n.animate(r.viewport,u(c,s,64),r.setViewport)},[t.id,a,m]);let g=(0,J.useRef)(h);g.current=h,(0,J.useEffect)(()=>{let e=e=>{if(e.button!==0)return;let r=e.target instanceof Element?e.target:null;if(!r?.closest(`[data-canvas-root]`)||r.closest(`[data-overlay]`))return;let i=r.closest(`[data-shape-id]`)?.getAttribute(`data-shape-id`)??r.closest(`[data-icon-label]`)?.getAttribute(`data-icon-label`),o=a.store.getState(),s=o.shapes.find(e=>e.id===t.id);if(!i||s?.type!==`figure`)return;let c=B(o.shapes,s).find(e=>e.id===i);if(!c)return;e.preventDefault(),e.stopPropagation(),_e();let l=T({selected:o.flowEdit?.picking},g.current);if(l!==null){S(a,t.id,n.id,l,c);return}if(o.flowEdit?.picking!=null&&o.patchFlowEdit({picking:null}),e.shiftKey){x(a,t.id,n.id,c);return}O(a,t.id,n.id,c)};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},[a,t.id,n.id]),fe(e=>{let r=a.store.getState(),i=r.shapes.find(e=>e.id===t.id),s=document.querySelector(`[data-canvas-root]`)?.getBoundingClientRect();if(!i||!s)return;let c=f({x:e.clientX-s.left,y:e.clientY-s.top},r.viewport),l=o(i);c.x>=l.x-X&&c.x<=l.x+l.width+X&&c.y>=l.y-Z&&c.y<=l.y+l.height+X||C(a,t.id,n.id)});let[_,v]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let e=e=>v(e.shiftKey);return window.addEventListener(`keydown`,e),window.addEventListener(`keyup`,e),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`keyup`,e)}},[]);let y=new Map(r.map(e=>[e.id,e])),b=d?y.get(d):void 0,D=w(p,h),k=T(p,h),A=T({selected:p.picking},h),j=E(p,h),M=T({selected:p.hovered},h),N=G(t.flows??[],n.id),P=N?.flow.steps[N.index],F=n.steps[D-1]?.target,I=new Map(r.map(e=>[e.id,U(r,e)])),L=b&&(A!==null||b.id!==F||_)?b:null,R=L?{id:L.id,number:ve(A,_?j:null,D)}:null,z=[...new Set([M,k])].flatMap(e=>e===null?[]:K(n.steps[e]));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(be,{frame:t,viewport:i}),P&&K(P).flatMap(e=>{let t=y.get(e);return t?[(0,Y.jsx)(ke,{shape:t,viewport:i,hint:h===0},e)]:[]}),[...new Set(z)].flatMap(e=>{let t=y.get(e);return t?[(0,Y.jsx)(`div`,{"data-testid":`flow-step-ring`,className:`pointer-events-none absolute rounded-md ring-[1.5px] ring-[color-mix(in_srgb,var(--chrome-fg-900)_35%,transparent)]`,style:q(t,i,5)},e)]:[]}),L&&(0,Y.jsx)(`div`,{"data-testid":`flow-add-hint`,"aria-label":ye(A,_?j:null,D,h),className:`pointer-events-none absolute rounded-md ring-[1.5px] ring-[var(--canvas-selection)]`,style:q(L,i,5)}),(0,Y.jsx)(Ce,{flow:n,byId:y,viewport:i,slot:D}),(0,Y.jsx)(we,{flow:n,targets:r,fork:P,viewport:i}),(0,Y.jsx)(De,{flow:n,byId:y,viewport:i,selected:k,names:I,ghost:R,onSelect:e=>a.store.getState().patchFlowEdit({selected:e}),onDrop:(e,r)=>S(a,t.id,n.id,e,r)}),(0,Y.jsx)(xe,{picking:A,slot:D,count:h})]})}function _e(){let e=document.activeElement;e instanceof HTMLElement&&h(e)&&e.blur()}function ve(e,t,n){return e===null?t===null?n+1:t+1:e+1}function ye(e,t,n,r){return e===null?t===null?n<r?`Add as step ${n+1}`:`Add as step ${r+1}`:`Add to step ${t+1}`:`Step ${e+1} lights this`}function be(e){let{frame:t,viewport:n}=e,r=o(t),i=l({x:r.x-X,y:r.y-Z},n),a=l({x:r.x+r.width+X,y:r.y+r.height+X},n);return(0,Y.jsx)(`div`,{"data-testid":`flow-edit-focus`,className:`pointer-events-none absolute rounded-lg ring-[1.5px] ring-[color-mix(in_srgb,var(--chrome-fg-900)_22%,transparent)]`,style:{left:i.x,top:i.y,width:Math.max(0,a.x-i.x),height:Math.max(0,a.y-i.y)}})}function xe(e){let{picking:t,slot:n,count:r}=e;return t===null?n<r?(0,Y.jsx)(Q,{text:`Click a box for step ${n+1}`,escape:!0}):null:(0,Y.jsx)(Q,{text:`Click the box step ${t+1} should light`,escape:!0})}function Q(e){let{text:t,escape:n}=e;return(0,Y.jsxs)(`p`,{"data-testid":`flow-board-hint`,className:`pointer-events-none absolute bottom-6 left-1/2 z-30 flex -translate-x-1/2 items-center gap-1.5 whitespace-nowrap rounded-lg bg-[var(--chrome-accent)] px-2.5 py-1.5 text-[12px] text-white shadow-lg`,children:[t,n&&(0,Y.jsx)(`kbd`,{className:`rounded px-1 font-mono text-[10.5px] ring-1 ring-white/30`,children:`esc`})]})}function Se(e,t,n){for(let r of n.values()){if(r.type!==`arrow`)continue;let n=r.startBinding?.shapeId,i=r.endBinding?.shapeId;if(n===e.target&&i===t.target||n===t.target&&i===e.target)return r}return null}function Ce(e){let{flow:t,byId:n,viewport:i,slot:a}=e,o=s(),c=t.steps.slice(1).flatMap((e,r)=>{let i=t.steps[r],a=Se(i,e,n);return a?[{arrow:a,slot:r+1}]:[]}),u=new Map;for(let{arrow:e}of c)u.set(e.id,(u.get(e.id)??0)+1);let d=new Map;return(0,Y.jsx)(Y.Fragment,{children:c.map(({arrow:e,slot:t})=>{let n=d.get(e.id)??0;d.set(e.id,n+1);let s=(n-((u.get(e.id)??1)-1)/2)*he,c=l(r(e),i),f=typeof e.label==`string`&&e.label.trim().length>0,p=t===a;return(0,Y.jsx)(`button`,{type:`button`,"data-overlay":!0,"data-testid":`flow-arrow-insert`,"aria-label":`Add a step between step ${t} and step ${t+1}`,title:`Add a step between ${t} and ${t+1}`,className:`absolute z-20 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center rounded-full ring-1 transition-colors ${p?`bg-[var(--chrome-fg-900)] text-[var(--canvas-bg)] ring-[var(--chrome-fg-900)]`:`bg-[var(--chrome-popup)] text-[var(--chrome-fg-600)] ring-[var(--chrome-input-hover)] hover:text-[var(--chrome-fg-900)]`}`,style:{left:c.x+s,top:c.y+(f?16:0)},onPointerDown:e=>e.stopPropagation(),onClick:()=>o.store.getState().patchFlowEdit({slot:t,picking:null}),children:(0,Y.jsx)(L,{size:9,stroke:2.5})},`${e.id}-${t}`)})})}function we(e){let{flow:t,targets:n,fork:r,viewport:i}=e,a=s(),o=[...b(n,t.steps,r).values()];return(0,Y.jsx)(Y.Fragment,{children:[...new Map(o.map(e=>[e.arrow.id,e])).values()].flatMap(e=>e.ends.map(t=>{let r=n.find(e=>e.id===t.shapeId);if(!r)return null;let o=U(n,r),s=l(t.point,i),c=l(Te(r,t.point),i),u=Math.hypot(c.x-s.x,c.y-s.y),d=Math.atan2(c.y-s.y,c.x-s.x);return(0,Y.jsxs)(`span`,{children:[u>1&&(0,Y.jsx)(`span`,{"aria-hidden":!0,"data-testid":`flow-loose-gap`,className:`pointer-events-none absolute z-20 h-0 origin-left border-t-[1.5px] border-dashed border-[var(--flow-warn)]`,style:{left:s.x,top:s.y-.75,width:u,transform:`rotate(${d}rad)`}}),(0,Y.jsxs)(`button`,{type:`button`,"data-overlay":!0,"data-testid":`flow-loose-end`,"aria-label":`Attach the arrow to ${o}`,title:`This arrow isn't attached to ${o}, so it won't move with it`,className:`group/loose absolute z-20 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 cursor-pointer items-center justify-center outline-none`,style:{left:(s.x+c.x)/2,top:(s.y+c.y)/2},onPointerDown:e=>e.stopPropagation(),onClick:()=>k(a,e),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-[9px] w-[9px] rounded-full bg-[var(--canvas-bg)] shadow-[inset_0_0_0_2px_var(--flow-warn)] transition-transform group-hover/loose:scale-125`}),(0,Y.jsxs)(`span`,{className:`pointer-events-none absolute left-1/2 top-[18px] flex h-[22px] -translate-x-1/2 items-center gap-1 whitespace-nowrap rounded-md bg-[var(--chrome-popup)] px-2 text-[11px] font-medium text-[var(--chrome-fg-800)] opacity-0 shadow-md ring-1 ring-[var(--chrome-ring)] transition-opacity group-hover/loose:opacity-100 group-focus-visible/loose:opacity-100`,children:[(0,Y.jsx)(F,{size:11,stroke:2}),`Attach`]})]})]},`${e.arrow.id}-${t.end}`)}))})}function Te(e,t){let n=o(e);return{x:Math.min(Math.max(t.x,n.x),n.x+n.width),y:Math.min(Math.max(t.y,n.y),n.y+n.height)}}function Ee(e,t,n){for(let r of document.elementsFromPoint(e,t)){let e=r.closest(`[data-shape-id]`)?.getAttribute(`data-shape-id`)??r.closest(`[data-icon-label]`)?.getAttribute(`data-icon-label`);if(e&&n.has(e))return e}return null}function De(e){let{flow:t,byId:n,viewport:r,selected:i,names:a,ghost:o,onSelect:s,onDrop:c}=e,[l,u]=(0,J.useState)(null),d=ae(t),f=re(t),p=new Set(n.keys()),m=(e,t)=>{if(e.button!==0)return;e.stopPropagation(),e.preventDefault(),_e();let n=e.currentTarget.closest(`[data-canvas-root]`)?.getBoundingClientRect(),r={left:n?.left??0,top:n?.top??0};e.currentTarget.setPointerCapture(e.pointerId),u({index:t,pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,x:e.clientX-r.left,y:e.clientY-r.top,origin:r,dragging:!1,over:null})},h=e=>{if(!l||l.pointerId!==e.pointerId)return;let t=Math.hypot(e.clientX-l.startX,e.clientY-l.startY),n=l.dragging||t>me;u({...l,x:e.clientX-l.origin.left,y:e.clientY-l.origin.top,dragging:n,over:n?Ee(e.clientX,e.clientY,p):null})},g=e=>{if(!l||l.pointerId!==e.pointerId)return;if(u(null),!l.dragging){s(l.index);return}let r=l.over?n.get(l.over):void 0;r&&r.id!==t.steps[l.index]?.target&&c(l.index,r)},_=l?.over?n.get(l.over):void 0,v=_&&l&&_.id!==t.steps[l.index]?.target?_:null,y=new Map(d);return o&&!l&&!y.has(o.id)&&y.set(o.id,[]),(0,Y.jsxs)(Y.Fragment,{children:[v&&l&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{"data-testid":`flow-badge-drop`,className:`pointer-events-none absolute rounded-md bg-[color-mix(in_srgb,var(--canvas-selection)_6%,transparent)] ring-[1.5px] ring-[var(--canvas-selection)]`,style:q(v,r,5)}),(0,Y.jsx)(Q,{text:`Step ${l.index+1} moves to ${a.get(v.id)??`this box`}`})]}),[...y].map(([e,a])=>{let c=n.get(e);if(!c)return null;let d=oe(c,r);return(0,Y.jsxs)(`span`,{"data-overlay":!0,className:`absolute z-20 flex items-center gap-1 ${c.type===`arrow`?`-translate-x-1/2 -translate-y-[calc(100%+14px)]`:`-translate-x-full -translate-y-full`}`,style:{left:d.x-2,top:d.y-2},children:[a.map(e=>{let n=e-1,r=l?.dragging&&l.index===n,a=i===n;return(0,Y.jsx)(`button`,{type:`button`,"data-testid":`flow-step-badge`,"data-selected":a||void 0,"aria-label":`Step ${e}: ${t.steps[n]?.title??``}`,"aria-pressed":a,title:`Click to select · drag onto another box to change it`,className:`flex h-[18px] min-w-[18px] cursor-grab touch-none items-center justify-center rounded-full px-1 text-[10.5px] font-semibold tabular-nums transition-colors active:cursor-grabbing ${Oe(f.has(e),a)} ${r?`opacity-35`:``}`,onPointerDown:e=>m(e,n),onPointerMove:h,onPointerUp:g,onPointerCancel:()=>u(null),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s(n))},children:e},e)}),o?.id===e&&!l&&(0,Y.jsx)(`span`,{"aria-hidden":!0,"data-testid":`flow-add-ghost`,className:`pointer-events-none flex h-[18px] min-w-[18px] items-center justify-center rounded-full bg-[var(--canvas-bg)] px-1 text-[10.5px] font-semibold tabular-nums text-[var(--chrome-fg-500)] shadow-[inset_0_0_0_1.5px_var(--chrome-fg-400)]`,children:o.number})]},e)}),l?.dragging&&(0,Y.jsx)(`span`,{"aria-hidden":!0,"data-testid":`flow-badge-ghost`,className:`pointer-events-none absolute z-30 flex h-6 min-w-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-[var(--flow-accent)] px-1.5 text-[12px] font-semibold tabular-nums text-white shadow-[0_6px_14px_rgba(0,0,0,0.25)]`,style:{left:l.x,top:l.y},children:l.index+1})]})}function Oe(e,t){return t?`text-white ${e?`bg-[var(--flow-fail)]`:`bg-[var(--flow-accent)]`}`:e?`bg-[var(--canvas-bg)] text-[var(--flow-fail)] shadow-[inset_0_0_0_1.5px_var(--flow-fail)] hover:bg-[color-mix(in_srgb,var(--flow-fail)_10%,var(--canvas-bg))]`:`bg-[var(--canvas-bg)] text-[var(--flow-accent)] shadow-[inset_0_0_0_1.5px_var(--flow-accent)] hover:bg-[color-mix(in_srgb,var(--flow-accent)_10%,var(--canvas-bg))]`}function ke(e){let{shape:t,viewport:n,hint:r}=e,i=oe(t,n),a=q(t,n,4);return(0,Y.jsxs)(`span`,{className:`pointer-events-none`,children:[(0,Y.jsx)(`span`,{"data-testid":`flow-fork-marker`,className:`absolute z-20 flex h-5 w-5 -translate-x-full -translate-y-full items-center justify-center rounded-full bg-[var(--canvas-bg)] text-[var(--flow-accent)] shadow-[inset_0_0_0_1.5px_var(--flow-accent)]`,style:{left:i.x-2,top:i.y-2},children:(0,Y.jsx)(A,{size:11,stroke:2})}),r&&(0,Y.jsx)(`span`,{className:`absolute z-20 -translate-x-1/2 whitespace-nowrap rounded-md bg-[var(--chrome-accent)] px-2 py-1 text-[11px] text-white shadow-md`,style:{left:a.left+a.width/2,top:a.top+a.height+6},children:`Click where it goes next`})]})}var Ae=2600,je=.55,Me=1.1;function Ne(e,t){let n=document.querySelector(`[data-canvas-root]`),r=n?.clientWidth??window.innerWidth,i=n?.clientHeight??window.innerHeight;return{width:Math.max(1,r-(e?V(t):0)),height:Math.max(1,i-Fe)}}var Pe={call:`Call`,async:`Fire and forget`,reply:`Reply`},Fe=150;function Ie(e){let{frame:t,flow:n,targets:r,step:a,viewport:l}=e,f=s(),{store:p,viewportAnimation:m}=f,h=c(e=>e.rightPanel),_=ee()===`docked`,v=n.steps.length,b=Math.min(Math.max(a,0),Math.max(v-1,0)),x=n.steps[b],S=(0,J.useMemo)(()=>new Map(r.map(e=>[e.id,e])),[r]),C=(0,J.useMemo)(()=>x?K(x).flatMap(e=>S.get(e)??[]):[],[x,S]),w=(0,J.useMemo)(()=>{let e=b>0?n.steps[b-1]:void 0;return e?K(e).flatMap(e=>S.get(e)??[]):[]},[n.steps,b,S]),T=c(e=>e.flowPlay?.trail),E=c(e=>e.viewMode),O=T?.[T.length-1],k=O?t.flows?.find(e=>e.id===O.flowId)?.name:void 0,[A,M]=(0,J.useState)(!1),[N,P]=(0,J.useState)(()=>u(o(t),Ne(_,h),64).zoom<je),F=e=>{let r=Math.min(Math.max(e,0),v-1);p.getState().setFlowPlay({frameId:t.id,flowId:n.id,step:r,trail:T})},I=()=>{!O||!T||(M(!1),p.getState().setFlowPlay({frameId:t.id,flowId:O.flowId,step:O.step,trail:T.slice(0,-1)}))},L=(0,J.useRef)(I);L.current=I;let R=()=>{p.getState().setFlowPlay(null)},z=t.flows??[],B={tabs:D(z).filter(e=>e.steps.length>0).map(e=>({id:e.id,name:e.name})),active:Le(z,n.id,T),onTab:e=>{M(!1),p.getState().setFlowPlay({frameId:t.id,flowId:e,step:0})},onEdit:E?null:()=>j(f,t.id,n.id),onNew:E?null:()=>{p.getState().setFlowPlay(null),y(f,t.id)}},V=(0,J.useRef)(F);V.current=F;let H=(0,J.useRef)(R);H.current=R;let U=(0,J.useRef)(b);U.current=b;let W=()=>Ne(_,h),G=(0,J.useRef)(W);if(G.current=W,(0,J.useEffect)(()=>{let e=p.getState();e.setSelectedIds(new Set),m.animate(e.viewport,u(o(t),G.current(),64),e.setViewport)},[t.id,p,m]),(0,J.useEffect)(()=>{let e=i(N?[...C,...w]:C);if(!e)return;let t=p.getState();if(N){let n=u(e,G.current(),120),r=Math.min(n.zoom,Me),i=G.current();m.animate(t.viewport,{zoom:r,x:i.width/2-(e.x+e.width/2)*r,y:i.height/2-(e.y+e.height/2)*r},t.setViewport);return}let n=d(e,t.viewport,G.current(),96);n&&m.animate(t.viewport,n,t.setViewport)},[C,w,N,p,m]),(0,J.useEffect)(()=>{let e=e=>{if((e.target instanceof Element?e.target:null)?.closest(`input, textarea, select, [contenteditable=true], [role=menu]`)||(e.key===` `||e.key===`Enter`)&&g(e.target))return;let t=U.current;if(e.key===`ArrowRight`||e.key===` `||e.key===`Enter`)e.preventDefault(),V.current(t+1);else if(e.key===`ArrowLeft`||e.key===`Backspace`){if(e.preventDefault(),t===0&&L.current){L.current();return}V.current(t-1)}else e.key===`Home`?(e.preventDefault(),V.current(0)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),H.current())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),fe(()=>H.current()),(0,J.useEffect)(()=>{let e=e=>{e.pointerType===`touch`||e.button!==0||!de(e.target)||(e.preventDefault(),e.stopPropagation())};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},[]),(0,J.useEffect)(()=>{if(!A)return;if(b>=v-1||(x?.branches?.length??0)>0){M(!1);return}let e=window.setTimeout(()=>V.current(U.current+1),Ae);return()=>window.clearTimeout(e)},[A,b,v,x]),!x)return(0,Y.jsx)(Re,{flow:n,index:0,kind:`call`,autoplay:!1,onAutoplay:()=>{},onGo:()=>{},onStop:R,branches:[],onBranch:()=>{},returnName:k??null,onBack:I,follow:N,onFollow:P,switcher:B});let q=ne(t.flows??[],n.id);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(se,{frameId:t.id,flow:n,targets:r,index:b,viewport:l,lead:q}),(0,Y.jsx)(Re,{flow:n,index:b,kind:te(r,[...q,...n.steps],q.length+b),autoplay:A,onAutoplay:M,onGo:F,onStop:R,branches:(x.branches??[]).flatMap(e=>{let r=t.flows?.find(t=>t.id===e&&t.id!==n.id);return r&&r.steps.length>0?[{id:r.id,name:r.name}]:[]}),onBranch:e=>{M(!1),p.getState().setFlowPlay({frameId:t.id,flowId:e,step:0,trail:[...T??[],{flowId:n.id,step:b}]})},returnName:k??null,onBack:I,follow:N,onFollow:P,switcher:B})]})}function Le(e,t,n){let r=n?.[0]?.flowId;if(r)return r;let i=t,a=new Set;for(;!a.has(i);){a.add(i);let t=G(e,i);if(!t)return i;i=t.flow.id}return i}function Re(e){let{flow:t,index:n,kind:r,autoplay:i,onAutoplay:a,onGo:o,onStop:s,branches:c,onBranch:l}=e,{returnName:u,onBack:d,follow:f,onFollow:p,switcher:m}=e,h=t.steps.length,g=t.steps[n],_=n>=h-1,y=`flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-lg text-[var(--chrome-fg-600)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)] disabled:pointer-events-none disabled:opacity-35`;return(0,Y.jsxs)(`div`,{"data-overlay":!0,"data-testid":`flow-player`,className:`absolute bottom-6 left-1/2 z-30 flex w-[min(600px,calc(100%-32px))] -translate-x-1/2 flex-col gap-2 rounded-2xl bg-[var(--chrome-popup)] p-3 shadow-[0_8px_32px_rgba(0,0,0,0.16)] ring-1 ring-[var(--chrome-ring)]`,onPointerDown:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),children:[(0,Y.jsx)(Be,{switcher:m}),(0,Y.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Y.jsx)(`span`,{className:`mt-0.5 flex h-6 min-w-6 shrink-0 items-center justify-center rounded-full px-1.5 text-[12px] font-medium tabular-nums text-white ${g?.fails?`bg-[var(--flow-fail)]`:`bg-[var(--flow-accent)]`}`,children:h===0?`–`:n+1}),(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`p`,{"data-testid":`flow-step-title`,className:`text-[14px] font-medium leading-snug text-[var(--chrome-fg-900)]`,children:g?.title||(h===0?`This flow has no steps yet`:`Untitled step`)}),g?.text&&(0,Y.jsx)(`p`,{"data-testid":`flow-step-text`,className:`mt-0.5 text-[13px] leading-relaxed text-[var(--chrome-fg-600)]`,children:g.text}),g&&(r!==`call`||g.payload||g.fails)&&(0,Y.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-1.5 text-[11px] text-[var(--chrome-fg-500)]`,children:[g.fails&&(0,Y.jsx)(`span`,{"data-testid":`flow-step-fails`,className:`rounded-full bg-[color-mix(in_srgb,var(--flow-fail)_14%,transparent)] px-2 py-0.5 font-medium text-[var(--flow-fail)]`,children:`Fails here`}),r!==`call`&&(0,Y.jsx)(`span`,{"data-testid":`flow-step-kind`,className:`rounded-full bg-[var(--chrome-rest)] px-2 py-0.5`,children:Pe[r]}),g.payload&&(0,Y.jsxs)(`span`,{className:`rounded-full bg-[var(--chrome-rest)] px-2 py-0.5`,children:[`Carries `,g.payload]})]}),c.length>0&&(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`flow-branches`,children:[(0,Y.jsx)(`span`,{className:`text-[12px] text-[var(--chrome-fg-500)]`,children:`Or follow:`}),c.map(e=>(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`flow-branch`,className:`flex cursor-pointer items-center gap-1 rounded-full px-2.5 py-1 text-[12px] font-medium text-[var(--chrome-fg-900)] bg-[var(--chrome-rest)] transition-colors hover:bg-[var(--chrome-hover)]`,onClick:()=>l(e.id),children:[(0,Y.jsx)(A,{size:12,stroke:2}),e.name]},e.id))]})]}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Stop playing`,className:y,onClick:s,children:(0,Y.jsx)(R,{size:16,stroke:1.75})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1 truncate text-[12px] text-[var(--chrome-fg-500)]`,children:[u&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`flow-back`,title:`Back to where this path was taken (←)`,className:`flex cursor-pointer items-center gap-0.5 rounded px-1 font-medium text-[var(--chrome-fg-900)] hover:bg-[var(--chrome-hover)]`,onClick:d,children:[(0,Y.jsx)(v,{size:13,stroke:2}),u]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`/`})]}),(u||!m.tabs.some(e=>e.id===t.id)||!ze(m))&&(0,Y.jsx)(`span`,{className:`truncate`,children:t.name})]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1`,"data-testid":`flow-dots`,children:t.steps.map((e,t)=>(0,Y.jsx)(`button`,{type:`button`,"aria-label":e.branches?.length?`Step ${t+1}, where another path starts`:`Step ${t+1}`,"data-fork":e.branches?.length?!0:void 0,onClick:()=>o(t),className:`relative h-1.5 cursor-pointer rounded-full transition-all ${t===n?`w-4 bg-[var(--flow-accent)]`:`w-1.5 bg-[var(--chrome-fg-300)] hover:bg-[var(--chrome-fg-500)]`}`,children:e.branches?.length?(0,Y.jsx)(A,{size:9,stroke:2.5,"aria-hidden":!0,className:`absolute left-1/2 top-2 -translate-x-1/2 text-[var(--chrome-fg-400)]`}):null},`${e.target}-${t}`))}),(0,Y.jsx)(`span`,{"data-testid":`flow-position`,className:`w-10 text-right text-[12px] tabular-nums text-[var(--chrome-fg-500)]`,children:h===0?`0 / 0`:`${n+1} / ${h}`}),(0,Y.jsxs)(`div`,{className:`flex items-center`,children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Previous step`,"data-testid":`flow-prev`,className:y,disabled:n===0&&!u,onClick:()=>n===0?d():o(n-1),children:(0,Y.jsx)(M,{size:16,stroke:2})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":f?`Show the whole diagram`:`Follow each step`,title:f?`Show the whole diagram`:`Follow each step`,"aria-pressed":f,"data-testid":`flow-follow`,className:`${y} ${f?`bg-[var(--chrome-active)] text-[var(--chrome-fg-900)]`:``}`,onClick:()=>p(!f),children:(0,Y.jsx)(P,{size:16,stroke:1.75})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":i?`Pause`:`Play automatically`,"data-testid":`flow-autoplay`,className:y,disabled:h<2,onClick:()=>{!i&&_&&o(0),a(!i)},children:i?(0,Y.jsx)(le,{size:14}):(0,Y.jsx)(z,{size:14})}),_&&h>1?(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Play again`,"data-testid":`flow-replay`,className:y,onClick:()=>o(0),children:(0,Y.jsx)(ce,{size:15,stroke:1.75})}):(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Next step`,"data-testid":`flow-next`,className:y,disabled:_,onClick:()=>o(n+1),children:(0,Y.jsx)(N,{size:16,stroke:2})})]})]})]})}function ze(e){return e.tabs.length>1||e.onEdit!==null}function Be(e){let{tabs:t,active:n,onTab:r,onEdit:i,onNew:a}=e.switcher;if(!ze(e.switcher))return null;let o=`shrink-0 cursor-pointer rounded-md px-2 py-1 text-[12.5px] transition-colors hover:bg-[var(--chrome-hover)]`;return(0,Y.jsxs)(`div`,{className:`-mx-1 -mt-1 flex items-center gap-1 border-b border-[var(--chrome-divider)] pb-1.5`,children:[(0,Y.jsxs)(`div`,{role:`group`,"aria-label":`Flows`,"data-testid":`flow-tabs`,className:`flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto`,children:[t.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":e.id===n,"data-testid":`flow-tab`,className:`${o} ${e.id===n?`bg-[var(--chrome-active)] font-medium text-[var(--chrome-fg-900)]`:`text-[var(--chrome-fg-500)]`}`,onClick:()=>r(e.id),children:e.name},e.id)),a&&(0,Y.jsx)(`button`,{type:`button`,"aria-label":`New flow`,title:`New flow`,"data-testid":`flow-tab-new`,className:`${o} flex items-center text-[var(--chrome-fg-400)]`,onClick:a,children:(0,Y.jsx)(L,{size:14,stroke:2})})]}),i&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`flow-player-edit`,className:`flex shrink-0 cursor-pointer items-center gap-1 rounded-md px-2 py-1 text-[12.5px] font-medium text-[var(--chrome-fg-700)] transition-colors hover:bg-[var(--chrome-hover)]`,onClick:i,children:[(0,Y.jsx)(I,{size:13,stroke:1.75}),`Edit`]})]})}var $=10,Ve=28,He=.28;function Ue(e){let{viewport:t}=e,{store:n}=s(),r=c(e=>e.shapes),i=c(e=>e.flowEdit),a=c(e=>e.flowPlay),o=c(e=>e.flowPreview),l=a??i??o,u=(0,J.useMemo)(()=>{let e=l?r.find(e=>e.id===l.frameId):void 0;return e?.type===`figure`?e:null},[r,l]),d=(0,J.useMemo)(()=>u?B(r,u):[],[r,u]),f=u?.flows?.find(e=>e.id===l?.flowId),p=(0,J.useMemo)(()=>f?W(f,d):null,[f,d]);return(0,J.useEffect)(()=>{if(!l||u&&f)return;let e=n.getState();e.setFlowPlay(null),e.setFlowEdit(null),e.setFlowPreview(null)},[l,u,f,n]),!l||!u||!p?null:a?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(We,{frame:u,viewport:t}),(0,Y.jsx)(Ie,{frame:u,flow:p,targets:d,step:a.step,viewport:t})]}):i?(0,Y.jsx)(ge,{frame:u,flow:p,targets:d,viewport:t}):(0,Y.jsx)(Ge,{flow:p,targets:d,viewport:t})}function We(e){let{frame:t,viewport:n}=e,r=o(t),i=l({x:r.x-$,y:r.y-Ve},n),a=l({x:r.x+r.width+$,y:r.y+r.height+$},n);return(0,Y.jsx)(`div`,{"data-testid":`flow-spotlight`,className:`pointer-events-none absolute rounded-lg`,style:{left:i.x,top:i.y,width:Math.max(0,a.x-i.x),height:Math.max(0,a.y-i.y),boxShadow:`0 0 0 9999px var(--canvas-scrim)`}})}function Ge(e){let{flow:t,targets:n,viewport:r}=e,i=(0,J.useMemo)(()=>new Map(n.map(e=>[e.id,e])),[n]);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`style`,{"data-testid":`flow-preview`,children:(0,J.useMemo)(()=>{let e=new Set(t.steps.flatMap(K));t.steps.forEach((r,i)=>{let a=t.steps[i-1];if(a)for(let t of K(r))for(let r of K(a)){let i=H(n,r,t);if(i?.kind===`arrows`){i.hops.forEach(t=>e.add(t.arrow.id)),i.through.forEach(t=>e.add(t));break}}});let r=n.filter(t=>!e.has(t.id)&&!a(t)).flatMap(e=>[p(e.id),m(`data-icon-label`,e.id)]);return[`[data-canvas-root] :is([data-shape-id],[data-icon-label]){transition:opacity 180ms ease}`,r.length>0?`${r.join(`,`)}{opacity:${He}!important}`:``].join(``)},[t.steps,n])}),(0,Y.jsx)(ie,{numbers:ae(t),byId:i,viewport:r,current:null,failing:re(t)})]})}export{Ue as FlowLayer};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./react-lCSYwAWP.js";import{t as n}from"./jsx-runtime-DKdBMi_L.js";import{t as r}from"./tooltip-ClTJbfBH.js";import{i}from"./useTriggerFocusGuards-Mibi8yYw.js";import{C as a,c as o,d as s,f as c,i as l,m as u,o as d,p as f,r as p,t as m,w as h}from"./menu-rOnlAYaK.js";import{a as g,o as _}from"./editor-CpiNbiMQ.js";import{i as v}from"./config-D8b1QyEk.js";import{G as y}from"./frames-C-jROub3.js";import{t as ee}from"./editable-target-BTLnvKNi.js";import{t as b}from"./createReactComponent-C51FAx3B.js";import{t as x}from"./IconAlertTriangle-B33xznYN.js";import{a as S,n as C,r as w}from"./flow-start-D_gK7Gur.js";import{n as T,r as E,t as D}from"./IconTrash-C8w6ThWx.js";import{_ as O,a as k,b as te,f as A,g as ne,h as j,i as re,l as ie,m as ae,p as oe,r as se,s as ce,t as M,u as le,v as N,x as P,y as F}from"./tree-Ch-RF7UJ.js";import{n as I}from"./useValueChanged-SqLfIDi5.js";import{t as ue}from"./IconChevronLeft-D7e7QC0h.js";import{t as L}from"./IconChevronRight-csfMBSUs.js";import{t as de}from"./IconCornerDownRight-DDiBMO4O.js";import{t as fe}from"./IconLink-VS5p9Ytk.js";import{t as R}from"./IconPencil-D_pQsAyv.js";import{t as z}from"./IconPlus-D4tAoi-A.js";import{n as B,r as V,t as H}from"./MenuSubmenuTrigger-CTLO1z_0.js";import{n as pe,r as me,t as he}from"./use-drag-reorder-ye8-kpyR.js";import{t as U}from"./IconSparkles-CnCp3BCQ.js";import{t as ge}from"./IconSquare-Ce_qY-mF.js";import{t as W}from"./IconX-KrRqxr2j.js";import{t as _e}from"./IconPlayerPlayFilled-DVAWmYt7.js";import{n as ve,r as G,t as ye}from"./core-DnS-1skV.js";import{n as be}from"./surface-Dke4SWpE.js";import{a as xe}from"./chrome-C2RCq3SI.js";import"./chrome-layout-500Q9pcx.js";import{t as Se}from"./panel-shell-CSvihB5L.js";import{i as Ce,l as we,n as Te,s as K}from"./flows-BAU4NQGk.js";var q=b(`outline`,`arrows-exchange`,`ArrowsExchange`,[[`path`,{d:`M7 10h14l-4 -4`,key:`svg-0`}],[`path`,{d:`M17 14h-14l4 4`,key:`svg-1`}]]),Ee=b(`outline`,`bolt`,`Bolt`,[[`path`,{d:`M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11`,key:`svg-0`}]]),J=b(`outline`,`package`,`Package`,[[`path`,{d:`M12 3l8 4.5l0 9l-8 4.5l-8 -4.5l0 -9l8 -4.5`,key:`svg-0`}],[`path`,{d:`M12 12l8 -4.5`,key:`svg-1`}],[`path`,{d:`M12 12l0 9`,key:`svg-2`}],[`path`,{d:`M12 12l-8 -4.5`,key:`svg-3`}],[`path`,{d:`M16 5.25l-8 4.5`,key:`svg-4`}]]),De=b(`outline`,`square-plus`,`SquarePlus`,[[`path`,{d:`M9 12h6`,key:`svg-0`}],[`path`,{d:`M12 9v6`,key:`svg-1`}],[`path`,{d:`M3 5a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2v-14`,key:`svg-2`}]]),Y=e(t(),1),Oe=`w-full min-w-0 rounded-md bg-transparent px-1.5 py-1 text-[12px] text-[var(--chrome-fg-800)] outline-none ring-1 ring-transparent transition-shadow placeholder:text-[var(--chrome-fg-300)] hover:ring-[var(--chrome-ring)] focus:bg-[var(--chrome-rest)] focus:ring-[var(--chrome-fg-300)]`,ke=`flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--chrome-fg-400)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-800)] disabled:pointer-events-none disabled:opacity-40`,Ae=`flex h-9 w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--chrome-accent)] text-[13px] text-white transition-colors hover:bg-[var(--chrome-accent-hover)] disabled:pointer-events-none disabled:bg-[var(--chrome-hover)] disabled:text-[var(--chrome-fg-400)]`,je=`inline-flex h-[18px] min-w-[18px] items-center justify-center rounded bg-[var(--chrome-popup)] px-1 font-mono text-[10.5px] text-[var(--chrome-fg-600)] shadow-[inset_0_0_0_1px_var(--chrome-input),0_1px_0_var(--chrome-input)]`,Me=`hover:bg-[color-mix(in_srgb,var(--chrome-fg-900)_3%,transparent)]`,Ne=`bg-[color-mix(in_srgb,var(--chrome-fg-900)_5%,transparent)]`,Pe=`flex cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 text-[13px] text-[var(--chrome-fg-700)] ring-1 ring-[var(--chrome-ring)] transition-colors hover:bg-[var(--chrome-rest)] hover:text-[var(--chrome-fg-900)] disabled:pointer-events-none disabled:opacity-50`,X=n(),Fe=2e3,Ie=`mb-1.5 flex gap-2 rounded-lg bg-[color-mix(in_srgb,var(--chrome-fg-900)_4%,transparent)] py-2 pl-2.5 pr-2 text-[12px] leading-[1.45] text-[var(--chrome-fg-600)]`;function Le(e){let{count:t,attached:n,onAttach:r,onSettled:i}=e,a=(0,Y.useRef)(i);a.current=i;let o=t===0&&n;return(0,Y.useEffect)(()=>{if(!o)return;let e=window.setTimeout(()=>a.current(),Fe);return()=>window.clearTimeout(e)},[o]),o?(0,X.jsxs)(`div`,{"data-testid":`flow-loose-attached`,role:`status`,className:`${Ie} items-center`,children:[(0,X.jsx)(I,{size:14,stroke:2,className:`shrink-0 text-[var(--chrome-fg-500)]`}),`Arrow attached`]}):t===0?null:(0,X.jsx)(Re,{count:t,onAttach:r})}function Re(e){let{count:t,onAttach:n}=e,r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=r.current;!e||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches||e.animate([{opacity:0,transform:`translateY(-4px)`},{opacity:1,transform:`none`}],{duration:180,easing:`ease-out`})},[]);let i=t===1;return(0,X.jsxs)(`div`,{ref:r,role:`status`,"data-testid":`flow-loose-banner`,className:`${Ie} items-start`,children:[(0,X.jsx)(x,{size:14,stroke:2,className:`mt-px shrink-0 text-[var(--flow-warn)]`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`b`,{className:`block font-medium text-[var(--chrome-fg-900)]`,children:i?`1 arrow isn't attached`:`${t} arrows aren't attached`}),i?`It`:`They`,` won't stay joined when the boxes move.`]}),(0,X.jsx)(`button`,{type:`button`,"data-testid":`flow-attach-all`,className:`${Pe} h-7 shrink-0 px-2.5 text-[12px]`,onClick:n,children:i?`Attach`:`Attach all`})]})}var ze=`w-[1.5px] bg-[color-mix(in_srgb,var(--chrome-fg-900)_14%,transparent)]`,Be=`w-[1.5px] bg-[var(--flow-accent)]`,Ve=`w-[1.5px] bg-[linear-gradient(color-mix(in_srgb,var(--chrome-fg-900)_14%,transparent),transparent)]`,Z=`relative z-[1] flex h-[22px] min-w-[22px] shrink-0 items-center justify-center rounded-full px-1 text-[11px] font-semibold tabular-nums`,He=`shadow-[inset_0_0_0_1.5px_color-mix(in_srgb,var(--chrome-fg-900)_22%,transparent)]`,Ue=`${Z} bg-[var(--chrome-popup)] text-[var(--chrome-fg-400)] shadow-[inset_0_0_0_1.5px_color-mix(in_srgb,var(--chrome-fg-900)_14%,transparent)]`,We=`${Z} bg-[var(--chrome-popup)] text-[var(--chrome-fg-900)] shadow-[inset_0_0_0_1.5px_var(--chrome-fg-900)]`;function Ge(e){return e.picking?We:e.current?`${Z} bg-[var(--flow-accent)] text-white`:e.selected?`${Z} text-white ${e.fails?`bg-[var(--flow-fail)]`:`bg-[var(--chrome-accent)]`}`:e.fails?`${Z} bg-[var(--chrome-popup)] text-[var(--flow-fail)] shadow-[inset_0_0_0_1.5px_var(--flow-fail)]`:`${Z} bg-[var(--chrome-popup)] text-[var(--chrome-fg-700)] ${He} hover:shadow-[inset_0_0_0_1.5px_var(--chrome-fg-500)]`}function Ke(e){let{node:t,first:n,end:r,litAbove:i,litBelow:a}=e;return(0,X.jsxs)(`span`,{className:`flex w-[22px] shrink-0 flex-col items-center`,children:[(0,X.jsx)(`span`,{className:`h-2 shrink-0 ${n?`w-[1.5px]`:i?Be:ze}`}),t,(0,X.jsx)(`span`,{className:`min-h-2 flex-1 ${r?Ve:a?Be:ze}`})]})}var qe=[{kind:`call`,label:`Call`,hint:`Waits for an answer`,pickable:!0},{kind:`async`,label:`Fire and forget`,hint:`Doesn't wait for an answer`,pickable:!0},{kind:`reply`,label:`Reply`,hint:`Answers an earlier step`,pickable:!1}],Je=e=>qe.find(t=>t.kind===e)?.label,Ye=`${Oe} -mx-1.5 px-1.5 hover:ring-transparent focus:bg-transparent focus:ring-transparent`;function Xe(e){let{step:t,index:n,count:r,current:a,selected:o,picking:s,names:c,otherFlows:l,loose:u}=e,{rail:f,actions:p,grip:m,rowRef:h,rowStyle:g}=e,{onPlay:_,onChange:v,onMove:y,onRemove:ee,onNewPath:b}=p,[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!1),E=(0,Y.useRef)(null),D=t.kind??`call`,O=t.also??[],k=t.branches??[],te=new Map(l.map(e=>[e.id,e.name])),A=o||w||S,ne=A||!!t.text,j=S||!!t.payload,re=O.length>0||D!==`call`||j||k.length>0;return(0,X.jsxs)(`li`,{ref:h,"data-testid":`flow-step-${n}`,"data-current":a||void 0,"data-selected":o||void 0,"aria-current":o?`step`:void 0,className:`group relative flex gap-2.5 rounded-lg pl-1 pr-1.5 transition-colors ${o||s?Ne:Me}`,style:g,onPointerDown:e=>{e.target.closest(`[data-step-insert]`)||p.onSelect()},onFocusCapture:e=>{e.target.closest(`[data-step-insert]`)||p.onSelect()},onPointerEnter:()=>p.onHover(!0),onPointerLeave:()=>p.onHover(!1),children:[(0,X.jsx)(Ze,{index:n,onInsert:p.onInsertBefore}),(0,X.jsx)(Ke,{first:f.first,end:f.end,litAbove:f.litAbove,litBelow:f.litBelow,node:(0,X.jsx)(`span`,{"data-testid":`flow-step-grip-${n}`,title:`Drag to reorder`,className:`${Ge({selected:o,current:a,fails:!!t.fails,picking:s})} cursor-grab touch-none transition-shadow active:cursor-grabbing`,...m,children:s?(0,X.jsx)(q,{size:12,stroke:2}):n+1})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 py-2 pr-6`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(`input`,{"aria-label":`Step title`,"data-testid":`flow-step-title-${n}`,className:`${Ye} h-[22px] text-[13px] font-medium text-[var(--chrome-fg-900)]`,defaultValue:t.title,onBlur:e=>{e.target.value!==t.title&&v({title:e.target.value})},onKeyDown:e=>{if(e.key===`Enter`&&!e.shiftKey&&E.current){e.preventDefault(),e.stopPropagation(),E.current.focus();return}ot(e)}},`t-${t.title}`),!o&&(0,X.jsx)(Qe,{index:n,step:t,names:c,flowName:te,loose:u?.names??null})]}),ne&&(0,X.jsx)(`textarea`,{ref:E,"aria-label":`What happens at this step`,"data-testid":`flow-step-text-${n}`,rows:1,className:`${Ye} resize-none py-0 text-[12px] leading-[1.55] text-[var(--chrome-fg-500)] placeholder:text-[var(--chrome-fg-400)] focus:text-[var(--chrome-fg-800)] [field-sizing:content]`,placeholder:O.length>0?`What happens at ${K([t.target,...O].map(e=>c.get(e)??`Shape`))}`:`Add a description`,defaultValue:t.text??``,onFocus:()=>T(!0),onBlur:e=>{T(!1);let n=e.target.value.trim();n!==(t.text??``)&&v({text:n})},onKeyDown:ot},`d-${t.text??``}`),t.fails&&(0,X.jsx)(`span`,{"data-testid":`flow-step-fails-${n}`,className:`text-[12px] leading-[1.55] text-[var(--flow-fail)]`,children:`Fails here`}),s&&(0,X.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[12px] text-[var(--chrome-fg-700)]`,children:[`Click the box this step should light`,(0,X.jsx)(`button`,{type:`button`,"aria-label":`Cancel`,title:`Cancel`,className:`inline-flex h-[18px] min-w-[18px] items-center justify-center rounded bg-[var(--chrome-popup)] px-1 font-mono text-[10.5px] text-[var(--chrome-fg-600)] shadow-[inset_0_0_0_1px_var(--chrome-input),0_1px_0_var(--chrome-input)] cursor-pointer hover:text-[var(--chrome-fg-900)]`,onClick:p.onCancelPick,children:`esc`})]}),o&&u&&(0,X.jsxs)(`div`,{role:`status`,"data-testid":`flow-step-loose-${n}`,className:`mt-1 flex items-start gap-2 rounded-md bg-[color-mix(in_srgb,var(--flow-warn)_9%,transparent)] p-2 text-[12px] leading-[1.45] text-[var(--chrome-fg-600)]`,children:[(0,X.jsx)(x,{size:14,stroke:2,className:`mt-px shrink-0 text-[var(--flow-warn)]`}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col items-start gap-1.5`,children:[`The arrow isn't attached to `,u.names,`, so it won't stay joined when the box moves.`,(0,X.jsxs)(`button`,{type:`button`,"data-testid":`flow-step-attach-${n}`,className:`flex h-6 shrink-0 cursor-pointer items-center gap-1 rounded-md bg-[var(--chrome-popup)] px-2 font-medium text-[var(--chrome-fg-800)] shadow-[inset_0_0_0_1px_var(--chrome-input-hover)] transition-colors hover:bg-[var(--chrome-hover)]`,onClick:u.onAttach,children:[(0,X.jsx)(fe,{size:12,stroke:2}),`Attach`]})]})]}),A&&re&&(0,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,"data-testid":`flow-step-chips-${n}`,children:[D!==`call`&&(0,X.jsx)(nt,{kind:D,onPick:e=>v({kind:e}),trigger:(0,X.jsxs)(d,{"data-testid":`flow-step-kind-${n}`,className:`${Q} cursor-pointer hover:bg-[var(--chrome-hover)]`,children:[Je(D),(0,X.jsx)(i,{size:11,stroke:2,className:`text-[var(--chrome-fg-400)]`})]})}),j&&(0,X.jsx)(tt,{index:n,payload:t.payload,editing:S,onEdit:()=>C(!0),onDone:e=>{C(!1),e!==(t.payload??``)&&v({payload:e||void 0})}}),O.length>0&&[t.target,...O].map((e,t)=>(0,X.jsx)(et,{testId:`flow-step-box-${n}`,icon:(0,X.jsx)(ge,{size:11,stroke:2}),label:c.get(e)??`Shape`,title:`Lit by this step`,onRemove:()=>v(t===0?{target:O[0],also:O.slice(1)}:{also:O.filter(t=>t!==e)})},e)),k.map(e=>(0,X.jsx)(et,{testId:`flow-step-path-${n}`,icon:(0,X.jsx)(P,{size:11,stroke:2}),label:te.get(e)??`Missing flow`,title:`Another path from here`,onRemove:()=>v({branches:k.filter(t=>t!==e)})},e))]})]}),(0,X.jsx)(at,{index:n,count:r,step:t,hasPayload:j,paths:l.filter(e=>!k.includes(e.id)),onPlay:_,onPayload:()=>C(!0),onChange:v,onMove:y,onRemove:ee,onNewPath:b,onInsertBefore:p.onInsertBefore,onInsertAfter:p.onInsertAfter,onChangeBox:p.onChangeBox})]})}function Ze(e){let{index:t,onInsert:n}=e;return(0,X.jsxs)(`button`,{type:`button`,"aria-label":`Add a step before step ${t+1}`,"data-testid":`flow-step-insert-${t}`,"data-step-insert":!0,className:`absolute inset-x-0 -top-[7px] z-10 flex h-3.5 cursor-pointer items-center gap-1.5 pl-[7px] opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100`,onPointerDown:e=>e.stopPropagation(),onClick:n,children:[(0,X.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center rounded-full bg-[var(--chrome-popup)] text-[var(--chrome-fg-600)] shadow-[inset_0_0_0_1px_var(--chrome-input-hover)]`,children:(0,X.jsx)(z,{size:10,stroke:2.5})}),(0,X.jsx)(`span`,{className:`rounded bg-[var(--chrome-popup)] px-1 text-[11.5px] text-[var(--chrome-fg-500)]`,children:`Insert a step`})]})}function Qe(e){let{index:t,step:n,names:i,flowName:a,loose:o}=e,s=[];if(n.kind===`async`&&s.push({key:`kind`,label:`Fire and forget`,icon:(0,X.jsx)(Ee,{size:13,stroke:1.75})}),n.kind===`reply`&&s.push({key:`kind`,label:`Reply`,icon:(0,X.jsx)(S,{size:13,stroke:1.75})}),n.payload&&s.push({key:`payload`,label:`Carries ${n.payload}`,icon:(0,X.jsx)(J,{size:13,stroke:1.75})}),n.also?.length){let e=K([n.target,...n.also].map(e=>i.get(e)??`Shape`));s.push({key:`also`,label:`Lights ${e}`,icon:(0,X.jsx)(De,{size:13,stroke:1.75})})}if(n.branches?.length){let e=n.branches.map(e=>a.get(e)??`Missing flow`).join(`, `);s.push({key:`paths`,label:`Path to ${e}`,icon:(0,X.jsx)(P,{size:13,stroke:1.75})})}return s.length===0&&!o?null:(0,X.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[var(--chrome-fg-400)]`,children:[s.map(e=>(0,X.jsx)(r,{label:e.label,children:(0,X.jsx)(`span`,{role:`img`,"aria-label":e.label,children:e.icon})},e.key)),o&&(0,X.jsx)(r,{label:`The arrow isn't attached to ${o}`,children:(0,X.jsx)(`span`,{role:`img`,"data-testid":`flow-step-loose-${t}`,"aria-label":`The arrow isn't attached to ${o}`,className:`text-[var(--flow-warn)]`,children:(0,X.jsx)(x,{size:13,stroke:2})})})]})}var Q=`flex h-6 items-center gap-1 rounded-md bg-[var(--chrome-rest)] px-1.5 text-[11.5px] text-[var(--chrome-fg-700)] ring-1 ring-[var(--chrome-ring)]`,$=`flex cursor-default select-none items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] text-[var(--chrome-fg-700)] outline-none data-[highlighted]:bg-[var(--chrome-hover)]`,$e=`min-w-[200px] p-1 outline-none ${be.popup}`;function et(e){let{label:t,icon:n,onRemove:r,testId:i,title:a,tone:o}=e;return(0,X.jsxs)(`span`,{"data-testid":i,title:a,className:`${Q} pr-0.5 ${o===`fail`?`bg-[color-mix(in_srgb,var(--flow-fail)_10%,transparent)] text-[var(--flow-fail)] ring-[color-mix(in_srgb,var(--flow-fail)_25%,transparent)]`:``}`,children:[(0,X.jsx)(`span`,{className:`opacity-70`,children:n}),(0,X.jsx)(`span`,{className:`max-w-[140px] truncate`,children:t}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Remove ${t}`,className:`flex h-4 w-4 cursor-pointer items-center justify-center rounded opacity-60 hover:bg-[var(--chrome-hover)] hover:opacity-100`,onClick:r,children:(0,X.jsx)(W,{size:10,stroke:2})})]})}function tt(e){let{index:t,payload:n,editing:r,onEdit:i,onDone:a}=e;return r?(0,X.jsxs)(`span`,{className:`${Q} pr-1`,children:[(0,X.jsx)(J,{size:11,stroke:2,className:`opacity-70`}),(0,X.jsx)(`input`,{autoFocus:!0,"data-testid":`flow-step-payload-${t}`,"aria-label":`What this step carries`,placeholder:`e.g. order #1042`,className:`w-28 bg-transparent text-[11.5px] outline-none placeholder:text-[var(--chrome-fg-400)]`,defaultValue:n??``,onBlur:e=>a(e.target.value.trim()),onKeyDown:e=>{e.stopPropagation(),(e.key===`Enter`||e.key===`Escape`)&&e.currentTarget.blur()}})]}):(0,X.jsxs)(`span`,{className:`${Q} pr-0.5`,"data-testid":`flow-step-payload-chip-${t}`,children:[(0,X.jsx)(J,{size:11,stroke:2,className:`opacity-70`}),(0,X.jsx)(`button`,{type:`button`,title:`What this step carries`,className:`max-w-[140px] cursor-text truncate`,onClick:i,children:n}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Remove what it carries`,className:`flex h-4 w-4 cursor-pointer items-center justify-center rounded opacity-60 hover:bg-[var(--chrome-hover)] hover:opacity-100`,onClick:()=>a(``),children:(0,X.jsx)(W,{size:10,stroke:2})})]})}function nt(e){let{kind:t,onPick:n,trigger:r}=e;return(0,X.jsxs)(o,{children:[r,(0,X.jsx)(c,{children:(0,X.jsx)(s,{side:`bottom`,align:`start`,sideOffset:4,className:`z-50 outline-none`,children:(0,X.jsx)(p,{"data-overlay":!0,className:`min-w-[220px] p-1`,children:(0,X.jsx)(rt,{kind:t,onPick:n})})})})]})}function rt(e){let{kind:t,onPick:n}=e;return(0,X.jsx)(X.Fragment,{children:qe.filter(e=>e.pickable).map(e=>(0,X.jsxs)(u,{"data-testid":`flow-kind-${e.kind}`,className:$,onClick:()=>n(e.kind===`call`?void 0:e.kind),children:[(0,X.jsx)(`span`,{className:`flex w-4 justify-center text-[var(--chrome-fg-900)]`,children:t===e.kind&&(0,X.jsx)(I,{size:14,stroke:2})}),(0,X.jsxs)(`span`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-[var(--chrome-fg-900)]`,children:e.label}),(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:e.hint})]})]},e.kind))})}function it(e){let{label:t,icon:n,testId:r,children:i}=e;return(0,X.jsxs)(B,{children:[(0,X.jsxs)(H,{className:`${$} justify-between`,"data-testid":r,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:n}),t]}),(0,X.jsx)(L,{size:14,stroke:1.75,className:`text-[var(--chrome-fg-400)]`})]}),(0,X.jsx)(c,{children:(0,X.jsx)(s,{className:`z-50 outline-none`,children:(0,X.jsx)(f,{"data-overlay":!0,className:$e,children:i})})})]})}function at(e){let{index:t,count:n,step:r,hasPayload:i,paths:f}=e,{onPlay:g,onPayload:_,onChange:v,onMove:y,onRemove:ee,onNewPath:b}=e,{onInsertBefore:S,onInsertAfter:C,onChangeBox:w}=e,O=r.branches??[];return(0,X.jsxs)(o,{children:[(0,X.jsx)(d,{"aria-label":`Step options`,"data-testid":`flow-step-menu-${t}`,className:`${ke} absolute right-1 top-[7px] opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100 group-aria-[current=step]:opacity-100 data-[popup-open]:opacity-100`,children:(0,X.jsx)(h,{size:14,stroke:1.75})}),(0,X.jsx)(c,{children:(0,X.jsx)(s,{side:`bottom`,align:`end`,sideOffset:4,className:`z-50 outline-none`,children:(0,X.jsxs)(p,{"data-overlay":!0,className:`min-w-[210px] p-1`,children:[(0,X.jsx)(m,{testId:`flow-step-play`,icon:(0,X.jsx)(a,{size:15,stroke:1.75}),onClick:g,children:`Play from here`}),(0,X.jsx)(l,{}),(0,X.jsx)(m,{testId:`flow-step-change-box`,icon:(0,X.jsx)(q,{size:15,stroke:1.75}),onClick:w,children:`Change box…`}),(0,X.jsx)(m,{testId:`flow-step-insert-above`,icon:(0,X.jsx)(pe,{size:15,stroke:1.75}),onClick:S,children:`Add a step above`}),(0,X.jsx)(m,{testId:`flow-step-insert-below`,icon:(0,X.jsx)(me,{size:15,stroke:1.75}),onClick:C,children:`Add a step below`}),(0,X.jsx)(l,{}),(0,X.jsx)(it,{label:`How it travels`,icon:(0,X.jsx)(V,{size:15,stroke:1.75}),testId:`flow-step-travels`,children:(0,X.jsx)(rt,{kind:r.kind??`call`,onPick:e=>v({kind:e})})}),!i&&(0,X.jsx)(m,{testId:`flow-step-add-payload`,icon:(0,X.jsx)(J,{size:15,stroke:1.75}),onClick:_,children:`Add what it carries`}),(0,X.jsx)(m,{testId:`flow-step-toggle-fails`,icon:(0,X.jsx)(x,{size:15,stroke:1.75}),onClick:()=>v({fails:!r.fails||void 0}),children:r.fails?`Doesn't fail here`:`Fails here`}),(0,X.jsxs)(it,{label:`Another path from here`,icon:(0,X.jsx)(P,{size:15,stroke:1.75}),testId:`flow-step-paths`,children:[f.map(e=>(0,X.jsx)(u,{className:$,onClick:()=>v({branches:[...O,e.id]}),children:e.name},e.id)),f.length>0&&(0,X.jsx)(l,{}),(0,X.jsxs)(u,{className:$,"data-testid":`flow-step-new-path`,onClick:b,children:[(0,X.jsx)(z,{size:14,stroke:1.75,className:`text-[var(--chrome-fg-400)]`}),`New path`]})]}),(0,X.jsx)(l,{}),(0,X.jsx)(m,{testId:`flow-step-up`,icon:(0,X.jsx)(T,{size:15,stroke:1.75}),disabled:t===0,onClick:()=>y(-1),children:`Move up`}),(0,X.jsx)(m,{testId:`flow-step-down`,icon:(0,X.jsx)(E,{size:15,stroke:1.75}),disabled:t===n-1,onClick:()=>y(1),children:`Move down`}),(0,X.jsx)(m,{testId:`flow-step-remove`,icon:(0,X.jsx)(D,{size:15,stroke:1.75}),onClick:ee,children:`Remove step`})]})})})]})}function ot(e){e.stopPropagation(),(e.key===`Enter`&&!e.shiftKey||e.key===`Escape`)&&e.currentTarget.blur()}function st(){let e=g(),{store:t}=e,n=_(e=>e.shapes),i=_(e=>e.viewMode),a=(0,Y.useMemo)(()=>G(n),[n]),o=(0,Y.useMemo)(()=>y(n).filter(e=>ye(n,[e])?.id===e.id),[n]),s=()=>t.getState().setFlowsOpen(!1),c=(e,n)=>t.getState().setFlowPreview(n?{frameId:e,flowId:n}:null);return(0,Y.useEffect)(()=>()=>t.getState().setFlowPreview(null),[t]),(0,X.jsxs)(Se,{width:300,testId:`flow-list`,ariaLabel:`Flows`,onDismiss:s,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1 py-2 pl-4 pr-2`,children:[(0,X.jsx)(`span`,{className:`flex-1 text-[14px] font-medium text-[var(--chrome-fg-900)]`,children:`Flows`}),!i&&o.length>0&&(0,X.jsx)(ut,{frames:o,onPick:t=>w(e,t.id)}),(0,X.jsx)(r,{label:`Close`,side:`bottom`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close flows`,"data-testid":`flow-list-close`,onClick:s,className:xe,children:(0,X.jsx)(W,{size:16,stroke:1.75})})})]}),(0,X.jsx)(`div`,{className:`mx-3 h-px bg-[var(--chrome-divider)]`}),(0,X.jsx)(`div`,{className:`flex flex-1 flex-col gap-4 overflow-y-auto p-3`,children:a.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-3 py-8 text-center`,children:[(0,X.jsx)(`p`,{className:`text-balance text-[13px] font-medium text-[var(--chrome-fg-900)]`,children:`No flows yet`}),(0,X.jsx)(`p`,{className:`text-balance text-[12px] leading-relaxed text-[var(--chrome-fg-500)]`,children:o.length>0?`A flow walks people through a diagram, one step at a time.`:`Put a diagram in a frame, then add a flow to it.`})]}):a.map(n=>(0,X.jsxs)(`section`,{className:`flex flex-col gap-0.5`,onPointerLeave:()=>c(n.id,null),children:[(0,X.jsx)(`h3`,{className:`truncate px-2 pb-1 text-[11px] font-medium text-[var(--chrome-fg-400)]`,children:n.label||`Untitled frame`}),M(n.flows??[]).map(({flow:r,depth:a,origin:o})=>(0,X.jsx)(ct,{flow:r,depth:a,forkStep:o?o.index+1:null,viewMode:i,onPreview:e=>c(n.id,e?r.id:null),onPlay:()=>C(e,n.id,r.id),onOpen:()=>t.getState().setFlowEdit({frameId:n.id,flowId:r.id})},r.id))]},n.id))})]})}function ct(e){let{flow:t,depth:n,forkStep:i,viewMode:a,onPreview:o,onPlay:s,onOpen:c}=e,l=t.steps.length,u=t.steps.some(e=>e.fails),d=`${l} ${l===1?`step`:`steps`}`;return(0,X.jsxs)(`div`,{"data-testid":`flow-list-row`,className:`group flex items-center gap-2 rounded-lg py-1.5 pr-1.5 transition-colors hover:bg-[var(--chrome-rest)]`,style:{paddingLeft:8+n*18},onPointerEnter:()=>o(!0),children:[(0,X.jsx)(`span`,{className:`shrink-0 text-[var(--chrome-fg-400)]`,children:n>0?(0,X.jsx)(P,{size:14,stroke:1.75}):(0,X.jsx)(V,{size:14,stroke:1.75})}),(0,X.jsxs)(`button`,{type:`button`,"data-testid":`flow-list-open`,title:a?`Play ${t.name}`:`Edit ${t.name}`,className:`flex min-w-0 flex-1 cursor-pointer flex-col text-left`,onFocus:()=>o(!0),onBlur:()=>o(!1),onClick:a?s:c,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`truncate text-[13px] font-medium text-[var(--chrome-fg-900)]`,children:t.name}),u&&(0,X.jsx)(`span`,{title:`Shows something failing`,className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--flow-fail)]`})]}),(0,X.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:i===null?d:`From step ${i} · ${d}`})]}),l>0&&(0,X.jsx)(r,{label:`Play`,side:`left`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Play ${t.name}`,"data-testid":`flow-list-play`,className:`flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded-full bg-[var(--flow-accent)] text-white opacity-90 transition-opacity hover:opacity-100`,onClick:s,children:(0,X.jsx)(_e,{size:11})})})]})}var lt=`flex h-7 cursor-pointer items-center gap-1 rounded-md px-2 text-[12.5px] font-medium text-[var(--flow-accent)] transition-colors hover:bg-[var(--chrome-hover)]`;function ut(e){let{frames:t,onPick:n}=e,r=t.length===1?t[0]:void 0;return r?(0,X.jsxs)(`button`,{type:`button`,"data-testid":`flow-list-new`,title:`New flow on ${r.label||`the frame`}`,className:lt,onClick:()=>n(r),children:[(0,X.jsx)(z,{size:14,stroke:2}),`New`]}):(0,X.jsxs)(o,{children:[(0,X.jsxs)(d,{"data-testid":`flow-list-new`,className:lt,children:[(0,X.jsx)(z,{size:14,stroke:2}),`New`]}),(0,X.jsx)(c,{children:(0,X.jsx)(s,{side:`bottom`,align:`end`,sideOffset:6,className:`z-50 outline-none`,children:(0,X.jsxs)(p,{"data-overlay":!0,className:`min-w-[240px] p-1`,children:[(0,X.jsx)(`span`,{className:`block px-2 pb-1 pt-1.5 text-[11px] font-medium text-[var(--chrome-fg-400)]`,children:`On which diagram?`}),t.map(e=>(0,X.jsx)(u,{"data-testid":`flow-list-new-frame`,className:`flex cursor-default select-none items-center gap-2 rounded-lg px-2 py-1.5 text-[13px] text-[var(--chrome-fg-700)] outline-none data-[highlighted]:bg-[var(--chrome-hover)]`,onClick:()=>n(e),children:e.label||`Untitled frame`},e.id))]})})})]})}function dt(e){let{frameId:t,readOnly:n}=e,r=g();return(0,X.jsx)(c,{children:(0,X.jsx)(s,{side:`bottom`,align:`end`,sideOffset:6,className:`z-50 outline-none`,children:(0,X.jsx)(p,{"data-overlay":!0,"data-testid":`figure-flow-list`,className:`w-[300px] p-1`,finalFocus:()=>r.store.getState().flowEdit===null,children:(0,X.jsx)(ft,{frameId:t,readOnly:n})})})})}function ft(e){let{frameId:t,readOnly:n}=e,r=g(),i=_(e=>{let n=e.shapes.find(e=>e.id===t);return n?.type===`figure`?n:null}),a=_(e=>e.lastFlow[t]),o=e=>r.store.getState().setFlowPreview(e?{frameId:t,flowId:e}:null);return(0,Y.useEffect)(()=>()=>r.store.getState().setFlowPreview(null),[r]),i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`px-2 pb-1 pt-1.5 text-[11px] font-medium text-[var(--chrome-fg-400)]`,children:[`Flows on `,i.label||`this diagram`]}),(0,X.jsx)(`div`,{onPointerLeave:()=>o(null),children:M(i.flows??[]).map(({flow:e,depth:t,origin:r})=>(0,X.jsx)(mt,{frame:i,flow:e,depth:t,forkStep:r?r.index+1:null,last:e.id===a,readOnly:n,onPreview:o},e.id))}),!n&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(l,{}),(0,X.jsx)(m,{testId:`figure-flow-new`,icon:(0,X.jsx)(z,{size:15,stroke:1.75}),onClick:()=>w(r,t),children:`New flow`})]})]}):null}var pt=`flex h-7 w-7 shrink-0 cursor-default items-center justify-center rounded-lg text-[var(--chrome-fg-400)] outline-none data-[highlighted]:bg-[var(--chrome-hover)] data-[highlighted]:text-[var(--chrome-fg-800)]`;function mt(e){let{frame:t,flow:n,depth:r,forkStep:i,last:o,readOnly:l,onPreview:d}=e,f=g(),_=n.steps.length,v=n.steps.some(e=>e.fails);return(0,X.jsxs)(`div`,{"data-testid":`figure-flow-row`,className:`flex items-center gap-0.5`,style:{paddingLeft:r*16},onPointerEnter:()=>d(n.id),children:[(0,X.jsxs)(u,{"data-testid":`figure-flow-row-play`,disabled:_===0,className:`${be.menuItem} min-w-0 flex-1`,onFocus:()=>d(n.id),onClick:()=>C(f,t.id,n.id),children:[(0,X.jsx)(`span`,{className:o?`text-[var(--flow-accent)]`:`text-[var(--chrome-fg-400)]`,children:r>0?(0,X.jsx)(P,{size:15,stroke:1.75}):o?(0,X.jsx)(_e,{size:13}):(0,X.jsx)(a,{size:15,stroke:1.75})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsx)(`span`,{className:`truncate text-[var(--chrome-fg-900)]`,children:n.name}),i!==null&&(0,X.jsxs)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:[`From step `,i]})]}),v&&(0,X.jsx)(`span`,{title:`Shows something failing`,className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--flow-fail)]`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-[var(--chrome-fg-400)]`,children:[_,` `,_===1?`step`:`steps`]})]}),!l&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(u,{"aria-label":`Edit ${n.name}`,"data-testid":`figure-flow-row-edit`,className:pt,onFocus:()=>d(n.id),onClick:()=>F(f,t.id,n.id),children:(0,X.jsx)(R,{size:14,stroke:1.75})}),(0,X.jsxs)(B,{children:[(0,X.jsx)(H,{"aria-label":`More for ${n.name}`,"data-testid":`figure-flow-row-more`,className:pt,children:(0,X.jsx)(h,{size:14,stroke:1.75})}),(0,X.jsx)(c,{children:(0,X.jsx)(s,{className:`z-50 outline-none`,sideOffset:4,children:(0,X.jsxs)(p,{"data-overlay":!0,className:`min-w-[160px] p-1`,children:[(0,X.jsx)(m,{testId:`figure-flow-rename`,icon:(0,X.jsx)(R,{size:15,stroke:1.75}),onClick:()=>f.store.getState().setFlowEdit({frameId:t.id,flowId:n.id,rename:!0}),children:`Rename`}),(0,X.jsx)(m,{testId:`figure-flow-delete`,icon:(0,X.jsx)(D,{size:15,stroke:1.75}),onClick:()=>N(f,t.id,n.id),children:`Delete`})]})})})]})]})]})}var ht=/^Flow \d+$/;function gt(){let e=_(e=>e.flowEdit);return _(e=>e.rightPanel===`flow`)?e?(0,X.jsx)(_t,{frameId:e.frameId,flowId:e.flowId},e.flowId):(0,X.jsx)(st,{}):null}function _t(e){let{frameId:t,flowId:n}=e,{ai:i}=v(),a=g(),{store:o}=a,s=_(e=>e.shapes),c=_(e=>e.flowPlay),l=_(e=>e.flowEdit)??{},u=c!==null,d=c?.flowId===n?c.step:null,f=(0,Y.useMemo)(()=>{let e=s.find(e=>e.id===t);return e?.type===`figure`?e:null},[s,t]),p=(0,Y.useMemo)(()=>f?ve(s,f):[],[s,f]),m=f?.flows?.find(e=>e.id===n),h=m?we(m,p):null,y=h?.steps.length??0,[b,x]=(0,Y.useState)(null),[S,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(!1),M=o.getState().patchFlowEdit;(0,Y.useEffect)(()=>{l.rename&&(T(!0),o.getState().patchFlowEdit({rename:!1}))},[l.rename,o]);let P=he({count:y,gap:0,onReorder:(e,r)=>ie(a,t,n,e,r),onPress:e=>M({selected:e})}),F=()=>A(a,t,n),I=()=>{h&&h.steps.length===0&&N(a,t,n),o.getState().setFlowsOpen(!0)},L=()=>{if(h&&h.steps.length>0&&ht.test(h.name)){x(St(h));return}F()},fe=(0,Y.useRef)(L);fe.current=L;let R=(0,Y.useRef)(y);if(R.current=y,(0,Y.useEffect)(()=>{let e=e=>{let r=o.getState();if(r.flowPlay||ee(e.target)||(e.target instanceof Element?e.target:null)?.closest(`[role=menu], [role=dialog]`))return;let i=r.flowEdit??{},s=R.current,c=j(i,s);if(e.key===`Escape`){if(e.preventDefault(),e.stopPropagation(),i.picking!==null&&i.picking!==void 0){r.patchFlowEdit({picking:null});return}if(oe(i,s)){r.patchFlowEdit({slot:null});return}fe.current();return}if(c!==null){if(e.key===`Delete`||e.key===`Backspace`){e.preventDefault(),e.stopPropagation(),le(a,t,n,c);return}if(e.altKey&&(e.key===`ArrowUp`||e.key===`ArrowDown`)){e.preventDefault(),e.stopPropagation();let r=c+(e.key===`ArrowUp`?-1:1);r>=0&&r<s&&ie(a,t,n,c,r)}}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[o,a,t,n]),!f||!h)return null;let z=f.flows??[],B=new Map(p.map(e=>[e.id,Ce(p,e)])),V=Te(z,n),H=V?.flow.steps[V.index],pe=H?.title??``,me=k(p,h.steps,H),U=ne(l,y),ge=j(l,y),G=j({selected:l.picking},y),ye=ae(l,y),be=z.filter(e=>e.id!==n).map(e=>({id:e.id,name:e.name})),K=[...new Map([...me.values()].map(e=>[e.arrow.id,e])).values()],q=e=>{for(let t of e)se(a,t);D(!0)};function Ee(e){let t=me.get(e);return t?{names:re(t,B),onAttach:()=>q([t])}:null}function J(){b!==null&&De(b),F()}function De(e){let r=e.trim();r&&r!==h?.name&&te(a,t,n,e=>({...e,name:r}))}return(0,X.jsxs)(Se,{width:300,testId:`flow-panel`,ariaLabel:`Flow`,onDismiss:F,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5 py-2 pl-1.5 pr-2`,children:[(0,X.jsx)(r,{label:`All flows`,side:`bottom`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`All flows`,"data-testid":`flow-panel-back`,onClick:I,className:xe,children:(0,X.jsx)(ue,{size:16,stroke:1.75})})}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:b===null?S?(0,X.jsx)(`input`,{autoFocus:!0,"aria-label":`Flow name`,"data-testid":`flow-name`,className:`${Oe} text-[14px] font-medium`,defaultValue:h.name,onFocus:e=>e.target.select(),onBlur:e=>{De(e.target.value),T(!1)},onKeyDown:ot}):(0,X.jsx)(xt,{current:h,flows:z,onPick:e=>o.getState().setFlowEdit({frameId:t,flowId:e}),onRename:()=>T(!0),onNew:()=>w(a,t),onDelete:()=>N(a,t,n)}):(0,X.jsx)(`input`,{autoFocus:!0,"aria-label":`Name this flow`,"data-testid":`flow-name-input`,className:`${Oe} text-[14px] font-medium ring-[var(--chrome-input-hover)] hover:ring-[var(--chrome-input-hover)]`,value:b,onFocus:e=>e.target.select(),onChange:e=>x(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&b.trim()&&J(),e.key===`Escape`&&F()}})}),(0,X.jsx)(r,{label:`Close`,side:`bottom`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close the flow panel`,"data-testid":`flow-panel-done`,onClick:F,className:xe,children:(0,X.jsx)(W,{size:16,stroke:1.75})})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-4 pb-2.5`,children:[b===null?(0,X.jsxs)(`span`,{className:`truncate text-[11px] text-[var(--chrome-fg-400)]`,children:[f.label||`Untitled frame`,` · `,y,` `,y===1?`step`:`steps`]}):(0,X.jsxs)(`span`,{"data-testid":`flow-name-prompt`,className:`flex flex-wrap items-center gap-1.5 text-[11px] text-[var(--chrome-fg-500)]`,children:[`Name this flow · `,(0,X.jsx)(`kbd`,{className:je,children:`↵`}),` save · `,(0,X.jsx)(`kbd`,{className:je,children:`esc`}),` keep "`,h.name,`"`]}),V&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`flow-origin`,title:`Open ${V.flow.name}`,className:`group/origin -mt-0.5 flex min-w-0 cursor-pointer items-center gap-1.5 self-start text-[12px] text-[var(--chrome-fg-500)]`,onClick:()=>o.getState().setFlowEdit({frameId:t,flowId:V.flow.id}),children:[(0,X.jsx)(de,{size:13,stroke:1.75,className:`shrink-0`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[`From`,` `,(0,X.jsx)(`b`,{className:`font-medium text-[var(--chrome-fg-700)] group-hover/origin:underline`,children:V.flow.name}),`, step `,V.index+1]})]})]}),(0,X.jsx)(`div`,{className:`mx-3 h-px bg-[var(--chrome-divider)]`}),(0,X.jsx)(`div`,{ref:P.listRef,className:`flex flex-1 flex-col overflow-y-auto p-3`,children:y===0?(0,X.jsx)(bt,{fork:V?{title:pe,step:V.index+1}:null,onAi:i?()=>{N(a,t,n),o.getState().askAi(`Write a flow for the frame "${f.label||`Untitled`}" (${f.id}) showing `)}:null}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Le,{count:K.length,attached:E,onAttach:()=>q(K),onSettled:()=>D(!1)}),(0,X.jsx)(`ol`,{className:`flex flex-col pt-1`,"data-testid":`flow-steps`,children:h.steps.map((e,r)=>(0,X.jsx)(vt,{before:U===r&&U<y,hidden:P.dragging,number:r+1,first:r===0,onCancel:()=>M({slot:null}),children:(0,X.jsx)(Xe,{step:e,index:r,count:y,current:d===r,selected:ge===r,picking:G===r,names:B,otherFlows:be,loose:Ee(r),rail:{first:r===0&&U!==0,end:G!==null&&r===y-1,litAbove:d!==null&&r>0&&r<=d,litBelow:d!==null&&r<d},rowRef:P.setItemRef(r),rowStyle:P.rowStyle(r),grip:P.rowHandlers(r),actions:{onPlay:()=>C(a,t,n,r),onChange:e=>ce(a,t,n,r,e),onMove:e=>ie(a,t,n,r,r+e),onRemove:()=>le(a,t,n,r),onNewPath:()=>O(a,t,n,r),onSelect:()=>{o.getState().flowEdit?.selected!==r&&M({selected:r})},onHover:e=>M({hovered:e?r:null}),onInsertBefore:()=>M({slot:r,picking:null}),onInsertAfter:()=>M({slot:r+1<y?r+1:null,picking:null}),onChangeBox:()=>M({picking:r,selected:r}),onCancelPick:()=>M({picking:null})}})},`${e.target}-${r}`))}),G===null&&(0,X.jsx)(yt,{inserting:U<y,next:y+1,joined:ye,onToEnd:()=>M({slot:null})})]})}),(0,X.jsx)(`div`,{className:`border-t border-[var(--chrome-ring)] p-3`,children:b===null?(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`${Pe} h-9 flex-1`,"data-testid":`flow-play`,disabled:y===0||u,onClick:()=>C(a,t,n),children:[(0,X.jsx)(_e,{size:12}),`Preview`]}),(0,X.jsx)(`button`,{type:`button`,className:`${Ae} flex-1`,"data-testid":`flow-done`,onClick:L,children:`Done`})]}):(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,className:`${Pe} h-9 flex-1`,"data-testid":`flow-name-skip`,onClick:F,children:`Skip`}),(0,X.jsx)(`button`,{type:`button`,className:`${Ae} flex-1`,"data-testid":`flow-name-save`,disabled:!b.trim(),onClick:J,children:`Save name`})]})})]})}function vt(e){let{before:t,hidden:n,number:i,first:a,onCancel:o,children:s}=e;return(0,X.jsxs)(X.Fragment,{children:[t&&(0,X.jsxs)(`li`,{"data-testid":`flow-slot`,className:`flex gap-2.5 rounded-lg pl-1 pr-1.5 bg-[color-mix(in_srgb,var(--chrome-fg-900)_5%,transparent)] ${n?`invisible`:``}`,children:[(0,X.jsx)(Ke,{first:a,node:(0,X.jsx)(`span`,{className:We,children:i})}),(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 py-2 text-[12.5px] text-[var(--chrome-fg-800)]`,children:[(0,X.jsxs)(`span`,{className:`flex-1 leading-[22px]`,children:[`Click a box for step `,i]}),(0,X.jsx)(r,{label:`Add at the end instead`,side:`left`,children:(0,X.jsx)(`button`,{type:`button`,"aria-label":`Add at the end instead`,"data-testid":`flow-slot-cancel`,className:`flex h-6 w-6 shrink-0 cursor-pointer items-center justify-center rounded-md text-[var(--chrome-fg-400)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-800)] disabled:pointer-events-none disabled:opacity-40`,onClick:o,children:(0,X.jsx)(W,{size:13,stroke:2})})})]})]}),s]})}function yt(e){let{inserting:t,next:n,joined:r,onToEnd:i}=e;return(0,X.jsxs)(`div`,{"data-testid":`flow-hint`,className:`flex gap-2.5 pl-1 pr-1.5`,children:[(0,X.jsx)(Ke,{end:!0,node:(0,X.jsx)(`span`,{className:Ue,children:t?(0,X.jsx)(z,{size:10,stroke:2.5}):n})}),(0,X.jsx)(`div`,{className:`py-2 text-[12px] leading-[22px] text-[var(--chrome-fg-400)]`,children:t?(0,X.jsx)(`button`,{type:`button`,className:`cursor-pointer text-[var(--chrome-fg-600)] transition-colors hover:text-[var(--chrome-fg-900)]`,onClick:i,children:`Add at the end instead`}):(0,X.jsxs)(X.Fragment,{children:[`Click the next box or arrow`,r!==null&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] leading-[18px]`,children:[(0,X.jsx)(`kbd`,{className:`inline-flex h-[18px] min-w-[18px] items-center justify-center rounded bg-[var(--chrome-popup)] px-1 font-mono text-[10.5px] text-[var(--chrome-fg-600)] shadow-[inset_0_0_0_1px_var(--chrome-input),0_1px_0_var(--chrome-input)]`,children:`⇧`}),` click adds it to step `,r+1]})]})})]})}function bt(e){let{onAi:t,fork:n}=e,r=n?n.title||`step ${n.step}`:``;return(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-3 py-8 text-center`,"data-testid":`flow-empty`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`flex h-11 w-11 items-center justify-center rounded-full bg-[var(--chrome-disc)] text-[var(--chrome-fg-500)]`,children:n?(0,X.jsx)(P,{size:20,stroke:1.75}):(0,X.jsx)(V,{size:20,stroke:1.75})}),(0,X.jsx)(`p`,{className:`text-balance text-[13px] font-medium text-[var(--chrome-fg-900)]`,children:n?`What happens after ${r}?`:`Click the boxes in order`}),(0,X.jsx)(`p`,{className:`text-balance text-[12px] leading-relaxed text-[var(--chrome-fg-500)]`,children:n?`Click the box it goes to next. Viewers can choose this path at step ${n.step}.`:`Start with whoever kicks things off.`}),t&&!n&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`flow-ai`,className:`flex cursor-pointer items-center gap-1.5 rounded-md px-1.5 py-1 text-[12px] text-[var(--chrome-fg-500)] transition-colors hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-900)] disabled:pointer-events-none disabled:text-[var(--chrome-fg-300)]`,onClick:t,children:[(0,X.jsx)(U,{size:13,stroke:1.75}),`Write the steps with AI`]})]})}function xt(e){let{current:t,flows:n,onPick:r,onRename:a,onNew:f,onDelete:h}=e,g=(0,Y.useRef)(!1);return(0,X.jsxs)(o,{onOpenChange:e=>{e&&(g.current=!1)},children:[(0,X.jsxs)(d,{"data-testid":`flow-switcher`,className:`flex max-w-full cursor-pointer items-center gap-1 rounded-md px-1.5 py-1 text-left transition-colors hover:bg-[var(--chrome-hover)] data-[popup-open]:bg-[var(--chrome-hover)]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[14px] font-medium text-[var(--chrome-fg-900)]`,children:t.name}),(0,X.jsx)(i,{size:14,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-400)]`})]}),(0,X.jsx)(c,{children:(0,X.jsx)(s,{side:`bottom`,align:`start`,sideOffset:4,className:`z-50 outline-none`,children:(0,X.jsxs)(p,{"data-overlay":!0,className:`min-w-[240px] p-1`,finalFocus:()=>!g.current,children:[M(n).map(({flow:e,depth:n})=>(0,X.jsxs)(u,{"data-testid":`flow-switcher-item`,className:`flex cursor-default select-none items-center gap-2 rounded-lg py-1.5 pr-2 text-[13px] text-[var(--chrome-fg-700)] outline-none data-[highlighted]:bg-[var(--chrome-hover)]`,style:{paddingLeft:8+n*16},onClick:()=>r(e.id),children:[(0,X.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:n>0?(0,X.jsx)(P,{size:14,stroke:1.75}):(0,X.jsx)(V,{size:14,stroke:1.75})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--chrome-fg-900)]`,children:e.name}),(0,X.jsx)(`span`,{className:`text-[11px] tabular-nums text-[var(--chrome-fg-400)]`,children:e.steps.length}),(0,X.jsx)(`span`,{className:`flex w-4 justify-center text-[var(--chrome-fg-900)]`,children:e.id===t.id&&(0,X.jsx)(I,{size:14,stroke:2})})]},e.id)),(0,X.jsx)(l,{}),(0,X.jsx)(m,{testId:`flow-name-edit`,icon:(0,X.jsx)(R,{size:15,stroke:1.75}),onClick:()=>{g.current=!0,a()},children:`Rename`}),(0,X.jsx)(m,{testId:`flow-new`,icon:(0,X.jsx)(z,{size:15,stroke:1.75}),onClick:f,children:`New flow on this frame`}),(0,X.jsx)(m,{testId:`flow-delete`,icon:(0,X.jsx)(D,{size:15,stroke:1.75}),onClick:h,children:`Delete this flow`})]})})})]})}function St(e){let t=e.steps[0]?.title.trim(),n=e.steps[e.steps.length-1]?.title.trim();return t?n&&n!==t?`${t} to ${n}`:t:e.name}export{dt as FlowMenuPopup,gt as FlowPanel};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./react-lCSYwAWP.js";import{t as n}from"./jsx-runtime-DKdBMi_L.js";import{Bt as r,Pn as i,Vt as a,k as o}from"./shapes-CHDGoELO.js";import{B as s}from"./frames-C-jROub3.js";import{r as c,t as l}from"./dom-PAoZruqo.js";import{p as u}from"./selection-overlay-primitives-DXtdWjNx.js";import{c as d,d as f,u as p}from"./flows-BAU4NQGk.js";var m=e(t(),1),h=n(),g=6;function _(e,t){if(e.type===`arrow`)return s(r(e),t);let n=o(e);return s({x:n.x,y:n.y},t)}function v(e,t,n=g,r){let i=u(e,r),a=s({x:i.x,y:i.y},t);return{left:a.x-n,top:a.y-n,width:i.width*t.zoom+n*2,height:i.height*t.zoom+n*2}}function y(e){return new Set(e.steps.flatMap((e,t)=>e.fails?[t+1]:[]))}function b(e){let t=new Map;return e.steps.forEach((e,n)=>{for(let r of p(e))t.set(r,[...t.get(r)??[],n+1])}),t}function x(e){let{numbers:t,byId:n,viewport:r,current:i,failing:a}=e;return(0,h.jsx)(h.Fragment,{children:[...t].map(([e,t])=>{let o=n.get(e);if(!o)return null;let s=_(o,r);return(0,h.jsx)(`span`,{"data-testid":`flow-step-badge`,"data-current":i!==null&&t.includes(i)||void 0,className:`pointer-events-none absolute z-10 flex items-center gap-1 transition-opacity ${o.type===`arrow`?`-translate-x-1/2 -translate-y-[calc(100%+14px)]`:`-translate-x-full -translate-y-full`}`,style:{left:s.x-2,top:s.y-2},children:t.map(e=>{let t=i===null||e===i;return(0,h.jsx)(`span`,{className:`flex h-[18px] min-w-[18px] items-center justify-center rounded-full px-1 text-[10.5px] font-semibold tabular-nums transition-colors ${a.has(e)&&t?`bg-[var(--flow-fail)] text-white`:t?`bg-[var(--flow-accent)] text-white`:`bg-[color-mix(in_srgb,var(--flow-accent)_14%,var(--chrome-popup))] text-[var(--flow-accent)]`} ${e===i?`scale-110`:``}`,children:e},e)})},e)})})}var S=`http://www.w3.org/2000/svg`,C=48;function w(e,t){if(e.kind===`ghost`){let n=t.get(e.from),r=t.get(e.to);if(!n||!r)return null;let i=o(n),a=o(r);return T([O(i,D(a)),O(a,D(i))].map(e=>[e]),!0)}let n=e.hops.flatMap(e=>{let t=j(a(e.arrow));return t.length<2?[]:[e.reversed?t.reverse():t]});return n.length>0?T(n,!1):null}function T(e,t){let n=[],r=[],i=0;return(t?[e.flat()]:e).forEach((e,t)=>{if(t>0){let t=E(n[n.length-1],e[0]);r.push({from:i,to:i+t,inside:!0}),i+=t}let a=i;e.forEach((t,r)=>{r>0&&(i+=E(e[r-1],t)),n.push(t)}),r.push({from:a,to:i,inside:!1})}),{d:n.map((e,t)=>`${t===0?`M`:`L`} ${e.x} ${e.y}`).join(` `),length:i,legs:r}}function E(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function D(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function O(e,t){let n=D(e),r=t.x-n.x,i=t.y-n.y;if(r===0&&i===0)return n;let a=Math.min(r===0?1/0:e.width/2/Math.abs(r),i===0?1/0:e.height/2/Math.abs(i));return{x:n.x+r*a,y:n.y+i*a}}var k=null;function A(){if(k)return k;let e=document.createElementNS(S,`svg`);e.setAttribute(`aria-hidden`,`true`),e.style.cssText=`position:absolute;width:0;height:0;overflow:hidden;visibility:hidden`;let t=document.createElementNS(S,`path`);return e.append(t),document.body.append(e),k=t,t}function j(e){let t=A();t.setAttribute(`d`,e);let n=t.getTotalLength();return!Number.isFinite(n)||n===0?[]:Array.from({length:49},(e,r)=>{let i=t.getPointAtLength(n*r/C);return{x:i.x,y:i.y}})}var M=.16,N=.45,P=3,F=1.5,I=100,L=[];function R(e){let{frameId:t,flow:n,targets:r,index:a,viewport:o,lead:s=L}=e,u=(0,m.useMemo)(()=>new Map(r.map(e=>[e.id,e])),[r]),g=n.steps[a],_=(0,m.useMemo)(()=>d(r,[...s,...n.steps],s.length+a),[r,s,n.steps,a]),v=g?.fails?`var(--flow-fail)`:`var(--flow-accent)`,S=(0,m.useMemo)(()=>g?p(g).flatMap(e=>u.get(e)??[]):[],[g,u]),C=(0,m.useMemo)(()=>{let e=[...s,...n.steps.slice(0,a)],t=e.slice(Math.max(0,e.length-P)).reverse().flatMap((e,t)=>p(e).map(e=>({id:e,back:t})));return S.flatMap(e=>{let n;if(e.type===`arrow`)n={kind:`arrows`,hops:[{arrow:e,reversed:!1}],through:[],cost:0};else{let i=1/0;for(let a of t){let t=f(r,a.id,e.id,{reply:_===`reply`});if(!t)continue;let o=(t.kind===`ghost`?I:t.cost)+a.back*F;o<i&&(i=o,n=t)}}let i=n?w(n,u):null;return n&&i?[{key:`${a}-${e.id}`,route:n,track:i}]:[]})},[S,s,n.steps,a,r,_,u]),T=(0,m.useMemo)(()=>{let e=new Set([t,...S.map(e=>e.id)]),o=S.filter(e=>e.type===`arrow`).map(e=>e.id);for(let t of C)t.route.kind===`arrows`&&(t.route.hops.forEach(t=>{e.add(t.arrow.id),o.push(t.arrow.id)}),t.route.through.forEach(t=>e.add(t)));let u=new Set([...s,...n.steps.slice(0,a)].flatMap(p)),d=[],f=[];for(let t of r){if(e.has(t.id))continue;let n=i(t);(u.has(t.id)||n?f:d).push(c(t.id),l(`data-icon-label`,t.id))}let m=(e,t)=>e.length>0?`${e.join(`,`)}{opacity:${t}!important}`:``;return[`[data-canvas-root] :is([data-shape-id],[data-icon-label]){transition:opacity 260ms ease}`,`[data-testid="hover-indicator"]{display:none}`,m(d,M),m(f,N),X(o,v,_)].join(``)},[t,S,s,C,n.steps,a,r,v,_]);return g?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`style`,{"data-testid":`flow-dim`,children:T}),C.length>0&&(0,h.jsx)(B,{handOffs:C,kind:_,color:v,fails:g.fails,payload:g.payload,viewport:o},`${n.id}-${a}`),(0,h.jsx)(x,{numbers:b(n),byId:u,viewport:o,current:a+1,failing:y(n)})]}):null}function z(e){let t=document.querySelector(`[data-canvas-root]`);if(!t)return[];let n=t.getBoundingClientRect();return e.flatMap(e=>e.route.kind===`arrows`?e.route.hops.flatMap(r=>{let i=t.querySelector(`[data-testid="arrow-label"]${c(r.arrow.id)}`);if(!i)return[];let a=i.getBoundingClientRect();return[{key:`${e.key}-${r.arrow.id}`,x:a.left-n.left,y:a.top-n.top,width:a.width,height:a.height}]}):[])}function B(e){let{handOffs:t,kind:n,color:r,fails:i,payload:a,viewport:o}=e,s=1/o.zoom,c=G(t,o.zoom),l=z(t),u=`flow-hand-off-mask-${t[0]?.key??``}`;return(0,h.jsxs)(`svg`,{"data-testid":`flow-hand-off`,"data-kind":n,"data-fails":i||void 0,className:`pointer-events-none absolute inset-0 h-full w-full overflow-visible`,children:[l.length>0&&(0,h.jsxs)(`mask`,{id:u,maskUnits:`userSpaceOnUse`,x:`-100000`,y:`-100000`,width:`200000`,height:`200000`,children:[(0,h.jsx)(`rect`,{x:`-100000`,y:`-100000`,width:`200000`,height:`200000`,fill:`white`}),l.map(e=>(0,h.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:4,fill:`black`},e.key))]}),(0,h.jsx)(`g`,{mask:l.length>0?`url(#${u})`:void 0,children:(0,h.jsx)(`g`,{transform:`translate(${o.x} ${o.y}) scale(${o.zoom})`,children:t.map(e=>{let t=e.route.kind===`ghost`,i=t||n===`async`;return(0,h.jsxs)(`g`,{"data-testid":t?`flow-ghost`:`flow-route`,children:[t&&(0,h.jsx)(`path`,{d:e.track.d,fill:`none`,stroke:r,strokeWidth:(n===`reply`?2.5:3.5)*s,strokeLinecap:`round`,strokeDasharray:i?`${6*s} ${6*s}`:`1`,strokeDashoffset:i?void 0:1,pathLength:i?void 0:1,opacity:n===`reply`?.6:.85,children:!i&&(0,h.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:`1`,to:`0`,dur:`0.7s`,fill:`freeze`})}),(0,h.jsxs)(`g`,{opacity:0,children:[(0,h.jsx)(`animateMotion`,{dur:`${c.seconds}s`,repeatCount:`indefinite`,path:e.track.d,calcMode:`linear`,keyPoints:`0;1;1`,keyTimes:`0;${c.travel(e.track)};1`}),(0,h.jsx)(`animate`,{attributeName:`opacity`,dur:`${c.seconds}s`,repeatCount:`indefinite`,calcMode:`linear`,...K(e.track,c.travel(e.track))}),(0,h.jsx)(`circle`,{r:11*s,fill:`var(--canvas-bg, white)`,opacity:.9}),(0,h.jsx)(`circle`,{r:7*s,fill:n===`async`?`var(--canvas-bg, white)`:r,stroke:r,strokeWidth:3*s}),a&&(0,h.jsx)(Y,{text:a,scale:s,color:r})]})]},e.key)})})})]})}var V=380,H=.7,U=.9,W=.12;function G(e,t){let n=Math.max(...e.map(e=>e.track.length)),r=Math.max(U,n*t/V),i=r+H;return{seconds:Number(i.toFixed(3)),travel:e=>Number((r*(e.length/n||1)/i).toFixed(4))}}function K(e,t){let n=n=>n/(e.length||1)*t,r=W*t*Math.min(1,300/(e.length||1)),i=[[0,0],[r,1]];for(let t of e.legs){if(!t.inside)continue;let e=n(t.from),a=n(t.to);i.push([Math.max(e-r/2,0),1],[e,0],[a,0],[a+r/2,1])}i.push([Math.max(t-r,0),1],[t,0],[1,0]);let a=[],o=[],s=0;for(let[e,t]of i){let n=Math.min(1,Math.max(s,e));a.push(Number(n.toFixed(4))),o.push(t),s=n}return{keyTimes:a.join(`;`),values:o.join(`;`)}}var q=11,J=6;function Y(e){let{text:t,scale:n,color:r}=e,i=(t.length*q*.6+J*2)*n,a=17*n,o=14*n;return(0,h.jsxs)(`g`,{"data-testid":`flow-payload`,transform:`translate(${-i/2} ${o})`,children:[(0,h.jsx)(`rect`,{width:i,height:a,rx:a/2,fill:r}),(0,h.jsx)(`text`,{x:i/2,y:a/2,textAnchor:`middle`,dominantBaseline:`central`,fill:`white`,fontSize:q*n,fontWeight:500,fontFamily:`ui-sans-serif, system-ui, sans-serif`,children:t})]})}function X(e,t,n){if(e.length===0)return``;let r=t=>e.map(e=>`${c(e)} [data-testid="${t}"]`).join(`,`),i=`${r(`arrow-stroke`)},${r(`arrow-head`)}`,a=e.flatMap(e=>[`arrow-stroke`,`arrow-head`].map(t=>`${c(e)} [data-testid="${t}"]:not([fill="none"])`)).join(`,`),o=n===`async`?`${r(`arrow-stroke`)}{stroke-dasharray:8 7!important}`:``;return[`${i}{stroke:${t}!important;transition:stroke 200ms ease,fill 200ms ease}`,`${a}{fill:${t}!important}`,o].join(``)}export{v as a,y as i,x as n,b as o,_ as r,R as t};
@@ -1 +1 @@
1
- import{t as e}from"./createReactComponent-C51FAx3B.js";import{i as t}from"./core-CmsJyU_-.js";var n=e(`outline`,`arrow-back-up`,`ArrowBackUp`,[[`path`,{d:`M9 14l-4 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M5 10h11a4 4 0 1 1 0 8h-1`,key:`svg-1`}]]);function r(e,t){let n=e.store.getState().shapes.find(e=>e.id===t);return n?.type===`figure`?n:null}function i(e,t,n){e.store.getState().updateShape(t.id,{flows:n.length>0?n:void 0})}function a(e,n){let a=r(e,n);if(!a)return null;let o=a.flows??[],s=t(o);return i(e,a,[...o,s]),e.store.getState().setFlowEdit({frameId:n,flowId:s.id}),s}function o(e,t,n,r=0){e.store.getState().setFlowPlay({frameId:t,flowId:n,step:r})}export{n as a,i,o as n,a as r,r as t};
1
+ import{t as e}from"./createReactComponent-C51FAx3B.js";import{i as t}from"./core-DnS-1skV.js";var n=e(`outline`,`arrow-back-up`,`ArrowBackUp`,[[`path`,{d:`M9 14l-4 -4l4 -4`,key:`svg-0`}],[`path`,{d:`M5 10h11a4 4 0 1 1 0 8h-1`,key:`svg-1`}]]);function r(e,t){let n=e.store.getState().shapes.find(e=>e.id===t);return n?.type===`figure`?n:null}function i(e,t,n){e.store.getState().updateShape(t.id,{flows:n.length>0?n:void 0})}function a(e,n){let a=r(e,n);if(!a)return null;let o=a.flows??[],s=t(o);return i(e,a,[...o,s]),e.store.getState().setFlowEdit({frameId:n,flowId:s.id}),s}function o(e,t,n,r=0){e.store.getState().setFlowPlay({frameId:t,flowId:n,step:r})}export{n as a,i,o as n,a as r,r as t};
@@ -0,0 +1,3 @@
1
+ import{Pn as e,dn as t,k as n}from"./shapes-CHDGoELO.js";import{N as r}from"./frames-C-jROub3.js";import{n as i}from"./core-DnS-1skV.js";var a=24;function o(e,n){let r=null;for(let i of e){if(t(i,`lineWork`))continue;let e=l(i,n);e<=a&&(!r||e<r.gap)&&(r={id:i.id,gap:e})}return r?.id??null}function s(e,t,n){for(let r of n){let n=c(e,t,r);if(n)return n}return null}function c(e,t,n){let r=new Set([...t,n]),i=e.filter(e=>r.has(e.id)),a=(e,r)=>t.includes(e)&&r===n||e===n&&t.includes(r),s=null;for(let t of e){if(t.type!==`arrow`)continue;let e={x:t.x,y:t.y},n={x:t.x2,y:t.y2},r=t.startBinding?.shapeId??o(i,e),c=t.endBinding?.shapeId??o(i,n);if(!r||!c||r===c||!a(r,c))continue;if(t.startBinding&&t.endBinding)return null;let l=[];t.startBinding||l.push({end:`start`,shapeId:r,point:e}),t.endBinding||l.push({end:`end`,shapeId:c,point:n}),s??={arrow:t,ends:l}}return s}function l(e,t){let r=n(e),i=r.x,a=r.x+r.width,o=r.y,s=r.y+r.height;if(t.x>=i&&t.x<=a&&t.y>=o&&t.y<=s)return Math.min(t.x-i,a-t.x,t.y-o,s-t.y);let c=Math.max(i-t.x,0,t.x-a),l=Math.max(o-t.y,0,t.y-s);return Math.hypot(c,l)}var u=5,d=1,f=1,p=3;function m(t){let n=t.filter(t=>e(t)),i=new Map;for(let e of n)i.set(e.id,new Set(r(t,e).map(e=>e.id)));return e=>{let t=new Set([e,...i.get(e)??[]]);for(let[n,r]of i)r.has(e)&&t.add(n);return t}}function h(e,t,n,r={}){if(t===n)return null;let i=m(e),a=i(t),s=i(n),c=r.reply?p:f,l=r.reply?f:p,h=new Map,g=(e,t)=>h.set(e,[...h.get(e)??[],t]);for(let t of e){if(t.type!==`arrow`)continue;let n=t.startBinding?.shapeId??o(e,{x:t.x,y:t.y}),i=t.endBinding?.shapeId??o(e,{x:t.x2,y:t.y2});!n||!i||n===i||(g(n,{to:i,hop:{arrow:t,reversed:!1},cost:c,wrongWay:!!r.reply}),g(i,{to:n,hop:{arrow:t,reversed:!0},cost:l,wrongWay:!r.reply}))}let _=[...a].map(e=>({at:e,cost:0,hops:[],path:[],wrongWay:0})),v=new Map;for(;_.length>0;){_.sort((e,t)=>e.cost-t.cost||e.hops.length-t.hops.length);let e=_.shift();if(s.has(e.at)&&e.hops.length>0){let t=e.path.filter(e=>!a.has(e)&&!s.has(e));return{kind:`arrows`,hops:e.hops,through:t,cost:e.cost}}if(!((v.get(e.at)??1/0)<=e.cost||e.hops.length>=u)){v.set(e.at,e.cost);for(let t of h.get(e.at)??[]){let n=e.wrongWay+ +!!t.wrongWay;n>d||_.push({wrongWay:n,at:t.to,cost:e.cost+t.cost,hops:[...e.hops,t.hop],path:[...e.path,t.to]})}}}return{kind:`ghost`,from:t,to:n}}function g(e,t){for(let n of e){let e=n.steps.findIndex(e=>e.branches?.includes(t));if(e>=0&&n.id!==t)return{flow:n,index:e}}return null}function _(e,t){let n=g(e,t);return n?n.flow.steps.slice(0,n.index+1):[]}function v(e,t){let n=new Set(t.map(e=>e.id));return{...e,steps:e.steps.flatMap(e=>{if(!n.has(e.target))return[];if(!e.also)return[e];let t=e.also.filter(t=>n.has(t)&&t!==e.target),r={...e,also:t};return t.length===0&&delete r.also,[r]})}}function y(e){return[e.target,...e.also??[]]}function b(e,t,n){let r=t[n],i=t[n-1];if(!r||r.kind)return r?.kind??`call`;if(!i)return`call`;let a=new Set(t.slice(0,n).flatMap(y)),o=y(r).filter(e=>a.has(e));for(let t of o)for(let n of y(i)){let r=h(e,n,t);if(r?.kind===`arrows`&&r.hops.every(e=>!e.reversed))return`call`;let i=h(e,n,t,{reply:!0});if(i?.kind===`arrows`&&i.hops.every(e=>e.reversed))return`reply`}return`call`}function x(e,t,n,r){let a=(e,t)=>w(e,t).toLowerCase().replace(/\s+/g,` `).trim(),o=new Map;for(let e of i(n,r)){let t=a(n,e);t&&!o.has(t)&&o.set(t,e.id)}let s=new Map([[t.id,r.id]]);for(let n of i(e,t)){let t=o.get(a(e,n));t&&s.set(n.id,t)}return s}function S(e,t,n,r){let i=t.flows??[];if(i.length===0)return{flows:void 0,dropped:0};let a=x(e,t,n,r),o=e=>a.get(e),s=0,c=i.flatMap(e=>{let t=e.steps.flatMap(e=>{let t=o(e.target);if(!t)return s+=1,[];let n=(e.also??[]).flatMap(e=>o(e)??[]),r={...e,target:t};return n.length>0?r.also=n:delete r.also,[r]});return t.length>0?[{...e,steps:t}]:[]}),l=new Set(c.map(e=>e.id)),u=c.map(e=>({...e,steps:e.steps.map(e=>{let t=(e.branches??[]).filter(e=>l.has(e)),n={...e};return t.length>0?n.branches=t:delete n.branches,n})}));return{flows:u.length>0?u:void 0,dropped:s}}function C(e){return e?`label`in e&&typeof e.label==`string`&&e.label.trim()?e.label.trim().split(`
2
+ `)[0].trim():`text`in e&&typeof e.text==`string`&&e.text.trim()?e.text.trim().split(`
3
+ `)[0]:e.type===`icon`&&e.name?e.name:``:``}function w(e,t){let n=C(t);if(n)return n;if(t.type===`arrow`){let n=new Map(e.map(e=>[e.id,e])),r=C(n.get(t.startBinding?.shapeId??``)),i=C(n.get(t.endBinding?.shapeId??``));return r&&i?`${r} → ${i}`:`Connection`}return`Step`}function T(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.flatMap(t=>{let r=n.get(t);return r?[w(e,r)]:[]});return r.length>0?E(r):`Step`}function E(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function D(e,t){if(!t.flows?.length)return[];let n=i(e,t);return t.flows.flatMap(e=>{let t=v(e,n);return t.steps.map((e,n)=>({flow:t,index:n}))})}export{T as a,b as c,h as d,s as f,w as i,v as l,g as n,D as o,S as r,E as s,_ as t,y as u};
@@ -0,0 +1,5 @@
1
+ import{$t as e,An as t,C as n,Dn as r,Gt as i,H as a,It as o,On as s,Pn as c,Rt as l,T as u,Tn as d,Vt as f,Y as p,at as m,en as h,k as g,kn as _,n as v,qt as ee,rt as te,t as ne,tt as y,w as re}from"./shapes-CHDGoELO.js";import{H as ie,T as ae,_ as b,a as x,ct as S,d as oe,g as se,h as ce,i as C,k as le,m as ue,n as de,t as fe,u as pe}from"./geometry-CVRSymIE.js";function me(e){return ce(e,!0)??0}function he(e){return ce(e,!1)??0}function ge(e,t){return e.length===0?{x:0,y:0}:se(e,ue(e)*x(t??.5)).point}function _e(e){return e.length===0?``:e.reduce((e,t,n)=>e+`${n===0?`M`:`L`} ${t.x} ${t.y} `,``)}function ve(e){let t=[];for(let n of e){let e=t[t.length-1];(!e||Math.abs(e.x-n.x)>.01||Math.abs(e.y-n.y)>.01)&&t.push(n)}return t}var ye=[`arrow`,`sweep`,`triangle`,`triangleOutline`],be=[`circle`,`circleOutline`,`diamond`,`diamondOutline`,`bar`,`cross`],xe=[`crowOne`,`crowMany`,`crowOneOrMany`,`crowOnlyOne`,`crowZeroOrOne`,`crowZeroOrMany`];function Se(e){let t={x:Math.cos(e),y:Math.sin(e)};return{dir:t,normal:{x:-t.y,y:t.x}}}function Ce(e){let[t,...n]=e;return`M ${t.x} ${t.y} `+n.map(e=>`L ${e.x} ${e.y} `).join(``)+`Z`}function we(e,t){return`M ${e.x-t} ${e.y} a ${t} ${t} 0 1 0 ${t*2} 0 a ${t} ${t} 0 1 0 ${-t*2} 0 Z`}function w(e,t,n,r){let{dir:a,normal:o}=Se(n),s=r,c=e=>({x:t.x-a.x*e,y:t.y-a.y*e}),l=(e,t)=>{let n=c(e),r={x:n.x+o.x*t,y:n.y+o.y*t},i={x:n.x-o.x*t,y:n.y-o.y*t};return`M ${r.x} ${r.y} L ${i.x} ${i.y}`},u=(e,n)=>{let r=c(e),i={x:t.x+o.x*n,y:t.y+o.y*n},a={x:t.x-o.x*n,y:t.y-o.y*n};return`M ${i.x} ${i.y} L ${r.x} ${r.y} L ${a.x} ${a.y}`},d=(e,t=`none`)=>({d:e,fill:t}),f=c(s);switch(e){case`arrow`:return[d(i(t,n,s))];case`sweep`:return[d(ee(t,n,s))];case`triangle`:case`triangleOutline`:{let n=s*.42;return[d(Ce([t,{x:f.x+o.x*n,y:f.y+o.y*n},{x:f.x-o.x*n,y:f.y-o.y*n}]),e===`triangle`?`solid`:`white`)]}case`diamond`:case`diamondOutline`:{let n=s*.34,r=c(s/2);return[d(Ce([t,{x:r.x+o.x*n,y:r.y+o.y*n},f,{x:r.x-o.x*n,y:r.y-o.y*n}]),e===`diamond`?`solid`:`white`)]}case`circle`:case`circleOutline`:{let t=s*.4;return[d(we(c(t),t),e===`circle`?`solid`:`white`)]}case`bar`:return[d(l(0,s*.5))];case`cross`:{let e=s*.4,t=t=>{let n=a.x*t+o.x,r=a.y*t+o.y,i=Math.hypot(n,r)||1,s=n/i*e,l=r/i*e,u=c(e);return`M ${u.x-s} ${u.y-l} L ${u.x+s} ${u.y+l}`};return[d(t(1)),d(t(-1))]}case`crowOne`:return[d(l(s*.55,s*.45))];case`crowOnlyOne`:return[d(l(s*.45,s*.45)),d(l(s*.9,s*.45))];case`crowMany`:return[d(u(s,s*.5))];case`crowOneOrMany`:return[d(u(s,s*.5)),d(l(s*1.3,s*.45))];case`crowZeroOrOne`:{let e=s*.3;return[d(l(s*.4,s*.45)),d(we(c(s),e),`white`)]}case`crowZeroOrMany`:{let e=s*.3;return[d(u(s*.85,s*.5)),d(we(c(s*1.4),e),`white`)]}}}function Te(e){let t=[];if(e.endArrow){let n=l(e,`end`);t.push(...w(e.endHead??`arrow`,n.tip,n.angle,n.length))}if(e.startArrow){let n=l(e,`start`);t.push(...w(e.startHead??`arrow`,n.tip,n.angle,n.length))}return t}function Ee(t){let n=t.points;if(n.length<2)return[];let r=e(t.strokeWidth),i=ue(n),a=[];if(t.endArrow){let e=t.endHead??`arrow`;a.push(...w(e,n[n.length-1],me(n),h(r,e,i,b(n,!0))))}if(t.startArrow){let e=t.startHead??`arrow`;a.push(...w(e,n[0],he(n),h(r,e,i,b(n,!1))))}return a}function De(e,t){return e===`solid`?t:e===`white`?`#ffffff`:`none`}function Oe(e,t,n){if(e&&e.length){let[r,i]=t,a=Math.PI/180*n,o=Math.cos(a),s=Math.sin(a);for(let t of e){let[e,n]=t;t[0]=(e-r)*o-(n-i)*s+r,t[1]=(e-r)*s+(n-i)*o+i}}}function ke(e,t){return e[0]===t[0]&&e[1]===t[1]}function Ae(e,t,n,r=1){let i=n,a=Math.max(t,.1),o=e[0]&&e[0][0]&&typeof e[0][0]==`number`?[e]:e,s=[0,0];if(i)for(let e of o)Oe(e,s,i);let c=function(e,t,n){let r=[];for(let t of e){let e=[...t];ke(e[0],e[e.length-1])||e.push([e[0][0],e[0][1]]),e.length>2&&r.push(e)}let i=[];t=Math.max(t,.1);let a=[];for(let e of r)for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(n[1]!==r[1]){let e=Math.min(n[1],r[1]);a.push({ymin:e,ymax:Math.max(n[1],r[1]),x:e===n[1]?n[0]:r[0],islope:(r[0]-n[0])/(r[1]-n[1])})}}if(a.sort(((e,t)=>e.ymin<t.ymin?-1:e.ymin>t.ymin?1:e.x<t.x?-1:e.x>t.x?1:e.ymax===t.ymax?0:(e.ymax-t.ymax)/Math.abs(e.ymax-t.ymax))),!a.length)return i;let o=[],s=a[0].ymin,c=0;for(;o.length||a.length;){if(a.length){let e=-1;for(let t=0;t<a.length&&!(a[t].ymin>s);t++)e=t;a.splice(0,e+1).forEach((e=>{o.push({s,edge:e})}))}if(o=o.filter((e=>!(e.edge.ymax<=s))),o.sort(((e,t)=>e.edge.x===t.edge.x?0:(e.edge.x-t.edge.x)/Math.abs(e.edge.x-t.edge.x))),(n!==1||c%t==0)&&o.length>1)for(let e=0;e<o.length;e+=2){let t=e+1;if(t>=o.length)break;let n=o[e].edge,r=o[t].edge;i.push([[Math.round(n.x),s],[Math.round(r.x),s]])}s+=n,o.forEach((e=>{e.edge.x=e.edge.x+n*e.edge.islope})),c++}return i}(o,a,r);if(i){for(let e of o)Oe(e,s,-i);(function(e,t,n){let r=[];e.forEach((e=>r.push(...e))),Oe(r,t,n)})(c,s,-i)}return c}function T(e,t){let n=t.hachureAngle+90,r=t.hachureGap;r<0&&(r=4*t.strokeWidth),r=Math.round(Math.max(r,.1));let i=1;return t.roughness>=1&&(t.randomizer?.next()||Math.random())>.7&&(i=r),Ae(e,r,n,i||1)}var je=class{constructor(e){this.helper=e}fillPolygons(e,t){return this._fillPolygons(e,t)}_fillPolygons(e,t){let n=T(e,t);return{type:`fillSketch`,ops:this.renderLines(n,t)}}renderLines(e,t){let n=[];for(let r of e)n.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],t));return n}};function Me(e){let t=e[0],n=e[1];return Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2)}var Ne=class extends je{fillPolygons(e,t){let n=t.hachureGap;n<0&&(n=4*t.strokeWidth),n=Math.max(n,.1);let r=T(e,Object.assign({},t,{hachureGap:n})),i=Math.PI/180*t.hachureAngle,a=[],o=.5*n*Math.cos(i),s=.5*n*Math.sin(i);for(let[e,t]of r)Me([e,t])&&a.push([[e[0]-o,e[1]+s],[...t]],[[e[0]+o,e[1]-s],[...t]]);return{type:`fillSketch`,ops:this.renderLines(a,t)}}},Pe=class extends je{fillPolygons(e,t){let n=this._fillPolygons(e,t),r=Object.assign({},t,{hachureAngle:t.hachureAngle+90}),i=this._fillPolygons(e,r);return n.ops=n.ops.concat(i.ops),n}},Fe=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=T(e,t=Object.assign({},t,{hachureAngle:0}));return this.dotsOnLines(n,t)}dotsOnLines(e,t){let n=[],r=t.hachureGap;r<0&&(r=4*t.strokeWidth),r=Math.max(r,.1);let i=t.fillWeight;i<0&&(i=t.strokeWidth/2);let a=r/4;for(let o of e){let e=Me(o),s=e/r,c=Math.ceil(s)-1,l=e-c*r,u=(o[0][0]+o[1][0])/2-r/4,d=Math.min(o[0][1],o[1][1]);for(let e=0;e<c;e++){let o=d+l+e*r,s=u-a+2*Math.random()*a,c=o-a+2*Math.random()*a,f=this.helper.ellipse(s,c,i,i,t);n.push(...f.ops)}}return{type:`fillSketch`,ops:n}}},Ie=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=T(e,t);return{type:`fillSketch`,ops:this.dashedLine(n,t)}}dashedLine(e,t){let n=t.dashOffset<0?t.hachureGap<0?4*t.strokeWidth:t.hachureGap:t.dashOffset,r=t.dashGap<0?t.hachureGap<0?4*t.strokeWidth:t.hachureGap:t.dashGap,i=[];return e.forEach((e=>{let a=Me(e),o=Math.floor(a/(n+r)),s=(a+r-o*(n+r))/2,c=e[0],l=e[1];c[0]>l[0]&&(c=e[1],l=e[0]);let u=Math.atan((l[1]-c[1])/(l[0]-c[0]));for(let e=0;e<o;e++){let a=e*(n+r),o=a+n,l=[c[0]+a*Math.cos(u)+s*Math.cos(u),c[1]+a*Math.sin(u)+s*Math.sin(u)],d=[c[0]+o*Math.cos(u)+s*Math.cos(u),c[1]+o*Math.sin(u)+s*Math.sin(u)];i.push(...this.helper.doubleLineOps(l[0],l[1],d[0],d[1],t))}})),i}},Le=class{constructor(e){this.helper=e}fillPolygons(e,t){let n=t.hachureGap<0?4*t.strokeWidth:t.hachureGap,r=t.zigzagOffset<0?n:t.zigzagOffset,i=T(e,t=Object.assign({},t,{hachureGap:n+r}));return{type:`fillSketch`,ops:this.zigzagLines(i,r,t)}}zigzagLines(e,t,n){let r=[];return e.forEach((e=>{let i=Me(e),a=Math.round(i/(2*t)),o=e[0],s=e[1];o[0]>s[0]&&(o=e[1],s=e[0]);let c=Math.atan((s[1]-o[1])/(s[0]-o[0]));for(let e=0;e<a;e++){let i=2*e*t,a=2*(e+1)*t,s=Math.sqrt(2*t**2),l=[o[0]+i*Math.cos(c),o[1]+i*Math.sin(c)],u=[o[0]+a*Math.cos(c),o[1]+a*Math.sin(c)],d=[l[0]+s*Math.cos(c+Math.PI/4),l[1]+s*Math.sin(c+Math.PI/4)];r.push(...this.helper.doubleLineOps(l[0],l[1],d[0],d[1],n),...this.helper.doubleLineOps(d[0],d[1],u[0],u[1],n))}})),r}},E={},Re=class{constructor(e){this.seed=e}next(){return this.seed?(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31:Math.random()}},ze=0,Be=1,Ve=2,He={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function Ue(e,t){return e.type===t}function We(e){let t=[],n=function(e){let t=[];for(;e!==``;)if(e.match(/^([ \t\r\n,]+)/))e=e.substr(RegExp.$1.length);else if(e.match(/^([aAcChHlLmMqQsStTvVzZ])/))t[t.length]={type:ze,text:RegExp.$1},e=e.substr(RegExp.$1.length);else{if(!e.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/))return[];t[t.length]={type:Be,text:`${parseFloat(RegExp.$1)}`},e=e.substr(RegExp.$1.length)}return t[t.length]={type:Ve,text:``},t}(e),r=`BOD`,i=0,a=n[i];for(;!Ue(a,Ve);){let o=0,s=[];if(r===`BOD`){if(a.text!==`M`&&a.text!==`m`)return We(`M0,0`+e);i++,o=He[a.text],r=a.text}else Ue(a,Be)?o=He[r]:(i++,o=He[a.text],r=a.text);if(!(i+o<n.length))throw Error(`Path data ended short`);for(let e=i;e<i+o;e++){let t=n[e];if(!Ue(t,Be))throw Error(`Param not a number: `+r+`,`+t.text);s[s.length]=+t.text}if(typeof He[r]!=`number`)throw Error(`Bad segment: `+r);{let e={key:r,data:s};t.push(e),i+=o,a=n[i],r===`M`&&(r=`L`),r===`m`&&(r=`l`)}}return t}function Ge(e){let t=0,n=0,r=0,i=0,a=[];for(let{key:o,data:s}of e)switch(o){case`M`:a.push({key:`M`,data:[...s]}),[t,n]=s,[r,i]=s;break;case`m`:t+=s[0],n+=s[1],a.push({key:`M`,data:[t,n]}),r=t,i=n;break;case`L`:a.push({key:`L`,data:[...s]}),[t,n]=s;break;case`l`:t+=s[0],n+=s[1],a.push({key:`L`,data:[t,n]});break;case`C`:a.push({key:`C`,data:[...s]}),t=s[4],n=s[5];break;case`c`:{let e=s.map(((e,r)=>r%2?e+n:e+t));a.push({key:`C`,data:e}),t=e[4],n=e[5];break}case`Q`:a.push({key:`Q`,data:[...s]}),t=s[2],n=s[3];break;case`q`:{let e=s.map(((e,r)=>r%2?e+n:e+t));a.push({key:`Q`,data:e}),t=e[2],n=e[3];break}case`A`:a.push({key:`A`,data:[...s]}),t=s[5],n=s[6];break;case`a`:t+=s[5],n+=s[6],a.push({key:`A`,data:[s[0],s[1],s[2],s[3],s[4],t,n]});break;case`H`:a.push({key:`H`,data:[...s]}),t=s[0];break;case`h`:t+=s[0],a.push({key:`H`,data:[t]});break;case`V`:a.push({key:`V`,data:[...s]}),n=s[0];break;case`v`:n+=s[0],a.push({key:`V`,data:[n]});break;case`S`:a.push({key:`S`,data:[...s]}),t=s[2],n=s[3];break;case`s`:{let e=s.map(((e,r)=>r%2?e+n:e+t));a.push({key:`S`,data:e}),t=e[2],n=e[3];break}case`T`:a.push({key:`T`,data:[...s]}),t=s[0],n=s[1];break;case`t`:t+=s[0],n+=s[1],a.push({key:`T`,data:[t,n]});break;case`Z`:case`z`:a.push({key:`Z`,data:[]}),t=r,n=i}return a}function Ke(e){let t=[],n=``,r=0,i=0,a=0,o=0,s=0,c=0;for(let{key:l,data:u}of e){switch(l){case`M`:t.push({key:`M`,data:[...u]}),[r,i]=u,[a,o]=u;break;case`C`:t.push({key:`C`,data:[...u]}),r=u[4],i=u[5],s=u[2],c=u[3];break;case`L`:t.push({key:`L`,data:[...u]}),[r,i]=u;break;case`H`:r=u[0],t.push({key:`L`,data:[r,i]});break;case`V`:i=u[0],t.push({key:`L`,data:[r,i]});break;case`S`:{let e=0,a=0;n===`C`||n===`S`?(e=r+(r-s),a=i+(i-c)):(e=r,a=i),t.push({key:`C`,data:[e,a,...u]}),s=u[0],c=u[1],r=u[2],i=u[3];break}case`T`:{let[e,a]=u,o=0,l=0;n===`Q`||n===`T`?(o=r+(r-s),l=i+(i-c)):(o=r,l=i);let d=r+2*(o-r)/3,f=i+2*(l-i)/3,p=e+2*(o-e)/3,m=a+2*(l-a)/3;t.push({key:`C`,data:[d,f,p,m,e,a]}),s=o,c=l,r=e,i=a;break}case`Q`:{let[e,n,a,o]=u,l=r+2*(e-r)/3,d=i+2*(n-i)/3,f=a+2*(e-a)/3,p=o+2*(n-o)/3;t.push({key:`C`,data:[l,d,f,p,a,o]}),s=e,c=n,r=a,i=o;break}case`A`:{let e=Math.abs(u[0]),n=Math.abs(u[1]),a=u[2],o=u[3],s=u[4],c=u[5],l=u[6];e===0||n===0?(t.push({key:`C`,data:[r,i,c,l,c,l]}),r=c,i=l):(r!==c||i!==l)&&(qe(r,i,c,l,e,n,a,o,s).forEach((function(e){t.push({key:`C`,data:e})})),r=c,i=l);break}case`Z`:t.push({key:`Z`,data:[]}),r=a,i=o}n=l}return t}function D(e,t,n){return[e*Math.cos(n)-t*Math.sin(n),e*Math.sin(n)+t*Math.cos(n)]}function qe(e,t,n,r,i,a,o,s,c,l){let u=(d=o,Math.PI*d/180);var d;let f=[],p=0,m=0,h=0,g=0;if(l)[p,m,h,g]=l;else{[e,t]=D(e,t,-u),[n,r]=D(n,r,-u);let o=(e-n)/2,l=(t-r)/2,d=o*o/(i*i)+l*l/(a*a);d>1&&(d=Math.sqrt(d),i*=d,a*=d);let f=i*i,_=a*a,v=f*_-f*l*l-_*o*o,ee=f*l*l+_*o*o,te=(s===c?-1:1)*Math.sqrt(Math.abs(v/ee));h=te*i*l/a+(e+n)/2,g=te*-a*o/i+(t+r)/2,p=Math.asin(parseFloat(((t-g)/a).toFixed(9))),m=Math.asin(parseFloat(((r-g)/a).toFixed(9))),e<h&&(p=Math.PI-p),n<h&&(m=Math.PI-m),p<0&&(p=2*Math.PI+p),m<0&&(m=2*Math.PI+m),c&&p>m&&(p-=2*Math.PI),!c&&m>p&&(m-=2*Math.PI)}let _=m-p;if(Math.abs(_)>120*Math.PI/180){let e=m,t=n,s=r;m=c&&m>p?p+120*Math.PI/180*1:p+120*Math.PI/180*-1,f=qe(n=h+i*Math.cos(m),r=g+a*Math.sin(m),t,s,i,a,o,0,c,[m,e,h,g])}_=m-p;let v=Math.cos(p),ee=Math.sin(p),te=Math.cos(m),ne=Math.sin(m),y=Math.tan(_/4),re=4/3*i*y,ie=4/3*a*y,ae=[e,t],b=[e+re*ee,t-ie*v],x=[n+re*ne,r-ie*te],S=[n,r];if(b[0]=2*ae[0]-b[0],b[1]=2*ae[1]-b[1],l)return[b,x,S].concat(f);{f=[b,x,S].concat(f);let e=[];for(let t=0;t<f.length;t+=3){let n=D(f[t][0],f[t][1],u),r=D(f[t+1][0],f[t+1][1],u),i=D(f[t+2][0],f[t+2][1],u);e.push([n[0],n[1],r[0],r[1],i[0],i[1]])}return e}}var Je={randOffset:function(e,t){return A(e,t)},randOffsetWithRange:function(e,t,n){return at(e,t,n)},ellipse:function(e,t,n,r,i){return $e(e,t,i,Qe(n,r,i)).opset},doubleLineOps:function(e,t,n,r,i){return j(e,t,n,r,i,!0)}};function Ye(e,t,n,r,i){return{type:`path`,ops:j(e,t,n,r,i)}}function O(e,t,n){let r=(e||[]).length;if(r>2){let i=[];for(let t=0;t<r-1;t++)i.push(...j(e[t][0],e[t][1],e[t+1][0],e[t+1][1],n));return t&&i.push(...j(e[r-1][0],e[r-1][1],e[0][0],e[0][1],n)),{type:`path`,ops:i}}return r===2?Ye(e[0][0],e[0][1],e[1][0],e[1][1],n):{type:`path`,ops:[]}}function Xe(e,t,n,r,i){return function(e,t){return O(e,!0,t)}([[e,t],[e+n,t],[e+n,t+r],[e,t+r]],i)}function Ze(e,t){if(e.length){let n=typeof e[0][0]==`number`?[e]:e,r=st(n[0],1*(1+.2*t.roughness),t),i=t.disableMultiStroke?[]:st(n[0],1.5*(1+.22*t.roughness),rt(t));for(let e=1;e<n.length;e++){let a=n[e];if(a.length){let e=st(a,1*(1+.2*t.roughness),t),n=t.disableMultiStroke?[]:st(a,1.5*(1+.22*t.roughness),rt(t));for(let t of e)t.op!==`move`&&r.push(t);for(let e of n)e.op!==`move`&&i.push(e)}}return{type:`path`,ops:r.concat(i)}}return{type:`path`,ops:[]}}function Qe(e,t,n){let r=Math.sqrt(2*Math.PI*Math.sqrt(((e/2)**2+(t/2)**2)/2)),i=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*r)),a=2*Math.PI/i,o=Math.abs(e/2),s=Math.abs(t/2),c=1-n.curveFitting;return o+=A(o*c,n),s+=A(s*c,n),{increment:a,rx:o,ry:s}}function $e(e,t,n,r){let[i,a]=lt(r.increment,e,t,r.rx,r.ry,1,r.increment*at(.1,at(.4,1,n),n),n),o=ct(i,null,n);if(!n.disableMultiStroke&&n.roughness!==0){let[i]=lt(r.increment,e,t,r.rx,r.ry,1.5,0,n),a=ct(i,null,n);o=o.concat(a)}return{estimatedPoints:a,opset:{type:`path`,ops:o}}}function et(e,t,n,r,i,a,o,s,c){let l=e,u=t,d=Math.abs(n/2),f=Math.abs(r/2);d+=A(.01*d,c),f+=A(.01*f,c);let p=i,m=a;for(;p<0;)p+=2*Math.PI,m+=2*Math.PI;m-p>2*Math.PI&&(p=0,m=2*Math.PI);let h=2*Math.PI/c.curveStepCount,g=Math.min(h/2,(m-p)/2),_=ut(g,l,u,d,f,p,m,1,c);if(!c.disableMultiStroke){let e=ut(g,l,u,d,f,p,m,1.5,c);_.push(...e)}return o&&(s?_.push(...j(l,u,l+d*Math.cos(p),u+f*Math.sin(p),c),...j(l,u,l+d*Math.cos(m),u+f*Math.sin(m),c)):_.push({op:`lineTo`,data:[l,u]},{op:`lineTo`,data:[l+d*Math.cos(p),u+f*Math.sin(p)]})),{type:`path`,ops:_}}function tt(e,t){let n=Ke(Ge(We(e))),r=[],i=[0,0],a=[0,0];for(let{key:e,data:o}of n)switch(e){case`M`:a=[o[0],o[1]],i=[o[0],o[1]];break;case`L`:r.push(...j(a[0],a[1],o[0],o[1],t)),a=[o[0],o[1]];break;case`C`:{let[e,n,i,s,c,l]=o;r.push(...dt(e,n,i,s,c,l,a,t)),a=[c,l];break}case`Z`:r.push(...j(a[0],a[1],i[0],i[1],t)),a=[i[0],i[1]]}return{type:`path`,ops:r}}function nt(e,t){let n=[];for(let r of e)if(r.length){let e=t.maxRandomnessOffset||0,i=r.length;if(i>2){n.push({op:`move`,data:[r[0][0]+A(e,t),r[0][1]+A(e,t)]});for(let a=1;a<i;a++)n.push({op:`lineTo`,data:[r[a][0]+A(e,t),r[a][1]+A(e,t)]})}}return{type:`fillPath`,ops:n}}function k(e,t){return function(e,t){let n=e.fillStyle||`hachure`;if(!E[n])switch(n){case`zigzag`:E[n]||(E[n]=new Ne(t));break;case`cross-hatch`:E[n]||(E[n]=new Pe(t));break;case`dots`:E[n]||(E[n]=new Fe(t));break;case`dashed`:E[n]||(E[n]=new Ie(t));break;case`zigzag-line`:E[n]||(E[n]=new Le(t));break;default:n=`hachure`,E[n]||(E[n]=new je(t))}return E[n]}(t,Je).fillPolygons(e,t)}function rt(e){let t=Object.assign({},e);return t.randomizer=void 0,e.seed&&(t.seed=e.seed+1),t}function it(e){return e.randomizer||=new Re(e.seed||0),e.randomizer.next()}function at(e,t,n,r=1){return n.roughness*r*(it(n)*(t-e)+e)}function A(e,t,n=1){return at(-e,e,t,n)}function j(e,t,n,r,i,a=!1){let o=a?i.disableMultiStrokeFill:i.disableMultiStroke,s=ot(e,t,n,r,i,!0,!1);if(o)return s;let c=ot(e,t,n,r,i,!0,!0);return s.concat(c)}function ot(e,t,n,r,i,a,o){let s=(e-n)**2+(t-r)**2,c=Math.sqrt(s),l=1;l=c<200?1:c>500?.4:-.0016668*c+1.233334;let u=i.maxRandomnessOffset||0;u*u*100>s&&(u=c/10);let d=u/2,f=.2+.2*it(i),p=i.bowing*i.maxRandomnessOffset*(r-t)/200,m=i.bowing*i.maxRandomnessOffset*(e-n)/200;p=A(p,i,l),m=A(m,i,l);let h=[],g=()=>A(d,i,l),_=()=>A(u,i,l),v=i.preserveVertices;return a&&(o?h.push({op:`move`,data:[e+(v?0:g()),t+(v?0:g())]}):h.push({op:`move`,data:[e+(v?0:A(u,i,l)),t+(v?0:A(u,i,l))]})),o?h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+g(),m+t+(r-t)*f+g(),p+e+2*(n-e)*f+g(),m+t+2*(r-t)*f+g(),n+(v?0:g()),r+(v?0:g())]}):h.push({op:`bcurveTo`,data:[p+e+(n-e)*f+_(),m+t+(r-t)*f+_(),p+e+2*(n-e)*f+_(),m+t+2*(r-t)*f+_(),n+(v?0:_()),r+(v?0:_())]}),h}function st(e,t,n){if(!e.length)return[];let r=[];r.push([e[0][0]+A(t,n),e[0][1]+A(t,n)]),r.push([e[0][0]+A(t,n),e[0][1]+A(t,n)]);for(let i=1;i<e.length;i++)r.push([e[i][0]+A(t,n),e[i][1]+A(t,n)]),i===e.length-1&&r.push([e[i][0]+A(t,n),e[i][1]+A(t,n)]);return ct(r,null,n)}function ct(e,t,n){let r=e.length,i=[];if(r>3){let a=[],o=1-n.curveTightness;i.push({op:`move`,data:[e[1][0],e[1][1]]});for(let t=1;t+2<r;t++){let n=e[t];a[0]=[n[0],n[1]],a[1]=[n[0]+(o*e[t+1][0]-o*e[t-1][0])/6,n[1]+(o*e[t+1][1]-o*e[t-1][1])/6],a[2]=[e[t+1][0]+(o*e[t][0]-o*e[t+2][0])/6,e[t+1][1]+(o*e[t][1]-o*e[t+2][1])/6],a[3]=[e[t+1][0],e[t+1][1]],i.push({op:`bcurveTo`,data:[a[1][0],a[1][1],a[2][0],a[2][1],a[3][0],a[3][1]]})}if(t&&t.length===2){let e=n.maxRandomnessOffset;i.push({op:`lineTo`,data:[t[0]+A(e,n),t[1]+A(e,n)]})}}else r===3?(i.push({op:`move`,data:[e[1][0],e[1][1]]}),i.push({op:`bcurveTo`,data:[e[1][0],e[1][1],e[2][0],e[2][1],e[2][0],e[2][1]]})):r===2&&i.push(...ot(e[0][0],e[0][1],e[1][0],e[1][1],n,!0,!0));return i}function lt(e,t,n,r,i,a,o,s){let c=[],l=[];if(s.roughness===0){e/=4,l.push([t+r*Math.cos(-e),n+i*Math.sin(-e)]);for(let a=0;a<=2*Math.PI;a+=e){let e=[t+r*Math.cos(a),n+i*Math.sin(a)];c.push(e),l.push(e)}l.push([t+r*Math.cos(0),n+i*Math.sin(0)]),l.push([t+r*Math.cos(e),n+i*Math.sin(e)])}else{let u=A(.5,s)-Math.PI/2;l.push([A(a,s)+t+.9*r*Math.cos(u-e),A(a,s)+n+.9*i*Math.sin(u-e)]);let d=2*Math.PI+u-.01;for(let o=u;o<d;o+=e){let e=[A(a,s)+t+r*Math.cos(o),A(a,s)+n+i*Math.sin(o)];c.push(e),l.push(e)}l.push([A(a,s)+t+r*Math.cos(u+2*Math.PI+.5*o),A(a,s)+n+i*Math.sin(u+2*Math.PI+.5*o)]),l.push([A(a,s)+t+.98*r*Math.cos(u+o),A(a,s)+n+.98*i*Math.sin(u+o)]),l.push([A(a,s)+t+.9*r*Math.cos(u+.5*o),A(a,s)+n+.9*i*Math.sin(u+.5*o)])}return[l,c]}function ut(e,t,n,r,i,a,o,s,c){let l=a+A(.1,c),u=[];u.push([A(s,c)+t+.9*r*Math.cos(l-e),A(s,c)+n+.9*i*Math.sin(l-e)]);for(let a=l;a<=o;a+=e)u.push([A(s,c)+t+r*Math.cos(a),A(s,c)+n+i*Math.sin(a)]);return u.push([t+r*Math.cos(o),n+i*Math.sin(o)]),u.push([t+r*Math.cos(o),n+i*Math.sin(o)]),ct(u,null,c)}function dt(e,t,n,r,i,a,o,s){let c=[],l=[s.maxRandomnessOffset||1,(s.maxRandomnessOffset||1)+.3],u=[0,0],d=s.disableMultiStroke?1:2,f=s.preserveVertices;for(let p=0;p<d;p++)p===0?c.push({op:`move`,data:[o[0],o[1]]}):c.push({op:`move`,data:[o[0]+(f?0:A(l[0],s)),o[1]+(f?0:A(l[0],s))]}),u=f?[i,a]:[i+A(l[p],s),a+A(l[p],s)],c.push({op:`bcurveTo`,data:[e+A(l[p],s),t+A(l[p],s),n+A(l[p],s),r+A(l[p],s),u[0],u[1]]});return c}function M(e){return[...e]}function ft(e,t=0){let n=e.length;if(n<3)throw Error(`A curve must have at least three points.`);let r=[];if(n===3)r.push(M(e[0]),M(e[1]),M(e[2]),M(e[2]));else{let n=[];n.push(e[0],e[0]);for(let t=1;t<e.length;t++)n.push(e[t]),t===e.length-1&&n.push(e[t]);let i=[],a=1-t;r.push(M(n[0]));for(let e=1;e+2<n.length;e++){let t=n[e];i[0]=[t[0],t[1]],i[1]=[t[0]+(a*n[e+1][0]-a*n[e-1][0])/6,t[1]+(a*n[e+1][1]-a*n[e-1][1])/6],i[2]=[n[e+1][0]+(a*n[e][0]-a*n[e+2][0])/6,n[e+1][1]+(a*n[e][1]-a*n[e+2][1])/6],i[3]=[n[e+1][0],n[e+1][1]],r.push(i[1],i[2],i[3])}}return r}function N(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2}function pt(e,t,n){let r=N(t,n);if(r===0)return N(e,t);let i=((e[0]-t[0])*(n[0]-t[0])+(e[1]-t[1])*(n[1]-t[1]))/r;return i=Math.max(0,Math.min(1,i)),N(e,P(t,n,i))}function P(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function mt(e,t,n,r){let i=r||[];if(function(e,t){let n=e[t+0],r=e[t+1],i=e[t+2],a=e[t+3],o=3*r[0]-2*n[0]-a[0];o*=o;let s=3*r[1]-2*n[1]-a[1];s*=s;let c=3*i[0]-2*a[0]-n[0];c*=c;let l=3*i[1]-2*a[1]-n[1];return l*=l,o<c&&(o=c),s<l&&(s=l),o+s}(e,t)<n){let n=e[t+0];i.length?(a=i[i.length-1],o=n,Math.sqrt(N(a,o)))>1&&i.push(n):i.push(n),i.push(e[t+3])}else{let r=.5,a=e[t+0],o=e[t+1],s=e[t+2],c=e[t+3],l=P(a,o,r),u=P(o,s,r),d=P(s,c,r),f=P(l,u,r),p=P(u,d,r),m=P(f,p,r);mt([a,l,f,m],0,n,i),mt([m,p,d,c],0,n,i)}var a,o;return i}function ht(e,t){return F(e,0,e.length,t)}function F(e,t,n,r,i){let a=i||[],o=e[t],s=e[n-1],c=0,l=1;for(let r=t+1;r<n-1;++r){let t=pt(e[r],o,s);t>c&&(c=t,l=r)}return Math.sqrt(c)>r?(F(e,t,l+1,r,a),F(e,l,n,r,a)):(a.length||a.push(o),a.push(s)),a}function gt(e,t=.15,n){let r=[],i=(e.length-1)/3;for(let n=0;n<i;n++)mt(e,3*n,t,r);return n&&n>0?F(r,0,r.length,n):r}var I=`none`,L=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:`#000`,strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:`hachure`,fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:!1,disableMultiStrokeFill:!1,preserveVertices:!1,fillShapeRoughnessGain:.8},this.config=e||{},this.config.options&&(this.defaultOptions=this._o(this.config.options))}static newSeed(){return Math.floor(Math.random()*2**31)}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,t,n){return{shape:e,sets:t||[],options:n||this.defaultOptions}}line(e,t,n,r,i){let a=this._o(i);return this._d(`line`,[Ye(e,t,n,r,a)],a)}rectangle(e,t,n,r,i){let a=this._o(i),o=[],s=Xe(e,t,n,r,a);if(a.fill){let i=[[e,t],[e+n,t],[e+n,t+r],[e,t+r]];a.fillStyle===`solid`?o.push(nt([i],a)):o.push(k([i],a))}return a.stroke!==I&&o.push(s),this._d(`rectangle`,o,a)}ellipse(e,t,n,r,i){let a=this._o(i),o=[],s=Qe(n,r,a),c=$e(e,t,a,s);if(a.fill)if(a.fillStyle===`solid`){let n=$e(e,t,a,s).opset;n.type=`fillPath`,o.push(n)}else o.push(k([c.estimatedPoints],a));return a.stroke!==I&&o.push(c.opset),this._d(`ellipse`,o,a)}circle(e,t,n,r){let i=this.ellipse(e,t,n,n,r);return i.shape=`circle`,i}linearPath(e,t){let n=this._o(t);return this._d(`linearPath`,[O(e,!1,n)],n)}arc(e,t,n,r,i,a,o=!1,s){let c=this._o(s),l=[],u=et(e,t,n,r,i,a,o,!0,c);if(o&&c.fill)if(c.fillStyle===`solid`){let o=Object.assign({},c);o.disableMultiStroke=!0;let s=et(e,t,n,r,i,a,!0,!1,o);s.type=`fillPath`,l.push(s)}else l.push(function(e,t,n,r,i,a,o){let s=e,c=t,l=Math.abs(n/2),u=Math.abs(r/2);l+=A(.01*l,o),u+=A(.01*u,o);let d=i,f=a;for(;d<0;)d+=2*Math.PI,f+=2*Math.PI;f-d>2*Math.PI&&(d=0,f=2*Math.PI);let p=(f-d)/o.curveStepCount,m=[];for(let e=d;e<=f;e+=p)m.push([s+l*Math.cos(e),c+u*Math.sin(e)]);return m.push([s+l*Math.cos(f),c+u*Math.sin(f)]),m.push([s,c]),k([m],o)}(e,t,n,r,i,a,c));return c.stroke!==I&&l.push(u),this._d(`arc`,l,c)}curve(e,t){let n=this._o(t),r=[],i=Ze(e,n);if(n.fill&&n.fill!==I)if(n.fillStyle===`solid`){let t=Ze(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else{let t=[],i=e;if(i.length){let e=typeof i[0][0]==`number`?[i]:i;for(let r of e)r.length<3?t.push(...r):r.length===3?t.push(...gt(ft([r[0],r[0],r[1],r[2]]),10,(1+n.roughness)/2)):t.push(...gt(ft(r),10,(1+n.roughness)/2))}t.length&&r.push(k([t],n))}return n.stroke!==I&&r.push(i),this._d(`curve`,r,n)}polygon(e,t){let n=this._o(t),r=[],i=O(e,!0,n);return n.fill&&(n.fillStyle===`solid`?r.push(nt([e],n)):r.push(k([e],n))),n.stroke!==I&&r.push(i),this._d(`polygon`,r,n)}path(e,t){let n=this._o(t),r=[];if(!e)return this._d(`path`,r,n);e=(e||``).replace(/\n/g,` `).replace(/(-\s)/g,`-`).replace(`/(ss)/g`,` `);let i=n.fill&&n.fill!==`transparent`&&n.fill!==I,a=n.stroke!==I,o=!!(n.simplification&&n.simplification<1),s=function(e,t,n){let r=Ke(Ge(We(e))),i=[],a=[],o=[0,0],s=[],c=()=>{s.length>=4&&a.push(...gt(s,t)),s=[]},l=()=>{c(),a.length&&(i.push(a),a=[])};for(let{key:e,data:t}of r)switch(e){case`M`:l(),o=[t[0],t[1]],a.push(o);break;case`L`:c(),a.push([t[0],t[1]]);break;case`C`:if(!s.length){let e=a.length?a[a.length-1]:o;s.push([e[0],e[1]])}s.push([t[0],t[1]]),s.push([t[2],t[3]]),s.push([t[4],t[5]]);break;case`Z`:c(),a.push([o[0],o[1]])}if(l(),!n)return i;let u=[];for(let e of i){let t=ht(e,n);t.length&&u.push(t)}return u}(e,1,o?4-4*(n.simplification||1):(1+n.roughness)/2),c=tt(e,n);if(i)if(n.fillStyle===`solid`)if(s.length===1){let t=tt(e,Object.assign(Object.assign({},n),{disableMultiStroke:!0,roughness:n.roughness?n.roughness+n.fillShapeRoughnessGain:0}));r.push({type:`fillPath`,ops:this._mergedShape(t.ops)})}else r.push(nt(s,n));else r.push(k(s,n));return a&&(o?s.forEach((e=>{r.push(O(e,!1,n))})):r.push(c)),this._d(`path`,r,n)}opsToPath(e,t){let n=``;for(let r of e.ops){let e=typeof t==`number`&&t>=0?r.data.map((e=>+e.toFixed(t))):r.data;switch(r.op){case`move`:n+=`M${e[0]} ${e[1]} `;break;case`bcurveTo`:n+=`C${e[0]} ${e[1]}, ${e[2]} ${e[3]}, ${e[4]} ${e[5]} `;break;case`lineTo`:n+=`L${e[0]} ${e[1]} `}}return n.trim()}toPaths(e){let t=e.sets||[],n=e.options||this.defaultOptions,r=[];for(let e of t){let t=null;switch(e.type){case`path`:t={d:this.opsToPath(e),stroke:n.stroke,strokeWidth:n.strokeWidth,fill:I};break;case`fillPath`:t={d:this.opsToPath(e),stroke:I,strokeWidth:0,fill:n.fill||I};break;case`fillSketch`:t=this.fillSketch(e,n)}t&&r.push(t)}return r}fillSketch(e,t){let n=t.fillWeight;return n<0&&(n=t.strokeWidth/2),{d:this.opsToPath(e),stroke:t.fill||I,strokeWidth:n,fill:I}}_mergedShape(e){return e.filter(((e,t)=>t===0||e.op!==`move`))}},_t=class{constructor(e,t){this.canvas=e,this.ctx=this.canvas.getContext(`2d`),this.gen=new L(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.ctx,i=e.options.fixedDecimalPlaceDigits;for(let a of t)switch(a.type){case`path`:r.save(),r.strokeStyle=n.stroke===`none`?`transparent`:n.stroke,r.lineWidth=n.strokeWidth,n.strokeLineDash&&r.setLineDash(n.strokeLineDash),n.strokeLineDashOffset&&(r.lineDashOffset=n.strokeLineDashOffset),this._drawToContext(r,a,i),r.restore();break;case`fillPath`:{r.save(),r.fillStyle=n.fill||``;let t=e.shape===`curve`||e.shape===`polygon`||e.shape===`path`?`evenodd`:`nonzero`;this._drawToContext(r,a,i,t),r.restore();break}case`fillSketch`:this.fillSketch(r,a,n)}}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2),e.save(),n.fillLineDash&&e.setLineDash(n.fillLineDash),n.fillLineDashOffset&&(e.lineDashOffset=n.fillLineDashOffset),e.strokeStyle=n.fill||``,e.lineWidth=r,this._drawToContext(e,t,n.fixedDecimalPlaceDigits),e.restore()}_drawToContext(e,t,n,r=`nonzero`){e.beginPath();for(let r of t.ops){let t=typeof n==`number`&&n>=0?r.data.map((e=>+e.toFixed(n))):r.data;switch(r.op){case`move`:e.moveTo(t[0],t[1]);break;case`bcurveTo`:e.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]);break;case`lineTo`:e.lineTo(t[0],t[1])}}t.type===`fillPath`?e.fill(r):e.stroke()}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a),a}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a),a}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a),a}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i),i}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n),n}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n),n}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c),c}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n),n}path(e,t){let n=this.gen.path(e,t);return this.draw(n),n}},vt=`http://www.w3.org/2000/svg`,yt=class{constructor(e,t){this.svg=e,this.gen=new L(t)}draw(e){let t=e.sets||[],n=e.options||this.getDefaultOptions(),r=this.svg.ownerDocument||window.document,i=r.createElementNS(vt,`g`),a=e.options.fixedDecimalPlaceDigits;for(let o of t){let t=null;switch(o.type){case`path`:t=r.createElementNS(vt,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,n.stroke),t.setAttribute(`stroke-width`,n.strokeWidth+``),t.setAttribute(`fill`,`none`),n.strokeLineDash&&t.setAttribute(`stroke-dasharray`,n.strokeLineDash.join(` `).trim()),n.strokeLineDashOffset&&t.setAttribute(`stroke-dashoffset`,`${n.strokeLineDashOffset}`);break;case`fillPath`:t=r.createElementNS(vt,`path`),t.setAttribute(`d`,this.opsToPath(o,a)),t.setAttribute(`stroke`,`none`),t.setAttribute(`stroke-width`,`0`),t.setAttribute(`fill`,n.fill||``),e.shape!==`curve`&&e.shape!==`polygon`||t.setAttribute(`fill-rule`,`evenodd`);break;case`fillSketch`:t=this.fillSketch(r,o,n)}t&&i.appendChild(t)}return i}fillSketch(e,t,n){let r=n.fillWeight;r<0&&(r=n.strokeWidth/2);let i=e.createElementNS(vt,`path`);return i.setAttribute(`d`,this.opsToPath(t,n.fixedDecimalPlaceDigits)),i.setAttribute(`stroke`,n.fill||``),i.setAttribute(`stroke-width`,r+``),i.setAttribute(`fill`,`none`),n.fillLineDash&&i.setAttribute(`stroke-dasharray`,n.fillLineDash.join(` `).trim()),n.fillLineDashOffset&&i.setAttribute(`stroke-dashoffset`,`${n.fillLineDashOffset}`),i}get generator(){return this.gen}getDefaultOptions(){return this.gen.defaultOptions}opsToPath(e,t){return this.gen.opsToPath(e,t)}line(e,t,n,r,i){let a=this.gen.line(e,t,n,r,i);return this.draw(a)}rectangle(e,t,n,r,i){let a=this.gen.rectangle(e,t,n,r,i);return this.draw(a)}ellipse(e,t,n,r,i){let a=this.gen.ellipse(e,t,n,r,i);return this.draw(a)}circle(e,t,n,r){let i=this.gen.circle(e,t,n,r);return this.draw(i)}linearPath(e,t){let n=this.gen.linearPath(e,t);return this.draw(n)}polygon(e,t){let n=this.gen.polygon(e,t);return this.draw(n)}arc(e,t,n,r,i,a,o=!1,s){let c=this.gen.arc(e,t,n,r,i,a,o,s);return this.draw(c)}curve(e,t){let n=this.gen.curve(e,t);return this.draw(n)}path(e,t){let n=this.gen.path(e,t);return this.draw(n)}},bt={canvas:(e,t)=>new _t(e,t),svg:(e,t)=>new yt(e,t),generator:e=>new L(e),newSeed:()=>L.newSeed()}.generator(),R=1,xt=1,St=.45,Ct=.2,wt=250,Tt=.5;function Et(e){return e<=wt?1:Math.max(Tt,wt/e)}var Dt=.3,Ot=220,kt=.35;function z(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)%2**31}var At=2e3,B=new Map;function jt(e,t){B.size>=At&&B.delete(B.keys().next().value),B.set(e,t)}function V(e,t,n,r=R,i=xt){let a=`${t}|${n}|${r}|${i}|${e}`,o=B.get(a);if(o)return o;let s=bt.path(e,{seed:t,roughness:r,bowing:i,disableMultiStroke:!0,preserveVertices:!0,strokeWidth:n}),c=bt.toPaths(s).map(e=>e.d);return jt(a,c),c}function Mt(e){let t=g(e),n={x:0,y:0,width:t.width,height:t.height},r=d(e.kind,n,e.corner,{x:e.flipX,y:e.flipY}),i=C(Math.min(t.width,t.height)/Ot,kt,1);return V(r,z(e.id),e.strokeWidth,R*i,Dt*i)}function Nt(e,t,n){let r=z(t.id)+n;if(n>0)return V(e,r,1.5,.5,Dt);let i=g(t),a=C(Math.min(i.width,i.height)/Ot,kt,1);return V(e,r,1.5,R*a,Dt*a)}function Pt(e,t,n,r,i){let a=z(r.id)+i,o=`disc|${a}|${e.toFixed(1)}|${t.toFixed(1)}|${n.toFixed(1)}`,s=B.get(o);if(s)return s;let c=bt.circle(e,t,n*2,{seed:a,roughness:R,bowing:xt,fill:`#000000`,fillStyle:`solid`,stroke:`none`,disableMultiStroke:!0}),l=bt.toPaths(c).filter(e=>e.fill&&e.fill!==`none`).map(e=>e.d);return jt(o,l),l}function Ft(e,t,n,r){let i=g(t),a=C(Math.min(i.width,i.height)/Ot,kt,1);return V(e,z(t.id)+n,r,R*a,Dt*a)}function It(e){return e.bendStyle===`elbow`?ue(o(e)):Math.hypot(e.x2-e.x,e.y2-e.y)+Math.abs(e.bend)}function Lt(e){let t=Et(It(e));return V(f(e),z(e.id),e.strokeWidth,St*t,Ct*t)}function Rt(e){let t=Et(ue(e.points));return V(_e(e.points),z(e.id),e.strokeWidth,St*t,Ct*t)}var H=`#8a8f98`,zt=2,U=1.5;function W(e,t,n,r=zt,i){return Ft(t,e.shape,e.nextSalt(),r).map(e=>({kind:`path`,d:e,stroke:n,width:r,testId:i}))}function Bt(e,t,n,r){return[{kind:`rect`,x:t.x,y:t.y,width:t.width,height:t.height,rx:n,fill:r},...W(e,_(t.x,t.y,t.width,t.height,n),e.ink)]}function G(e,t,n,r,i,a={}){return{kind:`text`,x:t,y:n,text:r,size:a.size??e.shape.fontSize,color:i,family:e.shape.fontFamily,anchor:a.anchor??`start`,baseline:a.baseline??`middle`,testId:a.testId}}function Vt(e,t,n){return e.text.measure(t,n??e.shape.fontSize,e.shape.fontFamily)}function K(e){return!e.fill||e.fill===`transparent`?null:e.fill}var Ht=1.6,Ut=.85,Wt=.85;function Gt(e){return Math.min(7,e.height*.18)}function Kt(e){return 12+Gt(e)*2+12}function qt(e){return Math.min(26,e.height)}function Jt(e){return qt(e)*1.9+10}function Yt(e){return Math.min(e.height,e.width/3)}function Xt(e){return Math.min(e.height*.28,13)}function Zt(e){return Xt(e)*2+24}function Qt(e,t){let n=[],r=``;for(let i of e.split(/\s+/)){let e=r.length===0?i:`${r} ${i}`;e.length>t&&r.length>0?(n.push(r),r=i):r=e}return r.length>0&&n.push(r),n}function $t(e,t,n){let r=n*.52;return Qt(e,Math.max(4,Math.floor(t/r)))}function en(e,t,n){return e.split(/\r?\n/).flatMap(e=>e?$t(e,t,n):[``])}var tn=`#e7f5ff`;function nn(e,t){let n=K(e.shape);if(!n)return[];let{bounds:r}=e;return[{kind:`rect`,x:r.x,y:r.y,width:r.width,height:r.height,rx:t,fill:n}]}function q(e,t){let{bounds:n,ink:r}=e,i=nn(e,t);return i.push(...W(e,_(n.x,n.y,n.width,n.height,t),r)),i}function J(e){return e.split(` | `).map(e=>e.trim()).filter(e=>e.length>0)}function Y(e,t){return t===0?0:Math.max(0,Math.min(t-1,Math.round(e.value??0)))}function rn(e){return(e.value??0)>=.5}function an(e){let{bounds:t,shape:n,ink:r}=e,i=[],a=K(n);if(a&&i.push({kind:`rect`,x:t.x,y:t.y,width:t.width,height:t.height,rx:10,fill:a}),i.push(...W(e,_(t.x,t.y,t.width,t.height,10),r)),n.label){let o=a?S(a):r;i.push(G(e,t.x+t.width/2,t.y+t.height/2,n.label,o,{anchor:`middle`}))}return i}function on(e,t=12){let{bounds:n,shape:r,ink:i}=e,a=W(e,_(n.x,n.y,n.width,n.height,6),i);return r.label&&a.push(G(e,n.x+t,n.y+n.height/2,r.label,H)),a}function sn(e){let{bounds:t,ink:n}=e,i=Gt(t),a=t.x+12+i,o=t.y+t.height/2-i*.4,c=on(e,Kt(t));return c.push(...W(e,r(a,o,i),n,U)),c.push(...W(e,s(a+i*.72,o+i*.72,a+i*1.7,o+i*1.7),n,U)),c}function cn(e){let{bounds:t,shape:n,ink:r}=e,i=t.x,a=t.y+t.height/2-22/2,o=W(e,_(i,a,22,22,4),r);if(rn(n)){let t=`M ${i+22*.22} ${a+22*.55} L ${i+22*.45} ${a+22*.75} L ${i+22*.8} ${a+22*.25}`;o.push(...W(e,t,r,2.2))}return n.label&&o.push(G(e,i+22+10,t.y+t.height/2,n.label,r)),o}function ln(e){let{bounds:t,shape:n,ink:i}=e,a=t.x+11,o=t.y+t.height/2,s=W(e,r(a,o,11),i);return rn(n)&&s.push({kind:`circle`,cx:a,cy:o,r:4.5,fill:i}),n.label&&s.push(G(e,a+11+10,o,n.label,i)),s}function un(e){let{bounds:t,shape:n,ink:i}=e,a=qt(t),o=a*1.9,s=t.x,c=t.y+t.height/2-a/2,l=t.y+t.height/2,u=rn(n),d=[];u&&d.push({kind:`rect`,x:s,y:c,width:o,height:a,rx:a/2,fill:K(n)??`#4dabf7`}),d.push(...W(e,_(s,c,o,a,a/2),i));let f=a/2-4,p=u?s+o-a/2:s+a/2;return d.push({kind:`circle`,cx:p,cy:l,r:f,fill:y.paper}),d.push(...W(e,r(p,l,f),i,U)),n.label&&d.push(G(e,t.x+Jt(t),l,n.label,i)),d}function dn(e){let{bounds:t,shape:n,ink:r}=e,i=t.y+t.height/2,a=t.x+t.width,o=W(e,_(t.x,t.y,t.width,t.height,6),r);n.label&&o.push(G(e,t.x+12,i,n.label,r));let s=`M ${a-25} ${i-4} L ${a-18} ${i+4} L ${a-11} ${i-4}`;return o.push(...W(e,s,r,U)),o}function fn(e){let{bounds:t,shape:n,ink:i}=e,a=x(n.value??.5),o=t.y+t.height/2+(n.label?t.height*.12:0),c=t.x+8,l=t.x+t.width-8,u=c+a*(l-c),d=W(e,s(c,o,l,o),H,U);return d.push({kind:`line`,x1:c,y1:o,x2:u,y2:o,stroke:i,width:3}),d.push({kind:`circle`,cx:u,cy:o,r:8,fill:y.paper}),d.push(...W(e,r(u,o,8),i,U)),n.label&&d.push(G(e,t.x,t.y+2,n.label,H,{size:n.fontSize*.7,baseline:`hanging`})),d}function pn(e){let{bounds:t,ink:n}=e,i=t.x+t.width/2,a=t.y+t.height/2,o=Math.min(t.width,t.height)/2-2,s=W(e,r(i,a,o),n);s.push(...W(e,r(i,a-o*.3,o*.32),n,U));let c=`M ${i-o*.55} ${a+o*.72} A ${o*.55} ${o*.55} 0 0 1 ${i+o*.55} ${a+o*.72}`;return s.push(...W(e,c,n,U)),s}function mn(e){let{bounds:t,shape:n,ink:r}=e;return n.label?[G(e,t.x,t.y+t.height/2,n.label,r,{size:n.fontSize*Ht})]:[]}function hn(e,t,n,r){let i=(e+t)/2;return`M ${e} ${n} Q ${i} ${n-r} ${t} ${n} Q ${i} ${n+r} ${e} ${n} Z`}function gn(e,t,n,r){return{kind:`path`,d:hn(e,t,n,r),fill:H,stroke:`none`}}function _n(e){let{bounds:t,shape:n,ink:r}=e;if(n.label){let i=n.fontSize*.9,a=i*1.4,o=$t(n.label,t.width,i),s=Math.max(1,Math.floor(t.height/a));return o.slice(0,s).map((n,o)=>G(e,t.x,t.y+a*(o+.6),n,r,{size:i}))}let i=n.fontSize*1.4,a=Math.max(2,Math.floor(t.height/i)),o=[];for(let e=0;e<a;e+=1){let n=t.y+i*(e+.7),r=e===a-1?.6:1;o.push(gn(t.x,t.x+t.width*r,n,3))}return o}function vn(e,t,n){let r=n*.45,i=[];for(let a=0;a<10;a+=1){let o=a%2==0?n:r,s=-Math.PI/2+a*Math.PI/5,c=e+Math.cos(s)*o,l=t+Math.sin(s)*o;i.push(`${a===0?`M`:`L`} ${c} ${l}`)}return`${i.join(` `)} Z`}function yn(e){let{bounds:t}=e,n=t.y+t.height/2;return W(e,s(t.x,n,t.x+t.width,n),H,U)}function bn(e){let{bounds:t,shape:n}=e;if(!n.label)return[];let r=t.x+t.width/2,i=t.y+t.height/2,a=Math.min(t.width,n.label.length*n.fontSize*.55),o=i+n.fontSize*.6;return[G(e,r,i,n.label,ie,{anchor:`middle`}),...W(e,s(r-a/2,o,r+a/2,o),ie,U)]}function xn(e){let{bounds:t,shape:n,ink:r}=e,i=W(e,_(t.x,t.y,t.width,t.height,6),r),a=n.fontSize*.9,o=a*1.4;if(n.label){let s=$t(n.label,t.width-24,a),c=Math.max(1,Math.floor((t.height-12)/o));s.slice(0,c).forEach((n,s)=>{i.push(G(e,t.x+12,t.y+12+o*(s+.5),n,r,{size:a}))})}else i.push(G(e,t.x+12,t.y+12+o*.5,`Type here…`,H,{size:a}));let c=t.x+t.width-6,l=t.y+t.height-6;return i.push(...W(e,s(c-6,l,c,l-6),H,U)),i.push(...W(e,s(c-11,l,c,l-11),H,U)),i}function Sn(e){let{bounds:t,shape:n,ink:r}=e,i=t.y+t.height/2,a=Yt(t),o=t.x+a,c=t.x+t.width-a,l=W(e,_(t.x,t.y,t.width,t.height,6),r);l.push(...W(e,s(o,t.y,o,t.y+t.height),r,U)),l.push(...W(e,s(c,t.y,c,t.y+t.height),r,U));let u=t.x+a/2,d=t.x+t.width-a/2,f=Math.min(n.fontSize*.42,a*.4,t.height*.3);return l.push(...W(e,s(u-f,i,u+f,i),r,2.2)),l.push(...W(e,s(d-f,i,d+f,i),r,2.2)),l.push(...W(e,s(d,i-f,d,i+f),r,2.2)),n.label&&l.push(G(e,(o+c)/2,i,n.label,r,{anchor:`middle`})),l}function Cn(e){let{bounds:t,shape:n,ink:r}=e,i=t.height/2,a=K(n),o=[];return a&&o.push({kind:`rect`,x:t.x,y:t.y,width:t.width,height:t.height,rx:i,fill:a}),o.push(...W(e,_(t.x,t.y,t.width,t.height,i),r)),n.label&&o.push(G(e,t.x+t.width/2,t.y+t.height/2,n.label,r,{anchor:`middle`,size:n.fontSize*Ut})),o}var wn=`#ffd43b`;function Tn(e){let{bounds:t,shape:n}=e,r=t.x+t.width/2,i=t.y+t.height/2,a=Math.min(t.width,t.height)/2,o=K(n)??`#ffd43b`,s=Pt(r,i,a,n,e.nextSalt()).map(e=>({kind:`path`,d:e,fill:o,stroke:`none`}));return n.label&&s.push(G(e,r,i,n.label,S(o),{anchor:`middle`,size:a*.95})),s}function En(e){let{bounds:t,shape:n,ink:r}=e,i=x(n.value??.6),a=Math.min(t.height,14),o=t.y+t.height/2-a/2,s=a/2,c=[],l=Math.max(a,t.width*i);return c.push({kind:`rect`,x:t.x,y:o,width:l,height:a,rx:s,fill:K(n)??r}),c.push(...W(e,_(t.x,o,t.width,a,s),r,U)),c}function Dn(e){let{bounds:t,shape:n,ink:r}=e,i=Math.max(0,Math.min(5,Math.round(n.value??3))),a=t.y+t.height/2,o=t.width/5,s=Math.min(o,t.height)*.42,c=[];for(let l=0;l<5;l+=1){let u=t.x+o*(l+.5);l<i&&c.push({kind:`path`,d:vn(u,a,s),fill:K(n)??r}),c.push(...W(e,vn(u,a,s),r,U))}return c}function On(e){let{bounds:t,shape:n,ink:r}=e,i=x(n.value??.3),a=t.width/2,o=W(e,_(t.x,t.y,t.width,t.height,a),H,U),s=Math.max(t.width*1.5,t.height*.32),c=t.y+i*(t.height-s);return o.push({kind:`rect`,x:t.x,y:c,width:t.width,height:s,rx:a,fill:K(n)??r}),o.push(...W(e,_(t.x,c,t.width,s,a),r,U)),o}var kn={button:an,input:on,search:sn,checkbox:cn,radio:ln,toggle:un,dropdown:dn,slider:fn,avatar:pn,heading:mn,paragraph:_n,divider:yn,link:bn,textarea:xn,stepper:Sn,badge:Cn,progress:En,rating:Dn,scrollbar:On,stepbadge:Tn},An=`rectangle.ellipse.circle.diamond.cylinder.queue.callout.hexagon.parallelogram.trapezoid.triangle.cloud.star.speech-bubble.note.sticky.checkbox.crossbox.heart.arrow-up.arrow-down.arrow-left.arrow-right.plus.bolt.document.predefined-process.manual-input.pentagon.chevron.octagon.cube.actor.double-circle.card.delay.fork-join.multi-document.multi-process.package.component.brace`.split(`.`),jn=[`browser`,`phone`,`window`,`tablet`],Mn={architecture:`architecture`,graph:`architecture`,flowchart:`flowchart`,flow:`flowchart`,bpmn:`bpmn`,orgchart:`orgchart`,org:`orgchart`,statemachine:`statemachine`,state:`statemachine`,fsm:`statemachine`,sequence:`sequence`,erd:`erd`,class:`erd`,uml:`erd`,wireframe:`wireframe`},Nn=[`architecture`,`flowchart`,`bpmn`,`orgchart`,`statemachine`,`sequence`,`erd`,`wireframe`],Pn=[`blue`,`green`,`red`,`orange`,`violet`,`teal`,`pink`,`yellow`,`gray`];function Fn(e){return Object.fromEntries(e.map(e=>[e,e]))}var In={...Fn(Pn),grey:`gray`,purple:`violet`},Ln={...Fn(An),box:`rectangle`,oval:`ellipse`,decision:`diamond`,database:`cylinder`,db:`cylinder`,storage:`cylinder`,process:`rectangle`,terminator:`ellipse`,start:`ellipse`,end:`ellipse`,data:`parallelogram`,io:`parallelogram`,prep:`hexagon`,preparation:`hexagon`,crossedbox:`crossbox`,lightning:`bolt`,cross:`plus`,doc:`document`,subroutine:`predefined-process`,offpage:`pentagon`,"off-page":`pentagon`,stop:`octagon`,box3d:`cube`,person:`actor`,activity:`rectangle`,event:`ellipse`,gateway:`diamond`,doublecircle:`double-circle`,ring:`double-circle`,"notched-rectangle":`card`,fork:`fork-join`,join:`fork-join`,"stacked-document":`multi-document`,documents:`multi-document`,"stacked-rectangle":`multi-process`,processes:`multi-process`},Rn={app:`app-window`,money:`banknote`};function zn(e){let t=e.replace(`/`,`:`),n=/^(tech|aws|gcp|azure)-(.+)$/.exec(t);return n?`${n[1]}:${n[2]}`:Rn[t]??t}var Bn=[`pastel`,`bold`,`outline`],Vn=[`sharp`,`rounded`],Hn=[`arrow`,`circle`,`cross`],Un=[`right`,`down`,`left`,`up`],Wn=[`loop`,`alt`,`opt`,`par`,`break`],Gn=[`public`,`private`,`protected`,`package`],Kn={public:`+`,private:`-`,protected:`#`,package:`~`},qn=[`zeroOrOne`,`one`,`zeroOrMany`,`oneOrMany`],Jn=[`inheritance`,`realization`,`composition`,`aggregation`,`dependency`,`association`];function Yn(e){if(e.fromCard||e.toCard)return{from:e.fromCard??`one`,to:e.toCard??`one`};switch(e.cardinality){case`1:1`:return{from:`one`,to:`one`};case`1:N`:return{from:`one`,to:`oneOrMany`};case`N:M`:return{from:`oneOrMany`,to:`oneOrMany`};default:return null}}var Xn=[`full`,`twoThirds`,`half`,`third`],Zn=[`info`,`success`,`warning`,`error`],Qn=[`timeline`,`journey`,`cycle`,`funnel`,`pyramid`,`venn`,`matrix`],$n={min:0,max:5,default:3},er=[`normal`,`reverse`,`highlight`],tr=[`done`,`active`,`critical`,`milestone`];function nr(e){let{bounds:t,shape:n,ink:r}=e,i=t.x+t.width,a=t.y+t.height,o=W(e,_(t.x,t.y,t.width,t.height,4),r);return o.push(...W(e,s(t.x,t.y,i,a),r,U)),o.push(...W(e,s(i,t.y,t.x,a),r,U)),n.label&&o.push(G(e,t.x+t.width/2,t.y+t.height/2+Math.min(t.height*.25,n.fontSize*1.4),n.label,H,{size:n.fontSize*.8,anchor:`middle`})),o}var rr=`Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt.`,ir=1.3;function ar(e,t){return Math.min(e.height*.5,Math.max(0,e.height-t*4))}function or(e){let t=g(e),n=e.fontSize,r=e.fontSize*.85,i=t.x+12,a=t.width-24,o=t.y+ar(t,e.fontSize)+8,s=t.y+t.height-6,c=n*ir,l=Math.max(1,e.label.trim()?en(e.label.trim(),a,n).length:1),u=Math.min(l*c,s-o),d=Math.min(o+u+4,s);return{title:{field:`label`,x:i,y:o,width:a,height:u,fontSize:n},body:{field:`body`,x:i,y:d,width:a,height:Math.max(r,s-d),fontSize:r}}}function sr(e,t,n,r){let i=n.trim();if(!i)return[];let a=t.fontSize*ir,o=Math.max(1,Math.floor(t.height/a));return en(i,t.width,t.fontSize).slice(0,o).map((n,i)=>G(e,t.x,t.y+a*i+2,n,r,{size:t.fontSize,baseline:`hanging`,testId:t.field===`body`?`card-body`:`card-title`}))}function cr(e){let{bounds:t,shape:n,ink:r}=e,i=t.x+t.width,a=t.y+ar(t,n.fontSize),o=q(e,10);o.push(...W(e,s(t.x,a,i,a),r,U)),o.push(...W(e,s(t.x,t.y,i,a),H,U)),o.push(...W(e,s(i,t.y,t.x,a),H,U));let c=or(n);return o.push(...sr(e,c.title,n.label,r)),o.push(...sr(e,c.body,n.body??``,H)),o}function lr(e){let{bounds:t,shape:n,ink:r}=e,i=J(n.label),a=q(e,6);if(i.length===0)return a;let o=t.height/i.length;return i.forEach((n,c)=>{let l=t.y+o*c,u=l+o/2,d=t.x+12;a.push({kind:`circle`,cx:d,cy:u,r:2.4,fill:H}),a.push(G(e,d+12,u,n,r)),c<i.length-1&&a.push(...W(e,s(t.x,l+o,t.x+t.width,l+o),H,1))}),a}var ur={info:{label:`Info`,tint:`#e7f5ff`,ink:`#1971c2`},success:{label:`Success`,tint:`#ebfbee`,ink:`#2f9e44`},warning:{label:`Warning`,tint:`#fff9db`,ink:`#f08c00`},error:{label:`Error`,tint:`#fff5f5`,ink:`#e03131`}},dr=Zn.map(e=>({key:e,...ur[e]}));function fr(e){return dr[Math.max(0,Math.min(dr.length-1,Math.round(e.value??0)))]}function pr(e,t,n,i,a,o){let c=[];return t===`warning`?c.push(...W(e,`M ${n} ${i-a} L ${n+a} ${i+a*.85} L ${n-a} ${i+a*.85} Z`,o,U)):c.push(...W(e,r(n,i,a),o,U)),t===`success`?(c.push(...W(e,`M ${n-a*.45} ${i} L ${n-a*.1} ${i+a*.4} L ${n+a*.5} ${i-a*.4}`,o,2)),c):t===`info`?(c.push({kind:`circle`,cx:n,cy:i-a*.45,r:1.5,fill:o}),c.push(...W(e,s(n,i-a*.1,n,i+a*.5),o,2)),c):t===`warning`?(c.push(...W(e,s(n,i-a*.08,n,i+a*.28),o,2)),c.push({kind:`circle`,cx:n,cy:i+a*.5,r:1.4,fill:o}),c):(c.push(...W(e,s(n,i-a*.42,n,i+a*.12),o,2)),c.push({kind:`circle`,cx:n,cy:i+a*.42,r:1.4,fill:o}),c)}function mr(e){let{bounds:t,shape:n}=e,r=fr(n),i=t.y+t.height/2,a=[{kind:`rect`,x:t.x,y:t.y,width:t.width,height:t.height,rx:8,fill:r.tint}];a.push(...W(e,_(t.x,t.y,t.width,t.height,8),r.ink));let o=Xt(t),s=t.x+o+12;if(a.push(...pr(e,r.key,s,i,o,r.ink)),n.label){let o=t.x+Zt(t);a.push(G(e,o,i,n.label,r.ink,{size:n.fontSize*.92}))}return a}function hr(e){let{bounds:t,shape:n,ink:r}=e,i=J(n.label),a=q(e,8);if(i.length===0)return a;let o=t.height/i.length,s=Y(n,i.length);return i.forEach((n,i)=>{let c=t.y+o*i,l=c+o/2;i===s&&a.push({kind:`rect`,x:t.x+4,y:c+3,width:t.width-8,height:o-6,rx:5,fill:tn}),a.push(G(e,t.x+12,l,n,r))}),a}function gr(e){let{bounds:t,shape:n,ink:r}=e,i=t.height-8,a=t.x+t.width/2,o=[],s=K(n),c=t.x,l=t.x+t.width,u=t.y,d=t.y+i,f=Math.min(6,i/2,t.width/2),p=`M ${c+f} ${u} H ${l-f} Q ${l} ${u} ${l} ${u+f} V ${d-f} Q ${l} ${d} ${l-f} ${d} H ${a+8} L ${a} ${d+8} L ${a-8} ${d} H ${c+f} Q ${c} ${d} ${c} ${d-f} V ${u+f} Q ${c} ${u} ${c+f} ${u} Z`;if(s&&(o.push({kind:`rect`,x:c,y:u,width:t.width,height:i,rx:f,fill:s}),o.push({kind:`path`,d:`M ${a-8} ${d} L ${a} ${d+8} L ${a+8} ${d} Z`,fill:s,stroke:`none`})),o.push(...W(e,p,r)),n.label){let c=s?S(s):r;o.push(G(e,a,t.y+i/2,n.label,c,{anchor:`middle`,size:n.fontSize*.9}))}return o}function _r(e){let{bounds:t,shape:n,ink:r}=e,i=J(n.label),a=q(e,8);if(i.length===0)return a;let o=Y(n,i.length),c=Math.min(38,t.height/i.length),l=Math.max(0,t.height-c*i.length),u=t.x+t.width,d=t.y;return i.forEach((f,p)=>{let m=d+c/2,h=u-20,g=p===o,_=g?`M ${h-5} ${m-3} L ${h} ${m+3} L ${h+5} ${m-3}`:`M ${h-3} ${m-5} L ${h+3} ${m} L ${h-3} ${m+5}`;if(a.push(G(e,t.x+12,m,f,r)),a.push(...W(e,_,H,U)),d+=c,g&&l>0){let r=Math.max(1,Math.floor(l/(n.fontSize*1.4)));for(let i=0;i<r;i+=1){let o=d+n.fontSize*1.4*(i+.6);if(o>d+l)break;let c=i===r-1?.6:.92;a.push(...W(e,s(t.x+12,o,t.x+t.width*c,o),H,1))}d+=l}p<i.length-1&&a.push(...W(e,s(t.x,d,u,d),H,1))}),a}var vr=`Are you sure you want to continue?`;function yr(e){return Math.min(46,e.height*.24)}function br(e){return Math.min(56,e.height*.28)}function xr(e){let t=e.x+e.width,n=e.y+e.height,r=br(e),i=n-r,a=Math.min(34,r-14),o=i+(r-a)/2,s=Math.min(88,(e.width-24-10)/2);if(s<=24)return null;let c=t-12-s;return{secondary:{x:c-10-s,y:o,width:s,height:a},primary:{x:c,y:o,width:s,height:a}}}function Sr(e){return e.primaryLabel??`OK`}function Cr(e){return e.secondaryLabel??`Cancel`}function wr(e){let{bounds:t,shape:n,ink:r}=e,i=t.x+t.width,a=t.y+t.height,o=yr(t),c=a-br(t),l=q(e,12);n.label&&l.push(G(e,t.x+12,t.y+o/2,n.label,r,{testId:`card-title`}));let u=i-12-4,d=t.y+o/2;l.push(...W(e,s(u-5,d-5,u+5,d+5),H,U)),l.push(...W(e,s(u+5,d-5,u-5,d+5),H,U)),l.push(...W(e,s(t.x,t.y+o,i,t.y+o),H,1));let f=n.body??``;if(f){let i=n.fontSize*.92,a=i*1.4,s=t.y+o+10,u=en(f,t.width-24,i),d=Math.max(1,Math.floor((c-s)/a));u.slice(0,d).forEach((n,o)=>l.push(G(e,t.x+12,s+a*(o+.5),n,r,{size:i,testId:`card-body`})))}l.push(...W(e,s(t.x,c,i,c),H,1));let p=xr(t);if(p){let{secondary:t,primary:i}=p,a=n.fontSize*.82,o=te(r)??S(r);l.push({kind:`rect`,x:i.x,y:i.y,width:i.width,height:i.height,rx:8,fill:r}),l.push(...W(e,_(i.x,i.y,i.width,i.height,8),r)),l.push(...W(e,_(t.x,t.y,t.width,t.height,8),r));let s=Sr(n),c=Cr(n);s&&l.push(G(e,i.x+i.width/2,i.y+i.height/2,s,o,{anchor:`middle`,size:a,testId:`modal-primary`})),c&&l.push(G(e,t.x+t.width/2,t.y+t.height/2,c,r,{anchor:`middle`,size:a,testId:`modal-secondary`}))}return l}var Tr={image:nr,card:cr,list:lr,alert:mr,menu:hr,tooltip:gr,accordion:_r,modal:wr},Er=`+id: string
2
+ +name: string
3
+ ---
4
+ +save()
5
+ +delete()`,Dr=1.9,Or=1.4,kr=/^-{2,}$/;function Ar(e){return(e??``).split(/\r?\n/).map(e=>e.trim()).filter(e=>e.length>0)}function jr(e){return Ar(e.body).map(e=>({text:e,divider:kr.test(e)}))}function Mr(e){return jr(e).filter(e=>!e.divider).map(e=>e.text)}function Nr(e){let t=e.fontSize*.9;return{fontSize:t,lineH:t*Or}}function Pr(e){let t=g(e),n=Mr(e).length===0?t.height:Math.min(t.height,e.fontSize*Dr),r=t.x+12,i=t.width-24,{fontSize:a}=Nr(e),o=t.y+n+4,s=t.y+t.height-4;return{title:{field:`label`,x:t.x,y:t.y,width:t.width,height:n,fontSize:e.fontSize},body:{field:`body`,x:r,y:o,width:i,height:Math.max(a,s-o),fontSize:a}}}function Fr(e,t,n){let r=n*.9,i=r*Or,a=n*Dr,o=Math.round(a+4+t.length*i+8),s=(e,t)=>e.length*t*.62,c=Math.max(s(e,n),0,...t.filter(e=>!kr.test(e)).map(e=>s(e,r)));return{width:Math.max(160,Math.round(c+24+16)),height:o}}function Ir(e){let t=Pr(e),{lineH:n}=Nr(e),r=g(e).y+e.height;return jr(e).map((e,r)=>({text:e.text,cy:t.body.y+n*(r+.5),divider:e.divider})).filter(e=>e.cy<=r)}function Lr(e){let t=g(e);return Ir(e).filter(e=>!e.divider).map(({cy:e})=>({cy:e,left:{x:t.x,y:e},right:{x:t.x+t.width,y:e}}))}function Rr(e){let{bounds:n,shape:r,ink:i}=e,a=Pr(r),o=n.y+a.title.height,c=Mr(r).length>0,l=K(r),u=[];l&&u.push({kind:`path`,d:c?t(n.x,n.y,n.width,a.title.height,6):_(n.x,n.y,n.width,n.height,6),fill:l,testId:`entity-header`}),u.push(...W(e,_(n.x,n.y,n.width,n.height,6),i)),c&&u.push(...W(e,s(n.x,o,n.x+n.width,o),i,U));let d=r.label.trim();d&&u.push(G(e,n.x+n.width/2,n.y+a.title.height/2,d,l?S(l):i,{anchor:`middle`,testId:`entity-title`}));for(let{text:t,cy:o,divider:c}of Ir(r)){if(c){u.push(...W(e,s(n.x,o,n.x+n.width,o),i,U,`entity-divider`));continue}u.push(G(e,a.body.x,o,t,i,{size:a.body.fontSize,testId:`entity-row`}))}return u}function X(e){return Math.min(e.height,zr(e.fontSize))}function zr(e){return e*2.4}var Br=12;function Vr(e){if(!e.activations||e.activations.length===0)return[];let t=X(e),n=e.height;return e.activations.map(r=>{let i=Math.min(Math.max(r.top,t),Math.max(t,n-12)),a=Math.max(12,Math.min(r.height,n-i));return{x:e.x+e.width/2-Br/2,y:e.y+i,width:Br,height:a}})}function Hr(e,t){for(let n of Vr(e))if(t>=n.y&&t<=n.y+n.height)return n;return null}function Ur(e){let t=X(e);return{x:e.x+e.width/2,y:e.y+t,width:0,height:Math.max(2,e.height-t)}}function Wr(e){let t=X(e),n=Math.max(0,e.height-t),r=Math.min(Math.max(n*.12,16),64);return{top:t+r,height:Math.max(12,n-r*2)}}function Gr(e){let t=Vr(e);if(t.length===0)return Wr(e);let n=X(e),r=t.map(t=>({top:t.y-e.y,bottom:t.y-e.y+t.height})).sort((e,t)=>e.top-t.top),i=[],a=n;for(let e of r)e.top>a&&i.push({start:a,end:e.top}),a=Math.max(a,e.bottom);a<e.height&&i.push({start:a,end:e.height});let o=i.sort((e,t)=>t.end-t.start-(e.end-e.start))[0];if(!o)return{top:Math.max(n,e.height-12),height:12};let s=o.end-o.start,c=Math.min(Math.max(s*.15,10),48);return{top:o.start+c,height:Math.max(12,s-c*2)}}var Kr=12,qr=7,Jr=1.5;function Yr(e){let t=K(e);return t?S(t):null}function Xr(e){let{bounds:t,shape:n,ink:r}=e,i=X(n),a=t.x+t.width/2,o=K(n)??y.paper,s=Bt(e,{x:t.x,y:t.y,width:t.width,height:i},6,o);n.label.trim()&&s.push(G(e,a,t.y+i/2,n.label.trim(),Yr(n)??r,{anchor:`middle`,testId:`lifeline-name`}));let c=t.y+t.height;for(let e=t.y+i;e<c;e+=Kr)s.push({kind:`line`,x1:a,y1:e,x2:a,y2:Math.min(e+qr,c),stroke:r,width:Jr});for(let t of Vr(n))s.push(...Bt(e,t,2,o));return s}var Zr=[`opt`,`alt`,`loop`,`par`,`break`,`critical`,`seq`],Qr=`#f3f0ff`,$r=14,ei=8,ti=1.75,ni=.1;function ri(e,t){let n=e.trimStart().match(/^\S+(\s[\s\S]*)?$/);return t+(n&&n[1]?n[1]:``)}function ii(e){return Math.min(g(e).height,e.fontSize*ti)}function ai(e,t){let n=g(e),r=e.label.trim()||`opt`,i=Math.min(n.width,t.measure(r,e.fontSize,e.fontFamily)+24);return{x:n.x,y:n.y,width:i,height:ii(e)}}function oi(e){let t=Math.min(ei,e.width/2,e.height/2);return{tl:Math.min($r,e.width-t,e.height-t),br:t}}function si(e){let{x:t,y:n,width:r,height:i}=e,{tl:a,br:o}=oi(e);return[`M ${t+a} ${n}`,`L ${t+r} ${n}`,`L ${t+r} ${n+i-o}`,`Q ${t+r} ${n+i} ${t+r-o} ${n+i}`,`L ${t} ${n+i}`,`L ${t} ${n+a}`,`Q ${t} ${n} ${t+a} ${n}`,`Z`].join(` `)}function ci(e){let{x:t,y:n,width:r,height:i}=e,{br:a}=oi(e);return`M ${t+r} ${n} L ${t+r} ${n+i-a} Q ${t+r} ${n+i} ${t+r-a} ${n+i} L ${t} ${n+i}`}function li(e){let{bounds:t,shape:n,ink:r}=e,i=K(n)??`#f3f0ff`,a=ai(n,e.text),o=[{kind:`path`,d:si(a),fill:i,testId:`fragment-tab`}];o.push(...W(e,_(t.x,t.y,t.width,t.height,$r),r)),o.push(...W(e,ci(a),r,U,`fragment-tab`));let s=n.label.trim();return s&&o.push(G(e,a.x+12,a.y+a.height/2+n.fontSize*ni,s,S(i),{anchor:`start`,testId:`fragment-label`})),o}var ui={entity:Rr,lifeline:Xr,fragment:li};function di(e){let{bounds:t,shape:n,ink:r}=e,i=t.y+t.height/2,a=W(e,_(t.x,t.y,t.width,t.height,8),r),o=J(n.label),s=Y(n,o.length);return o.forEach((n,c)=>{let l=t.x+t.width*(c+.5)/o.length;a.push(G(e,l,i,n,c===s?r:H,{anchor:`middle`}))}),a}var fi=14;function pi(e){let{bounds:t,shape:n,ink:r}=e,i=t.y+t.height/2,a=t.y+t.height-1,o=[{kind:`line`,x1:t.x,y1:a,x2:t.x+t.width,y2:a,stroke:H,width:1}],c=J(n.label);if(c.length>0){let l=Y(n,c.length),u=n.fontSize*.55,d=t.x;c.forEach((t,n)=>{let c=t.length*u+fi*2;n===l&&o.push(...W(e,s(d+4,a,d+c-4,a),r,2.5)),o.push(G(e,d+c/2,i,t,n===l?r:H,{anchor:`middle`})),d+=c})}return o}function mi(e){let{bounds:t,shape:n,ink:r}=e,i=t.y+t.height/2,a=J(n.label),o=n.fontSize*.4,s=[],c=t.x;return a.forEach((t,n)=>{let l=n===a.length-1;s.push(G(e,c,i,t,l?r:H,{anchor:`start`})),c+=Vt(e,t),l||(c+=o,s.push(G(e,c,i,`/`,H,{anchor:`start`})),c+=Vt(e,`/`)+o)}),s}function hi(e){let{bounds:t,shape:n,ink:r}=e,i=t.y+t.height/2,a=J(n.label),o=t.height*.5,s=[],c=t.x+o*.5;s.push(...W(e,`M ${c+3} ${i-5} L ${c-3} ${i} L ${c+3} ${i+5}`,H,U));let l=t.x+t.width-o*.5;if(s.push(...W(e,`M ${l-3} ${i-5} L ${l+3} ${i} L ${l-3} ${i+5}`,H,U)),a.length>0){let c={x:t.x+o,width:t.width-o*2},l=c.width/a.length,u=Y(n,a.length),d=Math.min(t.height,l)*.82;a.forEach((t,a)=>{let o=c.x+l*(a+.5);a===u&&s.push(...W(e,_(o-d/2,i-d/2,d,d,5),r,U)),s.push(G(e,o,i,t,a===u?r:H,{anchor:`middle`,size:n.fontSize*.85}))})}return s}function gi(e){let{bounds:t,shape:n,ink:r}=e,i=t.x+t.width,a=Math.min(34,t.height*.2),o=W(e,_(t.x,t.y,t.width,t.height,8),r),c=t.y+a/2;o.push(...W(e,`M ${t.x+18} ${c-4} L ${t.x+12} ${c} L ${t.x+18} ${c+4}`,H,U)),o.push(...W(e,`M ${i-18} ${c-4} L ${i-12} ${c} L ${i-18} ${c+4}`,H,U)),o.push(G(e,t.x+t.width/2,c,n.label||`Month`,H,{anchor:`middle`,size:n.fontSize*.85})),o.push(...W(e,s(t.x,t.y+a,i,t.y+a),H,1));let l=t.y+a+8,u=t.y+t.height-l-8,d=t.width/7,f=u/5,p=Math.min(d,f)*.16,m=Math.round((n.value??.4)*34);for(let e=0;e<5;e+=1)for(let i=0;i<7;i+=1){let a=t.x+d*(i+.5),s=l+f*(e+.5);e*7+i===m?o.push({kind:`circle`,cx:a,cy:s,r:p*1.8,fill:K(n)??r}):o.push({kind:`circle`,cx:a,cy:s,r:p,fill:H})}return o}function _i(e){let{bounds:t,shape:n,ink:r}=e,i=J(n.label),a=q(e,8);if(i.length===0)return a;let o=t.y+12,s=Math.min(40,(t.height-24)/i.length),c=Y(n,i.length);return i.forEach((i,l)=>{let u=o+s*l,d=u+s/2;l===c&&a.push({kind:`rect`,x:t.x+6,y:u+3,width:t.width-12,height:s-6,rx:6,fill:tn});let f=t.x+12+2;a.push({kind:`circle`,cx:f,cy:d,r:3,fill:l===c?r:H}),a.push(G(e,f+14,d,i,l===c?r:H,{size:n.fontSize*.9}))}),a}function vi(e){let{bounds:t,shape:n,ink:r}=e,i=J(n.label),a=Math.max(i.length,1),o=t.width/a,c=Math.min(8,t.height/2),l=t.y+t.height/2,u=Y(n,i.length),d=K(n)??`#4dabf7`,f=[];i.length>0&&f.push({kind:`rect`,x:t.x+u*o,y:t.y,width:o,height:t.height,rx:u===0||u===a-1?c:0,fill:d}),f.push(...W(e,_(t.x,t.y,t.width,t.height,c),r));for(let n=1;n<a;n+=1){let i=t.x+n*o;f.push(...W(e,s(i,t.y,i,t.y+t.height),r,U))}return i.forEach((n,r)=>{let i=t.x+(r+.5)*o,a=r===u?S(d):H;f.push(G(e,i,l,n,a,{anchor:`middle`}))}),f}function yi(e){let{bounds:t,shape:n,ink:i}=e,a=J(n.label),o=Math.max(a.length,1),c=t.width/o,l=Y(n,a.length),u=W(e,s(t.x,t.y,t.x+t.width,t.y),H,U),d=Math.min(8,t.height*.18),f=t.y+t.height*.4;return a.forEach((a,o)=>{let s=t.x+(o+.5)*c,p=o===l?i:H;u.push(...W(e,r(s,f,d),p,U)),u.push(G(e,s,t.y+t.height*.8,a,p,{anchor:`middle`,size:n.fontSize*.78}))}),u}function bi(e){let{bounds:t,shape:n,ink:r}=e,i=t.y+t.height/2,a=n.label&&n.label.length>0?n.label:`9:41`,o=[G(e,t.x+8,i,a,r,{size:n.fontSize*Wt})],s=t.x+t.width-8,c=Math.min(11,t.height*.5),l=c*2,u=s-l-2,d=i-c/2;o.push(...W(e,_(u,d,l,c,2),r,U)),o.push({kind:`rect`,x:u+l+1.5,y:i-c*.2,width:2,height:c*.4,fill:r}),o.push({kind:`rect`,x:u+1.5,y:d+1.5,width:(l-3)*.6,height:c-3,fill:r});let f=i+5,p=u-30;for(let e=0;e<4;e+=1){let t=3+e*2.2;o.push({kind:`rect`,x:p,y:f-t,width:3,height:t,fill:r}),p+=5}return o}function xi(e){let{bounds:t,shape:n,ink:i}=e,a=t.x+t.width/2,o=t.y+t.height/2,c=Math.min(t.width,t.height)/2-2,l=K(n),u=[];l&&u.push({kind:`circle`,cx:a,cy:o,r:c,fill:l}),u.push(...W(e,r(a,o,c),i));let d=c*.42,f=l?S(l):i;return u.push(...W(e,s(a-d,o,a+d,o),f,2.5)),u.push(...W(e,s(a,o-d,a,o+d),f,2.5)),u}var Si={navbar:di,tabs:pi,breadcrumbs:mi,pagination:hi,datepicker:gi,sidebar:_i,segmented:vi,tabbar:yi,statusbar:bi,fab:xi},Ci=`#1e1e1e`,wi={...kn,...Si,...Tr,...ui};function Ti(e,t){let n=g(e),r=0,i={shape:e,bounds:n,ink:m(e.color===`transparent`?Ci:e.color),text:t,nextSalt:()=>(r+=1,r)};return wi[e.kind](i)}var Ei={button:{width:140,height:46},input:{width:220,height:46},search:{width:220,height:46},checkbox:{width:160,height:32},radio:{width:160,height:32},toggle:{width:140,height:36},dropdown:{width:200,height:46},slider:{width:220,height:42},navbar:{width:360,height:52},tabs:{width:320,height:46},image:{width:240,height:160},avatar:{width:72,height:72},heading:{width:240,height:46},paragraph:{width:280,height:84},divider:{width:240,height:16},link:{width:120,height:28},textarea:{width:240,height:110},stepper:{width:140,height:46},badge:{width:76,height:28},progress:{width:240,height:16},breadcrumbs:{width:280,height:32},pagination:{width:240,height:40},rating:{width:150,height:32},card:{width:240,height:200},list:{width:240,height:150},alert:{width:320,height:56},menu:{width:200,height:150},tooltip:{width:160,height:48},accordion:{width:280,height:170},datepicker:{width:240,height:220},sidebar:{width:180,height:280},scrollbar:{width:14,height:220},segmented:{width:240,height:36},tabbar:{width:360,height:56},statusbar:{width:320,height:28},fab:{width:56,height:56},modal:{width:320,height:210},stepbadge:{width:44,height:44},entity:{width:200,height:176},lifeline:{width:150,height:300},fragment:{width:300,height:180}},Di={button:`Button`,input:`Type here…`,search:`Search…`,dropdown:`Select…`,heading:`Heading`,navbar:`Home | About | Contact`,tabs:`First | Second`,checkbox:`Checkbox`,radio:`Option`,toggle:`Toggle`,link:`Link text`,badge:`New`,breadcrumbs:`Home | Library | Item`,pagination:`1 | 2 | 3 | 4`,card:`Card title`,list:`Item one | Item two | Item three`,alert:`Heads up. Something needs attention.`,menu:`New | Open | Save | Close`,tooltip:`Tooltip text`,accordion:`Section one | Section two | Section three`,sidebar:`Dashboard | Projects | Team | Settings`,segmented:`Day | Week | Month`,tabbar:`Home | Search | Profile`,statusbar:`9:41`,modal:`Dialog title`,stepbadge:`1`,entity:`User`,lifeline:`Participant`,fragment:`opt`},Oi={button:{resize:`free`,fill:!0,font:!0,label:!0},input:{resize:`width`,fill:!1,font:!0,label:!0},search:{resize:`width`,fill:!1,font:!0,label:!0},checkbox:{resize:`width`,fill:!1,font:!0,label:!0,value:`toggle`},radio:{resize:`width`,fill:!1,font:!0,label:!0,value:`toggle`},toggle:{resize:`width`,fill:!0,font:!0,label:!0,value:`toggle`},dropdown:{resize:`width`,fill:!1,font:!0,label:!0},slider:{resize:`width`,fill:!1,font:!0,label:!0,value:`range`},navbar:{resize:`width`,fill:!1,font:!0,label:!0,value:`index`},tabs:{resize:`width`,fill:!1,font:!0,label:!0,value:`index`},image:{resize:`free`,fill:!1,font:!0,label:!0},avatar:{resize:`aspect`,fill:!1,font:!1,label:!1},heading:{resize:`free`,fill:!1,font:!0,label:!0},paragraph:{resize:`free`,fill:!1,font:!0,label:!0},divider:{resize:`width`,fill:!1,font:!1,label:!1},link:{resize:`width`,fill:!1,font:!0,label:!0},textarea:{resize:`free`,fill:!1,font:!0,label:!0},stepper:{resize:`width`,fill:!1,font:!0,label:!0},badge:{resize:`width`,fill:!0,font:!0,label:!0},progress:{resize:`width`,fill:!0,font:!1,label:!1,value:`range`},breadcrumbs:{resize:`width`,fill:!1,font:!0,label:!0},pagination:{resize:`width`,fill:!1,font:!0,label:!0,value:`index`},rating:{resize:`width`,fill:!0,font:!1,label:!1,value:`stars`},card:{resize:`free`,fill:!0,font:!0,label:!0},list:{resize:`free`,fill:!0,font:!0,label:!0},alert:{resize:`width`,fill:!1,font:!0,label:!0,value:`alert`},menu:{resize:`free`,fill:!0,font:!0,label:!0,value:`index`},tooltip:{resize:`width`,fill:!0,font:!0,label:!0},accordion:{resize:`free`,fill:!0,font:!0,label:!0,value:`index`},datepicker:{resize:`free`,fill:!1,font:!1,label:!1},sidebar:{resize:`free`,fill:!0,font:!0,label:!0,value:`index`},scrollbar:{resize:`height`,fill:!0,font:!1,label:!1,value:`range`},segmented:{resize:`width`,fill:!0,font:!0,label:!0,value:`index`},tabbar:{resize:`width`,fill:!1,font:!0,label:!0,value:`index`},statusbar:{resize:`width`,fill:!1,font:!0,label:!0},fab:{resize:`aspect`,fill:!0,font:!1,label:!1},modal:{resize:`free`,fill:!0,font:!0,label:!0},stepbadge:{resize:`aspect`,fill:!0,font:!0,label:!0},entity:{resize:`free`,fill:!0,font:!0,label:!0},lifeline:{resize:`free`,fill:!0,font:!0,label:!0,value:`activation`},fragment:{resize:`free`,fill:!0,font:!0,label:!0,value:`operator`}};function ki(e){return Oi[e].label}function Ai(e,t,n){let r=Ei[e];return{id:v(),type:`control`,kind:e,x:t.x,y:t.y,width:r.width,height:r.height,rotation:0,label:Di[e]??``,...e===`card`?{body:rr}:{},...e===`modal`?{body:vr}:{},...e===`entity`?{body:Er}:{},...e===`fragment`?{fill:Qr}:{},...e===`stepbadge`?{fill:wn}:{},fontSize:16,fontFamily:n.fontFamily,color:n.color===`transparent`?Ci:n.color,opacity:n.opacity,value:ji(e)}}function ji(e){if(e===`toggle`||e===`checkbox`||e===`radio`)return 1;if(e===`slider`||e===`progress`)return .6;if(e===`scrollbar`)return .3;if(e===`rating`)return 3;if(e===`alert`||e===`navbar`||e===`tabs`||e===`pagination`||e===`menu`||e===`accordion`||e===`sidebar`||e===`segmented`||e===`tabbar`)return 0}var Mi=8,Z=[],Q={get(e){for(let t=Z.length-1;t>=0;--t)if(Z[t].shapes===e)return Z[t].index},has(e){return Q.get(e)!==void 0},set(e,t){Z.push({shapes:e,index:t}),Z.length>Mi&&Z.shift()}};function Ni(e){if(e.type===`arrow`){let t=[];return e.startBinding&&t.push(e.startBinding.shapeId),e.endBinding&&t.push(e.endBinding.shapeId),t}return e.type===`polygon`&&e.band?[e.band.from,e.band.to]:[]}function Pi(e){let t=new Map,n=new Map,r=new Map;for(let i=0;i<e.length;i+=1){let a=e[i];t.has(a.id)||t.set(a.id,i);let o=r.get(a.type);o?o.push(i):r.set(a.type,[i]);for(let e of Ni(a)){let t=n.get(e);t?t.push(a.id):n.set(e,[a.id])}}return{position:t,dependents:n,byType:r}}function Fi(e){let t=Q.get(e);if(t)return t;let n=Pi(e);return Q.set(e,n),n}function Ii(e,t){if(e===t||Q.has(t))return;let n=Q.get(e);if(!(!n||e.length!==t.length)){for(let n=0;n<t.length;n+=1){let r=e[n],i=t[n];if(r!==i&&!Ri(r,i))return}Q.set(t,n)}}function Li(e,t,n){if(e===t||Q.has(t))return;let r=Q.get(e);if(!(!r||e.length!==t.length)){for(let r of n){let n=e[r],i=t[r];if(n!==i&&!Ri(n,i))return}Q.set(t,r)}}function Ri(e,t){return e.id===t.id&&e.type===t.type&&zi(e,t)}function zi(e,t){let n=Ni(t);if(n.length===0)return!0;let r=Ni(e);return n.every(e=>r.includes(e))}function Bi(e,t){let{position:n}=Fi(e),r=[];for(let e of t){let t=n.get(e);t!==void 0&&r.push(t)}return r.sort((e,t)=>e-t),r.map(t=>e[t])}function Vi(e,t){let n=Q.get(e);return n?(n.byType.get(t)??[]).map(t=>e[t]):e.filter(e=>e.type===t)}function Hi(e){return Vi(e,`figure`)}function Ui(e,t){let n=Q.get(e);if(n){let r=n.position.get(t);return r===void 0?void 0:e[r]}return e.find(e=>e.id===t)}var Wi=.05;function Gi(e){return Number.isNaN(e)?1:C(e,Wi,8)}function Ki(e){return{zoom:1,x:Number.isFinite(e.width)?e.width/2:0,y:Number.isFinite(e.height)?e.height/2:0}}function qi(e,t){return{x:(e.x-t.x)/t.zoom,y:(e.y-t.y)/t.zoom}}function Ji(e,t){return{x:e.x*t.zoom+t.x,y:e.y*t.zoom+t.y}}function Yi(e,t,n){let r=Gi(t),i=qi(n,e),a=n.x-i.x*r,o=n.y-i.y*r;return!Number.isFinite(a)||!Number.isFinite(o)?{zoom:r,x:n.x,y:n.y}:{zoom:r,x:a,y:o}}function Xi(e,t,n,r=80,i=24){if(!pe(e))return null;let a=Ji({x:e.x,y:e.y},t),o=Ji({x:e.x+e.width,y:e.y+e.height},t);if(a.x>=i&&a.y>=i&&o.x<=n.width-i&&o.y<=n.height-i)return null;if(e.width*t.zoom<=n.width-r*2&&e.height*t.zoom<=n.height-r*2){let r=e.x+e.width/2,i=e.y+e.height/2;return{zoom:t.zoom,x:n.width/2-r*t.zoom,y:n.height/2-i*t.zoom}}return Zi(e,n,r)}function Zi(e,t,n=80){if(!pe(e))return Ki(t);let r=Math.max(1,t.width-n*2),i=Math.max(1,t.height-n*2),a=Gi(Math.min(r/e.width,i/e.height,1)),o=e.x+e.width/2,s=e.y+e.height/2,c={zoom:a,x:t.width/2-o*a,y:t.height/2-s*a};return!Number.isFinite(c.x)||!Number.isFinite(c.y)?Ki(t):c}function Qi(e,t,n,r){return n.id===e.id?!1:c(n)?ta(t,g(n,r)):oe(fe(g(n,r)),t)}function $i(e,t,n){let r=g(t,n);return e.filter(e=>(u(e)||de(re(e),r))&&Qi(t,r,e,n))}function ea(e,t,n){let r=e.map((e,t)=>({x:fe(g(e,n)).x,order:t,shape:e})).sort((e,t)=>e.x-t.x),i=r.map(e=>e.x),a=e=>{let t=0,n=i.length;for(;t<n;){let r=t+n>>1;i[r]<e?t=r+1:n=r}return t},o=e=>{let t=0,n=i.length;for(;t<n;){let r=t+n>>1;i[r]<=e?t=r+1:n=r}return t};return{members(e){let i=g(e,n),s=a(i.x),c=o(i.x+i.width);t?.onCandidates?.(Math.max(0,c-s));let l=[];for(let t=s;t<c;t+=1){let a=r[t];Qi(e,i,a.shape,n)&&l.push(a)}return l.sort((e,t)=>e.order-t.order),l.map(e=>e.shape)}}}function ta(e,t){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height}function na(e,t){let n=g(t);return e.some(e=>c(e)&&e.id!==t.id&&ta(g(e),n))}function ra(e){let t=e.filter(e=>c(e)),n=t.map(e=>g(e)),r=new Set;for(let e=0;e<t.length;e+=1)for(let i=0;i<t.length;i+=1)if(e!==i&&ta(n[i],n[e])){r.add(t[e].id);break}return r}function ia(e,t,n){let r=new Set(t.map(e=>e.id)),i=[...t];if(r.size>=e.length)return i;let a=t.filter(e=>c(e)),o=a.length>2?ea(e,void 0,n):null;for(let t of a){let a=o?o.members(t):$i(e,t,n);for(let e of a)r.has(e.id)||(r.add(e.id),i.push(e))}return i}var aa=64,oa=480,sa=270;function ca(e,t){return c(e)&&e.slideOrder!==void 0&&!e.groupId&&(e.kind??`simple`)===`simple`&&!t.has(e.id)}function la(e){let t=Hi(e);return da(t,ra(t))}function ua(e){return e.filter(e=>!e.slideSkipped)}function da(e,t){return e.filter(e=>ca(e,t)).sort((e,t)=>(e.slideOrder??0)-(t.slideOrder??0))}function fa(e,t){let n=(a(e.label)?p(e.label):e.label).trim();return n.length>0?n:`Frame ${t+1}`}function pa(e,t){return fa(e,t).toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``)||`slide-${t+1}`}function ma(e,t,n){let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r.map((e,t)=>({...e,slideOrder:t}))}function ha(e,t,n=1){return e.map((e,r)=>({...e,slideOrder:r<t?r:r+n}))}function ga(e,t,r=[]){let i=e[e.length-1],a=i&&i.width>=oa&&i.height>=sa,o=a?i.width:960,s=a?i.height:540,c=i?null:n(r),l,u;return i?(l=Math.max(...e.map(e=>e.x+e.width))+aa,u=i.y):c?(l=c.x+c.width+aa,u=c.y+c.height/2-s/2):(l=t.x-o/2,u=t.y-s/2),{id:v(),type:`figure`,x:l,y:u,width:o,height:s,rotation:0,label:`Frame ${e.length+1}`,fontSize:24,fontFamily:le,color:ae,fill:`#ffffff`,opacity:1,slideOrder:e.length}}function _a(e,t,n){let r=t[n],i=$i(e,r),a={x:Math.max(...t.map(e=>e.x+e.width))+aa-r.x,y:0},[o,...s]=ne([r,...i],a);return{clones:[{...o,slideOrder:n+1},...s],renumbered:ha(t,n+1)}}function va(e,t){return new Set([t.id,...$i(e,t).map(e=>e.id)])}function ya(e,t){let n=ra(e);return e.filter(e=>ba(t,e,n))}function ba(e,t,n){if(t.id===e.id||c(t)&&!n.has(t.id))return!1;let r=g(e),i=re(t);return i.x<r.x+r.width&&i.x+i.width>r.x&&i.y<r.y+r.height&&i.y+i.height>r.y}function xa(e,t,n){if(n.size===0||t.length===0)return null;let r=ra(e),i=null;for(let a of e){if(!n.has(a.id))continue;let e=t.find(e=>e.id===a.id)??Sa(t,a,r);if(e){if(i&&i.id!==e.id)return null;i=e}}return i}function Sa(e,t,n){let r=null,i=1/0;for(let a of e){if(!ba(a,t,n))continue;let e=g(a),o=e.width*e.height;o<i&&(r=a,i=o)}return r}function Ca(e,t){let n=Gi(Math.min(t.width/e.width,t.height/e.height));return{zoom:n,x:t.width/2-(e.x+e.width/2)*n,y:t.height/2-(e.y+e.height/2)*n}}function wa(e,t,n){return Ta(e,qi({x:n.width/2,y:n.height/2},t))}function Ta(e,t){let n=-1,r=1/0;return e.forEach((e,i)=>{let a=g(e),o=t.x>=a.x&&t.x<=a.x+a.width&&t.y>=a.y&&t.y<=a.y+a.height,s=a.width*a.height;o&&s<r&&(n=i,r=s)}),n}var $=[{id:`lucide`,kind:`stroke`},{id:`drawnicons`,kind:`asset`,mono:!0,varyingExtent:!0,remote:`https://koboyo.com/icons`},{id:`emoji`,kind:`asset`},{id:`mood`,kind:`asset`},{id:`tech`,kind:`asset`,mono:!0},{id:`aws`,kind:`asset`},{id:`gcp`,kind:`asset`},{id:`azure`,kind:`asset`}],Ea=$.filter(e=>e.kind===`asset`).map(e=>e.id),Da=Object.fromEntries($.map(e=>[e.id,e.kind]));function Oa(e){return Da[e]===`asset`}var ka=new Set($.filter(e=>`mono`in e&&e.mono).map(e=>e.id));function Aa(e){return ka.has(e)}var ja=new Set($.filter(e=>`varyingExtent`in e&&e.varyingExtent).map(e=>e.id));function Ma(e){return ja.has(e)}var Na=new Map($.flatMap(e=>`remote`in e?[[e.id,e.remote]]:[]));function Pa(e){return Na.get(e)}var Fa={simple:`Frame`,phone:`Phone`,tablet:`Tablet`,browser:`Browser`,window:`Desktop window`,lanes:`Swimlanes`,vlanes:`Vertical swimlanes`,boundary:`Boundary`};function Ia(e){return e===`lanes`||e===`vlanes`}function La(e){return e===`vlanes`}var Ra={simple:{width:960,height:540},phone:{width:270,height:560},tablet:{width:400,height:540},browser:{width:560,height:400},window:{width:520,height:360},lanes:{width:760,height:420},vlanes:{width:720,height:460},boundary:{width:360,height:260}},za=[`Lane 1`,`Lane 2`,`Lane 3`],Ba=.7;function Va(e){return e&&e.length>0?e.length:za.length}function Ha(e,t){if(!t||t.length!==e||e===0)return Array.from({length:e},()=>1/e);let n=t.map(e=>Math.max(0,e)),r=n.reduce((e,t)=>e+t,0)||1;return n.map(e=>e/r)}function Ua(e,t,n){let r=Ha(e,n),i=[0],a=0;for(let e of r)a+=e*t,i.push(a);return i}var Wa=.06;function Ga(e,t,n){let r=[...e],i=r[t]+r[t+1],a=C(r[t]+n,Wa,i-Wa);return r[t]=a,r[t+1]=i-a,r}function Ka(e,t){let n=Math.min(t.width,t.height);return e===`phone`?Math.min(C(n*.13,10,44),t.width/2,t.height/2):e===`tablet`?Math.min(C(n*.07,8,26),t.width/2,t.height/2):e===`browser`||e===`window`?Math.min(8,t.width/2,t.height/2):10}function qa(e,t){let n=e.y+t/2;return[0,1,2].map(t=>r(e.x+15+t*13,n,3.5))}var Ja=18,Ya=12,Xa=14,Za=20,Qa=5,$a=18;function eo(e,t,n,i){let a=Ka(e,t),o=_(t.x,t.y,t.width,t.height,a),c=[];if(e===`phone`){let e=t.x+t.width/2;if(t.height>120&&t.width>80){let n=C(t.width*.16,24,56),r=t.y+Ja;c.push(s(e-n/2,r,e+n/2,r));let i=C(t.width*.3,40,110),a=t.y+t.height-Ya;c.push(s(e-i/2,a,e+i/2,a))}return{border:o,details:c}}if(e===`tablet`){let e=t.x+t.width/2;if(t.height>140&&t.width>100){c.push(r(e,t.y+Xa,2.5));let n=t.y+t.height-Za;c.push(r(e,n,Qa))}return{border:o,details:c}}if(e===`browser`||e===`window`){let n=e===`browser`?36:32;if(t.height>n*2.2&&t.width>70&&(c.push(s(t.x,t.y+n,t.x+t.width,t.y+n)),c.push(...qa(t,n)),e===`browser`&&t.width>200)){let e={x:t.x+56,y:t.y+(n-$a)/2,width:t.width-56-16,height:$a};c.push(_(e.x,e.y,e.width,e.height,$a/2))}return{border:o,details:c}}if(e===`lanes`||e===`vlanes`){let r=Va(n);if(e===`vlanes`){let e=Ua(r,t.width,i);for(let n=1;n<r;n+=1){let r=t.x+e[n];c.push(s(r,t.y,r,t.y+t.height))}return t.height>30*2.5&&c.push(s(t.x,t.y+30,t.x+t.width,t.y+30)),{border:o,details:c}}let a=Ua(r,t.height,i);for(let e=1;e<r;e+=1){let n=t.y+a[e];c.push(s(t.x,n,t.x+t.width,n))}return t.width>30*2.5&&c.push(s(t.x+30,t.y,t.x+30,t.y+t.height)),{border:o,details:c}}return{border:o,details:c}}export{Ti as $,Ut as $t,ba as A,Jn as At,Ji as B,$n as Bt,ha as C,xr as Ct,xa as D,Cr as Dt,pa as E,Sr as Et,ra as F,Mn as Ft,Hi as G,An as Gt,Ni as H,In as Ht,Gi as I,tr as It,Bi as J,Kn as Jt,Ui as K,Ln as Kt,Zi as L,er as Lt,ia as M,Un as Mt,$i as N,Hn as Nt,fa as O,Zn as Ot,na as P,qn as Pt,Ei as Q,wn as Qt,Xi as R,jn as Rt,ua as S,or as St,ya as T,yr as Tt,Ii as U,Vn as Ut,Yi as V,Pn as Vt,Li as W,Bn as Wt,Oi as X,Yn as Xt,Vi as Y,Gn as Yt,Di as Z,zn as Zt,wa as _,Ee as _n,zr as _t,eo as a,Jt as an,Zr as at,la as b,ge as bn,dr as bt,Ua as c,Lt as cn,Fr as ct,Ga as d,Mt as dn,ii as dt,Ht as en,ki as et,Ea as f,xe as fn,ri as ft,Pa as g,Te as gn,X as gt,Aa as h,w as hn,Ur as ht,Ba as i,Yt as in,ni as it,ea as j,Xn as jt,va as k,Nn as kt,Ha as l,Nt as ln,Lr as lt,Oa as m,be as mn,Hr as mt,Ra as n,Zt as nn,Or as nt,Ka as o,Qt as on,Jr as ot,Ma as p,ye as pn,Vr as pt,Fi as q,Wn as qt,Fa as r,Kt as rn,Qr as rt,Ia as s,$t as sn,Pr as st,za as t,Wt as tn,Ai as tt,La as u,Rt as un,ai as ut,ga as v,De as vn,Yr as vt,ma as w,br as wt,Ca as x,_e as xn,rr as xt,_a as y,ve as yn,Gr as yt,qi as z,Qn as zt};