@minimalcorp/tsunagi 0.1.33 → 0.1.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/.next/standalone/apps/web/.next/BUILD_ID +1 -1
  2. package/.next/standalone/apps/web/.next/build-manifest.json +3 -3
  3. package/.next/standalone/apps/web/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/apps/web/.next/server/app/_global-error.html +1 -1
  5. package/.next/standalone/apps/web/.next/server/app/_global-error.rsc +1 -1
  6. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/.next/standalone/apps/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/.next/standalone/apps/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/.next/standalone/apps/web/.next/server/app/_not-found.html +1 -1
  13. package/.next/standalone/apps/web/.next/server/app/_not-found.rsc +2 -2
  14. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/.next/standalone/apps/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/.next/standalone/apps/web/.next/server/app/index.html +1 -1
  21. package/.next/standalone/apps/web/.next/server/app/index.rsc +3 -3
  22. package/.next/standalone/apps/web/.next/server/app/index.segments/__PAGE__.segment.rsc +2 -2
  23. package/.next/standalone/apps/web/.next/server/app/index.segments/_full.segment.rsc +3 -3
  24. package/.next/standalone/apps/web/.next/server/app/index.segments/_head.segment.rsc +1 -1
  25. package/.next/standalone/apps/web/.next/server/app/index.segments/_index.segment.rsc +2 -2
  26. package/.next/standalone/apps/web/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  27. package/.next/standalone/apps/web/.next/server/app/page.js.nft.json +1 -1
  28. package/.next/standalone/apps/web/.next/server/app/page_client-reference-manifest.js +1 -1
  29. package/.next/standalone/apps/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  30. package/.next/standalone/apps/web/.next/server/app/settings.html +1 -1
  31. package/.next/standalone/apps/web/.next/server/app/settings.rsc +3 -3
  32. package/.next/standalone/apps/web/.next/server/app/settings.segments/_full.segment.rsc +3 -3
  33. package/.next/standalone/apps/web/.next/server/app/settings.segments/_head.segment.rsc +1 -1
  34. package/.next/standalone/apps/web/.next/server/app/settings.segments/_index.segment.rsc +2 -2
  35. package/.next/standalone/apps/web/.next/server/app/settings.segments/_tree.segment.rsc +2 -2
  36. package/.next/standalone/apps/web/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +2 -2
  37. package/.next/standalone/apps/web/.next/server/app/settings.segments/settings.segment.rsc +1 -1
  38. package/.next/standalone/apps/web/.next/server/app/tasks/[id]/page_client-reference-manifest.js +1 -1
  39. package/.next/standalone/apps/web/.next/server/chunks/ssr/{[root-of-the-server]__0r5k1o3._.js → [root-of-the-server]__0mct.7z._.js} +2 -2
  40. package/.next/standalone/apps/web/.next/server/chunks/ssr/_02dcd~k._.js +1 -1
  41. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0dar4c0._.js +1 -1
  42. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0g.cd6a._.js +1 -1
  43. package/.next/standalone/apps/web/.next/server/chunks/ssr/_0sxye4q._.js +1 -1
  44. package/.next/standalone/apps/web/.next/server/chunks/ssr/apps_web_src_app_tasks_[id]_page_tsx_0jshsm2._.js +1 -1
  45. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_03dusl-._.js → node_modules_07-e6tb._.js} +1 -1
  46. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_09g056t._.js → node_modules_0b6fjwn._.js} +1 -1
  47. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0ec.p48._.js → node_modules_0bix9lu._.js} +1 -1
  48. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0az0yoa._.js → node_modules_0fpqbi2._.js} +1 -1
  49. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_0_wjeog._.js → node_modules_0k8xmjr._.js} +1 -1
  50. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_09o-nzb._.js → node_modules_0r9vehj._.js} +1 -1
  51. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_00bsm~0._.js → node_modules_0w48uk8._.js} +1 -1
  52. package/.next/standalone/apps/web/.next/server/chunks/ssr/{node_modules_131360a._.js → node_modules_0yoat72._.js} +1 -1
  53. package/.next/standalone/apps/web/.next/server/middleware-build-manifest.js +3 -3
  54. package/.next/standalone/apps/web/.next/server/pages/404.html +1 -1
  55. package/.next/standalone/apps/web/.next/server/pages/500.html +1 -1
  56. package/.next/standalone/apps/web/.next/server/server-reference-manifest.js +1 -1
  57. package/.next/standalone/apps/web/.next/server/server-reference-manifest.json +1 -1
  58. package/.next/standalone/apps/web/.next/static/chunks/00e8eue.21.8h.css +4 -0
  59. package/.next/standalone/apps/web/.next/static/chunks/0j3485~p9pn9n.js +1 -0
  60. package/.next/standalone/apps/web/.next/static/chunks/{0szj.38-.-4p4.js → 0kmlu-0djf-rx.js} +1 -1
  61. package/.next/standalone/apps/web/.next/static/chunks/{0z8cfvtbwii50.js → 0vlse5ga2r0n7.js} +1 -1
  62. package/.next/standalone/apps/web/.next/static/chunks/{0dqv~laaou7x3.js → 0x3kp2s554oy5.js} +6 -6
  63. package/.next/standalone/apps/web/.next/static/chunks/{076mcjezjnahd.js → 13f6kj~4r5x0p.js} +1 -1
  64. package/dist/server/generated/prisma/internal/class.js +4 -4
  65. package/dist/server/generated/prisma/internal/prismaNamespace.d.ts +1 -0
  66. package/dist/server/generated/prisma/internal/prismaNamespace.js +1 -0
  67. package/dist/server/generated/prisma/internal/prismaNamespaceBrowser.d.ts +1 -0
  68. package/dist/server/generated/prisma/internal/prismaNamespaceBrowser.js +1 -0
  69. package/dist/server/generated/prisma/models/EnvironmentVariable.d.ts +0 -3
  70. package/dist/server/generated/prisma/models/Tab.d.ts +39 -1
  71. package/dist/server/lib/repositories/task.d.ts +5 -0
  72. package/dist/server/lib/repositories/task.js +13 -0
  73. package/dist/server/routes/hooks.js +21 -1
  74. package/dist/server/routes/tasks.js +20 -0
  75. package/npm-shrinkwrap.json +33 -29
  76. package/package.json +1 -1
  77. package/prisma/migrations/20260918000000_add_tab_unread/migration.sql +4 -0
  78. package/prisma/schema.prisma +2 -0
  79. package/.next/standalone/apps/web/.next/static/chunks/02k8hsfyr1oif.css +0 -4
  80. package/.next/standalone/apps/web/.next/static/chunks/0zdnw6m70_-dp.js +0 -1
  81. /package/.next/standalone/apps/web/.next/static/{fUycQdovbCSAwFW2xvyuD → mWBhkmlLJfxVxMeoAXXc3}/_buildManifest.js +0 -0
  82. /package/.next/standalone/apps/web/.next/static/{fUycQdovbCSAwFW2xvyuD → mWBhkmlLJfxVxMeoAXXc3}/_clientMiddlewareManifest.js +0 -0
  83. /package/.next/standalone/apps/web/.next/static/{fUycQdovbCSAwFW2xvyuD → mWBhkmlLJfxVxMeoAXXc3}/_ssgManifest.js +0 -0
@@ -19,6 +19,6 @@ WARNING: This link could potentially be dangerous`)){let i=window.open();if(i){t
19
19
  `))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(ia(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(eK(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let i=0;i<e;i++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
20
20
  `&&(this._liveRegionLineCount++,21===this._liveRegionLineCount&&(this._liveRegion.textContent+=Q)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,i){this._liveRegionDebouncer.refresh(e,i,this._terminal.rows)}_renderRows(e,i){let s=this._terminal.buffer,r=s.lines.length.toString();for(let n=e;n<=i;n++){let e=s.lines.get(s.ydisp+n),i=[],o=e?.translateToString(!0,void 0,void 0,i)||"",a=(s.ydisp+n+1).toString(),l=this._rowElements[n];l&&(0===o.length?(l.textContent=" ",this._rowColumns.set(l,[0,1])):(l.textContent=o,this._rowColumns.set(l,i)),l.setAttribute("aria-posinset",a),l.setAttribute("aria-setsize",r),this._alignRowWidth(l))}this._announceCharacters()}_announceCharacters(){0!==this._charsToAnnounce.length&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,i){let s,r,n=e.target,o=this._rowElements[0===i?1:this._rowElements.length-2];if(n.getAttribute("aria-posinset")!==(0===i?"1":`${this._terminal.buffer.lines.length}`)&&e.relatedTarget===o){if(0===i?(s=n,r=this._rowElements.pop(),this._rowContainer.removeChild(r)):(s=this._rowElements.shift(),r=n,this._rowContainer.removeChild(s)),s.removeEventListener("focus",this._topBoundaryFocusListener),r.removeEventListener("focus",this._bottomBoundaryFocusListener),0===i){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement("afterbegin",e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(0===i?-1:1),this._rowElements[0===i?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}}_handleSelectionChange(){if(0===this._rowElements.length)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode)return void console.error("anchorNode and/or focusNode are null");let i={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((i.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||i.node===s.node&&i.offset>s.offset)&&([i,s]=[s,i]),i.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(i={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(i.node))return;let r=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(s.node))return;let n=({node:e,offset:i})=>{let s=e instanceof Text?e.parentNode:e,r=parseInt(s?.getAttribute("aria-posinset"),10)-1;if(isNaN(r))return console.warn("row is invalid. Race condition?"),null;let n=this._rowColumns.get(s);if(!n)return console.warn("columns is null. Race condition?"),null;let o=i<n.length?n[i]:n.slice(-1)[0]+1;return o>=this._terminal.cols&&(++r,o=0),{row:r,column:o}},o=n(i),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform="";let i=e.getBoundingClientRect().width,s=this._rowColumns.get(e)?.slice(-1)?.[0];if(!s)return;let r=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/i})`}};nu=G([J(1,ev),J(2,eE),J(3,eM)],nu);var n_=class extends eq{constructor(e,i,s,r,n){super(),this._element=e,this._mouseService=i,this._renderService=s,this._bufferService=r,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new ti),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new ti),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(eK(()=>{eU(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(ia(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(ia(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(ia(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(ia(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let i=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!i)return;this._isMouseOut=!1;let s=e.composedPath();for(let e=0;e<s.length;e++){let i=s[e];if(i.classList.contains("xterm"))break;if(i.classList.contains("xterm-hover"))return}this._lastBufferCell&&i.x===this._lastBufferCell.x&&i.y===this._lastBufferCell.y||(this._handleHover(i),this._lastBufferCell=i)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,i){this._activeProviderReplies&&i||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[r,n]of this._linkProviderService.linkProviders.entries())i?this._activeProviderReplies?.get(r)&&(s=this._checkLinkProviderResult(r,e,s)):n.provideLinks(e.y,i=>{if(this._isMouseOut)return;let n=i?.map(e=>({link:e}));this._activeProviderReplies?.set(r,n),s=this._checkLinkProviderResult(r,e,s),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,i){let s=new Set;for(let r=0;r<i.size;r++){let n=i.get(r);if(n)for(let i=0;i<n.length;i++){let r=n[i],o=r.link.range.start.y<e?0:r.link.range.start.x,a=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=o;e<=a;e++){if(s.has(e)){n.splice(i--,1);break}s.add(e)}}}}_checkLinkProviderResult(e,i,s){if(!this._activeProviderReplies)return s;let r=this._activeProviderReplies.get(e),n=!1;for(let i=0;i<e;i++)(!this._activeProviderReplies.has(i)||this._activeProviderReplies.get(i))&&(n=!0);if(!n&&r){let e=r.find(e=>this._linkAtPosition(e.link,i));e&&(s=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,i));if(r){s=!0,this._handleNewLink(r);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){var i,s;if(!this._currentLink)return;let r=this._positionFromMouseEvent(e,this._element,this._mouseService);r&&this._mouseDownLink&&(i=this._mouseDownLink.link,s=this._currentLink.link,i.text===s.text&&i.range.start.x===s.range.start.x&&i.range.start.y===s.range.start.y&&i.range.end.x===s.range.end.x&&i.range.end.y===s.range.end.y)&&this._linkAtPosition(this._currentLink.link,r)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,i){this._currentLink&&this._lastMouseEvent&&(!e||!i||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=i)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,eU(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let i=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);i&&this._linkAtPosition(e.link,i)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:void 0===e.link.decorations||e.link.decorations.underline,pointerCursor:void 0===e.link.decorations||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:i=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==i&&(this._currentLink.state.decorations.underline=i,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,i))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let i=0===e.start?0:e.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),i.hover&&i.hover(s,i.text)}_fireUnderlineEvent(e,i){let s=e.range,r=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-r-1,s.end.x,s.end.y-r-1,void 0);(i?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,i,s){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(i,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),i.leave&&i.leave(s,i.text)}_linkAtPosition(e,i){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,n=i.y*this._bufferService.cols+i.x;return s<=n&&n<=r}_positionFromMouseEvent(e,i,s){let r=s.getCoords(e,i,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,i,s,r,n){return{x1:e,y1:i,x2:s,y2:r,cols:this._bufferService.cols,fg:n}}};n_=G([J(1,eR),J(2,eM),J(3,ef),J(4,eL)],n_);var nf=class extends ns{constructor(e={}){super(e),this._linkifier=this._register(new eY),this.browser=sR,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new eY),this._onCursorMove=this._register(new ti),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new ti),this.onKey=this._onKey.event,this._onRender=this._register(new ti),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new ti),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new ti),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new ti),this.onBell=this._onBell.event,this._onFocus=this._register(new ti),this._onBlur=this._register(new ti),this._onA11yCharEmitter=this._register(new ti),this._onA11yTabEmitter=this._register(new ti),this._onWillOpen=this._register(new ti),this._setup(),this._decorationService=this._instantiationService.createInstance(nh),this._instantiationService.setService(eC,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(sC),this._instantiationService.setService(eL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ex)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(e6.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(e6.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(e6.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(e6.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(eK(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let i of e){let e,s="";switch(i.index){case 256:e="foreground",s="10";break;case 257:e="background",s="11";break;case 258:e="cursor",s="12";break;default:e="ansi",s="4;"+i.index}switch(i.type){case 0:let r=rL.toColorRGB("ansi"===e?this._themeService.colors.ansi[i.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${iY.ESC}]${s};${function(e,i=16){let[s,r,n]=e;return`rgb:${r5(s,i)}/${r5(r,i)}/${r5(n,i)}`}(r)}${iG.ST}`);break;case 1:if("ansi"===e)this._themeService.modifyColors(e=>e.ansi[i.index]=iJ.toColor(...i.color));else{let s=e;this._themeService.modifyColors(e=>e[s]=iJ.toColor(...i.color))}break;case 2:this._themeService.restoreColor(i.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(nu,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(iY.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(iY.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,i=this.buffer.lines.get(e);if(!i)return;let s=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,n=i.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=r+"px",this.textarea.style.lineHeight=r+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(ia(this.element,"copy",e=>{var i;this.hasSelection()&&(i=this._selectionService,e.clipboardData&&e.clipboardData.setData("text/plain",i.selectionText),e.preventDefault())}));let e=e=>{var i,s,r;return i=this.textarea,s=this.coreService,r=this.optionsService,void(e.stopPropagation(),e.clipboardData&&ee(e.clipboardData.getData("text/plain"),i,s,r))};this._register(ia(this.textarea,"paste",e)),this._register(ia(this.element,"paste",e)),sP?this._register(ia(this.element,"mousedown",e=>{2===e.button&&ei(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(ia(this.element,"contextmenu",e=>{ei(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),sz&&this._register(ia(this.element,"auxclick",e=>{1===e.button&&et(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(ia(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(ia(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(ia(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(ia(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(ia(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(ia(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(ia(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let i=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),i.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(ia(this.screenElement,"mousemove",e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),i.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Z),s$||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(sy,this.textarea,e.ownerDocument.defaultView??window,this._document??"u">typeof window?window.document:null)),this._instantiationService.setService(eE,this._coreBrowserService),this._register(ia(this.textarea,"focus",e=>this._handleTextAreaFocus(e))),this._register(ia(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(sm,this._document,this._helperContainer),this._instantiationService.setService(ek,this._charSizeService),this._themeService=this._instantiationService.createInstance(ri),this._instantiationService.setService(eB,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ss),this._instantiationService.setService(eT,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(sY,this.rows,this.screenElement)),this._instantiationService.setService(eM,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(i$,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(sk),this._instantiationService.setService(eR,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(n_,this.screenElement));this.element.appendChild(i);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(iI,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(s3,this.element,this.screenElement,r)),this._instantiationService.setService(eD,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(e6.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(iA,this.screenElement)),this._register(ia(this.element,"mousedown",e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(nu,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(iz,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(iz,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(sg,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,i=this.element;function s(i){let s,r,n=e._mouseService.getMouseReportCoords(i,e.screenElement);if(!n)return!1;switch(i.overrideType||i.type){case"mousemove":r=32,void 0===i.buttons?(s=3,void 0!==i.button&&(s=i.button<3?i.button:3)):s=1&i.buttons?0:4&i.buttons?1:2&i.buttons?2:3;break;case"mouseup":r=0,s=i.button<3?i.button:3;break;case"mousedown":r=1,s=i.button<3?i.button:3;break;case"wheel":if(e._customWheelEventHandler&&!1===e._customWheelEventHandler(i))return!1;let o=i.deltaY;if(0===o||0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return!1;r=o<0?0:1,s=4;break;default:return!1}return void 0!==r&&void 0!==s&&!(s>4)&&e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:s,action:r,ctrl:i.ctrlKey,alt:i.altKey,shift:i.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n=e=>(s(e),e.buttons||(this._document.removeEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.removeEventListener("mousemove",r.mousedrag)),this.cancel(e)),o=e=>(s(e),this.cancel(e,!0)),a=e=>{e.buttons&&s(e)},l=e=>{e.buttons||s(e)};this._register(this.coreMouseService.onProtocolChange(e=>{e?("debug"===this.optionsService.rawOptions.logLevel&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(e)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&e?r.mousemove||(i.addEventListener("mousemove",l),r.mousemove=l):(i.removeEventListener("mousemove",r.mousemove),r.mousemove=null),16&e?r.wheel||(i.addEventListener("wheel",o,{passive:!1}),r.wheel=o):(i.removeEventListener("wheel",r.wheel),r.wheel=null),2&e?r.mouseup||(r.mouseup=n):(this._document.removeEventListener("mouseup",r.mouseup),r.mouseup=null),4&e?r.mousedrag||(r.mousedrag=a):(this._document.removeEventListener("mousemove",r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(ia(i,"mousedown",e=>{if(e.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(e)))return s(e),r.mouseup&&this._document.addEventListener("mouseup",r.mouseup),r.mousedrag&&this._document.addEventListener("mousemove",r.mousedrag),this.cancel(e)})),this._register(ia(i,"wheel",i=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(i))return!1;if(!this.buffer.hasScrollback){if(0===i.deltaY)return!1;if(0===e.coreMouseService.consumeWheelEvent(i,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr))return this.cancel(i,!0);let s=iY.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(i.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(s,!0),this.cancel(i,!0)}}},{passive:!1}))}refresh(e,i){this._renderService?.refreshRows(e,i)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,i){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,i),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let i=e-this._bufferService.buffer.ydisp;0!==i&&this.scrollLines(i)}paste(e){ee(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");let i=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),i}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(e,i,s){this._selectionService.setSelection(e,i,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,i){this._selectionService?.selectLines(e,i)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;let i=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!i&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;i||"Dead"!==e.key&&"AltGraph"!==e.key||(this._unprocessedDeadKey=!0);let s=function(e,i,s,r){let n={type:0,cancel:!1,key:void 0},o=!!e.shiftKey|2*!!e.altKey|4*!!e.ctrlKey|8*!!e.metaKey;switch(e.keyCode){case 0:"UIKeyInputUpArrow"===e.key?i?n.key=iY.ESC+"OA":n.key=iY.ESC+"[A":"UIKeyInputLeftArrow"===e.key?i?n.key=iY.ESC+"OD":n.key=iY.ESC+"[D":"UIKeyInputRightArrow"===e.key?i?n.key=iY.ESC+"OC":n.key=iY.ESC+"[C":"UIKeyInputDownArrow"===e.key&&(i?n.key=iY.ESC+"OB":n.key=iY.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":iY.DEL,e.altKey&&(n.key=iY.ESC+n.key);break;case 9:if(e.shiftKey){n.key=iY.ESC+"[Z";break}n.key=iY.HT,n.cancel=!0;break;case 13:n.key=e.altKey?iY.ESC+iY.CR:iY.CR,n.cancel=!0;break;case 27:n.key=iY.ESC,e.altKey&&(n.key=iY.ESC+iY.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=iY.ESC+"[1;"+(o+1)+"D":i?n.key=iY.ESC+"OD":n.key=iY.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=iY.ESC+"[1;"+(o+1)+"C":i?n.key=iY.ESC+"OC":n.key=iY.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=iY.ESC+"[1;"+(o+1)+"A":i?n.key=iY.ESC+"OA":n.key=iY.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=iY.ESC+"[1;"+(o+1)+"B":i?n.key=iY.ESC+"OB":n.key=iY.ESC+"[B";break;case 45:e.shiftKey||e.ctrlKey||(n.key=iY.ESC+"[2~");break;case 46:o?n.key=iY.ESC+"[3;"+(o+1)+"~":n.key=iY.ESC+"[3~";break;case 36:o?n.key=iY.ESC+"[1;"+(o+1)+"H":i?n.key=iY.ESC+"OH":n.key=iY.ESC+"[H";break;case 35:o?n.key=iY.ESC+"[1;"+(o+1)+"F":i?n.key=iY.ESC+"OF":n.key=iY.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=iY.ESC+"[5;"+(o+1)+"~":n.key=iY.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=iY.ESC+"[6;"+(o+1)+"~":n.key=iY.ESC+"[6~";break;case 112:o?n.key=iY.ESC+"[1;"+(o+1)+"P":n.key=iY.ESC+"OP";break;case 113:o?n.key=iY.ESC+"[1;"+(o+1)+"Q":n.key=iY.ESC+"OQ";break;case 114:o?n.key=iY.ESC+"[1;"+(o+1)+"R":n.key=iY.ESC+"OR";break;case 115:o?n.key=iY.ESC+"[1;"+(o+1)+"S":n.key=iY.ESC+"OS";break;case 116:o?n.key=iY.ESC+"[15;"+(o+1)+"~":n.key=iY.ESC+"[15~";break;case 117:o?n.key=iY.ESC+"[17;"+(o+1)+"~":n.key=iY.ESC+"[17~";break;case 118:o?n.key=iY.ESC+"[18;"+(o+1)+"~":n.key=iY.ESC+"[18~";break;case 119:o?n.key=iY.ESC+"[19;"+(o+1)+"~":n.key=iY.ESC+"[19~";break;case 120:o?n.key=iY.ESC+"[20;"+(o+1)+"~":n.key=iY.ESC+"[20~";break;case 121:o?n.key=iY.ESC+"[21;"+(o+1)+"~":n.key=iY.ESC+"[21~";break;case 122:o?n.key=iY.ESC+"[23;"+(o+1)+"~":n.key=iY.ESC+"[23~";break;case 123:o?n.key=iY.ESC+"[24;"+(o+1)+"~":n.key=iY.ESC+"[24~";break;default:if(!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)if((!s||r)&&e.altKey&&!e.metaKey){let i=nr[e.keyCode]?.[+!!e.shiftKey];if(i)n.key=iY.ESC+i;else if(e.keyCode>=65&&e.keyCode<=90){let i=String.fromCharCode(e.ctrlKey?e.keyCode-64:e.keyCode+32);e.shiftKey&&(i=i.toUpperCase()),n.key=iY.ESC+i}else if(32===e.keyCode)n.key=iY.ESC+(e.ctrlKey?iY.NUL:" ");else if("Dead"===e.key&&e.code.startsWith("Key")){let i=e.code.slice(3,4);e.shiftKey||(i=i.toLowerCase()),n.key=iY.ESC+i,n.cancel=!0}}else!s||e.altKey||e.ctrlKey||e.shiftKey||!e.metaKey?!e.key||e.ctrlKey||e.altKey||e.metaKey||!(e.keyCode>=48)||1!==e.key.length?e.key&&e.ctrlKey&&("_"===e.key&&(n.key=iY.US),"@"===e.key&&(n.key=iY.NUL)):n.key=e.key:65===e.keyCode&&(n.type=1);else e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):32===e.keyCode?n.key=iY.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):56===e.keyCode?n.key=iY.DEL:219===e.keyCode?n.key=iY.ESC:220===e.keyCode?n.key=iY.FS:221===e.keyCode&&(n.key=iY.GS)}return n}(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),3===s.type||2===s.type){let i=this.rows-1;return this.scrollLines(2===s.type?-i:i),this.cancel(e,!0)}return 1===s.type&&this.selectAll(),!!(this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&1===e.key.length&&e.key.charCodeAt(0)>=65&&90>=e.key.charCodeAt(0))||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):((s.key===iY.ETX||s.key===iY.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)?this.cancel(e,!0):void(this._keyDownHandled=!0))}_isThirdLevelShift(e,i){let s=e.isMac&&!this.options.macOptionIsMeta&&i.altKey&&!i.ctrlKey&&!i.metaKey||e.isWindows&&i.altKey&&i.ctrlKey&&!i.metaKey||e.isWindows&&i.getModifierState("AltGraph");return"keypress"===i.type?s:s&&(!i.keyCode||i.keyCode>47)}_keyUp(e){var i;this._keyDownSeen=!1,this._customKeyEventHandler&&!1===this._customKeyEventHandler(e)||(16===(i=e).keyCode||17===i.keyCode||18===i.keyCode||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let i;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))return!1;if(this.cancel(e),e.charCode)i=e.charCode;else if(null===e.which||void 0===e.which)i=e.keyCode;else{if(0===e.which||0===e.charCode)return!1;i=e.which}return!!i&&(!e.altKey&&!e.ctrlKey&&!e.metaKey||!!this._isThirdLevelShift(this.browser,e))&&(i=String.fromCharCode(i),this._onKey.fire({key:i,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(i,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&"insertText"===e.inputType&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let i=e.data;return this.coreService.triggerDataEvent(i,!0),this.cancel(e),!0}return!1}resize(e,i){if(e===this.cols&&i===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,i)}_afterResize(e,i){this._charSizeService?.measure()}clear(){if(0!==this.buffer.ybase||0!==this.buffer.y){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(rh));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains("focus")?this.coreService.triggerDataEvent(iY.ESC+"[I"):this.coreService.triggerDataEvent(iY.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let i=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${iY.ESC}[4;${s};${i}t`);break;case 1:let r=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${iY.ESC}[6;${n};${r}t`)}}cancel(e,i){if(!(!this.options.cancelEvents&&!i))return e.preventDefault(),e.stopPropagation(),!1}},np=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,i){let s={instance:i,dispose:i.dispose,isDisposed:!1};this._addons.push(s),i.dispose=()=>this._wrappedAddonDispose(s),i.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let i=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){i=s;break}if(-1===i)throw Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(i,1)}},ng=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,i){if(!(e<0||e>=this._line.length))return i?(this._line.loadCell(e,i),i):this._line.loadCell(e,new eh)}translateToString(e,i,s){return this._line.translateToString(e,i,s)}},nm=class{constructor(e,i){this._buffer=e,this.type=i}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let i=this._buffer.lines.get(e);if(i)return new ng(i)}getNullCell(){return new eh}},nv=class extends eq{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new ti),this.onBufferChange=this._onBufferChange.event,this._normal=new nm(this._core.buffers.normal,"normal"),this._alternate=new nm(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},nS=class{constructor(e){this._core=e}registerCsiHandler(e,i){return this._core.registerCsiHandler(e,e=>i(e.toArray()))}addCsiHandler(e,i){return this.registerCsiHandler(e,i)}registerDcsHandler(e,i){return this._core.registerDcsHandler(e,(e,s)=>i(e,s.toArray()))}addDcsHandler(e,i){return this.registerDcsHandler(e,i)}registerEscHandler(e,i){return this._core.registerEscHandler(e,i)}addEscHandler(e,i){return this.registerEscHandler(e,i)}registerOscHandler(e,i){return this._core.registerOscHandler(e,i)}addOscHandler(e,i){return this.registerOscHandler(e,i)}},nb=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},ny=["cols","rows"],nw=0,nC=class extends eq{constructor(e){super(),this._core=this._register(new nf(e)),this._addonManager=this._register(new np),this._publicOptions={...this._core.options};let i=e=>this._core.options[e],s=(e,i)=>{this._checkReadonlyOptions(e),this._core.options[e]=i};for(let e in this._core.options){let r={get:i.bind(this,e),set:s.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(ny.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new nS(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new nb(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new nv(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,i="none";switch(this._core.coreMouseService.activeProtocol){case"X10":i="x10";break;case"VT200":i="vt200";break;case"DRAG":i="drag";break;case"ANY":i="any"}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:i,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let i in e)this._publicOptions[i]=e[i]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,i=!0){this._core.input(e,i)}resize(e,i){this._verifyIntegers(e,i),this._core.resize(e,i)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,i,s){this._verifyIntegers(e,i,s),this._core.select(e,i,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,i){this._verifyIntegers(e,i),this._core.selectLines(e,i)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,i){this._core.write(e,i)}writeln(e,i){this._core.write(e),this._core.write(`\r
21
21
  `,i)}paste(e){this._core.paste(e)}refresh(e,i){this._verifyIntegers(e,i),this._core.refresh(e,i)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Z},set promptLabel(t){Z=t},get tooMuchOutput(){return Q},set tooMuchOutput(t){Q=t}}}_verifyIntegers(...e){for(nw of e)if(nw===1/0||isNaN(nw)||nw%1!=0)throw Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(nw of e)if(nw&&(nw===1/0||isNaN(nw)||nw%1!=0||nw<0))throw Error("This API only accepts positive integers")}},nx=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(0===e.css.cell.width||0===e.css.cell.height)return;let i=0===this._terminal.options.scrollback?0:this._terminal.options.overviewRuler?.width||14,s=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom;return{cols:Math.max(2,Math.floor((n-(a.right+a.left)-i)/e.css.cell.width)),rows:Math.max(1,Math.floor((r-l)/e.css.cell.height))}}},nk=e.i(96085),nE=e.i(627),nR=e.i(74886);let nM=(0,y.default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);var nD=e.i(43531);let nT=(0,y.default)("square-pen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);var nB=e.i(12382),nL=e.i(77814);let nP=(0,v.forwardRef)(function({tabId:e,cwd:i,env:s,worktreePath:r,command:n,className:o="",initialTodos:a,initialClaudeStatus:l,isActive:h,onTodosUpdated:c,onStatusChange:d},u){let _=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),g=(0,v.useRef)(null),S=(0,v.useRef)(e),[b,y]=(0,v.useState)(!1),w=(0,v.useRef)(!1),C=(0,v.useRef)(h),x=(0,v.useRef)("idle"),k=(0,v.useRef)(!1),E=(0,v.useRef)(!1),M=(0,v.useRef)(null),D=(0,v.useRef)(null),T=(0,v.useRef)(null),B=(0,v.useRef)(0),[L,P]=(0,v.useState)("idle"),[I,A]=(0,v.useState)(l??"idle"),N=(0,v.useRef)(l??"idle"),[H,W]=(0,v.useState)(a??[]),[F,z]=(0,v.useState)(!1),{effectiveTheme:$}=(0,nE.useTheme)(),K=(0,v.useRef)(d);K.current=d;let j="dark"===$,V=j?{background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78"}:{background:"#ffffff",foreground:"#1e1e1e",cursor:"#1e1e1e",selectionBackground:"#add6ff"};async function q(e){try{await fetch((0,R.apiUrl)(`/api/internal/tabs/${e}/interrupt`),{method:"POST"})}catch(e){console.warn("[TerminalView] Failed to notify interrupt:",e)}}function Y(){let e=g.current,i=f.current,s=S.current;e&&e.connected&&i&&s&&e.emit("resize",{sessionId:s,cols:i.cols,rows:i.rows})}function X(e){e.write("\x1b[2J\x1b[3J\x1b[H")}async function G(o,a,l){P("connecting");try{var h,d,u,_;let m,v,b=await fetch((0,R.apiUrl)("/api/terminal/sessions"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:i,env:s,worktreePath:r,sessionId:o,command:n}),signal:l});if(!b.ok){let e=await b.text().catch(()=>"");throw Error(`Failed to create session: ${b.status} ${e}`)}let y=await b.json();if(l.aborted)return;S.current=y.sessionId,y.reused||X(a),h=y.sessionId,d=y.reused,u=a,_=l,M.current?.dispose(),M.current=null,g.current&&(g.current.removeAllListeners(),g.current.disconnect()),g.current=m=(0,nk.io)((0,R.getServerUrl)(),{transports:["polling","websocket"]}),v=!1,m.on("connect",()=>{let e=k.current;k.current=!0,e?u.writeln("\x1b[90mReconnected.\x1b[0m"):d?(E.current=!0,X(u)):u.writeln("\x1b[90mConnected.\x1b[0m"),P("connected"),B.current=0,m.emit("join",{room:`tab:${h}`,mode:"terminal"}),e&&C.current&&u.focus()}),m.on("output",({data:e})=>{d&&!v?(v=!0,u.write(e,()=>{E.current=!1,p.current?.fit();let e=f.current;if(e){let i=64===e.cols?63:64;e.resize(i,e.rows),Y(),setTimeout(()=>{p.current?.fit(),Y()},50)}u.scrollToBottom()})):u.write(e)}),m.on("exit",({exitCode:e})=>{console.log("[TerminalView] PTY exited with code:",e),P("exited"),S.current=null,g.current=null}),m.on("error",({message:e})=>{if(console.error("[TerminalView] Socket error message:",e),e.startsWith("Session not found")&&B.current<1){B.current+=1,J();return}P("error")}),m.on("disconnect",()=>{_.aborted||P(e=>"exited"===e||"paused"===e||"idle"===e?e:"exited")}),m.on("status-changed",({status:e})=>{A(e)}),m.on("todos-updated",({todos:i})=>{W(i),c?.(e,i)}),m.on("editor:open",({sessionId:e,content:i})=>{window.dispatchEvent(new CustomEvent("editor-session-open-request",{detail:{sessionId:e,content:i}}))}),M.current=u.onData(e=>{"\x1b"===e&&("running"===N.current||"waiting"===N.current)&&S.current&&q(S.current),m.connected&&S.current&&m.emit("input",{sessionId:S.current,data:e})})}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;console.error("[TerminalView] connectSession error:",e instanceof Error?e.message:String(e)),P("error")}}async function J(){let i=f.current;if(!i)return;let s=new AbortController;await G(e,i,s.signal)}(0,v.useEffect)(()=>{K.current?.(e,L,I)},[e,L,I]),(0,v.useLayoutEffect)(()=>{C.current=h}),(0,v.useLayoutEffect)(()=>{x.current=L}),(0,v.useLayoutEffect)(()=>{N.current=I}),(0,v.useEffect)(()=>{h&&f.current?.focus()},[h]),(0,v.useEffect)(()=>{if(b)f.current?.blur();else if(h){let e=_.current?.querySelector("textarea.xterm-helper-textarea");e?.focus()}},[b,h]),(0,v.useEffect)(()=>{"connected"===L&&p.current&&(p.current.fit(),E.current||Y())},[L]),(0,v.useEffect)(()=>{if(!_.current)return;let i=_.current,s=new nC({cursorBlink:!0,fontSize:13,fontFamily:'"Cascadia Code", "Fira Code", "Menlo", monospace',theme:V,allowProposedApi:!0}),r=new nx;s.loadAddon(r),s.open(_.current),r.fit(),f.current=s,p.current=r,C.current&&s.focus(),s.attachCustomKeyEventHandler(()=>!w.current),s.buffer.onBufferChange(e=>{"normal"===e.type&&s.refresh(0,s.rows-1)});let n=0,o=e=>{let i=performance.now();""===e.data&&i-n<100?e.stopImmediatePropagation():n=i};i.addEventListener("compositionend",o,!0);let a=null,l=0,h=e=>{if(1!==e.touches.length){a=null;return}a=e.touches[0].clientY,l=s.buffer.active.viewportY},c=e=>{if(null===a||1!==e.touches.length)return;let r=i.clientHeight/s.rows;if(r<=0)return;let n=(a-e.touches[0].clientY)/r;s.scrollToLine(Math.round(l+n))};i.addEventListener("touchstart",h,{passive:!0}),i.addEventListener("touchmove",c,{passive:!0});let d=new ResizeObserver(()=>{!w.current&&(r.fit(),E.current||Y())});d.observe(_.current);let u=new AbortController;return G(e,s,u.signal),()=>{u.abort(),d.disconnect(),i.removeEventListener("compositionend",o,!0),i.removeEventListener("touchstart",h),i.removeEventListener("touchmove",c),M.current?.dispose(),M.current=null,s.dispose(),f.current=null,p.current=null,g.current?.removeAllListeners(),g.current?.disconnect(),g.current=null}},[]),(0,v.useEffect)(()=>{f.current&&(f.current.options.theme=V)},[j]),(0,v.useEffect)(()=>{function e(){w.current=!0,f.current?.blur()}function i(){if(setTimeout(()=>{let e=f.current;if(e){let i=64===e.cols?63:64;e.resize(i,e.rows),Y(),setTimeout(()=>{w.current=!1,p.current?.fit(),Y()},100)}else w.current=!1},300),!C.current)return;let e=_.current?.querySelector("textarea.xterm-helper-textarea");e?.focus()}return window.addEventListener("editor-session-open",e),window.addEventListener("editor-session-done",i),()=>{window.removeEventListener("editor-session-open",e),window.removeEventListener("editor-session-done",i)}},[]),(0,v.useEffect)(()=>{function e(e){let i=g.current;if(!i||!i.connected||D.current)return;D.current=setTimeout(()=>{D.current=null,T.current&&(i.off("health-check-ack",T.current),T.current=null),i.disconnect(),i.connect(),P("connecting")},6e3);let s=()=>{D.current&&(clearTimeout(D.current),D.current=null),T.current=null,e.refocus&&C.current&&f.current?.focus()};T.current=s,i.once("health-check-ack",s),i.emit("health-check")}function i(){"visible"===document.visibilityState&&e({refocus:!0})}let s=setInterval(()=>{"visible"!==document.visibilityState||"connected"===x.current&&e({refocus:!1})},8e3);return document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i),clearInterval(s),D.current&&(clearTimeout(D.current),D.current=null),T.current&&(g.current?.off("health-check-ack",T.current),T.current=null)}},[]),(0,v.useImperativeHandle)(u,()=>({sendInput:e=>{let i=g.current,s=S.current;i?.connected&&s&&i.emit("input",{sessionId:s,data:e})},focus:()=>{f.current?.focus()}}));let Z=(0,v.useCallback)(()=>{navigator.clipboard.writeText(e).then(()=>{z(!0),setTimeout(()=>z(!1),2e3)})},[e]),Q="connecting"===L,ee="paused"===L||"exited"===L||"error"===L,et="connected"===L,ei=H.filter(e=>"deleted"!==e.status),es=ei.filter(e=>"completed"===e.status).length,er=ei.length,en=e.length>8?`${e.slice(0,8)}…`:e;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("div",{className:`flex flex-col h-full min-h-0 ${o}`,children:[(0,m.jsxs)("div",{className:"flex items-center gap-2 px-2 py-1 border-b border-border flex-shrink-0 bg-card",children:[(0,m.jsx)("span",{className:"font-mono text-xs text-muted-foreground",title:e,children:en}),(0,m.jsx)(U.Button,{variant:"ghost",size:"icon-xs",onClick:Z,className:"text-muted-foreground hover:text-foreground",title:"Copy tab ID",children:F?(0,m.jsx)(nD.Check,{className:"w-3 h-3 text-success"}):(0,m.jsx)(nR.Copy,{className:"w-3 h-3"})}),(0,m.jsxs)(U.Button,{size:"xs",onClick:function(){let e=g.current,i=S.current;if(!e||!e.connected||!i)return;let s=`claude --dangerously-skip-permissions --resume ${i} 2>/dev/null || claude --dangerously-skip-permissions --session-id ${i}
22
- `;e.emit("input",{sessionId:i,data:s})},disabled:!et,title:"Run Claude",children:[(0,m.jsx)(nM,{className:"w-3 h-3"}),"Run Claude"]}),(0,m.jsxs)(U.Button,{variant:"ghost",size:"xs",onClick:()=>y(!0),disabled:!et,className:"text-muted-foreground hover:text-foreground",title:"Open editor input",children:[(0,m.jsx)(nT,{className:"w-3 h-3"}),"Open Editor"]}),er>0&&(0,m.jsxs)("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",title:H.find(e=>"in_progress"===e.status)?.content??"",children:[(0,m.jsx)(nL.Progress,{value:es,max:er,className:"w-16 gap-0 [&_[data-slot=progress-track]]:h-[3px]"}),(0,m.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[es,"/",er]})]})]}),(0,m.jsxs)("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[(0,m.jsx)("div",{ref:_,className:"w-full h-full",style:{padding:"4px"}}),Q&&(0,m.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background",children:(0,m.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:[(0,m.jsx)(O.Loader2,{className:"w-4 h-4 animate-spin"}),(0,m.jsx)("span",{children:"Connecting..."})]})}),ee&&(0,m.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/90",children:(0,m.jsxs)("div",{className:"text-center space-y-2",children:["error"===L&&(0,m.jsx)("p",{className:"text-xs text-destructive",children:"Connection failed"}),"exited"===L&&(0,m.jsx)("p",{className:"text-xs text-muted-foreground",children:"Session ended"}),"paused"===L&&(0,m.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paused"}),(0,m.jsx)(U.Button,{size:"xs",onClick:J,children:"Reconnect"})]})})]})]}),(0,m.jsx)(nB.MonacoEditorModal,{open:b,onOpenChange:e=>{e.open||y(!1)},onSubmit:e=>{f.current&&e&&f.current.paste(e),y(!1)},title:"Terminal Input",submitLabel:"Paste"})]})}),nO=(0,v.forwardRef)(function({task:e,tabs:i,activeTabId:s,onTabChange:r,onTabCreate:n,onTabDelete:o,onTodosUpdated:a},l){let[h,c]=(0,v.useState)(()=>new Set(s?[s]:[]));(0,v.useEffect)(()=>{s&&c(e=>{if(e.has(s))return e;let i=new Set(e);return i.add(s),i})},[s]);let[d,u]=(0,v.useState)(()=>new Map(i.map(e=>[e.tab_id,{terminal:"connecting",claude:e.status}])));(0,v.useEffect)(()=>{u(e=>{let s=!1,r=new Map(e);for(let e of i)r.has(e.tab_id)||(r.set(e.tab_id,{terminal:"connecting",claude:e.status}),s=!0);return s?r:e})},[i]);let _=(0,v.useRef)(new Map);(0,v.useEffect)(()=>{s&&_.current.get(s)?.focus()},[s]);let f=(0,v.useCallback)((e,i,s)=>{u(r=>{let n=new Map(r);return n.set(e,{terminal:i,claude:s}),n})},[]);(0,v.useImperativeHandle)(l,()=>({sendInput:(e,i)=>{let s=_.current.get(e);s?.sendInput(i)}}));let p=(0,v.useCallback)(e=>{c(i=>{if(i.has(e))return i;let s=new Set(i);return s.add(e),s}),r(e)},[r]),g=(0,v.useCallback)(async e=>{let i=await n(e);i&&c(e=>{let s=new Set(e);return s.add(i),s})},[n]),S=(0,v.useCallback)(()=>g("terminal"),[g]),b=(0,v.useCallback)(()=>g("claude"),[g]),y=(0,v.useCallback)(e=>{s&&_.current.get(s)?.sendInput(e)},[s]),w=(0,v.useCallback)(e=>{c(i=>{let s=new Set(i);return s.delete(e),s}),u(i=>{let s=new Map(i);return s.delete(e),s}),_.current.delete(e),o(e)},[o]);return(0,m.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,m.jsx)("div",{className:"px-4 pt-4 flex-shrink-0",children:i.length>0?(0,m.jsx)(V,{tabs:i,activeTabId:s,onTabChange:p,onTabCreateTerminal:S,onTabCreateClaude:b,onTabDelete:w,tabStatusMap:d,onVoiceInputTranscribed:y}):(0,m.jsxs)("div",{className:"text-center py-8",children:[(0,m.jsx)("p",{className:"text-muted-foreground mb-4",children:"No tabs yet"}),(0,m.jsx)(U.Button,{size:"lg",onClick:b,children:"+ Create First Tab"})]})}),(0,m.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[i.map(i=>{let r=h.has(i.tab_id),n=i.tab_id===s;return r?(0,m.jsx)("div",{className:"absolute inset-0 flex flex-col px-4 pb-4 pt-2",style:{visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:(0,m.jsx)(nP,{ref:e=>{e?_.current.set(i.tab_id,e):_.current.delete(i.tab_id)},tabId:i.tab_id,isActive:n,cwd:e.worktreePath,worktreePath:e.worktreePath,command:"terminal"===i.mode?void 0:`claude --dangerously-skip-permissions --resume ${i.tab_id} 2>/dev/null || claude --dangerously-skip-permissions --session-id ${i.tab_id}`,className:"h-full",initialTodos:i.todos,initialClaudeStatus:i.status,onTodosUpdated:a,onStatusChange:f})},i.tab_id):null}),i.length>0&&!s&&(0,m.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Select a tab to view terminal"})]})]})});e.s([],38727),e.i(38727);var nI=e.i(67805);let nA=v.createContext(void 0);function nN(e){let i=v.useContext(nA);if(void 0===i&&!e)throw Error((0,nI.default)(33));return i}let nH=v.createContext(void 0);function nW(e){let i=v.useContext(nH);if(void 0===i&&!e)throw Error((0,nI.default)(36));return i}var nF=e.i(27601),nz=e.i(83590);let n$=v.forwardRef(function(e,i){let{className:s,render:r,...n}=e,{store:o}=nW(),{arrowRef:a,side:l,align:h,arrowUncentered:c,arrowStyles:d}=nN(),u=o.useState("open");return(0,nF.useRenderElement)("div",e,{ref:[a,i],stateAttributesMapping:nz.popupStateMapping,state:{open:u,side:l,align:h,uncentered:c},props:{style:d,"aria-hidden":!0,...n}})});var nU=e.i(84759);let nK=v.createContext(void 0);function nj(e=!0){let i=v.useContext(nK);if(void 0===i&&!e)throw Error((0,nI.default)(25));return i}var nV=e.i(3404);let nq={...nz.popupStateMapping,...nU.transitionStatusMapping},nY=v.forwardRef(function(e,i){let{className:s,render:r,...n}=e,{store:o}=nW(),a=o.useState("open"),l=o.useState("mounted"),h=o.useState("transitionStatus"),c=o.useState("lastOpenChangeReason"),d=nj();return(0,nF.useRenderElement)("div",e,{ref:d?.backdropRef?[i,d.backdropRef]:i,state:{open:a,transitionStatus:h},stateAttributesMapping:nq,props:[{role:"presentation",hidden:!l,style:{pointerEvents:c===nV.REASONS.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},n]})});var nX=e.i(76477),nG=e.i(94349);let nJ=v.createContext(void 0);var nZ=e.i(26292),nQ=e.i(91730),n0=e.i(19805),n1=e.i(57666);function n2(e){let{closeOnClick:i,highlighted:s,id:r,nodeId:n,store:o,typingRef:a,itemRef:l,itemMetadata:h}=e,{events:c}=o.useState("floatingTreeRoot"),d=nj(!0),u=void 0!==d;return v.useMemo(()=>({id:r,role:"menuitem",tabIndex:s?0:-1,onKeyDown(e){" "===e.key&&a?.current&&e.preventDefault()},onMouseMove(e){n&&c.emit("itemhover",{nodeId:n,target:e.currentTarget})},onClick(e){i&&c.emit("close",{domEvent:e,reason:nV.REASONS.itemPress})},onMouseUp(e){if(d){let i=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,u&&i&&1>=Math.abs(e.clientX-i.x)&&1>=Math.abs(e.clientY-i.y)||u&&!n1.isMac&&2===e.button)return}l.current&&o.context.allowMouseUpTriggerRef.current&&(!u||2===e.button)&&(!h||"regular-item"===h.type)&&l.current.click()}}),[i,s,r,c,n,o,a,l,d,u,h])}let n5={type:"regular-item"};function n3(e){let{closeOnClick:i,disabled:s=!1,highlighted:r,id:n,store:o,typingRef:a=o.context.typingRef,nativeButton:l,itemMetadata:h,nodeId:c}=e,d=v.useRef(null),{getButtonProps:u,buttonRef:_}=(0,nQ.useButton)({disabled:s,focusableWhenDisabled:!0,native:l,composite:!0}),f=n2({closeOnClick:i,highlighted:r,id:n,nodeId:c,store:o,typingRef:a,itemRef:d,itemMetadata:h}),p=v.useCallback(e=>(0,n0.mergeProps)(f,{onMouseEnter(){"submenu-trigger"===h.type&&h.setActive()}},e,u),[f,u,h]),g=(0,nZ.useMergedRefs)(d,_);return v.useMemo(()=>({getItemProps:p,itemRef:g}),[p,g])}var n6=e.i(977);let n4=v.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}}),n8=((f={})[f.None=0]="None",f[f.GuessFromOrder=1]="GuessFromOrder",f);function n7(e={}){let{label:i,metadata:s,textRef:r,indexGuessBehavior:n,index:o}=e,{register:a,unregister:l,subscribeMapChange:h,elementsRef:c,labelsRef:d,nextIndexRef:u}=v.useContext(n4),_=v.useRef(-1),[f,p]=v.useState(o??(n===n8.GuessFromOrder?()=>{if(-1===_.current){let e=u.current;u.current+=1,_.current=e}return _.current}:-1)),g=v.useRef(null),m=v.useCallback(e=>{if(g.current=e,-1!==f&&null!==e&&(c.current[f]=e,d)){let s=void 0!==i;d.current[f]=s?i:r?.current?.textContent??e.textContent}},[f,c,d,i,r]);return(0,n6.useIsoLayoutEffect)(()=>{if(null!=o)return;let e=g.current;if(e)return a(e,s),()=>{l(e)}},[o,a,l,s]),(0,n6.useIsoLayoutEffect)(()=>{if(null==o)return h(e=>{let i=g.current?e.get(g.current)?.index:null;null!=i&&p(i)})},[o,h,p]),v.useMemo(()=>({ref:m,index:f}),[f,m])}var n9=e.i(89879);let oe=((p={}).checked="data-checked",p.unchecked="data-unchecked",p.disabled="data-disabled",p.highlighted="data-highlighted",p),ot={checked:e=>e?{[oe.checked]:""}:{[oe.unchecked]:""},...nU.transitionStatusMapping};var oi=e.i(5963);let os=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,nativeButton:a=!1,disabled:l=!1,closeOnClick:h=!1,checked:c,defaultChecked:d,onCheckedChange:u,..._}=e,f=n7({label:o}),p=nN(!0),g=(0,n9.useBaseUiId)(n),{store:S}=nW(),b=S.useState("isActive",f.index),y=S.useState("itemProps"),[w,C]=(0,nG.useControlled)({controlled:c,default:d??!1,name:"MenuCheckboxItem",state:"checked"}),{getItemProps:x,itemRef:k}=n3({closeOnClick:h,disabled:l,highlighted:b,id:g,store:S,nativeButton:a,nodeId:p?.nodeId,itemMetadata:n5}),E=v.useMemo(()=>({disabled:l,highlighted:b,checked:w}),[l,b,w]),R=(0,nX.useStableCallback)(e=>{let i={...(0,oi.createChangeEventDetails)(nV.REASONS.itemPress,e.nativeEvent),preventUnmountOnClose:()=>{}};u?.(!w,i),i.isCanceled||C(e=>!e)}),M=(0,nF.useRenderElement)("div",e,{state:E,stateAttributesMapping:ot,props:[y,{role:"menuitemcheckbox","aria-checked":w,onClick:R},_,x],ref:[k,i,f.ref]});return(0,m.jsx)(nJ.Provider,{value:E,children:M})});var or=e.i(88841),on=e.i(89269);let oo=v.forwardRef(function(e,i){let{render:s,className:r,keepMounted:n=!1,...o}=e,a=function(){let e=v.useContext(nJ);if(void 0===e)throw Error((0,nI.default)(30));return e}(),l=v.useRef(null),{transitionStatus:h,setMounted:c}=(0,or.useTransitionStatus)(a.checked);(0,on.useOpenChangeComplete)({open:a.checked,ref:l,onComplete(){a.checked||c(!1)}});let d={checked:a.checked,disabled:a.disabled,highlighted:a.highlighted,transitionStatus:h};return(0,nF.useRenderElement)("span",e,{state:d,ref:[i,l],stateAttributesMapping:ot,props:{"aria-hidden":!0,...o},enabled:n||a.checked})}),oa=v.createContext(void 0),ol=v.forwardRef(function(e,i){let{render:s,className:r,...n}=e,[o,a]=v.useState(void 0),l=v.useMemo(()=>({setLabelId:a}),[a]),h=(0,nF.useRenderElement)("div",e,{ref:i,props:{role:"group","aria-labelledby":o,...n}});return(0,m.jsx)(oa.Provider,{value:l,children:h})}),oh=v.forwardRef(function(e,i){let{className:s,render:r,id:n,...o}=e,a=(0,n9.useBaseUiId)(n),{setLabelId:l}=function(){let e=v.useContext(oa);if(void 0===e)throw Error((0,nI.default)(31));return e}();return(0,n6.useIsoLayoutEffect)(()=>(l(a),()=>{l(void 0)}),[l,a]),(0,nF.useRenderElement)("div",e,{ref:i,props:{id:a,role:"presentation",...o}})}),oc=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,nativeButton:a=!1,disabled:l=!1,closeOnClick:h=!0,...c}=e,d=n7({label:o}),u=nN(!0),_=(0,n9.useBaseUiId)(n),{store:f}=nW(),p=f.useState("isActive",d.index),g=f.useState("itemProps"),{getItemProps:m,itemRef:v}=n3({closeOnClick:h,disabled:l,highlighted:p,id:_,store:f,nativeButton:a,nodeId:u?.nodeId,itemMetadata:n5});return(0,nF.useRenderElement)("div",e,{state:{disabled:l,highlighted:p},props:[g,c,m],ref:[v,i,d.ref]})}),od=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,closeOnClick:a=!1,...l}=e,h=v.useRef(null),c=n7({label:o}),d=nN(!0),u=d?.nodeId,_=(0,n9.useBaseUiId)(n),{store:f}=nW(),p=f.useState("isActive",c.index),g=f.useState("itemProps"),m=f.context.typingRef,{getButtonProps:S,buttonRef:b}=(0,nQ.useButton)({native:!1,composite:!0}),y=n2({closeOnClick:a,highlighted:p,id:_,nodeId:u,store:f,typingRef:m,itemRef:h}),w=v.useMemo(()=>({highlighted:p}),[p]);return(0,nF.useRenderElement)("a",e,{state:w,props:[g,l,function(e){return(0,n0.mergeProps)(y,e,S)}],ref:[h,b,i,c.ref]})});var ou=e.i(88306),o_=e.i(61896),of=e.i(60752),op=e.i(92238),og=e.i(18847);let om={...nz.popupStateMapping,...nU.transitionStatusMapping},ov=v.forwardRef(function(e,i){let{render:s,className:r,finalFocus:n,...o}=e,{store:a}=nW(),{side:l,align:h}=nN(),c=null!=(0,of.useToolbarRootContext)(!0),d=a.useState("open"),u=a.useState("transitionStatus"),_=a.useState("popupProps"),f=a.useState("mounted"),p=a.useState("instantType"),g=a.useState("activeTriggerElement"),S=a.useState("parent"),b=a.useState("lastOpenChangeReason"),y=a.useState("rootId"),w=a.useState("floatingRootContext"),C=a.useState("floatingTreeRoot"),x=a.useState("closeDelay"),k=a.useState("activeTriggerElement"),E="context-menu"===S.type;(0,on.useOpenChangeComplete)({open:d,ref:a.context.popupRef,onComplete(){d&&a.context.onOpenChangeComplete?.(!0)}}),v.useEffect(()=>{function e(e){a.setOpen(!1,(0,oi.createChangeEventDetails)(e.reason,e.domEvent))}return C.events.on("close",e),()=>{C.events.off("close",e)}},[C.events,a]);let R=a.useState("hoverEnabled"),M=a.useState("disabled");(0,o_.useHoverFloatingInteraction)(w,{enabled:R&&!M&&!E&&"menubar"!==S.type,closeDelay:x});let D={transitionStatus:u,side:l,align:h,open:d,nested:"menu"===S.type,instant:p},T=v.useCallback(e=>{a.set("popupElement",e)},[a]),B=(0,nF.useRenderElement)("div",e,{state:D,ref:[i,a.context.popupRef,T],stateAttributesMapping:om,props:[_,{onKeyDown(e){c&&op.COMPOSITE_KEYS.has(e.key)&&e.stopPropagation()}},(0,og.getDisabledMountTransitionStyles)(u),o,{"data-rootownerid":y}]}),L=void 0===S.type||E;return(g||"menubar"===S.type&&b!==nV.REASONS.outsidePress)&&(L=!0),(0,m.jsx)(ou.FloatingFocusManager,{context:w,modal:E,disabled:!f,returnFocus:void 0===n?L:n,initialFocus:"menu"!==S.type,restoreFocus:!0,externalTree:"menubar"!==S.type?C:void 0,previousFocusableElement:k,nextFocusableElement:void 0===S.type?a.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:void 0===S.type?a.context.beforeContentFocusGuardRef:void 0,children:B})});var oS=e.i(37692);let ob=v.createContext(void 0),oy=v.forwardRef(function(e,i){let{keepMounted:s=!1,...r}=e,{store:n}=nW();return n.useState("mounted")||s?(0,m.jsx)(ob.Provider,{value:s,children:(0,m.jsx)(oS.FloatingPortal,{ref:i,...r})}):null});var ow=e.i(58130),oC=e.i(66745),ox=e.i(51665),ok=e.i(56590),oE=e.i(30628);function oR(e){let{children:i,elementsRef:s,labelsRef:r,onMapChange:n}=e,o=(0,nX.useStableCallback)(n),a=v.useRef(0),l=(0,oE.useRefWithInit)(oD).current,h=(0,oE.useRefWithInit)(oM).current,[c,d]=v.useState(0),u=v.useRef(c),_=(0,nX.useStableCallback)((e,i)=>{h.set(e,i??null),u.current+=1,d(u.current)}),f=(0,nX.useStableCallback)(e=>{h.delete(e),u.current+=1,d(u.current)}),p=v.useMemo(()=>{let e=new Map;return Array.from(h.keys()).filter(e=>e.isConnected).sort(oT).forEach((i,s)=>{let r=h.get(i)??{};e.set(i,{...r,index:s})}),e},[h,c]);(0,n6.useIsoLayoutEffect)(()=>{if("function"!=typeof MutationObserver||0===p.size)return;let e=new MutationObserver(e=>{let i=new Set,s=e=>i.has(e)?i.delete(e):i.add(e);e.forEach(e=>{e.removedNodes.forEach(s),e.addedNodes.forEach(s)}),0===i.size&&(u.current+=1,d(u.current))});return p.forEach((i,s)=>{s.parentElement&&e.observe(s.parentElement,{childList:!0})}),()=>{e.disconnect()}},[p]),(0,n6.useIsoLayoutEffect)(()=>{u.current===c&&(s.current.length!==p.size&&(s.current.length=p.size),r&&r.current.length!==p.size&&(r.current.length=p.size),a.current=p.size),o(p)},[o,p,s,r,c]),(0,n6.useIsoLayoutEffect)(()=>()=>{s.current=[]},[s]),(0,n6.useIsoLayoutEffect)(()=>()=>{r&&(r.current=[])},[r]);let g=(0,nX.useStableCallback)(e=>(l.add(e),()=>{l.delete(e)}));(0,n6.useIsoLayoutEffect)(()=>{l.forEach(e=>e(p))},[l,p]);let S=v.useMemo(()=>({register:_,unregister:f,subscribeMapChange:g,elementsRef:s,labelsRef:r,nextIndexRef:a}),[_,f,g,s,r,a]);return(0,m.jsx)(n4.Provider,{value:S,children:i})}function oM(){return new Map}function oD(){return new Set}function oT(e,i){let s=e.compareDocumentPosition(i);return s&Node.DOCUMENT_POSITION_FOLLOWING||s&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:s&Node.DOCUMENT_POSITION_PRECEDING||s&Node.DOCUMENT_POSITION_CONTAINS?1:0}var oB=e.i(36893),oL=e.i(7335),oP=e.i(67569),oO=e.i(77817);let oI=v.forwardRef(function(e,i){let{anchor:s,positionMethod:r="absolute",className:n,render:o,side:a,align:l,sideOffset:h=0,alignOffset:c=0,collisionBoundary:d="clipping-ancestors",collisionPadding:u=5,arrowPadding:_=5,sticky:f=!1,disableAnchorTracking:p=!1,collisionAvoidance:g=oL.DROPDOWN_COLLISION_AVOIDANCE,...S}=e,{store:b}=nW(),y=function(){let e=v.useContext(ob);if(void 0===e)throw Error((0,nI.default)(32));return e}(),w=nj(!0),C=b.useState("parent"),x=b.useState("floatingRootContext"),k=b.useState("floatingTreeRoot"),E=b.useState("mounted"),R=b.useState("open"),M=b.useState("modal"),D=b.useState("activeTriggerElement"),T=b.useState("transitionStatus"),B=b.useState("positionerElement"),L=b.useState("instantType"),P=b.useState("hasViewport"),O=b.useState("lastOpenChangeReason"),I=b.useState("floatingNodeId"),A=b.useState("floatingParentNodeId"),N=x.useState("domReferenceElement"),H=v.useRef(null),W=(0,oO.useAnimationsFinished)(B,!1,!1),F=s,z=h,$=c,U=l,K=g;"context-menu"===C.type&&(F=s??C.context?.anchor,U=U??"start",a||"center"===U||($=e.alignOffset??2,z=e.sideOffset??-5));let j=a,V=U;"menu"===C.type?(j=j??"inline-end",V=V??"start",K=e.collisionAvoidance??oL.POPUP_COLLISION_AVOIDANCE):"menubar"===C.type&&(j=j??"bottom",V=V??"start");let q="context-menu"===C.type,Y=(0,ok.useAnchorPositioning)({anchor:F,floatingRootContext:x,positionMethod:w?"fixed":r,mounted:E,side:j,sideOffset:z,align:V,alignOffset:$,arrowPadding:q?0:_,collisionBoundary:d,collisionPadding:u,sticky:f,nodeId:I,keepMounted:y,disableAnchorTracking:p,collisionAvoidance:K,shiftCrossAxis:q&&!("side"in K&&"flip"===K.side),externalTree:k,adaptiveOrigin:P?oP.adaptiveOrigin:void 0}),X=v.useMemo(()=>{let e={};return R||(e.pointerEvents="none"),{role:"presentation",hidden:!E,style:{...Y.positionerStyles,...e}}},[R,E,Y.positionerStyles]);v.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&b.set("hoverEnabled",!1),e.nodeId!==I&&e.parentNodeId===b.select("floatingParentNodeId")&&b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.siblingOpen)))}return k.events.on("menuopenchange",e),()=>{k.events.off("menuopenchange",e)}},[b,k.events,I]),v.useEffect(()=>{if(null!=b.select("floatingParentNodeId"))return k.events.on("menuopenchange",e),()=>{k.events.off("menuopenchange",e)};function e(e){if(e.open||e.nodeId!==b.select("floatingParentNodeId"))return;let i=e.reason??nV.REASONS.siblingOpen;b.setOpen(!1,(0,oi.createChangeEventDetails)(i))}},[k.events,b]);let G=(0,oC.useTimeout)();v.useEffect(()=>{R||G.clear()},[R,G]),v.useEffect(()=>{function e(e){if(R&&e.nodeId===b.select("floatingParentNodeId"))if(e.target&&D&&D!==e.target){let e=b.select("closeDelay");e>0?G.isStarted()||G.start(e,()=>{b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.siblingOpen))}):b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.siblingOpen))}else G.clear()}return k.events.on("itemhover",e),()=>{k.events.off("itemhover",e)}},[k.events,R,D,b,G]),v.useEffect(()=>{let e={open:R,nodeId:I,parentNodeId:A,reason:b.select("lastOpenChangeReason")};k.events.emit("menuopenchange",e)},[k.events,R,b,I,A]),(0,n6.useIsoLayoutEffect)(()=>{let e=H.current;if(N&&(H.current=N),e&&N&&N!==e){b.set("instantType",void 0);let e=new AbortController;return W(()=>{b.set("instantType","trigger-change")},e.signal),()=>{e.abort()}}},[N,W,b]);let J={open:R,side:Y.side,align:Y.align,anchorHidden:Y.anchorHidden,nested:"menu"===C.type,instant:L},Z=v.useMemo(()=>({side:Y.side,align:Y.align,arrowRef:Y.arrowRef,arrowUncentered:Y.arrowUncentered,arrowStyles:Y.arrowStyles,nodeId:Y.context.nodeId}),[Y.side,Y.align,Y.arrowRef,Y.arrowUncentered,Y.arrowStyles,Y.context.nodeId]),Q=(0,nF.useRenderElement)("div",e,{state:J,stateAttributesMapping:nz.popupStateMapping,ref:[i,b.useStateSetter("positionerElement")],props:[X,(0,og.getDisabledMountTransitionStyles)(T),S]}),ee=E&&"menu"!==C.type&&("menubar"!==C.type&&M&&O!==nV.REASONS.triggerHover||"menubar"===C.type&&C.context.modal),et=null;return"menubar"===C.type?et=C.context.contentElement:void 0===C.type&&(et=D),(0,m.jsxs)(nA.Provider,{value:Z,children:[ee&&(0,m.jsx)(oB.InternalBackdrop,{ref:"context-menu"===C.type||"nested-context-menu"===C.type?C.context.internalBackdropRef:null,inert:(0,ow.inertValue)(!R),cutout:et}),(0,m.jsx)(ox.FloatingNode,{id:I,children:(0,m.jsx)(oR,{elementsRef:b.context.itemDomElements,labelsRef:b.context.itemLabels,children:Q})})]})}),oA=v.createContext(void 0),oN=v.memo(v.forwardRef(function(e,i){let{render:s,className:r,value:n,defaultValue:o,onValueChange:a,disabled:l=!1,...h}=e,[c,d]=(0,nG.useControlled)({controlled:n,default:o,name:"MenuRadioGroup"}),u=(0,nX.useStableCallback)(a),_=(0,nX.useStableCallback)((e,i)=>{u?.(e,i),i.isCanceled||d(e)}),f=(0,nF.useRenderElement)("div",e,{state:{disabled:l},ref:i,props:{role:"group","aria-disabled":l||void 0,...h}}),p=v.useMemo(()=>({value:c,setValue:_,disabled:l}),[c,_,l]);return(0,m.jsx)(oA.Provider,{value:p,children:f})})),oH=v.createContext(void 0),oW=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,nativeButton:a=!1,disabled:l=!1,closeOnClick:h=!1,value:c,...d}=e,u=n7({label:o}),_=nN(!0),f=(0,n9.useBaseUiId)(n),{store:p}=nW(),g=p.useState("isActive",u.index),S=p.useState("itemProps"),{value:b,setValue:y,disabled:w}=function(){let e=v.useContext(oA);if(void 0===e)throw Error((0,nI.default)(34));return e}(),C=w||l,x=b===c,{getItemProps:k,itemRef:E}=n3({closeOnClick:h,disabled:C,highlighted:g,id:f,store:p,nativeButton:a,nodeId:_?.nodeId,itemMetadata:n5}),R=v.useMemo(()=>({disabled:C,highlighted:g,checked:x}),[C,g,x]),M=(0,nX.useStableCallback)(e=>{y(c,{...(0,oi.createChangeEventDetails)(nV.REASONS.itemPress,e.nativeEvent),preventUnmountOnClose:()=>{}})}),D=(0,nF.useRenderElement)("div",e,{state:R,stateAttributesMapping:ot,props:[S,{role:"menuitemradio","aria-checked":x,onClick:M},d,k],ref:[E,i,u.ref]});return(0,m.jsx)(oH.Provider,{value:R,children:D})}),oF=v.forwardRef(function(e,i){let{render:s,className:r,keepMounted:n=!1,...o}=e,a=function(){let e=v.useContext(oH);if(void 0===e)throw Error((0,nI.default)(35));return e}(),l=v.useRef(null),{transitionStatus:h,setMounted:c}=(0,or.useTransitionStatus)(a.checked);(0,on.useOpenChangeComplete)({open:a.checked,ref:l,onComplete(){a.checked||c(!1)}});let d={checked:a.checked,disabled:a.disabled,highlighted:a.highlighted,transitionStatus:h};return(0,nF.useRenderElement)("span",e,{state:d,stateAttributesMapping:ot,ref:[i,l],props:{"aria-hidden":!0,...o},enabled:n||a.checked})});var oz=e.i(83799),o$=e.i(58509),oU=e.i(66196),oK=e.i(17514),oj=e.i(3851),oV=e.i(33605),oq=e.i(89633),oY=e.i(29315),oX=e.i(231),oG=e.i(90219),oJ=e.i(47857),oZ=e.i(82033),oQ=e.i(43801),o0=e.i(98442),o1=e.i(494);function o2(e,i,s){switch(e){case"vertical":return i;case"horizontal":return s;default:return i||s}}function o5(e,i){return o2(i,e===o1.ARROW_UP||e===o1.ARROW_DOWN,e===o1.ARROW_LEFT||e===o1.ARROW_RIGHT)}function o3(e,i,s){return o2(i,e===o1.ARROW_DOWN,s?e===o1.ARROW_LEFT:e===o1.ARROW_RIGHT)||"Enter"===e||" "===e||""===e}var o6=e.i(26665),o4=e.i(6157);let o8=v.createContext(null);function o7(e){let i=v.useContext(o8);if(null===i&&!e)throw Error((0,nI.default)(5));return i}var o9=e.i(79144),ae=e.i(50091),at=e.i(83921),ai=e.i(98263),as=e.i(89429),ar=e.i(628),an=e.i(69375);let ao={...ar.popupStoreSelectors,disabled:(0,at.createSelector)(e=>"menubar"===e.parent.type&&e.parent.context.disabled||e.disabled),modal:(0,at.createSelector)(e=>(void 0===e.parent.type||"context-menu"===e.parent.type)&&(e.modal??!0)),allowMouseEnter:(0,at.createSelector)(e=>e.allowMouseEnter),stickIfOpen:(0,at.createSelector)(e=>e.stickIfOpen),parent:(0,at.createSelector)(e=>e.parent),rootId:(0,at.createSelector)(e=>"menu"===e.parent.type?e.parent.store.select("rootId"):void 0!==e.parent.type?e.parent.context.rootId:e.rootId),activeIndex:(0,at.createSelector)(e=>e.activeIndex),isActive:(0,at.createSelector)((e,i)=>e.activeIndex===i),hoverEnabled:(0,at.createSelector)(e=>e.hoverEnabled),instantType:(0,at.createSelector)(e=>e.instantType),lastOpenChangeReason:(0,at.createSelector)(e=>e.openChangeReason),floatingTreeRoot:(0,at.createSelector)(e=>"menu"===e.parent.type?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:(0,at.createSelector)(e=>e.floatingNodeId),floatingParentNodeId:(0,at.createSelector)(e=>e.floatingParentNodeId),itemProps:(0,at.createSelector)(e=>e.itemProps),closeDelay:(0,at.createSelector)(e=>e.closeDelay),hasViewport:(0,at.createSelector)(e=>e.hasViewport),keyboardEventRelay:(0,at.createSelector)(e=>e.keyboardEventRelay?e.keyboardEventRelay:"menu"===e.parent.type?e.parent.store.select("keyboardEventRelay"):void 0)};class aa extends ai.ReactStore{constructor(e){super({...{...(0,ar.createInitialPopupStoreState)(),disabled:!1,modal:!0,allowMouseEnter:!1,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new as.FloatingTreeStore,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:oK.EMPTY_OBJECT,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1},...e},{positionerRef:v.createRef(),popupRef:v.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:v.createRef(),beforeContentFocusGuardRef:v.createRef(),onOpenChangeComplete:void 0,triggerElements:new an.PopupTriggerMap},ao),this.unsubscribeParentListener=this.observe("parent",e=>{if(this.unsubscribeParentListener?.(),"menu"===e.type){let i=e.store.select("rootId"),s=e.store.select("floatingTreeRoot"),r=e.store.select("keyboardEventRelay");this.unsubscribeParentListener=e.store.subscribe(()=>{let n=e.store.select("rootId"),o=e.store.select("floatingTreeRoot"),a=e.store.select("keyboardEventRelay");(i!==n||s!==o||r!==a)&&(i=n,s=o,r=a,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}void 0!==e.type&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,i){this.state.floatingRootContext.context.events.emit("setOpen",{open:e,eventDetails:i})}static useStore(e,i){let s=(0,oE.useRefWithInit)(()=>new aa(i)).current;return e??s}unsubscribeParentListener=null}var al=e.i(58642);let ah=v.createContext(void 0);function ac(){return v.useContext(ah)}let ad=(0,oj.fastComponent)(function(e){let i,s,{children:r,open:n,onOpenChange:o,onOpenChangeComplete:a,defaultOpen:l=!1,disabled:h=!1,modal:c,loopFocus:d=!0,orientation:u="vertical",actionsRef:_,closeParentOnEsc:f=!1,handle:p,triggerId:g,defaultTriggerId:S=null,highlightItemOnHover:b=!0}=e,y=nj(!0),w=nW(!0),C=o7(!0),x=ac(),k=v.useMemo(()=>x&&w?{type:"menu",store:w.store}:C?{type:"menubar",context:C}:y&&!w?{type:"context-menu",context:y}:{type:void 0},[y,w,C,x]),E=aa.useStore(p?.store,{open:l,openProp:n,activeTriggerId:S,triggerIdProp:g,parent:k});(0,o$.useOnFirstRender)(()=>{void 0===n&&!1===E.state.open&&!0===l&&E.update({open:!0,activeTriggerId:S})}),E.useControlledProp("openProp",n),E.useControlledProp("triggerIdProp",g),E.useContextCallback("onOpenChangeComplete",a);let R=E.useState("floatingTreeRoot"),M=(0,ox.useFloatingNodeId)(R),D=(0,ox.useFloatingParentNodeId)();(0,n6.useIsoLayoutEffect)(()=>{y&&!w?E.update({parent:{type:"context-menu",context:y},floatingNodeId:M,floatingParentNodeId:D}):w&&E.update({floatingNodeId:M,floatingParentNodeId:D})},[y,w,M,D,E]);let T=E.useState("open"),B=E.useState("activeTriggerElement"),L=E.useState("positionerElement"),P=E.useState("hoverEnabled"),O=E.useState("modal"),I=E.useState("disabled"),A=E.useState("lastOpenChangeReason"),N=E.useState("parent"),H=E.useState("activeIndex"),W=E.useState("payload"),F=E.useState("floatingParentNodeId"),z=v.useRef(null),$=null!=F;E.useSyncedValues({disabled:h,modal:void 0===N.type?c:void 0,rootId:(0,oz.useId)()});let{openMethod:U,triggerProps:K}=(0,ae.useOpenInteractionType)(T);(0,al.useImplicitActiveTrigger)(E);let{forceUnmount:j}=(0,al.useOpenStateTransitions)(T,E,()=>{E.update({allowMouseEnter:!1,stickIfOpen:!0})}),V=v.useRef("context-menu"!==N.type),q=(0,oC.useTimeout)();v.useEffect(()=>{if(T||(z.current=null),"context-menu"===N.type){if(!T){q.clear(),V.current=!1;return}q.start(500,()=>{V.current=!0})}},[q,T,N.type]),(0,oU.useScrollLock)(T&&O&&A!==nV.REASONS.triggerHover&&"touch"!==U,L),(0,n6.useIsoLayoutEffect)(()=>{T||P||E.set("hoverEnabled",!0)},[T,P,E]);let Y=v.useRef(!0),X=(0,oC.useTimeout)(),G=(0,nX.useStableCallback)((e,s)=>{let r=s.reason;if(T===e&&s.trigger===B&&A===r||(s.preventUnmountOnClose=()=>{E.set("preventUnmountingOnClose",!0)},e||null!=s.trigger||(s.trigger=B??void 0),o?.(e,s),s.isCanceled))return;let n={open:e,nativeEvent:s.event,reason:s.reason,nested:$};i?.emit("openchange",n);let a=s.event;if(!1===e&&a?.type==="click"&&"touch"===a.pointerType&&!Y.current)return;if(!e&&null!==H){let e=E.context.itemDomElements.current[H];queueMicrotask(()=>{e?.setAttribute("tabindex","-1")})}e&&r===nV.REASONS.triggerFocus?(Y.current=!1,X.start(300,()=>{Y.current=!0})):(Y.current=!0,X.clear());let l=(r===nV.REASONS.triggerPress||r===nV.REASONS.itemPress)&&0===a.detail&&a?.isTrusted,h=!e&&(r===nV.REASONS.escapeKey||null==r),c={open:e,openChangeReason:r};z.current=s.event??null;let d=s.trigger?.id??null;(d||e)&&(c.activeTriggerId=d,c.activeTriggerElement=s.trigger??null),E.update(c),"menubar"===N.type&&(r===nV.REASONS.triggerFocus||r===nV.REASONS.focusOut||r===nV.REASONS.triggerHover||r===nV.REASONS.listNavigation||r===nV.REASONS.siblingOpen)?E.set("instantType","group"):l||h?E.set("instantType",l?"click":"dismiss"):E.set("instantType",void 0)}),J=v.useCallback(e=>{let i=(0,oi.createChangeEventDetails)(e);return i.preventUnmountOnClose=()=>{E.set("preventUnmountingOnClose",!0)},i},[E]),Z=v.useCallback(()=>{E.setOpen(!1,J(nV.REASONS.imperativeAction))},[E,J]);v.useImperativeHandle(_,()=>({unmount:j,close:Z}),[j,Z]),"context-menu"===N.type&&(s=N.context),v.useImperativeHandle(s?.positionerRef,()=>L,[L]),v.useImperativeHandle(s?.actionsRef,()=>({setOpen:G}),[G]);let Q=(0,o4.useSyncedFloatingRootContext)({popupStore:E,onOpenChange:G});i=Q.context.events,v.useEffect(()=>{let e=({open:e,eventDetails:i})=>G(e,i);return i.on("setOpen",e),()=>{i?.off("setOpen",e)}},[i,G]);let ee=(0,oV.useDismiss)(Q,{enabled:!I,bubbles:{escapeKey:f&&"menu"===N.type},outsidePress:()=>"context-menu"!==N.type||z.current?.type==="contextmenu"||V.current,externalTree:$?R:void 0}),et=(0,o6.useRole)(Q,{role:"menu"}),ei=(0,o9.useDirection)(),es=v.useCallback(e=>{E.select("activeIndex")!==e&&E.set("activeIndex",e)},[E]),er=function(e,i){let s="rootStore"in e?e.rootStore:e,r=s.useState("open"),n=s.useState("floatingElement"),o=s.useState("domReferenceElement"),a=s.context.dataRef,{listRef:l,activeIndex:h,onNavigate:c=()=>{},enabled:d=!0,selectedIndex:u=null,allowEscape:_=!1,loopFocus:f=!1,nested:p=!1,rtl:g=!1,virtual:m=!1,focusItemOnOpen:S="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:w,orientation:C="vertical",parentOrientation:x,cols:k=1,id:E,resetOnPointerLeave:R=!0,externalTree:M}=i,D=(0,oJ.getFloatingFocusElement)(n),T=(0,oX.useValueAsRef)(D),B=(0,ox.useFloatingParentNodeId)(),L=(0,ox.useFloatingTree)(M);(0,n6.useIsoLayoutEffect)(()=>{a.current.orientation=C},[a,C]);let P=(0,oJ.isTypeableCombobox)(o),O=v.useRef(S),I=v.useRef(u??-1),A=v.useRef(null),N=v.useRef(!0),H=(0,nX.useStableCallback)(e=>{c(-1===I.current?null:I.current,e)}),W=v.useRef(H),F=v.useRef(!!n),z=v.useRef(r),$=v.useRef(!1),U=v.useRef(!1),K=(0,oX.useValueAsRef)(w),j=(0,oX.useValueAsRef)(r),V=(0,oX.useValueAsRef)(u),q=(0,oX.useValueAsRef)(R),Y=(0,nX.useStableCallback)(()=>{function e(e){m?L?.events.emit("virtualfocus",e):(0,o0.enqueueFocus)(e,{sync:$.current,preventScroll:!0})}let i=l.current[I.current],s=U.current;i&&e(i),($.current?e=>e():requestAnimationFrame)(()=>{let r=l.current[I.current]||i;!r||(i||e(r),G&&(s||!N.current)&&r.scrollIntoView?.({block:"nearest",inline:"nearest"}))})});(0,n6.useIsoLayoutEffect)(()=>{d&&(r&&n?(I.current=u??-1,O.current&&null!=u&&(U.current=!0,H())):F.current&&(I.current=-1,W.current()))},[d,r,n,u,H]),(0,n6.useIsoLayoutEffect)(()=>{if(d){if(!r){$.current=!1;return}if(n)if(null==h){if($.current=!1,null!=V.current)return;if(F.current&&(I.current=-1,Y()),(!z.current||!F.current)&&O.current&&(null!=A.current||!0===O.current&&null==A.current)){let e=0,i=()=>{null==l.current[0]?(e<2&&(e?requestAnimationFrame:queueMicrotask)(i),e+=1):(I.current=null==A.current||o3(A.current,C,g)||p?(0,oQ.getMinListIndex)(l):(0,oQ.getMaxListIndex)(l),A.current=null,H())};i()}}else(0,oQ.isIndexOutOfListBounds)(l,h)||(I.current=h,Y(),U.current=!1)}},[d,r,n,h,V,p,l,C,g,H,Y,K]),(0,n6.useIsoLayoutEffect)(()=>{if(!d||n||!L||m||!F.current)return;let e=L.nodesRef.current,i=e.find(e=>e.id===B)?.context?.elements.floating,s=(0,oJ.activeElement)((0,oG.ownerDocument)(n)),r=e.some(e=>e.context&&(0,oJ.contains)(e.context.elements.floating,s));i&&!r&&N.current&&i.focus({preventScroll:!0})},[d,n,L,B,m]),(0,n6.useIsoLayoutEffect)(()=>{W.current=H,z.current=r,F.current=!!n}),(0,n6.useIsoLayoutEffect)(()=>{r||(A.current=null,O.current=S)},[r,S]);let X=null!=h,G=v.useMemo(()=>{function e(e){if(!j.current)return;let i=l.current.indexOf(e.currentTarget);-1!==i&&I.current!==i&&(I.current=i,H(e))}return{onFocus(i){$.current=!0,e(i)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(i){$.current=!0,U.current=!1,b&&e(i)},onPointerLeave(e){if(!j.current||!N.current||"touch"===e.pointerType)return;$.current=!0;let i=e.relatedTarget;if(!(!b||l.current.includes(i))&&q.current&&((0,o0.enqueueFocus)(null,{sync:!0}),I.current=-1,H(e),!m)){let e=T.current,i=(0,oJ.activeElement)((0,oG.ownerDocument)(e));e&&(0,oJ.contains)(e,i)&&e.focus({preventScroll:!0})}}}},[j,T,b,l,H,q,m]),J=v.useCallback(()=>x??L?.nodesRef.current.find(e=>e.id===B)?.context?.dataRef?.current.orientation,[B,L,x]),Z=(0,nX.useStableCallback)(e=>{var i;let n,a;if(N.current=!1,$.current=!0,229===e.which||!j.current&&e.currentTarget===T.current)return;if(p&&(i=e.key,n=g?i===o1.ARROW_RIGHT:i===o1.ARROW_LEFT,a=i===o1.ARROW_UP,"both"===C||"horizontal"===C&&k&&k>1?"Escape"===i:o2(C,n,a))){o5(e.key,J())||(0,oZ.stopEvent)(e),s.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.listNavigation,e.nativeEvent)),(0,oY.isHTMLElement)(o)&&(m?L?.events.emit("virtualfocus",o):o.focus());return}let h=I.current,c=(0,oQ.getMinListIndex)(l,w),d=(0,oQ.getMaxListIndex)(l,w);if(P||("Home"===e.key&&((0,oZ.stopEvent)(e),I.current=c,H(e)),"End"===e.key&&((0,oZ.stopEvent)(e),I.current=d,H(e))),k>1){let i=Array.from({length:l.current.length},()=>({width:1,height:1})),s=(0,oQ.createGridCellMap)(i,k,!1),r=s.findIndex(e=>null!=e&&!(0,oQ.isListIndexDisabled)(l,e,w)),n=s.reduce((e,i,s)=>null==i||(0,oQ.isListIndexDisabled)(l,i,w)?e:s,-1),o=s[(0,oQ.getGridNavigatedIndex)({current:s.map(e=>null!=e?l.current[e]:null)},{event:e,orientation:C,loopFocus:f,rtl:g,cols:k,disabledIndices:(0,oQ.getGridCellIndices)([...("function"!=typeof w?w:null)||l.current.map((e,i)=>(0,oQ.isListIndexDisabled)(l,i,w)?i:void 0),void 0],s),minIndex:r,maxIndex:n,prevIndex:(0,oQ.getGridCellIndexOfCorner)(I.current>d?c:I.current,i,s,k,e.key===o1.ARROW_DOWN?"bl":e.key===(g?o1.ARROW_LEFT:o1.ARROW_RIGHT)?"tr":"tl"),stopEvent:!0})];if(null!=o&&(I.current=o,H(e)),"both"===C)return}if(o5(e.key,C)){if((0,oZ.stopEvent)(e),r&&!m&&(0,oJ.activeElement)(e.currentTarget.ownerDocument)===e.currentTarget){I.current=o3(e.key,C,g)?c:d,H(e);return}o3(e.key,C,g)?f?h>=d?_&&h!==l.current.length?I.current=-1:($.current=!1,I.current=c):I.current=(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,disabledIndices:w}):I.current=Math.min(d,(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,disabledIndices:w})):f?h<=c?_&&-1!==h?I.current=l.current.length:($.current=!1,I.current=d):I.current=(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,decrement:!0,disabledIndices:w}):I.current=Math.max(c,(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,decrement:!0,disabledIndices:w})),(0,oQ.isIndexOutOfListBounds)(l,I.current)&&(I.current=-1),H(e)}}),Q=v.useMemo(()=>m&&r&&X&&{"aria-activedescendant":`${E}-${h}`},[m,r,X,E,h]),ee=v.useMemo(()=>({"aria-orientation":"both"===C?void 0:C,...!P?Q:{},onKeyDown(e){if("Tab"===e.key&&e.shiftKey&&r&&!m){let i=(0,oJ.getTarget)(e.nativeEvent);if(i&&!(0,oJ.contains)(T.current,i))return;(0,oZ.stopEvent)(e),s.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.focusOut,e.nativeEvent)),(0,oY.isHTMLElement)(o)&&o.focus();return}Z(e)},onPointerMove(){N.current=!0}}),[Q,Z,T,C,P,s,r,m,o]),et=v.useMemo(()=>{function e(e){"auto"===S&&(0,oZ.isVirtualClick)(e.nativeEvent)&&(O.current=!m)}function i(e){O.current=S,"auto"===S&&(0,oZ.isVirtualPointerEvent)(e.nativeEvent)&&(O.current=!0)}return{onKeyDown(e){var i,r;let n=s.select("open");N.current=!1;let o=e.key.startsWith("Arrow"),a=(i=e.key,r=J(),o2(r,g?i===o1.ARROW_LEFT:i===o1.ARROW_RIGHT,i===o1.ARROW_DOWN)),h=o5(e.key,C),c=(p?a:h)||"Enter"===e.key||""===e.key.trim();if(m&&n)return Z(e);if(n||y||!o){if(c){let i=o5(e.key,J());A.current=p&&i?null:e.key}if(p){a&&((0,oZ.stopEvent)(e),n?(I.current=(0,oQ.getMinListIndex)(l,K.current),H(e)):s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.listNavigation,e.nativeEvent,e.currentTarget)));return}h&&(null!=V.current&&(I.current=V.current),(0,oZ.stopEvent)(e),!n&&y?s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.listNavigation,e.nativeEvent,e.currentTarget)):Z(e),n&&H(e))}},onFocus(e){s.select("open")&&!m&&(I.current=-1,H(e))},onPointerDown:i,onPointerEnter:i,onMouseDown:e,onClick:e}},[Z,K,S,l,p,H,s,y,C,J,g,V,m]),ei=v.useMemo(()=>({...Q,...et}),[Q,et]);return v.useMemo(()=>d?{reference:ei,floating:ee,item:G,trigger:et}:{},[d,ei,ee,et,G])}(Q,{enabled:!I,listRef:E.context.itemDomElements,activeIndex:H,nested:void 0!==N.type,loopFocus:d,orientation:u,parentOrientation:"menubar"===N.type?N.context.orientation:void 0,rtl:"rtl"===ei,disabledIndices:oK.EMPTY_ARRAY,onNavigate:es,openOnArrowKeyDown:"context-menu"!==N.type,externalTree:$?R:void 0,focusItemOnHover:b}),en=v.useCallback(e=>{E.context.typingRef.current=e},[E]),eo=function(e,i){let s="rootStore"in e?e.rootStore:e,r=s.context.dataRef,n=s.useState("open"),{listRef:o,elementsRef:a,activeIndex:l,onMatch:h,onTypingChange:c,enabled:d=!0,resetMs:u=750,selectedIndex:_=null}=i,f=(0,oC.useTimeout)(),p=v.useRef(""),g=v.useRef(_??l??-1),m=v.useRef(null);(0,n6.useIsoLayoutEffect)(()=>{(n||null===_)&&(f.clear(),m.current=null,""!==p.current&&(p.current=""))},[n,_,f]),(0,n6.useIsoLayoutEffect)(()=>{n&&""===p.current&&(g.current=_??l??-1)},[n,_,l]);let S=(0,nX.useStableCallback)(e=>{e?r.current.typing||(r.current.typing=e,c?.(e)):r.current.typing&&(r.current.typing=e,c?.(e))}),b=(0,nX.useStableCallback)(e=>{function i(e,s,r=0){if(0===e.length)return -1;let n=(r%e.length+e.length)%e.length,o=s.toLocaleLowerCase();for(let i=0;i<e.length;i+=1){let s=(n+i)%e.length,r=e[s];if(r?.toLocaleLowerCase().startsWith(o)&&function(e){let i=a?.current[e];return!i||(0,oQ.isElementVisible)(i)}(s))return s}return -1}let s=o.current;if(p.current.length>0&&" "===e.key&&((0,oZ.stopEvent)(e),S(!0)),p.current.length>0&&" "!==p.current[0]&&-1===i(s,p.current)&&" "!==e.key&&S(!1),null==s||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;n&&" "!==e.key&&((0,oZ.stopEvent)(e),S(!0));let r=""===p.current;r&&(g.current=_??l??-1),s.every(e=>!e||e[0]?.toLocaleLowerCase()!==e[1]?.toLocaleLowerCase())&&p.current===e.key&&(p.current="",g.current=m.current),p.current+=e.key,f.start(u,()=>{p.current="",g.current=m.current,S(!1)});let c=r?_??l??-1:g.current,d=i(s,p.current,(c??0)+1);-1!==d?(h?.(d),m.current=d):" "!==e.key&&(p.current="",S(!1))}),y=(0,nX.useStableCallback)(e=>{let i=e.relatedTarget,r=s.select("domReferenceElement"),n=s.select("floatingElement"),o=(0,oJ.contains)(r,i),a=(0,oJ.contains)(n,i);o||a||(f.clear(),p.current="",g.current=m.current,S(!1))}),w=v.useMemo(()=>({onKeyDown:b,onBlur:y}),[b,y]),C=v.useMemo(()=>({onKeyDown:b,onBlur:y}),[b,y]);return v.useMemo(()=>d?{reference:w,floating:C}:{},[d,w,C])}(Q,{listRef:E.context.itemLabels,elementsRef:E.context.itemDomElements,activeIndex:H,resetMs:oL.TYPEAHEAD_RESET_MS,onMatch:e=>{T&&e!==H&&E.set("activeIndex",e)},onTypingChange:en}),{getReferenceProps:ea,getFloatingProps:el,getItemProps:eh,getTriggerProps:ec}=(0,oq.useInteractions)([ee,et,er,eo]),ed=v.useMemo(()=>{let e=(0,n0.mergeProps)(ea(),{onMouseMove(){E.set("allowMouseEnter",!0)}},K);return delete e.role,e},[ea,E,K]),eu=v.useMemo(()=>{let e=ec();if(!e)return e;let i=(0,n0.mergeProps)(e,K);return delete i.role,delete i["aria-controls"],i},[ec,K]),e_=v.useMemo(()=>el({onMouseMove(){E.set("allowMouseEnter",!0),"menu"===N.type&&E.set("hoverEnabled",!1)},onClick(){E.select("hoverEnabled")&&E.set("hoverEnabled",!1)},onKeyDown(e){let i=E.select("keyboardEventRelay");i&&!e.isPropagationStopped()&&i(e)}}),[el,N.type,E]),ef=v.useMemo(()=>eh(),[eh]);E.useSyncedValues({floatingRootContext:Q,activeTriggerProps:ed,inactiveTriggerProps:eu,popupProps:e_,itemProps:ef});let ep=v.useMemo(()=>({store:E,parent:k}),[E,k]),eg=(0,m.jsx)(nH.Provider,{value:ep,children:"function"==typeof r?r({payload:W}):r});return void 0===N.type||"context-menu"===N.type?(0,m.jsx)(ox.FloatingTree,{externalTree:R,children:eg}):eg});var au=e.i(74080),a_=e.i(37287),af=e.i(4012),ap=e.i(32652);let ag=n1.isMac&&n1.isSafari;var am=e.i(97254),av=e.i(59266),aS=e.i(54694);function ab(e){let{render:i,className:s,state:r=oK.EMPTY_OBJECT,props:n=oK.EMPTY_ARRAY,refs:o=oK.EMPTY_ARRAY,metadata:a,stateAttributesMapping:l,tag:h="div",...c}=e,{compositeProps:d,compositeRef:u}=function(e={}){let{highlightItemOnHover:i,highlightedIndex:s,onHighlightedIndexChange:r}=(0,aS.useCompositeRootContext)(),{ref:n,index:o}=n7(e),a=s===o,l=v.useRef(null),h=(0,nZ.useMergedRefs)(n,l);return{compositeProps:v.useMemo(()=>({tabIndex:a?0:-1,onFocus(){r(o)},onMouseMove(){let e=l.current;if(!i||!e)return;let s=e.hasAttribute("disabled")||"true"===e.ariaDisabled;a||s||e.focus()}}),[a,r,o,i]),compositeRef:h,index:o}}({metadata:a});return(0,nF.useRenderElement)(h,e,{state:r,ref:[...o,u],props:[d,...n,c],stateAttributesMapping:l})}var ay=e.i(72408);let aw=(0,oj.fastComponentRef)(function(e,i){let s,r,n,{render:o,className:a,disabled:l=!1,nativeButton:h=!0,id:c,openOnHover:d,delay:u=100,closeDelay:_=0,handle:f,payload:p,...g}=e,S=nW(!0),b=f?.store??S?.store;if(!b)throw Error((0,nI.default)(85));let y=(0,n9.useBaseUiId)(c),w=b.useState("isTriggerActive",y),C=b.useState("floatingRootContext"),x=b.useState("isOpenedByTrigger",y),k=v.useRef(null),E=(s=nj(!0),r=nW(!0),n=o7(!0),v.useMemo(()=>n?{type:"menubar",context:n}:s&&!r?{type:"context-menu",context:s}:{type:void 0},[s,r,n])),R=(0,aS.useCompositeRootContext)(!0),M=(0,ox.useFloatingTree)(),D=v.useMemo(()=>M??new as.FloatingTreeStore,[M]),T=(0,ox.useFloatingNodeId)(D),B=(0,ox.useFloatingParentNodeId)(),{registerTrigger:L,isMountedByThisTrigger:P}=(0,al.useTriggerDataForwarding)(y,k,b,{payload:p,closeDelay:_,parent:E,floatingTreeRoot:D,floatingNodeId:T,floatingParentNodeId:B,keyboardEventRelay:R?.relayKeyboardEvent}),O="menubar"===E.type,I=b.useState("disabled"),A=l||I||O&&E.context.disabled,{getButtonProps:N,buttonRef:H}=(0,nQ.useButton)({disabled:A,native:h});v.useEffect(()=>{x||void 0!==E.type||(b.context.allowMouseUpTriggerRef.current=!1)},[b,x,E.type]);let W=v.useRef(null),F=(0,oC.useTimeout)(),z=(0,nX.useStableCallback)(e=>{if(!W.current)return;F.clear(),b.context.allowMouseUpTriggerRef.current=!1;let i=e.target;if((0,oJ.contains)(W.current,i)||(0,oJ.contains)(b.select("positionerElement"),i)||i===W.current||null!=i&&function e(i){return(0,oY.isHTMLElement)(i)&&i.hasAttribute("data-rootownerid")?i.getAttribute("data-rootownerid")??void 0:(0,oY.isLastTraversableNode)(i)?void 0:e((0,oY.getParentNode)(i))}(i)===b.select("rootId"))return;let s=function(e){let i=e.getBoundingClientRect(),s=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if("none"===s.content&&"none"===r.content)return i;let n=parseFloat(s.width)||0,o=parseFloat(s.height)||0,a=parseFloat(r.width)||0,l=parseFloat(r.height)||0,h=Math.max(i.width,n,a),c=Math.max(i.height,o,l),d=h-i.width,u=c-i.height;return{left:i.left-d/2,right:i.right+d/2,top:i.top-u/2,bottom:i.bottom+u/2}}(W.current);e.clientX>=s.left-2&&e.clientX<=s.right+2&&e.clientY>=s.top-2&&e.clientY<=s.bottom+2||D.events.emit("close",{domEvent:e,reason:nV.REASONS.cancelOpen})});v.useEffect(()=>{x&&b.select("lastOpenChangeReason")===nV.REASONS.triggerHover&&(0,oG.ownerDocument)(W.current).addEventListener("mouseup",z,{once:!0})},[x,z,b]);let $=O&&E.context.hasSubmenuOpen,U=d??$,K=(0,am.useHoverReferenceInteraction)(C,{enabled:U&&!A&&"context-menu"!==E.type&&(!O||$&&!P),handleClose:(0,a_.safePolygon)({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:void 0===E.type?u:void 0,delay:{close:_},triggerElementRef:k,externalTree:D,isActiveTrigger:w}),j=function(e,i){let s=(0,oC.useTimeout)(),[r,n]=v.useState(!1);return(0,n6.useIsoLayoutEffect)(()=>{e&&"trigger-hover"===i?(n(!0),s.start(oL.PATIENT_CLICK_THRESHOLD,()=>{n(!1)})):e||(s.clear(),n(!1))},[e,i,s]),r}(x,b.select("lastOpenChangeReason")),V=(0,af.useClick)(C,{enabled:!A&&"context-menu"!==E.type,event:x&&O?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:void 0===E.type&&j}),q=function(e,i={}){let s="rootStore"in e?e.rootStore:e,{events:r,dataRef:n}=s.context,{enabled:o=!0,delay:a}=i,l=v.useRef(!1),h=v.useRef(null),c=(0,oC.useTimeout)(),d=v.useRef(!0);v.useEffect(()=>{let e=s.select("domReferenceElement");if(!o)return;let i=(0,oY.getWindow)(e);function r(){let e=s.select("domReferenceElement");!s.select("open")&&(0,oY.isHTMLElement)(e)&&e===(0,oJ.activeElement)((0,oG.ownerDocument)(e))&&(l.current=!0)}function n(){d.current=!0}function a(){d.current=!1}return i.addEventListener("blur",r),ag&&(i.addEventListener("keydown",n,!0),i.addEventListener("pointerdown",a,!0)),()=>{i.removeEventListener("blur",r),ag&&(i.removeEventListener("keydown",n,!0),i.removeEventListener("pointerdown",a,!0))}},[s,o]),v.useEffect(()=>{if(o)return r.on("openchange",e),()=>{r.off("openchange",e)};function e(e){if(e.reason===nV.REASONS.triggerPress||e.reason===nV.REASONS.escapeKey){let e=s.select("domReferenceElement");(0,oY.isElement)(e)&&(h.current=e,l.current=!0)}}},[r,o,s]);let u=v.useMemo(()=>({onMouseLeave(){l.current=!1,h.current=null},onFocus(e){let i=e.currentTarget;if(l.current){if(h.current===i)return;l.current=!1,h.current=null}let r=(0,oJ.getTarget)(e.nativeEvent);if((0,oY.isElement)(r)){if(ag&&!e.relatedTarget){if(!d.current&&!(0,oJ.isTypeableElement)(r))return}else if(!(0,oJ.matchesFocusVisible)(r))return}let n=(0,oJ.isTargetInsideEnabledTrigger)(e.relatedTarget,s.context.triggerElements),{nativeEvent:o,currentTarget:u}=e,_="function"==typeof a?a():a;s.select("open")&&n||0===_||void 0===_?s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.triggerFocus,o,u)):c.start(_,()=>{l.current||s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.triggerFocus,o,u))})},onBlur(e){l.current=!1,h.current=null;let i=e.relatedTarget,r=e.nativeEvent,o=(0,oY.isElement)(i)&&i.hasAttribute((0,ap.createAttribute)("focus-guard"))&&"outside"===i.getAttribute("data-type");c.start(0,()=>{let e=s.select("domReferenceElement"),a=(0,oJ.activeElement)(e?e.ownerDocument:document);if(!i&&a===e||(0,oJ.contains)(n.current.floatingContext?.refs.floating.current,a)||(0,oJ.contains)(e,a)||o)return;let l=i??a;(0,oJ.isTargetInsideEnabledTrigger)(l,s.context.triggerElements)||s.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.triggerFocus,r))})}}),[n,s,c,a]);return v.useMemo(()=>o?{reference:u,trigger:u}:{},[o,u])}(C,{enabled:!A&&$}),Y=function(e){let{enabled:i=!0,mouseDownAction:s,open:r}=e,n=v.useRef(!1);return v.useMemo(()=>i?{onMouseDown:e=>{("open"===s&&!r||"close"===s&&r)&&(n.current=!0,(0,oG.ownerDocument)(e.currentTarget).addEventListener("click",()=>{n.current=!1},{once:!0}))},onClick:e=>{n.current&&(n.current=!1,e.preventBaseUIHandler())}}:oK.EMPTY_OBJECT,[i,s,r])}({open:x,enabled:O,mouseDownAction:"open"}),X=(0,oq.useInteractions)([V,q]),G={disabled:A,open:x},J=b.useState("triggerProps",P),Z=[W,i,H,L,k],Q=[X.getReferenceProps(),K??oK.EMPTY_OBJECT,J,{"aria-haspopup":"menu",id:y,onMouseDown:e=>{b.select("open")||(F.start(200,()=>{b.context.allowMouseUpTriggerRef.current=!0}),(0,oG.ownerDocument)(e.currentTarget).addEventListener("mouseup",z,{once:!0}))}},O?{role:"menuitem"}:{},Y,g,N],ee=v.useRef(null),et=(0,nX.useStableCallback)(e=>{au.flushSync(()=>{b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.focusOut,e.nativeEvent,e.currentTarget))});let i=(0,av.getTabbableBeforeElement)(ee.current);i?.focus()}),ei=(0,nX.useStableCallback)(e=>{let i=b.select("positionerElement");if(i&&(0,av.isOutsideEvent)(e,i))b.context.beforeContentFocusGuardRef.current?.focus();else{au.flushSync(()=>{b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.focusOut,e.nativeEvent,e.currentTarget))});let s=(0,av.getTabbableAfterElement)(b.context.triggerFocusTargetRef.current||k.current);for(;null!==s&&(0,oJ.contains)(i,s);){let e=s;if((s=(0,av.getNextTabbable)(s))===e)break}s?.focus()}}),es=(0,nF.useRenderElement)("button",e,{enabled:!O,stateAttributesMapping:nz.pressableTriggerOpenStateMapping,state:G,ref:Z,props:Q});return O?(0,m.jsx)(ab,{tag:"button",render:o,className:a,state:G,refs:Z,props:Q,stateAttributesMapping:nz.pressableTriggerOpenStateMapping}):x?(0,m.jsxs)(v.Fragment,{children:[(0,m.jsx)(ay.FocusGuard,{ref:ee,onFocus:et},`${y}-pre-focus-guard`),(0,m.jsx)(v.Fragment,{children:es},y),(0,m.jsx)(ay.FocusGuard,{ref:b.context.triggerFocusTargetRef,onFocus:ei},`${y}-post-focus-guard`)]}):(0,m.jsx)(v.Fragment,{children:es},y)});var aC=e.i(12666);let ax=((g={}).popupWidth="--popup-width",g.popupHeight="--popup-height",g),ak={activationDirection:e=>e?{"data-activation-direction":e}:null},aE=v.forwardRef(function(e,i){let{render:s,className:r,children:n,...o}=e,{store:a}=nW(),{side:l}=nN(),h=a.useState("instantType"),{children:c,state:d}=(0,aC.usePopupViewport)({store:a,side:l,cssVars:ax,children:n}),u={activationDirection:d.activationDirection,transitioning:d.transitioning,instant:h};return(0,nF.useRenderElement)("div",e,{state:u,ref:i,props:[o,{children:c}],stateAttributesMapping:ak})}),aR=v.forwardRef(function(e,i){let{className:s,render:r,orientation:n="horizontal",...o}=e;return(0,nF.useRenderElement)("div",e,{state:{orientation:n},ref:i,props:[{role:"separator","aria-orientation":n},o]})}),aM=v.forwardRef(function(e,i){let{render:s,className:r,label:n,id:o,nativeButton:a=!1,openOnHover:l=!0,delay:h=100,closeDelay:c=0,disabled:d=!1,...u}=e,_=n7(),f=nN(),{store:p}=nW(),g=(0,n9.useBaseUiId)(o),m=p.useState("open"),S=p.useState("floatingRootContext"),b=p.useState("floatingTreeRoot"),y=(0,al.useTriggerRegistration)(g,p),w=v.useCallback(e=>{let i=y(e);return null!==e&&p.select("open")&&null==p.select("activeTriggerId")&&p.update({activeTriggerId:g,activeTriggerElement:e,closeDelay:c}),i},[y,c,p,g]),C=v.useRef(null),x=v.useCallback(e=>{C.current=e,p.set("activeTriggerElement",e)},[p]),k=ac();if(!k?.parentMenu)throw Error((0,nI.default)(37));p.useSyncedValue("closeDelay",c);let E=k.parentMenu,R=E.useState("itemProps"),M=E.useState("isActive",_.index),D=v.useMemo(()=>({type:"submenu-trigger",setActive(){E.set("activeIndex",_.index)}}),[E,_.index]),T=p.useState("disabled"),B=d||T,{getItemProps:L,itemRef:P}=n3({closeOnClick:!1,disabled:B,highlighted:M,id:g,store:p,typingRef:E.context.typingRef,nativeButton:a,itemMetadata:D,nodeId:f?.nodeId}),O=p.useState("hoverEnabled"),I=E.useState("allowMouseEnter"),A=(0,am.useHoverReferenceInteraction)(S,{enabled:O&&l&&!B,handleClose:(0,a_.safePolygon)({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:h,delay:I?{open:h,close:c}:0,triggerElementRef:C,externalTree:b}),N=(0,af.useClick)(S,{enabled:!B,event:"mousedown",toggle:!l,ignoreMouse:l,stickIfOpen:!1}),H=(0,oq.useInteractions)([N]),W=p.useState("triggerProps",!0);return delete W.id,(0,nF.useRenderElement)("div",e,{state:{disabled:B,highlighted:M,open:m},stateAttributesMapping:nz.triggerOpenStateMapping,props:[H.getReferenceProps(),A,W,R,{tabIndex:m||M?0:-1,onBlur(){M&&E.set("activeIndex",null)}},u,L],ref:[i,_.ref,P,w,x]})});class aD{constructor(){this.store=new aa}open(e){let i=e?this.store.context.triggerElements.getById(e):void 0;if(e&&!i)throw Error((0,nI.default)(83,e));this.store.setOpen(!0,(0,oi.createChangeEventDetails)("imperative-action",void 0,i))}close(){this.store.setOpen(!1,(0,oi.createChangeEventDetails)("imperative-action",void 0,void 0))}get isOpen(){return this.store.state.open}}e.s(["Arrow",0,n$,"Backdrop",0,nY,"CheckboxItem",0,os,"CheckboxItemIndicator",0,oo,"Group",0,ol,"GroupLabel",0,oh,"Handle",0,aD,"Item",0,oc,"LinkItem",0,od,"Popup",0,ov,"Portal",0,oy,"Positioner",0,oI,"RadioGroup",0,oN,"RadioItem",0,oW,"RadioItemIndicator",0,oF,"Root",0,ad,"Separator",0,aR,"SubmenuRoot",0,function(e){let i=nW().store,s=v.useMemo(()=>({parentMenu:i}),[i]);return(0,m.jsx)(ah.Provider,{value:s,children:(0,m.jsx)(ad,{...e})})},"SubmenuTrigger",0,aM,"Trigger",0,aw,"Viewport",0,aE,"createHandle",0,function(){return new aD}],30250);var aT=e.i(30250),aT=aT,aB=e.i(52088);function aL({...e}){return(0,m.jsx)(aT.Root,{"data-slot":"dropdown-menu",...e})}function aP({...e}){return(0,m.jsx)(aT.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function aO({align:e="start",alignOffset:i=0,side:s="bottom",sideOffset:r=4,className:n,...o}){return(0,m.jsx)(aT.Portal,{children:(0,m.jsx)(aT.Positioner,{className:"isolate z-50 outline-none",align:e,alignOffset:i,side:s,sideOffset:r,children:(0,m.jsx)(aT.Popup,{"data-slot":"dropdown-menu-content",className:(0,aB.cn)("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",n),...o})})})}function aI({className:e,inset:i,variant:s="default",...r}){return(0,m.jsx)(aT.Item,{"data-slot":"dropdown-menu-item","data-inset":i,"data-variant":s,className:(0,aB.cn)("group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:*:[svg]:text-destructive",e),...r})}function aA({className:e,...i}){return(0,m.jsx)(aT.Separator,{"data-slot":"dropdown-menu-separator",className:(0,aB.cn)("-mx-1 my-1 h-px bg-border/50",e),...i})}e.i(46349),e.i(78784),e.s(["default",0,function({params:e}){let{id:i}=(0,v.use)(e),s=(0,S.useRouter)(),r=(0,T.useToast)(),[n,o]=(0,v.useState)(null),[a,l]=(0,v.useState)([]),[h,c]=(0,v.useState)(),[d,u]=(0,v.useState)(!0),[_,f]=(0,v.useState)(!1),[p,g]=(0,v.useState)(!1),[y,P]=(0,v.useState)(!0),O=(0,v.useRef)(null);(0,B.useDocumentTitle)(n?.title),(0,L.useTaskEvents)({onTaskCreated:()=>{},onTaskUpdated:e=>{e.id===i&&o(e)},onTaskDeleted:e=>{e===i&&(r.info("Task deleted",n?.title??void 0),s.push("/"))}});let I=(0,v.useRef)(null),A=(0,v.useCallback)(async()=>{if(null!==I.current&&I.current!==i&&P(!0),I.current=i,y){u(!0);try{let e=await fetch((0,R.apiUrl)(`/api/tasks/${i}`));if(!e.ok)throw Error("Failed to fetch task");let s=(await e.json()).data.task,r=s.tabs||[];if(0===r.length){let e=await fetch((0,R.apiUrl)(`/api/tasks/${i}/tabs`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});e.ok&&(r=[(await e.json()).data.tab])}o(s),l(r),r.length>0&&c(r[0].tab_id)}catch(e){console.error("Failed to load data:",e)}finally{u(!1),P(!1)}}},[i,y]);(0,v.useEffect)(()=>{A()},[i,A]);let N=async(e,i)=>{let s=r.loading("Updating task...");try{let n=await fetch((0,R.apiUrl)(`/api/tasks/${e}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok)throw Error("Failed to update task");let a=await n.json();return o(a.data.task),r.success(s,"Successfully updated task"),{success:!0}}catch(i){console.error("Failed to update task:",i);let e=i instanceof Error?i.message:"Failed to update task";return r.error(s,"Failed to update task",e),{success:!1,errors:[{field:"global",message:"Failed to update task"}]}}},H=async(e="claude")=>{try{let s=await fetch((0,R.apiUrl)(`/api/tasks/${i}/tabs`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e})});if(!s.ok)throw Error("Failed to create tab");let r=(await s.json()).data.tab;return l(e=>e.some(e=>e.tab_id===r.tab_id)?e:[...e,r]),c(r.tab_id),r.tab_id}catch(e){console.error("Failed to create tab:",e);return}},W=async e=>{try{if(!(await fetch((0,R.apiUrl)(`/api/tasks/${i}/tabs/${e}`),{method:"DELETE"})).ok)throw Error("Failed to delete tab");if(l(i=>i.filter(i=>i.tab_id!==e)),h===e){let i=a.filter(i=>i.tab_id!==e);c(i[0]?.tab_id)}}catch(e){console.error("Failed to delete tab:",e)}},F=async()=>{if(!n)return;let e=r.loading("Opening terminal...",n.worktreePath);try{if(!(await fetch((0,R.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"terminal",owner:n.owner,repo:n.repo,branch:n.branch})})).ok)throw Error("Command execution failed");r.success(e,"Successfully opened terminal",n.worktreePath)}catch(s){let i=s instanceof Error?s.message:"Unknown error";r.error(e,"Failed to open terminal",i)}},z=async()=>{if(!n)return;let e=r.loading("Opening VS Code...",n.worktreePath);try{if(!(await fetch((0,R.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"vscode",owner:n.owner,repo:n.repo,branch:n.branch})})).ok)throw Error("Command execution failed");r.success(e,"Successfully opened VS Code",n.worktreePath)}catch(s){let i=s instanceof Error?s.message:"Unknown error";r.error(e,"Failed to open VS Code",i)}};return d&&!n?(0,m.jsx)("div",{className:"h-screen flex items-center justify-center bg-background",children:(0,m.jsx)(D.LoadingSpinner,{size:"lg",message:"Loading task..."})}):n?(0,m.jsxs)("div",{className:"h-screen flex flex-col bg-background",children:[(0,m.jsx)("div",{className:"sticky top-0 z-50 p-4 border-b border-border bg-card",children:(0,m.jsxs)("div",{className:"flex items-center justify-between",children:[(0,m.jsxs)(U.Button,{variant:"ghost",onClick:()=>s.push("/"),className:"text-primary font-medium hover:bg-primary/10 hover:text-foreground",children:[(0,m.jsx)(b.ArrowLeft,{className:"w-4 h-4"}),"Back to Board"]}),(0,m.jsx)("h1",{className:"text-base font-semibold text-foreground absolute left-1/2 -translate-x-1/2 max-w-[50vw] truncate",children:n.title}),(0,m.jsxs)(aL,{children:[(0,m.jsx)(aP,{render:(0,m.jsx)(U.Button,{variant:"ghost",size:"icon-lg",className:"text-primary hover:bg-primary/10 hover:text-foreground",title:"Task menu"}),children:(0,m.jsx)(C,{className:"w-5 h-5"})}),(0,m.jsxs)(aO,{align:"end",children:[(0,m.jsxs)(aI,{onClick:()=>f(!0),children:[(0,m.jsx)(x.Pencil,{className:"w-4 h-4"}),"Detail / Edit"]}),(0,m.jsx)(aA,{}),(0,m.jsxs)(aI,{onClick:F,children:[(0,m.jsx)(k,{className:"w-4 h-4"}),"Open Terminal"]}),(0,m.jsxs)(aI,{onClick:z,children:[(0,m.jsx)(w,{className:"w-4 h-4"}),"Open VS Code"]}),(0,m.jsx)(aA,{}),(0,m.jsxs)(aI,{className:"text-destructive focus:text-destructive",onClick:()=>g(!0),children:[(0,m.jsx)(E.Trash2,{className:"w-4 h-4"}),"Delete"]})]})]})]})}),(0,m.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:(0,m.jsx)("div",{className:"bg-card flex flex-col flex-1 min-h-0",children:(0,m.jsx)(nO,{ref:O,task:n,tabs:a,activeTabId:h,onTabChange:c,onTabCreate:H,onTabDelete:W})})}),(0,m.jsx)(M.TaskDialog,{mode:"edit",isOpen:_,onClose:()=>f(!1),task:n,onUpdate:N}),(0,m.jsx)($.ConfirmDialog,{open:p,onOpenChange:e=>g(e.open),title:"Delete Task",message:`Delete task "${n.title}"?
22
+ `;e.emit("input",{sessionId:i,data:s})},disabled:!et,title:"Run Claude",children:[(0,m.jsx)(nM,{className:"w-3 h-3"}),"Run Claude"]}),(0,m.jsxs)(U.Button,{variant:"ghost",size:"xs",onClick:()=>y(!0),disabled:!et,className:"text-muted-foreground hover:text-foreground",title:"Open editor input",children:[(0,m.jsx)(nT,{className:"w-3 h-3"}),"Open Editor"]}),er>0&&(0,m.jsxs)("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",title:H.find(e=>"in_progress"===e.status)?.content??"",children:[(0,m.jsx)(nL.Progress,{value:es,max:er,className:"w-16 gap-0 [&_[data-slot=progress-track]]:h-[3px]"}),(0,m.jsxs)("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[es,"/",er]})]})]}),(0,m.jsxs)("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[(0,m.jsx)("div",{ref:_,className:"w-full h-full",style:{padding:"4px"}}),Q&&(0,m.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background",children:(0,m.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground text-xs",children:[(0,m.jsx)(O.Loader2,{className:"w-4 h-4 animate-spin"}),(0,m.jsx)("span",{children:"Connecting..."})]})}),ee&&(0,m.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/90",children:(0,m.jsxs)("div",{className:"text-center space-y-2",children:["error"===L&&(0,m.jsx)("p",{className:"text-xs text-destructive",children:"Connection failed"}),"exited"===L&&(0,m.jsx)("p",{className:"text-xs text-muted-foreground",children:"Session ended"}),"paused"===L&&(0,m.jsx)("p",{className:"text-xs text-muted-foreground",children:"Paused"}),(0,m.jsx)(U.Button,{size:"xs",onClick:J,children:"Reconnect"})]})})]})]}),(0,m.jsx)(nB.MonacoEditorModal,{open:b,onOpenChange:e=>{e.open||y(!1)},onSubmit:e=>{f.current&&e&&f.current.paste(e),y(!1)},title:"Terminal Input",submitLabel:"Paste"})]})}),nO=(0,v.forwardRef)(function({task:e,tabs:i,activeTabId:s,onTabChange:r,onTabCreate:n,onTabDelete:o,onTodosUpdated:a,onClaudeStatusChange:l},h){let[c,d]=(0,v.useState)(()=>new Set(s?[s]:[]));(0,v.useEffect)(()=>{s&&d(e=>{if(e.has(s))return e;let i=new Set(e);return i.add(s),i})},[s]);let[u,_]=(0,v.useState)(()=>new Map(i.map(e=>[e.tab_id,{terminal:"connecting",claude:e.status}])));(0,v.useEffect)(()=>{_(e=>{let s=!1,r=new Map(e);for(let e of i)r.has(e.tab_id)||(r.set(e.tab_id,{terminal:"connecting",claude:e.status}),s=!0);return s?r:e})},[i]);let f=(0,v.useRef)(new Map);(0,v.useEffect)(()=>{s&&f.current.get(s)?.focus()},[s]);let p=(0,v.useCallback)((e,i,s)=>{_(r=>{let n=new Map(r);return n.set(e,{terminal:i,claude:s}),n}),l?.(e,s)},[l]);(0,v.useImperativeHandle)(h,()=>({sendInput:(e,i)=>{let s=f.current.get(e);s?.sendInput(i)}}));let g=(0,v.useCallback)(e=>{d(i=>{if(i.has(e))return i;let s=new Set(i);return s.add(e),s}),r(e)},[r]),S=(0,v.useCallback)(async e=>{let i=await n(e);i&&d(e=>{let s=new Set(e);return s.add(i),s})},[n]),b=(0,v.useCallback)(()=>S("terminal"),[S]),y=(0,v.useCallback)(()=>S("claude"),[S]),w=(0,v.useCallback)(e=>{s&&f.current.get(s)?.sendInput(e)},[s]),C=(0,v.useCallback)(e=>{d(i=>{let s=new Set(i);return s.delete(e),s}),_(i=>{let s=new Map(i);return s.delete(e),s}),f.current.delete(e),o(e)},[o]);return(0,m.jsxs)("div",{className:"flex flex-col flex-1 min-h-0",children:[(0,m.jsx)("div",{className:"px-4 pt-4 flex-shrink-0",children:i.length>0?(0,m.jsx)(V,{tabs:i,activeTabId:s,onTabChange:g,onTabCreateTerminal:b,onTabCreateClaude:y,onTabDelete:C,tabStatusMap:u,onVoiceInputTranscribed:w}):(0,m.jsxs)("div",{className:"text-center py-8",children:[(0,m.jsx)("p",{className:"text-muted-foreground mb-4",children:"No tabs yet"}),(0,m.jsx)(U.Button,{size:"lg",onClick:y,children:"+ Create First Tab"})]})}),(0,m.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[i.map(i=>{let r=c.has(i.tab_id),n=i.tab_id===s;return r?(0,m.jsx)("div",{className:"absolute inset-0 flex flex-col px-4 pb-4 pt-2",style:{visibility:n?"visible":"hidden",pointerEvents:n?"auto":"none"},children:(0,m.jsx)(nP,{ref:e=>{e?f.current.set(i.tab_id,e):f.current.delete(i.tab_id)},tabId:i.tab_id,isActive:n,cwd:e.worktreePath,worktreePath:e.worktreePath,command:"terminal"===i.mode?void 0:`claude --dangerously-skip-permissions --resume ${i.tab_id} 2>/dev/null || claude --dangerously-skip-permissions --session-id ${i.tab_id}`,className:"h-full",initialTodos:i.todos,initialClaudeStatus:i.status,onTodosUpdated:a,onStatusChange:p})},i.tab_id):null}),i.length>0&&!s&&(0,m.jsx)("div",{className:"h-full flex items-center justify-center text-muted-foreground text-sm",children:"Select a tab to view terminal"})]})]})});e.s([],38727),e.i(38727);var nI=e.i(67805);let nA=v.createContext(void 0);function nN(e){let i=v.useContext(nA);if(void 0===i&&!e)throw Error((0,nI.default)(33));return i}let nH=v.createContext(void 0);function nW(e){let i=v.useContext(nH);if(void 0===i&&!e)throw Error((0,nI.default)(36));return i}var nF=e.i(27601),nz=e.i(83590);let n$=v.forwardRef(function(e,i){let{className:s,render:r,...n}=e,{store:o}=nW(),{arrowRef:a,side:l,align:h,arrowUncentered:c,arrowStyles:d}=nN(),u=o.useState("open");return(0,nF.useRenderElement)("div",e,{ref:[a,i],stateAttributesMapping:nz.popupStateMapping,state:{open:u,side:l,align:h,uncentered:c},props:{style:d,"aria-hidden":!0,...n}})});var nU=e.i(84759);let nK=v.createContext(void 0);function nj(e=!0){let i=v.useContext(nK);if(void 0===i&&!e)throw Error((0,nI.default)(25));return i}var nV=e.i(3404);let nq={...nz.popupStateMapping,...nU.transitionStatusMapping},nY=v.forwardRef(function(e,i){let{className:s,render:r,...n}=e,{store:o}=nW(),a=o.useState("open"),l=o.useState("mounted"),h=o.useState("transitionStatus"),c=o.useState("lastOpenChangeReason"),d=nj();return(0,nF.useRenderElement)("div",e,{ref:d?.backdropRef?[i,d.backdropRef]:i,state:{open:a,transitionStatus:h},stateAttributesMapping:nq,props:[{role:"presentation",hidden:!l,style:{pointerEvents:c===nV.REASONS.triggerHover?"none":void 0,userSelect:"none",WebkitUserSelect:"none"}},n]})});var nX=e.i(76477),nG=e.i(94349);let nJ=v.createContext(void 0);var nZ=e.i(26292),nQ=e.i(91730),n0=e.i(19805),n1=e.i(57666);function n2(e){let{closeOnClick:i,highlighted:s,id:r,nodeId:n,store:o,typingRef:a,itemRef:l,itemMetadata:h}=e,{events:c}=o.useState("floatingTreeRoot"),d=nj(!0),u=void 0!==d;return v.useMemo(()=>({id:r,role:"menuitem",tabIndex:s?0:-1,onKeyDown(e){" "===e.key&&a?.current&&e.preventDefault()},onMouseMove(e){n&&c.emit("itemhover",{nodeId:n,target:e.currentTarget})},onClick(e){i&&c.emit("close",{domEvent:e,reason:nV.REASONS.itemPress})},onMouseUp(e){if(d){let i=d.initialCursorPointRef.current;if(d.initialCursorPointRef.current=null,u&&i&&1>=Math.abs(e.clientX-i.x)&&1>=Math.abs(e.clientY-i.y)||u&&!n1.isMac&&2===e.button)return}l.current&&o.context.allowMouseUpTriggerRef.current&&(!u||2===e.button)&&(!h||"regular-item"===h.type)&&l.current.click()}}),[i,s,r,c,n,o,a,l,d,u,h])}let n5={type:"regular-item"};function n3(e){let{closeOnClick:i,disabled:s=!1,highlighted:r,id:n,store:o,typingRef:a=o.context.typingRef,nativeButton:l,itemMetadata:h,nodeId:c}=e,d=v.useRef(null),{getButtonProps:u,buttonRef:_}=(0,nQ.useButton)({disabled:s,focusableWhenDisabled:!0,native:l,composite:!0}),f=n2({closeOnClick:i,highlighted:r,id:n,nodeId:c,store:o,typingRef:a,itemRef:d,itemMetadata:h}),p=v.useCallback(e=>(0,n0.mergeProps)(f,{onMouseEnter(){"submenu-trigger"===h.type&&h.setActive()}},e,u),[f,u,h]),g=(0,nZ.useMergedRefs)(d,_);return v.useMemo(()=>({getItemProps:p,itemRef:g}),[p,g])}var n6=e.i(977);let n4=v.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}}),n8=((f={})[f.None=0]="None",f[f.GuessFromOrder=1]="GuessFromOrder",f);function n7(e={}){let{label:i,metadata:s,textRef:r,indexGuessBehavior:n,index:o}=e,{register:a,unregister:l,subscribeMapChange:h,elementsRef:c,labelsRef:d,nextIndexRef:u}=v.useContext(n4),_=v.useRef(-1),[f,p]=v.useState(o??(n===n8.GuessFromOrder?()=>{if(-1===_.current){let e=u.current;u.current+=1,_.current=e}return _.current}:-1)),g=v.useRef(null),m=v.useCallback(e=>{if(g.current=e,-1!==f&&null!==e&&(c.current[f]=e,d)){let s=void 0!==i;d.current[f]=s?i:r?.current?.textContent??e.textContent}},[f,c,d,i,r]);return(0,n6.useIsoLayoutEffect)(()=>{if(null!=o)return;let e=g.current;if(e)return a(e,s),()=>{l(e)}},[o,a,l,s]),(0,n6.useIsoLayoutEffect)(()=>{if(null==o)return h(e=>{let i=g.current?e.get(g.current)?.index:null;null!=i&&p(i)})},[o,h,p]),v.useMemo(()=>({ref:m,index:f}),[f,m])}var n9=e.i(89879);let oe=((p={}).checked="data-checked",p.unchecked="data-unchecked",p.disabled="data-disabled",p.highlighted="data-highlighted",p),ot={checked:e=>e?{[oe.checked]:""}:{[oe.unchecked]:""},...nU.transitionStatusMapping};var oi=e.i(5963);let os=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,nativeButton:a=!1,disabled:l=!1,closeOnClick:h=!1,checked:c,defaultChecked:d,onCheckedChange:u,..._}=e,f=n7({label:o}),p=nN(!0),g=(0,n9.useBaseUiId)(n),{store:S}=nW(),b=S.useState("isActive",f.index),y=S.useState("itemProps"),[w,C]=(0,nG.useControlled)({controlled:c,default:d??!1,name:"MenuCheckboxItem",state:"checked"}),{getItemProps:x,itemRef:k}=n3({closeOnClick:h,disabled:l,highlighted:b,id:g,store:S,nativeButton:a,nodeId:p?.nodeId,itemMetadata:n5}),E=v.useMemo(()=>({disabled:l,highlighted:b,checked:w}),[l,b,w]),R=(0,nX.useStableCallback)(e=>{let i={...(0,oi.createChangeEventDetails)(nV.REASONS.itemPress,e.nativeEvent),preventUnmountOnClose:()=>{}};u?.(!w,i),i.isCanceled||C(e=>!e)}),M=(0,nF.useRenderElement)("div",e,{state:E,stateAttributesMapping:ot,props:[y,{role:"menuitemcheckbox","aria-checked":w,onClick:R},_,x],ref:[k,i,f.ref]});return(0,m.jsx)(nJ.Provider,{value:E,children:M})});var or=e.i(88841),on=e.i(89269);let oo=v.forwardRef(function(e,i){let{render:s,className:r,keepMounted:n=!1,...o}=e,a=function(){let e=v.useContext(nJ);if(void 0===e)throw Error((0,nI.default)(30));return e}(),l=v.useRef(null),{transitionStatus:h,setMounted:c}=(0,or.useTransitionStatus)(a.checked);(0,on.useOpenChangeComplete)({open:a.checked,ref:l,onComplete(){a.checked||c(!1)}});let d={checked:a.checked,disabled:a.disabled,highlighted:a.highlighted,transitionStatus:h};return(0,nF.useRenderElement)("span",e,{state:d,ref:[i,l],stateAttributesMapping:ot,props:{"aria-hidden":!0,...o},enabled:n||a.checked})}),oa=v.createContext(void 0),ol=v.forwardRef(function(e,i){let{render:s,className:r,...n}=e,[o,a]=v.useState(void 0),l=v.useMemo(()=>({setLabelId:a}),[a]),h=(0,nF.useRenderElement)("div",e,{ref:i,props:{role:"group","aria-labelledby":o,...n}});return(0,m.jsx)(oa.Provider,{value:l,children:h})}),oh=v.forwardRef(function(e,i){let{className:s,render:r,id:n,...o}=e,a=(0,n9.useBaseUiId)(n),{setLabelId:l}=function(){let e=v.useContext(oa);if(void 0===e)throw Error((0,nI.default)(31));return e}();return(0,n6.useIsoLayoutEffect)(()=>(l(a),()=>{l(void 0)}),[l,a]),(0,nF.useRenderElement)("div",e,{ref:i,props:{id:a,role:"presentation",...o}})}),oc=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,nativeButton:a=!1,disabled:l=!1,closeOnClick:h=!0,...c}=e,d=n7({label:o}),u=nN(!0),_=(0,n9.useBaseUiId)(n),{store:f}=nW(),p=f.useState("isActive",d.index),g=f.useState("itemProps"),{getItemProps:m,itemRef:v}=n3({closeOnClick:h,disabled:l,highlighted:p,id:_,store:f,nativeButton:a,nodeId:u?.nodeId,itemMetadata:n5});return(0,nF.useRenderElement)("div",e,{state:{disabled:l,highlighted:p},props:[g,c,m],ref:[v,i,d.ref]})}),od=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,closeOnClick:a=!1,...l}=e,h=v.useRef(null),c=n7({label:o}),d=nN(!0),u=d?.nodeId,_=(0,n9.useBaseUiId)(n),{store:f}=nW(),p=f.useState("isActive",c.index),g=f.useState("itemProps"),m=f.context.typingRef,{getButtonProps:S,buttonRef:b}=(0,nQ.useButton)({native:!1,composite:!0}),y=n2({closeOnClick:a,highlighted:p,id:_,nodeId:u,store:f,typingRef:m,itemRef:h}),w=v.useMemo(()=>({highlighted:p}),[p]);return(0,nF.useRenderElement)("a",e,{state:w,props:[g,l,function(e){return(0,n0.mergeProps)(y,e,S)}],ref:[h,b,i,c.ref]})});var ou=e.i(88306),o_=e.i(61896),of=e.i(60752),op=e.i(92238),og=e.i(18847);let om={...nz.popupStateMapping,...nU.transitionStatusMapping},ov=v.forwardRef(function(e,i){let{render:s,className:r,finalFocus:n,...o}=e,{store:a}=nW(),{side:l,align:h}=nN(),c=null!=(0,of.useToolbarRootContext)(!0),d=a.useState("open"),u=a.useState("transitionStatus"),_=a.useState("popupProps"),f=a.useState("mounted"),p=a.useState("instantType"),g=a.useState("activeTriggerElement"),S=a.useState("parent"),b=a.useState("lastOpenChangeReason"),y=a.useState("rootId"),w=a.useState("floatingRootContext"),C=a.useState("floatingTreeRoot"),x=a.useState("closeDelay"),k=a.useState("activeTriggerElement"),E="context-menu"===S.type;(0,on.useOpenChangeComplete)({open:d,ref:a.context.popupRef,onComplete(){d&&a.context.onOpenChangeComplete?.(!0)}}),v.useEffect(()=>{function e(e){a.setOpen(!1,(0,oi.createChangeEventDetails)(e.reason,e.domEvent))}return C.events.on("close",e),()=>{C.events.off("close",e)}},[C.events,a]);let R=a.useState("hoverEnabled"),M=a.useState("disabled");(0,o_.useHoverFloatingInteraction)(w,{enabled:R&&!M&&!E&&"menubar"!==S.type,closeDelay:x});let D={transitionStatus:u,side:l,align:h,open:d,nested:"menu"===S.type,instant:p},T=v.useCallback(e=>{a.set("popupElement",e)},[a]),B=(0,nF.useRenderElement)("div",e,{state:D,ref:[i,a.context.popupRef,T],stateAttributesMapping:om,props:[_,{onKeyDown(e){c&&op.COMPOSITE_KEYS.has(e.key)&&e.stopPropagation()}},(0,og.getDisabledMountTransitionStyles)(u),o,{"data-rootownerid":y}]}),L=void 0===S.type||E;return(g||"menubar"===S.type&&b!==nV.REASONS.outsidePress)&&(L=!0),(0,m.jsx)(ou.FloatingFocusManager,{context:w,modal:E,disabled:!f,returnFocus:void 0===n?L:n,initialFocus:"menu"!==S.type,restoreFocus:!0,externalTree:"menubar"!==S.type?C:void 0,previousFocusableElement:k,nextFocusableElement:void 0===S.type?a.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:void 0===S.type?a.context.beforeContentFocusGuardRef:void 0,children:B})});var oS=e.i(37692);let ob=v.createContext(void 0),oy=v.forwardRef(function(e,i){let{keepMounted:s=!1,...r}=e,{store:n}=nW();return n.useState("mounted")||s?(0,m.jsx)(ob.Provider,{value:s,children:(0,m.jsx)(oS.FloatingPortal,{ref:i,...r})}):null});var ow=e.i(58130),oC=e.i(66745),ox=e.i(51665),ok=e.i(56590),oE=e.i(30628);function oR(e){let{children:i,elementsRef:s,labelsRef:r,onMapChange:n}=e,o=(0,nX.useStableCallback)(n),a=v.useRef(0),l=(0,oE.useRefWithInit)(oD).current,h=(0,oE.useRefWithInit)(oM).current,[c,d]=v.useState(0),u=v.useRef(c),_=(0,nX.useStableCallback)((e,i)=>{h.set(e,i??null),u.current+=1,d(u.current)}),f=(0,nX.useStableCallback)(e=>{h.delete(e),u.current+=1,d(u.current)}),p=v.useMemo(()=>{let e=new Map;return Array.from(h.keys()).filter(e=>e.isConnected).sort(oT).forEach((i,s)=>{let r=h.get(i)??{};e.set(i,{...r,index:s})}),e},[h,c]);(0,n6.useIsoLayoutEffect)(()=>{if("function"!=typeof MutationObserver||0===p.size)return;let e=new MutationObserver(e=>{let i=new Set,s=e=>i.has(e)?i.delete(e):i.add(e);e.forEach(e=>{e.removedNodes.forEach(s),e.addedNodes.forEach(s)}),0===i.size&&(u.current+=1,d(u.current))});return p.forEach((i,s)=>{s.parentElement&&e.observe(s.parentElement,{childList:!0})}),()=>{e.disconnect()}},[p]),(0,n6.useIsoLayoutEffect)(()=>{u.current===c&&(s.current.length!==p.size&&(s.current.length=p.size),r&&r.current.length!==p.size&&(r.current.length=p.size),a.current=p.size),o(p)},[o,p,s,r,c]),(0,n6.useIsoLayoutEffect)(()=>()=>{s.current=[]},[s]),(0,n6.useIsoLayoutEffect)(()=>()=>{r&&(r.current=[])},[r]);let g=(0,nX.useStableCallback)(e=>(l.add(e),()=>{l.delete(e)}));(0,n6.useIsoLayoutEffect)(()=>{l.forEach(e=>e(p))},[l,p]);let S=v.useMemo(()=>({register:_,unregister:f,subscribeMapChange:g,elementsRef:s,labelsRef:r,nextIndexRef:a}),[_,f,g,s,r,a]);return(0,m.jsx)(n4.Provider,{value:S,children:i})}function oM(){return new Map}function oD(){return new Set}function oT(e,i){let s=e.compareDocumentPosition(i);return s&Node.DOCUMENT_POSITION_FOLLOWING||s&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:s&Node.DOCUMENT_POSITION_PRECEDING||s&Node.DOCUMENT_POSITION_CONTAINS?1:0}var oB=e.i(36893),oL=e.i(7335),oP=e.i(67569),oO=e.i(77817);let oI=v.forwardRef(function(e,i){let{anchor:s,positionMethod:r="absolute",className:n,render:o,side:a,align:l,sideOffset:h=0,alignOffset:c=0,collisionBoundary:d="clipping-ancestors",collisionPadding:u=5,arrowPadding:_=5,sticky:f=!1,disableAnchorTracking:p=!1,collisionAvoidance:g=oL.DROPDOWN_COLLISION_AVOIDANCE,...S}=e,{store:b}=nW(),y=function(){let e=v.useContext(ob);if(void 0===e)throw Error((0,nI.default)(32));return e}(),w=nj(!0),C=b.useState("parent"),x=b.useState("floatingRootContext"),k=b.useState("floatingTreeRoot"),E=b.useState("mounted"),R=b.useState("open"),M=b.useState("modal"),D=b.useState("activeTriggerElement"),T=b.useState("transitionStatus"),B=b.useState("positionerElement"),L=b.useState("instantType"),P=b.useState("hasViewport"),O=b.useState("lastOpenChangeReason"),I=b.useState("floatingNodeId"),A=b.useState("floatingParentNodeId"),N=x.useState("domReferenceElement"),H=v.useRef(null),W=(0,oO.useAnimationsFinished)(B,!1,!1),F=s,z=h,$=c,U=l,K=g;"context-menu"===C.type&&(F=s??C.context?.anchor,U=U??"start",a||"center"===U||($=e.alignOffset??2,z=e.sideOffset??-5));let j=a,V=U;"menu"===C.type?(j=j??"inline-end",V=V??"start",K=e.collisionAvoidance??oL.POPUP_COLLISION_AVOIDANCE):"menubar"===C.type&&(j=j??"bottom",V=V??"start");let q="context-menu"===C.type,Y=(0,ok.useAnchorPositioning)({anchor:F,floatingRootContext:x,positionMethod:w?"fixed":r,mounted:E,side:j,sideOffset:z,align:V,alignOffset:$,arrowPadding:q?0:_,collisionBoundary:d,collisionPadding:u,sticky:f,nodeId:I,keepMounted:y,disableAnchorTracking:p,collisionAvoidance:K,shiftCrossAxis:q&&!("side"in K&&"flip"===K.side),externalTree:k,adaptiveOrigin:P?oP.adaptiveOrigin:void 0}),X=v.useMemo(()=>{let e={};return R||(e.pointerEvents="none"),{role:"presentation",hidden:!E,style:{...Y.positionerStyles,...e}}},[R,E,Y.positionerStyles]);v.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===I&&b.set("hoverEnabled",!1),e.nodeId!==I&&e.parentNodeId===b.select("floatingParentNodeId")&&b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.siblingOpen)))}return k.events.on("menuopenchange",e),()=>{k.events.off("menuopenchange",e)}},[b,k.events,I]),v.useEffect(()=>{if(null!=b.select("floatingParentNodeId"))return k.events.on("menuopenchange",e),()=>{k.events.off("menuopenchange",e)};function e(e){if(e.open||e.nodeId!==b.select("floatingParentNodeId"))return;let i=e.reason??nV.REASONS.siblingOpen;b.setOpen(!1,(0,oi.createChangeEventDetails)(i))}},[k.events,b]);let G=(0,oC.useTimeout)();v.useEffect(()=>{R||G.clear()},[R,G]),v.useEffect(()=>{function e(e){if(R&&e.nodeId===b.select("floatingParentNodeId"))if(e.target&&D&&D!==e.target){let e=b.select("closeDelay");e>0?G.isStarted()||G.start(e,()=>{b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.siblingOpen))}):b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.siblingOpen))}else G.clear()}return k.events.on("itemhover",e),()=>{k.events.off("itemhover",e)}},[k.events,R,D,b,G]),v.useEffect(()=>{let e={open:R,nodeId:I,parentNodeId:A,reason:b.select("lastOpenChangeReason")};k.events.emit("menuopenchange",e)},[k.events,R,b,I,A]),(0,n6.useIsoLayoutEffect)(()=>{let e=H.current;if(N&&(H.current=N),e&&N&&N!==e){b.set("instantType",void 0);let e=new AbortController;return W(()=>{b.set("instantType","trigger-change")},e.signal),()=>{e.abort()}}},[N,W,b]);let J={open:R,side:Y.side,align:Y.align,anchorHidden:Y.anchorHidden,nested:"menu"===C.type,instant:L},Z=v.useMemo(()=>({side:Y.side,align:Y.align,arrowRef:Y.arrowRef,arrowUncentered:Y.arrowUncentered,arrowStyles:Y.arrowStyles,nodeId:Y.context.nodeId}),[Y.side,Y.align,Y.arrowRef,Y.arrowUncentered,Y.arrowStyles,Y.context.nodeId]),Q=(0,nF.useRenderElement)("div",e,{state:J,stateAttributesMapping:nz.popupStateMapping,ref:[i,b.useStateSetter("positionerElement")],props:[X,(0,og.getDisabledMountTransitionStyles)(T),S]}),ee=E&&"menu"!==C.type&&("menubar"!==C.type&&M&&O!==nV.REASONS.triggerHover||"menubar"===C.type&&C.context.modal),et=null;return"menubar"===C.type?et=C.context.contentElement:void 0===C.type&&(et=D),(0,m.jsxs)(nA.Provider,{value:Z,children:[ee&&(0,m.jsx)(oB.InternalBackdrop,{ref:"context-menu"===C.type||"nested-context-menu"===C.type?C.context.internalBackdropRef:null,inert:(0,ow.inertValue)(!R),cutout:et}),(0,m.jsx)(ox.FloatingNode,{id:I,children:(0,m.jsx)(oR,{elementsRef:b.context.itemDomElements,labelsRef:b.context.itemLabels,children:Q})})]})}),oA=v.createContext(void 0),oN=v.memo(v.forwardRef(function(e,i){let{render:s,className:r,value:n,defaultValue:o,onValueChange:a,disabled:l=!1,...h}=e,[c,d]=(0,nG.useControlled)({controlled:n,default:o,name:"MenuRadioGroup"}),u=(0,nX.useStableCallback)(a),_=(0,nX.useStableCallback)((e,i)=>{u?.(e,i),i.isCanceled||d(e)}),f=(0,nF.useRenderElement)("div",e,{state:{disabled:l},ref:i,props:{role:"group","aria-disabled":l||void 0,...h}}),p=v.useMemo(()=>({value:c,setValue:_,disabled:l}),[c,_,l]);return(0,m.jsx)(oA.Provider,{value:p,children:f})})),oH=v.createContext(void 0),oW=v.forwardRef(function(e,i){let{render:s,className:r,id:n,label:o,nativeButton:a=!1,disabled:l=!1,closeOnClick:h=!1,value:c,...d}=e,u=n7({label:o}),_=nN(!0),f=(0,n9.useBaseUiId)(n),{store:p}=nW(),g=p.useState("isActive",u.index),S=p.useState("itemProps"),{value:b,setValue:y,disabled:w}=function(){let e=v.useContext(oA);if(void 0===e)throw Error((0,nI.default)(34));return e}(),C=w||l,x=b===c,{getItemProps:k,itemRef:E}=n3({closeOnClick:h,disabled:C,highlighted:g,id:f,store:p,nativeButton:a,nodeId:_?.nodeId,itemMetadata:n5}),R=v.useMemo(()=>({disabled:C,highlighted:g,checked:x}),[C,g,x]),M=(0,nX.useStableCallback)(e=>{y(c,{...(0,oi.createChangeEventDetails)(nV.REASONS.itemPress,e.nativeEvent),preventUnmountOnClose:()=>{}})}),D=(0,nF.useRenderElement)("div",e,{state:R,stateAttributesMapping:ot,props:[S,{role:"menuitemradio","aria-checked":x,onClick:M},d,k],ref:[E,i,u.ref]});return(0,m.jsx)(oH.Provider,{value:R,children:D})}),oF=v.forwardRef(function(e,i){let{render:s,className:r,keepMounted:n=!1,...o}=e,a=function(){let e=v.useContext(oH);if(void 0===e)throw Error((0,nI.default)(35));return e}(),l=v.useRef(null),{transitionStatus:h,setMounted:c}=(0,or.useTransitionStatus)(a.checked);(0,on.useOpenChangeComplete)({open:a.checked,ref:l,onComplete(){a.checked||c(!1)}});let d={checked:a.checked,disabled:a.disabled,highlighted:a.highlighted,transitionStatus:h};return(0,nF.useRenderElement)("span",e,{state:d,stateAttributesMapping:ot,ref:[i,l],props:{"aria-hidden":!0,...o},enabled:n||a.checked})});var oz=e.i(83799),o$=e.i(58509),oU=e.i(66196),oK=e.i(17514),oj=e.i(3851),oV=e.i(33605),oq=e.i(89633),oY=e.i(29315),oX=e.i(231),oG=e.i(90219),oJ=e.i(47857),oZ=e.i(82033),oQ=e.i(43801),o0=e.i(98442),o1=e.i(494);function o2(e,i,s){switch(e){case"vertical":return i;case"horizontal":return s;default:return i||s}}function o5(e,i){return o2(i,e===o1.ARROW_UP||e===o1.ARROW_DOWN,e===o1.ARROW_LEFT||e===o1.ARROW_RIGHT)}function o3(e,i,s){return o2(i,e===o1.ARROW_DOWN,s?e===o1.ARROW_LEFT:e===o1.ARROW_RIGHT)||"Enter"===e||" "===e||""===e}var o6=e.i(26665),o4=e.i(6157);let o8=v.createContext(null);function o7(e){let i=v.useContext(o8);if(null===i&&!e)throw Error((0,nI.default)(5));return i}var o9=e.i(79144),ae=e.i(50091),at=e.i(83921),ai=e.i(98263),as=e.i(89429),ar=e.i(628),an=e.i(69375);let ao={...ar.popupStoreSelectors,disabled:(0,at.createSelector)(e=>"menubar"===e.parent.type&&e.parent.context.disabled||e.disabled),modal:(0,at.createSelector)(e=>(void 0===e.parent.type||"context-menu"===e.parent.type)&&(e.modal??!0)),allowMouseEnter:(0,at.createSelector)(e=>e.allowMouseEnter),stickIfOpen:(0,at.createSelector)(e=>e.stickIfOpen),parent:(0,at.createSelector)(e=>e.parent),rootId:(0,at.createSelector)(e=>"menu"===e.parent.type?e.parent.store.select("rootId"):void 0!==e.parent.type?e.parent.context.rootId:e.rootId),activeIndex:(0,at.createSelector)(e=>e.activeIndex),isActive:(0,at.createSelector)((e,i)=>e.activeIndex===i),hoverEnabled:(0,at.createSelector)(e=>e.hoverEnabled),instantType:(0,at.createSelector)(e=>e.instantType),lastOpenChangeReason:(0,at.createSelector)(e=>e.openChangeReason),floatingTreeRoot:(0,at.createSelector)(e=>"menu"===e.parent.type?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:(0,at.createSelector)(e=>e.floatingNodeId),floatingParentNodeId:(0,at.createSelector)(e=>e.floatingParentNodeId),itemProps:(0,at.createSelector)(e=>e.itemProps),closeDelay:(0,at.createSelector)(e=>e.closeDelay),hasViewport:(0,at.createSelector)(e=>e.hasViewport),keyboardEventRelay:(0,at.createSelector)(e=>e.keyboardEventRelay?e.keyboardEventRelay:"menu"===e.parent.type?e.parent.store.select("keyboardEventRelay"):void 0)};class aa extends ai.ReactStore{constructor(e){super({...{...(0,ar.createInitialPopupStoreState)(),disabled:!1,modal:!0,allowMouseEnter:!1,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new as.FloatingTreeStore,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:oK.EMPTY_OBJECT,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1},...e},{positionerRef:v.createRef(),popupRef:v.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:v.createRef(),beforeContentFocusGuardRef:v.createRef(),onOpenChangeComplete:void 0,triggerElements:new an.PopupTriggerMap},ao),this.unsubscribeParentListener=this.observe("parent",e=>{if(this.unsubscribeParentListener?.(),"menu"===e.type){let i=e.store.select("rootId"),s=e.store.select("floatingTreeRoot"),r=e.store.select("keyboardEventRelay");this.unsubscribeParentListener=e.store.subscribe(()=>{let n=e.store.select("rootId"),o=e.store.select("floatingTreeRoot"),a=e.store.select("keyboardEventRelay");(i!==n||s!==o||r!==a)&&(i=n,s=o,r=a,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}void 0!==e.type&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,i){this.state.floatingRootContext.context.events.emit("setOpen",{open:e,eventDetails:i})}static useStore(e,i){let s=(0,oE.useRefWithInit)(()=>new aa(i)).current;return e??s}unsubscribeParentListener=null}var al=e.i(58642);let ah=v.createContext(void 0);function ac(){return v.useContext(ah)}let ad=(0,oj.fastComponent)(function(e){let i,s,{children:r,open:n,onOpenChange:o,onOpenChangeComplete:a,defaultOpen:l=!1,disabled:h=!1,modal:c,loopFocus:d=!0,orientation:u="vertical",actionsRef:_,closeParentOnEsc:f=!1,handle:p,triggerId:g,defaultTriggerId:S=null,highlightItemOnHover:b=!0}=e,y=nj(!0),w=nW(!0),C=o7(!0),x=ac(),k=v.useMemo(()=>x&&w?{type:"menu",store:w.store}:C?{type:"menubar",context:C}:y&&!w?{type:"context-menu",context:y}:{type:void 0},[y,w,C,x]),E=aa.useStore(p?.store,{open:l,openProp:n,activeTriggerId:S,triggerIdProp:g,parent:k});(0,o$.useOnFirstRender)(()=>{void 0===n&&!1===E.state.open&&!0===l&&E.update({open:!0,activeTriggerId:S})}),E.useControlledProp("openProp",n),E.useControlledProp("triggerIdProp",g),E.useContextCallback("onOpenChangeComplete",a);let R=E.useState("floatingTreeRoot"),M=(0,ox.useFloatingNodeId)(R),D=(0,ox.useFloatingParentNodeId)();(0,n6.useIsoLayoutEffect)(()=>{y&&!w?E.update({parent:{type:"context-menu",context:y},floatingNodeId:M,floatingParentNodeId:D}):w&&E.update({floatingNodeId:M,floatingParentNodeId:D})},[y,w,M,D,E]);let T=E.useState("open"),B=E.useState("activeTriggerElement"),L=E.useState("positionerElement"),P=E.useState("hoverEnabled"),O=E.useState("modal"),I=E.useState("disabled"),A=E.useState("lastOpenChangeReason"),N=E.useState("parent"),H=E.useState("activeIndex"),W=E.useState("payload"),F=E.useState("floatingParentNodeId"),z=v.useRef(null),$=null!=F;E.useSyncedValues({disabled:h,modal:void 0===N.type?c:void 0,rootId:(0,oz.useId)()});let{openMethod:U,triggerProps:K}=(0,ae.useOpenInteractionType)(T);(0,al.useImplicitActiveTrigger)(E);let{forceUnmount:j}=(0,al.useOpenStateTransitions)(T,E,()=>{E.update({allowMouseEnter:!1,stickIfOpen:!0})}),V=v.useRef("context-menu"!==N.type),q=(0,oC.useTimeout)();v.useEffect(()=>{if(T||(z.current=null),"context-menu"===N.type){if(!T){q.clear(),V.current=!1;return}q.start(500,()=>{V.current=!0})}},[q,T,N.type]),(0,oU.useScrollLock)(T&&O&&A!==nV.REASONS.triggerHover&&"touch"!==U,L),(0,n6.useIsoLayoutEffect)(()=>{T||P||E.set("hoverEnabled",!0)},[T,P,E]);let Y=v.useRef(!0),X=(0,oC.useTimeout)(),G=(0,nX.useStableCallback)((e,s)=>{let r=s.reason;if(T===e&&s.trigger===B&&A===r||(s.preventUnmountOnClose=()=>{E.set("preventUnmountingOnClose",!0)},e||null!=s.trigger||(s.trigger=B??void 0),o?.(e,s),s.isCanceled))return;let n={open:e,nativeEvent:s.event,reason:s.reason,nested:$};i?.emit("openchange",n);let a=s.event;if(!1===e&&a?.type==="click"&&"touch"===a.pointerType&&!Y.current)return;if(!e&&null!==H){let e=E.context.itemDomElements.current[H];queueMicrotask(()=>{e?.setAttribute("tabindex","-1")})}e&&r===nV.REASONS.triggerFocus?(Y.current=!1,X.start(300,()=>{Y.current=!0})):(Y.current=!0,X.clear());let l=(r===nV.REASONS.triggerPress||r===nV.REASONS.itemPress)&&0===a.detail&&a?.isTrusted,h=!e&&(r===nV.REASONS.escapeKey||null==r),c={open:e,openChangeReason:r};z.current=s.event??null;let d=s.trigger?.id??null;(d||e)&&(c.activeTriggerId=d,c.activeTriggerElement=s.trigger??null),E.update(c),"menubar"===N.type&&(r===nV.REASONS.triggerFocus||r===nV.REASONS.focusOut||r===nV.REASONS.triggerHover||r===nV.REASONS.listNavigation||r===nV.REASONS.siblingOpen)?E.set("instantType","group"):l||h?E.set("instantType",l?"click":"dismiss"):E.set("instantType",void 0)}),J=v.useCallback(e=>{let i=(0,oi.createChangeEventDetails)(e);return i.preventUnmountOnClose=()=>{E.set("preventUnmountingOnClose",!0)},i},[E]),Z=v.useCallback(()=>{E.setOpen(!1,J(nV.REASONS.imperativeAction))},[E,J]);v.useImperativeHandle(_,()=>({unmount:j,close:Z}),[j,Z]),"context-menu"===N.type&&(s=N.context),v.useImperativeHandle(s?.positionerRef,()=>L,[L]),v.useImperativeHandle(s?.actionsRef,()=>({setOpen:G}),[G]);let Q=(0,o4.useSyncedFloatingRootContext)({popupStore:E,onOpenChange:G});i=Q.context.events,v.useEffect(()=>{let e=({open:e,eventDetails:i})=>G(e,i);return i.on("setOpen",e),()=>{i?.off("setOpen",e)}},[i,G]);let ee=(0,oV.useDismiss)(Q,{enabled:!I,bubbles:{escapeKey:f&&"menu"===N.type},outsidePress:()=>"context-menu"!==N.type||z.current?.type==="contextmenu"||V.current,externalTree:$?R:void 0}),et=(0,o6.useRole)(Q,{role:"menu"}),ei=(0,o9.useDirection)(),es=v.useCallback(e=>{E.select("activeIndex")!==e&&E.set("activeIndex",e)},[E]),er=function(e,i){let s="rootStore"in e?e.rootStore:e,r=s.useState("open"),n=s.useState("floatingElement"),o=s.useState("domReferenceElement"),a=s.context.dataRef,{listRef:l,activeIndex:h,onNavigate:c=()=>{},enabled:d=!0,selectedIndex:u=null,allowEscape:_=!1,loopFocus:f=!1,nested:p=!1,rtl:g=!1,virtual:m=!1,focusItemOnOpen:S="auto",focusItemOnHover:b=!0,openOnArrowKeyDown:y=!0,disabledIndices:w,orientation:C="vertical",parentOrientation:x,cols:k=1,id:E,resetOnPointerLeave:R=!0,externalTree:M}=i,D=(0,oJ.getFloatingFocusElement)(n),T=(0,oX.useValueAsRef)(D),B=(0,ox.useFloatingParentNodeId)(),L=(0,ox.useFloatingTree)(M);(0,n6.useIsoLayoutEffect)(()=>{a.current.orientation=C},[a,C]);let P=(0,oJ.isTypeableCombobox)(o),O=v.useRef(S),I=v.useRef(u??-1),A=v.useRef(null),N=v.useRef(!0),H=(0,nX.useStableCallback)(e=>{c(-1===I.current?null:I.current,e)}),W=v.useRef(H),F=v.useRef(!!n),z=v.useRef(r),$=v.useRef(!1),U=v.useRef(!1),K=(0,oX.useValueAsRef)(w),j=(0,oX.useValueAsRef)(r),V=(0,oX.useValueAsRef)(u),q=(0,oX.useValueAsRef)(R),Y=(0,nX.useStableCallback)(()=>{function e(e){m?L?.events.emit("virtualfocus",e):(0,o0.enqueueFocus)(e,{sync:$.current,preventScroll:!0})}let i=l.current[I.current],s=U.current;i&&e(i),($.current?e=>e():requestAnimationFrame)(()=>{let r=l.current[I.current]||i;!r||(i||e(r),G&&(s||!N.current)&&r.scrollIntoView?.({block:"nearest",inline:"nearest"}))})});(0,n6.useIsoLayoutEffect)(()=>{d&&(r&&n?(I.current=u??-1,O.current&&null!=u&&(U.current=!0,H())):F.current&&(I.current=-1,W.current()))},[d,r,n,u,H]),(0,n6.useIsoLayoutEffect)(()=>{if(d){if(!r){$.current=!1;return}if(n)if(null==h){if($.current=!1,null!=V.current)return;if(F.current&&(I.current=-1,Y()),(!z.current||!F.current)&&O.current&&(null!=A.current||!0===O.current&&null==A.current)){let e=0,i=()=>{null==l.current[0]?(e<2&&(e?requestAnimationFrame:queueMicrotask)(i),e+=1):(I.current=null==A.current||o3(A.current,C,g)||p?(0,oQ.getMinListIndex)(l):(0,oQ.getMaxListIndex)(l),A.current=null,H())};i()}}else(0,oQ.isIndexOutOfListBounds)(l,h)||(I.current=h,Y(),U.current=!1)}},[d,r,n,h,V,p,l,C,g,H,Y,K]),(0,n6.useIsoLayoutEffect)(()=>{if(!d||n||!L||m||!F.current)return;let e=L.nodesRef.current,i=e.find(e=>e.id===B)?.context?.elements.floating,s=(0,oJ.activeElement)((0,oG.ownerDocument)(n)),r=e.some(e=>e.context&&(0,oJ.contains)(e.context.elements.floating,s));i&&!r&&N.current&&i.focus({preventScroll:!0})},[d,n,L,B,m]),(0,n6.useIsoLayoutEffect)(()=>{W.current=H,z.current=r,F.current=!!n}),(0,n6.useIsoLayoutEffect)(()=>{r||(A.current=null,O.current=S)},[r,S]);let X=null!=h,G=v.useMemo(()=>{function e(e){if(!j.current)return;let i=l.current.indexOf(e.currentTarget);-1!==i&&I.current!==i&&(I.current=i,H(e))}return{onFocus(i){$.current=!0,e(i)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(i){$.current=!0,U.current=!1,b&&e(i)},onPointerLeave(e){if(!j.current||!N.current||"touch"===e.pointerType)return;$.current=!0;let i=e.relatedTarget;if(!(!b||l.current.includes(i))&&q.current&&((0,o0.enqueueFocus)(null,{sync:!0}),I.current=-1,H(e),!m)){let e=T.current,i=(0,oJ.activeElement)((0,oG.ownerDocument)(e));e&&(0,oJ.contains)(e,i)&&e.focus({preventScroll:!0})}}}},[j,T,b,l,H,q,m]),J=v.useCallback(()=>x??L?.nodesRef.current.find(e=>e.id===B)?.context?.dataRef?.current.orientation,[B,L,x]),Z=(0,nX.useStableCallback)(e=>{var i;let n,a;if(N.current=!1,$.current=!0,229===e.which||!j.current&&e.currentTarget===T.current)return;if(p&&(i=e.key,n=g?i===o1.ARROW_RIGHT:i===o1.ARROW_LEFT,a=i===o1.ARROW_UP,"both"===C||"horizontal"===C&&k&&k>1?"Escape"===i:o2(C,n,a))){o5(e.key,J())||(0,oZ.stopEvent)(e),s.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.listNavigation,e.nativeEvent)),(0,oY.isHTMLElement)(o)&&(m?L?.events.emit("virtualfocus",o):o.focus());return}let h=I.current,c=(0,oQ.getMinListIndex)(l,w),d=(0,oQ.getMaxListIndex)(l,w);if(P||("Home"===e.key&&((0,oZ.stopEvent)(e),I.current=c,H(e)),"End"===e.key&&((0,oZ.stopEvent)(e),I.current=d,H(e))),k>1){let i=Array.from({length:l.current.length},()=>({width:1,height:1})),s=(0,oQ.createGridCellMap)(i,k,!1),r=s.findIndex(e=>null!=e&&!(0,oQ.isListIndexDisabled)(l,e,w)),n=s.reduce((e,i,s)=>null==i||(0,oQ.isListIndexDisabled)(l,i,w)?e:s,-1),o=s[(0,oQ.getGridNavigatedIndex)({current:s.map(e=>null!=e?l.current[e]:null)},{event:e,orientation:C,loopFocus:f,rtl:g,cols:k,disabledIndices:(0,oQ.getGridCellIndices)([...("function"!=typeof w?w:null)||l.current.map((e,i)=>(0,oQ.isListIndexDisabled)(l,i,w)?i:void 0),void 0],s),minIndex:r,maxIndex:n,prevIndex:(0,oQ.getGridCellIndexOfCorner)(I.current>d?c:I.current,i,s,k,e.key===o1.ARROW_DOWN?"bl":e.key===(g?o1.ARROW_LEFT:o1.ARROW_RIGHT)?"tr":"tl"),stopEvent:!0})];if(null!=o&&(I.current=o,H(e)),"both"===C)return}if(o5(e.key,C)){if((0,oZ.stopEvent)(e),r&&!m&&(0,oJ.activeElement)(e.currentTarget.ownerDocument)===e.currentTarget){I.current=o3(e.key,C,g)?c:d,H(e);return}o3(e.key,C,g)?f?h>=d?_&&h!==l.current.length?I.current=-1:($.current=!1,I.current=c):I.current=(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,disabledIndices:w}):I.current=Math.min(d,(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,disabledIndices:w})):f?h<=c?_&&-1!==h?I.current=l.current.length:($.current=!1,I.current=d):I.current=(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,decrement:!0,disabledIndices:w}):I.current=Math.max(c,(0,oQ.findNonDisabledListIndex)(l,{startingIndex:h,decrement:!0,disabledIndices:w})),(0,oQ.isIndexOutOfListBounds)(l,I.current)&&(I.current=-1),H(e)}}),Q=v.useMemo(()=>m&&r&&X&&{"aria-activedescendant":`${E}-${h}`},[m,r,X,E,h]),ee=v.useMemo(()=>({"aria-orientation":"both"===C?void 0:C,...!P?Q:{},onKeyDown(e){if("Tab"===e.key&&e.shiftKey&&r&&!m){let i=(0,oJ.getTarget)(e.nativeEvent);if(i&&!(0,oJ.contains)(T.current,i))return;(0,oZ.stopEvent)(e),s.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.focusOut,e.nativeEvent)),(0,oY.isHTMLElement)(o)&&o.focus();return}Z(e)},onPointerMove(){N.current=!0}}),[Q,Z,T,C,P,s,r,m,o]),et=v.useMemo(()=>{function e(e){"auto"===S&&(0,oZ.isVirtualClick)(e.nativeEvent)&&(O.current=!m)}function i(e){O.current=S,"auto"===S&&(0,oZ.isVirtualPointerEvent)(e.nativeEvent)&&(O.current=!0)}return{onKeyDown(e){var i,r;let n=s.select("open");N.current=!1;let o=e.key.startsWith("Arrow"),a=(i=e.key,r=J(),o2(r,g?i===o1.ARROW_LEFT:i===o1.ARROW_RIGHT,i===o1.ARROW_DOWN)),h=o5(e.key,C),c=(p?a:h)||"Enter"===e.key||""===e.key.trim();if(m&&n)return Z(e);if(n||y||!o){if(c){let i=o5(e.key,J());A.current=p&&i?null:e.key}if(p){a&&((0,oZ.stopEvent)(e),n?(I.current=(0,oQ.getMinListIndex)(l,K.current),H(e)):s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.listNavigation,e.nativeEvent,e.currentTarget)));return}h&&(null!=V.current&&(I.current=V.current),(0,oZ.stopEvent)(e),!n&&y?s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.listNavigation,e.nativeEvent,e.currentTarget)):Z(e),n&&H(e))}},onFocus(e){s.select("open")&&!m&&(I.current=-1,H(e))},onPointerDown:i,onPointerEnter:i,onMouseDown:e,onClick:e}},[Z,K,S,l,p,H,s,y,C,J,g,V,m]),ei=v.useMemo(()=>({...Q,...et}),[Q,et]);return v.useMemo(()=>d?{reference:ei,floating:ee,item:G,trigger:et}:{},[d,ei,ee,et,G])}(Q,{enabled:!I,listRef:E.context.itemDomElements,activeIndex:H,nested:void 0!==N.type,loopFocus:d,orientation:u,parentOrientation:"menubar"===N.type?N.context.orientation:void 0,rtl:"rtl"===ei,disabledIndices:oK.EMPTY_ARRAY,onNavigate:es,openOnArrowKeyDown:"context-menu"!==N.type,externalTree:$?R:void 0,focusItemOnHover:b}),en=v.useCallback(e=>{E.context.typingRef.current=e},[E]),eo=function(e,i){let s="rootStore"in e?e.rootStore:e,r=s.context.dataRef,n=s.useState("open"),{listRef:o,elementsRef:a,activeIndex:l,onMatch:h,onTypingChange:c,enabled:d=!0,resetMs:u=750,selectedIndex:_=null}=i,f=(0,oC.useTimeout)(),p=v.useRef(""),g=v.useRef(_??l??-1),m=v.useRef(null);(0,n6.useIsoLayoutEffect)(()=>{(n||null===_)&&(f.clear(),m.current=null,""!==p.current&&(p.current=""))},[n,_,f]),(0,n6.useIsoLayoutEffect)(()=>{n&&""===p.current&&(g.current=_??l??-1)},[n,_,l]);let S=(0,nX.useStableCallback)(e=>{e?r.current.typing||(r.current.typing=e,c?.(e)):r.current.typing&&(r.current.typing=e,c?.(e))}),b=(0,nX.useStableCallback)(e=>{function i(e,s,r=0){if(0===e.length)return -1;let n=(r%e.length+e.length)%e.length,o=s.toLocaleLowerCase();for(let i=0;i<e.length;i+=1){let s=(n+i)%e.length,r=e[s];if(r?.toLocaleLowerCase().startsWith(o)&&function(e){let i=a?.current[e];return!i||(0,oQ.isElementVisible)(i)}(s))return s}return -1}let s=o.current;if(p.current.length>0&&" "===e.key&&((0,oZ.stopEvent)(e),S(!0)),p.current.length>0&&" "!==p.current[0]&&-1===i(s,p.current)&&" "!==e.key&&S(!1),null==s||1!==e.key.length||e.ctrlKey||e.metaKey||e.altKey)return;n&&" "!==e.key&&((0,oZ.stopEvent)(e),S(!0));let r=""===p.current;r&&(g.current=_??l??-1),s.every(e=>!e||e[0]?.toLocaleLowerCase()!==e[1]?.toLocaleLowerCase())&&p.current===e.key&&(p.current="",g.current=m.current),p.current+=e.key,f.start(u,()=>{p.current="",g.current=m.current,S(!1)});let c=r?_??l??-1:g.current,d=i(s,p.current,(c??0)+1);-1!==d?(h?.(d),m.current=d):" "!==e.key&&(p.current="",S(!1))}),y=(0,nX.useStableCallback)(e=>{let i=e.relatedTarget,r=s.select("domReferenceElement"),n=s.select("floatingElement"),o=(0,oJ.contains)(r,i),a=(0,oJ.contains)(n,i);o||a||(f.clear(),p.current="",g.current=m.current,S(!1))}),w=v.useMemo(()=>({onKeyDown:b,onBlur:y}),[b,y]),C=v.useMemo(()=>({onKeyDown:b,onBlur:y}),[b,y]);return v.useMemo(()=>d?{reference:w,floating:C}:{},[d,w,C])}(Q,{listRef:E.context.itemLabels,elementsRef:E.context.itemDomElements,activeIndex:H,resetMs:oL.TYPEAHEAD_RESET_MS,onMatch:e=>{T&&e!==H&&E.set("activeIndex",e)},onTypingChange:en}),{getReferenceProps:ea,getFloatingProps:el,getItemProps:eh,getTriggerProps:ec}=(0,oq.useInteractions)([ee,et,er,eo]),ed=v.useMemo(()=>{let e=(0,n0.mergeProps)(ea(),{onMouseMove(){E.set("allowMouseEnter",!0)}},K);return delete e.role,e},[ea,E,K]),eu=v.useMemo(()=>{let e=ec();if(!e)return e;let i=(0,n0.mergeProps)(e,K);return delete i.role,delete i["aria-controls"],i},[ec,K]),e_=v.useMemo(()=>el({onMouseMove(){E.set("allowMouseEnter",!0),"menu"===N.type&&E.set("hoverEnabled",!1)},onClick(){E.select("hoverEnabled")&&E.set("hoverEnabled",!1)},onKeyDown(e){let i=E.select("keyboardEventRelay");i&&!e.isPropagationStopped()&&i(e)}}),[el,N.type,E]),ef=v.useMemo(()=>eh(),[eh]);E.useSyncedValues({floatingRootContext:Q,activeTriggerProps:ed,inactiveTriggerProps:eu,popupProps:e_,itemProps:ef});let ep=v.useMemo(()=>({store:E,parent:k}),[E,k]),eg=(0,m.jsx)(nH.Provider,{value:ep,children:"function"==typeof r?r({payload:W}):r});return void 0===N.type||"context-menu"===N.type?(0,m.jsx)(ox.FloatingTree,{externalTree:R,children:eg}):eg});var au=e.i(74080),a_=e.i(37287),af=e.i(4012),ap=e.i(32652);let ag=n1.isMac&&n1.isSafari;var am=e.i(97254),av=e.i(59266),aS=e.i(54694);function ab(e){let{render:i,className:s,state:r=oK.EMPTY_OBJECT,props:n=oK.EMPTY_ARRAY,refs:o=oK.EMPTY_ARRAY,metadata:a,stateAttributesMapping:l,tag:h="div",...c}=e,{compositeProps:d,compositeRef:u}=function(e={}){let{highlightItemOnHover:i,highlightedIndex:s,onHighlightedIndexChange:r}=(0,aS.useCompositeRootContext)(),{ref:n,index:o}=n7(e),a=s===o,l=v.useRef(null),h=(0,nZ.useMergedRefs)(n,l);return{compositeProps:v.useMemo(()=>({tabIndex:a?0:-1,onFocus(){r(o)},onMouseMove(){let e=l.current;if(!i||!e)return;let s=e.hasAttribute("disabled")||"true"===e.ariaDisabled;a||s||e.focus()}}),[a,r,o,i]),compositeRef:h,index:o}}({metadata:a});return(0,nF.useRenderElement)(h,e,{state:r,ref:[...o,u],props:[d,...n,c],stateAttributesMapping:l})}var ay=e.i(72408);let aw=(0,oj.fastComponentRef)(function(e,i){let s,r,n,{render:o,className:a,disabled:l=!1,nativeButton:h=!0,id:c,openOnHover:d,delay:u=100,closeDelay:_=0,handle:f,payload:p,...g}=e,S=nW(!0),b=f?.store??S?.store;if(!b)throw Error((0,nI.default)(85));let y=(0,n9.useBaseUiId)(c),w=b.useState("isTriggerActive",y),C=b.useState("floatingRootContext"),x=b.useState("isOpenedByTrigger",y),k=v.useRef(null),E=(s=nj(!0),r=nW(!0),n=o7(!0),v.useMemo(()=>n?{type:"menubar",context:n}:s&&!r?{type:"context-menu",context:s}:{type:void 0},[s,r,n])),R=(0,aS.useCompositeRootContext)(!0),M=(0,ox.useFloatingTree)(),D=v.useMemo(()=>M??new as.FloatingTreeStore,[M]),T=(0,ox.useFloatingNodeId)(D),B=(0,ox.useFloatingParentNodeId)(),{registerTrigger:L,isMountedByThisTrigger:P}=(0,al.useTriggerDataForwarding)(y,k,b,{payload:p,closeDelay:_,parent:E,floatingTreeRoot:D,floatingNodeId:T,floatingParentNodeId:B,keyboardEventRelay:R?.relayKeyboardEvent}),O="menubar"===E.type,I=b.useState("disabled"),A=l||I||O&&E.context.disabled,{getButtonProps:N,buttonRef:H}=(0,nQ.useButton)({disabled:A,native:h});v.useEffect(()=>{x||void 0!==E.type||(b.context.allowMouseUpTriggerRef.current=!1)},[b,x,E.type]);let W=v.useRef(null),F=(0,oC.useTimeout)(),z=(0,nX.useStableCallback)(e=>{if(!W.current)return;F.clear(),b.context.allowMouseUpTriggerRef.current=!1;let i=e.target;if((0,oJ.contains)(W.current,i)||(0,oJ.contains)(b.select("positionerElement"),i)||i===W.current||null!=i&&function e(i){return(0,oY.isHTMLElement)(i)&&i.hasAttribute("data-rootownerid")?i.getAttribute("data-rootownerid")??void 0:(0,oY.isLastTraversableNode)(i)?void 0:e((0,oY.getParentNode)(i))}(i)===b.select("rootId"))return;let s=function(e){let i=e.getBoundingClientRect(),s=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if("none"===s.content&&"none"===r.content)return i;let n=parseFloat(s.width)||0,o=parseFloat(s.height)||0,a=parseFloat(r.width)||0,l=parseFloat(r.height)||0,h=Math.max(i.width,n,a),c=Math.max(i.height,o,l),d=h-i.width,u=c-i.height;return{left:i.left-d/2,right:i.right+d/2,top:i.top-u/2,bottom:i.bottom+u/2}}(W.current);e.clientX>=s.left-2&&e.clientX<=s.right+2&&e.clientY>=s.top-2&&e.clientY<=s.bottom+2||D.events.emit("close",{domEvent:e,reason:nV.REASONS.cancelOpen})});v.useEffect(()=>{x&&b.select("lastOpenChangeReason")===nV.REASONS.triggerHover&&(0,oG.ownerDocument)(W.current).addEventListener("mouseup",z,{once:!0})},[x,z,b]);let $=O&&E.context.hasSubmenuOpen,U=d??$,K=(0,am.useHoverReferenceInteraction)(C,{enabled:U&&!A&&"context-menu"!==E.type&&(!O||$&&!P),handleClose:(0,a_.safePolygon)({blockPointerEvents:!O}),mouseOnly:!0,move:!1,restMs:void 0===E.type?u:void 0,delay:{close:_},triggerElementRef:k,externalTree:D,isActiveTrigger:w}),j=function(e,i){let s=(0,oC.useTimeout)(),[r,n]=v.useState(!1);return(0,n6.useIsoLayoutEffect)(()=>{e&&"trigger-hover"===i?(n(!0),s.start(oL.PATIENT_CLICK_THRESHOLD,()=>{n(!1)})):e||(s.clear(),n(!1))},[e,i,s]),r}(x,b.select("lastOpenChangeReason")),V=(0,af.useClick)(C,{enabled:!A&&"context-menu"!==E.type,event:x&&O?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:void 0===E.type&&j}),q=function(e,i={}){let s="rootStore"in e?e.rootStore:e,{events:r,dataRef:n}=s.context,{enabled:o=!0,delay:a}=i,l=v.useRef(!1),h=v.useRef(null),c=(0,oC.useTimeout)(),d=v.useRef(!0);v.useEffect(()=>{let e=s.select("domReferenceElement");if(!o)return;let i=(0,oY.getWindow)(e);function r(){let e=s.select("domReferenceElement");!s.select("open")&&(0,oY.isHTMLElement)(e)&&e===(0,oJ.activeElement)((0,oG.ownerDocument)(e))&&(l.current=!0)}function n(){d.current=!0}function a(){d.current=!1}return i.addEventListener("blur",r),ag&&(i.addEventListener("keydown",n,!0),i.addEventListener("pointerdown",a,!0)),()=>{i.removeEventListener("blur",r),ag&&(i.removeEventListener("keydown",n,!0),i.removeEventListener("pointerdown",a,!0))}},[s,o]),v.useEffect(()=>{if(o)return r.on("openchange",e),()=>{r.off("openchange",e)};function e(e){if(e.reason===nV.REASONS.triggerPress||e.reason===nV.REASONS.escapeKey){let e=s.select("domReferenceElement");(0,oY.isElement)(e)&&(h.current=e,l.current=!0)}}},[r,o,s]);let u=v.useMemo(()=>({onMouseLeave(){l.current=!1,h.current=null},onFocus(e){let i=e.currentTarget;if(l.current){if(h.current===i)return;l.current=!1,h.current=null}let r=(0,oJ.getTarget)(e.nativeEvent);if((0,oY.isElement)(r)){if(ag&&!e.relatedTarget){if(!d.current&&!(0,oJ.isTypeableElement)(r))return}else if(!(0,oJ.matchesFocusVisible)(r))return}let n=(0,oJ.isTargetInsideEnabledTrigger)(e.relatedTarget,s.context.triggerElements),{nativeEvent:o,currentTarget:u}=e,_="function"==typeof a?a():a;s.select("open")&&n||0===_||void 0===_?s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.triggerFocus,o,u)):c.start(_,()=>{l.current||s.setOpen(!0,(0,oi.createChangeEventDetails)(nV.REASONS.triggerFocus,o,u))})},onBlur(e){l.current=!1,h.current=null;let i=e.relatedTarget,r=e.nativeEvent,o=(0,oY.isElement)(i)&&i.hasAttribute((0,ap.createAttribute)("focus-guard"))&&"outside"===i.getAttribute("data-type");c.start(0,()=>{let e=s.select("domReferenceElement"),a=(0,oJ.activeElement)(e?e.ownerDocument:document);if(!i&&a===e||(0,oJ.contains)(n.current.floatingContext?.refs.floating.current,a)||(0,oJ.contains)(e,a)||o)return;let l=i??a;(0,oJ.isTargetInsideEnabledTrigger)(l,s.context.triggerElements)||s.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.triggerFocus,r))})}}),[n,s,c,a]);return v.useMemo(()=>o?{reference:u,trigger:u}:{},[o,u])}(C,{enabled:!A&&$}),Y=function(e){let{enabled:i=!0,mouseDownAction:s,open:r}=e,n=v.useRef(!1);return v.useMemo(()=>i?{onMouseDown:e=>{("open"===s&&!r||"close"===s&&r)&&(n.current=!0,(0,oG.ownerDocument)(e.currentTarget).addEventListener("click",()=>{n.current=!1},{once:!0}))},onClick:e=>{n.current&&(n.current=!1,e.preventBaseUIHandler())}}:oK.EMPTY_OBJECT,[i,s,r])}({open:x,enabled:O,mouseDownAction:"open"}),X=(0,oq.useInteractions)([V,q]),G={disabled:A,open:x},J=b.useState("triggerProps",P),Z=[W,i,H,L,k],Q=[X.getReferenceProps(),K??oK.EMPTY_OBJECT,J,{"aria-haspopup":"menu",id:y,onMouseDown:e=>{b.select("open")||(F.start(200,()=>{b.context.allowMouseUpTriggerRef.current=!0}),(0,oG.ownerDocument)(e.currentTarget).addEventListener("mouseup",z,{once:!0}))}},O?{role:"menuitem"}:{},Y,g,N],ee=v.useRef(null),et=(0,nX.useStableCallback)(e=>{au.flushSync(()=>{b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.focusOut,e.nativeEvent,e.currentTarget))});let i=(0,av.getTabbableBeforeElement)(ee.current);i?.focus()}),ei=(0,nX.useStableCallback)(e=>{let i=b.select("positionerElement");if(i&&(0,av.isOutsideEvent)(e,i))b.context.beforeContentFocusGuardRef.current?.focus();else{au.flushSync(()=>{b.setOpen(!1,(0,oi.createChangeEventDetails)(nV.REASONS.focusOut,e.nativeEvent,e.currentTarget))});let s=(0,av.getTabbableAfterElement)(b.context.triggerFocusTargetRef.current||k.current);for(;null!==s&&(0,oJ.contains)(i,s);){let e=s;if((s=(0,av.getNextTabbable)(s))===e)break}s?.focus()}}),es=(0,nF.useRenderElement)("button",e,{enabled:!O,stateAttributesMapping:nz.pressableTriggerOpenStateMapping,state:G,ref:Z,props:Q});return O?(0,m.jsx)(ab,{tag:"button",render:o,className:a,state:G,refs:Z,props:Q,stateAttributesMapping:nz.pressableTriggerOpenStateMapping}):x?(0,m.jsxs)(v.Fragment,{children:[(0,m.jsx)(ay.FocusGuard,{ref:ee,onFocus:et},`${y}-pre-focus-guard`),(0,m.jsx)(v.Fragment,{children:es},y),(0,m.jsx)(ay.FocusGuard,{ref:b.context.triggerFocusTargetRef,onFocus:ei},`${y}-post-focus-guard`)]}):(0,m.jsx)(v.Fragment,{children:es},y)});var aC=e.i(12666);let ax=((g={}).popupWidth="--popup-width",g.popupHeight="--popup-height",g),ak={activationDirection:e=>e?{"data-activation-direction":e}:null},aE=v.forwardRef(function(e,i){let{render:s,className:r,children:n,...o}=e,{store:a}=nW(),{side:l}=nN(),h=a.useState("instantType"),{children:c,state:d}=(0,aC.usePopupViewport)({store:a,side:l,cssVars:ax,children:n}),u={activationDirection:d.activationDirection,transitioning:d.transitioning,instant:h};return(0,nF.useRenderElement)("div",e,{state:u,ref:i,props:[o,{children:c}],stateAttributesMapping:ak})}),aR=v.forwardRef(function(e,i){let{className:s,render:r,orientation:n="horizontal",...o}=e;return(0,nF.useRenderElement)("div",e,{state:{orientation:n},ref:i,props:[{role:"separator","aria-orientation":n},o]})}),aM=v.forwardRef(function(e,i){let{render:s,className:r,label:n,id:o,nativeButton:a=!1,openOnHover:l=!0,delay:h=100,closeDelay:c=0,disabled:d=!1,...u}=e,_=n7(),f=nN(),{store:p}=nW(),g=(0,n9.useBaseUiId)(o),m=p.useState("open"),S=p.useState("floatingRootContext"),b=p.useState("floatingTreeRoot"),y=(0,al.useTriggerRegistration)(g,p),w=v.useCallback(e=>{let i=y(e);return null!==e&&p.select("open")&&null==p.select("activeTriggerId")&&p.update({activeTriggerId:g,activeTriggerElement:e,closeDelay:c}),i},[y,c,p,g]),C=v.useRef(null),x=v.useCallback(e=>{C.current=e,p.set("activeTriggerElement",e)},[p]),k=ac();if(!k?.parentMenu)throw Error((0,nI.default)(37));p.useSyncedValue("closeDelay",c);let E=k.parentMenu,R=E.useState("itemProps"),M=E.useState("isActive",_.index),D=v.useMemo(()=>({type:"submenu-trigger",setActive(){E.set("activeIndex",_.index)}}),[E,_.index]),T=p.useState("disabled"),B=d||T,{getItemProps:L,itemRef:P}=n3({closeOnClick:!1,disabled:B,highlighted:M,id:g,store:p,typingRef:E.context.typingRef,nativeButton:a,itemMetadata:D,nodeId:f?.nodeId}),O=p.useState("hoverEnabled"),I=E.useState("allowMouseEnter"),A=(0,am.useHoverReferenceInteraction)(S,{enabled:O&&l&&!B,handleClose:(0,a_.safePolygon)({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:h,delay:I?{open:h,close:c}:0,triggerElementRef:C,externalTree:b}),N=(0,af.useClick)(S,{enabled:!B,event:"mousedown",toggle:!l,ignoreMouse:l,stickIfOpen:!1}),H=(0,oq.useInteractions)([N]),W=p.useState("triggerProps",!0);return delete W.id,(0,nF.useRenderElement)("div",e,{state:{disabled:B,highlighted:M,open:m},stateAttributesMapping:nz.triggerOpenStateMapping,props:[H.getReferenceProps(),A,W,R,{tabIndex:m||M?0:-1,onBlur(){M&&E.set("activeIndex",null)}},u,L],ref:[i,_.ref,P,w,x]})});class aD{constructor(){this.store=new aa}open(e){let i=e?this.store.context.triggerElements.getById(e):void 0;if(e&&!i)throw Error((0,nI.default)(83,e));this.store.setOpen(!0,(0,oi.createChangeEventDetails)("imperative-action",void 0,i))}close(){this.store.setOpen(!1,(0,oi.createChangeEventDetails)("imperative-action",void 0,void 0))}get isOpen(){return this.store.state.open}}e.s(["Arrow",0,n$,"Backdrop",0,nY,"CheckboxItem",0,os,"CheckboxItemIndicator",0,oo,"Group",0,ol,"GroupLabel",0,oh,"Handle",0,aD,"Item",0,oc,"LinkItem",0,od,"Popup",0,ov,"Portal",0,oy,"Positioner",0,oI,"RadioGroup",0,oN,"RadioItem",0,oW,"RadioItemIndicator",0,oF,"Root",0,ad,"Separator",0,aR,"SubmenuRoot",0,function(e){let i=nW().store,s=v.useMemo(()=>({parentMenu:i}),[i]);return(0,m.jsx)(ah.Provider,{value:s,children:(0,m.jsx)(ad,{...e})})},"SubmenuTrigger",0,aM,"Trigger",0,aw,"Viewport",0,aE,"createHandle",0,function(){return new aD}],30250);var aT=e.i(30250),aT=aT,aB=e.i(52088);function aL({...e}){return(0,m.jsx)(aT.Root,{"data-slot":"dropdown-menu",...e})}function aP({...e}){return(0,m.jsx)(aT.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function aO({align:e="start",alignOffset:i=0,side:s="bottom",sideOffset:r=4,className:n,...o}){return(0,m.jsx)(aT.Portal,{children:(0,m.jsx)(aT.Positioner,{className:"isolate z-50 outline-none",align:e,alignOffset:i,side:s,sideOffset:r,children:(0,m.jsx)(aT.Popup,{"data-slot":"dropdown-menu-content",className:(0,aB.cn)("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",n),...o})})})}function aI({className:e,inset:i,variant:s="default",...r}){return(0,m.jsx)(aT.Item,{"data-slot":"dropdown-menu-item","data-inset":i,"data-variant":s,className:(0,aB.cn)("group/dropdown-menu-item relative flex min-h-7 cursor-default items-center gap-2 rounded-md px-2 py-1 text-xs/relaxed outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7.5 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5 data-[variant=destructive]:*:[svg]:text-destructive",e),...r})}function aA({className:e,...i}){return(0,m.jsx)(aT.Separator,{"data-slot":"dropdown-menu-separator",className:(0,aB.cn)("-mx-1 my-1 h-px bg-border/50",e),...i})}e.i(46349),e.i(78784),e.s(["default",0,function({params:e}){let{id:i}=(0,v.use)(e),s=(0,S.useRouter)(),r=(0,T.useToast)(),[n,o]=(0,v.useState)(null),[a,l]=(0,v.useState)([]),[h,c]=(0,v.useState)(),[d,u]=(0,v.useState)(!0),[_,f]=(0,v.useState)(!1),[p,g]=(0,v.useState)(!1),[y,P]=(0,v.useState)(!0),O=(0,v.useRef)(null);(0,B.useDocumentTitle)(n?.title),(0,L.useTaskEvents)({onTaskCreated:()=>{},onTaskUpdated:e=>{e.id===i&&o(e)},onTaskDeleted:e=>{e===i&&(r.info("Task deleted",n?.title??void 0),s.push("/"))}});let I=(0,v.useCallback)(()=>{fetch((0,R.apiUrl)(`/api/tasks/${i}/read`),{method:"POST"}).catch(()=>{})},[i]),A=(0,v.useCallback)((e,i)=>{("success"===i||"failure"===i||"error"===i)&&I()},[I]),N=(0,v.useRef)(null),H=(0,v.useCallback)(async()=>{if(null!==N.current&&N.current!==i&&P(!0),N.current=i,y){u(!0);try{let e=await fetch((0,R.apiUrl)(`/api/tasks/${i}`));if(!e.ok)throw Error("Failed to fetch task");let s=(await e.json()).data.task,r=s.tabs||[];if(0===r.length){let e=await fetch((0,R.apiUrl)(`/api/tasks/${i}/tabs`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});e.ok&&(r=[(await e.json()).data.tab])}o(s),l(r),r.length>0&&c(r[0].tab_id),I()}catch(e){console.error("Failed to load data:",e)}finally{u(!1),P(!1)}}},[i,y,I]);(0,v.useEffect)(()=>{H()},[i,H]);let W=async(e,i)=>{let s=r.loading("Updating task...");try{let n=await fetch((0,R.apiUrl)(`/api/tasks/${e}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(!n.ok)throw Error("Failed to update task");let a=await n.json();return o(a.data.task),r.success(s,"Successfully updated task"),{success:!0}}catch(i){console.error("Failed to update task:",i);let e=i instanceof Error?i.message:"Failed to update task";return r.error(s,"Failed to update task",e),{success:!1,errors:[{field:"global",message:"Failed to update task"}]}}},F=async(e="claude")=>{try{let s=await fetch((0,R.apiUrl)(`/api/tasks/${i}/tabs`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:e})});if(!s.ok)throw Error("Failed to create tab");let r=(await s.json()).data.tab;return l(e=>e.some(e=>e.tab_id===r.tab_id)?e:[...e,r]),c(r.tab_id),r.tab_id}catch(e){console.error("Failed to create tab:",e);return}},z=async e=>{try{if(!(await fetch((0,R.apiUrl)(`/api/tasks/${i}/tabs/${e}`),{method:"DELETE"})).ok)throw Error("Failed to delete tab");if(l(i=>i.filter(i=>i.tab_id!==e)),h===e){let i=a.filter(i=>i.tab_id!==e);c(i[0]?.tab_id)}}catch(e){console.error("Failed to delete tab:",e)}},K=async()=>{if(!n)return;let e=r.loading("Opening terminal...",n.worktreePath);try{if(!(await fetch((0,R.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"terminal",owner:n.owner,repo:n.repo,branch:n.branch})})).ok)throw Error("Command execution failed");r.success(e,"Successfully opened terminal",n.worktreePath)}catch(s){let i=s instanceof Error?s.message:"Unknown error";r.error(e,"Failed to open terminal",i)}},j=async()=>{if(!n)return;let e=r.loading("Opening VS Code...",n.worktreePath);try{if(!(await fetch((0,R.apiUrl)("/api/commands/open"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({commandType:"vscode",owner:n.owner,repo:n.repo,branch:n.branch})})).ok)throw Error("Command execution failed");r.success(e,"Successfully opened VS Code",n.worktreePath)}catch(s){let i=s instanceof Error?s.message:"Unknown error";r.error(e,"Failed to open VS Code",i)}};return d&&!n?(0,m.jsx)("div",{className:"h-screen flex items-center justify-center bg-background",children:(0,m.jsx)(D.LoadingSpinner,{size:"lg",message:"Loading task..."})}):n?(0,m.jsxs)("div",{className:"h-screen flex flex-col bg-background",children:[(0,m.jsx)("div",{className:"sticky top-0 z-50 p-4 border-b border-border bg-card",children:(0,m.jsxs)("div",{className:"flex items-center justify-between",children:[(0,m.jsxs)(U.Button,{variant:"ghost",onClick:()=>s.push("/"),className:"text-primary font-medium hover:bg-primary/10 hover:text-foreground",children:[(0,m.jsx)(b.ArrowLeft,{className:"w-4 h-4"}),"Back to Board"]}),(0,m.jsx)("h1",{className:"text-base font-semibold text-foreground absolute left-1/2 -translate-x-1/2 max-w-[50vw] truncate",children:n.title}),(0,m.jsxs)(aL,{children:[(0,m.jsx)(aP,{render:(0,m.jsx)(U.Button,{variant:"ghost",size:"icon-lg",className:"text-primary hover:bg-primary/10 hover:text-foreground",title:"Task menu"}),children:(0,m.jsx)(C,{className:"w-5 h-5"})}),(0,m.jsxs)(aO,{align:"end",children:[(0,m.jsxs)(aI,{onClick:()=>f(!0),children:[(0,m.jsx)(x.Pencil,{className:"w-4 h-4"}),"Detail / Edit"]}),(0,m.jsx)(aA,{}),(0,m.jsxs)(aI,{onClick:K,children:[(0,m.jsx)(k,{className:"w-4 h-4"}),"Open Terminal"]}),(0,m.jsxs)(aI,{onClick:j,children:[(0,m.jsx)(w,{className:"w-4 h-4"}),"Open VS Code"]}),(0,m.jsx)(aA,{}),(0,m.jsxs)(aI,{className:"text-destructive focus:text-destructive",onClick:()=>g(!0),children:[(0,m.jsx)(E.Trash2,{className:"w-4 h-4"}),"Delete"]})]})]})]})}),(0,m.jsx)("div",{className:"flex-1 flex flex-col min-h-0",children:(0,m.jsx)("div",{className:"bg-card flex flex-col flex-1 min-h-0",children:(0,m.jsx)(nO,{ref:O,task:n,tabs:a,activeTabId:h,onTabChange:c,onTabCreate:F,onTabDelete:z,onClaudeStatusChange:A})})}),(0,m.jsx)(M.TaskDialog,{mode:"edit",isOpen:_,onClose:()=>f(!1),task:n,onUpdate:W}),(0,m.jsx)($.ConfirmDialog,{open:p,onOpenChange:e=>g(e.open),title:"Delete Task",message:`Delete task "${n.title}"?
23
23
 
24
24
  This will also delete the worktree and branch.`,confirmLabel:"Delete",cancelLabel:"Cancel",onConfirm:()=>{if(!n)return;let e=r.loading("Deleting task...",n.title);fetch((0,R.apiUrl)(`/api/tasks/${n.id}`),{method:"DELETE"}).then(()=>{r.success(e,"Successfully deleted task",n.title)}).catch(i=>{let s=i instanceof Error?i.message:"Unknown error";r.error(e,"Failed to delete task",s)}),s.push("/")},variant:"danger"})]}):(0,m.jsx)("div",{className:"h-screen flex items-center justify-center bg-background",children:(0,m.jsx)("div",{className:"text-center text-foreground",children:"Task not found"})})}],97099)}]);