@ra3orblade/swarm 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/web/index.html CHANGED
@@ -205,7 +205,9 @@
205
205
  .stdin button.danger{color:var(--warn);border-color:var(--warn-soft)}
206
206
  .stdin .hint{color:var(--dim);font-size:var(--fs-sm)}
207
207
  .pk-f{display:flex;gap:8px;padding:12px 14px;border-top:1px solid var(--line)}
208
- .pk-f button{flex:none}.pk-f .grow{flex:1}
208
+ .pk-f button{flex:none}
209
+ /* a flex spacer, anywhere (the picker header relied on this being global and it wasn't) */
210
+ .grow{flex:1}
209
211
  .pk-f .primary{background:var(--acc);border-color:var(--acc);color:var(--acc-contrast)}
210
212
  .pk-f .primary:hover{filter:brightness(1.06);color:var(--acc-contrast)}
211
213
  .proj .nm .pdir{opacity:.5;font-weight:400}
@@ -213,7 +215,10 @@
213
215
  .proj[draggable]{cursor:grab}
214
216
  .proj.dragging{opacity:.35;background:var(--panel-2);outline:1px dashed var(--acc)}
215
217
  button{background:var(--panel);border:1px solid var(--line);color:var(--fg-2);padding:var(--pad-ctl);
216
- border-radius:var(--r-sm);font:600 var(--fs-md) var(--sans);cursor:pointer;transition:border-color var(--t-fast),color var(--t-fast)}
218
+ border-radius:var(--r-sm);font:600 var(--fs-md) var(--sans);cursor:pointer;transition:border-color var(--t-fast),color var(--t-fast);
219
+ display:inline-flex;align-items:center;justify-content:center;gap:6px;line-height:1}
220
+ /* icon-only buttons (the picker's ×): square, the glyph dead-centre */
221
+ .pk-h button{padding:6px;line-height:0}
217
222
  button:hover{border-color:var(--acc);color:var(--fg)}
218
223
 
219
224
  /* main */
@@ -223,6 +228,12 @@
223
228
  h2{font-size:var(--fs-md);margin:0 0 12px;color:var(--dim);font-weight:600;text-transform:uppercase;
224
229
  letter-spacing:.07em;display:flex;gap:10px;align-items:baseline}
225
230
  h2 span{font-weight:500;text-transform:none;letter-spacing:0;color:var(--faint);font-size:var(--fs-md)}
231
+ /* section-header actions (New worktree, Collect stale, Dispatch clear, timeline ranges):
232
+ small buttons, not shouting header text — normal case, centered icon, hover chip */
233
+ h2 .nav{display:inline-flex;align-items:center;gap:5px;font:500 var(--fs-md) var(--sans);text-transform:none;letter-spacing:0;color:var(--acc);text-decoration:none;padding:2px 8px;border-radius:var(--r-sm);transition:background var(--t-fast)}
234
+ h2 .nav:hover{background:var(--acc-soft)}
235
+ h2 .nav.on{background:var(--acc-soft)}
236
+ h2 .nav .ph{display:block}
226
237
  h2 .back{color:var(--fg-2);text-transform:none;letter-spacing:0;font-weight:600;font-size:var(--fs-md);display:inline-flex;align-items:center;gap:5px;padding:5px 11px 5px 8px;border:1px solid var(--line);border-radius:var(--r-pill);background:var(--panel);transition:border-color var(--t-fast),color var(--t-fast)}
227
238
 
228
239
  /* tables */
@@ -447,11 +458,66 @@
447
458
  .fm-row[data-pressed="true"] .fm-ico{color:var(--acc)}
448
459
  /* Pixel icons in menu rows: flex-center them and drop the global .ph baseline nudge. */
449
460
  .fm-row__icon,.fm-ico{display:inline-flex;align-items:center;justify-content:center}
461
+ /* labels are the point of a menu: never ellipsize them — the caption yields instead */
462
+ .fm-row__name{flex:1 1 auto;min-width:0}
463
+ .fm-row__caption{flex:0 1 auto;min-width:0;max-width:45%;margin-left:auto;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
450
464
  .fm-ico .ph{vertical-align:0}
451
465
  main>h2:not(:first-child){margin-top:var(--gap-sec)}
452
466
  .mt-sec{margin-top:var(--gap-sec)}
467
+ /* project glyphs (icon/color settings) */
468
+ .pg{display:inline-flex;align-items:center;justify-content:center;width:16px;height:16px;flex:none;font-size:var(--fs-md);line-height:1;color:var(--dim);vertical-align:middle;margin-top:-2px;overflow:visible}
469
+ .pg-c1{color:var(--c1)} .pg-c2{color:var(--c2)} .pg-c3{color:var(--c3)} .pg-c4{color:var(--c4)} .pg-c5{color:var(--c5)} .pg-c6{color:var(--c6)} .pg-c7{color:var(--c7)}
470
+ .pg-img{width:16px;height:16px;object-fit:cover;border-radius:var(--r-xs);display:block}
471
+ .pg-lg{width:34px;height:34px;font-size:var(--fs-2xl);line-height:1;border:1px solid var(--line);border-radius:var(--r-sm);background:var(--panel-2);overflow:hidden} .pg-lg .pg-img{width:34px;height:34px;border-radius:0}
472
+ .icon-row{display:flex;align-items:center;gap:8px} .icon-row input{flex:1}
473
+ .icon-row .btn{display:inline-flex;align-items:center;gap:5px;padding:var(--pad-ctl);border:1px solid var(--line);border-radius:var(--r-sm);background:var(--panel-2);color:var(--fg-2);cursor:pointer;font:500 var(--fs-sm) var(--sans);white-space:nowrap}
474
+ .icon-row .btn:hover{border-color:var(--acc)}
475
+ .emoji-row{display:flex;flex-wrap:wrap;gap:4px}
476
+ .emoji-all{max-height:200px;overflow:auto;border:1px solid var(--line);border-radius:var(--r-sm);padding:8px;display:grid;gap:6px}
477
+ .emoji-sec{font-size:var(--fs-2xs);color:var(--dim);text-transform:uppercase;letter-spacing:.06em;font-weight:600;margin-top:4px}
478
+ .more-emoji{color:var(--fg-2);font-weight:700}
479
+ .emoji{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border:1px solid var(--line);border-radius:var(--r-sm);cursor:pointer;font-size:var(--fs-xl);line-height:1;background:var(--panel-2);color:var(--dim);overflow:hidden}
480
+ .emoji .ph{width:14px;height:14px}
481
+ .emoji:hover{border-color:var(--acc)} .emoji.on{border-color:var(--acc);background:var(--acc-soft)}
482
+ .swatches{display:flex;gap:6px}
483
+ .swatch{width:22px;height:22px;border-radius:50%;border:2px solid transparent;cursor:pointer;background:currentColor;box-shadow:inset 0 0 0 2px var(--panel)}
484
+ .swatch.none{background:var(--panel-2);color:var(--line);box-shadow:inset 0 0 0 1px var(--line)}
485
+ .swatch:hover{border-color:var(--fg-2)} .swatch.on{border-color:var(--fg)}
486
+ .pk-b label.chk{display:flex;align-items:center;gap:8px;flex-direction:row}
487
+ .pk-b label.chk input{width:auto}
488
+ /* board: kpi accents, kanban, worktree map */
489
+ .kpis-5{grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}
490
+ .kpi.hot .v{color:var(--warn)} .kpi.warm .v{color:var(--acc)}
491
+ .grow{flex:1}
492
+ .kanban{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;align-items:start;margin-bottom:var(--gap-sec)}
493
+ .lane{background:var(--panel-2);border:1px solid var(--line);border-radius:var(--r);padding:8px;display:flex;flex-direction:column;gap:8px;min-height:60px}
494
+ .lane-h{font-size:var(--fs-sm);color:var(--dim);text-transform:uppercase;letter-spacing:.06em;font-weight:600;padding:2px 4px}
495
+ .lane-h span{color:var(--faint);font-weight:500}
496
+ .lane-empty{color:var(--faint);text-align:center;padding:10px 0}
497
+ .lane-more{font-size:var(--fs-xs);padding:2px 4px}
498
+ .tcard{background:var(--panel);border:1px solid var(--line);border-left:3px solid var(--line);border-radius:var(--r-sm);box-shadow:var(--shadow);padding:8px 10px;cursor:pointer;transition:border-color var(--t-fast)}
499
+ .tcard:hover,.tcard:focus-visible,.wt:focus-visible,.more:focus-visible{border-color:var(--acc);outline:none}
500
+ .more:focus-visible{opacity:1}
501
+ .tcard.ready{border-left-color:var(--ok)} .tcard.held{border-left-color:var(--acc)} .tcard.blocked{border-left-color:var(--line)} .tcard.done{opacity:.7}
502
+ .tc-h{display:flex;gap:8px;align-items:center;font-size:var(--fs-sm);margin-bottom:3px}
503
+ .tc-h .dim{font-family:var(--mono);font-size:var(--fs-2xs);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
504
+ .tc-t{font-size:var(--fs-md);color:var(--fg);line-height:1.35;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
505
+ .tc-m{font-size:var(--fs-xs);color:var(--faint);margin-top:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
506
+ .tc-g{margin-top:6px}
507
+ .wtmap{display:flex;flex-direction:column;gap:14px;margin-bottom:var(--gap-sec)}
508
+ .wt-proj{font-size:var(--fs-sm);color:var(--dim);text-transform:uppercase;letter-spacing:.06em;font-weight:600;margin-bottom:6px}
509
+ .wt-proj span{color:var(--faint);font-weight:500}
510
+ .wt-tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}
511
+ .wt{background:var(--panel);border:1px solid var(--line);border-radius:var(--r-sm);box-shadow:var(--shadow);padding:8px 10px;cursor:pointer;min-width:0;transition:border-color var(--t-fast)}
512
+ .wt:hover{border-color:var(--acc)}
513
+ .wt.main{background:var(--panel-2)}
514
+ .wt.live{border-color:var(--ok)} .wt.dirty{border-color:var(--warn)} .wt.merged{opacity:.6}
515
+ .wt-b{display:flex;align-items:center;gap:6px;min-width:0}
516
+ .wt-b .s{margin:0;flex:none} .wt-b .br{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
517
+ .wt-m{font-size:var(--fs-xs);color:var(--faint);margin-top:3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
518
+ .wt-m i{font-style:normal} .wt-m i.warn{color:var(--warn)} .wt-m i.acc{color:var(--acc)}
453
519
  .chips{display:flex;gap:6px;margin-bottom:14px;flex-wrap:wrap}
454
- .chip{font:500 var(--fs-md) var(--sans);padding:4px 11px;border-radius:var(--r-pill);background:var(--panel);border:1px solid var(--line);color:var(--dim);cursor:pointer;user-select:none}
520
+ .chip{display:inline-flex;align-items:center;gap:5px;font:500 var(--fs-md) var(--sans);padding:4px 11px;border-radius:var(--r-pill);background:var(--panel);border:1px solid var(--line);color:var(--dim);cursor:pointer;user-select:none}
455
521
  .chip:hover{border-color:var(--acc);color:var(--fg-2)}
456
522
  .chip.on{background:var(--acc-soft);border-color:transparent;color:var(--acc)}
457
523
  .seg{display:inline-flex;gap:2px;background:var(--panel-2);border:1px solid var(--line);border-radius:var(--r-sm);padding:2px}
@@ -459,6 +525,43 @@
459
525
  .seg a:hover{color:var(--fg-2)}
460
526
  .seg a.on{background:var(--acc-soft);color:var(--acc)}
461
527
  .chip b{font-weight:700}
528
+ /* workflow step chips (M7.8) */
529
+ .wf-steps{display:inline-flex;gap:6px;flex-wrap:wrap}
530
+ .wfs{font:500 var(--fs-sm) var(--sans);color:var(--dim);background:var(--panel-2);border:1px solid var(--line);border-radius:var(--r-pill);padding:1px 8px;white-space:nowrap}
531
+ .wfs.ok{color:var(--ok);background:var(--ok-soft);border-color:transparent}
532
+ .wfs.run{color:var(--acc);background:var(--acc-soft);border-color:transparent}
533
+ .wfs.bad{color:var(--warn);background:var(--warn-soft);border-color:transparent}
534
+ /* M5.7: timeline ticks, idle-gap thin bars, claim lane; sidebar spend sparks; gate history */
535
+ .tl-track u{position:absolute;top:4px;bottom:4px;width:2px;border-radius:1px;opacity:.95}
536
+ .tl-track i.thin{opacity:.25}
537
+ .tl-row.claimlane .tl-name{font-size:var(--fs-2xs);text-transform:uppercase;letter-spacing:.06em}
538
+ .tl-track i.claim{top:7px;height:4px;border-radius:2px;background:var(--violet);opacity:.6}
539
+ .tl-track i.claim.orphaned{background:var(--warn);opacity:.9}
540
+ .tl-track i.claim.expired{background:var(--faint)}
541
+ .proj-spark{flex:none;width:44px;display:inline-flex;opacity:.7}
542
+ .proj-spark .spark{width:44px;height:14px}
543
+ .gh-strip{display:inline-flex;gap:12px;font-weight:400}
544
+ .gh{font-size:var(--fs-sm);color:var(--dim);display:inline-flex;align-items:center;gap:3px}
545
+ .gh i{width:7px;height:7px;border-radius:2px;display:inline-block}
546
+ .gh i.ok{background:var(--ok)} .gh i.bad{background:var(--warn)}
547
+ /* session message thread (M7.6) */
548
+ .msgs{display:flex;flex-direction:column;gap:6px;max-height:220px;overflow:auto;margin-bottom:8px}
549
+ .msg{background:var(--panel-2);border:1px solid var(--line);border-radius:var(--r-sm);padding:6px 9px;font-size:var(--fs-md);color:var(--fg-2);word-break:break-word}
550
+ .msg.out{background:var(--acc-soft);border-color:transparent}
551
+ .msg-f{display:block;font-size:var(--fs-2xs);color:var(--dim);margin-bottom:2px}
552
+ .msg-compose{display:flex;gap:6px}
553
+ .msg-compose input{flex:1;background:var(--panel-2);border:1px solid var(--line);color:var(--fg);border-radius:var(--r-sm);padding:6px 9px;font:400 var(--fs-md) var(--sans)}
554
+ .msg-compose input:focus{border-color:var(--acc);outline:none}
555
+ .msg-compose button{background:var(--acc-soft);border:1px solid transparent;color:var(--acc);border-radius:var(--r-sm);padding:6px 10px;cursor:pointer}
556
+ /* first-run onboarding card */
557
+ .onboard{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);padding:28px 30px;display:flex;flex-direction:column;gap:16px;align-items:flex-start;max-width:640px;margin:40px auto}
558
+ .onboard h3{font-size:var(--fs-xl);color:var(--fg)}
559
+ .onboard .px{margin:0 auto}
560
+ .ob-steps{display:flex;flex-direction:column;gap:12px}
561
+ .ob-step{display:flex;gap:12px;align-items:flex-start;color:var(--fg-2);line-height:1.5}
562
+ .ob-step.done{color:var(--dim)}
563
+ .ob-n{flex:none;width:22px;height:22px;border-radius:50%;border:1px solid var(--line);display:inline-flex;align-items:center;justify-content:center;font:600 var(--fs-sm) var(--sans);color:var(--dim);margin-top:1px}
564
+ .ob-step.done .ob-n{background:var(--ok-soft);color:var(--ok);border-color:transparent}
462
565
  /* star nudge (once a month, dismissable) */
463
566
  .nudge{position:fixed;right:18px;bottom:18px;z-index:40;max-width:400px;background:var(--panel);border:1px solid var(--line);
464
567
  border-radius:var(--r);box-shadow:var(--shadow-pop);padding:14px 16px;display:flex;gap:12px;align-items:flex-start;
package/web/menus.js CHANGED
@@ -11,4 +11,4 @@ Error generating stack: `+o.message+`
11
11
  While dragging, use the arrow keys to move the item.
12
12
  Press space again to drop the item in its new position, or press escape to cancel.
13
13
  `},Z_={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:a}=e;if(a)return"Draggable item "+t.id+" was moved over droppable area "+a.id+".";return"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:a}=e;if(a)return"Draggable item "+t.id+" was dropped over droppable area "+a.id;return"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function X_(e){let{announcements:t=Z_,container:a,hiddenTextDescribedById:o,screenReaderInstructions:n=q_}=e,{announce:s,announcement:i}=hH(),l=Ho("DndLiveRegion"),[c,u]=A.useState(!1);if(A.useEffect(()=>{u(!0)},[]),G_(A.useMemo(()=>({onDragStart(m){let{active:d}=m;s(t.onDragStart({active:d}))},onDragMove(m){let{active:d,over:p}=m;if(t.onDragMove)s(t.onDragMove({active:d,over:p}))},onDragOver(m){let{active:d,over:p}=m;s(t.onDragOver({active:d,over:p}))},onDragEnd(m){let{active:d,over:p}=m;s(t.onDragEnd({active:d,over:p}))},onDragCancel(m){let{active:d,over:p}=m;s(t.onDragCancel({active:d,over:p}))}}),[s,t])),!c)return null;let f=A.default.createElement(A.default.Fragment,null,A.default.createElement(dH,{id:o,value:n.draggable}),A.default.createElement(pH,{id:l,announcement:i}));return a?Fo.createPortal(f,a):f}var Ge;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(Ge||(Ge={}));function Bi(){}function Uu(e,t){return A.useMemo(()=>({sensor:e,options:t!=null?t:{}}),[e,t])}function DH(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return A.useMemo(()=>[...t].filter((o)=>o!=null),[...t])}var Wt=Object.freeze({x:0,y:0});function EH(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function j_(e,t){let a=En(e);if(!a)return"0 0";let o={x:(a.x-t.left)/t.width*100,y:(a.y-t.top)/t.height*100};return o.x+"% "+o.y+"%"}function LH(e,t){let{data:{value:a}}=e,{data:{value:o}}=t;return a-o}function Y_(e,t){let{data:{value:a}}=e,{data:{value:o}}=t;return o-a}function Ou(e){let{left:t,top:a,height:o,width:n}=e;return[{x:t,y:a},{x:t+n,y:a},{x:t,y:a+o},{x:t+n,y:a+o}]}function Fu(e,t){if(!e||e.length===0)return null;let[a]=e;return t?a[t]:a}var RH=(e)=>{let{collisionRect:t,droppableRects:a,droppableContainers:o}=e,n=Ou(t),s=[];for(let i of o){let{id:l}=i,c=a.get(l);if(c){let u=Ou(c),f=n.reduce((d,p,v)=>d+EH(u[v],p),0),m=Number((f/4).toFixed(4));s.push({id:l,data:{droppableContainer:i,value:m}})}}return s.sort(LH)};function Q_(e,t){let a=Math.max(t.top,e.top),o=Math.max(t.left,e.left),n=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=n-o,l=s-a;if(o<n&&a<s){let c=t.width*t.height,u=e.width*e.height,f=i*l,m=f/(c+u-f);return Number(m.toFixed(4))}return 0}var _u=(e)=>{let{collisionRect:t,droppableRects:a,droppableContainers:o}=e,n=[];for(let s of o){let{id:i}=s,l=a.get(i);if(l){let c=Q_(l,t);if(c>0)n.push({id:i,data:{droppableContainer:s,value:c}})}}return n.sort(Y_)};function W_(e,t){let{top:a,left:o,bottom:n,right:s}=t;return a<=e.y&&e.y<=n&&o<=e.x&&e.x<=s}var BH=(e)=>{let{droppableContainers:t,droppableRects:a,pointerCoordinates:o}=e;if(!o)return[];let n=[];for(let s of t){let{id:i}=s,l=a.get(i);if(l&&W_(o,l)){let u=Ou(l).reduce((m,d)=>m+EH(o,d),0),f=Number((u/4).toFixed(4));n.push({id:i,data:{droppableContainer:s,value:f}})}}return n.sort(LH)};function K_(e,t,a){return{...e,scaleX:t&&a?t.width/a.width:1,scaleY:t&&a?t.height/a.height:1}}function NH(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Wt}function J_(e){return function(a){for(var o=arguments.length,n=Array(o>1?o-1:0),s=1;s<o;s++)n[s-1]=arguments[s];return n.reduce((i,l)=>({...i,top:i.top+e*l.y,bottom:i.bottom+e*l.y,left:i.left+e*l.x,right:i.right+e*l.x}),{...a})}}var $_=J_(1);function OH(e){if(e.startsWith("matrix3d(")){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function e9(e,t,a){let o=OH(t);if(!o)return e;let{scaleX:n,scaleY:s,x:i,y:l}=o,c=e.left-i-(1-n)*parseFloat(a),u=e.top-l-(1-s)*parseFloat(a.slice(a.indexOf(" ")+1)),f=n?e.width/n:e.width,m=s?e.height/s:e.height;return{width:f,height:m,top:u,right:c+f,bottom:u+m,left:c}}var t9={ignoreTransform:!1};function _o(e,t){if(t===void 0)t=t9;let a=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:u,transformOrigin:f}=lt(e).getComputedStyle(e);if(u)a=e9(a,u,f)}let{top:o,left:n,width:s,height:i,bottom:l,right:c}=a;return{top:o,left:n,width:s,height:i,bottom:l,right:c}}function gH(e){return _o(e,{ignoreTransform:!0})}function a9(e){let{innerWidth:t,innerHeight:a}=e;return{top:0,left:0,right:t,bottom:a,width:t,height:a}}function o9(e,t){if(t===void 0)t=lt(e).getComputedStyle(e);return t.position==="fixed"}function n9(e,t){if(t===void 0)t=lt(e).getComputedStyle(e);let a=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((n)=>{let s=t[n];return typeof s==="string"?a.test(s):!1})}function Gr(e,t){let a=[];function o(n){if(t!=null&&a.length>=t)return a;if(!n)return a;if(Li(n)&&n.scrollingElement!=null&&!a.includes(n.scrollingElement))return a.push(n.scrollingElement),a;if(!Tn(n)||Lu(n))return a;if(a.includes(n))return a;let s=lt(e).getComputedStyle(n);if(n!==e){if(n9(n,s))a.push(n)}if(o9(n,s))return a;return o(n.parentNode)}if(!e)return a;return o(e)}function HH(e){let[t]=Gr(e,1);return t!=null?t:null}function Ru(e){if(!kr||!e)return null;if(No(e))return e;if(!Ei(e))return null;if(Li(e)||e===Oo(e).scrollingElement)return window;if(Tn(e))return e;return null}function kH(e){if(No(e))return e.scrollX;return e.scrollLeft}function zH(e){if(No(e))return e.scrollY;return e.scrollTop}function Hu(e){return{x:kH(e),y:zH(e)}}var Ye;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Ye||(Ye={}));function UH(e){if(!kr||!e)return!1;return e===document.scrollingElement}function FH(e){let t={x:0,y:0},a=UH(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-a.width,y:e.scrollHeight-a.height},n=e.scrollTop<=t.y,s=e.scrollLeft<=t.x,i=e.scrollTop>=o.y,l=e.scrollLeft>=o.x;return{isTop:n,isLeft:s,isBottom:i,isRight:l,maxScroll:o,minScroll:t}}var r9={x:0.2,y:0.2};function s9(e,t,a,o,n){let{top:s,left:i,right:l,bottom:c}=a;if(o===void 0)o=10;if(n===void 0)n=r9;let{isTop:u,isBottom:f,isLeft:m,isRight:d}=FH(e),p={x:0,y:0},v={x:0,y:0},b={height:t.height*n.y,width:t.width*n.x};if(!u&&s<=t.top+b.height)p.y=Ye.Backward,v.y=o*Math.abs((t.top+b.height-s)/b.height);else if(!f&&c>=t.bottom-b.height)p.y=Ye.Forward,v.y=o*Math.abs((t.bottom-b.height-c)/b.height);if(!d&&l>=t.right-b.width)p.x=Ye.Forward,v.x=o*Math.abs((t.right-b.width-l)/b.width);else if(!m&&i<=t.left+b.width)p.x=Ye.Backward,v.x=o*Math.abs((t.left+b.width-i)/b.width);return{direction:p,speed:v}}function i9(e){if(e===document.scrollingElement){let{innerWidth:s,innerHeight:i}=window;return{top:0,left:0,right:s,bottom:i,width:s,height:i}}let{top:t,left:a,right:o,bottom:n}=e.getBoundingClientRect();return{top:t,left:a,right:o,bottom:n,width:e.clientWidth,height:e.clientHeight}}function _H(e){return e.reduce((t,a)=>ko(t,Hu(a)),Wt)}function l9(e){return e.reduce((t,a)=>t+kH(a),0)}function c9(e){return e.reduce((t,a)=>t+zH(a),0)}function PH(e,t){if(t===void 0)t=_o;if(!e)return;let{top:a,left:o,bottom:n,right:s}=t(e);if(!HH(e))return;if(n<=0||s<=0||a>=window.innerHeight||o>=window.innerWidth)e.scrollIntoView({block:"center",inline:"center"})}var u9=[["x",["left","right"],l9],["y",["top","bottom"],c9]];class Oi{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let a=Gr(t),o=_H(a);this.rect={...e},this.width=e.width,this.height=e.height;for(let[n,s,i]of u9)for(let l of s)Object.defineProperty(this,l,{get:()=>{let c=i(a),u=o[n]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ln{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((t)=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...t)})},this.target=e}add(e,t,a){var o;(o=this.target)==null||o.addEventListener(e,t,a),this.listeners.push([e,t,a])}}function f9(e){let{EventTarget:t}=lt(e);return e instanceof t?e:Oo(e)}function Bu(e,t){let a=Math.abs(e.x),o=Math.abs(e.y);if(typeof t==="number")return Math.sqrt(a**2+o**2)>t;if("x"in t&&"y"in t)return a>t.x&&o>t.y;if("x"in t)return a>t.x;if("y"in t)return o>t.y;return!1}var zt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(zt||(zt={}));function IH(e){e.preventDefault()}function m9(e){e.stopPropagation()}var V;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(V||(V={}));var GH={start:[V.Space,V.Enter],cancel:[V.Esc],end:[V.Space,V.Enter,V.Tab]},d9=(e,t)=>{let{currentCoordinates:a}=t;switch(e.code){case V.Right:return{...a,x:a.x+25};case V.Left:return{...a,x:a.x-25};case V.Down:return{...a,y:a.y+25};case V.Up:return{...a,y:a.y-25}}return};class Vr{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Ln(Oo(t)),this.windowListeners=new Ln(lt(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(zt.Resize,this.handleCancel),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(zt.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,a=e.node.current;if(a)PH(a);t(Wt)}handleKeyDown(e){if(Dn(e)){let{active:t,context:a,options:o}=this.props,{keyboardCodes:n=GH,coordinateGetter:s=d9,scrollBehavior:i="smooth"}=o,{code:l}=e;if(n.end.includes(l)){this.handleEnd(e);return}if(n.cancel.includes(l)){this.handleCancel(e);return}let{collisionRect:c}=a.current,u=c?{x:c.left,y:c.top}:Wt;if(!this.referenceCoordinates)this.referenceCoordinates=u;let f=s(e,{active:t,context:a.current,currentCoordinates:u});if(f){let m=zo(f,u),d={x:0,y:0},{scrollableAncestors:p}=a.current;for(let v of p){let b=e.code,{isTop:C,isRight:g,isLeft:I,isBottom:S,maxScroll:y,minScroll:w}=FH(v),T=i9(v),x={x:Math.min(b===V.Right?T.right-T.width/2:T.right,Math.max(b===V.Right?T.left:T.left+T.width/2,f.x)),y:Math.min(b===V.Down?T.bottom-T.height/2:T.bottom,Math.max(b===V.Down?T.top:T.top+T.height/2,f.y))},E=b===V.Right&&!g||b===V.Left&&!I,L=b===V.Down&&!S||b===V.Up&&!C;if(E&&x.x!==f.x){let D=v.scrollLeft+m.x,N=b===V.Right&&D<=y.x||b===V.Left&&D>=w.x;if(N&&!m.y){v.scrollTo({left:D,behavior:i});return}if(N)d.x=v.scrollLeft-D;else d.x=b===V.Right?v.scrollLeft-y.x:v.scrollLeft-w.x;if(d.x)v.scrollBy({left:-d.x,behavior:i});break}else if(L&&x.y!==f.y){let D=v.scrollTop+m.y,N=b===V.Down&&D<=y.y||b===V.Up&&D>=w.y;if(N&&!m.x){v.scrollTo({top:D,behavior:i});return}if(N)d.y=v.scrollTop-D;else d.y=b===V.Down?v.scrollTop-y.y:v.scrollTop-w.y;if(d.y)v.scrollBy({top:-d.y,behavior:i});break}}this.handleMove(e,ko(zo(f,this.referenceCoordinates),d))}}}handleMove(e,t){let{onMove:a}=this.props;e.preventDefault(),a(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Vr.activators=[{eventName:"onKeyDown",handler:(e,t,a)=>{let{keyboardCodes:o=GH,onActivation:n}=t,{active:s}=a,{code:i}=e.nativeEvent;if(o.start.includes(i)){let l=s.activatorNode.current;if(l&&e.target!==l)return!1;return e.preventDefault(),n==null||n({event:e.nativeEvent}),!0}return!1}}];function SH(e){return Boolean(e&&"distance"in e)}function vH(e){return Boolean(e&&"delay"in e)}class Hi{constructor(e,t,a){var o;if(a===void 0)a=f9(e.event.target);this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:n}=e,{target:s}=n;this.props=e,this.events=t,this.document=Oo(s),this.documentListeners=new Ln(this.document),this.listeners=new Ln(a),this.windowListeners=new Ln(lt(s)),this.initialCoordinates=(o=En(n))!=null?o:Wt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:a}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel)this.listeners.add(e.cancel.name,this.handleCancel);if(this.windowListeners.add(zt.Resize,this.handleCancel),this.windowListeners.add(zt.DragStart,IH),this.windowListeners.add(zt.VisibilityChange,this.handleCancel),this.windowListeners.add(zt.ContextMenu,IH),this.documentListeners.add(zt.Keydown,this.handleKeydown),t){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(vH(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(SH(t)){this.handlePending(t);return}}this.handleStart()}detach(){if(this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null)clearTimeout(this.timeoutId),this.timeoutId=null}handlePending(e,t){let{active:a,onPending:o}=this.props;o(a,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;if(e)this.activated=!0,this.documentListeners.add(zt.Click,m9,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(zt.SelectionChange,this.removeTextSelection),t(e)}handleMove(e){var t;let{activated:a,initialCoordinates:o,props:n}=this,{onMove:s,options:{activationConstraint:i}}=n;if(!o)return;let l=(t=En(e))!=null?t:Wt,c=zo(o,l);if(!a&&i){if(SH(i)){if(i.tolerance!=null&&Bu(c,i.tolerance))return this.handleCancel();if(Bu(c,i.distance))return this.handleStart()}if(vH(i)){if(Bu(c,i.tolerance))return this.handleCancel()}this.handlePending(i,c);return}if(e.cancelable)e.preventDefault();s(l)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;if(this.detach(),!this.activated)e(this.props.active);t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;if(this.detach(),!this.activated)e(this.props.active);t()}handleKeydown(e){if(e.code===V.Esc)this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}var p9={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class qr extends Hi{constructor(e){let{event:t}=e,a=Oo(t.target);super(e,p9,a)}}qr.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:a}=e,{onActivation:o}=t;if(!a.isPrimary||a.button!==0)return!1;return o==null||o({event:a}),!0}}];var h9={move:{name:"mousemove"},end:{name:"mouseup"}},ku;(function(e){e[e.RightClick=2]="RightClick"})(ku||(ku={}));class VH extends Hi{constructor(e){super(e,h9,Oo(e.event.target))}}VH.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:a}=e,{onActivation:o}=t;if(a.button===ku.RightClick)return!1;return o==null||o({event:a}),!0}}];var Nu={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class qH extends Hi{constructor(e){super(e,Nu)}static setup(){return window.addEventListener(Nu.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Nu.move.name,e)};function e(){}}}qH.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:a}=e,{onActivation:o}=t,{touches:n}=a;if(n.length>1)return!1;return o==null||o({event:a}),!0}}];var _r;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(_r||(_r={}));var Ni;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Ni||(Ni={}));function g9(e){let{acceleration:t,activator:a=_r.Pointer,canScroll:o,draggingRect:n,enabled:s,interval:i=5,order:l=Ni.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:f,delta:m,threshold:d}=e,p=S9({delta:m,disabled:!s}),[v,b]=uH(),C=A.useRef({x:0,y:0}),g=A.useRef({x:0,y:0}),I=A.useMemo(()=>{switch(a){case _r.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case _r.DraggableRect:return n}},[a,n,c]),S=A.useRef(null),y=A.useCallback(()=>{let T=S.current;if(!T)return;let x=C.current.x*g.current.x,E=C.current.y*g.current.y;T.scrollBy(x,E)},[]),w=A.useMemo(()=>l===Ni.TreeOrder?[...u].reverse():u,[l,u]);A.useEffect(()=>{if(!s||!u.length||!I){b();return}for(let T of w){if((o==null?void 0:o(T))===!1)continue;let x=u.indexOf(T),E=f[x];if(!E)continue;let{direction:L,speed:D}=s9(T,E,I,t,d);for(let N of["x","y"])if(!p[N][L[N]])D[N]=0,L[N]=0;if(D.x>0||D.y>0){b(),S.current=T,v(y,i),C.current=D,g.current=L;return}}C.current={x:0,y:0},g.current={x:0,y:0},b()},[t,y,o,b,s,i,JSON.stringify(I),JSON.stringify(p),v,u,w,f,JSON.stringify(d)])}var I9={x:{[Ye.Backward]:!1,[Ye.Forward]:!1},y:{[Ye.Backward]:!1,[Ye.Forward]:!1}};function S9(e){let{delta:t,disabled:a}=e,o=Fr(t);return Mn((n)=>{if(a||!o||!n)return I9;let s={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[Ye.Backward]:n.x[Ye.Backward]||s.x===-1,[Ye.Forward]:n.x[Ye.Forward]||s.x===1},y:{[Ye.Backward]:n.y[Ye.Backward]||s.y===-1,[Ye.Forward]:n.y[Ye.Forward]||s.y===1}}},[a,t,o])}function v9(e,t){let a=t!=null?e.get(t):void 0,o=a?a.node.current:null;return Mn((n)=>{var s;if(t==null)return null;return(s=o!=null?o:n)!=null?s:null},[o,t])}function y9(e,t){return A.useMemo(()=>e.reduce((a,o)=>{let{sensor:n}=o,s=n.activators.map((i)=>({eventName:i.eventName,handler:t(i.handler,o)}));return[...a,...s]},[]),[e,t])}var Pr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Pr||(Pr={}));var zu;(function(e){e.Optimized="optimized"})(zu||(zu={}));var yH=new Map;function b9(e,t){let{dragging:a,dependencies:o,config:n}=t,[s,i]=A.useState(null),{frequency:l,measure:c,strategy:u}=n,f=A.useRef(e),m=C(),d=xn(m),p=A.useCallback(function(g){if(g===void 0)g=[];if(d.current)return;i((I)=>{if(I===null)return g;return I.concat(g.filter((S)=>!I.includes(S)))})},[d]),v=A.useRef(null),b=Mn((g)=>{if(m&&!a)return yH;if(!g||g===yH||f.current!==e||s!=null){let I=new Map;for(let S of e){if(!S)continue;if(s&&s.length>0&&!s.includes(S.id)&&S.rect.current){I.set(S.id,S.rect.current);continue}let y=S.node.current,w=y?new Oi(c(y),y):null;if(S.rect.current=w,w)I.set(S.id,w)}return I}return g},[e,s,a,m,c]);return A.useEffect(()=>{f.current=e},[e]),A.useEffect(()=>{if(m)return;p()},[a,m]),A.useEffect(()=>{if(s&&s.length>0)i(null)},[JSON.stringify(s)]),A.useEffect(()=>{if(m||typeof l!=="number"||v.current!==null)return;v.current=setTimeout(()=>{p(),v.current=null},l)},[l,m,p,...o]),{droppableRects:b,measureDroppableContainers:p,measuringScheduled:s!=null};function C(){switch(u){case Pr.Always:return!1;case Pr.BeforeDragging:return a;default:return!a}}}function Pu(e,t){return Mn((a)=>{if(!e)return null;if(a)return a;return typeof t==="function"?t(e):e},[t,e])}function C9(e,t){return Pu(e,t)}function w9(e){let{callback:t,disabled:a}=e,o=zr(t),n=A.useMemo(()=>{if(a||typeof window>"u"||typeof window.MutationObserver>"u")return;let{MutationObserver:s}=window;return new s(o)},[o,a]);return A.useEffect(()=>()=>n==null?void 0:n.disconnect(),[n]),n}function ki(e){let{callback:t,disabled:a}=e,o=zr(t),n=A.useMemo(()=>{if(a||typeof window>"u"||typeof window.ResizeObserver>"u")return;let{ResizeObserver:s}=window;return new s(o)},[a]);return A.useEffect(()=>()=>n==null?void 0:n.disconnect(),[n]),n}function A9(e){return new Oi(_o(e),e)}function bH(e,t,a){if(t===void 0)t=A9;let[o,n]=A.useState(null);function s(){n((c)=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c!=null?c:a)!=null?u:null}let f=t(e);if(JSON.stringify(c)===JSON.stringify(f))return c;return f})}let i=w9({callback(c){if(!e)return;for(let u of c){let{type:f,target:m}=u;if(f==="childList"&&m instanceof HTMLElement&&m.contains(e)){s();break}}}}),l=ki({callback:s});return Tt(()=>{if(s(),e)l==null||l.observe(e),i==null||i.observe(document.body,{childList:!0,subtree:!0});else l==null||l.disconnect(),i==null||i.disconnect()},[e]),o}function T9(e){let t=Pu(e);return NH(e,t)}var CH=[];function x9(e){let t=A.useRef(e),a=Mn((o)=>{if(!e)return CH;if(o&&o!==CH&&e&&t.current&&e.parentNode===t.current.parentNode)return o;return Gr(e)},[e]);return A.useEffect(()=>{t.current=e},[e]),a}function M9(e){let[t,a]=A.useState(null),o=A.useRef(e),n=A.useCallback((s)=>{let i=Ru(s.target);if(!i)return;a((l)=>{if(!l)return null;return l.set(i,Hu(i)),new Map(l)})},[]);return A.useEffect(()=>{let s=o.current;if(e!==s){i(s);let l=e.map((c)=>{let u=Ru(c);if(u)return u.addEventListener("scroll",n,{passive:!0}),[u,Hu(u)];return null}).filter((c)=>c!=null);a(l.length?new Map(l):null),o.current=e}return()=>{i(e),i(s)};function i(l){l.forEach((c)=>{let u=Ru(c);u==null||u.removeEventListener("scroll",n)})}},[n,e]),A.useMemo(()=>{if(e.length)return t?Array.from(t.values()).reduce((s,i)=>ko(s,i),Wt):_H(e);return Wt},[e,t])}function wH(e,t){if(t===void 0)t=[];let a=A.useRef(null);return A.useEffect(()=>{a.current=null},t),A.useEffect(()=>{let o=e!==Wt;if(o&&!a.current)a.current=e;if(!o&&a.current)a.current=null},[e]),a.current?zo(e,a.current):Wt}function D9(e){A.useEffect(()=>{if(!kr)return;let t=e.map((a)=>{let{sensor:o}=a;return o.setup==null?void 0:o.setup()});return()=>{for(let a of t)a==null||a()}},e.map((t)=>{let{sensor:a}=t;return a}))}function E9(e,t){return A.useMemo(()=>e.reduce((a,o)=>{let{eventName:n,handler:s}=o;return a[n]=(i)=>{s(i,t)},a},{}),[e,t])}function ZH(e){return A.useMemo(()=>e?a9(e):null,[e])}var AH=[];function L9(e,t){if(t===void 0)t=_o;let[a]=e,o=ZH(a?lt(a):null),[n,s]=A.useState(AH);function i(){s(()=>{if(!e.length)return AH;return e.map((c)=>UH(c)?o:new Oi(t(c),c))})}let l=ki({callback:i});return Tt(()=>{l==null||l.disconnect(),i(),e.forEach((c)=>l==null?void 0:l.observe(c))},[e]),n}function XH(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Tn(t)?t:e}function R9(e){let{measure:t}=e,[a,o]=A.useState(null),n=A.useCallback((u)=>{for(let{target:f}of u)if(Tn(f)){o((m)=>{let d=t(f);return m?{...m,width:d.width,height:d.height}:d});break}},[t]),s=ki({callback:n}),i=A.useCallback((u)=>{let f=XH(u);if(s==null||s.disconnect(),f)s==null||s.observe(f);o(f?t(f):null)},[t,s]),[l,c]=Ur(i);return A.useMemo(()=>({nodeRef:l,rect:a,setRef:c}),[a,l,c])}var B9=[{sensor:qr,options:{}},{sensor:Vr,options:{}}],N9={current:{}},Ri={draggable:{measure:gH},droppable:{measure:gH,strategy:Pr.WhileDragging,frequency:zu.Optimized},dragOverlay:{measure:_o}};class Rn extends Map{get(e){var t;return e!=null?(t=super.get(e))!=null?t:void 0:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e)=>{let{disabled:t}=e;return!t})}getNodeFor(e){var t,a;return(t=(a=this.get(e))==null?void 0:a.node.current)!=null?t:void 0}}var O9={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Rn,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Bi},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ri,measureDroppableContainers:Bi,windowRect:null,measuringScheduled:!1},jH={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Bi,draggableNodes:new Map,over:null,measureDroppableContainers:Bi},Zr=A.createContext(jH),YH=A.createContext(O9);function H9(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Rn}}}function k9(e,t){switch(t.type){case Ge.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Ge.DragMove:if(e.draggable.active==null)return e;return{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Ge.DragEnd:case Ge.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Ge.RegisterDroppable:{let{element:a}=t,{id:o}=a,n=new Rn(e.droppable.containers);return n.set(o,a),{...e,droppable:{...e.droppable,containers:n}}}case Ge.SetDroppableDisabled:{let{id:a,key:o,disabled:n}=t,s=e.droppable.containers.get(a);if(!s||o!==s.key)return e;let i=new Rn(e.droppable.containers);return i.set(a,{...s,disabled:n}),{...e,droppable:{...e.droppable,containers:i}}}case Ge.UnregisterDroppable:{let{id:a,key:o}=t,n=e.droppable.containers.get(a);if(!n||o!==n.key)return e;let s=new Rn(e.droppable.containers);return s.delete(a),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function z9(e){let{disabled:t}=e,{active:a,activatorEvent:o,draggableNodes:n}=A.useContext(Zr),s=Fr(o),i=Fr(a==null?void 0:a.id);return A.useEffect(()=>{if(t)return;if(!o&&s&&i!=null){if(!Dn(s))return;if(document.activeElement===s.target)return;let l=n.get(i);if(!l)return;let{activatorNode:c,node:u}=l;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(let f of[c.current,u.current]){if(!f)continue;let m=mH(f);if(m){m.focus();break}}})}},[o,t,n,i,s]),null}function QH(e,t){let{transform:a,...o}=t;return e!=null&&e.length?e.reduce((n,s)=>s({transform:n,...o}),a):a}function U9(e){return A.useMemo(()=>({draggable:{...Ri.draggable,...e==null?void 0:e.draggable},droppable:{...Ri.droppable,...e==null?void 0:e.droppable},dragOverlay:{...Ri.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function F9(e){let{activeNode:t,measure:a,initialRect:o,config:n=!0}=e,s=A.useRef(!1),{x:i,y:l}=typeof n==="boolean"?{x:n,y:n}:n;Tt(()=>{if(!i&&!l||!t){s.current=!1;return}if(s.current||!o)return;let u=t==null?void 0:t.node.current;if(!u||u.isConnected===!1)return;let f=a(u),m=NH(f,o);if(!i)m.x=0;if(!l)m.y=0;if(s.current=!0,Math.abs(m.x)>0||Math.abs(m.y)>0){let d=HH(u);if(d)d.scrollBy({top:m.y,left:m.x})}},[t,i,l,o,a])}var zi=A.createContext({...Wt,scaleX:1,scaleY:1}),Ka;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ka||(Ka={}));var WH=A.memo(function(t){var a,o,n,s;let{id:i,accessibility:l,autoScroll:c=!0,children:u,sensors:f=B9,collisionDetection:m=_u,measuring:d,modifiers:p,...v}=t,b=A.useReducer(k9,void 0,H9),[C,g]=b,[I,S]=V_(),[y,w]=A.useState(Ka.Uninitialized),T=y===Ka.Initialized,{draggable:{active:x,nodes:E,translate:L},droppable:{containers:D}}=C,N=x!=null?E.get(x):null,oe=A.useRef({initial:null,translated:null}),ne=A.useMemo(()=>{var it;return x!=null?{id:x,data:(it=N==null?void 0:N.data)!=null?it:N9,rect:oe}:null},[x,N]),ie=A.useRef(null),[de,Xe]=A.useState(null),[pe,je]=A.useState(null),B=xn(v,Object.values(v)),k=Ho("DndDescribedBy",i),G=A.useMemo(()=>D.getEnabled(),[D]),Q=U9(d),{droppableRects:$e,measureDroppableContainers:ut,measuringScheduled:Sa}=b9(G,{dragging:T,dependencies:[L.x,L.y],config:Q.droppable}),et=v9(E,x),pn=A.useMemo(()=>pe?En(pe):null,[pe]),qa=$7(),va=C9(et,Q.draggable.measure);F9({activeNode:x!=null?E.get(x):null,config:qa.layoutShiftCompensation,initialRect:va,measure:Q.draggable.measure});let ee=bH(et,Q.draggable.measure,va),Tr=bH(et?et.parentElement:null),na=A.useRef({activatorEvent:null,active:null,activeNode:et,collisionRect:null,collisions:null,droppableRects:$e,draggableNodes:E,draggingNode:null,draggingNodeRect:null,droppableContainers:D,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),hn=D.getNodeFor((a=na.current.over)==null?void 0:a.id),ya=R9({measure:Q.dragOverlay.measure}),gn=(o=ya.nodeRef.current)!=null?o:et,In=T?(n=ya.rect)!=null?n:ee:null,zd=Boolean(ya.nodeRef.current&&ya.rect),Ud=T9(zd?null:ee),xc=ZH(gn?lt(gn):null),Za=x9(T?hn!=null?hn:et:null),oi=L9(Za),ni=QH(p,{transform:{x:L.x-Ud.x,y:L.y-Ud.y,scaleX:1,scaleY:1},activatorEvent:pe,active:ne,activeNodeRect:ee,containerNodeRect:Tr,draggingNodeRect:In,over:na.current.over,overlayNodeRect:ya.rect,scrollableAncestors:Za,scrollableAncestorRects:oi,windowRect:xc}),Fd=pn?ko(pn,L):null,_d=M9(Za),X7=wH(_d),j7=wH(_d,[ee]),Sn=ko(ni,X7),vn=In?$_(In,ni):null,xr=ne&&vn?m({active:ne,collisionRect:vn,droppableRects:$e,droppableContainers:G,pointerCoordinates:Fd}):null,Pd=Fu(xr,"id"),[Xa,Gd]=A.useState(null),Y7=zd?ni:ko(ni,j7),Q7=K_(Y7,(s=Xa==null?void 0:Xa.rect)!=null?s:null,ee),Mc=A.useRef(null),Vd=A.useCallback((it,Ct)=>{let{sensor:wt,options:ja}=Ct;if(ie.current==null)return;let kt=E.get(ie.current);if(!kt)return;let At=it.nativeEvent,ra=new wt({active:ie.current,activeNode:kt,event:At,options:ja,context:na,onAbort(tt){if(!E.get(tt))return;let{onDragAbort:sa}=B.current,ba={id:tt};sa==null||sa(ba),I({type:"onDragAbort",event:ba})},onPending(tt,Ya,sa,ba){if(!E.get(tt))return;let{onDragPending:Dr}=B.current,Qa={id:tt,constraint:Ya,initialCoordinates:sa,offset:ba};Dr==null||Dr(Qa),I({type:"onDragPending",event:Qa})},onStart(tt){let Ya=ie.current;if(Ya==null)return;let sa=E.get(Ya);if(!sa)return;let{onDragStart:ba}=B.current,Mr={activatorEvent:At,active:{id:Ya,data:sa.data,rect:oe}};Fo.unstable_batchedUpdates(()=>{ba==null||ba(Mr),w(Ka.Initializing),g({type:Ge.DragStart,initialCoordinates:tt,active:Ya}),I({type:"onDragStart",event:Mr}),Xe(Mc.current),je(At)})},onMove(tt){g({type:Ge.DragMove,coordinates:tt})},onEnd:yn(Ge.DragEnd),onCancel:yn(Ge.DragCancel)});Mc.current=ra;function yn(tt){return async function(){let{active:sa,collisions:ba,over:Mr,scrollAdjustedTranslate:Dr}=na.current,Qa=null;if(sa&&Dr){let{cancelDrop:Er}=B.current;if(Qa={activatorEvent:At,active:sa,collisions:ba,delta:Dr,over:Mr},tt===Ge.DragEnd&&typeof Er==="function"){if(await Promise.resolve(Er(Qa)))tt=Ge.DragCancel}}ie.current=null,Fo.unstable_batchedUpdates(()=>{g({type:tt}),w(Ka.Uninitialized),Gd(null),Xe(null),je(null),Mc.current=null;let Er=tt===Ge.DragEnd?"onDragEnd":"onDragCancel";if(Qa){let Dc=B.current[Er];Dc==null||Dc(Qa),I({type:Er,event:Qa})}})}}},[E]),W7=A.useCallback((it,Ct)=>(wt,ja)=>{let kt=wt.nativeEvent,At=E.get(ja);if(ie.current!==null||!At||kt.dndKit||kt.defaultPrevented)return;let ra={active:At};if(it(wt,Ct.options,ra)===!0)kt.dndKit={capturedBy:Ct.sensor},ie.current=ja,Vd(wt,Ct)},[E,Vd]),qd=y9(f,W7);D9(f),Tt(()=>{if(ee&&y===Ka.Initializing)w(Ka.Initialized)},[ee,y]),A.useEffect(()=>{let{onDragMove:it}=B.current,{active:Ct,activatorEvent:wt,collisions:ja,over:kt}=na.current;if(!Ct||!wt)return;let At={active:Ct,activatorEvent:wt,collisions:ja,delta:{x:Sn.x,y:Sn.y},over:kt};Fo.unstable_batchedUpdates(()=>{it==null||it(At),I({type:"onDragMove",event:At})})},[Sn.x,Sn.y]),A.useEffect(()=>{let{active:it,activatorEvent:Ct,collisions:wt,droppableContainers:ja,scrollAdjustedTranslate:kt}=na.current;if(!it||ie.current==null||!Ct||!kt)return;let{onDragOver:At}=B.current,ra=ja.get(Pd),yn=ra&&ra.rect.current?{id:ra.id,rect:ra.rect.current,data:ra.data,disabled:ra.disabled}:null,tt={active:it,activatorEvent:Ct,collisions:wt,delta:{x:kt.x,y:kt.y},over:yn};Fo.unstable_batchedUpdates(()=>{Gd(yn),At==null||At(tt),I({type:"onDragOver",event:tt})})},[Pd]),Tt(()=>{na.current={activatorEvent:pe,active:ne,activeNode:et,collisionRect:vn,collisions:xr,droppableRects:$e,draggableNodes:E,draggingNode:gn,draggingNodeRect:In,droppableContainers:D,over:Xa,scrollableAncestors:Za,scrollAdjustedTranslate:Sn},oe.current={initial:In,translated:vn}},[ne,et,xr,vn,E,gn,In,$e,D,Xa,Za,Sn]),g9({...qa,delta:L,draggingRect:vn,pointerCoordinates:Fd,scrollableAncestors:Za,scrollableAncestorRects:oi});let K7=A.useMemo(()=>({active:ne,activeNode:et,activeNodeRect:ee,activatorEvent:pe,collisions:xr,containerNodeRect:Tr,dragOverlay:ya,draggableNodes:E,droppableContainers:D,droppableRects:$e,over:Xa,measureDroppableContainers:ut,scrollableAncestors:Za,scrollableAncestorRects:oi,measuringConfiguration:Q,measuringScheduled:Sa,windowRect:xc}),[ne,et,ee,pe,xr,Tr,ya,E,D,$e,Xa,ut,Za,oi,Q,Sa,xc]),J7=A.useMemo(()=>({activatorEvent:pe,activators:qd,active:ne,activeNodeRect:ee,ariaDescribedById:{draggable:k},dispatch:g,draggableNodes:E,over:Xa,measureDroppableContainers:ut}),[pe,qd,ne,ee,g,k,E,Xa,ut]);return A.default.createElement(MH.Provider,{value:S},A.default.createElement(Zr.Provider,{value:J7},A.default.createElement(YH.Provider,{value:K7},A.default.createElement(zi.Provider,{value:Q7},u)),A.default.createElement(z9,{disabled:(l==null?void 0:l.restoreFocus)===!1})),A.default.createElement(X_,{...l,hiddenTextDescribedById:k}));function $7(){let it=(de==null?void 0:de.autoScrollEnabled)===!1,Ct=typeof c==="object"?c.enabled===!1:c===!1,wt=T&&!it&&!Ct;if(typeof c==="object")return{...c,enabled:wt};return{enabled:wt}}}),_9=A.createContext(null),TH="button",P9="Draggable";function KH(e){let{id:t,data:a,disabled:o=!1,attributes:n}=e,s=Ho(P9),{activators:i,activatorEvent:l,active:c,activeNodeRect:u,ariaDescribedById:f,draggableNodes:m,over:d}=A.useContext(Zr),{role:p=TH,roleDescription:v="draggable",tabIndex:b=0}=n!=null?n:{},C=(c==null?void 0:c.id)===t,g=A.useContext(C?zi:_9),[I,S]=Ur(),[y,w]=Ur(),T=E9(i,t),x=xn(a);Tt(()=>(m.set(t,{id:t,key:s,node:I,activatorNode:y,data:x}),()=>{let L=m.get(t);if(L&&L.key===s)m.delete(t)}),[m,t]);let E=A.useMemo(()=>({role:p,tabIndex:b,"aria-disabled":o,"aria-pressed":C&&p===TH?!0:void 0,"aria-roledescription":v,"aria-describedby":f.draggable}),[o,p,b,C,v,f.draggable]);return{active:c,activatorEvent:l,activeNodeRect:u,attributes:E,isDragging:C,listeners:o?void 0:T,node:I,over:d,setNodeRef:S,setActivatorNodeRef:w,transform:g}}function Gu(){return A.useContext(YH)}var G9="Droppable",V9={timeout:25};function JH(e){let{data:t,disabled:a=!1,id:o,resizeObserverConfig:n}=e,s=Ho(G9),{active:i,dispatch:l,over:c,measureDroppableContainers:u}=A.useContext(Zr),f=A.useRef({disabled:a}),m=A.useRef(!1),d=A.useRef(null),p=A.useRef(null),{disabled:v,updateMeasurementsFor:b,timeout:C}={...V9,...n},g=xn(b!=null?b:o),I=A.useCallback(()=>{if(!m.current){m.current=!0;return}if(p.current!=null)clearTimeout(p.current);p.current=setTimeout(()=>{u(Array.isArray(g.current)?g.current:[g.current]),p.current=null},C)},[C]),S=ki({callback:I,disabled:v||!i}),y=A.useCallback((E,L)=>{if(!S)return;if(L)S.unobserve(L),m.current=!1;if(E)S.observe(E)},[S]),[w,T]=Ur(y),x=xn(t);return A.useEffect(()=>{if(!S||!w.current)return;S.disconnect(),m.current=!1,S.observe(w.current)},[w,S]),A.useEffect(()=>(l({type:Ge.RegisterDroppable,element:{id:o,key:s,disabled:a,node:w,rect:d,data:x}}),()=>l({type:Ge.UnregisterDroppable,key:s,id:o})),[o]),A.useEffect(()=>{if(a!==f.current.disabled)l({type:Ge.SetDroppableDisabled,id:o,key:s,disabled:a}),f.current.disabled=a},[o,s,a,l]),{active:i,rect:d,isOver:(c==null?void 0:c.id)===o,node:w,over:c,setNodeRef:T}}function q9(e){let{animation:t,children:a}=e,[o,n]=A.useState(null),[s,i]=A.useState(null),l=Fr(a);if(!a&&!o&&l)n(l);return Tt(()=>{if(!s)return;let c=o==null?void 0:o.key,u=o==null?void 0:o.props.id;if(c==null||u==null){n(null);return}Promise.resolve(t(u,s)).then(()=>{n(null)})},[t,o,s]),A.default.createElement(A.default.Fragment,null,a,o?A.cloneElement(o,{ref:i}):null)}var Z9={x:0,y:0,scaleX:1,scaleY:1};function X9(e){let{children:t}=e;return A.default.createElement(Zr.Provider,{value:jH},A.default.createElement(zi.Provider,{value:Z9},t))}var j9={position:"fixed",touchAction:"none"},Y9=(e)=>Dn(e)?"transform 250ms ease":void 0,Q9=A.forwardRef((e,t)=>{let{as:a,activatorEvent:o,adjustScale:n,children:s,className:i,rect:l,style:c,transform:u,transition:f=Y9}=e;if(!l)return null;let m=n?u:{...u,scaleX:1,scaleY:1},d={...j9,width:l.width,height:l.height,top:l.top,left:l.left,transform:Qt.Transform.toString(m),transformOrigin:n&&o?j_(o,l):void 0,transition:typeof f==="function"?f(o):f,...c};return A.default.createElement(a,{className:i,style:d,ref:t},s)}),W9=(e)=>(t)=>{let{active:a,dragOverlay:o}=t,n={},{styles:s,className:i}=e;if(s!=null&&s.active)for(let[l,c]of Object.entries(s.active)){if(c===void 0)continue;n[l]=a.node.style.getPropertyValue(l),a.node.style.setProperty(l,c)}if(s!=null&&s.dragOverlay)for(let[l,c]of Object.entries(s.dragOverlay)){if(c===void 0)continue;o.node.style.setProperty(l,c)}if(i!=null&&i.active)a.node.classList.add(i.active);if(i!=null&&i.dragOverlay)o.node.classList.add(i.dragOverlay);return function(){for(let[c,u]of Object.entries(n))a.node.style.setProperty(c,u);if(i!=null&&i.active)a.node.classList.remove(i.active)}},K9=(e)=>{let{transform:{initial:t,final:a}}=e;return[{transform:Qt.Transform.toString(t)},{transform:Qt.Transform.toString(a)}]},J9={duration:250,easing:"ease",keyframes:K9,sideEffects:W9({styles:{active:{opacity:"0"}}})};function $9(e){let{config:t,draggableNodes:a,droppableContainers:o,measuringConfiguration:n}=e;return zr((s,i)=>{if(t===null)return;let l=a.get(s);if(!l)return;let c=l.node.current;if(!c)return;let u=XH(i);if(!u)return;let{transform:f}=lt(i).getComputedStyle(i),m=OH(f);if(!m)return;let d=typeof t==="function"?t:eP(t);return PH(c,n.draggable.measure),d({active:{id:s,data:l.data,node:c,rect:n.draggable.measure(c)},draggableNodes:a,dragOverlay:{node:i,rect:n.dragOverlay.measure(u)},droppableContainers:o,measuringConfiguration:n,transform:m})})}function eP(e){let{duration:t,easing:a,sideEffects:o,keyframes:n}={...J9,...e};return(s)=>{let{active:i,dragOverlay:l,transform:c,...u}=s;if(!t)return;let f={x:l.rect.left-i.rect.left,y:l.rect.top-i.rect.top},m={scaleX:c.scaleX!==1?i.rect.width*c.scaleX/l.rect.width:1,scaleY:c.scaleY!==1?i.rect.height*c.scaleY/l.rect.height:1},d={x:c.x-f.x,y:c.y-f.y,...m},p=n({...u,active:i,dragOverlay:l,transform:{initial:c,final:d}}),[v]=p,b=p[p.length-1];if(JSON.stringify(v)===JSON.stringify(b))return;let C=o==null?void 0:o({active:i,dragOverlay:l,...u}),g=l.node.animate(p,{duration:t,easing:a,fill:"forwards"});return new Promise((I)=>{g.onfinish=()=>{C==null||C(),I()}})}}var xH=0;function tP(e){return A.useMemo(()=>{if(e==null)return;return xH++,xH},[e])}var $H=A.default.memo((e)=>{let{adjustScale:t=!1,children:a,dropAnimation:o,style:n,transition:s,modifiers:i,wrapperElement:l="div",className:c,zIndex:u=999}=e,{activatorEvent:f,active:m,activeNodeRect:d,containerNodeRect:p,draggableNodes:v,droppableContainers:b,dragOverlay:C,over:g,measuringConfiguration:I,scrollableAncestors:S,scrollableAncestorRects:y,windowRect:w}=Gu(),T=A.useContext(zi),x=tP(m==null?void 0:m.id),E=QH(i,{activatorEvent:f,active:m,activeNodeRect:d,containerNodeRect:p,draggingNodeRect:C.rect,over:g,overlayNodeRect:C.rect,scrollableAncestors:S,scrollableAncestorRects:y,transform:T,windowRect:w}),L=Pu(d),D=$9({config:o,draggableNodes:v,droppableContainers:b,measuringConfiguration:I}),N=L?C.setRef:void 0;return A.default.createElement(X9,null,A.default.createElement(q9,{animation:D},m&&x?A.default.createElement(Q9,{key:x,id:m.id,ref:N,as:l,activatorEvent:f,adjustScale:t,className:c,transition:s,rect:L,style:{zIndex:u,...n},transform:E},a):null))});function aP(e,t,a){let o={...e};if(t.top+e.y<=a.top)o.y=a.top-t.top;else if(t.bottom+e.y>=a.top+a.height)o.y=a.top+a.height-t.bottom;if(t.left+e.x<=a.left)o.x=a.left-t.left;else if(t.right+e.x>=a.left+a.width)o.x=a.left+a.width-t.right;return o}var ek=(e)=>{let{containerNodeRect:t,draggingNodeRect:a,transform:o}=e;if(!a||!t)return o;return aP(o,a,t)};var tk=(e)=>{let{transform:t}=e;return{...t,x:0}};var Oe=O(U(),1);function ak(e,t,a){let o=e.slice();return o.splice(a<0?o.length+a:a,0,o.splice(t,1)[0]),o}function oP(e,t){return e.reduce((a,o,n)=>{let s=t.get(o);if(s)a[n]=s;return a},Array(e.length))}function Ui(e){return e!==null&&e>=0}function nP(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(e[a]!==t[a])return!1;return!0}function rP(e){if(typeof e==="boolean")return{draggable:e,droppable:e};return e}var ok=(e)=>{let{rects:t,activeIndex:a,overIndex:o,index:n}=e,s=ak(t,o,a),i=t[n],l=s[n];if(!l||!i)return null;return{x:l.left-i.left,y:l.top-i.top,scaleX:l.width/i.width,scaleY:l.height/i.height}};var Fi={scaleX:1,scaleY:1},nk=(e)=>{var t;let{activeIndex:a,activeNodeRect:o,index:n,rects:s,overIndex:i}=e,l=(t=s[a])!=null?t:o;if(!l)return null;if(n===a){let u=s[i];if(!u)return null;return{x:0,y:a<i?u.top+u.height-(l.top+l.height):u.top-l.top,...Fi}}let c=sP(s,n,a);if(n>a&&n<=i)return{x:0,y:-l.height-c,...Fi};if(n<a&&n>=i)return{x:0,y:l.height+c,...Fi};return{x:0,y:0,...Fi}};function sP(e,t,a){let o=e[t],n=e[t-1],s=e[t+1];if(!o)return 0;if(a<t)return n?o.top-(n.top+n.height):s?s.top-(o.top+o.height):0;return s?s.top-(o.top+o.height):n?o.top-(n.top+n.height):0}var rk="Sortable",sk=Oe.default.createContext({activeIndex:-1,containerId:rk,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ok,disabled:{draggable:!1,droppable:!1}});function ik(e){let{children:t,id:a,items:o,strategy:n=ok,disabled:s=!1}=e,{active:i,dragOverlay:l,droppableRects:c,over:u,measureDroppableContainers:f}=Gu(),m=Ho(rk,a),d=Boolean(l.rect!==null),p=Oe.useMemo(()=>o.map((T)=>typeof T==="object"&&("id"in T)?T.id:T),[o]),v=i!=null,b=i?p.indexOf(i.id):-1,C=u?p.indexOf(u.id):-1,g=Oe.useRef(p),I=!nP(p,g.current),S=C!==-1&&b===-1||I,y=rP(s);Tt(()=>{if(I&&v)f(p)},[I,p,v,f]),Oe.useEffect(()=>{g.current=p},[p]);let w=Oe.useMemo(()=>({activeIndex:b,containerId:m,disabled:y,disableTransforms:S,items:p,overIndex:C,useDragOverlay:d,sortedRects:oP(p,c),strategy:n}),[b,m,y.draggable,y.droppable,S,p,C,c,d,n]);return Oe.default.createElement(sk.Provider,{value:w},t)}var iP=(e)=>{let{id:t,items:a,activeIndex:o,overIndex:n}=e;return ak(a,o,n).indexOf(t)},lP=(e)=>{let{containerId:t,isSorting:a,wasDragging:o,index:n,items:s,newIndex:i,previousItems:l,previousContainerId:c,transition:u}=e;if(!u||!o)return!1;if(l!==s&&n===i)return!1;if(a)return!0;return i!==n&&t===c},cP={duration:200,easing:"ease"},lk="transform",uP=Qt.Transition.toString({property:lk,duration:0,easing:"linear"}),fP={roleDescription:"sortable"};function mP(e){let{disabled:t,index:a,node:o,rect:n}=e,[s,i]=Oe.useState(null),l=Oe.useRef(a);return Tt(()=>{if(!t&&a!==l.current&&o.current){let c=n.current;if(c){let u=_o(o.current,{ignoreTransform:!0}),f={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};if(f.x||f.y)i(f)}}if(a!==l.current)l.current=a},[t,a,o,n]),Oe.useEffect(()=>{if(s)i(null)},[s]),s}function ck(e){let{animateLayoutChanges:t=lP,attributes:a,disabled:o,data:n,getNewIndex:s=iP,id:i,strategy:l,resizeObserverConfig:c,transition:u=cP}=e,{items:f,containerId:m,activeIndex:d,disabled:p,disableTransforms:v,sortedRects:b,overIndex:C,useDragOverlay:g,strategy:I}=Oe.useContext(sk),S=dP(o,p),y=f.indexOf(i),w=Oe.useMemo(()=>({sortable:{containerId:m,index:y,items:f},...n}),[m,n,y,f]),T=Oe.useMemo(()=>f.slice(f.indexOf(i)),[f,i]),{rect:x,node:E,isOver:L,setNodeRef:D}=JH({id:i,data:w,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...c}}),{active:N,activatorEvent:oe,activeNodeRect:ne,attributes:ie,setNodeRef:de,listeners:Xe,isDragging:pe,over:je,setActivatorNodeRef:B,transform:k}=KH({id:i,data:w,attributes:{...fP,...a},disabled:S.draggable}),G=cH(D,de),Q=Boolean(N),$e=Q&&!v&&Ui(d)&&Ui(C),ut=!g&&pe,Sa=ut&&$e?k:null,et=l!=null?l:I,pn=$e?Sa!=null?Sa:et({rects:b,activeNodeRect:ne,activeIndex:d,overIndex:C,index:y}):null,qa=Ui(d)&&Ui(C)?s({id:i,items:f,activeIndex:d,overIndex:C}):y,va=N==null?void 0:N.id,ee=Oe.useRef({activeId:va,items:f,newIndex:qa,containerId:m}),Tr=f!==ee.current.items,na=t({active:N,containerId:m,isDragging:pe,isSorting:Q,id:i,index:y,items:f,newIndex:ee.current.newIndex,previousItems:ee.current.items,previousContainerId:ee.current.containerId,transition:u,wasDragging:ee.current.activeId!=null}),hn=mP({disabled:!na,index:y,node:E,rect:x});return Oe.useEffect(()=>{if(Q&&ee.current.newIndex!==qa)ee.current.newIndex=qa;if(m!==ee.current.containerId)ee.current.containerId=m;if(f!==ee.current.items)ee.current.items=f},[Q,qa,m,f]),Oe.useEffect(()=>{if(va===ee.current.activeId)return;if(va!=null&&ee.current.activeId==null){ee.current.activeId=va;return}let gn=setTimeout(()=>{ee.current.activeId=va},50);return()=>clearTimeout(gn)},[va]),{active:N,activeIndex:d,attributes:ie,data:w,rect:x,index:y,newIndex:qa,items:f,isOver:L,isSorting:Q,isDragging:pe,listeners:Xe,node:E,overIndex:C,over:je,setNodeRef:G,setActivatorNodeRef:B,setDroppableNodeRef:D,setDraggableNodeRef:de,transform:hn!=null?hn:pn,transition:ya()};function ya(){if(hn||Tr&&ee.current.newIndex===y)return uP;if(ut&&!Dn(oe)||!u)return;if(Q||na)return Qt.Transition.toString({...u,property:lk});return}}function dP(e,t){var a,o;if(typeof e==="boolean")return{draggable:e,droppable:!1};return{draggable:(a=e==null?void 0:e.draggable)!=null?a:t.draggable,droppable:(o=e==null?void 0:e.droppable)!=null?o:t.droppable}}function _i(e){if(!e)return!1;let t=e.data.current;if(t&&"sortable"in t&&typeof t.sortable==="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)return!0;return!1}var pP=[V.Down,V.Right,V.Up,V.Left],uk=(e,t)=>{let{context:{active:a,collisionRect:o,droppableRects:n,droppableContainers:s,over:i,scrollableAncestors:l}}=t;if(pP.includes(e.code)){if(e.preventDefault(),!a||!o)return;let c=[];s.getEnabled().forEach((m)=>{if(!m||m!=null&&m.disabled)return;let d=n.get(m.id);if(!d)return;switch(e.code){case V.Down:if(o.top<d.top)c.push(m);break;case V.Up:if(o.top>d.top)c.push(m);break;case V.Left:if(o.left>d.left)c.push(m);break;case V.Right:if(o.left<d.left)c.push(m);break}});let u=RH({active:a,collisionRect:o,droppableRects:n,droppableContainers:c,pointerCoordinates:null}),f=Fu(u,"id");if(f===(i==null?void 0:i.id)&&u.length>1)f=u[1].id;if(f!=null){let m=s.get(a.id),d=s.get(f),p=d?n.get(d.id):null,v=d==null?void 0:d.node.current;if(v&&p&&m&&d){let C=Gr(v).some((T,x)=>l[x]!==T),g=fk(m,d),I=hP(m,d),S=C||!g?{x:0,y:0}:{x:I?o.width-p.width:0,y:I?o.height-p.height:0},y={x:p.left,y:p.top};return S.x&&S.y?y:zo(y,S)}}}return};function fk(e,t){if(!_i(e)||!_i(t))return!1;return e.data.current.sortable.containerId===t.data.current.sortable.containerId}function hP(e,t){if(!_i(e)||!_i(t))return!1;if(!fk(e,t))return!1;return e.data.current.sortable.index<t.data.current.sortable.index}var{min:Ja,max:Kt,round:jr,floor:Yr}=Math,ca=(e)=>({x:e,y:e}),gP={left:"right",right:"left",bottom:"top",top:"bottom"};function pk(e,t,a){return Kt(e,Ja(t,a))}function $a(e,t){return typeof e==="function"?e(t):e}function Ca(e){return e.split("-")[0]}function Bn(e){return e.split("-")[1]}function Gi(e){return e==="x"?"y":"x"}function Vu(e){return e==="y"?"height":"width"}function Jt(e){let t=e[0];return t==="t"||t==="b"?"y":"x"}function qu(e){return Gi(Jt(e))}function hk(e,t,a){if(a===void 0)a=!1;let o=Bn(e),n=qu(e),s=Vu(n),i=n==="x"?o===(a?"end":"start")?"right":"left":o==="start"?"bottom":"top";if(t.reference[s]>t.floating[s])i=Xr(i);return[i,Xr(i)]}function gk(e){let t=Xr(e);return[Pi(e),t,Pi(t)]}function Pi(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}var mk=["left","right"],dk=["right","left"],IP=["top","bottom"],SP=["bottom","top"];function vP(e,t,a){switch(e){case"top":case"bottom":if(a)return t?dk:mk;return t?mk:dk;case"left":case"right":return t?IP:SP;default:return[]}}function Ik(e,t,a,o){let n=Bn(e),s=vP(Ca(e),a==="start",o);if(n){if(s=s.map((i)=>i+"-"+n),t)s=s.concat(s.map(Pi))}return s}function Xr(e){let t=Ca(e);return gP[t]+e.slice(t.length)}function yP(e){var t,a,o,n;return{top:(t=e.top)!=null?t:0,right:(a=e.right)!=null?a:0,bottom:(o=e.bottom)!=null?o:0,left:(n=e.left)!=null?n:0}}function Sk(e){return typeof e!=="number"?yP(e):{top:e,right:e,bottom:e,left:e}}function Po(e){let{x:t,y:a,width:o,height:n}=e;return{width:o,height:n,top:a,left:t,right:t+o,bottom:a+n,x:t,y:a}}function vk(e,t,a){let{reference:o,floating:n}=e,s=Jt(t),i=qu(t),l=Vu(i),c=Ca(t),u=s==="y",f=o.x+o.width/2-n.width/2,m=o.y+o.height/2-n.height/2,d=o[l]/2-n[l]/2,p;switch(c){case"top":p={x:f,y:o.y-n.height};break;case"bottom":p={x:f,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:m};break;case"left":p={x:o.x-n.width,y:m};break;default:p={x:o.x,y:o.y}}let v=Bn(t);if(v)p[i]+=d*(v==="end"?1:-1)*(a&&u?-1:1);return p}async function yk(e,t){var a;if(t===void 0)t={};let{x:o,y:n,platform:s,rects:i,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:m="floating",altBoundary:d=!1,padding:p=0}=$a(t,e),v=Sk(p),C=l[d?m==="floating"?"reference":"floating":m],g=Po(await s.getClippingRect({element:((a=await(s.isElement==null?void 0:s.isElement(C)))!=null?a:!0)?C:C.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:u,rootBoundary:f,strategy:c})),I=m==="floating"?{x:o,y:n,width:i.floating.width,height:i.floating.height}:i.reference,S=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),y=await(s.isElement==null?void 0:s.isElement(S))&&await(s.getScale==null?void 0:s.getScale(S))||{x:1,y:1},w=Po(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:I,offsetParent:S,strategy:c}):I);return{top:(g.top-w.top+v.top)/y.y,bottom:(w.bottom-g.bottom+v.bottom)/y.y,left:(g.left-w.left+v.left)/y.x,right:(w.right-g.right+v.right)/y.x}}var bP=50,bk=async(e,t,a)=>{let{placement:o="bottom",strategy:n="absolute",middleware:s=[],platform:i}=a,l=i.detectOverflow?i:{...i,detectOverflow:yk},c=await(i.isRTL==null?void 0:i.isRTL(t)),u=await i.getElementRects({reference:e,floating:t,strategy:n}),{x:f,y:m}=vk(u,o,c),d=o,p=0,v={};for(let b=0;b<s.length;b++){let C=s[b];if(!C)continue;let{name:g,fn:I}=C,{x:S,y,data:w,reset:T}=await I({x:f,y:m,initialPlacement:o,placement:d,strategy:n,middlewareData:v,rects:u,platform:l,elements:{reference:e,floating:t}});if(f=S!=null?S:f,m=y!=null?y:m,v[g]={...v[g],...w},T&&p<bP){if(p++,typeof T==="object"){if(T.placement)d=T.placement;if(T.rects)u=T.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:n}):T.rects;({x:f,y:m}=vk(u,d,c))}b=-1}}return{x:f,y:m,placement:d,strategy:n,middlewareData:v}};var Ck=function(e){if(e===void 0)e={};return{name:"flip",options:e,async fn(t){var a,o;let{placement:n,middlewareData:s,rects:i,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:m=!0,fallbackPlacements:d,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:b=!0,...C}=$a(e,t);if((a=s.arrow)!=null&&a.alignmentOffset)return{};let g=Ca(n),I=Jt(l),S=Ca(l)===l,y=await(c.isRTL==null?void 0:c.isRTL(u.floating)),w=d||(S||!b?[Xr(l)]:gk(l)),T=v!=="none";if(!d&&T)w.push(...Ik(l,b,v,y));let x=[l,...w],E=await c.detectOverflow(t,C),L=[],D=((o=s.flip)==null?void 0:o.overflows)||[];if(f)L.push(E[g]);if(m){let ie=hk(n,i,y);L.push(E[ie[0]],E[ie[1]])}if(D=[...D,{placement:n,overflows:L}],!L.every((ie)=>ie<=0)){var N,oe;let ie=(((N=s.flip)==null?void 0:N.index)||0)+1,de=x[ie];if(de){if(!(m==="alignment"?I!==Jt(de):!1)||D.every((je)=>Jt(je.placement)===I?je.overflows[0]>0:!0))return{data:{index:ie,overflows:D},reset:{placement:de}}}let Xe=(oe=D.filter((pe)=>pe.overflows[0]<=0).sort((pe,je)=>pe.overflows[1]-je.overflows[1])[0])==null?void 0:oe.placement;if(!Xe)switch(p){case"bestFit":{var ne;let pe=(ne=D.filter((je)=>{if(T){let B=Jt(je.placement);return B===I||B==="y"}return!0}).map((je)=>[je.placement,je.overflows.filter((B)=>B>0).reduce((B,k)=>B+k,0)]).sort((je,B)=>je[1]-B[1])[0])==null?void 0:ne[0];if(pe)Xe=pe;break}case"initialPlacement":Xe=l;break}if(n!==Xe)return{reset:{placement:Xe}}}return{}}}};var wk=new Set(["left","top"]);async function CP(e,t){let{placement:a,platform:o,elements:n}=e,s=await(o.isRTL==null?void 0:o.isRTL(n.floating)),i=Ca(a),l=Bn(a),c=Jt(a)==="y",u=wk.has(i)?-1:1,f=s&&c?-1:1,m=$a(t,e),{mainAxis:d,crossAxis:p,alignmentAxis:v}=typeof m==="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};if(l&&typeof v==="number")p=l==="end"?v*-1:v;return c?{x:p*f,y:d*u}:{x:d*u,y:p*f}}var Ak=function(e){if(e===void 0)e=0;return{name:"offset",options:e,async fn(t){var a,o;let{x:n,y:s,placement:i,middlewareData:l}=t,c=await CP(t,e);if(i===((a=l.offset)==null?void 0:a.placement)&&(o=l.arrow)!=null&&o.alignmentOffset)return{};return{x:n+c.x,y:s+c.y,data:{...c,placement:i}}}}},Tk=function(e){if(e===void 0)e={};return{name:"shift",options:e,async fn(t){let{x:a,y:o,placement:n,platform:s}=t,{mainAxis:i=!0,crossAxis:l=!1,limiter:c={fn:(I)=>{let{x:S,y}=I;return{x:S,y}}},...u}=$a(e,t),f={x:a,y:o},m=await s.detectOverflow(t,u),d=Jt(n),p=Gi(d),v=f[p],b=f[d],C=(I,S)=>pk(S+m[I==="y"?"top":"left"],S,S-m[I==="y"?"bottom":"right"]);if(i)v=C(p,v);if(l)b=C(d,b);let g=c.fn({...t,[p]:v,[d]:b});return{...g,data:{x:g.x-a,y:g.y-o,enabled:{[p]:i,[d]:l}}}}}},xk=function(e){if(e===void 0)e={};return{options:e,fn(t){var a,o;let{x:n,y:s,placement:i,rects:l,middlewareData:c}=t,{offset:u=0,mainAxis:f=!0,crossAxis:m=!0}=$a(e,t),d={x:n,y:s},p=Jt(i),v=Gi(p),b=d[v],C=d[p],g=$a(u,t),I=typeof g==="number"?{mainAxis:g,crossAxis:0}:{mainAxis:(a=g.mainAxis)!=null?a:0,crossAxis:(o=g.crossAxis)!=null?o:0};if(f){let w=v==="y"?"height":"width",T=l.reference[v]-l.floating[w]+I.mainAxis,x=l.reference[v]+l.reference[w]-I.mainAxis;if(b<T)b=T;else if(b>x)b=x}if(m){var S,y;let w=v==="y"?"width":"height",T=wk.has(Ca(i)),x=l.reference[p]-l.floating[w]+(T?((S=c.offset)==null?void 0:S[p])||0:0)+(T?0:I.crossAxis),E=l.reference[p]+l.reference[w]+(T?0:((y=c.offset)==null?void 0:y[p])||0)-(T?I.crossAxis:0);if(C<x)C=x;else if(C>E)C=E}return{[v]:b,[p]:C}}}},Mk=function(e){if(e===void 0)e={};return{name:"size",options:e,async fn(t){let{placement:a,rects:o,platform:n,elements:s}=t,{apply:i=()=>{},...l}=$a(e,t),c=await n.detectOverflow(t,l),u=Ca(a),f=Bn(a),m=Jt(a)==="y",{width:d,height:p}=o.floating,v,b;if(u==="top"||u==="bottom")v=u,b=f===(await(n.isRTL==null?void 0:n.isRTL(s.floating))?"start":"end")?"left":"right";else b=u,v=f==="end"?"top":"bottom";let C=p-c.top-c.bottom,g=d-c.left-c.right,I=Ja(p-c[v],C),S=Ja(d-c[b],g),y=t.middlewareData.shift,w=!y,T=I,x=S;if(y!=null&&y.enabled.x)x=g;if(y!=null&&y.enabled.y)T=C;if(w&&!f)if(m)x=d-2*Kt(c.left,c.right);else T=p-2*Kt(c.top,c.bottom);await i({...t,availableWidth:x,availableHeight:T});let E=await n.getDimensions(s.floating);if(d!==E.width||p!==E.height)return{reset:{rects:!0}};return{}}}};function Vi(){return typeof window<"u"}function qo(e){if(Ek(e))return(e.nodeName||"").toLowerCase();return"#document"}function dt(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ua(e){var t;return(t=(Ek(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function Ek(e){if(!Vi())return!1;return e instanceof Node||e instanceof dt(e).Node}function $t(e){if(!Vi())return!1;return e instanceof Element||e instanceof dt(e).Element}function wa(e){if(!Vi())return!1;return e instanceof HTMLElement||e instanceof dt(e).HTMLElement}function Dk(e){if(!Vi()||typeof ShadowRoot>"u")return!1;return e instanceof ShadowRoot||e instanceof dt(e).ShadowRoot}function Qr(e){let{overflow:t,overflowX:a,overflowY:o,display:n}=ea(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+a)&&n!=="inline"&&n!=="contents"}function Lk(e){return/^(table|td|th)$/.test(qo(e))}function Wr(e){try{if(e.matches(":popover-open"))return!0}catch(t){}try{return e.matches(":modal")}catch(t){return!1}}var wP=/transform|translate|scale|rotate|perspective|filter/,AP=/paint|layout|strict|content/,Go=(e)=>!!e&&e!=="none",Zu;function qi(e){let t=$t(e)?ea(e):e;return Go(t.transform)||Go(t.translate)||Go(t.scale)||Go(t.rotate)||Go(t.perspective)||!Zi()&&(Go(t.backdropFilter)||Go(t.filter))||wP.test(t.willChange||"")||AP.test(t.contain||"")}function Rk(e){let t=eo(e);while(wa(t)&&!Nn(t)){if(qi(t))return t;else if(Wr(t))return null;t=eo(t)}return null}function Zi(){if(Zu==null)Zu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none");return Zu}function Nn(e){return/^(html|body|#document)$/.test(qo(e))}function ea(e){return dt(e).getComputedStyle(e)}function Kr(e){if($t(e))return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop};return{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function eo(e){if(qo(e)==="html")return e;let t=e.assignedSlot||e.parentNode||Dk(e)&&e.host||ua(e);return Dk(t)?t.host:t}function Bk(e){let t=eo(e);if(Nn(t))return(e.ownerDocument||e).body;if(wa(t)&&Qr(t))return t;return Bk(t)}function Vo(e,t,a){var o;if(t===void 0)t=[];if(a===void 0)a=!0;let n=Bk(e),s=n===((o=e.ownerDocument)==null?void 0:o.body),i=dt(n);if(s){let l=Xi(i);return t.concat(i,i.visualViewport||[],Qr(n)?n:[],l&&a?Vo(l):[])}else return t.concat(n,Vo(n,[],a))}function Xi(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Hk(e){let t=ea(e),a=parseFloat(t.width)||0,o=parseFloat(t.height)||0,n=wa(e),s=n?e.offsetWidth:a,i=n?e.offsetHeight:o,l=jr(a)!==s||jr(o)!==i;if(l)a=s,o=i;return{width:a,height:o,$:l}}function ju(e){return!$t(e)?e.contextElement:e}function On(e){let t=ju(e);if(!wa(t))return ca(1);let a=t.getBoundingClientRect(),{width:o,height:n,$:s}=Hk(t),i=(s?jr(a.width):a.width)/o,l=(s?jr(a.height):a.height)/n;if(!i||!Number.isFinite(i))i=1;if(!l||!Number.isFinite(l))l=1;return{x:i,y:l}}var TP=ca(0);function kk(e){let t=dt(e);if(!Zi()||!t.visualViewport)return TP;return{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function xP(e,t,a){if(t===void 0)t=!1;return!!a&&t&&a===dt(e)}function Zo(e,t,a,o){if(t===void 0)t=!1;if(a===void 0)a=!1;let n=e.getBoundingClientRect(),s=ju(e),i=ca(1);if(t)if(o){if($t(o))i=On(o)}else i=On(e);let l=xP(s,a,o)?kk(s):ca(0),c=(n.left+l.x)/i.x,u=(n.top+l.y)/i.y,f=n.width/i.x,m=n.height/i.y;if(s&&o){let d=dt(s),p=$t(o)?dt(o):o,v=d,b=Xi(v);while(b&&p!==v){let C=On(b),g=b.getBoundingClientRect(),I=ea(b),S=g.left+(b.clientLeft+parseFloat(I.paddingLeft))*C.x,y=g.top+(b.clientTop+parseFloat(I.paddingTop))*C.y;c*=C.x,u*=C.y,f*=C.x,m*=C.y,c+=S,u+=y,v=dt(b),b=Xi(v)}}return Po({width:f,height:m,x:c,y:u})}function ji(e,t){let a=Kr(e).scrollLeft;if(!t)return Zo(ua(e)).left+a;return t.left+a}function zk(e,t){let a=e.getBoundingClientRect(),o=a.left+t.scrollLeft-ji(e,a),n=a.top+t.scrollTop;return{x:o,y:n}}function MP(e){let{elements:t,rect:a,offsetParent:o,strategy:n}=e,s=n==="fixed",i=ua(o),l=t?Wr(t.floating):!1;if(o===i||l&&s)return a;let c={scrollLeft:0,scrollTop:0},u=ca(1),f=ca(0),m=wa(o);if(m||!s){if(qo(o)!=="body"||Qr(i))c=Kr(o);if(m){let p=Zo(o);u=On(o),f.x=p.x+o.clientLeft,f.y=p.y+o.clientTop}}let d=i&&!m&&!s?zk(i,c):ca(0);return{width:a.width*u.x,height:a.height*u.y,x:a.x*u.x-c.scrollLeft*u.x+f.x+d.x,y:a.y*u.y-c.scrollTop*u.y+f.y+d.y}}function DP(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function EP(e){let t=Kr(e),a=e.ownerDocument.body,o=Kt(e.scrollWidth,e.clientWidth,a.scrollWidth,a.clientWidth),n=Kt(e.scrollHeight,e.clientHeight,a.scrollHeight,a.clientHeight),s=-t.scrollLeft+ji(e),i=-t.scrollTop;if(ea(a).direction==="rtl")s+=Kt(e.clientWidth,a.clientWidth)-o;return{width:o,height:n,x:s,y:i}}var LP=25;function RP(e,t,a){if(a===void 0)a="viewport";let o=a==="layoutViewport",n=dt(e),s=ua(e),i=n.visualViewport,l=s.clientWidth,c=s.clientHeight,u=0,f=0;if(i){let d=!Zi()||t==="fixed";if(o){if(!d)u=-i.offsetLeft,f=-i.offsetTop}else if(l=i.width,c=i.height,d)u=i.offsetLeft,f=i.offsetTop}if(ji(s)<=0){let d=s.ownerDocument,p=d.body,v=getComputedStyle(p),b=d.compatMode==="CSS1Compat"?parseFloat(v.marginLeft)+parseFloat(v.marginRight)||0:0,C=Math.abs(s.clientWidth-p.clientWidth-b),g=getComputedStyle(s).scrollbarGutter==="stable both-edges"?C/2:C;if(g<=LP)l-=g}return{width:l,height:c,x:u,y:f}}function BP(e,t){let a=Zo(e,!0,t==="fixed"),o=a.top+e.clientTop,n=a.left+e.clientLeft,s=On(e),i=e.clientWidth*s.x,l=e.clientHeight*s.y,c=n*s.x,u=o*s.y;return{width:i,height:l,x:c,y:u}}function Nk(e,t,a){let o;if(t==="viewport"||t==="layoutViewport")o=RP(e,a,t);else if(t==="document")o=EP(ua(e));else if($t(t))o=BP(t,a);else{let n=kk(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Po(o)}function NP(e,t){let a=t.get(e);if(a)return a;let o=Vo(e,[],!1).filter((l)=>$t(l)&&qo(l)!=="body"),n=null,s=ea(e).position==="fixed",i=s?eo(e):e;while($t(i)&&!Nn(i)){let l=ea(i),c=qi(i),u=n?n.position:s?"fixed":"";if(!c&&(u==="fixed"||u==="absolute"&&l.position==="static"))o=o.filter((m)=>m!==i);else n=l;i=eo(i)}return t.set(e,o),o}function OP(e){let{element:t,boundary:a,rootBoundary:o,strategy:n}=e,i=[...a==="clippingAncestors"?Wr(t)?[]:NP(t,this._c):[].concat(a),o],l=Nk(t,i[0],n),c=l.top,u=l.right,f=l.bottom,m=l.left;for(let d=1;d<i.length;d++){let p=Nk(t,i[d],n);c=Kt(p.top,c),u=Ja(p.right,u),f=Ja(p.bottom,f),m=Kt(p.left,m)}return{width:u-m,height:f-c,x:m,y:c}}function HP(e){let{width:t,height:a}=Hk(e);return{width:t,height:a}}function kP(e,t,a){let o=wa(t),n=ua(t),s=a==="fixed",i=Zo(e,!0,s,t),l={scrollLeft:0,scrollTop:0},c=ca(0);if(o||!s){if(qo(t)!=="body"||Qr(n))l=Kr(t);if(o){let d=Zo(t,!0,s,t);c.x=d.x+t.clientLeft,c.y=d.y+t.clientTop}}if(!o&&n)c.x=ji(n);let u=n&&!o&&!s?zk(n,l):ca(0),f=i.left+l.scrollLeft-c.x-u.x,m=i.top+l.scrollTop-c.y-u.y;return{x:f,y:m,width:i.width,height:i.height}}function Xu(e){return ea(e).position==="static"}function Ok(e,t){if(!wa(e)||ea(e).position==="fixed")return null;if(t)return t(e);let a=e.offsetParent;if(ua(e)===a)a=a.ownerDocument.body;return a}function Uk(e,t){let a=dt(e);if(Wr(e))return a;if(!wa(e)){let n=eo(e);while(n&&!Nn(n)){if($t(n)&&!Xu(n))return n;n=eo(n)}return a}let o=Ok(e,t);while(o&&Lk(o)&&Xu(o))o=Ok(o,t);if(o&&Nn(o)&&Xu(o)&&!qi(o))return a;return o||Rk(e)||a}var zP=async function(e){let t=this.getOffsetParent||Uk,a=this.getDimensions,o=await a(e.floating);return{reference:kP(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function UP(e){return ea(e).direction==="rtl"}var Fk={convertOffsetParentRelativeRectToViewportRelativeRect:MP,getDocumentElement:ua,getClippingRect:OP,getOffsetParent:Uk,getElementRects:zP,getClientRects:DP,getDimensions:HP,getScale:On,isElement:$t,isRTL:UP};function _k(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function FP(e,t,a){let o=null,n,s=ua(e);function i(){var f;clearTimeout(n),(f=o)==null||f.disconnect(),o=null}function l(f,m){if(f===void 0)f=!1;if(m===void 0)m=1;i();let d=e.getBoundingClientRect(),{left:p,top:v,width:b,height:C}=d;if(!f)t();if(!b||!C)return;let g=Yr(v),I=Yr(s.clientWidth-(p+b)),S=Yr(s.clientHeight-(v+C)),y=Yr(p),T={rootMargin:-g+"px "+-I+"px "+-S+"px "+-y+"px",threshold:Kt(0,Ja(1,m))||1},x=!0;function E(L){let D=L[0].intersectionRatio;if(!_k(d,e.getBoundingClientRect()))return l();if(D!==m){if(!x)return l();if(!D)n=setTimeout(()=>{l(!1,0.0000001)},1000);else l(!1,D)}x=!1}try{o=new IntersectionObserver(E,{...T,root:s.ownerDocument})}catch(L){o=new IntersectionObserver(E,T)}o.observe(e)}let c=dt(e),u=()=>l(a);return c.addEventListener("resize",u),l(!0),()=>{c.removeEventListener("resize",u),i()}}function Yu(e,t,a,o){if(o===void 0)o={};let{ancestorScroll:n=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver==="function",layoutShift:l=typeof IntersectionObserver==="function",animationFrame:c=!1}=o,u=ju(e),f=n||s?[...u?Vo(u):[],...t?Vo(t):[]]:[];f.forEach((g)=>{n&&g.addEventListener("scroll",a),s&&g.addEventListener("resize",a)});let m=u&&l?FP(u,a,s):null,d=-1,p=null;if(i){if(p=new ResizeObserver((g)=>{let[I]=g;if(I&&I.target===u&&p&&t)p.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var S;(S=p)==null||S.observe(t)});a()}),u&&!c)p.observe(u);if(t)p.observe(t)}let v,b=c?Zo(e):null;if(c)C();function C(){let g=Zo(e);if(b&&!_k(b,g))a();b=g,v=requestAnimationFrame(C)}return a(),()=>{var g;if(f.forEach((I)=>{n&&I.removeEventListener("scroll",a),s&&I.removeEventListener("resize",a)}),m==null||m(),(g=p)==null||g.disconnect(),p=null,c)cancelAnimationFrame(v)}}var Pk=Ak;var Gk=Tk,Vk=Ck,qk=Mk;var Zk=xk,Yi=(e,t,a)=>{let o=new Map,n=a!=null?a:{},s={...Fk,...n.platform,_c:o};return bk(e,t,{...n,platform:s})};var Qi=O(U(),1),_P=O(U(),1),PP=O(An(),1);var Xk=(e,t)=>{let a=Pk(e);return{name:a.name,fn:a.fn,options:[e,t]}},jk=(e,t)=>{let a=Gk(e);return{name:a.name,fn:a.fn,options:[e,t]}},Yk=(e,t)=>({fn:Zk(e).fn,options:[e,t]}),Qk=(e,t)=>{let a=Vk(e);return{name:a.name,fn:a.fn,options:[e,t]}},Wk=(e,t)=>{let a=qk(e);return{name:a.name,fn:a.fn,options:[e,t]}};function GP({body:e,ctx:t}){let[a,o]=R.useState(()=>{let i={...e.initialValues};for(let l of e.fields)if(l.kind!=="button"&&l.name&&i[l.name]===void 0&&"defaultValue"in l)i[l.name]=l.defaultValue;return i}),n=(i,l)=>o((c)=>({...c,[i]:l})),s=()=>e.onSubmit(a,t);return h.jsxs("form",{className:"fm-form flex flex-col gap-2 px-2 py-2",onSubmit:(i)=>{i.preventDefault(),s()},children:[e.fields.map((i,l)=>h.jsx(VP,{field:i,values:a,setValue:n,ctx:t},i.name??l)),e.submit!==null&&h.jsx("button",{type:"submit",className:"mt-2 inline-flex h-8 items-center justify-center rounded-md bg-primary px-3 text-sm font-medium text-primary-foreground hover:bg-primary/90",children:e.submit?.label??"Save"})]})}function VP({field:e,values:t,setValue:a,ctx:o}){if(e.kind==="button")return h.jsx("button",{type:"button",onClick:()=>e.onClick(t,o),className:"inline-flex h-8 items-center justify-center rounded-md bg-secondary px-3 text-sm font-medium hover:bg-secondary/80",children:typeof e.label==="function"?e.label():e.label});let n=e.name;if(!n)return null;if(typeof e.hidden==="function"?e.hidden(t):e.hidden)return null;let i=e.label!=null?h.jsx("label",{className:"text-xs text-muted-foreground",children:typeof e.label==="function"?e.label():e.label}):null;switch(e.kind){case"switch":{let l=!!t[n];return h.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5",children:[h.jsx("span",{className:"text-sm",children:typeof e.label==="function"?e.label():e.label}),h.jsx("button",{type:"button",role:"switch","aria-checked":l,onClick:()=>a(n,!l),className:Y("inline-flex h-4 w-7 shrink-0 items-center rounded-full transition-colors",l?"bg-primary":"bg-muted"),children:h.jsx("span",{className:Y("block h-3 w-3 rounded-full bg-background shadow transition-transform",l?"translate-x-3.5":"translate-x-0.5")})})]})}case"checkbox":{let l=!!t[n];return h.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[h.jsx("input",{type:"checkbox",checked:l,onChange:(c)=>a(n,c.target.checked),className:"size-4 rounded border-border"}),typeof e.label==="function"?e.label():e.label]})}case"text":case"textarea":{let l=t[n]??"",c=e.kind==="textarea"?"textarea":"input";return h.jsxs("div",{className:"flex flex-col gap-1",children:[i,h.jsx(c,{value:l,placeholder:e.placeholder,onChange:(u)=>a(n,u.target.value),className:"h-8 rounded-md border border-input bg-transparent px-2 text-sm"})]})}case"select":{let l=t[n]??"",c=typeof e.options==="function"?e.options():e.options;return h.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md px-1 py-1.5",children:[h.jsx("span",{className:"text-sm",children:typeof e.label==="function"?e.label():e.label}),h.jsx("select",{value:l,onChange:(u)=>a(n,u.target.value),className:"h-7 rounded-md border border-input bg-transparent px-2 text-sm",children:c.map((u)=>h.jsx("option",{value:String(u.id),children:u.name},String(u.id)))})]})}case"custom":return e.render({value:t[n],setValue:(l)=>a(n,l),ctx:o});default:return h.jsxs("div",{className:"text-xs text-muted-foreground",children:["[",e.kind," field not yet rendered]"]})}}var Kk=typeof navigator<"u"&&/Mac/i.test(navigator.platform||navigator.userAgent||"");function Ju(e,t,a,o){R.useEffect(()=>{if(!e||t?.disabled)return;let n=t?.navigation??"1d";if(n==="none")return;let s=t?.defaults??{},i=s.closeOnEscape??!0,l=s.selectOnEnter??!0,c=s.selectOnTab??!1,u=s.cycleWrap??!0,f=(m)=>{if(t?.onKeyDown?.(m,o)===!0)return;if(t?.shortcuts){for(let L of t.shortcuts)if(qP(m,L.keys)){if(L.preventDefault!==!1)m.preventDefault();L.handler(m);return}}let{count:d,index:p,setIndex:v,onSelect:b,onClose:C,columns:g}=a,I=(L)=>{if(d===0)return-1;if(u)return(L%d+d)%d;return Math.max(0,Math.min(d-1,L))},S=m.key.toLowerCase(),y=S==="arrowup"||Kk&&m.ctrlKey&&S==="p",w=S==="arrowdown"||Kk&&m.ctrlKey&&S==="n",T=S==="arrowleft",x=S==="arrowright",E=(L)=>L===1?0:Math.max(0,d-1);if(y){m.preventDefault();let L=n==="2d-grid"?g??1:1;v(p<0?E(-1):I(p-L));return}if(w){m.preventDefault();let L=n==="2d-grid"?g??1:1;v(p<0?E(1):I(p+L));return}if(n==="2d-grid"&&(T||x)){m.preventDefault(),v(p<0?E(T?-1:1):I(p+(T?-1:1)));return}if(n!=="2d-grid"&&x){if(a.onSubmenuOpen?.(p)){m.preventDefault();return}}if(n!=="2d-grid"&&T&&a.closeOnArrowLeft){m.preventDefault(),C();return}if(S==="home"){m.preventDefault(),v(0);return}if(S==="end"){m.preventDefault(),v(Math.max(0,d-1));return}if(l&&S==="enter"){if(m.preventDefault(),p>=0)b(p);return}if(c&&S==="tab"){if(m.preventDefault(),p>=0)b(p);return}if(i&&S==="escape")m.preventDefault(),C()};return e.addEventListener("keydown",f),()=>e.removeEventListener("keydown",f)},[e,t,a,o])}function qP(e,t){return t.split(",").map((o)=>o.trim().toLowerCase()).some((o)=>{let n=o.split("+").map((m)=>m.trim()),s=new Set(n),i=n[n.length-1],l=s.has("shift"),c=s.has("alt"),u=s.has("ctrl"),f=s.has("cmd")||s.has("meta");return e.key.toLowerCase()===i&&e.shiftKey===l&&e.altKey===c&&e.ctrlKey===u&&e.metaKey===f})}function Jr(e,t,a){let[o,n]=R.useState({items:[],loading:!1,hasMore:!1}),s=R.useRef(0),i=R.useRef(0);R.useEffect(()=>{if(e.kind==="static"){n({items:e.items,loading:!1,hasMore:!1});return}if(e.kind==="prop"){n({items:e.getItems(a.data),loading:!1,hasMore:!1});return}if(e.kind==="sections"){let f=e.getSections(a.data).flatMap((m)=>[...m.items]);n({items:f,loading:!1,hasMore:!1});return}if(e.kind==="async"){s.current=0,i.current+=1;let u=i.current;return n((f)=>({...f,loading:!0,items:[]})),e.fetch({offset:0,limit:e.pageSize,filter:t}).then((f)=>{if(u!==i.current)return;n({items:f.items,loading:!1,hasMore:f.hasMore??!1}),s.current=f.items.length}).catch(()=>{if(u!==i.current)return;n((f)=>({...f,loading:!1}))}),()=>{i.current+=1}}if(e.kind==="store"){n({items:e.selector()??[],loading:!1,hasMore:!1});return}if(e.kind==="composite"){let u=[];for(let d of e.sources)if(d.kind==="static")u.push(...d.items);else if(d.kind==="prop")u.push(...d.getItems(a.data));else if(d.kind==="sections")for(let p of d.getSections(a.data))u.push(...p.items);else if(d.kind==="store")u.push(...d.selector()??[]);let f=e.dedupeBy,m=f?Array.from(new Map(u.map((d)=>[f(d),d])).values()):u;n({items:m,loading:!1,hasMore:!1});return}},[e,t,a.data]);let l=R.useRef(!1);return R.useEffect(()=>{l.current=o.loading},[o.loading]),{...o,loadMore:()=>{if(e.kind!=="async"||!o.hasMore)return;if(l.current)return;l.current=!0;let u=i.current;n((f)=>({...f,loading:!0})),e.fetch({offset:s.current,limit:e.pageSize,filter:t}).then((f)=>{if(u!==i.current)return;n((m)=>({items:[...m.items,...f.items],loading:!1,hasMore:f.hasMore??!1})),s.current+=f.items.length,l.current=!1}).catch(()=>{if(u!==i.current)return;n((f)=>({...f,loading:!1})),l.current=!1})}}}function ez(e,t){if(!t)return e;let a=t.toLowerCase();return e.filter((o)=>{let n=o?.name;return(typeof n==="string"?n:JSON.stringify(o)).toLowerCase().includes(a)})}function ZP({body:e,ctx:t,filter:a,onCloseRequest:o}){let{items:n,loading:s}=Jr(e.source,a,t),i=R.useRef(null),[l,c]=R.useState(0),[u,f]=R.useState(0);R.useEffect(()=>{let v=i.current;if(!v||e.columns!=="auto"||!e.responsive)return;let b=new ResizeObserver(()=>c(v.clientWidth));return b.observe(v),c(v.clientWidth),()=>b.disconnect()},[e.columns,e.responsive]);let m=R.useMemo(()=>{if(e.columns==="auto"){let v=e.responsive?.minCellWidth??64;return Math.max(1,Math.floor((l||240)/v))}return e.columns},[e.columns,e.responsive,l]),d=Math.ceil(n.length/m),p=Du({count:d,getScrollElement:()=>i.current,estimateSize:()=>e.rowHeight+(e.gap??4),overscan:4});if(Ju(i.current,{navigation:e.keyboardNav2D?"2d-grid":"1d"},{count:n.length,index:u,setIndex:(v)=>{f(v);let b=Math.floor(v/m);p.scrollToIndex(b,{align:"auto"})},onSelect:(v)=>{let b=n[v];if(b!=null)e.onCellClick?.(b,t)},onClose:o,columns:m},t),!s&&n.length===0&&e.emptyState)return h.jsx("div",{className:"flex flex-col items-center justify-center px-4 py-8 text-sm text-muted-foreground",children:typeof e.emptyState.message==="string"&&e.emptyState.message||"No items"});return h.jsxs("div",{ref:i,className:"fm-grid relative max-h-[60vh] min-h-[80px] overflow-y-auto outline-none",role:"grid",children:[h.jsx("div",{style:{height:p.getTotalSize(),position:"relative",width:"100%"},children:p.getVirtualItems().map((v)=>{let b=v.index*m,C=n.slice(b,b+m);return h.jsx("div",{role:"row",style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${v.start}px)`,display:"grid",gridTemplateColumns:`repeat(${m}, minmax(0, 1fr))`,gap:e.gap??4,padding:e.gap??4},children:C.map((g,I)=>{let S=b+I;return h.jsx("div",{role:"gridcell","aria-selected":S===u,onMouseEnter:()=>f(S),onClick:()=>e.onCellClick?.(g,t),onContextMenu:(y)=>{if(!e.onCellContextMenu)return;y.preventDefault(),e.onCellContextMenu(g,t)},className:Y("flex items-center justify-center rounded-md border border-transparent transition-colors cursor-pointer",S===u&&"border-border bg-accent"),style:{height:e.rowHeight},children:e.renderCell(g,t)},S)})},v.key)})}),s&&h.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading…"})]})}function Ve({icon:e,defaultSize:t=16}){if(!e)return null;let a=e.icon,o={};if(e.color)o.color=e.color;return h.jsx(a,{size:e.size??t,weight:e.weight,className:e.className,style:o,"aria-label":e["aria-label"]})}function ce(e,t){if(e==null)return null;if(typeof e==="function")return e(t);return e}function Qe(e,t){if(typeof e==="function")return e(t);return e}function XP({item:e,spec:t,active:a,ctx:o,onActivate:n,extra:s,prefix:i}){let l=t,c=s?.filter??"",u=l.useFilterAsName&&c?`Add "${c}"`:ce(l.name,e);return h.jsxs("div",{role:"option","aria-selected":a,"data-active":a||void 0,onMouseEnter:n,onClick:()=>l.onClick(c||void 0,o),className:"fm-row",children:[i,h.jsx("span",{className:"fm-row__icon",children:l.icon?h.jsx(Ve,{icon:l.icon,defaultSize:14}):h.jsx(eu,{className:"size-3.5"})}),h.jsx("span",{className:"fm-row__name",children:u})]})}function tz({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=i.checked(e),c=Qe(i.disabled,e)??!1,u=Qe(i.readonly,e)??!1,f=typeof i.icon==="function"?i.icon(e):i.icon;return h.jsxs("div",{role:"option","aria-selected":a,"aria-checked":l,"aria-disabled":c||void 0,"data-active":a||void 0,"data-checked":l||void 0,"data-disabled":c||void 0,onMouseEnter:n,onClick:()=>{if(c||u)return;i.onToggle(e,!l,o)},className:Y("fm-row",u&&"fm-row--readonly"),children:[s,f&&h.jsx("span",{className:"fm-row__icon",children:h.jsx(Ve,{icon:f,defaultSize:16})}),h.jsx("span",{className:"fm-row__name",children:ce(i.name,e)}),h.jsx("span",{"aria-hidden":!0,"data-checked":l||void 0,className:"fm-checkbox",children:l&&h.jsx(Rr,{weight:"bold"})})]})}function az({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=Qe(i.disabled,e)??!1,c=typeof i.icon==="function"?i.icon(e):i.icon,u=typeof i.trailing?.icon==="function"?i.trailing.icon(e):i.trailing?.icon;return h.jsxs("div",{role:"option","aria-selected":a,"aria-disabled":l||void 0,"data-active":a||void 0,onMouseEnter:n,onClick:(f)=>!l&&i.onClick?.(e,f,o),className:Y("fm-row fm-row--chip"),children:[s,c&&h.jsx("span",{className:"fm-row__icon",children:h.jsx(Ve,{icon:c,defaultSize:14})}),h.jsx("span",{className:"fm-row__name",children:ce(i.name,e)}),i.trailing&&u&&h.jsx("button",{type:"button",onClick:(f)=>{f.stopPropagation(),i.trailing?.onClick?.(e,o)},className:"fm-row__chip-trailing","aria-label":typeof i.trailing.ariaLabel==="function"?i.trailing.ariaLabel(e):i.trailing.ariaLabel??"Toggle",children:h.jsx(Ve,{icon:u,defaultSize:12})}),i.onDelete&&h.jsx("button",{type:"button",onClick:(f)=>{f.stopPropagation(),i.onDelete?.(e,o)},className:"fm-row__chip-delete","aria-label":typeof i.deleteAriaLabel==="function"?i.deleteAriaLabel(e):i.deleteAriaLabel??"Remove",children:h.jsx(Ro,{weight:"bold"})})]})}var jP={default:"text-foreground/80",red:"text-red-500",orange:"text-orange-500",amber:"text-amber-500",yellow:"text-yellow-500",green:"text-emerald-500",teal:"text-teal-500",blue:"text-blue-500",indigo:"text-indigo-500",purple:"text-purple-500",pink:"text-pink-500"},YP={default:"bg-muted",red:"bg-red-500",orange:"bg-orange-500",amber:"bg-amber-500",yellow:"bg-yellow-500",green:"bg-emerald-500",teal:"bg-teal-500",blue:"bg-blue-500",indigo:"bg-indigo-500",purple:"bg-purple-500",pink:"bg-pink-500"};function QP({item:e,spec:t,active:a,ctx:o,onActivate:n}){let s=t,i=String(s.value(e)),l=s.active?.(e)??!1,c=typeof s.scope==="function"?s.scope(e):s.scope,f=(c==="bg"?YP:jP)[i]??"bg-muted";return h.jsxs("div",{role:"option","aria-selected":a,"data-active":a||void 0,onMouseEnter:n,onClick:()=>s.onSelect(e,o),className:"fm-row",children:[h.jsx("span",{"aria-hidden":!0,className:Y("fm-swatch",c==="bg"&&f),children:c==="text"&&h.jsx("span",{className:Y("fm-swatch__letter",f),children:"A"})}),h.jsx("span",{className:"fm-row__name",children:ce(s.name,e)}),l&&h.jsx(Rr,{className:"size-3.5 text-[color:var(--fm-muted-fg)]"})]})}function WP({spec:e}){let t=e;return h.jsx("div",{role:"separator",className:"fm-divider",style:t.height?{height:t.height}:void 0})}function oz({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=Qe(i.disabled,e)??!1,c=i.icon(e),u=i.relationName(e),f=i.conditionLabel(e),m=i.valuePreview(e),d=i.withMore??Boolean(i.onMore);return h.jsxs("div",{role:"option","aria-selected":a,"aria-disabled":l||void 0,"data-active":a||void 0,onMouseEnter:n,onClick:()=>!l&&i.onClick?.(e,o),className:Y("fm-row fm-row--rule"),children:[s,h.jsx("span",{className:"fm-row__icon",children:h.jsx(Ve,{icon:c,defaultSize:14})}),h.jsxs("span",{className:"fm-row__name flex min-w-0 items-baseline gap-1.5",children:[h.jsx("span",{className:"truncate font-medium",children:u}),h.jsx("span",{className:"shrink-0 text-[color:var(--fm-muted-fg)]",children:f}),h.jsx("span",{className:"truncate text-[color:var(--fm-muted-fg)]",children:m})]}),d&&h.jsx("button",{type:"button","aria-label":"More",onClick:(p)=>{p.stopPropagation(),i.onMore?.(e,o)},className:"inline-flex size-6 items-center justify-center rounded-md text-[color:var(--fm-muted-fg)] hover:bg-[color:var(--fm-row-hover-bg)]",children:h.jsx(Br,{className:"size-4"})})]})}function nz({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=Qe(i.disabled,e)??!1,c=Qe(i.readonly,e)??!1;if(Qe(i.hidden,e)??!1)return null;let f=Qe(i.arrow,e)??!1,m=Qe(i.withMore,e)??!1,d=Qe(i.isBig,e)??!1,p=Qe(i.pressed,e)??!1,v=typeof i.icon==="function"?i.icon(e):i.icon,b=Qe(i.className,e),C=typeof i.subMenuId==="function"?i.subMenuId(e):i.subMenuId,g=i.subMenuTrigger??"arrowHover",I=i.subMenuHoverMs??200,S=R.useRef(null),y=R.useRef(null),w=()=>{if(!C||l||c)return;let D=i.subMenuData?i.subMenuData(e,o):o.data,N=S.current?.getBoundingClientRect(),oe=N&&N.width>0&&N.height>0?N:void 0;o.open(C,{element:S.current??void 0,data:D,triggerRect:oe})},T=()=>{if(y.current!=null)window.clearTimeout(y.current),y.current=null};return R.useEffect(()=>()=>T(),[e]),h.jsxs("div",{ref:S,role:"option","aria-selected":a,"aria-pressed":p||void 0,"aria-disabled":l||void 0,"aria-haspopup":C?"menu":void 0,"data-active":a||void 0,"data-pressed":p||void 0,"data-disabled":l||void 0,"data-submenu-id":C,onMouseEnter:()=>{if(n(),!C||l||c){T(),o.closeChildren();return}if(g!=="arrowHover")return;T(),y.current=window.setTimeout(w,I)},onMouseLeave:()=>{T()},onClick:(D)=>{if(l||c)return;if(C&&(g==="arrowClick"||g==="replace")){T(),w();return}i.onClick?.(e,D,o)},className:Y("fm-row",d&&"fm-row--big",c&&"fm-row--readonly",b),children:[s,v&&h.jsx("span",{className:"fm-row__icon",children:h.jsx(Ve,{icon:v,defaultSize:i.iconSize??16})}),h.jsx("span",{className:"fm-row__name",children:ce(i.name,e)}),i.caption!=null&&h.jsx("span",{className:"fm-row__caption",children:ce(i.caption,e)}),(m||f)&&h.jsxs("span",{className:"fm-row__suffix",children:[m&&h.jsx("button",{type:"button","aria-label":"More",onClick:(D)=>{D.stopPropagation(),i.onMore?.(e,D,o)},className:"inline-flex size-6 items-center justify-center rounded-md text-[color:var(--fm-muted-fg)] hover:bg-[color:var(--fm-row-hover-bg)]",children:h.jsx(Br,{className:"size-4"})}),f&&h.jsx(Lr,{className:"size-4 text-[color:var(--fm-muted-fg)]"})]})]})}function rz({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=Qe(i.disabled,e)??!1;return h.jsxs("div",{role:"option","aria-selected":a,"data-active":a||void 0,"data-disabled":l||void 0,onMouseEnter:n,onClick:(c)=>!l&&i.onClick?.(e,c,o),onContextMenu:(c)=>{if(!i.onContextMenu)return;c.preventDefault(),i.onContextMenu(e,c,o)},className:Y("fm-row",i.withDescription&&"fm-row--big"),children:[s,h.jsx("span",{className:"fm-row__icon",children:i.iconRender(e)}),h.jsxs("div",{className:"fm-row__name flex flex-col leading-tight",children:[h.jsx("span",{className:"truncate",children:ce(i.name,e)}),i.caption!=null&&!i.withDescription&&h.jsx("span",{className:"truncate text-[length:var(--fm-font-size-caption)] text-[color:var(--fm-muted-fg)]",children:ce(i.caption,e)})]}),i.caption!=null&&i.withDescription&&h.jsx("span",{className:"fm-row__caption",children:ce(i.caption,e)}),i.onMore&&h.jsx("button",{type:"button",onClick:(c)=>{c.stopPropagation(),i.onMore?.(e,c,o)},"aria-label":"More",className:"inline-flex size-6 items-center justify-center rounded-md text-[color:var(--fm-muted-fg)] hover:bg-[color:var(--fm-row-hover-bg)]",children:h.jsx(Br,{className:"size-4"})})]})}function sz({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=i.selected?.(e)??!1;return h.jsxs("div",{role:"option","aria-selected":a,"data-active":a||void 0,onMouseEnter:n,onClick:()=>i.onSelect(e,o),className:"fm-row fm-row--big",children:[s,h.jsx("span",{className:"fm-row__icon",children:i.iconRender(e)}),h.jsxs("div",{className:"fm-row__name flex flex-col leading-tight",children:[h.jsx("span",{className:"truncate",children:ce(i.name,e)}),i.identity!=null&&h.jsx("span",{className:"truncate text-[length:var(--fm-font-size-caption)] text-[color:var(--fm-muted-fg)]",children:ce(i.identity,e)})]}),l&&h.jsx(Rr,{className:"size-4 text-[color:var(--fm-accent)]"})]})}function KP({item:e,spec:t}){let a=t;return h.jsx("div",{role:"presentation",className:Y("fm-section",a.className),children:ce(a.name,e)})}function JP({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=Qe(i.disabled,e)??!1,c=Qe(i.readonly,e)??!1,u=typeof i.icon==="function"?i.icon(e):i.icon,f=R.useRef(null),m=()=>{if(!i.subMenuId||l||c)return;let d=f.current?.getBoundingClientRect(),p=d&&d.width>0&&d.height>0?d:void 0;o.open(i.subMenuId,{element:f.current??void 0,data:o.data,triggerRect:p})};return h.jsxs("div",{ref:f,role:"option","aria-haspopup":"menu","aria-selected":a,"aria-disabled":l||void 0,"data-active":a||void 0,"data-submenu-id":i.subMenuId,onMouseEnter:n,onClick:m,className:Y("fm-row",c&&"fm-row--readonly"),children:[s,u&&h.jsx("span",{className:"fm-row__icon",children:h.jsx(Ve,{icon:u,defaultSize:16})}),h.jsx("span",{className:"fm-row__name",children:ce(i.name,e)}),h.jsx("span",{className:"fm-row__caption",children:ce(i.caption,e)}),h.jsx(Lr,{className:"size-4 shrink-0 text-[color:var(--fm-muted-fg)]"})]})}function iz({item:e,spec:t,active:a,ctx:o,onActivate:n,prefix:s}){let i=t,l=Qe(i.disabled,e)??!1,c=Qe(i.readonly,e)??!1,u=i.switchValue(e),f=typeof i.icon==="function"?i.icon(e):i.icon,m=Qe(i.className,e);return h.jsxs("div",{role:"option","aria-selected":a,"data-active":a||void 0,"data-disabled":l||c||void 0,onMouseEnter:n,onPointerDown:(p)=>{if(l||c)return;if(p.button!==0)return;p.preventDefault(),i.onSwitch(e,!u,o)},className:Y("fm-row",(l||c)&&"fm-row--readonly",m),children:[s,f&&h.jsx("span",{className:"fm-row__icon",children:h.jsx(Ve,{icon:f,defaultSize:16})}),h.jsx("span",{className:"fm-row__name",children:ce(i.name,e)}),i.caption!=null&&h.jsx("span",{className:"fm-row__caption",children:ce(i.caption,e)}),h.jsx("span",{role:"switch","aria-checked":u,"aria-disabled":l||c||void 0,className:"fm-switch","data-on":u||void 0,children:h.jsx("span",{className:"fm-switch__thumb"})})]})}function $P(e,t){if(e==null)return String(t);return String(e?.id??t)}function eG(e){let t=e.spec,a=$P(e.item,e.index),{attributes:o,listeners:n,setNodeRef:s,transform:i,transition:l,isDragging:c}=ck({id:a}),u={transform:Qt.Transform.toString(i),transition:l,opacity:c?0.55:1,zIndex:c?10:void 0,pointerEvents:c?"none":void 0},f={...e,spec:t.inner,prefix:h.jsx(tG,{dragListeners:n,dragAttributes:o})},m=(()=>{switch(t.inner.kind){case"item":return h.jsx(nz,{...f});case"object":return h.jsx(rz,{...f});case"switch":return h.jsx(iz,{...f});case"checkbox":return h.jsx(tz,{...f});case"chip":return h.jsx(az,{...f});case"participant":return h.jsx(sz,{...f});case"filterRule":return h.jsx(oz,{...f});case"custom":return h.jsx(h.Fragment,{children:t.inner.render(e.item,e.ctx)});default:return null}})();return h.jsx("div",{ref:s,style:u,"data-fm-drag-source":c||void 0,children:m})}function tG({dragListeners:e,dragAttributes:t}){let a=e?.onPointerDown,o=e?.onKeyDown;return h.jsx("span",{...t,...e,onPointerDown:(n)=>{n.stopPropagation(),a?.(n)},onKeyDown:(n)=>{n.stopPropagation(),o?.(n)},onClick:(n)=>n.stopPropagation(),"aria-label":"Drag to reorder",role:"button",tabIndex:0,className:Y("shrink-0 cursor-grab text-[color:var(--fm-muted-fg)] opacity-50 transition-opacity","hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none active:cursor-grabbing"),"data-fm-drag-handle":!0,children:h.jsx(Wc,{className:"size-3.5"})})}function to(e,t){for(let a of e)if(!a.match||a.match(t))return a;return}function Qu(e){switch(e.spec.kind){case"item":return h.jsx(nz,{...e});case"section":return h.jsx(KP,{...e});case"divider":return h.jsx(WP,{...e});case"switch":return h.jsx(iz,{...e});case"checkbox":return h.jsx(tz,{...e});case"selectNav":return h.jsx(JP,{...e});case"color":return h.jsx(QP,{...e});case"add":return h.jsx(XP,{...e});case"object":return h.jsx(rz,{...e});case"participant":return h.jsx(sz,{...e});case"sortable":return h.jsx(eG,{...e});case"chip":return h.jsx(az,{...e});case"filterRule":return h.jsx(oz,{...e});case"custom":return e.spec.render(e.item,e.ctx);default:return h.jsxs("div",{"data-row-kind":e.spec.kind,className:"px-3 py-2 text-xs text-muted-foreground",children:["[",e.spec.kind," row not yet rendered]"]})}}var aG=32,Jk=8;function lz({body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i}){let{items:l,loading:c,hasMore:u,loadMore:f}=Jr(e.source,a,t),m=R.useMemo(()=>{let B=e.source?.kind;if(B==="async"||B==="composite")return l;return ez(l,a)},[l,a,e.source]),d=R.useRef(null),[p,v]=R.useState(0),b=i!=null,C=b?i:p;R.useEffect(()=>{if(e.orientation==="horizontal"){v(-1);return}v(m.length>0?oG(m,e.rows):-1)},[m,e.rows,e.orientation]);let g=e.focusOnMount??!0;R.useEffect(()=>{if(!g)return;let B=requestAnimationFrame(()=>{let k=d.current;if(!k)return;let G=document.activeElement;if(G&&G.tagName==="INPUT")return;if(k.contains(G))return;k.focus({preventScroll:!0})});return()=>cancelAnimationFrame(B)},[n,g]);let I=R.useCallback((B)=>{let k=e.virtualized;if(typeof k==="object"&&k.rowHeight)return typeof k.rowHeight==="function"?k.rowHeight(m[B],B):k.rowHeight;let G=to(e.rows,m[B]);if(G?.kind==="section")return 28;if(G?.kind==="divider")return 9;return aG},[e.virtualized,e.rows,m]),S=Du({count:m.length,getScrollElement:()=>d.current,estimateSize:I,overscan:typeof e.virtualized==="object"?e.virtualized.overscan??Jk:Jk});R.useEffect(()=>{if(!b||i==null||i<0)return;S.scrollToIndex(i,{align:"auto"})},[b,i,S]);let y=R.useMemo(()=>s?.navigation==="2d-grid"?{...s,navigation:"1d"}:s,[s]);Ju(d.current,y,{count:m.length,index:p,setIndex:(B)=>{let k=nG(B,m,e.rows,p);v(k),S.scrollToIndex(k,{align:"auto"})},onSelect:(B)=>{cz(m[B],e.rows,t)},onSubmenuOpen:(B)=>{let k=m[B],G=to(e.rows,k);if(!G||G.kind!=="item"&&G.kind!=="selectNav")return!1;if(!G.subMenuId)return!1;let Q=typeof G.subMenuId==="function"?G.subMenuId(k):G.subMenuId;if(!Q)return!1;let $e=d.current?.querySelector(`[data-index="${B}"] [data-submenu-id]`),ut=$e?.getBoundingClientRect(),Sa=ut&&ut.width>0&&ut.height>0?ut:void 0,et=G.subMenuData?G.subMenuData(k,t):t.data;return t.open(Q,{element:$e??void 0,data:et,triggerRect:Sa}),!0},onClose:o,closeOnArrowLeft:n},t);let w=R.useRef(-1),T=S.getVirtualItems(),x=T.length?T[T.length-1].index:-1;R.useEffect(()=>{if(!e.infiniteScroll)return;if(x<0)return;if(!u||c)return;if(x>=m.length-5&&w.current!==m.length)w.current=m.length,f()},[x,m.length,u,c,e.infiniteScroll,f]);let E=e.sortable,L=R.useMemo(()=>{let B=[];for(let k=0;k<m.length;k++){let G=m[k],Q=to(e.rows,G);if(!Q||Q.kind!=="sortable")continue;B.push(String(G?.id??k))}return B},[m,e.rows]),D=DH(Uu(qr,{activationConstraint:{distance:4}}),Uu(Vr,{coordinateGetter:uk})),[N,oe]=R.useState(null),ne=R.useRef(null),ie=N==null?null:ne.current,de=R.useCallback((B)=>{document.body.setAttribute("data-fm-dragging","true");let k=String(B.active.id);oe(k),ne.current=m.find((G,Q)=>String(G?.id??Q)===k)},[m]),Xe=R.useCallback((B)=>{if(oe(null),!E)return;let{active:k,over:G}=B;if(!G||k.id===G.id)return;let Q=(Sa)=>m.findIndex((et,pn)=>String(et?.id??pn)===Sa),$e=Q(String(k.id)),ut=Q(String(G.id));if($e<0||ut<0)return;E.onReorder($e,ut,t)},[E,m,t]);if(!c&&m.length===0&&e.emptyState){let B=typeof e.emptyState.title==="string"&&e.emptyState.title||typeof e.emptyState.message==="string"&&e.emptyState.message||"No results";return h.jsx("div",{className:"flex flex-col items-center justify-center px-4 py-8 text-sm text-muted-foreground",children:B})}if(e.orientation==="horizontal")return h.jsx("div",{tabIndex:0,className:"fm-list fm-list--horizontal",role:"listbox","aria-orientation":"horizontal",children:m.map((B,k)=>{let G=to(e.rows,B);if(!G)return null;let Q=B?.id,$e=typeof Q==="string"||typeof Q==="number"?Q:k;return h.jsx("div",{"data-index":k,children:Qu({item:B,spec:G,index:k,active:k===C,ctx:t,onActivate:()=>v(k),extra:{filter:a}})},$e)})});let pe=h.jsxs("div",{ref:d,tabIndex:0,className:"fm-list",role:"listbox","aria-orientation":"vertical",children:[h.jsx("div",{style:{height:S.getTotalSize(),position:"relative",width:"100%"},children:S.getVirtualItems().map((B)=>{let k=m[B.index],G=to(e.rows,k);if(!G)return null;return h.jsx("div",{"data-index":B.index,ref:S.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${B.start}px)`},children:Qu({item:k,spec:G,index:B.index,active:B.index===C,ctx:t,onActivate:()=>v(B.index),extra:{filter:a}})},B.key)})}),c&&h.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Loading…"})]});if(!E)return pe;let je=[ek,E.axis==="x"?null:tk].filter(Boolean);return h.jsxs(WH,{sensors:D,collisionDetection:(B)=>{let k=BH(B);return k.length?k:_u(B)},modifiers:je,onDragStart:de,onDragEnd:(B)=>{document.body.removeAttribute("data-fm-dragging"),Xe(B)},onDragCancel:()=>{document.body.removeAttribute("data-fm-dragging"),oe(null)},children:[h.jsx(ik,{items:L,strategy:nk,children:pe}),typeof document<"u"&&Ku.createPortal(h.jsx($H,{children:ie?h.jsx("div",{className:"fm-row-overlay","data-fm-drag-overlay":!0,children:(()=>{let B=to(e.rows,ie);if(!B)return null;return Qu({item:ie,spec:B,index:-1,active:!0,ctx:t,onActivate:()=>{},extra:{filter:a}})})()}):null}),document.body)]})}function cz(e,t,a){if(e==null)return;let o=to(t,e);if(!o)return;let n=new MouseEvent("click",{detail:0});switch(o.kind){case"item":o.onClick?.(e,n,a);return;case"switch":o.onSwitch?.(e,!o.switchValue?.(e),a);return;case"checkbox":o.onToggle?.(e,!o.checked?.(e),a);return;case"color":o.onSelect?.(e,a);return;case"participant":o.onSelect?.(e,a);return;case"add":o.onClick?.(void 0,a);return;case"object":o.onClick?.(e,n,a);return;case"chip":o.onClick?.(e,n,a);return;case"filterRule":o.onClick?.(e,a);return;case"selectNav":{if(!o.subMenuId)return;a.open(o.subMenuId,{data:a.data});return}case"sortable":cz(e,[{...o.inner,match:o.match}],a);return;default:return}}function uz(e,t){let a=to(t,e);if(!a)return!1;return a.kind!=="section"&&a.kind!=="divider"&&a.kind!=="empty"}function oG(e,t){for(let a=0;a<e.length;a++)if(uz(e[a],t))return a;return-1}function nG(e,t,a,o){let n=e>o?1:-1,s=e,i=t.length;while(i-- >0){if(s<0)s=t.length-1;if(s>=t.length)s=0;if(uz(t[s],a))return s;s+=n}return o}function rG({spec:e,ctx:t}){switch(e.kind){case"custom":return h.jsx(h.Fragment,{children:e.render(t)});case"label":return h.jsx(sG,{spec:e,ctx:t});case"divider":return h.jsx("hr",{className:"mx-2 my-1 border-border"});case"searchInput":return h.jsx(iG,{spec:e,ctx:t});case"recentStrip":return h.jsx(lG,{spec:e,ctx:t});case"categoryJump":return h.jsx(cG,{spec:e,ctx:t});case"fileDropZone":return h.jsx(uG,{spec:e,ctx:t});case"monthGrid":return h.jsx(fG,{spec:e,ctx:t});case"emojiGrid":return h.jsx(fz,{spec:e,ctx:t});case"tileGrid":return h.jsx(mG,{spec:e,ctx:t});case"queryBuilder":return h.jsx(dG,{spec:e,ctx:t});case"emptyState":return h.jsx(pG,{spec:e,ctx:t});case"loader":return h.jsx(hG,{spec:e});case"error":return h.jsx(gG,{spec:e,ctx:t});case"banner":return h.jsx(IG,{spec:e,ctx:t});case"linkPreview":return h.jsx(SG,{spec:e});case"tabBar":return h.jsx(vG,{spec:e,ctx:t});case"slider":return h.jsx(yG,{spec:e,ctx:t});case"markdownToolbar":return h.jsx(bG,{spec:e,ctx:t});case"codeEditor":return h.jsx(CG,{spec:e,ctx:t});case"katexPreview":return h.jsx(wG,{spec:e});case"qrCode":return h.jsx(AG,{spec:e});default:return null}}function sG({spec:e}){return h.jsx("div",{className:Y("px-3 py-1 text-xs text-muted-foreground",e.className),children:ce(e.text,void 0)})}function iG({spec:e,ctx:t}){let[a,o]=R.useState(""),n=R.useRef(void 0),s=R.useRef(t);return s.current=t,R.useEffect(()=>()=>window.clearTimeout(n.current),[]),h.jsxs("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[h.jsx("span",{className:"text-muted-foreground",children:e.icon?h.jsx(Ve,{icon:e.icon,defaultSize:14}):h.jsx(Nr,{className:"size-3.5"})}),h.jsx("input",{value:a,placeholder:e.placeholder??"Search…",onChange:(i)=>{o(i.target.value),window.clearTimeout(n.current),n.current=window.setTimeout(()=>e.onChange(i.target.value,s.current),e.debounceMs??200)},className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),a&&h.jsx("button",{type:"button","aria-label":"Clear",onClick:()=>{o(""),e.onChange("",t),e.onClear?.(t)},className:"text-muted-foreground hover:text-foreground",children:h.jsx(Ro,{className:"size-3.5"})})]})}function lG({spec:e,ctx:t}){let{items:a}=Jr(e.source,"",t);if(!a.length)return e.emptyMessage?h.jsx("div",{className:"px-3 py-1 text-xs text-muted-foreground",children:e.emptyMessage}):null;return h.jsx("div",{className:"flex items-center gap-1 overflow-x-auto px-2 py-1",children:a.map((o,n)=>h.jsx("button",{type:"button",onClick:()=>e.onSelect?.(o,t),className:"shrink-0 rounded-md p-1 hover:bg-accent",children:e.renderItem(o,t)},n))})}function cG({spec:e,ctx:t}){return h.jsxs("div",{className:"flex items-center justify-between border-t border-border bg-muted/30 px-1 py-1",children:[h.jsx("div",{className:"flex items-center gap-0.5",children:e.categories.map((a)=>{let o=a.id===e.activeId;return h.jsx("button",{type:"button",title:a.tooltip,onClick:()=>e.onJump(a.id,t),className:Y("inline-flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent",o&&"bg-accent text-foreground"),children:h.jsx(Ve,{icon:a.icon,defaultSize:14})},a.id)})}),e.trailing&&h.jsx("button",{type:"button",title:e.trailing.tooltip,onClick:()=>e.trailing.onClick(t),className:"inline-flex size-6 items-center justify-center rounded-md text-muted-foreground hover:bg-accent",children:h.jsx(Ve,{icon:e.trailing.icon,defaultSize:14})})]})}function uG({spec:e,ctx:t}){let[a,o]=R.useState(!1),n=R.useRef(null);return R.useEffect(()=>{if(!e.pasteFromClipboard)return;let s=(i)=>{let l=Array.from(i.clipboardData?.files??[]);if(l.length)i.preventDefault(),e.onFiles(l,t)};return window.addEventListener("paste",s),()=>window.removeEventListener("paste",s)},[e,t]),h.jsxs("div",{onClick:()=>e.clickToOpen!==!1&&n.current?.click(),onDragOver:(s)=>{s.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:(s)=>{s.preventDefault(),o(!1);let i=Array.from(s.dataTransfer.files);if(i.length)e.onFiles(i,t)},className:Y("m-2 flex h-32 flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed text-sm text-muted-foreground transition-colors cursor-pointer",a?"border-primary bg-accent/50 text-foreground":"border-border"),children:[e.icon?h.jsx(Ve,{icon:e.icon,defaultSize:20}):h.jsx(au,{className:"size-5"}),h.jsx("span",{children:ce(e.label,void 0)??"Drop files here"}),h.jsx("input",{ref:n,type:"file",accept:e.accept,multiple:e.multiple,className:"hidden",onChange:(s)=>{let i=Array.from(s.target.files??[]);if(i.length)e.onFiles(i,t);s.target.value=""}})]})}var $k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function fG({spec:e,ctx:t}){let[a,o]=R.useState(()=>new Date(e.value??Date.now())),[n,s]=R.useState("days"),i=(()=>{let C=e.value?new Date(e.value):new Date;return{hh:C.getHours(),mm:C.getMinutes()}})(),[l,c]=R.useState(i),u=(C)=>{let g=new Date(C);if(e.withTime)g.setHours(l.hh,l.mm,0,0);e.onChange(g.getTime(),t)},f=new Date,m=(C,g)=>C.getFullYear()===g.getFullYear()&&C.getMonth()===g.getMonth()&&C.getDate()===g.getDate(),d=h.jsxs("header",{className:"flex items-center justify-between gap-1 px-1 pb-1.5",children:[h.jsx("button",{type:"button",onClick:()=>{if(n==="days")o(new Date(a.getFullYear(),a.getMonth()-1,1));else if(n==="months")o(new Date(a.getFullYear()-1,a.getMonth(),1));else o(new Date(a.getFullYear()-12,a.getMonth(),1))},className:"rounded-md p-1 text-[color:var(--fm-muted-fg)] hover:bg-[color:var(--fm-row-hover-bg)]","aria-label":"Previous",children:h.jsx(qc,{className:"size-4"})}),h.jsxs("div",{className:"flex flex-1 items-center justify-center gap-1",children:[h.jsx("button",{type:"button",onClick:()=>s(n==="months"?"days":"months"),"aria-label":"Pick month",className:"rounded-md px-1.5 py-0.5 text-sm font-medium hover:bg-[color:var(--fm-row-hover-bg)]",children:$k[a.getMonth()]}),h.jsx("button",{type:"button",onClick:()=>s(n==="years"?"days":"years"),"aria-label":"Pick year",className:"rounded-md px-1.5 py-0.5 text-sm font-medium tabular-nums hover:bg-[color:var(--fm-row-hover-bg)]",children:a.getFullYear()})]}),h.jsx("button",{type:"button",onClick:()=>{if(n==="days")o(new Date(a.getFullYear(),a.getMonth()+1,1));else if(n==="months")o(new Date(a.getFullYear()+1,a.getMonth(),1));else o(new Date(a.getFullYear()+12,a.getMonth(),1))},className:"rounded-md p-1 text-[color:var(--fm-muted-fg)] hover:bg-[color:var(--fm-row-hover-bg)]","aria-label":"Next",children:h.jsx(Lr,{className:"size-4"})})]}),p;if(n==="months")p=h.jsx("div",{className:"grid grid-cols-3 gap-1 px-1",children:$k.map((C,g)=>{let I=g===a.getMonth();return h.jsx("button",{type:"button",onClick:()=>{o(new Date(a.getFullYear(),g,1)),s("days")},className:Y("rounded-md py-1.5 text-xs hover:bg-[color:var(--fm-row-hover-bg)]",I&&"bg-[color:var(--fm-accent)] text-[color:var(--fm-accent-fg)] hover:bg-[color:var(--fm-accent)]"),children:C},C)})});else if(n==="years"){let C=a.getFullYear(),g=e.yearRange?.from??C-50,I=e.yearRange?.to??C+50,S=Math.floor(C/12)*12,y=[];for(let w=0;w<12;w++)y.push(S+w);p=h.jsx("div",{className:"grid grid-cols-3 gap-1 px-1",children:y.map((w)=>{let T=w===C,x=w<g||w>I;return h.jsx("button",{type:"button",disabled:x,onClick:()=>{o(new Date(w,a.getMonth(),1)),s("days")},className:Y("rounded-md py-1.5 text-xs tabular-nums hover:bg-[color:var(--fm-row-hover-bg)]",T&&"bg-[color:var(--fm-accent)] text-[color:var(--fm-accent-fg)] hover:bg-[color:var(--fm-accent)]",x&&"opacity-30 pointer-events-none"),children:w},w)})})}else{let g=(new Date(a.getFullYear(),a.getMonth(),1).getDay()+6)%7,I=new Date(a.getFullYear(),a.getMonth()+1,0).getDate(),S=[];for(let y=0;y<g;y++)S.push(null);for(let y=1;y<=I;y++)S.push({day:y,date:new Date(a.getFullYear(),a.getMonth(),y)});while(S.length%7!==0)S.push(null);p=h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"grid grid-cols-7 gap-0.5 text-center text-[10px] text-[color:var(--fm-muted-fg)]",children:["M","T","W","T","F","S","S"].map((y,w)=>h.jsx("span",{className:"py-1",children:y},w))}),h.jsx("div",{className:"grid grid-cols-7 gap-0.5",children:S.map((y,w)=>{if(!y)return h.jsx("span",{},w);let T=e.value&&m(new Date(e.value),y.date),x=m(f,y.date);return h.jsx("button",{type:"button",onClick:()=>u(y.date),onContextMenu:(E)=>{if(!e.onDayContextMenu)return;E.preventDefault(),e.onDayContextMenu(y.date.getTime(),t)},className:Y("flex h-7 items-center justify-center rounded-md text-xs hover:bg-[color:var(--fm-row-hover-bg)]",T&&"bg-[color:var(--fm-accent)] text-[color:var(--fm-accent-fg)] hover:bg-[color:var(--fm-accent)]",!T&&x&&"border border-[color:var(--fm-surface-border)]"),children:y.day},w)})})]})}let v=(C,g)=>{let I=e.value?new Date(e.value):new Date(new Date().setHours(0,0,0,0));I.setHours(C,g,0,0),e.onChange(I.getTime(),t)},b=e.withTime?h.jsxs("div",{className:"mt-2 flex items-center justify-center gap-1 border-t border-[color:var(--fm-surface-border)] pt-2",children:[h.jsx("input",{type:"number",min:0,max:23,value:String(l.hh).padStart(2,"0"),onChange:(C)=>{let g=Math.max(0,Math.min(23,Number(C.target.value)||0));c((I)=>({...I,hh:g})),v(g,l.mm)},className:"w-10 rounded-md border border-[color:var(--fm-surface-border)] bg-transparent px-1 py-0.5 text-center font-mono text-xs tabular-nums","aria-label":"Hours"}),h.jsx("span",{className:"text-[color:var(--fm-muted-fg)]",children:":"}),h.jsx("input",{type:"number",min:0,max:59,value:String(l.mm).padStart(2,"0"),onChange:(C)=>{let g=Math.max(0,Math.min(59,Number(C.target.value)||0));c((I)=>({...I,mm:g})),v(l.hh,g)},className:"w-10 rounded-md border border-[color:var(--fm-surface-border)] bg-transparent px-1 py-0.5 text-center font-mono text-xs tabular-nums","aria-label":"Minutes"})]}):null;return h.jsxs("div",{className:"px-2 py-2 text-sm",children:[d,p,b]})}function fz({spec:e,ctx:t}){let{items:a}=Jr(e.source,"",t),o=a,n=e.columns;return h.jsx("div",{className:"grid p-1",style:{gridTemplateColumns:`repeat(${n}, minmax(0, 1fr))`,gap:e.gap??2},children:o.map((s,i)=>h.jsx("button",{type:"button",onClick:()=>e.onSelect?.(s,t),onContextMenu:(l)=>{if(!e.onLongPress)return;l.preventDefault(),e.onLongPress(s,t)},className:"flex items-center justify-center rounded-md hover:bg-accent",style:{height:e.rowHeight},children:e.renderTile(s,t)},i))})}function mG({spec:e,ctx:t}){return h.jsx(fz,{spec:e,ctx:t})}function dG({spec:e,ctx:t}){let a=(o,n=0)=>{let s=e.getOperator(o);return h.jsxs("div",{className:Y("flex flex-col gap-1 rounded-md border border-border p-2",n>0&&"ml-4"),children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("select",{value:s,onChange:(i)=>e.onOperatorChange(o,i.target.value,t),className:"h-6 rounded-md border border-input bg-transparent px-1 text-xs",children:e.operatorOptions.map((i)=>h.jsx("option",{value:i.id,children:i.label},i.id))}),h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{type:"button",onClick:()=>e.onAddRule(o,t),className:"rounded-md px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-accent",children:"+ Rule"}),h.jsx("button",{type:"button",onClick:()=>e.onAddGroup(o,t),className:"rounded-md px-1.5 py-0.5 text-xs text-muted-foreground hover:bg-accent",children:"+ Group"})]})]}),h.jsx("div",{className:"flex flex-col gap-1",children:e.getChildren(o).map((i,l)=>i.kind==="rule"?h.jsx("div",{children:e.renderRule(i.data,t)},l):h.jsx("div",{children:a(i.data,n+1)},l))})]})};return h.jsx("div",{className:"p-2",children:a(e.root)})}function pG({spec:e}){return h.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-center text-sm text-muted-foreground",children:[e.icon&&h.jsx(Ve,{icon:e.icon,defaultSize:20}),e.title&&h.jsx("div",{className:"text-foreground",children:ce(e.title,void 0)}),e.message&&h.jsx("div",{children:ce(e.message,void 0)}),e.action&&h.jsx("button",{type:"button",onClick:(t)=>e.action.onClick(t),className:"mt-1 inline-flex h-7 items-center rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground hover:bg-primary/90",children:e.action.label})]})}function hG({spec:e}){return h.jsxs("div",{className:"flex items-center justify-center gap-2 px-3 py-3 text-xs text-muted-foreground",children:[h.jsx(Yc,{className:"size-3.5 animate-spin"}),e.message?ce(e.message,void 0):"Loading…"]})}function gG({spec:e,ctx:t}){return h.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/10 p-2 text-xs text-destructive",children:[h.jsx(nu,{className:"size-3.5 shrink-0"}),h.jsx("div",{className:"flex-1",children:ce(e.message,void 0)}),e.retry&&h.jsx("button",{type:"button",onClick:()=>e.retry.onClick(t),className:"rounded-md bg-destructive/10 px-1.5 py-0.5 text-destructive hover:bg-destructive/20",children:e.retry.label??"Retry"})]})}function IG({spec:e}){return h.jsxs("div",{className:"m-2 flex items-start gap-2 rounded-md border border-border bg-muted/30 p-2 text-xs",children:[e.icon&&h.jsx(Ve,{icon:e.icon,defaultSize:14}),h.jsxs("div",{className:"flex-1",children:[e.title&&h.jsx("div",{className:"font-medium",children:ce(e.title,void 0)}),e.message&&h.jsx("div",{className:"text-muted-foreground",children:ce(e.message,void 0)})]}),e.action&&h.jsx("button",{type:"button",onClick:(t)=>e.action.onClick(t),className:"rounded-md bg-primary px-1.5 py-0.5 text-primary-foreground",children:e.action.label})]})}function SG({spec:e}){return h.jsxs("div",{className:"m-2 flex gap-3 rounded-md border border-border p-2",children:[e.image&&h.jsx("img",{src:e.image,alt:"",className:"size-12 shrink-0 rounded object-cover"}),h.jsxs("div",{className:"flex-1",children:[e.title&&h.jsx("div",{className:"text-sm font-medium",children:e.title}),e.description&&h.jsx("div",{className:"text-xs text-muted-foreground",children:e.description}),h.jsx("div",{className:"text-[10px] text-muted-foreground",children:e.url})]})]})}function vG({spec:e,ctx:t}){return h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-1 pt-1",children:[h.jsx("div",{className:"flex items-center gap-0.5",role:"tablist",children:e.tabs.map((a)=>{let o=a.id===e.activeId;return h.jsxs("button",{type:"button",role:"tab","aria-selected":o,onClick:()=>e.onChange(a.id,t),className:Y("inline-flex items-center gap-1 rounded-t-md px-2 py-1 text-xs font-medium",o?"border-b-2 border-primary text-foreground":"text-muted-foreground"),children:[a.icon&&h.jsx(Ve,{icon:a.icon,defaultSize:12}),a.label]},a.id)})}),e.rightSlot]})}function yG({spec:e,ctx:t}){let a=(o)=>{let n=e.snaps;if(!n||n.length===0)return o;return n.reduce((s,i)=>Math.abs(i-o)<Math.abs(s-o)?i:s,n[0])};return h.jsxs("div",{className:"flex flex-col gap-1.5 px-3 py-2",children:[(e.label||e.showValue)&&h.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[h.jsx("span",{children:ce(e.label,void 0)}),e.showValue&&h.jsx("span",{className:"font-mono tabular-nums",children:e.value})]}),h.jsx("input",{type:"range",min:e.min,max:e.max,step:e.step??1,value:e.value,onChange:(o)=>e.onChange(Number(o.target.value),t),onPointerUp:(o)=>{let n=a(Number(o.target.value));if(n!==e.value)e.onChange(n,t)},className:"w-full accent-[color:var(--fm-accent)]","aria-label":typeof e.label==="string"?e.label:void 0})]})}function bG({spec:e,ctx:t}){let a=new Set(e.activeMarks??[]);return h.jsxs("div",{className:"flex items-center gap-0.5 border-b border-border px-1 py-1",children:[e.styleSwitcher&&h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",onClick:()=>e.styleSwitcher.onClick(t),className:"inline-flex h-6 items-center gap-1 rounded-md px-1.5 text-xs text-muted-foreground hover:bg-accent","aria-label":`Style: ${e.styleSwitcher.activeStyle}`,children:[h.jsx(Ve,{icon:e.styleSwitcher.icon,defaultSize:12}),h.jsx("span",{className:"font-medium",children:e.styleSwitcher.activeStyle})]}),h.jsx("span",{className:"mx-0.5 h-4 w-px bg-border","aria-hidden":!0})]}),e.buttons.map((o)=>{let n=o.mark?a.has(o.mark):!1;return h.jsx("button",{type:"button",onClick:()=>o.onClick(t),"aria-pressed":n||void 0,title:typeof o.tooltip?.text==="string"?o.tooltip.text:void 0,className:Y("inline-flex size-6 items-center justify-center rounded-md hover:bg-accent",n?"bg-accent text-foreground":"text-muted-foreground"),children:h.jsx(Ve,{icon:o.icon,defaultSize:14})},o.id)})]})}function CG({spec:e,ctx:t}){let a=R.useRef(t);a.current=t;let o=e.minRows??4,n=e.maxRows??16,s=Math.min(n,Math.max(o,(e.value?.split(`
14
- `).length??0)||o));return h.jsxs("div",{className:"px-2 py-2",children:[e.language&&h.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:e.language}),h.jsx("textarea",{value:e.value??"",placeholder:e.placeholder,rows:s,spellCheck:!1,onChange:(i)=>e.onChange(i.target.value,a.current),onKeyDown:(i)=>{if(e.onSave&&(i.metaKey||i.ctrlKey)&&i.key==="Enter")i.preventDefault(),e.onSave?.(i.target.value,a.current)},className:"w-full resize-none rounded-md border border-border bg-transparent p-2 font-mono text-xs leading-relaxed outline-none"})]})}function wG({spec:e}){let t=e.displayMode??!0;return h.jsxs("div",{className:"px-3 py-2",children:[h.jsx("div",{className:Y("rounded-md border border-border bg-muted/30 px-3 py-2 font-mono text-xs",t?"text-center":"inline-block"),"aria-label":"LaTeX expression",children:e.expression}),e.caption&&h.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground",children:e.caption})]})}function AG({spec:e}){let t=e.size??128,a=Array.from(e.value).reduce((o,n)=>(o+n.charCodeAt(0))%4096,0).toString(2).padStart(12,"0");return h.jsxs("div",{className:"flex flex-col items-center gap-2 px-3 py-3",children:[h.jsx("div",{role:"presentation",className:"grid place-items-center rounded-md border border-border bg-foreground/5",style:{width:t,height:t},children:h.jsx("div",{className:"grid grid-cols-6 gap-px font-mono text-[8px] text-muted-foreground",children:a.split("").map((o,n)=>h.jsx("span",{className:Y("size-3 rounded-sm",o==="1"?"bg-foreground":"bg-transparent")},n))})}),h.jsx("div",{className:"text-center text-[10px] uppercase tracking-wider text-muted-foreground",children:"Preview only — not scannable"}),h.jsx("code",{className:"max-w-full break-all text-center text-[10px] text-muted-foreground",children:e.value}),e.buttons&&h.jsx("div",{className:"flex items-center gap-1",children:e.buttons.map((o)=>h.jsxs("button",{type:"button",onClick:o.onClick,className:"inline-flex h-6 items-center rounded-md border border-border px-2 text-[11px] text-muted-foreground hover:bg-accent",children:[o.icon&&h.jsx(Ve,{icon:o.icon,defaultSize:10}),o.label]},o.id))})]})}function mz({body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i}){switch(e.kind){case"list":return h.jsx(lz,{body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i});case"grid":return h.jsx(ZP,{body:e,ctx:t,filter:a,onCloseRequest:o});case"form":return h.jsx(GP,{body:e,ctx:t});case"custom":return h.jsx(h.Fragment,{children:e.render(t)});case"composed":return h.jsx(TG,{body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n})}}function TG({body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i}){let l=e;return h.jsx("div",{className:"fm-composed flex flex-col",style:{gap:l.gap??0},children:l.sections.map((c)=>{let u=c.id;if(c.kind==="list"||c.kind==="grid"||c.kind==="form"||c.kind==="custom")return h.jsx("div",{children:h.jsx(mz,{body:c,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i})},u);return h.jsx("div",{children:h.jsx(rG,{spec:c,ctx:t})},u)})})}function xG(e,t,a,o){let n=e.config.storage?.key??e.config.id,s=e.config.storage?.adapter??a.storage,i=()=>{if(!s)return{};try{return s.get(n)??{}}catch{return{}}},l={id:e.id,data:e.param.data,storage:{get(c){return i()[c]},set(c,u){if(!s)return;let f={...i(),[c]:u};s.set(n,f)}},open:async(c,u)=>{let f=e.config.subMenus?.[c];if(f){let m=f.getData?.(void 0,l),d={...u,data:u?.data??m,parentId:e.id};t.open(f.menuId,d);return}t.open(c,{...u,parentId:e.id})},close:()=>t.close(e.id),closeAll:(c)=>t.closeAll(c),closeChildren:()=>t.closeChildren(e.id),navigateTo:(c,u)=>t.navigateTo(e.id,c,u??{}),back:()=>t.back(e.id),canGoBack:()=>t.canGoBack(e.id),update:(c)=>t.update(e.id,c),updateData:(c)=>t.updateData(e.id,c),position:o.position,setActive:o.setActive,setHover:o.setHover,updateOther:(c,u)=>t.updateData(c,u),isOpen:(c)=>t.isOpen(c)};return l}function MG({config:e,onChange:t}){let[a,o]=R.useState(""),n=R.useRef(null),s=R.useRef(void 0);R.useEffect(()=>{if(e.focusOnMount!==!1)n.current?.focus()},[e.focusOnMount]),R.useEffect(()=>()=>window.clearTimeout(s.current),[]);let i=(l)=>{o(l),window.clearTimeout(s.current),s.current=window.setTimeout(()=>{t(l),e.onChange?.(l)},e.debounceMs??250)};return h.jsxs("div",{className:"fm-filter flex items-center gap-2 border-b border-border px-3 py-2",children:[h.jsx("span",{className:"text-muted-foreground",children:e.icon?h.jsx(Ve,{icon:e.icon,defaultSize:14}):h.jsx(Nr,{className:"size-3.5"})}),h.jsx("input",{ref:n,value:a,placeholder:e.placeholder??"Search…",onChange:(l)=>i(l.target.value),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),a&&h.jsx("button",{type:"button",onClick:()=>i(""),"aria-label":"Clear",className:"text-muted-foreground hover:text-foreground",children:h.jsx(Ro,{className:"size-3.5"})})]})}function DG(e){return e?.strategy??"fixed"}function EG(e,t){if(!t)return e;if(!e){let o={};for(let n of Object.keys(t))if(t[n]!==void 0)o[n]=t[n];return o}let a={...e};for(let o of Object.keys(t))if(t[o]!==void 0)a[o]=t[o];return a}function LG(e){let t=e?.vertical??"bottom",a=e?.horizontal??"left",o=e?.stickToElementEdge;if(o){if(o==="top"||o==="bottom"){let l=e?.horizontal==="right"?"end":e?.horizontal==="center"?"center":"start";return l==="center"?o:`${o}-${l}`}let i=e?.vertical==="bottom"?"end":e?.vertical==="center"?"center":"start";return i==="center"?o:`${o}-${i}`}let n,s;if(t==="top"||t==="bottom")n=t==="top"?"top":"bottom",s=a==="left"?"start":a==="right"?"end":"center";else n=a==="left"?"left":"right",s="center";return s==="center"?n:`${n}-${s}`}function dz(e,t){if(typeof DOMRect<"u")return new DOMRect(e,t,0,0);return{x:e,y:t,width:0,height:0,top:t,bottom:t,left:e,right:e,toJSON(){return this}}}function RG(e,t){if(!(e?.fixedX!=null||e?.fixedY!=null))return t??null;let o=t==null?void 0:("getBoundingClientRect"in t)?t.getBoundingClientRect():t,n=e?.fixedX??o?.left??0,s=e?.fixedY??o?.top??0;return dz(n,s)}async function Wi(e,t,a){let o=RG(a,e)??e,n="getBoundingClientRect"in o?o:{getBoundingClientRect:()=>o,contextElement:void 0},s=typeof a?.offsetX==="function"?a.offsetX():a?.offsetX??0,i=typeof a?.offsetY==="function"?a.offsetY():a?.offsetY??0,l=a?.border?.top??8,c=a?.border?.bottom??8,u=a?.border?.left??8,f=a?.border?.right??8,m=[Xk({mainAxis:i,crossAxis:s}),!a?.noFlipX&&!a?.noFlipY?Qk({fallbackStrategy:"initialPlacement",padding:{top:l,bottom:c,left:u,right:f}}):void 0,jk({padding:{top:l,bottom:c,left:u,right:f},limiter:Yk({offset:16}),crossAxis:!a?.noBorderX||!a?.noBorderY}),a?.maxHeight||a?.fillViewport?Wk({padding:{top:l,bottom:c},apply({availableHeight:p,elements:v}){let b=a?.maxHeight??Number.POSITIVE_INFINITY;v.floating.style.maxHeight=`${Math.min(b,p)}px`}}):void 0].filter(Boolean),d=await Yi(n,t,{placement:LG(a),strategy:DG(a),middleware:m});return{x:d.x,y:d.y,placement:d.placement}}function pz(e,t,a,o){let n=!1,s=async()=>{let l=await Wi(e,t,a);if(!n)o(l)};if(a?.followAnchor===!1)return s(),()=>{n=!0};let i=Yu(e,t,s);return()=>{n=!0,i()}}function BG({triggerEl:e,triggerRect:t,floatingEl:a}){let[o,n]=R.useState(null),s=R.useRef(null);if(R.useLayoutEffect(()=>{if(!t||!a)return;let i=()=>{let c=e?.getBoundingClientRect()??t,u=a.getBoundingClientRect(),f=c,m=u.left>=f.right-4,d,p,v,b,C;if(m){d=f.right,p=Math.min(f.top,u.top),v=Math.max(0,u.left-f.right),b=Math.max(f.bottom,u.bottom)-p;let g=f.top-p,I=f.bottom-p,S=u.top-p,y=u.bottom-p;C=`polygon(0 ${g}px, 0 ${I}px, 100% ${y}px, 100% ${S}px)`}else{d=u.right,p=Math.min(f.top,u.top),v=Math.max(0,f.left-u.right),b=Math.max(f.bottom,u.bottom)-p;let g=f.top-p,I=f.bottom-p,S=u.top-p,y=u.bottom-p;C=`polygon(100% ${g}px, 100% ${I}px, 0 ${y}px, 0 ${S}px)`}n({left:d,top:p,width:v,height:b,clipPath:C})};i();let l=()=>{if(s.current)cancelAnimationFrame(s.current);s.current=requestAnimationFrame(i)};return window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{if(window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0),s.current)cancelAnimationFrame(s.current)}},[e,t,a]),!o||o.width<=0||o.height<=0)return null;return h.jsx("div",{"data-fm-safe-polygon":!0,"aria-hidden":!0,style:{position:"fixed",left:o.left,top:o.top,width:o.width,height:o.height,clipPath:o.clipPath,zIndex:"var(--fm-z-menu)",pointerEvents:"auto",background:"transparent"}})}function hz({open:e}){let t=Cz(),a=bz(),[o,n]=R.useState(null),s=R.useCallback((D)=>n(D),[]),[i,l]=R.useState(""),[c,u]=R.useState(null),[f,m]=R.useState(e.config.chrome?.tabs?.initialTab??e.config.chrome?.tabs?.tabs?.[0]?.id),d=R.useMemo(()=>xG(e,t,a,{setActive:()=>{},setHover:()=>{},position:()=>{}}),[e,t,a]),p=R.useCallback(()=>t.close(e.id),[t,e.id]),v=R.useMemo(()=>EG(e.config.position,e.param.position),[e.config.position,e.param.position]),b=e.param.element,C=e.param.rect;R.useEffect(()=>{let D=o;if(!D)return;let N=b??C,oe=v?.fixedX!=null||v?.fixedY!=null;if(!N&&!oe){let{offsetWidth:de,offsetHeight:Xe}=D;u({x:Math.max(8,(window.innerWidth-de)/2),y:Math.max(8,(window.innerHeight-Xe)/2)});return}let ne=typeof N==="string"?document.querySelector(N):N;if(!ne&&oe){let de=!1;return Wi(dz(v?.fixedX??0,v?.fixedY??0),D,v).then((Xe)=>{if(de)return;u({x:Xe.x,y:Xe.y,placement:Xe.placement})}),()=>{de=!0}}if(!ne)return;if(ne instanceof Element)return pz(ne,D,v,(de)=>u({x:de.x,y:de.y,placement:de.placement}));let ie=!1;return Wi(ne,D,v).then((de)=>{if(ie)return;u({x:de.x,y:de.y,placement:de.placement})}),()=>{ie=!0}},[o,v,b,C]),R.useEffect(()=>{let D=e.config.lifecycle?.onMount?.(d);e.config.lifecycle?.onOpen?.(d);let N=e.param.parentId;return()=>{if(typeof D==="function")D();if(e.config.lifecycle?.onClose?.(d),N)document.querySelector(`[data-fm-menu-id="${N}"] .fm-list`)?.focus({preventScroll:!0})}},[]),R.useEffect(()=>{if(e.config.chrome?.noClose)return;if(e.state==="closing")return;let D=(N)=>{if(N.key==="Escape")p()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[e.config.chrome?.noClose,e.state,p]);let g=e.config.chrome?.dimmer??(e.param.parentId?"none":"default"),I=g!=="none",S=g==="passThrough",y=g==="visible",w=e.config.chrome?.tabs,x=(w?w.tabs.find((D)=>D.id===f)?.body:void 0)??e.config.body,E=Boolean(e.param.parentId),L=h.jsxs(h.Fragment,{children:[E&&e.param.triggerRect&&h.jsx(BG,{triggerEl:e.param.element instanceof Element?e.param.element:void 0,triggerRect:e.param.triggerRect,floatingEl:o}),I&&h.jsx("div",{"aria-hidden":!0,"data-state":e.state,onClick:S?void 0:p,className:Y("fm-dimmer",e.state==="closing"&&"fm-dimmer--closing",S&&"fm-dimmer--passthrough",y&&"fm-dimmer--visible")}),h.jsxs("div",{ref:s,role:e.config.chrome?.role??"dialog","aria-label":NG(e),"data-fm-menu-id":e.id,"data-placement":c?.placement,"data-state":e.state,className:Y("fm-menu",e.state==="closing"&&"fm-menu--closing",e.config.chrome?.classNameWrap,e.config.chrome?.className),style:{position:v?.strategy==="absolute"?"absolute":"fixed",left:c?.x,top:c?.y,width:v?.width,minWidth:v?.minWidth??220,opacity:c==null?0:1,pointerEvents:c==null?"none":"auto",...HG(c?.placement)},children:[h.jsx(kG,{open:e,onClose:p,filter:i,setFilter:l,onBack:()=>t.back(e.id),canBack:Boolean(e.history?.length),ctx:d}),w&&h.jsx(UG,{tabs:w.tabs.map((D)=>({id:D.id,label:D.label,icon:D.icon})),activeId:f,onChange:m,rightSlot:typeof w.rightSlot==="function"?w.rightSlot():w.rightSlot}),e.config.chrome?.filter&&h.jsx(MG,{config:e.config.chrome.filter,onChange:l}),!OG(x,d)&&h.jsx("div",{className:"fm-body",children:h.jsx(mz,{body:x,ctx:d,filter:i,onCloseRequest:p,isSubMenu:Boolean(e.param.parentId),keyboard:e.config.keyboard,controlledActiveIndex:e.param.activeIndex})}),h.jsx(FG,{open:e,onClose:p})]})]});return Ku.createPortal(L,document.body)}function NG(e){if(e.param.ariaLabel!=null)return e.param.ariaLabel;let t=e.config.chrome?.title;if(typeof t==="string")return t;return e.config.chrome?.ariaLabel}function OG(e,t){if(e.kind!=="custom")return!1;let a=e.measureHeight;return typeof a==="function"&&a(t)===0}function HG(e){if(!e)return{};let[t,a]=e.split("-"),o,n;if(t==="top"||t==="bottom")n=t==="top"?"bottom":"top",o=a==="start"?"left":a==="end"?"right":"center";else o=t==="left"?"right":"left",n=a==="start"?"top":a==="end"?"bottom":"center";return{transformOrigin:`${o} ${n}`}}function kG({open:e,onClose:t,filter:a,setFilter:o,onBack:n,canBack:s,ctx:i}){let l=e.config.chrome,c=l?.header;if(c?.kind==="searchBar")return h.jsx(zG,{spec:c,value:a,onChange:o,onClose:t});if(c?.kind==="custom")return h.jsx(h.Fragment,{children:c.render(i)});let u=l?.withBack||s;if(l?.title||u||l?.withClose)return h.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[u&&h.jsx("button",{type:"button",onClick:l?.onBack??n,className:"text-muted-foreground hover:text-foreground","aria-label":"Back",children:h.jsx(_c,{className:"size-4"})}),h.jsx("h3",{className:"flex-1 text-sm font-medium",children:typeof l?.title==="function"?l.title(i):l?.title}),l?.withClose&&h.jsx("button",{type:"button",onClick:t,className:"text-muted-foreground hover:text-foreground","aria-label":"Close",children:h.jsx(Ro,{className:"size-4"})})]});return null}function zG({spec:e,value:t,onChange:a,onClose:o}){return h.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[h.jsx(Nr,{className:"size-3.5 text-muted-foreground"}),h.jsx("input",{value:t,onChange:(n)=>a(n.target.value),placeholder:e.placeholder??"Find",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e.counter&&h.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:"0 / 0"}),e.prevNext&&h.jsxs("div",{className:"flex items-center gap-0.5",children:[h.jsx("button",{type:"button","aria-label":"Previous",className:"rounded-md p-1 text-muted-foreground hover:bg-accent",children:h.jsx(Gc,{className:"size-3"})}),h.jsx("button",{type:"button","aria-label":"Next",className:"rounded-md p-1 text-muted-foreground hover:bg-accent",children:h.jsx(Uc,{className:"size-3"})})]}),h.jsx("button",{type:"button","aria-label":t?"Clear":"Close",onClick:()=>t?a(""):o(),className:"text-muted-foreground hover:text-foreground",children:h.jsx(Ro,{className:"size-3.5"})})]})}function UG({tabs:e,activeId:t,onChange:a,rightSlot:o}){return h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-1 pt-1",children:[h.jsx("div",{className:"flex items-center gap-0.5",role:"tablist",children:e.map((n)=>{let s=n.id===t;return h.jsx("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(n.id),className:Y("inline-flex items-center gap-1 rounded-t-md px-2 py-1 text-xs font-medium",s?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"),children:n.label},n.id)})}),o]})}function FG({open:e,onClose:t}){let a=e.config.chrome?.footer;if(!a)return null;if(a.kind==="buttons")return h.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-border px-2 py-2",children:a.buttons.map((o)=>h.jsx("button",{type:"button",disabled:o.disabled,onClick:(n)=>{if(o.onClick(n),o.id==="done"||o.id==="close")t()},className:Y("inline-flex h-7 items-center rounded-md px-2.5 text-xs font-medium",o.color==="destructive"?"bg-destructive text-destructive-foreground":o.color==="accent"?"bg-primary text-primary-foreground":"border border-border text-foreground hover:bg-accent"),children:o.label},o.id))});if(a.kind==="add")return h.jsx("footer",{className:"border-t border-border",children:h.jsx("button",{type:"button",onClick:a.onClick,className:"flex w-full items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:bg-accent",children:a.label})});if(a.kind==="custom")return h.jsx("footer",{className:"border-t border-border",children:a.render()});return null}function gz(){let e=yz();return h.jsx(h.Fragment,{children:e.map((t)=>h.jsx(hz,{open:t},t.id))})}var Iz=class{constructor(e="fm:"){this.prefix=e}prefix;get(e){if(typeof localStorage>"u")return;try{let t=localStorage.getItem(this.prefix+e);return t==null?void 0:JSON.parse(t)}catch{return}}set(e,t){if(typeof localStorage>"u")return;try{localStorage.setItem(this.prefix+e,JSON.stringify(t))}catch{}}remove(e){if(typeof localStorage>"u")return;try{localStorage.removeItem(this.prefix+e)}catch{}}};var Wu=120,_G=90,Sz=class{menus=[];listeners=new Set;registry=new Map;timers=new Map;register(e){this.registry.set(e.id,e)}registerMany(e){for(let t of e)this.register(t)}getConfig(e){return this.registry.get(e)}getAll(){return this.menus}getState(e){return this.menus.find((t)=>t.id===e)?.state??"closed"}isAnyTransitioning(){return this.menus.some((e)=>e.state!=="open")}isOpen(e){if(e==null)return this.menus.some((t)=>t.state!=="closing");return this.menus.some((t)=>t.id===e&&t.state!=="closing")}open(e,t={}){let a=this.registry.get(e);if(!a){console.warn(`[fancy-menus] No menu registered with id "${e}"`);return}let o=this.timers.get(`close:${e}`);if(o)window.clearTimeout(o),this.timers.delete(`close:${e}`);let n=this.menus.findIndex((l)=>l.id===e);if(n>=0){let l=this.menus[n],c={...l.param,...t};if((t.parentId??l.param.parentId)===l.param.parentId){let f=this.menus.slice();f[n]={...l,param:c,state:l.state==="closing"?"open":l.state},this.menus=f,this.emit();return}this.menus=this.menus.filter((f)=>f.id!==e)}let s=this.menus;if(t.parentId){let l=new Set;for(let c of s)if(c.param.parentId===t.parentId&&c.id!==e)l.add(c.id);if(l.size){let c=!0;while(c){c=!1;for(let u of s)if(u.param.parentId&&l.has(u.param.parentId)&&!l.has(u.id))l.add(u.id),c=!0}s=s.filter((u)=>!l.has(u.id));for(let u of l){let f=this.timers.get(`close:${u}`);if(f)window.clearTimeout(f),this.timers.delete(`close:${u}`)}}}this.menus=[...s,{id:e,config:a,param:t,depth:t.parentId?(s.find((l)=>l.id===t.parentId)?.depth??0)+1:s.length,state:"opening"}],this.emit();let i=window.setTimeout(()=>{this.timers.delete(`open:${e}`);let l=this.menus.findIndex((u)=>u.id===e);if(l<0)return;if(this.menus[l].state!=="opening")return;let c=this.menus.slice();c[l]={...c[l],state:"open"},this.menus=c,this.emit()},Wu);this.timers.set(`open:${e}`,i)}close(e){let t=e??this.menus.at(-1)?.id;if(!t)return;let a=new Set([t]),o=!0;while(o){o=!1;for(let i of this.menus)if(i.param.parentId&&a.has(i.param.parentId)&&!a.has(i.id))a.add(i.id),o=!0}let n=this.menus.slice(),s=!1;for(let i=0;i<n.length;i++){if(!a.has(n[i].id))continue;if(n[i].state==="closing")continue;n[i]={...n[i],state:"closing"},s=!0;let l=n[i].id,c=this.timers.get(`open:${l}`);if(c)window.clearTimeout(c),this.timers.delete(`open:${l}`);let u=window.setTimeout(()=>{this.timers.delete(`close:${l}`),this.menus=this.menus.filter((f)=>f.id!==l),this.emit()},_G);this.timers.set(`close:${l}`,u)}if(!s)return;this.menus=n,this.emit()}closeChildren(e){let t=new Set,a=!0;while(a){a=!1;for(let o of this.menus){let n=o.param.parentId===e,s=o.param.parentId&&t.has(o.param.parentId);if((n||s)&&!t.has(o.id))t.add(o.id),a=!0}}if(t.size===0)return;for(let o of t)this.close(o)}closeAll(e){let t=e==null?this.menus.map((a)=>a.id):this.menus.filter((a)=>a.config.group===e).map((a)=>a.id);for(let a of t)this.close(a)}navigateTo(e,t,a={}){let o=this.menus.findIndex((f)=>f.id===e);if(o<0)return;let n=this.registry.get(t);if(!n){console.warn(`[fancy-menus] No menu registered with id "${t}"`);return}let s=this.menus[o],i=[...s.history??[],{id:s.id,config:s.config,param:s.param}],l=this.menus.slice();l[o]={id:t,config:n,param:{...s.param,...a,parentId:s.param.parentId},depth:s.depth,state:"opening",history:i},this.menus=l,this.emit();let c=this.timers.get(`open:${t}`);if(c)window.clearTimeout(c);let u=window.setTimeout(()=>{this.timers.delete(`open:${t}`);let f=this.menus.findIndex((d)=>d.id===t);if(f<0)return;if(this.menus[f].state!=="opening")return;let m=this.menus.slice();m[f]={...m[f],state:"open"},this.menus=m,this.emit()},Wu);this.timers.set(`open:${t}`,u)}canGoBack(e){let t=this.menus.find((a)=>a.id===e);return Boolean(t?.history&&t.history.length>0)}back(e){let t=this.menus.findIndex((u)=>u.id===e);if(t<0)return;let a=this.menus[t],o=a.history??[];if(o.length===0)return;let n=o[o.length-1],s=o.slice(0,-1),i=this.menus.slice();i[t]={id:n.id,config:n.config,param:n.param,depth:a.depth,state:"opening",history:s.length?s:void 0},this.menus=i,this.emit();let l=this.timers.get(`open:${n.id}`);if(l)window.clearTimeout(l);let c=window.setTimeout(()=>{this.timers.delete(`open:${n.id}`);let u=this.menus.findIndex((m)=>m.id===n.id);if(u<0)return;if(this.menus[u].state!=="opening")return;let f=this.menus.slice();f[u]={...f[u],state:"open"},this.menus=f,this.emit()},Wu);this.timers.set(`open:${n.id}`,c)}update(e,t){let a=this.menus.findIndex((n)=>n.id===e);if(a<0)return;let o=this.menus.slice();o[a]={...o[a],param:{...o[a].param,...t}},this.menus=o,this.emit()}updateData(e,t){let a=this.menus.findIndex((s)=>s.id===e);if(a<0)return;let o=this.menus.slice(),n=o[a];o[a]={...n,param:{...n.param,data:{...n.param.data??{},...t}}},this.menus=o,this.emit()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}dispose(){for(let e of this.timers.values())window.clearTimeout(e);this.timers.clear(),this.listeners.clear()}emit(){for(let e of this.listeners)e()}},vz=R.createContext(null);function $u({menus:e,options:t,store:a,children:o}){let n=R.useRef(null);if(n.current==null)n.current=a??new Sz;let s=n.current;R.useEffect(()=>{if(e?.length)s.registerMany([...e])},[e,s]);let i=R.useMemo(()=>({storage:t?.storage??new Iz,...t}),[t]),l=R.useMemo(()=>({store:s,options:i}),[s,i]);return h.jsxs(vz.Provider,{value:l,children:[o,h.jsx(gz,{})]})}function Ki(){let e=R.useContext(vz);if(!e)throw Error("useMenu / useMenuStore must be used inside <MenuProvider>");return e}function ef(){let{store:e}=Ki();return R.useMemo(()=>({open:(t,a)=>e.open(t,a??{}),close:(t)=>e.close(t),closeAll:(t)=>e.closeAll(t),update:(t,a)=>e.update(t,a),updateData:(t,a)=>e.updateData(t,a),isOpen:(t)=>e.isOpen(t),register:(t)=>e.register(t)}),[e])}function yz(){let{store:e}=Ki();return R.useSyncExternalStore((t)=>e.subscribe(t),()=>e.getAll(),()=>e.getAll())}function bz(){return Ki().options}function Cz(){return Ki().store}var Tc=O(U(),1),Z7=O(q7(),1),ai=O(Mi(),1),dZ={},pZ=(e)=>dZ[e]??=()=>ai.jsx("span",{className:"fm-ico",dangerouslySetInnerHTML:{__html:window.icon?.(e,16)??""}}),hZ=(e)=>e?pZ(e):void 0,gZ=(e)=>[{kind:bn.Section,match:(t)=>!!t.section,name:(t)=>t.section},{kind:bn.Divider,match:(t)=>!!t.divider},{kind:bn.Item,name:(t)=>t.label,caption:(t)=>t.caption,icon:(t)=>{let a=hZ(t.icon);return a?{icon:a,size:16,...t.danger?{color:"var(--bad)"}:{}}:void 0},pressed:(t)=>!!t.pressed,disabled:(t)=>!!t.disabled,arrow:(t)=>!!t.children?.length,className:(t)=>t.danger?"fm-row--danger":void 0,subMenuId:(t)=>t.children?.length?`swarm-actions-${e+1}`:void 0,subMenuTrigger:ci.ArrowClick,subMenuData:(t)=>({items:t.children??[]}),onClick:async(t,a,o)=>{if(t.children?.length)return;if(await t.run?.(),!o.data.stay)o.closeAll("swarm")}}],IZ=[0,1,2].map((e)=>Ec({id:`swarm-actions-${e}`,kind:si.Menu,group:"swarm",position:{minWidth:200,maxWidth:320},chrome:{role:"menu"},body:{kind:ii.List,source:{kind:li.Prop,getItems:(t)=>t?.items??[]},rows:gZ(e)},keyboard:{defaults:{closeOnEscape:!0,selectOnEnter:!0,arrowsToSubmenu:!0}}}));function SZ(){let e=ef();return Tc.useEffect(()=>{let t=(a,o)=>{e.closeAll("swarm");let s={rect:a instanceof Element?a.getBoundingClientRect():new DOMRect(a.x,a.y,0,0),data:o};e.open("swarm-actions-0",s)};window.menus={open:t,close:()=>e.closeAll("swarm"),isOpen:()=>e.isOpen()},window.dispatchEvent(new Event("menus:ready"))},[e]),null}var kd=document.createElement("div");kd.id="menus-root";document.body.appendChild(kd);Z7.createRoot(kd).render(ai.jsx(Tc.StrictMode,{children:ai.jsx($u,{menus:IZ,children:ai.jsx(SZ,{})})}));})();
14
+ `).length??0)||o));return h.jsxs("div",{className:"px-2 py-2",children:[e.language&&h.jsx("div",{className:"mb-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:e.language}),h.jsx("textarea",{value:e.value??"",placeholder:e.placeholder,rows:s,spellCheck:!1,onChange:(i)=>e.onChange(i.target.value,a.current),onKeyDown:(i)=>{if(e.onSave&&(i.metaKey||i.ctrlKey)&&i.key==="Enter")i.preventDefault(),e.onSave?.(i.target.value,a.current)},className:"w-full resize-none rounded-md border border-border bg-transparent p-2 font-mono text-xs leading-relaxed outline-none"})]})}function wG({spec:e}){let t=e.displayMode??!0;return h.jsxs("div",{className:"px-3 py-2",children:[h.jsx("div",{className:Y("rounded-md border border-border bg-muted/30 px-3 py-2 font-mono text-xs",t?"text-center":"inline-block"),"aria-label":"LaTeX expression",children:e.expression}),e.caption&&h.jsx("div",{className:"mt-1 text-[10px] text-muted-foreground",children:e.caption})]})}function AG({spec:e}){let t=e.size??128,a=Array.from(e.value).reduce((o,n)=>(o+n.charCodeAt(0))%4096,0).toString(2).padStart(12,"0");return h.jsxs("div",{className:"flex flex-col items-center gap-2 px-3 py-3",children:[h.jsx("div",{role:"presentation",className:"grid place-items-center rounded-md border border-border bg-foreground/5",style:{width:t,height:t},children:h.jsx("div",{className:"grid grid-cols-6 gap-px font-mono text-[8px] text-muted-foreground",children:a.split("").map((o,n)=>h.jsx("span",{className:Y("size-3 rounded-sm",o==="1"?"bg-foreground":"bg-transparent")},n))})}),h.jsx("div",{className:"text-center text-[10px] uppercase tracking-wider text-muted-foreground",children:"Preview only — not scannable"}),h.jsx("code",{className:"max-w-full break-all text-center text-[10px] text-muted-foreground",children:e.value}),e.buttons&&h.jsx("div",{className:"flex items-center gap-1",children:e.buttons.map((o)=>h.jsxs("button",{type:"button",onClick:o.onClick,className:"inline-flex h-6 items-center rounded-md border border-border px-2 text-[11px] text-muted-foreground hover:bg-accent",children:[o.icon&&h.jsx(Ve,{icon:o.icon,defaultSize:10}),o.label]},o.id))})]})}function mz({body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i}){switch(e.kind){case"list":return h.jsx(lz,{body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i});case"grid":return h.jsx(ZP,{body:e,ctx:t,filter:a,onCloseRequest:o});case"form":return h.jsx(GP,{body:e,ctx:t});case"custom":return h.jsx(h.Fragment,{children:e.render(t)});case"composed":return h.jsx(TG,{body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n})}}function TG({body:e,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i}){let l=e;return h.jsx("div",{className:"fm-composed flex flex-col",style:{gap:l.gap??0},children:l.sections.map((c)=>{let u=c.id;if(c.kind==="list"||c.kind==="grid"||c.kind==="form"||c.kind==="custom")return h.jsx("div",{children:h.jsx(mz,{body:c,ctx:t,filter:a,onCloseRequest:o,isSubMenu:n,keyboard:s,controlledActiveIndex:i})},u);return h.jsx("div",{children:h.jsx(rG,{spec:c,ctx:t})},u)})})}function xG(e,t,a,o){let n=e.config.storage?.key??e.config.id,s=e.config.storage?.adapter??a.storage,i=()=>{if(!s)return{};try{return s.get(n)??{}}catch{return{}}},l={id:e.id,data:e.param.data,storage:{get(c){return i()[c]},set(c,u){if(!s)return;let f={...i(),[c]:u};s.set(n,f)}},open:async(c,u)=>{let f=e.config.subMenus?.[c];if(f){let m=f.getData?.(void 0,l),d={...u,data:u?.data??m,parentId:e.id};t.open(f.menuId,d);return}t.open(c,{...u,parentId:e.id})},close:()=>t.close(e.id),closeAll:(c)=>t.closeAll(c),closeChildren:()=>t.closeChildren(e.id),navigateTo:(c,u)=>t.navigateTo(e.id,c,u??{}),back:()=>t.back(e.id),canGoBack:()=>t.canGoBack(e.id),update:(c)=>t.update(e.id,c),updateData:(c)=>t.updateData(e.id,c),position:o.position,setActive:o.setActive,setHover:o.setHover,updateOther:(c,u)=>t.updateData(c,u),isOpen:(c)=>t.isOpen(c)};return l}function MG({config:e,onChange:t}){let[a,o]=R.useState(""),n=R.useRef(null),s=R.useRef(void 0);R.useEffect(()=>{if(e.focusOnMount!==!1)n.current?.focus()},[e.focusOnMount]),R.useEffect(()=>()=>window.clearTimeout(s.current),[]);let i=(l)=>{o(l),window.clearTimeout(s.current),s.current=window.setTimeout(()=>{t(l),e.onChange?.(l)},e.debounceMs??250)};return h.jsxs("div",{className:"fm-filter flex items-center gap-2 border-b border-border px-3 py-2",children:[h.jsx("span",{className:"text-muted-foreground",children:e.icon?h.jsx(Ve,{icon:e.icon,defaultSize:14}):h.jsx(Nr,{className:"size-3.5"})}),h.jsx("input",{ref:n,value:a,placeholder:e.placeholder??"Search…",onChange:(l)=>i(l.target.value),className:"w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),a&&h.jsx("button",{type:"button",onClick:()=>i(""),"aria-label":"Clear",className:"text-muted-foreground hover:text-foreground",children:h.jsx(Ro,{className:"size-3.5"})})]})}function DG(e){return e?.strategy??"fixed"}function EG(e,t){if(!t)return e;if(!e){let o={};for(let n of Object.keys(t))if(t[n]!==void 0)o[n]=t[n];return o}let a={...e};for(let o of Object.keys(t))if(t[o]!==void 0)a[o]=t[o];return a}function LG(e){let t=e?.vertical??"bottom",a=e?.horizontal??"left",o=e?.stickToElementEdge;if(o){if(o==="top"||o==="bottom"){let l=e?.horizontal==="right"?"end":e?.horizontal==="center"?"center":"start";return l==="center"?o:`${o}-${l}`}let i=e?.vertical==="bottom"?"end":e?.vertical==="center"?"center":"start";return i==="center"?o:`${o}-${i}`}let n,s;if(t==="top"||t==="bottom")n=t==="top"?"top":"bottom",s=a==="left"?"start":a==="right"?"end":"center";else n=a==="left"?"left":"right",s="center";return s==="center"?n:`${n}-${s}`}function dz(e,t){if(typeof DOMRect<"u")return new DOMRect(e,t,0,0);return{x:e,y:t,width:0,height:0,top:t,bottom:t,left:e,right:e,toJSON(){return this}}}function RG(e,t){if(!(e?.fixedX!=null||e?.fixedY!=null))return t??null;let o=t==null?void 0:("getBoundingClientRect"in t)?t.getBoundingClientRect():t,n=e?.fixedX??o?.left??0,s=e?.fixedY??o?.top??0;return dz(n,s)}async function Wi(e,t,a){let o=RG(a,e)??e,n="getBoundingClientRect"in o?o:{getBoundingClientRect:()=>o,contextElement:void 0},s=typeof a?.offsetX==="function"?a.offsetX():a?.offsetX??0,i=typeof a?.offsetY==="function"?a.offsetY():a?.offsetY??0,l=a?.border?.top??8,c=a?.border?.bottom??8,u=a?.border?.left??8,f=a?.border?.right??8,m=[Xk({mainAxis:i,crossAxis:s}),!a?.noFlipX&&!a?.noFlipY?Qk({fallbackStrategy:"initialPlacement",padding:{top:l,bottom:c,left:u,right:f}}):void 0,jk({padding:{top:l,bottom:c,left:u,right:f},limiter:Yk({offset:16}),crossAxis:!a?.noBorderX||!a?.noBorderY}),a?.maxHeight||a?.fillViewport?Wk({padding:{top:l,bottom:c},apply({availableHeight:p,elements:v}){let b=a?.maxHeight??Number.POSITIVE_INFINITY;v.floating.style.maxHeight=`${Math.min(b,p)}px`}}):void 0].filter(Boolean),d=await Yi(n,t,{placement:LG(a),strategy:DG(a),middleware:m});return{x:d.x,y:d.y,placement:d.placement}}function pz(e,t,a,o){let n=!1,s=async()=>{let l=await Wi(e,t,a);if(!n)o(l)};if(a?.followAnchor===!1)return s(),()=>{n=!0};let i=Yu(e,t,s);return()=>{n=!0,i()}}function BG({triggerEl:e,triggerRect:t,floatingEl:a}){let[o,n]=R.useState(null),s=R.useRef(null);if(R.useLayoutEffect(()=>{if(!t||!a)return;let i=()=>{let c=e?.getBoundingClientRect()??t,u=a.getBoundingClientRect(),f=c,m=u.left>=f.right-4,d,p,v,b,C;if(m){d=f.right,p=Math.min(f.top,u.top),v=Math.max(0,u.left-f.right),b=Math.max(f.bottom,u.bottom)-p;let g=f.top-p,I=f.bottom-p,S=u.top-p,y=u.bottom-p;C=`polygon(0 ${g}px, 0 ${I}px, 100% ${y}px, 100% ${S}px)`}else{d=u.right,p=Math.min(f.top,u.top),v=Math.max(0,f.left-u.right),b=Math.max(f.bottom,u.bottom)-p;let g=f.top-p,I=f.bottom-p,S=u.top-p,y=u.bottom-p;C=`polygon(100% ${g}px, 100% ${I}px, 0 ${y}px, 0 ${S}px)`}n({left:d,top:p,width:v,height:b,clipPath:C})};i();let l=()=>{if(s.current)cancelAnimationFrame(s.current);s.current=requestAnimationFrame(i)};return window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{if(window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0),s.current)cancelAnimationFrame(s.current)}},[e,t,a]),!o||o.width<=0||o.height<=0)return null;return h.jsx("div",{"data-fm-safe-polygon":!0,"aria-hidden":!0,style:{position:"fixed",left:o.left,top:o.top,width:o.width,height:o.height,clipPath:o.clipPath,zIndex:"var(--fm-z-menu)",pointerEvents:"auto",background:"transparent"}})}function hz({open:e}){let t=Cz(),a=bz(),[o,n]=R.useState(null),s=R.useCallback((D)=>n(D),[]),[i,l]=R.useState(""),[c,u]=R.useState(null),[f,m]=R.useState(e.config.chrome?.tabs?.initialTab??e.config.chrome?.tabs?.tabs?.[0]?.id),d=R.useMemo(()=>xG(e,t,a,{setActive:()=>{},setHover:()=>{},position:()=>{}}),[e,t,a]),p=R.useCallback(()=>t.close(e.id),[t,e.id]),v=R.useMemo(()=>EG(e.config.position,e.param.position),[e.config.position,e.param.position]),b=e.param.element,C=e.param.rect;R.useEffect(()=>{let D=o;if(!D)return;let N=b??C,oe=v?.fixedX!=null||v?.fixedY!=null;if(!N&&!oe){let{offsetWidth:de,offsetHeight:Xe}=D;u({x:Math.max(8,(window.innerWidth-de)/2),y:Math.max(8,(window.innerHeight-Xe)/2)});return}let ne=typeof N==="string"?document.querySelector(N):N;if(!ne&&oe){let de=!1;return Wi(dz(v?.fixedX??0,v?.fixedY??0),D,v).then((Xe)=>{if(de)return;u({x:Xe.x,y:Xe.y,placement:Xe.placement})}),()=>{de=!0}}if(!ne)return;if(ne instanceof Element)return pz(ne,D,v,(de)=>u({x:de.x,y:de.y,placement:de.placement}));let ie=!1;return Wi(ne,D,v).then((de)=>{if(ie)return;u({x:de.x,y:de.y,placement:de.placement})}),()=>{ie=!0}},[o,v,b,C]),R.useEffect(()=>{let D=e.config.lifecycle?.onMount?.(d);e.config.lifecycle?.onOpen?.(d);let N=e.param.parentId;return()=>{if(typeof D==="function")D();if(e.config.lifecycle?.onClose?.(d),N)document.querySelector(`[data-fm-menu-id="${N}"] .fm-list`)?.focus({preventScroll:!0})}},[]),R.useEffect(()=>{if(e.config.chrome?.noClose)return;if(e.state==="closing")return;let D=(N)=>{if(N.key==="Escape")p()};return window.addEventListener("keydown",D),()=>window.removeEventListener("keydown",D)},[e.config.chrome?.noClose,e.state,p]);let g=e.config.chrome?.dimmer??(e.param.parentId?"none":"default"),I=g!=="none",S=g==="passThrough",y=g==="visible",w=e.config.chrome?.tabs,x=(w?w.tabs.find((D)=>D.id===f)?.body:void 0)??e.config.body,E=Boolean(e.param.parentId),L=h.jsxs(h.Fragment,{children:[E&&e.param.triggerRect&&h.jsx(BG,{triggerEl:e.param.element instanceof Element?e.param.element:void 0,triggerRect:e.param.triggerRect,floatingEl:o}),I&&h.jsx("div",{"aria-hidden":!0,"data-state":e.state,onClick:S?void 0:p,className:Y("fm-dimmer",e.state==="closing"&&"fm-dimmer--closing",S&&"fm-dimmer--passthrough",y&&"fm-dimmer--visible")}),h.jsxs("div",{ref:s,role:e.config.chrome?.role??"dialog","aria-label":NG(e),"data-fm-menu-id":e.id,"data-placement":c?.placement,"data-state":e.state,className:Y("fm-menu",e.state==="closing"&&"fm-menu--closing",e.config.chrome?.classNameWrap,e.config.chrome?.className),style:{position:v?.strategy==="absolute"?"absolute":"fixed",left:c?.x,top:c?.y,width:v?.width,minWidth:v?.minWidth??220,opacity:c==null?0:1,pointerEvents:c==null?"none":"auto",...HG(c?.placement)},children:[h.jsx(kG,{open:e,onClose:p,filter:i,setFilter:l,onBack:()=>t.back(e.id),canBack:Boolean(e.history?.length),ctx:d}),w&&h.jsx(UG,{tabs:w.tabs.map((D)=>({id:D.id,label:D.label,icon:D.icon})),activeId:f,onChange:m,rightSlot:typeof w.rightSlot==="function"?w.rightSlot():w.rightSlot}),e.config.chrome?.filter&&h.jsx(MG,{config:e.config.chrome.filter,onChange:l}),!OG(x,d)&&h.jsx("div",{className:"fm-body",children:h.jsx(mz,{body:x,ctx:d,filter:i,onCloseRequest:p,isSubMenu:Boolean(e.param.parentId),keyboard:e.config.keyboard,controlledActiveIndex:e.param.activeIndex})}),h.jsx(FG,{open:e,onClose:p})]})]});return Ku.createPortal(L,document.body)}function NG(e){if(e.param.ariaLabel!=null)return e.param.ariaLabel;let t=e.config.chrome?.title;if(typeof t==="string")return t;return e.config.chrome?.ariaLabel}function OG(e,t){if(e.kind!=="custom")return!1;let a=e.measureHeight;return typeof a==="function"&&a(t)===0}function HG(e){if(!e)return{};let[t,a]=e.split("-"),o,n;if(t==="top"||t==="bottom")n=t==="top"?"bottom":"top",o=a==="start"?"left":a==="end"?"right":"center";else o=t==="left"?"right":"left",n=a==="start"?"top":a==="end"?"bottom":"center";return{transformOrigin:`${o} ${n}`}}function kG({open:e,onClose:t,filter:a,setFilter:o,onBack:n,canBack:s,ctx:i}){let l=e.config.chrome,c=l?.header;if(c?.kind==="searchBar")return h.jsx(zG,{spec:c,value:a,onChange:o,onClose:t});if(c?.kind==="custom")return h.jsx(h.Fragment,{children:c.render(i)});let u=l?.withBack||s;if(l?.title||u||l?.withClose)return h.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[u&&h.jsx("button",{type:"button",onClick:l?.onBack??n,className:"text-muted-foreground hover:text-foreground","aria-label":"Back",children:h.jsx(_c,{className:"size-4"})}),h.jsx("h3",{className:"flex-1 text-sm font-medium",children:typeof l?.title==="function"?l.title(i):l?.title}),l?.withClose&&h.jsx("button",{type:"button",onClick:t,className:"text-muted-foreground hover:text-foreground","aria-label":"Close",children:h.jsx(Ro,{className:"size-4"})})]});return null}function zG({spec:e,value:t,onChange:a,onClose:o}){return h.jsxs("header",{className:"flex items-center gap-2 border-b border-border px-3 py-2",children:[h.jsx(Nr,{className:"size-3.5 text-muted-foreground"}),h.jsx("input",{value:t,onChange:(n)=>a(n.target.value),placeholder:e.placeholder??"Find",className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"}),e.counter&&h.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:"0 / 0"}),e.prevNext&&h.jsxs("div",{className:"flex items-center gap-0.5",children:[h.jsx("button",{type:"button","aria-label":"Previous",className:"rounded-md p-1 text-muted-foreground hover:bg-accent",children:h.jsx(Gc,{className:"size-3"})}),h.jsx("button",{type:"button","aria-label":"Next",className:"rounded-md p-1 text-muted-foreground hover:bg-accent",children:h.jsx(Uc,{className:"size-3"})})]}),h.jsx("button",{type:"button","aria-label":t?"Clear":"Close",onClick:()=>t?a(""):o(),className:"text-muted-foreground hover:text-foreground",children:h.jsx(Ro,{className:"size-3.5"})})]})}function UG({tabs:e,activeId:t,onChange:a,rightSlot:o}){return h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-1 pt-1",children:[h.jsx("div",{className:"flex items-center gap-0.5",role:"tablist",children:e.map((n)=>{let s=n.id===t;return h.jsx("button",{type:"button",role:"tab","aria-selected":s,onClick:()=>a(n.id),className:Y("inline-flex items-center gap-1 rounded-t-md px-2 py-1 text-xs font-medium",s?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"),children:n.label},n.id)})}),o]})}function FG({open:e,onClose:t}){let a=e.config.chrome?.footer;if(!a)return null;if(a.kind==="buttons")return h.jsx("footer",{className:"flex items-center justify-end gap-2 border-t border-border px-2 py-2",children:a.buttons.map((o)=>h.jsx("button",{type:"button",disabled:o.disabled,onClick:(n)=>{if(o.onClick(n),o.id==="done"||o.id==="close")t()},className:Y("inline-flex h-7 items-center rounded-md px-2.5 text-xs font-medium",o.color==="destructive"?"bg-destructive text-destructive-foreground":o.color==="accent"?"bg-primary text-primary-foreground":"border border-border text-foreground hover:bg-accent"),children:o.label},o.id))});if(a.kind==="add")return h.jsx("footer",{className:"border-t border-border",children:h.jsx("button",{type:"button",onClick:a.onClick,className:"flex w-full items-center gap-2 px-3 py-2 text-sm text-muted-foreground hover:bg-accent",children:a.label})});if(a.kind==="custom")return h.jsx("footer",{className:"border-t border-border",children:a.render()});return null}function gz(){let e=yz();return h.jsx(h.Fragment,{children:e.map((t)=>h.jsx(hz,{open:t},t.id))})}var Iz=class{constructor(e="fm:"){this.prefix=e}prefix;get(e){if(typeof localStorage>"u")return;try{let t=localStorage.getItem(this.prefix+e);return t==null?void 0:JSON.parse(t)}catch{return}}set(e,t){if(typeof localStorage>"u")return;try{localStorage.setItem(this.prefix+e,JSON.stringify(t))}catch{}}remove(e){if(typeof localStorage>"u")return;try{localStorage.removeItem(this.prefix+e)}catch{}}};var Wu=120,_G=90,Sz=class{menus=[];listeners=new Set;registry=new Map;timers=new Map;register(e){this.registry.set(e.id,e)}registerMany(e){for(let t of e)this.register(t)}getConfig(e){return this.registry.get(e)}getAll(){return this.menus}getState(e){return this.menus.find((t)=>t.id===e)?.state??"closed"}isAnyTransitioning(){return this.menus.some((e)=>e.state!=="open")}isOpen(e){if(e==null)return this.menus.some((t)=>t.state!=="closing");return this.menus.some((t)=>t.id===e&&t.state!=="closing")}open(e,t={}){let a=this.registry.get(e);if(!a){console.warn(`[fancy-menus] No menu registered with id "${e}"`);return}let o=this.timers.get(`close:${e}`);if(o)window.clearTimeout(o),this.timers.delete(`close:${e}`);let n=this.menus.findIndex((l)=>l.id===e);if(n>=0){let l=this.menus[n],c={...l.param,...t};if((t.parentId??l.param.parentId)===l.param.parentId){let f=this.menus.slice();f[n]={...l,param:c,state:l.state==="closing"?"open":l.state},this.menus=f,this.emit();return}this.menus=this.menus.filter((f)=>f.id!==e)}let s=this.menus;if(t.parentId){let l=new Set;for(let c of s)if(c.param.parentId===t.parentId&&c.id!==e)l.add(c.id);if(l.size){let c=!0;while(c){c=!1;for(let u of s)if(u.param.parentId&&l.has(u.param.parentId)&&!l.has(u.id))l.add(u.id),c=!0}s=s.filter((u)=>!l.has(u.id));for(let u of l){let f=this.timers.get(`close:${u}`);if(f)window.clearTimeout(f),this.timers.delete(`close:${u}`)}}}this.menus=[...s,{id:e,config:a,param:t,depth:t.parentId?(s.find((l)=>l.id===t.parentId)?.depth??0)+1:s.length,state:"opening"}],this.emit();let i=window.setTimeout(()=>{this.timers.delete(`open:${e}`);let l=this.menus.findIndex((u)=>u.id===e);if(l<0)return;if(this.menus[l].state!=="opening")return;let c=this.menus.slice();c[l]={...c[l],state:"open"},this.menus=c,this.emit()},Wu);this.timers.set(`open:${e}`,i)}close(e){let t=e??this.menus.at(-1)?.id;if(!t)return;let a=new Set([t]),o=!0;while(o){o=!1;for(let i of this.menus)if(i.param.parentId&&a.has(i.param.parentId)&&!a.has(i.id))a.add(i.id),o=!0}let n=this.menus.slice(),s=!1;for(let i=0;i<n.length;i++){if(!a.has(n[i].id))continue;if(n[i].state==="closing")continue;n[i]={...n[i],state:"closing"},s=!0;let l=n[i].id,c=this.timers.get(`open:${l}`);if(c)window.clearTimeout(c),this.timers.delete(`open:${l}`);let u=window.setTimeout(()=>{this.timers.delete(`close:${l}`),this.menus=this.menus.filter((f)=>f.id!==l),this.emit()},_G);this.timers.set(`close:${l}`,u)}if(!s)return;this.menus=n,this.emit()}closeChildren(e){let t=new Set,a=!0;while(a){a=!1;for(let o of this.menus){let n=o.param.parentId===e,s=o.param.parentId&&t.has(o.param.parentId);if((n||s)&&!t.has(o.id))t.add(o.id),a=!0}}if(t.size===0)return;for(let o of t)this.close(o)}closeAll(e){let t=e==null?this.menus.map((a)=>a.id):this.menus.filter((a)=>a.config.group===e).map((a)=>a.id);for(let a of t)this.close(a)}navigateTo(e,t,a={}){let o=this.menus.findIndex((f)=>f.id===e);if(o<0)return;let n=this.registry.get(t);if(!n){console.warn(`[fancy-menus] No menu registered with id "${t}"`);return}let s=this.menus[o],i=[...s.history??[],{id:s.id,config:s.config,param:s.param}],l=this.menus.slice();l[o]={id:t,config:n,param:{...s.param,...a,parentId:s.param.parentId},depth:s.depth,state:"opening",history:i},this.menus=l,this.emit();let c=this.timers.get(`open:${t}`);if(c)window.clearTimeout(c);let u=window.setTimeout(()=>{this.timers.delete(`open:${t}`);let f=this.menus.findIndex((d)=>d.id===t);if(f<0)return;if(this.menus[f].state!=="opening")return;let m=this.menus.slice();m[f]={...m[f],state:"open"},this.menus=m,this.emit()},Wu);this.timers.set(`open:${t}`,u)}canGoBack(e){let t=this.menus.find((a)=>a.id===e);return Boolean(t?.history&&t.history.length>0)}back(e){let t=this.menus.findIndex((u)=>u.id===e);if(t<0)return;let a=this.menus[t],o=a.history??[];if(o.length===0)return;let n=o[o.length-1],s=o.slice(0,-1),i=this.menus.slice();i[t]={id:n.id,config:n.config,param:n.param,depth:a.depth,state:"opening",history:s.length?s:void 0},this.menus=i,this.emit();let l=this.timers.get(`open:${n.id}`);if(l)window.clearTimeout(l);let c=window.setTimeout(()=>{this.timers.delete(`open:${n.id}`);let u=this.menus.findIndex((m)=>m.id===n.id);if(u<0)return;if(this.menus[u].state!=="opening")return;let f=this.menus.slice();f[u]={...f[u],state:"open"},this.menus=f,this.emit()},Wu);this.timers.set(`open:${n.id}`,c)}update(e,t){let a=this.menus.findIndex((n)=>n.id===e);if(a<0)return;let o=this.menus.slice();o[a]={...o[a],param:{...o[a].param,...t}},this.menus=o,this.emit()}updateData(e,t){let a=this.menus.findIndex((s)=>s.id===e);if(a<0)return;let o=this.menus.slice(),n=o[a];o[a]={...n,param:{...n.param,data:{...n.param.data??{},...t}}},this.menus=o,this.emit()}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}dispose(){for(let e of this.timers.values())window.clearTimeout(e);this.timers.clear(),this.listeners.clear()}emit(){for(let e of this.listeners)e()}},vz=R.createContext(null);function $u({menus:e,options:t,store:a,children:o}){let n=R.useRef(null);if(n.current==null)n.current=a??new Sz;let s=n.current;R.useEffect(()=>{if(e?.length)s.registerMany([...e])},[e,s]);let i=R.useMemo(()=>({storage:t?.storage??new Iz,...t}),[t]),l=R.useMemo(()=>({store:s,options:i}),[s,i]);return h.jsxs(vz.Provider,{value:l,children:[o,h.jsx(gz,{})]})}function Ki(){let e=R.useContext(vz);if(!e)throw Error("useMenu / useMenuStore must be used inside <MenuProvider>");return e}function ef(){let{store:e}=Ki();return R.useMemo(()=>({open:(t,a)=>e.open(t,a??{}),close:(t)=>e.close(t),closeAll:(t)=>e.closeAll(t),update:(t,a)=>e.update(t,a),updateData:(t,a)=>e.updateData(t,a),isOpen:(t)=>e.isOpen(t),register:(t)=>e.register(t)}),[e])}function yz(){let{store:e}=Ki();return R.useSyncExternalStore((t)=>e.subscribe(t),()=>e.getAll(),()=>e.getAll())}function bz(){return Ki().options}function Cz(){return Ki().store}var Tc=O(U(),1),Z7=O(q7(),1),ai=O(Mi(),1),dZ={},pZ=(e)=>dZ[e]??=()=>ai.jsx("span",{className:"fm-ico",dangerouslySetInnerHTML:{__html:window.icon?.(e,16)??""}}),hZ=(e)=>e?pZ(e):void 0,gZ=(e)=>[{kind:bn.Section,match:(t)=>!!t.section,name:(t)=>t.section},{kind:bn.Divider,match:(t)=>!!t.divider},{kind:bn.Item,name:(t)=>t.label,caption:(t)=>t.caption,icon:(t)=>{let a=hZ(t.icon);return a?{icon:a,size:16,...t.danger?{color:"var(--bad)"}:{}}:void 0},pressed:(t)=>!!t.pressed,disabled:(t)=>!!t.disabled,arrow:(t)=>!!t.children?.length,className:(t)=>t.danger?"fm-row--danger":void 0,subMenuId:(t)=>t.children?.length?`swarm-actions-${e+1}`:void 0,subMenuTrigger:ci.ArrowClick,subMenuData:(t)=>({items:t.children??[]}),onClick:async(t,a,o)=>{if(t.children?.length)return;if(await t.run?.(),!o.data.stay)o.closeAll("swarm")}}],IZ=[0,1,2].map((e)=>Ec({id:`swarm-actions-${e}`,kind:si.Menu,group:"swarm",position:{minWidth:260,maxWidth:420},chrome:{role:"menu"},body:{kind:ii.List,source:{kind:li.Prop,getItems:(t)=>t?.items??[]},rows:gZ(e)},keyboard:{defaults:{closeOnEscape:!0,selectOnEnter:!0,arrowsToSubmenu:!0}}}));function SZ(){let e=ef();return Tc.useEffect(()=>{let t=(a,o)=>{e.closeAll("swarm");let s={rect:a instanceof Element?a.getBoundingClientRect():new DOMRect(a.x,a.y,0,0),data:o};e.open("swarm-actions-0",s)};window.menus={open:t,close:()=>e.closeAll("swarm"),isOpen:()=>e.isOpen()},window.dispatchEvent(new Event("menus:ready"))},[e]),null}var kd=document.createElement("div");kd.id="menus-root";document.body.appendChild(kd);Z7.createRoot(kd).render(ai.jsx(Tc.StrictMode,{children:ai.jsx($u,{menus:IZ,children:ai.jsx(SZ,{})})}));})();