koboyo 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/README.md +6 -1
  2. package/assets/editor/assets/DialogDescription-Ddhk2rmF.js +1 -0
  3. package/assets/editor/assets/DialogRoot-DUeVfNhS.js +1 -0
  4. package/assets/editor/assets/DialogTitle-D5au2NAn.js +1 -0
  5. package/assets/editor/assets/FloatingPortalLite-HnWQWrLk.js +1 -0
  6. package/assets/editor/assets/{IconAlertTriangle-CxPhYpe-.js → IconAlertTriangle-B33xznYN.js} +1 -1
  7. package/assets/editor/assets/{IconArrowLeft-DFk3Krim.js → IconArrowLeft-B4Zcy-Fc.js} +1 -1
  8. package/assets/editor/assets/IconChevronLeft-D7e7QC0h.js +1 -0
  9. package/assets/editor/assets/IconChevronRight-csfMBSUs.js +1 -0
  10. package/assets/editor/assets/{IconCode-hd05zxU4.js → IconCode-CHIz1nCU.js} +1 -1
  11. package/assets/editor/assets/IconCornerDownRight-DDiBMO4O.js +1 -0
  12. package/assets/editor/assets/{IconEraser-DlZQe3-r.js → IconEraser-CYfXj27R.js} +1 -1
  13. package/assets/editor/assets/{IconFocusCentered-C5PcDeR0.js → IconFocusCentered-Cn8rbfRI.js} +1 -1
  14. package/assets/editor/assets/IconHelp-CaEwHrsN.js +2 -0
  15. package/assets/editor/assets/IconLink-VS5p9Ytk.js +1 -0
  16. package/assets/editor/assets/IconLoader2-CzCTn-Sn.js +1 -0
  17. package/assets/editor/assets/IconMinus-BcaDLts8.js +1 -0
  18. package/assets/editor/assets/{IconMoodSmile-Bic_fw54.js → IconMoodSmile-CSZ5p_Hy.js} +1 -1
  19. package/assets/editor/assets/{IconPencil-C5Y-Y4dC.js → IconPencil-D_pQsAyv.js} +1 -1
  20. package/assets/editor/assets/{IconPhoto-CR36IK-b.js → IconPhoto-5zuCDtnR.js} +1 -1
  21. package/assets/editor/assets/{IconPlayerPlayFilled-D4OODBX7.js → IconPlayerPlayFilled-DVAWmYt7.js} +1 -1
  22. package/assets/editor/assets/{IconPlayerStopFilled-BUbX6ZO5.js → IconPlayerStopFilled-D4qdct2R.js} +1 -1
  23. package/assets/editor/assets/IconPlus-D4tAoi-A.js +1 -0
  24. package/assets/editor/assets/{IconPresentation-DCrY3PKL.js → IconPresentation-BMKzt7fv.js} +1 -1
  25. package/assets/editor/assets/{IconSearch-C1K0_Pq_.js → IconSearch-CCpMt02s.js} +1 -1
  26. package/assets/editor/assets/{IconSparkles-WDcg8BA9.js → IconSparkles-CnCp3BCQ.js} +1 -1
  27. package/assets/editor/assets/{IconTrash-DbN_RxB7.js → IconTrash-C8w6ThWx.js} +1 -1
  28. package/assets/editor/assets/{IconUsers-Bwnyj4mm.js → IconUsers-Dp85N225.js} +1 -1
  29. package/assets/editor/assets/IconX-KrRqxr2j.js +1 -0
  30. package/assets/editor/assets/MenuSubmenuTrigger-KacA9GM8.js +1 -0
  31. package/assets/editor/assets/PopoverPopup-B3Y0VRYc.js +1 -0
  32. package/assets/editor/assets/{asset-glyph-B3c--Mx2.js → asset-glyph-C1E6cGwM.js} +1 -1
  33. package/assets/editor/assets/billing-BSXr-z2r.js +1 -0
  34. package/assets/editor/assets/build-pips-BV-uwXlP.js +1 -0
  35. package/assets/editor/assets/build-visibility-DyML9SHt.js +1 -0
  36. package/assets/editor/assets/builders-DMHAOPEv.js +1 -0
  37. package/assets/editor/assets/{chart-Z4HQx-0h.js → chart-4iRduYdU.js} +4 -4
  38. package/assets/editor/assets/{chrome-layout-B8YmHznO.js → chrome-layout-BzPU9far.js} +1 -1
  39. package/assets/editor/assets/{code-panel-BfsykjSz.js → code-panel-koBUgEWp.js} +7 -7
  40. package/assets/editor/assets/command-palette-BR-_ChOL.js +1 -0
  41. package/assets/editor/assets/config-D8b1QyEk.js +1 -0
  42. package/assets/editor/assets/connector-labels-CrEgadsC.js +2 -0
  43. package/assets/editor/assets/copy-image-dialog-BzGP7Xw8.js +1 -0
  44. package/assets/editor/assets/{core-CBnmD9hT.js → core-CmsJyU_-.js} +1 -1
  45. package/assets/editor/assets/createReactComponent-C51FAx3B.js +1 -0
  46. package/assets/editor/assets/{diagram-fingerprint-CsqZK4xZ.js → diagram-fingerprint-WGQ5iVXx.js} +1 -1
  47. package/assets/editor/assets/dialog-DnXgEbpz.js +1 -0
  48. package/assets/editor/assets/{edit-BJ_kibk8.js → edit-C0sBxxsg.js} +1 -1
  49. package/assets/editor/assets/editor-BeufBV54.js +1 -0
  50. package/assets/editor/assets/{elk-api-DnfklSaw.js → elk-api-C4wlHVIw.js} +1 -1
  51. package/assets/editor/assets/{elk-worker-loader-CC-I9MmI.js → elk-worker-loader-CVBdN1je.js} +1 -1
  52. package/assets/editor/assets/{export-ChP0k5F5.js → export-Bce6ra0N.js} +1 -1
  53. package/assets/editor/assets/export-K2VWg76n.js +6 -0
  54. package/assets/editor/assets/export-dialog-x2n2a4KX.js +1 -0
  55. package/assets/editor/assets/flow-layer-ewaL7g2y.js +1 -0
  56. package/assets/editor/assets/flow-panel-BzXNGGke.js +1 -0
  57. package/assets/editor/assets/flow-stage-Ba_CAggI.js +1 -0
  58. package/assets/editor/assets/flow-start-CpAvU-9P.js +1 -0
  59. package/assets/editor/assets/{flows-GGbkNqs8.js → flows-Cj7AFMIA.js} +2 -2
  60. package/assets/editor/assets/frames-Cp1QD3LR.js +1 -0
  61. package/assets/editor/assets/icon-picker-Cg39IKNJ.js +1 -0
  62. package/assets/editor/assets/image-library-JQu_tb8P.js +1 -0
  63. package/assets/editor/assets/index-CBPPqsiR.js +24 -0
  64. package/assets/editor/assets/{index-CC2h28V_.css → index-DBrN0u0i.css} +1 -1
  65. package/assets/editor/assets/jsx-runtime-DKdBMi_L.js +1 -0
  66. package/assets/editor/assets/layout-offthread-mRHRulkS.js +18 -0
  67. package/assets/editor/assets/{layout.worker-BIE1_z0S.js → layout.worker-CekYkaxO.js} +2 -2
  68. package/assets/editor/assets/menu-B9BAk63v.js +1 -0
  69. package/assets/editor/assets/panel-controls-DWVXiNUZ.js +1 -0
  70. package/assets/editor/assets/{panel-shell-CG2aq4Ia.js → panel-shell-BnMOHgWM.js} +1 -1
  71. package/assets/editor/assets/{plan-jQm1jDpt.js → plan-CkgM52Yh.js} +1 -1
  72. package/assets/editor/assets/presentation-DJUO0t7I.js +1 -0
  73. package/assets/editor/assets/presenter-keys-Bs3LnmOa.js +1 -0
  74. package/assets/editor/assets/{jsx-runtime-2Zwg-L3c.js → react-lCSYwAWP.js} +1 -1
  75. package/assets/editor/assets/reflow-DaYiVkwp.js +1 -0
  76. package/assets/editor/assets/registry-rEGZW7Ab.js +1 -0
  77. package/assets/editor/assets/renderer-environment-D3n3hbug.js +1 -0
  78. package/assets/editor/assets/ride-overlay-Hx90v4ZK.js +1 -0
  79. package/assets/editor/assets/selection-overlay-primitives-BRp854AD.js +1 -0
  80. package/assets/editor/assets/shape-meta-COE2ATNh.js +1 -0
  81. package/assets/editor/assets/sign-in-dialog-tmQEB2bx.js +1 -0
  82. package/assets/editor/assets/slide-notes-dialog-BQBXpep6.js +1 -0
  83. package/assets/editor/assets/slides-D686obFO.js +15 -0
  84. package/assets/editor/assets/slides-panel-BEJCevJi.js +26 -0
  85. package/assets/editor/assets/text-breaks-DM4W6y5f.js +7 -0
  86. package/assets/editor/assets/{theme-palette-D1nbDFBC.js → theme-palette-Dl_G_VIJ.js} +1 -1
  87. package/assets/editor/assets/tidy-browser-dF3BON7J.js +1 -0
  88. package/assets/editor/assets/tidy-scope-BGG3ZXvZ.js +1 -0
  89. package/assets/editor/assets/toast-Czv_DJ-4.js +1 -0
  90. package/assets/editor/assets/tool-catalog-DXPhX2S1.js +1 -0
  91. package/assets/editor/assets/tool-drawer-CWOX_njp.js +1 -0
  92. package/assets/editor/assets/tooltip-CyBz17g8.js +1 -0
  93. package/assets/editor/assets/tree-KSgPjntC.js +1 -0
  94. package/assets/editor/assets/upgrade-dialog-DhSZnDpx.js +1 -0
  95. package/assets/editor/assets/use-drag-reorder-ye8-kpyR.js +1 -0
  96. package/assets/editor/assets/use-export-command-sC9UHj3_.js +2 -0
  97. package/assets/editor/assets/use-grid-keyboard-nav-DhQKecO1.js +0 -0
  98. package/assets/editor/assets/use-icon-node-BxqH7H27.js +1 -0
  99. package/assets/editor/assets/use-key-held-094C3Mn3.js +1 -0
  100. package/assets/editor/assets/use-recent-list-DuazDypH.js +1 -0
  101. package/assets/editor/assets/useAnchoredPopupScrollLock-i8D5Dm1d.js +1 -0
  102. package/assets/editor/assets/useBaseUiId-D2RfU0uY.js +1 -0
  103. package/assets/editor/assets/useButton-CLQYGhRJ.js +1 -0
  104. package/assets/editor/assets/useControlled-BE8zdmih.js +1 -0
  105. package/assets/editor/assets/usePositioner-AtbrPc7w.js +1 -0
  106. package/assets/editor/assets/useScrollLock-CQpr0n6U.js +1 -0
  107. package/assets/editor/assets/useValueChanged-SqLfIDi5.js +1 -0
  108. package/assets/editor/assets/web-controls-CLE9zr7i.js +1 -0
  109. package/assets/editor/assets/web-embed-dialog-XUNelFFM.js +1 -0
  110. package/assets/editor/assets/web-html-dialog-BcAyzH5D.js +1 -0
  111. package/assets/editor/assets/web-shape-C941TGTy.js +1 -0
  112. package/assets/editor/assets/widget-source-CHujvUeA.js +1 -0
  113. package/assets/editor/index.html +73 -69
  114. package/dist/koboyo.js +258 -214
  115. package/package.json +5 -5
  116. package/skills/koboyo/SKILL.md +22 -2
  117. package/skills/koboyo/references/architecture.md +1 -1
  118. package/skills/koboyo/references/bpmn.md +1 -1
  119. package/skills/koboyo/references/chart.md +1 -1
  120. package/skills/koboyo/references/cycle.md +1 -1
  121. package/skills/koboyo/references/erd.md +1 -1
  122. package/skills/koboyo/references/flowchart.md +1 -1
  123. package/skills/koboyo/references/funnel.md +1 -1
  124. package/skills/koboyo/references/gantt.md +1 -1
  125. package/skills/koboyo/references/gitgraph.md +1 -1
  126. package/skills/koboyo/references/journey.md +1 -1
  127. package/skills/koboyo/references/matrix.md +1 -1
  128. package/skills/koboyo/references/mindmap.md +1 -1
  129. package/skills/koboyo/references/orgchart.md +1 -1
  130. package/skills/koboyo/references/pyramid.md +1 -1
  131. package/skills/koboyo/references/sankey.md +1 -1
  132. package/skills/koboyo/references/sequence.md +1 -1
  133. package/skills/koboyo/references/statemachine.md +1 -1
  134. package/skills/koboyo/references/timeline.md +1 -1
  135. package/skills/koboyo/references/venn.md +1 -1
  136. package/skills/koboyo/references/wireframe.md +1 -1
  137. package/assets/editor/assets/DialogDescription-ZtZCUsfy.js +0 -1
  138. package/assets/editor/assets/DialogRoot-mHGRFW9m.js +0 -1
  139. package/assets/editor/assets/DialogTitle-CFhr-gP9.js +0 -1
  140. package/assets/editor/assets/FloatingPortalLite-Bf0q6fmL.js +0 -1
  141. package/assets/editor/assets/IconArrowBackUp-Brd2WpCh.js +0 -1
  142. package/assets/editor/assets/IconChevronLeft-BR0iwdRI.js +0 -1
  143. package/assets/editor/assets/IconChevronRight-DBDnxPYT.js +0 -1
  144. package/assets/editor/assets/IconHelp-DKNacRqS.js +0 -2
  145. package/assets/editor/assets/IconLoader2-BQaF1LKo.js +0 -1
  146. package/assets/editor/assets/IconMinus-y4ejub-s.js +0 -1
  147. package/assets/editor/assets/IconNote-CSELvWzx.js +0 -1
  148. package/assets/editor/assets/IconPlus-BbmieIBT.js +0 -1
  149. package/assets/editor/assets/IconX-AlbPkO_g.js +0 -1
  150. package/assets/editor/assets/MenuSubmenuTrigger-CpN67g09.js +0 -1
  151. package/assets/editor/assets/PopoverPopup-BqGWd_uB.js +0 -1
  152. package/assets/editor/assets/billing-C-BNGM3Z.js +0 -1
  153. package/assets/editor/assets/build-pips-CIaHaEPB.js +0 -1
  154. package/assets/editor/assets/build-visibility-E1mHeDCW.js +0 -1
  155. package/assets/editor/assets/builders-DbF28yId.js +0 -1
  156. package/assets/editor/assets/command-palette-BjFnQHnz.js +0 -1
  157. package/assets/editor/assets/config-a_lz-57R.js +0 -1
  158. package/assets/editor/assets/connector-labels-vVnYQJRz.js +0 -2
  159. package/assets/editor/assets/copy-image-dialog-CCY_6fM4.js +0 -1
  160. package/assets/editor/assets/createReactComponent-9UsI5fmM.js +0 -1
  161. package/assets/editor/assets/dialog-B32krrce.js +0 -1
  162. package/assets/editor/assets/editor-B0tARd79.js +0 -1
  163. package/assets/editor/assets/export-DEFKKRRi.js +0 -6
  164. package/assets/editor/assets/export-dialog-DPg1uzX5.js +0 -1
  165. package/assets/editor/assets/flow-layer-BC35drcK.js +0 -1
  166. package/assets/editor/assets/flow-panel-D_K9wgZi.js +0 -1
  167. package/assets/editor/assets/flow-stage-fiF5Nggn.js +0 -1
  168. package/assets/editor/assets/flow-start-ccYJ2KB9.js +0 -1
  169. package/assets/editor/assets/frames-CRP8oPP8.js +0 -1
  170. package/assets/editor/assets/icon-picker-NboB5Fvv.js +0 -1
  171. package/assets/editor/assets/image-library-Bb6bV6eK.js +0 -1
  172. package/assets/editor/assets/index-DfNbwHl_.js +0 -24
  173. package/assets/editor/assets/layout-offthread-BwetpTFH.js +0 -18
  174. package/assets/editor/assets/menu-BPrc8Ara.js +0 -1
  175. package/assets/editor/assets/panel-controls-DYZ7QFT5.js +0 -1
  176. package/assets/editor/assets/presentation-BavfNtxp.js +0 -1
  177. package/assets/editor/assets/presenter-keys-DVQcBdy1.js +0 -1
  178. package/assets/editor/assets/reflow-Cv75wPSh.js +0 -1
  179. package/assets/editor/assets/registry-DCgwH8wI.js +0 -1
  180. package/assets/editor/assets/renderer-environment-DmWXvuT4.js +0 -1
  181. package/assets/editor/assets/ride-overlay-DhygYdx1.js +0 -1
  182. package/assets/editor/assets/selection-overlay-primitives-hWJ1xjF7.js +0 -1
  183. package/assets/editor/assets/shape-meta-BpwsiB82.js +0 -1
  184. package/assets/editor/assets/sign-in-dialog-DRooo5xw.js +0 -1
  185. package/assets/editor/assets/slide-notes-dialog-DLdTmd7_.js +0 -1
  186. package/assets/editor/assets/slides-D9bnXqtf.js +0 -15
  187. package/assets/editor/assets/slides-panel-DV-zQJhV.js +0 -26
  188. package/assets/editor/assets/text-breaks-YU-ymaF9.js +0 -7
  189. package/assets/editor/assets/tidy-browser-BwodBnAH.js +0 -1
  190. package/assets/editor/assets/tidy-scope-BgBSUklT.js +0 -1
  191. package/assets/editor/assets/toast-Nu_fiCd9.js +0 -1
  192. package/assets/editor/assets/tool-catalog-ChSwaLIq.js +0 -1
  193. package/assets/editor/assets/tool-drawer-CG7-cnML.js +0 -1
  194. package/assets/editor/assets/tooltip-DgEojto1.js +0 -1
  195. package/assets/editor/assets/tree-rq4RTGgw.js +0 -1
  196. package/assets/editor/assets/upgrade-dialog-DpZeaLDB.js +0 -1
  197. package/assets/editor/assets/use-drag-reorder-C3h4ZMoZ.js +0 -1
  198. package/assets/editor/assets/use-export-command-CPc7qug1.js +0 -2
  199. package/assets/editor/assets/use-grid-keyboard-nav-B88Qw-cQ.js +0 -0
  200. package/assets/editor/assets/use-icon-node-DJZFjABX.js +0 -1
  201. package/assets/editor/assets/use-recent-list-BEG0iBIm.js +0 -1
  202. package/assets/editor/assets/useAnchoredPopupScrollLock-BGKchwpi.js +0 -1
  203. package/assets/editor/assets/useBaseUiId-C0Zm5sUV.js +0 -1
  204. package/assets/editor/assets/useButton-D3eS7fh5.js +0 -1
  205. package/assets/editor/assets/useControlled-C5xhvPXX.js +0 -1
  206. package/assets/editor/assets/usePositioner-DA3aR0-T.js +0 -1
  207. package/assets/editor/assets/useScrollLock-B7mQdXyv.js +0 -1
  208. package/assets/editor/assets/useValueChanged-p8z-93L4.js +0 -1
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./react-lCSYwAWP.js";import{A as n,B as r,C as i,F as a,H as o,I as s,L as c,M as l,N as u,O as d,P as f,R as ee,V as te,j as ne,k as re,t as ie,u as ae,x as oe,z as se}from"./reflow-DaYiVkwp.js";import{A as ce,At as le,D as ue,O as de,T as fe,Y as pe,fi as me,i as he,j as ge,q as _e,ui as ve,x as ye}from"./slides-D686obFO.js";import{G as be,h as xe}from"./style-BENGW2ZV.js";var p=e(t(),1),Se=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},Ce=(e=>e?Se(e):Se),we=e=>e;function Te(e,t=we){let n=p.useSyncExternalStore(e.subscribe,p.useCallback(()=>t(e.getState()),[e,t]),p.useCallback(()=>t(e.getInitialState()),[e,t]));return p.useDebugValue(n),n}var Ee=(e,t,n)=>(r,i)=>({pastStates:n?.pastStates||[],futureStates:n?.futureStates||[],undo:(a=1)=>{if(i().pastStates.length){let o=n?.partialize?.(t())||t(),s=i().pastStates.splice(-a,a),c=s.shift();e(c),r({pastStates:i().pastStates,futureStates:i().futureStates.concat(n?.diff?.(o,c)||o,s.reverse())})}},redo:(a=1)=>{if(i().futureStates.length){let o=n?.partialize?.(t())||t(),s=i().futureStates.splice(-a,a),c=s.shift();e(c),r({pastStates:i().pastStates.concat(n?.diff?.(o,c)||o,s.reverse()),futureStates:i().futureStates})}},clear:()=>r({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>r({isTracking:!1}),resume:()=>r({isTracking:!0}),setOnSave:e=>r({_onSave:e}),_onSave:n?.onSave,_handleSet:(e,t,a,o)=>{n?.limit&&i().pastStates.length>=n?.limit&&i().pastStates.shift(),i()._onSave?.(e,a),r({pastStates:i().pastStates.concat(o||e),futureStates:[]})}}),De=(e,t)=>(n,r,i)=>{i.temporal=Ce(t?.wrapTemporal?.(Ee(n,r,t))||Ee(n,r,t));let a=t?.handleSet?.(i.temporal.getState()._handleSet)||i.temporal.getState()._handleSet,o=e=>{if(!i.temporal.getState().isTracking)return;let n=t?.partialize?.(r())||r(),o=t?.diff?.(e,n);o===null||t?.equality?.(e,n)||a(e,void 0,n,o)},s=i.setState;return i.setState=(...e)=>{let n=t?.partialize?.(r())||r();s(...e),o(n)},e((...e)=>{let i=t?.partialize?.(r())||r();n(...e),o(i)},r,i)},Oe=100,m=1e6;function ke(e){for(let t=0;t<e.length;t+=1){let n=e.charCodeAt(t);if(n===0)return!1;if(n>=55296&&n<=56319){let n=e.charCodeAt(t+1);if(!(n>=56320&&n<=57343))return!1;t+=1}else if(n>=56320&&n<=57343)return!1}return!0}function Ae(e){if(ke(e))return e;let t=``;for(let n=0;n<e.length;n+=1){let r=e.charCodeAt(n);if(r!==0){if(r>=55296&&r<=56319){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=e.slice(n,n+2),n+=1):t+=`�`;continue}t+=r>=56320&&r<=57343?`�`:e[n]}}return t}function je(e,t,n){if(n.values+=1,n.values>m)return`complexity`;if(typeof e==`string`)return ke(e)?null:`text`;if(e===null||typeof e==`boolean`)return null;if(typeof e==`number`)return Number.isFinite(e)?null:`number`;if(typeof e!=`object`)return`value`;if(t>Oe)return`depth`;if(n.ancestors.has(e))return`cycle`;n.ancestors.add(e);try{if(Array.isArray(e)){if(e.length>m-n.values)return`complexity`;for(let t of Reflect.ownKeys(e))if(t!==`length`&&(typeof t!=`string`||!/^(0|[1-9]\d*)$/.test(t)||Number(t)>=e.length))return`array-property`;for(let r=0;r<e.length;r+=1){let i=Object.getOwnPropertyDescriptor(e,String(r));if(!i||!(`value`in i))return`array-entry`;let a=je(i.value,t+1,n);if(a)return a}return null}let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return`object`;let i=Reflect.ownKeys(e);if(i.length>m-n.values)return`complexity`;for(let r of i){if(typeof r!=`string`||!ke(r))return`object-key`;let i=Object.getOwnPropertyDescriptor(e,r);if(!i?.enumerable||!(`value`in i))return`object-property`;if(i.value===void 0)continue;let a=je(i.value,t+1,n);if(a)return a}return null}catch{return`unreadable`}finally{n.ancestors.delete(e)}}function Me(e){return je(e,0,{ancestors:new Set,values:0})}var Ne={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function Pe(e){return e.replace(/[&<>"']/g,e=>Ne[e])}function h(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Fe=new Set(s),g=new Set(d),_=new Set(l),Ie=new Set(u),Le=new Set(ne),Re=new Set(se),ze=new Set(r),Be=new Set(re),Ve=new Set(n),He=new Set(c),Ue=new Set(a),We=new Set(ee),Ge=new Set(f),Ke=new Set(te),qe={modal:!0,entity:!0,lifeline:!0,fragment:!0},Je=new Set([...o,...Object.keys(qe)]),Ye=new Set([`hanging`,`inside`]),Xe=new Set([`x`,`y`]),Ze=256;function v(){return{issues:[],capped:!1,unknownEnum:0}}function y(e,t,n,r=!1){if(e.issues.length<100){e.issues.push({path:t,message:n}),r&&(e.unknownEnum+=1);return}e.capped=!0}var Qe={complexity:`document is too complex to persist`,text:`document contains unsupported text`,number:`document contains an unsupported number`,value:`document contains an unsupported value`,depth:`document is nested too deeply to persist`,cycle:`document contains a circular reference`,"array-property":`document contains a non-JSON array property`,"array-entry":`document contains a non-JSON array entry`,object:`document contains a non-JSON object`,"object-key":`document contains an unsupported object key`,"object-property":`document contains a non-JSON object property`,unreadable:`document contains an unreadable value`};function b(e,t,n){return typeof n==`number`&&Number.isFinite(n)?!0:(y(e,t,`expected a finite number`),!1)}function x(e,t,n){return typeof n==`string`?!0:(y(e,t,`expected a string`),!1)}function S(e,t,n){return typeof n==`boolean`?!0:(y(e,t,`expected a boolean`),!1)}function C(e,t,n,r){return typeof n==`string`?!r&&n.length===0?(y(e,t,`id must not be empty`),!1):n.length>Ze?(y(e,t,`id is too long`),!1):!0:(y(e,t,`expected a string id`),!1)}function w(e,t,n,r){return typeof n==`string`&&r.has(n)?!0:(y(e,t,`not an allowed value`,typeof n==`string`),!1)}function T(e,t,n){return typeof n==`number`&&Number.isFinite(n)&&n>=0&&n<=1?!0:(y(e,t,`expected a number in 0..1`),!1)}function $e(e,t,n){return typeof n==`number`&&Number.isFinite(n)&&n>=-.2&&n<=1.2?!0:(y(e,t,`expected a number in -0.2..1.2`),!1)}function et(e,t,n){if(!h(n))return y(e,t,`expected a point`),!1;let r=b(e,`${t}.x`,n.x),i=b(e,`${t}.y`,n.y);return r&&i}function tt(e,t,n){if(!Array.isArray(n))return y(e,t,`expected an array of points`),!1;let r=!0;for(let i=0;i<n.length&&!e.capped;i+=1)et(e,`${t}[${i}]`,n[i])||(r=!1);return r}function E(e,t,n,r){t[r]!==void 0&&b(e,`${n}.${r}`,t[r])}function D(e,t,n,r){t[r]!==void 0&&x(e,`${n}.${r}`,t[r])}function O(e,t,n,r){t[r]!==void 0&&S(e,`${n}.${r}`,t[r])}function nt(e,t,n,r,i){t[r]!==void 0&&w(e,`${n}.${r}`,t[r],i)}function rt(e,t,n){C(e,`${t}.id`,n.id,!1),n.groupId!==void 0&&C(e,`${t}.groupId`,n.groupId,!0),n.lockId!==void 0&&C(e,`${t}.lockId`,n.lockId,!0),O(e,n,t,`locked`),it(e,t,n.animations)}function it(e,t,n){if(n!==void 0){if(!Array.isArray(n)){y(e,`${t}.animations`,`expected an array`);return}n.forEach((n,r)=>{at(e,`${t}.animations[${r}]`,n)})}}function at(e,t,n){if(!h(n)){y(e,t,`expected an object`);return}b(e,`${t}.step`,n.step),x(e,`${t}.kind`,n.kind),x(e,`${t}.effect`,n.effect),D(e,n,t,`direction`),E(e,n,t,`duration`),E(e,n,t,`delay`),O(e,n,t,`afterPrevious`)}function ot(e,t,n){if(n!==null){if(!h(n)){y(e,t,`expected a binding or null`);return}if(n.kind===`path`){C(e,`${t}.shapeId`,n.shapeId,!0),(typeof n.seg!=`number`||!Number.isInteger(n.seg)||n.seg<0)&&y(e,`${t}.seg`,`expected a nonnegative integer segment`),T(e,`${t}.t`,n.t);return}if(C(e,`${t}.shapeId`,n.shapeId,!0),et(e,`${t}.anchor`,n.anchor)){let r=n.anchor;$e(e,`${t}.anchor.x`,r.x),$e(e,`${t}.anchor.y`,r.y)}S(e,`${t}.precise`,n.precise),nt(e,n,t,`port`,We)}}function st(e,t,n,r){if(n!==void 0){if(!h(n)){y(e,`${t}.titleIcon`,`expected an object`);return}x(e,`${t}.titleIcon.source`,n.source),x(e,`${t}.titleIcon.name`,n.name),r&&nt(e,n,`${t}.titleIcon`,`placement`,Ye)}}function ct(e,t,n){if(n===void 0)return;if(typeof n!=`object`||!n){y(e,t,`expected an object`);return}let r=n;x(e,`${t}.from`,r.from),x(e,`${t}.to`,r.to);for(let n of[`fromTop`,`fromSpan`,`toTop`,`toSpan`])b(e,`${t}.${n}`,r[n])}function lt(e,t,n){if(!h(n)){y(e,t,`expected a crop rectangle`);return}let r=T(e,`${t}.x`,n.x),i=T(e,`${t}.y`,n.y),a=T(e,`${t}.width`,n.width),o=T(e,`${t}.height`,n.height);r&&a&&n.x+n.width>1.000001&&y(e,t,`crop extends past the source width`),i&&o&&n.y+n.height>1.000001&&y(e,t,`crop extends past the source height`)}function k(e,t,n){if(n!==void 0){if(!Array.isArray(n)){y(e,t,`expected an array of strings`);return}for(let r=0;r<n.length&&!e.capped;r+=1)x(e,`${t}[${r}]`,n[r])}}function ut(e,t,n){if(n!==void 0){if(!Array.isArray(n)){y(e,t,`expected an array of numbers`);return}for(let r=0;r<n.length&&!e.capped;r+=1)b(e,`${t}[${r}]`,n[r])}}function dt(e,t,n){let r=n.cells,i=n.colWidths,a=n.rowHeights,o=ft(e,`${t}.colWidths`,i);ft(e,`${t}.rowHeights`,a);let s=o&&Array.isArray(i)?i.length:null;if(!Array.isArray(r)){y(e,`${t}.cells`,`expected a grid of rows`);return}Array.isArray(a)&&a.length!==r.length&&y(e,`${t}.rowHeights`,`must have one entry per row`);for(let n=0;n<r.length&&!e.capped;n+=1){let i=r[n];if(!Array.isArray(i)){y(e,`${t}.cells[${n}]`,`expected a row of cells`);continue}s!==null&&i.length!==s&&y(e,`${t}.cells[${n}]`,`row width does not match colWidths`);for(let r=0;r<i.length;r+=1)x(e,`${t}.cells[${n}][${r}]`,i[r])}pt(e,`${t}.cellStyles`,n.cellStyles,r)}function ft(e,t,n){if(!Array.isArray(n))return y(e,t,`expected an array of numbers`),!1;let r=!0;for(let i=0;i<n.length&&!e.capped;i+=1)b(e,`${t}[${i}]`,n[i])||(r=!1);return r}function pt(e,t,n,r){if(n!==void 0){if(!Array.isArray(n)){y(e,t,`expected a grid of cell styles`);return}n.length!==r.length&&y(e,t,`must mirror the cells grid`);for(let i=0;i<n.length&&!e.capped;i+=1){let a=n[i];if(!Array.isArray(a)){y(e,`${t}[${i}]`,`expected a row of cell styles`);continue}let o=r[i];Array.isArray(o)&&a.length!==o.length&&y(e,`${t}[${i}]`,`row width does not match the cells row`);for(let n=0;n<a.length;n+=1)mt(e,`${t}[${i}][${n}]`,a[n])}}}function mt(e,t,n){if(!h(n)){y(e,t,`expected a cell style object`);return}D(e,n,t,`fontFamily`),E(e,n,t,`fontSize`),D(e,n,t,`background`)}function ht(e,t,n){if(!Array.isArray(n)){y(e,t,`expected a grid of rows`);return}for(let r=0;r<n.length&&!e.capped;r+=1){let i=n[r];if(!Array.isArray(i)){y(e,`${t}[${r}]`,`expected a row`);continue}for(let n=0;n<i.length;n+=1)x(e,`${t}[${r}][${n}]`,i[n])}}function gt(e,t,n){if(n!==void 0){if(!Array.isArray(n)){y(e,t,`expected an array`);return}for(let r=0;r<n.length&&!e.capped;r+=1){let i=n[r];i==null||typeof i==`string`||y(e,`${t}[${r}]`,`expected a string or null`)}}}function _t(e,t,n){if(n!==void 0){if(!Array.isArray(n)){y(e,t,`expected an array of flows`);return}n.forEach((n,r)=>{let i=`${t}[${r}]`;if(!h(n)){y(e,i,`expected a flow`);return}if(C(e,`${i}.id`,n.id,!1),x(e,`${i}.name`,n.name),!Array.isArray(n.steps)){y(e,`${i}.steps`,`expected an array of steps`);return}n.steps.forEach((t,n)=>{let r=`${i}.steps[${n}]`;if(!h(t)){y(e,r,`expected a step`);return}C(e,`${r}.target`,t.target,!1),x(e,`${r}.title`,t.title),D(e,t,r,`text`),k(e,`${r}.also`,t.also),nt(e,t,r,`kind`,Ge),D(e,t,r,`payload`),k(e,`${r}.branches`,t.branches),O(e,t,r,`fails`)})})}}function vt(e,t,n){if(!Array.isArray(n)){y(e,t,`expected an array of activation bars`);return}for(let r=0;r<n.length&&!e.capped;r+=1){let i=n[r];if(!h(i)){y(e,`${t}[${r}]`,`expected an activation bar`);continue}b(e,`${t}[${r}].top`,i.top),b(e,`${t}[${r}].height`,i.height)}}function A(e){return(t,n,r,i)=>{e(t,`${n}.${i}`,r[i])}}function j(e){return(t,n,r,i)=>{r[i]!==void 0&&e(t,n,r,i)}}function M(e){return A((t,n,r)=>w(t,n,r,e))}function yt(e){return(t,n,r)=>{st(t,n,r.titleIcon,e)}}var N=A(b),P=A(x),F=A(S),I=A(tt),L=j(N),R=j(P),z=j(F),B=j(A(T)),bt=j(I),xt=(e,t,n,r)=>{if(n[r]===void 0){y(e,`${t}.${r}`,`expected a binding or null`);return}ot(e,`${t}.${r}`,n[r])},V=()=>{},St={kind:M(Fe),x:N,y:N,width:N,height:N,rotation:N,label:P,fontSize:N,fontFamily:P,color:P,fill:P,strokeWidth:N,dash:M(_),opacity:N,textAlign:j(M(Re)),textVAlign:j(M(ze)),textPadding:L,lineHeight:L,letterSpacing:L,labelColor:R,stroke:R,fillStyle:j(M(Ie)),corner:j(M(Le)),flipX:z,flipY:z,shadow:z,minHeight:L,autoHeightFrom:L,link:R,titleIcon:yt(!0)},Ct={x:N,y:N,x2:N,y2:N,bend:N,bendAlong:N,startBend:L,endBend:L,bendStyle:M(Be),color:P,strokeWidth:N,dash:M(_),startArrow:F,endArrow:F,opacity:N,startBinding:xt,endBinding:xt,bow:L,bowAlong:L,elbowMid:B,labelAlong:B,elbowPoints:bt,elbowRoute:bt,elbowMidHandle:j(A((e,t,n)=>{if(!h(n)){y(e,t,`expected an object`);return}b(e,`${t}.x`,n.x),b(e,`${t}.y`,n.y),w(e,`${t}.axis`,n.axis,Xe),b(e,`${t}.span`,n.span)})),label:R,startLabel:R,endLabel:R,fontSize:L,fontFamily:R,startHead:j(M(g)),endHead:j(M(g)),flow:z},wt={x:N,y:N,text:P,fontSize:N,fontFamily:P,rotation:N,color:P,opacity:N,width:L,height:L,textAlign:j(M(Re)),textVAlign:j(M(ze)),lineHeight:L,letterSpacing:L,flipX:z,flipY:z},Tt={x:N,y:N,width:N,height:N,rotation:N,text:P,fontSize:N,fontFamily:P,fill:P,opacity:N,lineHeight:L,letterSpacing:L},Et={points:I,color:P,strokeWidth:N,opacity:N,highlighter:z},Dt={points:I,fill:P,color:P,strokeWidth:N,opacity:N,smooth:z,band:A(ct)},Ot={points:I,color:P,strokeWidth:N,dash:M(_),startArrow:F,endArrow:F,opacity:N,startHead:j(M(g)),endHead:j(M(g)),flow:z,label:R,labelAlong:B,fontSize:L,fontFamily:R},kt={x:N,y:N,width:N,height:N,rotation:N,src:P,opacity:N,corner:j(M(Le)),flipX:z,flipY:z,crop:A(lt)},At={x:N,y:N,width:N,height:N,rotation:N,source:P,name:P,label:P,fontSize:N,fontFamily:P,color:P,strokeWidth:N,flipX:z,flipY:z,opacity:N},jt={x:N,y:N,width:N,height:N,rotation:N,label:P,fontSize:N,fontFamily:P,color:P,opacity:N,kind:j(M(Ue)),lanes:A(k),laneSizes:A(ut),slideOrder:L,slideSkipped:z,notes:R,flows:A(_t),slideLayout:R,fill:R,strokeWidth:L,dash:j(M(_)),code:R,codeFingerprint:R,titleIcon:yt(!1)},Mt={x:N,y:N,rotation:N,fontSize:N,fontFamily:P,color:P,opacity:N,background:R,colWidths:dt,rowHeights:V,cells:V,cellStyles:V},Nt={chartType:M(Ve),x:N,y:N,width:N,height:N,rotation:N,fontSize:N,fontFamily:P,color:P,opacity:N,cells:A(ht),horizontal:z,stacked:z,showLegend:z,showValues:z,showTitles:z,numberFormat:j(M(He)),seriesColors:A(gt),quadrantColors:A(gt),quadrantLabels:A(k),title:R,xTitle:R,yTitle:R,code:R,codeFingerprint:R},Pt={kind:M(Je),x:N,y:N,width:N,height:N,rotation:N,label:P,fontSize:N,fontFamily:P,color:P,opacity:N,body:R,primaryLabel:R,secondaryLabel:R,link:R,fill:R,value:L,widthManual:z,activations:j(A(vt))},Ft=500,It={rectangle:St,arrow:Ct,text:wt,sticky:Tt,draw:Et,polygon:Dt,line:Ot,image:kt,icon:At,figure:jt,table:Mt,chart:Nt,control:Pt,web:{kind:(e,t,n,r)=>{w(e,`${t}.${r}`,n[r],Ke)&&(n.kind===`embed`&&n.url===void 0&&y(e,`${t}.url`,`an embed needs a url`),n.kind===`html`&&n.html===void 0&&n.htmlSrc===void 0&&y(e,`${t}.html`,`an html widget needs html or htmlSrc`))},x:N,y:N,width:N,height:N,rotation:N,label:A((e,t,n)=>{x(e,t,n)&&n.length>Ft&&y(e,t,`label is too long`)}),url:j(A((e,t,n)=>{x(e,t,n)&&!me(n)&&y(e,t,`expected an https url without credentials, at most ${ve} characters`)})),html:j(A((e,t,n)=>{x(e,t,n)&&i(n)>131072&&y(e,t,`html is too large`)})),htmlSrc:j(A((e,t,n)=>{x(e,t,n)&&!oe(n)&&y(e,t,`expected an https url`)})),poster:R,posterOf:R,keepAspect:z,opacity:N}};function Lt(e,t,n,r){for(let i of Object.keys(r))r[i](e,t,n,i)}function Rt(e,t,n,r){let i=n.type,a=typeof i==`string`?It[i]:void 0;if(!r)return rt(e,t,n),a?(Lt(e,t,n,a),`understood`):(y(e,`${t}.type`,`unknown shape type`),`understood`);let o=v();return rt(o,t,n),a&&Lt(o,t,n,a),a?o.issues.length===0?`understood`:o.issues.length===o.unknownEnum?`unknown`:`damaged`:typeof i==`string`&&o.issues.length===0?`unknown`:`damaged`}function zt(e,t,n,r,i){Bt(e,`${t}.startBinding`,n,n.startBinding,r,i),Bt(e,`${t}.endBinding`,n,n.endBinding,r,i)}function Bt(e,t,n,r,i,a){if(!h(r))return;let o=r.shapeId;if(typeof o!=`string`)return;if(o===n.id){y(e,`${t}.shapeId`,`binding targets its own arrow`);return}let s=i.get(o);if(!s){y(e,`${t}.shapeId`,`binding target does not exist`);return}if(!a.has(o)){if(r.kind===`path`){if(s.type!==`line`&&s.type!==`arrow`){y(e,`${t}.shapeId`,`path binding must target a line or arrow`);return}let n=(s.type===`line`&&Array.isArray(s.points)?s.points.length:2)-2;typeof r.seg==`number`&&(r.seg<0||r.seg>n)&&y(e,`${t}.seg`,`path segment does not exist on the target`);return}s.type===`arrow`&&y(e,`${t}.shapeId`,`node binding cannot target an arrow`)}}var Vt=1e4;function Ht(e){try{if(!h(e))return!1;let t=v();return Rt(t,`shape`,e,!1),t.issues.length===0&&Me(e)===null}catch{return!1}}function Ut(e,t){return Gt(e,!0,t)}function Wt(e,t){return Gt(e,!1,t)}function Gt(e,t,n){try{return Kt(e,t,n?.unknownShapes===`preserve`)}catch{return{status:`invalid`,issues:[{path:``,message:`could not be validated`}]}}}function Kt(e,t,n){if(!h(e))return{status:`invalid`,issues:[{path:``,message:`expected an object`}]};let r=e.version;if(r!==1)return typeof r==`number`&&Number.isFinite(r)?{status:`unsupported-version`,version:r}:{status:`invalid`,issues:[{path:`version`,message:`unsupported version`}]};let i=e.shapes;if(!Array.isArray(i))return{status:`invalid`,issues:[{path:`shapes`,message:`expected an array`}]};if(i.length>1e4)return{status:`invalid`,issues:[{path:`shapes`,message:`too many shapes`}]};let a=v(),o=new Map,s=new Set,c=new Map,l=new Set;for(let e=0;e<i.length;e+=1){if(a.issues.length>=100){a.capped=!0;break}let t=i[e],r=`shapes[${e}]`;if(!h(t)){y(a,r,`expected a shape object`);continue}typeof t.id==`string`&&(s.has(t.id)?y(a,`${r}.id`,`duplicate shape id`):(s.add(t.id),o.set(t.id,t)));let u=Rt(a,r,t,n);if(u===`understood`||!C(a,`${r}.id`,t.id,!1))continue;if(u===`unknown`&&JSON.stringify(t).length>1048576){y(a,r,`unrecognized shape is too large to preserve`);continue}let d=t.id;c.set(e,{index:e,id:d,shape:t,reason:u}),l.add(d)}for(let e=0;e<i.length;e+=1){if(a.issues.length>=100){a.capped=!0;break}let t=i[e];if(!h(t)||t.type!==`arrow`||c.has(e))continue;let r=`shapes[${e}]`;if(!n){zt(a,r,t,o,l);continue}let s=v();if(zt(s,r,t,o,l),s.issues.length===0||!C(a,`${r}.id`,t.id,!1))continue;let u=t.id;c.set(e,{index:e,id:u,shape:t,reason:`damaged`}),l.add(u)}if(a.issues.length>0)return{status:`invalid`,issues:a.issues};if(t){let t=Me(e);if(t)return y(a,``,Qe[t]),{status:`invalid`,issues:a.issues}}return c.size===0?{status:`valid`,document:e,opaque:[]}:{status:`valid`,document:{...e,shapes:i.filter((e,t)=>!c.has(t))},opaque:[...c.values()].sort((e,t)=>e.index-t.index)}}function H(e){return JSON.stringify(e,(e,t)=>{if(typeof t!=`object`||!t||Array.isArray(t))return t;let n=t;return Object.fromEntries(Object.keys(n).sort().map(e=>[e,n[e]]))})}function qt(e,t,n){let{shapes:r,conflicts:i}=Yt(e.shapes,t.shapes,n.shapes);return{document:{version:1,shapes:r},conflicts:i}}function Jt(e,t,n){let r=new Map(e.shapes.map(e=>[e.id,H(e)])),i=new Map(t.shapes.map(e=>[e.id,H(e)])),a=0;for(let e of n.shapes){let t=i.get(e.id);t!==r.get(e.id)&&H(e)!==t&&(a+=1)}return a}function Yt(e,t,n){let r=e=>H(e),i=new Map(e.map(e=>[e.id,r(e)])),a=new Map(t.map(e=>[e.id,e])),o=new Set(n.map(e=>e.id)),s=0,c=[],l=new Set;for(let e of n){let t=e.id,n=i.get(t),o=a.get(t);if(l.add(t),n===void 0){o&&r(o)!==r(e)?(s+=1,c.push(o)):c.push(e);continue}if(!o){r(e)!==n&&(s+=1,c.push(e));continue}let u=r(o)!==n,d=r(e)!==n;u&&d&&r(o)!==r(e)?(s+=1,c.push(o)):u?c.push(o):c.push(e)}for(let[e,t]of i){if(o.has(e)||l.has(e))continue;let n=a.get(e);l.add(e),n&&r(n)!==t&&(s+=1,c.push(n))}for(let e of t)l.has(e.id)||c.push(e);return{shapes:c,conflicts:s}}function Xt(e,t){if(t===null)return 0;let n=e.length-1;if(n>=0&&e[n].id===t)return e.length;let r=e.findIndex(e=>e.id===t);return r===-1?e.length:r+1}var Zt=16;function Qt(e,t){return e.findIndex(e=>e.id===t)}function U(e,t){let n=[...e],r=null,i=e=>{if(t.length<Zt)return Qt(n,e);if(r===null){r=new Map;for(let e=0;e<n.length;e+=1)r.has(n[e].id)||r.set(n[e].id,e)}return r.get(e)??-1};for(let e of t){if(e.o===`put`){let t=i(e.shape.id);if(t!==-1){n[t]=e.shape;continue}n.splice(Xt(n,e.after),0,e.shape),r=null;continue}if(e.o===`set`){let t=i(e.id);if(t===-1)continue;let r={...n[t],...e.props,id:e.id};for(let t of e.unset??[])t!==`id`&&delete r[t];n[t]=r;continue}if(e.o===`del`){let t=i(e.id);t!==-1&&(n.splice(t,1),r=null);continue}let t=i(e.id);if(t===-1||e.after===e.id)continue;let[a]=n.splice(t,1);n.splice(Xt(n,e.after),0,a),r=null}return n}function $t(e,t){return e===t?!0:typeof e!=`object`||typeof t!=`object`||e===null||t===null?!1:H(e)===H(t)}function en(e){let t=[],n=Array(e.length).fill(-1);for(let r=0;r<e.length;r+=1){let i=0,a=t.length;for(;i<a;){let n=i+a>>1;e[t[n]]<e[r]?i=n+1:a=n}i>0&&(n[r]=t[i-1]),t[i]=r}let r=new Set,i=t.length>0?t[t.length-1]:-1;for(;i!==-1;)r.add(i),i=n[i];return r}function tn(e,t){let n=[],r=new Map,i=new Map;e.forEach((e,t)=>{r.set(e.id,e),i.set(e.id,t)});let a=new Set(t.map(e=>e.id));for(let t of e)a.has(t.id)||n.push({o:`del`,id:t.id});let o=[],s=[];t.forEach((e,t)=>{let n=i.get(e.id);n!==void 0&&(o.push(n),s.push(t))});let c=en(o),l=new Set;return s.forEach((e,t)=>{c.has(t)||l.add(e)}),t.forEach((e,i)=>{let a=i===0?null:t[i-1].id,o=r.get(e.id);if(!o){n.push({o:`put`,shape:e,after:a});return}if(l.has(i)&&n.push({o:`move`,id:e.id,after:a}),o===e)return;let s=o,c=e,u={},d=!1;for(let e of Object.keys(c))c[e]!==void 0&&($t(s[e],c[e])||(u[e]=c[e],d=!0));let f=Object.keys(s).filter(e=>s[e]!==void 0&&c[e]===void 0);!d&&f.length===0||n.push(f.length>0?{o:`set`,id:e.id,props:u,unset:f}:{o:`set`,id:e.id,props:u})}),n}var W=Vt,nn=8e3;function rn(e,t){return e+t>W?{kind:`block`,message:`That would put this canvas past ${W.toLocaleString()} shapes, so nothing was added. Split the work across canvases instead.`}:e<=8e3&&e+t>8e3?{kind:`warn`,message:`This canvas now has over ${nn.toLocaleString()} shapes. Boards this large can feel slow.`}:null}function an(e,t){return e>W?t===`open`?{kind:`block`,message:`That board has ${e.toLocaleString()} shapes, more than the ${W.toLocaleString()} a canvas supports, so it wasn't opened.`}:{kind:`warn`,message:`This board has ${e.toLocaleString()} shapes, more than the ${W.toLocaleString()} a canvas supports. Expect it to feel slow.`}:e>8e3?{kind:`warn`,message:`This board has ${e.toLocaleString()} shapes. Boards this large can feel slow.`}:null}function on(e){let t=0;for(let n of e)n.type===`figure`&&n.slideOrder!==void 0&&(t=Math.max(t,n.slideOrder+1));return t}function sn(e,t){if(!t.some(e=>e.type===`figure`&&e.slideOrder!==void 0))return t;let n=new Set;for(let t of e)t.type===`figure`&&t.slideOrder!==void 0&&n.add(t.slideOrder);let r=on([...e,...t]);return t.map(e=>{if(e.type!==`figure`||e.slideOrder===void 0)return e;if(!n.has(e.slideOrder))return n.add(e.slideOrder),e;let t=r++;return n.add(t),{...e,slideOrder:t}})}function cn(e){let t=new Map;return he(e).forEach((e,n)=>{e.slideOrder!==n&&t.set(e.id,{...e,slideOrder:n})}),t.size===0?e:e.map(e=>t.get(e.id)??e)}var ln=`(prefers-color-scheme: dark)`;function un(e,t){return e===`system`?t?`dark`:`light`:e}function dn(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(ln).matches}var G={showGrid:!0,snapEnabled:!0,presentationAnimation:!0,showZoomIndicator:!1,theme:`light`},K=1,fn={"'Balsamiq Sans', cursive":`'Balsamiq Sans Neue', cursive`};function pn(e){let t=e.activation;if(!t||typeof t!=`object`||Array.isArray(t))return null;let{top:n,height:r}=t;return typeof n!=`number`||!Number.isFinite(n)||typeof r!=`number`||!Number.isFinite(r)?null:{top:n,height:r}}function mn(e){let t=new Map,n=e.map(e=>{if(e.type!==`control`||e.kind!==`lifeline`||!(`activation`in e))return e;let{activation:n,...r}=e,i=Array.isArray(e.activations),a=pn(e);if(i||!a)return r;let o={...r,activations:[a]};return t.set(o.id,o),o});if(t.size===0)return n;let r=e=>{if(!e||ae(e)||!e.precise)return e;let n=t.get(e.shapeId);if(!n)return e;let r=_e(n)[0],i=pe(n),a=be((r.y+e.anchor.y*r.height-i.y)/i.height);return{...e,anchor:{x:.5,y:a}}};return n.map(e=>{if(e.type!==`arrow`)return e;let t=r(e.startBinding),n=r(e.endBinding);return t===e.startBinding&&n===e.endBinding?e:{...e,startBinding:t,endBinding:n}})}var hn=100;function q(e,t=0,n=new Set){if(typeof e==`string`)return Ae(e);if(typeof e!=`object`||!e||t>=hn||n.has(e))return e;n.add(e);try{if(Array.isArray(e)){let r=!1,i=Array(e.length);for(let a=0;a<e.length;a+=1){let o=Object.getOwnPropertyDescriptor(e,String(a));if(!o||!(`value`in o))return e;let s=o.value,c=q(s,t+1,n);c!==s&&(r=!0),i[a]=c}return r?i:e}let r=Object.getPrototypeOf(e);if(r!==Object.prototype&&r!==null)return e;let i=!1,a={};for(let r of Reflect.ownKeys(e)){if(typeof r!=`string`)return e;let o=Object.getOwnPropertyDescriptor(e,r);if(!o?.enumerable||!(`value`in o))return e;let s=o.value,c=q(s,t+1,n);c!==s&&(i=!0),a[r]=c}return i?a:e}finally{n.delete(e)}}function gn(e){return mn(e).map(e=>{if(`fontFamily`in e&&e.fontFamily){let t=fn[e.fontFamily];if(t)return{...e,fontFamily:t}}return e})}function _n(e){if(typeof e!=`object`||!e)return null;let t=e;return typeof t.x!=`number`||typeof t.y!=`number`||typeof t.zoom!=`number`||!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.zoom)||t.zoom<=0?null:{x:t.x,y:t.y,zoom:t.zoom}}var J={unknownShapes:`preserve`};function Y(e,t){if(t.length===0)return e;let n=[...e.shapes];for(let e of[...t].sort((e,t)=>e.index-t.index))n.splice(Math.min(e.index,n.length),0,e.shape);return{...e,shapes:n}}function vn(e){let t=Ut(e,J);if(t.status!==`valid`)return{document:e,opaque:[]};let n=t.opaque.filter(e=>e.reason===`unknown`);if(n.length===t.opaque.length)return{document:t.document,opaque:t.opaque};let r=yn(t.opaque.filter(e=>e.reason===`damaged`),n);return{document:Y(t.document,r),opaque:n}}function yn(e,t){return e.length===0||t.length===0?e:e.map(e=>({...e,index:e.index-t.filter(t=>t.index<e.index).length}))}function bn(e,t){if(t.length===0)return e;let n=new Set(t.map(e=>e.id));return{...e,shapes:e.shapes.filter(e=>!n.has(e.id))}}function xn(e){let t=Wt(e,J);if(t.status===`unsupported-version`)return{status:`unsupported-version`};if(t.status===`invalid`)return{status:`invalid`};let n=q(t.document),r=Ut(Y({...n,shapes:gn(n.shapes)},t.opaque),J);if(r.status!==`valid`)return{status:`invalid`};let i=r.opaque.filter(e=>e.reason===`damaged`),a=yn(r.opaque.filter(e=>e.reason===`unknown`),i),o=r.document.shapes.length+r.opaque.length;return o>0&&i.length===o?{status:`invalid`}:{status:`valid`,document:Y(r.document,a),opaque:a,damaged:i}}function X(e,t){return typeof e==`function`?e(t):e}function Z(e){return t=>n=>e(e=>{let r=X(n,e[t]);return Object.is(r,e[t])?e:{[t]:r}})}var Sn=1.2,Cn={x:0,y:0,zoom:1};function Q(e,t){return Number.isFinite(t.x)&&Number.isFinite(t.y)&&Number.isFinite(t.zoom)&&t.zoom>0?{viewport:t}:{viewport:e}}var wn=e=>({viewport:Cn,zoomGestureNonce:0,pulseZoomGesture:()=>e(e=>({zoomGestureNonce:e.zoomGestureNonce+1})),setViewport:t=>e(e=>Q(e.viewport,X(t,e.viewport))),zoomIn:t=>e(e=>Q(e.viewport,fe(e.viewport,e.viewport.zoom*Sn,t))),zoomOut:t=>e(e=>Q(e.viewport,fe(e.viewport,e.viewport.zoom/Sn,t))),resetZoom:t=>e(e=>Q(e.viewport,fe(e.viewport,1,t))),fitToBounds:(t,n)=>e(e=>Q(e.viewport,t?ye(t,n):{zoom:1,x:n.width/2,y:n.height/2}))});function Tn(e){let t=new Map;for(let n of e)n.groupId&&t.set(n.groupId,(t.get(n.groupId)??0)+1);return[...t.values()].some(e=>e===1)?e.map(e=>e.groupId&&t.get(e.groupId)===1?{...e,groupId:void 0}:e):e}function En(e,t){let{position:n}=ge(e),r=e.slice(),i=[];for(let a of t(t=>{let r=n.get(t);return r===void 0?void 0:e[r]})){let e=n.get(a.id);e!==void 0&&(r[e]=a,i.push(e))}return de(e,r,i),r}var $=new Set,Dn=e=>(t,n,r)=>{let i=r.temporal;function a(){return n().viewModeLocked&&i?.getState().isTracking!==!1}function o(n,r,i,o){a()||t(t=>{let a=n(t.shapes);ue(t.shapes,a);let s=ie(a,r,e,o);return t.activeGroupId&&!s.some(e=>e.groupId===t.activeGroupId)?{shapes:s,...i,activeGroupId:null}:{shapes:s,...i}})}function s(e){o(t=>{let n=t.some(t=>e.has(t.id)&&t.type===`figure`&&t.slideOrder!==void 0),r=t.filter(t=>!e.has(t.id));return n?cn(r):r},e)}function c(e,r){if(a())return;let i=rn(n().shapes.length,e.length);i&&(t({limitNotice:i}),i.kind===`block`)||o(t=>r(t,sn(t,e)),new Set(e.map(e=>e.id)))}return{shapes:[],hydrate:(n,r,i)=>{let a=n?vn(n):null;t({shapes:ie(a?.document.shapes??[],null,e),opaqueShapes:a?.opaque??[],viewport:r??Cn,showGrid:i?.showGrid??G.showGrid,snapEnabled:i?.snapEnabled??G.snapEnabled,presentationAnimation:i?.presentationAnimation??G.presentationAnimation,showZoomIndicator:i?.showZoomIndicator??G.showZoomIndicator,theme:i?.theme??G.theme})},opaqueShapes:[],limitNotice:null,clearLimitNotice:()=>t({limitNotice:null}),addShape:e=>c([e],(e,t)=>[...e,...t]),addMany:e=>c(e,(e,t)=>[...e,...t]),addShapeBehind:(e,t)=>c([e],(e,n)=>{let r=e.findIndex(e=>t.has(e.id));return r===-1?[...e,...n]:[...e.slice(0,r),...n,...e.slice(r)]}),updateShape:(e,t)=>o(n=>En(n,n=>{let r=n(e);return r?[{...r,...t}]:[]}),new Set([e])),replaceShape:e=>o(t=>En(t,()=>[e]),new Set([e.id])),replaceMany:(e,t)=>{o(t=>En(t,()=>e),new Set(e.map(e=>e.id)),void 0,t)},loadShapes:e=>{let t=vn({version:K,shapes:e});o(()=>t.document.shapes,null,{opaqueShapes:t.opaque})},applyRemoteOps:e=>{e.length!==0&&t(t=>{let n=t.opaqueShapes.length===0&&e.every(e=>e.o!==`put`||Ht(e.shape)),r,i=t.opaqueShapes;if(n)r=U(t.shapes,e),ue(t.shapes,r);else{let n=vn({version:K,shapes:U(Y({version:K,shapes:t.shapes},t.opaqueShapes).shapes,e)});r=n.document.shapes,i=n.opaque}let a=e=>ge(r).position.has(e),o=[...t.selectedIds].every(a)?t.selectedIds:new Set([...t.selectedIds].filter(a));return t.activeGroupId&&!r.some(e=>e.groupId===t.activeGroupId)?{shapes:r,opaqueShapes:i,selectedIds:o,activeGroupId:null}:{shapes:r,opaqueShapes:i,selectedIds:o}})},remeasureBindings:()=>o(e=>e,null),settleBindings:e=>o(e=>e,e),removeShape:e=>s(new Set([e])),removeShapes:e=>s(e),bringToFront:e=>o(t=>[...t.filter(t=>!e.has(t.id)),...t.filter(t=>e.has(t.id))],$),sendToBack:e=>o(t=>[...t.filter(t=>e.has(t.id)),...t.filter(t=>!e.has(t.id))],$),bringForward:e=>o(t=>{let n=[...t];for(let t=n.length-2;t>=0;--t)e.has(n[t].id)&&!e.has(n[t+1].id)&&([n[t],n[t+1]]=[n[t+1],n[t]]);return n},$),sendBackward:e=>o(t=>{let n=[...t];for(let t=1;t<n.length;t+=1)e.has(n[t].id)&&!e.has(n[t-1].id)&&([n[t],n[t-1]]=[n[t-1],n[t]]);return n},$),group:e=>{let t=le();o(n=>{let r=n.filter(t=>e.has(t.id));if(r.length<2)return n;let i=r.map(e=>({...e,groupId:t})),a=n.filter(t=>!e.has(t.id)),o=0;n.forEach((t,n)=>{e.has(t.id)&&(o=n)});let s=n.slice(0,o+1).filter(t=>!e.has(t.id)).length,c=[...a];return c.splice(s,0,...i),Tn(c)},$)},ungroup:e=>o(t=>{let n=new Set(t.filter(t=>e.has(t.id)&&t.groupId).map(e=>e.groupId));return n.size===0?t:t.map(e=>e.groupId&&n.has(e.groupId)?{...e,groupId:void 0}:e)},$)}};function On(e){return e.kind===`none`?null:e.shapeId}function kn(e,t){if(e.kind===`none`||e.shapeId!==t)return{kind:`none`};switch(e.kind){case`text`:return{kind:`text`,field:e.field};case`table-cell`:return{kind:`table-cell`,row:e.row,col:e.col};case`lane`:return{kind:`lane`,lane:e.lane};case`crop`:return{kind:`crop`};case`chart-data`:return{kind:`chart-data`};case`vertices`:return{kind:`vertices`};case`interact`:return{kind:`interact`};default:return e}}function An(e){return e.kind===`crop`||e.kind===`vertices`}function jn(e){return An(e)||e.kind===`interact`}function Mn(e){return e.kind===`text`||e.kind===`table-cell`||e.kind===`lane`}function Nn(e,t){return e.kind===`text`&&ce(t,e.shapeId)?.type!==`figure`}function Pn(e){return Number.isFinite(e)?Math.max(0,Math.trunc(e)):0}var Fn=(e,t)=>{let n=Z(e);return{tool:`select`,selectedIds:new Set,erasingIds:new Set,editSession:{kind:`none`},tableSelection:null,hoveredId:null,activeGroupId:null,style:xe,shapeKind:`rectangle`,chartKind:`bar`,frameKind:`simple`,pendingIcon:null,pendingControl:null,toolLock:!1,lockRevealId:null,setTool:t=>e(e=>{let n=X(t,e.tool);return n===e.tool?e:e.tool===`highlight`&&n===`select`?{tool:n,style:xe}:{tool:n}}),releaseTool:()=>e(e=>e.toolLock?e:{tool:`select`}),placeShape:(e,n)=>{let r=t();r.addShape(e),r.setSelectedIds(new Set([e.id])),n?.edit&&r.beginTextEdit(e.id),r.releaseTool()},setSelectedIds:n(`selectedIds`),setErasingIds:n(`erasingIds`),beginTextEdit:(t,n=`label`)=>e({editSession:{kind:`text`,shapeId:t,field:n}}),beginTableCellEdit:(t,n,r)=>e({editSession:{kind:`table-cell`,shapeId:t,row:Pn(n),col:Pn(r)}}),beginLaneEdit:(t,n)=>e({editSession:{kind:`lane`,shapeId:t,lane:Pn(n)}}),beginCrop:t=>e({editSession:{kind:`crop`,shapeId:t}}),beginChartDataEdit:t=>e({editSession:{kind:`chart-data`,shapeId:t}}),beginVertexEdit:t=>e({editSession:{kind:`vertices`,shapeId:t}}),beginInteract:t=>e({editSession:{kind:`interact`,shapeId:t}}),endEdit:t=>e(e=>{let n=e.editSession;return n.kind===`none`||t!==void 0&&n.shapeId!==t?e:{editSession:{kind:`none`}}}),setTableSelection:n(`tableSelection`),setHoveredId:t=>e(e=>{let n=X(t,e.hoveredId);return n===e.hoveredId?e:{hoveredId:n}}),setActiveGroupId:n(`activeGroupId`),setStyle:n(`style`),setShapeKind:n(`shapeKind`),setChartKind:n(`chartKind`),setFrameKind:n(`frameKind`),setPendingIcon:n(`pendingIcon`),setPendingControl:n(`pendingControl`),setToolLock:n(`toolLock`),setLockRevealId:n(`lockRevealId`)}},In=e=>{let t=Z(e),n={slidePickerOpen:!1,animateSlideId:null},r=e=>({rightPanel:e,...e===`slides`?{}:n,...e===`flow`?{}:{flowEdit:null}}),i=(e,t)=>e.rightPanel===t?{rightPanel:null}:void 0;return{iconPickerOpen:!1,imageLibraryOpen:!1,rightPanel:null,slidePickerOpen:!1,notesEditorId:null,animateSlideId:null,flowEdit:null,flowPlay:null,flowPreview:null,lastFlow:{},codeSeed:null,pendingBoard:null,textAiSignInOpen:!1,textAiUpgradeOpen:!1,embedSignInOpen:!1,paletteOpen:!1,exportDialog:null,imageToCopy:null,toolDrawerOpen:!1,searchOpen:!1,zenMode:!1,rideMode:!1,viewMode:!1,viewModeLocked:!1,presentingIndex:null,pasteChoiceGrid:null,aiGhost:null,aiPrompt:null,deviceMode:`desktop`,coarsePointer:!1,setIconPickerOpen:t(`iconPickerOpen`),setImageLibraryOpen:t(`imageLibraryOpen`),setSlidesOpen:t=>e(e=>X(t,e.rightPanel===`slides`)?r(`slides`):{...i(e,`slides`),...n}),setSlidePickerOpen:t(`slidePickerOpen`),setNotesEditorId:t(`notesEditorId`),setAnimateSlideId:t=>e(t===null?{animateSlideId:null}:{animateSlideId:t,rightPanel:`slides`,tool:`select`,pendingIcon:null,pendingControl:null}),setFlowEdit:t=>e(e=>t===null?{flowEdit:null,...i(e,`flow`)}:{...r(`flow`),flowEdit:t,flowPreview:null,tool:`select`,pendingIcon:null,pendingControl:null}),patchFlowEdit:t=>e(e=>e.flowEdit?{flowEdit:{...e.flowEdit,...t}}:{}),setFlowPreview:t(`flowPreview`),setFlowsOpen:t=>e(e=>X(t,e.rightPanel===`flow`&&e.flowEdit===null)?{...r(`flow`),flowEdit:null}:{flowEdit:null,...i(e,`flow`)}),setFlowPlay:t=>e(e=>t?{flowPlay:t,flowPreview:null,...!t.trail?.length&&e.lastFlow[t.frameId]!==t.flowId?{lastFlow:{...e.lastFlow,[t.frameId]:t.flowId}}:{}}:{flowPlay:null}),setAiOpen:t=>e(e=>{let n=X(t,e.rightPanel===`ai`);return n&&e.viewMode?e:n?r(`ai`):i(e,`ai`)??e}),setCodeOpen:t=>e(e=>{let n=X(t,e.rightPanel===`code`);return n&&e.viewMode?e:n?r(`code`):i(e,`code`)??e}),setCodeSeed:t=>e({codeSeed:t}),setPendingBoard:t=>e({pendingBoard:t}),setTextAiSignInOpen:t(`textAiSignInOpen`),setTextAiUpgradeOpen:t(`textAiUpgradeOpen`),setEmbedSignInOpen:t(`embedSignInOpen`),setPaletteOpen:t(`paletteOpen`),setExportDialog:t(`exportDialog`),setImageToCopy:t=>e({imageToCopy:t}),setToolDrawerOpen:t(`toolDrawerOpen`),setSearchOpen:t(`searchOpen`),setZenMode:t(`zenMode`),setRideMode:t(`rideMode`),setViewMode:t=>e(e=>{let n=X(t,e.viewMode);return n?{viewMode:n,tool:`select`,editSession:{kind:`none`},pendingIcon:null,pendingControl:null,erasingIds:new Set,toolDrawerOpen:!1,...e.rightPanel===`ai`||e.rightPanel===`code`?{rightPanel:null}:{}}:e.viewModeLocked?e:{viewMode:n}}),setViewModeLocked:t=>e({viewModeLocked:t}),setPresentingIndex:t(`presentingIndex`),setPasteChoiceGrid:t(`pasteChoiceGrid`),setAiGhost:t=>e({aiGhost:t}),askAi:(t,n=!1)=>e(e=>e.viewMode?e:{...r(`ai`),aiPrompt:{text:t,send:n}}),setAiPrompt:t=>e({aiPrompt:t}),setDeviceMode:t(`deviceMode`),setCoarsePointer:t(`coarsePointer`)}},Ln=e=>{let t=Z(e),n=G;return{showGrid:n.showGrid,snapEnabled:n.snapEnabled,theme:n.theme,presentationAnimation:n.presentationAnimation,showZoomIndicator:n.showZoomIndicator,setShowGrid:t(`showGrid`),setSnapEnabled:t(`snapEnabled`),setTheme:t(`theme`),setPresentationAnimation:t(`presentationAnimation`),setShowZoomIndicator:t(`showZoomIndicator`)}},Rn=e=>({remoteCursors:new Map,lastPeerPointers:new Map,setRemoteCursors:t=>e(e=>{let n=e.lastPeerPointers;for(let r of t.values()){let t=n.get(r.peerId);t&&t.at>=r.at||(n===e.lastPeerPointers&&(n=new Map(n)),n.set(r.peerId,{x:r.x,y:r.y,at:r.at}))}return{remoteCursors:t,lastPeerPointers:n}})}),zn=e=>({openThreadId:null,commentDraft:null,commentsVisible:!0,setOpenThreadId:t=>e({openThreadId:t,commentDraft:null}),setCommentDraft:t=>e(t?{commentDraft:t,openThreadId:null,commentsVisible:!0}:{commentDraft:null}),setCommentsVisible:Z(e)(`commentsVisible`)}),Bn={isPanning:!1,dragging:!1,transforming:!1,resizing:!1,marquee:null,lasso:null,bindTarget:null,snapDot:null};function Vn(e){return e.isPanning||e.dragging||e.transforming||e.draft!==null||e.marquee!==null||e.lasso!==null}var Hn=e=>{let t=Z(e);return{draft:null,polyDraft:null,marquee:null,lasso:null,bindTarget:null,snapDot:null,hoverWorld:null,snapGuides:[],isPanning:!1,dragging:!1,transforming:!1,resizing:!1,eraserTrail:``,selectionFrame:null,setDraft:t(`draft`),setPolyDraft:t(`polyDraft`),setMarquee:t(`marquee`),setLasso:t(`lasso`),setBindTarget:t(`bindTarget`),setSnapDot:t(`snapDot`),setHoverWorld:t(`hoverWorld`),setSnapGuides:t(`snapGuides`),setIsPanning:t(`isPanning`),setDragging:t(`dragging`),setTransforming:t(`transforming`),setResizing:t(`resizing`),setEraserTrail:t(`eraserTrail`),setSelectionFrame:t(`selectionFrame`),clearSnapGuides:()=>e(e=>e.snapGuides.length===0?e:{snapGuides:[]}),resetGestureVisuals:()=>e(e=>e.snapGuides.length===0&&Object.keys(Bn).every(t=>e[t]===Bn[t])?e:{...Bn,snapGuides:[]})}};function Un(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}var Wn=e=>{let t=Z(e);return{liveWebIds:new Set,startedWebIds:new Set,webEmbedDialog:null,webHtmlEditorId:null,setLiveWebIds:t=>e(e=>Un(e.liveWebIds,t)?e:{liveWebIds:new Set(t)}),startWeb:t=>e(e=>e.startedWebIds.has(t)?e:{startedWebIds:new Set([...e.startedWebIds,t])}),stopWeb:t=>e(e=>{if(!e.startedWebIds.has(t))return e;let n=new Set(e.startedWebIds);return n.delete(t),{startedWebIds:n}}),setWebEmbedDialog:t(`webEmbedDialog`),setWebHtmlEditorId:t(`webHtmlEditorId`)}},Gn=200;function Kn(e){let t={holding:()=>!1},n=Ce()(De((...t)=>({...Dn(e)(...t),...Fn(...t),...In(...t),...Ln(...t),...Rn(...t),...zn(...t),...wn(...t),...Hn(...t),...Wn(...t)}),{partialize:e=>({shapes:e.shapes,opaqueShapes:e.opaqueShapes}),equality:(e,n)=>e.shapes===n.shapes||t.holding(),limit:Gn}));return Object.assign(n,{historyGate:t})}function qn(e,t){let n=Kn(t);return e&&(n.getState().hydrate(e.document,e.viewport,e.preferences),n.temporal.getState().clear()),n}var Jn=(0,p.createContext)(null),Yn=Jn.Provider;function Xn(){let e=(0,p.useContext)(Jn);if(!e)throw Error(`useEditorRuntime must be called under a mounted <Canvas>. Editor hooks and commands resolve through the canvas's own runtime.`);return e}function Zn(){return Xn().store}function Qn(e){return Te(Zn(),e)}function $n(e,t,n){let r=(0,p.useRef)(null);return Qn(i=>{let a=e(i),o=r.current;if(o&&er(o.inputs,a))return o.value;let s=t(...a),c=o&&n?.(o.value,s)?o.value:s;return r.current={inputs:a,value:c},c})}function er(e,t){return e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]))}function tr(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}export{Ht as A,on as C,H as D,tn as E,Te as M,Jt as O,dn as S,U as T,_n as _,Xn as a,ln as b,Vn as c,Mn as d,An as f,xn as g,K as h,$n as i,Pe as j,qt as k,On as l,Nn as m,qn as n,Qn as o,kn as p,tr as r,Zn as s,Yn as t,jn as u,Y as v,an as w,un as x,bn as y};
@@ -1 +1 @@
1
- import{n as e,t}from"./layout.worker-BIE1_z0S.js";var n=t(((t,n)=>{(function(e){if(typeof t==`object`&&n!==void 0)n.exports=e();else if(typeof define==`function`&&define.amd)define([],e);else{var r=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this;r.ELK=e()}})(function(){return(function(){function t(n,r,i){function a(s,c){if(!r[s]){if(!n[s]){var l=typeof e==`function`&&e;if(!c&&l)return l(s,!0);if(o)return o(s,!0);var u=Error(`Cannot find module '`+s+`'`);throw u.code=`MODULE_NOT_FOUND`,u}var d=r[s]={exports:{}};n[s][0].call(d.exports,function(e){var t=n[s][1][e];return a(t||e)},d,d.exports,t,n,r,i)}return r[s].exports}for(var o=typeof e==`function`&&e,s=0;s<i.length;s++)a(i[s]);return a}return t})()({1:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;function r(e){"@babel/helpers - typeof";return r=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},r(e)}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=c(e,`string`);return r(t)==`symbol`?t:t+``}function c(e,t){if(r(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||`default`);if(r(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}n.default=function(){function e(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=n.defaultLayoutOptions,a=r===void 0?{}:r,o=n.algorithms,s=o===void 0?[`layered`,`stress`,`mrtree`,`radial`,`force`,`disco`,`sporeOverlap`,`sporeCompaction`,`rectpacking`]:o,c=n.workerFactory,u=n.workerUrl;if(i(this,e),this.defaultLayoutOptions=a,this.initialized=!1,u===void 0&&c===void 0)throw Error(`Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.`);var d=c;u!==void 0&&c===void 0&&(d=function(e){return new Worker(e)});var f=d(u);if(typeof f.postMessage!=`function`)throw TypeError(`Created worker does not provide the required 'postMessage' function.`);this.worker=new l(f),this.worker.postMessage({cmd:`register`,algorithms:s}).then(function(e){return t.initialized=!0}).catch(console.err)}return o(e,[{key:`layout`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.layoutOptions,r=n===void 0?this.defaultLayoutOptions:n,i=t.logging,a=i!==void 0&&i,o=t.measureExecutionTime,s=o!==void 0&&o;return e?this.worker.postMessage({cmd:`layout`,graph:e,layoutOptions:r,options:{logging:a,measureExecutionTime:s}}):Promise.reject(Error(`Missing mandatory parameter 'graph'.`))}},{key:`knownLayoutAlgorithms`,value:function(){return this.worker.postMessage({cmd:`algorithms`})}},{key:`knownLayoutOptions`,value:function(){return this.worker.postMessage({cmd:`options`})}},{key:`knownLayoutCategories`,value:function(){return this.worker.postMessage({cmd:`categories`})}},{key:`terminateWorker`,value:function(){this.worker&&this.worker.terminate()}}])}();var l=function(){function e(t){var n=this;if(i(this,e),t===void 0)throw Error(`Missing mandatory parameter 'worker'.`);this.resolvers={},this.worker=t,this.worker.onmessage=function(e){setTimeout(function(){n.receive(n,e)},0)}}return o(e,[{key:`postMessage`,value:function(e){var t=this.id||0;this.id=t+1,e.id=t;var n=this;return new Promise(function(r,i){n.resolvers[t]=function(e,t){e?(n.convertGwtStyleError(e),i(e)):r(t)},n.worker.postMessage(e)})}},{key:`receive`,value:function(e,t){var n=t.data,r=e.resolvers[n.id];r&&(delete e.resolvers[n.id],n.error?r(n.error):r(null,n.data))}},{key:`terminate`,value:function(){this.worker&&this.worker.terminate()}},{key:`convertGwtStyleError`,value:function(e){if(e){var t=e.__java$exception;t&&(t.cause&&t.cause.backingJsObject&&(e.cause=t.cause.backingJsObject,this.convertGwtStyleError(e.cause)),delete e.__java$exception)}}}])}()},{}],2:[function(e,t,n){var r=e("./elk-api.js").default;Object.defineProperty(t.exports,"__esModule",{value:!0}),t.exports=r,r.default=r},{"./elk-api.js":1}]},{},[2])(2)})}));export default n();
1
+ import{n as e,t}from"./layout.worker-CekYkaxO.js";var n=t(((t,n)=>{(function(e){if(typeof t==`object`&&n!==void 0)n.exports=e();else if(typeof define==`function`&&define.amd)define([],e);else{var r=typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:this;r.ELK=e()}})(function(){return(function(){function t(n,r,i){function a(s,c){if(!r[s]){if(!n[s]){var l=typeof e==`function`&&e;if(!c&&l)return l(s,!0);if(o)return o(s,!0);var u=Error(`Cannot find module '`+s+`'`);throw u.code=`MODULE_NOT_FOUND`,u}var d=r[s]={exports:{}};n[s][0].call(d.exports,function(e){var t=n[s][1][e];return a(t||e)},d,d.exports,t,n,r,i)}return r[s].exports}for(var o=typeof e==`function`&&e,s=0;s<i.length;s++)a(i[s]);return a}return t})()({1:[function(e,t,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;function r(e){"@babel/helpers - typeof";return r=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},r(e)}function i(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function o(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){var t=c(e,`string`);return r(t)==`symbol`?t:t+``}function c(e,t){if(r(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,t||`default`);if(r(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}n.default=function(){function e(){var t=this,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=n.defaultLayoutOptions,a=r===void 0?{}:r,o=n.algorithms,s=o===void 0?[`layered`,`stress`,`mrtree`,`radial`,`force`,`disco`,`sporeOverlap`,`sporeCompaction`,`rectpacking`]:o,c=n.workerFactory,u=n.workerUrl;if(i(this,e),this.defaultLayoutOptions=a,this.initialized=!1,u===void 0&&c===void 0)throw Error(`Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.`);var d=c;u!==void 0&&c===void 0&&(d=function(e){return new Worker(e)});var f=d(u);if(typeof f.postMessage!=`function`)throw TypeError(`Created worker does not provide the required 'postMessage' function.`);this.worker=new l(f),this.worker.postMessage({cmd:`register`,algorithms:s}).then(function(e){return t.initialized=!0}).catch(console.err)}return o(e,[{key:`layout`,value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.layoutOptions,r=n===void 0?this.defaultLayoutOptions:n,i=t.logging,a=i!==void 0&&i,o=t.measureExecutionTime,s=o!==void 0&&o;return e?this.worker.postMessage({cmd:`layout`,graph:e,layoutOptions:r,options:{logging:a,measureExecutionTime:s}}):Promise.reject(Error(`Missing mandatory parameter 'graph'.`))}},{key:`knownLayoutAlgorithms`,value:function(){return this.worker.postMessage({cmd:`algorithms`})}},{key:`knownLayoutOptions`,value:function(){return this.worker.postMessage({cmd:`options`})}},{key:`knownLayoutCategories`,value:function(){return this.worker.postMessage({cmd:`categories`})}},{key:`terminateWorker`,value:function(){this.worker&&this.worker.terminate()}}])}();var l=function(){function e(t){var n=this;if(i(this,e),t===void 0)throw Error(`Missing mandatory parameter 'worker'.`);this.resolvers={},this.worker=t,this.worker.onmessage=function(e){setTimeout(function(){n.receive(n,e)},0)}}return o(e,[{key:`postMessage`,value:function(e){var t=this.id||0;this.id=t+1,e.id=t;var n=this;return new Promise(function(r,i){n.resolvers[t]=function(e,t){e?(n.convertGwtStyleError(e),i(e)):r(t)},n.worker.postMessage(e)})}},{key:`receive`,value:function(e,t){var n=t.data,r=e.resolvers[n.id];r&&(delete e.resolvers[n.id],n.error?r(n.error):r(null,n.data))}},{key:`terminate`,value:function(){this.worker&&this.worker.terminate()}},{key:`convertGwtStyleError`,value:function(e){if(e){var t=e.__java$exception;t&&(t.cause&&t.cause.backingJsObject&&(e.cause=t.cause.backingJsObject,this.convertGwtStyleError(e.cause)),delete e.__java$exception)}}}])}()},{}],2:[function(e,t,n){var r=e("./elk-api.js").default;Object.defineProperty(t.exports,"__esModule",{value:!0}),t.exports=r,r.default=r},{"./elk-api.js":1}]},{},[2])(2)})}));export default n();
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/elk-api-CdZ15eos.js","assets/rolldown-runtime-aKtaBQYM.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./preload-helper-Czpn1I53.js";import{f as n,m as r,u as i}from"./text-breaks-YU-ymaF9.js";import{t as a}from"./blob-CTPsKWYv.js";import{n as o,t as s}from"./icons-DzW1j-r3.js";import{n as c}from"./theme-palette-D1nbDFBC.js";function l(e){let t=null;function n(){if(!t){let n=e();t=n,n.catch(()=>{t===n&&(t=null)})}return t}return{async layout(e){return await(await n()).layout(e)}}}async function u(){let{default:e}=await t(async()=>{let{default:e}=await import(`./elk-in-process-absent-CzI8UVp-.js`);return{default:e}},[]);return new e}function d(){return{async inline(e){let t=document.baseURI,n=t?new URL(e,t).href:e;try{return await a(await f(n))}catch(t){return r(`asset-inline`,t,e),null}}}}async function f(e){let t=await fetch(e,{cache:`force-cache`}).catch(()=>null),n=t?.ok?t:await fetch(e,{cache:`reload`});if(!n.ok)throw Error(`asset request failed with ${n.status}`);let r=await n.blob();if(!r.type.startsWith(`image/`))throw Error(`asset was ${r.type||`untyped`}, not an image`);return r}function p(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function m(){let e=[];for(let t of Array.from(document.styleSheets)){let n=null;try{n=t.cssRules}catch{continue}if(n)for(let t of Array.from(n)){if(!(t instanceof CSSFontFaceRule))continue;let n=t.style,r=[...n.getPropertyValue(`src`).matchAll(/url\(\s*["']?([^"')]+)["']?\s*\)/g)].map(e=>e[1]);r.length!==0&&e.push({family:n.getPropertyValue(`font-family`).replace(/['"]/g,``).trim(),weight:n.getPropertyValue(`font-weight`)||`400`,style:n.getPropertyValue(`font-style`)||`normal`,unicodeRange:n.getPropertyValue(`unicode-range`),srcUrls:r})}}return e}function h(e){return e.find(e=>e.includes(`.woff2`))??e[0]}function g(e){return e.includes(`.woff2`)?`woff2`:e.includes(`.woff`)?`woff`:e.includes(`.otf`)?`opentype`:e.includes(`.ttf`)?`truetype`:`woff2`}async function _(e){return a(await(await fetch(e,{cache:`force-cache`})).blob())}function v(e,t){let n=e.unicodeRange?` unicode-range: ${e.unicodeRange};\n`:``;return`@font-face {\n font-family: "${e.family}";\n font-style: ${e.style};\n font-weight: ${e.weight};\n font-display: swap;\n src: url(${t}) format("${g(h(e.srcUrls))}");\n`+n+`}`}function y(){let e=new Map,t=t=>{let n=e.get(t);return n||(n=_(t),n.catch(()=>e.delete(t)),e.set(t,n)),n};return{async embed(e,a){let{families:o,bold:s,italic:c,codepoints:l}=e;if(o.size===0)return``;if(a&&a.length>0)return i(e,a,p);let u=m(),d=[];for(let e of o){let i=u.filter(t=>t.family===e&&(s||t.weight.trim()!==`700`)&&(c||t.style!==`italic`)&&n(t.unicodeRange,l));for(let e of i)try{let n=await t(new URL(h(e.srcUrls),document.baseURI).href);d.push(v(e,n))}catch(t){r(`font-embed`,t,e.family)}}return d.join(`
2
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{t}from"./preload-helper-Czpn1I53.js";import{f as n,g as r,u as i}from"./text-breaks-DM4W6y5f.js";import{t as a}from"./blob-CTPsKWYv.js";import{n as o,t as s}from"./icons-DzW1j-r3.js";import{n as c}from"./theme-palette-Dl_G_VIJ.js";function l(e){let t=null;function n(){if(!t){let n=e();t=n,n.catch(()=>{t===n&&(t=null)})}return t}return{async layout(e){return await(await n()).layout(e)}}}async function u(){let{default:e}=await t(async()=>{let{default:e}=await import(`./elk-in-process-absent-CzI8UVp-.js`);return{default:e}},[]);return new e}function d(){return{async inline(e){let t=document.baseURI,n=t?new URL(e,t).href:e;try{return await a(await f(n))}catch(t){return r(`asset-inline`,t,e),null}}}}async function f(e){let t=await fetch(e,{cache:`force-cache`}).catch(()=>null),n=t?.ok?t:await fetch(e,{cache:`reload`});if(!n.ok)throw Error(`asset request failed with ${n.status}`);let r=await n.blob();if(!r.type.startsWith(`image/`))throw Error(`asset was ${r.type||`untyped`}, not an image`);return r}function p(e){let t=``,n=32768;for(let r=0;r<e.length;r+=n)t+=String.fromCharCode(...e.subarray(r,r+n));return btoa(t)}function m(){let e=[];for(let t of Array.from(document.styleSheets)){let n=null;try{n=t.cssRules}catch{continue}if(n)for(let t of Array.from(n)){if(!(t instanceof CSSFontFaceRule))continue;let n=t.style,r=[...n.getPropertyValue(`src`).matchAll(/url\(\s*["']?([^"')]+)["']?\s*\)/g)].map(e=>e[1]);r.length!==0&&e.push({family:n.getPropertyValue(`font-family`).replace(/['"]/g,``).trim(),weight:n.getPropertyValue(`font-weight`)||`400`,style:n.getPropertyValue(`font-style`)||`normal`,unicodeRange:n.getPropertyValue(`unicode-range`),srcUrls:r})}}return e}function h(e){return e.find(e=>e.includes(`.woff2`))??e[0]}function g(e){return e.includes(`.woff2`)?`woff2`:e.includes(`.woff`)?`woff`:e.includes(`.otf`)?`opentype`:e.includes(`.ttf`)?`truetype`:`woff2`}async function _(e){return a(await(await fetch(e,{cache:`force-cache`})).blob())}function v(e,t){let n=e.unicodeRange?` unicode-range: ${e.unicodeRange};\n`:``;return`@font-face {\n font-family: "${e.family}";\n font-style: ${e.style};\n font-weight: ${e.weight};\n font-display: swap;\n src: url(${t}) format("${g(h(e.srcUrls))}");\n`+n+`}`}function y(){let e=new Map,t=t=>{let n=e.get(t);return n||(n=_(t),n.catch(()=>e.delete(t)),e.set(t,n)),n};return{async embed(e,a){let{families:o,bold:s,italic:c,codepoints:l}=e;if(o.size===0)return``;if(a&&a.length>0)return i(e,a,p);let u=m(),d=[];for(let e of o){let i=u.filter(t=>t.family===e&&(s||t.weight.trim()!==`700`)&&(c||t.style!==`italic`)&&n(t.unicodeRange,l));for(let e of i)try{let n=await t(new URL(h(e.srcUrls),document.baseURI).href);d.push(v(e,n))}catch(t){r(`font-embed`,t,e.family)}}return d.join(`
3
3
  `)}}}function b(e,t,n,r){return`${r?`italic `:``}${n??400} ${e}px ${t}`}function x(e,t,n,r,i,a){return e.font=b(n,r,i,a),e.measureText(t).width}function S(e,t){return e.length*t*.6}function C(){let e=null,t=!1,n=()=>(t||=(e=document.createElement(`canvas`).getContext(`2d`),!0),e);return{prepare:()=>Promise.resolve(),measure:(e,t,r,i,a)=>{let o=n();return o?x(o,e,t,r,i,a):S(e,t)}}}function w(){if(typeof document>`u`)return{...c};let e=getComputedStyle(document.documentElement),t=(t,n)=>e.getPropertyValue(t).trim()||n;return{bg:t(`--canvas-bg`,c.bg),ink:t(`--canvas-ink`,c.ink),inkMuted:t(`--canvas-ink-muted`,c.inkMuted),inkInverse:t(`--canvas-ink-inverse`,c.inkInverse),paperBg:t(`--paper-bg`,c.paperBg),paperGrid:t(`--paper-grid`,c.paperGrid),paperLine:t(`--paper-line`,c.paperLine)}}function T(){return{palette:w}}function E(e={}){let t=e.assetBase===void 0&&e.loadIconCatalog===void 0?s():o({assetBase:e.assetBase,loadCatalog:e.loadIconCatalog});return{text:C(),fonts:y(),assets:d(),icons:t,elk:l(e.elk??u),theme:T()}}async function D(){try{let[{default:n},{default:r}]=await Promise.all([t(()=>import(`./elk-api-CdZ15eos.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1])),t(()=>import(`./elk-worker.min-SDxTC6NI.js`),[])]),i=new n({workerFactory:()=>new r});return await i.layout({id:`__probe__`,children:[{id:`n`,width:1,height:1}]}),i}catch{return u()}}export{E as n,C as r,D as t};
@@ -1,2 +1,2 @@
1
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{an as e,i as t,l as n,o as r}from"./slides-D9bnXqtf.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-D1nbDFBC.js";import{n as s,r as c}from"./clipboard-CO7YHov7.js";import{n as l,t as u}from"./export-DEFKKRRi.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=r(t(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};
2
+ import{an as e,i as t,l as n,o as r}from"./slides-D686obFO.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-Dl_G_VIJ.js";import{n as s,r as c}from"./clipboard-CO7YHov7.js";import{n as l,t as u}from"./export-K2VWg76n.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=r(t(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,6 @@
1
+ import{$n as e,An as t,Cn as n,Dn as r,En as i,Ft as a,Gn as o,It as s,Kn as c,Lt as l,Qn as u,Rn as d,Rt as f,Un as p,Vn as m,Vr as h,Yr as g,Zt as _,an as v,ar as y,cr as b,fr as x,gr as S,hr as C,jn as w,lr as T,mr as E,or as D,pr as O,qn as k,rn as ee,sn as A,sr as j,un as te,ur as ne,wn as re}from"./slides-D686obFO.js";import{B as ie,F as ae,I as oe,O as M,R as N,b as se,s as ce}from"./style-BENGW2ZV.js";import{i as le}from"./registry-rEGZW7Ab.js";import{a as ue,g as de,h as fe,m as pe,p as me,t as he}from"./text-breaks-DM4W6y5f.js";import{i as ge,r as P}from"./icon-sources-CZI1h18s.js";import{P as _e,a as ve,b as ye,c as be,g as F,i as xe,l as Se,n as Ce,o as we,s as Te,y as Ee}from"./chart-4iRduYdU.js";import{c as De,i as Oe,s as ke,u as Ae}from"./frames-Cp1QD3LR.js";import{n as je,t as Me}from"./connector-labels-CrEgadsC.js";var Ne=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Pe=(()=>{let e=new Int8Array(128).fill(-1);for(let t=0;t<64;t+=1)e[Ne.charCodeAt(t)]=t;return e})();function Fe(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?Pe[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}var I=`#ffffff`;function L(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function R(e){return String(e).replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`)}function Ie(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}="${R(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}="${R(t)}"`).join(` `)}function z(e,t,n){let r=Ie(t);return n===void 0?`<${e}${r?` `+r:``}/>`:`<${e}${r?` `+r:``}>${n}</${e}>`}function B(e,t){if(e)return`rotate(${e} ${t.x+t.width/2} ${t.y+t.height/2})`}function V(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 H(e,t){let n=B(e.rotation??0,t),r=V({x:t.x+t.width/2,y:t.y+t.height/2},e.flipX,e.flipY);return r?n?`${n} ${r}`:r:n}var Le=`'JetBrains Mono', ui-monospace, monospace`,Re=.9,ze=`#fde68a`;function U(e,t){let n=e.fontSize??t;return e.code?n*Re:n}function W(e,t,n,r,i){let a=t.code?Le:n,o=U(t,r),s=t.bold?700:i??400;return e.measure(t.text,o,a,s,t.italic)}var G=.55,Be=1.4,Ve=1.4;function He(e,t){return(e.depth??0)*Ve*t}function Ue(e){return e.kind===`bullet`?`• `:e.kind===`number`?`${e.text} `:null}function We(e,t,n,r,i,a){if(!e)return 0;let o=Ue(e);return o===null?Be*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=z(`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=z(`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 z(`g`,{opacity:G},l+u)}function Ke(e,t,n,r,i,a){return ue(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 K(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=We(s.marker,r,n,i,0,a),c=Math.max(r,t-e-He(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+W(a,{...t.run,text:t.text},n,r,i),0),g=(e,t)=>{for(let t of e)m(t.run,t.text,W(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,...he(n),Array.from(n).length];for(let t=0;t<r.length-1;t+=1){let n=K(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=K(n,o,e);e-o>1&&h(t)>c&&(g(K(n,o,e-1),0),p(),o=e-1)}g(K(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=z(`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,V(o,t.flipX,t.flipY)].filter(Boolean).join(` `);return s?z(`g`,{transform:s},a):a}function Qe(e,t,r){if(e)return t.fixedInk?e:r.theme.paint(t=>p(n(e),t),e)}function q(e,t){if(r(e.text)&&i())return $e(e,t);let n=M(e.fontFamily),a=e.maxWidth,o=w(e.text).split(`
2
+ `);a!==void 0&&(o=o.flatMap(r=>Ke(r,a,e.fontSize,e.fontFamily,n,t.text)));let s=e.ascent??S(e.fontSize,e.lineHeight??1.2),c=Ye(e),l=Xe(e),u=o.length*c,d=e.vAlign===`center`?e.y-u/2+s:e.vAlign===`bottom`?e.y-u+s:e.y+s,f=o.map((t,n)=>z(`tspan`,{x:e.x,y:d+n*c},L(t)||` `)).join(``);return Ze(z(`text`,{"font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":n,fill:e.color,"text-anchor":e.align,"white-space":`pre`,"letter-spacing":l||void 0},f),e,e.background?Math.max(...o.map(r=>t.text.measure(r,e.fontSize,e.fontFamily,n)+l*r.length)):0,u,t)}function $e(e,n){let r=M(e.fontFamily),i=t(e.text);e.maxWidth!==void 0&&(i=Je(i,e.maxWidth,e.fontFamily,e.fontSize,r,n.text));let a=e.lineHeight??1.2,o=e.letterSpacing??0,s=i.map(t=>Math.max(e.fontSize,...t.runs.map(t=>U(t,e.fontSize)))),c=s.map(e=>e*a),l=c.reduce((e,t)=>e+t,0),u=e.vAlign===`center`?e.y-l/2:e.vAlign===`bottom`?e.y-l:e.y,d=[],f=[],p=0,m=u;i.forEach((t,i)=>{let l=e.ascent?e.ascent/e.fontSize*s[i]:S(s[i],a),u=c[i],h=m,g=h+l;m+=u;let _=We(t.marker,e.fontSize,e.fontFamily,r,o*e.fontSize,n.text),v=t.runs.map(t=>U(t,e.fontSize)),y=t.runs.map((t,i)=>W(n.text,t,e.fontFamily,e.fontSize,r)+o*v[i]*t.text.length),x=y.reduce((e,t)=>e+t,0),C=He(t,e.fontSize),w=C+_+x;p=Math.max(p,w);let T=e.align===`middle`?e.x-w/2:e.align===`end`?e.x-w:e.x;if(T+=C,t.marker){let n=Ue(t.marker);n===null?d.push(Ge(T,h,u,e.fontSize,t.checked,e.color)):f.push(z(`tspan`,{x:T,y:g},L(n))),T+=_}t.runs.forEach((r,i)=>{let a=y[i],s=v[i];r.highlight&&d.push(z(`rect`,{x:T,y:g-s*j,width:a,height:s*(j+b),rx:3,fill:ze,opacity:t.checked?G:void 0}));let c=[r.href||r.underline?`underline`:``,r.strike?`line-through`:``].filter(Boolean).join(` `);f.push(z(`tspan`,{x:T,y:g,"font-style":r.italic?`italic`:void 0,"font-weight":r.bold?700:void 0,"font-family":r.code?Le:void 0,"font-size":s===e.fontSize?void 0:s,"letter-spacing":o?o*s:void 0,fill:r.href?se:Qe(r.color,e,n),"fill-opacity":t.checked?G:void 0,"text-decoration":c||void 0},L(r.text)||` `)),T+=a})});let h=z(`text`,{"font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":r,fill:e.color,"text-anchor":`start`,"white-space":`pre`},f.join(``));return Ze(d.join(``)+h,e,p,l,n)}function et(e){return`light`in e&&`dark`in e}function tt(){return{paint:(e,t)=>t,css:()=>``,rootClass:void 0}}function nt(e){return{paint:t=>t(e),css:()=>``,rootClass:void 0}}var J=`koboyo-adaptive`;function rt(e){if(ae(e.light.bg,1)<.5||ae(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(${it(t,r,i)})`},css(){if(t.size===0)return``;let e=e=>[...t].map(([t,n])=>`${t}:${n[e]}`).join(`;`);return`.${J}{${e(0)}}@media (prefers-color-scheme: dark){.${J}{${e(1)}}}`},rootClass:J}}function it(e,t,n){let r=`--kb-${at(`${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 at(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 ot(e,t){let n=oe(e);return st(e)?t.theme.paint(e=>p(n,e),n):n}function st(e){return e.fill===`transparent`||e.fill===`#ffffff`||N(e)!==null}function ct(e,t){if(!e.label)return``;let n=v(e),r=E(e.kind,n.width,n.height,{x:e.flipX,y:e.flipY}),i={x:n.x+r.left,y:n.y+r.top,width:n.width-r.left-r.right,height:n.height-r.top-r.bottom},a=ot(e,t),o=e.textAlign??`center`,s=e.textVAlign??`middle`,c=e.textPadding??6,l=e.fontSize??20,u=e.titleIcon?.placement===`inside`?O(l)+x(l):0;return q({text:e.label,fontSize:l,fontFamily:e.fontFamily,color:a,fixedInk:!st(e),lineHeight:e.lineHeight??1.25,letterSpacing:e.letterSpacing,x:o===`left`?i.x+c+u:o===`right`?i.x+i.width-c:i.x+i.width/2+u/2,y:s===`top`?i.y+c:s===`bottom`?i.y+i.height-c:i.y+i.height/2,align:o===`left`?`start`:o===`right`?`end`:`middle`,vAlign:s===`top`?`top`:s===`bottom`?`bottom`:`center`,maxWidth:i.width-c*2-u,rotation:e.rotation,rotateCenter:{x:i.x+i.width/2,y:i.y+i.height/2}},t)}var lt=15;function ut(e){return e.titleIcon?19:0}function dt(e,t){let n=e.titleIcon;if(!n||!e.label)return``;let r=v(e),i=r.x,a=r.y-D-14*1.2+S(14,1.2)-14*.35-lt/2;return Z({source:n.source,name:n.name,srcMap:t.srcMap,icons:t.icons,x:i,y:a,size:lt,stroke:t.theme.paint(t=>p(e.color,t),e.color)})}function ft(e,t){if(!e.label)return``;let n=v(e);return dt(e,t)+q({text:e.label,fontSize:14,fontFamily:e.fontFamily,color:t.theme.paint(t=>p(e.color,t),e.color),x:n.x+ut(e),y:n.y-D,align:`start`,vAlign:`bottom`},t)}function pt(e,t){let n=e.lanes??[];if(!ke(e.kind)||n.length===0)return``;let r=Ae(e.kind),i=v(e),a=De(n.length,r?i.width:i.height,e.laneSizes),o=t.theme.paint(t=>p(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 q({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 z(`g`,{opacity:Oe},s)}function mt(e,t){if(!e.label)return null;let n=v(e),r=M(e.fontFamily),i=w(e.label).split(`
3
+ `),a=i.length*14*1.2,o=ut(e)+Math.max(...i.map(n=>t.measure(n,14,e.fontFamily,r))),s=n.y-D-a;return{x:n.x,y:s,width:o,height:n.y-s}}function ht(e,t,n,r,i){let a=r.color===`transparent`?d:r.color,o=i.theme.paint(e=>p(a,e),a);return q({text:e,fontSize:n,fontFamily:r.fontFamily??ce,color:o,lineHeight:ne,x:t.x,y:t.y,align:`middle`,vAlign:`center`,background:!0},i)}function gt(e,t,n){let r=e.label??``;return r?ht(r,t,e.fontSize??20,e,n):``}function _t(e,t){let n=``;for(let r of Me(e))n+=ht(r.text,r.point,14,e,t);return n}function vt(e,t){if(!e.label)return``;let n=v(e),r=n.x+n.width/2,i=e.fontSize??36,a=ee(i),o=e.color===`transparent`?d:e.color;return q({text:e.label,fontSize:i,fontFamily:e.fontFamily,color:t.theme.paint(e=>p(o,e),o),lineHeight:T,x:r,y:n.y+n.height+a,align:`middle`,vAlign:`top`,rotation:e.rotation,rotateCenter:{x:r,y:n.y+n.height/2}},t)}function yt(e,t){if(!e.text)return``;let n=v(e,t.measurement),r=e.textAlign??`left`,i=e.textVAlign??`top`,a=M(e.fontFamily),o=(e.letterSpacing??0)*e.fontSize,s=e.width??Math.max(...w(e.text).split(`
4
+ `).map(n=>t.text.measure(n,e.fontSize,e.fontFamily,a)+o*n.length));return q({text:e.text,fontSize:e.fontSize,fontFamily:e.fontFamily,color:t.theme.paint(t=>p(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:S(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)}function Y(t,n,r,i){let a={};for(let[s,l]of Object.entries(t))a[s]=typeof l==`string`?r.paint(t=>e(s,l,n,e=>p(e,t),e=>c(e,t),i?o(i,t):void 0),l):l;return a}function X(e,t,n=`keep`,r){return e.filter(e=>e!==null).map(e=>z(e.tag,Y(e.attrs,n,t,r))).join(``)}function bt(e,t){let n=v(e),r=be(e),i={x:0,y:0,width:n.width,height:n.height},a=`translate(${n.x} ${n.y})`,o=B(e.rotation??0,i),s=e.fill===`#ffffff`?`paper`:`keep`,c=N(e)??void 0;return z(`g`,{transform:o?`${a} ${o}`:a},X([r.shadow],t.theme)+X([r.fill],t.theme,s,c)+X(r.strokes,t.theme,`keep`,c))}function xt(e){let t=v(e),n=Se(e),r={x:0,y:0,width:t.width,height:t.height},i=`translate(${t.x} ${t.y})`,a=B(A(e),r);return z(`g`,{transform:a?`${i} ${a}`:i},X([n.shadow,n.card],tt()))}function St(e,t){if(!e.text)return``;let n=v(e),r=e.fill===`transparent`?t.theme.paint(e=>p(d,e),ie(e.fill)):ie(e.fill);return q({text:e.text,fontSize:e.fontSize,fontFamily:e.fontFamily,color:r,fixedInk:e.fill!==`transparent`,lineHeight:e.lineHeight??1.25,letterSpacing:e.letterSpacing,x:n.x+n.width/2,y:n.y+n.height/2,align:`middle`,vAlign:`center`,maxWidth:n.width-28,rotation:e.rotation,rotateCenter:{x:n.x+n.width/2,y:n.y+n.height/2}},t)}function Ct(e,t){let n=v(e),r=we(e);return z(`g`,{transform:B(A(e),n)},X([r.outline],t.theme,`paper`)+X(r.chrome,t.theme))}function wt(e,t){let n=xe(e);return X(n.strokes,t.theme)+X(n.heads,t.theme,`ink`)}function Tt(e,t){let n=ve(e),r=Y(n.attrs,`ink`,t.theme),i=e.highlighter?{style:`mix-blend-mode:${t.theme.paint(m,m())}`}:void 0;return z(n.tag,{...r,opacity:e.opacity,...i})}function Et(e,t){return z(`path`,{...Y({d:Te(e.points,e.smooth),fill:e.fill,stroke:e.color},`ink`,t.theme),"stroke-width":e.strokeWidth})}function Dt(e,t){let n=v(e),{x:r,y:i,width:a,height:o}=l(n,e.crop),c=`imgclip-${e.id}`,u=t.srcMap.get(e.src)??e.src,d=z(`clipPath`,{id:c},z(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,rx:s(e.corner,n)})),f=z(`image`,{href:u,x:r,y:i,width:a,height:o,preserveAspectRatio:`none`,"clip-path":`url(#${c})`});return z(`g`,{transform:H(e,n)},d+f)}function Ot(e,t){let n=t.cachedNode(e);return n?n.map(([e,t])=>z(e,t)).join(``):``}function kt(e){let t=/^data:image\/svg\+xml(;base64)?,([\s\S]*)$/.exec(e.dataUrl);if(!t)return null;let n;try{n=t[1]?Fe(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=z(`filter`,{id:t},z(`feMorphology`,{operator:`erode`,radius:-d/4}))+z(`g`,{filter:`url(#${t})`},f)}return z(`svg`,o,f)}function Z(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(P(t)){let e=i.assetIconUrl(t,n),u=r.get(e);if(u&&ge(t)){let e=kt({dataUrl:u,x:a,y:o,size:s,height:c,ink:l,weight:d,weightId:f});if(e)return e}return z(`image`,{href:u??e,x:a,y:o,width:s,height:c})}return z(`g`,{transform:`translate(${a} ${o}) scale(${s/24})`,fill:`none`,stroke:l,"stroke-width":u,"stroke-linecap":`round`,"stroke-linejoin":`round`},Ot(n,i))}function At(e,t,n){let r=v(t),i=C(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=z(`rect`,{x:a,y:o,width:28,height:28,rx:6,fill:`#ffffff`,stroke:t.color,"stroke-width":1.5}),c=Z({source:e.source,name:e.name,srcMap:n.srcMap,icons:n.icons,x:a+5,y:o+5,size:18,stroke:t.color});return z(`g`,{transform:B(t.rotation??0,r)},s+c)}function jt(e,t,n){let r=v(t),i=t.fontSize??20,a=O(i),o=x(i),s=t.textPadding??6,c=t.textAlign??`center`,l=t.textVAlign??`middle`,u=M(t.fontFamily),d=w(t.label).split(`
5
+ `),f=E(t.kind,r.width,r.height,{x:t.flipX,y:t.flipY}),p=Math.max(i,r.width-f.left-f.right-s*2-a-o),m=d.map(e=>n.text.measure(e,i,t.fontFamily,u)),h=Math.min(p,Math.max(0,...m)),g=m.reduce((e,t)=>e+Math.max(1,Math.ceil(t/p)),0)*(i*(t.lineHeight??1.25)),_=l===`top`?r.y+s:l===`bottom`?r.y+r.height-s-g:r.y+r.height/2-g/2,y=a+o+h,b=c===`left`?r.x+s:c===`right`?r.x+r.width-s-y:r.x+r.width/2-y/2,C=_+S(i,t.lineHeight??1.25)-i*.3-a/2,T=ot(t,n),D=Z({source:e.source,name:e.name,srcMap:n.srcMap,icons:n.icons,x:b,y:C,size:a,stroke:T});return z(`g`,{transform:B(t.rotation??0,r)},D)}function Mt(e,t){let n=v(e),r=n.width/24,i=Z({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=>p(e.color,t),e.color),strokeWidth:r>0?a(e.strokeWidth,n.width)/r:e.strokeWidth,weight:f(e.strokeWidth,n.width),weightId:e.id});return z(`g`,{transform:H(e,n)},i)}function Nt(e,t){let n=_e(e),r=z(`rect`,{x:n.frame.x,y:n.frame.y,width:n.frame.width,height:n.frame.height,fill:t.theme.paint(e=>k(`#ffffff`,e),`#ffffff`),stroke:F,"stroke-width":1});for(let e of n.cellFills)r+=z(`rect`,{x:e.rect.x,y:e.rect.y,width:e.rect.width,height:e.rect.height,fill:t.theme.paint(t=>k(e.fill,t),e.fill)});for(let e of n.dividers)r+=z(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:F,"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=ye(e,n,i);r+=q({text:a,fontSize:s.fontSize,fontFamily:s.fontFamily,color:t.theme.paint(e=>p(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:T},t)}return r}function Pt(e,t){let n=e=>e===void 0?void 0:t.paint(t=>u(e,t),u(e));return e.kind===`rect`?z(`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`?z(`line`,{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2,stroke:n(e.stroke),"stroke-width":e.width}):e.kind===`polyline`?z(`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`?z(`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`?z(`circle`,{cx:e.cx,cy:e.cy,r:e.r,fill:n(e.fill),stroke:n(e.stroke),"stroke-width":e.width}):z(`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 Ft(e,t){let n=v(e),r=t.theme.paint(e=>k(I,e),I),i=z(`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+=Pt(n,t.theme));return z(`g`,{transform:B(A(e),n)},i)}function It(e,t){let n=v(e),r=``;for(let n of le(e,t.text))r+=Pt(n,t.theme);return z(`g`,{transform:B(A(e),n)},r)}var Q=15,Lt=12,Rt=28,zt=16;function $(e,t,n,r){let i=e=>r.text.measure(e,n,pe)<=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 Bt(e,t,n,r){let i=Rt/2,a={fill:`none`,stroke:r,"stroke-width":1.75,"stroke-linecap":`round`};if(e===`play`){let e=i*.42;return z(`circle`,{cx:t,cy:n,r:i,...a})+z(`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 z(`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 z(`circle`,{cx:t,cy:n,r:i,...a})+z(`ellipse`,{cx:t,cy:n,rx:i*.45,ry:i,...a})+z(`path`,{d:`M${t-i} ${n}H${t+i}`,...a})}function Vt(e,t){let n=v(e),r=Math.min(12,n.width/4,n.height/4),i=t.theme.paint(e=>p(d,e),d),a=z(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,rx:r,fill:`none`,stroke:i,"stroke-opacity":.2});if(e.poster){let i=`webclip-${e.id}`;return z(`clipPath`,{id:i},z(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,rx:r}))+z(`image`,{href:t.srcMap.get(e.poster)??e.poster,x:n.x,y:n.y,width:n.width,height:n.height,preserveAspectRatio:`xMidYMid slice`,"clip-path":`url(#${i})`})+a}let o=t.theme.paint(e=>k(I,e),I),s=z(`rect`,{x:n.x,y:n.y,width:n.width,height:n.height,rx:r,fill:o,stroke:i,"stroke-opacity":.2}),c=fe(e),l=Math.max(0,n.width-zt*2),u=$(c.title,l,Q,t),f=$(c.caption,l,Lt,t),m=n.height>=96,h=f!==``&&n.height>=52,g=m?38:0,_=h?19:0,y=g+Q*1.25+_,b=n.x+n.width/2,x=n.y+(n.height-y)/2,S=s;m&&(S+=Bt(c.glyph,b,x+Rt/2,i),x+=g);let C=(e,t,n,r)=>z(`text`,{x:b,y:n+t*.95,"font-family":pe,"font-size":t,fill:i,"fill-opacity":r,"text-anchor":`middle`},L(e));return u&&(S+=C(u,Q,x)),x+=Q*1.25,h&&(S+=C(f,Lt,x+4,.6)),S}function Ht(e,t){let n=Ut(e,t);return!n||e.type===`draw`||!(e.opacity<1)?n:z(`g`,{opacity:e.opacity},n)}function Ut(e,t){switch(e.type){case`rectangle`:return bt(e,t)+ct(e,t)+(e.titleIcon?e.titleIcon.placement===`inside`?jt(e.titleIcon,e,t):At(e.titleIcon,e,t):``);case`sticky`:return xt(e)+St(e,t);case`figure`:return Ct(e,t)+pt(e,t)+ft(e,t);case`arrow`:return wt(e,t)+gt(e,g(e),t)+_t(e,t);case`line`:return wt(e,t)+gt(e,h(e.points,e.labelAlong),t);case`draw`:return Tt(e,t);case`polygon`:return Et(e,t);case`image`:return Dt(e,t);case`icon`:return Mt(e,t)+vt(e,t);case`text`:return yt(e,t);case`table`:return Nt(e,t);case`chart`:return Ft(e,t);case`control`:return It(e,t);case`web`:return Vt(e,t);default:return te(e)}}async function Wt(e,t,n){let r=new Set;for(let n of e)n.type===`image`&&!n.src.startsWith(`data:`)&&r.add(n.src),n.type===`web`&&n.poster&&!n.poster.startsWith(`data:`)&&r.add(n.poster),n.type===`icon`&&P(n.source)&&r.add(t.assetIconUrl(n.source,n.name)),(n.type===`rectangle`||n.type===`figure`)&&n.titleIcon&&P(n.titleIcon.source)&&r.add(t.assetIconUrl(n.titleIcon.source,n.titleIcon.name));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}de(`asset-inline`,Error(`asset was not inlined`),e)})),i}function Gt(e){let t=e.filter(e=>e.type===`figure`),n=e.filter(e=>e.type!==`figure`);return[...t,...n]}function Kt(e){return e?et(e)?rt(e):nt(e):tt()}async function qt(e,t,n={}){await re();let r=n.padding??16,i=n.bounds??_(e,n.measurement);if(!i)return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:1,height:1});let a=i.x,o=i.y,s=i.x+i.width,c=i.y+i.height;if(!n.bounds)for(let n of e){let e=[];if(n.type===`figure`){let r=mt(n,t.text);r&&e.push(r)}else(n.type===`arrow`||n.type===`line`)&&e.push(...je(n,t.text));for(let t of e)a=Math.min(a,t.x),o=Math.min(o,t.y),s=Math.max(s,t.x+t.width),c=Math.max(c,t.y+t.height)}let l={x:a,y:o,width:s-a,height:c-o};await t.text.prepare(n.fonts);let[,u,d]=await Promise.all([t.icons.ensureCatalog().catch(e=>{de(`icon-catalog`,e)}),n.embedFonts===!1?Promise.resolve(``):t.fonts.embed(me(e),n.fonts),Wt(e,t.icons,t.assets)]),f=l.x-r,p=l.y-r,m=Math.max(1,Math.round(l.width+r*2)),h=Math.max(1,Math.round(l.height+r*2)),g=Kt(n.palette),v={text:t.text,icons:t.icons,srcMap:d,theme:g,measurement:n.measurement},b=Gt(e).map(e=>{let t=Ht(e,v),n=e.type===`rectangle`||e.type===`control`?y(e.link):e.type===`web`&&e.kind===`embed`?y(e.url):void 0;return n?z(`a`,{href:n,target:`_blank`,rel:`noopener`},t):t}).join(``),x=n.palette!==void 0&&et(n.palette),S=n.background??(x?g.paint(e=>e.bg,`#ffffff`):`#ffffff`),C=S===`transparent`?``:z(`rect`,{x:0,y:0,width:m,height:h,fill:S}),w=[u,g.css()].filter(Boolean).join(`
6
+ `),T=w?z(`defs`,{},z(`style`,{type:`text/css`},`\n${w}\n`)):``,E=z(`g`,{transform:`translate(${-f} ${-p})`},b),D=n.width?{width:n.width,height:Math.max(1,Math.round(h*n.width/m))}:{width:m,height:h},O=n.title?z(`title`,{},L(n.title)):``;return z(`svg`,{xmlns:`http://www.w3.org/2000/svg`,"xmlns:xlink":`http://www.w3.org/1999/xlink`,class:g.rootClass,role:n.title?`img`:void 0,"aria-label":n.title,width:D.width,height:D.height,viewBox:`0 0 ${m} ${h}`},O+T+C+E)}function Jt(e){return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}export{qt as n,Jt as t};
@@ -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{i as r}from"./config-D8b1QyEk.js";import{a as i,i as a,o,s}from"./editor-BeufBV54.js";import{g as c,i as l,o as u}from"./slides-D686obFO.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-sC9UHj3_.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=s(),k=i(),{canvasMeta:A}=r(),j=te(),P=o(e=>e.selectedIds.size),F=a(e=>[e.shapes],e=>u(l(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{a as r,o as i}from"./editor-BeufBV54.js";import{C as a,S as o,Yr as s,Zt as c,an as l,w as u,x as d}from"./slides-D686obFO.js";import{r as f,t as p}from"./dom-PAoZruqo.js";import{t as m}from"./editable-target-BTLnvKNi.js";import{t as h}from"./use-key-held-094C3Mn3.js";import{t as g}from"./createReactComponent-C51FAx3B.js";import{a as _,r as v}from"./flow-start-CpAvU-9P.js";import{a as y,c as b,d as x,f as S,g as C,h as w,m as T,n as E,o as D,r as O,x as k,y as A}from"./tree-KSgPjntC.js";import{t as j}from"./IconChevronLeft-D7e7QC0h.js";import{t as M}from"./IconChevronRight-csfMBSUs.js";import{t as N}from"./IconFocusCentered-Cn8rbfRI.js";import{t as P}from"./IconLink-VS5p9Ytk.js";import{t as F}from"./IconPencil-D_pQsAyv.js";import{t as I}from"./IconPlus-D4tAoi-A.js";import{t as L}from"./IconX-KrRqxr2j.js";import{t as R}from"./IconPlayerPlayFilled-DVAWmYt7.js";import{n as z}from"./core-CmsJyU_-.js";import{r as ee,t as B}from"./chrome-layout-BzPU9far.js";import{c as V,i as H,l as U,n as W,o as te,s as G,t as ne}from"./flows-Cj7AFMIA.js";import{a as K,i as q,n as re,o as ie,r as ae,t as oe}from"./flow-stage-Ba_CAggI.js";var se=g(`outline`,`rotate`,`Rotate`,[[`path`,{d:`M19.95 11a8 8 0 1 0 -.5 4m.5 5v-5h-5`,key:`svg-0`}]]),ce=g(`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),le=6;function ue(e){let t=e instanceof Element?e:null;return!!(t?.closest(`[data-canvas-root]`)&&!t.closest(`[data-overlay]`))}function de(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&&ue(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)<=le&&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,fe=.5,pe=4,me=24;function he(e){let{frame:t,flow:n,targets:o,viewport:s}=e,c=r(),f=i(e=>e.hoveredId),p=i(e=>e.flowEdit)??{},m=ee()===`docked`,h=n.steps.length;(0,J.useEffect)(()=>{let{store:e,viewportAnimation:n}=c,r=e.getState(),i=document.querySelector(`[data-canvas-root]`),a={width:(i?.clientWidth??window.innerWidth)-(m?B(`flow`):0),height:i?.clientHeight??window.innerHeight},o=l(t),s=u({x:o.x,y:o.y-Z},r.viewport),f=u({x:o.x+o.width,y:o.y+o.height},r.viewport),p=s.x>=0&&s.y>=0&&f.x<=a.width&&f.y<=a.height,h=f.x-s.x>=a.width*fe||f.y-s.y>=a.height*fe;p&&h||n.animate(r.viewport,d(o,a,64),r.setViewport)},[t.id,c,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`),a=c.store.getState(),o=a.shapes.find(e=>e.id===t.id);if(!i||o?.type!==`figure`)return;let s=z(a.shapes,o).find(e=>e.id===i);if(!s)return;e.preventDefault(),e.stopPropagation(),ge();let l=w({selected:a.flowEdit?.picking},g.current);if(l!==null){x(c,t.id,n.id,l,s);return}if(a.flowEdit?.picking!=null&&a.patchFlowEdit({picking:null}),e.shiftKey){b(c,t.id,n.id,s);return}D(c,t.id,n.id,s)};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},[c,t.id,n.id]),de(e=>{let r=c.store.getState(),i=r.shapes.find(e=>e.id===t.id),o=document.querySelector(`[data-canvas-root]`)?.getBoundingClientRect();if(!i||!o)return;let s=a({x:e.clientX-o.left,y:e.clientY-o.top},r.viewport),u=l(i);s.x>=u.x-X&&s.x<=u.x+u.width+X&&s.y>=u.y-Z&&s.y<=u.y+u.height+X||S(c,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(o.map(e=>[e.id,e])),E=f?y.get(f):void 0,O=C(p,h),k=w(p,h),A=w({selected:p.picking},h),j=T(p,h),M=w({selected:p.hovered},h),N=W(t.flows??[],n.id),P=N?.flow.steps[N.index],F=n.steps[O-1]?.target,I=new Map(o.map(e=>[e.id,H(o,e)])),L=E&&(A!==null||E.id!==F||_)?E:null,R=L?{id:L.id,number:_e(A,_?j:null,O)}:null,U=[...new Set([M,k])].flatMap(e=>e===null?[]:V(n.steps[e]));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ye,{frame:t,viewport:s}),P&&V(P).flatMap(e=>{let t=y.get(e);return t?[(0,Y.jsx)(Oe,{shape:t,viewport:s,hint:h===0},e)]:[]}),[...new Set(U)].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:K(t,s,5)},e)]:[]}),L&&(0,Y.jsx)(`div`,{"data-testid":`flow-add-hint`,"aria-label":ve(A,_?j:null,O,h),className:`pointer-events-none absolute rounded-md ring-[1.5px] ring-[var(--canvas-selection)]`,style:K(L,s,5)}),(0,Y.jsx)(Se,{flow:n,byId:y,viewport:s,slot:O}),(0,Y.jsx)(Ce,{flow:n,targets:o,fork:P,viewport:s}),(0,Y.jsx)(Ee,{flow:n,byId:y,viewport:s,selected:k,names:I,ghost:R,onSelect:e=>c.store.getState().patchFlowEdit({selected:e}),onDrop:(e,r)=>x(c,t.id,n.id,e,r)}),(0,Y.jsx)(be,{picking:A,slot:O,count:h})]})}function ge(){let e=document.activeElement;e instanceof HTMLElement&&m(e)&&e.blur()}function _e(e,t,n){return e===null?t===null?n+1:t+1:e+1}function ve(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 ye(e){let{frame:t,viewport:n}=e,r=l(t),i=u({x:r.x-X,y:r.y-Z},n),a=u({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 be(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 xe(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 Se(e){let{flow:t,byId:n,viewport:i,slot:a}=e,o=r(),c=t.steps.slice(1).flatMap((e,r)=>{let i=t.steps[r],a=xe(i,e,n);return a?[{arrow:a,slot:r+1}]:[]}),l=new Map;for(let{arrow:e}of c)l.set(e.id,(l.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 r=(n-((l.get(e.id)??1)-1)/2)*me,c=u(s(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+r,top:c.y+(f?16:0)},onPointerDown:e=>e.stopPropagation(),onClick:()=>o.store.getState().patchFlowEdit({slot:t,picking:null}),children:(0,Y.jsx)(I,{size:9,stroke:2.5})},`${e.id}-${t}`)})})}function Ce(e){let{flow:t,targets:n,fork:i,viewport:a}=e,o=r(),s=[...y(n,t.steps,i).values()];return(0,Y.jsx)(Y.Fragment,{children:[...new Map(s.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 i=H(n,r),s=u(t.point,a),c=u(we(r,t.point),a),l=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:[l>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:l,transform:`rotate(${d}rad)`}}),(0,Y.jsxs)(`button`,{type:`button`,"data-overlay":!0,"data-testid":`flow-loose-end`,"aria-label":`Attach the arrow to ${i}`,title:`This arrow isn't attached to ${i}, so the flow can't follow 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:()=>O(o,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)(P,{size:11,stroke:2}),`Attach`]})]})]},`${e.arrow.id}-${t.end}`)}))})}function we(e,t){let n=l(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 Te(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 Ee(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=ie(t),f=q(t),p=new Set(n.keys()),m=(e,t)=>{if(e.button!==0)return;e.stopPropagation(),e.preventDefault(),ge();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>pe;u({...l,x:e.clientX-l.origin.left,y:e.clientY-l.origin.top,dragging:n,over:n?Te(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:K(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=ae(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-5 min-w-5 cursor-grab touch-none items-center justify-center rounded-full px-1 text-[11px] font-semibold tabular-nums transition-colors active:cursor-grabbing ${De(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-5 min-w-5 items-center justify-center rounded-full bg-[var(--canvas-bg)] px-1 text-[11px] 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 De(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 Oe(e){let{shape:t,viewport:n,hint:r}=e,i=ae(t,n),a=K(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)(k,{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 ke=2600,Ae=.55,je=1.1;function Me(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?B(t):0)),height:Math.max(1,i-Pe)}}var Ne={call:`Call`,async:`Fire and forget`,reply:`Reply`},Pe=150;function Fe(e){let{frame:t,flow:n,targets:a,step:s,viewport:u}=e,f=r(),{store:p,viewportAnimation:m}=f,g=i(e=>e.rightPanel),_=ee()===`docked`,y=n.steps.length,b=Math.min(Math.max(s,0),Math.max(y-1,0)),x=n.steps[b],S=(0,J.useMemo)(()=>new Map(a.map(e=>[e.id,e])),[a]),C=(0,J.useMemo)(()=>x?V(x).flatMap(e=>S.get(e)??[]):[],[x,S]),w=(0,J.useMemo)(()=>{let e=b>0?n.steps[b-1]:void 0;return e?V(e).flatMap(e=>S.get(e)??[]):[]},[n.steps,b,S]),T=i(e=>e.flowPlay?.trail),D=i(e=>e.viewMode),O=T?.[T.length-1],k=O?t.flows?.find(e=>e.id===O.flowId)?.name:void 0,[j,M]=(0,J.useState)(!1),[N,P]=(0,J.useState)(()=>d(l(t),Me(_,g),64).zoom<Ae),F=e=>{let r=Math.min(Math.max(e,0),y-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:E(z).filter(e=>e.steps.length>0).map(e=>({id:e.id,name:e.name})),active:Ie(z,n.id,T),onTab:e=>{M(!1),p.getState().setFlowPlay({frameId:t.id,flowId:e,step:0})},onEdit:D?null:()=>A(f,t.id,n.id),onNew:D?null:()=>{p.getState().setFlowPlay(null),v(f,t.id)}},H=(0,J.useRef)(F);H.current=F;let U=(0,J.useRef)(R);U.current=R;let W=(0,J.useRef)(b);W.current=b;let G=()=>Me(_,g),K=(0,J.useRef)(G);if(K.current=G,(0,J.useEffect)(()=>{let e=p.getState();e.setSelectedIds(new Set),m.animate(e.viewport,d(l(t),K.current(),64),e.setViewport)},[t.id,p,m]),(0,J.useEffect)(()=>{let e=c(N?[...C,...w]:C);if(!e)return;let t=p.getState();if(N){let n=d(e,K.current(),120),r=Math.min(n.zoom,je),i=K.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=o(e,t.viewport,K.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`)&&h(e.target))return;let t=W.current;if(e.key===`ArrowRight`||e.key===` `||e.key===`Enter`)e.preventDefault(),H.current(t+1);else if(e.key===`ArrowLeft`||e.key===`Backspace`){if(e.preventDefault(),t===0&&L.current){L.current();return}H.current(t-1)}else e.key===`Home`?(e.preventDefault(),H.current(0)):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),U.current())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[]),de(()=>U.current()),(0,J.useEffect)(()=>{let e=e=>{e.pointerType===`touch`||e.button!==0||!ue(e.target)||(e.preventDefault(),e.stopPropagation())};return window.addEventListener(`pointerdown`,e,!0),()=>window.removeEventListener(`pointerdown`,e,!0)},[]),(0,J.useEffect)(()=>{if(!j)return;if(b>=y-1||(x?.branches?.length??0)>0){M(!1);return}let e=window.setTimeout(()=>H.current(W.current+1),ke);return()=>window.clearTimeout(e)},[j,b,y,x]),!x)return(0,Y.jsx)(Le,{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)(oe,{frameId:t.id,flow:n,targets:a,index:b,viewport:u,lead:q}),(0,Y.jsx)(Le,{flow:n,index:b,kind:te(a,[...q,...n.steps],q.length+b),autoplay:j,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 Ie(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=W(e,i);if(!t)return i;i=t.flow.id}return i}function Le(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],v=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)(ze,{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:Ne[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)(k,{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)(L,{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)(_,{size:13,stroke:2}),u]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,children:`/`})]}),(u||!m.tabs.some(e=>e.id===t.id)||!Re(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)(k,{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)(j,{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)(N,{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&&v&&o(0),a(!i)},children:i?(0,Y.jsx)(ce,{size:14}):(0,Y.jsx)(R,{size:14})}),v&&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)(se,{size:15,stroke:1.75})}):(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Next step`,"data-testid":`flow-next`,className:y,disabled:v,onClick:()=>o(n+1),children:(0,Y.jsx)(M,{size:16,stroke:2})})]})]})]})}function Re(e){return e.tabs.length>1||e.onEdit!==null}function ze(e){let{tabs:t,active:n,onTab:r,onEdit:i,onNew:a}=e.switcher;if(!Re(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)(I,{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)(F,{size:13,stroke:1.75}),`Edit`]})]})}var $=10,Be=28,Ve=.28;function He(e){let{viewport:t}=e,{store:n}=r(),a=i(e=>e.shapes),o=i(e=>e.flowEdit),s=i(e=>e.flowPlay),c=i(e=>e.flowPreview),l=s??o??c,u=(0,J.useMemo)(()=>{let e=l?a.find(e=>e.id===l.frameId):void 0;return e?.type===`figure`?e:null},[a,l]),d=(0,J.useMemo)(()=>u?z(a,u):[],[a,u]),f=u?.flows?.find(e=>e.id===l?.flowId),p=(0,J.useMemo)(()=>f?G(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:s?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ue,{frame:u,viewport:t}),(0,Y.jsx)(Fe,{frame:u,flow:p,targets:d,step:s.step,viewport:t})]}):o?(0,Y.jsx)(he,{frame:u,flow:p,targets:d,viewport:t}):(0,Y.jsx)(We,{flow:p,targets:d,viewport:t})}function Ue(e){let{frame:t,viewport:n}=e,r=l(t),i=u({x:r.x-$,y:r.y-Be},n),a=u({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 We(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(V));t.steps.forEach((r,i)=>{let a=t.steps[i-1];if(a)for(let t of V(r))for(let r of V(a)){let i=U(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)&&t.type!==`figure`).flatMap(e=>[f(e.id),p(`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:${Ve}!important}`:``].join(``)},[t.steps,n])}),(0,Y.jsx)(re,{numbers:ie(t),byId:i,viewport:r,current:null,failing:q(t)})]})}export{He 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-CyBz17g8.js";import{D as i,E as a,T as o,g as s,h as c,i as l,l as u,m as d,o as f,p,r as m,t as h}from"./menu-B9BAk63v.js";import{i as g}from"./config-D8b1QyEk.js";import{a as _,o as v}from"./editor-BeufBV54.js";import{k as y}from"./slides-D686obFO.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-CpAvU-9P.js";import{n as T,r as E,t as D}from"./IconTrash-C8w6ThWx.js";import{_ as O,a as k,b as A,f as te,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-KSgPjntC.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-KacA9GM8.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 W}from"./IconX-KrRqxr2j.js";import{t as ge}from"./IconPlayerPlayFilled-DVAWmYt7.js";import{n as _e,r as ve,t as G}from"./core-CmsJyU_-.js";import{n as ye}from"./surface-Dke4SWpE.js";import{a as be}from"./chrome-C2RCq3SI.js";import"./chrome-layout-BzPU9far.js";import{t as xe}from"./panel-shell-BnMOHgWM.js";import{i as Se,n as Ce,s as we}from"./flows-Cj7AFMIA.js";var Te=b(`outline`,`arrows-exchange`,`ArrowsExchange`,[[`path`,{d:`M7 10h14l-4 -4`,key:`svg-0`}],[`path`,{d:`M17 14h-14l4 4`,key:`svg-1`}]]),K=b(`outline`,`bolt`,`Bolt`,[[`path`,{d:`M13 3l0 7l6 0l-8 11l0 -7l-6 0l8 -11`,key:`svg-0`}]]),q=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`}]]),Ee=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`}]]),J=e(t(),1),De=`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)]`,Oe=`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`,ke=`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)]`,Ae=`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)]`,je=`hover:bg-[color-mix(in_srgb,var(--chrome-fg-900)_3%,transparent)]`,Me=`bg-[color-mix(in_srgb,var(--chrome-fg-900)_5%,transparent)]`,Ne=`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`,Y=n(),Pe=2e3,Fe=`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 Ie(e){let{count:t,attached:n,onAttach:r,onSettled:i}=e,a=(0,J.useRef)(i);a.current=i;let o=t===0&&n;return(0,J.useEffect)(()=>{if(!o)return;let e=window.setTimeout(()=>a.current(),Pe);return()=>window.clearTimeout(e)},[o]),o?(0,Y.jsxs)(`div`,{"data-testid":`flow-loose-attached`,role:`status`,className:`${Fe} items-center`,children:[(0,Y.jsx)(I,{size:14,stroke:2,className:`shrink-0 text-[var(--chrome-fg-500)]`}),`Arrow attached`]}):t===0?null:(0,Y.jsx)(Le,{count:t,onAttach:r})}function Le(e){let{count:t,onAttach:n}=e,r=(0,J.useRef)(null);(0,J.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,Y.jsxs)(`div`,{ref:r,role:`status`,"data-testid":`flow-loose-banner`,className:`${Fe} items-start`,children:[(0,Y.jsx)(x,{size:14,stroke:2,className:`mt-px shrink-0 text-[var(--flow-warn)]`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`b`,{className:`block font-medium text-[var(--chrome-fg-900)]`,children:i?`1 arrow isn't attached`:`${t} arrows aren't attached`}),`The hand-off can't follow `,i?`it`:`them`,`.`]}),(0,Y.jsx)(`button`,{type:`button`,"data-testid":`flow-attach-all`,className:`${Ne} h-7 shrink-0 px-2.5 text-[12px]`,onClick:n,children:i?`Attach`:`Attach all`})]})}var Re=`w-[1.5px] bg-[color-mix(in_srgb,var(--chrome-fg-900)_14%,transparent)]`,ze=`w-[1.5px] bg-[var(--flow-accent)]`,Be=`w-[1.5px] bg-[linear-gradient(color-mix(in_srgb,var(--chrome-fg-900)_14%,transparent),transparent)]`,X=`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`,Ve=`shadow-[inset_0_0_0_1.5px_color-mix(in_srgb,var(--chrome-fg-900)_22%,transparent)]`,He=`${X} 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)]`,Ue=`${X} bg-[var(--chrome-popup)] text-[var(--chrome-fg-900)] shadow-[inset_0_0_0_1.5px_var(--chrome-fg-900)]`;function We(e){return e.picking?Ue:e.current?`${X} bg-[var(--flow-accent)] text-white`:e.selected?`${X} text-white ${e.fails?`bg-[var(--flow-fail)]`:`bg-[var(--chrome-accent)]`}`:e.fails?`${X} bg-[var(--chrome-popup)] text-[var(--flow-fail)] shadow-[inset_0_0_0_1.5px_var(--flow-fail)]`:`${X} bg-[var(--chrome-popup)] text-[var(--chrome-fg-700)] ${Ve} hover:shadow-[inset_0_0_0_1.5px_var(--chrome-fg-500)]`}function Ge(e){let{node:t,first:n,end:r,litAbove:i,litBelow:a}=e;return(0,Y.jsxs)(`span`,{className:`flex w-[22px] shrink-0 flex-col items-center`,children:[(0,Y.jsx)(`span`,{className:`h-2 shrink-0 ${n?`w-[1.5px]`:i?ze:Re}`}),t,(0,Y.jsx)(`span`,{className:`min-h-2 flex-1 ${r?Be:a?ze:Re}`})]})}var Ke=[{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}],qe=e=>Ke.find(t=>t.kind===e)?.label,Je=`${De} -mx-1.5 px-1.5 hover:ring-transparent focus:bg-transparent focus:ring-transparent`;function Ye(e){let{step:t,index:n,count:r,current:a,selected:o,picking:s,names:c,otherFlows:l,loose:u}=e,{rail:d,actions:p,grip:m,rowRef:h,rowStyle:g}=e,{onPlay:_,onChange:v,onMove:y,onRemove:ee,onNewPath:b}=p,[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(!1),E=(0,J.useRef)(null),D=t.kind??`call`,O=t.also??[],k=t.branches??[],A=new Map(l.map(e=>[e.id,e.name])),te=o||w||S,ne=te||!!t.text,j=S||!!t.payload,re=O.length>0||D!==`call`||j||k.length>0;return(0,Y.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?Me:je}`,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,Y.jsx)(Xe,{index:n,onInsert:p.onInsertBefore}),(0,Y.jsx)(Ge,{first:d.first,end:d.end,litAbove:d.litAbove,litBelow:d.litBelow,node:(0,Y.jsx)(`span`,{"data-testid":`flow-step-grip-${n}`,title:`Drag to reorder`,className:`${We({selected:o,current:a,fails:!!t.fails,picking:s})} cursor-grab touch-none transition-shadow active:cursor-grabbing`,...m,children:s?(0,Y.jsx)(Te,{size:12,stroke:2}):n+1})}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5 py-2 pr-6`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Y.jsx)(`input`,{"aria-label":`Step title`,"data-testid":`flow-step-title-${n}`,className:`${Je} 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}$(e)}},`t-${t.title}`),!o&&(0,Y.jsx)(Ze,{index:n,step:t,names:c,flowName:A,loose:u?.names??null})]}),ne&&(0,Y.jsx)(`textarea`,{ref:E,"aria-label":`What happens at this step`,"data-testid":`flow-step-text-${n}`,rows:1,className:`${Je} 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:`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:$},`d-${t.text??``}`),t.fails&&(0,Y.jsx)(`span`,{"data-testid":`flow-step-fails-${n}`,className:`text-[12px] leading-[1.55] text-[var(--flow-fail)]`,children:`Fails here`}),s&&(0,Y.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,Y.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,Y.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,Y.jsx)(x,{size:14,stroke:2,className:`mt-px shrink-0 text-[var(--flow-warn)]`}),(0,Y.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 the hand-off can't follow it.`,(0,Y.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,Y.jsx)(fe,{size:12,stroke:2}),`Attach`]})]})]}),te&&re&&(0,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,"data-testid":`flow-step-chips-${n}`,children:[D!==`call`&&(0,Y.jsx)(tt,{kind:D,onPick:e=>v({kind:e}),trigger:(0,Y.jsxs)(f,{"data-testid":`flow-step-kind-${n}`,className:`${Z} cursor-pointer hover:bg-[var(--chrome-hover)]`,children:[qe(D),(0,Y.jsx)(i,{size:11,stroke:2,className:`text-[var(--chrome-fg-400)]`})]})}),j&&(0,Y.jsx)(et,{index:n,payload:t.payload,editing:S,onEdit:()=>C(!0),onDone:e=>{C(!1),e!==(t.payload??``)&&v({payload:e||void 0})}}),O.map(e=>(0,Y.jsx)($e,{icon:(0,Y.jsx)(z,{size:11,stroke:2}),label:c.get(e)??`Shape`,title:`Part of this step`,onRemove:()=>v({also:O.filter(t=>t!==e)})},e)),k.map(e=>(0,Y.jsx)($e,{testId:`flow-step-path-${n}`,icon:(0,Y.jsx)(P,{size:11,stroke:2}),label:A.get(e)??`Missing flow`,title:`Another path from here`,onRemove:()=>v({branches:k.filter(t=>t!==e)})},e))]})]}),(0,Y.jsx)(it,{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 Xe(e){let{index:t,onInsert:n}=e;return(0,Y.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,Y.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,Y.jsx)(z,{size:10,stroke:2.5})}),(0,Y.jsx)(`span`,{className:`rounded bg-[var(--chrome-popup)] px-1 text-[11.5px] text-[var(--chrome-fg-500)]`,children:`Insert a step`})]})}function Ze(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,Y.jsx)(K,{size:13,stroke:1.75})}),n.kind===`reply`&&s.push({key:`kind`,label:`Reply`,icon:(0,Y.jsx)(S,{size:13,stroke:1.75})}),n.payload&&s.push({key:`payload`,label:`Carries ${n.payload}`,icon:(0,Y.jsx)(q,{size:13,stroke:1.75})}),n.also?.length){let e=n.also.map(e=>i.get(e)??`Shape`).join(`, `);s.push({key:`also`,label:`With ${e}`,icon:(0,Y.jsx)(Ee,{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,Y.jsx)(P,{size:13,stroke:1.75})})}return s.length===0&&!o?null:(0,Y.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-[var(--chrome-fg-400)]`,children:[s.map(e=>(0,Y.jsx)(r,{label:e.label,children:(0,Y.jsx)(`span`,{role:`img`,"aria-label":e.label,children:e.icon})},e.key)),o&&(0,Y.jsx)(r,{label:`The arrow isn't attached to ${o}`,children:(0,Y.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,Y.jsx)(x,{size:13,stroke:2})})})]})}var Z=`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)]`,Q=`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)]`,Qe=`min-w-[200px] p-1 outline-none ${ye.popup}`;function $e(e){let{label:t,icon:n,onRemove:r,testId:i,title:a,tone:o}=e;return(0,Y.jsxs)(`span`,{"data-testid":i,title:a,className:`${Z} 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,Y.jsx)(`span`,{className:`opacity-70`,children:n}),(0,Y.jsx)(`span`,{className:`max-w-[140px] truncate`,children:t}),(0,Y.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,Y.jsx)(W,{size:10,stroke:2})})]})}function et(e){let{index:t,payload:n,editing:r,onEdit:i,onDone:a}=e;return r?(0,Y.jsxs)(`span`,{className:`${Z} pr-1`,children:[(0,Y.jsx)(q,{size:11,stroke:2,className:`opacity-70`}),(0,Y.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,Y.jsxs)(`span`,{className:`${Z} pr-0.5`,"data-testid":`flow-step-payload-chip-${t}`,children:[(0,Y.jsx)(q,{size:11,stroke:2,className:`opacity-70`}),(0,Y.jsx)(`button`,{type:`button`,title:`What this step carries`,className:`max-w-[140px] cursor-text truncate`,onClick:i,children:n}),(0,Y.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,Y.jsx)(W,{size:10,stroke:2})})]})}function tt(e){let{kind:t,onPick:n,trigger:r}=e;return(0,Y.jsxs)(u,{children:[r,(0,Y.jsx)(d,{children:(0,Y.jsx)(p,{side:`bottom`,align:`start`,sideOffset:4,className:`z-50 outline-none`,children:(0,Y.jsx)(m,{"data-overlay":!0,className:`min-w-[220px] p-1`,children:(0,Y.jsx)(nt,{kind:t,onPick:n})})})})]})}function nt(e){let{kind:t,onPick:n}=e;return(0,Y.jsx)(Y.Fragment,{children:Ke.filter(e=>e.pickable).map(e=>(0,Y.jsxs)(s,{"data-testid":`flow-kind-${e.kind}`,className:Q,onClick:()=>n(e.kind===`call`?void 0:e.kind),children:[(0,Y.jsx)(`span`,{className:`flex w-4 justify-center text-[var(--chrome-fg-900)]`,children:t===e.kind&&(0,Y.jsx)(I,{size:14,stroke:2})}),(0,Y.jsxs)(`span`,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`text-[var(--chrome-fg-900)]`,children:e.label}),(0,Y.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:e.hint})]})]},e.kind))})}function rt(e){let{label:t,icon:n,testId:r,children:i}=e;return(0,Y.jsxs)(B,{children:[(0,Y.jsxs)(H,{className:`${Q} justify-between`,"data-testid":r,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:n}),t]}),(0,Y.jsx)(L,{size:14,stroke:1.75,className:`text-[var(--chrome-fg-400)]`})]}),(0,Y.jsx)(d,{children:(0,Y.jsx)(p,{className:`z-50 outline-none`,children:(0,Y.jsx)(c,{"data-overlay":!0,className:Qe,children:i})})})]})}function it(e){let{index:t,count:n,step:r,hasPayload:i,paths:c}=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,Y.jsxs)(u,{children:[(0,Y.jsx)(f,{"aria-label":`Step options`,"data-testid":`flow-step-menu-${t}`,className:`${Oe} 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,Y.jsx)(a,{size:14,stroke:1.75})}),(0,Y.jsx)(d,{children:(0,Y.jsx)(p,{side:`bottom`,align:`end`,sideOffset:4,className:`z-50 outline-none`,children:(0,Y.jsxs)(m,{"data-overlay":!0,className:`min-w-[210px] p-1`,children:[(0,Y.jsx)(h,{testId:`flow-step-play`,icon:(0,Y.jsx)(o,{size:15,stroke:1.75}),onClick:g,children:`Play from here`}),(0,Y.jsx)(l,{}),(0,Y.jsx)(h,{testId:`flow-step-change-box`,icon:(0,Y.jsx)(Te,{size:15,stroke:1.75}),onClick:w,children:`Change box…`}),(0,Y.jsx)(h,{testId:`flow-step-insert-above`,icon:(0,Y.jsx)(pe,{size:15,stroke:1.75}),onClick:S,children:`Add a step above`}),(0,Y.jsx)(h,{testId:`flow-step-insert-below`,icon:(0,Y.jsx)(me,{size:15,stroke:1.75}),onClick:C,children:`Add a step below`}),(0,Y.jsx)(l,{}),(0,Y.jsx)(rt,{label:`How it travels`,icon:(0,Y.jsx)(V,{size:15,stroke:1.75}),testId:`flow-step-travels`,children:(0,Y.jsx)(nt,{kind:r.kind??`call`,onPick:e=>v({kind:e})})}),!i&&(0,Y.jsx)(h,{testId:`flow-step-add-payload`,icon:(0,Y.jsx)(q,{size:15,stroke:1.75}),onClick:_,children:`Add what it carries`}),(0,Y.jsx)(h,{testId:`flow-step-toggle-fails`,icon:(0,Y.jsx)(x,{size:15,stroke:1.75}),onClick:()=>v({fails:!r.fails||void 0}),children:r.fails?`Doesn't fail here`:`Fails here`}),(0,Y.jsxs)(rt,{label:`Another path from here`,icon:(0,Y.jsx)(P,{size:15,stroke:1.75}),testId:`flow-step-paths`,children:[c.map(e=>(0,Y.jsx)(s,{className:Q,onClick:()=>v({branches:[...O,e.id]}),children:e.name},e.id)),c.length>0&&(0,Y.jsx)(l,{}),(0,Y.jsxs)(s,{className:Q,"data-testid":`flow-step-new-path`,onClick:b,children:[(0,Y.jsx)(z,{size:14,stroke:1.75,className:`text-[var(--chrome-fg-400)]`}),`New path`]})]}),(0,Y.jsx)(l,{}),(0,Y.jsx)(h,{testId:`flow-step-up`,icon:(0,Y.jsx)(T,{size:15,stroke:1.75}),disabled:t===0,onClick:()=>y(-1),children:`Move up`}),(0,Y.jsx)(h,{testId:`flow-step-down`,icon:(0,Y.jsx)(E,{size:15,stroke:1.75}),disabled:t===n-1,onClick:()=>y(1),children:`Move down`}),(0,Y.jsx)(h,{testId:`flow-step-remove`,icon:(0,Y.jsx)(D,{size:15,stroke:1.75}),onClick:ee,children:`Remove step`})]})})})]})}function $(e){e.stopPropagation(),(e.key===`Enter`&&!e.shiftKey||e.key===`Escape`)&&e.currentTarget.blur()}function at(){let e=_(),{store:t}=e,n=v(e=>e.shapes),i=v(e=>e.viewMode),a=(0,J.useMemo)(()=>ve(n),[n]),o=(0,J.useMemo)(()=>y(n).filter(e=>G(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,J.useEffect)(()=>()=>t.getState().setFlowPreview(null),[t]),(0,Y.jsxs)(xe,{width:300,testId:`flow-list`,ariaLabel:`Flows`,onDismiss:s,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 py-2 pl-4 pr-2`,children:[(0,Y.jsx)(`span`,{className:`flex-1 text-[14px] font-medium text-[var(--chrome-fg-900)]`,children:`Flows`}),!i&&o.length>0&&(0,Y.jsx)(ct,{frames:o,onPick:t=>w(e,t.id)}),(0,Y.jsx)(r,{label:`Close`,side:`bottom`,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Close flows`,"data-testid":`flow-list-close`,onClick:s,className:be,children:(0,Y.jsx)(W,{size:16,stroke:1.75})})})]}),(0,Y.jsx)(`div`,{className:`mx-3 h-px bg-[var(--chrome-divider)]`}),(0,Y.jsx)(`div`,{className:`flex flex-1 flex-col gap-4 overflow-y-auto p-3`,children:a.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-3 py-8 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-balance text-[13px] font-medium text-[var(--chrome-fg-900)]`,children:`No flows yet`}),(0,Y.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,Y.jsxs)(`section`,{className:`flex flex-col gap-0.5`,onPointerLeave:()=>c(n.id,null),children:[(0,Y.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,Y.jsx)(ot,{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 ot(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,Y.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,Y.jsx)(`span`,{className:`shrink-0 text-[var(--chrome-fg-400)]`,children:n>0?(0,Y.jsx)(P,{size:14,stroke:1.75}):(0,Y.jsx)(V,{size:14,stroke:1.75})}),(0,Y.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,Y.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`truncate text-[13px] font-medium text-[var(--chrome-fg-900)]`,children:t.name}),u&&(0,Y.jsx)(`span`,{title:`Shows something failing`,className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--flow-fail)]`})]}),(0,Y.jsx)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:i===null?d:`From step ${i} · ${d}`})]}),l>0&&(0,Y.jsx)(r,{label:`Play`,side:`left`,children:(0,Y.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,Y.jsx)(ge,{size:11})})})]})}var st=`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 ct(e){let{frames:t,onPick:n}=e,r=t.length===1?t[0]:void 0;return r?(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`flow-list-new`,title:`New flow on ${r.label||`the frame`}`,className:st,onClick:()=>n(r),children:[(0,Y.jsx)(z,{size:14,stroke:2}),`New`]}):(0,Y.jsxs)(u,{children:[(0,Y.jsxs)(f,{"data-testid":`flow-list-new`,className:st,children:[(0,Y.jsx)(z,{size:14,stroke:2}),`New`]}),(0,Y.jsx)(d,{children:(0,Y.jsx)(p,{side:`bottom`,align:`end`,sideOffset:6,className:`z-50 outline-none`,children:(0,Y.jsxs)(m,{"data-overlay":!0,className:`min-w-[240px] p-1`,children:[(0,Y.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,Y.jsx)(s,{"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 lt(e){let{frameId:t,readOnly:n}=e,r=_();return(0,Y.jsx)(d,{children:(0,Y.jsx)(p,{side:`bottom`,align:`end`,sideOffset:6,className:`z-50 outline-none`,children:(0,Y.jsx)(m,{"data-overlay":!0,"data-testid":`figure-flow-list`,className:`w-[300px] p-1`,finalFocus:()=>r.store.getState().flowEdit===null,children:(0,Y.jsx)(ut,{frameId:t,readOnly:n})})})})}function ut(e){let{frameId:t,readOnly:n}=e,r=_(),i=v(e=>{let n=e.shapes.find(e=>e.id===t);return n?.type===`figure`?n:null}),a=v(e=>e.lastFlow[t]),o=e=>r.store.getState().setFlowPreview(e?{frameId:t,flowId:e}:null);return(0,J.useEffect)(()=>()=>r.store.getState().setFlowPreview(null),[r]),i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsx)(`div`,{onPointerLeave:()=>o(null),children:M(i.flows??[]).map(({flow:e,depth:t,origin:r})=>(0,Y.jsx)(ft,{frame:i,flow:e,depth:t,forkStep:r?r.index+1:null,last:e.id===a,readOnly:n,onPreview:o},e.id))}),!n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(l,{}),(0,Y.jsx)(h,{testId:`figure-flow-new`,icon:(0,Y.jsx)(z,{size:15,stroke:1.75}),onClick:()=>w(r,t),children:`New flow`})]})]}):null}var dt=`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 ft(e){let{frame:t,flow:n,depth:r,forkStep:i,last:c,readOnly:l,onPreview:u}=e,f=_(),g=n.steps.length,v=n.steps.some(e=>e.fails);return(0,Y.jsxs)(`div`,{"data-testid":`figure-flow-row`,className:`flex items-center gap-0.5`,style:{paddingLeft:r*16},onPointerEnter:()=>u(n.id),children:[(0,Y.jsxs)(s,{"data-testid":`figure-flow-row-play`,disabled:g===0,className:`${ye.menuItem} min-w-0 flex-1`,onFocus:()=>u(n.id),onClick:()=>C(f,t.id,n.id),children:[(0,Y.jsx)(`span`,{className:c?`text-[var(--flow-accent)]`:`text-[var(--chrome-fg-400)]`,children:r>0?(0,Y.jsx)(P,{size:15,stroke:1.75}):c?(0,Y.jsx)(ge,{size:13}):(0,Y.jsx)(o,{size:15,stroke:1.75})}),(0,Y.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-[var(--chrome-fg-900)]`,children:n.name}),i!==null&&(0,Y.jsxs)(`span`,{className:`text-[11px] text-[var(--chrome-fg-400)]`,children:[`From step `,i]})]}),v&&(0,Y.jsx)(`span`,{title:`Shows something failing`,className:`h-1.5 w-1.5 shrink-0 rounded-full bg-[var(--flow-fail)]`}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-[var(--chrome-fg-400)]`,children:[g,` `,g===1?`step`:`steps`]})]}),!l&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(s,{"aria-label":`Edit ${n.name}`,"data-testid":`figure-flow-row-edit`,className:dt,onFocus:()=>u(n.id),onClick:()=>F(f,t.id,n.id),children:(0,Y.jsx)(R,{size:14,stroke:1.75})}),(0,Y.jsxs)(B,{children:[(0,Y.jsx)(H,{"aria-label":`More for ${n.name}`,"data-testid":`figure-flow-row-more`,className:dt,children:(0,Y.jsx)(a,{size:14,stroke:1.75})}),(0,Y.jsx)(d,{children:(0,Y.jsx)(p,{className:`z-50 outline-none`,sideOffset:4,children:(0,Y.jsxs)(m,{"data-overlay":!0,className:`min-w-[160px] p-1`,children:[(0,Y.jsx)(h,{testId:`figure-flow-rename`,icon:(0,Y.jsx)(R,{size:15,stroke:1.75}),onClick:()=>f.store.getState().setFlowEdit({frameId:t.id,flowId:n.id,rename:!0}),children:`Rename`}),(0,Y.jsx)(h,{testId:`figure-flow-delete`,icon:(0,Y.jsx)(D,{size:15,stroke:1.75}),onClick:()=>N(f,t.id,n.id),children:`Delete`})]})})})]})]})]})}var pt=/^Flow \d+$/;function mt(){let e=v(e=>e.flowEdit);return v(e=>e.rightPanel===`flow`)?e?(0,Y.jsx)(ht,{frameId:e.frameId,flowId:e.flowId},e.flowId):(0,Y.jsx)(at,{}):null}function ht(e){let{frameId:t,flowId:n}=e,{ai:i}=g(),a=_(),{store:o}=a,s=v(e=>e.shapes),c=v(e=>e.flowPlay),l=v(e=>e.flowEdit)??{},u=c!==null,d=c?.flowId===n?c.step:null,f=(0,J.useMemo)(()=>{let e=s.find(e=>e.id===t);return e?.type===`figure`?e:null},[s,t]),p=(0,J.useMemo)(()=>f?_e(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,J.useState)(null),[S,T]=(0,J.useState)(!1),[E,D]=(0,J.useState)(!1),M=o.getState().patchFlowEdit;(0,J.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=()=>te(a,t,n),I=()=>{h&&h.steps.length===0&&N(a,t,n),o.getState().setFlowsOpen(!0)},L=()=>{if(h&&h.steps.length>0&&pt.test(h.name)){x(bt(h));return}F()},fe=(0,J.useRef)(L);fe.current=L;let R=(0,J.useRef)(y);if(R.current=y,(0,J.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,Se(p,e)])),V=Ce(z,n),H=V?.flow.steps[V.index],pe=H?.title??``,me=k(p,h.steps,H),U=ne(l,y),ve=j(l,y),G=j({selected:l.picking},y),ye=ae(l,y),Te=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 Oe(){b!==null&&je(b),F()}function je(e){let r=e.trim();r&&r!==h?.name&&A(a,t,n,e=>({...e,name:r}))}return(0,Y.jsxs)(xe,{width:300,testId:`flow-panel`,ariaLabel:`Flow`,onDismiss:F,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 py-2 pl-1.5 pr-2`,children:[(0,Y.jsx)(r,{label:`All flows`,side:`bottom`,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`All flows`,"data-testid":`flow-panel-back`,onClick:I,className:be,children:(0,Y.jsx)(ue,{size:16,stroke:1.75})})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`,children:b===null?S?(0,Y.jsx)(`input`,{autoFocus:!0,"aria-label":`Flow name`,"data-testid":`flow-name`,className:`${De} text-[14px] font-medium`,defaultValue:h.name,onFocus:e=>e.target.select(),onBlur:e=>{je(e.target.value),T(!1)},onKeyDown:$}):(0,Y.jsx)(yt,{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,Y.jsx)(`input`,{autoFocus:!0,"aria-label":`Name this flow`,"data-testid":`flow-name-input`,className:`${De} 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()&&Oe(),e.key===`Escape`&&F()}})}),(0,Y.jsx)(r,{label:`Close`,side:`bottom`,children:(0,Y.jsx)(`button`,{type:`button`,"aria-label":`Close the flow panel`,"data-testid":`flow-panel-done`,onClick:F,className:be,children:(0,Y.jsx)(W,{size:16,stroke:1.75})})})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-4 pb-2.5`,children:[b===null?(0,Y.jsxs)(`span`,{className:`truncate text-[11px] text-[var(--chrome-fg-400)]`,children:[f.label||`Untitled frame`,` · `,y,` `,y===1?`step`:`steps`]}):(0,Y.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,Y.jsx)(`kbd`,{className:Ae,children:`↵`}),` save · `,(0,Y.jsx)(`kbd`,{className:Ae,children:`esc`}),` keep "`,h.name,`"`]}),V&&(0,Y.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,Y.jsx)(de,{size:13,stroke:1.75,className:`shrink-0`}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`From`,` `,(0,Y.jsx)(`b`,{className:`font-medium text-[var(--chrome-fg-700)] group-hover/origin:underline`,children:V.flow.name}),`, step `,V.index+1]})]})]}),(0,Y.jsx)(`div`,{className:`mx-3 h-px bg-[var(--chrome-divider)]`}),(0,Y.jsx)(`div`,{ref:P.listRef,className:`flex flex-1 flex-col overflow-y-auto p-3`,children:y===0?(0,Y.jsx)(vt,{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,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ie,{count:K.length,attached:E,onAttach:()=>q(K),onSettled:()=>D(!1)}),(0,Y.jsx)(`ol`,{className:`flex flex-col pt-1`,"data-testid":`flow-steps`,children:h.steps.map((e,r)=>(0,Y.jsx)(gt,{before:U===r&&U<y,hidden:P.dragging,number:r+1,first:r===0,onCancel:()=>M({slot:null}),children:(0,Y.jsx)(Ye,{step:e,index:r,count:y,current:d===r,selected:ve===r,picking:G===r,names:B,otherFlows:Te,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,Y.jsx)(_t,{inserting:U<y,next:y+1,joined:ye,onToEnd:()=>M({slot:null})})]})}),(0,Y.jsx)(`div`,{className:`border-t border-[var(--chrome-ring)] p-3`,children:b===null?(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`${Ne} h-9 flex-1`,"data-testid":`flow-play`,disabled:y===0||u,onClick:()=>C(a,t,n),children:[(0,Y.jsx)(ge,{size:12}),`Preview`]}),(0,Y.jsx)(`button`,{type:`button`,className:`${ke} flex-1`,"data-testid":`flow-done`,onClick:L,children:`Done`})]}):(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`${Ne} h-9 flex-1`,"data-testid":`flow-name-skip`,onClick:F,children:`Skip`}),(0,Y.jsx)(`button`,{type:`button`,className:`${ke} flex-1`,"data-testid":`flow-name-save`,disabled:!b.trim(),onClick:Oe,children:`Save name`})]})})]})}function gt(e){let{before:t,hidden:n,number:i,first:a,onCancel:o,children:s}=e;return(0,Y.jsxs)(Y.Fragment,{children:[t&&(0,Y.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,Y.jsx)(Ge,{first:a,node:(0,Y.jsx)(`span`,{className:Ue,children:i})}),(0,Y.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,Y.jsxs)(`span`,{className:`flex-1 leading-[22px]`,children:[`Click a box for step `,i]}),(0,Y.jsx)(r,{label:`Add at the end instead`,side:`left`,children:(0,Y.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,Y.jsx)(W,{size:13,stroke:2})})})]})]}),s]})}function _t(e){let{inserting:t,next:n,joined:r,onToEnd:i}=e;return(0,Y.jsxs)(`div`,{"data-testid":`flow-hint`,className:`flex gap-2.5 pl-1 pr-1.5`,children:[(0,Y.jsx)(Ge,{end:!0,node:(0,Y.jsx)(`span`,{className:He,children:t?(0,Y.jsx)(z,{size:10,stroke:2.5}):n})}),(0,Y.jsx)(`div`,{className:`py-2 text-[12px] leading-[22px] text-[var(--chrome-fg-400)]`,children:t?(0,Y.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,Y.jsxs)(Y.Fragment,{children:[`Click the next box or arrow`,r!==null&&(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] leading-[18px]`,children:[(0,Y.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 vt(e){let{onAi:t,fork:n}=e,r=n?n.title||`step ${n.step}`:``;return(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-3 px-3 py-8 text-center`,"data-testid":`flow-empty`,children:[(0,Y.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,Y.jsx)(P,{size:20,stroke:1.75}):(0,Y.jsx)(V,{size:20,stroke:1.75})}),(0,Y.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,Y.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,Y.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,Y.jsx)(U,{size:13,stroke:1.75}),`Write the steps with AI`]})]})}function yt(e){let{current:t,flows:n,onPick:r,onRename:a,onNew:o,onDelete:c}=e,g=(0,J.useRef)(!1);return(0,Y.jsxs)(u,{onOpenChange:e=>{e&&(g.current=!1)},children:[(0,Y.jsxs)(f,{"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,Y.jsx)(`span`,{className:`truncate text-[14px] font-medium text-[var(--chrome-fg-900)]`,children:t.name}),(0,Y.jsx)(i,{size:14,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-400)]`})]}),(0,Y.jsx)(d,{children:(0,Y.jsx)(p,{side:`bottom`,align:`start`,sideOffset:4,className:`z-50 outline-none`,children:(0,Y.jsxs)(m,{"data-overlay":!0,className:`min-w-[240px] p-1`,finalFocus:()=>!g.current,children:[M(n).map(({flow:e,depth:n})=>(0,Y.jsxs)(s,{"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,Y.jsx)(`span`,{className:`text-[var(--chrome-fg-400)]`,children:n>0?(0,Y.jsx)(P,{size:14,stroke:1.75}):(0,Y.jsx)(V,{size:14,stroke:1.75})}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[var(--chrome-fg-900)]`,children:e.name}),(0,Y.jsx)(`span`,{className:`text-[11px] tabular-nums text-[var(--chrome-fg-400)]`,children:e.steps.length}),(0,Y.jsx)(`span`,{className:`flex w-4 justify-center text-[var(--chrome-fg-900)]`,children:e.id===t.id&&(0,Y.jsx)(I,{size:14,stroke:2})})]},e.id)),(0,Y.jsx)(l,{}),(0,Y.jsx)(h,{testId:`flow-name-edit`,icon:(0,Y.jsx)(R,{size:15,stroke:1.75}),onClick:()=>{g.current=!0,a()},children:`Rename`}),(0,Y.jsx)(h,{testId:`flow-new`,icon:(0,Y.jsx)(z,{size:15,stroke:1.75}),onClick:o,children:`New flow on this frame`}),(0,Y.jsx)(h,{testId:`flow-delete`,icon:(0,Y.jsx)(D,{size:15,stroke:1.75}),onClick:c,children:`Delete this flow`})]})})})]})}function bt(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{lt as FlowMenuPopup,mt 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{Xr as r,Yr as i,an as a,w as o}from"./slides-D686obFO.js";import{r as s,t as c}from"./dom-PAoZruqo.js";import{g as l}from"./selection-overlay-primitives-BRp854AD.js";import{c as u,l as d,o as f}from"./flows-Cj7AFMIA.js";var p=e(t(),1),m=n(),h=6;function g(e,t){if(e.type===`arrow`)return o(i(e),t);let n=a(e);return o({x:n.x,y:n.y},t)}function _(e,t,n=h,r){let i=l(e,r),a=o({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 v(e){return new Set(e.steps.flatMap((e,t)=>e.fails?[t+1]:[]))}function y(e){let t=new Map;return e.steps.forEach((e,n)=>{for(let r of u(e))t.set(r,[...t.get(r)??[],n+1])}),t}function b(e){let{numbers:t,byId:n,viewport:r,current:i,failing:a}=e;return(0,m.jsx)(m.Fragment,{children:[...t].map(([e,t])=>{let o=n.get(e);if(!o)return null;let s=g(o,r);return(0,m.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,m.jsx)(`span`,{className:`flex h-[22px] min-w-[22px] items-center justify-center rounded-full px-1.5 text-[11.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 x=`http://www.w3.org/2000/svg`,S=48;function C(e,t){if(e.kind===`ghost`){let n=t.get(e.from),r=t.get(e.to);if(!n||!r)return null;let i=a(n),o=a(r);return w([D(i,E(o)),D(o,E(i))].map(e=>[e]),!0)}let n=e.hops.flatMap(e=>{let t=A(r(e.arrow));return t.length<2?[]:[e.reversed?t.reverse():t]});return n.length>0?w(n,!1):null}function w(e,t){let n=[],r=[],i=0;return(t?[e.flat()]:e).forEach((e,t)=>{if(t>0){let t=T(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+=T(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 T(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function E(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function D(e,t){let n=E(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 O=null;function k(){if(O)return O;let e=document.createElementNS(x,`svg`);e.setAttribute(`aria-hidden`,`true`),e.style.cssText=`position:absolute;width:0;height:0;overflow:hidden;visibility:hidden`;let t=document.createElementNS(x,`path`);return e.append(t),document.body.append(e),O=t,t}function A(e){let t=k();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/S);return{x:i.x,y:i.y}})}var j=.16,M=.45,N=3,P=1.5,F=100,I=[];function L(e){let{frameId:t,flow:n,targets:r,index:i,viewport:a,lead:o=I}=e,l=(0,p.useMemo)(()=>new Map(r.map(e=>[e.id,e])),[r]),h=n.steps[i],g=(0,p.useMemo)(()=>f(r,[...o,...n.steps],o.length+i),[r,o,n.steps,i]),_=h?.fails?`var(--flow-fail)`:`var(--flow-accent)`,x=(0,p.useMemo)(()=>h?u(h).flatMap(e=>l.get(e)??[]):[],[h,l]),S=(0,p.useMemo)(()=>{let e=[...o,...n.steps.slice(0,i)],t=e.slice(Math.max(0,e.length-N)).reverse().flatMap((e,t)=>u(e).map(e=>({id:e,back:t})));return x.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=d(r,a.id,e.id,{reply:g===`reply`});if(!t)continue;let o=(t.kind===`ghost`?F:t.cost)+a.back*P;o<i&&(i=o,n=t)}}let a=n?C(n,l):null;return n&&a?[{key:`${i}-${e.id}`,route:n,track:a}]:[]})},[x,o,n.steps,i,r,g,l]),w=(0,p.useMemo)(()=>{let e=new Set([t,...x.map(e=>e.id)]),a=x.filter(e=>e.type===`arrow`).map(e=>e.id);for(let t of S)t.route.kind===`arrows`&&(t.route.hops.forEach(t=>{e.add(t.arrow.id),a.push(t.arrow.id)}),t.route.through.forEach(t=>e.add(t)));let l=new Set([...o,...n.steps.slice(0,i)].flatMap(u)),d=[],f=[];for(let t of r){if(e.has(t.id))continue;let n=t.type===`figure`;(l.has(t.id)||n?f:d).push(s(t.id),c(`data-icon-label`,t.id))}let p=(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}`,p(d,j),p(f,M),Y(a,_,g)].join(``)},[t,x,o,S,n.steps,i,r,_,g]);return h?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`style`,{"data-testid":`flow-dim`,children:w}),S.length>0&&(0,m.jsx)(z,{handOffs:S,kind:g,color:_,fails:h.fails,payload:h.payload,viewport:a},`${n.id}-${i}`),(0,m.jsx)(b,{numbers:y(n),byId:l,viewport:a,current:i+1,failing:v(n)})]}):null}function R(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"]${s(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 z(e){let{handOffs:t,kind:n,color:r,fails:i,payload:a,viewport:o}=e,s=1/o.zoom,c=W(t,o.zoom),l=R(t),u=`flow-hand-off-mask-${t[0]?.key??``}`;return(0,m.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,m.jsxs)(`mask`,{id:u,maskUnits:`userSpaceOnUse`,x:`-100000`,y:`-100000`,width:`200000`,height:`200000`,children:[(0,m.jsx)(`rect`,{x:`-100000`,y:`-100000`,width:`200000`,height:`200000`,fill:`white`}),l.map(e=>(0,m.jsx)(`rect`,{x:e.x,y:e.y,width:e.width,height:e.height,rx:4,fill:`black`},e.key))]}),(0,m.jsx)(`g`,{mask:l.length>0?`url(#${u})`:void 0,children:(0,m.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,m.jsxs)(`g`,{"data-testid":t?`flow-ghost`:`flow-route`,children:[t&&(0,m.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,m.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:`1`,to:`0`,dur:`0.7s`,fill:`freeze`})}),(0,m.jsxs)(`g`,{opacity:0,children:[(0,m.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,m.jsx)(`animate`,{attributeName:`opacity`,dur:`${c.seconds}s`,repeatCount:`indefinite`,calcMode:`linear`,...G(e.track,c.travel(e.track))}),(0,m.jsx)(`circle`,{r:11*s,fill:`var(--canvas-bg, white)`,opacity:.9}),(0,m.jsx)(`circle`,{r:7*s,fill:n===`async`?`var(--canvas-bg, white)`:r,stroke:r,strokeWidth:3*s}),a&&(0,m.jsx)(J,{text:a,scale:s,color:r})]})]},e.key)})})})]})}var B=380,V=.7,H=.9,U=.12;function W(e,t){let n=Math.max(...e.map(e=>e.track.length)),r=Math.max(H,n*t/B),i=r+V;return{seconds:Number(i.toFixed(3)),travel:e=>Number((r*(e.length/n||1)/i).toFixed(4))}}function G(e,t){let n=n=>n/(e.length||1)*t,r=U*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 K=11,q=6;function J(e){let{text:t,scale:n,color:r}=e,i=(t.length*K*.6+q*2)*n,a=17*n,o=14*n;return(0,m.jsxs)(`g`,{"data-testid":`flow-payload`,transform:`translate(${-i/2} ${o})`,children:[(0,m.jsx)(`rect`,{width:i,height:a,rx:a/2,fill:r}),(0,m.jsx)(`text`,{x:i/2,y:a/2,textAnchor:`middle`,dominantBaseline:`central`,fill:`white`,fontSize:K*n,fontWeight:500,fontFamily:`ui-sans-serif, system-ui, sans-serif`,children:t})]})}function Y(e,t,n){if(e.length===0)return``;let r=t=>e.map(e=>`${s(e)} [data-testid="${t}"]`).join(`,`),i=`${r(`arrow-stroke`)},${r(`arrow-head`)}`,a=e.flatMap(e=>[`arrow-stroke`,`arrow-head`].map(t=>`${s(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{_ as a,v as i,b as n,y as o,g as r,L as t};
@@ -0,0 +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,3 +1,3 @@
1
- import{_ as e}from"./slides-D9bnXqtf.js";import{n as t}from"./core-CBnmD9hT.js";var n=5,r=1,i=1,a=3;function o(t){let n=t.filter(e=>e.type===`figure`),r=new Map;for(let i of n)r.set(i.id,new Set(e(t,i).map(e=>e.id)));return e=>{let t=new Set([e,...r.get(e)??[]]);for(let[n,i]of r)i.has(e)&&t.add(n);return t}}function s(e,t,s,c={}){if(t===s)return null;let l=o(e),u=l(t),d=l(s),f=c.reply?a:i,p=c.reply?i:a,m=new Map,h=(e,t)=>m.set(e,[...m.get(e)??[],t]);for(let t of e){if(t.type!==`arrow`)continue;let e=t.startBinding?.shapeId,n=t.endBinding?.shapeId;!e||!n||e===n||(h(e,{to:n,hop:{arrow:t,reversed:!1},cost:f,wrongWay:!!c.reply}),h(n,{to:e,hop:{arrow:t,reversed:!0},cost:p,wrongWay:!c.reply}))}let g=[...u].map(e=>({at:e,cost:0,hops:[],path:[],wrongWay:0})),_=new Map;for(;g.length>0;){g.sort((e,t)=>e.cost-t.cost||e.hops.length-t.hops.length);let e=g.shift();if(d.has(e.at)&&e.hops.length>0){let t=e.path.filter(e=>!u.has(e)&&!d.has(e));return{kind:`arrows`,hops:e.hops,through:t,cost:e.cost}}if(!((_.get(e.at)??1/0)<=e.cost||e.hops.length>=n)){_.set(e.at,e.cost);for(let t of m.get(e.at)??[]){let n=e.wrongWay+ +!!t.wrongWay;n>r||g.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:s}}function c(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 l(e,t){let n=c(e,t);return n?n.flow.steps.slice(0,n.index+1):[]}function u(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 d(e){return[e.target,...e.also??[]]}function f(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(d)),o=d(r).filter(e=>a.has(e));for(let t of o)for(let n of d(i)){let r=s(e,n,t);if(r?.kind===`arrows`&&r.hops.every(e=>!e.reversed))return`call`;let i=s(e,n,t,{reply:!0});if(i?.kind===`arrows`&&i.hops.every(e=>e.reversed))return`reply`}return`call`}function p(e,n,r,i){let a=n.flows??[];if(a.length===0)return{flows:void 0,dropped:0};let o=(e,t)=>h(e,t).toLowerCase().replace(/\s+/g,` `).trim(),s=new Map(t(e,n).map(t=>[t.id,o(e,t)])),c=new Map;for(let e of t(r,i)){let t=o(r,e);t&&!c.has(t)&&c.set(t,e.id)}let l=e=>c.get(s.get(e)??``),u=0,d=a.flatMap(e=>{let t=e.steps.flatMap(e=>{let t=l(e.target);if(!t)return u+=1,[];let n=(e.also??[]).flatMap(e=>l(e)??[]),r={...e,target:t};return n.length>0?r.also=n:delete r.also,[r]});return t.length>0?[{...e,steps:t}]:[]}),f=new Set(d.map(e=>e.id)),p=d.map(e=>({...e,steps:e.steps.map(e=>{let t=(e.branches??[]).filter(e=>f.has(e)),n={...e};return t.length>0?n.branches=t:delete n.branches,n})}));return{flows:p.length>0?p:void 0,dropped:u}}function m(e){return e?`label`in e&&typeof e.label==`string`&&e.label.trim()?e.label.trim().split(`
1
+ import{_ as e}from"./slides-D686obFO.js";import{n as t}from"./core-CmsJyU_-.js";var n=5,r=1,i=1,a=3;function o(t){let n=t.filter(e=>e.type===`figure`),r=new Map;for(let i of n)r.set(i.id,new Set(e(t,i).map(e=>e.id)));return e=>{let t=new Set([e,...r.get(e)??[]]);for(let[n,i]of r)i.has(e)&&t.add(n);return t}}function s(e,t,s,c={}){if(t===s)return null;let l=o(e),u=l(t),d=l(s),f=c.reply?a:i,p=c.reply?i:a,m=new Map,h=(e,t)=>m.set(e,[...m.get(e)??[],t]);for(let t of e){if(t.type!==`arrow`)continue;let e=t.startBinding?.shapeId,n=t.endBinding?.shapeId;!e||!n||e===n||(h(e,{to:n,hop:{arrow:t,reversed:!1},cost:f,wrongWay:!!c.reply}),h(n,{to:e,hop:{arrow:t,reversed:!0},cost:p,wrongWay:!c.reply}))}let g=[...u].map(e=>({at:e,cost:0,hops:[],path:[],wrongWay:0})),_=new Map;for(;g.length>0;){g.sort((e,t)=>e.cost-t.cost||e.hops.length-t.hops.length);let e=g.shift();if(d.has(e.at)&&e.hops.length>0){let t=e.path.filter(e=>!u.has(e)&&!d.has(e));return{kind:`arrows`,hops:e.hops,through:t,cost:e.cost}}if(!((_.get(e.at)??1/0)<=e.cost||e.hops.length>=n)){_.set(e.at,e.cost);for(let t of m.get(e.at)??[]){let n=e.wrongWay+ +!!t.wrongWay;n>r||g.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:s}}function c(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 l(e,t){let n=c(e,t);return n?n.flow.steps.slice(0,n.index+1):[]}function u(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 d(e){return[e.target,...e.also??[]]}function f(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(d)),o=d(r).filter(e=>a.has(e));for(let t of o)for(let n of d(i)){let r=s(e,n,t);if(r?.kind===`arrows`&&r.hops.every(e=>!e.reversed))return`call`;let i=s(e,n,t,{reply:!0});if(i?.kind===`arrows`&&i.hops.every(e=>e.reversed))return`reply`}return`call`}function p(e,n,r,i){let a=(e,t)=>g(e,t).toLowerCase().replace(/\s+/g,` `).trim(),o=new Map;for(let e of t(r,i)){let t=a(r,e);t&&!o.has(t)&&o.set(t,e.id)}let s=new Map([[n.id,i.id]]);for(let r of t(e,n)){let t=o.get(a(e,r));t&&s.set(r.id,t)}return s}function m(e,t,n,r){let i=t.flows??[];if(i.length===0)return{flows:void 0,dropped:0};let a=p(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 h(e){return e?`label`in e&&typeof e.label==`string`&&e.label.trim()?e.label.trim().split(`
2
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 h(e,t){let n=m(t);if(n)return n;if(t.type===`arrow`){let n=new Map(e.map(e=>[e.id,e])),r=m(n.get(t.startBinding?.shapeId??``)),i=m(n.get(t.endBinding?.shapeId??``));return r&&i?`${r} → ${i}`:`Connection`}return`Step`}function g(e,n){if(!n.flows?.length)return[];let r=t(e,n);return n.flows.flatMap(e=>{let t=u(e,r);return t.steps.map((e,n)=>({flow:t,index:n}))})}export{g as a,d as c,h as i,s as l,c as n,f as o,p as r,u as s,l as t};
3
+ `)[0]:e.type===`icon`&&e.name?e.name:``:``}function g(e,t){let n=h(t);if(n)return n;if(t.type===`arrow`){let n=new Map(e.map(e=>[e.id,e])),r=h(n.get(t.startBinding?.shapeId??``)),i=h(n.get(t.endBinding?.shapeId??``));return r&&i?`${r} → ${i}`:`Connection`}return`Step`}function _(e,n){if(!n.flows?.length)return[];let r=t(e,n);return n.flows.flatMap(e=>{let t=u(e,r);return t.steps.map((e,n)=>({flow:t,index:n}))})}export{_ as a,d as c,g as i,s as l,c as n,f as o,m as r,u as s,l as t};
@@ -0,0 +1 @@
1
+ import{Ar as e,Mr as t,jr as n}from"./slides-D686obFO.js";import{W as r}from"./style-BENGW2ZV.js";var i={simple:`Frame`,phone:`Phone`,tablet:`Tablet`,browser:`Browser`,window:`Desktop window`,lanes:`Swimlanes`,vlanes:`Vertical swimlanes`,boundary:`Boundary`};function a(e){return e===`lanes`||e===`vlanes`}function o(e){return e===`vlanes`}var s={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}},c=[`Lane 1`,`Lane 2`,`Lane 3`],l=.7;function u(e){return e&&e.length>0?e.length:c.length}function d(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 f(e,t,n){let r=d(e,n),i=[0],a=0;for(let e of r)a+=e*t,i.push(a);return i}var p=.06;function m(e,t,n){let i=[...e],a=i[t]+i[t+1],o=r(i[t]+n,p,a-p);return i[t]=o,i[t+1]=a-o,i}function h(e,t){let n=Math.min(t.width,t.height);return e===`phone`?Math.min(r(n*.13,10,44),t.width/2,t.height/2):e===`tablet`?Math.min(r(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 g(t,n){let r=t.y+n/2;return[0,1,2].map(n=>e(t.x+15+n*13,r,3.5))}var _=18,v=12,y=14,b=20,x=5,S=18;function C(i,a,o,s){let c=h(i,a),l=t(a.x,a.y,a.width,a.height,c),d=[];if(i===`phone`){let e=a.x+a.width/2;if(a.height>120&&a.width>80){let t=r(a.width*.16,24,56),i=a.y+_;d.push(n(e-t/2,i,e+t/2,i));let o=r(a.width*.3,40,110),s=a.y+a.height-v;d.push(n(e-o/2,s,e+o/2,s))}return{border:l,details:d}}if(i===`tablet`){let t=a.x+a.width/2;if(a.height>140&&a.width>100){d.push(e(t,a.y+y,2.5));let n=a.y+a.height-b;d.push(e(t,n,x))}return{border:l,details:d}}if(i===`browser`||i===`window`){let e=i===`browser`?36:32;if(a.height>e*2.2&&a.width>70&&(d.push(n(a.x,a.y+e,a.x+a.width,a.y+e)),d.push(...g(a,e)),i===`browser`&&a.width>200)){let n={x:a.x+56,y:a.y+(e-S)/2,width:a.width-56-16,height:S};d.push(t(n.x,n.y,n.width,n.height,S/2))}return{border:l,details:d}}if(i===`lanes`||i===`vlanes`){let e=u(o);if(i===`vlanes`){let t=f(e,a.width,s);for(let r=1;r<e;r+=1){let e=a.x+t[r];d.push(n(e,a.y,e,a.y+a.height))}return a.height>30*2.5&&d.push(n(a.x,a.y+30,a.x+a.width,a.y+30)),{border:l,details:d}}let t=f(e,a.height,s);for(let r=1;r<e;r+=1){let e=a.y+t[r];d.push(n(a.x,e,a.x+a.width,e))}return a.width>30*2.5&&d.push(n(a.x+30,a.y,a.x+30,a.y+a.height)),{border:l,details:d}}return{border:l,details:d}}export{C as a,f as c,m as d,l as i,d as l,s as n,h as o,i as r,a as s,c as t,o as u};
@@ -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{o as r}from"./editor-BeufBV54.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{r as a,t as o}from"./icon-sources-CZI1h18s.js";import{t as s}from"./icons-DzW1j-r3.js";import{a as c,i as l,r as u,t as d,u as f}from"./PopoverPopup-B3Y0VRYc.js";import{s as ee}from"./chrome-C2RCq3SI.js";import{n as p,t as te}from"./icon-catalog-CbUlEKtK.js";import{a as ne,c as m,d as h,f as g,i as re,l as _,n as ie,o as v,r as y,s as b,t as x,u as ae}from"./use-grid-keyboard-nav-DhQKecO1.js";var S=e(t(),1),C=new Set(`zodiac-aquarius.zodiac-aries.zodiac-cancer.zodiac-capricorn.zodiac-gemini.zodiac-leo.zodiac-libra.zodiac-ophiuchus.zodiac-pisces.zodiac-sagittarius.zodiac-scorpio.zodiac-taurus.zodiac-virgo.clock-1.clock-2.clock-3.clock-4.clock-5.clock-6.clock-7.clock-8.clock-9.clock-10.clock-11.clock-12.dice-1.dice-2.dice-3.dice-4.dice-5.dice-6.tally-1.tally-2.tally-3.tally-4.bean-off.beef-off.beer-off.candy-off.cannabis.cannabis-off.cigarette.cigarette-off.dna-off.egg-off.fish-off.hop.hop-off.milk-off.nut-off.wheat-off.wine-off.panda.rat.squirrel.worm.shrimp.amphora.anvil.axe.bow-arrow.castle.sword.pocket-knife.drama.venetian-mask.ferris-wheel.roller-coaster.tent-tree.drum.guitar.piano.metronome.turntable.boom-box.cassette-tape.videotape.towel-rack.soap-dispenser-droplet.shower-head.toilet.washing-machine.microwave.refrigerator.blinds.rocking-chair.shelving-unit.lamp-ceiling.lamp-desk.lamp-floor.lamp-wall-down.lamp-wall-up.birdhouse.mirror-rectangular.mirror-round.parasol.fence.drill.shovel.pickaxe.dam.utility-pole.tractor.cable-car.caravan.helicopter.kayak.volleyball.fishing-hook.fishing-rod.club.spade.hat-glasses.keyboard-music.astroid.spool.stone`.split(`.`)),oe=p.filter(e=>!C.has(e)),w={smile:[`mood`,`satisfied`],"smile-plus":[`mood`,`satisfied`],laugh:[`mood`,`satisfied`],meh:[`mood`],frown:[`mood`,`dissatisfied`],angry:[`mood`],annoyed:[`mood`]},T=n();function E(e,t){return e.label.toLowerCase().includes(t)||e.keywords&&e.keywords.some(e=>e.includes(t))?!0:h(e.label).startsWith(t)}var D=92;function O(e){let{onPick:t,onClose:n,library:c}=e,[l,u]=(0,S.useState)(`all`),[d,p]=(0,S.useState)(null),[h,C]=(0,S.useState)(``),O=(0,S.useRef)(null),k=(0,S.useRef)(null),[A,se]=(0,S.useState)(0),[j,ce]=(0,S.useState)({width:360,height:420}),[M,le]=(0,S.useState)({}),[N,P]=(0,S.useState)({}),{recent:F,remember:I}=ie(),[L,R]=(0,S.useState)(null),z=r(e=>e.setImageLibraryOpen),B=r(e=>e.coarsePointer);(0,S.useEffect)(()=>{s().ensureCatalog();let e=!0;return i(()=>import(`./icon-tags-Bw7m3Jke.js`).then(t=>{e&&le(t.default)}),[]).catch(()=>void 0),()=>{e=!1}},[]);let V=(0,S.useRef)(!0);(0,S.useEffect)(()=>(V.current=!0,()=>{V.current=!1}),[]);function H(e){s().loadAssetIndex(e).then(t=>{V.current&&P(n=>({...n,[e]:t}))}).catch(()=>void 0)}(0,S.useEffect)(()=>{for(let e of b)H(e);if(v.length===0)return;let e=()=>{for(let e of v)H(e)};if(typeof window.requestIdleCallback==`function`){let t=window.requestIdleCallback(e);return()=>window.cancelIdleCallback(t)}let t=window.setTimeout(e,400);return()=>window.clearTimeout(t)},[]),(0,S.useEffect)(()=>{let e=d?[d]:g(l);for(let t of v)e.includes(t)&&(h.trim()||l!==`all`)&&H(t)},[l,d,h]),(0,S.useEffect)(()=>{let e=k.current;if(!e)return;let t=()=>ce({width:e.clientWidth,height:e.clientHeight});t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let U=(0,S.useMemo)(()=>{let e={};for(let[t,n]of Object.entries(te))(e[n]??=[]).push(t);return oe.map(t=>{let n=[...M[t]??[],...w[t]??[],...e[t]??[]];return{source:`lucide`,id:t,label:t,keywords:n.length>0?n:void 0}})},[M]),W=(0,S.useMemo)(()=>{let e={lucide:U};for(let t of o)e[t]=(N[t]??[]).map(([e,n,r])=>({source:t,id:n,label:e,keywords:Array.isArray(r)?r:typeof r==`string`?r.split(` `):void 0}));return e},[U,N]),G=ne((0,S.useMemo)(()=>{let e=h.trim().toLowerCase(),t=d?[d]:g(l),n=t.length>1,r=[];!e&&l===`all`&&F.length>0&&r.push({label:`Recent`,entries:F});for(let i of t){let t=n?_[i]:null;if(!e){let e=a(i)&&N[i]===void 0,n=W[i]??[];e?r.push({label:t,entries:[],tail:!0}):n.length>0&&r.push({label:t,entries:n});continue}let o=(W[i]??[]).filter(t=>E(t,e));o.length>0&&r.push({label:t,entries:o})}return r},[h,l,d,W,N,F]),j.width);function K(e){I(e),t(e.id,e.source)}let{focus:q,setFocus:ue,onKeyDown:de}=x({layout:G,scrollRef:k,onEnter:K});function fe(e){C(e),Y()}function pe(e){u(e),p(null),Y(),B||O.current?.focus()}function J(e){p(e),Y(),B||O.current?.focus()}function Y(){ue(0),R(null),k.current&&(k.current.scrollTop=0)}let me=A-D,he=A+j.height+D,ge=Math.max(1,Math.floor(j.width/46)),X=[];for(let e of G.rows)if(!(e.top+e.height<me)){if(e.top>he)break;if(e.type===`header`){X.push((0,T.jsxs)(`div`,{className:`absolute inset-x-0 flex items-baseline gap-1.5 px-1.5 pt-3`,style:{top:e.top},children:[(0,T.jsx)(`span`,{className:`text-[11px] uppercase tracking-wide text-gray-500`,children:e.label}),(0,T.jsx)(`span`,{className:`text-[10px] text-gray-400`,children:e.count})]},`header-${e.top}`));continue}if(e.type===`skeleton`){X.push((0,T.jsx)(`div`,{className:`absolute inset-x-0 flex`,style:{top:e.top},children:Array.from({length:ge},(e,t)=>(0,T.jsx)(`span`,{className:`flex h-[46px] w-[46px] items-center justify-center`,children:(0,T.jsx)(`span`,{className:`h-8 w-8 animate-pulse rounded-lg bg-black/5`})},t))},`skeleton-${e.top}`));continue}e.entries.forEach((t,n)=>{let r=e.startIndex+n,i=n*46,o=r===q;a(t.source)?X.push((0,T.jsx)(y,{source:t.source,slug:t.id,label:t.label,left:i,top:e.top,focused:o,onPick:()=>K(t),onHover:e=>R(e?t:null)},r)):X.push((0,T.jsx)(re,{name:t.id,left:i,top:e.top,focused:o,onPick:()=>K(t),onHover:e=>R(e?t:null)},r))})}let Z=m.find(e=>e.id===l)?.label??`All`,Q=ae(l),_e=l===`all`?`all`:d?_[d]:Z,$=L?.source??G.flat[q]?.source;return(0,T.jsxs)(`div`,{"data-overlay":!0,className:`flex w-[min(380px,calc(100vw-1rem))] flex-col overflow-hidden rounded-xl ${ee}`,style:{height:`min(70vh, 560px)`},onKeyDown:de,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-1 overflow-x-auto border-b border-black/5 px-2 py-2`,style:{scrollbarWidth:`none`},children:[m.map(e=>(0,T.jsx)(`button`,{type:`button`,onClick:()=>pe(e.id),className:`shrink-0 rounded-full px-2.5 py-1 text-xs transition-colors ${l===e.id?`bg-gray-200 text-gray-900`:`text-gray-500 hover:bg-gray-100 hover:text-gray-700`}`,children:e.label},e.id)),c&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>{z(!0),n?.()},"aria-label":`Image library`,title:`Image library`,"data-testid":`image-library-open`,className:`ml-auto flex h-[26px] w-[26px] shrink-0 items-center justify-center rounded-full transition-colors hover:bg-gray-100`,children:(0,T.jsx)(`img`,{src:s().assetIconUrl(`drawnicons`,`solid-smiley-face`),alt:``,draggable:!1,className:`h-[19px] w-[19px]`})})]}),Q&&(0,T.jsxs)(`div`,{className:`flex items-center gap-1 border-b border-black/5 px-3 py-1.5`,children:[(0,T.jsx)(`button`,{type:`button`,onClick:()=>J(null),className:`rounded-full px-2 py-0.5 text-[11px] transition-colors ${d===null?`bg-gray-200 text-gray-900`:`text-gray-500 hover:bg-gray-100 hover:text-gray-700`}`,children:`All`}),Q.sources.map(e=>(0,T.jsx)(`button`,{type:`button`,onClick:()=>J(e),className:`rounded-full px-2 py-0.5 text-[11px] transition-colors ${d===e?`bg-gray-200 text-gray-900`:`text-gray-500 hover:bg-gray-100 hover:text-gray-700`}`,children:_[e]},e))]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-black/5 p-3`,children:[(0,T.jsx)(`input`,{ref:O,autoFocus:!B,value:h,"data-testid":`icon-picker-search`,onChange:e=>fe(e.target.value),placeholder:`Search ${_e} icons`,className:`h-9 flex-1 rounded-lg bg-black/5 px-3 text-sm text-gray-800 outline-none placeholder:text-gray-400 focus:bg-black/[0.07]`}),n&&(0,T.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close`,className:`flex h-9 w-9 items-center justify-center rounded-lg text-gray-500 transition-colors hover:bg-black/5`,children:(0,T.jsx)(f,{})})]}),(0,T.jsx)(`div`,{ref:k,onScroll:e=>se(e.currentTarget.scrollTop),className:`scrollbar-slim relative flex-1 overflow-y-auto p-2`,children:G.flat.length===0&&h.trim()?(0,T.jsx)(`div`,{className:`px-2 py-8 text-center text-sm text-gray-400`,children:`No icons match “${h}”.`}):(0,T.jsx)(`div`,{className:`relative`,style:{height:G.totalHeight},children:X})}),(0,T.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-t border-black/5 px-3 py-2 text-[11px] text-gray-400`,children:[(0,T.jsx)(`span`,{className:`truncate text-gray-600`,children:L?.label??G.flat[q]?.label??Z}),(0,T.jsxs)(`span`,{className:`shrink-0`,children:[G.flat.length,` · `,$?_[$]:Z]})]})]})}function k(e){let{onPick:t,onClose:n}=e;return(0,T.jsx)(c,{open:!0,modal:!1,onOpenChange:e=>{e||n()},children:(0,T.jsx)(l,{children:(0,T.jsx)(u,{anchor:()=>document.querySelector(`[data-canvas-toolbar]`),side:`right`,align:`start`,sideOffset:8,children:(0,T.jsx)(d,{finalFocus:!1,children:(0,T.jsx)(O,{onPick:t,onClose:n,library:!0})})})})})}export{k as IconPicker,O as IconPickerContent};
@@ -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{i as r}from"./config-D8b1QyEk.js";import{o as ee}from"./editor-BeufBV54.js";import{i as te,r as ne,t as i}from"./icons-DzW1j-r3.js";import{t as re}from"./IconLoader2-CzCTn-Sn.js";import{t as ie}from"./IconSearch-CCpMt02s.js";import{s as ae}from"./asset-glyph-C1E6cGwM.js";import{n as oe}from"./surface-Dke4SWpE.js";import{i as a,n as o,r as se,t as ce}from"./DialogRoot-DUeVfNhS.js";import{a as le,n as ue,r as de,t as fe}from"./use-grid-keyboard-nav-DhQKecO1.js";var s=e(t(),1),c=n(),l=64,u=16,d=2*l;function f(e,t){return e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.includes(t))}var p={face:`M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-3.4 6.4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm6.8 0a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Zm-8 5.3c.9 2.3 2.6 3.6 4.6 3.6s3.7-1.3 4.6-3.6c-1.5.9-3 1.3-4.6 1.3s-3.1-.4-4.6-1.3Z`,mark:`M20.6 4.6 22 6.7l-11.6 12L2 11.6l1.7-1.9 6.4 5.3L20.6 4.6Z`,object:`M12 1.8l9 5v10.4l-9 5-9-5V6.8l9-5Zm0 2.5L6 7.6l6 3.3 6-3.3-6-3.3ZM4.8 9.3v6.6l6.1 3.4v-6.6L4.8 9.3Zm14.4 0-6.1 3.4v6.6l6.1-3.4V9.3Z`,people:`M8.2 3.6a3.2 3.2 0 1 1 0 6.4 3.2 3.2 0 0 1 0-6.4Zm8.3 1.6a2.6 2.6 0 1 1 0 5.2 2.6 2.6 0 0 1 0-5.2ZM8.2 11.3c3 0 5.3 1.9 5.3 4.7V20H2.9v-4c0-2.8 2.3-4.7 5.3-4.7Zm8.3 1c2.4 0 4.3 1.6 4.3 4V19h-5.9v-3c0-1.2-.4-2.3-1-3.2a7 7 0 0 1 2.6-.5Z`,scene:`M4.5 3.5h15A2.5 2.5 0 0 1 22 6v12a2.5 2.5 0 0 1-2.5 2.5h-15A2.5 2.5 0 0 1 2 18V6a2.5 2.5 0 0 1 2.5-2.5Zm12 3.2a1.9 1.9 0 1 0 0 3.8 1.9 1.9 0 0 0 0-3.8ZM5 17.6h14.2l-4.9-6.6-3.4 4.6-2.2-2.7L5 17.6Z`,solid:`M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm0 2.4a7.6 7.6 0 1 0 0 15.2 7.6 7.6 0 0 0 0-15.2Zm0 0v15.2a7.6 7.6 0 0 0 0-15.2Z`},pe=`M4 4h7v7H4V4Zm9 0h7v7h-7V4ZM4 13h7v7H4v-7Zm9 0h7v7h-7v-7Z`;function m(e){return e.path?(0,c.jsx)(`svg`,{className:`h-4 w-4 shrink-0`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,c.jsx)(`path`,{fillRule:`evenodd`,d:e.path})}):null}function me(e){let t=new Map;for(let n of e){let e=t.get(n.group)??[];e.push(n),t.set(n.group,e)}return[...t.entries()].map(([e,t])=>({name:e,total:t.reduce((e,t)=>e+t.count,0),subs:t.sort((e,t)=>e.subgroup.localeCompare(t.subgroup))})).sort((e,t)=>e.name.localeCompare(t.name))}var h=`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-[5px] text-left text-[12.5px] outline-none transition-colors`;function he(){return(0,c.jsx)(`div`,{"aria-hidden":!0,children:[64,40,44,52,48,44,40].map((e,t)=>(0,c.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-[5px]`,children:[(0,c.jsx)(`span`,{className:`h-4 w-4 shrink-0 animate-pulse rounded bg-black/5`}),(0,c.jsx)(`span`,{className:`h-3 animate-pulse rounded bg-black/5`,style:{width:e}}),(0,c.jsx)(`span`,{className:`ml-auto h-3 w-7 shrink-0 animate-pulse rounded bg-black/5`})]},t))})}function g(e){return{source:`drawnicons`,id:e[0],label:e[1],keywords:e[2]?e[2].split(` `):void 0,style:e[7]}}function _(e,t){e(e=>{let{[t]:n,...r}=e;return r})}function v(e){let{open:t,onOpenChange:n,onPick:v}=e,{searchIcons:y}=r(),{remember:ge}=ue(),_e=ee(e=>e.coarsePointer),[b,x]=(0,s.useState)(``),[S,ve]=(0,s.useState)([]),[ye,be]=(0,s.useState)(null),[C,w]=(0,s.useState)(()=>i().cachedLibraryGroups(`drawnicons`)??`loading`),[T,xe]=(0,s.useState)(null),[Se,Ce]=(0,s.useState)(null),[E,D]=(0,s.useState)({}),[O,k]=(0,s.useState)({query:``,failed:!1,entries:[]}),A=(0,s.useRef)([]),j=(0,s.useRef)(null),M=(0,s.useRef)(null),[N,we]=(0,s.useState)(0),[P,Te]=(0,s.useState)({width:480,height:360}),[Ee,F]=(0,s.useState)(null);(0,s.useEffect)(()=>{if(!t)return;let e=!0;return i().loadAssetIndex(`drawnicons`).then(t=>{if(e){let e=t.map(([e,t,n])=>({source:`drawnicons`,id:t,label:e,keywords:Array.isArray(n)?n:void 0}));A.current=e,ve(e)}}).catch(()=>void 0),te(`drawnicons`).then(t=>{e&&t&&be(t)}).catch(()=>void 0),i().loadLibraryGroups(`drawnicons`).then(t=>{e&&w(t.length>0?t:`unavailable`)}).catch(()=>{e&&w(`unavailable`)}),()=>{e=!1}},[t]),(0,s.useEffect)(()=>{let e=b.trim().toLowerCase();if(!y||e.length<2){k({query:``,failed:!1,entries:[]});return}let t=!0,n=window.setTimeout(()=>{y(e).then(n=>{t&&k({query:e,failed:!1,entries:n.map(e=>({source:`drawnicons`,id:e.slug,label:e.name}))})}).catch(()=>{t&&k({query:e,failed:!0,entries:A.current.filter(t=>f(t,e))})})},150);return()=>{t=!1,window.clearTimeout(n)}},[b,y]);let I=(0,s.useRef)(null),De=(0,s.useCallback)(e=>{if(M.current=e,I.current?.disconnect(),I.current=null,e){let t=()=>Te({width:e.clientWidth-u,height:e.clientHeight});t();let n=new ResizeObserver(t);n.observe(e),I.current=n}},[]);function L(){Ae(0),F(null),M.current&&(M.current.scrollTop=0)}function Oe(e){ne(`drawnicons`,e.group,e.subgroup).then(t=>{t&&D(n=>({...n,[e.id]:{count:t.count,entries:t.entries.map(g)}}))}).catch(()=>{D(t=>({...t,[e.id]:`error`}))})}function R(e){xe(e),x(``),L(),e&&(E[e.id]===void 0||E[e.id]===`error`)&&(E[e.id]===`error`&&_(D,e.id),Oe(e))}let z=b.trim().toLowerCase(),B=!z&&T?E[T.id]:void 0,V=(0,s.useMemo)(()=>z?y&&z.length>=2?O.query===z?O.entries:null:S.filter(e=>f(e,z)):T?B===void 0?null:B===`error`?[]:B.entries:S,[z,S,O,y,T,B]),H=(0,s.useRef)([]);V&&(H.current=V);let U=V??H.current,W=V===null,ke=B===`error`,G=le((0,s.useMemo)(()=>[{label:null,entries:U}],[U]),P.width,l);function K(e){ge(e),n(!1),v(e.id,e.source)}let{focus:q,setFocus:Ae,onKeyDown:je}=fe({layout:G,scrollRef:M,onEnter:K});function Me(e){x(e),L()}let Ne=N-d,Pe=N+P.height+d,Fe=Math.max(1,Math.floor(P.width/l)),J=P.width/Fe,Y=[];for(let e of G.rows)if(!(e.top+e.height<Ne)){if(e.top>Pe)break;e.type===`icons`&&e.entries.forEach((t,n)=>{let r=e.startIndex+n;Y.push((0,c.jsx)(de,{source:`drawnicons`,slug:t.id,label:t.label,left:n*J+(J-l)/2,top:e.top,focused:r===q,onPick:()=>K(t),onHover:e=>{F(e?t:null),e&&ae(`drawnicons`,t.id)},size:l},t.id))})}let X=ye?.count,Ie=(0,s.useMemo)(()=>Array.isArray(C)?me(C):[],[C]),Le=C!==`unavailable`,Z=C===`loading`,Q=!!z&&O.query===z&&O.failed,$=W?`Searching…`:z?Q?`Couldn't reach the image search — check your connection and try again.`:`No images match “${b}”.`:ke?`Couldn't load these — pick it again to retry.`:`Loading images…`;function Re(){return z?Q?G.flat.length>0?`${G.flat.length.toLocaleString()} offline results`:`search unavailable`:`${G.flat.length.toLocaleString()} results`:T?`${(B!==`error`&&B?.count||T.count).toLocaleString()} images in ${T.subgroup}`:X?`${X.toLocaleString()} images`:`${G.flat.length.toLocaleString()} featured`}return(0,c.jsx)(ce,{open:t,onOpenChange:n,children:(0,c.jsxs)(o,{children:[(0,c.jsx)(a,{className:`fixed inset-0 bg-gray-900/15`}),(0,c.jsxs)(se,{initialFocus:_e?void 0:j,"data-overlay":!0,"data-testid":`image-library`,className:`fixed left-1/2 top-[16%] flex w-[min(720px,92vw)] -translate-x-1/2 flex-col overflow-hidden rounded-xl outline-none ${oe.popup}`,style:{height:`min(64vh, 560px)`},onKeyDown:e=>{e.target?.closest?.(`[data-library-sidebar]`)||je(e),e.stopPropagation()},children:[(0,c.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--chrome-ring)] px-3.5`,children:[W?(0,c.jsx)(re,{size:15,stroke:1.75,className:`shrink-0 animate-spin text-[var(--chrome-fg-400)]`}):(0,c.jsx)(ie,{size:15,stroke:1.75,className:`shrink-0 text-[var(--chrome-fg-400)]`}),(0,c.jsx)(`input`,{ref:j,"data-testid":`image-library-search`,value:b,onChange:e=>Me(e.target.value),placeholder:X?`Search ${X.toLocaleString()} images…`:`Search images…`,className:`w-full bg-transparent py-2.5 text-[13.5px] text-[var(--chrome-fg-900)] outline-none placeholder:text-[var(--chrome-fg-400)]`})]}),(0,c.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[Le&&(0,c.jsx)(`nav`,{"data-library-sidebar":!0,"data-testid":`image-library-sidebar`,"aria-label":`Image categories`,"aria-busy":Z||void 0,className:`scrollbar-slim w-[176px] shrink-0 overflow-y-auto border-r border-[var(--chrome-ring)] p-1.5`,children:Z?(0,c.jsx)(he,{}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)(`button`,{type:`button`,onClick:()=>R(null),"aria-current":T?void 0:`true`,className:`${h} ${T?`text-[var(--chrome-fg-700)] hover:bg-[var(--chrome-hover)]`:`bg-[var(--chrome-hover)] font-medium text-[var(--chrome-fg-900)]`}`,children:[(0,c.jsx)(m,{path:pe}),(0,c.jsx)(`span`,{className:`truncate`,children:`All images`}),X!=null&&(0,c.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] font-normal text-[var(--chrome-fg-400)]`,children:X.toLocaleString()})]}),Ie.map(e=>{if(e.subs.length===1){let t=e.subs[0],n=T?.id===t.id;return(0,c.jsxs)(`button`,{type:`button`,onClick:()=>R(t),"aria-current":n?`true`:void 0,className:`${h} capitalize ${n?`bg-[var(--chrome-hover)] font-medium text-[var(--chrome-fg-900)]`:`text-[var(--chrome-fg-700)] hover:bg-[var(--chrome-hover)]`}`,children:[(0,c.jsx)(m,{path:p[e.name]}),(0,c.jsx)(`span`,{className:`truncate`,children:e.name}),(0,c.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] font-normal text-[var(--chrome-fg-400)]`,children:e.total.toLocaleString()})]},e.name)}let t=Se===e.name;return(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`button`,{type:`button`,onClick:()=>Ce(t?null:e.name),"aria-expanded":t,className:`${h} capitalize text-[var(--chrome-fg-700)] hover:bg-[var(--chrome-hover)]`,children:[(0,c.jsx)(m,{path:p[e.name]}),(0,c.jsx)(`span`,{className:`truncate`,children:e.name}),(0,c.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-[var(--chrome-fg-400)]`,children:e.total.toLocaleString()})]}),t&&e.subs.map(e=>{let t=T?.id===e.id;return(0,c.jsxs)(`button`,{type:`button`,onClick:()=>R(e),"aria-current":t?`true`:void 0,className:`${h} pl-8 ${t?`bg-[var(--chrome-hover)] font-medium text-[var(--chrome-fg-900)]`:`text-[var(--chrome-fg-500)] hover:bg-[var(--chrome-hover)] hover:text-[var(--chrome-fg-700)]`}`,children:[(0,c.jsx)(`span`,{className:`truncate`,children:e.subgroup}),(0,c.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] font-normal text-[var(--chrome-fg-400)]`,children:e.count.toLocaleString()})]},e.id)})]},e.name)})]})}),(0,c.jsx)(`div`,{ref:De,onScroll:e=>we(e.currentTarget.scrollTop),className:`scrollbar-slim relative min-w-0 flex-1 overflow-y-auto overflow-x-hidden p-2`,children:G.flat.length===0?(0,c.jsx)(`div`,{className:`px-2 py-8 text-center text-sm text-gray-400`,children:$}):(0,c.jsx)(`div`,{className:`relative`,style:{height:G.totalHeight},children:Y})})]}),(0,c.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-black/5 px-3 py-2 text-[11px] text-gray-400`,children:[(0,c.jsx)(`span`,{className:`truncate text-gray-600`,children:Ee?.label??G.flat[q]?.label??(!z&&T?`${T.group} / ${T.subgroup}`:`Image library`)}),(0,c.jsx)(`span`,{className:`shrink-0`,children:Re()})]})]})]})})}export{v as ImageLibraryDialog};